@4i/modal-manager 1.0.101 → 1.0.112

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@4i/modal-manager",
3
- "version": "1.0.101",
3
+ "version": "1.0.112",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
@@ -22,10 +22,7 @@
22
22
  "url": "https://github.com/tonichiga/modal-manager/issues"
23
23
  },
24
24
  "homepage": "https://github.com/tonichiga/modal-manager#readme",
25
- "dependencies": {
26
- "react": "^18.2.0",
27
- "uuid": "^9.0.1"
28
- },
25
+ "dependencies": {},
29
26
  "devDependencies": {
30
27
  "@babel/cli": "^7.23.4",
31
28
  "@babel/core": "^7.23.5",
package/readme.md CHANGED
@@ -15,6 +15,16 @@ npm install @4i/modal-manager
15
15
 
16
16
  ## Usage
17
17
 
18
+ #### Instance methods:
19
+
20
+ ##### .call(action, props)
21
+
22
+ Call a modal by its action name and pass props to it.
23
+
24
+ ##### .close()
25
+
26
+ Close all modals.
27
+
18
28
  #### Define Modal Actions:
19
29
 
20
30
  In your project, define modal actions as keys in the modalAction object. Each key represents a specific modal or UI element.
@@ -131,14 +141,19 @@ export default App;
131
141
 
132
142
  ```javascript
133
143
  import React from "react";
144
+ import { modal } from "@4i/modal-manager";
134
145
 
135
146
  // Get props
136
147
  const ModalPrompts = ({ title, content }) => {
148
+ const handleClose = () => {
149
+ modal.close();
150
+ };
151
+
137
152
  return (
138
153
  <div className="w-[400px] h-[300px] bg-slate-50 p-[24px] flex flex-col justify-center items-center">
139
154
  <h1>{title}</h1>
140
155
  <p>{content}</p>
141
- <button>Close</button>
156
+ <button onClick={handleClose}>Close</button>
142
157
  </div>
143
158
  );
144
159
  };
@@ -1,5 +1,8 @@
1
1
  import Manager from "./Manager";
2
- import { v4 as uuidv4 } from "uuid";
2
+
3
+ function uniqueID() {
4
+ return Math.floor(Math.random() * Date.now());
5
+ }
3
6
 
4
7
  const constants = {
5
8
  CHANGE: "change",
@@ -18,7 +21,7 @@ class ModalManager extends Manager {
18
21
  }
19
22
 
20
23
  call(name: string, data: any = {}) {
21
- this.create(name, { modalId: uuidv4(), data });
24
+ this.create(name, { modalId: uniqueID(), data });
22
25
  }
23
26
 
24
27
  close<T>(position?: T) {