@hanzogui/sheet 8.3.0 → 8.3.2

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 (559) hide show
  1. package/dist/cjs/GestureDetectorWrapper.js +23 -0
  2. package/dist/cjs/GestureDetectorWrapper.js.map +1 -0
  3. package/dist/cjs/GestureSheetContext.js +21 -0
  4. package/dist/cjs/GestureSheetContext.js.map +1 -0
  5. package/dist/cjs/Sheet.js +102 -0
  6. package/dist/cjs/Sheet.js.map +1 -0
  7. package/dist/cjs/SheetContext.js +8 -0
  8. package/dist/cjs/SheetContext.js.map +1 -0
  9. package/dist/cjs/SheetController.js +33 -0
  10. package/dist/cjs/SheetController.js.map +1 -0
  11. package/dist/cjs/SheetImplementationCustom.js +866 -0
  12. package/dist/cjs/SheetImplementationCustom.js.map +1 -0
  13. package/dist/cjs/SheetScrollView.js +278 -0
  14. package/dist/cjs/SheetScrollView.js.map +1 -0
  15. package/dist/cjs/constants.js +8 -0
  16. package/dist/cjs/constants.js.map +1 -0
  17. package/dist/cjs/contexts.js +10 -0
  18. package/dist/cjs/contexts.js.map +1 -0
  19. package/dist/cjs/controller.js +11 -0
  20. package/dist/cjs/controller.js.map +1 -0
  21. package/dist/cjs/createSheet.js +153 -0
  22. package/dist/cjs/createSheet.js.map +1 -0
  23. package/dist/cjs/gestureState.js +35 -0
  24. package/dist/cjs/gestureState.js.map +1 -0
  25. package/dist/cjs/helpers.js +29 -0
  26. package/dist/cjs/helpers.js.map +1 -0
  27. package/dist/cjs/index.js +19 -0
  28. package/dist/cjs/index.js.map +1 -0
  29. package/dist/cjs/keyboardAvoidance.js +67 -0
  30. package/dist/cjs/keyboardAvoidance.js.map +1 -0
  31. package/dist/cjs/nativeSheet.js +52 -0
  32. package/dist/cjs/nativeSheet.js.map +1 -0
  33. package/dist/cjs/package.json +1 -0
  34. package/dist/cjs/setupGestureHandler.js +31 -0
  35. package/dist/cjs/setupGestureHandler.js.map +1 -0
  36. package/dist/cjs/types.js +3 -0
  37. package/dist/cjs/types.js.map +1 -0
  38. package/dist/cjs/useGestureHandlerPan.js +356 -0
  39. package/dist/cjs/useGestureHandlerPan.js.map +1 -0
  40. package/dist/cjs/useKeyboardControllerSheet.js +124 -0
  41. package/dist/cjs/useKeyboardControllerSheet.js.map +1 -0
  42. package/dist/cjs/useSafeAreaInsets.js +16 -0
  43. package/dist/cjs/useSafeAreaInsets.js.map +1 -0
  44. package/dist/cjs/useSheet.js +7 -0
  45. package/dist/cjs/useSheet.js.map +1 -0
  46. package/dist/cjs/useSheetController.js +19 -0
  47. package/dist/cjs/useSheetController.js.map +1 -0
  48. package/dist/cjs/useSheetOffscreenSize.js +40 -0
  49. package/dist/cjs/useSheetOffscreenSize.js.map +1 -0
  50. package/dist/cjs/useSheetOpenState.js +29 -0
  51. package/dist/cjs/useSheetOpenState.js.map +1 -0
  52. package/dist/cjs/useSheetProviderProps.js +169 -0
  53. package/dist/cjs/useSheetProviderProps.js.map +1 -0
  54. package/dist/cjs/useSheetScrollViewGestures.js +195 -0
  55. package/dist/cjs/useSheetScrollViewGestures.js.map +1 -0
  56. package/dist/cjs/webViewport.js +108 -0
  57. package/dist/cjs/webViewport.js.map +1 -0
  58. package/dist/esm/GestureDetectorWrapper.js +20 -0
  59. package/dist/esm/GestureDetectorWrapper.js.map +1 -0
  60. package/dist/esm/GestureSheetContext.js +17 -0
  61. package/dist/esm/GestureSheetContext.js.map +1 -0
  62. package/dist/esm/Sheet.js +97 -0
  63. package/dist/esm/Sheet.js.map +1 -0
  64. package/dist/esm/SheetContext.js +5 -0
  65. package/dist/esm/SheetContext.js.map +1 -0
  66. package/dist/esm/SheetController.js +28 -0
  67. package/dist/esm/SheetController.js.map +1 -0
  68. package/dist/esm/SheetImplementationCustom.js +862 -0
  69. package/dist/esm/SheetImplementationCustom.js.map +1 -0
  70. package/dist/esm/SheetScrollView.js +274 -0
  71. package/dist/esm/SheetScrollView.js.map +1 -0
  72. package/dist/esm/constants.js +5 -0
  73. package/dist/esm/constants.js.map +1 -0
  74. package/dist/esm/contexts.js +6 -0
  75. package/dist/esm/contexts.js.map +1 -0
  76. package/dist/esm/controller.js +5 -0
  77. package/dist/esm/controller.js.map +1 -0
  78. package/dist/esm/createSheet.js +150 -0
  79. package/dist/esm/createSheet.js.map +1 -0
  80. package/dist/esm/gestureState.js +29 -0
  81. package/dist/esm/gestureState.js.map +1 -0
  82. package/dist/esm/helpers.js +26 -0
  83. package/dist/esm/helpers.js.map +1 -0
  84. package/dist/esm/index.js +13 -14
  85. package/dist/esm/index.js.map +1 -1
  86. package/dist/esm/keyboardAvoidance.js +62 -0
  87. package/dist/esm/keyboardAvoidance.js.map +1 -0
  88. package/dist/esm/nativeSheet.js +48 -0
  89. package/dist/esm/nativeSheet.js.map +1 -0
  90. package/dist/esm/setupGestureHandler.js +27 -0
  91. package/dist/esm/setupGestureHandler.js.map +1 -0
  92. package/dist/esm/types.js +2 -0
  93. package/dist/esm/types.js.map +1 -0
  94. package/dist/esm/useGestureHandlerPan.js +353 -0
  95. package/dist/esm/useGestureHandlerPan.js.map +1 -0
  96. package/dist/esm/useKeyboardControllerSheet.js +121 -0
  97. package/dist/esm/useKeyboardControllerSheet.js.map +1 -0
  98. package/dist/esm/useSafeAreaInsets.js +11 -0
  99. package/dist/esm/useSafeAreaInsets.js.map +1 -0
  100. package/dist/esm/useSheet.js +3 -0
  101. package/dist/esm/useSheet.js.map +1 -0
  102. package/dist/esm/useSheetController.js +14 -0
  103. package/dist/esm/useSheetController.js.map +1 -0
  104. package/dist/esm/useSheetOffscreenSize.js +36 -0
  105. package/dist/esm/useSheetOffscreenSize.js.map +1 -0
  106. package/dist/esm/useSheetOpenState.js +25 -0
  107. package/dist/esm/useSheetOpenState.js.map +1 -0
  108. package/dist/esm/useSheetProviderProps.js +165 -0
  109. package/dist/esm/useSheetProviderProps.js.map +1 -0
  110. package/dist/esm/useSheetScrollViewGestures.js +192 -0
  111. package/dist/esm/useSheetScrollViewGestures.js.map +1 -0
  112. package/dist/esm/webViewport.js +98 -0
  113. package/dist/esm/webViewport.js.map +1 -0
  114. package/dist/native/GestureDetectorWrapper.js +20 -0
  115. package/dist/native/GestureDetectorWrapper.js.map +1 -0
  116. package/dist/native/GestureSheetContext.js +17 -0
  117. package/dist/native/GestureSheetContext.js.map +1 -0
  118. package/dist/native/Sheet.js +97 -0
  119. package/dist/native/Sheet.js.map +1 -0
  120. package/dist/native/SheetContext.js +5 -0
  121. package/dist/native/SheetContext.js.map +1 -0
  122. package/dist/native/SheetController.js +28 -0
  123. package/dist/native/SheetController.js.map +1 -0
  124. package/dist/native/SheetImplementationCustom.js +862 -0
  125. package/dist/native/SheetImplementationCustom.js.map +1 -0
  126. package/dist/native/SheetScrollView.js +274 -0
  127. package/dist/native/SheetScrollView.js.map +1 -0
  128. package/dist/native/constants.js +5 -0
  129. package/dist/native/constants.js.map +1 -0
  130. package/dist/native/contexts.js +6 -0
  131. package/dist/native/contexts.js.map +1 -0
  132. package/dist/native/controller.js +5 -0
  133. package/dist/native/controller.js.map +1 -0
  134. package/dist/native/createSheet.js +150 -0
  135. package/dist/native/createSheet.js.map +1 -0
  136. package/dist/native/gestureState.js +29 -0
  137. package/dist/native/gestureState.js.map +1 -0
  138. package/dist/native/helpers.js +26 -0
  139. package/dist/native/helpers.js.map +1 -0
  140. package/dist/native/index.js +13 -0
  141. package/dist/native/index.js.map +1 -0
  142. package/dist/native/keyboardAvoidance.js +62 -0
  143. package/dist/native/keyboardAvoidance.js.map +1 -0
  144. package/dist/native/nativeSheet.js +48 -0
  145. package/dist/native/nativeSheet.js.map +1 -0
  146. package/dist/native/setupGestureHandler.js +27 -0
  147. package/dist/native/setupGestureHandler.js.map +1 -0
  148. package/dist/native/types.js +2 -0
  149. package/dist/native/types.js.map +1 -0
  150. package/dist/native/useGestureHandlerPan.js +353 -0
  151. package/dist/native/useGestureHandlerPan.js.map +1 -0
  152. package/dist/native/useKeyboardControllerSheet.js +118 -0
  153. package/dist/native/useKeyboardControllerSheet.js.map +1 -0
  154. package/dist/native/useSafeAreaInsets.js +25 -0
  155. package/dist/native/useSafeAreaInsets.js.map +1 -0
  156. package/dist/native/useSheet.js +3 -0
  157. package/dist/native/useSheet.js.map +1 -0
  158. package/dist/native/useSheetController.js +14 -0
  159. package/dist/native/useSheetController.js.map +1 -0
  160. package/dist/native/useSheetOffscreenSize.js +36 -0
  161. package/dist/native/useSheetOffscreenSize.js.map +1 -0
  162. package/dist/native/useSheetOpenState.js +25 -0
  163. package/dist/native/useSheetOpenState.js.map +1 -0
  164. package/dist/native/useSheetProviderProps.js +165 -0
  165. package/dist/native/useSheetProviderProps.js.map +1 -0
  166. package/dist/native/useSheetScrollViewGestures.js +131 -0
  167. package/dist/native/useSheetScrollViewGestures.js.map +1 -0
  168. package/dist/native/webViewport.js +98 -0
  169. package/dist/native/webViewport.js.map +1 -0
  170. package/package.json +46 -49
  171. package/src/GestureDetectorWrapper.tsx +1 -1
  172. package/src/Sheet.tsx +4 -4
  173. package/src/SheetContext.tsx +2 -2
  174. package/src/SheetController.d.ts +7 -0
  175. package/src/SheetController.d.ts.map +1 -0
  176. package/src/SheetController.js +38 -0
  177. package/src/SheetController.js.map +1 -0
  178. package/src/SheetController.tsx +2 -2
  179. package/src/SheetImplementationCustom.tsx +14 -14
  180. package/src/SheetScrollView.tsx +6 -6
  181. package/src/controller.ts +2 -2
  182. package/src/createSheet.tsx +9 -9
  183. package/src/index.ts +12 -12
  184. package/src/nativeSheet.tsx +4 -4
  185. package/src/useGestureHandlerPan.tsx +3 -3
  186. package/src/useKeyboardControllerSheet.native.ts +1 -1
  187. package/src/useKeyboardControllerSheet.ts +2 -2
  188. package/src/useSafeAreaInsets.native.ts +1 -1
  189. package/src/useSheet.tsx +1 -1
  190. package/src/useSheetController.d.ts +20 -0
  191. package/src/useSheetController.d.ts.map +1 -0
  192. package/src/useSheetController.js +14 -0
  193. package/src/useSheetController.js.map +1 -0
  194. package/src/useSheetOffscreenSize.tsx +1 -1
  195. package/src/useSheetOpenState.tsx +2 -2
  196. package/src/useSheetProviderProps.tsx +2 -2
  197. package/src/useSheetScrollViewGestures.native.ts +1 -1
  198. package/src/useSheetScrollViewGestures.ts +1 -1
  199. package/types/GestureDetectorWrapper.d.ts +1 -1
  200. package/types/GestureDetectorWrapper.d.ts.map +1 -1
  201. package/types/GestureSheetContext.d.ts +1 -1
  202. package/types/GestureSheetContext.d.ts.map +1 -1
  203. package/types/Sheet.d.ts +81 -89
  204. package/types/Sheet.d.ts.map +1 -1
  205. package/types/SheetContext.d.ts +5 -5
  206. package/types/SheetContext.d.ts.map +1 -1
  207. package/types/SheetController.d.ts +3 -2
  208. package/types/SheetController.d.ts.map +1 -1
  209. package/types/SheetImplementationCustom.d.ts +3 -3
  210. package/types/SheetImplementationCustom.d.ts.map +1 -1
  211. package/types/SheetScrollView.d.ts +6 -6
  212. package/types/controller.d.ts +2 -2
  213. package/types/controller.d.ts.map +1 -1
  214. package/types/createSheet.d.ts +85 -85
  215. package/types/createSheet.d.ts.map +1 -1
  216. package/types/index.d.ts +12 -12
  217. package/types/index.d.ts.map +1 -1
  218. package/types/nativeSheet.d.ts +1 -1
  219. package/types/nativeSheet.d.ts.map +1 -1
  220. package/types/useGestureHandlerPan.d.ts +1 -1
  221. package/types/useGestureHandlerPan.d.ts.map +1 -1
  222. package/types/useKeyboardControllerSheet.d.ts +1 -1
  223. package/types/useKeyboardControllerSheet.d.ts.map +1 -1
  224. package/types/useKeyboardControllerSheet.native.d.ts +1 -1
  225. package/types/useKeyboardControllerSheet.native.d.ts.map +1 -1
  226. package/types/useSafeAreaInsets.native.d.ts +1 -1
  227. package/types/useSafeAreaInsets.native.d.ts.map +1 -1
  228. package/types/useSheet.d.ts +1 -1
  229. package/types/useSheet.d.ts.map +1 -1
  230. package/types/useSheetOffscreenSize.d.ts +1 -1
  231. package/types/useSheetOffscreenSize.d.ts.map +1 -1
  232. package/types/useSheetOpenState.d.ts +2 -2
  233. package/types/useSheetOpenState.d.ts.map +1 -1
  234. package/types/useSheetProviderProps.d.ts +3 -3
  235. package/types/useSheetProviderProps.d.ts.map +1 -1
  236. package/types/useSheetScrollViewGestures.d.ts +1 -1
  237. package/types/useSheetScrollViewGestures.d.ts.map +1 -1
  238. package/types/useSheetScrollViewGestures.native.d.ts +1 -1
  239. package/types/useSheetScrollViewGestures.native.d.ts.map +1 -1
  240. package/controller/index.cjs +0 -2
  241. package/controller/index.d.ts +0 -5
  242. package/controller/index.js +0 -2
  243. package/controller/index.native.cjs +0 -2
  244. package/controller/index.native.js +0 -2
  245. package/dist/cjs/GestureDetectorWrapper.cjs +0 -54
  246. package/dist/cjs/GestureDetectorWrapper.native.js +0 -58
  247. package/dist/cjs/GestureDetectorWrapper.native.js.map +0 -1
  248. package/dist/cjs/GestureSheetContext.cjs +0 -54
  249. package/dist/cjs/GestureSheetContext.native.js +0 -58
  250. package/dist/cjs/GestureSheetContext.native.js.map +0 -1
  251. package/dist/cjs/Sheet.cjs +0 -119
  252. package/dist/cjs/Sheet.native.js +0 -122
  253. package/dist/cjs/Sheet.native.js.map +0 -1
  254. package/dist/cjs/SheetContext.cjs +0 -34
  255. package/dist/cjs/SheetContext.native.js +0 -37
  256. package/dist/cjs/SheetContext.native.js.map +0 -1
  257. package/dist/cjs/SheetController.cjs +0 -73
  258. package/dist/cjs/SheetController.native.js +0 -79
  259. package/dist/cjs/SheetController.native.js.map +0 -1
  260. package/dist/cjs/SheetImplementationCustom.cjs +0 -652
  261. package/dist/cjs/SheetImplementationCustom.native.js +0 -694
  262. package/dist/cjs/SheetImplementationCustom.native.js.map +0 -1
  263. package/dist/cjs/SheetScrollView.cjs +0 -337
  264. package/dist/cjs/SheetScrollView.native.js +0 -348
  265. package/dist/cjs/SheetScrollView.native.js.map +0 -1
  266. package/dist/cjs/constants.cjs +0 -34
  267. package/dist/cjs/constants.native.js +0 -37
  268. package/dist/cjs/constants.native.js.map +0 -1
  269. package/dist/cjs/contexts.cjs +0 -44
  270. package/dist/cjs/contexts.native.js +0 -47
  271. package/dist/cjs/contexts.native.js.map +0 -1
  272. package/dist/cjs/controller.cjs +0 -31
  273. package/dist/cjs/controller.native.js +0 -34
  274. package/dist/cjs/controller.native.js.map +0 -1
  275. package/dist/cjs/createSheet.cjs +0 -194
  276. package/dist/cjs/createSheet.native.js +0 -204
  277. package/dist/cjs/createSheet.native.js.map +0 -1
  278. package/dist/cjs/gestureState.cjs +0 -52
  279. package/dist/cjs/gestureState.native.js +0 -56
  280. package/dist/cjs/gestureState.native.js.map +0 -1
  281. package/dist/cjs/helpers.cjs +0 -35
  282. package/dist/cjs/helpers.native.js +0 -39
  283. package/dist/cjs/helpers.native.js.map +0 -1
  284. package/dist/cjs/index.cjs +0 -41
  285. package/dist/cjs/index.native.js +0 -44
  286. package/dist/cjs/index.native.js.map +0 -1
  287. package/dist/cjs/keyboardAvoidance.cjs +0 -93
  288. package/dist/cjs/keyboardAvoidance.native.js +0 -99
  289. package/dist/cjs/keyboardAvoidance.native.js.map +0 -1
  290. package/dist/cjs/nativeSheet.cjs +0 -99
  291. package/dist/cjs/nativeSheet.native.js +0 -109
  292. package/dist/cjs/nativeSheet.native.js.map +0 -1
  293. package/dist/cjs/setupGestureHandler.cjs +0 -55
  294. package/dist/cjs/setupGestureHandler.native.js +0 -60
  295. package/dist/cjs/setupGestureHandler.native.js.map +0 -1
  296. package/dist/cjs/types.cjs +0 -18
  297. package/dist/cjs/types.native.js +0 -21
  298. package/dist/cjs/types.native.js.map +0 -1
  299. package/dist/cjs/useGestureHandlerPan.cjs +0 -274
  300. package/dist/cjs/useGestureHandlerPan.native.js +0 -286
  301. package/dist/cjs/useGestureHandlerPan.native.js.map +0 -1
  302. package/dist/cjs/useKeyboardControllerSheet.cjs +0 -102
  303. package/dist/cjs/useKeyboardControllerSheet.native.js +0 -132
  304. package/dist/cjs/useKeyboardControllerSheet.native.js.map +0 -1
  305. package/dist/cjs/useSafeAreaInsets.cjs +0 -44
  306. package/dist/cjs/useSafeAreaInsets.native.js +0 -48
  307. package/dist/cjs/useSafeAreaInsets.native.js.map +0 -1
  308. package/dist/cjs/useSheet.cjs +0 -29
  309. package/dist/cjs/useSheet.native.js +0 -34
  310. package/dist/cjs/useSheet.native.js.map +0 -1
  311. package/dist/cjs/useSheetController.cjs +0 -52
  312. package/dist/cjs/useSheetController.native.js +0 -55
  313. package/dist/cjs/useSheetController.native.js.map +0 -1
  314. package/dist/cjs/useSheetOffscreenSize.cjs +0 -63
  315. package/dist/cjs/useSheetOffscreenSize.native.js +0 -70
  316. package/dist/cjs/useSheetOffscreenSize.native.js.map +0 -1
  317. package/dist/cjs/useSheetOpenState.cjs +0 -52
  318. package/dist/cjs/useSheetOpenState.native.js +0 -58
  319. package/dist/cjs/useSheetOpenState.native.js.map +0 -1
  320. package/dist/cjs/useSheetProviderProps.cjs +0 -181
  321. package/dist/cjs/useSheetProviderProps.native.js +0 -196
  322. package/dist/cjs/useSheetProviderProps.native.js.map +0 -1
  323. package/dist/cjs/useSheetScrollViewGestures.cjs +0 -191
  324. package/dist/cjs/useSheetScrollViewGestures.native.js +0 -163
  325. package/dist/cjs/useSheetScrollViewGestures.native.js.map +0 -1
  326. package/dist/cjs/webViewport.cjs +0 -75
  327. package/dist/cjs/webViewport.native.js +0 -81
  328. package/dist/cjs/webViewport.native.js.map +0 -1
  329. package/dist/esm/GestureDetectorWrapper.mjs +0 -29
  330. package/dist/esm/GestureDetectorWrapper.mjs.map +0 -1
  331. package/dist/esm/GestureDetectorWrapper.native.js +0 -30
  332. package/dist/esm/GestureDetectorWrapper.native.js.map +0 -1
  333. package/dist/esm/GestureSheetContext.mjs +0 -28
  334. package/dist/esm/GestureSheetContext.mjs.map +0 -1
  335. package/dist/esm/GestureSheetContext.native.js +0 -29
  336. package/dist/esm/GestureSheetContext.native.js.map +0 -1
  337. package/dist/esm/Sheet.mjs +0 -89
  338. package/dist/esm/Sheet.mjs.map +0 -1
  339. package/dist/esm/Sheet.native.js +0 -89
  340. package/dist/esm/Sheet.native.js.map +0 -1
  341. package/dist/esm/SheetContext.mjs +0 -6
  342. package/dist/esm/SheetContext.mjs.map +0 -1
  343. package/dist/esm/SheetContext.native.js +0 -6
  344. package/dist/esm/SheetContext.native.js.map +0 -1
  345. package/dist/esm/SheetController.mjs +0 -37
  346. package/dist/esm/SheetController.mjs.map +0 -1
  347. package/dist/esm/SheetController.native.js +0 -40
  348. package/dist/esm/SheetController.native.js.map +0 -1
  349. package/dist/esm/SheetImplementationCustom.mjs +0 -611
  350. package/dist/esm/SheetImplementationCustom.mjs.map +0 -1
  351. package/dist/esm/SheetImplementationCustom.native.js +0 -643
  352. package/dist/esm/SheetImplementationCustom.native.js.map +0 -1
  353. package/dist/esm/SheetScrollView.mjs +0 -301
  354. package/dist/esm/SheetScrollView.mjs.map +0 -1
  355. package/dist/esm/SheetScrollView.native.js +0 -309
  356. package/dist/esm/SheetScrollView.native.js.map +0 -1
  357. package/dist/esm/constants.mjs +0 -6
  358. package/dist/esm/constants.mjs.map +0 -1
  359. package/dist/esm/constants.native.js +0 -6
  360. package/dist/esm/constants.native.js.map +0 -1
  361. package/dist/esm/contexts.mjs +0 -7
  362. package/dist/esm/contexts.mjs.map +0 -1
  363. package/dist/esm/contexts.native.js +0 -7
  364. package/dist/esm/contexts.native.js.map +0 -1
  365. package/dist/esm/controller.mjs +0 -4
  366. package/dist/esm/controller.mjs.map +0 -1
  367. package/dist/esm/controller.native.js +0 -4
  368. package/dist/esm/controller.native.js.map +0 -1
  369. package/dist/esm/createSheet.mjs +0 -168
  370. package/dist/esm/createSheet.mjs.map +0 -1
  371. package/dist/esm/createSheet.native.js +0 -176
  372. package/dist/esm/createSheet.native.js.map +0 -1
  373. package/dist/esm/gestureState.mjs +0 -24
  374. package/dist/esm/gestureState.mjs.map +0 -1
  375. package/dist/esm/gestureState.native.js +0 -25
  376. package/dist/esm/gestureState.native.js.map +0 -1
  377. package/dist/esm/helpers.mjs +0 -10
  378. package/dist/esm/helpers.mjs.map +0 -1
  379. package/dist/esm/helpers.native.js +0 -11
  380. package/dist/esm/helpers.native.js.map +0 -1
  381. package/dist/esm/index.mjs +0 -14
  382. package/dist/esm/index.mjs.map +0 -1
  383. package/dist/esm/index.native.js +0 -14
  384. package/dist/esm/index.native.js.map +0 -1
  385. package/dist/esm/keyboardAvoidance.mjs +0 -66
  386. package/dist/esm/keyboardAvoidance.mjs.map +0 -1
  387. package/dist/esm/keyboardAvoidance.native.js +0 -69
  388. package/dist/esm/keyboardAvoidance.native.js.map +0 -1
  389. package/dist/esm/nativeSheet.mjs +0 -73
  390. package/dist/esm/nativeSheet.mjs.map +0 -1
  391. package/dist/esm/nativeSheet.native.js +0 -80
  392. package/dist/esm/nativeSheet.native.js.map +0 -1
  393. package/dist/esm/setupGestureHandler.mjs +0 -29
  394. package/dist/esm/setupGestureHandler.mjs.map +0 -1
  395. package/dist/esm/setupGestureHandler.native.js +0 -31
  396. package/dist/esm/setupGestureHandler.native.js.map +0 -1
  397. package/dist/esm/types.mjs +0 -2
  398. package/dist/esm/types.mjs.map +0 -1
  399. package/dist/esm/types.native.js +0 -2
  400. package/dist/esm/types.native.js.map +0 -1
  401. package/dist/esm/useGestureHandlerPan.mjs +0 -249
  402. package/dist/esm/useGestureHandlerPan.mjs.map +0 -1
  403. package/dist/esm/useGestureHandlerPan.native.js +0 -258
  404. package/dist/esm/useGestureHandlerPan.native.js.map +0 -1
  405. package/dist/esm/useKeyboardControllerSheet.mjs +0 -77
  406. package/dist/esm/useKeyboardControllerSheet.mjs.map +0 -1
  407. package/dist/esm/useKeyboardControllerSheet.native.js +0 -104
  408. package/dist/esm/useKeyboardControllerSheet.native.js.map +0 -1
  409. package/dist/esm/useSafeAreaInsets.mjs +0 -7
  410. package/dist/esm/useSafeAreaInsets.mjs.map +0 -1
  411. package/dist/esm/useSafeAreaInsets.native.js +0 -8
  412. package/dist/esm/useSafeAreaInsets.native.js.map +0 -1
  413. package/dist/esm/useSheet.mjs +0 -4
  414. package/dist/esm/useSheet.mjs.map +0 -1
  415. package/dist/esm/useSheet.native.js +0 -6
  416. package/dist/esm/useSheet.native.js.map +0 -1
  417. package/dist/esm/useSheetController.mjs +0 -15
  418. package/dist/esm/useSheetController.mjs.map +0 -1
  419. package/dist/esm/useSheetController.native.js +0 -15
  420. package/dist/esm/useSheetController.native.js.map +0 -1
  421. package/dist/esm/useSheetOffscreenSize.mjs +0 -38
  422. package/dist/esm/useSheetOffscreenSize.mjs.map +0 -1
  423. package/dist/esm/useSheetOffscreenSize.native.js +0 -42
  424. package/dist/esm/useSheetOffscreenSize.native.js.map +0 -1
  425. package/dist/esm/useSheetOpenState.mjs +0 -27
  426. package/dist/esm/useSheetOpenState.mjs.map +0 -1
  427. package/dist/esm/useSheetOpenState.native.js +0 -30
  428. package/dist/esm/useSheetOpenState.native.js.map +0 -1
  429. package/dist/esm/useSheetProviderProps.mjs +0 -145
  430. package/dist/esm/useSheetProviderProps.mjs.map +0 -1
  431. package/dist/esm/useSheetProviderProps.native.js +0 -157
  432. package/dist/esm/useSheetProviderProps.native.js.map +0 -1
  433. package/dist/esm/useSheetScrollViewGestures.mjs +0 -166
  434. package/dist/esm/useSheetScrollViewGestures.mjs.map +0 -1
  435. package/dist/esm/useSheetScrollViewGestures.native.js +0 -135
  436. package/dist/esm/useSheetScrollViewGestures.native.js.map +0 -1
  437. package/dist/esm/webViewport.mjs +0 -43
  438. package/dist/esm/webViewport.mjs.map +0 -1
  439. package/dist/esm/webViewport.native.js +0 -46
  440. package/dist/esm/webViewport.native.js.map +0 -1
  441. package/dist/jsx/GestureDetectorWrapper.mjs +0 -29
  442. package/dist/jsx/GestureDetectorWrapper.mjs.map +0 -1
  443. package/dist/jsx/GestureDetectorWrapper.native.js +0 -58
  444. package/dist/jsx/GestureDetectorWrapper.native.js.map +0 -1
  445. package/dist/jsx/GestureSheetContext.mjs +0 -28
  446. package/dist/jsx/GestureSheetContext.mjs.map +0 -1
  447. package/dist/jsx/GestureSheetContext.native.js +0 -58
  448. package/dist/jsx/GestureSheetContext.native.js.map +0 -1
  449. package/dist/jsx/Sheet.mjs +0 -89
  450. package/dist/jsx/Sheet.mjs.map +0 -1
  451. package/dist/jsx/Sheet.native.js +0 -122
  452. package/dist/jsx/Sheet.native.js.map +0 -1
  453. package/dist/jsx/SheetContext.mjs +0 -6
  454. package/dist/jsx/SheetContext.mjs.map +0 -1
  455. package/dist/jsx/SheetContext.native.js +0 -37
  456. package/dist/jsx/SheetContext.native.js.map +0 -1
  457. package/dist/jsx/SheetController.mjs +0 -37
  458. package/dist/jsx/SheetController.mjs.map +0 -1
  459. package/dist/jsx/SheetController.native.js +0 -79
  460. package/dist/jsx/SheetController.native.js.map +0 -1
  461. package/dist/jsx/SheetImplementationCustom.mjs +0 -611
  462. package/dist/jsx/SheetImplementationCustom.mjs.map +0 -1
  463. package/dist/jsx/SheetImplementationCustom.native.js +0 -694
  464. package/dist/jsx/SheetImplementationCustom.native.js.map +0 -1
  465. package/dist/jsx/SheetScrollView.mjs +0 -301
  466. package/dist/jsx/SheetScrollView.mjs.map +0 -1
  467. package/dist/jsx/SheetScrollView.native.js +0 -348
  468. package/dist/jsx/SheetScrollView.native.js.map +0 -1
  469. package/dist/jsx/constants.mjs +0 -6
  470. package/dist/jsx/constants.mjs.map +0 -1
  471. package/dist/jsx/constants.native.js +0 -37
  472. package/dist/jsx/constants.native.js.map +0 -1
  473. package/dist/jsx/contexts.mjs +0 -7
  474. package/dist/jsx/contexts.mjs.map +0 -1
  475. package/dist/jsx/contexts.native.js +0 -47
  476. package/dist/jsx/contexts.native.js.map +0 -1
  477. package/dist/jsx/controller.mjs +0 -4
  478. package/dist/jsx/controller.mjs.map +0 -1
  479. package/dist/jsx/controller.native.js +0 -34
  480. package/dist/jsx/controller.native.js.map +0 -1
  481. package/dist/jsx/createSheet.mjs +0 -168
  482. package/dist/jsx/createSheet.mjs.map +0 -1
  483. package/dist/jsx/createSheet.native.js +0 -204
  484. package/dist/jsx/createSheet.native.js.map +0 -1
  485. package/dist/jsx/gestureState.mjs +0 -24
  486. package/dist/jsx/gestureState.mjs.map +0 -1
  487. package/dist/jsx/gestureState.native.js +0 -56
  488. package/dist/jsx/gestureState.native.js.map +0 -1
  489. package/dist/jsx/helpers.mjs +0 -10
  490. package/dist/jsx/helpers.mjs.map +0 -1
  491. package/dist/jsx/helpers.native.js +0 -39
  492. package/dist/jsx/helpers.native.js.map +0 -1
  493. package/dist/jsx/index.js +0 -14
  494. package/dist/jsx/index.js.map +0 -1
  495. package/dist/jsx/index.mjs +0 -14
  496. package/dist/jsx/index.mjs.map +0 -1
  497. package/dist/jsx/index.native.js +0 -44
  498. package/dist/jsx/index.native.js.map +0 -1
  499. package/dist/jsx/keyboardAvoidance.mjs +0 -66
  500. package/dist/jsx/keyboardAvoidance.mjs.map +0 -1
  501. package/dist/jsx/keyboardAvoidance.native.js +0 -99
  502. package/dist/jsx/keyboardAvoidance.native.js.map +0 -1
  503. package/dist/jsx/nativeSheet.mjs +0 -73
  504. package/dist/jsx/nativeSheet.mjs.map +0 -1
  505. package/dist/jsx/nativeSheet.native.js +0 -109
  506. package/dist/jsx/nativeSheet.native.js.map +0 -1
  507. package/dist/jsx/setupGestureHandler.mjs +0 -29
  508. package/dist/jsx/setupGestureHandler.mjs.map +0 -1
  509. package/dist/jsx/setupGestureHandler.native.js +0 -60
  510. package/dist/jsx/setupGestureHandler.native.js.map +0 -1
  511. package/dist/jsx/types.mjs +0 -2
  512. package/dist/jsx/types.mjs.map +0 -1
  513. package/dist/jsx/types.native.js +0 -21
  514. package/dist/jsx/types.native.js.map +0 -1
  515. package/dist/jsx/useGestureHandlerPan.mjs +0 -249
  516. package/dist/jsx/useGestureHandlerPan.mjs.map +0 -1
  517. package/dist/jsx/useGestureHandlerPan.native.js +0 -286
  518. package/dist/jsx/useGestureHandlerPan.native.js.map +0 -1
  519. package/dist/jsx/useKeyboardControllerSheet.mjs +0 -77
  520. package/dist/jsx/useKeyboardControllerSheet.mjs.map +0 -1
  521. package/dist/jsx/useKeyboardControllerSheet.native.js +0 -132
  522. package/dist/jsx/useKeyboardControllerSheet.native.js.map +0 -1
  523. package/dist/jsx/useSafeAreaInsets.mjs +0 -7
  524. package/dist/jsx/useSafeAreaInsets.mjs.map +0 -1
  525. package/dist/jsx/useSafeAreaInsets.native.js +0 -48
  526. package/dist/jsx/useSafeAreaInsets.native.js.map +0 -1
  527. package/dist/jsx/useSheet.mjs +0 -4
  528. package/dist/jsx/useSheet.mjs.map +0 -1
  529. package/dist/jsx/useSheet.native.js +0 -34
  530. package/dist/jsx/useSheet.native.js.map +0 -1
  531. package/dist/jsx/useSheetController.mjs +0 -15
  532. package/dist/jsx/useSheetController.mjs.map +0 -1
  533. package/dist/jsx/useSheetController.native.js +0 -55
  534. package/dist/jsx/useSheetController.native.js.map +0 -1
  535. package/dist/jsx/useSheetOffscreenSize.mjs +0 -38
  536. package/dist/jsx/useSheetOffscreenSize.mjs.map +0 -1
  537. package/dist/jsx/useSheetOffscreenSize.native.js +0 -70
  538. package/dist/jsx/useSheetOffscreenSize.native.js.map +0 -1
  539. package/dist/jsx/useSheetOpenState.mjs +0 -27
  540. package/dist/jsx/useSheetOpenState.mjs.map +0 -1
  541. package/dist/jsx/useSheetOpenState.native.js +0 -58
  542. package/dist/jsx/useSheetOpenState.native.js.map +0 -1
  543. package/dist/jsx/useSheetProviderProps.mjs +0 -145
  544. package/dist/jsx/useSheetProviderProps.mjs.map +0 -1
  545. package/dist/jsx/useSheetProviderProps.native.js +0 -196
  546. package/dist/jsx/useSheetProviderProps.native.js.map +0 -1
  547. package/dist/jsx/useSheetScrollViewGestures.mjs +0 -166
  548. package/dist/jsx/useSheetScrollViewGestures.mjs.map +0 -1
  549. package/dist/jsx/useSheetScrollViewGestures.native.js +0 -163
  550. package/dist/jsx/useSheetScrollViewGestures.native.js.map +0 -1
  551. package/dist/jsx/webViewport.mjs +0 -43
  552. package/dist/jsx/webViewport.mjs.map +0 -1
  553. package/dist/jsx/webViewport.native.js +0 -81
  554. package/dist/jsx/webViewport.native.js.map +0 -1
  555. package/setup-gesture-handler/index.cjs +0 -2
  556. package/setup-gesture-handler/index.js +0 -2
  557. package/setup-gesture-handler/index.native.cjs +0 -2
  558. package/setup-gesture-handler/index.native.js +0 -2
  559. package/setup-gesture-handler.cjs +0 -1
