@tamagui/sheet 2.7.7 → 3.0.0-beta.643.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 (435) hide show
  1. package/dist/cjs/GestureDetectorWrapper.cjs +32 -41
  2. package/dist/cjs/GestureDetectorWrapper.native.cjs +48 -0
  3. package/dist/cjs/GestureDetectorWrapper.native.js +32 -40
  4. package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -1
  5. package/dist/cjs/GestureSheetContext.cjs +29 -37
  6. package/dist/cjs/GestureSheetContext.native.cjs +49 -0
  7. package/dist/cjs/GestureSheetContext.native.js +30 -37
  8. package/dist/cjs/GestureSheetContext.native.js.map +1 -1
  9. package/dist/cjs/Sheet.cjs +206 -99
  10. package/dist/cjs/Sheet.native.cjs +234 -0
  11. package/dist/cjs/Sheet.native.js +212 -98
  12. package/dist/cjs/Sheet.native.js.map +1 -1
  13. package/dist/cjs/SheetContext.cjs +44 -22
  14. package/dist/cjs/SheetContext.native.cjs +58 -0
  15. package/dist/cjs/SheetContext.native.js +45 -22
  16. package/dist/cjs/SheetContext.native.js.map +1 -1
  17. package/dist/cjs/SheetController.cjs +50 -56
  18. package/dist/cjs/SheetController.native.cjs +72 -0
  19. package/dist/cjs/SheetController.native.js +53 -58
  20. package/dist/cjs/SheetController.native.js.map +1 -1
  21. package/dist/cjs/SheetImplementationCustom.cjs +674 -605
  22. package/dist/cjs/SheetImplementationCustom.native.cjs +762 -0
  23. package/dist/cjs/SheetImplementationCustom.native.js +713 -644
  24. package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
  25. package/dist/cjs/SheetScrollView.cjs +291 -312
  26. package/dist/cjs/SheetScrollView.native.cjs +326 -0
  27. package/dist/cjs/SheetScrollView.native.js +299 -319
  28. package/dist/cjs/SheetScrollView.native.js.map +1 -1
  29. package/dist/cjs/constants.cjs +22 -21
  30. package/dist/cjs/constants.native.cjs +37 -0
  31. package/dist/cjs/constants.native.js +22 -20
  32. package/dist/cjs/constants.native.js.map +1 -1
  33. package/dist/cjs/contexts.cjs +20 -28
  34. package/dist/cjs/contexts.native.cjs +38 -0
  35. package/dist/cjs/contexts.native.js +20 -27
  36. package/dist/cjs/contexts.native.js.map +1 -1
  37. package/dist/cjs/controller.cjs +17 -18
  38. package/dist/cjs/controller.native.cjs +32 -0
  39. package/dist/cjs/controller.native.js +17 -17
  40. package/dist/cjs/controller.native.js.map +1 -1
  41. package/dist/cjs/gestureState.cjs +29 -30
  42. package/dist/cjs/gestureState.native.cjs +54 -0
  43. package/dist/cjs/gestureState.native.js +30 -30
  44. package/dist/cjs/gestureState.native.js.map +1 -1
  45. package/dist/cjs/helpers.cjs +21 -24
  46. package/dist/cjs/helpers.native.cjs +35 -0
  47. package/dist/cjs/helpers.native.js +22 -24
  48. package/dist/cjs/helpers.native.js.map +1 -1
  49. package/dist/cjs/index.cjs +15 -21
  50. package/dist/cjs/index.native.cjs +37 -0
  51. package/dist/cjs/index.native.js +16 -21
  52. package/dist/cjs/index.native.js.map +1 -1
  53. package/dist/cjs/keyboardAvoidance.cjs +56 -79
  54. package/dist/cjs/keyboardAvoidance.native.cjs +75 -0
  55. package/dist/cjs/keyboardAvoidance.native.js +56 -78
  56. package/dist/cjs/keyboardAvoidance.native.js.map +1 -1
  57. package/dist/cjs/nativeSheet.cjs +64 -76
  58. package/dist/cjs/nativeSheet.native.cjs +94 -0
  59. package/dist/cjs/nativeSheet.native.js +70 -83
  60. package/dist/cjs/nativeSheet.native.js.map +1 -1
  61. package/dist/cjs/types.cjs +10 -11
  62. package/dist/cjs/types.native.cjs +19 -0
  63. package/dist/cjs/types.native.js +10 -10
  64. package/dist/cjs/types.native.js.map +1 -1
  65. package/dist/cjs/useGestureHandlerPan.cjs +245 -257
  66. package/dist/cjs/useGestureHandlerPan.native.cjs +273 -0
  67. package/dist/cjs/useGestureHandlerPan.native.js +254 -265
  68. package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
  69. package/dist/cjs/useKeyboardControllerSheet.cjs +83 -88
  70. package/dist/cjs/useKeyboardControllerSheet.native.cjs +119 -0
  71. package/dist/cjs/useKeyboardControllerSheet.native.js +100 -111
  72. package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -1
  73. package/dist/cjs/useSafeAreaInsets.cjs +20 -26
  74. package/dist/cjs/useSafeAreaInsets.native.cjs +51 -0
  75. package/dist/cjs/useSafeAreaInsets.native.js +30 -25
  76. package/dist/cjs/useSafeAreaInsets.native.js.map +1 -1
  77. package/dist/cjs/useSheetController.cjs +27 -39
  78. package/dist/cjs/useSheetController.native.cjs +42 -0
  79. package/dist/cjs/useSheetController.native.js +28 -39
  80. package/dist/cjs/useSheetController.native.js.map +1 -1
  81. package/dist/cjs/useSheetOffscreenSize.cjs +44 -53
  82. package/dist/cjs/useSheetOffscreenSize.native.cjs +60 -0
  83. package/dist/cjs/useSheetOffscreenSize.native.js +48 -56
  84. package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -1
  85. package/dist/cjs/useSheetOpenState.cjs +69 -40
  86. package/dist/cjs/useSheetOpenState.native.cjs +88 -0
  87. package/dist/cjs/useSheetOpenState.native.js +74 -42
  88. package/dist/cjs/useSheetOpenState.native.js.map +1 -1
  89. package/dist/cjs/useSheetProviderProps.cjs +146 -164
  90. package/dist/cjs/useSheetProviderProps.native.cjs +176 -0
  91. package/dist/cjs/useSheetProviderProps.native.js +156 -174
  92. package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
  93. package/dist/cjs/useSheetScrollViewGestures.cjs +172 -180
  94. package/dist/cjs/useSheetScrollViewGestures.native.cjs +150 -0
  95. package/dist/cjs/useSheetScrollViewGestures.native.js +136 -147
  96. package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
  97. package/dist/cjs/webViewport.cjs +47 -48
  98. package/dist/cjs/webViewport.native.cjs +79 -0
  99. package/dist/cjs/webViewport.native.js +50 -50
  100. package/dist/cjs/webViewport.native.js.map +1 -1
  101. package/dist/esm/GestureDetectorWrapper.mjs +19 -23
  102. package/dist/esm/GestureDetectorWrapper.mjs.map +1 -1
  103. package/dist/esm/GestureDetectorWrapper.native.js +20 -24
  104. package/dist/esm/GestureDetectorWrapper.native.js.map +1 -1
  105. package/dist/esm/GestureSheetContext.mjs +15 -20
  106. package/dist/esm/GestureSheetContext.mjs.map +1 -1
  107. package/dist/esm/GestureSheetContext.native.js +17 -22
  108. package/dist/esm/GestureSheetContext.native.js.map +1 -1
  109. package/dist/esm/Sheet.mjs +191 -83
  110. package/dist/esm/Sheet.mjs.map +1 -1
  111. package/dist/esm/Sheet.native.js +198 -83
  112. package/dist/esm/Sheet.native.js.map +1 -1
  113. package/dist/esm/SheetContext.mjs +21 -5
  114. package/dist/esm/SheetContext.mjs.map +1 -1
  115. package/dist/esm/SheetContext.native.js +21 -5
  116. package/dist/esm/SheetContext.native.js.map +1 -1
  117. package/dist/esm/SheetController.mjs +34 -30
  118. package/dist/esm/SheetController.mjs.map +1 -1
  119. package/dist/esm/SheetController.native.js +38 -34
  120. package/dist/esm/SheetController.native.js.map +1 -1
  121. package/dist/esm/SheetImplementationCustom.mjs +655 -580
  122. package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
  123. package/dist/esm/SheetImplementationCustom.native.js +691 -612
  124. package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
  125. package/dist/esm/SheetScrollView.mjs +277 -288
  126. package/dist/esm/SheetScrollView.mjs.map +1 -1
  127. package/dist/esm/SheetScrollView.native.js +286 -297
  128. package/dist/esm/SheetScrollView.native.js.map +1 -1
  129. package/dist/esm/constants.mjs +5 -3
  130. package/dist/esm/constants.mjs.map +1 -1
  131. package/dist/esm/constants.native.js +5 -3
  132. package/dist/esm/constants.native.js.map +1 -1
  133. package/dist/esm/contexts.mjs +3 -3
  134. package/dist/esm/contexts.mjs.map +1 -1
  135. package/dist/esm/contexts.native.js +3 -3
  136. package/dist/esm/contexts.native.js.map +1 -1
  137. package/dist/esm/controller.mjs +2 -2
  138. package/dist/esm/controller.native.js +2 -2
  139. package/dist/esm/gestureState.mjs +13 -11
  140. package/dist/esm/gestureState.mjs.map +1 -1
  141. package/dist/esm/gestureState.native.js +14 -12
  142. package/dist/esm/gestureState.native.js.map +1 -1
  143. package/dist/esm/helpers.mjs +7 -6
  144. package/dist/esm/helpers.mjs.map +1 -1
  145. package/dist/esm/helpers.native.js +8 -7
  146. package/dist/esm/helpers.native.js.map +1 -1
  147. package/dist/esm/index.js +21 -14
  148. package/dist/esm/index.mjs +21 -14
  149. package/dist/esm/index.native.js +21 -14
  150. package/dist/esm/keyboardAvoidance.mjs +40 -61
  151. package/dist/esm/keyboardAvoidance.mjs.map +1 -1
  152. package/dist/esm/keyboardAvoidance.native.js +40 -61
  153. package/dist/esm/keyboardAvoidance.native.js.map +1 -1
  154. package/dist/esm/nativeSheet.mjs +52 -61
  155. package/dist/esm/nativeSheet.mjs.map +1 -1
  156. package/dist/esm/nativeSheet.native.js +58 -69
  157. package/dist/esm/nativeSheet.native.js.map +1 -1
  158. package/dist/esm/types.mjs +0 -2
  159. package/dist/esm/types.native.js +0 -2
  160. package/dist/esm/useGestureHandlerPan.mjs +232 -239
  161. package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
  162. package/dist/esm/useGestureHandlerPan.native.js +241 -248
  163. package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
  164. package/dist/esm/useKeyboardControllerSheet.mjs +71 -71
  165. package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -1
  166. package/dist/esm/useKeyboardControllerSheet.native.js +92 -94
  167. package/dist/esm/useKeyboardControllerSheet.native.js.map +1 -1
  168. package/dist/esm/useSafeAreaInsets.mjs +3 -1
  169. package/dist/esm/useSafeAreaInsets.mjs.map +1 -1
  170. package/dist/esm/useSafeAreaInsets.native.js +15 -3
  171. package/dist/esm/useSafeAreaInsets.native.js.map +1 -1
  172. package/dist/esm/useSheetController.mjs +14 -12
  173. package/dist/esm/useSheetController.mjs.map +1 -1
  174. package/dist/esm/useSheetController.native.js +14 -12
  175. package/dist/esm/useSheetController.native.js.map +1 -1
  176. package/dist/esm/useSheetOffscreenSize.mjs +30 -35
  177. package/dist/esm/useSheetOffscreenSize.mjs.map +1 -1
  178. package/dist/esm/useSheetOffscreenSize.native.js +34 -39
  179. package/dist/esm/useSheetOffscreenSize.native.js.map +1 -1
  180. package/dist/esm/useSheetOpenState.mjs +50 -22
  181. package/dist/esm/useSheetOpenState.mjs.map +1 -1
  182. package/dist/esm/useSheetOpenState.native.js +55 -25
  183. package/dist/esm/useSheetOpenState.native.js.map +1 -1
  184. package/dist/esm/useSheetProviderProps.mjs +130 -138
  185. package/dist/esm/useSheetProviderProps.mjs.map +1 -1
  186. package/dist/esm/useSheetProviderProps.native.js +140 -149
  187. package/dist/esm/useSheetProviderProps.native.js.map +1 -1
  188. package/dist/esm/useSheetScrollViewGestures.mjs +159 -162
  189. package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -1
  190. package/dist/esm/useSheetScrollViewGestures.native.js +123 -130
  191. package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -1
  192. package/dist/esm/webViewport.mjs +26 -25
  193. package/dist/esm/webViewport.mjs.map +1 -1
  194. package/dist/esm/webViewport.native.js +29 -28
  195. package/dist/esm/webViewport.native.js.map +1 -1
  196. package/dist/jsx/GestureDetectorWrapper.mjs +19 -23
  197. package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -1
  198. package/dist/jsx/GestureDetectorWrapper.native.cjs +48 -0
  199. package/dist/jsx/GestureDetectorWrapper.native.js +32 -40
  200. package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -1
  201. package/dist/jsx/GestureSheetContext.mjs +15 -20
  202. package/dist/jsx/GestureSheetContext.mjs.map +1 -1
  203. package/dist/jsx/GestureSheetContext.native.cjs +49 -0
  204. package/dist/jsx/GestureSheetContext.native.js +30 -37
  205. package/dist/jsx/GestureSheetContext.native.js.map +1 -1
  206. package/dist/jsx/Sheet.mjs +191 -83
  207. package/dist/jsx/Sheet.mjs.map +1 -1
  208. package/dist/jsx/Sheet.native.cjs +234 -0
  209. package/dist/jsx/Sheet.native.js +212 -98
  210. package/dist/jsx/Sheet.native.js.map +1 -1
  211. package/dist/jsx/SheetContext.mjs +21 -5
  212. package/dist/jsx/SheetContext.mjs.map +1 -1
  213. package/dist/jsx/SheetContext.native.cjs +58 -0
  214. package/dist/jsx/SheetContext.native.js +45 -22
  215. package/dist/jsx/SheetContext.native.js.map +1 -1
  216. package/dist/jsx/SheetController.mjs +34 -30
  217. package/dist/jsx/SheetController.mjs.map +1 -1
  218. package/dist/jsx/SheetController.native.cjs +72 -0
  219. package/dist/jsx/SheetController.native.js +53 -58
  220. package/dist/jsx/SheetController.native.js.map +1 -1
  221. package/dist/jsx/SheetImplementationCustom.mjs +655 -580
  222. package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
  223. package/dist/jsx/SheetImplementationCustom.native.cjs +762 -0
  224. package/dist/jsx/SheetImplementationCustom.native.js +713 -644
  225. package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
  226. package/dist/jsx/SheetScrollView.mjs +277 -288
  227. package/dist/jsx/SheetScrollView.mjs.map +1 -1
  228. package/dist/jsx/SheetScrollView.native.cjs +326 -0
  229. package/dist/jsx/SheetScrollView.native.js +299 -319
  230. package/dist/jsx/SheetScrollView.native.js.map +1 -1
  231. package/dist/jsx/constants.mjs +5 -3
  232. package/dist/jsx/constants.mjs.map +1 -1
  233. package/dist/jsx/constants.native.cjs +37 -0
  234. package/dist/jsx/constants.native.js +22 -20
  235. package/dist/jsx/constants.native.js.map +1 -1
  236. package/dist/jsx/contexts.mjs +3 -3
  237. package/dist/jsx/contexts.mjs.map +1 -1
  238. package/dist/jsx/contexts.native.cjs +38 -0
  239. package/dist/jsx/contexts.native.js +20 -27
  240. package/dist/jsx/contexts.native.js.map +1 -1
  241. package/dist/jsx/controller.mjs +2 -2
  242. package/dist/jsx/controller.native.cjs +32 -0
  243. package/dist/jsx/controller.native.js +17 -17
  244. package/dist/jsx/controller.native.js.map +1 -1
  245. package/dist/jsx/gestureState.mjs +13 -11
  246. package/dist/jsx/gestureState.mjs.map +1 -1
  247. package/dist/jsx/gestureState.native.cjs +54 -0
  248. package/dist/jsx/gestureState.native.js +30 -30
  249. package/dist/jsx/gestureState.native.js.map +1 -1
  250. package/dist/jsx/helpers.mjs +7 -6
  251. package/dist/jsx/helpers.mjs.map +1 -1
  252. package/dist/jsx/helpers.native.cjs +35 -0
  253. package/dist/jsx/helpers.native.js +22 -24
  254. package/dist/jsx/helpers.native.js.map +1 -1
  255. package/dist/jsx/index.js +21 -14
  256. package/dist/jsx/index.mjs +21 -14
  257. package/dist/jsx/index.native.cjs +37 -0
  258. package/dist/jsx/index.native.js +16 -21
  259. package/dist/jsx/index.native.js.map +1 -1
  260. package/dist/jsx/keyboardAvoidance.mjs +40 -61
  261. package/dist/jsx/keyboardAvoidance.mjs.map +1 -1
  262. package/dist/jsx/keyboardAvoidance.native.cjs +75 -0
  263. package/dist/jsx/keyboardAvoidance.native.js +56 -78
  264. package/dist/jsx/keyboardAvoidance.native.js.map +1 -1
  265. package/dist/jsx/nativeSheet.mjs +52 -61
  266. package/dist/jsx/nativeSheet.mjs.map +1 -1
  267. package/dist/jsx/nativeSheet.native.cjs +94 -0
  268. package/dist/jsx/nativeSheet.native.js +70 -83
  269. package/dist/jsx/nativeSheet.native.js.map +1 -1
  270. package/dist/jsx/types.mjs +0 -2
  271. package/dist/jsx/types.native.cjs +19 -0
  272. package/dist/jsx/types.native.js +10 -10
  273. package/dist/jsx/types.native.js.map +1 -1
  274. package/dist/jsx/useGestureHandlerPan.mjs +232 -239
  275. package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
  276. package/dist/jsx/useGestureHandlerPan.native.cjs +273 -0
  277. package/dist/jsx/useGestureHandlerPan.native.js +254 -265
  278. package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
  279. package/dist/jsx/useKeyboardControllerSheet.mjs +71 -71
  280. package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -1
  281. package/dist/jsx/useKeyboardControllerSheet.native.cjs +119 -0
  282. package/dist/jsx/useKeyboardControllerSheet.native.js +100 -111
  283. package/dist/jsx/useKeyboardControllerSheet.native.js.map +1 -1
  284. package/dist/jsx/useSafeAreaInsets.mjs +3 -1
  285. package/dist/jsx/useSafeAreaInsets.mjs.map +1 -1
  286. package/dist/jsx/useSafeAreaInsets.native.cjs +51 -0
  287. package/dist/jsx/useSafeAreaInsets.native.js +30 -25
  288. package/dist/jsx/useSafeAreaInsets.native.js.map +1 -1
  289. package/dist/jsx/useSheetController.mjs +14 -12
  290. package/dist/jsx/useSheetController.mjs.map +1 -1
  291. package/dist/jsx/useSheetController.native.cjs +42 -0
  292. package/dist/jsx/useSheetController.native.js +28 -39
  293. package/dist/jsx/useSheetController.native.js.map +1 -1
  294. package/dist/jsx/useSheetOffscreenSize.mjs +30 -35
  295. package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -1
  296. package/dist/jsx/useSheetOffscreenSize.native.cjs +60 -0
  297. package/dist/jsx/useSheetOffscreenSize.native.js +48 -56
  298. package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -1
  299. package/dist/jsx/useSheetOpenState.mjs +50 -22
  300. package/dist/jsx/useSheetOpenState.mjs.map +1 -1
  301. package/dist/jsx/useSheetOpenState.native.cjs +88 -0
  302. package/dist/jsx/useSheetOpenState.native.js +74 -42
  303. package/dist/jsx/useSheetOpenState.native.js.map +1 -1
  304. package/dist/jsx/useSheetProviderProps.mjs +130 -138
  305. package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
  306. package/dist/jsx/useSheetProviderProps.native.cjs +176 -0
  307. package/dist/jsx/useSheetProviderProps.native.js +156 -174
  308. package/dist/jsx/useSheetProviderProps.native.js.map +1 -1
  309. package/dist/jsx/useSheetScrollViewGestures.mjs +159 -162
  310. package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -1
  311. package/dist/jsx/useSheetScrollViewGestures.native.cjs +150 -0
  312. package/dist/jsx/useSheetScrollViewGestures.native.js +136 -147
  313. package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -1
  314. package/dist/jsx/webViewport.mjs +26 -25
  315. package/dist/jsx/webViewport.mjs.map +1 -1
  316. package/dist/jsx/webViewport.native.cjs +79 -0
  317. package/dist/jsx/webViewport.native.js +50 -50
  318. package/dist/jsx/webViewport.native.js.map +1 -1
  319. package/package.json +33 -39
  320. package/src/Sheet.tsx +316 -77
  321. package/src/SheetContext.tsx +57 -7
  322. package/src/SheetController.tsx +7 -6
  323. package/src/SheetImplementationCustom.tsx +343 -140
  324. package/src/SheetScrollView.tsx +24 -13
  325. package/src/constants.tsx +3 -3
  326. package/src/helpers.tsx +0 -14
  327. package/src/index.ts +3 -6
  328. package/src/nativeSheet.tsx +5 -15
  329. package/src/types.tsx +104 -92
  330. package/src/useKeyboardControllerSheet.native.ts +7 -2
  331. package/src/useSafeAreaInsets.native.ts +20 -13
  332. package/src/useSheetController.tsx +15 -7
  333. package/src/useSheetOpenState.tsx +50 -4
  334. package/src/useSheetProviderProps.tsx +4 -27
  335. package/src/useSheetScrollViewGestures.ts +2 -2
  336. package/types/GestureDetectorWrapper.d.ts +1 -1
  337. package/types/GestureDetectorWrapper.d.ts.map +1 -1
  338. package/types/GestureSheetContext.d.ts +1 -1
  339. package/types/GestureSheetContext.d.ts.map +1 -1
  340. package/types/Sheet.d.ts +384 -135
  341. package/types/Sheet.d.ts.map +1 -1
  342. package/types/SheetContext.d.ts +28 -42
  343. package/types/SheetContext.d.ts.map +1 -1
  344. package/types/SheetController.d.ts +4 -2
  345. package/types/SheetController.d.ts.map +1 -1
  346. package/types/SheetImplementationCustom.d.ts +3 -35
  347. package/types/SheetImplementationCustom.d.ts.map +1 -1
  348. package/types/SheetScrollView.d.ts +57 -23
  349. package/types/SheetScrollView.d.ts.map +1 -1
  350. package/types/constants.d.ts +3 -2
  351. package/types/constants.d.ts.map +1 -1
  352. package/types/index.d.ts +1 -3
  353. package/types/index.d.ts.map +1 -1
  354. package/types/nativeSheet.d.ts.map +1 -1
  355. package/types/types.d.ts +28 -17
  356. package/types/types.d.ts.map +1 -1
  357. package/types/useKeyboardControllerSheet.native.d.ts.map +1 -1
  358. package/types/useSafeAreaInsets.native.d.ts +4 -12
  359. package/types/useSafeAreaInsets.native.d.ts.map +1 -1
  360. package/types/useSheetController.d.ts +6 -6
  361. package/types/useSheetController.d.ts.map +1 -1
  362. package/types/useSheetOffscreenSize.d.ts.map +1 -1
  363. package/types/useSheetOpenState.d.ts +3 -2
  364. package/types/useSheetOpenState.d.ts.map +1 -1
  365. package/types/useSheetProviderProps.d.ts +5 -8
  366. package/types/useSheetProviderProps.d.ts.map +1 -1
  367. package/types/useSheetScrollViewGestures.d.ts +2 -2
  368. package/types/useSheetScrollViewGestures.d.ts.map +1 -1
  369. package/.turbo/turbo-build.log +0 -2
  370. package/controller/index.cjs +0 -2
  371. package/controller/index.d.ts +0 -5
  372. package/controller/index.js +0 -2
  373. package/controller/index.native.cjs +0 -2
  374. package/controller/index.native.js +0 -2
  375. package/dist/cjs/createSheet.cjs +0 -194
  376. package/dist/cjs/createSheet.native.js +0 -204
  377. package/dist/cjs/createSheet.native.js.map +0 -1
  378. package/dist/cjs/setupGestureHandler.cjs +0 -55
  379. package/dist/cjs/setupGestureHandler.native.js +0 -60
  380. package/dist/cjs/setupGestureHandler.native.js.map +0 -1
  381. package/dist/cjs/useSheet.cjs +0 -29
  382. package/dist/cjs/useSheet.native.js +0 -34
  383. package/dist/cjs/useSheet.native.js.map +0 -1
  384. package/dist/esm/controller.mjs.map +0 -1
  385. package/dist/esm/controller.native.js.map +0 -1
  386. package/dist/esm/createSheet.mjs +0 -168
  387. package/dist/esm/createSheet.mjs.map +0 -1
  388. package/dist/esm/createSheet.native.js +0 -176
  389. package/dist/esm/createSheet.native.js.map +0 -1
  390. package/dist/esm/index.js.map +0 -1
  391. package/dist/esm/index.mjs.map +0 -1
  392. package/dist/esm/index.native.js.map +0 -1
  393. package/dist/esm/setupGestureHandler.mjs +0 -29
  394. package/dist/esm/setupGestureHandler.mjs.map +0 -1
  395. package/dist/esm/setupGestureHandler.native.js +0 -31
  396. package/dist/esm/setupGestureHandler.native.js.map +0 -1
  397. package/dist/esm/types.mjs.map +0 -1
  398. package/dist/esm/types.native.js.map +0 -1
  399. package/dist/esm/useSheet.mjs +0 -4
  400. package/dist/esm/useSheet.mjs.map +0 -1
  401. package/dist/esm/useSheet.native.js +0 -6
  402. package/dist/esm/useSheet.native.js.map +0 -1
  403. package/dist/jsx/controller.mjs.map +0 -1
  404. package/dist/jsx/createSheet.mjs +0 -168
  405. package/dist/jsx/createSheet.mjs.map +0 -1
  406. package/dist/jsx/createSheet.native.js +0 -204
  407. package/dist/jsx/createSheet.native.js.map +0 -1
  408. package/dist/jsx/index.js.map +0 -1
  409. package/dist/jsx/index.mjs.map +0 -1
  410. package/dist/jsx/setupGestureHandler.mjs +0 -29
  411. package/dist/jsx/setupGestureHandler.mjs.map +0 -1
  412. package/dist/jsx/setupGestureHandler.native.js +0 -60
  413. package/dist/jsx/setupGestureHandler.native.js.map +0 -1
  414. package/dist/jsx/types.mjs.map +0 -1
  415. package/dist/jsx/useSheet.mjs +0 -4
  416. package/dist/jsx/useSheet.mjs.map +0 -1
  417. package/dist/jsx/useSheet.native.js +0 -34
  418. package/dist/jsx/useSheet.native.js.map +0 -1
  419. package/next.md +0 -78
  420. package/setup-gesture-handler/index.cjs +0 -2
  421. package/setup-gesture-handler/index.js +0 -2
  422. package/setup-gesture-handler/index.native.cjs +0 -2
  423. package/setup-gesture-handler/index.native.js +0 -2
  424. package/setup-gesture-handler.cjs +0 -1
  425. package/src/createSheet.tsx +0 -309
  426. package/src/setupGestureHandler.ts +0 -43
  427. package/src/useSheet.tsx +0 -3
  428. package/test/keyboardAvoidance.test.ts +0 -269
  429. package/tsconfig.json +0 -57
  430. package/types/createSheet.d.ts +0 -195
  431. package/types/createSheet.d.ts.map +0 -1
  432. package/types/setupGestureHandler.d.ts +0 -11
  433. package/types/setupGestureHandler.d.ts.map +0 -1
  434. package/types/useSheet.d.ts +0 -2
  435. package/types/useSheet.d.ts.map +0 -1
