diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c8618b4..c5770e9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +v2.3.3 - Wed, 04 Oct 2017 01:59:30 UTC +-------------------------------------- + +- [876972b](../../commit/876972b) [chore] removed depencendy 'react-dom-factory'. +- [73db6dd](../../commit/73db6dd) [chore] improve examples style. +- [8970956](../../commit/8970956) [chore] remove code climate yml. +- [d896241](../../commit/d896241) [chore] fix multiple modal example. +- [ce2b34e](../../commit/ce2b34e) [chore] added example with react-router. +- [16c3dce](../../commit/16c3dce) [chore] update dependencies, lint rules and refactor tests. +- [13dfc4e](../../commit/13dfc4e) [chore] update tests. +- [ba81894](../../commit/ba81894) Remove required flag from contentLabel propType in Modal +- [f007aeb](../../commit/f007aeb) [chore] Update description for onRequestClose. + + v2.3.2 - Wed, 06 Sep 2017 16:09:58 UTC -------------------------------------- diff --git a/bower.json b/bower.json index 094534a5..9df221b4 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "2.3.2", + "version": "2.3.3", "homepage": "https://github.com/reactjs/react-modal", "authors": [ "Ryan Florence", diff --git a/dist/react-modal.js b/dist/react-modal.js index b5dda02e..efd4d229 100644 --- a/dist/react-modal.js +++ b/dist/react-modal.js @@ -7,1948 +7,2100 @@ exports["ReactModal"] = factory(require("react"), require("react-dom")); else root["ReactModal"] = factory(root["React"], root["ReactDOM"]); -})(this, function(__WEBPACK_EXTERNAL_MODULE_2__, __WEBPACK_EXTERNAL_MODULE_3__) { +})(this, function(__WEBPACK_EXTERNAL_MODULE_3__, __WEBPACK_EXTERNAL_MODULE_12__) { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; - +/******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { - +/******/ /******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) +/******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; - +/******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} /******/ }; - +/******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - +/******/ /******/ // Flag the module as loaded -/******/ module.loaded = true; - +/******/ module.l = true; +/******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } - - +/******/ +/******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; - +/******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; - +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { +/******/ configurable: false, +/******/ enumerable: true, +/******/ get: getter +/******/ }); +/******/ } +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = "/"; - +/******/ /******/ // Load entry module and return exports -/******/ return __webpack_require__(0); +/******/ return __webpack_require__(__webpack_require__.s = 10); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Modal = __webpack_require__(1); - - var _Modal2 = _interopRequireDefault(_Modal); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.default = _Modal2.default; - module.exports = exports['default']; +"use strict"; + + +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * + */ + +function makeEmptyFunction(arg) { + return function () { + return arg; + }; +} + +/** + * This function accepts and discards inputs; it has no side effects. This is + * primarily useful idiomatically for overridable function endpoints which + * always need to be callable, since JS lacks a null-call idiom ala Cocoa. + */ +var emptyFunction = function emptyFunction() {}; + +emptyFunction.thatReturns = makeEmptyFunction; +emptyFunction.thatReturnsFalse = makeEmptyFunction(false); +emptyFunction.thatReturnsTrue = makeEmptyFunction(true); +emptyFunction.thatReturnsNull = makeEmptyFunction(null); +emptyFunction.thatReturnsThis = function () { + return this; +}; +emptyFunction.thatReturnsArgument = function (arg) { + return arg; +}; + +module.exports = emptyFunction; /***/ }), /* 1 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.bodyOpenClassName = exports.portalClassName = undefined; - - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _react = __webpack_require__(2); - - var _react2 = _interopRequireDefault(_react); - - var _reactDom = __webpack_require__(3); - - var _reactDom2 = _interopRequireDefault(_reactDom); +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + + + +/** + * Use invariant() to assert state which your program assumes to be true. + * + * Provide sprintf-style format (only %s is supported) and arguments + * to provide information about what broke and what you were + * expecting. + * + * The invariant message will be stripped in production, but the invariant + * will remain to ensure logic does not differ in production. + */ + +var validateFormat = function validateFormat(format) {}; + +if (undefined !== 'production') { + validateFormat = function validateFormat(format) { + if (format === undefined) { + throw new Error('invariant requires an error message argument'); + } + }; +} + +function invariant(condition, format, a, b, c, d, e, f) { + validateFormat(format); + + if (!condition) { + var error; + if (format === undefined) { + error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); + } else { + var args = [a, b, c, d, e, f]; + var argIndex = 0; + error = new Error(format.replace(/%s/g, function () { + return args[argIndex++]; + })); + error.name = 'Invariant Violation'; + } + + error.framesToPop = 1; // we don't care about invariant's own frame + throw error; + } +} + +module.exports = invariant; - var _propTypes = __webpack_require__(4); - - var _propTypes2 = _interopRequireDefault(_propTypes); - - var _ModalPortal = __webpack_require__(12); - - var _ModalPortal2 = _interopRequireDefault(_ModalPortal); - - var _ariaAppHider = __webpack_require__(16); - - var ariaAppHider = _interopRequireWildcard(_ariaAppHider); - - var _safeHTMLElement = __webpack_require__(19); - - var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement); - - 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 }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } +/***/ }), +/* 2 */ +/***/ (function(module, exports, __webpack_require__) { - var portalClassName = exports.portalClassName = 'ReactModalPortal'; - var bodyOpenClassName = exports.bodyOpenClassName = 'ReactModal__Body--open'; +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ - var renderSubtreeIntoContainer = _reactDom2.default.unstable_renderSubtreeIntoContainer; - function getParentElement(parentSelector) { - return parentSelector(); - } - var Modal = function (_Component) { - _inherits(Modal, _Component); - - function Modal() { - var _ref; - - var _temp, _this, _ret; - - _classCallCheck(this, Modal); - - for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Modal.__proto__ || Object.getPrototypeOf(Modal)).call.apply(_ref, [this].concat(args))), _this), _this.removePortal = function () { - _reactDom2.default.unmountComponentAtNode(_this.node); - var parent = getParentElement(_this.props.parentSelector); - parent.removeChild(_this.node); - }, _this.renderPortal = function (props) { - _this.portal = renderSubtreeIntoContainer(_this, _react2.default.createElement(_ModalPortal2.default, _extends({ defaultStyles: Modal.defaultStyles }, props)), _this.node); - }, _temp), _possibleConstructorReturn(_this, _ret); - } - - _createClass(Modal, [{ - key: 'componentDidMount', - value: function componentDidMount() { - this.node = document.createElement('div'); - this.node.className = this.props.portalClassName; - - var parent = getParentElement(this.props.parentSelector); - parent.appendChild(this.node); - - this.renderPortal(this.props); - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(newProps) { - var isOpen = newProps.isOpen; - // Stop unnecessary renders if modal is remaining closed - - if (!this.props.isOpen && !isOpen) return; - - var currentParent = getParentElement(this.props.parentSelector); - var newParent = getParentElement(newProps.parentSelector); - - if (newParent !== currentParent) { - currentParent.removeChild(this.node); - newParent.appendChild(this.node); - } - - this.renderPortal(newProps); - } - }, { - key: 'componentWillUpdate', - value: function componentWillUpdate(newProps) { - if (newProps.portalClassName !== this.props.portalClassName) { - this.node.className = newProps.portalClassName; - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - if (!this.node || !this.portal) return; - - var state = this.portal.state; - var now = Date.now(); - var closesAt = state.isOpen && this.props.closeTimeoutMS && (state.closesAt || now + this.props.closeTimeoutMS); - - if (closesAt) { - if (!state.beforeClose) { - this.portal.closeWithTimeout(); - } - - setTimeout(this.removePortal, closesAt - now); - } else { - this.removePortal(); - } - } - }, { - key: 'render', - value: function render() { - return null; - } - }], [{ - key: 'setAppElement', - value: function setAppElement(element) { - ariaAppHider.setElement(element); - } - - /* eslint-disable no-console */ - - }, { - key: 'injectCSS', - value: function injectCSS() { - (undefined) !== "production" && console.warn('React-Modal: injectCSS has been deprecated ' + 'and no longer has any effect. It will be removed in a later version'); - } - /* eslint-enable no-console */ - - /* eslint-disable react/no-unused-prop-types */ - - /* eslint-enable react/no-unused-prop-types */ - - }]); - - return Modal; - }(_react.Component); - - Modal.propTypes = { - isOpen: _propTypes2.default.bool.isRequired, - style: _propTypes2.default.shape({ - content: _propTypes2.default.object, - overlay: _propTypes2.default.object - }), - portalClassName: _propTypes2.default.string, - bodyOpenClassName: _propTypes2.default.string, - className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), - overlayClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), - appElement: _propTypes2.default.instanceOf(_safeHTMLElement2.default), - onAfterOpen: _propTypes2.default.func, - onRequestClose: _propTypes2.default.func, - closeTimeoutMS: _propTypes2.default.number, - ariaHideApp: _propTypes2.default.bool, - shouldFocusAfter: _propTypes2.default.bool, - shouldCloseOnOverlayClick: _propTypes2.default.bool, - parentSelector: _propTypes2.default.func, - aria: _propTypes2.default.object, - role: _propTypes2.default.string, - contentLabel: _propTypes2.default.string.isRequired - }; - Modal.defaultProps = { - isOpen: false, - portalClassName: portalClassName, - bodyOpenClassName: bodyOpenClassName, - ariaHideApp: true, - closeTimeoutMS: 0, - shouldFocusAfterRender: true, - shouldCloseOnOverlayClick: true, - parentSelector: function parentSelector() { - return document.body; - } - }; - Modal.defaultStyles = { - overlay: { - position: 'fixed', - top: 0, - left: 0, - right: 0, - bottom: 0, - backgroundColor: 'rgba(255, 255, 255, 0.75)' - }, - content: { - position: 'absolute', - top: '40px', - left: '40px', - right: '40px', - bottom: '40px', - border: '1px solid #ccc', - background: '#fff', - overflow: 'auto', - WebkitOverflowScrolling: 'touch', - borderRadius: '4px', - outline: 'none', - padding: '20px' - } - }; - exports.default = Modal; +var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; -/***/ }), -/* 2 */ -/***/ (function(module, exports) { +module.exports = ReactPropTypesSecret; - module.exports = __WEBPACK_EXTERNAL_MODULE_2__; /***/ }), /* 3 */ /***/ (function(module, exports) { - module.exports = __WEBPACK_EXTERNAL_MODULE_3__; +module.exports = __WEBPACK_EXTERNAL_MODULE_3__; /***/ }), /* 4 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - - if ((undefined) !== 'production') { - var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && - Symbol.for && - Symbol.for('react.element')) || - 0xeac7; - - var isValidElement = function(object) { - return typeof object === 'object' && - object !== null && - object.$$typeof === REACT_ELEMENT_TYPE; - }; - - // By explicitly using `prop-types` you are opting into new development behavior. - // http://fb.me/prop-types-in-prod - var throwOnDirectAccess = true; - module.exports = __webpack_require__(5)(isValidElement, throwOnDirectAccess); - } else { - // By explicitly using `prop-types` you are opting into new production behavior. - // http://fb.me/prop-types-in-prod - module.exports = __webpack_require__(11)(); - } +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +if (undefined !== 'production') { + var REACT_ELEMENT_TYPE = (typeof Symbol === 'function' && + Symbol.for && + Symbol.for('react.element')) || + 0xeac7; + + var isValidElement = function(object) { + return typeof object === 'object' && + object !== null && + object.$$typeof === REACT_ELEMENT_TYPE; + }; + + // By explicitly using `prop-types` you are opting into new development behavior. + // http://fb.me/prop-types-in-prod + var throwOnDirectAccess = true; + module.exports = __webpack_require__(13)(isValidElement, throwOnDirectAccess); +} else { + // By explicitly using `prop-types` you are opting into new production behavior. + // http://fb.me/prop-types-in-prod + module.exports = __webpack_require__(16)(); +} /***/ }), /* 5 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - - 'use strict'; - - var emptyFunction = __webpack_require__(6); - var invariant = __webpack_require__(7); - var warning = __webpack_require__(8); - - var ReactPropTypesSecret = __webpack_require__(9); - var checkPropTypes = __webpack_require__(10); - - module.exports = function(isValidElement, throwOnDirectAccess) { - /* global Symbol */ - var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; - var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. - - /** - * Returns the iterator method function contained on the iterable object. - * - * Be sure to invoke the function with the iterable as context: - * - * var iteratorFn = getIteratorFn(myIterable); - * if (iteratorFn) { - * var iterator = iteratorFn.call(myIterable); - * ... - * } - * - * @param {?object} maybeIterable - * @return {?function} - */ - function getIteratorFn(maybeIterable) { - var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); - if (typeof iteratorFn === 'function') { - return iteratorFn; - } - } - - /** - * Collection of methods that allow declaration and validation of props that are - * supplied to React components. Example usage: - * - * var Props = require('ReactPropTypes'); - * var MyArticle = React.createClass({ - * propTypes: { - * // An optional string prop named "description". - * description: Props.string, - * - * // A required enum prop named "category". - * category: Props.oneOf(['News','Photos']).isRequired, - * - * // A prop named "dialog" that requires an instance of Dialog. - * dialog: Props.instanceOf(Dialog).isRequired - * }, - * render: function() { ... } - * }); - * - * A more formal specification of how these methods are used: - * - * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) - * decl := ReactPropTypes.{type}(.isRequired)? - * - * Each and every declaration produces a function with the same signature. This - * allows the creation of custom validation functions. For example: - * - * var MyLink = React.createClass({ - * propTypes: { - * // An optional string or URI prop named "href". - * href: function(props, propName, componentName) { - * var propValue = props[propName]; - * if (propValue != null && typeof propValue !== 'string' && - * !(propValue instanceof URI)) { - * return new Error( - * 'Expected a string or an URI for ' + propName + ' in ' + - * componentName - * ); - * } - * } - * }, - * render: function() {...} - * }); - * - * @internal - */ - - var ANONYMOUS = '<>'; - - // Important! - // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. - var ReactPropTypes = { - array: createPrimitiveTypeChecker('array'), - bool: createPrimitiveTypeChecker('boolean'), - func: createPrimitiveTypeChecker('function'), - number: createPrimitiveTypeChecker('number'), - object: createPrimitiveTypeChecker('object'), - string: createPrimitiveTypeChecker('string'), - symbol: createPrimitiveTypeChecker('symbol'), - - any: createAnyTypeChecker(), - arrayOf: createArrayOfTypeChecker, - element: createElementTypeChecker(), - instanceOf: createInstanceTypeChecker, - node: createNodeChecker(), - objectOf: createObjectOfTypeChecker, - oneOf: createEnumTypeChecker, - oneOfType: createUnionTypeChecker, - shape: createShapeTypeChecker - }; - - /** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ - /*eslint-disable no-self-compare*/ - function is(x, y) { - // SameValue algorithm - if (x === y) { - // Steps 1-5, 7-10 - // Steps 6.b-6.e: +0 != -0 - return x !== 0 || 1 / x === 1 / y; - } else { - // Step 6.a: NaN == NaN - return x !== x && y !== y; - } - } - /*eslint-enable no-self-compare*/ - - /** - * We use an Error-like object for backward compatibility as people may call - * PropTypes directly and inspect their output. However, we don't use real - * Errors anymore. We don't inspect their stack anyway, and creating them - * is prohibitively expensive if they are created too often, such as what - * happens in oneOfType() for any type before the one that matched. - */ - function PropTypeError(message) { - this.message = message; - this.stack = ''; - } - // Make `instanceof Error` still work for returned errors. - PropTypeError.prototype = Error.prototype; - - function createChainableTypeChecker(validate) { - if ((undefined) !== 'production') { - var manualPropTypeCallCache = {}; - var manualPropTypeWarningCount = 0; - } - function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { - componentName = componentName || ANONYMOUS; - propFullName = propFullName || propName; - - if (secret !== ReactPropTypesSecret) { - if (throwOnDirectAccess) { - // New behavior only for users of `prop-types` package - invariant( - false, - 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + - 'Use `PropTypes.checkPropTypes()` to call them. ' + - 'Read more at http://fb.me/use-check-prop-types' - ); - } else if ((undefined) !== 'production' && typeof console !== 'undefined') { - // Old behavior for people using React.PropTypes - var cacheKey = componentName + ':' + propName; - if ( - !manualPropTypeCallCache[cacheKey] && - // Avoid spamming the console because they are often not actionable except for lib authors - manualPropTypeWarningCount < 3 - ) { - warning( - false, - 'You are manually calling a React.PropTypes validation ' + - 'function for the `%s` prop on `%s`. This is deprecated ' + - 'and will throw in the standalone `prop-types` package. ' + - 'You may be seeing this warning due to a third-party PropTypes ' + - 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', - propFullName, - componentName - ); - manualPropTypeCallCache[cacheKey] = true; - manualPropTypeWarningCount++; - } - } - } - if (props[propName] == null) { - if (isRequired) { - if (props[propName] === null) { - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); - } - return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); - } - return null; - } else { - return validate(props, propName, componentName, location, propFullName); - } - } - - var chainedCheckType = checkType.bind(null, false); - chainedCheckType.isRequired = checkType.bind(null, true); - - return chainedCheckType; - } - - function createPrimitiveTypeChecker(expectedType) { - function validate(props, propName, componentName, location, propFullName, secret) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== expectedType) { - // `propValue` being instance of, say, date/regexp, pass the 'object' - // check, but we can offer a more precise error message here rather than - // 'of type `object`'. - var preciseType = getPreciseType(propValue); - - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createAnyTypeChecker() { - return createChainableTypeChecker(emptyFunction.thatReturnsNull); - } - - function createArrayOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); - } - var propValue = props[propName]; - if (!Array.isArray(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); - } - for (var i = 0; i < propValue.length; i++) { - var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createElementTypeChecker() { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - if (!isValidElement(propValue)) { - var propType = getPropType(propValue); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createInstanceTypeChecker(expectedClass) { - function validate(props, propName, componentName, location, propFullName) { - if (!(props[propName] instanceof expectedClass)) { - var expectedClassName = expectedClass.name || ANONYMOUS; - var actualClassName = getClassName(props[propName]); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createEnumTypeChecker(expectedValues) { - if (!Array.isArray(expectedValues)) { - (undefined) !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; - return emptyFunction.thatReturnsNull; - } - - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - for (var i = 0; i < expectedValues.length; i++) { - if (is(propValue, expectedValues[i])) { - return null; - } - } - - var valuesString = JSON.stringify(expectedValues); - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); - } - return createChainableTypeChecker(validate); - } - - function createObjectOfTypeChecker(typeChecker) { - function validate(props, propName, componentName, location, propFullName) { - if (typeof typeChecker !== 'function') { - return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); - } - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); - } - for (var key in propValue) { - if (propValue.hasOwnProperty(key)) { - var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error instanceof Error) { - return error; - } - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createUnionTypeChecker(arrayOfTypeCheckers) { - if (!Array.isArray(arrayOfTypeCheckers)) { - (undefined) !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; - return emptyFunction.thatReturnsNull; - } - - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (typeof checker !== 'function') { - warning( - false, - 'Invalid argument supplid to oneOfType. Expected an array of check functions, but ' + - 'received %s at index %s.', - getPostfixForTypeWarning(checker), - i - ); - return emptyFunction.thatReturnsNull; - } - } - - function validate(props, propName, componentName, location, propFullName) { - for (var i = 0; i < arrayOfTypeCheckers.length; i++) { - var checker = arrayOfTypeCheckers[i]; - if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { - return null; - } - } - - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); - } - return createChainableTypeChecker(validate); - } - - function createNodeChecker() { - function validate(props, propName, componentName, location, propFullName) { - if (!isNode(props[propName])) { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); - } - return null; - } - return createChainableTypeChecker(validate); - } - - function createShapeTypeChecker(shapeTypes) { - function validate(props, propName, componentName, location, propFullName) { - var propValue = props[propName]; - var propType = getPropType(propValue); - if (propType !== 'object') { - return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); - } - for (var key in shapeTypes) { - var checker = shapeTypes[key]; - if (!checker) { - continue; - } - var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); - if (error) { - return error; - } - } - return null; - } - return createChainableTypeChecker(validate); - } - - function isNode(propValue) { - switch (typeof propValue) { - case 'number': - case 'string': - case 'undefined': - return true; - case 'boolean': - return !propValue; - case 'object': - if (Array.isArray(propValue)) { - return propValue.every(isNode); - } - if (propValue === null || isValidElement(propValue)) { - return true; - } - - var iteratorFn = getIteratorFn(propValue); - if (iteratorFn) { - var iterator = iteratorFn.call(propValue); - var step; - if (iteratorFn !== propValue.entries) { - while (!(step = iterator.next()).done) { - if (!isNode(step.value)) { - return false; - } - } - } else { - // Iterator will provide entry [k,v] tuples rather than values. - while (!(step = iterator.next()).done) { - var entry = step.value; - if (entry) { - if (!isNode(entry[1])) { - return false; - } - } - } - } - } else { - return false; - } - - return true; - default: - return false; - } - } - - function isSymbol(propType, propValue) { - // Native Symbol. - if (propType === 'symbol') { - return true; - } - - // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' - if (propValue['@@toStringTag'] === 'Symbol') { - return true; - } - - // Fallback for non-spec compliant Symbols which are polyfilled. - if (typeof Symbol === 'function' && propValue instanceof Symbol) { - return true; - } - - return false; - } - - // Equivalent of `typeof` but with special handling for array and regexp. - function getPropType(propValue) { - var propType = typeof propValue; - if (Array.isArray(propValue)) { - return 'array'; - } - if (propValue instanceof RegExp) { - // Old webkits (at least until Android 4.0) return 'function' rather than - // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ - // passes PropTypes.object. - return 'object'; - } - if (isSymbol(propType, propValue)) { - return 'symbol'; - } - return propType; - } - - // This handles more types than `getPropType`. Only used for error messages. - // See `createPrimitiveTypeChecker`. - function getPreciseType(propValue) { - if (typeof propValue === 'undefined' || propValue === null) { - return '' + propValue; - } - var propType = getPropType(propValue); - if (propType === 'object') { - if (propValue instanceof Date) { - return 'date'; - } else if (propValue instanceof RegExp) { - return 'regexp'; - } - } - return propType; - } - - // Returns a string that is postfixed to a warning about an invalid type. - // For example, "undefined" or "of type array" - function getPostfixForTypeWarning(value) { - var type = getPreciseType(value); - switch (type) { - case 'array': - case 'object': - return 'an ' + type; - case 'boolean': - case 'date': - case 'regexp': - return 'a ' + type; - default: - return type; - } - } - - // Returns class name of the object, if any. - function getClassName(propValue) { - if (!propValue.constructor || !propValue.constructor.name) { - return ANONYMOUS; - } - return propValue.constructor.name; - } - - ReactPropTypes.checkPropTypes = checkPropTypes; - ReactPropTypes.PropTypes = ReactPropTypes; - - return ReactPropTypes; - }; - +"use strict"; +/** + * Copyright (c) 2014-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + */ + + + +var emptyFunction = __webpack_require__(0); + +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = emptyFunction; + +if (undefined !== 'production') { + var printWarning = function printWarning(format) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var argIndex = 0; + var message = 'Warning: ' + format.replace(/%s/g, function () { + return args[argIndex++]; + }); + if (typeof console !== 'undefined') { + console.error(message); + } + try { + // --- Welcome to debugging React --- + // This error was thrown as a convenience so that you can use this stack + // to find the callsite that caused this warning to fire. + throw new Error(message); + } catch (x) {} + }; + + warning = function warning(condition, format) { + if (format === undefined) { + throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); + } + + if (format.indexOf('Failed Composite propType: ') === 0) { + return; // Ignore CompositeComponent proptype check. + } + + if (!condition) { + for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + args[_key2 - 2] = arguments[_key2]; + } + + printWarning.apply(undefined, [format].concat(args)); + } + }; +} + +module.exports = warning; /***/ }), /* 6 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { - "use strict"; - - /** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - * - */ - - function makeEmptyFunction(arg) { - return function () { - return arg; - }; - } +"use strict"; - /** - * This function accepts and discards inputs; it has no side effects. This is - * primarily useful idiomatically for overridable function endpoints which - * always need to be callable, since JS lacks a null-call idiom ala Cocoa. - */ - var emptyFunction = function emptyFunction() {}; - - emptyFunction.thatReturns = makeEmptyFunction; - emptyFunction.thatReturnsFalse = makeEmptyFunction(false); - emptyFunction.thatReturnsTrue = makeEmptyFunction(true); - emptyFunction.thatReturnsNull = makeEmptyFunction(null); - emptyFunction.thatReturnsThis = function () { - return this; - }; - emptyFunction.thatReturnsArgument = function (arg) { - return arg; - }; - module.exports = emptyFunction; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = findTabbableDescendants; +/*! + * Adapted from jQuery UI core + * + * http://jqueryui.com + * + * Copyright 2014 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/ui-core/ + */ + +var tabbableNode = /input|select|textarea|button|object/; + +function hidden(el) { + return el.offsetWidth <= 0 && el.offsetHeight <= 0 || el.style.display === 'none'; +} + +function visible(element) { + var parentElement = element; + while (parentElement) { + if (parentElement === document.body) break; + if (hidden(parentElement)) return false; + parentElement = parentElement.parentNode; + } + return true; +} + +function focusable(element, isTabIndexNotNaN) { + var nodeName = element.nodeName.toLowerCase(); + var res = tabbableNode.test(nodeName) && !element.disabled || (nodeName === "a" ? element.href || isTabIndexNotNaN : isTabIndexNotNaN); + return res && visible(element); +} + +function tabbable(element) { + var tabIndex = element.getAttribute('tabindex'); + if (tabIndex === null) tabIndex = undefined; + var isTabIndexNaN = isNaN(tabIndex); + return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN); +} + +function findTabbableDescendants(element) { + return [].slice.call(element.querySelectorAll('*'), 0).filter(tabbable); +} +module.exports = exports['default']; /***/ }), /* 7 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright (c) 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - */ - - 'use strict'; - - /** - * Use invariant() to assert state which your program assumes to be true. - * - * Provide sprintf-style format (only %s is supported) and arguments - * to provide information about what broke and what you were - * expecting. - * - * The invariant message will be stripped in production, but the invariant - * will remain to ensure logic does not differ in production. - */ - - var validateFormat = function validateFormat(format) {}; - - if ((undefined) !== 'production') { - validateFormat = function validateFormat(format) { - if (format === undefined) { - throw new Error('invariant requires an error message argument'); - } - }; - } +"use strict"; - function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error; - if (format === undefined) { - error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.'); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error(format.replace(/%s/g, function () { - return args[argIndex++]; - })); - error.name = 'Invariant Violation'; - } - - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; - } - } - module.exports = invariant; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.assertNodeList = assertNodeList; +exports.setElement = setElement; +exports.tryForceFallback = tryForceFallback; +exports.validateElement = validateElement; +exports.hide = hide; +exports.show = show; +exports.documentNotReadyOrSSRTesting = documentNotReadyOrSSRTesting; +exports.resetForTesting = resetForTesting; +var globalElement = null; + +function assertNodeList(nodeList, selector) { + if (!nodeList || !nodeList.length) { + throw new Error('react-modal: No elements were found for selector ' + selector + '.'); + } +} + +function setElement(element) { + var useElement = element; + if (typeof useElement === 'string') { + var el = document.querySelectorAll(useElement); + assertNodeList(el, useElement); + useElement = 'length' in el ? el[0] : el; + } + globalElement = useElement || globalElement; + return globalElement; +} + +function tryForceFallback() { + if (document && document.body) { + // force fallback to document.body + setElement(document.body); + return true; + } + return false; +} + +function validateElement(appElement) { + if (!appElement && !globalElement && !tryForceFallback()) { + throw new Error(['react-modal: Cannot fallback to `document.body`, because it\'s not ready or available.', 'If you are doing server-side rendering, use this function to defined an element.', '`Modal.setAppElement(el)` to make this accessible']); + } +} + +function hide(appElement) { + validateElement(appElement); + (appElement || globalElement).setAttribute('aria-hidden', 'true'); +} + +function show(appElement) { + validateElement(appElement); + (appElement || globalElement).removeAttribute('aria-hidden'); +} + +function documentNotReadyOrSSRTesting() { + globalElement = null; +} + +function resetForTesting() { + globalElement = document.body; +} /***/ }), /* 8 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2014-2015, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - * - */ - - 'use strict'; +"use strict"; - var emptyFunction = __webpack_require__(6); - - /** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - - var warning = emptyFunction; - - if ((undefined) !== 'production') { - (function () { - var printWarning = function printWarning(format) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - var argIndex = 0; - var message = 'Warning: ' + format.replace(/%s/g, function () { - return args[argIndex++]; - }); - if (typeof console !== 'undefined') { - console.error(message); - } - try { - // --- Welcome to debugging React --- - // This error was thrown as a convenience so that you can use this stack - // to find the callsite that caused this warning to fire. - throw new Error(message); - } catch (x) {} - }; - - warning = function warning(condition, format) { - if (format === undefined) { - throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument'); - } - - if (format.indexOf('Failed Composite propType: ') === 0) { - return; // Ignore CompositeComponent proptype check. - } - - if (!condition) { - for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { - args[_key2 - 2] = arguments[_key2]; - } - - printWarning.apply(undefined, [format].concat(args)); - } - }; - })(); - } - module.exports = warning; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.get = get; +exports.add = add; +exports.remove = remove; +exports.totalCount = totalCount; +var classListMap = {}; + +function get() { + return classListMap; +} + +function add(bodyClass) { + // Set variable and default if none + if (!classListMap[bodyClass]) { + classListMap[bodyClass] = 0; + } + classListMap[bodyClass] += 1; + return bodyClass; +} + +function remove(bodyClass) { + if (classListMap[bodyClass]) { + classListMap[bodyClass] -= 1; + } + return bodyClass; +} + +function totalCount() { + return Object.keys(classListMap).reduce(function (acc, curr) { + return acc + classListMap[curr]; + }, 0); +} /***/ }), /* 9 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ +"use strict"; - 'use strict'; - var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _exenv = __webpack_require__(21); + +var _exenv2 = _interopRequireDefault(_exenv); - module.exports = ReactPropTypesSecret; +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var EE = _exenv2.default; + +var SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {}; + +exports.default = SafeHTMLElement; +module.exports = exports['default']; /***/ }), /* 10 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ +"use strict"; - 'use strict'; - if ((undefined) !== 'production') { - var invariant = __webpack_require__(7); - var warning = __webpack_require__(8); - var ReactPropTypesSecret = __webpack_require__(9); - var loggedTypeFailures = {}; - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - /** - * Assert that the values match with the type specs. - * Error messages are memorized and will only be shown once. - * - * @param {object} typeSpecs Map of name to a ReactPropType - * @param {object} values Runtime values that need to be type-checked - * @param {string} location e.g. "prop", "context", "child context" - * @param {string} componentName Name of the component for error messages. - * @param {?Function} getStack Returns the component stack. - * @private - */ - function checkPropTypes(typeSpecs, values, location, componentName, getStack) { - if ((undefined) !== 'production') { - for (var typeSpecName in typeSpecs) { - if (typeSpecs.hasOwnProperty(typeSpecName)) { - var error; - // Prop type validation may throw. In case they do, we don't want to - // fail the render phase where it didn't fail before. So we log it. - // After these have been cleaned up, we'll let them throw. - try { - // This is intentionally an invariant that gets caught. It's the same - // behavior as without this statement except with a better message. - invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', location, typeSpecName); - error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); - } catch (ex) { - error = ex; - } - warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); - if (error instanceof Error && !(error.message in loggedTypeFailures)) { - // Only monitor this failure once because there tends to be a lot of the - // same error. - loggedTypeFailures[error.message] = true; - - var stack = getStack ? getStack() : ''; - - warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); - } - } - } - } - } +var _Modal = __webpack_require__(11); - module.exports = checkPropTypes; +var _Modal2 = _interopRequireDefault(_Modal); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +exports.default = _Modal2.default; +module.exports = exports['default']; /***/ }), /* 11 */ /***/ (function(module, exports, __webpack_require__) { - /** - * Copyright 2013-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ +"use strict"; - 'use strict'; - var emptyFunction = __webpack_require__(6); - var invariant = __webpack_require__(7); - var ReactPropTypesSecret = __webpack_require__(9); - - module.exports = function() { - function shim(props, propName, componentName, location, propFullName, secret) { - if (secret === ReactPropTypesSecret) { - // It is still safe when called from React. - return; - } - invariant( - false, - 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + - 'Use PropTypes.checkPropTypes() to call them. ' + - 'Read more at http://fb.me/use-check-prop-types' - ); - }; - shim.isRequired = shim; - function getShim() { - return shim; - }; - // Important! - // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. - var ReactPropTypes = { - array: shim, - bool: shim, - func: shim, - number: shim, - object: shim, - string: shim, - symbol: shim, - - any: shim, - arrayOf: getShim, - element: shim, - instanceOf: getShim, - node: shim, - objectOf: getShim, - oneOf: getShim, - oneOfType: getShim, - shape: getShim - }; - - ReactPropTypes.checkPropTypes = emptyFunction; - ReactPropTypes.PropTypes = ReactPropTypes; - - return ReactPropTypes; - }; +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.bodyOpenClassName = exports.portalClassName = undefined; +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; -/***/ }), -/* 12 */ -/***/ (function(module, exports, __webpack_require__) { +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - 'use strict'; +var _react = __webpack_require__(3); - Object.defineProperty(exports, "__esModule", { - value: true - }); +var _react2 = _interopRequireDefault(_react); - var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; +var _reactDom = __webpack_require__(12); - var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; +var _reactDom2 = _interopRequireDefault(_reactDom); - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); +var _propTypes = __webpack_require__(4); - var _react = __webpack_require__(2); +var _propTypes2 = _interopRequireDefault(_propTypes); - var _react2 = _interopRequireDefault(_react); +var _ModalPortal = __webpack_require__(17); - var _propTypes = __webpack_require__(4); +var _ModalPortal2 = _interopRequireDefault(_ModalPortal); - var _focusManager = __webpack_require__(13); +var _ariaAppHider = __webpack_require__(7); - var focusManager = _interopRequireWildcard(_focusManager); +var ariaAppHider = _interopRequireWildcard(_ariaAppHider); - var _scopeTab = __webpack_require__(15); +var _safeHTMLElement = __webpack_require__(9); - var _scopeTab2 = _interopRequireDefault(_scopeTab); +var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement); - var _ariaAppHider = __webpack_require__(16); +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; } } - var ariaAppHider = _interopRequireWildcard(_ariaAppHider); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - var _refCount = __webpack_require__(17); +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - var refCount = _interopRequireWildcard(_refCount); +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - var _bodyClassList = __webpack_require__(18); +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - var bodyClassList = _interopRequireWildcard(_bodyClassList); +var portalClassName = exports.portalClassName = 'ReactModalPortal'; +var bodyOpenClassName = exports.bodyOpenClassName = 'ReactModal__Body--open'; - var _safeHTMLElement = __webpack_require__(19); +var renderSubtreeIntoContainer = _reactDom2.default.unstable_renderSubtreeIntoContainer; - var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement); +function getParentElement(parentSelector) { + return parentSelector(); +} - 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; } } +var Modal = function (_Component) { + _inherits(Modal, _Component); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + function Modal() { + var _ref; - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + var _temp, _this, _ret; - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + _classCallCheck(this, Modal); - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - // so that our CSS is statically analyzable - var CLASS_NAMES = { - overlay: 'ReactModal__Overlay', - content: 'ReactModal__Content' - }; + return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Modal.__proto__ || Object.getPrototypeOf(Modal)).call.apply(_ref, [this].concat(args))), _this), _this.removePortal = function () { + _reactDom2.default.unmountComponentAtNode(_this.node); + var parent = getParentElement(_this.props.parentSelector); + parent.removeChild(_this.node); + }, _this.renderPortal = function (props) { + _this.portal = renderSubtreeIntoContainer(_this, _react2.default.createElement(_ModalPortal2.default, _extends({ defaultStyles: Modal.defaultStyles }, props)), _this.node); + }, _temp), _possibleConstructorReturn(_this, _ret); + } - var TAB_KEY = 9; - var ESC_KEY = 27; - - var ModalPortal = function (_Component) { - _inherits(ModalPortal, _Component); - - function ModalPortal(props) { - _classCallCheck(this, ModalPortal); - - var _this = _possibleConstructorReturn(this, (ModalPortal.__proto__ || Object.getPrototypeOf(ModalPortal)).call(this, props)); - - _this.setFocusAfterRender = function (focus) { - _this.focusAfterRender = _this.props.shouldFocusAfterRender && focus; - }; - - _this.setOverlayRef = function (overlay) { - _this.overlay = overlay; - }; - - _this.setContentRef = function (content) { - _this.content = content; - }; - - _this.afterClose = function () { - focusManager.returnFocus(); - focusManager.teardownScopedFocus(); - }; - - _this.open = function () { - _this.beforeOpen(); - if (_this.state.afterOpen && _this.state.beforeClose) { - clearTimeout(_this.closeTimer); - _this.setState({ beforeClose: false }); - } else { - focusManager.setupScopedFocus(_this.node); - focusManager.markForFocusLater(); - _this.setState({ isOpen: true }, function () { - _this.setState({ afterOpen: true }); - - if (_this.props.isOpen && _this.props.onAfterOpen) { - _this.props.onAfterOpen(); - } - }); - } - }; - - _this.close = function () { - _this.beforeClose(); - if (_this.props.closeTimeoutMS > 0) { - _this.closeWithTimeout(); - } else { - _this.closeWithoutTimeout(); - } - }; - - _this.focusContent = function () { - return _this.content && !_this.contentHasFocus() && _this.content.focus(); - }; - - _this.closeWithTimeout = function () { - var closesAt = Date.now() + _this.props.closeTimeoutMS; - _this.setState({ beforeClose: true, closesAt: closesAt }, function () { - _this.closeTimer = setTimeout(_this.closeWithoutTimeout, _this.state.closesAt - Date.now()); - }); - }; - - _this.closeWithoutTimeout = function () { - _this.setState({ - beforeClose: false, - isOpen: false, - afterOpen: false, - closesAt: null - }, _this.afterClose); - }; - - _this.handleKeyDown = function (event) { - if (event.keyCode === TAB_KEY) { - (0, _scopeTab2.default)(_this.content, event); - } - if (event.keyCode === ESC_KEY) { - event.preventDefault(); - _this.requestClose(event); - } - }; - - _this.handleOverlayOnClick = function (event) { - if (_this.shouldClose === null) { - _this.shouldClose = true; - } - - if (_this.shouldClose && _this.props.shouldCloseOnOverlayClick) { - if (_this.ownerHandlesClose()) { - _this.requestClose(event); - } else { - _this.focusContent(); - } - } - _this.shouldClose = null; - }; - - _this.handleContentOnClick = function () { - _this.shouldClose = false; - }; - - _this.handleContentOnMouseDown = function () { - _this.shouldClose = false; - }; - - _this.requestClose = function (event) { - return _this.ownerHandlesClose() && _this.props.onRequestClose(event); - }; - - _this.ownerHandlesClose = function () { - return _this.props.onRequestClose; - }; - - _this.shouldBeClosed = function () { - return !_this.state.isOpen && !_this.state.beforeClose; - }; - - _this.contentHasFocus = function () { - return document.activeElement === _this.content || _this.content.contains(document.activeElement); - }; - - _this.buildClassName = function (which, additional) { - var classNames = (typeof additional === 'undefined' ? 'undefined' : _typeof(additional)) === 'object' ? additional : { - base: CLASS_NAMES[which], - afterOpen: CLASS_NAMES[which] + '--after-open', - beforeClose: CLASS_NAMES[which] + '--before-close' - }; - var className = classNames.base; - if (_this.state.afterOpen) { - className = className + ' ' + classNames.afterOpen; - } - if (_this.state.beforeClose) { - className = className + ' ' + classNames.beforeClose; - } - return typeof additional === 'string' && additional ? className + ' ' + additional : className; - }; - - _this.ariaAttributes = function (items) { - return Object.keys(items).reduce(function (acc, name) { - acc['aria-' + name] = items[name]; - return acc; - }, {}); - }; - - _this.state = { - afterOpen: false, - beforeClose: false - }; - - _this.shouldClose = null; - return _this; - } - - _createClass(ModalPortal, [{ - key: 'componentDidMount', - value: function componentDidMount() { - // Focus needs to be set when mounting and already open - if (this.props.isOpen) { - this.setFocusAfterRender(true); - this.open(); - } - } - }, { - key: 'componentWillReceiveProps', - value: function componentWillReceiveProps(newProps) { - if ((undefined) !== "production") { - if (newProps.bodyOpenClassName !== this.props.bodyOpenClassName) { - // eslint-disable-next-line no-console - console.warn('React-Modal: "bodyOpenClassName" prop has been modified. ' + 'This may cause unexpected behavior when multiple modals are open.'); - } - } - // Focus only needs to be set once when the modal is being opened - if (!this.props.isOpen && newProps.isOpen) { - this.setFocusAfterRender(true); - this.open(); - } else if (this.props.isOpen && !newProps.isOpen) { - this.close(); - } - } - }, { - key: 'componentDidUpdate', - value: function componentDidUpdate() { - if (this.focusAfterRender) { - this.focusContent(); - this.setFocusAfterRender(false); - } - } - }, { - key: 'componentWillUnmount', - value: function componentWillUnmount() { - this.beforeClose(); - clearTimeout(this.closeTimer); - } - }, { - key: 'beforeOpen', - value: function beforeOpen() { - var _props = this.props, - appElement = _props.appElement, - ariaHideApp = _props.ariaHideApp, - bodyOpenClassName = _props.bodyOpenClassName; - // Add body class - - bodyClassList.add(bodyOpenClassName); - // Add aria-hidden to appElement - if (ariaHideApp) { - ariaAppHider.hide(appElement); - } - } - }, { - key: 'beforeClose', - value: function beforeClose() { - var _props2 = this.props, - appElement = _props2.appElement, - ariaHideApp = _props2.ariaHideApp, - bodyOpenClassName = _props2.bodyOpenClassName; - // Remove class if no more modals are open - - bodyClassList.remove(bodyOpenClassName); - // Reset aria-hidden attribute if all modals have been removed - if (ariaHideApp && refCount.totalCount() < 1) { - ariaAppHider.show(appElement); - } - } - - // Don't steal focus from inner elements - - }, { - key: 'render', - value: function render() { - var _props3 = this.props, - className = _props3.className, - overlayClassName = _props3.overlayClassName, - defaultStyles = _props3.defaultStyles; - - var contentStyles = className ? {} : defaultStyles.content; - var overlayStyles = overlayClassName ? {} : defaultStyles.overlay; - - return this.shouldBeClosed() ? null : _react2.default.createElement( - 'div', - { - ref: this.setOverlayRef, - className: this.buildClassName('overlay', overlayClassName), - style: _extends({}, overlayStyles, this.props.style.overlay), - onClick: this.handleOverlayOnClick }, - _react2.default.createElement( - 'div', - _extends({ - ref: this.setContentRef, - style: _extends({}, contentStyles, this.props.style.content), - className: this.buildClassName('content', className), - tabIndex: '-1', - onKeyDown: this.handleKeyDown, - onMouseDown: this.handleContentOnMouseDown, - onClick: this.handleContentOnClick, - role: this.props.role, - 'aria-label': this.props.contentLabel - }, this.ariaAttributes(this.props.aria || {})), - this.props.children - ) - ); - } - }]); - - return ModalPortal; - }(_react.Component); - - ModalPortal.defaultProps = { - style: { - overlay: {}, - content: {} - } - }; - ModalPortal.propTypes = { - isOpen: _propTypes.PropTypes.bool.isRequired, - defaultStyles: _propTypes.PropTypes.shape({ - content: _propTypes.PropTypes.object, - overlay: _propTypes.PropTypes.object - }), - style: _propTypes.PropTypes.shape({ - content: _propTypes.PropTypes.object, - overlay: _propTypes.PropTypes.object - }), - className: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.object]), - overlayClassName: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.object]), - bodyOpenClassName: _propTypes.PropTypes.string, - ariaHideApp: _propTypes.PropTypes.bool, - appElement: _propTypes.PropTypes.instanceOf(_safeHTMLElement2.default), - onAfterOpen: _propTypes.PropTypes.func, - onRequestClose: _propTypes.PropTypes.func, - closeTimeoutMS: _propTypes.PropTypes.number, - shouldFocusAfterRender: _propTypes.PropTypes.bool, - shouldCloseOnOverlayClick: _propTypes.PropTypes.bool, - role: _propTypes.PropTypes.string, - contentLabel: _propTypes.PropTypes.string, - aria: _propTypes.PropTypes.object, - children: _propTypes.PropTypes.node - }; - exports.default = ModalPortal; - module.exports = exports['default']; + _createClass(Modal, [{ + key: 'componentDidMount', + value: function componentDidMount() { + this.node = document.createElement('div'); + this.node.className = this.props.portalClassName; + + var parent = getParentElement(this.props.parentSelector); + parent.appendChild(this.node); + + this.renderPortal(this.props); + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(newProps) { + var isOpen = newProps.isOpen; + // Stop unnecessary renders if modal is remaining closed + + if (!this.props.isOpen && !isOpen) return; + + var currentParent = getParentElement(this.props.parentSelector); + var newParent = getParentElement(newProps.parentSelector); + + if (newParent !== currentParent) { + currentParent.removeChild(this.node); + newParent.appendChild(this.node); + } + + this.renderPortal(newProps); + } + }, { + key: 'componentWillUpdate', + value: function componentWillUpdate(newProps) { + if (newProps.portalClassName !== this.props.portalClassName) { + this.node.className = newProps.portalClassName; + } + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + if (!this.node || !this.portal) return; + + var state = this.portal.state; + var now = Date.now(); + var closesAt = state.isOpen && this.props.closeTimeoutMS && (state.closesAt || now + this.props.closeTimeoutMS); + + if (closesAt) { + if (!state.beforeClose) { + this.portal.closeWithTimeout(); + } + + setTimeout(this.removePortal, closesAt - now); + } else { + this.removePortal(); + } + } + }, { + key: 'render', + value: function render() { + return null; + } + }], [{ + key: 'setAppElement', + value: function setAppElement(element) { + ariaAppHider.setElement(element); + } + + /* eslint-disable no-console */ + + }, { + key: 'injectCSS', + value: function injectCSS() { + undefined !== "production" && console.warn('React-Modal: injectCSS has been deprecated ' + 'and no longer has any effect. It will be removed in a later version'); + } + /* eslint-enable no-console */ + + /* eslint-disable react/no-unused-prop-types */ + + /* eslint-enable react/no-unused-prop-types */ + + }]); + + return Modal; +}(_react.Component); + +Modal.propTypes = { + isOpen: _propTypes2.default.bool.isRequired, + style: _propTypes2.default.shape({ + content: _propTypes2.default.object, + overlay: _propTypes2.default.object + }), + portalClassName: _propTypes2.default.string, + bodyOpenClassName: _propTypes2.default.string, + className: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + overlayClassName: _propTypes2.default.oneOfType([_propTypes2.default.string, _propTypes2.default.object]), + appElement: _propTypes2.default.instanceOf(_safeHTMLElement2.default), + onAfterOpen: _propTypes2.default.func, + onRequestClose: _propTypes2.default.func, + closeTimeoutMS: _propTypes2.default.number, + ariaHideApp: _propTypes2.default.bool, + shouldFocusAfter: _propTypes2.default.bool, + shouldCloseOnOverlayClick: _propTypes2.default.bool, + parentSelector: _propTypes2.default.func, + aria: _propTypes2.default.object, + role: _propTypes2.default.string, + contentLabel: _propTypes2.default.string +}; +Modal.defaultProps = { + isOpen: false, + portalClassName: portalClassName, + bodyOpenClassName: bodyOpenClassName, + ariaHideApp: true, + closeTimeoutMS: 0, + shouldFocusAfterRender: true, + shouldCloseOnOverlayClick: true, + parentSelector: function parentSelector() { + return document.body; + } +}; +Modal.defaultStyles = { + overlay: { + position: 'fixed', + top: 0, + left: 0, + right: 0, + bottom: 0, + backgroundColor: 'rgba(255, 255, 255, 0.75)' + }, + content: { + position: 'absolute', + top: '40px', + left: '40px', + right: '40px', + bottom: '40px', + border: '1px solid #ccc', + background: '#fff', + overflow: 'auto', + WebkitOverflowScrolling: 'touch', + borderRadius: '4px', + outline: 'none', + padding: '20px' + } +}; +exports.default = Modal; + +/***/ }), +/* 12 */ +/***/ (function(module, exports) { + +module.exports = __WEBPACK_EXTERNAL_MODULE_12__; /***/ }), /* 13 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var emptyFunction = __webpack_require__(0); +var invariant = __webpack_require__(1); +var warning = __webpack_require__(5); +var assign = __webpack_require__(14); + +var ReactPropTypesSecret = __webpack_require__(2); +var checkPropTypes = __webpack_require__(15); + +module.exports = function(isValidElement, throwOnDirectAccess) { + /* global Symbol */ + var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator; + var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec. + + /** + * Returns the iterator method function contained on the iterable object. + * + * Be sure to invoke the function with the iterable as context: + * + * var iteratorFn = getIteratorFn(myIterable); + * if (iteratorFn) { + * var iterator = iteratorFn.call(myIterable); + * ... + * } + * + * @param {?object} maybeIterable + * @return {?function} + */ + function getIteratorFn(maybeIterable) { + var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]); + if (typeof iteratorFn === 'function') { + return iteratorFn; + } + } + + /** + * Collection of methods that allow declaration and validation of props that are + * supplied to React components. Example usage: + * + * var Props = require('ReactPropTypes'); + * var MyArticle = React.createClass({ + * propTypes: { + * // An optional string prop named "description". + * description: Props.string, + * + * // A required enum prop named "category". + * category: Props.oneOf(['News','Photos']).isRequired, + * + * // A prop named "dialog" that requires an instance of Dialog. + * dialog: Props.instanceOf(Dialog).isRequired + * }, + * render: function() { ... } + * }); + * + * A more formal specification of how these methods are used: + * + * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...) + * decl := ReactPropTypes.{type}(.isRequired)? + * + * Each and every declaration produces a function with the same signature. This + * allows the creation of custom validation functions. For example: + * + * var MyLink = React.createClass({ + * propTypes: { + * // An optional string or URI prop named "href". + * href: function(props, propName, componentName) { + * var propValue = props[propName]; + * if (propValue != null && typeof propValue !== 'string' && + * !(propValue instanceof URI)) { + * return new Error( + * 'Expected a string or an URI for ' + propName + ' in ' + + * componentName + * ); + * } + * } + * }, + * render: function() {...} + * }); + * + * @internal + */ + + var ANONYMOUS = '<>'; + + // Important! + // Keep this list in sync with production version in `./factoryWithThrowingShims.js`. + var ReactPropTypes = { + array: createPrimitiveTypeChecker('array'), + bool: createPrimitiveTypeChecker('boolean'), + func: createPrimitiveTypeChecker('function'), + number: createPrimitiveTypeChecker('number'), + object: createPrimitiveTypeChecker('object'), + string: createPrimitiveTypeChecker('string'), + symbol: createPrimitiveTypeChecker('symbol'), + + any: createAnyTypeChecker(), + arrayOf: createArrayOfTypeChecker, + element: createElementTypeChecker(), + instanceOf: createInstanceTypeChecker, + node: createNodeChecker(), + objectOf: createObjectOfTypeChecker, + oneOf: createEnumTypeChecker, + oneOfType: createUnionTypeChecker, + shape: createShapeTypeChecker, + exact: createStrictShapeTypeChecker, + }; + + /** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ + /*eslint-disable no-self-compare*/ + function is(x, y) { + // SameValue algorithm + if (x === y) { + // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return x !== 0 || 1 / x === 1 / y; + } else { + // Step 6.a: NaN == NaN + return x !== x && y !== y; + } + } + /*eslint-enable no-self-compare*/ + + /** + * We use an Error-like object for backward compatibility as people may call + * PropTypes directly and inspect their output. However, we don't use real + * Errors anymore. We don't inspect their stack anyway, and creating them + * is prohibitively expensive if they are created too often, such as what + * happens in oneOfType() for any type before the one that matched. + */ + function PropTypeError(message) { + this.message = message; + this.stack = ''; + } + // Make `instanceof Error` still work for returned errors. + PropTypeError.prototype = Error.prototype; + + function createChainableTypeChecker(validate) { + if (undefined !== 'production') { + var manualPropTypeCallCache = {}; + var manualPropTypeWarningCount = 0; + } + function checkType(isRequired, props, propName, componentName, location, propFullName, secret) { + componentName = componentName || ANONYMOUS; + propFullName = propFullName || propName; + + if (secret !== ReactPropTypesSecret) { + if (throwOnDirectAccess) { + // New behavior only for users of `prop-types` package + invariant( + false, + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use `PropTypes.checkPropTypes()` to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + } else if (undefined !== 'production' && typeof console !== 'undefined') { + // Old behavior for people using React.PropTypes + var cacheKey = componentName + ':' + propName; + if ( + !manualPropTypeCallCache[cacheKey] && + // Avoid spamming the console because they are often not actionable except for lib authors + manualPropTypeWarningCount < 3 + ) { + warning( + false, + 'You are manually calling a React.PropTypes validation ' + + 'function for the `%s` prop on `%s`. This is deprecated ' + + 'and will throw in the standalone `prop-types` package. ' + + 'You may be seeing this warning due to a third-party PropTypes ' + + 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.', + propFullName, + componentName + ); + manualPropTypeCallCache[cacheKey] = true; + manualPropTypeWarningCount++; + } + } + } + if (props[propName] == null) { + if (isRequired) { + if (props[propName] === null) { + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.')); + } + return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.')); + } + return null; + } else { + return validate(props, propName, componentName, location, propFullName); + } + } + + var chainedCheckType = checkType.bind(null, false); + chainedCheckType.isRequired = checkType.bind(null, true); + + return chainedCheckType; + } + + function createPrimitiveTypeChecker(expectedType) { + function validate(props, propName, componentName, location, propFullName, secret) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== expectedType) { + // `propValue` being instance of, say, date/regexp, pass the 'object' + // check, but we can offer a more precise error message here rather than + // 'of type `object`'. + var preciseType = getPreciseType(propValue); + + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createAnyTypeChecker() { + return createChainableTypeChecker(emptyFunction.thatReturnsNull); + } + + function createArrayOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.'); + } + var propValue = props[propName]; + if (!Array.isArray(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.')); + } + for (var i = 0; i < propValue.length; i++) { + var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createElementTypeChecker() { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + if (!isValidElement(propValue)) { + var propType = getPropType(propValue); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createInstanceTypeChecker(expectedClass) { + function validate(props, propName, componentName, location, propFullName) { + if (!(props[propName] instanceof expectedClass)) { + var expectedClassName = expectedClass.name || ANONYMOUS; + var actualClassName = getClassName(props[propName]); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createEnumTypeChecker(expectedValues) { + if (!Array.isArray(expectedValues)) { + undefined !== 'production' ? warning(false, 'Invalid argument supplied to oneOf, expected an instance of array.') : void 0; + return emptyFunction.thatReturnsNull; + } + + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + for (var i = 0; i < expectedValues.length; i++) { + if (is(propValue, expectedValues[i])) { + return null; + } + } + + var valuesString = JSON.stringify(expectedValues); + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.')); + } + return createChainableTypeChecker(validate); + } + + function createObjectOfTypeChecker(typeChecker) { + function validate(props, propName, componentName, location, propFullName) { + if (typeof typeChecker !== 'function') { + return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.'); + } + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.')); + } + for (var key in propValue) { + if (propValue.hasOwnProperty(key)) { + var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error instanceof Error) { + return error; + } + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createUnionTypeChecker(arrayOfTypeCheckers) { + if (!Array.isArray(arrayOfTypeCheckers)) { + undefined !== 'production' ? warning(false, 'Invalid argument supplied to oneOfType, expected an instance of array.') : void 0; + return emptyFunction.thatReturnsNull; + } + + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (typeof checker !== 'function') { + warning( + false, + 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' + + 'received %s at index %s.', + getPostfixForTypeWarning(checker), + i + ); + return emptyFunction.thatReturnsNull; + } + } + + function validate(props, propName, componentName, location, propFullName) { + for (var i = 0; i < arrayOfTypeCheckers.length; i++) { + var checker = arrayOfTypeCheckers[i]; + if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) { + return null; + } + } + + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.')); + } + return createChainableTypeChecker(validate); + } + + function createNodeChecker() { + function validate(props, propName, componentName, location, propFullName) { + if (!isNode(props[propName])) { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.')); + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + for (var key in shapeTypes) { + var checker = shapeTypes[key]; + if (!checker) { + continue; + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + return createChainableTypeChecker(validate); + } + + function createStrictShapeTypeChecker(shapeTypes) { + function validate(props, propName, componentName, location, propFullName) { + var propValue = props[propName]; + var propType = getPropType(propValue); + if (propType !== 'object') { + return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.')); + } + // We need to check all keys in case some are required but missing from + // props. + var allKeys = assign({}, props[propName], shapeTypes); + for (var key in allKeys) { + var checker = shapeTypes[key]; + if (!checker) { + return new PropTypeError( + 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' + + '\nBad object: ' + JSON.stringify(props[propName], null, ' ') + + '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ') + ); + } + var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret); + if (error) { + return error; + } + } + return null; + } + + return createChainableTypeChecker(validate); + } + + function isNode(propValue) { + switch (typeof propValue) { + case 'number': + case 'string': + case 'undefined': + return true; + case 'boolean': + return !propValue; + case 'object': + if (Array.isArray(propValue)) { + return propValue.every(isNode); + } + if (propValue === null || isValidElement(propValue)) { + return true; + } + + var iteratorFn = getIteratorFn(propValue); + if (iteratorFn) { + var iterator = iteratorFn.call(propValue); + var step; + if (iteratorFn !== propValue.entries) { + while (!(step = iterator.next()).done) { + if (!isNode(step.value)) { + return false; + } + } + } else { + // Iterator will provide entry [k,v] tuples rather than values. + while (!(step = iterator.next()).done) { + var entry = step.value; + if (entry) { + if (!isNode(entry[1])) { + return false; + } + } + } + } + } else { + return false; + } + + return true; + default: + return false; + } + } + + function isSymbol(propType, propValue) { + // Native Symbol. + if (propType === 'symbol') { + return true; + } + + // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol' + if (propValue['@@toStringTag'] === 'Symbol') { + return true; + } + + // Fallback for non-spec compliant Symbols which are polyfilled. + if (typeof Symbol === 'function' && propValue instanceof Symbol) { + return true; + } + + return false; + } + + // Equivalent of `typeof` but with special handling for array and regexp. + function getPropType(propValue) { + var propType = typeof propValue; + if (Array.isArray(propValue)) { + return 'array'; + } + if (propValue instanceof RegExp) { + // Old webkits (at least until Android 4.0) return 'function' rather than + // 'object' for typeof a RegExp. We'll normalize this here so that /bla/ + // passes PropTypes.object. + return 'object'; + } + if (isSymbol(propType, propValue)) { + return 'symbol'; + } + return propType; + } + + // This handles more types than `getPropType`. Only used for error messages. + // See `createPrimitiveTypeChecker`. + function getPreciseType(propValue) { + if (typeof propValue === 'undefined' || propValue === null) { + return '' + propValue; + } + var propType = getPropType(propValue); + if (propType === 'object') { + if (propValue instanceof Date) { + return 'date'; + } else if (propValue instanceof RegExp) { + return 'regexp'; + } + } + return propType; + } + + // Returns a string that is postfixed to a warning about an invalid type. + // For example, "undefined" or "of type array" + function getPostfixForTypeWarning(value) { + var type = getPreciseType(value); + switch (type) { + case 'array': + case 'object': + return 'an ' + type; + case 'boolean': + case 'date': + case 'regexp': + return 'a ' + type; + default: + return type; + } + } + + // Returns class name of the object, if any. + function getClassName(propValue) { + if (!propValue.constructor || !propValue.constructor.name) { + return ANONYMOUS; + } + return propValue.constructor.name; + } + + ReactPropTypes.checkPropTypes = checkPropTypes; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.handleBlur = handleBlur; - exports.handleFocus = handleFocus; - exports.markForFocusLater = markForFocusLater; - exports.returnFocus = returnFocus; - exports.setupScopedFocus = setupScopedFocus; - exports.teardownScopedFocus = teardownScopedFocus; - var _tabbable = __webpack_require__(14); - - var _tabbable2 = _interopRequireDefault(_tabbable); +/***/ }), +/* 14 */ +/***/ (function(module, exports, __webpack_require__) { - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +"use strict"; +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ - var focusLaterElements = []; - var modalElement = null; - var needToFocus = false; - function handleBlur() { - needToFocus = true; - } +/* eslint-disable no-unused-vars */ +var getOwnPropertySymbols = Object.getOwnPropertySymbols; +var hasOwnProperty = Object.prototype.hasOwnProperty; +var propIsEnumerable = Object.prototype.propertyIsEnumerable; - function handleFocus() { - if (needToFocus) { - needToFocus = false; - if (!modalElement) { - return; - } - // need to see how jQuery shims document.on('focusin') so we don't need the - // setTimeout, firefox doesn't support focusin, if it did, we could focus - // the element outside of a setTimeout. Side-effect of this implementation - // is that the document.body gets focus, and then we focus our element right - // after, seems fine. - setTimeout(function () { - if (modalElement.contains(document.activeElement)) { - return; - } - var el = (0, _tabbable2.default)(modalElement)[0] || modalElement; - el.focus(); - }, 0); - } +function toObject(val) { + if (val === null || val === undefined) { + throw new TypeError('Object.assign cannot be called with null or undefined'); } - function markForFocusLater() { - focusLaterElements.push(document.activeElement); - } + return Object(val); +} - /* eslint-disable no-console */ - function returnFocus() { - var toFocus = null; - try { - toFocus = focusLaterElements.pop(); - toFocus.focus(); - return; - } catch (e) { - console.warn(['You tried to return focus to', toFocus, 'but it is not in the DOM anymore'].join(" ")); - } - } - /* eslint-enable no-console */ - - function setupScopedFocus(element) { - modalElement = element; - - if (window.addEventListener) { - window.addEventListener('blur', handleBlur, false); - document.addEventListener('focus', handleFocus, true); - } else { - window.attachEvent('onBlur', handleBlur); - document.attachEvent('onFocus', handleFocus); - } - } +function shouldUseNative() { + try { + if (!Object.assign) { + return false; + } - function teardownScopedFocus() { - modalElement = null; + // Detect buggy property enumeration order in older V8 versions. - if (window.addEventListener) { - window.removeEventListener('blur', handleBlur); - document.removeEventListener('focus', handleFocus); - } else { - window.detachEvent('onBlur', handleBlur); - document.detachEvent('onFocus', handleFocus); - } - } + // https://bugs.chromium.org/p/v8/issues/detail?id=4118 + var test1 = new String('abc'); // eslint-disable-line no-new-wrappers + test1[5] = 'de'; + if (Object.getOwnPropertyNames(test1)[0] === '5') { + return false; + } -/***/ }), -/* 14 */ -/***/ (function(module, exports) { + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test2 = {}; + for (var i = 0; i < 10; i++) { + test2['_' + String.fromCharCode(i)] = i; + } + var order2 = Object.getOwnPropertyNames(test2).map(function (n) { + return test2[n]; + }); + if (order2.join('') !== '0123456789') { + return false; + } - 'use strict'; + // https://bugs.chromium.org/p/v8/issues/detail?id=3056 + var test3 = {}; + 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { + test3[letter] = letter; + }); + if (Object.keys(Object.assign({}, test3)).join('') !== + 'abcdefghijklmnopqrst') { + return false; + } - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = findTabbableDescendants; - /*! - * Adapted from jQuery UI core - * - * http://jqueryui.com - * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/ui-core/ - */ - - var tabbableNode = /input|select|textarea|button|object/; - - function hidden(el) { - return el.offsetWidth <= 0 && el.offsetHeight <= 0 || el.style.display === 'none'; + return true; + } catch (err) { + // We don't expect any of the above to throw, but better to be safe. + return false; } +} - function visible(element) { - var parentElement = element; - while (parentElement) { - if (parentElement === document.body) break; - if (hidden(parentElement)) return false; - parentElement = parentElement.parentNode; - } - return true; - } +module.exports = shouldUseNative() ? Object.assign : function (target, source) { + var from; + var to = toObject(target); + var symbols; - function focusable(element, isTabIndexNotNaN) { - var nodeName = element.nodeName.toLowerCase(); - var res = tabbableNode.test(nodeName) && !element.disabled || (nodeName === "a" ? element.href || isTabIndexNotNaN : isTabIndexNotNaN); - return res && visible(element); - } + for (var s = 1; s < arguments.length; s++) { + from = Object(arguments[s]); - function tabbable(element) { - var tabIndex = element.getAttribute('tabindex'); - if (tabIndex === null) tabIndex = undefined; - var isTabIndexNaN = isNaN(tabIndex); - return (isTabIndexNaN || tabIndex >= 0) && focusable(element, !isTabIndexNaN); - } + for (var key in from) { + if (hasOwnProperty.call(from, key)) { + to[key] = from[key]; + } + } - function findTabbableDescendants(element) { - return [].slice.call(element.querySelectorAll('*'), 0).filter(tabbable); + if (getOwnPropertySymbols) { + symbols = getOwnPropertySymbols(from); + for (var i = 0; i < symbols.length; i++) { + if (propIsEnumerable.call(from, symbols[i])) { + to[symbols[i]] = from[symbols[i]]; + } + } + } } - module.exports = exports['default']; + + return to; +}; + /***/ }), /* 15 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +if (undefined !== 'production') { + var invariant = __webpack_require__(1); + var warning = __webpack_require__(5); + var ReactPropTypesSecret = __webpack_require__(2); + var loggedTypeFailures = {}; +} + +/** + * Assert that the values match with the type specs. + * Error messages are memorized and will only be shown once. + * + * @param {object} typeSpecs Map of name to a ReactPropType + * @param {object} values Runtime values that need to be type-checked + * @param {string} location e.g. "prop", "context", "child context" + * @param {string} componentName Name of the component for error messages. + * @param {?Function} getStack Returns the component stack. + * @private + */ +function checkPropTypes(typeSpecs, values, location, componentName, getStack) { + if (undefined !== 'production') { + for (var typeSpecName in typeSpecs) { + if (typeSpecs.hasOwnProperty(typeSpecName)) { + var error; + // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + invariant(typeof typeSpecs[typeSpecName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'the `prop-types` package, but received `%s`.', componentName || 'React class', location, typeSpecName, typeof typeSpecs[typeSpecName]); + error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret); + } catch (ex) { + error = ex; + } + warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', location, typeSpecName, typeof error); + if (error instanceof Error && !(error.message in loggedTypeFailures)) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error.message] = true; + + var stack = getStack ? getStack() : ''; + + warning(false, 'Failed %s type: %s%s', location, error.message, stack != null ? stack : ''); + } + } + } + } +} + +module.exports = checkPropTypes; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = scopeTab; - - var _tabbable = __webpack_require__(14); - - var _tabbable2 = _interopRequireDefault(_tabbable); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function scopeTab(node, event) { - var tabbable = (0, _tabbable2.default)(node); - if (!tabbable.length) { - event.preventDefault(); - return; - } - var finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]; - var leavingFinalTabbable = finalTabbable === document.activeElement || - // handle immediate shift+tab after opening with mouse - node === document.activeElement; - if (!leavingFinalTabbable) return; - event.preventDefault(); - var target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]; - target.focus(); - } - module.exports = exports['default']; /***/ }), /* 16 */ -/***/ (function(module, exports) { +/***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + + + +var emptyFunction = __webpack_require__(0); +var invariant = __webpack_require__(1); +var ReactPropTypesSecret = __webpack_require__(2); + +module.exports = function() { + function shim(props, propName, componentName, location, propFullName, secret) { + if (secret === ReactPropTypesSecret) { + // It is still safe when called from React. + return; + } + invariant( + false, + 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + + 'Use PropTypes.checkPropTypes() to call them. ' + + 'Read more at http://fb.me/use-check-prop-types' + ); + }; + shim.isRequired = shim; + function getShim() { + return shim; + }; + // Important! + // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. + var ReactPropTypes = { + array: shim, + bool: shim, + func: shim, + number: shim, + object: shim, + string: shim, + symbol: shim, + + any: shim, + arrayOf: getShim, + element: shim, + instanceOf: getShim, + node: shim, + objectOf: getShim, + oneOf: getShim, + oneOfType: getShim, + shape: getShim, + exact: getShim + }; + + ReactPropTypes.checkPropTypes = emptyFunction; + ReactPropTypes.PropTypes = ReactPropTypes; + + return ReactPropTypes; +}; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.assertNodeList = assertNodeList; - exports.setElement = setElement; - exports.tryForceFallback = tryForceFallback; - exports.validateElement = validateElement; - exports.hide = hide; - exports.show = show; - exports.documentNotReadyOrSSRTesting = documentNotReadyOrSSRTesting; - exports.resetForTesting = resetForTesting; - var globalElement = null; - - function assertNodeList(nodeList, selector) { - if (!nodeList || !nodeList.length) { - throw new Error('react-modal: No elements were found for selector ' + selector + '.'); - } - } - function setElement(element) { - var useElement = element; - if (typeof useElement === 'string') { - var el = document.querySelectorAll(useElement); - assertNodeList(el, useElement); - useElement = 'length' in el ? el[0] : el; - } - globalElement = useElement || globalElement; - return globalElement; - } +/***/ }), +/* 17 */ +/***/ (function(module, exports, __webpack_require__) { - function tryForceFallback() { - if (document && document.body) { - // force fallback to document.body - setElement(document.body); - return true; - } - return false; - } +"use strict"; - function validateElement(appElement) { - if (!appElement && !globalElement && !tryForceFallback()) { - throw new Error(['react-modal: Cannot fallback to `document.body`, because it\'s not ready or available.', 'If you are doing server-side rendering, use this function to defined an element.', '`Modal.setAppElement(el)` to make this accessible']); - } - } - function hide(appElement) { - validateElement(appElement); - (appElement || globalElement).setAttribute('aria-hidden', 'true'); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); - function show(appElement) { - validateElement(appElement); - (appElement || globalElement).removeAttribute('aria-hidden'); - } +var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; - function documentNotReadyOrSSRTesting() { - globalElement = null; - } +var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; - function resetForTesting() { - globalElement = document.body; - } +var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); -/***/ }), -/* 17 */ -/***/ (function(module, exports) { +var _react = __webpack_require__(3); - "use strict"; +var _react2 = _interopRequireDefault(_react); - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.get = get; - exports.add = add; - exports.remove = remove; - exports.totalCount = totalCount; - var classListMap = {}; +var _propTypes = __webpack_require__(4); - function get() { - return classListMap; - } +var _focusManager = __webpack_require__(18); - function add(bodyClass) { - // Set variable and default if none - if (!classListMap[bodyClass]) { - classListMap[bodyClass] = 0; - } - classListMap[bodyClass] += 1; - return bodyClass; - } +var focusManager = _interopRequireWildcard(_focusManager); - function remove(bodyClass) { - if (classListMap[bodyClass]) { - classListMap[bodyClass] -= 1; - } - return bodyClass; - } +var _scopeTab = __webpack_require__(19); - function totalCount() { - return Object.keys(classListMap).reduce(function (acc, curr) { - return acc + classListMap[curr]; - }, 0); - } +var _scopeTab2 = _interopRequireDefault(_scopeTab); + +var _ariaAppHider = __webpack_require__(7); + +var ariaAppHider = _interopRequireWildcard(_ariaAppHider); + +var _refCount = __webpack_require__(8); + +var refCount = _interopRequireWildcard(_refCount); + +var _bodyClassList = __webpack_require__(20); + +var bodyClassList = _interopRequireWildcard(_bodyClassList); + +var _safeHTMLElement = __webpack_require__(9); + +var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement); + +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 }; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } + +// so that our CSS is statically analyzable +var CLASS_NAMES = { + overlay: 'ReactModal__Overlay', + content: 'ReactModal__Content' +}; + +var TAB_KEY = 9; +var ESC_KEY = 27; + +var ModalPortal = function (_Component) { + _inherits(ModalPortal, _Component); + + function ModalPortal(props) { + _classCallCheck(this, ModalPortal); + + var _this = _possibleConstructorReturn(this, (ModalPortal.__proto__ || Object.getPrototypeOf(ModalPortal)).call(this, props)); + + _this.setFocusAfterRender = function (focus) { + _this.focusAfterRender = _this.props.shouldFocusAfterRender && focus; + }; + + _this.setOverlayRef = function (overlay) { + _this.overlay = overlay; + }; + + _this.setContentRef = function (content) { + _this.content = content; + }; + + _this.afterClose = function () { + focusManager.returnFocus(); + focusManager.teardownScopedFocus(); + }; + + _this.open = function () { + _this.beforeOpen(); + if (_this.state.afterOpen && _this.state.beforeClose) { + clearTimeout(_this.closeTimer); + _this.setState({ beforeClose: false }); + } else { + focusManager.setupScopedFocus(_this.node); + focusManager.markForFocusLater(); + _this.setState({ isOpen: true }, function () { + _this.setState({ afterOpen: true }); + + if (_this.props.isOpen && _this.props.onAfterOpen) { + _this.props.onAfterOpen(); + } + }); + } + }; + + _this.close = function () { + _this.beforeClose(); + if (_this.props.closeTimeoutMS > 0) { + _this.closeWithTimeout(); + } else { + _this.closeWithoutTimeout(); + } + }; + + _this.focusContent = function () { + return _this.content && !_this.contentHasFocus() && _this.content.focus(); + }; + + _this.closeWithTimeout = function () { + var closesAt = Date.now() + _this.props.closeTimeoutMS; + _this.setState({ beforeClose: true, closesAt: closesAt }, function () { + _this.closeTimer = setTimeout(_this.closeWithoutTimeout, _this.state.closesAt - Date.now()); + }); + }; + + _this.closeWithoutTimeout = function () { + _this.setState({ + beforeClose: false, + isOpen: false, + afterOpen: false, + closesAt: null + }, _this.afterClose); + }; + + _this.handleKeyDown = function (event) { + if (event.keyCode === TAB_KEY) { + (0, _scopeTab2.default)(_this.content, event); + } + if (event.keyCode === ESC_KEY) { + event.preventDefault(); + _this.requestClose(event); + } + }; + + _this.handleOverlayOnClick = function (event) { + if (_this.shouldClose === null) { + _this.shouldClose = true; + } + + if (_this.shouldClose && _this.props.shouldCloseOnOverlayClick) { + if (_this.ownerHandlesClose()) { + _this.requestClose(event); + } else { + _this.focusContent(); + } + } + _this.shouldClose = null; + }; + + _this.handleContentOnClick = function () { + _this.shouldClose = false; + }; + + _this.handleContentOnMouseDown = function () { + _this.shouldClose = false; + }; + + _this.requestClose = function (event) { + return _this.ownerHandlesClose() && _this.props.onRequestClose(event); + }; + + _this.ownerHandlesClose = function () { + return _this.props.onRequestClose; + }; + + _this.shouldBeClosed = function () { + return !_this.state.isOpen && !_this.state.beforeClose; + }; + + _this.contentHasFocus = function () { + return document.activeElement === _this.content || _this.content.contains(document.activeElement); + }; + + _this.buildClassName = function (which, additional) { + var classNames = (typeof additional === 'undefined' ? 'undefined' : _typeof(additional)) === 'object' ? additional : { + base: CLASS_NAMES[which], + afterOpen: CLASS_NAMES[which] + '--after-open', + beforeClose: CLASS_NAMES[which] + '--before-close' + }; + var className = classNames.base; + if (_this.state.afterOpen) { + className = className + ' ' + classNames.afterOpen; + } + if (_this.state.beforeClose) { + className = className + ' ' + classNames.beforeClose; + } + return typeof additional === 'string' && additional ? className + ' ' + additional : className; + }; + + _this.ariaAttributes = function (items) { + return Object.keys(items).reduce(function (acc, name) { + acc['aria-' + name] = items[name]; + return acc; + }, {}); + }; + + _this.state = { + afterOpen: false, + beforeClose: false + }; + + _this.shouldClose = null; + return _this; + } + + _createClass(ModalPortal, [{ + key: 'componentDidMount', + value: function componentDidMount() { + // Focus needs to be set when mounting and already open + if (this.props.isOpen) { + this.setFocusAfterRender(true); + this.open(); + } + } + }, { + key: 'componentWillReceiveProps', + value: function componentWillReceiveProps(newProps) { + if (undefined !== "production") { + if (newProps.bodyOpenClassName !== this.props.bodyOpenClassName) { + // eslint-disable-next-line no-console + console.warn('React-Modal: "bodyOpenClassName" prop has been modified. ' + 'This may cause unexpected behavior when multiple modals are open.'); + } + } + // Focus only needs to be set once when the modal is being opened + if (!this.props.isOpen && newProps.isOpen) { + this.setFocusAfterRender(true); + this.open(); + } else if (this.props.isOpen && !newProps.isOpen) { + this.close(); + } + } + }, { + key: 'componentDidUpdate', + value: function componentDidUpdate() { + if (this.focusAfterRender) { + this.focusContent(); + this.setFocusAfterRender(false); + } + } + }, { + key: 'componentWillUnmount', + value: function componentWillUnmount() { + this.beforeClose(); + clearTimeout(this.closeTimer); + } + }, { + key: 'beforeOpen', + value: function beforeOpen() { + var _props = this.props, + appElement = _props.appElement, + ariaHideApp = _props.ariaHideApp, + bodyOpenClassName = _props.bodyOpenClassName; + // Add body class + + bodyClassList.add(bodyOpenClassName); + // Add aria-hidden to appElement + if (ariaHideApp) { + ariaAppHider.hide(appElement); + } + } + }, { + key: 'beforeClose', + value: function beforeClose() { + var _props2 = this.props, + appElement = _props2.appElement, + ariaHideApp = _props2.ariaHideApp, + bodyOpenClassName = _props2.bodyOpenClassName; + // Remove class if no more modals are open + + bodyClassList.remove(bodyOpenClassName); + // Reset aria-hidden attribute if all modals have been removed + if (ariaHideApp && refCount.totalCount() < 1) { + ariaAppHider.show(appElement); + } + } + + // Don't steal focus from inner elements + + }, { + key: 'render', + value: function render() { + var _props3 = this.props, + className = _props3.className, + overlayClassName = _props3.overlayClassName, + defaultStyles = _props3.defaultStyles; + + var contentStyles = className ? {} : defaultStyles.content; + var overlayStyles = overlayClassName ? {} : defaultStyles.overlay; + + return this.shouldBeClosed() ? null : _react2.default.createElement( + 'div', + { + ref: this.setOverlayRef, + className: this.buildClassName('overlay', overlayClassName), + style: _extends({}, overlayStyles, this.props.style.overlay), + onClick: this.handleOverlayOnClick }, + _react2.default.createElement( + 'div', + _extends({ + ref: this.setContentRef, + style: _extends({}, contentStyles, this.props.style.content), + className: this.buildClassName('content', className), + tabIndex: '-1', + onKeyDown: this.handleKeyDown, + onMouseDown: this.handleContentOnMouseDown, + onClick: this.handleContentOnClick, + role: this.props.role, + 'aria-label': this.props.contentLabel + }, this.ariaAttributes(this.props.aria || {})), + this.props.children + ) + ); + } + }]); + + return ModalPortal; +}(_react.Component); + +ModalPortal.defaultProps = { + style: { + overlay: {}, + content: {} + } +}; +ModalPortal.propTypes = { + isOpen: _propTypes.PropTypes.bool.isRequired, + defaultStyles: _propTypes.PropTypes.shape({ + content: _propTypes.PropTypes.object, + overlay: _propTypes.PropTypes.object + }), + style: _propTypes.PropTypes.shape({ + content: _propTypes.PropTypes.object, + overlay: _propTypes.PropTypes.object + }), + className: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.object]), + overlayClassName: _propTypes.PropTypes.oneOfType([_propTypes.PropTypes.string, _propTypes.PropTypes.object]), + bodyOpenClassName: _propTypes.PropTypes.string, + ariaHideApp: _propTypes.PropTypes.bool, + appElement: _propTypes.PropTypes.instanceOf(_safeHTMLElement2.default), + onAfterOpen: _propTypes.PropTypes.func, + onRequestClose: _propTypes.PropTypes.func, + closeTimeoutMS: _propTypes.PropTypes.number, + shouldFocusAfterRender: _propTypes.PropTypes.bool, + shouldCloseOnOverlayClick: _propTypes.PropTypes.bool, + role: _propTypes.PropTypes.string, + contentLabel: _propTypes.PropTypes.string, + aria: _propTypes.PropTypes.object, + children: _propTypes.PropTypes.node +}; +exports.default = ModalPortal; +module.exports = exports['default']; /***/ }), /* 18 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.add = add; - exports.remove = remove; - var _refCount = __webpack_require__(17); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.handleBlur = handleBlur; +exports.handleFocus = handleFocus; +exports.markForFocusLater = markForFocusLater; +exports.returnFocus = returnFocus; +exports.setupScopedFocus = setupScopedFocus; +exports.teardownScopedFocus = teardownScopedFocus; + +var _tabbable = __webpack_require__(6); + +var _tabbable2 = _interopRequireDefault(_tabbable); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var focusLaterElements = []; +var modalElement = null; +var needToFocus = false; + +function handleBlur() { + needToFocus = true; +} + +function handleFocus() { + if (needToFocus) { + needToFocus = false; + if (!modalElement) { + return; + } + // need to see how jQuery shims document.on('focusin') so we don't need the + // setTimeout, firefox doesn't support focusin, if it did, we could focus + // the element outside of a setTimeout. Side-effect of this implementation + // is that the document.body gets focus, and then we focus our element right + // after, seems fine. + setTimeout(function () { + if (modalElement.contains(document.activeElement)) { + return; + } + var el = (0, _tabbable2.default)(modalElement)[0] || modalElement; + el.focus(); + }, 0); + } +} + +function markForFocusLater() { + focusLaterElements.push(document.activeElement); +} + +/* eslint-disable no-console */ +function returnFocus() { + var toFocus = null; + try { + toFocus = focusLaterElements.pop(); + toFocus.focus(); + return; + } catch (e) { + console.warn(['You tried to return focus to', toFocus, 'but it is not in the DOM anymore'].join(" ")); + } +} +/* eslint-enable no-console */ + +function setupScopedFocus(element) { + modalElement = element; + + if (window.addEventListener) { + window.addEventListener('blur', handleBlur, false); + document.addEventListener('focus', handleFocus, true); + } else { + window.attachEvent('onBlur', handleBlur); + document.attachEvent('onFocus', handleFocus); + } +} + +function teardownScopedFocus() { + modalElement = null; + + if (window.addEventListener) { + window.removeEventListener('blur', handleBlur); + document.removeEventListener('focus', handleFocus); + } else { + window.detachEvent('onBlur', handleBlur); + document.detachEvent('onFocus', handleFocus); + } +} - var refCount = _interopRequireWildcard(_refCount); +/***/ }), +/* 19 */ +/***/ (function(module, exports, __webpack_require__) { - 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; } } +"use strict"; - function add(bodyClass) { - // Increment class(es) on refCount tracker and add class(es) to body - bodyClass.split(' ').map(refCount.add).forEach(function (className) { - return document.body.classList.add(className); - }); - } - function remove(bodyClass) { - var classListMap = refCount.get(); - // Decrement class(es) from the refCount tracker - // and remove unused class(es) from body - bodyClass.split(' ').map(refCount.remove).filter(function (className) { - return classListMap[className] === 0; - }).forEach(function (className) { - return document.body.classList.remove(className); - }); - } +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = scopeTab; + +var _tabbable = __webpack_require__(6); + +var _tabbable2 = _interopRequireDefault(_tabbable); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +function scopeTab(node, event) { + var tabbable = (0, _tabbable2.default)(node); + if (!tabbable.length) { + event.preventDefault(); + return; + } + var finalTabbable = tabbable[event.shiftKey ? 0 : tabbable.length - 1]; + var leavingFinalTabbable = finalTabbable === document.activeElement || + // handle immediate shift+tab after opening with mouse + node === document.activeElement; + if (!leavingFinalTabbable) return; + event.preventDefault(); + var target = tabbable[event.shiftKey ? tabbable.length - 1 : 0]; + target.focus(); +} +module.exports = exports['default']; /***/ }), -/* 19 */ +/* 20 */ /***/ (function(module, exports, __webpack_require__) { - 'use strict'; +"use strict"; - Object.defineProperty(exports, "__esModule", { - value: true - }); - var _exenv = __webpack_require__(20); +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.add = add; +exports.remove = remove; - var _exenv2 = _interopRequireDefault(_exenv); +var _refCount = __webpack_require__(8); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +var refCount = _interopRequireWildcard(_refCount); - var EE = _exenv2.default; +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; } } - var SafeHTMLElement = EE.canUseDOM ? window.HTMLElement : {}; +function add(bodyClass) { + // Increment class(es) on refCount tracker and add class(es) to body + bodyClass.split(' ').map(refCount.add).forEach(function (className) { + return document.body.classList.add(className); + }); +} - exports.default = SafeHTMLElement; - module.exports = exports['default']; +function remove(bodyClass) { + var classListMap = refCount.get(); + // Decrement class(es) from the refCount tracker + // and remove unused class(es) from body + bodyClass.split(' ').map(refCount.remove).filter(function (className) { + return classListMap[className] === 0; + }).forEach(function (className) { + return document.body.classList.remove(className); + }); +} /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, exports, __webpack_require__) { - var __WEBPACK_AMD_DEFINE_RESULT__;/*! - Copyright (c) 2015 Jed Watson. - Based on code that is Copyright 2013-2015, Facebook, Inc. - All rights reserved. - */ - /* global define */ +var __WEBPACK_AMD_DEFINE_RESULT__;/*! + Copyright (c) 2015 Jed Watson. + Based on code that is Copyright 2013-2015, Facebook, Inc. + All rights reserved. +*/ +/* global define */ - (function () { - 'use strict'; +(function () { + 'use strict'; - var canUseDOM = !!( - typeof window !== 'undefined' && - window.document && - window.document.createElement - ); + var canUseDOM = !!( + typeof window !== 'undefined' && + window.document && + window.document.createElement + ); - var ExecutionEnvironment = { + var ExecutionEnvironment = { - canUseDOM: canUseDOM, + canUseDOM: canUseDOM, - canUseWorkers: typeof Worker !== 'undefined', + canUseWorkers: typeof Worker !== 'undefined', - canUseEventListeners: - canUseDOM && !!(window.addEventListener || window.attachEvent), + canUseEventListeners: + canUseDOM && !!(window.addEventListener || window.attachEvent), - canUseViewport: canUseDOM && !!window.screen + canUseViewport: canUseDOM && !!window.screen - }; + }; - if (true) { - !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { - return ExecutionEnvironment; - }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); - } else if (typeof module !== 'undefined' && module.exports) { - module.exports = ExecutionEnvironment; - } else { - window.ExecutionEnvironment = ExecutionEnvironment; - } + if (true) { + !(__WEBPACK_AMD_DEFINE_RESULT__ = function () { + return ExecutionEnvironment; + }.call(exports, __webpack_require__, exports, module), + __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); + } else if (typeof module !== 'undefined' && module.exports) { + module.exports = ExecutionEnvironment; + } else { + window.ExecutionEnvironment = ExecutionEnvironment; + } - }()); +}()); /***/ }) -/******/ ]) -}); -; \ No newline at end of file +/******/ ]); +}); \ No newline at end of file diff --git a/dist/react-modal.min.js b/dist/react-modal.min.js index 40cfd5a0..07d1cd95 100644 --- a/dist/react-modal.min.js +++ b/dist/react-modal.min.js @@ -1,17 +1,22 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactModal=t(require("react"),require("react-dom")):e.ReactModal=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),a=o(r);t.default=a.default,e.exports=t.default},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e){return e&&e.__esModule?e:{default:e}}function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function s(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){return e()}Object.defineProperty(t,"__esModule",{value:!0}),t.bodyOpenClassName=t.portalClassName=void 0;var l=Object.assign||function(e){for(var t=1;t1?t-1:0),o=1;o2?o-2:0),a=2;a0?n.closeWithTimeout():n.closeWithoutTimeout()},n.focusContent=function(){return n.content&&!n.contentHasFocus()&&n.content.focus()},n.closeWithTimeout=function(){var e=Date.now()+n.props.closeTimeoutMS;n.setState({beforeClose:!0,closesAt:e},function(){n.closeTimer=setTimeout(n.closeWithoutTimeout,n.state.closesAt-Date.now())})},n.closeWithoutTimeout=function(){n.setState({beforeClose:!1,isOpen:!1,afterOpen:!1,closesAt:null},n.afterClose)},n.handleKeyDown=function(e){e.keyCode===E&&(0,m.default)(n.content,e),e.keyCode===R&&(e.preventDefault(),n.requestClose(e))},n.handleOverlayOnClick=function(e){null===n.shouldClose&&(n.shouldClose=!0),n.shouldClose&&n.props.shouldCloseOnOverlayClick&&(n.ownerHandlesClose()?n.requestClose(e):n.focusContent()),n.shouldClose=null},n.handleContentOnClick=function(){n.shouldClose=!1},n.handleContentOnMouseDown=function(){n.shouldClose=!1},n.requestClose=function(e){return n.ownerHandlesClose()&&n.props.onRequestClose(e)},n.ownerHandlesClose=function(){return n.props.onRequestClose},n.shouldBeClosed=function(){return!n.state.isOpen&&!n.state.beforeClose},n.contentHasFocus=function(){return document.activeElement===n.content||n.content.contains(document.activeElement)},n.buildClassName=function(e,t){var o="object"===("undefined"==typeof t?"undefined":l(t))?t:{base:j[e],afterOpen:j[e]+"--after-open",beforeClose:j[e]+"--before-close"},r=o.base;return n.state.afterOpen&&(r=r+" "+o.afterOpen),n.state.beforeClose&&(r=r+" "+o.beforeClose),"string"==typeof t&&t?r+" "+t:r},n.ariaAttributes=function(e){return Object.keys(e).reduce(function(t,n){return t["aria-"+n]=e[n],t},{})},n.state={afterOpen:!1,beforeClose:!1},n.shouldClose=null,n}return s(t,e),c(t,[{key:"componentDidMount",value:function(){this.props.isOpen&&(this.setFocusAfterRender(!0),this.open())}},{key:"componentWillReceiveProps",value:function(e){e.bodyOpenClassName!==this.props.bodyOpenClassName&&console.warn('React-Modal: "bodyOpenClassName" prop has been modified. This may cause unexpected behavior when multiple modals are open.'),!this.props.isOpen&&e.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!e.isOpen&&this.close()}},{key:"componentDidUpdate",value:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))}},{key:"componentWillUnmount",value:function(){this.beforeClose(),clearTimeout(this.closeTimer)}},{key:"beforeOpen",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,o=e.bodyOpenClassName;T.add(o),n&&O.hide(t)}},{key:"beforeClose",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,o=e.bodyOpenClassName;T.remove(o),n&&C.totalCount()<1&&O.show(t)}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.overlayClassName,o=e.defaultStyles,r=t?{}:o.content,a=n?{}:o.overlay;return this.shouldBeClosed()?null:p.default.createElement("div",{ref:this.setOverlayRef,className:this.buildClassName("overlay",n),style:i({},a,this.props.style.overlay),onClick:this.handleOverlayOnClick},p.default.createElement("div",i({ref:this.setContentRef,style:i({},r,this.props.style.content),className:this.buildClassName("content",t),tabIndex:"-1",onKeyDown:this.handleKeyDown,onMouseDown:this.handleContentOnMouseDown,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.ariaAttributes(this.props.aria||{})),this.props.children))}}]),t}(f.Component);x.defaultProps={style:{overlay:{},content:{}}},x.propTypes={isOpen:d.PropTypes.bool.isRequired,defaultStyles:d.PropTypes.shape({content:d.PropTypes.object,overlay:d.PropTypes.object}),style:d.PropTypes.shape({content:d.PropTypes.object,overlay:d.PropTypes.object}),className:d.PropTypes.oneOfType([d.PropTypes.string,d.PropTypes.object]),overlayClassName:d.PropTypes.oneOfType([d.PropTypes.string,d.PropTypes.object]),bodyOpenClassName:d.PropTypes.string,ariaHideApp:d.PropTypes.bool,appElement:d.PropTypes.instanceOf(_.default),onAfterOpen:d.PropTypes.func,onRequestClose:d.PropTypes.func,closeTimeoutMS:d.PropTypes.number,shouldFocusAfterRender:d.PropTypes.bool,shouldCloseOnOverlayClick:d.PropTypes.bool,role:d.PropTypes.string,contentLabel:d.PropTypes.string,aria:d.PropTypes.object,children:d.PropTypes.node},t.default=x,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(){y=!0}function a(){if(y){if(y=!1,!d)return;setTimeout(function(){if(!d.contains(document.activeElement)){var e=(0,f.default)(d)[0]||d;e.focus()}},0)}}function u(){p.push(document.activeElement)}function s(){var e=null;try{return e=p.pop(),void e.focus()}catch(t){console.warn(["You tried to return focus to",e,"but it is not in the DOM anymore"].join(" "))}}function i(e){d=e,window.addEventListener?(window.addEventListener("blur",r,!1),document.addEventListener("focus",a,!0)):(window.attachEvent("onBlur",r),document.attachEvent("onFocus",a))}function l(){d=null,window.addEventListener?(window.removeEventListener("blur",r),document.removeEventListener("focus",a)):(window.detachEvent("onBlur",r),document.detachEvent("onFocus",a))}Object.defineProperty(t,"__esModule",{value:!0}),t.handleBlur=r,t.handleFocus=a,t.markForFocusLater=u,t.returnFocus=s,t.setupScopedFocus=i,t.teardownScopedFocus=l;var c=n(14),f=o(c),p=[],d=null,y=!1},function(e,t){"use strict";function n(e){return e.offsetWidth<=0&&e.offsetHeight<=0||"none"===e.style.display}function o(e){for(var t=e;t&&t!==document.body;){if(n(t))return!1;t=t.parentNode}return!0}function r(e,t){var n=e.nodeName.toLowerCase(),r=s.test(n)&&!e.disabled||("a"===n?e.href||t:t);return r&&o(e)}function a(e){var t=e.getAttribute("tabindex");null===t&&(t=void 0);var n=isNaN(t);return(n||t>=0)&&r(e,!n)}function u(e){return[].slice.call(e.querySelectorAll("*"),0).filter(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;/*! - * Adapted from jQuery UI core - * - * http://jqueryui.com - * - * Copyright 2014 jQuery Foundation and other contributors - * Released under the MIT license. - * http://jquery.org/license - * - * http://api.jqueryui.com/category/ui-core/ - */ -var s=/input|select|textarea|button|object/;e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=(0,u.default)(e);if(!n.length)return void t.preventDefault();var o=n[t.shiftKey?0:n.length-1],r=o===document.activeElement||e===document.activeElement;if(r){t.preventDefault();var a=n[t.shiftKey?n.length-1:0];a.focus()}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r;var a=n(14),u=o(a);e.exports=t.default},function(e,t){"use strict";function n(e,t){if(!e||!e.length)throw new Error("react-modal: No elements were found for selector "+t+".")}function o(e){var t=e;if("string"==typeof t){var o=document.querySelectorAll(t);n(o,t),t="length"in o?o[0]:o}return c=t||c}function r(){return!(!document||!document.body)&&(o(document.body),!0)}function a(e){if(!e&&!c&&!r())throw new Error(["react-modal: Cannot fallback to `document.body`, because it's not ready or available.","If you are doing server-side rendering, use this function to defined an element.","`Modal.setAppElement(el)` to make this accessible"])}function u(e){a(e),(e||c).setAttribute("aria-hidden","true")}function s(e){a(e),(e||c).removeAttribute("aria-hidden")}function i(){c=null}function l(){c=document.body}Object.defineProperty(t,"__esModule",{value:!0}),t.assertNodeList=n,t.setElement=o,t.tryForceFallback=r,t.validateElement=a,t.hide=u,t.show=s,t.documentNotReadyOrSSRTesting=i,t.resetForTesting=l;var c=null},function(e,t){"use strict";function n(){return u}function o(e){return u[e]||(u[e]=0),u[e]+=1,e}function r(e){return u[e]&&(u[e]-=1),e}function a(){return Object.keys(u).reduce(function(e,t){return e+u[t]},0)}Object.defineProperty(t,"__esModule",{value:!0}),t.get=n,t.add=o,t.remove=r,t.totalCount=a;var u={}},function(e,t,n){"use strict";function o(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function r(e){e.split(" ").map(s.add).forEach(function(e){return document.body.classList.add(e)})}function a(e){var t=s.get();e.split(" ").map(s.remove).filter(function(e){return 0===t[e]}).forEach(function(e){return document.body.classList.remove(e)})}Object.defineProperty(t,"__esModule",{value:!0}),t.add=r,t.remove=a;var u=n(17),s=o(u)},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(20),a=o(r),u=a.default,s=u.canUseDOM?window.HTMLElement:{};t.default=s,e.exports=t.default},function(e,t,n){var o;/*! - Copyright (c) 2015 Jed Watson. - Based on code that is Copyright 2013-2015, Facebook, Inc. - All rights reserved. - */ -!function(){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),a={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen};o=function(){return a}.call(t,n,t,e),!(void 0!==o&&(e.exports=o))}()}])}); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["react","react-dom"],t):"object"==typeof exports?exports.ReactModal=t(require("react"),require("react-dom")):e.ReactModal=t(e.React,e.ReactDOM)}(this,function(e,t){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=10)}([function(e,t,n){"use strict";function o(e){return function(){return e}}var r=function(){};r.thatReturns=o,r.thatReturnsFalse=o(!1),r.thatReturnsTrue=o(!0),r.thatReturnsNull=o(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";function o(e,t,n,o,a,u,i,s){if(r(t),!e){var l;if(void 0===t)l=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var c=[n,o,a,u,i,s],f=0;l=new Error(t.replace(/%s/g,function(){return c[f++]})),l.name="Invariant Violation"}throw l.framesToPop=1,l}}var r=function(e){};r=function(e){if(void 0===e)throw new Error("invariant requires an error message argument")},e.exports=o},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,n){t.exports=e},function(e,t,n){var o="function"==typeof Symbol&&Symbol.for&&Symbol.for("react.element")||60103,r=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o};e.exports=n(13)(r,!0)},function(e,t,n){"use strict";var o=n(0),r=o,a=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o2?n-2:0),r=2;r=0)&&a(e,!n)}function i(e){return[].slice.call(e.querySelectorAll("*"),0).filter(u)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;/*! + * Adapted from jQuery UI core + * + * http://jqueryui.com + * + * Copyright 2014 jQuery Foundation and other contributors + * Released under the MIT license. + * http://jquery.org/license + * + * http://api.jqueryui.com/category/ui-core/ + */ +var s=/input|select|textarea|button|object/;e.exports=t.default},function(e,t,n){"use strict";function o(e,t){if(!e||!e.length)throw new Error("react-modal: No elements were found for selector "+t+".")}function r(e){var t=e;if("string"==typeof t){var n=document.querySelectorAll(t);o(n,t),t="length"in n?n[0]:n}return f=t||f}function a(){return!(!document||!document.body)&&(r(document.body),!0)}function u(e){if(!e&&!f&&!a())throw new Error(["react-modal: Cannot fallback to `document.body`, because it's not ready or available.","If you are doing server-side rendering, use this function to defined an element.","`Modal.setAppElement(el)` to make this accessible"])}function i(e){u(e),(e||f).setAttribute("aria-hidden","true")}function s(e){u(e),(e||f).removeAttribute("aria-hidden")}function l(){f=null}function c(){f=document.body}Object.defineProperty(t,"__esModule",{value:!0}),t.assertNodeList=o,t.setElement=r,t.tryForceFallback=a,t.validateElement=u,t.hide=i,t.show=s,t.documentNotReadyOrSSRTesting=l,t.resetForTesting=c;var f=null},function(e,t,n){"use strict";function o(){return i}function r(e){return i[e]||(i[e]=0),i[e]+=1,e}function a(e){return i[e]&&(i[e]-=1),e}function u(){return Object.keys(i).reduce(function(e,t){return e+i[t]},0)}Object.defineProperty(t,"__esModule",{value:!0}),t.get=o,t.add=r,t.remove=a,t.totalCount=u;var i={}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(21),r=function(e){return e&&e.__esModule?e:{default:e}}(o),a=r.default,u=a.canUseDOM?window.HTMLElement:{};t.default=u,e.exports=t.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=n(11),r=function(e){return e&&e.__esModule?e:{default:e}}(o);t.default=r.default,e.exports=t.default},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function u(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e){return e()}Object.defineProperty(t,"__esModule",{value:!0}),t.bodyOpenClassName=t.portalClassName=void 0;var s=Object.assign||function(e){for(var t=1;t0?n.closeWithTimeout():n.closeWithoutTimeout()},n.focusContent=function(){return n.content&&!n.contentHasFocus()&&n.content.focus()},n.closeWithTimeout=function(){var e=Date.now()+n.props.closeTimeoutMS;n.setState({beforeClose:!0,closesAt:e},function(){n.closeTimer=setTimeout(n.closeWithoutTimeout,n.state.closesAt-Date.now())})},n.closeWithoutTimeout=function(){n.setState({beforeClose:!1,isOpen:!1,afterOpen:!1,closesAt:null},n.afterClose)},n.handleKeyDown=function(e){e.keyCode===E&&(0,b.default)(n.content,e),e.keyCode===S&&(e.preventDefault(),n.requestClose(e))},n.handleOverlayOnClick=function(e){null===n.shouldClose&&(n.shouldClose=!0),n.shouldClose&&n.props.shouldCloseOnOverlayClick&&(n.ownerHandlesClose()?n.requestClose(e):n.focusContent()),n.shouldClose=null},n.handleContentOnClick=function(){n.shouldClose=!1},n.handleContentOnMouseDown=function(){n.shouldClose=!1},n.requestClose=function(e){return n.ownerHandlesClose()&&n.props.onRequestClose(e)},n.ownerHandlesClose=function(){return n.props.onRequestClose},n.shouldBeClosed=function(){return!n.state.isOpen&&!n.state.beforeClose},n.contentHasFocus=function(){return document.activeElement===n.content||n.content.contains(document.activeElement)},n.buildClassName=function(e,t){var o="object"===(void 0===t?"undefined":l(t))?t:{base:_[e],afterOpen:_[e]+"--after-open",beforeClose:_[e]+"--before-close"},r=o.base;return n.state.afterOpen&&(r=r+" "+o.afterOpen),n.state.beforeClose&&(r=r+" "+o.beforeClose),"string"==typeof t&&t?r+" "+t:r},n.ariaAttributes=function(e){return Object.keys(e).reduce(function(t,n){return t["aria-"+n]=e[n],t},{})},n.state={afterOpen:!1,beforeClose:!1},n.shouldClose=null,n}return i(t,e),c(t,[{key:"componentDidMount",value:function(){this.props.isOpen&&(this.setFocusAfterRender(!0),this.open())}},{key:"componentWillReceiveProps",value:function(e){e.bodyOpenClassName!==this.props.bodyOpenClassName&&console.warn('React-Modal: "bodyOpenClassName" prop has been modified. This may cause unexpected behavior when multiple modals are open.'),!this.props.isOpen&&e.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!e.isOpen&&this.close()}},{key:"componentDidUpdate",value:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))}},{key:"componentWillUnmount",value:function(){this.beforeClose(),clearTimeout(this.closeTimer)}},{key:"beforeOpen",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,o=e.bodyOpenClassName;T.add(o),n&&O.hide(t)}},{key:"beforeClose",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,o=e.bodyOpenClassName;T.remove(o),n&&g.totalCount()<1&&O.show(t)}},{key:"render",value:function(){var e=this.props,t=e.className,n=e.overlayClassName,o=e.defaultStyles,r=t?{}:o.content,a=n?{}:o.overlay;return this.shouldBeClosed()?null:p.default.createElement("div",{ref:this.setOverlayRef,className:this.buildClassName("overlay",n),style:s({},a,this.props.style.overlay),onClick:this.handleOverlayOnClick},p.default.createElement("div",s({ref:this.setContentRef,style:s({},r,this.props.style.content),className:this.buildClassName("content",t),tabIndex:"-1",onKeyDown:this.handleKeyDown,onMouseDown:this.handleContentOnMouseDown,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.ariaAttributes(this.props.aria||{})),this.props.children))}}]),t}(f.Component);x.defaultProps={style:{overlay:{},content:{}}},x.propTypes={isOpen:d.PropTypes.bool.isRequired,defaultStyles:d.PropTypes.shape({content:d.PropTypes.object,overlay:d.PropTypes.object}),style:d.PropTypes.shape({content:d.PropTypes.object,overlay:d.PropTypes.object}),className:d.PropTypes.oneOfType([d.PropTypes.string,d.PropTypes.object]),overlayClassName:d.PropTypes.oneOfType([d.PropTypes.string,d.PropTypes.object]),bodyOpenClassName:d.PropTypes.string,ariaHideApp:d.PropTypes.bool,appElement:d.PropTypes.instanceOf(P.default),onAfterOpen:d.PropTypes.func,onRequestClose:d.PropTypes.func,closeTimeoutMS:d.PropTypes.number,shouldFocusAfterRender:d.PropTypes.bool,shouldCloseOnOverlayClick:d.PropTypes.bool,role:d.PropTypes.string,contentLabel:d.PropTypes.string,aria:d.PropTypes.object,children:d.PropTypes.node},t.default=x,e.exports=t.default},function(e,t,n){"use strict";function o(){d=!0}function r(){if(d){if(d=!1,!p)return;setTimeout(function(){if(!p.contains(document.activeElement)){((0,c.default)(p)[0]||p).focus()}},0)}}function a(){f.push(document.activeElement)}function u(){var e=null;try{return e=f.pop(),void e.focus()}catch(t){console.warn(["You tried to return focus to",e,"but it is not in the DOM anymore"].join(" "))}}function i(e){p=e,window.addEventListener?(window.addEventListener("blur",o,!1),document.addEventListener("focus",r,!0)):(window.attachEvent("onBlur",o),document.attachEvent("onFocus",r))}function s(){p=null,window.addEventListener?(window.removeEventListener("blur",o),document.removeEventListener("focus",r)):(window.detachEvent("onBlur",o),document.detachEvent("onFocus",r))}Object.defineProperty(t,"__esModule",{value:!0}),t.handleBlur=o,t.handleFocus=r,t.markForFocusLater=a,t.returnFocus=u,t.setupScopedFocus=i,t.teardownScopedFocus=s;var l=n(6),c=function(e){return e&&e.__esModule?e:{default:e}}(l),f=[],p=null,d=!1},function(e,t,n){"use strict";function o(e,t){var n=(0,a.default)(e);if(!n.length)return void t.preventDefault();n[t.shiftKey?0:n.length-1]!==document.activeElement&&e!==document.activeElement||(t.preventDefault(),n[t.shiftKey?n.length-1:0].focus())}Object.defineProperty(t,"__esModule",{value:!0}),t.default=o;var r=n(6),a=function(e){return e&&e.__esModule?e:{default:e}}(r);e.exports=t.default},function(e,t,n){"use strict";function o(e){e.split(" ").map(u.add).forEach(function(e){return document.body.classList.add(e)})}function r(e){var t=u.get();e.split(" ").map(u.remove).filter(function(e){return 0===t[e]}).forEach(function(e){return document.body.classList.remove(e)})}Object.defineProperty(t,"__esModule",{value:!0}),t.add=o,t.remove=r;var a=n(8),u=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}(a)},function(e,t,n){var o;/*! + Copyright (c) 2015 Jed Watson. + Based on code that is Copyright 2013-2015, Facebook, Inc. + All rights reserved. +*/ +!function(){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),a={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen};void 0!==(o=function(){return a}.call(t,n,t,e))&&(e.exports=o)}()}])}); \ No newline at end of file diff --git a/package.json b/package.json index 39ec4081..803a557c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "2.3.2", + "version": "2.3.3", "description": "Accessible modal dialog component for React.JS", "main": "./lib/index.js", "repository": {