@mustmove/overlay-kit-rn 1.0.84 → 1.0.87
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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +352 -59
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +352 -59
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -4
package/dist/index.mjs
CHANGED
|
@@ -32,10 +32,10 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/context/provider/index.tsx
|
|
34
34
|
import {
|
|
35
|
-
useCallback as
|
|
36
|
-
useEffect as
|
|
37
|
-
useReducer,
|
|
38
|
-
useRef as
|
|
35
|
+
useCallback as useCallback4,
|
|
36
|
+
useEffect as useEffect7,
|
|
37
|
+
useReducer as useReducer2,
|
|
38
|
+
useRef as useRef3
|
|
39
39
|
} from "react";
|
|
40
40
|
import { BackHandler, Platform as Platform2 } from "react-native";
|
|
41
41
|
|
|
@@ -73,11 +73,11 @@ var ContentOverlayController = memo(
|
|
|
73
73
|
);
|
|
74
74
|
|
|
75
75
|
// src/context/provider/bottom-sheet-controller.tsx
|
|
76
|
-
import
|
|
77
|
-
memo as
|
|
78
|
-
useEffect as
|
|
79
|
-
useRef,
|
|
80
|
-
useCallback,
|
|
76
|
+
import React4, {
|
|
77
|
+
memo as memo5,
|
|
78
|
+
useEffect as useEffect4,
|
|
79
|
+
useRef as useRef2,
|
|
80
|
+
useCallback as useCallback3,
|
|
81
81
|
useState
|
|
82
82
|
} from "react";
|
|
83
83
|
import BottomSheet, {
|
|
@@ -88,9 +88,282 @@ import {
|
|
|
88
88
|
Keyboard
|
|
89
89
|
} from "react-native";
|
|
90
90
|
import { useReducedMotion } from "react-native-reanimated";
|
|
91
|
-
|
|
91
|
+
|
|
92
|
+
// node_modules/@gorhom/portal/lib/module/components/portal/Portal.js
|
|
93
|
+
import { memo as memo2, useCallback as useCallback2, useEffect as useEffect2, useMemo, useRef } from "react";
|
|
94
|
+
|
|
95
|
+
// node_modules/nanoid/non-secure/index.js
|
|
96
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
97
|
+
var nanoid = (size = 21) => {
|
|
98
|
+
let id = "";
|
|
99
|
+
let i = size | 0;
|
|
100
|
+
while (i--) {
|
|
101
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
102
|
+
}
|
|
103
|
+
return id;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortal.js
|
|
107
|
+
import { useCallback, useContext } from "react";
|
|
108
|
+
|
|
109
|
+
// node_modules/@gorhom/portal/lib/module/state/constants.js
|
|
110
|
+
var ACTIONS;
|
|
111
|
+
(function(ACTIONS2) {
|
|
112
|
+
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
113
|
+
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
114
|
+
ACTIONS2[ACTIONS2["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
|
|
115
|
+
ACTIONS2[ACTIONS2["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
|
|
116
|
+
})(ACTIONS || (ACTIONS = {}));
|
|
117
|
+
var INITIAL_STATE = {};
|
|
118
|
+
|
|
119
|
+
// node_modules/@gorhom/portal/lib/module/contexts/portal.js
|
|
120
|
+
import { createContext } from "react";
|
|
121
|
+
var PortalStateContext = /* @__PURE__ */ createContext(null);
|
|
122
|
+
var PortalDispatchContext = /* @__PURE__ */ createContext(null);
|
|
123
|
+
|
|
124
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortal.js
|
|
125
|
+
var usePortal = (hostName = "root") => {
|
|
126
|
+
const dispatch = useContext(PortalDispatchContext);
|
|
127
|
+
if (dispatch === null) {
|
|
128
|
+
throw new Error("'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.");
|
|
129
|
+
}
|
|
130
|
+
const registerHost2 = useCallback(() => {
|
|
131
|
+
dispatch({
|
|
132
|
+
type: ACTIONS.REGISTER_HOST,
|
|
133
|
+
hostName
|
|
134
|
+
});
|
|
135
|
+
}, []);
|
|
136
|
+
const deregisterHost2 = useCallback(() => {
|
|
137
|
+
dispatch({
|
|
138
|
+
type: ACTIONS.DEREGISTER_HOST,
|
|
139
|
+
hostName
|
|
140
|
+
});
|
|
141
|
+
}, []);
|
|
142
|
+
const addUpdatePortal2 = useCallback((name, node) => {
|
|
143
|
+
dispatch({
|
|
144
|
+
type: ACTIONS.ADD_UPDATE_PORTAL,
|
|
145
|
+
hostName,
|
|
146
|
+
portalName: name,
|
|
147
|
+
node
|
|
148
|
+
});
|
|
149
|
+
}, []);
|
|
150
|
+
const removePortal2 = useCallback((name) => {
|
|
151
|
+
dispatch({
|
|
152
|
+
type: ACTIONS.REMOVE_PORTAL,
|
|
153
|
+
hostName,
|
|
154
|
+
portalName: name
|
|
155
|
+
});
|
|
156
|
+
}, []);
|
|
157
|
+
return {
|
|
158
|
+
registerHost: registerHost2,
|
|
159
|
+
deregisterHost: deregisterHost2,
|
|
160
|
+
addPortal: addUpdatePortal2,
|
|
161
|
+
updatePortal: addUpdatePortal2,
|
|
162
|
+
removePortal: removePortal2
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
// node_modules/@gorhom/portal/lib/module/components/portal/Portal.js
|
|
167
|
+
var PortalComponent = ({
|
|
168
|
+
name: _providedName,
|
|
169
|
+
hostName,
|
|
170
|
+
handleOnMount: _providedHandleOnMount,
|
|
171
|
+
handleOnUnmount: _providedHandleOnUnmount,
|
|
172
|
+
handleOnUpdate: _providedHandleOnUpdate,
|
|
173
|
+
children
|
|
174
|
+
}) => {
|
|
175
|
+
const {
|
|
176
|
+
addPortal: addUpdatePortal2,
|
|
177
|
+
removePortal: removePortal2
|
|
178
|
+
} = usePortal(hostName);
|
|
179
|
+
const name = useMemo(() => _providedName || nanoid(), [_providedName]);
|
|
180
|
+
const handleOnMountRef = useRef();
|
|
181
|
+
const handleOnUnmountRef = useRef();
|
|
182
|
+
const handleOnUpdateRef = useRef();
|
|
183
|
+
const handleOnMount = useCallback2(() => {
|
|
184
|
+
if (_providedHandleOnMount) {
|
|
185
|
+
_providedHandleOnMount(() => addUpdatePortal2(name, children));
|
|
186
|
+
} else {
|
|
187
|
+
addUpdatePortal2(name, children);
|
|
188
|
+
}
|
|
189
|
+
}, [_providedHandleOnMount, addUpdatePortal2]);
|
|
190
|
+
handleOnMountRef.current = handleOnMount;
|
|
191
|
+
const handleOnUnmount = useCallback2(() => {
|
|
192
|
+
if (_providedHandleOnUnmount) {
|
|
193
|
+
_providedHandleOnUnmount(() => removePortal2(name));
|
|
194
|
+
} else {
|
|
195
|
+
removePortal2(name);
|
|
196
|
+
}
|
|
197
|
+
}, [_providedHandleOnUnmount, removePortal2]);
|
|
198
|
+
handleOnUnmountRef.current = handleOnUnmount;
|
|
199
|
+
const handleOnUpdate = useCallback2(() => {
|
|
200
|
+
if (_providedHandleOnUpdate) {
|
|
201
|
+
_providedHandleOnUpdate(() => addUpdatePortal2(name, children));
|
|
202
|
+
} else {
|
|
203
|
+
addUpdatePortal2(name, children);
|
|
204
|
+
}
|
|
205
|
+
}, [_providedHandleOnUpdate, addUpdatePortal2, children]);
|
|
206
|
+
handleOnUpdateRef.current = handleOnUpdate;
|
|
207
|
+
useEffect2(() => {
|
|
208
|
+
var _handleOnMountRef$cur;
|
|
209
|
+
(_handleOnMountRef$cur = handleOnMountRef.current) === null || _handleOnMountRef$cur === void 0 ? void 0 : _handleOnMountRef$cur.call(handleOnMountRef);
|
|
210
|
+
return () => {
|
|
211
|
+
var _handleOnUnmountRef$c;
|
|
212
|
+
(_handleOnUnmountRef$c = handleOnUnmountRef.current) === null || _handleOnUnmountRef$c === void 0 ? void 0 : _handleOnUnmountRef$c.call(handleOnUnmountRef);
|
|
213
|
+
handleOnMountRef.current = void 0;
|
|
214
|
+
handleOnUnmountRef.current = void 0;
|
|
215
|
+
handleOnUpdateRef.current = void 0;
|
|
216
|
+
};
|
|
217
|
+
}, []);
|
|
218
|
+
useEffect2(() => {
|
|
219
|
+
var _handleOnUpdateRef$cu;
|
|
220
|
+
(_handleOnUpdateRef$cu = handleOnUpdateRef.current) === null || _handleOnUpdateRef$cu === void 0 ? void 0 : _handleOnUpdateRef$cu.call(handleOnUpdateRef);
|
|
221
|
+
}, [children]);
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
var Portal = /* @__PURE__ */ memo2(PortalComponent);
|
|
225
|
+
Portal.displayName = "Portal";
|
|
226
|
+
|
|
227
|
+
// node_modules/@gorhom/portal/lib/module/components/portalHost/PortalHost.js
|
|
228
|
+
import React2, { memo as memo3, useEffect as useEffect3 } from "react";
|
|
229
|
+
|
|
230
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortalState.js
|
|
231
|
+
import { useContext as useContext2 } from "react";
|
|
232
|
+
var usePortalState = (hostName) => {
|
|
233
|
+
const state = useContext2(PortalStateContext);
|
|
234
|
+
if (state === null) {
|
|
235
|
+
throw new Error("'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.");
|
|
236
|
+
}
|
|
237
|
+
return state[hostName] || [];
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
// node_modules/@gorhom/portal/lib/module/components/portalHost/PortalHost.js
|
|
241
|
+
var PortalHostComponent = ({
|
|
242
|
+
name
|
|
243
|
+
}) => {
|
|
244
|
+
const state = usePortalState(name);
|
|
245
|
+
const {
|
|
246
|
+
registerHost: registerHost2,
|
|
247
|
+
deregisterHost: deregisterHost2
|
|
248
|
+
} = usePortal(name);
|
|
249
|
+
useEffect3(() => {
|
|
250
|
+
registerHost2();
|
|
251
|
+
return () => {
|
|
252
|
+
deregisterHost2();
|
|
253
|
+
};
|
|
254
|
+
}, []);
|
|
255
|
+
return /* @__PURE__ */ React2.createElement(React2.Fragment, null, state.map((item) => item.node));
|
|
256
|
+
};
|
|
257
|
+
var PortalHost = /* @__PURE__ */ memo3(PortalHostComponent);
|
|
258
|
+
PortalHost.displayName = "PortalHost";
|
|
259
|
+
|
|
260
|
+
// node_modules/@gorhom/portal/lib/module/components/portalProvider/PortalProvider.js
|
|
261
|
+
import React3, { memo as memo4, useReducer } from "react";
|
|
262
|
+
|
|
263
|
+
// node_modules/@gorhom/portal/lib/module/utilities/logger.js
|
|
264
|
+
var isLoggingEnabled = false;
|
|
265
|
+
var isDev = Boolean(typeof __DEV__ !== "undefined" && __DEV__);
|
|
266
|
+
var print = () => {
|
|
267
|
+
};
|
|
268
|
+
if (isDev) {
|
|
269
|
+
print = ({
|
|
270
|
+
component,
|
|
271
|
+
method,
|
|
272
|
+
params
|
|
273
|
+
}) => {
|
|
274
|
+
if (!isLoggingEnabled) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
277
|
+
let message = "";
|
|
278
|
+
if (typeof params === "object") {
|
|
279
|
+
message = Object.keys(params).map((key) => "".concat(key, ":").concat(params[key])).join(" ");
|
|
280
|
+
} else {
|
|
281
|
+
message = "".concat(params !== null && params !== void 0 ? params : "");
|
|
282
|
+
}
|
|
283
|
+
console.log("[Portal::".concat([component, method].filter(Boolean).join("::"), "]"), message);
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
Object.freeze(print);
|
|
287
|
+
|
|
288
|
+
// node_modules/@gorhom/portal/lib/module/state/reducer.js
|
|
289
|
+
var registerHost = (state, hostName) => {
|
|
290
|
+
if (!(hostName in state)) {
|
|
291
|
+
state[hostName] = [];
|
|
292
|
+
}
|
|
293
|
+
return state;
|
|
294
|
+
};
|
|
295
|
+
var deregisterHost = (state, hostName) => {
|
|
296
|
+
delete state[hostName];
|
|
297
|
+
return state;
|
|
298
|
+
};
|
|
299
|
+
var addUpdatePortal = (state, hostName, portalName, node) => {
|
|
300
|
+
if (!(hostName in state)) {
|
|
301
|
+
state = registerHost(state, hostName);
|
|
302
|
+
}
|
|
303
|
+
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
304
|
+
if (index !== -1) {
|
|
305
|
+
state[hostName][index].node = node;
|
|
306
|
+
} else {
|
|
307
|
+
state[hostName].push({
|
|
308
|
+
name: portalName,
|
|
309
|
+
node
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
return state;
|
|
313
|
+
};
|
|
314
|
+
var removePortal = (state, hostName, portalName) => {
|
|
315
|
+
if (!(hostName in state)) {
|
|
316
|
+
print({
|
|
317
|
+
component: reducer.name,
|
|
318
|
+
method: removePortal.name,
|
|
319
|
+
params: "Failed to remove portal '".concat(portalName, "', '").concat(hostName, "' was not registered!")
|
|
320
|
+
});
|
|
321
|
+
return state;
|
|
322
|
+
}
|
|
323
|
+
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
324
|
+
if (index !== -1) state[hostName].splice(index, 1);
|
|
325
|
+
return state;
|
|
326
|
+
};
|
|
327
|
+
var reducer = (state, action) => {
|
|
328
|
+
const {
|
|
329
|
+
type
|
|
330
|
+
} = action;
|
|
331
|
+
let clonedState = __spreadValues({}, state);
|
|
332
|
+
switch (type) {
|
|
333
|
+
case ACTIONS.REGISTER_HOST:
|
|
334
|
+
return registerHost(clonedState, action.hostName);
|
|
335
|
+
case ACTIONS.DEREGISTER_HOST:
|
|
336
|
+
return deregisterHost(clonedState, action.hostName);
|
|
337
|
+
case ACTIONS.ADD_UPDATE_PORTAL:
|
|
338
|
+
return addUpdatePortal(clonedState, action.hostName, action.portalName, action.node);
|
|
339
|
+
case ACTIONS.REMOVE_PORTAL:
|
|
340
|
+
return removePortal(clonedState, action.hostName, action.portalName);
|
|
341
|
+
default:
|
|
342
|
+
return state;
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
// node_modules/@gorhom/portal/lib/module/components/portalProvider/PortalProvider.js
|
|
347
|
+
var PortalProviderComponent = ({
|
|
348
|
+
rootHostName = "root",
|
|
349
|
+
shouldAddRootHost = true,
|
|
350
|
+
children
|
|
351
|
+
}) => {
|
|
352
|
+
const [state, dispatch] = useReducer(reducer, INITIAL_STATE);
|
|
353
|
+
return /* @__PURE__ */ React3.createElement(PortalDispatchContext.Provider, {
|
|
354
|
+
value: dispatch
|
|
355
|
+
}, /* @__PURE__ */ React3.createElement(PortalStateContext.Provider, {
|
|
356
|
+
value: state
|
|
357
|
+
}, children, shouldAddRootHost && /* @__PURE__ */ React3.createElement(PortalHost, {
|
|
358
|
+
name: rootHostName
|
|
359
|
+
})));
|
|
360
|
+
};
|
|
361
|
+
var PortalProvider = /* @__PURE__ */ memo4(PortalProviderComponent);
|
|
362
|
+
PortalProvider.displayName = "PortalProvider";
|
|
363
|
+
|
|
364
|
+
// src/context/provider/bottom-sheet-controller.tsx
|
|
92
365
|
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
93
|
-
var ContentBottomSheetController =
|
|
366
|
+
var ContentBottomSheetController = memo5(
|
|
94
367
|
({
|
|
95
368
|
isOpen,
|
|
96
369
|
overlayId,
|
|
@@ -99,10 +372,11 @@ var ContentBottomSheetController = memo2(
|
|
|
99
372
|
overlayOrderList,
|
|
100
373
|
options = {}
|
|
101
374
|
}) => {
|
|
102
|
-
const bottomSheetRef =
|
|
375
|
+
const bottomSheetRef = useRef2(null);
|
|
103
376
|
const reducedMotion = useReducedMotion();
|
|
104
377
|
const [keyboardHeight, setKeyboardHeight] = useState(0);
|
|
105
|
-
const isKeyboardActiveRef =
|
|
378
|
+
const isKeyboardActiveRef = useRef2(false);
|
|
379
|
+
const isClosingRef = useRef2(false);
|
|
106
380
|
const getZIndex = () => {
|
|
107
381
|
const index = overlayOrderList.indexOf(overlayId);
|
|
108
382
|
return 1e3 + index;
|
|
@@ -118,7 +392,8 @@ var ContentBottomSheetController = memo2(
|
|
|
118
392
|
keyboardBehavior = Platform.OS === "android" ? "extend" : "interactive",
|
|
119
393
|
keyboardBlurBehavior = "restore",
|
|
120
394
|
androidKeyboardInputMode = "adjustResize",
|
|
121
|
-
closeAllOnGestureClose = false
|
|
395
|
+
closeAllOnGestureClose = false,
|
|
396
|
+
closeFunction
|
|
122
397
|
} = _a, restOptions = __objRest(_a, [
|
|
123
398
|
"snapPoints",
|
|
124
399
|
"enablePanDownToClose",
|
|
@@ -130,9 +405,10 @@ var ContentBottomSheetController = memo2(
|
|
|
130
405
|
"keyboardBehavior",
|
|
131
406
|
"keyboardBlurBehavior",
|
|
132
407
|
"androidKeyboardInputMode",
|
|
133
|
-
"closeAllOnGestureClose"
|
|
408
|
+
"closeAllOnGestureClose",
|
|
409
|
+
"closeFunction"
|
|
134
410
|
]);
|
|
135
|
-
|
|
411
|
+
useEffect4(() => {
|
|
136
412
|
const keyboardWillShowListener = Keyboard.addListener(
|
|
137
413
|
Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
138
414
|
(e) => {
|
|
@@ -152,7 +428,7 @@ var ContentBottomSheetController = memo2(
|
|
|
152
428
|
keyboardWillHideListener.remove();
|
|
153
429
|
};
|
|
154
430
|
}, []);
|
|
155
|
-
|
|
431
|
+
useEffect4(() => {
|
|
156
432
|
if (isOpen) {
|
|
157
433
|
const rafId = requestAnimationFrame(() => {
|
|
158
434
|
var _a2;
|
|
@@ -163,7 +439,11 @@ var ContentBottomSheetController = memo2(
|
|
|
163
439
|
} else {
|
|
164
440
|
}
|
|
165
441
|
}, [isOpen, overlayDispatch, overlayId]);
|
|
166
|
-
const handleClose =
|
|
442
|
+
const handleClose = useCallback3(() => {
|
|
443
|
+
if (isClosingRef.current) {
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
isClosingRef.current = true;
|
|
167
447
|
if (isKeyboardActiveRef.current) {
|
|
168
448
|
Keyboard.dismiss();
|
|
169
449
|
setTimeout(() => {
|
|
@@ -172,18 +452,24 @@ var ContentBottomSheetController = memo2(
|
|
|
172
452
|
} else {
|
|
173
453
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
174
454
|
}
|
|
175
|
-
|
|
455
|
+
if (closeFunction) {
|
|
456
|
+
closeFunction();
|
|
457
|
+
}
|
|
458
|
+
}, 50);
|
|
176
459
|
return;
|
|
177
460
|
}
|
|
178
|
-
|
|
461
|
+
requestAnimationFrame(() => {
|
|
179
462
|
if (closeAllOnGestureClose) {
|
|
180
463
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
181
464
|
} else {
|
|
182
465
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
183
466
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
467
|
+
if (closeFunction) {
|
|
468
|
+
closeFunction();
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
}, [overlayDispatch, overlayId, closeAllOnGestureClose, closeFunction]);
|
|
472
|
+
const renderBackdrop = useCallback3(
|
|
187
473
|
(props) => /* @__PURE__ */ jsx2(
|
|
188
474
|
BottomSheetBackdrop,
|
|
189
475
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -195,7 +481,7 @@ var ContentBottomSheetController = memo2(
|
|
|
195
481
|
),
|
|
196
482
|
[backdropOpacity, handleClose]
|
|
197
483
|
);
|
|
198
|
-
const handleSheetChange =
|
|
484
|
+
const handleSheetChange = useCallback3((index) => {
|
|
199
485
|
}, []);
|
|
200
486
|
const getLayerIndex = () => {
|
|
201
487
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
@@ -232,10 +518,10 @@ var ContentBottomSheetController = memo2(
|
|
|
232
518
|
],
|
|
233
519
|
enableDynamicSizing,
|
|
234
520
|
animateOnMount: !reducedMotion,
|
|
235
|
-
children:
|
|
521
|
+
children: React4.isValidElement(Controller) ? React4.cloneElement(Controller, {
|
|
236
522
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
237
523
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
238
|
-
}) :
|
|
524
|
+
}) : React4.createElement(Controller, __spreadValues({
|
|
239
525
|
isOpen,
|
|
240
526
|
overlayId,
|
|
241
527
|
snapPoints,
|
|
@@ -250,7 +536,7 @@ var ContentBottomSheetController = memo2(
|
|
|
250
536
|
);
|
|
251
537
|
|
|
252
538
|
// src/context/provider/modal-controller.tsx
|
|
253
|
-
import
|
|
539
|
+
import React5, { memo as memo6, useEffect as useEffect5, useState as useState2 } from "react";
|
|
254
540
|
import {
|
|
255
541
|
View as View2,
|
|
256
542
|
Animated,
|
|
@@ -259,10 +545,9 @@ import {
|
|
|
259
545
|
Pressable,
|
|
260
546
|
Keyboard as Keyboard2
|
|
261
547
|
} from "react-native";
|
|
262
|
-
import { Portal as Portal2 } from "@gorhom/portal";
|
|
263
548
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
264
549
|
var { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window");
|
|
265
|
-
var ContentModalController =
|
|
550
|
+
var ContentModalController = memo6(
|
|
266
551
|
({
|
|
267
552
|
isOpen,
|
|
268
553
|
overlayId,
|
|
@@ -275,12 +560,14 @@ var ContentModalController = memo3(
|
|
|
275
560
|
modalType = "center",
|
|
276
561
|
backdropOpacity = 0.5,
|
|
277
562
|
animationType = "fade",
|
|
278
|
-
swipeDirection
|
|
563
|
+
swipeDirection,
|
|
564
|
+
closeFunction
|
|
279
565
|
} = options;
|
|
280
566
|
const [backdropAnimation] = useState2(new Animated.Value(0));
|
|
281
567
|
const [contentAnimation] = useState2(new Animated.Value(0));
|
|
282
568
|
const [mounted, setMounted] = useState2(isOpen);
|
|
283
|
-
|
|
569
|
+
const [isClosing, setIsClosing] = useState2(false);
|
|
570
|
+
useEffect5(() => {
|
|
284
571
|
if (isOpen) {
|
|
285
572
|
if (!mounted) setMounted(true);
|
|
286
573
|
setImmediate(() => {
|
|
@@ -317,10 +604,17 @@ var ContentModalController = memo3(
|
|
|
317
604
|
}
|
|
318
605
|
}, [isOpen]);
|
|
319
606
|
const handleClose = () => {
|
|
607
|
+
if (isClosing) {
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
setIsClosing(true);
|
|
320
611
|
Keyboard2.dismiss();
|
|
321
|
-
|
|
612
|
+
requestAnimationFrame(() => {
|
|
322
613
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
323
|
-
|
|
614
|
+
if (closeFunction) {
|
|
615
|
+
closeFunction();
|
|
616
|
+
}
|
|
617
|
+
});
|
|
324
618
|
};
|
|
325
619
|
const getLayerIndex = () => {
|
|
326
620
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
@@ -407,7 +701,7 @@ var ContentModalController = memo3(
|
|
|
407
701
|
}
|
|
408
702
|
};
|
|
409
703
|
if (!mounted) return null;
|
|
410
|
-
return /* @__PURE__ */ jsx3(
|
|
704
|
+
return /* @__PURE__ */ jsx3(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ jsxs(
|
|
411
705
|
View2,
|
|
412
706
|
{
|
|
413
707
|
style: [styles.absoluteContainer],
|
|
@@ -440,10 +734,10 @@ var ContentModalController = memo3(
|
|
|
440
734
|
{
|
|
441
735
|
style: [getContainerStyle(), getContentAnimationStyle()],
|
|
442
736
|
pointerEvents: "box-none",
|
|
443
|
-
children: /* @__PURE__ */ jsx3(View2, { pointerEvents: "box-none", children:
|
|
737
|
+
children: /* @__PURE__ */ jsx3(View2, { pointerEvents: "box-none", children: React5.isValidElement(Controller) ? React5.cloneElement(Controller, {
|
|
444
738
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
445
739
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
446
|
-
}) :
|
|
740
|
+
}) : React5.createElement(Controller, {
|
|
447
741
|
isOpen,
|
|
448
742
|
overlayId,
|
|
449
743
|
modalType,
|
|
@@ -490,10 +784,10 @@ var styles = StyleSheet2.create({
|
|
|
490
784
|
});
|
|
491
785
|
|
|
492
786
|
// src/event.ts
|
|
493
|
-
import
|
|
787
|
+
import React7 from "react";
|
|
494
788
|
|
|
495
789
|
// src/utils/create-use-external-events.ts
|
|
496
|
-
import { useEffect as
|
|
790
|
+
import { useEffect as useEffect6 } from "react";
|
|
497
791
|
|
|
498
792
|
// src/utils/emitter.ts
|
|
499
793
|
function createEmitter(all) {
|
|
@@ -538,7 +832,7 @@ function createEmitter(all) {
|
|
|
538
832
|
// src/utils/create-use-external-events.ts
|
|
539
833
|
var emitter = createEmitter();
|
|
540
834
|
function useClientEffect(...args) {
|
|
541
|
-
|
|
835
|
+
useEffect6(...args);
|
|
542
836
|
}
|
|
543
837
|
function dispatchEvent(type, detail) {
|
|
544
838
|
emitter.emit(type, detail);
|
|
@@ -578,13 +872,13 @@ function randomId() {
|
|
|
578
872
|
}
|
|
579
873
|
|
|
580
874
|
// src/utils/get-component-name.ts
|
|
581
|
-
import
|
|
875
|
+
import React6 from "react";
|
|
582
876
|
function getComponentName(controller) {
|
|
583
877
|
var _a, _b;
|
|
584
878
|
if (controller == null ? void 0 : controller.displayName) {
|
|
585
879
|
return controller.displayName;
|
|
586
880
|
}
|
|
587
|
-
if (
|
|
881
|
+
if (React6.isValidElement(controller)) {
|
|
588
882
|
const type = controller.type;
|
|
589
883
|
if (type == null ? void 0 : type.displayName) return type.displayName;
|
|
590
884
|
if ((type == null ? void 0 : type.name) && type.name !== "anonymous") return type.name;
|
|
@@ -617,9 +911,9 @@ function createOverlay(overlayId) {
|
|
|
617
911
|
const dispatchOpenEvent = createEvent("open");
|
|
618
912
|
const _c = options || {}, { overlayId: _, overlayType: __ } = _c, restOptions = __objRest(_c, ["overlayId", "overlayType"]);
|
|
619
913
|
let finalController;
|
|
620
|
-
if (
|
|
914
|
+
if (React7.isValidElement(controller)) {
|
|
621
915
|
finalController = (props) => {
|
|
622
|
-
return
|
|
916
|
+
return React7.cloneElement(controller, __spreadProps(__spreadValues(__spreadValues({}, controller.props || {}), props), {
|
|
623
917
|
close: props.close,
|
|
624
918
|
unmount: props.unmount
|
|
625
919
|
}));
|
|
@@ -649,8 +943,8 @@ function createOverlay(overlayId) {
|
|
|
649
943
|
overlayProps.unmount();
|
|
650
944
|
};
|
|
651
945
|
const props = __spreadProps(__spreadValues({}, overlayProps), { close: close2, unmount: unmount2 });
|
|
652
|
-
if (
|
|
653
|
-
return
|
|
946
|
+
if (React7.isValidElement(controller)) {
|
|
947
|
+
return React7.cloneElement(controller, __spreadValues(__spreadValues({}, controller.props || {}), props));
|
|
654
948
|
}
|
|
655
949
|
if (typeof controller === "function") {
|
|
656
950
|
return controller(props);
|
|
@@ -676,13 +970,13 @@ function createOverlay(overlayId) {
|
|
|
676
970
|
}
|
|
677
971
|
|
|
678
972
|
// src/utils/create-safe-context.ts
|
|
679
|
-
import { createContext, useContext } from "react";
|
|
973
|
+
import { createContext as createContext2, useContext as useContext3 } from "react";
|
|
680
974
|
var NullSymbol = Symbol("Null");
|
|
681
975
|
function createSafeContext(displayName) {
|
|
682
|
-
const Context =
|
|
976
|
+
const Context = createContext2(NullSymbol);
|
|
683
977
|
Context.displayName = displayName != null ? displayName : "SafeContext";
|
|
684
978
|
function useSafeContext() {
|
|
685
|
-
const context =
|
|
979
|
+
const context = useContext3(Context);
|
|
686
980
|
if (context === NullSymbol) {
|
|
687
981
|
const error = new Error(`[${Context.displayName}]: Provider not found.`);
|
|
688
982
|
error.name = "[Error] Context";
|
|
@@ -816,23 +1110,22 @@ function overlayReducer(state, action) {
|
|
|
816
1110
|
// src/context/provider/index.tsx
|
|
817
1111
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
818
1112
|
import { BottomSheetModalProvider as BottomSheetModalProvider2 } from "@gorhom/bottom-sheet";
|
|
819
|
-
import { PortalProvider, PortalHost } from "@gorhom/portal";
|
|
820
1113
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
821
1114
|
function createOverlayProvider() {
|
|
822
1115
|
const overlayId = randomId();
|
|
823
1116
|
const _a = createOverlay(overlayId), { useOverlayEvent } = _a, overlay2 = __objRest(_a, ["useOverlayEvent"]);
|
|
824
1117
|
const { OverlayContextProvider, useCurrentOverlay: useCurrentOverlay2, useOverlayData: useOverlayData2 } = createOverlaySafeContext();
|
|
825
1118
|
function OverlayProvider2({ children }) {
|
|
826
|
-
const [overlayState, overlayDispatch] =
|
|
1119
|
+
const [overlayState, overlayDispatch] = useReducer2(overlayReducer, {
|
|
827
1120
|
current: null,
|
|
828
1121
|
overlayOrderList: [],
|
|
829
1122
|
overlayData: {}
|
|
830
1123
|
});
|
|
831
|
-
const overlayStateRef =
|
|
832
|
-
|
|
1124
|
+
const overlayStateRef = useRef3(overlayState);
|
|
1125
|
+
useEffect7(() => {
|
|
833
1126
|
overlayStateRef.current = overlayState;
|
|
834
1127
|
}, [overlayState]);
|
|
835
|
-
const overlayOpen =
|
|
1128
|
+
const overlayOpen = useCallback4(
|
|
836
1129
|
({
|
|
837
1130
|
controller,
|
|
838
1131
|
overlayId: overlayId2,
|
|
@@ -857,16 +1150,16 @@ function createOverlayProvider() {
|
|
|
857
1150
|
},
|
|
858
1151
|
[]
|
|
859
1152
|
);
|
|
860
|
-
const close =
|
|
1153
|
+
const close = useCallback4((overlayId2) => {
|
|
861
1154
|
overlayDispatch({ type: "CLOSE", overlayId: overlayId2 });
|
|
862
1155
|
}, []);
|
|
863
|
-
const unmount =
|
|
1156
|
+
const unmount = useCallback4((overlayId2) => {
|
|
864
1157
|
overlayDispatch({ type: "REMOVE", overlayId: overlayId2 });
|
|
865
1158
|
}, []);
|
|
866
|
-
const closeAll =
|
|
1159
|
+
const closeAll = useCallback4(() => {
|
|
867
1160
|
overlayDispatch({ type: "CLOSE_ALL" });
|
|
868
1161
|
}, []);
|
|
869
|
-
const unmountAll =
|
|
1162
|
+
const unmountAll = useCallback4(() => {
|
|
870
1163
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
871
1164
|
}, []);
|
|
872
1165
|
useOverlayEvent({
|
|
@@ -876,12 +1169,12 @@ function createOverlayProvider() {
|
|
|
876
1169
|
closeAll,
|
|
877
1170
|
unmountAll
|
|
878
1171
|
});
|
|
879
|
-
|
|
1172
|
+
useEffect7(() => {
|
|
880
1173
|
return () => {
|
|
881
1174
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
882
1175
|
};
|
|
883
1176
|
}, []);
|
|
884
|
-
|
|
1177
|
+
useEffect7(() => {
|
|
885
1178
|
if (Platform2.OS !== "android") {
|
|
886
1179
|
return;
|
|
887
1180
|
}
|