@shaquillehinds/react-native-bottom-sheet 0.0.1

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 (187) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +880 -0
  3. package/lib/commonjs/BottomSheet/animations/drag.animation.js +72 -0
  4. package/lib/commonjs/BottomSheet/animations/drag.animation.js.map +1 -0
  5. package/lib/commonjs/BottomSheet/components/BottomSheet.js +92 -0
  6. package/lib/commonjs/BottomSheet/components/BottomSheet.js.map +1 -0
  7. package/lib/commonjs/BottomSheet/components/BottomSheetFlatlist.js +38 -0
  8. package/lib/commonjs/BottomSheet/components/BottomSheetFlatlist.js.map +1 -0
  9. package/lib/commonjs/BottomSheet/components/BottomSheetModal.js +34 -0
  10. package/lib/commonjs/BottomSheet/components/BottomSheetModal.js.map +1 -0
  11. package/lib/commonjs/BottomSheet/components/BottomSheetScrollView.js +37 -0
  12. package/lib/commonjs/BottomSheet/components/BottomSheetScrollView.js.map +1 -0
  13. package/lib/commonjs/BottomSheet/config/bottomSheet.constants.js +35 -0
  14. package/lib/commonjs/BottomSheet/config/bottomSheet.constants.js.map +1 -0
  15. package/lib/commonjs/BottomSheet/config/bottomSheet.styles.js +42 -0
  16. package/lib/commonjs/BottomSheet/config/bottomSheet.styles.js.map +1 -0
  17. package/lib/commonjs/BottomSheet/config/bottomSheet.types.js +14 -0
  18. package/lib/commonjs/BottomSheet/config/bottomSheet.types.js.map +1 -0
  19. package/lib/commonjs/BottomSheet/controller/bottomFlatlist.controller.js +69 -0
  20. package/lib/commonjs/BottomSheet/controller/bottomFlatlist.controller.js.map +1 -0
  21. package/lib/commonjs/BottomSheet/controller/bottomScrollView.controller.js +41 -0
  22. package/lib/commonjs/BottomSheet/controller/bottomScrollView.controller.js.map +1 -0
  23. package/lib/commonjs/BottomSheet/controller/bottomSheet.controller.js +216 -0
  24. package/lib/commonjs/BottomSheet/controller/bottomSheet.controller.js.map +1 -0
  25. package/lib/commonjs/BottomSheet/controller/callbacks.controller.js +135 -0
  26. package/lib/commonjs/BottomSheet/controller/callbacks.controller.js.map +1 -0
  27. package/lib/commonjs/BottomSheet/controller/dragAnimation.controller.js +127 -0
  28. package/lib/commonjs/BottomSheet/controller/dragAnimation.controller.js.map +1 -0
  29. package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetRef.js +60 -0
  30. package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetRef.js.map +1 -0
  31. package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetUtils.js +74 -0
  32. package/lib/commonjs/BottomSheet/controller/hooks/useBottomSheetUtils.js.map +1 -0
  33. package/lib/commonjs/BottomSheet/controller/index.js +17 -0
  34. package/lib/commonjs/BottomSheet/controller/index.js.map +1 -0
  35. package/lib/commonjs/BottomSheet/controller/keyboardAnimation.controller.js +88 -0
  36. package/lib/commonjs/BottomSheet/controller/keyboardAnimation.controller.js.map +1 -0
  37. package/lib/commonjs/BottomSheet/controller/scrollContent.controller.js +89 -0
  38. package/lib/commonjs/BottomSheet/controller/scrollContent.controller.js.map +1 -0
  39. package/lib/commonjs/BottomSheet/index.js +130 -0
  40. package/lib/commonjs/BottomSheet/index.js.map +1 -0
  41. package/lib/commonjs/index.js +17 -0
  42. package/lib/commonjs/index.js.map +1 -0
  43. package/lib/commonjs/package.json +1 -0
  44. package/lib/module/BottomSheet/animations/drag.animation.js +68 -0
  45. package/lib/module/BottomSheet/animations/drag.animation.js.map +1 -0
  46. package/lib/module/BottomSheet/components/BottomSheet.js +87 -0
  47. package/lib/module/BottomSheet/components/BottomSheet.js.map +1 -0
  48. package/lib/module/BottomSheet/components/BottomSheetFlatlist.js +32 -0
  49. package/lib/module/BottomSheet/components/BottomSheetFlatlist.js.map +1 -0
  50. package/lib/module/BottomSheet/components/BottomSheetModal.js +30 -0
  51. package/lib/module/BottomSheet/components/BottomSheetModal.js.map +1 -0
  52. package/lib/module/BottomSheet/components/BottomSheetScrollView.js +31 -0
  53. package/lib/module/BottomSheet/components/BottomSheetScrollView.js.map +1 -0
  54. package/lib/module/BottomSheet/config/bottomSheet.constants.js +30 -0
  55. package/lib/module/BottomSheet/config/bottomSheet.constants.js.map +1 -0
  56. package/lib/module/BottomSheet/config/bottomSheet.styles.js +38 -0
  57. package/lib/module/BottomSheet/config/bottomSheet.styles.js.map +1 -0
  58. package/lib/module/BottomSheet/config/bottomSheet.types.js +10 -0
  59. package/lib/module/BottomSheet/config/bottomSheet.types.js.map +1 -0
  60. package/lib/module/BottomSheet/controller/bottomFlatlist.controller.js +64 -0
  61. package/lib/module/BottomSheet/controller/bottomFlatlist.controller.js.map +1 -0
  62. package/lib/module/BottomSheet/controller/bottomScrollView.controller.js +37 -0
  63. package/lib/module/BottomSheet/controller/bottomScrollView.controller.js.map +1 -0
  64. package/lib/module/BottomSheet/controller/bottomSheet.controller.js +212 -0
  65. package/lib/module/BottomSheet/controller/bottomSheet.controller.js.map +1 -0
  66. package/lib/module/BottomSheet/controller/callbacks.controller.js +130 -0
  67. package/lib/module/BottomSheet/controller/callbacks.controller.js.map +1 -0
  68. package/lib/module/BottomSheet/controller/dragAnimation.controller.js +122 -0
  69. package/lib/module/BottomSheet/controller/dragAnimation.controller.js.map +1 -0
  70. package/lib/module/BottomSheet/controller/hooks/useBottomSheetRef.js +56 -0
  71. package/lib/module/BottomSheet/controller/hooks/useBottomSheetRef.js.map +1 -0
  72. package/lib/module/BottomSheet/controller/hooks/useBottomSheetUtils.js +70 -0
  73. package/lib/module/BottomSheet/controller/hooks/useBottomSheetUtils.js.map +1 -0
  74. package/lib/module/BottomSheet/controller/index.js +4 -0
  75. package/lib/module/BottomSheet/controller/index.js.map +1 -0
  76. package/lib/module/BottomSheet/controller/keyboardAnimation.controller.js +84 -0
  77. package/lib/module/BottomSheet/controller/keyboardAnimation.controller.js.map +1 -0
  78. package/lib/module/BottomSheet/controller/scrollContent.controller.js +84 -0
  79. package/lib/module/BottomSheet/controller/scrollContent.controller.js.map +1 -0
  80. package/lib/module/BottomSheet/index.js +112 -0
  81. package/lib/module/BottomSheet/index.js.map +1 -0
  82. package/lib/module/index.js +4 -0
  83. package/lib/module/index.js.map +1 -0
  84. package/lib/module/package.json +1 -0
  85. package/lib/typescript/commonjs/package.json +1 -0
  86. package/lib/typescript/commonjs/src/BottomSheet/animations/drag.animation.d.ts +31 -0
  87. package/lib/typescript/commonjs/src/BottomSheet/animations/drag.animation.d.ts.map +1 -0
  88. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheet.d.ts +9 -0
  89. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheet.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetFlatlist.d.ts +3 -0
  91. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetFlatlist.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetModal.d.ts +8 -0
  93. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetModal.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetScrollView.d.ts +3 -0
  95. package/lib/typescript/commonjs/src/BottomSheet/components/BottomSheetScrollView.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.constants.d.ts +30 -0
  97. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.constants.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.styles.d.ts +37 -0
  99. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.styles.d.ts.map +1 -0
  100. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.types.d.ts +185 -0
  101. package/lib/typescript/commonjs/src/BottomSheet/config/bottomSheet.types.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomFlatlist.controller.d.ts +480 -0
  103. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomFlatlist.controller.d.ts.map +1 -0
  104. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomScrollView.controller.d.ts +338 -0
  105. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomScrollView.controller.d.ts.map +1 -0
  106. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomSheet.controller.d.ts +51 -0
  107. package/lib/typescript/commonjs/src/BottomSheet/controller/bottomSheet.controller.d.ts.map +1 -0
  108. package/lib/typescript/commonjs/src/BottomSheet/controller/callbacks.controller.d.ts +36 -0
  109. package/lib/typescript/commonjs/src/BottomSheet/controller/callbacks.controller.d.ts.map +1 -0
  110. package/lib/typescript/commonjs/src/BottomSheet/controller/dragAnimation.controller.d.ts +27 -0
  111. package/lib/typescript/commonjs/src/BottomSheet/controller/dragAnimation.controller.d.ts.map +1 -0
  112. package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts +12 -0
  113. package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts.map +1 -0
  114. package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts +40 -0
  115. package/lib/typescript/commonjs/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts.map +1 -0
  116. package/lib/typescript/commonjs/src/BottomSheet/controller/index.d.ts +2 -0
  117. package/lib/typescript/commonjs/src/BottomSheet/controller/index.d.ts.map +1 -0
  118. package/lib/typescript/commonjs/src/BottomSheet/controller/keyboardAnimation.controller.d.ts +15 -0
  119. package/lib/typescript/commonjs/src/BottomSheet/controller/keyboardAnimation.controller.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/src/BottomSheet/controller/scrollContent.controller.d.ts +20 -0
  121. package/lib/typescript/commonjs/src/BottomSheet/controller/scrollContent.controller.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/src/BottomSheet/index.d.ts +23 -0
  123. package/lib/typescript/commonjs/src/BottomSheet/index.d.ts.map +1 -0
  124. package/lib/typescript/commonjs/src/index.d.ts +2 -0
  125. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  126. package/lib/typescript/module/package.json +1 -0
  127. package/lib/typescript/module/src/BottomSheet/animations/drag.animation.d.ts +31 -0
  128. package/lib/typescript/module/src/BottomSheet/animations/drag.animation.d.ts.map +1 -0
  129. package/lib/typescript/module/src/BottomSheet/components/BottomSheet.d.ts +9 -0
  130. package/lib/typescript/module/src/BottomSheet/components/BottomSheet.d.ts.map +1 -0
  131. package/lib/typescript/module/src/BottomSheet/components/BottomSheetFlatlist.d.ts +3 -0
  132. package/lib/typescript/module/src/BottomSheet/components/BottomSheetFlatlist.d.ts.map +1 -0
  133. package/lib/typescript/module/src/BottomSheet/components/BottomSheetModal.d.ts +8 -0
  134. package/lib/typescript/module/src/BottomSheet/components/BottomSheetModal.d.ts.map +1 -0
  135. package/lib/typescript/module/src/BottomSheet/components/BottomSheetScrollView.d.ts +3 -0
  136. package/lib/typescript/module/src/BottomSheet/components/BottomSheetScrollView.d.ts.map +1 -0
  137. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.constants.d.ts +30 -0
  138. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.constants.d.ts.map +1 -0
  139. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.styles.d.ts +37 -0
  140. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.styles.d.ts.map +1 -0
  141. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.types.d.ts +185 -0
  142. package/lib/typescript/module/src/BottomSheet/config/bottomSheet.types.d.ts.map +1 -0
  143. package/lib/typescript/module/src/BottomSheet/controller/bottomFlatlist.controller.d.ts +480 -0
  144. package/lib/typescript/module/src/BottomSheet/controller/bottomFlatlist.controller.d.ts.map +1 -0
  145. package/lib/typescript/module/src/BottomSheet/controller/bottomScrollView.controller.d.ts +338 -0
  146. package/lib/typescript/module/src/BottomSheet/controller/bottomScrollView.controller.d.ts.map +1 -0
  147. package/lib/typescript/module/src/BottomSheet/controller/bottomSheet.controller.d.ts +51 -0
  148. package/lib/typescript/module/src/BottomSheet/controller/bottomSheet.controller.d.ts.map +1 -0
  149. package/lib/typescript/module/src/BottomSheet/controller/callbacks.controller.d.ts +36 -0
  150. package/lib/typescript/module/src/BottomSheet/controller/callbacks.controller.d.ts.map +1 -0
  151. package/lib/typescript/module/src/BottomSheet/controller/dragAnimation.controller.d.ts +27 -0
  152. package/lib/typescript/module/src/BottomSheet/controller/dragAnimation.controller.d.ts.map +1 -0
  153. package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts +12 -0
  154. package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetRef.d.ts.map +1 -0
  155. package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts +40 -0
  156. package/lib/typescript/module/src/BottomSheet/controller/hooks/useBottomSheetUtils.d.ts.map +1 -0
  157. package/lib/typescript/module/src/BottomSheet/controller/index.d.ts +2 -0
  158. package/lib/typescript/module/src/BottomSheet/controller/index.d.ts.map +1 -0
  159. package/lib/typescript/module/src/BottomSheet/controller/keyboardAnimation.controller.d.ts +15 -0
  160. package/lib/typescript/module/src/BottomSheet/controller/keyboardAnimation.controller.d.ts.map +1 -0
  161. package/lib/typescript/module/src/BottomSheet/controller/scrollContent.controller.d.ts +20 -0
  162. package/lib/typescript/module/src/BottomSheet/controller/scrollContent.controller.d.ts.map +1 -0
  163. package/lib/typescript/module/src/BottomSheet/index.d.ts +23 -0
  164. package/lib/typescript/module/src/BottomSheet/index.d.ts.map +1 -0
  165. package/lib/typescript/module/src/index.d.ts +2 -0
  166. package/lib/typescript/module/src/index.d.ts.map +1 -0
  167. package/package.json +203 -0
  168. package/src/BottomSheet/animations/drag.animation.ts +86 -0
  169. package/src/BottomSheet/components/BottomSheet.tsx +157 -0
  170. package/src/BottomSheet/components/BottomSheetFlatlist.tsx +46 -0
  171. package/src/BottomSheet/components/BottomSheetModal.tsx +47 -0
  172. package/src/BottomSheet/components/BottomSheetScrollView.tsx +46 -0
  173. package/src/BottomSheet/config/bottomSheet.constants.ts +31 -0
  174. package/src/BottomSheet/config/bottomSheet.styles.ts +42 -0
  175. package/src/BottomSheet/config/bottomSheet.types.ts +246 -0
  176. package/src/BottomSheet/controller/bottomFlatlist.controller.ts +87 -0
  177. package/src/BottomSheet/controller/bottomScrollView.controller.ts +43 -0
  178. package/src/BottomSheet/controller/bottomSheet.controller.ts +238 -0
  179. package/src/BottomSheet/controller/callbacks.controller.ts +222 -0
  180. package/src/BottomSheet/controller/dragAnimation.controller.ts +211 -0
  181. package/src/BottomSheet/controller/hooks/useBottomSheetRef.ts +73 -0
  182. package/src/BottomSheet/controller/hooks/useBottomSheetUtils.ts +75 -0
  183. package/src/BottomSheet/controller/index.ts +1 -0
  184. package/src/BottomSheet/controller/keyboardAnimation.controller.ts +148 -0
  185. package/src/BottomSheet/controller/scrollContent.controller.ts +120 -0
  186. package/src/BottomSheet/index.tsx +139 -0
  187. package/src/index.tsx +1 -0
