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

mui-modal-provider

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mui-modal-provider - npm Package Compare versions

Comparing version 1.4.3 to 1.5.0

dist/test-utils/LegacyModal.d.ts

3

dist/ModalProvider.d.ts
import React from 'react';
declare type Props = {
children: React.ReactNode;
beta?: boolean;
};
export default function ModalProvider({ children }: Props): JSX.Element;
export default function ModalProvider({ children, beta }: Props): JSX.Element;
export {};

@@ -173,3 +173,5 @@ 'use strict';

function ModalProvider(_ref) {
var children = _ref.children;
var children = _ref.children,
_ref$beta = _ref.beta,
beta = _ref$beta === void 0 ? false : _ref$beta;

@@ -288,15 +290,35 @@ var _React$useReducer = React__default.useReducer(reducer, initialState),

var handleExited = function handleExited() {
_destroy(id);
var _props$TransitionProp;
if (props && props.onExited) {
if (props === null || props === void 0 ? void 0 : props.onExited) {
props.onExited.apply(props, arguments);
}
if (props === null || props === void 0 ? void 0 : (_props$TransitionProp = props.TransitionProps) === null || _props$TransitionProp === void 0 ? void 0 : _props$TransitionProp.onExited) {
var _props$TransitionProp2;
(_props$TransitionProp2 = props.TransitionProps).onExited.apply(_props$TransitionProp2, arguments);
}
_destroy(id);
};
var extraProps = {};
if (beta) {
extraProps = {
TransitionProps: _extends({}, props === null || props === void 0 ? void 0 : props.TransitionProps, {
onExited: handleExited
})
};
} else {
extraProps = {
onExited: handleExited
};
}
return React__default.createElement(Component, Object.assign({}, props, {
key: id,
onClose: handleClose
}, options && !options.destroyOnClose && {
onExited: handleExited
}));
}, options && !options.destroyOnClose && extraProps));
});

