@lodev09/react-native-true-sheet 4.0.0-beta.23 → 4.0.0-beta.25
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 +3 -2
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +13 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayView.kt +11 -0
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +89 -9
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +100 -24
- package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +13 -10
- package/android/src/main/java/com/lodev09/truesheet/core/RNScreensEventObserver.kt +31 -6
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +3 -8
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +14 -1
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +11 -17
- package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +2 -4
- package/android/src/main/java/com/lodev09/truesheet/utils/ColorUtils.kt +19 -0
- package/ios/TrueSheetModule.mm +11 -2
- package/ios/TrueSheetView.h +2 -0
- package/ios/TrueSheetView.mm +62 -7
- package/ios/TrueSheetViewController.h +2 -0
- package/ios/TrueSheetViewController.mm +158 -4
- package/ios/core/RNScreensEventObserver.mm +18 -1
- package/ios/core/TrueSheetDimView.h +27 -0
- package/ios/core/TrueSheetDimView.mm +41 -0
- package/ios/core/TrueSheetKeyboardObserver.mm +11 -8
- package/lib/module/TrueSheet.js +88 -17
- package/lib/module/TrueSheet.js.map +1 -1
- package/lib/module/TrueSheet.web.js +150 -37
- package/lib/module/TrueSheet.web.js.map +1 -1
- package/lib/module/TrueSheetProvider.web.js +13 -9
- package/lib/module/TrueSheetProvider.web.js.map +1 -1
- package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +2 -3
- package/lib/module/fabric/TrueSheetViewNativeComponent.ts +76 -71
- package/lib/module/navigation/createTrueSheetRouter.js +114 -91
- package/lib/module/navigation/createTrueSheetRouter.js.map +1 -1
- package/lib/module/navigation/expo-router/extendTrueSheetRouter.js +43 -0
- package/lib/module/navigation/expo-router/extendTrueSheetRouter.js.map +1 -0
- package/lib/module/navigation/expo-router/index.js +9 -4
- package/lib/module/navigation/expo-router/index.js.map +1 -1
- package/lib/module/scrollable.js +28 -0
- package/lib/module/scrollable.js.map +1 -0
- package/lib/module/web/keyboard.js +69 -0
- package/lib/module/web/keyboard.js.map +1 -0
- package/lib/module/web/layout.js +1 -1
- package/lib/module/web/layout.js.map +1 -1
- package/lib/module/web/vaul/context.js.map +1 -1
- package/lib/module/web/vaul/index.js +18 -8
- package/lib/module/web/vaul/index.js.map +1 -1
- package/lib/module/web/vaul/use-snap-points.js +15 -10
- package/lib/module/web/vaul/use-snap-points.js.map +1 -1
- package/lib/typescript/src/TrueSheet.d.ts +14 -1
- package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.types.d.ts +23 -3
- package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -1
- package/lib/typescript/src/TrueSheetProvider.web.d.ts +5 -1
- package/lib/typescript/src/TrueSheetProvider.web.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +2 -3
- package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +67 -66
- package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +27 -0
- package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/extendTrueSheetRouter.d.ts +29 -0
- package/lib/typescript/src/navigation/expo-router/extendTrueSheetRouter.d.ts.map +1 -0
- package/lib/typescript/src/navigation/expo-router/index.d.ts +3 -2
- package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -1
- package/lib/typescript/src/navigation/expo-router/types.d.ts +1 -1
- package/lib/typescript/src/navigation/types.d.ts +3 -2
- package/lib/typescript/src/navigation/types.d.ts.map +1 -1
- package/lib/typescript/src/scrollable.d.ts +2 -0
- package/lib/typescript/src/scrollable.d.ts.map +1 -0
- package/lib/typescript/src/web/keyboard.d.ts +15 -0
- package/lib/typescript/src/web/keyboard.d.ts.map +1 -0
- package/lib/typescript/src/web/layout.d.ts +1 -0
- package/lib/typescript/src/web/layout.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/context.d.ts +2 -1
- package/lib/typescript/src/web/vaul/context.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/index.d.ts +8 -1
- package/lib/typescript/src/web/vaul/index.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/types.d.ts +9 -0
- package/lib/typescript/src/web/vaul/types.d.ts.map +1 -1
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts +3 -2
- package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -1
- package/package.json +5 -4
- package/src/TrueSheet.tsx +93 -14
- package/src/TrueSheet.types.ts +27 -2
- package/src/TrueSheet.web.tsx +170 -41
- package/src/TrueSheetProvider.web.tsx +22 -13
- package/src/fabric/TrueSheetFooterViewNativeComponent.ts +2 -3
- package/src/fabric/TrueSheetViewNativeComponent.ts +76 -71
- package/src/navigation/createTrueSheetRouter.ts +149 -113
- package/src/navigation/expo-router/extendTrueSheetRouter.ts +71 -0
- package/src/navigation/expo-router/index.ts +14 -6
- package/src/navigation/expo-router/types.ts +1 -1
- package/src/navigation/types.ts +5 -1
- package/src/scrollable.ts +25 -0
- package/src/web/keyboard.ts +79 -0
- package/src/web/layout.ts +1 -1
- package/src/web/vaul/context.ts +2 -1
- package/src/web/vaul/index.tsx +20 -5
- package/src/web/vaul/types.ts +10 -0
- package/src/web/vaul/use-snap-points.ts +19 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useSyncExternalStore","jsx","_jsx","jsxs","_jsxs","SheetContext","NO_PROVIDER_ERROR","EMPTY_STACK","Object","freeze","TrueSheetProvider","children","namedSheetsRef","Map","stackRef","listenersRef","
|
|
1
|
+
{"version":3,"names":["createContext","useCallback","useContext","useEffect","useLayoutEffect","useMemo","useRef","useSyncExternalStore","jsx","_jsx","jsxs","_jsxs","SheetContext","NO_PROVIDER_ERROR","EMPTY_STACK","Object","freeze","TrueSheetProvider","children","sheetsRef","Set","namedSheetsRef","Map","stackRef","listenersRef","portalContainer","document","createElement","anchorRef","anchor","current","appendChild","parentNode","removeChild","value","notify","forEach","listener","registerSheet","ref","name","add","set","delete","get","getSheets","resolveByName","methods","Error","pushOpen","entry","some","e","popOpen","idx","findIndex","slice","subscribeStack","getStackSnapshot","Provider","usePortalContainer","ctx","useTrueSheet","reject","present","resize","dismiss","dismissStack","dismissAll","index","animated","Promise","all","map","dismissQuietly","useRegisterSheet","useSheetStack","nodeRef","isOpen","isFormSheet","isFormSheetRef","subscribe","getSnapshot","stack","stackIndex","isNested","descendants","dismissAbove","snapshot","above","reverse"],"sourceRoot":"../../src","sources":["TrueSheetProvider.web.tsx"],"mappings":";;AAAA,SACEA,aAAa,EACbC,WAAW,EACXC,UAAU,EACVC,SAAS,EACTC,eAAe,EACfC,OAAO,EACPC,MAAM,EACNC,oBAAoB,QAGf,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AA8Bf,MAAMC,YAAY,gBAAGZ,aAAa,CAA2B,IAAI,CAAC;AAElE,MAAMa,iBAAiB,GACrB,2EAA2E;AAE7E,MAAMC,WAAkC,GAAGC,MAAM,CAACC,MAAM,CAAC,EAAE,CAAC;AAM5D,OAAO,SAASC,iBAAiBA,CAAC;EAAEC;AAAiC,CAAC,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tF,WAAW,CAC9B,MAAOqE,QAAkB,IAAK;IAC5B,IAAI,CAACT,GAAG,EAAE;IACV,MAAM2B,QAAQ,GAAG3B,GAAG,CAACH,gBAAgB,CAAC,CAAC;IACvC,MAAMJ,GAAG,GAAGkC,QAAQ,CAACjC,SAAS,CAAEH,CAAC,IAAKA,CAAC,CAACb,GAAG,KAAKA,GAAG,CAAC;IACpD,IAAIe,GAAG,GAAG,CAAC,EAAE;IACb,MAAMmC,KAAK,GAAGD,QAAQ,CAAChC,KAAK,CAACF,GAAG,GAAG,CAAC,CAAC;IACrC,MAAMiB,OAAO,CAACC,GAAG,CAAC,CAAC,GAAGiB,KAAK,CAAC,CAACC,OAAO,CAAC,CAAC,CAACjB,GAAG,CAAErB,CAAC,IAAKA,CAAC,CAACb,GAAG,CAACT,OAAO,EAAE4C,cAAc,CAACJ,QAAQ,CAAC,CAAC,CAAC;EAC7F,CAAC,EACD,CAACT,GAAG,EAAEtB,GAAG,CACX,CAAC;EAED,OAAO;IAAE+C,WAAW;IAAED,QAAQ;IAAEE;EAAa,CAAC;AAChD","ignoreList":[]}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { ViewProps } from 'react-native';
|
|
2
|
-
import type { WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
|
|
1
|
+
import type { CodegenTypes, ViewProps } from 'react-native';
|
|
3
2
|
import { codegenNativeComponent } from 'react-native';
|
|
4
3
|
|
|
5
4
|
export interface NativeProps extends ViewProps {
|
|
6
5
|
// Seeds the footer's first layout with the sheet's bottom safe-area inset
|
|
7
6
|
// (insetAdjustment: 'automatic') so a late-set footer doesn't need a second
|
|
8
7
|
// layout pass — and a visible sheet resize — once native pushes the inset
|
|
9
|
-
autoBottomInset?: WithDefault<boolean, false>;
|
|
8
|
+
autoBottomInset?: CodegenTypes.WithDefault<boolean, false>;
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
// interfaceOnly: shadow node/state/descriptor are custom (common/cpp) so the
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
import type { ColorValue, ProcessedColorValue, ViewProps } from 'react-native';
|
|
2
|
-
import type {
|
|
3
|
-
DirectEventHandler,
|
|
4
|
-
Double,
|
|
5
|
-
Int32,
|
|
6
|
-
WithDefault,
|
|
7
|
-
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
1
|
+
import type { CodegenTypes, ColorValue, ProcessedColorValue, ViewProps } from 'react-native';
|
|
8
2
|
import { codegenNativeComponent } from 'react-native';
|
|
9
3
|
|
|
10
4
|
type GrabberOptionsType = Readonly<{
|
|
11
|
-
width?: Double;
|
|
12
|
-
height?: Double;
|
|
13
|
-
topMargin?: Double;
|
|
14
|
-
cornerRadius?: WithDefault<Double, -1>;
|
|
5
|
+
width?: CodegenTypes.Double;
|
|
6
|
+
height?: CodegenTypes.Double;
|
|
7
|
+
topMargin?: CodegenTypes.Double;
|
|
8
|
+
cornerRadius?: CodegenTypes.WithDefault<CodegenTypes.Double, -1>;
|
|
15
9
|
color?: ProcessedColorValue | null;
|
|
16
|
-
adaptive?: WithDefault<boolean, true>;
|
|
10
|
+
adaptive?: CodegenTypes.WithDefault<boolean, true>;
|
|
17
11
|
}>;
|
|
18
12
|
|
|
19
13
|
type AccessibilityOptionsType = Readonly<{
|
|
20
|
-
grabberLabel?: WithDefault<string, 'Sheet Grabber'>;
|
|
21
|
-
grabberHint?: WithDefault<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
grabberLabel?: CodegenTypes.WithDefault<string, 'Sheet Grabber'>;
|
|
15
|
+
grabberHint?: CodegenTypes.WithDefault<
|
|
16
|
+
string,
|
|
17
|
+
'Double-tap to expand. Swipe up or down to resize the sheet'
|
|
18
|
+
>;
|
|
19
|
+
expandedValue?: CodegenTypes.WithDefault<string, 'Expanded'>;
|
|
20
|
+
collapsedValue?: CodegenTypes.WithDefault<string, 'Collapsed'>;
|
|
21
|
+
detentValue?: CodegenTypes.WithDefault<string, 'Detent {index} of {count}'>;
|
|
22
|
+
expandActionLabel?: CodegenTypes.WithDefault<string, 'Expand'>;
|
|
23
|
+
collapseActionLabel?: CodegenTypes.WithDefault<string, 'Collapse'>;
|
|
24
|
+
paneTitle?: CodegenTypes.WithDefault<string, 'Bottom sheet'>;
|
|
28
25
|
}>;
|
|
29
26
|
|
|
30
27
|
type ScrollEdgeEffect = 'automatic' | 'hard' | 'soft' | 'hidden';
|
|
31
28
|
|
|
32
29
|
type ScrollableOptionsType = Readonly<{
|
|
33
|
-
contentInsetAdjustment?: WithDefault<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
contentInsetAdjustment?: CodegenTypes.WithDefault<
|
|
31
|
+
'automatic' | 'safe-area' | 'footer' | 'never',
|
|
32
|
+
'automatic'
|
|
33
|
+
>;
|
|
34
|
+
keyboardScrollOffset?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
35
|
+
keyboardOffset?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
36
|
+
scrollingExpandsSheet?: CodegenTypes.WithDefault<boolean, true>;
|
|
37
|
+
topScrollEdgeEffect?: CodegenTypes.WithDefault<ScrollEdgeEffect, 'hidden'>;
|
|
38
|
+
bottomScrollEdgeEffect?: CodegenTypes.WithDefault<ScrollEdgeEffect, 'hidden'>;
|
|
39
39
|
}>;
|
|
40
40
|
|
|
41
41
|
type FooterOptionsType = Readonly<{
|
|
42
42
|
// Named uniquely across option structs — codegen derives the enum name from
|
|
43
43
|
// the field name, so a second `position` would redefine TrueSheetViewPosition
|
|
44
|
-
footerPosition?: WithDefault<'relative' | 'absolute', 'relative'>;
|
|
45
|
-
keyboardOffset?: WithDefault<Double, 0>;
|
|
46
|
-
avoidKeyboard?: WithDefault<boolean, true>;
|
|
44
|
+
footerPosition?: CodegenTypes.WithDefault<'relative' | 'absolute', 'relative'>;
|
|
45
|
+
keyboardOffset?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
46
|
+
avoidKeyboard?: CodegenTypes.WithDefault<boolean, true>;
|
|
47
47
|
}>;
|
|
48
48
|
|
|
49
49
|
type HeaderOptionsType = Readonly<{
|
|
50
|
-
position?: WithDefault<'relative' | 'absolute', 'relative'>;
|
|
50
|
+
position?: CodegenTypes.WithDefault<'relative' | 'absolute', 'relative'>;
|
|
51
51
|
}>;
|
|
52
52
|
|
|
53
53
|
export interface DetentInfoEventPayload {
|
|
54
|
-
index: Int32;
|
|
55
|
-
position: Double;
|
|
56
|
-
detent: Double;
|
|
54
|
+
index: CodegenTypes.Int32;
|
|
55
|
+
position: CodegenTypes.Double;
|
|
56
|
+
detent: CodegenTypes.Double;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
export interface PositionChangeEventPayload {
|
|
60
|
-
index: Double;
|
|
61
|
-
position: Double;
|
|
62
|
-
detent: Double;
|
|
60
|
+
index: CodegenTypes.Double;
|
|
61
|
+
position: CodegenTypes.Double;
|
|
62
|
+
detent: CodegenTypes.Double;
|
|
63
63
|
realtime: boolean;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
export interface NativeProps extends ViewProps {
|
|
67
67
|
// Array properties
|
|
68
|
-
detents?: ReadonlyArray<Double>;
|
|
68
|
+
detents?: ReadonlyArray<CodegenTypes.Double>;
|
|
69
69
|
detentBackgrounds?: ReadonlyArray<
|
|
70
70
|
Readonly<{
|
|
71
71
|
color?: ProcessedColorValue | null;
|
|
@@ -74,18 +74,20 @@ export interface NativeProps extends ViewProps {
|
|
|
74
74
|
>;
|
|
75
75
|
|
|
76
76
|
// Number properties - use 0 as default to avoid nil insertion
|
|
77
|
-
maxContentHeight?: WithDefault<Double, 0>;
|
|
78
|
-
maxContentWidth?: WithDefault<Double, 0>;
|
|
79
|
-
cornerRadius?: WithDefault<Double, -1>;
|
|
80
|
-
elevation?: WithDefault<Double, -1>;
|
|
77
|
+
maxContentHeight?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
78
|
+
maxContentWidth?: CodegenTypes.WithDefault<CodegenTypes.Double, 0>;
|
|
79
|
+
cornerRadius?: CodegenTypes.WithDefault<CodegenTypes.Double, -1>;
|
|
80
|
+
elevation?: CodegenTypes.WithDefault<CodegenTypes.Double, -1>;
|
|
81
81
|
|
|
82
82
|
// Color properties
|
|
83
83
|
backgroundColor?: ColorValue;
|
|
84
|
-
initialDetentIndex?: WithDefault<Int32, -1>;
|
|
85
|
-
|
|
84
|
+
initialDetentIndex?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
85
|
+
dimColor?: ColorValue;
|
|
86
|
+
dimOpacity?: CodegenTypes.WithDefault<CodegenTypes.Double, -1>;
|
|
87
|
+
dimmedDetentIndex?: CodegenTypes.WithDefault<CodegenTypes.Int32, 0>;
|
|
86
88
|
|
|
87
89
|
// String properties - use empty string as default to avoid nil insertion
|
|
88
|
-
backgroundBlur?: WithDefault<
|
|
90
|
+
backgroundBlur?: CodegenTypes.WithDefault<
|
|
89
91
|
| 'none'
|
|
90
92
|
| 'light'
|
|
91
93
|
| 'dark'
|
|
@@ -111,43 +113,46 @@ export interface NativeProps extends ViewProps {
|
|
|
111
113
|
'none'
|
|
112
114
|
>;
|
|
113
115
|
|
|
114
|
-
placement?: WithDefault<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
placement?: CodegenTypes.WithDefault<
|
|
117
|
+
'automatic' | 'leading' | 'center' | 'trailing',
|
|
118
|
+
'automatic'
|
|
119
|
+
>;
|
|
120
|
+
placementOffset?: CodegenTypes.WithDefault<CodegenTypes.Double, 16>;
|
|
121
|
+
insetAdjustment?: CodegenTypes.WithDefault<'automatic' | 'never', 'automatic'>;
|
|
122
|
+
dismissThreshold?: CodegenTypes.WithDefault<'half' | 'short', 'half'>;
|
|
118
123
|
|
|
119
124
|
// Boolean properties - match defaults from TrueSheet.types.ts
|
|
120
|
-
grabber?: WithDefault<boolean, true>;
|
|
125
|
+
grabber?: CodegenTypes.WithDefault<boolean, true>;
|
|
121
126
|
grabberOptions?: GrabberOptionsType;
|
|
122
127
|
accessibilityOptions?: AccessibilityOptionsType;
|
|
123
|
-
dismissible?: WithDefault<boolean, true>;
|
|
124
|
-
draggable?: WithDefault<boolean, true>;
|
|
125
|
-
dimmed?: WithDefault<boolean, true>;
|
|
126
|
-
initialDetentAnimated?: WithDefault<boolean, true>;
|
|
128
|
+
dismissible?: CodegenTypes.WithDefault<boolean, true>;
|
|
129
|
+
draggable?: CodegenTypes.WithDefault<boolean, true>;
|
|
130
|
+
dimmed?: CodegenTypes.WithDefault<boolean, true>;
|
|
131
|
+
initialDetentAnimated?: CodegenTypes.WithDefault<boolean, true>;
|
|
127
132
|
// React tag of the scrollable component within the content (see scrollableRef)
|
|
128
|
-
scrollableHandle?: WithDefault<Int32, -1>;
|
|
133
|
+
scrollableHandle?: CodegenTypes.WithDefault<CodegenTypes.Int32, -1>;
|
|
129
134
|
scrollableOptions?: ScrollableOptionsType;
|
|
130
135
|
headerOptions?: HeaderOptionsType;
|
|
131
136
|
footerOptions?: FooterOptionsType;
|
|
132
|
-
presentation?: WithDefault<'page' | 'form', 'page'>;
|
|
137
|
+
presentation?: CodegenTypes.WithDefault<'page' | 'form', 'page'>;
|
|
133
138
|
|
|
134
139
|
// Event handlers
|
|
135
|
-
onMount?: DirectEventHandler<null>;
|
|
136
|
-
onWillPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
137
|
-
onDidPresent?: DirectEventHandler<DetentInfoEventPayload>;
|
|
138
|
-
onWillDismiss?: DirectEventHandler<null>;
|
|
139
|
-
onDidDismiss?: DirectEventHandler<null>;
|
|
140
|
-
onDismissAttempt?: DirectEventHandler<null>;
|
|
141
|
-
onDetentChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
142
|
-
onDragBegin?: DirectEventHandler<DetentInfoEventPayload>;
|
|
143
|
-
onDragChange?: DirectEventHandler<DetentInfoEventPayload>;
|
|
144
|
-
onDragEnd?: DirectEventHandler<DetentInfoEventPayload>;
|
|
145
|
-
onPositionChange?: DirectEventHandler<PositionChangeEventPayload>;
|
|
146
|
-
onWillFocus?: DirectEventHandler<null>;
|
|
147
|
-
onDidFocus?: DirectEventHandler<null>;
|
|
148
|
-
onWillBlur?: DirectEventHandler<null>;
|
|
149
|
-
onDidBlur?: DirectEventHandler<null>;
|
|
150
|
-
onVisibilityChange?: DirectEventHandler<Readonly<{ visible: boolean }>>;
|
|
140
|
+
onMount?: CodegenTypes.DirectEventHandler<null>;
|
|
141
|
+
onWillPresent?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
142
|
+
onDidPresent?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
143
|
+
onWillDismiss?: CodegenTypes.DirectEventHandler<null>;
|
|
144
|
+
onDidDismiss?: CodegenTypes.DirectEventHandler<null>;
|
|
145
|
+
onDismissAttempt?: CodegenTypes.DirectEventHandler<null>;
|
|
146
|
+
onDetentChange?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
147
|
+
onDragBegin?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
148
|
+
onDragChange?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
149
|
+
onDragEnd?: CodegenTypes.DirectEventHandler<DetentInfoEventPayload>;
|
|
150
|
+
onPositionChange?: CodegenTypes.DirectEventHandler<PositionChangeEventPayload>;
|
|
151
|
+
onWillFocus?: CodegenTypes.DirectEventHandler<null>;
|
|
152
|
+
onDidFocus?: CodegenTypes.DirectEventHandler<null>;
|
|
153
|
+
onWillBlur?: CodegenTypes.DirectEventHandler<null>;
|
|
154
|
+
onDidBlur?: CodegenTypes.DirectEventHandler<null>;
|
|
155
|
+
onVisibilityChange?: CodegenTypes.DirectEventHandler<Readonly<{ visible: boolean }>>;
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
export default codegenNativeComponent<NativeProps>('TrueSheetView', {
|
|
@@ -21,6 +21,118 @@ const ensureBaseRoute = (state, baseRouteName, routeParamList) => {
|
|
|
21
21
|
}
|
|
22
22
|
return state;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Index of the route a `RESIZE` targets: the dispatching screen, else the focused route.
|
|
26
|
+
*/
|
|
27
|
+
export const getResizeRouteIndex = (state, action) => action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Reduces the sheet-specific actions shared by every router flavour.
|
|
31
|
+
* Returns `undefined` for actions the base `StackRouter` should handle.
|
|
32
|
+
*/
|
|
33
|
+
export const getTrueSheetStateForAction = (state, action) => {
|
|
34
|
+
switch (action.type) {
|
|
35
|
+
case 'RESIZE':
|
|
36
|
+
{
|
|
37
|
+
const routeIndex = getResizeRouteIndex(state, action);
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
routes: state.routes.map((route, i) => i === routeIndex ? {
|
|
41
|
+
...route,
|
|
42
|
+
resizeIndex: action.index,
|
|
43
|
+
resizeKey: (route.resizeKey ?? 0) + 1
|
|
44
|
+
} : route)
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
case 'GO_BACK':
|
|
48
|
+
case 'DISMISS':
|
|
49
|
+
{
|
|
50
|
+
return getTrueSheetStateForAction(state, TrueSheetActions.pop(1));
|
|
51
|
+
}
|
|
52
|
+
case 'POP':
|
|
53
|
+
{
|
|
54
|
+
// Only base screen remains - let parent navigator handle it
|
|
55
|
+
if (state.routes.length <= 1) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
const count = 'payload' in action && typeof action.payload?.count === 'number' ? action.payload.count : 1;
|
|
59
|
+
|
|
60
|
+
// Calculate how many routes we can actually pop (don't pop base screen)
|
|
61
|
+
const maxPopCount = state.routes.length - 1;
|
|
62
|
+
const actualCount = Math.min(count, maxPopCount);
|
|
63
|
+
|
|
64
|
+
// Base screen - let parent navigator handle it
|
|
65
|
+
if (actualCount <= 0) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Target index is the route we want to stay on (land on after pop)
|
|
70
|
+
// closingIndex is the first route to be dismissed (the one after target)
|
|
71
|
+
const targetIndex = state.routes.length - 1 - actualCount;
|
|
72
|
+
const closingIndex = targetIndex + 1;
|
|
73
|
+
|
|
74
|
+
// Mark only the bottom-most route to pop as closing
|
|
75
|
+
// The sheet's dismiss() will handle dismissing sheets above it first
|
|
76
|
+
return {
|
|
77
|
+
...state,
|
|
78
|
+
index: closingIndex,
|
|
79
|
+
routes: state.routes.map((route, i) => {
|
|
80
|
+
if (i === closingIndex) return {
|
|
81
|
+
...route,
|
|
82
|
+
closing: true
|
|
83
|
+
};
|
|
84
|
+
if (i > closingIndex) return {
|
|
85
|
+
...route,
|
|
86
|
+
dismissing: true
|
|
87
|
+
};
|
|
88
|
+
return route;
|
|
89
|
+
})
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
case 'POP_TO_TOP':
|
|
93
|
+
{
|
|
94
|
+
const popCount = state.routes.length - 1;
|
|
95
|
+
return getTrueSheetStateForAction(state, TrueSheetActions.pop(popCount));
|
|
96
|
+
}
|
|
97
|
+
case 'POP_TO':
|
|
98
|
+
{
|
|
99
|
+
const targetName = 'payload' in action && typeof action.payload?.name === 'string' ? action.payload.name : null;
|
|
100
|
+
if (!targetName) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
const targetIndex = state.routes.findIndex(r => r.name === targetName);
|
|
104
|
+
|
|
105
|
+
// Target not found or is the current route
|
|
106
|
+
if (targetIndex === -1 || targetIndex >= state.index) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const popCount = state.routes.length - 1 - targetIndex;
|
|
110
|
+
return getTrueSheetStateForAction(state, TrueSheetActions.pop(popCount));
|
|
111
|
+
}
|
|
112
|
+
case 'REMOVE':
|
|
113
|
+
{
|
|
114
|
+
// Actually remove the closing route and all routes above it
|
|
115
|
+
const routeKey = action.source;
|
|
116
|
+
const routeIndex = routeKey ? state.routes.findIndex(r => r.key === routeKey) : state.routes.findIndex(r => r.closing);
|
|
117
|
+
if (routeIndex === -1) {
|
|
118
|
+
return state;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Remove the route and the routes dismissed with it. A popped route keeps the
|
|
122
|
+
// routes pushed after the pop started: they aren't stacked on it natively.
|
|
123
|
+
const removed = state.routes[routeIndex];
|
|
124
|
+
const isPopped = removed.closing || removed.dismissing;
|
|
125
|
+
const routes = state.routes.filter((route, i) => i < routeIndex || i > routeIndex && isPopped && !route.dismissing);
|
|
126
|
+
return {
|
|
127
|
+
...state,
|
|
128
|
+
index: Math.min(state.index, routes.length - 1),
|
|
129
|
+
routes
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
default:
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
24
136
|
export const createTrueSheetRouter = stackRouter => routerOptions => {
|
|
25
137
|
const baseRouter = stackRouter(routerOptions);
|
|
26
138
|
return {
|
|
@@ -38,97 +150,8 @@ export const createTrueSheetRouter = stackRouter => routerOptions => {
|
|
|
38
150
|
};
|
|
39
151
|
},
|
|
40
152
|
getStateForAction(state, action, options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
{
|
|
44
|
-
const routeIndex = action.target === state.key && action.source ? state.routes.findIndex(r => r.key === action.source) : state.index;
|
|
45
|
-
return {
|
|
46
|
-
...state,
|
|
47
|
-
routes: state.routes.map((route, i) => i === routeIndex ? {
|
|
48
|
-
...route,
|
|
49
|
-
resizeIndex: action.index,
|
|
50
|
-
resizeKey: (route.resizeKey ?? 0) + 1
|
|
51
|
-
} : route)
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
case 'GO_BACK':
|
|
55
|
-
case 'DISMISS':
|
|
56
|
-
{
|
|
57
|
-
return this.getStateForAction(state, TrueSheetActions.pop(1), options);
|
|
58
|
-
}
|
|
59
|
-
case 'POP':
|
|
60
|
-
{
|
|
61
|
-
// Only base screen remains - let parent navigator handle it
|
|
62
|
-
if (state.routes.length <= 1) {
|
|
63
|
-
return null;
|
|
64
|
-
}
|
|
65
|
-
const count = 'payload' in action && typeof action.payload?.count === 'number' ? action.payload.count : 1;
|
|
66
|
-
|
|
67
|
-
// Calculate how many routes we can actually pop (don't pop base screen)
|
|
68
|
-
const maxPopCount = state.routes.length - 1;
|
|
69
|
-
const actualCount = Math.min(count, maxPopCount);
|
|
70
|
-
|
|
71
|
-
// Base screen - let parent navigator handle it
|
|
72
|
-
if (actualCount <= 0) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Target index is the route we want to stay on (land on after pop)
|
|
77
|
-
// closingIndex is the first route to be dismissed (the one after target)
|
|
78
|
-
const targetIndex = state.routes.length - 1 - actualCount;
|
|
79
|
-
const closingIndex = targetIndex + 1;
|
|
80
|
-
|
|
81
|
-
// Mark only the bottom-most route to pop as closing
|
|
82
|
-
// The sheet's dismiss() will handle dismissing sheets above it first
|
|
83
|
-
return {
|
|
84
|
-
...state,
|
|
85
|
-
index: closingIndex,
|
|
86
|
-
routes: state.routes.map((route, i) => i === closingIndex ? {
|
|
87
|
-
...route,
|
|
88
|
-
closing: true
|
|
89
|
-
} : route)
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
case 'POP_TO_TOP':
|
|
93
|
-
{
|
|
94
|
-
const popCount = state.routes.length - 1;
|
|
95
|
-
return this.getStateForAction(state, TrueSheetActions.pop(popCount), options);
|
|
96
|
-
}
|
|
97
|
-
case 'POP_TO':
|
|
98
|
-
{
|
|
99
|
-
const targetName = 'payload' in action && typeof action.payload?.name === 'string' ? action.payload.name : null;
|
|
100
|
-
if (!targetName) {
|
|
101
|
-
return null;
|
|
102
|
-
}
|
|
103
|
-
const targetIndex = state.routes.findIndex(r => r.name === targetName);
|
|
104
|
-
|
|
105
|
-
// Target not found or is the current route
|
|
106
|
-
if (targetIndex === -1 || targetIndex >= state.index) {
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
const popCount = state.routes.length - 1 - targetIndex;
|
|
110
|
-
return this.getStateForAction(state, TrueSheetActions.pop(popCount), options);
|
|
111
|
-
}
|
|
112
|
-
case 'REMOVE':
|
|
113
|
-
{
|
|
114
|
-
// Actually remove the closing route and all routes above it
|
|
115
|
-
const routeKey = action.source;
|
|
116
|
-
const routeIndex = routeKey ? state.routes.findIndex(r => r.key === routeKey) : state.routes.findIndex(r => r.closing);
|
|
117
|
-
if (routeIndex === -1) {
|
|
118
|
-
return state;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Remove the route and all routes above it (they were dismissed together)
|
|
122
|
-
const routes = state.routes.filter((_, i) => i < routeIndex);
|
|
123
|
-
return {
|
|
124
|
-
...state,
|
|
125
|
-
index: Math.min(state.index, routes.length - 1),
|
|
126
|
-
routes
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
default:
|
|
130
|
-
return baseRouter.getStateForAction(state, action, options);
|
|
131
|
-
}
|
|
153
|
+
const result = getTrueSheetStateForAction(state, action);
|
|
154
|
+
return result === undefined ? baseRouter.getStateForAction(state, action, options) : result;
|
|
132
155
|
},
|
|
133
156
|
getRehydratedState(partialState, {
|
|
134
157
|
routeNames,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TrueSheetActions","uid","Math","random","toString","slice","ensureBaseRoute","state","baseRouteName","routeParamList","hasBaseRoute","routes","some","r","name","baseRoute","key","params","index","length","
|
|
1
|
+
{"version":3,"names":["TrueSheetActions","uid","Math","random","toString","slice","ensureBaseRoute","state","baseRouteName","routeParamList","hasBaseRoute","routes","some","r","name","baseRoute","key","params","index","length","getResizeRouteIndex","action","target","source","findIndex","getTrueSheetStateForAction","type","routeIndex","map","route","i","resizeIndex","resizeKey","pop","count","payload","maxPopCount","actualCount","min","targetIndex","closingIndex","closing","dismissing","popCount","targetName","routeKey","removed","isPopped","filter","undefined","createTrueSheetRouter","stackRouter","routerOptions","baseRouter","getInitialState","options","initialRouteName","routeNames","stateWithBaseRoute","stale","getStateForAction","result","getRehydratedState","partialState","routeGetIdList","actionCreators"],"sourceRoot":"../../../src","sources":["navigation/createTrueSheetRouter.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAkC,cAAW;AAGtE,MAAMC,GAAG,GAAGA,CAAA,KAAMC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC;AAEzD,MAAMC,eAAe,GAAGA,CACtBC,KAAQ,EACRC,aAAiC,EACjCC,cAA8D,KACf;EAC/C,IAAI,CAACD,aAAa,EAAE;IAClB,OAAOD,KAAK;EACd;EAEA,MAAMG,YAAY,GAAGH,KAAK,CAACI,MAAM,CAACC,IAAI,CAAEC,CAAC,IAAKA,CAAC,CAACC,IAAI,KAAKN,aAAa,CAAC;EAEvE,IAAI,CAACE,YAAY,EAAE;IACjB,MAAMK,SAAS,GAAG;MAChBC,GAAG,EAAE,GAAGR,aAAa,IAAIP,GAAG,CAAC,CAAC,EAAE;MAChCa,IAAI,EAAEN,aAAa;MACnBS,MAAM,EAAER,cAAc,GAAGD,aAAa;IACxC,CAAC;IAED,OAAO;MACL,GAAGD,KAAK;MACRW,KAAK,EAAEX,KAAK,CAACI,MAAM,CAACQ,MAAM;MAC1BR,MAAM,EAAE,CAACI,SAAS,EAAE,GAAGR,KAAK,CAACI,MAAM;IACrC,CAAC;EACH;EAEA,OAAOJ,KAAK;AACd,CAAC;AAYD;AACA;AACA;AACA,OAAO,MAAMa,mBAAmB,GAAGA,CACjCb,KAAiB,EACjBc,MAA4C,KAE5CA,MAAM,CAACC,MAAM,KAAKf,KAAK,CAACS,GAAG,IAAIK,MAAM,CAACE,MAAM,GACxChB,KAAK,CAACI,MAAM,CAACa,SAAS,CAAEX,CAAC,IAAKA,CAAC,CAACG,GAAG,KAAKK,MAAM,C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IAEDgE,cAAc,EAAEjE;EAClB,CAAC;AACH,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { TrueSheetActions } from "../actions.js";
|
|
4
|
+
import { getResizeRouteIndex, getTrueSheetStateForAction } from "../createTrueSheetRouter.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* `extendRouter` from Expo Router 58+. Declared locally because the
|
|
8
|
+
* Expo Router types this package builds against predate it.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Router for Expo Router 58+, where navigator state is seeded by Expo Router
|
|
13
|
+
* (no `getInitialState`/`getRehydratedState`) and `getStateForAction` returns
|
|
14
|
+
* `{ state, affectedRouteKey }`.
|
|
15
|
+
*/
|
|
16
|
+
export const extendTrueSheetRouter = (extendRouter, stackRouter) => extendRouter(stackRouter, ({
|
|
17
|
+
baseRouter,
|
|
18
|
+
options
|
|
19
|
+
}) => {
|
|
20
|
+
if (__DEV__ && options.initialRouteName === undefined) {
|
|
21
|
+
console.warn("TrueSheet: this Sheet layout has no `unstable_settings.anchor`. On Expo Router 58+, a sheet route opened directly (deep link or push from another navigator) renders without its base screen. Export `unstable_settings = { anchor: '<base route>' }` from the layout.");
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
getStateForAction(state, action, config) {
|
|
25
|
+
const result = getTrueSheetStateForAction(state, action);
|
|
26
|
+
if (result === undefined) {
|
|
27
|
+
return baseRouter.getStateForAction(state, action, config);
|
|
28
|
+
}
|
|
29
|
+
if (result === null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const affectedIndex = action.type === 'RESIZE' ? getResizeRouteIndex(state, action) : result.index;
|
|
33
|
+
return {
|
|
34
|
+
state: result,
|
|
35
|
+
affectedRouteKey: result.routes[affectedIndex]?.key
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
actionCreators: TrueSheetActions
|
|
39
|
+
};
|
|
40
|
+
}, {
|
|
41
|
+
type: 'true-sheet'
|
|
42
|
+
});
|
|
43
|
+
//# sourceMappingURL=extendTrueSheetRouter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["TrueSheetActions","getResizeRouteIndex","getTrueSheetStateForAction","extendTrueSheetRouter","extendRouter","stackRouter","baseRouter","options","__DEV__","initialRouteName","undefined","console","warn","getStateForAction","state","action","config","result","affectedIndex","type","index","affectedRouteKey","routes","key","actionCreators"],"sourceRoot":"../../../../src","sources":["navigation/expo-router/extendTrueSheetRouter.ts"],"mappings":";;AAAA,SAASA,gBAAgB,QAAkC,eAAY;AACvE,SAASC,mBAAmB,EAAEC,0BAA0B,QAAQ,6BAA0B;;AAgB1F;AACA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,qBAAqB,GAAGA,CACnCC,YAA0B,EAC1BC,WAA+B,KAE/BD,YAAY,CACVC,WAAW,EACX,CAAC;EAAEC,UAAU;EAAEC;AAAQ,CAAC,KAAK;EAC3B,IAAIC,OAAO,IAAID,OAAO,CAACE,gBAAgB,KAAKC,SAAS,EAAE;IACrDC,OAAO,CAACC,IAAI,CACV,wQACF,CAAC;EACH;EAEA,OAAO;IACLC,iBAAiBA,CACfC,KAA2B,EAC3BC,MAA2B,EAC3BC,MAAc,EACO;MACrB,MAAMC,MAAM,GAAGf,0BAA0B,CAACY,KAAK,EAAEC,MAAM,CAAC;MAExD,IAAIE,MAAM,KAAKP,SAAS,EAAE;QACxB,OAAOJ,UAAU,CAACO,iBAAiB,CAACC,KAAK,EAAEC,MAAM,EAAEC,MAAM,CAAC;MAC5D;MAEA,IAAIC,MAAM,KAAK,IAAI,EAAE;QACnB,OAAO,IAAI;MACb;MAEA,MAAMC,aAAa,GACjBH,MAAM,CAACI,IAAI,KAAK,QAAQ,GAAGlB,mBAAmB,CAACa,KAAK,EAAEC,MAAM,CAAC,GAAGE,MAAM,CAACG,KAAK;MAE9E,OAAO;QAAEN,KAAK,EAAEG,MAAM;QAAEI,gBAAgB,EAAEJ,MAAM,CAACK,MAAM,CAACJ,aAAa,CAAC,EAAEK;MAAI,CAAC;IAC/E,CAAC;IACDC,cAAc,EAAExB;EAClB,CAAC;AACH,CAAC,EACD;EAAEmB,IAAI,EAAE;AAAa,CACvB,CAAC","ignoreList":[]}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import * as ExpoRouter from 'expo-router';
|
|
3
4
|
import { StackRouter, unstable_integrateWithRouter, useNavigation } from 'expo-router';
|
|
4
5
|
import { createTrueSheetRouter } from "../createTrueSheetRouter.js";
|
|
5
6
|
import { trueSheetNavigator } from "../navigator.js";
|
|
6
|
-
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
7
|
+
import { extendTrueSheetRouter } from "./extendTrueSheetRouter.js";
|
|
8
|
+
// Expo Router 58+ replaced the React Navigation router contract and ships `extendRouter`
|
|
9
|
+
// for it. Before that, the vendored StackRouter is structurally identical to
|
|
10
|
+
// @react-navigation's. Pinned to this entry's own router types: `createTrueSheetRouter` is
|
|
11
|
+
// shared and typed against React Navigation, which resolves to `any` in apps that only
|
|
12
|
+
// install expo-router.
|
|
13
|
+
const extendRouter = ExpoRouter.extendRouter;
|
|
14
|
+
const sheetRouter = extendRouter ? extendTrueSheetRouter(extendRouter, StackRouter) : createTrueSheetRouter(StackRouter);
|
|
10
15
|
|
|
11
16
|
// `routes`/`dispatch` are injected by `createProps`, so they are declared as
|
|
12
17
|
// CreateProps (last generic) and excluded from the public navigator props
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["StackRouter","unstable_integrateWithRouter","useNavigation","createTrueSheetRouter","trueSheetNavigator","sheetRouter","SheetNavigator","createProps","state","dispatch","routes","Sheet","useTrueSheetNavigation","TrueSheetActions"],"sourceRoot":"../../../../src","sources":["navigation/expo-router/index.ts"],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"names":["ExpoRouter","StackRouter","unstable_integrateWithRouter","useNavigation","createTrueSheetRouter","trueSheetNavigator","extendTrueSheetRouter","extendRouter","sheetRouter","SheetNavigator","createProps","state","dispatch","routes","Sheet","useTrueSheetNavigation","TrueSheetActions"],"sourceRoot":"../../../../src","sources":["navigation/expo-router/index.ts"],"mappings":";;AAAA,OAAO,KAAKA,UAAU,MAAM,aAAa;AACzC,SAASC,WAAW,EAAEC,4BAA4B,EAAEC,aAAa,QAAQ,aAAa;AAEtF,SAASC,qBAAqB,QAAQ,6BAA0B;AAChE,SAASC,kBAAkB,QAAQ,iBAAc;AAEjD,SAASC,qBAAqB,QAA2B,4BAAyB;AAalF;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAY,GAAIP,UAAU,CAA6BO,YAEhD;AAEb,MAAMC,WAAmC,GAAGD,YAAY,GACpDD,qBAAqB,CAACC,YAAY,EAAEN,WAAiC,CAAC,GACtEG,qBAAqB,CAACH,WAAiC,CAAC;;AAE5D;AACA;AACA,MAAMQ,cAAc,GAAGP,4BAA4B,CAOjDG,kBAAkB,EAAEG,WAAW,EAAE;EACjCE,WAAW,EAAEA,CAAC;IAAEC,KAAK;IAAEC;EAAS,CAAC,MAAM;IACrCC,MAAM,EAAEF,KAAK,CAACE,MAAM;IACpBD;EACF,CAAC;AACH,CAAC,CAAC;;AAEF;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAME,KAAK,GAAGL,cAGpB;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMM,sBAAsB,GAAGA,CAAA,KAEHZ,aAAa,CAA6B,CAAC;AAE9E,SAASa,gBAAgB,QAAkC,eAAY","ignoreList":[]}
|