@4i/modal-manager 1.0.116 → 1.0.117
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 +1 -1
- package/readme.md +20 -10
package/package.json
CHANGED
package/readme.md
CHANGED
@@ -129,11 +129,14 @@ export default customModalManager;
|
|
129
129
|
```javascript
|
130
130
|
import { memo, useEffect, useRef, useState } from "react";
|
131
131
|
import bottomModal, { constants } from "../../service/BottomModal";
|
132
|
+
import widgets from "../../config/modal/modal-list";
|
132
133
|
|
133
|
-
const
|
134
|
-
|
135
|
-
|
136
|
-
|
134
|
+
const initialData = {
|
135
|
+
data: null,
|
136
|
+
};
|
137
|
+
|
138
|
+
const BottomModalProvider = () => {
|
139
|
+
const [data, setData] = useState(initialData);
|
137
140
|
const [name, setName] = useState < string > null;
|
138
141
|
const modalRef = useRef < HTMLDivElement > null;
|
139
142
|
|
@@ -145,8 +148,9 @@ const BottomModalProvider = ({ modalList }) => {
|
|
145
148
|
}
|
146
149
|
|
147
150
|
function handleClose() {
|
151
|
+
console.log("LOG", "close");
|
148
152
|
setName(null);
|
149
|
-
setData(
|
153
|
+
setData(initialData);
|
150
154
|
}
|
151
155
|
|
152
156
|
bottomModal.addEventListener(constants.OPEN, handleOpenModal);
|
@@ -160,20 +164,26 @@ const BottomModalProvider = ({ modalList }) => {
|
|
160
164
|
|
161
165
|
const handleCloseModal = (e: any) => {
|
162
166
|
if (modalRef.current && !modalRef.current.contains(e.target)) {
|
167
|
+
console.log("LOG", "close");
|
163
168
|
bottomModal.close();
|
164
169
|
}
|
165
170
|
};
|
166
171
|
|
167
|
-
const Widget =
|
172
|
+
const Widget = widgets[name];
|
168
173
|
|
169
174
|
return (
|
170
|
-
|
175
|
+
<>
|
171
176
|
{name && Widget && (
|
172
|
-
<div
|
173
|
-
|
177
|
+
<div
|
178
|
+
onClick={handleCloseModal}
|
179
|
+
className="animate-backdrop fixed z-[1000] h-full w-full overflow-hidden flex items-end"
|
180
|
+
>
|
181
|
+
<div className="animate-fromBottom w-full" ref={modalRef}>
|
182
|
+
<Widget {...data.data} />
|
183
|
+
</div>
|
174
184
|
</div>
|
175
185
|
)}
|
176
|
-
|
186
|
+
</>
|
177
187
|
);
|
178
188
|
};
|
179
189
|
|