@tamagui/sheet 2.7.7 → 3.0.0-beta.1091.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,36 +5,27 @@ 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 SheetScrollView_exports = {};
35
- __export(SheetScrollView_exports, {
36
- SheetScrollView: () => SheetScrollView
37
- });
28
+ __export(SheetScrollView_exports, { SheetScrollView: () => SheetScrollView });
38
29
  module.exports = __toCommonJS(SheetScrollView_exports);
39
30
  var import_compose_refs = require("@tamagui/compose-refs");
40
31
  var import_core = require("@tamagui/core");
@@ -48,290 +39,278 @@ var import_useSheetScrollViewGestures = require("./useSheetScrollViewGestures.cj
48
39
  var import_webViewport = require("./webViewport.cjs");
49
40
  var import_jsx_runtime = require("react/jsx-runtime");
50
41
  const SHEET_SCROLL_VIEW_NAME = "SheetScrollView";
51
- const SheetScrollView = import_react.default.forwardRef(({
52
- __scopeSheet,
53
- children,
54
- onScroll,
55
- scrollEnabled: scrollEnabledProp,
56
- ...props
57
- }, ref) => {
58
- const context = (0, import_SheetContext.useSheetContext)(SHEET_SCROLL_VIEW_NAME, __scopeSheet);
59
- const gestureContext = (0, import_GestureSheetContext.useGestureSheetContext)();
60
- const {
61
- scrollBridge,
62
- setHasScrollView,
63
- hasFit,
64
- screenSize
65
- } = context;
66
- const keyboardOccludedHeight = Math.max(0, context.keyboardOccludedHeight || 0);
67
- const isKeyboardVisible = context.isKeyboardVisible === true || import_core.isWeb && (0, import_webViewport.getWebKeyboardResizeHeight)() >= import_webViewport.MIN_KEYBOARD_HEIGHT;
68
- const [scrollEnabled] = (0, import_use_controllable_state.useControllableState)({
69
- prop: scrollEnabledProp,
70
- defaultProp: true
71
- });
72
- const scrollRef = import_react.default.useRef(null);
73
- const [hasScrollableContent, setHasScrollableContent] = (0, import_react.useState)(true);
74
- const parentHeight = (0, import_react.useRef)(0);
75
- const contentHeight = (0, import_react.useRef)(0);
76
- const frozenFrameHeight = Math.max(0, context.keyboardStableFrameHeight || 0);
77
- const fitSizingStyle = hasFit ? {
78
- flex: void 0,
79
- height: void 0,
80
- maxHeight: screenSize || void 0
81
- } : {
82
- flex: 1
83
- };
84
- const contentContainerStyle = hasFit ? void 0 : {
85
- minHeight: "100%"
86
- };
87
- const keyboardFrozenOverride = hasFit && isKeyboardVisible && frozenFrameHeight > 0 ? {
88
- height: frozenFrameHeight,
89
- maxHeight: frozenFrameHeight
90
- } : null;
91
- const panGestureRef = gestureContext?.panGestureRef;
92
- const {
93
- ScrollView: RNGHScrollView
94
- } = (0, import_gestureState.getGestureHandlerState)();
95
- const useRNGHScrollView = (0, import_gestureState.isGestureHandlerEnabled)() && RNGHScrollView && panGestureRef;
96
- const currentScrollOffset = (0, import_react.useRef)(0);
97
- const lastEmittedScrollOffset = (0, import_react.useRef)(0);
98
- const lockedScrollY = (0, import_react.useRef)(0);
99
- const focusedInputScrollFrame = (0, import_react.useRef)(0);
100
- const setScrollEnabled = (next, lockTo) => {
101
- if (!next) {
102
- const lockY = lockTo ?? scrollBridge.scrollLockY ?? currentScrollOffset.current;
103
- if (scrollBridge.enabled === false && scrollBridge.scrollLockY === lockY) {
104
- return;
105
- }
106
- scrollBridge.enabled = false;
107
- lockedScrollY.current = lockY;
108
- scrollBridge.scrollLockY = lockY;
109
- if (currentScrollOffset.current !== lockY) {
110
- scrollRef.current?.scrollTo?.({
111
- x: 0,
112
- y: lockY,
113
- animated: false
114
- });
115
- currentScrollOffset.current = lockY;
116
- }
117
- } else {
118
- if (scrollBridge.enabled === true && scrollBridge.scrollLockY === void 0) {
119
- return;
120
- }
121
- scrollBridge.enabled = true;
122
- lockedScrollY.current = currentScrollOffset.current;
123
- scrollBridge.scrollLockY = void 0;
124
- }
125
- };
126
- const forceScrollTo = y => {
127
- scrollRef.current?.scrollTo?.({
128
- x: 0,
129
- y,
130
- animated: false
131
- });
132
- currentScrollOffset.current = y;
133
- };
134
- const emitManualScroll = import_react.default.useCallback((node, y) => {
135
- currentScrollOffset.current = y;
136
- scrollBridge.y = y;
137
- if (y > 0) scrollBridge.scrollStartY = -1;
138
- lastEmittedScrollOffset.current = y;
139
- onScroll?.({
140
- nativeEvent: {
141
- contentOffset: {
142
- x: node.scrollLeft,
143
- y
144
- },
145
- contentSize: {
146
- height: node.scrollHeight,
147
- width: node.scrollWidth
148
- },
149
- layoutMeasurement: {
150
- height: node.offsetHeight,
151
- width: node.offsetWidth
152
- }
153
- },
154
- timeStamp: Date.now()
155
- });
156
- }, [onScroll, scrollBridge]);
157
- const scrollFocusedInputClearOfKeyboard = import_react.default.useCallback(() => {
158
- if (!import_core.isWeb || !hasFit || !isKeyboardVisible || keyboardOccludedHeight <= 0) {
159
- return;
160
- }
161
- const node = scrollRef.current?.getScrollableNode();
162
- const active = document.activeElement;
163
- if (!node || !active || !(0, import_webViewport.isEditableElement)(active) || !node.contains(active)) {
164
- return;
165
- }
166
- const keyboardHeight = Math.max(keyboardOccludedHeight, (0, import_webViewport.getWebKeyboardBottomInset)());
167
- if (keyboardHeight <= 0) return;
168
- const activeRect = active.getBoundingClientRect();
169
- const nodeRect = node.getBoundingClientRect();
170
- const margin = 12;
171
- const keyboardTop = (0, import_webViewport.getStableLayoutViewportHeight)() - keyboardHeight;
172
- const visibleTop = nodeRect.top + margin;
173
- const visibleBottom = Math.min(nodeRect.bottom, keyboardTop) - margin;
174
- let nextScrollTop = node.scrollTop;
175
- if (activeRect.bottom > visibleBottom) {
176
- nextScrollTop += Math.ceil(activeRect.bottom - visibleBottom);
177
- } else if (activeRect.top < visibleTop) {
178
- nextScrollTop -= Math.ceil(visibleTop - activeRect.top);
179
- }
180
- const maxScrollTop = Math.max(0, node.scrollHeight - node.clientHeight);
181
- nextScrollTop = Math.max(0, Math.min(maxScrollTop, nextScrollTop));
182
- if (nextScrollTop === node.scrollTop) return;
183
- node.scrollTop = nextScrollTop;
184
- currentScrollOffset.current = nextScrollTop;
185
- scrollBridge.y = nextScrollTop;
186
- if (nextScrollTop > 0) scrollBridge.scrollStartY = -1;
187
- }, [hasFit, isKeyboardVisible, keyboardOccludedHeight, scrollBridge]);
188
- const scheduleFocusedInputScroll = import_react.default.useCallback(() => {
189
- if (!import_core.isWeb || !hasFit) return;
190
- cancelAnimationFrame(focusedInputScrollFrame.current);
191
- focusedInputScrollFrame.current = requestAnimationFrame(() => {
192
- scrollFocusedInputClearOfKeyboard();
193
- focusedInputScrollFrame.current = requestAnimationFrame(scrollFocusedInputClearOfKeyboard);
194
- });
195
- }, [hasFit, scrollFocusedInputClearOfKeyboard]);
196
- (0, import_react.useEffect)(() => {
197
- if (!import_core.isWeb || !hasFit) return;
198
- scheduleFocusedInputScroll();
199
- window.addEventListener("focusin", scheduleFocusedInputScroll);
200
- window.visualViewport?.addEventListener("resize", scheduleFocusedInputScroll);
201
- return () => {
202
- cancelAnimationFrame(focusedInputScrollFrame.current);
203
- window.removeEventListener("focusin", scheduleFocusedInputScroll);
204
- window.visualViewport?.removeEventListener("resize", scheduleFocusedInputScroll);
205
- };
206
- }, [hasFit, scheduleFocusedInputScroll]);
207
- (0, import_react.useEffect)(() => {
208
- setHasScrollView(true);
209
- if ((0, import_gestureState.isGestureHandlerEnabled)()) {
210
- scrollBridge.setScrollEnabled = setScrollEnabled;
211
- scrollBridge.forceScrollTo = forceScrollTo;
212
- }
213
- return () => {
214
- setHasScrollView(false);
215
- scrollBridge.setScrollEnabled = void 0;
216
- scrollBridge.forceScrollTo = void 0;
217
- };
218
- }, []);
219
- const updateScrollable = () => {
220
- if (parentHeight.current && contentHeight.current) {
221
- setHasScrollableContent(contentHeight.current > parentHeight.current);
222
- }
223
- };
224
- const recordFitHeight = height => {
225
- parentHeight.current = height;
226
- };
227
- (0, import_react.useEffect)(() => {
228
- scrollBridge.hasScrollableContent = hasScrollableContent;
229
- }, [hasScrollableContent]);
230
- const gestureProps = (0, import_useSheetScrollViewGestures.useSheetScrollViewGestures)({
231
- scrollRef,
232
- scrollBridge,
233
- hasScrollableContent,
234
- scrollEnabled,
235
- setScrollEnabled,
236
- onManualScroll: emitManualScroll
237
- });
238
- const contentWrapper = /* @__PURE__ */(0, import_jsx_runtime.jsxs)(import_core.View, {
239
- onLayout: e => {
240
- const height = Math.floor(e.nativeEvent.layout.height);
241
- if (height !== contentHeight.current) {
242
- contentHeight.current = height;
243
- updateScrollable();
244
- if (keyboardOccludedHeight > 0) {
245
- scheduleFocusedInputScroll();
246
- }
247
- }
248
- },
249
- children: [children, keyboardOccludedHeight > 0 && /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_core.View, {
250
- "data-sheet-keyboard-scroll-pad": true,
251
- height: keyboardOccludedHeight,
252
- width: "100%"
253
- })]
254
- });
255
- if (useRNGHScrollView && RNGHScrollView && panGestureRef) {
256
- const RNGHComponent = RNGHScrollView;
257
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(RNGHComponent, {
258
- ref: (0, import_compose_refs.composeRefs)(scrollRef, ref),
259
- style: fitSizingStyle,
260
- scrollEventThrottle: 1,
261
- scrollEnabled,
262
- simultaneousHandlers: [panGestureRef],
263
- onLayout: e => {
264
- recordFitHeight(Math.ceil(e.nativeEvent.layout.height));
265
- updateScrollable();
266
- },
267
- onScroll: e => {
268
- const {
269
- y
270
- } = e.nativeEvent.contentOffset;
271
- currentScrollOffset.current = y;
272
- if (scrollBridge.scrollLockY !== void 0) {
273
- if (y !== scrollBridge.scrollLockY) {
274
- scrollRef.current?.scrollTo?.({
275
- x: 0,
276
- y: scrollBridge.scrollLockY,
277
- animated: false
278
- });
279
- }
280
- currentScrollOffset.current = scrollBridge.scrollLockY;
281
- scrollBridge.y = scrollBridge.scrollLockY;
282
- if (lastEmittedScrollOffset.current !== scrollBridge.scrollLockY) {
283
- lastEmittedScrollOffset.current = scrollBridge.scrollLockY;
284
- onScroll?.({
285
- ...e,
286
- nativeEvent: {
287
- ...e.nativeEvent,
288
- contentOffset: {
289
- ...e.nativeEvent.contentOffset,
290
- y: scrollBridge.scrollLockY
291
- }
292
- }
293
- });
294
- }
295
- return;
296
- }
297
- scrollBridge.y = y;
298
- if (y > 0) scrollBridge.scrollStartY = -1;
299
- lastEmittedScrollOffset.current = y;
300
- onScroll?.(e);
301
- },
302
- contentContainerStyle,
303
- bounces: false,
304
- keyboardShouldPersistTaps: "always",
305
- keyboardDismissMode: "none",
306
- ...props,
307
- ...keyboardFrozenOverride,
308
- children: contentWrapper
309
- });
310
- }
311
- return /* @__PURE__ */(0, import_jsx_runtime.jsx)(import_scroll_view.ScrollView, {
312
- onLayout: e => {
313
- recordFitHeight(Math.ceil(e.nativeEvent.layout.height));
314
- updateScrollable();
315
- },
316
- ref: (0, import_compose_refs.composeRefs)(scrollRef, ref),
317
- ...fitSizingStyle,
318
- scrollEventThrottle: 1,
319
- className: "_ovs-contain",
320
- scrollEnabled,
321
- onScroll: e => {
322
- const {
323
- y
324
- } = e.nativeEvent.contentOffset;
325
- currentScrollOffset.current = y;
326
- scrollBridge.y = y;
327
- if (y > 0) scrollBridge.scrollStartY = -1;
328
- lastEmittedScrollOffset.current = y;
329
- onScroll?.(e);
330
- },
331
- contentContainerStyle,
332
- ...gestureProps,
333
- ...props,
334
- ...keyboardFrozenOverride,
335
- children: contentWrapper
336
- });
337
- });
42
+ const sheetContentStyle = (0, import_core.style)({ minHeight: "100%" });
43
+ const SheetScrollView = (0, import_core.createStyledHOC)(import_scroll_view.ScrollView, ({ scope, children, onScroll, scrollEnabled: scrollEnabledProp, style: style2, ...props }, ref) => {
44
+ const context = (0, import_SheetContext.useSheetContext)(scope);
45
+ const gestureContext = (0, import_GestureSheetContext.useGestureSheetContext)();
46
+ const { scrollBridge, setHasScrollView, hasFit, screenSize } = context;
47
+ const keyboardOccludedHeight = Math.max(0, context.keyboardOccludedHeight || 0);
48
+ const isKeyboardVisible = context.isKeyboardVisible === true || import_core.isWeb && (0, import_webViewport.getWebKeyboardResizeHeight)() >= import_webViewport.MIN_KEYBOARD_HEIGHT;
49
+ const [scrollEnabled] = (0, import_use_controllable_state.useControllableState)({
50
+ prop: scrollEnabledProp,
51
+ defaultProp: true
52
+ });
53
+ const scrollRef = import_react.default.useRef(null);
54
+ const [hasScrollableContent, setHasScrollableContent] = (0, import_react.useState)(true);
55
+ const parentHeight = (0, import_react.useRef)(0);
56
+ const contentHeight = (0, import_react.useRef)(0);
57
+ const frozenFrameHeight = Math.max(0, context.keyboardStableFrameHeight || 0);
58
+ const fitSizingProps = hasFit ? {
59
+ flex: void 0,
60
+ height: void 0,
61
+ maxHeight: screenSize || void 0
62
+ } : { flex: 1 };
63
+ const contentContainerStyle = hasFit ? void 0 : sheetContentStyle;
64
+ const keyboardFrozenOverride = hasFit && isKeyboardVisible && frozenFrameHeight > 0 ? {
65
+ height: frozenFrameHeight,
66
+ maxHeight: frozenFrameHeight
67
+ } : null;
68
+ const scrollViewStyle = [...Array.isArray(style2) ? style2 : [style2], keyboardFrozenOverride];
69
+ const panGestureRef = gestureContext?.panGestureRef;
70
+ const { ScrollView: RNGHScrollView } = (0, import_gestureState.getGestureHandlerState)();
71
+ const useRNGHScrollView = (0, import_gestureState.isGestureHandlerEnabled)() && RNGHScrollView && panGestureRef;
72
+ const currentScrollOffset = (0, import_react.useRef)(0);
73
+ const lastEmittedScrollOffset = (0, import_react.useRef)(0);
74
+ const lockedScrollY = (0, import_react.useRef)(0);
75
+ const focusedInputScrollFrame = (0, import_react.useRef)(0);
76
+ const setScrollEnabled = (next, lockTo) => {
77
+ if (!next) {
78
+ const lockY = lockTo ?? scrollBridge.scrollLockY ?? currentScrollOffset.current;
79
+ if (scrollBridge.enabled === false && scrollBridge.scrollLockY === lockY) {
80
+ return;
81
+ }
82
+ scrollBridge.enabled = false;
83
+ lockedScrollY.current = lockY;
84
+ scrollBridge.scrollLockY = lockY;
85
+ if (currentScrollOffset.current !== lockY) {
86
+ scrollRef.current?.scrollTo?.({
87
+ x: 0,
88
+ y: lockY,
89
+ animated: false
90
+ });
91
+ currentScrollOffset.current = lockY;
92
+ }
93
+ } else {
94
+ if (scrollBridge.enabled === true && scrollBridge.scrollLockY === void 0) {
95
+ return;
96
+ }
97
+ scrollBridge.enabled = true;
98
+ lockedScrollY.current = currentScrollOffset.current;
99
+ scrollBridge.scrollLockY = void 0;
100
+ }
101
+ };
102
+ const forceScrollTo = (y) => {
103
+ scrollRef.current?.scrollTo?.({
104
+ x: 0,
105
+ y,
106
+ animated: false
107
+ });
108
+ currentScrollOffset.current = y;
109
+ };
110
+ const emitManualScroll = import_react.default.useCallback((node, y) => {
111
+ currentScrollOffset.current = y;
112
+ scrollBridge.y = y;
113
+ if (y > 0) scrollBridge.scrollStartY = -1;
114
+ lastEmittedScrollOffset.current = y;
115
+ onScroll?.({
116
+ nativeEvent: {
117
+ contentOffset: {
118
+ x: node.scrollLeft,
119
+ y
120
+ },
121
+ contentSize: {
122
+ height: node.scrollHeight,
123
+ width: node.scrollWidth
124
+ },
125
+ layoutMeasurement: {
126
+ height: node.offsetHeight,
127
+ width: node.offsetWidth
128
+ }
129
+ },
130
+ timeStamp: Date.now()
131
+ });
132
+ }, [onScroll, scrollBridge]);
133
+ const scrollFocusedInputClearOfKeyboard = import_react.default.useCallback(() => {
134
+ if (!import_core.isWeb || !hasFit || !isKeyboardVisible || keyboardOccludedHeight <= 0) {
135
+ return;
136
+ }
137
+ const node = scrollRef.current?.getScrollableNode();
138
+ const active = document.activeElement;
139
+ if (!node || !active || !(0, import_webViewport.isEditableElement)(active) || !node.contains(active)) {
140
+ return;
141
+ }
142
+ const keyboardHeight = Math.max(keyboardOccludedHeight, (0, import_webViewport.getWebKeyboardBottomInset)());
143
+ if (keyboardHeight <= 0) return;
144
+ const activeRect = active.getBoundingClientRect();
145
+ const nodeRect = node.getBoundingClientRect();
146
+ const margin = 12;
147
+ const keyboardTop = (0, import_webViewport.getStableLayoutViewportHeight)() - keyboardHeight;
148
+ const visibleTop = nodeRect.top + margin;
149
+ const visibleBottom = Math.min(nodeRect.bottom, keyboardTop) - margin;
150
+ let nextScrollTop = node.scrollTop;
151
+ if (activeRect.bottom > visibleBottom) {
152
+ nextScrollTop += Math.ceil(activeRect.bottom - visibleBottom);
153
+ } else if (activeRect.top < visibleTop) {
154
+ nextScrollTop -= Math.ceil(visibleTop - activeRect.top);
155
+ }
156
+ const maxScrollTop = Math.max(0, node.scrollHeight - node.clientHeight);
157
+ nextScrollTop = Math.max(0, Math.min(maxScrollTop, nextScrollTop));
158
+ if (nextScrollTop === node.scrollTop) return;
159
+ node.scrollTop = nextScrollTop;
160
+ currentScrollOffset.current = nextScrollTop;
161
+ scrollBridge.y = nextScrollTop;
162
+ if (nextScrollTop > 0) scrollBridge.scrollStartY = -1;
163
+ }, [
164
+ hasFit,
165
+ isKeyboardVisible,
166
+ keyboardOccludedHeight,
167
+ scrollBridge
168
+ ]);
169
+ const scheduleFocusedInputScroll = import_react.default.useCallback(() => {
170
+ if (!import_core.isWeb || !hasFit) return;
171
+ cancelAnimationFrame(focusedInputScrollFrame.current);
172
+ focusedInputScrollFrame.current = requestAnimationFrame(() => {
173
+ scrollFocusedInputClearOfKeyboard();
174
+ focusedInputScrollFrame.current = requestAnimationFrame(scrollFocusedInputClearOfKeyboard);
175
+ });
176
+ }, [hasFit, scrollFocusedInputClearOfKeyboard]);
177
+ (0, import_react.useEffect)(() => {
178
+ if (!import_core.isWeb || !hasFit) return;
179
+ scheduleFocusedInputScroll();
180
+ window.addEventListener("focusin", scheduleFocusedInputScroll);
181
+ window.visualViewport?.addEventListener("resize", scheduleFocusedInputScroll);
182
+ return () => {
183
+ cancelAnimationFrame(focusedInputScrollFrame.current);
184
+ window.removeEventListener("focusin", scheduleFocusedInputScroll);
185
+ window.visualViewport?.removeEventListener("resize", scheduleFocusedInputScroll);
186
+ };
187
+ }, [hasFit, scheduleFocusedInputScroll]);
188
+ (0, import_react.useEffect)(() => {
189
+ setHasScrollView(true);
190
+ if ((0, import_gestureState.isGestureHandlerEnabled)()) {
191
+ scrollBridge.setScrollEnabled = setScrollEnabled;
192
+ scrollBridge.forceScrollTo = forceScrollTo;
193
+ }
194
+ return () => {
195
+ setHasScrollView(false);
196
+ scrollBridge.setScrollEnabled = void 0;
197
+ scrollBridge.forceScrollTo = void 0;
198
+ };
199
+ }, []);
200
+ const updateScrollable = () => {
201
+ if (parentHeight.current && contentHeight.current) {
202
+ setHasScrollableContent(contentHeight.current > parentHeight.current);
203
+ }
204
+ };
205
+ const recordFitHeight = (height) => {
206
+ parentHeight.current = height;
207
+ };
208
+ (0, import_react.useEffect)(() => {
209
+ scrollBridge.hasScrollableContent = hasScrollableContent;
210
+ }, [hasScrollableContent]);
211
+ const gestureProps = (0, import_useSheetScrollViewGestures.useSheetScrollViewGestures)({
212
+ scrollRef,
213
+ scrollBridge,
214
+ hasScrollableContent,
215
+ scrollEnabled,
216
+ setScrollEnabled,
217
+ onManualScroll: emitManualScroll
218
+ });
219
+ const contentWrapper = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_core.View, {
220
+ onLayout: (e) => {
221
+ const height = Math.floor(e.nativeEvent.layout.height);
222
+ if (height !== contentHeight.current) {
223
+ contentHeight.current = height;
224
+ updateScrollable();
225
+ if (keyboardOccludedHeight > 0) {
226
+ scheduleFocusedInputScroll();
227
+ }
228
+ }
229
+ },
230
+ children: [children, keyboardOccludedHeight > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_core.View, {
231
+ "data-sheet-keyboard-scroll-pad": true,
232
+ height: keyboardOccludedHeight,
233
+ width: "100%"
234
+ })]
235
+ });
236
+ if (useRNGHScrollView && RNGHScrollView && panGestureRef) {
237
+ const RNGHComponent = RNGHScrollView;
238
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RNGHComponent, {
239
+ ref: (0, import_compose_refs.composeRefs)(scrollRef, ref),
240
+ style: [fitSizingProps, ...scrollViewStyle],
241
+ scrollEventThrottle: 1,
242
+ scrollEnabled,
243
+ simultaneousHandlers: [panGestureRef],
244
+ onLayout: (e) => {
245
+ recordFitHeight(Math.ceil(e.nativeEvent.layout.height));
246
+ updateScrollable();
247
+ },
248
+ onScroll: (e) => {
249
+ const { y } = e.nativeEvent.contentOffset;
250
+ currentScrollOffset.current = y;
251
+ if (scrollBridge.scrollLockY !== void 0) {
252
+ if (y !== scrollBridge.scrollLockY) {
253
+ scrollRef.current?.scrollTo?.({
254
+ x: 0,
255
+ y: scrollBridge.scrollLockY,
256
+ animated: false
257
+ });
258
+ }
259
+ currentScrollOffset.current = scrollBridge.scrollLockY;
260
+ scrollBridge.y = scrollBridge.scrollLockY;
261
+ if (lastEmittedScrollOffset.current !== scrollBridge.scrollLockY) {
262
+ lastEmittedScrollOffset.current = scrollBridge.scrollLockY;
263
+ onScroll?.({
264
+ ...e,
265
+ nativeEvent: {
266
+ ...e.nativeEvent,
267
+ contentOffset: {
268
+ ...e.nativeEvent.contentOffset,
269
+ y: scrollBridge.scrollLockY
270
+ }
271
+ }
272
+ });
273
+ }
274
+ return;
275
+ }
276
+ scrollBridge.y = y;
277
+ if (y > 0) scrollBridge.scrollStartY = -1;
278
+ lastEmittedScrollOffset.current = y;
279
+ onScroll?.(e);
280
+ },
281
+ contentContainerStyle,
282
+ bounces: false,
283
+ keyboardShouldPersistTaps: "always",
284
+ keyboardDismissMode: "none",
285
+ ...props,
286
+ children: contentWrapper
287
+ });
288
+ }
289
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_scroll_view.ScrollView, {
290
+ ...fitSizingProps,
291
+ onLayout: (e) => {
292
+ recordFitHeight(Math.ceil(e.nativeEvent.layout.height));
293
+ updateScrollable();
294
+ },
295
+ ref: (0, import_compose_refs.composeRefs)(scrollRef, ref),
296
+ scrollEventThrottle: 1,
297
+ className: "_ovs-contain",
298
+ scrollEnabled,
299
+ onScroll: (e) => {
300
+ const { y } = e.nativeEvent.contentOffset;
301
+ currentScrollOffset.current = y;
302
+ scrollBridge.y = y;
303
+ if (y > 0) scrollBridge.scrollStartY = -1;
304
+ lastEmittedScrollOffset.current = y;
305
+ onScroll?.(e);
306
+ },
307
+ contentContainerStyle,
308
+ ...gestureProps,
309
+ ...props,
310
+ style: scrollViewStyle,
311
+ children: contentWrapper
312
+ });
313
+ }, {
314
+ disableTheme: true,
315
+ displayName: SHEET_SCROLL_VIEW_NAME
316
+ });