@@ -1,3 +1,4 @@
1
+
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -5,35 +6,29 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
5
6
  var __getProtoOf = Object.getPrototypeOf;
6
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
7
8
  var __export = (target, all) => {
8
- for (var name in all) __defProp(target, name, {
9
- get: all[name],
10
- enumerable: true
11
- });
9
+ for (var name in all) __defProp(target, name, {
10
+ get: all[name],
11
+ enumerable: true
12
+ });
12
13
  };
13
14
  var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
16
- get: () => from[key],
17
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
18
- });
19
- }
20
- return to;
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
17
+ get: () => from[key],
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ return to;
21
22
  };
22
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
- // If the importer is in node compatibility mode or this is not an ESM
24
- // file that has been converted to a CommonJS file using a Babel-
25
- // compatible transform (i.e. "__esModule" has not been set), then set
26
- // "default" to the CommonJS "module.exports" for node compatibility.
27
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
28
- value: mod,
29
- enumerable: true
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
24
+ value: mod,
25
+ enumerable: true
30
26
  }) : target, mod));
31
- var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
32
- value: true
33
- }), mod);
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
28
  var SheetImplementationCustom_exports = {};
35
29
  __export(SheetImplementationCustom_exports, {
36
- SheetImplementationCustom: () => SheetImplementationCustom
30
+ SheetImplementationCustom: () => SheetImplementationCustom,
31
+ isSheetOverlayComponent: () => isSheetOverlayComponent
37
32
  });
