Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

styled-react-modal

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

styled-react-modal - npm Package Compare versions

Comparing version 3.1.0 to 3.1.1

2

build/umd/index.js

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("styled-components"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","styled-components","react","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["styled-react-modal"]={},e.styled,e.React,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n),u=o(t),l=o(r),c=a.default.div.withConfig({displayName:"baseStyles__BaseModalBackground"})(["display:flex;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:30;background-color:rgba(0,0,0,0.5);align-items:center;justify-content:center;"]);function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function i(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,a=[],u=!0,l=!1;try{for(t=t.call(e);!(u=(r=t.next()).done)&&(a.push(r.value),!n||a.length!==n);u=!0);}catch(e){l=!0,o=e}finally{try{u||null==t.return||t.return()}finally{if(l)throw o}}return a}}(e,n)||function(e,n){if(e){if("string"==typeof e)return f(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?f(e,n):void 0}}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(){}function s(){}s.resetWarningCache=p;var d=function(){function e(e,n,t,r,o,a){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==a){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function n(){return e}e.isRequired=e;var t={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:s,resetWarningCache:p};return t.PropTypes=t,t},y=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){e.exports=d()})),m=u.default.createContext({}),b=m.Provider,v=m.Consumer;function g(e){var n=e.backgroundComponent,r=e.children,o=t.useRef(null),a=i(t.useState(null),2),l=a[0],f=a[1],p=i(t.useState(c),2),s=p[0],d=p[1];return t.useEffect((function(){n&&d(n)}),[d,n]),t.useEffect((function(){f(o.current)}),[f,o]),u.default.createElement(b,{value:{modalNode:l,BackgroundComponent:s}},r,u.default.createElement("div",{ref:o}))}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(this,arguments)}function O(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}g.propTypes={backgroundComponent:y.oneOfType([y.element,y.object])};var w=["WrapperComponent","children","onBackgroundClick","onEscapeKeydown","allowScroll","beforeOpen","afterOpen","beforeClose","afterClose","backgroundProps","isOpen"];function C(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];e&&e.apply(void 0,t)}function k(e){var n,r=e.WrapperComponent,o=e.children,a=e.onBackgroundClick,c=e.onEscapeKeydown,f=e.allowScroll,p=e.beforeOpen,s=e.afterOpen,d=e.beforeClose,y=e.afterClose,m=e.backgroundProps,b=e.isOpen,g=O(e,w),k=t.useRef(null),E=t.useRef(null),j=t.useRef(!1),P=i(t.useState(!1),2),S=P[0],T=P[1];function _(e){k.current===e.target&&a&&a(e)}return t.useEffect((function(){function e(e){T(e),C(e?s:y)}function n(n){if(n){var t=n();"function"==typeof(null==t?void 0:t.then)?(j.current=!0,t.then((function(){e(b),j.current=!1}))):e(b)}else e(b)}S===b||j.current||n(b?p:d)}),[j,S,b,p,d,y,s]),t.useEffect((function(){function e(e){"Escape"===e.key&&c&&c(e)}return S&&document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[S,c]),t.useEffect((function(){return S&&!f&&(E.current=document.body.style.overflow,document.body.style.overflow="hidden"),function(){f||(document.body.style.overflow=E.current||"")}}),[S,f]),n=r?u.default.createElement(r,g,o):o,u.default.createElement(v,null,(function(e){var t=e.modalNode,r=e.BackgroundComponent;return t&&r&&S?l.default.createPortal(u.default.createElement(r,h({},m,{onClick:_,ref:k}),n),t):null}))}k.styled=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n?a.default.div.withConfig({displayName:"Modal__wrap"}).apply(void 0,n):a.default.div.withConfig({displayName:"Modal__wrap"})();return function(e){return u.default.createElement(k,h({WrapperComponent:r},e))}},k.defaultProps={backgroundProps:{}},k.propTypes={WrapperComponent:y.oneOfType([y.element,y.object]),onBackgroundClick:y.func,onEscapeKeydown:y.func,allowScroll:y.bool,beforeOpen:y.func,afterOpen:y.func,beforeClose:y.func,afterClose:y.func,backgroundProps:y.object,isOpen:y.bool},e.BaseModalBackground=c,e.ModalProvider=g,e.default=k,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("styled-components"),require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","styled-components","react","react-dom"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self)["styled-react-modal"]={},e.styled,e.React,e.ReactDOM)}(this,(function(e,n,t,r){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(n),u=o(t),l=o(r),c=a.default.div.withConfig({displayName:"baseStyles__BaseModalBackground"})(["display:flex;position:fixed;top:0;left:0;width:100vw;height:100vh;z-index:30;background-color:rgba(0,0,0,0.5);align-items:center;justify-content:center;"]);function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function i(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,a=[],u=!0,l=!1;try{for(t=t.call(e);!(u=(r=t.next()).done)&&(a.push(r.value),!n||a.length!==n);u=!0);}catch(e){l=!0,o=e}finally{try{u||null==t.return||t.return()}finally{if(l)throw o}}return a}}(e,n)||function(e,n){if(e){if("string"==typeof e)return f(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?f(e,n):void 0}}(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function p(){}function d(){}d.resetWarningCache=p;var s=function(){function e(e,n,t,r,o,a){if("SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"!==a){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function n(){return e}e.isRequired=e;var t={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:n,element:e,elementType:e,instanceOf:n,node:e,objectOf:n,oneOf:n,oneOfType:n,shape:n,exact:n,checkPropTypes:d,resetWarningCache:p};return t.PropTypes=t,t},y=function(e,n){return e(n={exports:{}},n.exports),n.exports}((function(e){e.exports=s()})),m=u.default.createContext({}),b=m.Provider,v=m.Consumer;function g(e){var n=e.backgroundComponent,r=e.children,o=t.useRef(null),a=i(t.useState(null),2),l=a[0],f=a[1],p=i(t.useState(c),2),d=p[0],s=p[1];return t.useEffect((function(){n&&s(n)}),[s,n]),t.useEffect((function(){f(o.current)}),[f,o]),u.default.createElement(b,{value:{modalNode:l,BackgroundComponent:d}},r,u.default.createElement("div",{ref:o}))}function h(){return h=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},h.apply(this,arguments)}function O(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},a=Object.keys(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)t=a[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}g.propTypes={backgroundComponent:y.oneOfType([y.element,y.object])};var w=["WrapperComponent","children","onBackgroundClick","onEscapeKeydown","allowScroll","beforeOpen","afterOpen","beforeClose","afterClose","backgroundProps","isOpen"];function C(e){for(var n=arguments.length,t=new Array(n>1?n-1:0),r=1;r<n;r++)t[r-1]=arguments[r];e&&e.apply(void 0,t)}function k(e){var n,r=e.WrapperComponent,o=e.children,a=e.onBackgroundClick,c=e.onEscapeKeydown,f=e.allowScroll,p=e.beforeOpen,d=e.afterOpen,s=e.beforeClose,y=e.afterClose,m=e.backgroundProps,b=void 0===m?{}:m,g=e.isOpen,k=O(e,w),E=t.useRef(null),j=t.useRef(null),S=t.useRef(!1),T=i(t.useState(!1),2),_=T[0],P=T[1];function x(e){E.current===e.target&&a&&a(e)}return t.useEffect((function(){function e(e){P(e),C(e?d:y)}function n(n){if(n){var t=n();"function"==typeof(null==t?void 0:t.then)?(S.current=!0,t.then((function(){e(g),S.current=!1}))):e(g)}else e(g)}_===g||S.current||n(g?p:s)}),[S,_,g,p,s,y,d]),t.useEffect((function(){function e(e){"Escape"===e.key&&c&&c(e)}return _&&document.addEventListener("keydown",e),function(){document.removeEventListener("keydown",e)}}),[_,c]),t.useEffect((function(){return _&&!f&&(j.current=document.body.style.overflow,document.body.style.overflow="hidden"),function(){f||(document.body.style.overflow=j.current||"")}}),[_,f]),n=r?u.default.createElement(r,k,o):o,u.default.createElement(v,null,(function(e){var t=e.modalNode,r=e.BackgroundComponent;return t&&r&&_?l.default.createPortal(u.default.createElement(r,h({},b,{onClick:x,ref:E}),n),t):null}))}k.styled=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=n?a.default.div.withConfig({displayName:"Modal__wrap"}).apply(void 0,n):a.default.div.withConfig({displayName:"Modal__wrap"})();return function(e){return u.default.createElement(k,h({WrapperComponent:r},e))}},k.propTypes={WrapperComponent:y.oneOfType([y.element,y.object]),onBackgroundClick:y.func,onEscapeKeydown:y.func,allowScroll:y.bool,beforeOpen:y.func,afterOpen:y.func,beforeClose:y.func,afterClose:y.func,backgroundProps:y.object,isOpen:y.bool},e.BaseModalBackground=c,e.ModalProvider=g,e.default=k,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "styled-react-modal",
"version": "3.1.0",
"version": "3.1.1",
"description": "A React modal built with styled-components.",

@@ -5,0 +5,0 @@ "main": "build/umd/index.js",

@@ -21,3 +21,3 @@ import React, { useState, useRef, useEffect } from "react";

afterClose,
backgroundProps,
backgroundProps = {},
isOpen: isOpenProp,

@@ -149,6 +149,2 @@ ...rest

Modal.defaultProps = {
backgroundProps: {}
};
Modal.propTypes = {

@@ -155,0 +151,0 @@ WrapperComponent: PropTypes.oneOfType([PropTypes.element, PropTypes.object]),

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc