@mustmove/overlay-kit-rn 1.0.86 → 1.0.88

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 CHANGED
@@ -147,7 +147,6 @@ type BottomSheetControllerProps<T = any> = {
147
147
  isLoading?: boolean;
148
148
  emptyText?: string;
149
149
  extraData?: any;
150
- keyboardHeight?: number;
151
150
  };
152
151
  type BottomSheetControllerComponent<T = any> = FC<BottomSheetControllerProps<T>>;
153
152
 
package/dist/index.d.ts CHANGED
@@ -147,7 +147,6 @@ type BottomSheetControllerProps<T = any> = {
147
147
  isLoading?: boolean;
148
148
  emptyText?: string;
149
149
  extraData?: any;
150
- keyboardHeight?: number;
151
150
  };
152
151
  type BottomSheetControllerComponent<T = any> = FC<BottomSheetControllerProps<T>>;
153
152
 
package/dist/index.js CHANGED
@@ -111,6 +111,7 @@ 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
+ var import_react_native_keyboard_controller = require("react-native-keyboard-controller");
114
115
 
115
116
  // node_modules/@gorhom/portal/lib/module/components/portal/Portal.js
116
117
  var import_react4 = require("react");
@@ -397,8 +398,8 @@ var ContentBottomSheetController = (0, import_react8.memo)(
397
398
  }) => {
398
399
  const bottomSheetRef = (0, import_react8.useRef)(null);
399
400
  const reducedMotion = (0, import_react_native_reanimated.useReducedMotion)();
400
- const [keyboardHeight, setKeyboardHeight] = (0, import_react8.useState)(0);
401
- const isKeyboardActiveRef = (0, import_react8.useRef)(false);
401
+ const isClosingRef = (0, import_react8.useRef)(false);
402
+ const { height: keyboardHeight } = (0, import_react_native_keyboard_controller.useReanimatedKeyboardAnimation)();
402
403
  const getZIndex = () => {
403
404
  const index = overlayOrderList.indexOf(overlayId);
404
405
  return 1e3 + index;
@@ -430,26 +431,6 @@ var ContentBottomSheetController = (0, import_react8.memo)(
430
431
  "closeAllOnGestureClose",
431
432
  "closeFunction"
432
433
  ]);
433
- (0, import_react8.useEffect)(() => {
434
- const keyboardWillShowListener = import_react_native.Keyboard.addListener(
435
- import_react_native.Platform.OS === "ios" ? "keyboardWillShow" : "keyboardDidShow",
436
- (e) => {
437
- isKeyboardActiveRef.current = true;
438
- setKeyboardHeight(e.endCoordinates.height);
439
- }
440
- );
441
- const keyboardWillHideListener = import_react_native.Keyboard.addListener(
442
- import_react_native.Platform.OS === "ios" ? "keyboardWillHide" : "keyboardDidHide",
443
- () => {
444
- isKeyboardActiveRef.current = false;
445
- setKeyboardHeight(0);
446
- }
447
- );
448
- return () => {
449
- keyboardWillShowListener.remove();
450
- keyboardWillHideListener.remove();
451
- };
452
- }, []);
453
434
  (0, import_react8.useEffect)(() => {
454
435
  if (isOpen) {
455
436
  const rafId = requestAnimationFrame(() => {
@@ -462,7 +443,11 @@ var ContentBottomSheetController = (0, import_react8.memo)(
462
443
  }
463
444
  }, [isOpen, overlayDispatch, overlayId]);
464
445
  const handleClose = (0, import_react8.useCallback)(() => {
465
- if (isKeyboardActiveRef.current) {
446
+ if (isClosingRef.current) {
447
+ return;
448
+ }
449
+ isClosingRef.current = true;
450
+ if (keyboardHeight.value > 0) {
466
451
  import_react_native.Keyboard.dismiss();
467
452
  setTimeout(() => {
468
453
  if (closeAllOnGestureClose) {
@@ -473,10 +458,10 @@ var ContentBottomSheetController = (0, import_react8.memo)(
473
458
  if (closeFunction) {
474
459
  closeFunction();
475
460
  }
476
- }, 100);
461
+ }, 50);
477
462
  return;
478
463
  }
479
- setTimeout(() => {
464
+ requestAnimationFrame(() => {
480
465
  if (closeAllOnGestureClose) {
481
466
  overlayDispatch({ type: "REMOVE_ALL" });
482
467
  } else {
@@ -485,8 +470,14 @@ var ContentBottomSheetController = (0, import_react8.memo)(
485
470
  if (closeFunction) {
486
471
  closeFunction();
487
472
  }
488
- }, 50);
489
- }, [overlayDispatch, overlayId, closeAllOnGestureClose, closeFunction]);
473
+ });
474
+ }, [
475
+ overlayDispatch,
476
+ overlayId,
477
+ closeAllOnGestureClose,
478
+ closeFunction,
479
+ keyboardHeight
480
+ ]);
490
481
  const renderBackdrop = (0, import_react8.useCallback)(
491
482
  (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
492
483
  import_bottom_sheet.BottomSheetBackdrop,
@@ -516,7 +507,6 @@ var ContentBottomSheetController = (0, import_react8.memo)(
516
507
  snapPoints: enableDynamicSizing ? void 0 : snapPoints,
517
508
  enablePanDownToClose,
518
509
  onClose: handleClose,
519
- bottomInset: import_react_native.Platform.OS === "android" ? keyboardHeight : void 0,
520
510
  keyboardBlurBehavior,
521
511
  backdropComponent: enableBackdrop ? renderBackdrop : void 0,
522
512
  backgroundStyle: [
@@ -545,8 +535,7 @@ var ContentBottomSheetController = (0, import_react8.memo)(
545
535
  snapPoints,
546
536
  enablePanDownToClose,
547
537
  close: () => overlayDispatch({ type: "CLOSE", overlayId }),
548
- unmount: () => overlayDispatch({ type: "REMOVE", overlayId }),
549
- keyboardHeight
538
+ unmount: () => overlayDispatch({ type: "REMOVE", overlayId })
550
539
  }, restOptions))
551
540
  }
552
541
  ) });
@@ -571,11 +560,13 @@ var ContentModalController = (0, import_react9.memo)(
571
560
  modalType = "center",
572
561
  backdropOpacity = 0.5,
573
562
  animationType = "fade",
574
- swipeDirection
563
+ swipeDirection,
564
+ closeFunction
575
565
  } = options;
576
566
  const [backdropAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
577
567
  const [contentAnimation] = (0, import_react9.useState)(new import_react_native2.Animated.Value(0));
578
568
  const [mounted, setMounted] = (0, import_react9.useState)(isOpen);
569
+ const [isClosing, setIsClosing] = (0, import_react9.useState)(false);
579
570
  (0, import_react9.useEffect)(() => {
580
571
  if (isOpen) {
581
572
  if (!mounted) setMounted(true);
@@ -613,10 +604,17 @@ var ContentModalController = (0, import_react9.memo)(
613
604
  }
614
605
  }, [isOpen]);
615
606
  const handleClose = () => {
607
+ if (isClosing) {
608
+ return;
609
+ }
610
+ setIsClosing(true);
616
611
  import_react_native2.Keyboard.dismiss();
617
- setTimeout(() => {
612
+ requestAnimationFrame(() => {
618
613
  overlayDispatch({ type: "REMOVE", overlayId });
619
- }, 100);
614
+ if (closeFunction) {
615
+ closeFunction();
616
+ }
617
+ });
620
618
  };
621
619
  const getLayerIndex = () => {
622
620
  return Math.max(0, overlayOrderList.indexOf(overlayId));