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