From b836f8fdf779389a7cf4bb29fa63cbd23cfad8aa Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 6 Aug 2018 14:28:59 -0500 Subject: [PATCH] fix: remove babel-plugin-flow-react-proptypes --- .babelrc | 4 - index.js | 235 -------------------------------------------------- index.js.flow | 202 ------------------------------------------- package.json | 1 - yarn.lock | 17 +--- 5 files changed, 4 insertions(+), 455 deletions(-) delete mode 100644 index.js delete mode 100644 index.js.flow diff --git a/.babelrc b/.babelrc index 16f9b8d..98fca73 100644 --- a/.babelrc +++ b/.babelrc @@ -8,7 +8,6 @@ "transform-class-properties", "transform-export-extensions", "transform-object-rest-spread", - "flow-react-proptypes" ], "env": { "test": { @@ -21,7 +20,6 @@ "transform-class-properties", "transform-export-extensions", "transform-object-rest-spread", - "flow-react-proptypes", "transform-runtime" ] }, @@ -35,7 +33,6 @@ "transform-class-properties", "transform-export-extensions", "transform-object-rest-spread", - "flow-react-proptypes", "transform-runtime", "istanbul" ] @@ -55,7 +52,6 @@ "transform-class-properties", "transform-export-extensions", "transform-object-rest-spread", - "flow-react-proptypes", "transform-react-constant-elements" ] } diff --git a/index.js b/index.js deleted file mode 100644 index 318d863..0000000 --- a/index.js +++ /dev/null @@ -1,235 +0,0 @@ -'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.bindMenu = undefined; - -var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of'); - -var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf); - -var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); - -var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); - -var _createClass2 = require('babel-runtime/helpers/createClass'); - -var _createClass3 = _interopRequireDefault(_createClass2); - -var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn'); - -var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); - -var _inherits2 = require('babel-runtime/helpers/inherits'); - -var _inherits3 = _interopRequireDefault(_inherits2); - -exports.bindTrigger = bindTrigger; -exports.bindToggle = bindToggle; -exports.bindHover = bindHover; -exports.bindPopover = bindPopover; -exports.bindPopper = bindPopper; - -var _react = require('react'); - -var React = _interopRequireWildcard(_react); - -var _propTypes = require('prop-types'); - -var _propTypes2 = _interopRequireDefault(_propTypes); - -function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * Creates props for a component that opens the popup when clicked. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -function bindTrigger(_ref) { - var isOpen = _ref.isOpen, - open = _ref.open, - popupId = _ref.popupId; - - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onClick: open - }; -} - -/** - * Creates props for a component that toggles the popup when clicked. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -function bindToggle(_ref2) { - var isOpen = _ref2.isOpen, - toggle = _ref2.toggle, - popupId = _ref2.popupId; - - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onClick: toggle - }; -} - -/** - * Creates props for a component that opens the popup while hovered. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -function bindHover(_ref3) { - var isOpen = _ref3.isOpen, - open = _ref3.open, - close = _ref3.close, - popupId = _ref3.popupId; - - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onMouseEnter: open, - onMouseLeave: close - }; -} - -/** - * Creates props for a `Popover` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -function bindPopover(_ref4) { - var isOpen = _ref4.isOpen, - anchorEl = _ref4.anchorEl, - close = _ref4.close, - popupId = _ref4.popupId; - - return { - id: popupId, - anchorEl: anchorEl, - open: isOpen, - onClose: close - }; -} - -/** - * Creates props for a `Menu` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -var bindMenu = exports.bindMenu = bindPopover; - -/** - * Creates props for a `Popper` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -function bindPopper(_ref5) { - var isOpen = _ref5.isOpen, - anchorEl = _ref5.anchorEl, - popupId = _ref5.popupId; - - return { - id: popupId, - anchorEl: anchorEl, - open: isOpen - }; -} - -var eventOrAnchorElWarned = false; - -var PopupState = function (_React$Component) { - (0, _inherits3.default)(PopupState, _React$Component); - - function PopupState() { - var _ref6; - - var _temp, _this, _ret; - - (0, _classCallCheck3.default)(this, PopupState); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = (0, _possibleConstructorReturn3.default)(this, (_ref6 = PopupState.__proto__ || (0, _getPrototypeOf2.default)(PopupState)).call.apply(_ref6, [this].concat(args))), _this), _this.state = { anchorEl: null }, _this.handleToggle = function (eventOrAnchorEl) { - if (_this.state.anchorEl) _this.handleClose();else _this.handleOpen(eventOrAnchorEl); - }, _this.handleOpen = function (eventOrAnchorEl) { - if (!eventOrAnchorElWarned && !eventOrAnchorEl && !eventOrAnchorEl.target) { - eventOrAnchorElWarned = true; - console.error('eventOrAnchorEl should be defined'); // eslint-disable-line no-console - } - _this.setState({ - anchorEl: eventOrAnchorEl && eventOrAnchorEl.target ? eventOrAnchorEl.target : eventOrAnchorEl - }); - }, _this.handleClose = function () { - return _this.setState({ anchorEl: null }); - }, _this.handleSetOpen = function (open, eventOrAnchorEl) { - if (open) _this.handleOpen(eventOrAnchorEl);else _this.handleClose(); - }, _temp), (0, _possibleConstructorReturn3.default)(_this, _ret); - } - - (0, _createClass3.default)(PopupState, [{ - key: 'render', - value: function render() { - var _props = this.props, - children = _props.children, - popupId = _props.popupId; - var anchorEl = this.state.anchorEl; - - - var isOpen = Boolean(anchorEl); - - return children({ - open: this.handleOpen, - close: this.handleClose, - toggle: this.handleToggle, - setOpen: this.handleSetOpen, - isOpen: isOpen, - anchorEl: anchorEl, - popupId: popupId - }); - } - }]); - return PopupState; -}(React.Component); - -PopupState.propTypes = { - /** - * The render function. - * - * @param {object} props the properties injected by `PopupState`: - * - * - * @returns {React.Node} the content to display - */ - children: _propTypes2.default.func.isRequired, - /** - * The `id` property to use for the popup. Will be passed to the render - * function as `bindPopup.id`, and also used for the `aria-owns` property - * passed to the trigger component via `bindTrigger`. - */ - popupId: _propTypes2.default.string -}; -exports.default = PopupState; \ No newline at end of file diff --git a/index.js.flow b/index.js.flow deleted file mode 100644 index bf94c54..0000000 --- a/index.js.flow +++ /dev/null @@ -1,202 +0,0 @@ -// @flow - -import * as React from 'react' -import PropTypes from 'prop-types' - -export type InjectedProps = { - open: (eventOrAnchorEl: Event | HTMLElement) => void, - close: () => void, - toggle: (eventOrAnchorEl: Event | HTMLElement) => void, - setOpen: (open: boolean, eventOrAnchorEl: Event | HTMLElement) => void, - isOpen: boolean, - anchorEl: ?HTMLElement, - popupId: ?string, -} - -/** - * Creates props for a component that opens the popup when clicked. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export function bindTrigger({ isOpen, open, popupId }: InjectedProps): { - 'aria-owns': ?string, - 'aria-haspopup': true, - onClick: (event: Event) => void, -} { - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onClick: open, - } -} - -/** - * Creates props for a component that toggles the popup when clicked. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export function bindToggle({ isOpen, toggle, popupId }: InjectedProps): { - 'aria-owns': ?string, - 'aria-haspopup': true, - onClick: (event: Event) => void, -} { - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onClick: toggle, - } -} - -/** - * Creates props for a component that opens the popup while hovered. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export function bindHover({ isOpen, open, close, popupId }: InjectedProps): { - 'aria-owns': ?string, - 'aria-haspopup': true, - onMouseEnter: (event: Event) => any, - onMouseLeave: (event: Event) => any, -} { - return { - 'aria-owns': isOpen ? popupId : null, - 'aria-haspopup': true, - onMouseEnter: open, - onMouseLeave: close, - } -} - -/** - * Creates props for a `Popover` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export function bindPopover({ isOpen, anchorEl, close, popupId }: InjectedProps): { - id: ?string, - anchorEl: ?HTMLElement, - open: boolean, - onClose: () => void, -} { - return { - id: popupId, - anchorEl, - open: isOpen, - onClose: close, - } -} - -/** - * Creates props for a `Menu` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export const bindMenu = bindPopover - -/** - * Creates props for a `Popper` component. - * - * @param {object} popupState the argument passed to the child function of - * `PopupState` - */ -export function bindPopper({ isOpen, anchorEl, popupId }: InjectedProps): { - id: ?string, - anchorEl: ?HTMLElement, - open: boolean, -} { - return { - id: popupId, - anchorEl, - open: isOpen, - } -} - -export type Props = { - popupId?: string, - children: (props: InjectedProps) => ?React.Node, -} - -type State = { - anchorEl: ?HTMLElement, -} - -let eventOrAnchorElWarned: boolean = false - -export default class PopupState extends React.Component { - state: State = { anchorEl: null }; - - static propTypes = { - /** - * The render function. - * - * @param {object} props the properties injected by `PopupState`: - * - * - * @returns {React.Node} the content to display - */ - children: PropTypes.func.isRequired, - /** - * The `id` property to use for the popup. Will be passed to the render - * function as `bindPopup.id`, and also used for the `aria-owns` property - * passed to the trigger component via `bindTrigger`. - */ - popupId: PropTypes.string, - } - - handleToggle = (eventOrAnchorEl: Event | HTMLElement) => { - if (this.state.anchorEl) this.handleClose() - else this.handleOpen(eventOrAnchorEl) - } - - handleOpen = (eventOrAnchorEl: Event | HTMLElement) => { - if (!eventOrAnchorElWarned && !eventOrAnchorEl && !eventOrAnchorEl.target) { - eventOrAnchorElWarned = true - console.error('eventOrAnchorEl should be defined') // eslint-disable-line no-console - } - this.setState({ - anchorEl: eventOrAnchorEl && eventOrAnchorEl.target - ? (eventOrAnchorEl.target: any) - : (eventOrAnchorEl: any), - }) - } - - handleClose = () => this.setState({ anchorEl: null }); - - handleSetOpen = (open: boolean, eventOrAnchorEl: Event | HTMLElement) => { - if (open) this.handleOpen(eventOrAnchorEl) - else this.handleClose() - } - - render(): ?React.Node { - const { children, popupId } = this.props - const { anchorEl } = this.state - - const isOpen = Boolean(anchorEl) - - return children({ - open: this.handleOpen, - close: this.handleClose, - toggle: this.handleToggle, - setOpen: this.handleSetOpen, - isOpen, - anchorEl, - popupId, - }) - } -} diff --git a/package.json b/package.json index 32522b3..2f1d481 100644 --- a/package.json +++ b/package.json @@ -73,7 +73,6 @@ "babel-cli": "^6.23.0", "babel-core": "^6.23.1", "babel-eslint": "^7.1.1", - "babel-plugin-flow-react-proptypes": "^17.0.0", "babel-plugin-istanbul": "^4.0.0", "babel-plugin-syntax-dynamic-import": "^6.18.0", "babel-plugin-transform-class-properties": "^6.24.1", diff --git a/yarn.lock b/yarn.lock index 12fc310..7fc8f90 100644 --- a/yarn.lock +++ b/yarn.lock @@ -655,7 +655,7 @@ babel-core@^6.23.1: slash "^1.0.0" source-map "^0.5.7" -babel-core@^6.25.0, babel-core@^6.26.0: +babel-core@^6.26.0: version "6.26.0" resolved "https://registry.npmjs.org/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: @@ -839,15 +839,6 @@ babel-plugin-check-es2015-constants@^6.22.0: dependencies: babel-runtime "^6.22.0" -babel-plugin-flow-react-proptypes@^17.0.0: - version "17.1.0" - resolved "https://registry.yarnpkg.com/babel-plugin-flow-react-proptypes/-/babel-plugin-flow-react-proptypes-17.1.0.tgz#332509038c52da1b3bd9aef97136a03133b21184" - dependencies: - babel-core "^6.25.0" - babel-template "^6.25.0" - babel-traverse "^6.25.0" - babel-types "^6.25.0" - babel-plugin-istanbul@^4.0.0: version "4.1.5" resolved "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" @@ -1338,7 +1329,7 @@ babel-runtime@6.26.0, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtim core-js "^2.4.0" regenerator-runtime "^0.11.0" -babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.25.0, babel-template@^6.26.0: +babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: version "6.26.0" resolved "https://registry.npmjs.org/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" dependencies: @@ -1348,7 +1339,7 @@ babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.25.0, babel-te babylon "^6.18.0" lodash "^4.17.4" -babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.25.0, babel-traverse@^6.26.0: +babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-traverse@^6.26.0: version "6.26.0" resolved "https://registry.npmjs.org/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: @@ -1362,7 +1353,7 @@ babel-traverse@^6.18.0, babel-traverse@^6.23.1, babel-traverse@^6.24.1, babel-tr invariant "^2.2.2" lodash "^4.17.4" -babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.25.0, babel-types@^6.26.0: +babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.23.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.npmjs.org/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: