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