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.1.0 to 1.2.0

6

dist/ModalContext.d.ts
/// <reference types="react" />
import { IState } from './State';
import { IState, IProps } from './State';
export interface IModalContext {
state: IState;
hideModal(id: string): void;
showModal(component: React.ComponentType<any>, props: Object): {
showModal(component: React.ComponentType<any>, props: IProps): {
id: string;
hide: () => void;
destroy: () => void;
update: (newProps: Object) => void;
update: (newProps: IProps) => void;
};

@@ -12,0 +12,0 @@ destroyModal(id: string): void;

@@ -86,3 +86,3 @@ 'use strict';

var hideModal = React__default.useCallback(function (id) {
setState(function (prevState) {
return setState(function (prevState) {
var _extends2;

@@ -98,3 +98,3 @@

var destroyModal = React__default.useCallback(function (id) {
setState(function (prevState) {
return setState(function (prevState) {
var newState = _objectWithoutPropertiesLoose(prevState, [id].map(_toPropertyKey));

@@ -106,23 +106,12 @@

var showModal = React__default.useCallback(function (component, props) {
if (props === void 0) {
props = {};
}
var id = "" + (+new Date()).toString(16);
var updateState = function updateState(prevState, newProps) {
var id = Math.random().toString(36).substr(2, 9);
setState(function (prevState) {
var _extends3;
if (newProps === void 0) {
newProps = {};
}
return _extends({}, prevState, (_extends3 = {}, _extends3[id] = {
component: component,
props: _extends({}, props, newProps)
props: _extends({}, props, {
open: true
})
}, _extends3));
};
setState(function (prevState) {
return updateState(prevState);
});

@@ -138,8 +127,8 @@ return {

update: function update(newProps) {
if (newProps === void 0) {
newProps = {};
}
return setState(function (prevState) {
var _extends4;
return setState(function (prevState) {
return updateState(prevState, newProps);
return !prevState[id] ? prevState : _extends({}, prevState, (_extends4 = {}, _extends4[id] = _extends({}, prevState[id], {
props: _extends({}, prevState[id] ? prevState[id].props : {}, newProps)
}), _extends4));
});

@@ -150,3 +139,3 @@ }

function renderState() {
var renderState = function renderState() {
return Object.keys(state).map(function (id) {

@@ -156,13 +145,26 @@ var _state$id = state[id],

props = _state$id.props;
var handleClose = function handleClose() {
if (props && props.onClose) {
props.onClose();
}
hideModal(id);
};
var handleExited = function handleExited() {
if (props && props.onExited) {
props.onExited();
}
destroyModal(id);
};
return Component ? React__default.createElement(Component, Object.assign({}, props, {
key: id,
onClose: function onClose() {
return hideModal(id);
},
onExited: function onExited() {
return destroyModal(id);
}
onClose: handleClose,
onExited: handleExited
})) : null;
});
}
};

@@ -169,0 +171,0 @@ return React__default.createElement(ModalContext.Provider, {

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=e.createContext({state:{},hideModal:function(){},showModal:function(){return{id:"id",hide:function(){},destroy:function(){},update:function(){}}},destroyModal:function(){}}),i={};exports.ModalContext=u,exports.default=function(t){var e=t.children,a=n.useState(i),c=a[0],f=a[1],l=n.useCallback((function(t){f((function(e){var n;return r({},e,((n={})[t]=r({},e[t],{props:r({},e[t]?e[t].props:{},{open:!1})}),n))}))}),[]),s=n.useCallback((function(t){f((function(e){return function(t,e){if(null==t)return{};var n,r,o={},u=Object.keys(t);for(r=0;r<u.length;r++)e.indexOf(n=u[r])>=0||(o[n]=t[n]);return o}(e,[t].map(o))}))}),[]),d=n.useCallback((function(t,e){void 0===e&&(e={});var n=""+(+new Date).toString(16),o=function(o,u){var i;return void 0===u&&(u={}),r({},o,((i={})[n]={component:t,props:r({},e,u)},i))};return f((function(t){return o(t)})),{id:n,hide:function(){return l(n)},destroy:function(){return s(n)},update:function(t){return void 0===t&&(t={}),f((function(e){return o(e,t)}))}}}),[s,l]);return n.createElement(u.Provider,{value:{hideModal:l,showModal:d,destroyModal:s,state:c}},e,Object.keys(c).map((function(t){var e=c[t],r=e.component;return r?n.createElement(r,Object.assign({},e.props,{key:t,onClose:function(){return l(t)},onExited:function(){return s(t)}})):null})))},exports.useModal=function(){return e.useContext(u)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("react"),n=(t=e)&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function o(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var r=n.call(t,"string");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=e.createContext({state:{},hideModal:function(){},showModal:function(){return{id:"id",hide:function(){},destroy:function(){},update:function(){}}},destroyModal:function(){}}),i={};exports.ModalContext=u,exports.default=function(t){var e=t.children,a=n.useState(i),c=a[0],s=a[1],f=n.useCallback((function(t){return s((function(e){var n;return r({},e,((n={})[t]=r({},e[t],{props:r({},e[t]?e[t].props:{},{open:!1})}),n))}))}),[]),l=n.useCallback((function(t){return s((function(e){return function(t,e){if(null==t)return{};var n,r,o={},u=Object.keys(t);for(r=0;r<u.length;r++)e.indexOf(n=u[r])>=0||(o[n]=t[n]);return o}(e,[t].map(o))}))}),[]),p=n.useCallback((function(t,e){var n=Math.random().toString(36).substr(2,9);return s((function(o){var u;return r({},o,((u={})[n]={component:t,props:r({},e,{open:!0})},u))})),{id:n,hide:function(){return f(n)},destroy:function(){return l(n)},update:function(t){return s((function(e){var o;return e[n]?r({},e,((o={})[n]=r({},e[n],{props:r({},e[n]?e[n].props:{},t)}),o)):e}))}}}),[l,f]);return n.createElement(u.Provider,{value:{hideModal:f,showModal:p,destroyModal:l,state:c}},e,Object.keys(c).map((function(t){var e=c[t],r=e.component,o=e.props;return r?n.createElement(r,Object.assign({},o,{key:t,onClose:function(){o&&o.onClose&&o.onClose(),f(t)},onExited:function(){o&&o.onExited&&o.onExited(),l(t)}})):null})))},exports.useModal=function(){return e.useContext(u)};
//# sourceMappingURL=mui-modal-provider.cjs.production.min.js.map

@@ -79,3 +79,3 @@ import React, { createContext, useContext } from 'react';

var hideModal = React.useCallback(function (id) {
setState(function (prevState) {
return setState(function (prevState) {
var _extends2;

@@ -91,3 +91,3 @@

var destroyModal = React.useCallback(function (id) {
setState(function (prevState) {
return setState(function (prevState) {
var newState = _objectWithoutPropertiesLoose(prevState, [id].map(_toPropertyKey));

@@ -99,23 +99,12 @@

var showModal = React.useCallback(function (component, props) {
if (props === void 0) {
props = {};
}
var id = "" + (+new Date()).toString(16);
var updateState = function updateState(prevState, newProps) {
var id = Math.random().toString(36).substr(2, 9);
setState(function (prevState) {
var _extends3;
if (newProps === void 0) {
newProps = {};
}
return _extends({}, prevState, (_extends3 = {}, _extends3[id] = {
component: component,
props: _extends({}, props, newProps)
props: _extends({}, props, {
open: true
})
}, _extends3));
};
setState(function (prevState) {
return updateState(prevState);
});

@@ -131,8 +120,8 @@ return {

update: function update(newProps) {
if (newProps === void 0) {
newProps = {};
}
return setState(function (prevState) {
var _extends4;
return setState(function (prevState) {
return updateState(prevState, newProps);
return !prevState[id] ? prevState : _extends({}, prevState, (_extends4 = {}, _extends4[id] = _extends({}, prevState[id], {
props: _extends({}, prevState[id] ? prevState[id].props : {}, newProps)
}), _extends4));
});

@@ -143,3 +132,3 @@ }

function renderState() {
var renderState = function renderState() {
return Object.keys(state).map(function (id) {

@@ -149,13 +138,26 @@ var _state$id = state[id],

props = _state$id.props;
var handleClose = function handleClose() {
if (props && props.onClose) {
props.onClose();
}
hideModal(id);
};
var handleExited = function handleExited() {
if (props && props.onExited) {
props.onExited();
}
destroyModal(id);
};
return Component ? React.createElement(Component, Object.assign({}, props, {
key: id,
onClose: function onClose() {
return hideModal(id);
},
onExited: function onExited() {
return destroyModal(id);
}
onClose: handleClose,
onExited: handleExited
})) : null;
});
}
};

@@ -162,0 +164,0 @@ return React.createElement(ModalContext.Provider, {

/// <reference types="react" />
export interface IProps {
open?: Boolean;
onClose?: () => void;
onExited?: () => void;
[key: string]: any;
}
export interface IStateElement {
component: React.ComponentType<any>;
props: Object;
props: IProps;
}

@@ -6,0 +12,0 @@ export interface IState {

{
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",

@@ -16,5 +16,2 @@ "main": "dist/index.js",

},
"peerDependencies": {
"react": ">=16"
},
"husky": {

@@ -34,13 +31,23 @@ "hooks": {

"module": "dist/modal.esm.js",
"peerDependencies": {
"@types/react": "^16.8.6",
"react": "^16.8.0",
"react-dom": "^16.8.0"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"devDependencies": {
"@types/jest": "^24.9.0",
"@types/react": "^16.9.17",
"@types/react-dom": "^16.9.4",
"husky": "^4.0.10",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"tsdx": "^0.12.3",
"tslib": "^1.10.0",
"typescript": "^3.7.5"
"@types/jest": "^26.0.10",
"@types/react": "^16.9.48",
"@types/react-dom": "^16.9.8",
"husky": "^4.2.5",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"tsdx": "^0.13.3",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
}
}

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