@@ -0,0 +1,15 @@
1
+ import { type SharedValue } from 'react-native-reanimated';
2
+ import { type TextInput } from 'react-native';
3
+ type UseKeyboardAnimationProps = {
4
+ avoidKeyboard?: boolean;
5
+ screenHeight: number;
6
+ inputsForKeyboardToAvoid?: React.RefObject<TextInput>[];
7
+ keyboardHeight: SharedValue<number>;
8
+ translationY: SharedValue<number>;
9
+ prevTranslationY: SharedValue<number>;
10
+ modalContentTranslateY: SharedValue<number>;
11
+ setDisableLayoutAnimation: (bool: boolean) => void;
12
+ };
13
+ export declare function keyboardAnimationController(props: UseKeyboardAnimationProps): void;
14
+ export {};
15
+ //# sourceMappingURL=keyboardAnimation.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyboardAnimation.controller.d.ts","sourceRoot":"","sources":["../../../../../../src/BottomSheet/controller/keyboardAnimation.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,WAAW,EAAc,MAAM,yBAAyB,CAAC;AAKhF,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAQlE,KAAK,yBAAyB,GAAG;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,wBAAwB,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;IACxD,cAAc,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACpC,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,gBAAgB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACtC,sBAAsB,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC5C,yBAAyB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACpD,CAAC;AAEF,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,yBAAyB,QA0H3E"}
@@ -0,0 +1,20 @@
1
+ import { type SharedValue } from 'react-native-reanimated';
2
+ import type { GestureStateChangeEvent, GestureUpdateEvent, PanGestureHandlerEventPayload } from 'react-native-gesture-handler';
3
+ import type { ScrollComponentRef } from '../config/bottomSheet.types';
4
+ type ScrollContentControllerType = {
5
+ scrollY: SharedValue<number>;
6
+ maxScrollOffset: SharedValue<number>;
7
+ inverted: SharedValue<boolean>;
8
+ scrollActive: SharedValue<boolean>;
9
+ onDragStartGesture: (e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
10
+ onDragEndGesture: (e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
11
+ onDragGesture: (e: GestureUpdateEvent<PanGestureHandlerEventPayload>) => void;
12
+ scrollableComponentRef?: ScrollComponentRef;
13
+ };
14
+ export declare function scrollContentController({ scrollActive, scrollY, onDragStartGesture, onDragEndGesture, onDragGesture, maxScrollOffset, inverted, scrollableComponentRef, }: ScrollContentControllerType): {
15
+ onBeginScroll: (e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
16
+ onUpdateScroll: (e: GestureUpdateEvent<PanGestureHandlerEventPayload>) => void;
17
+ onEndScroll: (e: GestureStateChangeEvent<PanGestureHandlerEventPayload>) => void;
18
+ };
19
+ export {};
20
+ //# sourceMappingURL=scrollContent.controller.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollContent.controller.d.ts","sourceRoot":"","sources":["../../../../../../src/BottomSheet/controller/scrollContent.controller.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAC;AACjC,OAAO,KAAK,EACV,uBAAuB,EACvB,kBAAkB,EAClB,6BAA6B,EAC9B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAGtE,KAAK,2BAA2B,GAAG;IACjC,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7B,eAAe,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IACrC,QAAQ,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC/B,YAAY,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACnC,kBAAkB,EAAE,CAClB,CAAC,EAAE,uBAAuB,CAAC,6BAA6B,CAAC,KACtD,IAAI,CAAC;IACV,gBAAgB,EAAE,CAChB,CAAC,EAAE,uBAAuB,CAAC,6BAA6B,CAAC,KACtD,IAAI,CAAC;IACV,aAAa,EAAE,CAAC,CAAC,EAAE,kBAAkB,CAAC,6BAA6B,CAAC,KAAK,IAAI,CAAC;IAC9E,sBAAsB,CAAC,EAAE,kBAAkB,CAAC;CAC7C,CAAC;AAEF,wBAAgB,uBAAuB,CAAC,EACtC,YAAY,EACZ,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,eAAe,EACf,QAAQ,EACR,sBAAsB,GACvB,EAAE,2BAA2B;;;;EAgF7B"}
@@ -0,0 +1,23 @@
1
+ import { type BottomSheetProps, type BottomModalContextProps } from './config/bottomSheet.types';
2
+ import { BottomSheetFlatlist } from './components/BottomSheetFlatlist';
3
+ import { BottomSheetScrollView } from './components/BottomSheetScrollView';
4
+ export declare const BottomModalContext: import("react").Context<BottomModalContextProps | null>;
5
+ declare const BottomSheetModal: import("react").ForwardRefExoticComponent<{
6
+ BackdropComponent?: React.ReactNode;
7
+ onBackDropPress?: () => void;
8
+ disableCloseOnBackdropPress?: boolean;
9
+ } & BottomSheetProps & import("@shaquillehinds/react-native-essentials").ModalWrapperProps & {
10
+ children?: import("react").ReactNode | undefined;
11
+ } & import("react").RefAttributes<import("./config/bottomSheet.types").BottomModalRef>>;
12
+ declare const BottomSheet: import("react").ForwardRefExoticComponent<{
13
+ BackdropComponent?: React.ReactNode;
14
+ onBackDropPress?: () => void;
15
+ disableCloseOnBackdropPress?: boolean;
16
+ } & BottomSheetProps & import("@shaquillehinds/react-native-essentials").ModalWrapperProps & {
17
+ children?: import("react").ReactNode | undefined;
18
+ } & import("react").RefAttributes<import("./config/bottomSheet.types").BottomModalRef>>;
19
+ declare const useBottomSheetRef: () => {
20
+ modalRef: import("./config/bottomSheet.types").BottomModalRef | undefined;
21
+ };
22
+ export { BottomSheet, BottomSheetModal, BottomSheetFlatlist, BottomSheetScrollView, useBottomSheetRef, };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/BottomSheet/index.tsx"],"names":[],"mappings":"AAOA,OAAO,EACL,KAAK,gBAAgB,EAIrB,KAAK,uBAAuB,EAC7B,MAAM,4BAA4B,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AACvE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAU3E,eAAO,MAAM,kBAAkB,yDAE9B,CAAC;AAEF,QAAA,MAAM,gBAAgB;;;;;;uFAyCrB,CAAC;AAaF,QAAA,MAAM,WAAW;;;;;;uFAyChB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;CAGtB,CAAC;AAEF,OAAO,EACL,WAAW,EACX,gBAAgB,EAChB,mBAAmB,EACnB,qBAAqB,EACrB,iBAAiB,GAClB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './BottomSheet';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
package/package.json ADDED
@@ -0,0 +1,203 @@
1
+ {
2
+ "name": "@shaquillehinds/react-native-bottom-sheet",
3
+ "version": "0.0.1",
4
+ "description": "A simple bottom sheet for react native that just works.",
5
+ "source": "./src/index.tsx",
6
+ "main": "./lib/commonjs/index.js",
7
+ "module": "./lib/module/index.js",
8
+ "react-native": "./src/index.tsx",
9
+ "types": "lib/typescript/commonjs/src/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "import": {
13
+ "types": "./lib/typescript/module/src/index.d.ts",
14
+ "react-native": "./src/index.tsx",
15
+ "default": "./lib/module/index.js"
16
+ },
17
+ "require": {
18
+ "types": "./lib/typescript/commonjs/src/index.d.ts",
19
+ "default": "./lib/commonjs/index.js"
20
+ }
21
+ }
22
+ },
23
+ "files": [
24
+ "lib",
25
+ "src",
26
+ "android",
27
+ "ios",
28
+ "cpp",
29
+ "*.podspec",
30
+ "react-native.config.js",
31
+ "!ios/build",
32
+ "!android/build",
33
+ "!android/gradle",
34
+ "!android/gradlew",
35
+ "!android/gradlew.bat",
36
+ "!android/local.properties",
37
+ "!**/__tests__",
38
+ "!**/__fixtures__",
39
+ "!**/__mocks__",
40
+ "!**/.*"
41
+ ],
42
+ "scripts": {
43
+ "example": "yarn workspace react-native-bottom-sheet-example",
44
+ "dev:mkdir": "mkdir -p ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-bottom-sheet/src",
45
+ "dev:copy": "cp -r src/* ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-bottom-sheet/src",
46
+ "dev:sync": "npm run dev:copy && chokidar \"src/**/*\" -c \"rsync -a src/ ../../expo-dev-playground-2/node_modules/@shaquillehinds/react-native-bottom-sheet/src\"",
47
+ "test": "jest",
48
+ "tarball": "npm pack @shaquillehinds/react-native-bottom-sheet",
49
+ "typecheck": "tsc",
50
+ "lint": "eslint \"**/*.{js,ts,tsx}\"",
51
+ "clean": "del-cli lib",
52
+ "prepare": "bob build",
53
+ "release": "release-it"
54
+ },
55
+ "keywords": [
56
+ "react-native",
57
+ "ios",
58
+ "android",
59
+ "modal",
60
+ "sheet",
61
+ "bottomsheet",
62
+ "bottommodal",
63
+ "bottom-sheet",
64
+ "bottom-modal"
65
+ ],
66
+ "repository": {
67
+ "type": "git",
68
+ "url": "git+https://github.com/shaquillehinds/react-native-bottom-sheet.git"
69
+ },
70
+ "author": "Shaquille Hinds <shaqdulove@gmail.com> (https://github.com/shaquillehinds)",
71
+ "license": "MIT",
72
+ "bugs": {
73
+ "url": "https://github.com/shaquillehinds/react-native-bottom-sheet/issues"
74
+ },
75
+ "homepage": "https://github.com/shaquillehinds/react-native-bottom-sheet#readme",
76
+ "publishConfig": {
77
+ "registry": "https://registry.npmjs.org/",
78
+ "access": "public"
79
+ },
80
+ "dependencies": {
81
+ "@shaquillehinds/react-native-essentials": "^1.8.0"
82
+ },
83
+ "devDependencies": {
84
+ "@commitlint/config-conventional": "^19.6.0",
85
+ "@react-native/eslint-config": "^0.73.1",
86
+ "@release-it/conventional-changelog": "^9.0.2",
87
+ "@types/jest": "^29.5.5",
88
+ "@types/react": "^18.2.44",
89
+ "chokidar-cli": "^3.0.0",
90
+ "commitlint": "^19.6.1",
91
+ "del-cli": "^5.1.0",
92
+ "eslint": "^8.51.0",
93
+ "eslint-config-prettier": "^9.0.0",
94
+ "eslint-plugin-prettier": "^5.0.1",
95
+ "jest": "^29.7.0",
96
+ "prettier": "^3.0.3",
97
+ "react": "18.3.1",
98
+ "react-native": "0.76.7",
99
+ "react-native-builder-bob": "^0.38.0",
100
+ "react-native-gesture-handler": "^2.24.0",
101
+ "react-native-reanimated": "^3.17.1",
102
+ "react-native-svg": "^15.11.2",
103
+ "release-it": "^17.10.0",
104
+ "typescript": "^5.2.2"
105
+ },
106
+ "resolutions": {
107
+ "@types/react": "^18.2.44"
108
+ },
109
+ "peerDependencies": {
110
+ "react": "*",
111
+ "react-native": "*"
112
+ },
113
+ "workspaces": [
114
+ "example"
115
+ ],
116
+ "packageManager": "yarn@3.6.1",
117
+ "jest": {
118
+ "preset": "react-native",
119
+ "modulePathIgnorePatterns": [
120
+ "<rootDir>/example/node_modules",
121
+ "<rootDir>/lib/"
122
+ ]
123
+ },
124
+ "commitlint": {
125
+ "extends": [
126
+ "@commitlint/config-conventional"
127
+ ]
128
+ },
129
+ "release-it": {
130
+ "git": {
131
+ "commitMessage": "chore: release ${version}",
132
+ "tagName": "v${version}"
133
+ },
134
+ "npm": {
135
+ "publish": true,
136
+ "access": true
137
+ },
138
+ "github": {
139
+ "release": true
140
+ },
141
+ "plugins": {
142
+ "@release-it/conventional-changelog": {
143
+ "preset": {
144
+ "name": "angular"
145
+ }
146
+ }
147
+ }
148
+ },
149
+ "eslintConfig": {
150
+ "root": true,
151
+ "extends": [
152
+ "@react-native",
153
+ "prettier"
154
+ ],
155
+ "rules": {
156
+ "react/react-in-jsx-scope": "off",
157
+ "react-hooks/rules-of-hooks": "off",
158
+ "react-hooks/exhaustive-deps": "off",
159
+ "prettier/prettier": "off"
160
+ }
161
+ },
162
+ "eslintIgnore": [
163
+ "node_modules/",
164
+ "lib/"
165
+ ],
166
+ "prettier": {
167
+ "quoteProps": "consistent",
168
+ "singleQuote": true,
169
+ "tabWidth": 2,
170
+ "trailingComma": "es5",
171
+ "useTabs": false
172
+ },
173
+ "react-native-builder-bob": {
174
+ "source": "src",
175
+ "output": "lib",
176
+ "targets": [
177
+ [
178
+ "commonjs",
179
+ {
180
+ "esm": true
181
+ }
182
+ ],
183
+ [
184
+ "module",
185
+ {
186
+ "esm": true
187
+ }
188
+ ],
189
+ [
190
+ "typescript",
191
+ {
192
+ "project": "tsconfig.build.json",
193
+ "esm": true
194
+ }
195
+ ]
196
+ ]
197
+ },
198
+ "create-react-native-library": {
199
+ "languages": "js",
200
+ "type": "library",
201
+ "version": "0.48.5"
202
+ }
203
+ }
@@ -0,0 +1,86 @@
1
+ //$lf-ignore
2
+ import {
3
+ useSharedValue,
4
+ useAnimatedStyle,
5
+ type SharedValue,
6
+ } from 'react-native-reanimated';
7
+ import { useCallback } from 'react';
8
+
9
+ // function clamp(val: number, min: number, max: number) {
10
+ // 'worklet';
11
+ // return Math.min(Math.max(val, min), max);
12
+ // }
13
+
14
+ //prettier-ignore
15
+ // function stretch(val: number,min: number,max: number,maxStretch: number,stretchOn: 'min' | 'max') {
16
+ // 'worklet';
17
+ // const isMax = stretchOn === 'max';
18
+ // const limit = isMax ? max : min;
19
+ // const direction = isMax ? 1 : -1;
20
+ // const inBounds = isMax ? val <= max : val >= min;
21
+ // if (inBounds) return val;
22
+ // const overshoot = Math.abs(val - limit);
23
+ // const resistance = maxStretch * (1 - 1 / (overshoot / maxStretch + 1));
24
+ // return limit + resistance * direction;
25
+ // }
26
+
27
+ // function maxStretch(val:number, max: number, stretch: number){
28
+ // 'worklet';
29
+ // return val <= max ? val : max - stretch + stretch / ((val - max) / stretch + 1);
30
+ // }
31
+ function minStretch(val: number, min: number, stretch: number) {
32
+ 'worklet';
33
+ //prettier-ignore
34
+ return val >= min ? val : min - stretch + stretch / ((min - val) / stretch + 1);
35
+ }
36
+
37
+ export type OnMoveAnimationProps = {
38
+ posX: number;
39
+ posY: number;
40
+ minPosY: number;
41
+ maxPosY: number;
42
+ };
43
+
44
+ export type OnDragAnimationProps = {
45
+ translationX?: SharedValue<number>;
46
+ translationY?: SharedValue<number>;
47
+ prevTranslationX?: SharedValue<number>;
48
+ prevTranslationY?: SharedValue<number>;
49
+ };
50
+
51
+ export function useDragAnimation(props?: OnDragAnimationProps) {
52
+ const translationX = props?.translationX || useSharedValue(0);
53
+ const translationY = props?.translationY || useSharedValue(0);
54
+ const prevTranslationX = props?.prevTranslationX || useSharedValue(0);
55
+ const prevTranslationY = props?.prevTranslationY || useSharedValue(0);
56
+
57
+ const dragAnimatedStyle = useAnimatedStyle(() => ({
58
+ transform: [
59
+ { translateX: translationX.value },
60
+ { translateY: translationY.value },
61
+ ],
62
+ }));
63
+
64
+ const onDragStart = useCallback(() => {
65
+ 'worklet';
66
+ prevTranslationX.value = translationX.value;
67
+ prevTranslationY.value = translationY.value;
68
+ }, []);
69
+ const onDrag = useCallback((dragProps: OnMoveAnimationProps) => {
70
+ 'worklet';
71
+ translationY.value = minStretch(
72
+ prevTranslationY.value + dragProps.posY,
73
+ dragProps.minPosY,
74
+ 100
75
+ );
76
+ }, []);
77
+ return {
78
+ onDrag,
79
+ onDragStart,
80
+ dragAnimatedStyle,
81
+ translationX,
82
+ translationY,
83
+ prevTranslationX,
84
+ prevTranslationY,
85
+ };
86
+ }
@@ -0,0 +1,157 @@
1
+ import Animated, { FadeIn, runOnUI } from 'react-native-reanimated';
2
+ import { View } from 'react-native';
3
+ import {
4
+ forwardRef,
5
+ createContext,
6
+ useImperativeHandle,
7
+ type PropsWithChildren,
8
+ } from 'react';
9
+ import { bottomModalStyle as styles } from '../config/bottomSheet.styles';
10
+ import { type BottomSheetControllerReturn } from '../controller/bottomSheet.controller';
11
+ import {
12
+ type BottomSheetContextProps,
13
+ type BottomSheetProps,
14
+ type BottomSheetRefObject,
15
+ } from '../config/bottomSheet.types';
16
+ import {
17
+ ModalForegroundWrapper,
18
+ ComponentMounter,
19
+ DragGesture,
20
+ } from '@shaquillehinds/react-native-essentials';
21
+
22
+ export const BottomSheetContext = createContext<BottomSheetContextProps | null>(
23
+ null
24
+ );
25
+
26
+ export const BottomSheet = forwardRef(
27
+ (
28
+ props: PropsWithChildren<BottomSheetProps> & {
29
+ controller: BottomSheetControllerReturn;
30
+ },
31
+ ref: BottomSheetRefObject
32
+ ) => {
33
+ const controller = props.controller;
34
+ useImperativeHandle(
35
+ ref,
36
+ () => ({
37
+ animateCloseModal: (prop) => {
38
+ controller.disableLayoutAnimation.current = true;
39
+ runOnUI(controller.animateModalClose)(prop);
40
+ },
41
+ snapToIndex: (snapPointIndex) => {
42
+ runOnUI(controller.animateToSnapPointIndex)(snapPointIndex);
43
+ },
44
+ snapToPercentage: (percentage) => {
45
+ runOnUI(controller.animateToPercentage)(
46
+ percentage,
47
+ controller.screenHeight
48
+ );
49
+ },
50
+ getModalState: () => controller.modalState.current,
51
+ }),
52
+ [controller.screenHeight, controller.modalState.current]
53
+ );
54
+ return (
55
+ <ModalForegroundWrapper>
56
+ <DragGesture
57
+ minDistance={15}
58
+ disable={props.dragArea !== 'full'}
59
+ onDrag={controller.onDragGesture}
60
+ onDragStart={controller.onDragStartGesture}
61
+ onDragEnd={controller.onDragEndGesture}
62
+ >
63
+ <Animated.View
64
+ style={[
65
+ styles.bottomSheet,
66
+ props.style,
67
+ controller.modalDimensionsStyle,
68
+ controller.dragAnimatedStyle,
69
+ {
70
+ backgroundColor: props.backgroundColor,
71
+ bottom:
72
+ controller.modalDimensionsStyle.bottom +
73
+ (props.bottomOffset || 0),
74
+ },
75
+ ]}
76
+ >
77
+ {props.hideBumper ? (
78
+ <></>
79
+ ) : props.dragArea === 'bumper' || !props.dragArea ? (
80
+ <DragGesture
81
+ onDrag={controller.onDragGesture}
82
+ onDragStart={controller.onDragStartGesture}
83
+ onDragEnd={controller.onDragEndGesture}
84
+ >
85
+ {props.BumperComponent ? (
86
+ <props.BumperComponent />
87
+ ) : (
88
+ <Bumper {...props} />
89
+ )}
90
+ </DragGesture>
91
+ ) : props.BumperComponent ? (
92
+ <props.BumperComponent />
93
+ ) : (
94
+ <Bumper {...props} />
95
+ )}
96
+ <Animated.View
97
+ onLayout={controller.onModalContentLayout}
98
+ style={[
99
+ styles.contentContainer,
100
+ controller.modalContentAnimatedStyle,
101
+ props.contentContainerStyle,
102
+ ]}
103
+ >
104
+ <BottomSheetContext.Provider
105
+ value={{
106
+ scrollY: controller.scrollY,
107
+ onBeginScroll: controller.onBeginScroll,
108
+ onUpdateScroll: controller.onUpdateScroll,
109
+ onEndScroll: controller.onEndScroll,
110
+ scrollableComponentRef: controller.scrollableComponentRef,
111
+ maxScrollOffset: controller.maxScrollOffset,
112
+ inverted: controller.inverted,
113
+ }}
114
+ >
115
+ {!props.showContentDelay ? (
116
+ props.children
117
+ ) : !props.showContentDelay.type ||
118
+ props.showContentDelay.type === 'opacity' ? (
119
+ <Animated.View style={[controller.contentOpacityStyle]}>
120
+ {props.children}
121
+ </Animated.View>
122
+ ) : (
123
+ <ComponentMounter
124
+ component={
125
+ <Animated.View entering={FadeIn.delay(50).duration(200)}>
126
+ {props.children}
127
+ </Animated.View>
128
+ }
129
+ mountDelayInMilliSeconds={
130
+ props.showContentDelay.timeInMilliSecs
131
+ }
132
+ showComponent={true}
133
+ setShowComponent={() => true}
134
+ />
135
+ )}
136
+ </BottomSheetContext.Provider>
137
+ </Animated.View>
138
+ </Animated.View>
139
+ </DragGesture>
140
+ </ModalForegroundWrapper>
141
+ );
142
+ }
143
+ );
144
+
145
+ function Bumper(props: PropsWithChildren<BottomSheetProps>) {
146
+ return (
147
+ <View
148
+ style={[
149
+ styles.bumperContainer,
150
+ { backgroundColor: props.backgroundColor },
151
+ props.bumperContainerStyle,
152
+ ]}
153
+ >
154
+ <View style={[styles.bumper, props.bumperStyle]} />
155
+ </View>
156
+ );
157
+ }
@@ -0,0 +1,46 @@
1
+ //$lf-ignore
2
+ import Animated from 'react-native-reanimated';
3
+ import type {
4
+ BottomSheetFlatlistProps,
5
+ DefaultOnScroll,
6
+ } from '../config/bottomSheet.types';
7
+ import type { FlatList } from 'react-native';
8
+ import { bottomFlatlistController } from '../controller/bottomFlatlist.controller';
9
+ import { DragGesture } from '@shaquillehinds/react-native-essentials';
10
+
11
+ export function BottomSheetFlatlist<T>(props: BottomSheetFlatlistProps<T>) {
12
+ const controller = bottomFlatlistController(props);
13
+
14
+ if (!controller.context)
15
+ return (
16
+ <Animated.FlatList
17
+ {...controller.flatlistProps}
18
+ ref={controller.refFlatlist}
19
+ onScroll={controller.onScroll as DefaultOnScroll}
20
+ />
21
+ );
22
+
23
+ return (
24
+ <DragGesture
25
+ minDistance={15}
26
+ enableContentScroll
27
+ onDragStart={controller.context.onBeginScroll}
28
+ onDrag={controller.context.onUpdateScroll}
29
+ onDragEnd={controller.context.onEndScroll}
30
+ >
31
+ <Animated.FlatList
32
+ {...controller.flatlistProps}
33
+ onScrollBeginDrag={controller.onScrollBegin}
34
+ onLayout={controller.onLayout}
35
+ onContentSizeChange={controller.onContentSizeChange}
36
+ ref={
37
+ controller.refFlatlist ||
38
+ (controller.context
39
+ .scrollableComponentRef as React.RefObject<FlatList>)
40
+ }
41
+ bounces={false}
42
+ onScroll={controller.animatedScrollHandler}
43
+ />
44
+ </DragGesture>
45
+ );
46
+ }
@@ -0,0 +1,47 @@
1
+ import {
2
+ ModalBackgroundAnimated,
3
+ ModalWrapper,
4
+ } from '@shaquillehinds/react-native-essentials';
5
+ import { forwardRef, type PropsWithChildren } from 'react';
6
+ import { bottomModalStyle as styles } from '../config/bottomSheet.styles';
7
+ import { BottomSheet } from '../components/BottomSheet';
8
+ import {
9
+ type BottomSheetModalProps,
10
+ type BottomSheetRefObject,
11
+ } from '../config/bottomSheet.types';
12
+ import { bottomSheetController } from '../controller';
13
+
14
+ export const BottomSheetModal = forwardRef(
15
+ (
16
+ props: PropsWithChildren<BottomSheetModalProps>,
17
+ ref: BottomSheetRefObject
18
+ ) => {
19
+ const controller = bottomSheetController(props);
20
+ return (
21
+ <ModalWrapper
22
+ useNativeModal={props.useNativeModal}
23
+ enableBackgroundContentPress={props.enableBackgroundContentPress}
24
+ onRequestClose={controller.onRequestClose}
25
+ disableAndroidBackButton={props.disableAndroidBackButton}
26
+ >
27
+ {!props.enableBackgroundContentPress ? (
28
+ <ModalBackgroundAnimated
29
+ onPress={
30
+ props.disableCloseOnBackdropPress
31
+ ? undefined
32
+ : controller.onModalBackdropPress
33
+ }
34
+ style={styles.background}
35
+ animatedStyle={controller.backdropOpacityStyle}
36
+ avoidStatusBar={props.useNativeModal}
37
+ >
38
+ {props.BackdropComponent}
39
+ </ModalBackgroundAnimated>
40
+ ) : undefined}
41
+ <BottomSheet {...props} controller={controller} ref={ref}>
42
+ {props.children}
43
+ </BottomSheet>
44
+ </ModalWrapper>
45
+ );
46
+ }
47
+ );
@@ -0,0 +1,46 @@
1
+ //$lf-ignore
2
+ import Animated from 'react-native-reanimated';
3
+ import type {
4
+ BottomSheetScrollViewProps,
5
+ DefaultOnScroll,
6
+ } from '../config/bottomSheet.types';
7
+ import { AnimatedScrollView } from 'react-native-reanimated/lib/typescript/component/ScrollView';
8
+ import { bottomScrollViewController } from '../controller/bottomScrollView.controller';
9
+ import { DragGesture } from '@shaquillehinds/react-native-essentials';
10
+
11
+ export function BottomSheetScrollView(props: BottomSheetScrollViewProps) {
12
+ const controller = bottomScrollViewController(props);
13
+
14
+ if (!controller.context)
15
+ return (
16
+ <Animated.ScrollView
17
+ {...controller.scrollViewProps}
18
+ ref={controller.refScrollView}
19
+ onScroll={controller.onScroll as DefaultOnScroll}
20
+ />
21
+ );
22
+
23
+ return (
24
+ <DragGesture
25
+ minDistance={15}
26
+ enableContentScroll
27
+ onDragStart={controller.context.onBeginScroll}
28
+ onDrag={controller.context.onUpdateScroll}
29
+ onDragEnd={controller.context.onEndScroll}
30
+ >
31
+ <Animated.ScrollView
32
+ {...controller.scrollViewProps}
33
+ ref={
34
+ controller.refScrollView ||
35
+ (controller.context
36
+ .scrollableComponentRef as React.RefObject<AnimatedScrollView>)
37
+ }
38
+ onScrollBeginDrag={controller.assignRef}
39
+ bounces={false}
40
+ onScroll={controller.animatedScrollHandler}
41
+ >
42
+ {controller.scrollViewProps.children}
43
+ </Animated.ScrollView>
44
+ </DragGesture>
45
+ );
46
+ }