@niibase/bottom-sheet-manager 1.1.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/LICENSE +21 -0
- package/README.md +147 -0
- package/lib/commonjs/events.js +35 -0
- package/lib/commonjs/events.js.map +1 -0
- package/lib/commonjs/index.js +85 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/manager.js +171 -0
- package/lib/commonjs/manager.js.map +1 -0
- package/lib/commonjs/provider.js +229 -0
- package/lib/commonjs/provider.js.map +1 -0
- package/lib/commonjs/router/index.js +100 -0
- package/lib/commonjs/router/index.js.map +1 -0
- package/lib/commonjs/router/router.js +72 -0
- package/lib/commonjs/router/router.js.map +1 -0
- package/lib/commonjs/router/types.js +6 -0
- package/lib/commonjs/router/types.js.map +1 -0
- package/lib/commonjs/router/view.js +180 -0
- package/lib/commonjs/router/view.js.map +1 -0
- package/lib/commonjs/sheet.js +240 -0
- package/lib/commonjs/sheet.js.map +1 -0
- package/lib/commonjs/types.js +6 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/module/events.js +29 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/manager.js +165 -0
- package/lib/module/manager.js.map +1 -0
- package/lib/module/provider.js +210 -0
- package/lib/module/provider.js.map +1 -0
- package/lib/module/router/index.js +79 -0
- package/lib/module/router/index.js.map +1 -0
- package/lib/module/router/router.js +65 -0
- package/lib/module/router/router.js.map +1 -0
- package/lib/module/router/types.js +2 -0
- package/lib/module/router/types.js.map +1 -0
- package/lib/module/router/view.js +173 -0
- package/lib/module/router/view.js.map +1 -0
- package/lib/module/sheet.js +232 -0
- package/lib/module/sheet.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/events.d.ts +16 -0
- package/lib/typescript/events.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +6 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/manager.d.ts +78 -0
- package/lib/typescript/manager.d.ts.map +1 -0
- package/lib/typescript/provider.d.ts +69 -0
- package/lib/typescript/provider.d.ts.map +1 -0
- package/lib/typescript/router/index.d.ts +59 -0
- package/lib/typescript/router/index.d.ts.map +1 -0
- package/lib/typescript/router/router.d.ts +47 -0
- package/lib/typescript/router/router.d.ts.map +1 -0
- package/lib/typescript/router/types.d.ts +46 -0
- package/lib/typescript/router/types.d.ts.map +1 -0
- package/lib/typescript/router/view.d.ts +11 -0
- package/lib/typescript/router/view.d.ts.map +1 -0
- package/lib/typescript/sheet.d.ts +19 -0
- package/lib/typescript/sheet.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +125 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/package.json +102 -0
- package/src/events.ts +40 -0
- package/src/index.ts +11 -0
- package/src/manager.ts +223 -0
- package/src/provider.tsx +293 -0
- package/src/router/index.tsx +130 -0
- package/src/router/router.ts +94 -0
- package/src/router/types.ts +117 -0
- package/src/router/view.tsx +265 -0
- package/src/sheet.tsx +350 -0
- package/src/types.ts +153 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { BottomSheetProps as RNBottomSheetProps } from "@gorhom/bottom-sheet";
|
|
2
|
+
import type { WithSpringConfig, WithTimingConfig } from "react-native-reanimated";
|
|
3
|
+
import React from "react";
|
|
4
|
+
|
|
5
|
+
export interface Sheets {}
|
|
6
|
+
export type SheetIds = keyof Sheets;
|
|
7
|
+
export type SheetID<Id extends SheetIds> = Id | (string & {});
|
|
8
|
+
|
|
9
|
+
export type SheetPayload<Id extends SheetIds> = Sheets[Id]["payload"];
|
|
10
|
+
export type SheetReturnValue<Id extends SheetIds> = Sheets[Id]["returnValue"];
|
|
11
|
+
type AnimationConfigs = WithSpringConfig | WithTimingConfig;
|
|
12
|
+
|
|
13
|
+
export interface SheetProps<Id extends SheetIds = SheetIds> {
|
|
14
|
+
readonly id: SheetID<Id>;
|
|
15
|
+
readonly payload: SheetPayload<Id>;
|
|
16
|
+
readonly context: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SheetDefinition<Payload = never, ReturnValue = never> {
|
|
20
|
+
payload: Payload;
|
|
21
|
+
returnValue: ReturnValue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface BottomSheetInstance<Id extends SheetIds = SheetIds> {
|
|
25
|
+
/**
|
|
26
|
+
* Close the bottom sheet.
|
|
27
|
+
* @param args
|
|
28
|
+
*/
|
|
29
|
+
readonly close: (
|
|
30
|
+
...args: SheetReturnValue<Id> extends never
|
|
31
|
+
? [
|
|
32
|
+
options?: {
|
|
33
|
+
/**
|
|
34
|
+
* Snap animation configs.
|
|
35
|
+
*/
|
|
36
|
+
animationConfigs?: AnimationConfigs;
|
|
37
|
+
},
|
|
38
|
+
]
|
|
39
|
+
: [
|
|
40
|
+
options: {
|
|
41
|
+
/**
|
|
42
|
+
* Return some data to the caller on closing the `BottomSheet`.
|
|
43
|
+
*/
|
|
44
|
+
value: SheetReturnValue<Id>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Snap animation configs.
|
|
48
|
+
*/
|
|
49
|
+
animationConfigs?: AnimationConfigs;
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
) => void;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Snap to the maximum provided point from `snapPoints`.
|
|
56
|
+
* @param animationConfigs Snap animation configs.
|
|
57
|
+
*/
|
|
58
|
+
readonly expand: (animationConfigs?: AnimationConfigs) => void;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Snap to the minimum provided point from `snapPoints`.
|
|
62
|
+
* @param animationConfigs Snap animation configs.
|
|
63
|
+
*/
|
|
64
|
+
readonly collapse: (animationConfigs?: AnimationConfigs) => void;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Snap to one of the provided points from `snapPoints`.
|
|
68
|
+
* @param index Snap point index.
|
|
69
|
+
* @param animationConfigs Snap animation configs.
|
|
70
|
+
*/
|
|
71
|
+
readonly snapToIndex: (index: number, animationConfigs?: AnimationConfigs) => void;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Snap to a position out of provided `snapPoints`.
|
|
75
|
+
* @param position Position in pixel or percentage.
|
|
76
|
+
* @param animationConfigs Snap animation configs.
|
|
77
|
+
*/
|
|
78
|
+
readonly snapToPosition: (
|
|
79
|
+
position: string | number,
|
|
80
|
+
animationConfigs?: AnimationConfigs,
|
|
81
|
+
) => void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export type BottomSheetProps = Omit<
|
|
85
|
+
RNBottomSheetProps,
|
|
86
|
+
"children" | "onClose" | "animatedIndex" | "topInset"
|
|
87
|
+
> & {
|
|
88
|
+
/**
|
|
89
|
+
* ID of the `BottomSheet`.
|
|
90
|
+
*/
|
|
91
|
+
id?: SheetID<SheetIds>;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Content of the `BottomSheet`.
|
|
95
|
+
*/
|
|
96
|
+
children: React.ReactNode;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* When set to true, `BottomSheet` is closed when the hardware back button is pressed.
|
|
100
|
+
* @default true
|
|
101
|
+
*/
|
|
102
|
+
hardwareBackPressToClose?: boolean;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Callback when the sheet close.
|
|
106
|
+
*
|
|
107
|
+
* @type () => void;
|
|
108
|
+
*/
|
|
109
|
+
onClose?: (data?: any) => void;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Event called before sheets is visible.
|
|
113
|
+
* @param data Payload of the sheet if any.
|
|
114
|
+
* @type () => void;
|
|
115
|
+
*/
|
|
116
|
+
onBeforeShow?: (data?: any) => void;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Can click through the sheet to the underlying view.
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
clickThrough?: boolean;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Opacity of the sheet's overlay.
|
|
126
|
+
* @default 0.45
|
|
127
|
+
*/
|
|
128
|
+
opacity?: number;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Defines the stack behavior when modal mounts. (experimental)
|
|
132
|
+
* @default "switch"
|
|
133
|
+
*/
|
|
134
|
+
stackBehavior?: "push" | "replace" | "switch";
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Whether the bottom sheet edge to edge.
|
|
138
|
+
* @default false
|
|
139
|
+
*/
|
|
140
|
+
fullScreen?: boolean;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Whether the bottom sheet is an iOS modal sheet type of animation.
|
|
144
|
+
* @default false
|
|
145
|
+
*/
|
|
146
|
+
iosModalSheetTypeOfAnimation?: boolean;
|
|
147
|
+
|
|
148
|
+
className?: string;
|
|
149
|
+
handleIndicatorClassName?: string;
|
|
150
|
+
backgroundClassName?: string;
|
|
151
|
+
containerClassName?: string;
|
|
152
|
+
handleClassName?: string;
|
|
153
|
+
};
|