@@ -0,0 +1,862 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ProvideAdaptContext, useAdaptContext } from '@hanzogui/adapt';
3
+ import { AnimatePresence } from '@hanzogui/animate-presence';
4
+ import { useComposedRefs } from '@hanzogui/compose-refs';
5
+ import { isWeb, useIsomorphicLayoutEffect } from '@hanzogui/constants';
6
+ import { LayoutMeasurementController, View as GuiView, useConfiguration, useDidFinishSSR, useEvent, useThemeName, } from '@hanzogui/core';
7
+ import { needsPortalRepropagation, Portal } from '@hanzogui/portal';
8
+ import React, { useState } from 'react';
9
+ import { Dimensions, PanResponder, View } from 'react-native';
10
+ import { ParentSheetContext, SheetInsideSheetContext } from './contexts.js';
11
+ import { GestureDetectorWrapper } from './GestureDetectorWrapper.js';
12
+ import { getGestureHandlerState } from './gestureState.js';
13
+ import { GestureSheetProvider } from './GestureSheetContext.js';
14
+ import { resisted } from './helpers.js';
15
+ import { getKeyboardAdjustedSheetY, getKeyboardOccludedHeight, getSheetReleasePosition, } from './keyboardAvoidance.js';
16
+ import { getWebKeyboardResizeHeight, getMaxViewportHeight, getStableLayoutViewportHeight, getWebVisualViewportOffsetTop, MIN_KEYBOARD_HEIGHT, } from './webViewport.js';
17
+ import { SheetProvider } from './SheetContext.js';
18
+ import { useGestureHandlerPan } from './useGestureHandlerPan.js';
19
+ import { useKeyboardControllerSheet } from './useKeyboardControllerSheet.js';
20
+ import { SafeAreaInsetsContext, useSafeAreaInsets } from './useSafeAreaInsets.js';
21
+ import { useSheetOpenState } from './useSheetOpenState.js';
22
+ import { useSheetProviderProps } from './useSheetProviderProps.js';
23
+ const hiddenSize = 10000.1;
24
+ // the re-established rngh root for a modal sheet (see modal branch below).
25
+ // GestureHandlerRootView does its own native touch interception and ignores
26
+ // pointerEvents, so it would block the whole app while the sheet sits closed
27
+ // but mounted. instead it stays full-width for correct child layout/measurement
28
+ // and collapses to 0 height when closed so it has no hit area.
29
+ const rnghRootStyleOpen = { width: '100%', height: '100%' };
30
+ const rnghRootStyleClosed = { width: '100%', height: 0 };
31
+ let sheetHiddenStyleSheet = null;
32
+ // on web we are always relative to window, on to screen
33
+ const relativeDimensionTo = isWeb ? 'window' : 'screen';
34
+ // height of the viewport the sheet positions against. on web this MUST be the
35
+ // stable layout viewport and NOT Dimensions.get('window') — react-native-web's
36
+ // Dimensions tracks visualViewport, which shrinks by the soft keyboard. capping
37
+ // frameSize / maxContentSize against that shrinking value corrupts the fit-mode
38
+ // math (translateY = screenSize - frameSize), detaching the sheet's bottom from
39
+ // the screen edge when the keyboard opens. NOTE: window.innerHeight is NOT
40
+ // stable on real iOS Safari (it shrinks with the keyboard too), so we use the
41
+ // self-correcting baseline from webViewport instead. see getStableLayoutViewportHeight.
42
+ function getStableViewportHeight() {
43
+ if (isWeb && typeof window !== 'undefined')
44
+ return getStableLayoutViewportHeight();
45
+ return Dimensions.get(relativeDimensionTo).height;
46
+ }
47
+ export const SheetImplementationCustom = React.forwardRef(function SheetImplementationCustom(props, forwardedRef) {
48
+ const parentSheet = React.useContext(ParentSheetContext);
49
+ // live safe-area insets (notch / status bar). read here in the component
50
+ // body — which renders INSIDE the app's SafeAreaProvider — so it is correct
51
+ // even though a modal sheet's CONTENT is teleported out through the portal.
52
+ // the keyboard-avoidance clamp below uses the top inset so a keyboard-shifted
53
+ // sheet tops out at the notch instead of sliding under it. web has no native
54
+ // safe-area context (CSS env() handles it) and uses the visual-viewport
55
+ // offset instead.
56
+ const safeAreaInsets = useSafeAreaInsets();
57
+ const safeAreaTopInset = safeAreaInsets?.top ?? 0;
58
+ const { transition, transitionConfig: transitionConfigProp, modal = false, zIndex = parentSheet.zIndex + 1, moveOnKeyboardChange = false, unmountChildrenWhenHidden = false, disableTransparencyHide = false, portalProps, containerComponent: ContainerComponent = React.Fragment, onAnimationComplete, } = props;
59
+ const state = useSheetOpenState(props);
60
+ const [overlayComponent, setOverlayComponent] = React.useState(null);
61
+ const providerProps = useSheetProviderProps(props, state, {
62
+ onOverlayComponent: setOverlayComponent,
63
+ });
64
+ const { frameSize, setFrameSize, dismissOnSnapToBottom, snapPoints, snapPointsMode, hasFit, position, setPosition, scrollBridge, screenSize, setMaxContentSize, maxSnapPoint, } = providerProps;
65
+ const { open, controller, isHidden } = state;
66
+ const openRef = React.useRef(open);
67
+ openRef.current = open;
68
+ const sheetRef = React.useRef(undefined);
69
+ const ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef);
70
+ // TODO this can be extracted into a helper getAnimationConfig(animationProp as array | string)
71
+ const { animationDriver } = useConfiguration();
72
+ if (!animationDriver) {
73
+ throw new Error(`Sheet requires an animation driver to be set`);
74
+ }
75
+ const transitionConfig = (() => {
76
+ // explicit transitionConfig prop always takes precedence
77
+ if (transitionConfigProp) {
78
+ return transitionConfigProp;
79
+ }
80
+ const [animationProp, animationPropConfig] = !transition
81
+ ? []
82
+ : Array.isArray(transition)
83
+ ? transition
84
+ : [transition];
85
+ // look up named animation config from driver if available
86
+ if (animationProp && animationDriver.animations?.[animationProp]) {
87
+ return {
88
+ ...animationDriver.animations[animationProp],
89
+ ...animationPropConfig,
90
+ };
91
+ }
92
+ return null;
93
+ })();
94
+ /**
95
+ * This is a hacky workaround for native:
96
+ */
97
+ const [isShowingInnerSheet, setIsShowingInnerSheet] = React.useState(false);
98
+ // when using Gorhom portal (no teleport), inner sheets need to hide parent
99
+ const shouldHideParentSheet = !isWeb && modal && isShowingInnerSheet && needsPortalRepropagation();
100
+ const sheetInsideSheet = React.useContext(SheetInsideSheetContext);
101
+ const onInnerSheet = React.useCallback((hasChild) => {
102
+ setIsShowingInnerSheet(hasChild);
103
+ }, []);
104
+ // keyboard state tracking — just tracks height/visibility, no position animation.
105
+ // Position animation is handled via keyboard-adjusted positions below,
106
+ // matching the react-native-actions-sheet pattern.
107
+ const { keyboardHeight, isKeyboardVisible, dismissKeyboard, pauseKeyboardHandler, flushPendingHide, } = useKeyboardControllerSheet({
108
+ enabled: Boolean(moveOnKeyboardChange),
109
+ });
110
+ // FIX: Store stable frameSize to prevent recalculation during exit animation
111
+ const stableFrameSize = React.useRef(frameSize);
112
+ React.useEffect(() => {
113
+ // Only update stable size when sheet is open
114
+ if (open && frameSize) {
115
+ stableFrameSize.current = frameSize;
116
+ }
117
+ }, [open, frameSize]);
118
+ // WEB keyboard frame freeze. on real iOS Safari opening the keyboard shrinks
119
+ // the visual viewport AND innerHeight AND the measured layout, which would
120
+ // re-derive screenSize/frameSize smaller, recompute the fit positions, and
121
+ // fly the frame up then back down ("goes back down after the keyboard opens").
122
+ // so we snapshot the pre-keyboard geometry — captured every render while the
123
+ // keyboard is CLOSED, which dodges the open-transition race where a shrunk
124
+ // onLayout lands before isKeyboardVisible flips — and use it for frame-size
125
+ // math while the keyboard is open. the active snap position still shifts up
126
+ // by the keyboard height, capped at the safe-area top; the scroll view gets
127
+ // keyboardOccludedHeight padding for any tail left behind the keyboard.
128
+ // this sheet is the kind the web keyboard frame freeze is designed for — a
129
+ // fit-mode web sheet opted into keyboard handling. percent/constant sheets
130
+ // keep the live geometry (their height isn't pinned, so a frozen frame
131
+ // height would mismatch).
132
+ const isWebKbSheet = isWeb && hasFit && moveOnKeyboardChange;
133
+ // NATIVE keyboard frame freeze. native fit sheets feed keyboardOccludedHeight
134
+ // into the ScrollView as scrollable tail padding so content can clear the
135
+ // keyboard. but that padding grows the fit content, which grows the frame,
136
+ // which grows the occluded height — a feedback loop that balloons the sheet
137
+ // to the full-screen cap. web breaks the loop by freezing geometry against
138
+ // effScreenSize; native has no such freeze, so we pin the ScrollView to the
139
+ // frame height measured while the keyboard was closed (preKeyboardFrameSize)
140
+ // via keyboardStableFrameHeight below. unlike web, the native keyboard is an
141
+ // overlay that never shrinks the measured screen, so screenSize stays live.
142
+ const isNativeKbFitSheet = !isWeb && hasFit && Boolean(moveOnKeyboardChange);
143
+ // snapshot the fit frame height while the keyboard is closed, so the pin above
144
+ // holds the pre-keyboard viewport rather than a mid-feedback-loop value.
145
+ const preKeyboardFrameSize = React.useRef(0);
146
+ React.useEffect(() => {
147
+ if (isNativeKbFitSheet && open && !isKeyboardVisible && frameSize > 0) {
148
+ preKeyboardFrameSize.current = frameSize;
149
+ }
150
+ }, [isNativeKbFitSheet, open, isKeyboardVisible, frameSize]);
151
+ // the space the snap positions are built against. WEB: the stable layout
152
+ // viewport (document.documentElement.clientHeight), which the soft keyboard
153
+ // never shrinks (unlike the measured screenSize / visualViewport). NATIVE:
154
+ // the measured screenSize. activePositions shift up by keyboardHeight below
155
+ // so a small fit sheet keeps its natural height and moves with the keyboard;
156
+ // a tall fit sheet moves until capped at the safe-area top, leaving its tail
157
+ // behind the keyboard for the ScrollView padding to expose.
158
+ const effScreenSize = isWebKbSheet ? getStableViewportHeight() : screenSize;
159
+ // use stableFrameSize when closing to prevent position jumps during the exit
160
+ // animation; while open use the live frameSize.
161
+ const effectiveFrameSize = open ? frameSize : stableFrameSize.current || frameSize;
162
+ const positions = React.useMemo(() => snapPoints.map((point) => getYPositions(snapPointsMode, point, effScreenSize, effectiveFrameSize)), [effScreenSize, effectiveFrameSize, snapPoints, snapPointsMode]);
163
+ const [isDragging, setIsDragging_] = React.useState(false);
164
+ // synchronous dragging ref — set BEFORE async state commits.
165
+ // RNGH onBegin fires before keyboard hide event reaches JS,
166
+ // so the ref is true by the time activePositions memo re-evaluates.
167
+ // Also controls pauseKeyboardHandler to freeze keyboard state during drag.
168
+ const isDraggingRef = React.useRef(false);
169
+ const setIsDragging = React.useCallback((val) => {
170
+ isDraggingRef.current = val;
171
+ pauseKeyboardHandler.current = val;
172
+ setIsDragging_(val);
173
+ // when drag ends, flush any keyboard hide that was suppressed during drag
174
+ // so isKeyboardVisible/keyboardHeight reflect actual state
175
+ if (!val) {
176
+ flushPendingHide();
177
+ }
178
+ }, [pauseKeyboardHandler, flushPendingHide]);
179
+ // keyboard-adjusted snap positions.
180
+ //
181
+ // WEB + NATIVE: shift snap points up by keyboard height, capped at the
182
+ // safe-area top inset. web fit sheets keep their frozen pre-keyboard height
183
+ // and add bottom spacer padding when the safe-area cap leaves a hidden tail.
184
+ //
185
+ // IMPORTANT: frozen during drag to prevent gesture handler recreation —
186
+ // when a TextInput blurs mid-drag the keyboard state would otherwise revert
187
+ // and recreate the gesture useMemo, cancelling the active drag.
188
+ const activePositionsRef = React.useRef(positions);
189
+ const activePositions = React.useMemo(() => {
190
+ if (isDragging || isDraggingRef.current)
191
+ return activePositionsRef.current;
192
+ let result;
193
+ if (!isKeyboardVisible || keyboardHeight <= 0) {
194
+ result = positions;
195
+ }
196
+ else {
197
+ result = positions.map((p) => getKeyboardAdjustedSheetY({
198
+ sheetY: p,
199
+ screenSize: effScreenSize,
200
+ isKeyboardVisible,
201
+ keyboardHeight,
202
+ shouldTranslate: true,
203
+ safeAreaTop: isWeb ? getWebVisualViewportOffsetTop() : safeAreaTopInset,
204
+ }));
205
+ }
206
+ activePositionsRef.current = result;
207
+ return result;
208
+ }, [
209
+ positions,
210
+ isKeyboardVisible,
211
+ keyboardHeight,
212
+ effScreenSize,
213
+ isDragging,
214
+ safeAreaTopInset,
215
+ ]);
216
+ // bottom spacer for the part of the sheet hidden by the keyboard after the
217
+ // keyboard translation and safe-area clamping. if a small sheet fits above
218
+ // the keyboard this is 0; if a tall sheet is capped at the safe-area top, the
219
+ // spacer makes the remaining hidden tail scrollable.
220
+ const keyboardOccludedHeight = getKeyboardOccludedHeight({
221
+ frameSize: effectiveFrameSize,
222
+ isKeyboardVisible,
223
+ keyboardHeight,
224
+ screenSize: effScreenSize,
225
+ sheetY: position >= 0 ? activePositions[position] : undefined,
226
+ });
227
+ // pin the scroll view to the held (pre-keyboard) frame height while the
228
+ // keyboard is up on web. on older iOS the consumer's window-derived maxHeight
229
+ // shrinks with the keyboard, which would clip the scroll view (and the frame)
230
+ // smaller; this override keeps it at the full height so the frame translates
231
+ // with the keyboard but never resizes. 0 = no override (use the consumer maxHeight).
232
+ const keyboardStableFrameHeight = isWebKbSheet && isKeyboardVisible && frameSize > 0
233
+ ? frameSize
234
+ : isNativeKbFitSheet && isKeyboardVisible && preKeyboardFrameSize.current > 0
235
+ ? preKeyboardFrameSize.current
236
+ : 0;
237
+ const { useAnimatedNumber, useAnimatedNumberStyle } = animationDriver;
238
+ const AnimatedView = (animationDriver.View ?? GuiView);
239
+ useIsomorphicLayoutEffect(() => {
240
+ if (!(sheetInsideSheet && open))
241
+ return;
242
+ sheetInsideSheet(true);
243
+ return () => {
244
+ sheetInsideSheet(false);
245
+ };
246
+ }, [sheetInsideSheet, open]);
247
+ const nextParentContext = React.useMemo(() => ({
248
+ zIndex,
249
+ }), [zIndex]);
250
+ const isMounted = useDidFinishSSR();
251
+ const startPosition = isMounted && screenSize ? screenSize : hiddenSize;
252
+ const animatedNumber = useAnimatedNumber(startPosition);
253
+ const at = React.useRef(startPosition);
254
+ const hasntMeasured = at.current === hiddenSize;
255
+ const [disableAnimation, setDisableAnimation] = useState(hasntMeasured);
256
+ // use skipNextAnimation signal from controller (set when adapt handoff occurs)
257
+ const skipAdaptAnimation = React.useRef(false);
258
+ if (controller?.skipNextAnimation) {
259
+ skipAdaptAnimation.current = true;
260
+ }
261
+ const hasScrollView = React.useRef(false);
262
+ // safety fallback timer for sheet close opacity
263
+ const opacityFallbackTimer = React.useRef(null);
264
+ const syncAnimatedPosition = useEvent((value) => {
265
+ at.current = value;
266
+ scrollBridge.paneY = value;
267
+ // update isAtTop for scroll enable/disable. activePositions[0] is the
268
+ // top snap point (keyboard-adjusted minY).
269
+ const minY = activePositions[0];
270
+ const wasAtTop = scrollBridge.isAtTop;
271
+ const nowAtTop = value <= minY + 5;
272
+ if (wasAtTop === nowAtTop)
273
+ return;
274
+ scrollBridge.isAtTop = nowAtTop;
275
+ if (nowAtTop) {
276
+ if (scrollBridge.lockScrollAtTop) {
277
+ if (scrollBridge.y > 0) {
278
+ scrollBridge.forceScrollTo?.(0);
279
+ scrollBridge.y = 0;
280
+ }
281
+ scrollBridge.scrollLockY = 0;
282
+ scrollBridge.setScrollEnabled?.(false, 0);
283
+ return;
284
+ }
285
+ // if scroll drifted during drag (e.g. fast swipe from position 1),
286
+ // reset it to 0 before enabling free scroll.
287
+ if (scrollBridge.y > 0) {
288
+ scrollBridge.forceScrollTo?.(0);
289
+ scrollBridge.y = 0;
290
+ }
291
+ scrollBridge.scrollLockY = undefined;
292
+ scrollBridge.setScrollEnabled?.(true);
293
+ }
294
+ else {
295
+ scrollBridge.scrollLockY = 0;
296
+ scrollBridge.setScrollEnabled?.(false);
297
+ }
298
+ });
299
+ const setAnimatedPositionDirect = useEvent((value) => {
300
+ syncAnimatedPosition(value);
301
+ animatedNumber.setValue(value, { type: 'direct' });
302
+ });
303
+ const getAnimatedPosition = useEvent(() => {
304
+ const value = animatedNumber.getValue();
305
+ syncAnimatedPosition(value);
306
+ return value;
307
+ });
308
+ function stopSpring() {
309
+ animatedNumber.stop();
310
+ if (scrollBridge.onFinishAnimate) {
311
+ scrollBridge.onFinishAnimate();
312
+ scrollBridge.onFinishAnimate = undefined;
313
+ }
314
+ }
315
+ const animateTo = useEvent((position, animationOverride) => {
316
+ if (frameSize === 0)
317
+ return;
318
+ // use effScreenSize (the frozen anchor space the positions were built in) for
319
+ // the off-screen/close target too, so a close while the keyboard is still up
320
+ // animates fully out instead of to a mismatched live screenSize.
321
+ //
322
+ // web: clear the maximum the viewport can ever reveal, not just the current
323
+ // layout viewport. iOS Safari retracts its chrome on scroll and exposes area
324
+ // below the current viewport, so a sheet parked at effScreenSize would peek
325
+ // back in as the page scrolls. getMaxViewportHeight floors the target past
326
+ // anything Safari can expose.
327
+ const closeTarget = isWeb
328
+ ? Math.max(effScreenSize, getMaxViewportHeight())
329
+ : effScreenSize;
330
+ let toValue = isHidden || position === -1 ? closeTarget : activePositions[position];
331
+ if (at.current === toValue)
332
+ return;
333
+ at.current = toValue;
334
+ stopSpring();
335
+ const isOpenAnimation = position !== -1 && !isHidden;
336
+ // clear any pending fallback timer
337
+ if (opacityFallbackTimer.current) {
338
+ clearTimeout(opacityFallbackTimer.current);
339
+ opacityFallbackTimer.current = null;
340
+ }
341
+ const animationCompleteCallback = () => {
342
+ syncAnimatedPosition(toValue);
343
+ if (opacityFallbackTimer.current) {
344
+ clearTimeout(opacityFallbackTimer.current);
345
+ opacityFallbackTimer.current = null;
346
+ }
347
+ // use openRef (live) not open (stale closure) — if the sheet
348
+ // was reopened before this callback fires (e.g. cancelled close
349
+ // animation), we must not hide it
350
+ if (!isOpenAnimation && !openRef.current) {
351
+ setOpacity(0);
352
+ }
353
+ onAnimationComplete?.({ open: isOpenAnimation });
354
+ // also notify the SheetController so a parent (e.g. Dialog adapt)
355
+ // can hold the sheet's children mounted until the slide-out is done
356
+ controller?.onAnimationComplete?.({ open: isOpenAnimation });
357
+ };
358
+ // safety fallback: if animation callback never fires, still hide the sheet
359
+ if (!isOpenAnimation) {
360
+ opacityFallbackTimer.current = setTimeout(() => {
361
+ opacityFallbackTimer.current = null;
362
+ // check live open state via ref — sheet may have reopened (e.g. adapt handoff)
363
+ if (!openRef.current) {
364
+ setOpacity(0);
365
+ }
366
+ }, 1000);
367
+ }
368
+ // skip animation when adapting from dialog to sheet
369
+ if (skipAdaptAnimation.current) {
370
+ skipAdaptAnimation.current = false;
371
+ animatedNumber.setValue(toValue, { type: 'timing', duration: 0 }, animationCompleteCallback);
372
+ return;
373
+ }
374
+ animatedNumber.setValue(toValue, animationOverride || {
375
+ type: 'spring',
376
+ ...transitionConfig,
377
+ }, animationCompleteCallback);
378
+ });
379
+ useIsomorphicLayoutEffect(() => {
380
+ // we need to do a *three* step process for the css driver
381
+ // first render off screen for ssr safety (hiddenSize)
382
+ // then render to bottom of screen without animation (screenSize)
383
+ // then add the animation as it animates from screenSize to position
384
+ if (hasntMeasured && screenSize && frameSize) {
385
+ at.current = screenSize;
386
+ animatedNumber.setValue(screenSize, {
387
+ type: 'timing',
388
+ duration: 0,
389
+ }, () => {
390
+ syncAnimatedPosition(screenSize);
391
+ // imperfect but struggling to render properly here
392
+ setTimeout(() => {
393
+ setDisableAnimation(false);
394
+ }, 10);
395
+ });
396
+ return;
397
+ }
398
+ if (disableAnimation) {
399
+ return;
400
+ }
401
+ // never fight an active drag: the gesture owns the animated position. on
402
+ // web the AnimatedView's onLayout re-fires with sub-pixel jitter as the
403
+ // frame translates (frameSize 499.99996 <-> 500.00003), and since frameSize
404
+ // is a dep of this effect that would re-run it mid-pull and snap the sheet
405
+ // back to its resting snap point. read the live ref so drag-end (which the
406
+ // reconcile-after-drag effect handles) isn't gated by stale deps.
407
+ if (isDraggingRef.current) {
408
+ return;
409
+ }
410
+ if (!frameSize || !screenSize || isHidden || (hasntMeasured && !open)) {
411
+ return;
412
+ }
413
+ // finally, animate
414
+ animateTo(position);
415
+ // reset scroll bridge
416
+ if (position === -1) {
417
+ scrollBridge.scrollLock = false;
418
+ scrollBridge.scrollStartY = -1;
419
+ }
420
+ // set initial isAtTop state when sheet opens
421
+ // position 0 = top snap point, so isAtTop = true
422
+ if (open && position >= 0) {
423
+ const isTopPosition = position === 0;
424
+ scrollBridge.isAtTop = isTopPosition;
425
+ if (isTopPosition) {
426
+ scrollBridge.scrollLockY = undefined;
427
+ scrollBridge.setScrollEnabled?.(true);
428
+ }
429
+ else {
430
+ scrollBridge.scrollLockY = 0;
431
+ scrollBridge.setScrollEnabled?.(false);
432
+ }
433
+ }
434
+ // NOTE: effScreenSize/effectiveFrameSize are intentionally NOT deps. With the
435
+ // spacer approach the frame's position target is frozen across keyboard
436
+ // open/close (same stable baseline), so it must NOT re-animate — keyboard
437
+ // avoidance is the bottom spacer + scroll, not a frame move.
438
+ }, [hasntMeasured, disableAnimation, isHidden, frameSize, screenSize, open, position]);
439
+ const disableDrag = props.disableDrag ?? controller?.disableDrag;
440
+ const themeName = useThemeName();
441
+ const [blockPan, setBlockPan] = React.useState(false);
442
+ const panResponder = React.useMemo(() => {
443
+ if (disableDrag)
444
+ return;
445
+ if (!frameSize)
446
+ return;
447
+ if (isShowingInnerSheet)
448
+ return;
449
+ // use keyboard-adjusted positions (matches the RNGH path): when the
450
+ // keyboard is open the sheet sits at activePositions[0], so clamping drags
451
+ // against the un-adjusted positions[0] would rubber-band the sheet down to
452
+ // near the bottom on any drag.
453
+ const minY = activePositions[0];
454
+ scrollBridge.paneMinY = minY;
455
+ let startY = at.current;
456
+ function setPanning(val) {
457
+ setIsDragging(val);
458
+ // make unselectable:
459
+ if ("web" === 'web') {
460
+ if (!sheetHiddenStyleSheet) {
461
+ sheetHiddenStyleSheet = document.createElement('style');
462
+ if (typeof document.head !== 'undefined') {
463
+ document.head.appendChild(sheetHiddenStyleSheet);
464
+ }
465
+ }
466
+ if (!val) {
467
+ sheetHiddenStyleSheet.innerText = '';
468
+ }
469
+ else {
470
+ sheetHiddenStyleSheet.innerText =
471
+ ':root * { user-select: none !important; -webkit-user-select: none !important; }';
472
+ }
473
+ }
474
+ }
475
+ const release = ({ vy }) => {
476
+ scrollBridge.setParentDragging(false);
477
+ if (scrollBridge.scrollLock) {
478
+ return;
479
+ }
480
+ isExternalDrag = false;
481
+ previouslyScrolling = false;
482
+ setPanning(false);
483
+ // use the actual current animated position rather than dragAt + startY.
484
+ // after mid-gesture handoffs (pan→scroll→pan), startY can be stale
485
+ // causing the computed position to be wildly wrong (triggering dismiss).
486
+ const currentPos = at.current;
487
+ // vy goes up to about 4 at most (+ is down, - is up)
488
+ const end = currentPos + frameSize * vy * 0.2;
489
+ const closestPoint = getSheetReleasePosition({
490
+ positions: activePositions,
491
+ projectedEnd: end,
492
+ currentPosition: currentPos,
493
+ frameSize,
494
+ dismissOnSnapToBottom,
495
+ snapPointsMode,
496
+ isKeyboardVisible,
497
+ isWeb,
498
+ });
499
+ // have to call both because state may not change but need to snap back
500
+ setPosition(closestPoint);
501
+ animateTo(closestPoint);
502
+ };
503
+ const finish = (_e, state) => {
504
+ release({
505
+ vy: state.vy,
506
+ dragAt: state.dy,
507
+ });
508
+ };
509
+ let previouslyScrolling = false;
510
+ const onMoveShouldSet = (e, { dy }) => {
511
+ function getShouldSet() {
512
+ // if dragging handle always allow:
513
+ if (e.target === providerProps.handleRef.current) {
514
+ return true;
515
+ }
516
+ // touch is on the ScrollView node — the web scroll-view gesture hook
517
+ // owns it and drives drag/release through scrollBridge directly (it
518
+ // re-baselines via scrollBridge.startPanDrag on each pan handoff). if
519
+ // we also granted here, RNW's PanResponder would set the animated
520
+ // position from a second, differently-based offset every move and the
521
+ // sheet would jitter/jump. defer entirely to the hook.
522
+ if (scrollBridge.scrollNodeTouched) {
523
+ return false;
524
+ }
525
+ if (scrollBridge.hasScrollableContent === true) {
526
+ if (scrollBridge.scrollLock) {
527
+ return false;
528
+ }
529
+ const isScrolled = scrollBridge.y !== 0;
530
+ // Update the dragging direction
531
+ const isDraggingUp = dy < 0;
532
+ // we can treat near top instead of exactly to avoid trouble with springs
533
+ const isNearTop = scrollBridge.paneY - 5 <= scrollBridge.paneMinY;
534
+ if (isScrolled) {
535
+ previouslyScrolling = true;
536
+ return false;
537
+ }
538
+ // prevent drag once at top and pulling up
539
+ if (isNearTop) {
540
+ if (hasScrollView.current && isDraggingUp) {
541
+ return false;
542
+ }
543
+ }
544
+ }
545
+ // we could do some detection of other touchables and cancel here..
546
+ return Math.abs(dy) > 10;
547
+ }
548
+ const granted = getShouldSet();
549
+ if (granted) {
550
+ scrollBridge.setParentDragging(true);
551
+ }
552
+ return granted;
553
+ };
554
+ const grant = () => {
555
+ setPanning(true);
556
+ stopSpring();
557
+ startY = getAnimatedPosition();
558
+ };
559
+ let isExternalDrag = false;
560
+ // re-baseline a pan drag to the current animated position. the web
561
+ // scroll-view hook calls this on every transition INTO pan ownership
562
+ // (including handoffs back from scroll), so its panDragOffset — which it
563
+ // resets to 0 at each pan entry — is measured from where the sheet
564
+ // actually is now, not from where the gesture first grabbed it. without
565
+ // this the sheet would jump to a stale origin on a scroll→pan handoff.
566
+ scrollBridge.startPanDrag = () => {
567
+ isExternalDrag = true;
568
+ grant();
569
+ };
570
+ scrollBridge.drag = (dy) => {
571
+ if (!isExternalDrag) {
572
+ isExternalDrag = true;
573
+ grant();
574
+ }
575
+ const to = dy + startY;
576
+ setAnimatedPositionDirect(resisted(to, minY));
577
+ };
578
+ scrollBridge.release = release;
579
+ // direct snap to position without release calculation (for handoff cases)
580
+ scrollBridge.snapToPosition = (positionIndex) => {
581
+ isExternalDrag = false;
582
+ previouslyScrolling = false;
583
+ setPanning(false);
584
+ setPosition(positionIndex);
585
+ animateTo(positionIndex);
586
+ };
587
+ return PanResponder.create({
588
+ onMoveShouldSetPanResponder: onMoveShouldSet,
589
+ // once we own the drag, don't yield it to another responder
590
+ // (re-renders during the drag were cooperatively terminating it under
591
+ // load, killing the gesture mid-drag)
592
+ onPanResponderTerminationRequest: () => false,
593
+ onPanResponderGrant: grant,
594
+ onPanResponderMove: (_e, { dy }) => {
595
+ const toFull = dy + startY;
596
+ const to = resisted(toFull, minY);
597
+ // handles the case where you hand off back and forth more than once
598
+ const isAtTop = to <= minY;
599
+ if (isAtTop) {
600
+ scrollBridge.setParentDragging(false);
601
+ }
602
+ else {
603
+ scrollBridge.setParentDragging(true);
604
+ }
605
+ setAnimatedPositionDirect(to);
606
+ },
607
+ onPanResponderEnd: finish,
608
+ onPanResponderTerminate: finish,
609
+ onPanResponderRelease: finish,
610
+ });
611
+ }, [
612
+ disableDrag,
613
+ isShowingInnerSheet,
614
+ animateTo,
615
+ frameSize,
616
+ activePositions,
617
+ setPosition,
618
+ dismissOnSnapToBottom,
619
+ snapPointsMode,
620
+ ]);
621
+ // animate to the current keyboard-adjusted position when the keyboard state
622
+ // changes. activePositions shift the frame up by keyboardHeight, capped at
623
+ // the safe-area top; tall web fit sheets keep a frozen height and gain scroll
624
+ // padding for whatever tail remains behind the keyboard.
625
+ React.useEffect(() => {
626
+ if (isDragging || isHidden || !open || disableAnimation)
627
+ return;
628
+ if (!frameSize || !screenSize)
629
+ return;
630
+ // timing animation matches the iOS keyboard animation (~250ms)
631
+ animateTo(position, { type: 'timing', duration: 250 });
632
+ }, [isKeyboardVisible, keyboardHeight]);
633
+ // reconcile position after drag ends — if keyboard dismissed during drag
634
+ // (e.g., input blur), activePositions reverted but onEnd used frozen positions
635
+ // for snap index. This effect ensures the sheet animates to the correct
636
+ // non-keyboard-adjusted position for the chosen snap index.
637
+ const wasDragging = React.useRef(false);
638
+ React.useEffect(() => {
639
+ if (isDragging) {
640
+ wasDragging.current = true;
641
+ return;
642
+ }
643
+ if (!wasDragging.current)
644
+ return;
645
+ wasDragging.current = false;
646
+ // drag just ended — reconcile position with latest activePositions
647
+ if (!frameSize || !screenSize || isHidden || !open)
648
+ return;
649
+ animateTo(position);
650
+ }, [isDragging]);
651
+ // dismiss keyboard when sheet closes
652
+ React.useEffect(() => {
653
+ if (!open && isKeyboardVisible) {
654
+ dismissKeyboard();
655
+ // if the sheet was closed mid-drag the keyboard-hide handler was paused
656
+ // and a hide could be left pending — clear it so isKeyboardVisible can't
657
+ // stick true after the sheet is gone. (no-op for a normal close.)
658
+ pauseKeyboardHandler.current = false;
659
+ flushPendingHide();
660
+ }
661
+ }, [open]);
662
+ // gesture handler hook for RNGH-based gesture coordination
663
+ const { panGesture, panGestureRef, gestureHandlerEnabled } = useGestureHandlerPan({
664
+ positions: activePositions,
665
+ frameSize,
666
+ setPosition,
667
+ animateTo,
668
+ stopSpring,
669
+ scrollBridge,
670
+ setIsDragging,
671
+ getCurrentPosition: getAnimatedPosition,
672
+ resisted,
673
+ disableDrag,
674
+ isShowingInnerSheet,
675
+ // directly set the animated value for smooth dragging
676
+ setAnimatedPosition: setAnimatedPositionDirect,
677
+ dismissOnSnapToBottom,
678
+ snapPointsMode,
679
+ isKeyboardVisible,
680
+ pauseKeyboardHandler,
681
+ });
682
+ // ignore any layout measured while the soft keyboard is up (web +
683
+ // moveOnKeyboardChange): the visual viewport (which RN's web layout follows)
684
+ // shrinks, so the height would be the collapsed sheet — keeping it would
685
+ // recompute the fit anchor and fly the frame. a LIVE DOM check, NOT the
686
+ // isKeyboardVisible React state, is required: the state lags the resize, so
687
+ // the first shrunk onLayout lands before the flag flips. holding the measured
688
+ // size keeps the fit geometry stable while the frame translates with the kb.
689
+ const ignoreLayoutForKeyboard = useEvent(() => isWeb &&
690
+ moveOnKeyboardChange &&
691
+ getWebKeyboardResizeHeight() >= MIN_KEYBOARD_HEIGHT);
692
+ const handleAnimationViewLayout = useEvent((e) => {
693
+ // don't update frameSize during exit animation to prevent position jumps
694
+ if (!open && stableFrameSize.current !== 0) {
695
+ return;
696
+ }
697
+ const layoutHeight = e.nativeEvent?.layout.height;
698
+ // drop a layout measured while the keyboard is up: on older iOS the web
699
+ // viewport shrinks and the frame would resize. keep the pre-keyboard frame
700
+ // height so the web frame translates without resizing.
701
+ // exception: if we have no frame height yet (sheet opened with the keyboard
702
+ // already up), accept it so the sheet can appear at all.
703
+ if (ignoreLayoutForKeyboard() && frameSize > 0)
704
+ return;
705
+ // avoid bugs where it grows forever for whatever reason
706
+ // For inline mode (non-modal), don't cap at window height - use actual layout
707
+ const next = modal
708
+ ? Math.min(layoutHeight, getStableViewportHeight())
709
+ : layoutHeight;
710
+ if (!next)
711
+ return;
712
+ // round: web onLayout reports sub-pixel heights (e.g. 499.99996) that jitter
713
+ // frame to frame as the view transforms; the raw float would re-fire every
714
+ // effect that depends on frameSize on each drag move.
715
+ setFrameSize(Math.round(next));
716
+ });
717
+ const handleMaxContentViewLayout = React.useCallback((e) => {
718
+ // keep maxContentSize at the full pre-keyboard viewport: drop layouts
719
+ // measured while the keyboard is up (the shrunk viewport), unless we have
720
+ // none yet (keyboard-already-up open).
721
+ if (ignoreLayoutForKeyboard() && screenSize > 0)
722
+ return;
723
+ // avoid bugs where it grows forever for whatever reason
724
+ const next = Math.min(e.nativeEvent?.layout.height, getStableViewportHeight());
725
+ if (!next)
726
+ return;
727
+ // round to avoid sub-pixel churn re-firing size-dependent effects
728
+ setMaxContentSize(Math.round(next));
729
+ }, [ignoreLayoutForKeyboard, screenSize]);
730
+ const getAnimatedNumberStyle = React.useCallback((val) => {
731
+ 'worklet';
732
+ const translateY = frameSize === 0 ? hiddenSize : val;
733
+ return {
734
+ transform: [{ translateY }],
735
+ };
736
+ }, [frameSize]);
737
+ const animatedStyle = useAnimatedNumberStyle(animatedNumber, getAnimatedNumberStyle);
738
+ // we need to set this *after* fully closed to 0, to avoid it overlapping
739
+ // the page when resizing quickly on web for example
740
+ const [opacity, setOpacity] = React.useState(open ? 1 : 0);
741
+ if (open && opacity === 0) {
742
+ setOpacity(1);
743
+ // cancel any pending close fallback — sheet is reopening
744
+ if (opacityFallbackTimer.current) {
745
+ clearTimeout(opacityFallbackTimer.current);
746
+ opacityFallbackTimer.current = null;
747
+ }
748
+ }
749
+ const forcedContentHeight = hasFit
750
+ ? undefined
751
+ : snapPointsMode === 'percent'
752
+ ? // Use dvh for modal (viewport-relative), % for inline (container-relative)
753
+ `${maxSnapPoint}${isWeb ? (modal ? 'dvh' : '%') : '%'}`
754
+ : maxSnapPoint;
755
+ const setHasScrollView = React.useCallback((val) => {
756
+ hasScrollView.current = val;
757
+ }, []);
758
+ // const id = useId()
759
+ // const { AdaptProvider, when, children } = useAdaptParent({
760
+ // scope: `${id}Sheet`,
761
+ // portal: true,
762
+ // })
763
+ let contents = (_jsx(LayoutMeasurementController, { disable: !open, children: _jsx(ParentSheetContext.Provider, { value: nextParentContext, children: _jsx(SheetProvider, { ...providerProps, keyboardOccludedHeight: keyboardOccludedHeight, isKeyboardVisible: isKeyboardVisible, keyboardStableFrameHeight: keyboardStableFrameHeight, setHasScrollView: setHasScrollView, children: _jsxs(GestureSheetProvider, { isDragging: isDragging, blockPan: blockPan, setBlockPan: setBlockPan, panGesture: panGesture, panGestureRef: panGestureRef, children: [_jsx(AnimatePresence, { custom: { open }, children: shouldHideParentSheet || !open ? null : overlayComponent }), snapPointsMode !== 'percent' && (_jsx(View, { style: {
764
+ opacity: 0,
765
+ position: 'absolute',
766
+ top: 0,
767
+ left: 0,
768
+ right: 0,
769
+ bottom: 0,
770
+ pointerEvents: 'none',
771
+ }, onLayout: handleMaxContentViewLayout })), _jsx(AnimatedView, { ref: ref, onLayout: handleAnimationViewLayout,
772
+ // @ts-ignore for CSS driver this is necessary to attach the transition
773
+ // also motion driver at least though i suspect all drivers?
774
+ transition: isDragging || disableAnimation ? null : transition,
775
+ // @ts-ignore
776
+ disableClassName: true, style: [
777
+ {
778
+ position: 'absolute',
779
+ zIndex,
780
+ width: '100%',
781
+ height: forcedContentHeight,
782
+ minHeight: forcedContentHeight,
783
+ opacity: shouldHideParentSheet
784
+ ? 0
785
+ : disableTransparencyHide
786
+ ? 1
787
+ : opacity,
788
+ ...((shouldHideParentSheet || !open) && {
789
+ pointerEvents: 'none',
790
+ }),
791
+ },
792
+ animatedStyle,
793
+ ], children: gestureHandlerEnabled && panGesture ? (_jsx(GestureDetectorWrapper, { gesture: panGesture, style: { flex: 1 }, children: props.children })) : (_jsx(View, { ...panResponder?.panHandlers, style: { flex: 1, width: '100%', height: '100%' }, children: props.children })) })] }) }) }) }));
794
+ if ("web" === 'native' && needsPortalRepropagation()) {
795
+ // TODO alongside sheet scope="" need to pass scope here
796
+ const adaptContext = useAdaptContext();
797
+ contents = (_jsx(ProvideAdaptContext, { ...adaptContext, children: _jsx(SafeAreaInsetsContext.Provider, { value: safeAreaInsets, children: contents }) }));
798
+ }
799
+ // start mounted so we get an accurate measurement the first time
800
+ const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true;
801
+ if (modal) {
802
+ // a modal sheet is teleported through <Portal> to the root portal host.
803
+ // that host is mounted by GuiProvider, which may sit ABOVE the app's
804
+ // GestureHandlerRootView - so the teleported content lands outside any
805
+ // rngh root and every gesture inside the sheet (the drag pan, pressables
806
+ // on the rngh press path) silently goes dead. re-establish an rngh root
807
+ // around the teleported content so it works regardless of where the app
808
+ // mounts GestureHandlerRootView.
809
+ //
810
+ // the root stays mounted and full-width whenever the sheet content is
811
+ // (so child layout/measurement/close-animation are unaffected) and only
812
+ // collapses to 0 height while closed so it occupies no hit area - see
813
+ // rnghRootStyleOpen/Closed above for why pointerEvents can't be used.
814
+ const RNGHRoot = getGestureHandlerState().RootView;
815
+ const mountedContents = shouldMountChildren ? (_jsx(ContainerComponent, { children: contents })) : null;
816
+ const modalContents = (_jsx(Portal, { stackZIndex: zIndex, ...portalProps, children: mountedContents && RNGHRoot ? (_jsx(RNGHRoot, { style: open ? rnghRootStyleOpen : rnghRootStyleClosed, children: mountedContents })) : (mountedContents) }));
817
+ if (isWeb) {
818
+ return modalContents;
819
+ }
820
+ // on native we don't support multiple modals yet... fix for now is to hide outer one
821
+ return (_jsx(SheetInsideSheetContext.Provider, { value: onInnerSheet, children: modalContents }));
822
+ }
823
+ return contents;
824
+ });
825
+ function getYPositions(mode, point, screenSize, frameSize) {
826
+ if (!screenSize || !frameSize) {
827
+ return 0;
828
+ }
829
+ if (mode === 'mixed') {
830
+ if (typeof point === 'number') {
831
+ return screenSize - Math.min(screenSize, Math.max(0, point));
832
+ }
833
+ if (point === 'fit') {
834
+ return screenSize - Math.min(screenSize, frameSize);
835
+ }
836
+ if (point.endsWith('%')) {
837
+ const pct = Math.min(100, Math.max(0, Number(point.slice(0, -1)))) / 100;
838
+ if (Number.isNaN(pct)) {
839
+ console.warn('Invalid snapPoint percentage string');
840
+ return 0;
841
+ }
842
+ return Math.round(screenSize - pct * screenSize);
843
+ }
844
+ console.warn('Invalid snapPoint unknown value');
845
+ return 0;
846
+ }
847
+ if (mode === 'fit') {
848
+ if (point === 0)
849
+ return screenSize;
850
+ return screenSize - Math.min(screenSize, frameSize);
851
+ }
852
+ if (mode === 'constant' && typeof point === 'number') {
853
+ return screenSize - Math.min(screenSize, Math.max(0, point));
854
+ }
855
+ const pct = Math.min(100, Math.max(0, Number(point))) / 100;
856
+ if (Number.isNaN(pct)) {
857
+ console.warn('Invalid snapPoint percentage');
858
+ return 0;
859
+ }
860
+ return Math.round(screenSize - pct * screenSize);
861
+ }
862
+ //# sourceMappingURL=SheetImplementationCustom.js.map