38
33
  module.exports = __toCommonJS(SheetImplementationCustom_exports);
39
34
  require("@tamagui/adapt");
@@ -45,6 +40,7 @@ var import_portal = require("@tamagui/portal");
45
40
  var import_react = __toESM(require("react"), 1);
46
41
  var import_react_native = require("react-native-web");
47
42
  var import_contexts = require("./contexts.cjs");
43
+ var import_constants2 = require("./constants.cjs");
48
44
  var import_GestureDetectorWrapper = require("./GestureDetectorWrapper.cjs");
49
45
  var import_gestureState = require("./gestureState.cjs");
50
46
  var import_GestureSheetContext = require("./GestureSheetContext.cjs");
@@ -60,594 +56,667 @@ var import_useSheetProviderProps = require("./useSheetProviderProps.cjs");
60
56
  var import_jsx_runtime = require("react/jsx-runtime");
61
57
  const hiddenSize = 10000.1;
62
58
  const rnghRootStyleOpen = {
63
- width: "100%",
64
- height: "100%"
59
+ width: "100%",
60
+ height: "100%"
65
61
  };
66
62
  const rnghRootStyleClosed = {
67
- width: "100%",
68
- height: 0
63
+ width: "100%",
64
+ height: 0
69
65
  };
70
66
  let sheetHiddenStyleSheet = null;
67
+ const sheetEscapeLayers = [];
71
68
  const relativeDimensionTo = import_constants.isWeb ? "window" : "screen";
72
69
  function getStableViewportHeight() {
73
- if (import_constants.isWeb && typeof window !== "undefined") return (0, import_webViewport.getStableLayoutViewportHeight)();
74
- return import_react_native.Dimensions.get(relativeDimensionTo).height;
70
+ if (import_constants.isWeb && typeof window !== "undefined") return (0, import_webViewport.getStableLayoutViewportHeight)();
71
+ return import_react_native.Dimensions.get(relativeDimensionTo).height;
75
72
  }