@@ -303,0 +325,0 @@ };

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o,e,t=require("react"),n=(o=t)&&"object"==typeof o&&"default"in o?o.default:o;function r(){return(r=Object.assign||function(o){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n])}return o}).apply(this,arguments)}function a(o,e){if(null==o)return{};var t,n,r={},a=Object.keys(o);for(n=0;n<a.length;n++)e.indexOf(t=a[n])>=0||(r[t]=o[t]);return r}!function(o){o.SHOW="SHOW",o.HIDE="HIDE",o.UPDATE="UPDATE",o.DESTROY="DESTROY",o.DESTROY_BY_ROOT_ID="DESTROY_BY_ROOT_ID",o.UNKNOWN="UNKNOWN"}(e||(e={}));var s={};function d(o,t){switch(t.type){case e.SHOW:var n,a=t.payload,s=a.options;return r({},o,((n={})[a.id]={component:a.component,props:r({},a.props,{open:!0}),options:s},n));case e.HIDE:var d,i=t.payload.id;return o[i]?r({},o,((d={})[i]=r({},o[i],{props:r({},o[i].props,{open:!1})}),d)):o;case e.UPDATE:var u,l=t.payload,c=l.id;return o[c]?r({},o,((u={})[c]=r({},o[c],{props:r({},o[c].props,l.props)}),u)):o;case e.DESTROY:var p=t.payload.id,f=r({},o);return delete f[p],f;case e.DESTROY_BY_ROOT_ID:var y=t.payload.rootId;return Object.keys(o).filter((function(o){return o.split(".")[0]!==y})).reduce((function(e,t){var n;return r({},e,((n={})[t]=o[t],n))}),{});default:throw new Error("Unexpected action")}}var i=t.createContext({state:s,hideModal:function(){},showModal:function(){return{id:"id",hide:function(){},destroy:function(){},update:function(){}}},destroyModal:function(){},updateModal:function(){},destroyModalsByRootId:function(){}}),u=function(o){void 0===o&&(o=8);for(var e=[],t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length,r=0;r<o;r++)e[r]=t.charAt(Math.floor(Math.random()*n));return e.join("")},l={disableAutoDestroy:!1};exports.default=function(o){var t=o.children,r=n.useReducer(d,s),l=r[0],c=r[1],p=n.useCallback((function(o,t){var n=a(t,["open"]);o?c({type:e.UPDATE,payload:{id:o,props:n}}):console.error("[ERROR]: Modal ID is missing")}),[c]),f=n.useCallback((function(o){o?c({type:e.HIDE,payload:{id:o}}):console.error("[ERROR]: Modal ID is missing")}),[c]),y=n.useCallback((function(o){o?c({type:e.DESTROY,payload:{id:o}}):console.error("[ERROR]: Modal ID is missing")}),[c]),O=n.useCallback((function(o){o?c({type:e.DESTROY_BY_ROOT_ID,payload:{rootId:o}}):console.error("[ERROR]: Modal root ID is missing")}),[c]),R=n.useCallback((function(o,t,n){var r=u(8);return n&&n.rootId&&(r=n.rootId+"."+r),c({type:e.SHOW,payload:{id:r,component:o,props:t,options:n}}),{id:r,hide:function(){return f(r)},destroy:function(){return y(r)},update:function(o){return p(r,o)}}}),[c,f,y,p]);return n.createElement(i.Provider,{value:{state:l,updateModal:p,hideModal:f,destroyModal:y,showModal:R,destroyModalsByRootId:O}},t,Object.keys(l).map((function(o){var e=l[o],t=e.props,r=e.options;return n.createElement(e.component,Object.assign({},t,{key:o,onClose:function(){r&&r.destroyOnClose?y(o):f(o),t&&t.onClose&&t.onClose.apply(t,arguments)}},r&&!r.destroyOnClose&&{onExited:function(){y(o),t&&t.onExited&&t.onExited.apply(t,arguments)}}))})))},exports.useModal=function(o){void 0===o&&(o=l);var e=r({},l,o).disableAutoDestroy,n=t.useContext(i),s=n.showModal,d=n.destroyModalsByRootId,c=a(n,["showModal","destroyModalsByRootId"]),p=t.useRef(u(6));return t.useEffect((function(){return function(){e||d(p.current)}}),[e,d]),r({showModal:t.useCallback((function(o,e,t){return s(o,e,r({rootId:p.current},t))}),[s])},c)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var o,e,t=require("react"),n=(o=t)&&"object"==typeof o&&"default"in o?o.default:o;function r(){return(r=Object.assign||function(o){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n])}return o}).apply(this,arguments)}function a(o,e){if(null==o)return{};var t,n,r={},a=Object.keys(o);for(n=0;n<a.length;n++)e.indexOf(t=a[n])>=0||(r[t]=o[t]);return r}!function(o){o.SHOW="SHOW",o.HIDE="HIDE",o.UPDATE="UPDATE",o.DESTROY="DESTROY",o.DESTROY_BY_ROOT_ID="DESTROY_BY_ROOT_ID",o.UNKNOWN="UNKNOWN"}(e||(e={}));var i={};function s(o,t){switch(t.type){case e.SHOW:var n,a=t.payload,i=a.options;return r({},o,((n={})[a.id]={component:a.component,props:r({},a.props,{open:!0}),options:i},n));case e.HIDE:var s,d=t.payload.id;return o[d]?r({},o,((s={})[d]=r({},o[d],{props:r({},o[d].props,{open:!1})}),s)):o;case e.UPDATE:var u,l=t.payload,c=l.id;return o[c]?r({},o,((u={})[c]=r({},o[c],{props:r({},o[c].props,l.props)}),u)):o;case e.DESTROY:var p=t.payload.id,f=r({},o);return delete f[p],f;case e.DESTROY_BY_ROOT_ID:var y=t.payload.rootId;return Object.keys(o).filter((function(o){return o.split(".")[0]!==y})).reduce((function(e,t){var n;return r({},e,((n={})[t]=o[t],n))}),{});default:throw new Error("Unexpected action")}}var d=t.createContext({state:i,hideModal:function(){},showModal:function(){return{id:"id",hide:function(){},destroy:function(){},update:function(){}}},destroyModal:function(){},updateModal:function(){},destroyModalsByRootId:function(){}}),u=function(o){void 0===o&&(o=8);for(var e=[],t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=t.length,r=0;r<o;r++)e[r]=t.charAt(Math.floor(Math.random()*n));return e.join("")},l={disableAutoDestroy:!1};exports.default=function(o){var t=o.children,l=o.beta,c=void 0!==l&&l,p=n.useReducer(s,i),f=p[0],y=p[1],O=n.useCallback((function(o,t){var n=a(t,["open"]);o?y({type:e.UPDATE,payload:{id:o,props:n}}):console.error("[ERROR]: Modal ID is missing")}),[y]),v=n.useCallback((function(o){o?y({type:e.HIDE,payload:{id:o}}):console.error("[ERROR]: Modal ID is missing")}),[y]),E=n.useCallback((function(o){o?y({type:e.DESTROY,payload:{id:o}}):console.error("[ERROR]: Modal ID is missing")}),[y]),R=n.useCallback((function(o){o?y({type:e.DESTROY_BY_ROOT_ID,payload:{rootId:o}}):console.error("[ERROR]: Modal root ID is missing")}),[y]),D=n.useCallback((function(o,t,n){var r=u(8);return n&&n.rootId&&(r=n.rootId+"."+r),y({type:e.SHOW,payload:{id:r,component:o,props:t,options:n}}),{id:r,hide:function(){return v(r)},destroy:function(){return E(r)},update:function(o){return O(r,o)}}}),[y,v,E,O]);return n.createElement(d.Provider,{value:{state:f,updateModal:O,hideModal:v,destroyModal:E,showModal:D,destroyModalsByRootId:R}},t,Object.keys(f).map((function(o){var e,t=f[o],a=t.component,i=t.props,s=t.options,d=function(){var e,t;(null==i?void 0:i.onExited)&&i.onExited.apply(i,arguments),(null==i||null===(e=i.TransitionProps)||void 0===e?void 0:e.onExited)&&(t=i.TransitionProps).onExited.apply(t,arguments),E(o)};return e=c?{TransitionProps:r({},null==i?void 0:i.TransitionProps,{onExited:d})}:{onExited:d},n.createElement(a,Object.assign({},i,{key:o,onClose:function(){s&&s.destroyOnClose?E(o):v(o),i&&i.onClose&&i.onClose.apply(i,arguments)}},s&&!s.destroyOnClose&&e))})))},exports.useModal=function(o){void 0===o&&(o=l);var e=r({},l,o).disableAutoDestroy,n=t.useContext(d),i=n.showModal,s=n.destroyModalsByRootId,c=a(n,["showModal","destroyModalsByRootId"]),p=t.useRef(u(6));return t.useEffect((function(){return function(){e||s(p.current)}}),[e,s]),r({showModal:t.useCallback((function(o,e,t){return i(o,e,r({rootId:p.current},t))}),[i])},c)};
//# sourceMappingURL=mui-modal-provider.cjs.production.min.js.map

