@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.js
CHANGED
|
@@ -70,7 +70,7 @@ __export(index_exports, {
|
|
|
70
70
|
module.exports = __toCommonJS(index_exports);
|
|
71
71
|
|
|
72
72
|
// src/context/provider/index.tsx
|
|
73
|
-
var
|
|
73
|
+
var import_react14 = require("react");
|
|
74
74
|
var import_react_native3 = require("react-native");
|
|
75
75
|
|
|
76
76
|
// src/context/provider/content-overlay-controller.tsx
|
|
@@ -107,13 +107,286 @@ var ContentOverlayController = (0, import_react.memo)(
|
|
|
107
107
|
);
|
|
108
108
|
|
|
109
109
|
// src/context/provider/bottom-sheet-controller.tsx
|
|
110
|
-
var
|
|
110
|
+
var import_react8 = __toESM(require("react"));
|
|
111
111
|
var import_bottom_sheet = __toESM(require("@gorhom/bottom-sheet"));
|
|
112
112
|
var import_react_native = require("react-native");
|
|
113
113
|
var import_react_native_reanimated = require("react-native-reanimated");
|
|
114
|
-
|
|
114
|
+
|
|
115
|
+
// node_modules/@gorhom/portal/lib/module/components/portal/Portal.js
|
|
116
|
+
var import_react4 = require("react");
|
|
117
|
+
|
|
118
|
+
// node_modules/nanoid/non-secure/index.js
|
|
119
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
120
|
+
var nanoid = (size = 21) => {
|
|
121
|
+
let id = "";
|
|
122
|
+
let i = size | 0;
|
|
123
|
+
while (i--) {
|
|
124
|
+
id += urlAlphabet[Math.random() * 64 | 0];
|
|
125
|
+
}
|
|
126
|
+
return id;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortal.js
|
|
130
|
+
var import_react3 = require("react");
|
|
131
|
+
|
|
132
|
+
// node_modules/@gorhom/portal/lib/module/state/constants.js
|
|
133
|
+
var ACTIONS;
|
|
134
|
+
(function(ACTIONS2) {
|
|
135
|
+
ACTIONS2[ACTIONS2["REGISTER_HOST"] = 0] = "REGISTER_HOST";
|
|
136
|
+
ACTIONS2[ACTIONS2["DEREGISTER_HOST"] = 1] = "DEREGISTER_HOST";
|
|
137
|
+
ACTIONS2[ACTIONS2["ADD_UPDATE_PORTAL"] = 2] = "ADD_UPDATE_PORTAL";
|
|
138
|
+
ACTIONS2[ACTIONS2["REMOVE_PORTAL"] = 3] = "REMOVE_PORTAL";
|
|
139
|
+
})(ACTIONS || (ACTIONS = {}));
|
|
140
|
+
var INITIAL_STATE = {};
|
|
141
|
+
|
|
142
|
+
// node_modules/@gorhom/portal/lib/module/contexts/portal.js
|
|
143
|
+
var import_react2 = require("react");
|
|
144
|
+
var PortalStateContext = /* @__PURE__ */ (0, import_react2.createContext)(null);
|
|
145
|
+
var PortalDispatchContext = /* @__PURE__ */ (0, import_react2.createContext)(null);
|
|
146
|
+
|
|
147
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortal.js
|
|
148
|
+
var usePortal = (hostName = "root") => {
|
|
149
|
+
const dispatch = (0, import_react3.useContext)(PortalDispatchContext);
|
|
150
|
+
if (dispatch === null) {
|
|
151
|
+
throw new Error("'PortalDispatchContext' cannot be null, please add 'PortalProvider' to the root component.");
|
|
152
|
+
}
|
|
153
|
+
const registerHost2 = (0, import_react3.useCallback)(() => {
|
|
154
|
+
dispatch({
|
|
155
|
+
type: ACTIONS.REGISTER_HOST,
|
|
156
|
+
hostName
|
|
157
|
+
});
|
|
158
|
+
}, []);
|
|
159
|
+
const deregisterHost2 = (0, import_react3.useCallback)(() => {
|
|
160
|
+
dispatch({
|
|
161
|
+
type: ACTIONS.DEREGISTER_HOST,
|
|
162
|
+
hostName
|
|
163
|
+
});
|
|
164
|
+
}, []);
|
|
165
|
+
const addUpdatePortal2 = (0, import_react3.useCallback)((name, node) => {
|
|
166
|
+
dispatch({
|
|
167
|
+
type: ACTIONS.ADD_UPDATE_PORTAL,
|
|
168
|
+
hostName,
|
|
169
|
+
portalName: name,
|
|
170
|
+
node
|
|
171
|
+
});
|
|
172
|
+
}, []);
|
|
173
|
+
const removePortal2 = (0, import_react3.useCallback)((name) => {
|
|
174
|
+
dispatch({
|
|
175
|
+
type: ACTIONS.REMOVE_PORTAL,
|
|
176
|
+
hostName,
|
|
177
|
+
portalName: name
|
|
178
|
+
});
|
|
179
|
+
}, []);
|
|
180
|
+
return {
|
|
181
|
+
registerHost: registerHost2,
|
|
182
|
+
deregisterHost: deregisterHost2,
|
|
183
|
+
addPortal: addUpdatePortal2,
|
|
184
|
+
updatePortal: addUpdatePortal2,
|
|
185
|
+
removePortal: removePortal2
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// node_modules/@gorhom/portal/lib/module/components/portal/Portal.js
|
|
190
|
+
var PortalComponent = ({
|
|
191
|
+
name: _providedName,
|
|
192
|
+
hostName,
|
|
193
|
+
handleOnMount: _providedHandleOnMount,
|
|
194
|
+
handleOnUnmount: _providedHandleOnUnmount,
|
|
195
|
+
handleOnUpdate: _providedHandleOnUpdate,
|
|
196
|
+
children
|
|
197
|
+
}) => {
|
|
198
|
+
const {
|
|
199
|
+
addPortal: addUpdatePortal2,
|
|
200
|
+
removePortal: removePortal2
|
|
201
|
+
} = usePortal(hostName);
|
|
202
|
+
const name = (0, import_react4.useMemo)(() => _providedName || nanoid(), [_providedName]);
|
|
203
|
+
const handleOnMountRef = (0, import_react4.useRef)();
|
|
204
|
+
const handleOnUnmountRef = (0, import_react4.useRef)();
|
|
205
|
+
const handleOnUpdateRef = (0, import_react4.useRef)();
|
|
206
|
+
const handleOnMount = (0, import_react4.useCallback)(() => {
|
|
207
|
+
if (_providedHandleOnMount) {
|
|
208
|
+
_providedHandleOnMount(() => addUpdatePortal2(name, children));
|
|
209
|
+
} else {
|
|
210
|
+
addUpdatePortal2(name, children);
|
|
211
|
+
}
|
|
212
|
+
}, [_providedHandleOnMount, addUpdatePortal2]);
|
|
213
|
+
handleOnMountRef.current = handleOnMount;
|
|
214
|
+
const handleOnUnmount = (0, import_react4.useCallback)(() => {
|
|
215
|
+
if (_providedHandleOnUnmount) {
|
|
216
|
+
_providedHandleOnUnmount(() => removePortal2(name));
|
|
217
|
+
} else {
|
|
218
|
+
removePortal2(name);
|
|
219
|
+
}
|
|
220
|
+
}, [_providedHandleOnUnmount, removePortal2]);
|
|
221
|
+
handleOnUnmountRef.current = handleOnUnmount;
|
|
222
|
+
const handleOnUpdate = (0, import_react4.useCallback)(() => {
|
|
223
|
+
if (_providedHandleOnUpdate) {
|
|
224
|
+
_providedHandleOnUpdate(() => addUpdatePortal2(name, children));
|
|
225
|
+
} else {
|
|
226
|
+
addUpdatePortal2(name, children);
|
|
227
|
+
}
|
|
228
|
+
}, [_providedHandleOnUpdate, addUpdatePortal2, children]);
|
|
229
|
+
handleOnUpdateRef.current = handleOnUpdate;
|
|
230
|
+
(0, import_react4.useEffect)(() => {
|
|
231
|
+
var _handleOnMountRef$cur;
|
|
232
|
+
(_handleOnMountRef$cur = handleOnMountRef.current) === null || _handleOnMountRef$cur === void 0 ? void 0 : _handleOnMountRef$cur.call(handleOnMountRef);
|
|
233
|
+
return () => {
|
|
234
|
+
var _handleOnUnmountRef$c;
|
|
235
|
+
(_handleOnUnmountRef$c = handleOnUnmountRef.current) === null || _handleOnUnmountRef$c === void 0 ? void 0 : _handleOnUnmountRef$c.call(handleOnUnmountRef);
|
|
236
|
+
handleOnMountRef.current = void 0;
|
|
237
|
+
handleOnUnmountRef.current = void 0;
|
|
238
|
+
handleOnUpdateRef.current = void 0;
|
|
239
|
+
};
|
|
240
|
+
}, []);
|
|
241
|
+
(0, import_react4.useEffect)(() => {
|
|
242
|
+
var _handleOnUpdateRef$cu;
|
|
243
|
+
(_handleOnUpdateRef$cu = handleOnUpdateRef.current) === null || _handleOnUpdateRef$cu === void 0 ? void 0 : _handleOnUpdateRef$cu.call(handleOnUpdateRef);
|
|
244
|
+
}, [children]);
|
|
245
|
+
return null;
|
|
246
|
+
};
|
|
247
|
+
var Portal = /* @__PURE__ */ (0, import_react4.memo)(PortalComponent);
|
|
248
|
+
Portal.displayName = "Portal";
|
|
249
|
+
|
|
250
|
+
// node_modules/@gorhom/portal/lib/module/components/portalHost/PortalHost.js
|
|
251
|
+
var import_react6 = __toESM(require("react"));
|
|
252
|
+
|
|
253
|
+
// node_modules/@gorhom/portal/lib/module/hooks/usePortalState.js
|
|
254
|
+
var import_react5 = require("react");
|
|
255
|
+
var usePortalState = (hostName) => {
|
|
256
|
+
const state = (0, import_react5.useContext)(PortalStateContext);
|
|
257
|
+
if (state === null) {
|
|
258
|
+
throw new Error("'PortalStateContext' cannot be null, please add 'PortalProvider' to the root component.");
|
|
259
|
+
}
|
|
260
|
+
return state[hostName] || [];
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
// node_modules/@gorhom/portal/lib/module/components/portalHost/PortalHost.js
|
|
264
|
+
var PortalHostComponent = ({
|
|
265
|
+
name
|
|
266
|
+
}) => {
|
|
267
|
+
const state = usePortalState(name);
|
|
268
|
+
const {
|
|
269
|
+
registerHost: registerHost2,
|
|
270
|
+
deregisterHost: deregisterHost2
|
|
271
|
+
} = usePortal(name);
|
|
272
|
+
(0, import_react6.useEffect)(() => {
|
|
273
|
+
registerHost2();
|
|
274
|
+
return () => {
|
|
275
|
+
deregisterHost2();
|
|
276
|
+
};
|
|
277
|
+
}, []);
|
|
278
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, state.map((item) => item.node));
|
|
279
|
+
};
|
|
280
|
+
var PortalHost = /* @__PURE__ */ (0, import_react6.memo)(PortalHostComponent);
|
|
281
|
+
PortalHost.displayName = "PortalHost";
|
|
282
|
+
|
|
283
|
+
// node_modules/@gorhom/portal/lib/module/components/portalProvider/PortalProvider.js
|
|
284
|
+
var import_react7 = __toESM(require("react"));
|
|
285
|
+
|
|
286
|
+
// node_modules/@gorhom/portal/lib/module/utilities/logger.js
|
|
287
|
+
var isLoggingEnabled = false;
|
|
288
|
+
var isDev = Boolean(typeof __DEV__ !== "undefined" && __DEV__);
|
|
289
|
+
var print = () => {
|
|
290
|
+
};
|
|
291
|
+
if (isDev) {
|
|
292
|
+
print = ({
|
|
293
|
+
component,
|
|
294
|
+
method,
|
|
295
|
+
params
|
|
296
|
+
}) => {
|
|
297
|
+
if (!isLoggingEnabled) {
|
|
298
|
+
return;
|
|
299
|
+
}
|
|
300
|
+
let message = "";
|
|
301
|
+
if (typeof params === "object") {
|
|
302
|
+
message = Object.keys(params).map((key) => "".concat(key, ":").concat(params[key])).join(" ");
|
|
303
|
+
} else {
|
|
304
|
+
message = "".concat(params !== null && params !== void 0 ? params : "");
|
|
305
|
+
}
|
|
306
|
+
console.log("[Portal::".concat([component, method].filter(Boolean).join("::"), "]"), message);
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
Object.freeze(print);
|
|
310
|
+
|
|
311
|
+
// node_modules/@gorhom/portal/lib/module/state/reducer.js
|
|
312
|
+
var registerHost = (state, hostName) => {
|
|
313
|
+
if (!(hostName in state)) {
|
|
314
|
+
state[hostName] = [];
|
|
315
|
+
}
|
|
316
|
+
return state;
|
|
317
|
+
};
|
|
318
|
+
var deregisterHost = (state, hostName) => {
|
|
319
|
+
delete state[hostName];
|
|
320
|
+
return state;
|
|
321
|
+
};
|
|
322
|
+
var addUpdatePortal = (state, hostName, portalName, node) => {
|
|
323
|
+
if (!(hostName in state)) {
|
|
324
|
+
state = registerHost(state, hostName);
|
|
325
|
+
}
|
|
326
|
+
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
327
|
+
if (index !== -1) {
|
|
328
|
+
state[hostName][index].node = node;
|
|
329
|
+
} else {
|
|
330
|
+
state[hostName].push({
|
|
331
|
+
name: portalName,
|
|
332
|
+
node
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
return state;
|
|
336
|
+
};
|
|
337
|
+
var removePortal = (state, hostName, portalName) => {
|
|
338
|
+
if (!(hostName in state)) {
|
|
339
|
+
print({
|
|
340
|
+
component: reducer.name,
|
|
341
|
+
method: removePortal.name,
|
|
342
|
+
params: "Failed to remove portal '".concat(portalName, "', '").concat(hostName, "' was not registered!")
|
|
343
|
+
});
|
|
344
|
+
return state;
|
|
345
|
+
}
|
|
346
|
+
const index = state[hostName].findIndex((item) => item.name === portalName);
|
|
347
|
+
if (index !== -1) state[hostName].splice(index, 1);
|
|
348
|
+
return state;
|
|
349
|
+
};
|
|
350
|
+
var reducer = (state, action) => {
|
|
351
|
+
const {
|
|
352
|
+
type
|
|
353
|
+
} = action;
|
|
354
|
+
let clonedState = __spreadValues({}, state);
|
|
355
|
+
switch (type) {
|
|
356
|
+
case ACTIONS.REGISTER_HOST:
|
|
357
|
+
return registerHost(clonedState, action.hostName);
|
|
358
|
+
case ACTIONS.DEREGISTER_HOST:
|
|
359
|
+
return deregisterHost(clonedState, action.hostName);
|
|
360
|
+
case ACTIONS.ADD_UPDATE_PORTAL:
|
|
361
|
+
return addUpdatePortal(clonedState, action.hostName, action.portalName, action.node);
|
|
362
|
+
case ACTIONS.REMOVE_PORTAL:
|
|
363
|
+
return removePortal(clonedState, action.hostName, action.portalName);
|
|
364
|
+
default:
|
|
365
|
+
return state;
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
// node_modules/@gorhom/portal/lib/module/components/portalProvider/PortalProvider.js
|
|
370
|
+
var PortalProviderComponent = ({
|
|
371
|
+
rootHostName = "root",
|
|
372
|
+
shouldAddRootHost = true,
|
|
373
|
+
children
|
|
374
|
+
}) => {
|
|
375
|
+
const [state, dispatch] = (0, import_react7.useReducer)(reducer, INITIAL_STATE);
|
|
376
|
+
return /* @__PURE__ */ import_react7.default.createElement(PortalDispatchContext.Provider, {
|
|
377
|
+
value: dispatch
|
|
378
|
+
}, /* @__PURE__ */ import_react7.default.createElement(PortalStateContext.Provider, {
|
|
379
|
+
value: state
|
|
380
|
+
}, children, shouldAddRootHost && /* @__PURE__ */ import_react7.default.createElement(PortalHost, {
|
|
381
|
+
name: rootHostName
|
|
382
|
+
})));
|
|
383
|
+
};
|
|
384
|
+
var PortalProvider = /* @__PURE__ */ (0, import_react7.memo)(PortalProviderComponent);
|
|
385
|
+
PortalProvider.displayName = "PortalProvider";
|
|
386
|
+
|
|
387
|
+
// src/context/provider/bottom-sheet-controller.tsx
|
|
115
388
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
116
|
-
var ContentBottomSheetController = (0,
|
|
389
|
+
var ContentBottomSheetController = (0, import_react8.memo)(
|
|
117
390
|
({
|
|
118
391
|
isOpen,
|
|
119
392
|
overlayId,
|
|
@@ -122,10 +395,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
122
395
|
overlayOrderList,
|
|
123
396
|
options = {}
|
|
124
397
|
}) => {
|
|
125
|
-
const bottomSheetRef = (0,
|
|
398
|
+
const bottomSheetRef = (0, import_react8.useRef)(null);
|
|
126
399
|
const reducedMotion = (0, import_react_native_reanimated.useReducedMotion)();
|
|
127
|
-
const [keyboardHeight, setKeyboardHeight] = (0,
|
|
128
|
-
const isKeyboardActiveRef = (0,
|
|
400
|
+
const [keyboardHeight, setKeyboardHeight] = (0, import_react8.useState)(0);
|
|
401
|
+
const isKeyboardActiveRef = (0, import_react8.useRef)(false);
|
|
129
402
|
const getZIndex = () => {
|
|
130
403
|
const index = overlayOrderList.indexOf(overlayId);
|
|
131
404
|
return 1e3 + index;
|
|
@@ -141,7 +414,8 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
141
414
|
keyboardBehavior = import_react_native.Platform.OS === "android" ? "extend" : "interactive",
|
|
142
415
|
keyboardBlurBehavior = "restore",
|
|
143
416
|
androidKeyboardInputMode = "adjustResize",
|
|
144
|
-
closeAllOnGestureClose = false
|
|
417
|
+
closeAllOnGestureClose = false,
|
|
418
|
+
closeFunction
|
|
145
419
|
} = _a, restOptions = __objRest(_a, [
|
|
146
420
|
"snapPoints",
|
|
147
421
|
"enablePanDownToClose",
|
|
@@ -153,9 +427,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
153
427
|
"keyboardBehavior",
|
|
154
428
|
"keyboardBlurBehavior",
|
|
155
429
|
"androidKeyboardInputMode",
|
|
156
|
-
"closeAllOnGestureClose"
|
|
430
|
+
"closeAllOnGestureClose",
|
|
431
|
+
"closeFunction"
|
|
157
432
|
]);
|
|
158
|
-
(0,
|
|
433
|
+
(0, import_react8.useEffect)(() => {
|
|
159
434
|
const keyboardWillShowListener = import_react_native.Keyboard.addListener(
|
|
160
435
|
import_react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
161
436
|
(e) => {
|
|
@@ -175,7 +450,7 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
175
450
|
keyboardWillHideListener.remove();
|
|
176
451
|
};
|
|
177
452
|
}, []);
|
|
178
|
-
(0,
|
|
453
|
+
(0, import_react8.useEffect)(() => {
|
|
179
454
|
if (isOpen) {
|
|
180
455
|
const rafId = requestAnimationFrame(() => {
|
|
181
456
|
var _a2;
|
|
@@ -186,7 +461,7 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
186
461
|
} else {
|
|
187
462
|
}
|
|
188
463
|
}, [isOpen, overlayDispatch, overlayId]);
|
|
189
|
-
const handleClose = (0,
|
|
464
|
+
const handleClose = (0, import_react8.useCallback)(() => {
|
|
190
465
|
if (isKeyboardActiveRef.current) {
|
|
191
466
|
import_react_native.Keyboard.dismiss();
|
|
192
467
|
setTimeout(() => {
|
|
@@ -195,7 +470,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
195
470
|
} else {
|
|
196
471
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
197
472
|
}
|
|
198
|
-
|
|
473
|
+
if (closeFunction) {
|
|
474
|
+
closeFunction();
|
|
475
|
+
}
|
|
476
|
+
}, 100);
|
|
199
477
|
return;
|
|
200
478
|
}
|
|
201
479
|
setTimeout(() => {
|
|
@@ -204,9 +482,12 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
204
482
|
} else {
|
|
205
483
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
206
484
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
485
|
+
if (closeFunction) {
|
|
486
|
+
closeFunction();
|
|
487
|
+
}
|
|
488
|
+
}, 50);
|
|
489
|
+
}, [overlayDispatch, overlayId, closeAllOnGestureClose, closeFunction]);
|
|
490
|
+
const renderBackdrop = (0, import_react8.useCallback)(
|
|
210
491
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
211
492
|
import_bottom_sheet.BottomSheetBackdrop,
|
|
212
493
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -218,13 +499,13 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
218
499
|
),
|
|
219
500
|
[backdropOpacity, handleClose]
|
|
220
501
|
);
|
|
221
|
-
const handleSheetChange = (0,
|
|
502
|
+
const handleSheetChange = (0, import_react8.useCallback)((index) => {
|
|
222
503
|
}, []);
|
|
223
504
|
const getLayerIndex = () => {
|
|
224
505
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
225
506
|
};
|
|
226
507
|
if (!isOpen) return null;
|
|
227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
508
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
228
509
|
import_bottom_sheet.default,
|
|
229
510
|
{
|
|
230
511
|
style: [{ zIndex: getZIndex() }],
|
|
@@ -255,10 +536,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
255
536
|
],
|
|
256
537
|
enableDynamicSizing,
|
|
257
538
|
animateOnMount: !reducedMotion,
|
|
258
|
-
children:
|
|
539
|
+
children: import_react8.default.isValidElement(Controller) ? import_react8.default.cloneElement(Controller, {
|
|
259
540
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
260
541
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
261
|
-
}) :
|
|
542
|
+
}) : import_react8.default.createElement(Controller, __spreadValues({
|
|
262
543
|
isOpen,
|
|
263
544
|
overlayId,
|
|
264
545
|
snapPoints,
|
|
@@ -273,12 +554,11 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
273
554
|
);
|
|
274
555
|
|
|
275
556
|
// src/context/provider/modal-controller.tsx
|
|
276
|
-
var
|
|
557
|
+
var import_react9 = __toESM(require("react"));
|
|
277
558
|
var import_react_native2 = require("react-native");
|
|
278
|
-
var import_portal2 = require("@gorhom/portal");
|
|
279
559
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
280
560
|
var { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = import_react_native2.Dimensions.get("window");
|
|
281
|
-
var ContentModalController = (0,
|
|
561
|
+
var ContentModalController = (0, import_react9.memo)(
|
|
282
562
|
({
|
|
283
563
|
isOpen,
|
|
284
564
|
overlayId,
|
|
@@ -293,10 +573,10 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
293
573
|
animationType = "fade",
|
|
294
574
|
swipeDirection
|
|
295
575
|
} = options;
|
|
296
|
-
const [backdropAnimation] = (0,
|
|
297
|
-
const [contentAnimation] = (0,
|
|
298
|
-
const [mounted, setMounted] = (0,
|
|
299
|
-
(0,
|
|
576
|
+
const [backdropAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
|
|
577
|
+
const [contentAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
|
|
578
|
+
const [mounted, setMounted] = (0, import_react9.useState)(isOpen);
|
|
579
|
+
(0, import_react9.useEffect)(() => {
|
|
300
580
|
if (isOpen) {
|
|
301
581
|
if (!mounted) setMounted(true);
|
|
302
582
|
setImmediate(() => {
|
|
@@ -423,7 +703,7 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
423
703
|
}
|
|
424
704
|
};
|
|
425
705
|
if (!mounted) return null;
|
|
426
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
706
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
427
707
|
import_react_native2.View,
|
|
428
708
|
{
|
|
429
709
|
style: [styles.absoluteContainer],
|
|
@@ -456,10 +736,10 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
456
736
|
{
|
|
457
737
|
style: [getContainerStyle(), getContentAnimationStyle()],
|
|
458
738
|
pointerEvents: "box-none",
|
|
459
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { pointerEvents: "box-none", children:
|
|
739
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { pointerEvents: "box-none", children: import_react9.default.isValidElement(Controller) ? import_react9.default.cloneElement(Controller, {
|
|
460
740
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
461
741
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
462
|
-
}) :
|
|
742
|
+
}) : import_react9.default.createElement(Controller, {
|
|
463
743
|
isOpen,
|
|
464
744
|
overlayId,
|
|
465
745
|
modalType,
|
|
@@ -506,10 +786,10 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
506
786
|
});
|
|
507
787
|
|
|
508
788
|
// src/event.ts
|
|
509
|
-
var
|
|
789
|
+
var import_react12 = __toESM(require("react"));
|
|
510
790
|
|
|
511
791
|
// src/utils/create-use-external-events.ts
|
|
512
|
-
var
|
|
792
|
+
var import_react10 = require("react");
|
|
513
793
|
|
|
514
794
|
// src/utils/emitter.ts
|
|
515
795
|
function createEmitter(all) {
|
|
@@ -554,7 +834,7 @@ function createEmitter(all) {
|
|
|
554
834
|
// src/utils/create-use-external-events.ts
|
|
555
835
|
var emitter = createEmitter();
|
|
556
836
|
function useClientEffect(...args) {
|
|
557
|
-
(0,
|
|
837
|
+
(0, import_react10.useEffect)(...args);
|
|
558
838
|
}
|
|
559
839
|
function dispatchEvent(type, detail) {
|
|
560
840
|
emitter.emit(type, detail);
|
|
@@ -594,13 +874,13 @@ function randomId() {
|
|
|
594
874
|
}
|
|
595
875
|
|
|
596
876
|
// src/utils/get-component-name.ts
|
|
597
|
-
var
|
|
877
|
+
var import_react11 = __toESM(require("react"));
|
|
598
878
|
function getComponentName(controller) {
|
|
599
879
|
var _a, _b;
|
|
600
880
|
if (controller == null ? void 0 : controller.displayName) {
|
|
601
881
|
return controller.displayName;
|
|
602
882
|
}
|
|
603
|
-
if (
|
|
883
|
+
if (import_react11.default.isValidElement(controller)) {
|
|
604
884
|
const type = controller.type;
|
|
605
885
|
if (type == null ? void 0 : type.displayName) return type.displayName;
|
|
606
886
|
if ((type == null ? void 0 : type.name) && type.name !== "anonymous") return type.name;
|
|
@@ -633,9 +913,9 @@ function createOverlay(overlayId) {
|
|
|
633
913
|
const dispatchOpenEvent = createEvent("open");
|
|
634
914
|
const _c = options || {}, { overlayId: _, overlayType: __ } = _c, restOptions = __objRest(_c, ["overlayId", "overlayType"]);
|
|
635
915
|
let finalController;
|
|
636
|
-
if (
|
|
916
|
+
if (import_react12.default.isValidElement(controller)) {
|
|
637
917
|
finalController = (props) => {
|
|
638
|
-
return
|
|
918
|
+
return import_react12.default.cloneElement(controller, __spreadProps(__spreadValues(__spreadValues({}, controller.props || {}), props), {
|
|
639
919
|
close: props.close,
|
|
640
920
|
unmount: props.unmount
|
|
641
921
|
}));
|
|
@@ -665,8 +945,8 @@ function createOverlay(overlayId) {
|
|
|
665
945
|
overlayProps.unmount();
|
|
666
946
|
};
|
|
667
947
|
const props = __spreadProps(__spreadValues({}, overlayProps), { close: close2, unmount: unmount2 });
|
|
668
|
-
if (
|
|
669
|
-
return
|
|
948
|
+
if (import_react12.default.isValidElement(controller)) {
|
|
949
|
+
return import_react12.default.cloneElement(controller, __spreadValues(__spreadValues({}, controller.props || {}), props));
|
|
670
950
|
}
|
|
671
951
|
if (typeof controller === "function") {
|
|
672
952
|
return controller(props);
|
|
@@ -692,13 +972,13 @@ function createOverlay(overlayId) {
|
|
|
692
972
|
}
|
|
693
973
|
|
|
694
974
|
// src/utils/create-safe-context.ts
|
|
695
|
-
var
|
|
975
|
+
var import_react13 = require("react");
|
|
696
976
|
var NullSymbol = Symbol("Null");
|
|
697
977
|
function createSafeContext(displayName) {
|
|
698
|
-
const Context = (0,
|
|
978
|
+
const Context = (0, import_react13.createContext)(NullSymbol);
|
|
699
979
|
Context.displayName = displayName != null ? displayName : "SafeContext";
|
|
700
980
|
function useSafeContext() {
|
|
701
|
-
const context = (0,
|
|
981
|
+
const context = (0, import_react13.useContext)(Context);
|
|
702
982
|
if (context === NullSymbol) {
|
|
703
983
|
const error = new Error(`[${Context.displayName}]: Provider not found.`);
|
|
704
984
|
error.name = "[Error] Context";
|
|
@@ -832,23 +1112,22 @@ function overlayReducer(state, action) {
|
|
|
832
1112
|
// src/context/provider/index.tsx
|
|
833
1113
|
var import_react_native_gesture_handler = require("react-native-gesture-handler");
|
|
834
1114
|
var import_bottom_sheet2 = require("@gorhom/bottom-sheet");
|
|
835
|
-
var import_portal3 = require("@gorhom/portal");
|
|
836
1115
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
837
1116
|
function createOverlayProvider() {
|
|
838
1117
|
const overlayId = randomId();
|
|
839
1118
|
const _a = createOverlay(overlayId), { useOverlayEvent } = _a, overlay2 = __objRest(_a, ["useOverlayEvent"]);
|
|
840
1119
|
const { OverlayContextProvider, useCurrentOverlay: useCurrentOverlay2, useOverlayData: useOverlayData2 } = createOverlaySafeContext();
|
|
841
1120
|
function OverlayProvider2({ children }) {
|
|
842
|
-
const [overlayState, overlayDispatch] = (0,
|
|
1121
|
+
const [overlayState, overlayDispatch] = (0, import_react14.useReducer)(overlayReducer, {
|
|
843
1122
|
current: null,
|
|
844
1123
|
overlayOrderList: [],
|
|
845
1124
|
overlayData: {}
|
|
846
1125
|
});
|
|
847
|
-
const overlayStateRef = (0,
|
|
848
|
-
(0,
|
|
1126
|
+
const overlayStateRef = (0, import_react14.useRef)(overlayState);
|
|
1127
|
+
(0, import_react14.useEffect)(() => {
|
|
849
1128
|
overlayStateRef.current = overlayState;
|
|
850
1129
|
}, [overlayState]);
|
|
851
|
-
const overlayOpen = (0,
|
|
1130
|
+
const overlayOpen = (0, import_react14.useCallback)(
|
|
852
1131
|
({
|
|
853
1132
|
controller,
|
|
854
1133
|
overlayId: overlayId2,
|
|
@@ -873,16 +1152,16 @@ function createOverlayProvider() {
|
|
|
873
1152
|
},
|
|
874
1153
|
[]
|
|
875
1154
|
);
|
|
876
|
-
const close = (0,
|
|
1155
|
+
const close = (0, import_react14.useCallback)((overlayId2) => {
|
|
877
1156
|
overlayDispatch({ type: "CLOSE", overlayId: overlayId2 });
|
|
878
1157
|
}, []);
|
|
879
|
-
const unmount = (0,
|
|
1158
|
+
const unmount = (0, import_react14.useCallback)((overlayId2) => {
|
|
880
1159
|
overlayDispatch({ type: "REMOVE", overlayId: overlayId2 });
|
|
881
1160
|
}, []);
|
|
882
|
-
const closeAll = (0,
|
|
1161
|
+
const closeAll = (0, import_react14.useCallback)(() => {
|
|
883
1162
|
overlayDispatch({ type: "CLOSE_ALL" });
|
|
884
1163
|
}, []);
|
|
885
|
-
const unmountAll = (0,
|
|
1164
|
+
const unmountAll = (0, import_react14.useCallback)(() => {
|
|
886
1165
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
887
1166
|
}, []);
|
|
888
1167
|
useOverlayEvent({
|
|
@@ -892,12 +1171,12 @@ function createOverlayProvider() {
|
|
|
892
1171
|
closeAll,
|
|
893
1172
|
unmountAll
|
|
894
1173
|
});
|
|
895
|
-
(0,
|
|
1174
|
+
(0, import_react14.useEffect)(() => {
|
|
896
1175
|
return () => {
|
|
897
1176
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
898
1177
|
};
|
|
899
1178
|
}, []);
|
|
900
|
-
(0,
|
|
1179
|
+
(0, import_react14.useEffect)(() => {
|
|
901
1180
|
if (import_react_native3.Platform.OS !== "android") {
|
|
902
1181
|
return;
|
|
903
1182
|
}
|
|
@@ -924,7 +1203,7 @@ function createOverlayProvider() {
|
|
|
924
1203
|
subscription.remove();
|
|
925
1204
|
};
|
|
926
1205
|
}, [overlayDispatch]);
|
|
927
|
-
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_gesture_handler.GestureHandlerRootView, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1206
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_native_gesture_handler.GestureHandlerRootView, { style: { flex: 1 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PortalProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_bottom_sheet2.BottomSheetModalProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(OverlayContextProvider, { value: overlayState, children: [
|
|
928
1207
|
children,
|
|
929
1208
|
overlayState.overlayOrderList.map((item) => {
|
|
930
1209
|
const overlayItem = overlayState.overlayData[item];
|
|
@@ -1011,7 +1290,7 @@ function createOverlayProvider() {
|
|
|
1011
1290
|
);
|
|
1012
1291
|
}),
|
|
1013
1292
|
overlayState.overlayOrderList.map((id, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1014
|
-
|
|
1293
|
+
PortalHost,
|
|
1015
1294
|
{
|
|
1016
1295
|
name: `overlay-modal-${idx}`
|
|
1017
1296
|
},
|