From 975e9ab320f777ffb6d18a575f79b86766f7b910 Mon Sep 17 00:00:00 2001 From: Clay Diffrient Date: Wed, 1 Mar 2017 20:54:08 -0700 Subject: [PATCH] release v1.7.0 --- CHANGELOG.md | 7 +++++ bower.json | 2 +- dist/react-modal.js | 70 ++++++++++++++++++++++++----------------- dist/react-modal.min.js | 6 ++-- package.json | 2 +- 5 files changed, 54 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fcfb281..ba2379aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +v1.7.0 - Thu, 02 Mar 2017 03:54:08 GMT +-------------------------------------- + +- [ea4f37a](../../commit/ea4f37a) [fixed] respect closeTimeoutMS during unmount +- [4232477](../../commit/4232477) [fixed] Enable click to close in iOS (#301) (#304) (#313) + + v1.6.5 - Sat, 31 Dec 2016 17:14:28 GMT -------------------------------------- diff --git a/bower.json b/bower.json index 23fc6129..357e3e50 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "1.6.5", + "version": "1.7.0", "homepage": "https://github.com/reactjs/react-modal", "authors": [ "Ryan Florence", diff --git a/dist/react-modal.js b/dist/react-modal.js index 8e0a51f0..fe990023 100644 --- a/dist/react-modal.js +++ b/dist/react-modal.js @@ -149,12 +149,29 @@ return /******/ (function(modules) { // webpackBootstrap ariaAppHider.show(this.props.appElement); } + 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.bind(this), closesAt - now); + } else { + this.removePortal(); + } + }, + + removePortal: function removePortal() { ReactDOM.unmountComponentAtNode(this.node); var parent = getParentElement(this.props.parentSelector); parent.removeChild(this.node); elementClass(document.body).remove('ReactModal__Body--open'); }, + renderPortal: function renderPortal(props) { if (props.isOpen) { elementClass(document.body).add('ReactModal__Body--open'); @@ -338,6 +355,11 @@ return /******/ (function(modules) { // webpackBootstrap this.focusAfterRender = focus; }, + afterClose: function afterClose() { + focusManager.returnFocus(); + focusManager.teardownScopedFocus(); + }, + open: function open() { if (this.state.afterOpen && this.state.beforeClose) { clearTimeout(this.closeTimer); @@ -355,6 +377,7 @@ return /******/ (function(modules) { // webpackBootstrap } }, + close: function close() { if (this.props.closeTimeoutMS > 0) this.closeWithTimeout();else this.closeWithoutTimeout(); }, @@ -367,8 +390,9 @@ return /******/ (function(modules) { // webpackBootstrap }, closeWithTimeout: function closeWithTimeout() { - this.setState({ beforeClose: true }, function () { - this.closeTimer = setTimeout(this.closeWithoutTimeout, this.props.closeTimeoutMS); + var closesAt = Date.now() + this.props.closeTimeoutMS; + this.setState({ beforeClose: true, closesAt: closesAt }, function () { + this.closeTimer = setTimeout(this.closeWithoutTimeout, this.state.closesAt - Date.now()); }.bind(this)); }, @@ -376,15 +400,11 @@ return /******/ (function(modules) { // webpackBootstrap this.setState({ beforeClose: false, isOpen: false, - afterOpen: false + afterOpen: false, + closesAt: null }, this.afterClose); }, - afterClose: function afterClose() { - focusManager.returnFocus(); - focusManager.teardownScopedFocus(); - }, - handleKeyDown: function handleKeyDown(event) { if (event.keyCode == 9 /*tab*/) scopeTab(this.refs.content, event); if (event.keyCode == 27 /*esc*/) { @@ -393,24 +413,18 @@ return /******/ (function(modules) { // webpackBootstrap } }, - handleOverlayMouseDown: function handleOverlayMouseDown(event) { + handleOverlayOnClick: function handleOverlayOnClick(event) { if (this.shouldClose === null) { this.shouldClose = true; } - }, - handleOverlayMouseUp: function handleOverlayMouseUp(event) { if (this.shouldClose && this.props.shouldCloseOnOverlayClick) { if (this.ownerHandlesClose()) this.requestClose(event);else this.focusContent(); } this.shouldClose = null; }, - handleContentMouseDown: function handleContentMouseDown(event) { - this.shouldClose = false; - }, - - handleContentMouseUp: function handleContentMouseUp(event) { + handleContentOnClick: function handleContentOnClick() { this.shouldClose = false; }, @@ -423,7 +437,7 @@ return /******/ (function(modules) { // webpackBootstrap }, shouldBeClosed: function shouldBeClosed() { - return !this.props.isOpen && !this.state.beforeClose; + return !this.state.isOpen && !this.state.beforeClose; }, contentHasFocus: function contentHasFocus() { @@ -445,16 +459,14 @@ return /******/ (function(modules) { // webpackBootstrap ref: "overlay", className: this.buildClassName('overlay', this.props.overlayClassName), style: Assign({}, overlayStyles, this.props.style.overlay || {}), - onMouseDown: this.handleOverlayMouseDown, - onMouseUp: this.handleOverlayMouseUp + onClick: this.handleOverlayOnClick }, div({ ref: "content", style: Assign({}, contentStyles, this.props.style.content || {}), className: this.buildClassName('content', this.props.className), tabIndex: "-1", onKeyDown: this.handleKeyDown, - onMouseDown: this.handleContentMouseDown, - onMouseUp: this.handleContentMouseUp, + onClick: this.handleContentOnClick, role: this.props.role, "aria-label": this.props.contentLabel }, this.props.children)); @@ -468,8 +480,8 @@ return /******/ (function(modules) { // webpackBootstrap 'use strict'; var findTabbable = __webpack_require__(7); + var focusLaterElements = []; var modalElement = null; - var focusLaterElement = null; var needToFocus = false; function handleBlur(event) { @@ -484,8 +496,8 @@ return /******/ (function(modules) { // webpackBootstrap } // 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 + // 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; @@ -496,16 +508,18 @@ return /******/ (function(modules) { // webpackBootstrap } exports.markForFocusLater = function () { - focusLaterElement = document.activeElement; + focusLaterElements.push(document.activeElement); }; exports.returnFocus = function () { + var toFocus = null; try { - focusLaterElement.focus(); + toFocus = focusLaterElements.pop(); + toFocus.focus(); + return; } catch (e) { - console.warn('You tried to return focus to ' + focusLaterElement + ' but it is not in the DOM anymore'); + console.warn('You tried to return focus to ' + toFocus + ' but it is not in the DOM anymore'); } - focusLaterElement = null; }; exports.setupScopedFocus = function (element) { diff --git a/dist/react-modal.min.js b/dist/react-modal.min.js index 65c87419..20e27b1d 100644 --- a/dist/react-modal.min.js +++ b/dist/react-modal.min.js @@ -1,9 +1,9 @@ -!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";e.exports=n(1)},function(e,t,n){"use strict";function o(e){return e()}var r=n(2),s=n(3),i=n(4),u=r.createFactory(n(5)),a=n(10),c=n(11),l=n(3).unstable_renderSubtreeIntoContainer,p=n(9),f=i.canUseDOM?window.HTMLElement:{},d=i.canUseDOM?document.body:{appendChild:function(){}},h=r.createClass({displayName:"Modal",statics:{setAppElement:function(e){d=a.setElement(e)},injectCSS:function(){console.warn("React-Modal: injectCSS has been deprecated and no longer has any effect. It will be removed in a later version")}},propTypes:{isOpen:r.PropTypes.bool.isRequired,style:r.PropTypes.shape({content:r.PropTypes.object,overlay:r.PropTypes.object}),portalClassName:r.PropTypes.string,appElement:r.PropTypes.instanceOf(f),onAfterOpen:r.PropTypes.func,onRequestClose:r.PropTypes.func,closeTimeoutMS:r.PropTypes.number,ariaHideApp:r.PropTypes.bool,shouldCloseOnOverlayClick:r.PropTypes.bool,parentSelector:r.PropTypes.func,role:r.PropTypes.string,contentLabel:r.PropTypes.string.isRequired},getDefaultProps:function(){return{isOpen:!1,portalClassName:"ReactModalPortal",ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0,parentSelector:function(){return document.body}}},componentDidMount:function(){this.node=document.createElement("div"),this.node.className=this.props.portalClassName;var e=o(this.props.parentSelector);e.appendChild(this.node),this.renderPortal(this.props)},componentWillReceiveProps:function(e){var t=o(this.props.parentSelector),n=o(e.parentSelector);n!==t&&(t.removeChild(this.node),n.appendChild(this.node)),this.renderPortal(e)},componentWillUnmount:function(){this.props.ariaHideApp&&a.show(this.props.appElement),s.unmountComponentAtNode(this.node);var e=o(this.props.parentSelector);e.removeChild(this.node),c(document.body).remove("ReactModal__Body--open")},renderPortal:function(e){e.isOpen?c(document.body).add("ReactModal__Body--open"):c(document.body).remove("ReactModal__Body--open"),e.ariaHideApp&&a.toggle(e.isOpen,e.appElement),this.portal=l(this,u(p({},e,{defaultStyles:h.defaultStyles})),this.node)},render:function(){return r.DOM.noscript()}});h.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"}},e.exports=h},function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){var o;/*! +!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";e.exports=n(1)},function(e,t,n){"use strict";function o(e){return e()}var r=n(2),s=n(3),i=n(4),c=r.createFactory(n(5)),a=n(10),l=n(11),u=n(3).unstable_renderSubtreeIntoContainer,p=n(9),f=i.canUseDOM?window.HTMLElement:{},d=i.canUseDOM?document.body:{appendChild:function(){}},h=r.createClass({displayName:"Modal",statics:{setAppElement:function(e){d=a.setElement(e)},injectCSS:function(){console.warn("React-Modal: injectCSS has been deprecated and no longer has any effect. It will be removed in a later version")}},propTypes:{isOpen:r.PropTypes.bool.isRequired,style:r.PropTypes.shape({content:r.PropTypes.object,overlay:r.PropTypes.object}),portalClassName:r.PropTypes.string,appElement:r.PropTypes.instanceOf(f),onAfterOpen:r.PropTypes.func,onRequestClose:r.PropTypes.func,closeTimeoutMS:r.PropTypes.number,ariaHideApp:r.PropTypes.bool,shouldCloseOnOverlayClick:r.PropTypes.bool,parentSelector:r.PropTypes.func,role:r.PropTypes.string,contentLabel:r.PropTypes.string.isRequired},getDefaultProps:function(){return{isOpen:!1,portalClassName:"ReactModalPortal",ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0,parentSelector:function(){return document.body}}},componentDidMount:function(){this.node=document.createElement("div"),this.node.className=this.props.portalClassName;var e=o(this.props.parentSelector);e.appendChild(this.node),this.renderPortal(this.props)},componentWillReceiveProps:function(e){var t=o(this.props.parentSelector),n=o(e.parentSelector);n!==t&&(t.removeChild(this.node),n.appendChild(this.node)),this.renderPortal(e)},componentWillUnmount:function(){this.props.ariaHideApp&&a.show(this.props.appElement);var e=this.portal.state,t=Date.now(),n=e.isOpen&&this.props.closeTimeoutMS&&(e.closesAt||t+this.props.closeTimeoutMS);n?(e.beforeClose||this.portal.closeWithTimeout(),setTimeout(this.removePortal.bind(this),n-t)):this.removePortal()},removePortal:function(){s.unmountComponentAtNode(this.node);var e=o(this.props.parentSelector);e.removeChild(this.node),l(document.body).remove("ReactModal__Body--open")},renderPortal:function(e){e.isOpen?l(document.body).add("ReactModal__Body--open"):l(document.body).remove("ReactModal__Body--open"),e.ariaHideApp&&a.toggle(e.isOpen,e.appElement),this.portal=u(this,c(p({},e,{defaultStyles:h.defaultStyles})),this.node)},render:function(){return r.DOM.noscript()}});h.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"}},e.exports=h},function(t,n){t.exports=e},function(e,n){e.exports=t},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),s={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen};o=function(){return s}.call(t,n,t,e),!(void 0!==o&&(e.exports=o))}()},function(e,t,n){"use strict";var o=n(2),r=o.DOM.div,s=n(6),i=n(8),u=n(9),a={overlay:{base:"ReactModal__Overlay",afterOpen:"ReactModal__Overlay--after-open",beforeClose:"ReactModal__Overlay--before-close"},content:{base:"ReactModal__Content",afterOpen:"ReactModal__Content--after-open",beforeClose:"ReactModal__Content--before-close"}};e.exports=o.createClass({displayName:"ModalPortal",shouldClose:null,getDefaultProps:function(){return{style:{overlay:{},content:{}}}},getInitialState:function(){return{afterOpen:!1,beforeClose:!1}},componentDidMount:function(){this.props.isOpen&&(this.setFocusAfterRender(!0),this.open())},componentWillUnmount:function(){clearTimeout(this.closeTimer)},componentWillReceiveProps:function(e){!this.props.isOpen&&e.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!e.isOpen&&this.close()},componentDidUpdate:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))},setFocusAfterRender:function(e){this.focusAfterRender=e},open:function(){this.state.afterOpen&&this.state.beforeClose?(clearTimeout(this.closeTimer),this.setState({beforeClose:!1})):(s.setupScopedFocus(this.node),s.markForFocusLater(),this.setState({isOpen:!0},function(){this.setState({afterOpen:!0}),this.props.isOpen&&this.props.onAfterOpen&&this.props.onAfterOpen()}.bind(this)))},close:function(){this.props.closeTimeoutMS>0?this.closeWithTimeout():this.closeWithoutTimeout()},focusContent:function(){this.contentHasFocus()||this.refs.content.focus()},closeWithTimeout:function(){this.setState({beforeClose:!0},function(){this.closeTimer=setTimeout(this.closeWithoutTimeout,this.props.closeTimeoutMS)}.bind(this))},closeWithoutTimeout:function(){this.setState({beforeClose:!1,isOpen:!1,afterOpen:!1},this.afterClose)},afterClose:function(){s.returnFocus(),s.teardownScopedFocus()},handleKeyDown:function(e){9==e.keyCode&&i(this.refs.content,e),27==e.keyCode&&(e.preventDefault(),this.requestClose(e))},handleOverlayMouseDown:function(e){null===this.shouldClose&&(this.shouldClose=!0)},handleOverlayMouseUp:function(e){this.shouldClose&&this.props.shouldCloseOnOverlayClick&&(this.ownerHandlesClose()?this.requestClose(e):this.focusContent()),this.shouldClose=null},handleContentMouseDown:function(e){this.shouldClose=!1},handleContentMouseUp:function(e){this.shouldClose=!1},requestClose:function(e){this.ownerHandlesClose()&&this.props.onRequestClose(e)},ownerHandlesClose:function(){return this.props.onRequestClose},shouldBeClosed:function(){return!this.props.isOpen&&!this.state.beforeClose},contentHasFocus:function(){return document.activeElement===this.refs.content||this.refs.content.contains(document.activeElement)},buildClassName:function(e,t){var n=a[e].base;return this.state.afterOpen&&(n+=" "+a[e].afterOpen),this.state.beforeClose&&(n+=" "+a[e].beforeClose),t?n+" "+t:n},render:function(){var e=this.props.className?{}:this.props.defaultStyles.content,t=this.props.overlayClassName?{}:this.props.defaultStyles.overlay;return this.shouldBeClosed()?r():r({ref:"overlay",className:this.buildClassName("overlay",this.props.overlayClassName),style:u({},t,this.props.style.overlay||{}),onMouseDown:this.handleOverlayMouseDown,onMouseUp:this.handleOverlayMouseUp},r({ref:"content",style:u({},e,this.props.style.content||{}),className:this.buildClassName("content",this.props.className),tabIndex:"-1",onKeyDown:this.handleKeyDown,onMouseDown:this.handleContentMouseDown,onMouseUp:this.handleContentMouseUp,role:this.props.role,"aria-label":this.props.contentLabel},this.props.children))}})},function(e,t,n){"use strict";function o(e){a=!0}function r(e){if(a){if(a=!1,!i)return;setTimeout(function(){if(!i.contains(document.activeElement)){var e=s(i)[0]||i;e.focus()}},0)}}var s=n(7),i=null,u=null,a=!1;t.markForFocusLater=function(){u=document.activeElement},t.returnFocus=function(){try{u.focus()}catch(e){console.warn("You tried to return focus to "+u+" but it is not in the DOM anymore")}u=null},t.setupScopedFocus=function(e){i=e,window.addEventListener?(window.addEventListener("blur",o,!1),document.addEventListener("focus",r,!0)):(window.attachEvent("onBlur",o),document.attachEvent("onFocus",r))},t.teardownScopedFocus=function(){i=null,window.addEventListener?(window.removeEventListener("blur",o),document.removeEventListener("focus",r)):(window.detachEvent("onBlur",o),document.detachEvent("onFocus",r))}},function(e,t){"use strict";/*! +!function(){"use strict";var r=!("undefined"==typeof window||!window.document||!window.document.createElement),s={canUseDOM:r,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:r&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:r&&!!window.screen};o=function(){return s}.call(t,n,t,e),!(void 0!==o&&(e.exports=o))}()},function(e,t,n){"use strict";var o=n(2),r=o.DOM.div,s=n(6),i=n(8),c=n(9),a={overlay:{base:"ReactModal__Overlay",afterOpen:"ReactModal__Overlay--after-open",beforeClose:"ReactModal__Overlay--before-close"},content:{base:"ReactModal__Content",afterOpen:"ReactModal__Content--after-open",beforeClose:"ReactModal__Content--before-close"}};e.exports=o.createClass({displayName:"ModalPortal",shouldClose:null,getDefaultProps:function(){return{style:{overlay:{},content:{}}}},getInitialState:function(){return{afterOpen:!1,beforeClose:!1}},componentDidMount:function(){this.props.isOpen&&(this.setFocusAfterRender(!0),this.open())},componentWillUnmount:function(){clearTimeout(this.closeTimer)},componentWillReceiveProps:function(e){!this.props.isOpen&&e.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!e.isOpen&&this.close()},componentDidUpdate:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))},setFocusAfterRender:function(e){this.focusAfterRender=e},afterClose:function(){s.returnFocus(),s.teardownScopedFocus()},open:function(){this.state.afterOpen&&this.state.beforeClose?(clearTimeout(this.closeTimer),this.setState({beforeClose:!1})):(s.setupScopedFocus(this.node),s.markForFocusLater(),this.setState({isOpen:!0},function(){this.setState({afterOpen:!0}),this.props.isOpen&&this.props.onAfterOpen&&this.props.onAfterOpen()}.bind(this)))},close:function(){this.props.closeTimeoutMS>0?this.closeWithTimeout():this.closeWithoutTimeout()},focusContent:function(){this.contentHasFocus()||this.refs.content.focus()},closeWithTimeout:function(){var e=Date.now()+this.props.closeTimeoutMS;this.setState({beforeClose:!0,closesAt:e},function(){this.closeTimer=setTimeout(this.closeWithoutTimeout,this.state.closesAt-Date.now())}.bind(this))},closeWithoutTimeout:function(){this.setState({beforeClose:!1,isOpen:!1,afterOpen:!1,closesAt:null},this.afterClose)},handleKeyDown:function(e){9==e.keyCode&&i(this.refs.content,e),27==e.keyCode&&(e.preventDefault(),this.requestClose(e))},handleOverlayOnClick:function(e){null===this.shouldClose&&(this.shouldClose=!0),this.shouldClose&&this.props.shouldCloseOnOverlayClick&&(this.ownerHandlesClose()?this.requestClose(e):this.focusContent()),this.shouldClose=null},handleContentOnClick:function(){this.shouldClose=!1},requestClose:function(e){this.ownerHandlesClose()&&this.props.onRequestClose(e)},ownerHandlesClose:function(){return this.props.onRequestClose},shouldBeClosed:function(){return!this.state.isOpen&&!this.state.beforeClose},contentHasFocus:function(){return document.activeElement===this.refs.content||this.refs.content.contains(document.activeElement)},buildClassName:function(e,t){var n=a[e].base;return this.state.afterOpen&&(n+=" "+a[e].afterOpen),this.state.beforeClose&&(n+=" "+a[e].beforeClose),t?n+" "+t:n},render:function(){var e=this.props.className?{}:this.props.defaultStyles.content,t=this.props.overlayClassName?{}:this.props.defaultStyles.overlay;return this.shouldBeClosed()?r():r({ref:"overlay",className:this.buildClassName("overlay",this.props.overlayClassName),style:c({},t,this.props.style.overlay||{}),onClick:this.handleOverlayOnClick},r({ref:"content",style:c({},e,this.props.style.content||{}),className:this.buildClassName("content",this.props.className),tabIndex:"-1",onKeyDown:this.handleKeyDown,onClick:this.handleContentOnClick,role:this.props.role,"aria-label":this.props.contentLabel},this.props.children))}})},function(e,t,n){"use strict";function o(e){a=!0}function r(e){if(a){if(a=!1,!c)return;setTimeout(function(){if(!c.contains(document.activeElement)){var e=s(c)[0]||c;e.focus()}},0)}}var s=n(7),i=[],c=null,a=!1;t.markForFocusLater=function(){i.push(document.activeElement)},t.returnFocus=function(){var e=null;try{return e=i.pop(),void e.focus()}catch(t){console.warn("You tried to return focus to "+e+" but it is not in the DOM anymore")}},t.setupScopedFocus=function(e){c=e,window.addEventListener?(window.addEventListener("blur",o,!1),document.addEventListener("focus",r,!0)):(window.attachEvent("onBlur",o),document.attachEvent("onFocus",r))},t.teardownScopedFocus=function(){c=null,window.addEventListener?(window.removeEventListener("blur",o),document.removeEventListener("focus",r)):(window.detachEvent("onBlur",o),document.detachEvent("onFocus",r))}},function(e,t){"use strict";/*! * Adapted from jQuery UI core * * http://jqueryui.com @@ -14,4 +14,4 @@ * * http://api.jqueryui.com/category/ui-core/ */ -function n(e,t){var n=e.nodeName.toLowerCase();return(/input|select|textarea|button|object/.test(n)?!e.disabled:"a"===n?e.href||t:t)&&r(e)}function o(e){return e.offsetWidth<=0&&e.offsetHeight<=0||"none"===e.style.display}function r(e){for(;e&&e!==document.body;){if(o(e))return!1;e=e.parentNode}return!0}function s(e){var t=e.getAttribute("tabindex");null===t&&(t=void 0);var o=isNaN(t);return(o||t>=0)&&n(e,!o)}function i(e){return[].slice.call(e.querySelectorAll("*"),0).filter(function(e){return s(e)})}e.exports=i},function(e,t,n){"use strict";var o=n(7);e.exports=function(e,t){var n=o(e);if(!n.length)return void t.preventDefault();var r=n[t.shiftKey?0:n.length-1],s=r===document.activeElement||e===document.activeElement;if(s){t.preventDefault();var i=n[t.shiftKey?n.length-1:0];i.focus()}}},function(e,t){function n(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function o(e,t){for(var n=-1,o=Array(e);++n1?n[r-1]:void 0,i=r>2?n[2]:void 0;for(s=e.length>3&&"function"==typeof s?(r--,s):void 0,i&&f(n[0],n[1],i)&&(s=r<3?void 0:s,r=1),t=Object(t);++o-1&&e%1==0&&e-1&&e%1==0&&e<=M}function w(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function O(e){return!!e&&"object"==typeof e}function g(e){return v(e)?s(e):u(e)}var M=9007199254740991,S="[object Arguments]",T="[object Function]",x="[object GeneratorFunction]",E=/^(?:0|[1-9]\d*)$/,R=Object.prototype,N=R.hasOwnProperty,A=R.toString,D=R.propertyIsEnumerable,P=r(Object.keys,Object),F=Math.max,j=!D.call({valueOf:1},"valueOf"),_=Array.isArray,q=l(function(e,t){if(j||d(t)||v(t))return void c(t,g(t),e);for(var n in t)N.call(t,n)&&i(e,n,t[n])});e.exports=q},function(e,t){"use strict";function n(e){if("string"==typeof e){var t=document.querySelectorAll(e);e="length"in t?t[0]:t}return a=e||a}function o(e){i(e),(e||a).setAttribute("aria-hidden","true")}function r(e){i(e),(e||a).removeAttribute("aria-hidden")}function s(e,t){e?o(t):r(t)}function i(e){if(!e&&!a)throw new Error("react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible")}function u(){a=document.body}var a="undefined"!=typeof document?document.body:null;t.toggle=s,t.setElement=n,t.show=r,t.hide=o,t.resetForTesting=u},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))}}])}); \ No newline at end of file +function n(e,t){var n=e.nodeName.toLowerCase();return(/input|select|textarea|button|object/.test(n)?!e.disabled:"a"===n?e.href||t:t)&&r(e)}function o(e){return e.offsetWidth<=0&&e.offsetHeight<=0||"none"===e.style.display}function r(e){for(;e&&e!==document.body;){if(o(e))return!1;e=e.parentNode}return!0}function s(e){var t=e.getAttribute("tabindex");null===t&&(t=void 0);var o=isNaN(t);return(o||t>=0)&&n(e,!o)}function i(e){return[].slice.call(e.querySelectorAll("*"),0).filter(function(e){return s(e)})}e.exports=i},function(e,t,n){"use strict";var o=n(7);e.exports=function(e,t){var n=o(e);if(!n.length)return void t.preventDefault();var r=n[t.shiftKey?0:n.length-1],s=r===document.activeElement||e===document.activeElement;if(s){t.preventDefault();var i=n[t.shiftKey?n.length-1:0];i.focus()}}},function(e,t){function n(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function o(e,t){for(var n=-1,o=Array(e);++n1?n[r-1]:void 0,i=r>2?n[2]:void 0;for(s=e.length>3&&"function"==typeof s?(r--,s):void 0,i&&f(n[0],n[1],i)&&(s=r<3?void 0:s,r=1),t=Object(t);++o-1&&e%1==0&&e-1&&e%1==0&&e<=S}function O(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function w(e){return!!e&&"object"==typeof e}function g(e){return v(e)?s(e):c(e)}var S=9007199254740991,T="[object Arguments]",x="[object Function]",M="[object GeneratorFunction]",A=/^(?:0|[1-9]\d*)$/,E=Object.prototype,R=E.hasOwnProperty,N=E.toString,P=E.propertyIsEnumerable,F=r(Object.keys,Object),j=Math.max,D=!P.call({valueOf:1},"valueOf"),k=Array.isArray,_=u(function(e,t){if(D||d(t)||v(t))return void l(t,g(t),e);for(var n in t)R.call(t,n)&&i(e,n,t[n])});e.exports=_},function(e,t){"use strict";function n(e){if("string"==typeof e){var t=document.querySelectorAll(e);e="length"in t?t[0]:t}return a=e||a}function o(e){i(e),(e||a).setAttribute("aria-hidden","true")}function r(e){i(e),(e||a).removeAttribute("aria-hidden")}function s(e,t){e?o(t):r(t)}function i(e){if(!e&&!a)throw new Error("react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible")}function c(){a=document.body}var a="undefined"!=typeof document?document.body:null;t.toggle=s,t.setElement=n,t.show=r,t.hide=o,t.resetForTesting=c},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))}}])}); \ No newline at end of file diff --git a/package.json b/package.json index 25f0b685..af3a68ed 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-modal", - "version": "1.6.5", + "version": "1.7.0", "description": "Accessible modal dialog component for React.JS", "main": "./lib/index.js", "repository": {