react-native-bottom-sheet-stack 1.9.2 → 1.10.0
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/README.md +14 -0
- package/lib/commonjs/BottomSheetBackdrop.js +15 -17
- package/lib/commonjs/BottomSheetBackdrop.js.map +1 -1
- package/lib/commonjs/QueueItem.js +2 -0
- package/lib/commonjs/QueueItem.js.map +1 -1
- package/lib/commonjs/adapters/actions-sheet/ActionsSheetAdapter.js +17 -9
- package/lib/commonjs/adapters/actions-sheet/ActionsSheetAdapter.js.map +1 -1
- package/lib/commonjs/adapters/gorhom-sheet/GorhomSheetAdapter.js +12 -9
- package/lib/commonjs/adapters/gorhom-sheet/GorhomSheetAdapter.js.map +1 -1
- package/lib/commonjs/adapters/react-native-modal/ReactNativeModalAdapter.js +14 -8
- package/lib/commonjs/adapters/react-native-modal/ReactNativeModalAdapter.js.map +1 -1
- package/lib/commonjs/bottomSheetCoordinator.js +103 -0
- package/lib/commonjs/bottomSheetCoordinator.js.map +1 -1
- package/lib/commonjs/index.js +38 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/onBeforeCloseRegistry.js +42 -0
- package/lib/commonjs/onBeforeCloseRegistry.js.map +1 -0
- package/lib/commonjs/store/hooks.js +24 -4
- package/lib/commonjs/store/hooks.js.map +1 -1
- package/lib/commonjs/store/store.js +8 -0
- package/lib/commonjs/store/store.js.map +1 -1
- package/lib/commonjs/useBottomSheetContext.js +31 -17
- package/lib/commonjs/useBottomSheetContext.js.map +1 -1
- package/lib/commonjs/useBottomSheetControl.js +46 -33
- package/lib/commonjs/useBottomSheetControl.js.map +1 -1
- package/lib/commonjs/useBottomSheetManager.js +16 -10
- package/lib/commonjs/useBottomSheetManager.js.map +1 -1
- package/lib/commonjs/useOnBeforeClose.js +107 -0
- package/lib/commonjs/useOnBeforeClose.js.map +1 -0
- package/lib/typescript/example/src/screens/HomeScreen.d.ts.map +1 -1
- package/lib/typescript/example/src/sheets/CloseInterceptionSheets.d.ts +14 -0
- package/lib/typescript/example/src/sheets/CloseInterceptionSheets.d.ts.map +1 -0
- package/lib/typescript/example/src/sheets/index.d.ts +1 -0
- package/lib/typescript/example/src/sheets/index.d.ts.map +1 -1
- package/lib/typescript/src/BottomSheetBackdrop.d.ts.map +1 -1
- package/lib/typescript/src/QueueItem.d.ts.map +1 -1
- package/lib/typescript/src/adapters/actions-sheet/ActionsSheetAdapter.d.ts.map +1 -1
- package/lib/typescript/src/adapters/gorhom-sheet/GorhomSheetAdapter.d.ts.map +1 -1
- package/lib/typescript/src/adapters/react-native-modal/ReactNativeModalAdapter.d.ts.map +1 -1
- package/lib/typescript/src/bottomSheetCoordinator.d.ts +25 -0
- package/lib/typescript/src/bottomSheetCoordinator.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +6 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/onBeforeCloseRegistry.d.ts +26 -0
- package/lib/typescript/src/onBeforeCloseRegistry.d.ts.map +1 -0
- package/lib/typescript/src/store/hooks.d.ts +2 -0
- package/lib/typescript/src/store/hooks.d.ts.map +1 -1
- package/lib/typescript/src/store/store.d.ts.map +1 -1
- package/lib/typescript/src/store/types.d.ts +8 -0
- package/lib/typescript/src/store/types.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetContext.d.ts +5 -0
- package/lib/typescript/src/useBottomSheetContext.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetControl.d.ts +2 -0
- package/lib/typescript/src/useBottomSheetControl.d.ts.map +1 -1
- package/lib/typescript/src/useBottomSheetManager.d.ts +5 -0
- package/lib/typescript/src/useBottomSheetManager.d.ts.map +1 -1
- package/lib/typescript/src/useOnBeforeClose.d.ts +65 -0
- package/lib/typescript/src/useOnBeforeClose.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/BottomSheetBackdrop.tsx +2 -3
- package/src/QueueItem.tsx +2 -0
- package/src/adapters/actions-sheet/ActionsSheetAdapter.tsx +5 -3
- package/src/adapters/gorhom-sheet/GorhomSheetAdapter.tsx +3 -1
- package/src/adapters/react-native-modal/ReactNativeModalAdapter.tsx +4 -2
- package/src/bottomSheetCoordinator.ts +128 -0
- package/src/index.tsx +15 -2
- package/src/onBeforeCloseRegistry.ts +44 -0
- package/src/store/hooks.ts +8 -0
- package/src/store/store.ts +10 -0
- package/src/store/types.ts +8 -0
- package/src/useBottomSheetContext.ts +11 -1
- package/src/useBottomSheetControl.ts +11 -8
- package/src/useBottomSheetManager.tsx +14 -8
- package/src/useOnBeforeClose.ts +92 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useOnBeforeClose = useOnBeforeClose;
|
|
7
|
+
var _compilerRuntime = require("react/compiler-runtime");
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _BottomSheet = require("./BottomSheet.context");
|
|
10
|
+
var _bottomSheet = require("./bottomSheet.store");
|
|
11
|
+
var _onBeforeCloseRegistry = require("./onBeforeCloseRegistry");
|
|
12
|
+
var _useEvent = require("./useEvent");
|
|
13
|
+
/**
|
|
14
|
+
* Registers an interceptor that is called before the sheet closes.
|
|
15
|
+
*
|
|
16
|
+
* When active, this hook:
|
|
17
|
+
* 1. Sets `preventDismiss` on the sheet so adapters block user-initiated
|
|
18
|
+
* gestures (swipe down, pan-to-close) at the native level.
|
|
19
|
+
* 2. Intercepts all programmatic close paths (backdrop tap, back button,
|
|
20
|
+
* `close()`, `closeAll()`) and calls the callback first.
|
|
21
|
+
*
|
|
22
|
+
* The interceptor receives `onConfirm` and `onCancel` callbacks. Call these
|
|
23
|
+
* when the user makes a decision. This works seamlessly with `Alert.alert`:
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* useOnBeforeClose(({ onConfirm, onCancel }) => {
|
|
27
|
+
* if (dirty) {
|
|
28
|
+
* Alert.alert('Discard changes?', '', [
|
|
29
|
+
* { text: 'Cancel', onPress: onCancel },
|
|
30
|
+
* { text: 'Discard', onPress: onConfirm },
|
|
31
|
+
* ]);
|
|
32
|
+
* } else {
|
|
33
|
+
* onConfirm(); // Allow close immediately
|
|
34
|
+
* }
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* For backward compatibility, you can still return `boolean` or `Promise<boolean>`:
|
|
39
|
+
* - Return `false` (or resolve to `false`) to prevent closing
|
|
40
|
+
* - Return `true` (or resolve to `true`) to allow closing
|
|
41
|
+
*
|
|
42
|
+
* Use `forceClose()` from `useBottomSheetContext` to bypass the interceptor entirely.
|
|
43
|
+
*
|
|
44
|
+
* Must be used inside a sheet component (within BottomSheetContext).
|
|
45
|
+
*
|
|
46
|
+
* @example Callback pattern (recommended)
|
|
47
|
+
* ```tsx
|
|
48
|
+
* function MySheet() {
|
|
49
|
+
* const [dirty, setDirty] = useState(false);
|
|
50
|
+
*
|
|
51
|
+
* useOnBeforeClose(({ onConfirm, onCancel }) => {
|
|
52
|
+
* if (dirty) {
|
|
53
|
+
* Alert.alert('Discard changes?', '', [
|
|
54
|
+
* { text: 'Cancel', style: 'cancel', onPress: onCancel },
|
|
55
|
+
* { text: 'Discard', onPress: onConfirm },
|
|
56
|
+
* ]);
|
|
57
|
+
* } else {
|
|
58
|
+
* onConfirm();
|
|
59
|
+
* }
|
|
60
|
+
* });
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @example Boolean return (backward compatible)
|
|
65
|
+
* ```tsx
|
|
66
|
+
* function MySheet() {
|
|
67
|
+
* const [dirty, setDirty] = useState(false);
|
|
68
|
+
*
|
|
69
|
+
* useOnBeforeClose(() => {
|
|
70
|
+
* return !dirty; // false blocks, true allows
|
|
71
|
+
* });
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
function useOnBeforeClose(callback) {
|
|
76
|
+
const $ = (0, _compilerRuntime.c)(5);
|
|
77
|
+
const context = (0, _BottomSheet.useMaybeBottomSheetContext)();
|
|
78
|
+
const setPreventDismiss = (0, _bottomSheet.useSetPreventDismiss)();
|
|
79
|
+
if (!context?.id) {
|
|
80
|
+
throw new Error("useOnBeforeClose must be used within a BottomSheet component");
|
|
81
|
+
}
|
|
82
|
+
const id = context.id;
|
|
83
|
+
const stableCallback = (0, _useEvent.useEvent)(callback);
|
|
84
|
+
let t0;
|
|
85
|
+
let t1;
|
|
86
|
+
if ($[0] !== id || $[1] !== setPreventDismiss || $[2] !== stableCallback) {
|
|
87
|
+
t0 = () => {
|
|
88
|
+
(0, _onBeforeCloseRegistry.setOnBeforeClose)(id, stableCallback);
|
|
89
|
+
setPreventDismiss(id, true);
|
|
90
|
+
return () => {
|
|
91
|
+
(0, _onBeforeCloseRegistry.removeOnBeforeClose)(id);
|
|
92
|
+
setPreventDismiss(id, false);
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
t1 = [id, stableCallback, setPreventDismiss];
|
|
96
|
+
$[0] = id;
|
|
97
|
+
$[1] = setPreventDismiss;
|
|
98
|
+
$[2] = stableCallback;
|
|
99
|
+
$[3] = t0;
|
|
100
|
+
$[4] = t1;
|
|
101
|
+
} else {
|
|
102
|
+
t0 = $[3];
|
|
103
|
+
t1 = $[4];
|
|
104
|
+
}
|
|
105
|
+
(0, _react.useEffect)(t0, t1);
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=useOnBeforeClose.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_BottomSheet","_bottomSheet","_onBeforeCloseRegistry","_useEvent","useOnBeforeClose","callback","$","_compilerRuntime","c","context","useMaybeBottomSheetContext","setPreventDismiss","useSetPreventDismiss","id","Error","stableCallback","useEvent","t0","t1","setOnBeforeClose","removeOnBeforeClose","useEffect"],"sourceRoot":"../../src","sources":["useOnBeforeClose.ts"],"mappings":";;;;;;;A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AAE,EAAEE,cAAc,EAAEJ,iBAAiB,CAAC;IAAAL,CAAA,MAAAO,EAAA;IAAAP,CAAA,MAAAK,iBAAA;IAAAL,CAAA,MAAAS,cAAA;IAAAT,CAAA,MAAAW,EAAA;IAAAX,CAAA,MAAAY,EAAA;EAAA;IAAAD,EAAA,GAAAX,CAAA;IAAAY,EAAA,GAAAZ,CAAA;EAAA;EAP1C,IAAAe,gBAAS,EAACJ,EAOT,EAAEC,EAAuC,CAAC;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomeScreen.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/HomeScreen.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"HomeScreen.d.ts","sourceRoot":"","sources":["../../../../../example/src/screens/HomeScreen.tsx"],"names":[],"mappings":"AA4BA,wBAAgB,UAAU,4CAuOzB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BottomSheetMethods } from '@gorhom/bottom-sheet/lib/typescript/types';
|
|
2
|
+
/**
|
|
3
|
+
* Root sheet that demonstrates closeAll() with cascading animation
|
|
4
|
+
*/
|
|
5
|
+
export declare const CloseInterceptionDemo: import("react").ForwardRefExoticComponent<import("react").RefAttributes<BottomSheetMethods>>;
|
|
6
|
+
/**
|
|
7
|
+
* Form sheet with unsaved changes - demonstrates onBeforeClose interceptor
|
|
8
|
+
*/
|
|
9
|
+
export declare const FormSheet: import("react").ForwardRefExoticComponent<import("react").RefAttributes<BottomSheetMethods>>;
|
|
10
|
+
/**
|
|
11
|
+
* Read-only sheet without interceptor - closes immediately
|
|
12
|
+
*/
|
|
13
|
+
export declare const ReadOnlySheet: import("react").ForwardRefExoticComponent<import("react").RefAttributes<BottomSheetMethods>>;
|
|
14
|
+
//# sourceMappingURL=CloseInterceptionSheets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CloseInterceptionSheets.d.ts","sourceRoot":"","sources":["../../../../../example/src/sheets/CloseInterceptionSheets.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2CAA2C,CAAC;AAYpF;;GAEG;AACH,eAAO,MAAM,qBAAqB,8FA4DjC,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,SAAS,8FA0HpB,CAAC;AAIH;;GAEG;AACH,eAAO,MAAM,aAAa,8FAsDxB,CAAC"}
|
|
@@ -8,4 +8,5 @@ export { PortalModeSheetA, PortalModeSheetB } from './PortalModeSheets';
|
|
|
8
8
|
export { ScannerSheet } from './ScannerSheet';
|
|
9
9
|
export { MixedStackContent, SimpleModalContent, AdapterComparisonContent, } from './ModalSheets';
|
|
10
10
|
export { ModalAdapterDemoContent, RNModalDemoContent, ActionsSheetDemoContent, GorhomSheetDemoContent, } from './ThirdPartyAdapterSheets';
|
|
11
|
+
export { CloseInterceptionDemo, FormSheet, ReadOnlySheet, } from './CloseInterceptionSheets';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../example/src/sheets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../example/src/sheets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,SAAS,EACT,aAAa,GACd,MAAM,2BAA2B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetBackdrop.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetBackdrop.tsx"],"names":[],"mappings":"AAUA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"BottomSheetBackdrop.d.ts","sourceRoot":"","sources":["../../../src/BottomSheetBackdrop.tsx"],"names":[],"mappings":"AAUA,UAAU,wBAAwB;IAChC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CAAC,EAAE,OAAO,EAAE,EAAE,wBAAwB,kDAwCxE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueueItem.d.ts","sourceRoot":"","sources":["../../../src/QueueItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueueItem.d.ts","sourceRoot":"","sources":["../../../src/QueueItem.tsx"],"names":[],"mappings":"AAmBA,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,eAAO,MAAM,SAAS,sDAwDpB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ActionsSheetAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/actions-sheet/ActionsSheetAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ActionsSheetAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/actions-sheet/ActionsSheetAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAS3D;;;;;;;;;;;;;;GAcG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,mBAAmB,+GAmD9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GorhomSheetAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/gorhom-sheet/GorhomSheetAdapter.tsx"],"names":[],"mappings":"AAAA,OAA4B,EAE1B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"GorhomSheetAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/gorhom-sheet/GorhomSheetAdapter.tsx"],"names":[],"mappings":"AAAA,OAA4B,EAE1B,KAAK,gBAAgB,EACtB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAS3D,MAAM,WAAW,uBAAwB,SAAQ,gBAAgB;CAAG;AAIpE,eAAO,MAAM,kBAAkB,iGAmG9B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeModalAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/react-native-modal/ReactNativeModalAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"ReactNativeModalAdapter.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/react-native-modal/ReactNativeModalAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAS3D;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,eAAO,MAAM,uBAAuB,mHAkDlC,CAAC"}
|
|
@@ -4,6 +4,31 @@ import type { SheetAdapterEvents } from './adapter.types';
|
|
|
4
4
|
* Direction: Store → Adapter (via SheetAdapterRef)
|
|
5
5
|
*/
|
|
6
6
|
export declare function initBottomSheetCoordinator(groupId: string): () => void;
|
|
7
|
+
/**
|
|
8
|
+
* Attempts to close a sheet, respecting the onBeforeClose interceptor.
|
|
9
|
+
*
|
|
10
|
+
* If an onBeforeClose callback is registered for the sheet and it returns
|
|
11
|
+
* `false` (or resolves to `false`), the close is cancelled.
|
|
12
|
+
*
|
|
13
|
+
* @returns `true` if the close proceeded, `false` if it was intercepted.
|
|
14
|
+
*/
|
|
15
|
+
export declare function requestClose(sheetId: string): Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Closes all sheets in a group from top to bottom with cascading animation.
|
|
18
|
+
*
|
|
19
|
+
* Each sheet is closed with a staggered delay so the user sees them
|
|
20
|
+
* peel off one-by-one (similar to `popToRoot` in React Navigation).
|
|
21
|
+
*
|
|
22
|
+
* If a sheet has an `onBeforeClose` interceptor that rejects, the cascade
|
|
23
|
+
* stops at that sheet — sheets below it remain open.
|
|
24
|
+
*
|
|
25
|
+
* @param groupId - The manager group to close sheets in.
|
|
26
|
+
* @param options.stagger - Delay in ms between each close (default: 100).
|
|
27
|
+
* @returns A promise that resolves when the cascade finishes (or is stopped).
|
|
28
|
+
*/
|
|
29
|
+
export declare function closeAllAnimated(groupId: string, options?: {
|
|
30
|
+
stagger?: number;
|
|
31
|
+
}): Promise<void>;
|
|
7
32
|
/**
|
|
8
33
|
* Creates event handlers that adapters call to sync UI state back to the store.
|
|
9
34
|
* Direction: Adapter Events → Store
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"bottomSheetCoordinator.d.ts","sourceRoot":"","sources":["../../../src/bottomSheetCoordinator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAK1D;;;GAGG;AACH,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,cAkCzD;AAED;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAwDpE;AAOD;;;;;;;;;;;;GAYG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7B,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,kBAAkB,CAwC5E"}
|
|
@@ -5,20 +5,24 @@ export { BottomSheetPortal } from './BottomSheetPortal';
|
|
|
5
5
|
export { BottomSheetPersistent } from './BottomSheetPersistent';
|
|
6
6
|
export { CustomModalAdapter, type ModalAdapterProps, } from './adapters/custom-modal';
|
|
7
7
|
export type { SheetAdapterRef, SheetAdapterRef as BottomSheetRef, SheetAdapterEvents, SheetRef, } from './adapter.types';
|
|
8
|
-
export { createSheetEventHandlers } from './bottomSheetCoordinator';
|
|
8
|
+
export { createSheetEventHandlers, requestClose, closeAllAnimated, } from './bottomSheetCoordinator';
|
|
9
9
|
export { useAdapterRef } from './useAdapterRef';
|
|
10
10
|
export { useAnimatedIndex } from './useAnimatedIndex';
|
|
11
11
|
export { useBackHandler } from './useBackHandler';
|
|
12
12
|
export { getAnimatedIndex, setAnimatedIndexValue } from './animatedRegistry';
|
|
13
|
-
export { useBottomSheetManager } from './useBottomSheetManager';
|
|
13
|
+
export { useBottomSheetManager, type CloseAllOptions, } from './useBottomSheetManager';
|
|
14
14
|
export { useBottomSheetControl, type UseBottomSheetControlReturn, } from './useBottomSheetControl';
|
|
15
15
|
export { useBottomSheetContext, useBottomSheetState, type UseBottomSheetContextReturn, } from './useBottomSheetContext';
|
|
16
16
|
export { useBottomSheetStatus, type UseBottomSheetStatusReturn, } from './useBottomSheetStatus';
|
|
17
|
+
export { useOnBeforeClose } from './useOnBeforeClose';
|
|
17
18
|
export type { ScaleConfig, ScaleAnimationConfig } from './useScaleAnimation';
|
|
18
19
|
export type { BottomSheetStatus, OpenMode, BottomSheetState, } from './bottomSheet.store';
|
|
19
20
|
export type { BottomSheetPortalRegistry, BottomSheetPortalId, BottomSheetPortalParams, } from './portal.types';
|
|
20
21
|
export { useBottomSheetStore } from './bottomSheet.store';
|
|
22
|
+
export type { OnBeforeCloseCallback } from './onBeforeCloseRegistry';
|
|
23
|
+
export { setOnBeforeClose, removeOnBeforeClose } from './onBeforeCloseRegistry';
|
|
21
24
|
export { __resetSheetRefs } from './refsMap';
|
|
22
25
|
export { __resetAnimatedIndexes, __getAllAnimatedIndexes, } from './animatedRegistry';
|
|
23
26
|
export { __resetPortalSessions } from './portalSessionRegistry';
|
|
27
|
+
export { __resetOnBeforeClose } from './onBeforeCloseRegistry';
|
|
24
28
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,qB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A2B,GACjC,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,oBAAoB,EACpB,KAAK,0BAA0B,GAChC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAGtD,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,YAAY,EACV,iBAAiB,EACjB,QAAQ,EACR,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,yBAAyB,EACzB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAG1D,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAGhF,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry for onBeforeClose interceptors.
|
|
3
|
+
*
|
|
4
|
+
* Callbacks are keyed by sheet ID. When a sheet is about to close,
|
|
5
|
+
* the coordinator checks this registry and calls the interceptor.
|
|
6
|
+
*
|
|
7
|
+
* The interceptor receives `onConfirm` and `onCancel` callbacks that
|
|
8
|
+
* should be called when the user makes a decision. Alternatively, it can
|
|
9
|
+
* return `boolean` or `Promise<boolean>` for backward compatibility.
|
|
10
|
+
*
|
|
11
|
+
* If the interceptor returns `false` (or resolves to `false`), or if
|
|
12
|
+
* `onCancel()` is called, the close is cancelled.
|
|
13
|
+
*/
|
|
14
|
+
export type OnBeforeCloseCallback = (context: {
|
|
15
|
+
onConfirm: () => void;
|
|
16
|
+
onCancel: () => void;
|
|
17
|
+
}) => void | boolean | Promise<boolean>;
|
|
18
|
+
export declare function getOnBeforeClose(sheetId: string): OnBeforeCloseCallback | undefined;
|
|
19
|
+
export declare function setOnBeforeClose(sheetId: string, callback: OnBeforeCloseCallback): void;
|
|
20
|
+
export declare function removeOnBeforeClose(sheetId: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Reset all interceptors. Useful for testing.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export declare function __resetOnBeforeClose(): void;
|
|
26
|
+
//# sourceMappingURL=onBeforeCloseRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onBeforeCloseRegistry.d.ts","sourceRoot":"","sources":["../../../src/onBeforeCloseRegistry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,EAAE;IAC5C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB,KAAK,IAAI,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAIxC,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,GACd,qBAAqB,GAAG,SAAS,CAEnC;AAED,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,qBAAqB,GAC9B,IAAI,CAEN;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}
|
|
@@ -5,6 +5,7 @@ export declare const useSheetContent: (id: string) => import("react").ReactNode;
|
|
|
5
5
|
export declare const useSheetUsePortal: (id: string) => boolean | undefined;
|
|
6
6
|
export declare const useSheetKeepMounted: (id: string) => boolean | undefined;
|
|
7
7
|
export declare const useSheetPortalSession: (id: string) => number | undefined;
|
|
8
|
+
export declare const useSheetPreventDismiss: (id: string) => boolean;
|
|
8
9
|
export declare const useSheetExists: (id: string) => boolean;
|
|
9
10
|
export declare const useIsSheetOpen: (id: string) => boolean;
|
|
10
11
|
export declare const useHasScaleBackgroundAbove: (id: string) => boolean;
|
|
@@ -12,6 +13,7 @@ export declare const useOpen: () => (sheet: import("./types").TriggerState, mode
|
|
|
12
13
|
export declare const useStartClosing: () => (id: string) => void;
|
|
13
14
|
export declare const useUpdateParams: () => (id: string, params: Record<string, unknown> | undefined) => void;
|
|
14
15
|
export declare const useClearGroup: () => (groupId: string) => void;
|
|
16
|
+
export declare const useSetPreventDismiss: () => (id: string, prevent: boolean) => void;
|
|
15
17
|
export declare const useMount: () => (sheet: Omit<import("react-native-bottom-sheet-stack").BottomSheetState, "status">) => void;
|
|
16
18
|
export declare const useUnmount: () => (id: string) => void;
|
|
17
19
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/store/hooks.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,2EAC4B,CAAC;AAEhE,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,4EAC8B,CAAC;AAExE,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,wCAC8B,CAAC;AAExE,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,8BAC8B,CAAC;AAEzE,eAAO,MAAM,iBAAiB,GAAI,IAAI,MAAM,wBAC8B,CAAC;AAE3E,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,wBAC8B,CAAC;AAC7E,eAAO,MAAM,qBAAqB,GAAI,IAAI,MAAM,uBAC8B,CAAC;
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../src/store/hooks.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,QAAQ,GAAI,IAAI,MAAM,2EAC4B,CAAC;AAEhE,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,4EAC8B,CAAC;AAExE,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,wCAC8B,CAAC;AAExE,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,8BAC8B,CAAC;AAEzE,eAAO,MAAM,iBAAiB,GAAI,IAAI,MAAM,wBAC8B,CAAC;AAE3E,eAAO,MAAM,mBAAmB,GAAI,IAAI,MAAM,wBAC8B,CAAC;AAC7E,eAAO,MAAM,qBAAqB,GAAI,IAAI,MAAM,uBAC8B,CAAC;AAC/E,eAAO,MAAM,sBAAsB,GAAI,IAAI,MAAM,YAI9C,CAAC;AAEJ,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,YACwB,CAAC;AAElE,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,YAI5B,CAAC;AAEd,eAAO,MAAM,0BAA0B,GAAI,IAAI,MAAM,YAuBxC,CAAC;AAId,eAAO,MAAM,OAAO,kHAAmD,CAAC;AAExE,eAAO,MAAM,eAAe,4BACwB,CAAC;AAErD,eAAO,MAAM,eAAe,yEACwB,CAAC;AAErD,eAAO,MAAM,aAAa,iCACwB,CAAC;AAEnD,eAAO,MAAM,oBAAoB,8CACwB,CAAC;AAE1D,eAAO,MAAM,QAAQ,mGAAoD,CAAC;AAE1E,eAAO,MAAM,UAAU,4BAAsD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store/store.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,mBAAmB;;;;;;;;
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../../src/store/store.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAElE,eAAO,MAAM,mBAAmB;;;;;;;;EAoL/B,CAAC"}
|
|
@@ -16,6 +16,13 @@ export interface BottomSheetState {
|
|
|
16
16
|
* react-native-teleport connection issues after replace flows.
|
|
17
17
|
*/
|
|
18
18
|
portalSession?: number;
|
|
19
|
+
/**
|
|
20
|
+
* When true, the adapter should block user-initiated dismiss gestures
|
|
21
|
+
* (swipe down, backdrop tap). Set by `useOnBeforeClose` to ensure the
|
|
22
|
+
* interceptor runs before closing. Programmatic close via `forceClose()`
|
|
23
|
+
* bypasses this.
|
|
24
|
+
*/
|
|
25
|
+
preventDismiss?: boolean;
|
|
19
26
|
}
|
|
20
27
|
export type TriggerState = Omit<BottomSheetState, 'status'>;
|
|
21
28
|
export interface BottomSheetStoreState {
|
|
@@ -28,6 +35,7 @@ export interface BottomSheetStoreActions {
|
|
|
28
35
|
startClosing(id: string): void;
|
|
29
36
|
finishClosing(id: string): void;
|
|
30
37
|
updateParams(id: string, params: Record<string, unknown> | undefined): void;
|
|
38
|
+
setPreventDismiss(id: string, prevent: boolean): void;
|
|
31
39
|
clearGroup(groupId: string): void;
|
|
32
40
|
clearAll(): void;
|
|
33
41
|
mount(sheet: Omit<BottomSheetState, 'status'>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/store/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,MAAM,MAAM,iBAAiB,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,QAAQ,CAAC;AAC1E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,eAAe,CAAC,EAAE,OA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G,IAAI,CAAC;IACjD,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,YAAY,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IAC5E,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IACtD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,QAAQ,IAAI,IAAI,CAAC;IACjB,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,gBAAgB,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;IACrD,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,uBAAuB,CAAC"}
|
|
@@ -3,6 +3,11 @@ export interface UseBottomSheetContextReturn<TParams> {
|
|
|
3
3
|
id: string;
|
|
4
4
|
params: TParams;
|
|
5
5
|
close: () => void;
|
|
6
|
+
/**
|
|
7
|
+
* Close the sheet, bypassing any onBeforeClose interceptor.
|
|
8
|
+
* Useful for force-closing from within onBeforeClose confirmation flows.
|
|
9
|
+
*/
|
|
10
|
+
forceClose: () => void;
|
|
6
11
|
/** @deprecated Use `close` instead */
|
|
7
12
|
closeBottomSheet: () => void;
|
|
8
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBottomSheetContext.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBottomSheetContext.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetContext.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,gBAAgB,CAAC;AAExB,MAAM,WAAW,2BAA2B,CAAC,OAAO;IAClD,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;OAGG;IACH,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,sCAAsC;IACtC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B;AAED,gDAAgD;AAChD,wBAAgB,qBAAqB,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAC;AAC9E,2DAA2D;AAC3D,wBAAgB,qBAAqB,CACnC,CAAC,SAAS,mBAAmB,KAC1B,2BAA2B,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;AA4B7D;;GAEG;AACH,eAAO,MAAM,mBAAmB,8BAAwB,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type OpenMode } from './bottomSheet.store';
|
|
2
2
|
import type { BottomSheetPortalId, BottomSheetPortalParams, HasParams } from './portal.types';
|
|
3
|
+
import type { CloseAllOptions } from './useBottomSheetManager';
|
|
3
4
|
interface BaseOpenOptions<TParams> {
|
|
4
5
|
mode?: OpenMode;
|
|
5
6
|
scaleBackground?: boolean;
|
|
@@ -14,6 +15,7 @@ type OpenFunction<T extends BottomSheetPortalId> = HasParams<T> extends true ? (
|
|
|
14
15
|
export interface UseBottomSheetControlReturn<T extends BottomSheetPortalId> {
|
|
15
16
|
open: OpenFunction<T>;
|
|
16
17
|
close: () => void;
|
|
18
|
+
closeAll: (options?: CloseAllOptions) => Promise<void>;
|
|
17
19
|
updateParams: (params: BottomSheetPortalParams<T>) => void;
|
|
18
20
|
resetParams: () => void;
|
|
19
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBottomSheetControl.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetControl.ts"],"names":[],"mappings":"AAGA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AC,MAAM,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;IAC3D,WAAW,EAAE,MAAM,IAAI,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,mBAAmB,EACjE,EAAE,EAAE,CAAC,GACJ,2BAA2B,CAAC,CAAC,CAAC,CAqDhC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { type OpenMode } from './bottomSheet.store';
|
|
3
|
+
export interface CloseAllOptions {
|
|
4
|
+
/** Delay in ms between each cascading close animation. Default: 100 */
|
|
5
|
+
stagger?: number;
|
|
6
|
+
}
|
|
3
7
|
export declare const useBottomSheetManager: () => {
|
|
4
8
|
open: (content: React.ReactElement, options?: {
|
|
5
9
|
id?: string;
|
|
@@ -8,6 +12,7 @@ export declare const useBottomSheetManager: () => {
|
|
|
8
12
|
scaleBackground?: boolean;
|
|
9
13
|
}) => string;
|
|
10
14
|
close: (id: string) => void;
|
|
15
|
+
closeAll: (options?: CloseAllOptions) => Promise<void>;
|
|
11
16
|
clear: () => void;
|
|
12
17
|
/** @deprecated Use `open` instead */
|
|
13
18
|
openBottomSheet: (content: React.ReactElement, options?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,
|
|
1
|
+
{"version":3,"file":"useBottomSheetManager.d.ts","sourceRoot":"","sources":["../../../src/useBottomSheetManager.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAA0B,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM5E,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB;oBAOrB,KAAK,CAAC,YAAY,YAClB;QACP,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;gBA2BgB,MAAM;yBAIG,eAAe;;IAezC,qCAAqC;+BApD5B,KAAK,CAAC,YAAY,YAClB;QACP,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,CAAC,EAAE,QAAQ,CAAC;QAChB,eAAe,CAAC,EAAE,OAAO,CAAC;KAC3B;IAgDD,sCAAsC;;CAGzC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { OnBeforeCloseCallback } from './onBeforeCloseRegistry';
|
|
2
|
+
/**
|
|
3
|
+
* Registers an interceptor that is called before the sheet closes.
|
|
4
|
+
*
|
|
5
|
+
* When active, this hook:
|
|
6
|
+
* 1. Sets `preventDismiss` on the sheet so adapters block user-initiated
|
|
7
|
+
* gestures (swipe down, pan-to-close) at the native level.
|
|
8
|
+
* 2. Intercepts all programmatic close paths (backdrop tap, back button,
|
|
9
|
+
* `close()`, `closeAll()`) and calls the callback first.
|
|
10
|
+
*
|
|
11
|
+
* The interceptor receives `onConfirm` and `onCancel` callbacks. Call these
|
|
12
|
+
* when the user makes a decision. This works seamlessly with `Alert.alert`:
|
|
13
|
+
*
|
|
14
|
+
* ```tsx
|
|
15
|
+
* useOnBeforeClose(({ onConfirm, onCancel }) => {
|
|
16
|
+
* if (dirty) {
|
|
17
|
+
* Alert.alert('Discard changes?', '', [
|
|
18
|
+
* { text: 'Cancel', onPress: onCancel },
|
|
19
|
+
* { text: 'Discard', onPress: onConfirm },
|
|
20
|
+
* ]);
|
|
21
|
+
* } else {
|
|
22
|
+
* onConfirm(); // Allow close immediately
|
|
23
|
+
* }
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* For backward compatibility, you can still return `boolean` or `Promise<boolean>`:
|
|
28
|
+
* - Return `false` (or resolve to `false`) to prevent closing
|
|
29
|
+
* - Return `true` (or resolve to `true`) to allow closing
|
|
30
|
+
*
|
|
31
|
+
* Use `forceClose()` from `useBottomSheetContext` to bypass the interceptor entirely.
|
|
32
|
+
*
|
|
33
|
+
* Must be used inside a sheet component (within BottomSheetContext).
|
|
34
|
+
*
|
|
35
|
+
* @example Callback pattern (recommended)
|
|
36
|
+
* ```tsx
|
|
37
|
+
* function MySheet() {
|
|
38
|
+
* const [dirty, setDirty] = useState(false);
|
|
39
|
+
*
|
|
40
|
+
* useOnBeforeClose(({ onConfirm, onCancel }) => {
|
|
41
|
+
* if (dirty) {
|
|
42
|
+
* Alert.alert('Discard changes?', '', [
|
|
43
|
+
* { text: 'Cancel', style: 'cancel', onPress: onCancel },
|
|
44
|
+
* { text: 'Discard', onPress: onConfirm },
|
|
45
|
+
* ]);
|
|
46
|
+
* } else {
|
|
47
|
+
* onConfirm();
|
|
48
|
+
* }
|
|
49
|
+
* });
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @example Boolean return (backward compatible)
|
|
54
|
+
* ```tsx
|
|
55
|
+
* function MySheet() {
|
|
56
|
+
* const [dirty, setDirty] = useState(false);
|
|
57
|
+
*
|
|
58
|
+
* useOnBeforeClose(() => {
|
|
59
|
+
* return !dirty; // false blocks, true allows
|
|
60
|
+
* });
|
|
61
|
+
* }
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function useOnBeforeClose(callback: OnBeforeCloseCallback): void;
|
|
65
|
+
//# sourceMappingURL=useOnBeforeClose.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useOnBeforeClose.d.ts","sourceRoot":"","sources":["../../../src/useOnBeforeClose.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAIrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6DG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,qBAAqB,GAAG,IAAI,CAqBtE"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@ import Animated, {
|
|
|
6
6
|
useAnimatedStyle,
|
|
7
7
|
} from 'react-native-reanimated';
|
|
8
8
|
import { getAnimatedIndex } from './animatedRegistry';
|
|
9
|
-
import {
|
|
9
|
+
import { requestClose } from './bottomSheetCoordinator';
|
|
10
10
|
|
|
11
11
|
interface BottomSheetBackdropProps {
|
|
12
12
|
sheetId: string;
|
|
@@ -14,7 +14,6 @@ interface BottomSheetBackdropProps {
|
|
|
14
14
|
|
|
15
15
|
export function BottomSheetBackdrop({ sheetId }: BottomSheetBackdropProps) {
|
|
16
16
|
const animatedIndex = getAnimatedIndex(sheetId);
|
|
17
|
-
const startClosing = useStartClosing();
|
|
18
17
|
|
|
19
18
|
if (!animatedIndex) {
|
|
20
19
|
throw new Error('animatedIndex must be defined in BottomSheetBackdrop');
|
|
@@ -46,7 +45,7 @@ export function BottomSheetBackdrop({ sheetId }: BottomSheetBackdropProps) {
|
|
|
46
45
|
return (
|
|
47
46
|
<Pressable
|
|
48
47
|
style={StyleSheet.absoluteFillObject}
|
|
49
|
-
onPress={() =>
|
|
48
|
+
onPress={() => requestClose(sheetId)}
|
|
50
49
|
>
|
|
51
50
|
<Animated.View
|
|
52
51
|
style={[StyleSheet.absoluteFillObject, animatedStyle, styles.backdrop]}
|
package/src/QueueItem.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
useSheetUsePortal,
|
|
14
14
|
} from './bottomSheet.store';
|
|
15
15
|
import { BottomSheetBackdrop } from './BottomSheetBackdrop';
|
|
16
|
+
import { removeOnBeforeClose } from './onBeforeCloseRegistry';
|
|
16
17
|
import { cleanupSheetRef } from './refsMap';
|
|
17
18
|
import { useSheetScaleAnimatedStyle } from './useScaleAnimation';
|
|
18
19
|
|
|
@@ -40,6 +41,7 @@ export const QueueItem = memo(function QueueItem({
|
|
|
40
41
|
return () => {
|
|
41
42
|
cleanupSheetRef(id);
|
|
42
43
|
cleanupAnimatedIndex(id);
|
|
44
|
+
removeOnBeforeClose(id);
|
|
43
45
|
};
|
|
44
46
|
}, [id, keepMounted]);
|
|
45
47
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useImperativeHandle, useRef } from 'react';
|
|
2
2
|
|
|
3
3
|
import type { SheetAdapterRef } from '../../adapter.types';
|
|
4
|
+
import { useSheetPreventDismiss } from '../../bottomSheet.store';
|
|
4
5
|
import { createSheetEventHandlers } from '../../bottomSheetCoordinator';
|
|
5
6
|
import { useAdapterRef } from '../../useAdapterRef';
|
|
6
7
|
import { useAnimatedIndex } from '../../useAnimatedIndex';
|
|
@@ -35,6 +36,7 @@ export const ActionsSheetAdapter = React.forwardRef<
|
|
|
35
36
|
const { id } = useBottomSheetContext();
|
|
36
37
|
const ref = useAdapterRef(forwardedRef);
|
|
37
38
|
const animatedIndex = useAnimatedIndex();
|
|
39
|
+
const preventDismiss = useSheetPreventDismiss(id);
|
|
38
40
|
|
|
39
41
|
const actionSheetRef = useRef<any>(null);
|
|
40
42
|
|
|
@@ -63,9 +65,9 @@ export const ActionsSheetAdapter = React.forwardRef<
|
|
|
63
65
|
return (
|
|
64
66
|
<ActionSheet
|
|
65
67
|
// Adapter defaults (overridable via spread)
|
|
66
|
-
gestureEnabled
|
|
67
|
-
closeOnTouchBackdrop
|
|
68
|
-
closeOnPressBack
|
|
68
|
+
gestureEnabled={!preventDismiss}
|
|
69
|
+
closeOnTouchBackdrop={!preventDismiss}
|
|
70
|
+
closeOnPressBack={!preventDismiss}
|
|
69
71
|
keyboardHandlerEnabled
|
|
70
72
|
{...sheetProps}
|
|
71
73
|
// Managed by adapter (not overridable)
|
|
@@ -7,6 +7,7 @@ import React, { useImperativeHandle, useRef } from 'react';
|
|
|
7
7
|
import { useAnimatedReaction } from 'react-native-reanimated';
|
|
8
8
|
|
|
9
9
|
import type { SheetAdapterRef } from '../../adapter.types';
|
|
10
|
+
import { useSheetPreventDismiss } from '../../bottomSheet.store';
|
|
10
11
|
import { createSheetEventHandlers } from '../../bottomSheetCoordinator';
|
|
11
12
|
import { useBottomSheetDefaultIndex } from '../../BottomSheetDefaultIndex.context';
|
|
12
13
|
import { useAdapterRef } from '../../useAdapterRef';
|
|
@@ -39,6 +40,7 @@ export const GorhomSheetAdapter = React.forwardRef<
|
|
|
39
40
|
const ref = useAdapterRef(forwardedRef);
|
|
40
41
|
const contextAnimatedIndex = useAnimatedIndex();
|
|
41
42
|
const defaultIndex = useBottomSheetDefaultIndex();
|
|
43
|
+
const preventDismiss = useSheetPreventDismiss(id);
|
|
42
44
|
|
|
43
45
|
const gorhomRef = useRef<BottomSheetMethods | null>(null);
|
|
44
46
|
|
|
@@ -110,7 +112,7 @@ export const GorhomSheetAdapter = React.forwardRef<
|
|
|
110
112
|
onClose={wrappedOnClose}
|
|
111
113
|
onAnimate={wrappedOnAnimate}
|
|
112
114
|
backdropComponent={backdropComponent}
|
|
113
|
-
enablePanDownToClose={enablePanDownToClose}
|
|
115
|
+
enablePanDownToClose={preventDismiss ? false : enablePanDownToClose}
|
|
114
116
|
>
|
|
115
117
|
{children}
|
|
116
118
|
</BottomSheetOriginal>
|