Socket
Socket
Sign inDemoInstall

react-modal-global

Package Overview
Dependencies
7
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.2.1 to 2.3.0

1

dist/index.d.ts

@@ -227,2 +227,3 @@ import EventEmitter from 'eventemitter3';

closeByComponent<P>(component: ModalComponent<P>, params?: P): void;
closeByName(componentName: keyof Config["components"]): void;
/**

@@ -229,0 +230,0 @@ * Closes all modals.

4

dist/index.ts

@@ -12,4 +12,4 @@ 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var EventEmitter=require("eventemitter3"),jsxRuntime=require("react/jsx-runtime"),react=require("react"),reactDom=require("react-dom");function _interopDefaultLegacy(a){return a&&"object"===typeof a&&"default"in a?a:{"default":a}}var EventEmitter__default=_interopDefaultLegacy(EventEmitter);

b)}replace(a,...[b]){let c=[...this.windows].at(-1);null!=c&&this.windows.delete(c);return this.open(a,b)}replaceNamed(a,...[b]){a=this.getNamedComponent(a);return this.replace(a,b)}close(a){0!==this.windows.size&&this.windows.has(a)&&(1===this.windows.size?this.hide():(this.windows.delete(a),this.events.emit("remove",a)))}closeById(a){[...this.windows].filter(b=>b.params.id===a).forEach(b=>this.close(b))}closeByComponent(a,b){[...this.windows].filter(c=>c.component!==a||null!=b&&c.params.params!==
b?!1:!0).forEach(c=>this.close(c))}closeAll(){this.windows.forEach(a=>this.close(a))}getNamedComponent(a){let b={config:this.config,componentName:a};if(null==this.config)throw Error("ModalController `config` is not defined.",{cause:b});if(null==this.config.components)throw Error("ModalController `config.components` is not defined.",{cause:b});return this.config.components[a]}on(a,b){this.events.on(a,b);return()=>{this.events.off(a,b)}}subscribe(a){this.events.on("add",a);this.events.on("remove",a);
this.events.on("update",a);return()=>{this.events.off("add",a);this.events.off("remove",a);this.events.off("update",a)}}getSnapshot(){return __classPrivateFieldGet(this,_ModalController_snapshot,"f")}refreshSnapshot(){__classPrivateFieldSet(this,_ModalController_snapshot,{active:this.active,windows:[...this.windows]},"f")}}_ModalController_active=new WeakMap;_ModalController_snapshot=new WeakMap;let modalContext=react.createContext(null);
b?!1:!0).forEach(c=>this.close(c))}closeByName(a){a=this.getNamedComponent(a);this.closeByComponent(a)}closeAll(){this.windows.forEach(a=>this.close(a))}getNamedComponent(a){let b={config:this.config,componentName:a};if(null==this.config)throw Error("ModalController `config` is not defined.",{cause:b});if(null==this.config.components)throw Error("ModalController `config.components` is not defined.",{cause:b});return this.config.components[a]}on(a,b){this.events.on(a,b);return()=>{this.events.off(a,
b)}}subscribe(a){this.events.on("add",a);this.events.on("remove",a);this.events.on("update",a);return()=>{this.events.off("add",a);this.events.off("remove",a);this.events.off("update",a)}}getSnapshot(){return __classPrivateFieldGet(this,_ModalController_snapshot,"f")}refreshSnapshot(){__classPrivateFieldSet(this,_ModalController_snapshot,{active:this.active,windows:[...this.windows]},"f")}}_ModalController_active=new WeakMap;_ModalController_snapshot=new WeakMap;let modalContext=react.createContext(null);
function useModalWindow(){let a=react.useContext(modalContext);if(!a)throw Error(`ModalError: ${useModalWindow.name} must be used within a modal context.`);return a}function useModalSnapshot(a){return react.useSyncExternalStore(a.subscribe.bind(a),a.getSnapshot.bind(a))}

@@ -16,0 +16,0 @@ function ModalContainer(a){var b;let {active:c,windows:d}=useModalSnapshot(a.controller),e=null!==(b=a.className)&&void 0!==b?b:"modal";a=d.reduceRight((g,f)=>{null==g[f.params.layer]&&(g[f.params.layer]=f);return g},[]);return jsxRuntime.jsx("div",Object.assign({className:classWithModifiers(e,c&&"active"),"aria-modal":!0,"aria-hidden":!c},{children:a.map(g=>jsxRuntime.jsx("div",Object.assign({className:classWithModifiers(e+"__container"),onClick:stopPropagation(function(){g.params.closable&&g.close()})},

{
"name": "react-modal-global",
"version": "2.2.1",
"version": "2.3.0",
"description": "Highly reusable React Modal that can be run from useEffect.",

@@ -22,3 +22,3 @@ "main": "dist/index.ts",

"eventemitter3": "^5.0.0",
"type-fest": "^3.5.5"
"type-fest": "^4.0.0"
},

@@ -36,3 +36,3 @@ "devDependencies": {

"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-unused-imports": "^2.0.0",
"eslint-plugin-unused-imports": "^3.0.0",
"rollup": "^2.77.0",

@@ -39,0 +39,0 @@ "rollup-plugin-dts": "^4.2.2",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc