@mustmove/bottom-sheet 1.0.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.
Files changed (133) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/mock.js +231 -0
  4. package/package.json +107 -0
  5. package/src/components/bottomSheet/BottomSheet.tsx +1885 -0
  6. package/src/components/bottomSheet/BottomSheetBody.tsx +44 -0
  7. package/src/components/bottomSheet/BottomSheetContent.tsx +261 -0
  8. package/src/components/bottomSheet/constants.ts +58 -0
  9. package/src/components/bottomSheet/index.ts +2 -0
  10. package/src/components/bottomSheet/styles.ts +11 -0
  11. package/src/components/bottomSheet/types.d.ts +358 -0
  12. package/src/components/bottomSheetBackdrop/BottomSheetBackdrop.tsx +165 -0
  13. package/src/components/bottomSheetBackdrop/constants.ts +22 -0
  14. package/src/components/bottomSheetBackdrop/index.ts +2 -0
  15. package/src/components/bottomSheetBackdrop/styles.ts +8 -0
  16. package/src/components/bottomSheetBackdrop/types.d.ts +58 -0
  17. package/src/components/bottomSheetBackground/BottomSheetBackground.tsx +20 -0
  18. package/src/components/bottomSheetBackground/BottomSheetBackgroundContainer.tsx +35 -0
  19. package/src/components/bottomSheetBackground/index.ts +2 -0
  20. package/src/components/bottomSheetBackground/styles.ts +9 -0
  21. package/src/components/bottomSheetBackground/types.d.ts +12 -0
  22. package/src/components/bottomSheetDebugView/BottomSheetDebugView.tsx +26 -0
  23. package/src/components/bottomSheetDebugView/ReText.tsx +72 -0
  24. package/src/components/bottomSheetDebugView/ReText.webx.tsx +55 -0
  25. package/src/components/bottomSheetDebugView/index.ts +1 -0
  26. package/src/components/bottomSheetDebugView/styles.ts +19 -0
  27. package/src/components/bottomSheetDebugView/styles.web.ts +20 -0
  28. package/src/components/bottomSheetDraggableView/BottomSheetDraggableView.tsx +123 -0
  29. package/src/components/bottomSheetDraggableView/index.ts +1 -0
  30. package/src/components/bottomSheetDraggableView/types.d.ts +9 -0
  31. package/src/components/bottomSheetFooter/BottomSheetFooter.tsx +119 -0
  32. package/src/components/bottomSheetFooter/BottomSheetFooterContainer.tsx +43 -0
  33. package/src/components/bottomSheetFooter/index.ts +3 -0
  34. package/src/components/bottomSheetFooter/styles.ts +12 -0
  35. package/src/components/bottomSheetFooter/types.d.ts +41 -0
  36. package/src/components/bottomSheetGestureHandlersProvider/BottomSheetGestureHandlersProvider.tsx +69 -0
  37. package/src/components/bottomSheetGestureHandlersProvider/index.ts +1 -0
  38. package/src/components/bottomSheetGestureHandlersProvider/types.d.ts +8 -0
  39. package/src/components/bottomSheetHandle/BottomSheetHandle.tsx +51 -0
  40. package/src/components/bottomSheetHandle/BottomSheetHandleContainer.tsx +187 -0
  41. package/src/components/bottomSheetHandle/constants.ts +12 -0
  42. package/src/components/bottomSheetHandle/index.ts +6 -0
  43. package/src/components/bottomSheetHandle/styles.ts +23 -0
  44. package/src/components/bottomSheetHandle/types.d.ts +52 -0
  45. package/src/components/bottomSheetHostingContainer/BottomSheetHostingContainer.tsx +130 -0
  46. package/src/components/bottomSheetHostingContainer/index.ts +2 -0
  47. package/src/components/bottomSheetHostingContainer/styles.ts +5 -0
  48. package/src/components/bottomSheetHostingContainer/styles.web.ts +11 -0
  49. package/src/components/bottomSheetHostingContainer/types.d.ts +17 -0
  50. package/src/components/bottomSheetModal/BottomSheetModal.tsx +482 -0
  51. package/src/components/bottomSheetModal/constants.ts +4 -0
  52. package/src/components/bottomSheetModal/index.ts +6 -0
  53. package/src/components/bottomSheetModal/types.d.ts +67 -0
  54. package/src/components/bottomSheetModalProvider/BottomSheetModalProvider.tsx +211 -0
  55. package/src/components/bottomSheetModalProvider/index.ts +1 -0
  56. package/src/components/bottomSheetModalProvider/types.d.ts +12 -0
  57. package/src/components/bottomSheetRefreshControl/BottomSheetRefreshControl.android.tsx +84 -0
  58. package/src/components/bottomSheetRefreshControl/BottomSheetRefreshControl.tsx +1 -0
  59. package/src/components/bottomSheetRefreshControl/index.ts +20 -0
  60. package/src/components/bottomSheetScrollable/BottomSheetDraggableScrollable.tsx +23 -0
  61. package/src/components/bottomSheetScrollable/BottomSheetFlashList.tsx +88 -0
  62. package/src/components/bottomSheetScrollable/BottomSheetFlashList.web.tsx +1 -0
  63. package/src/components/bottomSheetScrollable/BottomSheetFlatList.tsx +26 -0
  64. package/src/components/bottomSheetScrollable/BottomSheetScrollView.tsx +27 -0
  65. package/src/components/bottomSheetScrollable/BottomSheetSectionList.tsx +29 -0
  66. package/src/components/bottomSheetScrollable/BottomSheetVirtualizedList.tsx +27 -0
  67. package/src/components/bottomSheetScrollable/ScrollableContainer.android.tsx +55 -0
  68. package/src/components/bottomSheetScrollable/ScrollableContainer.tsx +22 -0
  69. package/src/components/bottomSheetScrollable/ScrollableContainer.web.tsx +102 -0
  70. package/src/components/bottomSheetScrollable/createBottomSheetScrollableComponent.tsx +153 -0
  71. package/src/components/bottomSheetScrollable/index.ts +15 -0
  72. package/src/components/bottomSheetScrollable/styles.ts +8 -0
  73. package/src/components/bottomSheetScrollable/types.d.ts +280 -0
  74. package/src/components/bottomSheetScrollable/useBottomSheetContentSizeSetter.ts +32 -0
  75. package/src/components/bottomSheetTextInput/BottomSheetTextInput.tsx +127 -0
  76. package/src/components/bottomSheetTextInput/index.ts +2 -0
  77. package/src/components/bottomSheetTextInput/types.ts +3 -0
  78. package/src/components/bottomSheetView/BottomSheetView.tsx +93 -0
  79. package/src/components/bottomSheetView/index.ts +1 -0
  80. package/src/components/bottomSheetView/styles.ts +10 -0
  81. package/src/components/bottomSheetView/types.d.ts +24 -0
  82. package/src/components/touchables/Touchables.ios.tsx +5 -0
  83. package/src/components/touchables/Touchables.tsx +5 -0
  84. package/src/components/touchables/index.ts +20 -0
  85. package/src/constants.ts +159 -0
  86. package/src/contexts/external.ts +8 -0
  87. package/src/contexts/gesture.ts +13 -0
  88. package/src/contexts/index.ts +15 -0
  89. package/src/contexts/internal.ts +65 -0
  90. package/src/contexts/modal/external.ts +11 -0
  91. package/src/contexts/modal/internal.ts +25 -0
  92. package/src/hooks/index.ts +29 -0
  93. package/src/hooks/useAnimatedDetents.ts +119 -0
  94. package/src/hooks/useAnimatedKeyboard.ts +174 -0
  95. package/src/hooks/useAnimatedLayout.ts +109 -0
  96. package/src/hooks/useBottomSheet.ts +12 -0
  97. package/src/hooks/useBottomSheetContentContainerStyle.ts +88 -0
  98. package/src/hooks/useBottomSheetGestureHandlers.ts +12 -0
  99. package/src/hooks/useBottomSheetInternal.ts +25 -0
  100. package/src/hooks/useBottomSheetModal.ts +12 -0
  101. package/src/hooks/useBottomSheetModalInternal.ts +25 -0
  102. package/src/hooks/useBottomSheetScrollableCreator.tsx +60 -0
  103. package/src/hooks/useBottomSheetSpringConfigs.ts +11 -0
  104. package/src/hooks/useBottomSheetTimingConfigs.ts +36 -0
  105. package/src/hooks/useBoundingClientRect.ts +77 -0
  106. package/src/hooks/useGestureEventsHandlersDefault.tsx +436 -0
  107. package/src/hooks/useGestureEventsHandlersDefault.web.tsx +418 -0
  108. package/src/hooks/useGestureHandler.ts +90 -0
  109. package/src/hooks/usePropsValidator.ts +108 -0
  110. package/src/hooks/useReactiveSharedValue.ts +45 -0
  111. package/src/hooks/useScrollEventsHandlersDefault.ts +167 -0
  112. package/src/hooks/useScrollHandler.ts +72 -0
  113. package/src/hooks/useScrollHandler.web.ts +181 -0
  114. package/src/hooks/useScrollable.ts +131 -0
  115. package/src/hooks/useScrollableSetter.ts +56 -0
  116. package/src/hooks/useStableCallback.ts +26 -0
  117. package/src/index.ts +79 -0
  118. package/src/types.d.ts +336 -0
  119. package/src/utilities/animate.ts +56 -0
  120. package/src/utilities/clamp.ts +8 -0
  121. package/src/utilities/easingExp.ts +10 -0
  122. package/src/utilities/findNodeHandle.ts +1 -0
  123. package/src/utilities/findNodeHandle.web.ts +33 -0
  124. package/src/utilities/getKeyboardAnimationConfigs.ts +44 -0
  125. package/src/utilities/getRefNativeTag.web.ts +6 -0
  126. package/src/utilities/id.ts +6 -0
  127. package/src/utilities/index.ts +7 -0
  128. package/src/utilities/isFabricInstalled.ts +9 -0
  129. package/src/utilities/logger.ts +55 -0
  130. package/src/utilities/noop.ts +7 -0
  131. package/src/utilities/normalizeSnapPoint.ts +17 -0
  132. package/src/utilities/snapPoint.ts +11 -0
  133. package/src/utilities/validateSnapPoint.ts +20 -0
@@ -0,0 +1,127 @@
1
+ import React, {
2
+ forwardRef,
3
+ memo,
4
+ useCallback,
5
+ useEffect,
6
+ useImperativeHandle,
7
+ useRef,
8
+ } from 'react';
9
+ import type {
10
+ NativeSyntheticEvent,
11
+ TextInputFocusEventData,
12
+ } from 'react-native';
13
+ import { TextInput as RNTextInput } from 'react-native';
14
+ import { TextInput } from 'react-native-gesture-handler';
15
+ import { useBottomSheetInternal } from '../../hooks';
16
+ import { findNodeHandle } from '../../utilities';
17
+ import type { BottomSheetTextInputProps } from './types';
18
+
19
+ const BottomSheetTextInputComponent = forwardRef<
20
+ TextInput | undefined,
21
+ BottomSheetTextInputProps
22
+ >(({ onFocus, onBlur, ...rest }, providedRef) => {
23
+ //#region refs
24
+ const ref = useRef<TextInput>(null);
25
+ //#endregion
26
+
27
+ //#region hooks
28
+ const { animatedKeyboardState, textInputNodesRef } = useBottomSheetInternal();
29
+ //#endregion
30
+
31
+ //#region callbacks
32
+ const handleOnFocus = useCallback(
33
+ (args: NativeSyntheticEvent<TextInputFocusEventData>) => {
34
+ animatedKeyboardState.set(state => ({
35
+ ...state,
36
+ target: args.nativeEvent.target,
37
+ }));
38
+ if (onFocus) {
39
+ onFocus(args);
40
+ }
41
+ },
42
+ [onFocus, animatedKeyboardState]
43
+ );
44
+ const handleOnBlur = useCallback(
45
+ (args: NativeSyntheticEvent<TextInputFocusEventData>) => {
46
+ const keyboardState = animatedKeyboardState.get();
47
+ const currentFocusedInput = findNodeHandle(
48
+ RNTextInput.State.currentlyFocusedInput()
49
+ );
50
+
51
+ /**
52
+ * we need to make sure that we only remove the target
53
+ * if the target belong to the current component and
54
+ * if the currently focused input is not in the targets set.
55
+ */
56
+ const shouldRemoveCurrentTarget =
57
+ keyboardState.target === args.nativeEvent.target;
58
+ const shouldIgnoreBlurEvent =
59
+ currentFocusedInput &&
60
+ textInputNodesRef.current.has(currentFocusedInput);
61
+
62
+ if (shouldRemoveCurrentTarget && !shouldIgnoreBlurEvent) {
63
+ animatedKeyboardState.set(state => ({
64
+ ...state,
65
+ target: undefined,
66
+ }));
67
+ }
68
+
69
+ if (onBlur) {
70
+ onBlur(args);
71
+ }
72
+ },
73
+ [onBlur, animatedKeyboardState, textInputNodesRef]
74
+ );
75
+ //#endregion
76
+
77
+ //#region effects
78
+ useEffect(() => {
79
+ const componentNode = findNodeHandle(ref.current);
80
+ if (!componentNode) {
81
+ return;
82
+ }
83
+
84
+ if (!textInputNodesRef.current.has(componentNode)) {
85
+ textInputNodesRef.current.add(componentNode);
86
+ }
87
+
88
+ return () => {
89
+ const componentNode = findNodeHandle(ref.current);
90
+ if (!componentNode) {
91
+ return;
92
+ }
93
+
94
+ const keyboardState = animatedKeyboardState.get();
95
+ /**
96
+ * remove the keyboard state target if it belong
97
+ * to the current component.
98
+ */
99
+ if (keyboardState.target === componentNode) {
100
+ animatedKeyboardState.set(state => ({
101
+ ...state,
102
+ target: undefined,
103
+ }));
104
+ }
105
+
106
+ if (textInputNodesRef.current.has(componentNode)) {
107
+ textInputNodesRef.current.delete(componentNode);
108
+ }
109
+ };
110
+ }, [textInputNodesRef, animatedKeyboardState]);
111
+ useImperativeHandle(providedRef, () => ref.current ?? undefined, []);
112
+ //#endregion
113
+
114
+ return (
115
+ <TextInput
116
+ ref={ref}
117
+ onFocus={handleOnFocus}
118
+ onBlur={handleOnBlur}
119
+ {...rest}
120
+ />
121
+ );
122
+ });
123
+
124
+ const BottomSheetTextInput = memo(BottomSheetTextInputComponent);
125
+ BottomSheetTextInput.displayName = 'BottomSheetTextInput';
126
+
127
+ export default BottomSheetTextInput;
@@ -0,0 +1,2 @@
1
+ export { default } from './BottomSheetTextInput';
2
+ export type { BottomSheetTextInputProps } from './types';
@@ -0,0 +1,3 @@
1
+ import type { TextInputProps } from 'react-native';
2
+
3
+ export interface BottomSheetTextInputProps extends TextInputProps {}
@@ -0,0 +1,93 @@
1
+ import React, { memo, useEffect, useCallback, useMemo } from 'react';
2
+ import { type LayoutChangeEvent, View } from 'react-native';
3
+ import { SCROLLABLE_TYPE } from '../../constants';
4
+ import {
5
+ useBottomSheetContentContainerStyle,
6
+ useBottomSheetInternal,
7
+ } from '../../hooks';
8
+ import { print } from '../../utilities';
9
+ import { styles } from './styles';
10
+ import type { BottomSheetViewProps } from './types';
11
+
12
+ function BottomSheetViewComponent({
13
+ focusHook: useFocusHook = useEffect,
14
+ enableFooterMarginAdjustment = false,
15
+ onLayout,
16
+ style: _providedStyle,
17
+ children,
18
+ ...rest
19
+ }: BottomSheetViewProps) {
20
+ //#region hooks
21
+ const { animatedScrollableState, enableDynamicSizing, animatedLayoutState } =
22
+ useBottomSheetInternal();
23
+ //#endregion
24
+
25
+ //#region styles
26
+ const containerStyle = useBottomSheetContentContainerStyle(
27
+ enableFooterMarginAdjustment,
28
+ _providedStyle
29
+ );
30
+ const style = useMemo(
31
+ () => [containerStyle, styles.container],
32
+ [containerStyle]
33
+ );
34
+ //#endregion
35
+
36
+ //#region callbacks
37
+ const handleSettingScrollable = useCallback(() => {
38
+ animatedScrollableState.set(state => ({
39
+ ...state,
40
+ contentOffsetY: 0,
41
+ type: SCROLLABLE_TYPE.VIEW,
42
+ }));
43
+ }, [animatedScrollableState]);
44
+ const handleLayout = useCallback(
45
+ (event: LayoutChangeEvent) => {
46
+ if (enableDynamicSizing) {
47
+ const {
48
+ nativeEvent: {
49
+ layout: { height },
50
+ },
51
+ } = event;
52
+ animatedLayoutState.modify(state => {
53
+ 'worklet';
54
+ state.contentHeight = height;
55
+ return state;
56
+ });
57
+ }
58
+
59
+ if (onLayout) {
60
+ onLayout(event);
61
+ }
62
+
63
+ if (__DEV__) {
64
+ print({
65
+ component: 'BottomSheetView',
66
+ method: 'handleLayout',
67
+ category: 'layout',
68
+ params: {
69
+ height: event.nativeEvent.layout.height,
70
+ },
71
+ });
72
+ }
73
+ },
74
+ [onLayout, animatedLayoutState, enableDynamicSizing]
75
+ );
76
+ //#endregion
77
+
78
+ //#region effects
79
+ useFocusHook(handleSettingScrollable);
80
+ //#endregion
81
+
82
+ //render
83
+ return (
84
+ <View {...rest} onLayout={handleLayout} style={style}>
85
+ {children}
86
+ </View>
87
+ );
88
+ }
89
+
90
+ const BottomSheetView = memo(BottomSheetViewComponent);
91
+ BottomSheetView.displayName = 'BottomSheetView';
92
+
93
+ export default BottomSheetView;
@@ -0,0 +1 @@
1
+ export { default } from './BottomSheetView';
@@ -0,0 +1,10 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const styles = StyleSheet.create({
4
+ container: {
5
+ position: 'absolute',
6
+ left: 0,
7
+ top: 0,
8
+ right: 0,
9
+ },
10
+ });
@@ -0,0 +1,24 @@
1
+ import type { DependencyList, EffectCallback, ReactNode } from 'react';
2
+ import type { ViewProps as RNViewProps } from 'react-native';
3
+
4
+ export interface BottomSheetViewProps extends RNViewProps {
5
+ /**
6
+ * Adjust the scrollable bottom margin to avoid the animated footer.
7
+ *
8
+ * @type boolean
9
+ * @default false
10
+ */
11
+ enableFooterMarginAdjustment?: boolean;
12
+
13
+ /**
14
+ * This needed when bottom sheet used with multiple scrollables to allow bottom sheet
15
+ * detect the current scrollable ref, especially when used with `React Navigation`.
16
+ * You will need to provide `useFocusEffect` from `@react-navigation/native`.
17
+ *
18
+ * @type (effect: EffectCallback, deps?: DependencyList) => void
19
+ * @default useEffect
20
+ */
21
+ focusHook?: (effect: EffectCallback, deps?: DependencyList) => void;
22
+
23
+ children: ReactNode[] | ReactNode;
24
+ }
@@ -0,0 +1,5 @@
1
+ export {
2
+ TouchableOpacity,
3
+ TouchableHighlight,
4
+ TouchableWithoutFeedback,
5
+ } from 'react-native';
@@ -0,0 +1,5 @@
1
+ export {
2
+ TouchableOpacity,
3
+ TouchableHighlight,
4
+ TouchableWithoutFeedback,
5
+ } from 'react-native-gesture-handler';
@@ -0,0 +1,20 @@
1
+ import type {
2
+ TouchableHighlight as RNTouchableHighlight,
3
+ TouchableOpacity as RNTouchableOpacity,
4
+ TouchableWithoutFeedback as RNTouchableWithoutFeedback,
5
+ } from 'react-native';
6
+
7
+ import {
8
+ TouchableHighlight,
9
+ TouchableOpacity,
10
+ TouchableWithoutFeedback,
11
+ // @ts-ignore
12
+ } from './Touchables';
13
+
14
+ export default {
15
+ TouchableOpacity: TouchableOpacity as never as typeof RNTouchableOpacity,
16
+ TouchableHighlight:
17
+ TouchableHighlight as never as typeof RNTouchableHighlight,
18
+ TouchableWithoutFeedback:
19
+ TouchableWithoutFeedback as never as typeof RNTouchableWithoutFeedback,
20
+ };
@@ -0,0 +1,159 @@
1
+ import { Dimensions, Platform } from 'react-native';
2
+ import { Easing } from 'react-native-reanimated';
3
+ import type { SpringConfig, TimingConfig } from './types';
4
+
5
+ const { height: WINDOW_HEIGHT, width: WINDOW_WIDTH } = Dimensions.get('window');
6
+ const { height: SCREEN_HEIGHT, width: SCREEN_WIDTH } = Dimensions.get('screen');
7
+
8
+ enum GESTURE_SOURCE {
9
+ UNDETERMINED = 0,
10
+ SCROLLABLE = 1,
11
+ HANDLE = 2,
12
+ CONTENT = 3,
13
+ }
14
+
15
+ enum SHEET_STATE {
16
+ CLOSED = 0,
17
+ OPENED = 1,
18
+ EXTENDED = 2,
19
+ OVER_EXTENDED = 3,
20
+ FILL_PARENT = 4,
21
+ }
22
+
23
+ enum SCROLLABLE_STATUS {
24
+ LOCKED = 0,
25
+ UNLOCKED = 1,
26
+ UNDETERMINED = 2,
27
+ }
28
+
29
+ enum SCROLLABLE_TYPE {
30
+ UNDETERMINED = 0,
31
+ VIEW = 1,
32
+ FLATLIST = 2,
33
+ SCROLLVIEW = 3,
34
+ SECTIONLIST = 4,
35
+ VIRTUALIZEDLIST = 5,
36
+ }
37
+
38
+ enum ANIMATION_STATUS {
39
+ UNDETERMINED = 0,
40
+ RUNNING = 1,
41
+ STOPPED = 2,
42
+ INTERRUPTED = 3,
43
+ }
44
+
45
+ enum ANIMATION_SOURCE {
46
+ NONE = 0,
47
+ MOUNT = 1,
48
+ GESTURE = 2,
49
+ USER = 3,
50
+ CONTAINER_RESIZE = 4,
51
+ SNAP_POINT_CHANGE = 5,
52
+ KEYBOARD = 6,
53
+ }
54
+
55
+ enum ANIMATION_METHOD {
56
+ TIMING = 0,
57
+ SPRING = 1,
58
+ }
59
+
60
+ enum KEYBOARD_STATUS {
61
+ UNDETERMINED = 0,
62
+ SHOWN = 1,
63
+ HIDDEN = 2,
64
+ }
65
+
66
+ enum SNAP_POINT_TYPE {
67
+ PROVIDED = 0,
68
+ DYNAMIC = 1,
69
+ }
70
+
71
+ const ANIMATION_EASING = Easing.out(Easing.exp);
72
+ const ANIMATION_DURATION = 250;
73
+
74
+ const ANIMATION_CONFIGS = Platform.select<TimingConfig | SpringConfig>({
75
+ android: {
76
+ duration: ANIMATION_DURATION,
77
+ easing: ANIMATION_EASING,
78
+ },
79
+ default: {
80
+ damping: 500,
81
+ stiffness: 1000,
82
+ mass: 3,
83
+ overshootClamping: true,
84
+ restDisplacementThreshold: 10,
85
+ restSpeedThreshold: 10,
86
+ },
87
+ });
88
+
89
+ const SCROLLABLE_DECELERATION_RATE_MAPPER = {
90
+ [SCROLLABLE_STATUS.UNDETERMINED]: 0,
91
+ [SCROLLABLE_STATUS.LOCKED]: 0,
92
+ [SCROLLABLE_STATUS.UNLOCKED]: Platform.select({
93
+ ios: 0.998,
94
+ android: 0.985,
95
+ default: 1,
96
+ }),
97
+ };
98
+
99
+ const MODAL_STACK_BEHAVIOR = {
100
+ replace: 'replace',
101
+ push: 'push',
102
+ switch: 'switch',
103
+ };
104
+
105
+ const KEYBOARD_BEHAVIOR = {
106
+ interactive: 'interactive',
107
+ extend: 'extend',
108
+ fillParent: 'fillParent',
109
+ } as const;
110
+
111
+ const KEYBOARD_BLUR_BEHAVIOR = {
112
+ none: 'none',
113
+ restore: 'restore',
114
+ } as const;
115
+
116
+ const KEYBOARD_INPUT_MODE = {
117
+ adjustPan: 'adjustPan',
118
+ adjustResize: 'adjustResize',
119
+ } as const;
120
+
121
+ const KEYBOARD_DISMISS_THRESHOLD = 12.5;
122
+
123
+ const INITIAL_LAYOUT_VALUE = -999;
124
+ const INITIAL_CONTAINER_LAYOUT = {
125
+ height: INITIAL_LAYOUT_VALUE,
126
+ offset: {
127
+ top: 0,
128
+ bottom: 0,
129
+ right: 0,
130
+ left: 0,
131
+ },
132
+ };
133
+
134
+ export {
135
+ GESTURE_SOURCE,
136
+ SHEET_STATE,
137
+ ANIMATION_STATUS,
138
+ ANIMATION_METHOD,
139
+ ANIMATION_SOURCE,
140
+ SCROLLABLE_TYPE,
141
+ SCROLLABLE_STATUS,
142
+ KEYBOARD_STATUS,
143
+ SNAP_POINT_TYPE,
144
+ WINDOW_HEIGHT,
145
+ WINDOW_WIDTH,
146
+ SCREEN_HEIGHT,
147
+ SCREEN_WIDTH,
148
+ SCROLLABLE_DECELERATION_RATE_MAPPER,
149
+ MODAL_STACK_BEHAVIOR,
150
+ KEYBOARD_BEHAVIOR,
151
+ KEYBOARD_BLUR_BEHAVIOR,
152
+ KEYBOARD_INPUT_MODE,
153
+ KEYBOARD_DISMISS_THRESHOLD,
154
+ ANIMATION_CONFIGS,
155
+ ANIMATION_EASING,
156
+ ANIMATION_DURATION,
157
+ INITIAL_LAYOUT_VALUE,
158
+ INITIAL_CONTAINER_LAYOUT,
159
+ };
@@ -0,0 +1,8 @@
1
+ import { createContext } from 'react';
2
+ import type { BottomSheetMethods, BottomSheetVariables } from '../types';
3
+
4
+ export const BottomSheetContext = createContext<
5
+ (BottomSheetMethods & BottomSheetVariables) | null
6
+ >(null);
7
+
8
+ export const BottomSheetProvider = BottomSheetContext.Provider;
@@ -0,0 +1,13 @@
1
+ import { createContext } from 'react';
2
+ import type { Gesture } from 'react-native-gesture-handler/lib/typescript/handlers/gestures/gesture';
3
+ import type { GestureHandlersHookType } from '../types';
4
+
5
+ export interface BottomSheetGestureHandlersContextType {
6
+ contentPanGestureHandler: ReturnType<GestureHandlersHookType>;
7
+ handlePanGestureHandler: ReturnType<GestureHandlersHookType>;
8
+ }
9
+
10
+ export const BottomSheetGestureHandlersContext =
11
+ createContext<BottomSheetGestureHandlersContextType | null>(null);
12
+
13
+ export const BottomSheetDraggableContext = createContext<Gesture | null>(null);
@@ -0,0 +1,15 @@
1
+ export { BottomSheetContext, BottomSheetProvider } from './external';
2
+ export {
3
+ BottomSheetInternalContext,
4
+ BottomSheetInternalProvider,
5
+ } from './internal';
6
+ export { BottomSheetGestureHandlersContext } from './gesture';
7
+ export {
8
+ BottomSheetModalContext,
9
+ BottomSheetModalProvider,
10
+ } from './modal/external';
11
+ export {
12
+ BottomSheetModalInternalContext,
13
+ BottomSheetModalInternalProvider,
14
+ } from './modal/internal';
15
+ export type { BottomSheetModalInternalContextType } from './modal/internal';
@@ -0,0 +1,65 @@
1
+ import { createContext, type RefObject } from 'react';
2
+ import type { State } from 'react-native-gesture-handler';
3
+ import type { SharedValue } from 'react-native-reanimated';
4
+ import type {
5
+ AnimateToPositionType,
6
+ BottomSheetGestureProps,
7
+ BottomSheetProps,
8
+ } from '../components/bottomSheet/types';
9
+ import type { SCROLLABLE_STATUS, SHEET_STATE } from '../constants';
10
+ import type {
11
+ AnimationState,
12
+ DetentsState,
13
+ KeyboardState,
14
+ LayoutState,
15
+ Scrollable,
16
+ ScrollableRef,
17
+ ScrollableState,
18
+ } from '../types';
19
+
20
+ export interface BottomSheetInternalContextType
21
+ extends Partial<BottomSheetGestureProps>,
22
+ Required<
23
+ Pick<
24
+ BottomSheetProps,
25
+ | 'enableContentPanningGesture'
26
+ | 'enableOverDrag'
27
+ | 'enablePanDownToClose'
28
+ | 'enableDynamicSizing'
29
+ | 'enableBlurKeyboardOnGesture'
30
+ | 'overDragResistanceFactor'
31
+ >
32
+ > {
33
+ // animated states
34
+ animatedDetentsState: SharedValue<DetentsState>;
35
+ animatedAnimationState: SharedValue<AnimationState>;
36
+ animatedSheetState: SharedValue<SHEET_STATE>;
37
+ animatedKeyboardState: SharedValue<KeyboardState>;
38
+ animatedContentGestureState: SharedValue<State>;
39
+ animatedHandleGestureState: SharedValue<State>;
40
+ animatedLayoutState: SharedValue<LayoutState>;
41
+
42
+ // scrollable
43
+ animatedScrollableState: SharedValue<ScrollableState>;
44
+ animatedScrollableStatus: SharedValue<SCROLLABLE_STATUS>;
45
+
46
+ // animated values
47
+ animatedPosition: SharedValue<number>;
48
+ animatedIndex: SharedValue<number>;
49
+ animatedSheetHeight: SharedValue<number>;
50
+ isInTemporaryPosition: SharedValue<boolean>;
51
+
52
+ // methods
53
+ stopAnimation: () => void;
54
+ animateToPosition: AnimateToPositionType;
55
+ setScrollableRef: (ref: ScrollableRef) => void;
56
+ removeScrollableRef: (ref: RefObject<Scrollable>) => void;
57
+
58
+ // refs
59
+ textInputNodesRef: React.MutableRefObject<Set<number>>;
60
+ }
61
+
62
+ export const BottomSheetInternalContext =
63
+ createContext<BottomSheetInternalContextType | null>(null);
64
+
65
+ export const BottomSheetInternalProvider = BottomSheetInternalContext.Provider;
@@ -0,0 +1,11 @@
1
+ import { createContext } from 'react';
2
+
3
+ export interface BottomSheetModalContextType {
4
+ dismiss: (key?: string) => boolean;
5
+ dismissAll: () => void;
6
+ }
7
+
8
+ export const BottomSheetModalContext =
9
+ createContext<BottomSheetModalContextType | null>(null);
10
+
11
+ export const BottomSheetModalProvider = BottomSheetModalContext.Provider;
@@ -0,0 +1,25 @@
1
+ import { type RefObject, createContext } from 'react';
2
+ import type { SharedValue } from 'react-native-reanimated';
3
+ import type {
4
+ BottomSheetModalPrivateMethods,
5
+ BottomSheetModalStackBehavior,
6
+ } from '../../components/bottomSheetModal';
7
+ import type { ContainerLayoutState } from '../../types';
8
+
9
+ export interface BottomSheetModalInternalContextType {
10
+ hostName: string;
11
+ containerLayoutState: SharedValue<ContainerLayoutState>;
12
+ mountSheet: (
13
+ key: string,
14
+ ref: RefObject<BottomSheetModalPrivateMethods>,
15
+ stackBehavior: BottomSheetModalStackBehavior
16
+ ) => void;
17
+ unmountSheet: (key: string) => void;
18
+ willUnmountSheet: (key: string) => void;
19
+ }
20
+
21
+ export const BottomSheetModalInternalContext =
22
+ createContext<BottomSheetModalInternalContextType | null>(null);
23
+
24
+ export const BottomSheetModalInternalProvider =
25
+ BottomSheetModalInternalContext.Provider;
@@ -0,0 +1,29 @@
1
+ export { useBottomSheet } from './useBottomSheet';
2
+ export { useBottomSheetInternal } from './useBottomSheetInternal';
3
+
4
+ // modal
5
+ export { useBottomSheetModal } from './useBottomSheetModal';
6
+ export { useBottomSheetModalInternal } from './useBottomSheetModalInternal';
7
+
8
+ // scrollable
9
+ export { useScrollable } from './useScrollable';
10
+ export { useScrollableSetter } from './useScrollableSetter';
11
+ export { useScrollHandler } from './useScrollHandler';
12
+
13
+ // gestures
14
+ export { useGestureHandler } from './useGestureHandler';
15
+ export { useGestureEventsHandlersDefault } from './useGestureEventsHandlersDefault';
16
+ export { useBottomSheetGestureHandlers } from './useBottomSheetGestureHandlers';
17
+
18
+ // utilities
19
+ export { useAnimatedLayout } from './useAnimatedLayout';
20
+ export { useAnimatedKeyboard } from './useAnimatedKeyboard';
21
+ export { useStableCallback } from './useStableCallback';
22
+ export { usePropsValidator } from './usePropsValidator';
23
+ export { useAnimatedDetents } from './useAnimatedDetents';
24
+ export { useReactiveSharedValue } from './useReactiveSharedValue';
25
+ export {
26
+ useBoundingClientRect,
27
+ type BoundingClientRect,
28
+ } from './useBoundingClientRect';
29
+ export { useBottomSheetContentContainerStyle } from './useBottomSheetContentContainerStyle';