@mustmove/overlay-kit-rn 1.0.83 → 1.0.86
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 +334 -55
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +334 -55
- 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,10 @@ 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);
|
|
106
379
|
const getZIndex = () => {
|
|
107
380
|
const index = overlayOrderList.indexOf(overlayId);
|
|
108
381
|
return 1e3 + index;
|
|
@@ -118,7 +391,8 @@ var ContentBottomSheetController = memo2(
|
|
|
118
391
|
keyboardBehavior = Platform.OS === "android" ? "extend" : "interactive",
|
|
119
392
|
keyboardBlurBehavior = "restore",
|
|
120
393
|
androidKeyboardInputMode = "adjustResize",
|
|
121
|
-
closeAllOnGestureClose = false
|
|
394
|
+
closeAllOnGestureClose = false,
|
|
395
|
+
closeFunction
|
|
122
396
|
} = _a, restOptions = __objRest(_a, [
|
|
123
397
|
"snapPoints",
|
|
124
398
|
"enablePanDownToClose",
|
|
@@ -130,9 +404,10 @@ var ContentBottomSheetController = memo2(
|
|
|
130
404
|
"keyboardBehavior",
|
|
131
405
|
"keyboardBlurBehavior",
|
|
132
406
|
"androidKeyboardInputMode",
|
|
133
|
-
"closeAllOnGestureClose"
|
|
407
|
+
"closeAllOnGestureClose",
|
|
408
|
+
"closeFunction"
|
|
134
409
|
]);
|
|
135
|
-
|
|
410
|
+
useEffect4(() => {
|
|
136
411
|
const keyboardWillShowListener = Keyboard.addListener(
|
|
137
412
|
Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
138
413
|
(e) => {
|
|
@@ -152,7 +427,7 @@ var ContentBottomSheetController = memo2(
|
|
|
152
427
|
keyboardWillHideListener.remove();
|
|
153
428
|
};
|
|
154
429
|
}, []);
|
|
155
|
-
|
|
430
|
+
useEffect4(() => {
|
|
156
431
|
if (isOpen) {
|
|
157
432
|
const rafId = requestAnimationFrame(() => {
|
|
158
433
|
var _a2;
|
|
@@ -163,7 +438,7 @@ var ContentBottomSheetController = memo2(
|
|
|
163
438
|
} else {
|
|
164
439
|
}
|
|
165
440
|
}, [isOpen, overlayDispatch, overlayId]);
|
|
166
|
-
const handleClose =
|
|
441
|
+
const handleClose = useCallback3(() => {
|
|
167
442
|
if (isKeyboardActiveRef.current) {
|
|
168
443
|
Keyboard.dismiss();
|
|
169
444
|
setTimeout(() => {
|
|
@@ -172,7 +447,10 @@ var ContentBottomSheetController = memo2(
|
|
|
172
447
|
} else {
|
|
173
448
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
174
449
|
}
|
|
175
|
-
|
|
450
|
+
if (closeFunction) {
|
|
451
|
+
closeFunction();
|
|
452
|
+
}
|
|
453
|
+
}, 100);
|
|
176
454
|
return;
|
|
177
455
|
}
|
|
178
456
|
setTimeout(() => {
|
|
@@ -181,9 +459,12 @@ var ContentBottomSheetController = memo2(
|
|
|
181
459
|
} else {
|
|
182
460
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
183
461
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
462
|
+
if (closeFunction) {
|
|
463
|
+
closeFunction();
|
|
464
|
+
}
|
|
465
|
+
}, 50);
|
|
466
|
+
}, [overlayDispatch, overlayId, closeAllOnGestureClose, closeFunction]);
|
|
467
|
+
const renderBackdrop = useCallback3(
|
|
187
468
|
(props) => /* @__PURE__ */ jsx2(
|
|
188
469
|
BottomSheetBackdrop,
|
|
189
470
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -195,7 +476,7 @@ var ContentBottomSheetController = memo2(
|
|
|
195
476
|
),
|
|
196
477
|
[backdropOpacity, handleClose]
|
|
197
478
|
);
|
|
198
|
-
const handleSheetChange =
|
|
479
|
+
const handleSheetChange = useCallback3((index) => {
|
|
199
480
|
}, []);
|
|
200
481
|
const getLayerIndex = () => {
|
|
201
482
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
@@ -232,10 +513,10 @@ var ContentBottomSheetController = memo2(
|
|
|
232
513
|
],
|
|
233
514
|
enableDynamicSizing,
|
|
234
515
|
animateOnMount: !reducedMotion,
|
|
235
|
-
children:
|
|
516
|
+
children: React4.isValidElement(Controller) ? React4.cloneElement(Controller, {
|
|
236
517
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
237
518
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
238
|
-
}) :
|
|
519
|
+
}) : React4.createElement(Controller, __spreadValues({
|
|
239
520
|
isOpen,
|
|
240
521
|
overlayId,
|
|
241
522
|
snapPoints,
|
|
@@ -250,7 +531,7 @@ var ContentBottomSheetController = memo2(
|
|
|
250
531
|
);
|
|
251
532
|
|
|
252
533
|
// src/context/provider/modal-controller.tsx
|
|
253
|
-
import
|
|
534
|
+
import React5, { memo as memo6, useEffect as useEffect5, useState as useState2 } from "react";
|
|
254
535
|
import {
|
|
255
536
|
View as View2,
|
|
256
537
|
Animated,
|
|
@@ -259,10 +540,9 @@ import {
|
|
|
259
540
|
Pressable,
|
|
260
541
|
Keyboard as Keyboard2
|
|
261
542
|
} from "react-native";
|
|
262
|
-
import { Portal as Portal2 } from "@gorhom/portal";
|
|
263
543
|
import { jsx as jsx3, jsxs } from "react/jsx-runtime";
|
|
264
544
|
var { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = Dimensions.get("window");
|
|
265
|
-
var ContentModalController =
|
|
545
|
+
var ContentModalController = memo6(
|
|
266
546
|
({
|
|
267
547
|
isOpen,
|
|
268
548
|
overlayId,
|
|
@@ -280,7 +560,7 @@ var ContentModalController = memo3(
|
|
|
280
560
|
const [backdropAnimation] = useState2(new Animated.Value(0));
|
|
281
561
|
const [contentAnimation] = useState2(new Animated.Value(0));
|
|
282
562
|
const [mounted, setMounted] = useState2(isOpen);
|
|
283
|
-
|
|
563
|
+
useEffect5(() => {
|
|
284
564
|
if (isOpen) {
|
|
285
565
|
if (!mounted) setMounted(true);
|
|
286
566
|
setImmediate(() => {
|
|
@@ -407,7 +687,7 @@ var ContentModalController = memo3(
|
|
|
407
687
|
}
|
|
408
688
|
};
|
|
409
689
|
if (!mounted) return null;
|
|
410
|
-
return /* @__PURE__ */ jsx3(
|
|
690
|
+
return /* @__PURE__ */ jsx3(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ jsxs(
|
|
411
691
|
View2,
|
|
412
692
|
{
|
|
413
693
|
style: [styles.absoluteContainer],
|
|
@@ -440,10 +720,10 @@ var ContentModalController = memo3(
|
|
|
440
720
|
{
|
|
441
721
|
style: [getContainerStyle(), getContentAnimationStyle()],
|
|
442
722
|
pointerEvents: "box-none",
|
|
443
|
-
children: /* @__PURE__ */ jsx3(View2, { pointerEvents: "box-none", children:
|
|
723
|
+
children: /* @__PURE__ */ jsx3(View2, { pointerEvents: "box-none", children: React5.isValidElement(Controller) ? React5.cloneElement(Controller, {
|
|
444
724
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
445
725
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
446
|
-
}) :
|
|
726
|
+
}) : React5.createElement(Controller, {
|
|
447
727
|
isOpen,
|
|
448
728
|
overlayId,
|
|
449
729
|
modalType,
|
|
@@ -490,10 +770,10 @@ var styles = StyleSheet2.create({
|
|
|
490
770
|
});
|
|
491
771
|
|
|
492
772
|
// src/event.ts
|
|
493
|
-
import
|
|
773
|
+
import React7 from "react";
|
|
494
774
|
|
|
495
775
|
// src/utils/create-use-external-events.ts
|
|
496
|
-
import { useEffect as
|
|
776
|
+
import { useEffect as useEffect6 } from "react";
|
|
497
777
|
|
|
498
778
|
// src/utils/emitter.ts
|
|
499
779
|
function createEmitter(all) {
|
|
@@ -538,7 +818,7 @@ function createEmitter(all) {
|
|
|
538
818
|
// src/utils/create-use-external-events.ts
|
|
539
819
|
var emitter = createEmitter();
|
|
540
820
|
function useClientEffect(...args) {
|
|
541
|
-
|
|
821
|
+
useEffect6(...args);
|
|
542
822
|
}
|
|
543
823
|
function dispatchEvent(type, detail) {
|
|
544
824
|
emitter.emit(type, detail);
|
|
@@ -578,13 +858,13 @@ function randomId() {
|
|
|
578
858
|
}
|
|
579
859
|
|
|
580
860
|
// src/utils/get-component-name.ts
|
|
581
|
-
import
|
|
861
|
+
import React6 from "react";
|
|
582
862
|
function getComponentName(controller) {
|
|
583
863
|
var _a, _b;
|
|
584
864
|
if (controller == null ? void 0 : controller.displayName) {
|
|
585
865
|
return controller.displayName;
|
|
586
866
|
}
|
|
587
|
-
if (
|
|
867
|
+
if (React6.isValidElement(controller)) {
|
|
588
868
|
const type = controller.type;
|
|
589
869
|
if (type == null ? void 0 : type.displayName) return type.displayName;
|
|
590
870
|
if ((type == null ? void 0 : type.name) && type.name !== "anonymous") return type.name;
|
|
@@ -617,9 +897,9 @@ function createOverlay(overlayId) {
|
|
|
617
897
|
const dispatchOpenEvent = createEvent("open");
|
|
618
898
|
const _c = options || {}, { overlayId: _, overlayType: __ } = _c, restOptions = __objRest(_c, ["overlayId", "overlayType"]);
|
|
619
899
|
let finalController;
|
|
620
|
-
if (
|
|
900
|
+
if (React7.isValidElement(controller)) {
|
|
621
901
|
finalController = (props) => {
|
|
622
|
-
return
|
|
902
|
+
return React7.cloneElement(controller, __spreadProps(__spreadValues(__spreadValues({}, controller.props || {}), props), {
|
|
623
903
|
close: props.close,
|
|
624
904
|
unmount: props.unmount
|
|
625
905
|
}));
|
|
@@ -649,8 +929,8 @@ function createOverlay(overlayId) {
|
|
|
649
929
|
overlayProps.unmount();
|
|
650
930
|
};
|
|
651
931
|
const props = __spreadProps(__spreadValues({}, overlayProps), { close: close2, unmount: unmount2 });
|
|
652
|
-
if (
|
|
653
|
-
return
|
|
932
|
+
if (React7.isValidElement(controller)) {
|
|
933
|
+
return React7.cloneElement(controller, __spreadValues(__spreadValues({}, controller.props || {}), props));
|
|
654
934
|
}
|
|
655
935
|
if (typeof controller === "function") {
|
|
656
936
|
return controller(props);
|
|
@@ -676,13 +956,13 @@ function createOverlay(overlayId) {
|
|
|
676
956
|
}
|
|
677
957
|
|
|
678
958
|
// src/utils/create-safe-context.ts
|
|
679
|
-
import { createContext, useContext } from "react";
|
|
959
|
+
import { createContext as createContext2, useContext as useContext3 } from "react";
|
|
680
960
|
var NullSymbol = Symbol("Null");
|
|
681
961
|
function createSafeContext(displayName) {
|
|
682
|
-
const Context =
|
|
962
|
+
const Context = createContext2(NullSymbol);
|
|
683
963
|
Context.displayName = displayName != null ? displayName : "SafeContext";
|
|
684
964
|
function useSafeContext() {
|
|
685
|
-
const context =
|
|
965
|
+
const context = useContext3(Context);
|
|
686
966
|
if (context === NullSymbol) {
|
|
687
967
|
const error = new Error(`[${Context.displayName}]: Provider not found.`);
|
|
688
968
|
error.name = "[Error] Context";
|
|
@@ -816,23 +1096,22 @@ function overlayReducer(state, action) {
|
|
|
816
1096
|
// src/context/provider/index.tsx
|
|
817
1097
|
import { GestureHandlerRootView } from "react-native-gesture-handler";
|
|
818
1098
|
import { BottomSheetModalProvider as BottomSheetModalProvider2 } from "@gorhom/bottom-sheet";
|
|
819
|
-
import { PortalProvider, PortalHost } from "@gorhom/portal";
|
|
820
1099
|
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
821
1100
|
function createOverlayProvider() {
|
|
822
1101
|
const overlayId = randomId();
|
|
823
1102
|
const _a = createOverlay(overlayId), { useOverlayEvent } = _a, overlay2 = __objRest(_a, ["useOverlayEvent"]);
|
|
824
1103
|
const { OverlayContextProvider, useCurrentOverlay: useCurrentOverlay2, useOverlayData: useOverlayData2 } = createOverlaySafeContext();
|
|
825
1104
|
function OverlayProvider2({ children }) {
|
|
826
|
-
const [overlayState, overlayDispatch] =
|
|
1105
|
+
const [overlayState, overlayDispatch] = useReducer2(overlayReducer, {
|
|
827
1106
|
current: null,
|
|
828
1107
|
overlayOrderList: [],
|
|
829
1108
|
overlayData: {}
|
|
830
1109
|
});
|
|
831
|
-
const overlayStateRef =
|
|
832
|
-
|
|
1110
|
+
const overlayStateRef = useRef3(overlayState);
|
|
1111
|
+
useEffect7(() => {
|
|
833
1112
|
overlayStateRef.current = overlayState;
|
|
834
1113
|
}, [overlayState]);
|
|
835
|
-
const overlayOpen =
|
|
1114
|
+
const overlayOpen = useCallback4(
|
|
836
1115
|
({
|
|
837
1116
|
controller,
|
|
838
1117
|
overlayId: overlayId2,
|
|
@@ -857,16 +1136,16 @@ function createOverlayProvider() {
|
|
|
857
1136
|
},
|
|
858
1137
|
[]
|
|
859
1138
|
);
|
|
860
|
-
const close =
|
|
1139
|
+
const close = useCallback4((overlayId2) => {
|
|
861
1140
|
overlayDispatch({ type: "CLOSE", overlayId: overlayId2 });
|
|
862
1141
|
}, []);
|
|
863
|
-
const unmount =
|
|
1142
|
+
const unmount = useCallback4((overlayId2) => {
|
|
864
1143
|
overlayDispatch({ type: "REMOVE", overlayId: overlayId2 });
|
|
865
1144
|
}, []);
|
|
866
|
-
const closeAll =
|
|
1145
|
+
const closeAll = useCallback4(() => {
|
|
867
1146
|
overlayDispatch({ type: "CLOSE_ALL" });
|
|
868
1147
|
}, []);
|
|
869
|
-
const unmountAll =
|
|
1148
|
+
const unmountAll = useCallback4(() => {
|
|
870
1149
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
871
1150
|
}, []);
|
|
872
1151
|
useOverlayEvent({
|
|
@@ -876,12 +1155,12 @@ function createOverlayProvider() {
|
|
|
876
1155
|
closeAll,
|
|
877
1156
|
unmountAll
|
|
878
1157
|
});
|
|
879
|
-
|
|
1158
|
+
useEffect7(() => {
|
|
880
1159
|
return () => {
|
|
881
1160
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
882
1161
|
};
|
|
883
1162
|
}, []);
|
|
884
|
-
|
|
1163
|
+
useEffect7(() => {
|
|
885
1164
|
if (Platform2.OS !== "android") {
|
|
886
1165
|
return;
|
|
887
1166
|
}
|