@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.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,11 @@ 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);
|
|
402
|
+
const isClosingRef = (0, import_react8.useRef)(false);
|
|
129
403
|
const getZIndex = () => {
|
|
130
404
|
const index = overlayOrderList.indexOf(overlayId);
|
|
131
405
|
return 1e3 + index;
|
|
@@ -141,7 +415,8 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
141
415
|
keyboardBehavior = import_react_native.Platform.OS === "android" ? "extend" : "interactive",
|
|
142
416
|
keyboardBlurBehavior = "restore",
|
|
143
417
|
androidKeyboardInputMode = "adjustResize",
|
|
144
|
-
closeAllOnGestureClose = false
|
|
418
|
+
closeAllOnGestureClose = false,
|
|
419
|
+
closeFunction
|
|
145
420
|
} = _a, restOptions = __objRest(_a, [
|
|
146
421
|
"snapPoints",
|
|
147
422
|
"enablePanDownToClose",
|
|
@@ -153,9 +428,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
153
428
|
"keyboardBehavior",
|
|
154
429
|
"keyboardBlurBehavior",
|
|
155
430
|
"androidKeyboardInputMode",
|
|
156
|
-
"closeAllOnGestureClose"
|
|
431
|
+
"closeAllOnGestureClose",
|
|
432
|
+
"closeFunction"
|
|
157
433
|
]);
|
|
158
|
-
(0,
|
|
434
|
+
(0, import_react8.useEffect)(() => {
|
|
159
435
|
const keyboardWillShowListener = import_react_native.Keyboard.addListener(
|
|
160
436
|
import_react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
161
437
|
(e) => {
|
|
@@ -175,7 +451,7 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
175
451
|
keyboardWillHideListener.remove();
|
|
176
452
|
};
|
|
177
453
|
}, []);
|
|
178
|
-
(0,
|
|
454
|
+
(0, import_react8.useEffect)(() => {
|
|
179
455
|
if (isOpen) {
|
|
180
456
|
const rafId = requestAnimationFrame(() => {
|
|
181
457
|
var _a2;
|
|
@@ -186,7 +462,11 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
186
462
|
} else {
|
|
187
463
|
}
|
|
188
464
|
}, [isOpen, overlayDispatch, overlayId]);
|
|
189
|
-
const handleClose = (0,
|
|
465
|
+
const handleClose = (0, import_react8.useCallback)(() => {
|
|
466
|
+
if (isClosingRef.current) {
|
|
467
|
+
return;
|
|
468
|
+
}
|
|
469
|
+
isClosingRef.current = true;
|
|
190
470
|
if (isKeyboardActiveRef.current) {
|
|
191
471
|
import_react_native.Keyboard.dismiss();
|
|
192
472
|
setTimeout(() => {
|
|
@@ -195,18 +475,24 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
195
475
|
} else {
|
|
196
476
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
197
477
|
}
|
|
198
|
-
|
|
478
|
+
if (closeFunction) {
|
|
479
|
+
closeFunction();
|
|
480
|
+
}
|
|
481
|
+
}, 50);
|
|
199
482
|
return;
|
|
200
483
|
}
|
|
201
|
-
|
|
484
|
+
requestAnimationFrame(() => {
|
|
202
485
|
if (closeAllOnGestureClose) {
|
|
203
486
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
204
487
|
} else {
|
|
205
488
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
206
489
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
490
|
+
if (closeFunction) {
|
|
491
|
+
closeFunction();
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
}, [overlayDispatch, overlayId, closeAllOnGestureClose, closeFunction]);
|
|
495
|
+
const renderBackdrop = (0, import_react8.useCallback)(
|
|
210
496
|
(props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
211
497
|
import_bottom_sheet.BottomSheetBackdrop,
|
|
212
498
|
__spreadProps(__spreadValues({}, props), {
|
|
@@ -218,13 +504,13 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
218
504
|
),
|
|
219
505
|
[backdropOpacity, handleClose]
|
|
220
506
|
);
|
|
221
|
-
const handleSheetChange = (0,
|
|
507
|
+
const handleSheetChange = (0, import_react8.useCallback)((index) => {
|
|
222
508
|
}, []);
|
|
223
509
|
const getLayerIndex = () => {
|
|
224
510
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
225
511
|
};
|
|
226
512
|
if (!isOpen) return null;
|
|
227
|
-
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
513
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
228
514
|
import_bottom_sheet.default,
|
|
229
515
|
{
|
|
230
516
|
style: [{ zIndex: getZIndex() }],
|
|
@@ -255,10 +541,10 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
255
541
|
],
|
|
256
542
|
enableDynamicSizing,
|
|
257
543
|
animateOnMount: !reducedMotion,
|
|
258
|
-
children:
|
|
544
|
+
children: import_react8.default.isValidElement(Controller) ? import_react8.default.cloneElement(Controller, {
|
|
259
545
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
260
546
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
261
|
-
}) :
|
|
547
|
+
}) : import_react8.default.createElement(Controller, __spreadValues({
|
|
262
548
|
isOpen,
|
|
263
549
|
overlayId,
|
|
264
550
|
snapPoints,
|
|
@@ -273,12 +559,11 @@ var ContentBottomSheetController = (0, import_react2.memo)(
|
|
|
273
559
|
);
|
|
274
560
|
|
|
275
561
|
// src/context/provider/modal-controller.tsx
|
|
276
|
-
var
|
|
562
|
+
var import_react9 = __toESM(require("react"));
|
|
277
563
|
var import_react_native2 = require("react-native");
|
|
278
|
-
var import_portal2 = require("@gorhom/portal");
|
|
279
564
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
280
565
|
var { width: SCREEN_WIDTH, height: SCREEN_HEIGHT } = import_react_native2.Dimensions.get("window");
|
|
281
|
-
var ContentModalController = (0,
|
|
566
|
+
var ContentModalController = (0, import_react9.memo)(
|
|
282
567
|
({
|
|
283
568
|
isOpen,
|
|
284
569
|
overlayId,
|
|
@@ -291,12 +576,14 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
291
576
|
modalType = "center",
|
|
292
577
|
backdropOpacity = 0.5,
|
|
293
578
|
animationType = "fade",
|
|
294
|
-
swipeDirection
|
|
579
|
+
swipeDirection,
|
|
580
|
+
closeFunction
|
|
295
581
|
} = options;
|
|
296
|
-
const [backdropAnimation] = (0,
|
|
297
|
-
const [contentAnimation] = (0,
|
|
298
|
-
const [mounted, setMounted] = (0,
|
|
299
|
-
(0,
|
|
582
|
+
const [backdropAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
|
|
583
|
+
const [contentAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
|
|
584
|
+
const [mounted, setMounted] = (0, import_react9.useState)(isOpen);
|
|
585
|
+
const [isClosing, setIsClosing] = (0, import_react9.useState)(false);
|
|
586
|
+
(0, import_react9.useEffect)(() => {
|
|
300
587
|
if (isOpen) {
|
|
301
588
|
if (!mounted) setMounted(true);
|
|
302
589
|
setImmediate(() => {
|
|
@@ -333,10 +620,17 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
333
620
|
}
|
|
334
621
|
}, [isOpen]);
|
|
335
622
|
const handleClose = () => {
|
|
623
|
+
if (isClosing) {
|
|
624
|
+
return;
|
|
625
|
+
}
|
|
626
|
+
setIsClosing(true);
|
|
336
627
|
import_react_native2.Keyboard.dismiss();
|
|
337
|
-
|
|
628
|
+
requestAnimationFrame(() => {
|
|
338
629
|
overlayDispatch({ type: "REMOVE", overlayId });
|
|
339
|
-
|
|
630
|
+
if (closeFunction) {
|
|
631
|
+
closeFunction();
|
|
632
|
+
}
|
|
633
|
+
});
|
|
340
634
|
};
|
|
341
635
|
const getLayerIndex = () => {
|
|
342
636
|
return Math.max(0, overlayOrderList.indexOf(overlayId));
|
|
@@ -423,7 +717,7 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
423
717
|
}
|
|
424
718
|
};
|
|
425
719
|
if (!mounted) return null;
|
|
426
|
-
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
720
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(Portal, { hostName: `overlay-modal-${getLayerIndex()}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
427
721
|
import_react_native2.View,
|
|
428
722
|
{
|
|
429
723
|
style: [styles.absoluteContainer],
|
|
@@ -456,10 +750,10 @@ var ContentModalController = (0, import_react3.memo)(
|
|
|
456
750
|
{
|
|
457
751
|
style: [getContainerStyle(), getContentAnimationStyle()],
|
|
458
752
|
pointerEvents: "box-none",
|
|
459
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_native2.View, { pointerEvents: "box-none", children:
|
|
753
|
+
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
754
|
close: () => overlayDispatch({ type: "CLOSE", overlayId }),
|
|
461
755
|
unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
|
|
462
|
-
}) :
|
|
756
|
+
}) : import_react9.default.createElement(Controller, {
|
|
463
757
|
isOpen,
|
|
464
758
|
overlayId,
|
|
465
759
|
modalType,
|
|
@@ -506,10 +800,10 @@ var styles = import_react_native2.StyleSheet.create({
|
|
|
506
800
|
});
|
|
507
801
|
|
|
508
802
|
// src/event.ts
|
|
509
|
-
var
|
|
803
|
+
var import_react12 = __toESM(require("react"));
|
|
510
804
|
|
|
511
805
|
// src/utils/create-use-external-events.ts
|
|
512
|
-
var
|
|
806
|
+
var import_react10 = require("react");
|
|
513
807
|
|
|
514
808
|
// src/utils/emitter.ts
|
|
515
809
|
function createEmitter(all) {
|
|
@@ -554,7 +848,7 @@ function createEmitter(all) {
|
|
|
554
848
|
// src/utils/create-use-external-events.ts
|
|
555
849
|
var emitter = createEmitter();
|
|
556
850
|
function useClientEffect(...args) {
|
|
557
|
-
(0,
|
|
851
|
+
(0, import_react10.useEffect)(...args);
|
|
558
852
|
}
|
|
559
853
|
function dispatchEvent(type, detail) {
|
|
560
854
|
emitter.emit(type, detail);
|
|
@@ -594,13 +888,13 @@ function randomId() {
|
|
|
594
888
|
}
|
|
595
889
|
|
|
596
890
|
// src/utils/get-component-name.ts
|
|
597
|
-
var
|
|
891
|
+
var import_react11 = __toESM(require("react"));
|
|
598
892
|
function getComponentName(controller) {
|
|
599
893
|
var _a, _b;
|
|
600
894
|
if (controller == null ? void 0 : controller.displayName) {
|
|
601
895
|
return controller.displayName;
|
|
602
896
|
}
|
|
603
|
-
if (
|
|
897
|
+
if (import_react11.default.isValidElement(controller)) {
|
|
604
898
|
const type = controller.type;
|
|
605
899
|
if (type == null ? void 0 : type.displayName) return type.displayName;
|
|
606
900
|
if ((type == null ? void 0 : type.name) && type.name !== "anonymous") return type.name;
|
|
@@ -633,9 +927,9 @@ function createOverlay(overlayId) {
|
|
|
633
927
|
const dispatchOpenEvent = createEvent("open");
|
|
634
928
|
const _c = options || {}, { overlayId: _, overlayType: __ } = _c, restOptions = __objRest(_c, ["overlayId", "overlayType"]);
|
|
635
929
|
let finalController;
|
|
636
|
-
if (
|
|
930
|
+
if (import_react12.default.isValidElement(controller)) {
|
|
637
931
|
finalController = (props) => {
|
|
638
|
-
return
|
|
932
|
+
return import_react12.default.cloneElement(controller, __spreadProps(__spreadValues(__spreadValues({}, controller.props || {}), props), {
|
|
639
933
|
close: props.close,
|
|
640
934
|
unmount: props.unmount
|
|
641
935
|
}));
|
|
@@ -665,8 +959,8 @@ function createOverlay(overlayId) {
|
|
|
665
959
|
overlayProps.unmount();
|
|
666
960
|
};
|
|
667
961
|
const props = __spreadProps(__spreadValues({}, overlayProps), { close: close2, unmount: unmount2 });
|
|
668
|
-
if (
|
|
669
|
-
return
|
|
962
|
+
if (import_react12.default.isValidElement(controller)) {
|
|
963
|
+
return import_react12.default.cloneElement(controller, __spreadValues(__spreadValues({}, controller.props || {}), props));
|
|
670
964
|
}
|
|
671
965
|
if (typeof controller === "function") {
|
|
672
966
|
return controller(props);
|
|
@@ -692,13 +986,13 @@ function createOverlay(overlayId) {
|
|
|
692
986
|
}
|
|
693
987
|
|
|
694
988
|
// src/utils/create-safe-context.ts
|
|
695
|
-
var
|
|
989
|
+
var import_react13 = require("react");
|
|
696
990
|
var NullSymbol = Symbol("Null");
|
|
697
991
|
function createSafeContext(displayName) {
|
|
698
|
-
const Context = (0,
|
|
992
|
+
const Context = (0, import_react13.createContext)(NullSymbol);
|
|
699
993
|
Context.displayName = displayName != null ? displayName : "SafeContext";
|
|
700
994
|
function useSafeContext() {
|
|
701
|
-
const context = (0,
|
|
995
|
+
const context = (0, import_react13.useContext)(Context);
|
|
702
996
|
if (context === NullSymbol) {
|
|
703
997
|
const error = new Error(`[${Context.displayName}]: Provider not found.`);
|
|
704
998
|
error.name = "[Error] Context";
|
|
@@ -832,23 +1126,22 @@ function overlayReducer(state, action) {
|
|
|
832
1126
|
// src/context/provider/index.tsx
|
|
833
1127
|
var import_react_native_gesture_handler = require("react-native-gesture-handler");
|
|
834
1128
|
var import_bottom_sheet2 = require("@gorhom/bottom-sheet");
|
|
835
|
-
var import_portal3 = require("@gorhom/portal");
|
|
836
1129
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
837
1130
|
function createOverlayProvider() {
|
|
838
1131
|
const overlayId = randomId();
|
|
839
1132
|
const _a = createOverlay(overlayId), { useOverlayEvent } = _a, overlay2 = __objRest(_a, ["useOverlayEvent"]);
|
|
840
1133
|
const { OverlayContextProvider, useCurrentOverlay: useCurrentOverlay2, useOverlayData: useOverlayData2 } = createOverlaySafeContext();
|
|
841
1134
|
function OverlayProvider2({ children }) {
|
|
842
|
-
const [overlayState, overlayDispatch] = (0,
|
|
1135
|
+
const [overlayState, overlayDispatch] = (0, import_react14.useReducer)(overlayReducer, {
|
|
843
1136
|
current: null,
|
|
844
1137
|
overlayOrderList: [],
|
|
845
1138
|
overlayData: {}
|
|
846
1139
|
});
|
|
847
|
-
const overlayStateRef = (0,
|
|
848
|
-
(0,
|
|
1140
|
+
const overlayStateRef = (0, import_react14.useRef)(overlayState);
|
|
1141
|
+
(0, import_react14.useEffect)(() => {
|
|
849
1142
|
overlayStateRef.current = overlayState;
|
|
850
1143
|
}, [overlayState]);
|
|
851
|
-
const overlayOpen = (0,
|
|
1144
|
+
const overlayOpen = (0, import_react14.useCallback)(
|
|
852
1145
|
({
|
|
853
1146
|
controller,
|
|
854
1147
|
overlayId: overlayId2,
|
|
@@ -873,16 +1166,16 @@ function createOverlayProvider() {
|
|
|
873
1166
|
},
|
|
874
1167
|
[]
|
|
875
1168
|
);
|
|
876
|
-
const close = (0,
|
|
1169
|
+
const close = (0, import_react14.useCallback)((overlayId2) => {
|
|
877
1170
|
overlayDispatch({ type: "CLOSE", overlayId: overlayId2 });
|
|
878
1171
|
}, []);
|
|
879
|
-
const unmount = (0,
|
|
1172
|
+
const unmount = (0, import_react14.useCallback)((overlayId2) => {
|
|
880
1173
|
overlayDispatch({ type: "REMOVE", overlayId: overlayId2 });
|
|
881
1174
|
}, []);
|
|
882
|
-
const closeAll = (0,
|
|
1175
|
+
const closeAll = (0, import_react14.useCallback)(() => {
|
|
883
1176
|
overlayDispatch({ type: "CLOSE_ALL" });
|
|
884
1177
|
}, []);
|
|
885
|
-
const unmountAll = (0,
|
|
1178
|
+
const unmountAll = (0, import_react14.useCallback)(() => {
|
|
886
1179
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
887
1180
|
}, []);
|
|
888
1181
|
useOverlayEvent({
|
|
@@ -892,12 +1185,12 @@ function createOverlayProvider() {
|
|
|
892
1185
|
closeAll,
|
|
893
1186
|
unmountAll
|
|
894
1187
|
});
|
|
895
|
-
(0,
|
|
1188
|
+
(0, import_react14.useEffect)(() => {
|
|
896
1189
|
return () => {
|
|
897
1190
|
overlayDispatch({ type: "REMOVE_ALL" });
|
|
898
1191
|
};
|
|
899
1192
|
}, []);
|
|
900
|
-
(0,
|
|
1193
|
+
(0, import_react14.useEffect)(() => {
|
|
901
1194
|
if (import_react_native3.Platform.OS !== "android") {
|
|
902
1195
|
return;
|
|
903
1196
|
}
|
|
@@ -924,7 +1217,7 @@ function createOverlayProvider() {
|
|
|
924
1217
|
subscription.remove();
|
|
925
1218
|
};
|
|
926
1219
|
}, [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)(
|
|
1220
|
+
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
1221
|
children,
|
|
929
1222
|
overlayState.overlayOrderList.map((item) => {
|
|
930
1223
|
const overlayItem = overlayState.overlayData[item];
|
|
@@ -1011,7 +1304,7 @@ function createOverlayProvider() {
|
|
|
1011
1304
|
);
|
|
1012
1305
|
}),
|
|
1013
1306
|
overlayState.overlayOrderList.map((id, idx) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1014
|
-
|
|
1307
|
+
PortalHost,
|
|
1015
1308
|
{
|
|
1016
1309
|
name: `overlay-modal-${idx}`
|
|
1017
1310
|
},
|