react-modal
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -0,1 +1,7 @@ | ||
v1.1.0 - Tue, 12 Apr 2016 13:03:08 GMT | ||
-------------------------------------- | ||
- [6c03d17](../../commit/6c03d17) [added] trigger onAfterOpen callback when available. (#154) | ||
v1.0.0 - Sat, 09 Apr 2016 05:03:25 GMT | ||
@@ -2,0 +8,0 @@ -------------------------------------- |
@@ -35,2 +35,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ReactModal = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
appElement: React.PropTypes.instanceOf(SafeHTMLElement), | ||
onAfterOpen: React.PropTypes.func, | ||
onRequestClose: React.PropTypes.func, | ||
@@ -198,2 +199,6 @@ closeTimeoutMS: React.PropTypes.number, | ||
this.setState({afterOpen: true}); | ||
if (this.props.isOpen && this.props.onAfterOpen) { | ||
this.props.onAfterOpen(); | ||
} | ||
}.bind(this)); | ||
@@ -200,0 +205,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.ReactModal=f()}}(function(){var define;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function sanitizeProps(props){delete props.ref}var React="undefined"!=typeof window?window.React:"undefined"!=typeof global?global.React:null,ReactDOM="undefined"!=typeof window?window.ReactDOM:"undefined"!=typeof global?global.ReactDOM:null,ExecutionEnvironment=require("exenv"),ModalPortal=React.createFactory(require("./ModalPortal")),ariaAppHider=require("../helpers/ariaAppHider"),elementClass=require("element-class"),renderSubtreeIntoContainer=("undefined"!=typeof window?window.ReactDOM:"undefined"!=typeof global?global.ReactDOM:null).unstable_renderSubtreeIntoContainer,Assign=require("lodash.assign"),SafeHTMLElement=ExecutionEnvironment.canUseDOM?window.HTMLElement:{},AppElement=ExecutionEnvironment.canUseDOM?document.body:{appendChild:function(){}},Modal=React.createClass({displayName:"Modal",statics:{setAppElement:function(element){AppElement=ariaAppHider.setElement(element)},injectCSS:function(){}},propTypes:{isOpen:React.PropTypes.bool.isRequired,style:React.PropTypes.shape({content:React.PropTypes.object,overlay:React.PropTypes.object}),appElement:React.PropTypes.instanceOf(SafeHTMLElement),onRequestClose:React.PropTypes.func,closeTimeoutMS:React.PropTypes.number,ariaHideApp:React.PropTypes.bool,shouldCloseOnOverlayClick:React.PropTypes.bool},getDefaultProps:function(){return{isOpen:!1,ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0}},componentDidMount:function(){this.node=document.createElement("div"),this.node.className="ReactModalPortal",AppElement.appendChild(this.node),this.renderPortal(this.props)},componentWillReceiveProps:function(newProps){this.renderPortal(newProps)},componentWillUnmount:function(){ReactDOM.unmountComponentAtNode(this.node),AppElement.removeChild(this.node),elementClass(document.body).remove("ReactModal__Body--open")},renderPortal:function(props){props.isOpen?elementClass(document.body).add("ReactModal__Body--open"):elementClass(document.body).remove("ReactModal__Body--open"),props.ariaHideApp&&ariaAppHider.toggle(props.isOpen,props.appElement),sanitizeProps(props),this.portal=renderSubtreeIntoContainer(this,ModalPortal(Assign({},props,{defaultStyles:Modal.defaultStyles})),this.node)},render:function(){return React.DOM.noscript()}});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"}},module.exports=Modal},{"../helpers/ariaAppHider":3,"./ModalPortal":2,"element-class":8,exenv:9,"lodash.assign":16}],2:[function(require,module,exports){var React="undefined"!=typeof window?window.React:"undefined"!=typeof global?global.React:null,div=React.DOM.div,focusManager=require("../helpers/focusManager"),scopeTab=require("../helpers/scopeTab"),Assign=require("lodash.assign"),CLASS_NAMES={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"}};module.exports=React.createClass({displayName:"ModalPortal",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(newProps){!this.props.isOpen&&newProps.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!newProps.isOpen&&this.close()},componentDidUpdate:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))},setFocusAfterRender:function(focus){this.focusAfterRender=focus},open:function(){focusManager.setupScopedFocus(this.node),focusManager.markForFocusLater(),this.setState({isOpen:!0},function(){this.setState({afterOpen:!0})}.bind(this))},close:function(){this.ownerHandlesClose()&&(this.props.closeTimeoutMS>0?this.closeWithTimeout():this.closeWithoutTimeout())},focusContent:function(){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({afterOpen:!1,beforeClose:!1},this.afterClose)},afterClose:function(){focusManager.returnFocus(),focusManager.teardownScopedFocus()},handleKeyDown:function(event){9==event.keyCode&&scopeTab(this.refs.content,event),27==event.keyCode&&(event.preventDefault(),this.requestClose())},handleOverlayClick:function(event){for(var node=event.target;node;){if(node===this.refs.content)return;node=node.parentNode}this.props.shouldCloseOnOverlayClick&&(this.ownerHandlesClose()?this.requestClose():this.focusContent())},requestClose:function(){this.ownerHandlesClose()&&this.props.onRequestClose()},ownerHandlesClose:function(){return this.props.onRequestClose},shouldBeClosed:function(){return!this.props.isOpen&&!this.state.beforeClose},buildClassName:function(which,additional){var className=CLASS_NAMES[which].base;return this.state.afterOpen&&(className+=" "+CLASS_NAMES[which].afterOpen),this.state.beforeClose&&(className+=" "+CLASS_NAMES[which].beforeClose),additional?className+" "+additional:className},render:function(){var contentStyles=this.props.className?{}:this.props.defaultStyles.content,overlayStyles=this.props.overlayClassName?{}:this.props.defaultStyles.overlay;return this.shouldBeClosed()?div():div({ref:"overlay",className:this.buildClassName("overlay",this.props.overlayClassName),style:Assign({},overlayStyles,this.props.style.overlay||{}),onClick:this.handleOverlayClick},div({ref:"content",style:Assign({},contentStyles,this.props.style.content||{}),className:this.buildClassName("content",this.props.className),tabIndex:"-1",onKeyDown:this.handleKeyDown},this.props.children))}})},{"../helpers/focusManager":4,"../helpers/scopeTab":5,"lodash.assign":16}],3:[function(require,module,exports){function setElement(element){if("string"==typeof element){var el=document.querySelectorAll(element);element="length"in el?el[0]:el}return _element=element||_element}function hide(appElement){validateElement(appElement),(appElement||_element).setAttribute("aria-hidden","true")}function show(appElement){validateElement(appElement),(appElement||_element).removeAttribute("aria-hidden")}function toggle(shouldHide,appElement){shouldHide?hide(appElement):show(appElement)}function validateElement(appElement){if(!appElement&&!_element)throw new Error("react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible")}function resetForTesting(){_element=document.body}var _element="undefined"!=typeof document?document.body:null;exports.toggle=toggle,exports.setElement=setElement,exports.show=show,exports.hide=hide,exports.resetForTesting=resetForTesting},{}],4:[function(require,module,exports){function handleBlur(event){needToFocus=!0}function handleFocus(event){if(needToFocus){if(needToFocus=!1,!modalElement)return;setTimeout(function(){if(!modalElement.contains(document.activeElement)){var el=findTabbable(modalElement)[0]||modalElement;el.focus()}},0)}}var findTabbable=require("../helpers/tabbable"),modalElement=null,focusLaterElement=null,needToFocus=!1;exports.markForFocusLater=function(){focusLaterElement=document.activeElement},exports.returnFocus=function(){try{focusLaterElement.focus()}catch(e){console.warn("You tried to return focus to "+focusLaterElement+" but it is not in the DOM anymore")}focusLaterElement=null},exports.setupScopedFocus=function(element){modalElement=element,window.addEventListener?(window.addEventListener("blur",handleBlur,!1),document.addEventListener("focus",handleFocus,!0)):(window.attachEvent("onBlur",handleBlur),document.attachEvent("onFocus",handleFocus))},exports.teardownScopedFocus=function(){modalElement=null,window.addEventListener?(window.removeEventListener("blur",handleBlur),document.removeEventListener("focus",handleFocus)):(window.detachEvent("onBlur",handleBlur),document.detachEvent("onFocus",handleFocus))}},{"../helpers/tabbable":6}],5:[function(require,module,exports){var findTabbable=require("../helpers/tabbable");module.exports=function(node,event){var tabbable=findTabbable(node);if(!tabbable.length)return void event.preventDefault();var finalTabbable=tabbable[event.shiftKey?0:tabbable.length-1],leavingFinalTabbable=finalTabbable===document.activeElement||node===document.activeElement;if(leavingFinalTabbable){event.preventDefault();var target=tabbable[event.shiftKey?tabbable.length-1:0];target.focus()}}},{"../helpers/tabbable":6}],6:[function(require,module,exports){function focusable(element,isTabIndexNotNaN){var nodeName=element.nodeName.toLowerCase();return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)}function hidden(el){return el.offsetWidth<=0&&el.offsetHeight<=0||"none"===el.style.display}function visible(element){for(;element&&element!==document.body;){if(hidden(element))return!1;element=element.parentNode}return!0}function tabbable(element){var tabIndex=element.getAttribute("tabindex");null===tabIndex&&(tabIndex=void 0);var isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}function findTabbableDescendants(element){return[].slice.call(element.querySelectorAll("*"),0).filter(function(el){return tabbable(el)})}module.exports=findTabbableDescendants},{}],7:[function(require,module,exports){module.exports=require("./components/Modal")},{"./components/Modal":1}],8:[function(require,module,exports){function indexOf(arr,prop){if(arr.indexOf)return arr.indexOf(prop);for(var i=0,len=arr.length;len>i;i++)if(arr[i]===prop)return i;return-1}function ElementClass(opts){if(!(this instanceof ElementClass))return new ElementClass(opts);opts||(opts={}),opts.nodeType&&(opts={el:opts}),this.opts=opts,this.el=opts.el||document.body,"object"!=typeof this.el&&(this.el=document.querySelector(this.el))}module.exports=function(opts){return new ElementClass(opts)},ElementClass.prototype.add=function(className){var el=this.el;if(el){if(""===el.className)return el.className=className;var classes=el.className.split(" ");return indexOf(classes,className)>-1?classes:(classes.push(className),el.className=classes.join(" "),classes)}},ElementClass.prototype.remove=function(className){var el=this.el;if(el&&""!==el.className){var classes=el.className.split(" "),idx=indexOf(classes,className);return idx>-1&&classes.splice(idx,1),el.className=classes.join(" "),classes}},ElementClass.prototype.has=function(className){var el=this.el;if(el){var classes=el.className.split(" ");return indexOf(classes,className)>-1}},ElementClass.prototype.toggle=function(className){var el=this.el;el&&(this.has(className)?this.remove(className):this.add(className))}},{}],9:[function(require,module,exports){!function(){"use strict";var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement),ExecutionEnvironment={canUseDOM:canUseDOM,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:canUseDOM&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:canUseDOM&&!!window.screen};"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return ExecutionEnvironment}):"undefined"!=typeof module&&module.exports?module.exports=ExecutionEnvironment:window.ExecutionEnvironment=ExecutionEnvironment}()},{}],10:[function(require,module,exports){function baseAssign(object,source){return null==source?object:baseCopy(source,keys(source),object)}var baseCopy=require("lodash._basecopy"),keys=require("lodash.keys");module.exports=baseAssign},{"lodash._basecopy":11,"lodash.keys":19}],11:[function(require,module,exports){function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;++index<length;){var key=props[index];object[key]=source[key]}return object}module.exports=baseCopy},{}],12:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if("function"!=typeof func)return identity;if(void 0===thisArg)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],13:[function(require,module,exports){function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2?sources[length-2]:void 0,guard=length>2?sources[2]:void 0,thisArg=length>1?sources[length-1]:void 0;for("function"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer="function"==typeof thisArg?thisArg:void 0,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?void 0:customizer,length=1);++index<length;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}var bindCallback=require("lodash._bindcallback"),isIterateeCall=require("lodash._isiterateecall"),restParam=require("lodash.restparam");module.exports=createAssigner},{"lodash._bindcallback":12,"lodash._isiterateecall":15,"lodash.restparam":20}],14:[function(require,module,exports){function isObjectLike(value){return!!value&&"object"==typeof value}function getNative(object,key){var value=null==object?void 0:object[key];return isNative(value)?value:void 0}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isNative(value){return null==value?!1:isFunction(value)?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}var funcTag="[object Function]",reIsHostCtor=/^\[object .+?Constructor\]$/,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");module.exports=getNative},{}],15:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArrayLike(value){return null!=value&&isLength(getLength(value))}function isIndex(value,length){return value="number"==typeof value||reIsUint.test(value)?+value:-1,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&value%1==0&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if("number"==type?isArrayLike(object)&&isIndex(index,object.length):"string"==type&&index in object){var other=object[index];return value===value?value===other:other!==other}return!1}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}var reIsUint=/^\d+$/,MAX_SAFE_INTEGER=9007199254740991,getLength=baseProperty("length");module.exports=isIterateeCall},{}],16:[function(require,module,exports){function assignWith(object,source,customizer){for(var index=-1,props=keys(source),length=props.length;++index<length;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(void 0!==value||key in object)||(object[key]=result)}return object}var baseAssign=require("lodash._baseassign"),createAssigner=require("lodash._createassigner"),keys=require("lodash.keys"),assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)});module.exports=assign},{"lodash._baseassign":10,"lodash._createassigner":13,"lodash.keys":19}],17:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArguments(value){return isArrayLikeObject(value)&&hasOwnProperty.call(value,"callee")&&(!propertyIsEnumerable.call(value,"callee")||objectToString.call(value)==argsTag)}function isArrayLike(value){return null!=value&&isLength(getLength(value))&&!isFunction(value)}function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isObjectLike(value){return!!value&&"object"==typeof value}var MAX_SAFE_INTEGER=9007199254740991,argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,propertyIsEnumerable=objectProto.propertyIsEnumerable,getLength=baseProperty("length");module.exports=isArguments},{}],18:[function(require,module,exports){function isObjectLike(value){return!!value&&"object"==typeof value}function getNative(object,key){var value=null==object?void 0:object[key];return isNative(value)?value:void 0}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isNative(value){return null==value?!1:isFunction(value)?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}var arrayTag="[object Array]",funcTag="[object Function]",reIsHostCtor=/^\[object .+?Constructor\]$/,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nativeIsArray=getNative(Array,"isArray"),MAX_SAFE_INTEGER=9007199254740991,isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};module.exports=isArray},{}],19:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArrayLike(value){return null!=value&&isLength(getLength(value))}function isIndex(value,length){return value="number"==typeof value||reIsUint.test(value)?+value:-1,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&value%1==0&&length>value}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object)),index=-1,result=[];++index<propsLength;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto="function"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;++index<length;)result[index]=index+"";for(var key in object)skipIndexes&&isIndex(key,length)||"constructor"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray"),reIsUint=/^\d+$/,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeKeys=getNative(Object,"keys"),MAX_SAFE_INTEGER=9007199254740991,getLength=baseProperty("length"),keys=nativeKeys?function(object){var Ctor=null==object?void 0:object.constructor;return"function"==typeof Ctor&&Ctor.prototype===object||"function"!=typeof object&&isArrayLike(object)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys;module.exports=keys},{"lodash._getnative":14,"lodash.isarguments":17,"lodash.isarray":18}],20:[function(require,module,exports){function restParam(func,start){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(void 0===start?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);++index<length;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;++index<start;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}var FUNC_ERROR_TEXT="Expected a function",nativeMax=Math.max;module.exports=restParam},{}]},{},[7])(7)}); | ||
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{var g;g="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,g.ReactModal=f()}}(function(){var define;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function sanitizeProps(props){delete props.ref}var React="undefined"!=typeof window?window.React:"undefined"!=typeof global?global.React:null,ReactDOM="undefined"!=typeof window?window.ReactDOM:"undefined"!=typeof global?global.ReactDOM:null,ExecutionEnvironment=require("exenv"),ModalPortal=React.createFactory(require("./ModalPortal")),ariaAppHider=require("../helpers/ariaAppHider"),elementClass=require("element-class"),renderSubtreeIntoContainer=("undefined"!=typeof window?window.ReactDOM:"undefined"!=typeof global?global.ReactDOM:null).unstable_renderSubtreeIntoContainer,Assign=require("lodash.assign"),SafeHTMLElement=ExecutionEnvironment.canUseDOM?window.HTMLElement:{},AppElement=ExecutionEnvironment.canUseDOM?document.body:{appendChild:function(){}},Modal=React.createClass({displayName:"Modal",statics:{setAppElement:function(element){AppElement=ariaAppHider.setElement(element)},injectCSS:function(){}},propTypes:{isOpen:React.PropTypes.bool.isRequired,style:React.PropTypes.shape({content:React.PropTypes.object,overlay:React.PropTypes.object}),appElement:React.PropTypes.instanceOf(SafeHTMLElement),onAfterOpen:React.PropTypes.func,onRequestClose:React.PropTypes.func,closeTimeoutMS:React.PropTypes.number,ariaHideApp:React.PropTypes.bool,shouldCloseOnOverlayClick:React.PropTypes.bool},getDefaultProps:function(){return{isOpen:!1,ariaHideApp:!0,closeTimeoutMS:0,shouldCloseOnOverlayClick:!0}},componentDidMount:function(){this.node=document.createElement("div"),this.node.className="ReactModalPortal",AppElement.appendChild(this.node),this.renderPortal(this.props)},componentWillReceiveProps:function(newProps){this.renderPortal(newProps)},componentWillUnmount:function(){ReactDOM.unmountComponentAtNode(this.node),AppElement.removeChild(this.node),elementClass(document.body).remove("ReactModal__Body--open")},renderPortal:function(props){props.isOpen?elementClass(document.body).add("ReactModal__Body--open"):elementClass(document.body).remove("ReactModal__Body--open"),props.ariaHideApp&&ariaAppHider.toggle(props.isOpen,props.appElement),sanitizeProps(props),this.portal=renderSubtreeIntoContainer(this,ModalPortal(Assign({},props,{defaultStyles:Modal.defaultStyles})),this.node)},render:function(){return React.DOM.noscript()}});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"}},module.exports=Modal},{"../helpers/ariaAppHider":3,"./ModalPortal":2,"element-class":8,exenv:9,"lodash.assign":16}],2:[function(require,module,exports){var React="undefined"!=typeof window?window.React:"undefined"!=typeof global?global.React:null,div=React.DOM.div,focusManager=require("../helpers/focusManager"),scopeTab=require("../helpers/scopeTab"),Assign=require("lodash.assign"),CLASS_NAMES={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"}};module.exports=React.createClass({displayName:"ModalPortal",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(newProps){!this.props.isOpen&&newProps.isOpen?(this.setFocusAfterRender(!0),this.open()):this.props.isOpen&&!newProps.isOpen&&this.close()},componentDidUpdate:function(){this.focusAfterRender&&(this.focusContent(),this.setFocusAfterRender(!1))},setFocusAfterRender:function(focus){this.focusAfterRender=focus},open:function(){focusManager.setupScopedFocus(this.node),focusManager.markForFocusLater(),this.setState({isOpen:!0},function(){this.setState({afterOpen:!0}),this.props.isOpen&&this.props.onAfterOpen&&this.props.onAfterOpen()}.bind(this))},close:function(){this.ownerHandlesClose()&&(this.props.closeTimeoutMS>0?this.closeWithTimeout():this.closeWithoutTimeout())},focusContent:function(){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({afterOpen:!1,beforeClose:!1},this.afterClose)},afterClose:function(){focusManager.returnFocus(),focusManager.teardownScopedFocus()},handleKeyDown:function(event){9==event.keyCode&&scopeTab(this.refs.content,event),27==event.keyCode&&(event.preventDefault(),this.requestClose())},handleOverlayClick:function(event){for(var node=event.target;node;){if(node===this.refs.content)return;node=node.parentNode}this.props.shouldCloseOnOverlayClick&&(this.ownerHandlesClose()?this.requestClose():this.focusContent())},requestClose:function(){this.ownerHandlesClose()&&this.props.onRequestClose()},ownerHandlesClose:function(){return this.props.onRequestClose},shouldBeClosed:function(){return!this.props.isOpen&&!this.state.beforeClose},buildClassName:function(which,additional){var className=CLASS_NAMES[which].base;return this.state.afterOpen&&(className+=" "+CLASS_NAMES[which].afterOpen),this.state.beforeClose&&(className+=" "+CLASS_NAMES[which].beforeClose),additional?className+" "+additional:className},render:function(){var contentStyles=this.props.className?{}:this.props.defaultStyles.content,overlayStyles=this.props.overlayClassName?{}:this.props.defaultStyles.overlay;return this.shouldBeClosed()?div():div({ref:"overlay",className:this.buildClassName("overlay",this.props.overlayClassName),style:Assign({},overlayStyles,this.props.style.overlay||{}),onClick:this.handleOverlayClick},div({ref:"content",style:Assign({},contentStyles,this.props.style.content||{}),className:this.buildClassName("content",this.props.className),tabIndex:"-1",onKeyDown:this.handleKeyDown},this.props.children))}})},{"../helpers/focusManager":4,"../helpers/scopeTab":5,"lodash.assign":16}],3:[function(require,module,exports){function setElement(element){if("string"==typeof element){var el=document.querySelectorAll(element);element="length"in el?el[0]:el}return _element=element||_element}function hide(appElement){validateElement(appElement),(appElement||_element).setAttribute("aria-hidden","true")}function show(appElement){validateElement(appElement),(appElement||_element).removeAttribute("aria-hidden")}function toggle(shouldHide,appElement){shouldHide?hide(appElement):show(appElement)}function validateElement(appElement){if(!appElement&&!_element)throw new Error("react-modal: You must set an element with `Modal.setAppElement(el)` to make this accessible")}function resetForTesting(){_element=document.body}var _element="undefined"!=typeof document?document.body:null;exports.toggle=toggle,exports.setElement=setElement,exports.show=show,exports.hide=hide,exports.resetForTesting=resetForTesting},{}],4:[function(require,module,exports){function handleBlur(event){needToFocus=!0}function handleFocus(event){if(needToFocus){if(needToFocus=!1,!modalElement)return;setTimeout(function(){if(!modalElement.contains(document.activeElement)){var el=findTabbable(modalElement)[0]||modalElement;el.focus()}},0)}}var findTabbable=require("../helpers/tabbable"),modalElement=null,focusLaterElement=null,needToFocus=!1;exports.markForFocusLater=function(){focusLaterElement=document.activeElement},exports.returnFocus=function(){try{focusLaterElement.focus()}catch(e){console.warn("You tried to return focus to "+focusLaterElement+" but it is not in the DOM anymore")}focusLaterElement=null},exports.setupScopedFocus=function(element){modalElement=element,window.addEventListener?(window.addEventListener("blur",handleBlur,!1),document.addEventListener("focus",handleFocus,!0)):(window.attachEvent("onBlur",handleBlur),document.attachEvent("onFocus",handleFocus))},exports.teardownScopedFocus=function(){modalElement=null,window.addEventListener?(window.removeEventListener("blur",handleBlur),document.removeEventListener("focus",handleFocus)):(window.detachEvent("onBlur",handleBlur),document.detachEvent("onFocus",handleFocus))}},{"../helpers/tabbable":6}],5:[function(require,module,exports){var findTabbable=require("../helpers/tabbable");module.exports=function(node,event){var tabbable=findTabbable(node);if(!tabbable.length)return void event.preventDefault();var finalTabbable=tabbable[event.shiftKey?0:tabbable.length-1],leavingFinalTabbable=finalTabbable===document.activeElement||node===document.activeElement;if(leavingFinalTabbable){event.preventDefault();var target=tabbable[event.shiftKey?tabbable.length-1:0];target.focus()}}},{"../helpers/tabbable":6}],6:[function(require,module,exports){function focusable(element,isTabIndexNotNaN){var nodeName=element.nodeName.toLowerCase();return(/input|select|textarea|button|object/.test(nodeName)?!element.disabled:"a"===nodeName?element.href||isTabIndexNotNaN:isTabIndexNotNaN)&&visible(element)}function hidden(el){return el.offsetWidth<=0&&el.offsetHeight<=0||"none"===el.style.display}function visible(element){for(;element&&element!==document.body;){if(hidden(element))return!1;element=element.parentNode}return!0}function tabbable(element){var tabIndex=element.getAttribute("tabindex");null===tabIndex&&(tabIndex=void 0);var isTabIndexNaN=isNaN(tabIndex);return(isTabIndexNaN||tabIndex>=0)&&focusable(element,!isTabIndexNaN)}function findTabbableDescendants(element){return[].slice.call(element.querySelectorAll("*"),0).filter(function(el){return tabbable(el)})}module.exports=findTabbableDescendants},{}],7:[function(require,module,exports){module.exports=require("./components/Modal")},{"./components/Modal":1}],8:[function(require,module,exports){function indexOf(arr,prop){if(arr.indexOf)return arr.indexOf(prop);for(var i=0,len=arr.length;len>i;i++)if(arr[i]===prop)return i;return-1}function ElementClass(opts){if(!(this instanceof ElementClass))return new ElementClass(opts);opts||(opts={}),opts.nodeType&&(opts={el:opts}),this.opts=opts,this.el=opts.el||document.body,"object"!=typeof this.el&&(this.el=document.querySelector(this.el))}module.exports=function(opts){return new ElementClass(opts)},ElementClass.prototype.add=function(className){var el=this.el;if(el){if(""===el.className)return el.className=className;var classes=el.className.split(" ");return indexOf(classes,className)>-1?classes:(classes.push(className),el.className=classes.join(" "),classes)}},ElementClass.prototype.remove=function(className){var el=this.el;if(el&&""!==el.className){var classes=el.className.split(" "),idx=indexOf(classes,className);return idx>-1&&classes.splice(idx,1),el.className=classes.join(" "),classes}},ElementClass.prototype.has=function(className){var el=this.el;if(el){var classes=el.className.split(" ");return indexOf(classes,className)>-1}},ElementClass.prototype.toggle=function(className){var el=this.el;el&&(this.has(className)?this.remove(className):this.add(className))}},{}],9:[function(require,module,exports){!function(){"use strict";var canUseDOM=!("undefined"==typeof window||!window.document||!window.document.createElement),ExecutionEnvironment={canUseDOM:canUseDOM,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:canUseDOM&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:canUseDOM&&!!window.screen};"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(function(){return ExecutionEnvironment}):"undefined"!=typeof module&&module.exports?module.exports=ExecutionEnvironment:window.ExecutionEnvironment=ExecutionEnvironment}()},{}],10:[function(require,module,exports){function baseAssign(object,source){return null==source?object:baseCopy(source,keys(source),object)}var baseCopy=require("lodash._basecopy"),keys=require("lodash.keys");module.exports=baseAssign},{"lodash._basecopy":11,"lodash.keys":19}],11:[function(require,module,exports){function baseCopy(source,props,object){object||(object={});for(var index=-1,length=props.length;++index<length;){var key=props[index];object[key]=source[key]}return object}module.exports=baseCopy},{}],12:[function(require,module,exports){function bindCallback(func,thisArg,argCount){if("function"!=typeof func)return identity;if(void 0===thisArg)return func;switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)};case 5:return function(value,other,key,object,source){return func.call(thisArg,value,other,key,object,source)}}return function(){return func.apply(thisArg,arguments)}}function identity(value){return value}module.exports=bindCallback},{}],13:[function(require,module,exports){function createAssigner(assigner){return restParam(function(object,sources){var index=-1,length=null==object?0:sources.length,customizer=length>2?sources[length-2]:void 0,guard=length>2?sources[2]:void 0,thisArg=length>1?sources[length-1]:void 0;for("function"==typeof customizer?(customizer=bindCallback(customizer,thisArg,5),length-=2):(customizer="function"==typeof thisArg?thisArg:void 0,length-=customizer?1:0),guard&&isIterateeCall(sources[0],sources[1],guard)&&(customizer=3>length?void 0:customizer,length=1);++index<length;){var source=sources[index];source&&assigner(object,source,customizer)}return object})}var bindCallback=require("lodash._bindcallback"),isIterateeCall=require("lodash._isiterateecall"),restParam=require("lodash.restparam");module.exports=createAssigner},{"lodash._bindcallback":12,"lodash._isiterateecall":15,"lodash.restparam":20}],14:[function(require,module,exports){function isObjectLike(value){return!!value&&"object"==typeof value}function getNative(object,key){var value=null==object?void 0:object[key];return isNative(value)?value:void 0}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isNative(value){return null==value?!1:isFunction(value)?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}var funcTag="[object Function]",reIsHostCtor=/^\[object .+?Constructor\]$/,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");module.exports=getNative},{}],15:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArrayLike(value){return null!=value&&isLength(getLength(value))}function isIndex(value,length){return value="number"==typeof value||reIsUint.test(value)?+value:-1,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&value%1==0&&length>value}function isIterateeCall(value,index,object){if(!isObject(object))return!1;var type=typeof index;if("number"==type?isArrayLike(object)&&isIndex(index,object.length):"string"==type&&index in object){var other=object[index];return value===value?value===other:other!==other}return!1}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}var reIsUint=/^\d+$/,MAX_SAFE_INTEGER=9007199254740991,getLength=baseProperty("length");module.exports=isIterateeCall},{}],16:[function(require,module,exports){function assignWith(object,source,customizer){for(var index=-1,props=keys(source),length=props.length;++index<length;){var key=props[index],value=object[key],result=customizer(value,source[key],key,object,source);(result===result?result===value:value!==value)&&(void 0!==value||key in object)||(object[key]=result)}return object}var baseAssign=require("lodash._baseassign"),createAssigner=require("lodash._createassigner"),keys=require("lodash.keys"),assign=createAssigner(function(object,source,customizer){return customizer?assignWith(object,source,customizer):baseAssign(object,source)});module.exports=assign},{"lodash._baseassign":10,"lodash._createassigner":13,"lodash.keys":19}],17:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArguments(value){return isArrayLikeObject(value)&&hasOwnProperty.call(value,"callee")&&(!propertyIsEnumerable.call(value,"callee")||objectToString.call(value)==argsTag)}function isArrayLike(value){return null!=value&&isLength(getLength(value))&&!isFunction(value)}function isArrayLikeObject(value){return isObjectLike(value)&&isArrayLike(value)}function isFunction(value){var tag=isObject(value)?objectToString.call(value):"";return tag==funcTag||tag==genTag}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isObjectLike(value){return!!value&&"object"==typeof value}var MAX_SAFE_INTEGER=9007199254740991,argsTag="[object Arguments]",funcTag="[object Function]",genTag="[object GeneratorFunction]",objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,objectToString=objectProto.toString,propertyIsEnumerable=objectProto.propertyIsEnumerable,getLength=baseProperty("length");module.exports=isArguments},{}],18:[function(require,module,exports){function isObjectLike(value){return!!value&&"object"==typeof value}function getNative(object,key){var value=null==object?void 0:object[key];return isNative(value)?value:void 0}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function isFunction(value){return isObject(value)&&objToString.call(value)==funcTag}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function isNative(value){return null==value?!1:isFunction(value)?reIsNative.test(fnToString.call(value)):isObjectLike(value)&&reIsHostCtor.test(value)}var arrayTag="[object Array]",funcTag="[object Function]",reIsHostCtor=/^\[object .+?Constructor\]$/,objectProto=Object.prototype,fnToString=Function.prototype.toString,hasOwnProperty=objectProto.hasOwnProperty,objToString=objectProto.toString,reIsNative=RegExp("^"+fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),nativeIsArray=getNative(Array,"isArray"),MAX_SAFE_INTEGER=9007199254740991,isArray=nativeIsArray||function(value){return isObjectLike(value)&&isLength(value.length)&&objToString.call(value)==arrayTag};module.exports=isArray},{}],19:[function(require,module,exports){function baseProperty(key){return function(object){return null==object?void 0:object[key]}}function isArrayLike(value){return null!=value&&isLength(getLength(value))}function isIndex(value,length){return value="number"==typeof value||reIsUint.test(value)?+value:-1,length=null==length?MAX_SAFE_INTEGER:length,value>-1&&value%1==0&&length>value}function isLength(value){return"number"==typeof value&&value>-1&&value%1==0&&MAX_SAFE_INTEGER>=value}function shimKeys(object){for(var props=keysIn(object),propsLength=props.length,length=propsLength&&object.length,allowIndexes=!!length&&isLength(length)&&(isArray(object)||isArguments(object)),index=-1,result=[];++index<propsLength;){var key=props[index];(allowIndexes&&isIndex(key,length)||hasOwnProperty.call(object,key))&&result.push(key)}return result}function isObject(value){var type=typeof value;return!!value&&("object"==type||"function"==type)}function keysIn(object){if(null==object)return[];isObject(object)||(object=Object(object));var length=object.length;length=length&&isLength(length)&&(isArray(object)||isArguments(object))&&length||0;for(var Ctor=object.constructor,index=-1,isProto="function"==typeof Ctor&&Ctor.prototype===object,result=Array(length),skipIndexes=length>0;++index<length;)result[index]=index+"";for(var key in object)skipIndexes&&isIndex(key,length)||"constructor"==key&&(isProto||!hasOwnProperty.call(object,key))||result.push(key);return result}var getNative=require("lodash._getnative"),isArguments=require("lodash.isarguments"),isArray=require("lodash.isarray"),reIsUint=/^\d+$/,objectProto=Object.prototype,hasOwnProperty=objectProto.hasOwnProperty,nativeKeys=getNative(Object,"keys"),MAX_SAFE_INTEGER=9007199254740991,getLength=baseProperty("length"),keys=nativeKeys?function(object){var Ctor=null==object?void 0:object.constructor;return"function"==typeof Ctor&&Ctor.prototype===object||"function"!=typeof object&&isArrayLike(object)?shimKeys(object):isObject(object)?nativeKeys(object):[]}:shimKeys;module.exports=keys},{"lodash._getnative":14,"lodash.isarguments":17,"lodash.isarray":18}],20:[function(require,module,exports){function restParam(func,start){if("function"!=typeof func)throw new TypeError(FUNC_ERROR_TEXT);return start=nativeMax(void 0===start?func.length-1:+start||0,0),function(){for(var args=arguments,index=-1,length=nativeMax(args.length-start,0),rest=Array(length);++index<length;)rest[index]=args[start+index];switch(start){case 0:return func.call(this,rest);case 1:return func.call(this,args[0],rest);case 2:return func.call(this,args[0],args[1],rest)}var otherArgs=Array(start+1);for(index=-1;++index<start;)otherArgs[index]=args[index];return otherArgs[start]=rest,func.apply(this,otherArgs)}}var FUNC_ERROR_TEXT="Expected a function",nativeMax=Math.max;module.exports=restParam},{}]},{},[7])(7)}); |
@@ -34,2 +34,3 @@ var React = require('react'); | ||
appElement: React.PropTypes.instanceOf(SafeHTMLElement), | ||
onAfterOpen: React.PropTypes.func, | ||
onRequestClose: React.PropTypes.func, | ||
@@ -36,0 +37,0 @@ closeTimeoutMS: React.PropTypes.number, |
@@ -79,2 +79,6 @@ var React = require('react'); | ||
this.setState({afterOpen: true}); | ||
if (this.props.isOpen && this.props.onAfterOpen) { | ||
this.props.onAfterOpen(); | ||
} | ||
}.bind(this)); | ||
@@ -81,0 +85,0 @@ }, |
{ | ||
"name": "react-modal", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Accessible modal dialog component for React.JS", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index", |
@@ -10,6 +10,7 @@ # react-modal | ||
isOpen={bool} | ||
onRequestClose={fn} | ||
onAfterOpen={afterOpenFn} | ||
onRequestClose={requestOpenFn} | ||
closeTimeoutMS={n} | ||
style={customStyle}> | ||
style={customStyle} | ||
> | ||
<h1>Modal Content</h1> | ||
@@ -19,2 +20,3 @@ <p>Etc.</p> | ||
``` | ||
## Styles | ||
@@ -53,6 +55,14 @@ Styles are passed as an object with 2 keys, 'overlay' and 'content' like so | ||
###Overriding styles globally | ||
### Using CSS Classes | ||
The default styles above are available on `Modal.defaultStyles`. | ||
If you prefer not to use inline styles or are unable to do so in your project, | ||
you can pass `className` and `overlayClassName` props to the Modal. If you do | ||
this then none of the default styles will apply and you will have full control | ||
over styling via CSS. | ||
### Overriding styles globally | ||
The default styles above are available on `Modal.defaultStyles`. Changes to this | ||
object will apply to all instances of the modal. | ||
## Examples | ||
@@ -101,2 +111,7 @@ Inside an app: | ||
afterOpenModal: function() { | ||
// references are now sync'd and can be accessed. | ||
this.refs.subtitle.style.color = '#f00'; | ||
}, | ||
closeModal: function() { | ||
@@ -112,6 +127,7 @@ this.setState({modalIsOpen: false}); | ||
isOpen={this.state.modalIsOpen} | ||
onAfterOpen={this.afterOpenModal} | ||
onRequestClose={this.closeModal} | ||
style={customStyles} > | ||
<h2>Hello</h2> | ||
<h2 ref="subtitle">Hello</h2> | ||
<button onClick={this.closeModal}>close</button> | ||
@@ -145,3 +161,4 @@ <div>I am a modal</div> | ||
isOpen={bool} | ||
onRequestClose={fn} | ||
onAfterOpen={afterOpenFn} | ||
onRequestClose={requestCloseFn} | ||
closeTimeoutMS={n} | ||
@@ -148,0 +165,0 @@ shouldCloseOnOverlayClick={false} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
108095
26
2227
171
0