diff --git a/CHANGELOG.md b/CHANGELOG.md index add8b9bc..bb250893 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +v2.2.2 - Tue, 11 Jul 2017 14:20:05 UTC +-------------------------------------- + +- [581be77](../../commit/581be77) [chore] added test for default parentSelector. +- [e56c414](../../commit/e56c414) [chore] Return null for portal when modal is closed + + v2.2.1 - Fri, 30 Jun 2017 09:21:36 UTC -------------------------------------- diff --git a/bower.json b/bower.json index bbfcac31..fdf42f8a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "2.2.1", + "version": "2.2.2", "homepage": "https://github.com/reactjs/react-modal", "authors": [ "Ryan Florence", diff --git a/dist/react-modal.js b/dist/react-modal.js index 4b4126aa..2430c800 100644 --- a/dist/react-modal.js +++ b/dist/react-modal.js @@ -99,7 +99,7 @@ return /******/ (function(modules) { // webpackBootstrap var _ModalPortal2 = _interopRequireDefault(_ModalPortal); - var _ariaAppHider = __webpack_require__(17); + var _ariaAppHider = __webpack_require__(16); var ariaAppHider = _interopRequireWildcard(_ariaAppHider); @@ -1205,26 +1205,26 @@ return /******/ (function(modules) { // webpackBootstrap var _propTypes = __webpack_require__(4); - var _elementClass = __webpack_require__(13); - - var _elementClass2 = _interopRequireDefault(_elementClass); - - var _focusManager = __webpack_require__(14); + var _focusManager = __webpack_require__(13); var focusManager = _interopRequireWildcard(_focusManager); - var _scopeTab = __webpack_require__(16); + var _scopeTab = __webpack_require__(15); var _scopeTab2 = _interopRequireDefault(_scopeTab); - var _ariaAppHider = __webpack_require__(17); + var _ariaAppHider = __webpack_require__(16); var ariaAppHider = _interopRequireWildcard(_ariaAppHider); - var _refCount = __webpack_require__(18); + var _refCount = __webpack_require__(17); var refCount = _interopRequireWildcard(_refCount); + var _bodyClassList = __webpack_require__(18); + + var bodyClassList = _interopRequireWildcard(_bodyClassList); + var _safeHTMLElement = __webpack_require__(19); var _safeHTMLElement2 = _interopRequireDefault(_safeHTMLElement); @@ -1444,10 +1444,9 @@ return /******/ (function(modules) { // webpackBootstrap appElement = _props.appElement, ariaHideApp = _props.ariaHideApp, bodyOpenClassName = _props.bodyOpenClassName; - - refCount.add(bodyOpenClassName); // Add body class - (0, _elementClass2.default)(document.body).add(bodyOpenClassName); + + bodyClassList.add(bodyOpenClassName); // Add aria-hidden to appElement if (ariaHideApp) { ariaAppHider.hide(appElement); @@ -1460,12 +1459,9 @@ return /******/ (function(modules) { // webpackBootstrap appElement = _props2.appElement, ariaHideApp = _props2.ariaHideApp, bodyOpenClassName = _props2.bodyOpenClassName; - - refCount.remove(bodyOpenClassName); // Remove class if no more modals are open - if (refCount.count(bodyOpenClassName) === 0) { - (0, _elementClass2.default)(document.body).remove(bodyOpenClassName); - } + + bodyClassList.remove(bodyOpenClassName); // Reset aria-hidden attribute if all modals have been removed if (ariaHideApp && refCount.totalCount() < 1) { ariaAppHider.show(appElement); @@ -1485,7 +1481,7 @@ return /******/ (function(modules) { // webpackBootstrap var contentStyles = className ? {} : defaultStyles.content; var overlayStyles = overlayClassName ? {} : defaultStyles.overlay; - return this.shouldBeClosed() ? _react2.default.createElement('div', null) : _react2.default.createElement( + return this.shouldBeClosed() ? null : _react2.default.createElement( 'div', { ref: this.setOverlayRef, @@ -1547,71 +1543,6 @@ return /******/ (function(modules) { // webpackBootstrap /***/ }), /* 13 */ -/***/ (function(module, exports) { - - module.exports = function(opts) { - return new ElementClass(opts) - } - - function indexOf(arr, prop) { - if (arr.indexOf) return arr.indexOf(prop) - for (var i = 0, len = arr.length; i < len; i++) - if (arr[i] === prop) return i - return -1 - } - - function ElementClass(opts) { - if (!(this instanceof ElementClass)) return new ElementClass(opts) - var self = this - if (!opts) opts = {} - - // similar doing instanceof HTMLElement but works in IE8 - if (opts.nodeType) opts = {el: opts} - - this.opts = opts - this.el = opts.el || document.body - if (typeof this.el !== 'object') this.el = document.querySelector(this.el) - } - - ElementClass.prototype.add = function(className) { - var el = this.el - if (!el) return - if (el.className === "") return el.className = className - var classes = el.className.split(' ') - if (indexOf(classes, className) > -1) return classes - classes.push(className) - el.className = classes.join(' ') - return classes - } - - ElementClass.prototype.remove = function(className) { - var el = this.el - if (!el) return - if (el.className === "") return - var classes = el.className.split(' ') - var idx = indexOf(classes, className) - if (idx > -1) classes.splice(idx, 1) - el.className = classes.join(' ') - return classes - } - - ElementClass.prototype.has = function(className) { - var el = this.el - if (!el) return - var classes = el.className.split(' ') - return indexOf(classes, className) > -1 - } - - ElementClass.prototype.toggle = function(className) { - var el = this.el - if (!el) return - if (this.has(className)) this.remove(className) - else this.add(className) - } - - -/***/ }), -/* 14 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -1626,7 +1557,7 @@ return /******/ (function(modules) { // webpackBootstrap exports.setupScopedFocus = setupScopedFocus; exports.teardownScopedFocus = teardownScopedFocus; - var _tabbable = __webpack_require__(15); + var _tabbable = __webpack_require__(14); var _tabbable2 = _interopRequireDefault(_tabbable); @@ -1703,7 +1634,7 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }), -/* 15 */ +/* 14 */ /***/ (function(module, exports) { 'use strict'; @@ -1758,7 +1689,7 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }), -/* 16 */ +/* 15 */ /***/ (function(module, exports, __webpack_require__) { 'use strict'; @@ -1768,7 +1699,7 @@ return /******/ (function(modules) { // webpackBootstrap }); exports.default = scopeTab; - var _tabbable = __webpack_require__(15); + var _tabbable = __webpack_require__(14); var _tabbable2 = _interopRequireDefault(_tabbable); @@ -1791,7 +1722,7 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }), -/* 17 */ +/* 16 */ /***/ (function(module, exports) { 'use strict'; @@ -1860,7 +1791,7 @@ return /******/ (function(modules) { // webpackBootstrap } /***/ }), -/* 18 */ +/* 17 */ /***/ (function(module, exports) { "use strict"; @@ -1868,36 +1799,74 @@ return /******/ (function(modules) { // webpackBootstrap Object.defineProperty(exports, "__esModule", { value: true }); + exports.get = get; exports.add = add; exports.remove = remove; - exports.count = count; exports.totalCount = totalCount; - var modals = {}; + var classListMap = {}; + + function get() { + return classListMap; + } function add(bodyClass) { // Set variable and default if none - if (!modals[bodyClass]) { - modals[bodyClass] = 0; + if (!classListMap[bodyClass]) { + classListMap[bodyClass] = 0; } - modals[bodyClass] += 1; + classListMap[bodyClass] += 1; + return bodyClass; } function remove(bodyClass) { - if (modals[bodyClass]) { - modals[bodyClass] -= 1; + if (classListMap[bodyClass]) { + classListMap[bodyClass] -= 1; } - } - - function count(bodyClass) { - return modals[bodyClass]; + return bodyClass; } function totalCount() { - return Object.keys(modals).reduce(function (acc, curr) { - return acc + modals[curr]; + return Object.keys(classListMap).reduce(function (acc, curr) { + return acc + classListMap[curr]; }, 0); } +/***/ }), +/* 18 */ +/***/ (function(module, exports, __webpack_require__) { + + 'use strict'; + + Object.defineProperty(exports, "__esModule", { + value: true + }); + exports.add = add; + exports.remove = remove; + + var _refCount = __webpack_require__(17); + + var refCount = _interopRequireWildcard(_refCount); + + 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 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); + }); + } + /***/ }), /* 19 */ /***/ (function(module, exports, __webpack_require__) { diff --git a/dist/react-modal.min.js b/dist/react-modal.min.js index 7e216e3d..fe8930aa 100644 --- a/dist/react-modal.min.js +++ b/dist/react-modal.min.js @@ -1,4 +1,4 @@ -!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},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 i(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 u(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,O.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.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:_[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 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),(0,v.default)(document.body).add(o),n&&C.hide(t)}},{key:"beforeClose",value:function(){var e=this.props,t=e.appElement,n=e.ariaHideApp,o=e.bodyOpenClassName;T.remove(o),0===T.count(o)&&(0,v.default)(document.body).remove(o),n&&T.totalCount()<1&&C.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()?p.default.createElement("div",null):p.default.createElement("div",{ref:this.setOverlayRef,className:this.buildClassName("overlay",n),style:u({},a,this.props.style.overlay),onClick:this.handleOverlayOnClick},p.default.createElement("div",u({ref:this.setContentRef,style:u({},r,this.props.style.content),className:this.buildClassName("content",t),tabIndex:"-1",onKeyDown:this.handleKeyDown,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.ariaAttributes(this.props.aria||{})),this.props.children))}}]),t}(f.Component);R.defaultProps={style:{overlay:{},content:{}}},R.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(j.default),onAfterOpen:d.PropTypes.func,onRequestClose:d.PropTypes.func,closeTimeoutMS:d.PropTypes.number,shouldCloseOnOverlayClick:d.PropTypes.bool,role:d.PropTypes.string,contentLabel:d.PropTypes.string,aria:d.PropTypes.object,children:d.PropTypes.node},t.default=R},function(e,t){function n(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0,o=e.length;n-1?o:(o.push(e),t.className=o.join(" "),o)}},o.prototype.remove=function(e){var t=this.el;if(t&&""!==t.className){var o=t.className.split(" "),r=n(o,e);return r>-1&&o.splice(r,1),t.className=o.join(" "),o}},o.prototype.has=function(e){var t=this.el;if(t){var o=t.className.split(" ");return n(o,e)>-1}},o.prototype.toggle=function(e){var t=this.el;t&&(this.has(e)?this.remove(e):this.add(e))}},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 i(){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 u(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=i,t.returnFocus=s,t.setupScopedFocus=u,t.teardownScopedFocus=l;var c=n(15),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 i(e){return[].slice.call(e.querySelectorAll("*"),0).filter(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;/*! +!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},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 i(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 s(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,h.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.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 u(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: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,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.ariaAttributes(this.props.aria||{})),this.props.children))}}]),t}(f.Component);S.defaultProps={style:{overlay:{},content:{}}},S.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,shouldCloseOnOverlayClick:d.PropTypes.bool,role:d.PropTypes.string,contentLabel:d.PropTypes.string,aria:d.PropTypes.object,children:d.PropTypes.node},t.default=S},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 i(){p.push(document.activeElement)}function u(){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 s(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=i,t.returnFocus=u,t.setupScopedFocus=s,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=u.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 i(e){return[].slice.call(e.querySelectorAll("*"),0).filter(a)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;/*! * Adapted from jQuery UI core * * http://jqueryui.com @@ -9,7 +9,7 @@ * * http://api.jqueryui.com/category/ui-core/ */ -var s=/input|select|textarea|button|object/},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=(0,i.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(15),i=o(a)},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 i(e){a(e),(e||c).setAttribute("aria-hidden","true")}function s(e){a(e),(e||c).removeAttribute("aria-hidden")}function u(){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=i,t.show=s,t.documentNotReadyOrSSRTesting=u,t.resetForTesting=l;var c=null},function(e,t){"use strict";function n(e){i[e]||(i[e]=0),i[e]+=1}function o(e){i[e]&&(i[e]-=1)}function r(e){return i[e]}function a(){return Object.keys(i).reduce(function(e,t){return e+i[t]},0)}Object.defineProperty(t,"__esModule",{value:!0}),t.add=n,t.remove=o,t.count=r,t.totalCount=a;var i={}},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),i=a.default,s=i.canUseDOM?window.HTMLElement:{};t.default=s},function(e,t,n){var o;/*! +var u=/input|select|textarea|button|object/},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e,t){var n=(0,i.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),i=o(a)},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 i(e){a(e),(e||c).setAttribute("aria-hidden","true")}function u(e){a(e),(e||c).removeAttribute("aria-hidden")}function s(){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=i,t.show=u,t.documentNotReadyOrSSRTesting=s,t.resetForTesting=l;var c=null},function(e,t){"use strict";function n(){return i}function o(e){return i[e]||(i[e]=0),i[e]+=1,e}function r(e){return i[e]&&(i[e]-=1),e}function a(){return Object.keys(i).reduce(function(e,t){return e+i[t]},0)}Object.defineProperty(t,"__esModule",{value:!0}),t.get=n,t.add=o,t.remove=r,t.totalCount=a;var i={}},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(u.add).forEach(function(e){return document.body.classList.add(e)})}function a(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=r,t.remove=a;var i=n(17),u=o(i)},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),i=a.default,u=i.canUseDOM?window.HTMLElement:{};t.default=u},function(e,t,n){var o;/*! Copyright (c) 2015 Jed Watson. Based on code that is Copyright 2013-2015, Facebook, Inc. All rights reserved. diff --git a/package.json b/package.json index 35f98e53..1d1a5ced 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "2.2.1", + "version": "2.2.2", "description": "Accessible modal dialog component for React.JS", "main": "./lib/index.js", "repository": {