styled-react-modal
Advanced tools
Comparing version 1.2.3 to 1.2.4
@@ -1,1 +0,1 @@ | ||
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t){e.exports=require("react")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseModalBackground=void 0;var o,r,i,a=(o=["\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 30;\n background-color: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n"],r=["\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 30;\n background-color: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n"],Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(r)}}))),u=n(2),l=(i=u)&&i.__esModule?i:{default:i};t.BaseModalBackground=l.default.div.withConfig({displayName:"baseStyles__BaseModalBackground",componentId:"sc-12bzkqq-0"})(a)},function(e,t){e.exports=require("styled-components")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Consumer=t.Provider=void 0;var o,r=n(0);var i=((o=r)&&o.__esModule?o:{default:o}).default.createContext(null),a=i.Provider,u=i.Consumer;t.Provider=a,t.Consumer=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseModalBackground=t.ModalProvider=void 0;var o=n(1),r=a(n(5)),i=a(n(6));function a(e){return e&&e.__esModule?e:{default:e}}t.ModalProvider=r.default,t.BaseModalBackground=o.BaseModalBackground,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(0),a=(o=i)&&o.__esModule?o:{default:o},u=n(1),l=n(3);var s=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={modalNode:null,BackgroundComponent:u.BaseModalBackground},n.setModalNode=n.setModalNode.bind(n),n}return function(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)}(t,i.Component),r(t,[{key:"setModalNode",value:function(e){this.setState({modalNode:e})}},{key:"render",value:function(){return a.default.createElement(l.Provider,{value:{modalNode:this.state.modalNode,BackgroundComponent:this.state.BackgroundComponent}},this.props.children,a.default.createElement("div",{ref:this.setModalNode}))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return e.backgroundComponent!==t.BackgroundComponent&&e.backgroundComponent?{BackgroundComponent:e.backgroundComponent}:null}}]),t}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=y(["",""],["",""]),a=y([""],[""]),u=n(0),l=f(u),s=f(n(7)),c=n(2),p=f(c),d=n(3);function f(e){return e&&e.__esModule?e:{default:e}}function y(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(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 b(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)}var O=function(e){function t(e){h(this,t);var n=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={isOpen:!1},n.node=null,n.prevBodyOverflow=null,n.onKeydown=n.onKeydown.bind(n),n.onBackgroundClick=n.onBackgroundClick.bind(n),n.cleanUp=n.cleanUp.bind(n),n}return b(t,u.Component),r(t,[{key:"componentDidMount",value:function(){this.props.isOpen&&this.setState({isOpen:this.props.isOpen})}},{key:"componentDidUpdate",value:function(e,t){t.isOpen!==this.state.isOpen&&(this.state.isOpen?this.state.isOpen&&(document.addEventListener("keydown",this.onKeydown),this.props.allowScroll||(this.prevBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"),this.props.afterOpen&&this.props.afterOpen()):(this.cleanUp(),this.props.afterClose&&this.props.afterClose())),e.isOpen!==this.props.isOpen&&(this.props.isOpen?this.handleChange("beforeOpen",{isOpen:!0}):this.handleChange("beforeClose",{isOpen:!1}))}},{key:"handleChange",value:function(e,t){var n=this;if(this.props[e])try{this.props[e]().then(function(){return n.setState(t)})}catch(e){this.setState(t)}else this.setState(t)}},{key:"componentWillUnmount",value:function(){this.props.isOpen&&this.cleanUp()}},{key:"cleanUp",value:function(){document.removeEventListener("keydown",this.onKeydown),this.props.allowScroll||(document.body.style.overflow=this.prevBodyOverflow||"")}},{key:"onKeydown",value:function(e){"Escape"===e.key&&this.props.onEscapeKeydown&&this.props.onEscapeKeydown(e)}},{key:"onBackgroundClick",value:function(e){this.node===e.target&&this.props.onBackgroundClick&&this.props.onBackgroundClick(e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.WrapperComponent,r=t.children,i=(t.onBackgroundClick,t.onEscapeKeydown,t.allowScroll,t.beforeOpen,t.afterOpen,t.beforeClose,t.afterClose,t.backgroundProps),a=(t.isOpen,function(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}(t,["WrapperComponent","children","onBackgroundClick","onEscapeKeydown","allowScroll","beforeOpen","afterOpen","beforeClose","afterClose","backgroundProps","isOpen"])),u=this.state.isOpen,c=void 0;return c=n?l.default.createElement(n,a,r):r,l.default.createElement(d.Consumer,null,function(t){var n=t.modalNode,r=t.BackgroundComponent;return n&&r&&u?s.default.createPortal(l.default.createElement(r,o({},i,{onClick:e.onBackgroundClick,ref:function(t){e.node=t}}),c),n):null})}}],[{key:"styled",value:function(){var e=p.default.div.withConfig({displayName:"Modal__styles",componentId:"sc-1q9xwty-0"})(i,c.css.apply(void 0,arguments))||p.default.div.withConfig({displayName:"Modal__styles",componentId:"sc-1q9xwty-1"})(a);return function(n){function i(){return h(this,i),v(this,(i.__proto__||Object.getPrototypeOf(i)).apply(this,arguments))}return b(i,u.Component),r(i,[{key:"render",value:function(){return l.default.createElement(t,o({WrapperComponent:e},this.props))}}]),i}()}}]),t}();O.defaultProps={backgroundProps:{}},t.default=O},function(e,t){e.exports=require("react-dom")}]); | ||
module.exports=function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t){e.exports=require("react")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseModalBackground=void 0;var o,r,i,a=(o=["\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 30;\n background-color: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n"],r=["\n display: flex;\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 30;\n background-color: rgba(0, 0, 0, 0.5);\n align-items: center;\n justify-content: center;\n"],Object.freeze(Object.defineProperties(o,{raw:{value:Object.freeze(r)}}))),u=n(2),l=(i=u)&&i.__esModule?i:{default:i};t.BaseModalBackground=l.default.div.withConfig({displayName:"baseStyles__BaseModalBackground",componentId:"sc-12bzkqq-0"})(a)},function(e,t){e.exports=require("styled-components")},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Consumer=t.Provider=void 0;var o,r=n(0);var i=((o=r)&&o.__esModule?o:{default:o}).default.createContext({}),a=i.Provider,u=i.Consumer;t.Provider=a,t.Consumer=u},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.BaseModalBackground=t.ModalProvider=void 0;var o=n(1),r=a(n(5)),i=a(n(6));function a(e){return e&&e.__esModule?e:{default:e}}t.ModalProvider=r.default,t.BaseModalBackground=o.BaseModalBackground,t.default=i.default},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o,r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=n(0),a=(o=i)&&o.__esModule?o:{default:o},u=n(1),l=n(3);var s=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(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}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={modalNode:null,BackgroundComponent:u.BaseModalBackground},n.setModalNode=n.setModalNode.bind(n),n}return function(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)}(t,i.Component),r(t,[{key:"setModalNode",value:function(e){this.setState({modalNode:e})}},{key:"render",value:function(){return a.default.createElement(l.Provider,{value:{modalNode:this.state.modalNode,BackgroundComponent:this.state.BackgroundComponent}},this.props.children,a.default.createElement("div",{ref:this.setModalNode}))}}],[{key:"getDerivedStateFromProps",value:function(e,t){return e.backgroundComponent!==t.BackgroundComponent&&e.backgroundComponent?{BackgroundComponent:e.backgroundComponent}:null}}]),t}();t.default=s},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}(),i=y(["",""],["",""]),a=y([""],[""]),u=n(0),l=f(u),s=f(n(7)),c=n(2),p=f(c),d=n(3);function f(e){return e&&e.__esModule?e:{default:e}}function y(e,t){return Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(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 b(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)}var O=function(e){function t(e){h(this,t);var n=v(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.state={isOpen:!1},n.node=null,n.prevBodyOverflow=null,n.onKeydown=n.onKeydown.bind(n),n.onBackgroundClick=n.onBackgroundClick.bind(n),n.cleanUp=n.cleanUp.bind(n),n}return b(t,u.Component),r(t,[{key:"componentDidMount",value:function(){this.props.isOpen&&this.setState({isOpen:this.props.isOpen})}},{key:"componentDidUpdate",value:function(e,t){t.isOpen!==this.state.isOpen&&(this.state.isOpen?this.state.isOpen&&(document.addEventListener("keydown",this.onKeydown),this.props.allowScroll||(this.prevBodyOverflow=document.body.style.overflow,document.body.style.overflow="hidden"),this.props.afterOpen&&this.props.afterOpen()):(this.cleanUp(),this.props.afterClose&&this.props.afterClose())),e.isOpen!==this.props.isOpen&&(this.props.isOpen?this.handleChange("beforeOpen",{isOpen:!0}):this.handleChange("beforeClose",{isOpen:!1}))}},{key:"handleChange",value:function(e,t){var n=this;if(this.props[e])try{this.props[e]().then(function(){return n.setState(t)})}catch(e){this.setState(t)}else this.setState(t)}},{key:"componentWillUnmount",value:function(){this.props.isOpen&&this.cleanUp()}},{key:"cleanUp",value:function(){document.removeEventListener("keydown",this.onKeydown),this.props.allowScroll||(document.body.style.overflow=this.prevBodyOverflow||"")}},{key:"onKeydown",value:function(e){"Escape"===e.key&&this.props.onEscapeKeydown&&this.props.onEscapeKeydown(e)}},{key:"onBackgroundClick",value:function(e){this.node===e.target&&this.props.onBackgroundClick&&this.props.onBackgroundClick(e)}},{key:"render",value:function(){var e=this,t=this.props,n=t.WrapperComponent,r=t.children,i=(t.onBackgroundClick,t.onEscapeKeydown,t.allowScroll,t.beforeOpen,t.afterOpen,t.beforeClose,t.afterClose,t.backgroundProps),a=(t.isOpen,function(e,t){var n={};for(var o in e)t.indexOf(o)>=0||Object.prototype.hasOwnProperty.call(e,o)&&(n[o]=e[o]);return n}(t,["WrapperComponent","children","onBackgroundClick","onEscapeKeydown","allowScroll","beforeOpen","afterOpen","beforeClose","afterClose","backgroundProps","isOpen"])),u=this.state.isOpen,c=void 0;return c=n?l.default.createElement(n,a,r):r,l.default.createElement(d.Consumer,null,function(t){var n=t.modalNode,r=t.BackgroundComponent;return n&&r&&u?s.default.createPortal(l.default.createElement(r,o({},i,{onClick:e.onBackgroundClick,ref:function(t){e.node=t}}),c),n):null})}}],[{key:"styled",value:function(){var e=p.default.div.withConfig({displayName:"Modal__styles",componentId:"sc-1q9xwty-0"})(i,c.css.apply(void 0,arguments))||p.default.div.withConfig({displayName:"Modal__styles",componentId:"sc-1q9xwty-1"})(a);return function(n){function i(){return h(this,i),v(this,(i.__proto__||Object.getPrototypeOf(i)).apply(this,arguments))}return b(i,u.Component),r(i,[{key:"render",value:function(){return l.default.createElement(t,o({WrapperComponent:e},this.props))}}]),i}()}}]),t}();O.defaultProps={backgroundProps:{}},t.default=O},function(e,t){e.exports=require("react-dom")}]); |
{ | ||
"name": "styled-react-modal", | ||
"version": "1.2.3", | ||
"version": "1.2.4", | ||
"description": "A React modal built with styled-components.", | ||
@@ -27,3 +27,3 @@ "main": "build/index.js", | ||
], | ||
"author": "Alexander Richey <alex@meural.com>", | ||
"author": "Alexander Richey <alexander.richey@gmail.com>", | ||
"license": "MIT", | ||
@@ -30,0 +30,0 @@ "bugs": { |
import React from 'react' | ||
export const { Provider, Consumer } = React.createContext(null) | ||
export const { Provider, Consumer } = React.createContext({}) |
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
31563
20