@@ -166,3 +166,5 @@ import React, { createContext, useContext, useRef, useEffect, useCallback } from 'react';

function ModalProvider(_ref) {
var children = _ref.children;
var children = _ref.children,
_ref$beta = _ref.beta,
beta = _ref$beta === void 0 ? false : _ref$beta;

@@ -281,15 +283,35 @@ var _React$useReducer = React.useReducer(reducer, initialState),

var handleExited = function handleExited() {
_destroy(id);
var _props$TransitionProp;
if (props && props.onExited) {
if (props === null || props === void 0 ? void 0 : props.onExited) {
props.onExited.apply(props, arguments);
}
if (props === null || props === void 0 ? void 0 : (_props$TransitionProp = props.TransitionProps) === null || _props$TransitionProp === void 0 ? void 0 : _props$TransitionProp.onExited) {
var _props$TransitionProp2;
(_props$TransitionProp2 = props.TransitionProps).onExited.apply(_props$TransitionProp2, arguments);
}
_destroy(id);
};
var extraProps = {};
if (beta) {
extraProps = {
TransitionProps: _extends({}, props === null || props === void 0 ? void 0 : props.TransitionProps, {
onExited: handleExited
})
};
} else {
extraProps = {
onExited: handleExited
};
}
return React.createElement(Component, Object.assign({}, props, {
key: id,
onClose: handleClose
}, options && !options.destroyOnClose && {
onExited: handleExited
}));
}, options && !options.destroyOnClose && extraProps));
});

@@ -296,0 +318,0 @@ };

import React from 'react';
export declare const OnCloseEvent: Event;
export declare const OnExitedEvent: Event;
export declare type ModalProps = {
open?: boolean;
text: string;
onExited?: (args: any) => void;
onClose?: (args: any) => void;
};
export declare const Modal: React.FC<ModalProps>;
export declare const ModalProviderWrapper: React.FC;
export declare const LegacyModalProviderWrapper: React.FC;
export declare const ModalContextProviderWrapper: React.FC;
{
"version": "1.4.3",
"version": "1.5.0",
"license": "MIT",

@@ -75,6 +75,6 @@ "name": "mui-modal-provider",

"global": {
"branches": 95,
"functions": 95,
"lines": 95,
"statements": 95
"branches": 90,
"functions": 90,
"lines": 90,
"statements": 90
}

@@ -81,0 +81,0 @@ }

@@ -61,2 +61,4 @@ # mui-modal-provider

For [Material-UI v5](https://next.material-ui.com/) use `beta={true}` prop on the ModalProvider.
### See more examples in [example](https://github.com/Quernest/mui-modal-provider/tree/master/example) folder

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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