@mustmove/overlay-kit-rn 1.0.105 → 1.0.107
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.js +47 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -17
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -386,6 +386,16 @@ PortalProvider.displayName = "PortalProvider";
|
|
|
386
386
|
|
|
387
387
|
// src/context/provider/bottom-sheet-controller.tsx
|
|
388
388
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
389
|
+
var KeyboardControllerEvents = null;
|
|
390
|
+
var _a;
|
|
391
|
+
try {
|
|
392
|
+
const rnkc = require("react-native-keyboard-controller");
|
|
393
|
+
if ((_a = rnkc == null ? void 0 : rnkc.KeyboardEvents) == null ? void 0 : _a.addListener) {
|
|
394
|
+
KeyboardControllerEvents = rnkc.KeyboardEvents;
|
|
395
|
+
}
|
|
396
|
+
} catch (e) {
|
|
397
|
+
}
|
|
398
|
+
var useKeyboardControllerEvents = import_react_native.Platform.OS === "android" && !!KeyboardControllerEvents;
|
|
389
399
|
var ContentBottomSheetController = (0, import_react8.memo)(
|
|
390
400
|
({
|
|
391
401
|
isOpen,
|
|
@@ -410,6 +420,26 @@ var ContentBottomSheetController = (0, import_react8.memo)(
|
|
|
410
420
|
const [keyboardHeight, setKeyboardHeight] = (0, import_react8.useState)(0);
|
|
411
421
|
const isKeyboardActiveRef = (0, import_react8.useRef)(false);
|
|
412
422
|
(0, import_react8.useEffect)(() => {
|
|
423
|
+
if (useKeyboardControllerEvents && KeyboardControllerEvents) {
|
|
424
|
+
const showSub = KeyboardControllerEvents.addListener(
|
|
425
|
+
"keyboardWillShow",
|
|
426
|
+
(e) => {
|
|
427
|
+
isKeyboardActiveRef.current = true;
|
|
428
|
+
setKeyboardHeight(e.height);
|
|
429
|
+
}
|
|
430
|
+
);
|
|
431
|
+
const hideSub = KeyboardControllerEvents.addListener(
|
|
432
|
+
"keyboardWillHide",
|
|
433
|
+
() => {
|
|
434
|
+
isKeyboardActiveRef.current = false;
|
|
435
|
+
setKeyboardHeight(0);
|
|
436
|
+
}
|
|
437
|
+
);
|
|
438
|
+
return () => {
|
|
439
|
+
showSub.remove();
|
|
440
|
+
hideSub.remove();
|
|
441
|
+
};
|
|
442
|
+
}
|
|
413
443
|
const keyboardWillShowListener = import_react_native.Keyboard.addListener(
|
|
414
444
|
import_react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
|
|
415
445
|
(e) => {
|
|
@@ -433,7 +463,7 @@ var ContentBottomSheetController = (0, import_react8.memo)(
|
|
|
433
463
|
const index = overlayOrderList.indexOf(overlayId);
|
|
434
464
|
return 1e3 + index;
|
|
435
465
|
};
|
|
436
|
-
const
|
|
466
|
+
const _a2 = options, {
|
|
437
467
|
snapPoints,
|
|
438
468
|
enablePanDownToClose = true,
|
|
439
469
|
enableBackdrop = true,
|
|
@@ -447,7 +477,7 @@ var ContentBottomSheetController = (0, import_react8.memo)(
|
|
|
447
477
|
closeAllOnGestureClose = false,
|
|
448
478
|
isHandleClose = true,
|
|
449
479
|
closeFunction
|
|
450
|
-
} =
|
|
480
|
+
} = _a2, restOptions = __objRest(_a2, [
|
|
451
481
|
"snapPoints",
|
|
452
482
|
"enablePanDownToClose",
|
|
453
483
|
"enableBackdrop",
|
|
@@ -470,8 +500,8 @@ var ContentBottomSheetController = (0, import_react8.memo)(
|
|
|
470
500
|
closeTimerRef.current = null;
|
|
471
501
|
}
|
|
472
502
|
const rafId = requestAnimationFrame(() => {
|
|
473
|
-
var
|
|
474
|
-
(
|
|
503
|
+
var _a3;
|
|
504
|
+
(_a3 = bottomSheetRef.current) == null ? void 0 : _a3.expand();
|
|
475
505
|
overlayDispatch({ type: "OPEN", overlayId });
|
|
476
506
|
});
|
|
477
507
|
return () => cancelAnimationFrame(rafId);
|
|
@@ -928,7 +958,7 @@ function randomId() {
|
|
|
928
958
|
// src/utils/get-component-name.ts
|
|
929
959
|
var import_react11 = __toESM(require("react"));
|
|
930
960
|
function getComponentName(controller) {
|
|
931
|
-
var
|
|
961
|
+
var _a2, _b;
|
|
932
962
|
if (controller == null ? void 0 : controller.displayName) {
|
|
933
963
|
return controller.displayName;
|
|
934
964
|
}
|
|
@@ -942,7 +972,7 @@ function getComponentName(controller) {
|
|
|
942
972
|
return controller.name;
|
|
943
973
|
}
|
|
944
974
|
}
|
|
945
|
-
if ((
|
|
975
|
+
if ((_a2 = controller == null ? void 0 : controller.type) == null ? void 0 : _a2.displayName) {
|
|
946
976
|
return controller.type.displayName;
|
|
947
977
|
}
|
|
948
978
|
if (((_b = controller == null ? void 0 : controller.type) == null ? void 0 : _b.name) && controller.type.name !== "anonymous") {
|
|
@@ -957,8 +987,8 @@ function createOverlay(overlayId) {
|
|
|
957
987
|
`${overlayId}/overlay-kit`
|
|
958
988
|
);
|
|
959
989
|
const open = (controller, options) => {
|
|
960
|
-
var
|
|
961
|
-
const overlayId2 = (
|
|
990
|
+
var _a2, _b;
|
|
991
|
+
const overlayId2 = (_a2 = options == null ? void 0 : options.overlayId) != null ? _a2 : randomId();
|
|
962
992
|
const componentKey = randomId();
|
|
963
993
|
const overlayType = (_b = options == null ? void 0 : options.overlayType) != null ? _b : "overlay";
|
|
964
994
|
const componentName = getComponentName(controller);
|
|
@@ -1055,12 +1085,12 @@ function createOverlaySafeContext() {
|
|
|
1055
1085
|
|
|
1056
1086
|
// src/context/reducer.ts
|
|
1057
1087
|
var determineCurrentOverlayId = (overlayOrderList, overlayData, targetOverlayId) => {
|
|
1058
|
-
var
|
|
1088
|
+
var _a2, _b;
|
|
1059
1089
|
const openedOverlayOrderList = overlayOrderList.filter(
|
|
1060
1090
|
(orderedOverlayId) => overlayData[orderedOverlayId].isOpen === true
|
|
1061
1091
|
);
|
|
1062
1092
|
const targetIndexInOpenedList = openedOverlayOrderList.findIndex((item) => item === targetOverlayId);
|
|
1063
|
-
return targetIndexInOpenedList === openedOverlayOrderList.length - 1 ? (
|
|
1093
|
+
return targetIndexInOpenedList === openedOverlayOrderList.length - 1 ? (_a2 = openedOverlayOrderList[targetIndexInOpenedList - 1]) != null ? _a2 : null : (_b = openedOverlayOrderList[openedOverlayOrderList.length - 1]) != null ? _b : null;
|
|
1064
1094
|
};
|
|
1065
1095
|
function overlayReducer(state, action) {
|
|
1066
1096
|
switch (action.type) {
|
|
@@ -1167,7 +1197,7 @@ var import_bottom_sheet2 = require("@mustmove/bottom-sheet");
|
|
|
1167
1197
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
1168
1198
|
function createOverlayProvider() {
|
|
1169
1199
|
const overlayId = randomId();
|
|
1170
|
-
const
|
|
1200
|
+
const _a2 = createOverlay(overlayId), { useOverlayEvent } = _a2, overlay2 = __objRest(_a2, ["useOverlayEvent"]);
|
|
1171
1201
|
const { OverlayContextProvider, useCurrentOverlay: useCurrentOverlay2, useOverlayData: useOverlayData2 } = createOverlaySafeContext();
|
|
1172
1202
|
function OverlayProvider2({ children }) {
|
|
1173
1203
|
const [overlayState, overlayDispatch] = (0, import_react14.useReducer)(overlayReducer, {
|
|
@@ -1270,15 +1300,15 @@ function createOverlayProvider() {
|
|
|
1270
1300
|
if (overlayType === "bottomSheet") return null;
|
|
1271
1301
|
const hasOpenBottomSheet = overlayState.overlayOrderList.some(
|
|
1272
1302
|
(id) => {
|
|
1273
|
-
var
|
|
1274
|
-
return ((
|
|
1303
|
+
var _a3, _b;
|
|
1304
|
+
return ((_a3 = overlayState.overlayData[id]) == null ? void 0 : _a3.overlayType) === "bottomSheet" && ((_b = overlayState.overlayData[id]) == null ? void 0 : _b.isOpen);
|
|
1275
1305
|
}
|
|
1276
1306
|
);
|
|
1277
1307
|
if (overlayType === "modal") {
|
|
1278
1308
|
const sameTypeOverlays = overlayState.overlayOrderList.filter(
|
|
1279
1309
|
(id) => {
|
|
1280
|
-
var
|
|
1281
|
-
return ((
|
|
1310
|
+
var _a3, _b;
|
|
1311
|
+
return ((_a3 = overlayState.overlayData[id]) == null ? void 0 : _a3.overlayType) === "modal" && ((_b = overlayState.overlayData[id]) == null ? void 0 : _b.isOpen);
|
|
1282
1312
|
}
|
|
1283
1313
|
);
|
|
1284
1314
|
const isTopModal = sameTypeOverlays[sameTypeOverlays.length - 1] === currentOverlayId;
|
|
@@ -1322,8 +1352,8 @@ function createOverlayProvider() {
|
|
|
1322
1352
|
if (overlayType !== "bottomSheet") return null;
|
|
1323
1353
|
const sameTypeOverlays = overlayState.overlayOrderList.filter(
|
|
1324
1354
|
(id) => {
|
|
1325
|
-
var
|
|
1326
|
-
return ((
|
|
1355
|
+
var _a3, _b;
|
|
1356
|
+
return ((_a3 = overlayState.overlayData[id]) == null ? void 0 : _a3.overlayType) === "bottomSheet" && ((_b = overlayState.overlayData[id]) == null ? void 0 : _b.isOpen);
|
|
1327
1357
|
}
|
|
1328
1358
|
);
|
|
1329
1359
|
const isTopBottomSheet = sameTypeOverlays[sameTypeOverlays.length - 1] === currentOverlayId;
|