76
- const SheetImplementationCustom = import_react.default.forwardRef(function SheetImplementationCustom2(props, forwardedRef) {
77
- const parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext);
78
- const safeAreaTopInset = (0, import_useSafeAreaInsets.useSafeAreaInsets)()?.top ?? 0;
79
- const {
80
- transition,
81
- transitionConfig: transitionConfigProp,
82
- modal = false,
83
- zIndex = parentSheet.zIndex + 1,
84
- moveOnKeyboardChange = false,
85
- unmountChildrenWhenHidden = false,
86
- disableTransparencyHide = false,
87
- portalProps,
88
- containerComponent: ContainerComponent = import_react.default.Fragment,
89
- onAnimationComplete
90
- } = props;
91
- const state = (0, import_useSheetOpenState.useSheetOpenState)(props);
92
- const [overlayComponent, setOverlayComponent] = import_react.default.useState(null);
93
- const providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state, {
94
- onOverlayComponent: setOverlayComponent
95
- });
96
- const {
97
- frameSize,
98
- setFrameSize,
99
- dismissOnSnapToBottom,
100
- snapPoints,
101
- snapPointsMode,
102
- hasFit,
103
- position,
104
- setPosition,
105
- scrollBridge,
106
- screenSize,
107
- setMaxContentSize,
108
- maxSnapPoint
109
- } = providerProps;
110
- const {
111
- open,
112
- controller,
113
- isHidden
114
- } = state;
115
- const openRef = import_react.default.useRef(open);
116
- openRef.current = open;
117
- const sheetRef = import_react.default.useRef(void 0);
118
- const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef);
119
- const {
120
- animationDriver
121
- } = (0, import_core.useConfiguration)();
122
- if (!animationDriver) throw new Error(`Sheet requires an animation driver to be set`);
123
- const transitionConfig = (() => {
124
- if (transitionConfigProp) return transitionConfigProp;
125
- const [animationProp, animationPropConfig] = !transition ? [] : Array.isArray(transition) ? transition : [transition];
126
- if (animationProp && animationDriver.animations?.[animationProp]) return {
127
- ...animationDriver.animations[animationProp],
128
- ...animationPropConfig
129
- };
130
- return null;
131
- })();
132
- const [isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(false);
133
- const shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet && (0, import_portal.needsPortalRepropagation)();
134
- const sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext);
135
- const onInnerSheet = import_react.default.useCallback(hasChild => {
136
- setIsShowingInnerSheet(hasChild);
137
- }, []);
138
- const {
139
- keyboardHeight,
140
- isKeyboardVisible,
141
- dismissKeyboard,
142
- pauseKeyboardHandler,
143
- flushPendingHide
144
- } = (0, import_useKeyboardControllerSheet.useKeyboardControllerSheet)({
145
- enabled: Boolean(moveOnKeyboardChange)
146
- });
147
- const stableFrameSize = import_react.default.useRef(frameSize);
148
- import_react.default.useEffect(() => {
149
- if (open && frameSize) stableFrameSize.current = frameSize;
150
- }, [open, frameSize]);
151
- const isWebKbSheet = import_constants.isWeb && hasFit && moveOnKeyboardChange;
152
- const isNativeKbFitSheet = !import_constants.isWeb && hasFit && Boolean(moveOnKeyboardChange);
153
- const preKeyboardFrameSize = import_react.default.useRef(0);
154
- import_react.default.useEffect(() => {
155
- if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) preKeyboardFrameSize.current = frameSize;
156
- }, [isNativeKbFitSheet, open, isKeyboardVisible, frameSize]);
157
- const effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
158
- const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
159
- const positions = import_react.default.useMemo(() => snapPoints.map(point => getYPositions(snapPointsMode, point, effScreenSize, effectiveFrameSize)), [effScreenSize, effectiveFrameSize, snapPoints, snapPointsMode]);
160
- const [isDragging, setIsDragging_] = import_react.default.useState(false);
161
- const isDraggingRef = import_react.default.useRef(false);
162
- const setIsDragging = import_react.default.useCallback(val => {
163
- isDraggingRef.current = val;
164
- pauseKeyboardHandler.current = val;
165
- setIsDragging_(val);
166
- if (!val) flushPendingHide();
167
- }, [pauseKeyboardHandler, flushPendingHide]);
168
- const activePositionsRef = import_react.default.useRef(positions);
169
- const activePositions = import_react.default.useMemo(() => {
170
- if (isDragging || isDraggingRef.current) return activePositionsRef.current;
171
- let result;
172
- if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;else result = positions.map(p => (0, import_keyboardAvoidance.getKeyboardAdjustedSheetY)({
173
- sheetY: p,
174
- screenSize: effScreenSize,
175
- isKeyboardVisible,
176
- keyboardHeight,
177
- shouldTranslate: true,
178
- safeAreaTop: import_constants.isWeb ? (0, import_webViewport.getWebVisualViewportOffsetTop)() : safeAreaTopInset
179
- }));
180
- activePositionsRef.current = result;
181
- return result;
182
- }, [positions, isKeyboardVisible, keyboardHeight, effScreenSize, isDragging, safeAreaTopInset]);
183
- const keyboardOccludedHeight = (0, import_keyboardAvoidance.getKeyboardOccludedHeight)({
184
- frameSize: effectiveFrameSize,
185
- isKeyboardVisible,
186
- keyboardHeight,
187
- screenSize: effScreenSize,
188
- sheetY: position >= 0 ? activePositions[position] : void 0
189
- });
190
- const keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0 ? preKeyboardFrameSize.current : 0;
191
- const {
192
- useAnimatedNumber,
193
- useAnimatedNumberStyle
194
- } = animationDriver;
195
- const AnimatedView = animationDriver.View ?? import_core.View;
196
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
197
- if (!(sheetInsideSheet && open)) return;
198
- sheetInsideSheet(true);
199
- return () => {
200
- sheetInsideSheet(false);
201
- };
202
- }, [sheetInsideSheet, open]);
203
- const nextParentContext = import_react.default.useMemo(() => ({
204
- zIndex
205
- }), [zIndex]);
206
- const startPosition = (0, import_core.useDidFinishSSR)() && screenSize ? screenSize : hiddenSize;
207
- const animatedNumber = useAnimatedNumber(startPosition);
208
- const at = import_react.default.useRef(startPosition);
209
- const hasntMeasured = at.current === hiddenSize;
210
- const [disableAnimation, setDisableAnimation] = (0, import_react.useState)(hasntMeasured);
211
- const skipAdaptAnimation = import_react.default.useRef(false);
212
- if (controller?.skipNextAnimation) skipAdaptAnimation.current = true;
213
- const hasScrollView = import_react.default.useRef(false);
214
- const opacityFallbackTimer = import_react.default.useRef(null);
215
- const syncAnimatedPosition = (0, import_core.useEvent)(value => {
216
- at.current = value;
217
- scrollBridge.paneY = value;
218
- const minY = activePositions[0];
219
- const wasAtTop = scrollBridge.isAtTop;
220
- const nowAtTop = value <= minY + 5;
221
- if (wasAtTop === nowAtTop) return;
222
- scrollBridge.isAtTop = nowAtTop;
223
- if (nowAtTop) {
224
- if (scrollBridge.lockScrollAtTop) {
225
- if (scrollBridge.y > 0) {
226
- scrollBridge.forceScrollTo?.(0);
227
- scrollBridge.y = 0;
228
- }
229
- scrollBridge.scrollLockY = 0;
230
- scrollBridge.setScrollEnabled?.(false, 0);
231
- return;
232
- }
233
- if (scrollBridge.y > 0) {
234
- scrollBridge.forceScrollTo?.(0);
235
- scrollBridge.y = 0;
236
- }
237
- scrollBridge.scrollLockY = void 0;
238
- scrollBridge.setScrollEnabled?.(true);
239
- } else {
240
- scrollBridge.scrollLockY = 0;
241
- scrollBridge.setScrollEnabled?.(false);
242
- }
243
- });
244
- const setAnimatedPositionDirect = (0, import_core.useEvent)(value => {
245
- syncAnimatedPosition(value);
246
- animatedNumber.setValue(value, {
247
- type: "direct"
248
- });
249
- });
250
- const getAnimatedPosition = (0, import_core.useEvent)(() => {
251
- const value = animatedNumber.getValue();
252
- syncAnimatedPosition(value);
253
- return value;
254
- });
255
- function stopSpring() {
256
- animatedNumber.stop();
257
- if (scrollBridge.onFinishAnimate) {
258
- scrollBridge.onFinishAnimate();
259
- scrollBridge.onFinishAnimate = void 0;
260
- }
261
- }
262
- const animateTo = (0, import_core.useEvent)((position2, animationOverride) => {
263
- if (frameSize === 0) return;
264
- const closeTarget = import_constants.isWeb ? Math.max(effScreenSize, (0, import_webViewport.getMaxViewportHeight)()) : effScreenSize;
265
- let toValue = isHidden || position2 === -1 ? closeTarget : activePositions[position2];
266
- if (at.current === toValue) return;
267
- at.current = toValue;
268
- stopSpring();
269
- const isOpenAnimation = position2 !== -1 && !isHidden;
270
- if (opacityFallbackTimer.current) {
271
- clearTimeout(opacityFallbackTimer.current);
272
- opacityFallbackTimer.current = null;
273
- }
274
- const animationCompleteCallback = () => {
275
- if (at.current !== toValue) return;
276
- syncAnimatedPosition(toValue);
277
- if (opacityFallbackTimer.current) {
278
- clearTimeout(opacityFallbackTimer.current);
279
- opacityFallbackTimer.current = null;
280
- }
281
- if (!isOpenAnimation && !openRef.current) setOpacity(0);
282
- onAnimationComplete?.({
283
- open: isOpenAnimation
284
- });
285
- controller?.onAnimationComplete?.({
286
- open: isOpenAnimation
287
- });
288
- };
289
- if (!isOpenAnimation) opacityFallbackTimer.current = setTimeout(() => {
290
- opacityFallbackTimer.current = null;
291
- if (!openRef.current) setOpacity(0);
292
- }, 1e3);
293
- if (skipAdaptAnimation.current) {
294
- skipAdaptAnimation.current = false;
295
- animatedNumber.setValue(toValue, {
296
- type: "timing",
297
- duration: 0
298
- }, animationCompleteCallback);
299
- return;
300
- }
301
- animatedNumber.setValue(toValue, animationOverride || {
302
- type: "spring",
303
- ...transitionConfig
304
- }, animationCompleteCallback);
305
- });
306
- (0, import_constants.useIsomorphicLayoutEffect)(() => {
307
- if (hasntMeasured && screenSize && frameSize) {
308
- at.current = screenSize;
309
- animatedNumber.setValue(screenSize, {
310
- type: "timing",
311
- duration: 0
312
- }, () => {
313
- syncAnimatedPosition(screenSize);
314
- setTimeout(() => {
315
- setDisableAnimation(false);
316
- }, 10);
317
- });
318
- return;
319
- }
320
- if (disableAnimation) return;
321
- if (isDraggingRef.current) return;
322
- if (!frameSize || !screenSize || isHidden || hasntMeasured && !open) return;
323
- animateTo(position);
324
- if (position === -1) {
325
- scrollBridge.scrollLock = false;
326
- scrollBridge.scrollStartY = -1;
327
- }
328
- if (open && position >= 0) {
329
- const isTopPosition = position === 0;
330
- scrollBridge.isAtTop = isTopPosition;
331
- if (isTopPosition) {
332
- scrollBridge.scrollLockY = void 0;
333
- scrollBridge.setScrollEnabled?.(true);
334
- } else {
335
- scrollBridge.scrollLockY = 0;
336
- scrollBridge.setScrollEnabled?.(false);
337
- }
338
- }
339
- }, [hasntMeasured, disableAnimation, isHidden, frameSize, screenSize, open, position]);
340
- const disableDrag = props.disableDrag ?? controller?.disableDrag;
341
- (0, import_core.useThemeName)();
342
- const [blockPan, setBlockPan] = import_react.default.useState(false);
343
- const panResponder = import_react.default.useMemo(() => {
344
- if (disableDrag) return;
345
- if (!frameSize) return;
346
- if (isShowingInnerSheet) return;
347
- const minY = activePositions[0];
348
- scrollBridge.paneMinY = minY;
349
- let startY = at.current;
350
- function setPanning(val) {
351
- setIsDragging(val);
352
- if (!sheetHiddenStyleSheet) {
353
- sheetHiddenStyleSheet = document.createElement("style");
354
- if (typeof document.head !== "undefined") document.head.appendChild(sheetHiddenStyleSheet);
355
- }
356
- if (!val) sheetHiddenStyleSheet.innerText = "";else sheetHiddenStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }";
357
- }
358
- const release = ({
359
- vy
360
- }) => {
361
- scrollBridge.setParentDragging(false);
362
- if (scrollBridge.scrollLock) return;
363
- isExternalDrag = false;
364
- previouslyScrolling = false;
365
- setPanning(false);
366
- const currentPos = at.current;
367
- const end = currentPos + frameSize * vy * .2;
368
- const closestPoint = (0, import_keyboardAvoidance.getSheetReleasePosition)({
369
- positions: activePositions,
370
- projectedEnd: end,
371
- currentPosition: currentPos,
372
- frameSize,
373
- dismissOnSnapToBottom,
374
- snapPointsMode,
375
- isKeyboardVisible,
376
- isWeb: import_constants.isWeb
377
- });
378
- setPosition(closestPoint);
379
- animateTo(closestPoint);
380
- };
381
- const finish = (_e, state2) => {
382
- release({
383
- vy: state2.vy,
384
- dragAt: state2.dy
385
- });
386
- };
387
- let previouslyScrolling = false;
388
- const onMoveShouldSet = (e, {
389
- dy
390
- }) => {
391
- function getShouldSet() {
392
- if (e.target === providerProps.handleRef.current) return true;
393
- if (scrollBridge.scrollNodeTouched) return false;
394
- if (scrollBridge.hasScrollableContent === true) {
395
- if (scrollBridge.scrollLock) return false;
396
- const isScrolled = scrollBridge.y !== 0;
397
- const isDraggingUp = dy < 0;
398
- const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
399
- if (isScrolled) return false;
400
- if (isNearTop) {
401
- if (hasScrollView.current && isDraggingUp) return false;
402
- }
403
- }
404
- return Math.abs(dy) > 10;
405
- }
406
- const granted = getShouldSet();
407
- if (granted) scrollBridge.setParentDragging(true);
408
- return granted;
409
- };
410
- const grant = () => {
411
- setPanning(true);
412
- stopSpring();
413
- startY = getAnimatedPosition();
414
- };
415
- let isExternalDrag = false;
416
- scrollBridge.startPanDrag = () => {
417
- isExternalDrag = true;
418
- grant();
419
- };
420
- scrollBridge.drag = dy => {
421
- if (!isExternalDrag) {
422
- isExternalDrag = true;
423
- grant();
424
- }
425
- const to = dy + startY;
426
- setAnimatedPositionDirect((0, import_helpers.resisted)(to, minY));
427
- };
428
- scrollBridge.release = release;
429
- scrollBridge.snapToPosition = positionIndex => {
430
- isExternalDrag = false;
431
- setPanning(false);
432
- setPosition(positionIndex);
433
- animateTo(positionIndex);
434
- };
435
- return import_react_native.PanResponder.create({
436
- onMoveShouldSetPanResponder: onMoveShouldSet,
437
- onPanResponderTerminationRequest: () => false,
438
- onPanResponderGrant: grant,
439
- onPanResponderMove: (_e, {
440
- dy
441
- }) => {
442
- const toFull = dy + startY;
443
- const to = (0, import_helpers.resisted)(toFull, minY);
444
- if (to <= minY) scrollBridge.setParentDragging(false);else scrollBridge.setParentDragging(true);
445
- setAnimatedPositionDirect(to);
446
- },
447
- onPanResponderEnd: finish,
448
- onPanResponderTerminate: finish,
449
- onPanResponderRelease: finish
450
- });
451
- }, [disableDrag, isShowingInnerSheet, animateTo, frameSize, activePositions, setPosition, dismissOnSnapToBottom, snapPointsMode]);
452
- import_react.default.useEffect(() => {
453
- if (isDragging || isHidden || !open || disableAnimation) return;
454
- if (!frameSize || !screenSize) return;
455
- animateTo(position, {
456
- type: "timing",
457
- duration: 250
458
- });
459
- }, [isKeyboardVisible, keyboardHeight]);
460
- const wasDragging = import_react.default.useRef(false);
461
- import_react.default.useEffect(() => {
462
- if (isDragging) {
463
- wasDragging.current = true;
464
- return;
465
- }
466
- if (!wasDragging.current) return;
467
- wasDragging.current = false;
468
- if (!frameSize || !screenSize || isHidden || !open) return;
469
- animateTo(position);
470
- }, [isDragging]);
471
- import_react.default.useEffect(() => {
472
- if (!open && isKeyboardVisible) {
473
- dismissKeyboard();
474
- pauseKeyboardHandler.current = false;
475
- flushPendingHide();
476
- }
477
- }, [open]);
478
- const {
479
- panGesture,
480
- panGestureRef,
481
- gestureHandlerEnabled
482
- } = (0, import_useGestureHandlerPan.useGestureHandlerPan)({
483
- positions: activePositions,
484
- frameSize,
485
- setPosition,
486
- animateTo,
487
- stopSpring,
488
- scrollBridge,
489
- setIsDragging,
490
- getCurrentPosition: getAnimatedPosition,
491
- resisted: import_helpers.resisted,
492
- disableDrag,
493
- isShowingInnerSheet,
494
- setAnimatedPosition: setAnimatedPositionDirect,
495
- dismissOnSnapToBottom,
496
- snapPointsMode,
497
- isKeyboardVisible,
498
- pauseKeyboardHandler
499
- });
500
- const ignoreLayoutForKeyboard = (0, import_core.useEvent)(() => import_constants.isWeb && moveOnKeyboardChange && (0, import_webViewport.getWebKeyboardResizeHeight)() >= import_webViewport.MIN_KEYBOARD_HEIGHT);
501
- const handleAnimationViewLayout = (0, import_core.useEvent)(e => {
502
- if (!open && stableFrameSize.current !== 0) return;
503
- const layoutHeight = e.nativeEvent?.layout.height;
504
- if (ignoreLayoutForKeyboard() && frameSize > 0) return;
505
- const next = modal ? Math.min(layoutHeight, getStableViewportHeight()) : layoutHeight;
506
- if (!next) return;
507
- setFrameSize(Math.round(next));
508
- });
509
- const handleMaxContentViewLayout = import_react.default.useCallback(e => {
510
- if (ignoreLayoutForKeyboard() && screenSize > 0) return;
511
- const next = Math.min(e.nativeEvent?.layout.height, getStableViewportHeight());
512
- if (!next) return;
513
- setMaxContentSize(Math.round(next));
514
- }, [ignoreLayoutForKeyboard, screenSize]);
515
- const animatedStyle = useAnimatedNumberStyle(animatedNumber, import_react.default.useCallback(val => {
516
- "worklet";
517
-
518
- return {
519
- transform: [{
520
- translateY: frameSize === 0 ? hiddenSize : val
521
- }]
522
- };
523
- }, [frameSize]));
524
- const [opacity, setOpacity] = import_react.default.useState(open ? 1 : 0);
525
- if (open && opacity === 0) {
526
- setOpacity(1);
527
- if (opacityFallbackTimer.current) {
528
- clearTimeout(opacityFallbackTimer.current);
529
- opacityFallbackTimer.current = null;
530
- }
531
- }
532
- const forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${import_constants.isWeb ? modal ? "dvh" : "%" : "%"}` : maxSnapPoint;
533
- const setHasScrollView = import_react.default.useCallback(val => {
534
- hasScrollView.current = val;
535
- }, []);
536
- let contents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
537
- disable: !open,
538
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
539
- value: nextParentContext,
540
- children: /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_SheetContext.SheetProvider, {
541
- ...providerProps,
542
- keyboardOccludedHeight,
543
- isKeyboardVisible,
544
- keyboardStableFrameHeight,
545
- setHasScrollView,
546
- children: /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_GestureSheetContext.GestureSheetProvider, {
547
- isDragging,
548
- blockPan,
549
- setBlockPan,
550
- panGesture,
551
- panGestureRef,
552
- children: [/* @__PURE__ */(0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
553
- custom: {
554
- open
555
- },
556
- children: shouldHideParentSheet || !open ? null : overlayComponent
557
- }), snapPointsMode !== "percent" && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
558
- style: {
559
- opacity: 0,
560
- position: "absolute",
561
- top: 0,
562
- left: 0,
563
- right: 0,
564
- bottom: 0,
565
- pointerEvents: "none"
566
- },
567
- onLayout: handleMaxContentViewLayout
568
- }), /* @__PURE__ */(0, import_jsx_runtime.jsx)(AnimatedView, {
569
- ref,
570
- onLayout: handleAnimationViewLayout,
571
- transition: isDragging || disableAnimation ? null : transition,
572
- disableClassName: true,
573
- style: [{
574
- position: "absolute",
575
- zIndex,
576
- width: "100%",
577
- height: forcedContentHeight,
578
- minHeight: forcedContentHeight,
579
- opacity: shouldHideParentSheet ? 0 : disableTransparencyHide ? 1 : opacity,
580
- ...((shouldHideParentSheet || !open) && {
581
- pointerEvents: "none"
582
- })
583
- }, animatedStyle],
584
- children: gestureHandlerEnabled && panGesture ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_GestureDetectorWrapper.GestureDetectorWrapper, {
585
- gesture: panGesture,
586
- style: {
587
- flex: 1
588
- },
589
- children: props.children
590
- }) : /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_react_native.View, {
591
- ...panResponder?.panHandlers,
592
- style: {
593
- flex: 1,
594
- width: "100%",
595
- height: "100%"
596
- },
597
- children: props.children
598
- })
599
- })]
600
- })
601
- })
602
- })
603
- });
604
- const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true;
605
- if (modal) {
606
- const RNGHRoot = (0, import_gestureState.getGestureHandlerState)().RootView;
607
- const mountedContents = shouldMountChildren ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(ContainerComponent, {
608
- children: contents
609
- }) : null;
610
- const modalContents = /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_portal.Portal, {
611
- stackZIndex: zIndex,
612
- ...portalProps,
613
- children: mountedContents && RNGHRoot ? /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNGHRoot, {
614
- style: open ? rnghRootStyleOpen : rnghRootStyleClosed,
615
- children: mountedContents
616
- }) : mountedContents
617
- });
618
- if (import_constants.isWeb) return modalContents;
619
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, {
620
- value: onInnerSheet,
621
- children: modalContents
622
- });
623
- }
624
- return contents;
73
+ const SheetImplementationCustom = (0, import_core.createRefComponent)(function SheetImplementationCustom2(props, forwardedRef) {
74
+ const parentSheet = import_react.default.useContext(import_contexts.ParentSheetContext);
75
+ const safeAreaTopInset = (0, import_useSafeAreaInsets.useSafeAreaInsets)()?.top ?? 0;
76
+ const { transition, transitionConfig: transitionConfigProp, modal = false, zIndex = parentSheet.zIndex + 1, moveOnKeyboardChange = false, unmountChildrenWhenHidden = false, disableHideWhenClosed = false, portalProps, containerComponent: ContainerComponent = import_react.default.Fragment, onTransition } = props;
77
+ const state = (0, import_useSheetOpenState.useSheetOpenState)(props);
78
+ const providerProps = (0, import_useSheetProviderProps.useSheetProviderProps)(props, state);
79
+ const { frameSize, setFrameSize, dismissOnSnapToBottom, snapPoints, snapPointsMode, hasFit, position, setPosition, scrollBridge, screenSize, setMaxContentSize, maxSnapPoint } = providerProps;
80
+ const { open, controller, isHidden } = state;
81
+ const openRef = import_react.default.useRef(open);
82
+ openRef.current = open;
83
+ const sheetRef = import_react.default.useRef(void 0);
84
+ const ref = (0, import_compose_refs.useComposedRefs)(forwardedRef, sheetRef, providerProps.contentRef);
85
+ const animationDriver = (0, import_core.useAnimationDriver)();
86
+ const transitionConfig = (() => {
87
+ if (transitionConfigProp) return transitionConfigProp;
88
+ const [animationProp, animationPropConfig] = !transition ? [] : Array.isArray(transition) ? transition : [transition];
89
+ const namedConfig = animationProp && animationDriver.animations?.[animationProp];
90
+ if (namedConfig) {
91
+ if (typeof namedConfig === "string") return animationPropConfig ?? null;
92
+ return {
93
+ ...namedConfig,
94
+ ...animationPropConfig
95
+ };
96
+ }
97
+ return null;
98
+ })();
99
+ const [isShowingInnerSheet, setIsShowingInnerSheet] = import_react.default.useState(false);
100
+ const shouldHideParentSheet = !import_constants.isWeb && modal && isShowingInnerSheet && (0, import_portal.needsPortalRepropagation)();
101
+ const sheetInsideSheet = import_react.default.useContext(import_contexts.SheetInsideSheetContext);
102
+ const onInnerSheet = import_react.default.useCallback((hasChild) => {
103
+ setIsShowingInnerSheet(hasChild);
104
+ }, []);
105
+ const { keyboardHeight, isKeyboardVisible, dismissKeyboard, pauseKeyboardHandler, flushPendingHide } = (0, import_useKeyboardControllerSheet.useKeyboardControllerSheet)({ enabled: Boolean(moveOnKeyboardChange) });
106
+ const stableFrameSize = import_react.default.useRef(frameSize);
107
+ import_react.default.useEffect(() => {
108
+ if (open && frameSize) stableFrameSize.current = frameSize;
109
+ }, [open, frameSize]);
110
+ const isWebKbSheet = import_constants.isWeb && hasFit && moveOnKeyboardChange;
111
+ const isNativeKbFitSheet = !import_constants.isWeb && hasFit && Boolean(moveOnKeyboardChange);
112
+ const preKeyboardFrameSize = import_react.default.useRef(0);
113
+ import_react.default.useEffect(() => {
114
+ if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) preKeyboardFrameSize.current = frameSize;
115
+ }, [
116
+ isNativeKbFitSheet,
117
+ open,
118
+ isKeyboardVisible,
119
+ frameSize
120
+ ]);
121
+ const effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
122
+ const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
123
+ const positions = import_react.default.useMemo(() => snapPoints.map((point) => getYPositions(snapPointsMode, point, effScreenSize, effectiveFrameSize)), [
124
+ effScreenSize,
125
+ effectiveFrameSize,
126
+ snapPoints,
127
+ snapPointsMode
128
+ ]);
129
+ const [isDragging, setIsDragging_] = import_react.default.useState(false);
130
+ const isDraggingRef = import_react.default.useRef(false);
131
+ const setIsDragging = import_react.default.useCallback((val) => {
132
+ isDraggingRef.current = val;
133
+ pauseKeyboardHandler.current = val;
134
+ setIsDragging_(val);
135
+ if (!val) flushPendingHide();
136
+ }, [pauseKeyboardHandler, flushPendingHide]);
137
+ const activePositionsRef = import_react.default.useRef(positions);
138
+ const activePositions = import_react.default.useMemo(() => {
139
+ if (isDragging || isDraggingRef.current) return activePositionsRef.current;
140
+ let result;
141
+ if (!isKeyboardVisible || keyboardHeight <= 0) result = positions;
142
+ else result = positions.map((p) => (0, import_keyboardAvoidance.getKeyboardAdjustedSheetY)({
143
+ sheetY: p,
144
+ screenSize: effScreenSize,
145
+ isKeyboardVisible,
146
+ keyboardHeight,
147
+ shouldTranslate: true,
148
+ safeAreaTop: import_constants.isWeb ? (0, import_webViewport.getWebVisualViewportOffsetTop)() : safeAreaTopInset
149
+ }));
150
+ activePositionsRef.current = result;
151
+ return result;
152
+ }, [
153
+ positions,
154
+ isKeyboardVisible,
155
+ keyboardHeight,
156
+ effScreenSize,
157
+ isDragging,
158
+ safeAreaTopInset
159
+ ]);
160
+ const keyboardOccludedHeight = (0, import_keyboardAvoidance.getKeyboardOccludedHeight)({
161
+ frameSize: effectiveFrameSize,
162
+ isKeyboardVisible,
163
+ keyboardHeight,
164
+ screenSize: effScreenSize,
165
+ sheetY: position >= 0 ? activePositions[position] : void 0
166
+ });
167
+ const keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0 ? frameSize : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0 ? preKeyboardFrameSize.current : 0;
168
+ const AnimatedView = animationDriver.View ?? import_core.View;
169
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
170
+ if (!(sheetInsideSheet && open)) return;
171
+ sheetInsideSheet(true);
172
+ return () => {
173
+ sheetInsideSheet(false);
174
+ };
175
+ }, [sheetInsideSheet, open]);
176
+ const nextParentContext = import_react.default.useMemo(() => ({ zIndex }), [zIndex]);
177
+ const startPosition = (0, import_core.useDidFinishSSR)() && screenSize ? screenSize : hiddenSize;
178
+ const animatedNumber = (0, import_core.useAnimatedNumber)(startPosition);
179
+ const at = import_react.default.useRef(startPosition);
180
+ const hasntMeasured = at.current === hiddenSize;
181
+ const [disableAnimation, setDisableAnimation] = (0, import_react.useState)(hasntMeasured);
182
+ const skipAdaptAnimation = import_react.default.useRef(false);
183
+ if (controller?.skipNextAnimation) skipAdaptAnimation.current = true;
184
+ const hasScrollView = import_react.default.useRef(false);
185
+ const lastPositionIndexRef = import_react.default.useRef(-1);
186
+ const pendingTransitionRef = import_react.default.useRef(null);
187
+ const emitTransition = (0, import_core.useEvent)((phase, event, finished) => {
188
+ const e = {
189
+ phase,
190
+ cause: event.cause,
191
+ position: event.position
192
+ };
193
+ if (phase === "end") e.finished = finished;
194
+ onTransition?.(e);
195
+ controller?.onTransition?.(e);
196
+ });
197
+ const syncAnimatedPosition = (0, import_core.useEvent)((value) => {
198
+ at.current = value;
199
+ scrollBridge.paneY = value;
200
+ const minY = activePositions[0];
201
+ const wasAtTop = scrollBridge.isAtTop;
202
+ const nowAtTop = value <= minY + 5;
203
+ if (wasAtTop === nowAtTop) return;
204
+ scrollBridge.isAtTop = nowAtTop;
205
+ if (nowAtTop) {
206
+ if (scrollBridge.lockScrollAtTop) {
207
+ if (scrollBridge.y > 0) {
208
+ scrollBridge.forceScrollTo?.(0);
209
+ scrollBridge.y = 0;
210
+ }
211
+ scrollBridge.scrollLockY = 0;
212
+ scrollBridge.setScrollEnabled?.(false, 0);
213
+ return;
214
+ }
215
+ if (scrollBridge.y > 0) {
216
+ scrollBridge.forceScrollTo?.(0);
217
+ scrollBridge.y = 0;
218
+ }
219
+ scrollBridge.scrollLockY = void 0;
220
+ scrollBridge.setScrollEnabled?.(true);
221
+ } else {
222
+ scrollBridge.scrollLockY = 0;
223
+ scrollBridge.setScrollEnabled?.(false);
224
+ }
225
+ });
226
+ const setAnimatedPositionDirect = (0, import_core.useEvent)((value) => {
227
+ syncAnimatedPosition(value);
228
+ animatedNumber.setValue(value, { type: "direct" });
229
+ });
230
+ const getAnimatedPosition = (0, import_core.useEvent)(() => {
231
+ const value = animatedNumber.getValue();
232
+ syncAnimatedPosition(value);
233
+ return value;
234
+ });
235
+ function stopSpring() {
236
+ animatedNumber.stop();
237
+ if (scrollBridge.onFinishAnimate) {
238
+ scrollBridge.onFinishAnimate();
239
+ scrollBridge.onFinishAnimate = void 0;
240
+ }
241
+ }
242
+ const animateTo = (0, import_core.useEvent)((position2, animationOverride) => {
243
+ if (frameSize === 0) return;
244
+ const closeTarget = import_constants.isWeb ? Math.max(effScreenSize, (0, import_webViewport.getMaxViewportHeight)()) : effScreenSize;
245
+ const isDismissPosition = dismissOnSnapToBottom && position2 === activePositions.length - 1;
246
+ const isOpenAnimation = position2 !== -1 && !isHidden && !isDismissPosition;
247
+ const toValue = isOpenAnimation ? activePositions[position2] : closeTarget;
248
+ if (at.current === toValue) {
249
+ if (isDismissPosition) {
250
+ if (pendingTransitionRef.current) {
251
+ emitTransition("end", pendingTransitionRef.current, false);
252
+ pendingTransitionRef.current = null;
253
+ }
254
+ stopSpring();
255
+ const event2 = {
256
+ cause: "close",
257
+ position: toValue
258
+ };
259
+ lastPositionIndexRef.current = -1;
260
+ emitTransition("start", event2);
261
+ syncAnimatedPosition(toValue);
262
+ setIsFullyClosed(true);
263
+ emitTransition("end", event2, true);
264
+ }
265
+ return;
266
+ }
267
+ at.current = toValue;
268
+ const cause = !isOpenAnimation ? "close" : lastPositionIndexRef.current < 0 ? "open" : "snap";
269
+ lastPositionIndexRef.current = isOpenAnimation ? position2 : -1;
270
+ const event = {
271
+ cause,
272
+ position: toValue
273
+ };
274
+ if (pendingTransitionRef.current) {
275
+ emitTransition("end", pendingTransitionRef.current, false);
276
+ pendingTransitionRef.current = null;
277
+ }
278
+ stopSpring();
279
+ const animationCompleteCallback = () => {
280
+ if (at.current !== toValue) return;
281
+ syncAnimatedPosition(toValue);
282
+ pendingTransitionRef.current = null;
283
+ if (!isOpenAnimation && !openRef.current) setIsFullyClosed(true);
284
+ emitTransition("end", event, true);
285
+ };
286
+ pendingTransitionRef.current = event;
287
+ emitTransition("start", event);
288
+ if (skipAdaptAnimation.current) {
289
+ skipAdaptAnimation.current = false;
290
+ animatedNumber.setValue(toValue, {
291
+ type: "timing",
292
+ duration: 0
293
+ }, animationCompleteCallback);
294
+ return;
295
+ }
296
+ const resolvedConfig = animationOverride || {
297
+ type: "spring",
298
+ ...transitionConfig
299
+ };
300
+ const springConfig = !resolvedConfig.type || resolvedConfig.type === "spring" ? {
301
+ restDisplacementThreshold: 1,
302
+ restSpeedThreshold: 10,
303
+ energyThreshold: 1e-5,
304
+ ...resolvedConfig
305
+ } : resolvedConfig;
306
+ animatedNumber.setValue(toValue, springConfig, animationCompleteCallback);
307
+ });
308
+ (0, import_constants.useIsomorphicLayoutEffect)(() => {
309
+ if (hasntMeasured && screenSize && frameSize) {
310
+ at.current = screenSize;
311
+ animatedNumber.setValue(screenSize, {
312
+ type: "timing",
313
+ duration: 0
314
+ }, () => {
315
+ syncAnimatedPosition(screenSize);
316
+ setTimeout(() => {
317
+ setDisableAnimation(false);
318
+ }, 10);
319
+ });
320
+ return;
321
+ }
322
+ if (disableAnimation) return;
323
+ if (isDraggingRef.current) return;
324
+ if (!frameSize || !screenSize || isHidden || hasntMeasured && !open) return;
325
+ animateTo(position);
326
+ if (position === -1) {
327
+ scrollBridge.scrollLock = false;
328
+ scrollBridge.scrollStartY = -1;
329
+ }
330
+ if (open && position >= 0) {
331
+ const isTopPosition = position === 0;
332
+ scrollBridge.isAtTop = isTopPosition;
333
+ if (isTopPosition) {
334
+ scrollBridge.scrollLockY = void 0;
335
+ scrollBridge.setScrollEnabled?.(true);
336
+ } else {
337
+ scrollBridge.scrollLockY = 0;
338
+ scrollBridge.setScrollEnabled?.(false);
339
+ }
340
+ }
341
+ }, [
342
+ hasntMeasured,
343
+ disableAnimation,
344
+ isHidden,
345
+ frameSize,
346
+ screenSize,
347
+ open,
348
+ position
349
+ ]);
350
+ const disableDrag = props.disableDrag ?? controller?.disableDrag;
351
+ (0, import_core.useThemeName)();
352
+ const [blockPan, setBlockPan] = import_react.default.useState(false);
353
+ const panResponder = import_react.default.useMemo(() => {
354
+ if (disableDrag) return;
355
+ if (!frameSize) return;
356
+ if (isShowingInnerSheet) return;
357
+ const minY = activePositions[0];
358
+ scrollBridge.paneMinY = minY;
359
+ let startY = at.current;
360
+ function setPanning(val) {
361
+ setIsDragging(val);
362
+ if (!sheetHiddenStyleSheet) {
363
+ sheetHiddenStyleSheet = document.createElement("style");
364
+ if (typeof document.head !== "undefined") document.head.appendChild(sheetHiddenStyleSheet);
365
+ }
366
+ if (!val) sheetHiddenStyleSheet.innerText = "";
367
+ else sheetHiddenStyleSheet.innerText = ":root * { user-select: none !important; -webkit-user-select: none !important; }";
368
+ }
369
+ const release = ({ vy }) => {
370
+ scrollBridge.setParentDragging(false);
371
+ if (scrollBridge.scrollLock) return;
372
+ isExternalDrag = false;
373
+ previouslyScrolling = false;
374
+ setPanning(false);
375
+ const currentPos = at.current;
376
+ const end = currentPos + frameSize * vy * .2;
377
+ const closestPoint = (0, import_keyboardAvoidance.getSheetReleasePosition)({
378
+ positions: activePositions,
379
+ projectedEnd: end,
380
+ currentPosition: currentPos,
381
+ frameSize,
382
+ dismissOnSnapToBottom,
383
+ snapPointsMode,
384
+ isKeyboardVisible,
385
+ isWeb: import_constants.isWeb
386
+ });
387
+ setPosition(closestPoint);
388
+ animateTo(closestPoint);
389
+ };
390
+ const finish = (_e, state2) => {
391
+ release({
392
+ vy: state2.vy,
393
+ dragAt: state2.dy
394
+ });
395
+ };
396
+ let previouslyScrolling = false;
397
+ const onMoveShouldSet = (e, { dy }) => {
398
+ function getShouldSet() {
399
+ if (e.target === providerProps.handleRef.current) return true;
400
+ if (scrollBridge.scrollNodeTouched) return false;
401
+ if (scrollBridge.hasScrollableContent === true) {
402
+ if (scrollBridge.scrollLock) return false;
403
+ const isScrolled = scrollBridge.y !== 0;
404
+ const isDraggingUp = dy < 0;
405
+ const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
406
+ if (isScrolled) return false;
407
+ if (isNearTop) {
408
+ if (hasScrollView.current && isDraggingUp) return false;
409
+ }
410
+ }
411
+ return Math.abs(dy) > 10;
412
+ }
413
+ const granted = getShouldSet();
414
+ if (granted) scrollBridge.setParentDragging(true);
415
+ return granted;
416
+ };
417
+ const grant = () => {
418
+ setPanning(true);
419
+ stopSpring();
420
+ startY = getAnimatedPosition();
421
+ };
422
+ let isExternalDrag = false;
423
+ scrollBridge.startPanDrag = () => {
424
+ isExternalDrag = true;
425
+ grant();
426
+ };
427
+ scrollBridge.drag = (dy) => {
428
+ if (!isExternalDrag) {
429
+ isExternalDrag = true;
430
+ grant();
431
+ }
432
+ const to = dy + startY;
433
+ setAnimatedPositionDirect((0, import_helpers.resisted)(to, minY));
434
+ };
435
+ scrollBridge.release = release;
436
+ scrollBridge.snapToPosition = (positionIndex) => {
437
+ isExternalDrag = false;
438
+ setPanning(false);
439
+ setPosition(positionIndex);
440
+ animateTo(positionIndex);
441
+ };
442
+ return import_react_native.PanResponder.create({
443
+ onMoveShouldSetPanResponder: onMoveShouldSet,
444
+ onPanResponderTerminationRequest: () => false,
445
+ onPanResponderGrant: grant,
446
+ onPanResponderMove: (_e, { dy }) => {
447
+ const toFull = dy + startY;
448
+ const to = (0, import_helpers.resisted)(toFull, minY);
449
+ if (to <= minY) scrollBridge.setParentDragging(false);
450
+ else scrollBridge.setParentDragging(true);
451
+ setAnimatedPositionDirect(to);
452
+ },
453
+ onPanResponderEnd: finish,
454
+ onPanResponderTerminate: finish,
455
+ onPanResponderRelease: finish
456
+ });
457
+ }, [
458
+ disableDrag,
459
+ isShowingInnerSheet,
460
+ animateTo,
461
+ frameSize,
462
+ activePositions,
463
+ setPosition,
464
+ dismissOnSnapToBottom,
465
+ snapPointsMode
466
+ ]);
467
+ import_react.default.useEffect(() => {
468
+ if (isDragging || isHidden || !open || disableAnimation) return;
469
+ if (!frameSize || !screenSize) return;
470
+ animateTo(position, {
471
+ type: "timing",
472
+ duration: 250
473
+ });
474
+ }, [isKeyboardVisible, keyboardHeight]);
475
+ const wasDragging = import_react.default.useRef(false);
476
+ import_react.default.useEffect(() => {
477
+ if (isDragging) {
478
+ wasDragging.current = true;
479
+ return;
480
+ }
481
+ if (!wasDragging.current) return;
482
+ wasDragging.current = false;
483
+ if (!frameSize || !screenSize || isHidden || !open) return;
484
+ animateTo(position);
485
+ }, [isDragging]);
486
+ import_react.default.useEffect(() => {
487
+ if (!open && isKeyboardVisible) {
488
+ dismissKeyboard();
489
+ pauseKeyboardHandler.current = false;
490
+ flushPendingHide();
491
+ }
492
+ }, [open]);
493
+ import_react.default.useEffect(() => {
494
+ if (!import_constants.isWeb || !modal || !open || shouldHideParentSheet) return;
495
+ const layer = {};
496
+ sheetEscapeLayers.push(layer);
497
+ const onKeyDown = (event) => {
498
+ if (event.key === "Escape") {
499
+ if (sheetEscapeLayers[sheetEscapeLayers.length - 1] === layer) state.setOpen(false);
500
+ }
501
+ };
502
+ document.addEventListener("keydown", onKeyDown);
503
+ return () => {
504
+ const index = sheetEscapeLayers.indexOf(layer);
505
+ if (index > -1) sheetEscapeLayers.splice(index, 1);
506
+ document.removeEventListener("keydown", onKeyDown);
507
+ };
508
+ }, [
509
+ modal,
510
+ open,
511
+ shouldHideParentSheet,
512
+ state.setOpen
513
+ ]);
514
+ const { panGesture, panGestureRef, gestureHandlerEnabled } = (0, import_useGestureHandlerPan.useGestureHandlerPan)({
515
+ positions: activePositions,
516
+ frameSize,
517
+ setPosition,
518
+ animateTo,
519
+ stopSpring,
520
+ scrollBridge,
521
+ setIsDragging,
522
+ getCurrentPosition: getAnimatedPosition,
523
+ resisted: import_helpers.resisted,
524
+ disableDrag,
525
+ isShowingInnerSheet,
526
+ setAnimatedPosition: setAnimatedPositionDirect,
527
+ dismissOnSnapToBottom,
528
+ snapPointsMode,
529
+ isKeyboardVisible,
530
+ pauseKeyboardHandler
531
+ });
532
+ const ignoreLayoutForKeyboard = (0, import_core.useEvent)(() => import_constants.isWeb && moveOnKeyboardChange && (0, import_webViewport.getWebKeyboardResizeHeight)() >= import_webViewport.MIN_KEYBOARD_HEIGHT);
533
+ const handleAnimationViewLayout = (0, import_core.useEvent)((e) => {
534
+ if (!open && stableFrameSize.current !== 0) return;
535
+ const layoutHeight = e.nativeEvent?.layout.height;
536
+ if (ignoreLayoutForKeyboard() && frameSize > 0) return;
537
+ const next = modal ? Math.min(layoutHeight, getStableViewportHeight()) : layoutHeight;
538
+ if (!next) return;
539
+ setFrameSize(Math.round(next));
540
+ });
541
+ const handleMaxContentViewLayout = import_react.default.useCallback((e) => {
542
+ if (ignoreLayoutForKeyboard() && screenSize > 0) return;
543
+ const next = Math.min(e.nativeEvent?.layout.height, getStableViewportHeight());
544
+ if (!next) return;
545
+ setMaxContentSize(Math.round(next));
546
+ }, [ignoreLayoutForKeyboard, screenSize]);
547
+ const getAnimatedNumberStyle = import_react.default.useCallback((val) => {
548
+ "worklet";
549
+ return { transform: [{ translateY: frameSize === 0 ? hiddenSize : val }] };
550
+ }, [frameSize]);
551
+ const animatedStyle = (0, import_core.useAnimatedNumberStyle)(animatedNumber, getAnimatedNumberStyle);
552
+ const [isFullyClosed, setIsFullyClosed] = import_react.default.useState(false);
553
+ if (open && isFullyClosed) setIsFullyClosed(false);
554
+ const hasEverOpened = import_react.default.useRef(open);
555
+ if (open) hasEverOpened.current = true;
556
+ const isVisuallyActive = open || hasEverOpened.current && !isFullyClosed;
557
+ const applyHidden = shouldHideParentSheet || isFullyClosed && !disableHideWhenClosed;
558
+ const forcedContentHeight = hasFit ? void 0 : snapPointsMode === "percent" ? `${maxSnapPoint}${import_constants.isWeb ? modal ? "dvh" : "%" : "%"}` : maxSnapPoint;
559
+ const setHasScrollView = import_react.default.useCallback((val) => {
560
+ hasScrollView.current = val;
561
+ }, []);
562
+ const animatedPositionValue = import_react.default.useMemo(() => ({
563
+ value: animatedNumber,
564
+ screenSize: effScreenSize,
565
+ frameSize,
566
+ snapOffsets: activePositions,
567
+ minY: activePositions[0] ?? 0
568
+ }), [
569
+ animatedNumber,
570
+ effScreenSize,
571
+ frameSize,
572
+ activePositions
573
+ ]);
574
+ const { overlayChildren, animatedChildren } = import_react.default.useMemo(() => partitionSheetChildren(props.children), [props.children]);
575
+ let contents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.LayoutMeasurementController, {
576
+ disable: !open,
577
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.ParentSheetContext.Provider, {
578
+ value: nextParentContext,
579
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SheetContext.SheetProvider, {
580
+ ...providerProps,
581
+ keyboardOccludedHeight,
582
+ isKeyboardVisible,
583
+ keyboardStableFrameHeight,
584
+ setHasScrollView,
585
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_GestureSheetContext.GestureSheetProvider, {
586
+ isDragging,
587
+ blockPan,
588
+ setBlockPan,
589
+ panGesture,
590
+ panGestureRef,
591
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_SheetContext.SheetAnimatedPositionContext.Provider, {
592
+ value: animatedPositionValue,
593
+ children: [
594
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_SheetContext.SheetOverlayLayerContext.Provider, {
595
+ value: true,
596
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_animate_presence.AnimatePresence, {
597
+ custom: { open },
598
+ children: shouldHideParentSheet || !open ? null : overlayChildren
599
+ })
600
+ }),
601
+ snapPointsMode !== "percent" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
602
+ style: {
603
+ opacity: 0,
604
+ position: "absolute",
605
+ top: 0,
606
+ left: 0,
607
+ right: 0,
608
+ bottom: 0,
609
+ pointerEvents: "none"
610
+ },
611
+ onLayout: handleMaxContentViewLayout
612
+ }),
613
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AnimatedView, {
614
+ ref,
615
+ onLayout: handleAnimationViewLayout,
616
+ transition: isDragging || disableAnimation ? null : transition,
617
+ disableClassName: true,
618
+ style: [{
619
+ position: "absolute",
620
+ zIndex,
621
+ width: "100%",
622
+ height: forcedContentHeight,
623
+ minHeight: forcedContentHeight,
624
+ ...applyHidden && { display: "none" },
625
+ ...(shouldHideParentSheet || !open) && { pointerEvents: "none" }
626
+ }, animatedStyle],
627
+ children: gestureHandlerEnabled && panGesture ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_GestureDetectorWrapper.GestureDetectorWrapper, {
628
+ gesture: panGesture,
629
+ style: { flex: 1 },
630
+ children: animatedChildren
631
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.View, {
632
+ ...panResponder?.panHandlers,
633
+ style: {
634
+ flex: 1,
635
+ width: "100%",
636
+ height: "100%"
637
+ },
638
+ children: animatedChildren
639
+ })
640
+ })
641
+ ]
642
+ })
643
+ })
644
+ })
645
+ })
646
+ });
647
+ const shouldMountChildren = unmountChildrenWhenHidden ? !isFullyClosed : true;
648
+ if (modal) {
649
+ const RNGHRoot = (0, import_gestureState.getGestureHandlerState)().RootView;
650
+ const mountedContents = shouldMountChildren ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ContainerComponent, { children: contents }) : null;
651
+ const modalContents = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_portal.Portal, {
652
+ stackZIndex: zIndex,
653
+ hidden: !isVisuallyActive,
654
+ ...portalProps,
655
+ children: mountedContents && RNGHRoot ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RNGHRoot, {
656
+ style: open ? rnghRootStyleOpen : rnghRootStyleClosed,
657
+ children: mountedContents
658
+ }) : mountedContents
659
+ });
660
+ if (import_constants.isWeb) return modalContents;
661
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_contexts.SheetInsideSheetContext.Provider, {
662
+ value: onInnerSheet,
663
+ children: modalContents
664
+ });
665
+ }
666
+ return contents;
625
667
  });
668
+ function isSheetOverlayComponent(type) {
669
+ let staticConfig = type?.staticConfig;
670
+ while (staticConfig) {
671
+ if (staticConfig[import_constants2.SHEET_OVERLAY_MARKER]) return true;
672
+ staticConfig = staticConfig.parentStaticConfig;
673
+ }
674
+ return false;
675
+ }
676
+ function partitionSheetChildren(children) {
677
+ const overlayChildren = [];
678
+ const animatedChildren = [];
679
+ import_react.default.Children.forEach(children, (child) => {
680
+ if (!import_react.default.isValidElement(child)) {
681
+ animatedChildren.push(child);
682
+ return;
683
+ }
684
+ if (isSheetOverlayComponent(child.type)) {
685
+ overlayChildren.push(child);
686
+ return;
687
+ }
688
+ animatedChildren.push(child);
689
+ });
690
+ return {
691
+ overlayChildren,
692
+ animatedChildren
693
+ };
694
+ }
626
695
  function getYPositions(mode, point, screenSize, frameSize) {
627
- if (!screenSize || !frameSize) return 0;
628
- if (mode === "mixed") {
629
- if (typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
630
- if (point === "fit") return screenSize - Math.min(screenSize, frameSize);
631
- if (point.endsWith("%")) {
632
- const pct2 = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
633
- if (Number.isNaN(pct2)) {
634
- console.warn("Invalid snapPoint percentage string");
635
- return 0;
636
- }
637
- return Math.round(screenSize - pct2 * screenSize);
638
- }
639
- console.warn("Invalid snapPoint unknown value");
640
- return 0;
641
- }
642
- if (mode === "fit") {
643
- if (point === 0) return screenSize;
644
- return screenSize - Math.min(screenSize, frameSize);
645
- }
646
- if (mode === "constant" && typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
647
- const pct = Math.min(100, Math.max(0, Number(point))) / 100;
648
- if (Number.isNaN(pct)) {
649
- console.warn("Invalid snapPoint percentage");
650
- return 0;
651
- }
652
- return Math.round(screenSize - pct * screenSize);
653
- }
696
+ if (!screenSize || !frameSize) return 0;
697
+ if (mode === "mixed") {
698
+ if (typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
699
+ if (point === "fit") return screenSize - Math.min(screenSize, frameSize);
700
+ if (point.endsWith("%")) {
701
+ const pct2 = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
702
+ if (Number.isNaN(pct2)) {
703
+ console.warn((0, import_core.formatDiagnostic)("TAMAGUI_SHEET_SNAP_POINT", "Sheet", "snapPoints contains an invalid percentage string", "Use \"fit\", a pixel number, or a percentage such as \"50%\"", "snapPoint", point));
704
+ return 0;
705
+ }
706
+ return Math.round(screenSize - pct2 * screenSize);
707
+ }
708
+ console.warn((0, import_core.formatDiagnostic)("TAMAGUI_SHEET_SNAP_POINT", "Sheet", "snapPoints contains an unsupported mixed-mode value", "Use \"fit\", a pixel number, or a percentage such as \"50%\"", "snapPoint", point));
709
+ return 0;
710
+ }
711
+ if (mode === "fit") {
712
+ if (point === 0) return screenSize;
713
+ return screenSize - Math.min(screenSize, frameSize);
714
+ }
715
+ if (mode === "constant" && typeof point === "number") return screenSize - Math.min(screenSize, Math.max(0, point));
716
+ const pct = Math.min(100, Math.max(0, Number(point))) / 100;
717
+ if (Number.isNaN(pct)) {
718
+ console.warn((0, import_core.formatDiagnostic)("TAMAGUI_SHEET_SNAP_POINT", "Sheet", "snapPoints contains a value that cannot be converted to a percentage", "Use a numeric percentage such as 50", "snapPoint", point));
719
+ return 0;
720
+ }
721
+ return Math.round(screenSize - pct * screenSize);
722
+ }