@tamagui/sheet 2.0.0-rc.9 → 2.0.0

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 (450) hide show
  1. package/.turbo/turbo-build.log +2 -0
  2. package/controller/index.cjs +2 -1
  3. package/controller/index.js +2 -0
  4. package/controller/index.native.cjs +2 -0
  5. package/controller/index.native.js +2 -0
  6. package/dist/cjs/GestureDetectorWrapper.cjs +27 -21
  7. package/dist/cjs/GestureDetectorWrapper.native.js +33 -28
  8. package/dist/cjs/GestureDetectorWrapper.native.js.map +1 -1
  9. package/dist/cjs/GestureSheetContext.cjs +14 -12
  10. package/dist/cjs/GestureSheetContext.native.js +29 -27
  11. package/dist/cjs/GestureSheetContext.native.js.map +1 -1
  12. package/dist/cjs/Sheet.cjs +88 -86
  13. package/dist/cjs/Sheet.native.js +88 -86
  14. package/dist/cjs/Sheet.native.js.map +1 -1
  15. package/dist/cjs/SheetContext.cjs +16 -14
  16. package/dist/cjs/SheetContext.native.js +16 -14
  17. package/dist/cjs/SheetContext.native.js.map +1 -1
  18. package/dist/cjs/SheetController.cjs +40 -32
  19. package/dist/cjs/SheetController.native.js +62 -54
  20. package/dist/cjs/SheetController.native.js.map +1 -1
  21. package/dist/cjs/SheetImplementationCustom.cjs +568 -429
  22. package/dist/cjs/SheetImplementationCustom.native.js +592 -474
  23. package/dist/cjs/SheetImplementationCustom.native.js.map +1 -1
  24. package/dist/cjs/SheetScrollView.cjs +184 -135
  25. package/dist/cjs/SheetScrollView.native.js +202 -163
  26. package/dist/cjs/SheetScrollView.native.js.map +1 -1
  27. package/dist/cjs/constants.cjs +16 -14
  28. package/dist/cjs/constants.native.js +16 -14
  29. package/dist/cjs/constants.native.js.map +1 -1
  30. package/dist/cjs/contexts.cjs +27 -25
  31. package/dist/cjs/contexts.native.js +29 -27
  32. package/dist/cjs/contexts.native.js.map +1 -1
  33. package/dist/cjs/controller.cjs +14 -12
  34. package/dist/cjs/controller.native.js +14 -12
  35. package/dist/cjs/controller.native.js.map +1 -1
  36. package/dist/cjs/createSheet.cjs +159 -160
  37. package/dist/cjs/createSheet.native.js +172 -180
  38. package/dist/cjs/createSheet.native.js.map +1 -1
  39. package/dist/cjs/gestureState.cjs +12 -10
  40. package/dist/cjs/gestureState.native.js +12 -10
  41. package/dist/cjs/gestureState.native.js.map +1 -1
  42. package/dist/cjs/helpers.cjs +17 -13
  43. package/dist/cjs/helpers.native.js +17 -13
  44. package/dist/cjs/helpers.native.js.map +1 -1
  45. package/dist/cjs/index.cjs +7 -5
  46. package/dist/cjs/index.native.js +7 -5
  47. package/dist/cjs/index.native.js.map +1 -1
  48. package/dist/cjs/keyboardAvoidance.cjs +42 -0
  49. package/dist/cjs/keyboardAvoidance.native.js +46 -0
  50. package/dist/cjs/keyboardAvoidance.native.js.map +1 -0
  51. package/dist/cjs/nativeSheet.cjs +65 -55
  52. package/dist/cjs/nativeSheet.native.js +74 -68
  53. package/dist/cjs/nativeSheet.native.js.map +1 -1
  54. package/dist/cjs/setupGestureHandler.cjs +24 -18
  55. package/dist/cjs/setupGestureHandler.native.js +24 -19
  56. package/dist/cjs/setupGestureHandler.native.js.map +1 -1
  57. package/dist/cjs/types.cjs +7 -5
  58. package/dist/cjs/types.native.js +7 -5
  59. package/dist/cjs/types.native.js.map +1 -1
  60. package/dist/cjs/useGestureHandlerPan.cjs +181 -111
  61. package/dist/cjs/useGestureHandlerPan.native.js +183 -115
  62. package/dist/cjs/useGestureHandlerPan.native.js.map +1 -1
  63. package/dist/cjs/useKeyboardControllerSheet.cjs +15 -13
  64. package/dist/cjs/useKeyboardControllerSheet.native.js +100 -82
  65. package/dist/cjs/useKeyboardControllerSheet.native.js.map +1 -1
  66. package/dist/cjs/useSheet.cjs +12 -10
  67. package/dist/cjs/useSheet.native.js +16 -14
  68. package/dist/cjs/useSheet.native.js.map +1 -1
  69. package/dist/cjs/useSheetController.cjs +35 -33
  70. package/dist/cjs/useSheetController.native.js +37 -35
  71. package/dist/cjs/useSheetController.native.js.map +1 -1
  72. package/dist/cjs/useSheetOffscreenSize.cjs +35 -23
  73. package/dist/cjs/useSheetOffscreenSize.native.js +36 -27
  74. package/dist/cjs/useSheetOffscreenSize.native.js.map +1 -1
  75. package/dist/cjs/useSheetOpenState.cjs +28 -25
  76. package/dist/cjs/useSheetOpenState.native.js +39 -37
  77. package/dist/cjs/useSheetOpenState.native.js.map +1 -1
  78. package/dist/cjs/useSheetProviderProps.cjs +129 -81
  79. package/dist/cjs/useSheetProviderProps.native.js +165 -122
  80. package/dist/cjs/useSheetProviderProps.native.js.map +1 -1
  81. package/dist/cjs/useSheetScrollViewGestures.cjs +124 -81
  82. package/dist/cjs/useSheetScrollViewGestures.native.js +128 -79
  83. package/dist/cjs/useSheetScrollViewGestures.native.js.map +1 -1
  84. package/dist/esm/GestureDetectorWrapper.mjs +12 -8
  85. package/dist/esm/GestureDetectorWrapper.mjs.map +1 -1
  86. package/dist/esm/GestureDetectorWrapper.native.js +18 -15
  87. package/dist/esm/GestureDetectorWrapper.native.js.map +1 -1
  88. package/dist/esm/GestureSheetContext.native.js +14 -14
  89. package/dist/esm/GestureSheetContext.native.js.map +1 -1
  90. package/dist/esm/Sheet.mjs +70 -70
  91. package/dist/esm/Sheet.mjs.map +1 -1
  92. package/dist/esm/Sheet.native.js +70 -70
  93. package/dist/esm/Sheet.native.js.map +1 -1
  94. package/dist/esm/SheetContext.mjs +2 -2
  95. package/dist/esm/SheetContext.mjs.map +1 -1
  96. package/dist/esm/SheetContext.native.js +2 -2
  97. package/dist/esm/SheetContext.native.js.map +1 -1
  98. package/dist/esm/SheetController.mjs +12 -6
  99. package/dist/esm/SheetController.mjs.map +1 -1
  100. package/dist/esm/SheetController.native.js +18 -12
  101. package/dist/esm/SheetController.native.js.map +1 -1
  102. package/dist/esm/SheetImplementationCustom.mjs +526 -389
  103. package/dist/esm/SheetImplementationCustom.mjs.map +1 -1
  104. package/dist/esm/SheetImplementationCustom.native.js +546 -434
  105. package/dist/esm/SheetImplementationCustom.native.js.map +1 -1
  106. package/dist/esm/SheetScrollView.mjs +150 -103
  107. package/dist/esm/SheetScrollView.mjs.map +1 -1
  108. package/dist/esm/SheetScrollView.native.js +169 -132
  109. package/dist/esm/SheetScrollView.native.js.map +1 -1
  110. package/dist/esm/constants.mjs +4 -4
  111. package/dist/esm/constants.mjs.map +1 -1
  112. package/dist/esm/constants.native.js +4 -4
  113. package/dist/esm/constants.native.js.map +1 -1
  114. package/dist/esm/contexts.mjs +3 -3
  115. package/dist/esm/contexts.mjs.map +1 -1
  116. package/dist/esm/contexts.native.js +3 -3
  117. package/dist/esm/contexts.native.js.map +1 -1
  118. package/dist/esm/createSheet.mjs +130 -133
  119. package/dist/esm/createSheet.mjs.map +1 -1
  120. package/dist/esm/createSheet.native.js +142 -152
  121. package/dist/esm/createSheet.native.js.map +1 -1
  122. package/dist/esm/helpers.mjs +5 -3
  123. package/dist/esm/helpers.mjs.map +1 -1
  124. package/dist/esm/helpers.native.js +5 -3
  125. package/dist/esm/helpers.native.js.map +1 -1
  126. package/dist/esm/index.js +11 -11
  127. package/dist/esm/index.js.map +1 -6
  128. package/dist/esm/keyboardAvoidance.mjs +17 -0
  129. package/dist/esm/keyboardAvoidance.mjs.map +1 -0
  130. package/dist/esm/keyboardAvoidance.native.js +18 -0
  131. package/dist/esm/keyboardAvoidance.native.js.map +1 -0
  132. package/dist/esm/nativeSheet.mjs +46 -38
  133. package/dist/esm/nativeSheet.mjs.map +1 -1
  134. package/dist/esm/nativeSheet.native.js +52 -48
  135. package/dist/esm/nativeSheet.native.js.map +1 -1
  136. package/dist/esm/setupGestureHandler.mjs +12 -8
  137. package/dist/esm/setupGestureHandler.mjs.map +1 -1
  138. package/dist/esm/setupGestureHandler.native.js +12 -9
  139. package/dist/esm/setupGestureHandler.native.js.map +1 -1
  140. package/dist/esm/useGestureHandlerPan.mjs +167 -99
  141. package/dist/esm/useGestureHandlerPan.mjs.map +1 -1
  142. package/dist/esm/useGestureHandlerPan.native.js +168 -102
  143. package/dist/esm/useGestureHandlerPan.native.js.map +1 -1
  144. package/dist/esm/useKeyboardControllerSheet.mjs +3 -3
  145. package/dist/esm/useKeyboardControllerSheet.mjs.map +1 -1
  146. package/dist/esm/useKeyboardControllerSheet.native.js +85 -69
  147. package/dist/esm/useKeyboardControllerSheet.native.js.map +1 -1
  148. package/dist/esm/useSheetController.mjs +11 -11
  149. package/dist/esm/useSheetController.mjs.map +1 -1
  150. package/dist/esm/useSheetController.native.js +11 -11
  151. package/dist/esm/useSheetController.native.js.map +1 -1
  152. package/dist/esm/useSheetOffscreenSize.mjs +23 -13
  153. package/dist/esm/useSheetOffscreenSize.mjs.map +1 -1
  154. package/dist/esm/useSheetOffscreenSize.native.js +24 -17
  155. package/dist/esm/useSheetOffscreenSize.native.js.map +1 -1
  156. package/dist/esm/useSheetOpenState.mjs +14 -13
  157. package/dist/esm/useSheetOpenState.mjs.map +1 -1
  158. package/dist/esm/useSheetOpenState.native.js +17 -17
  159. package/dist/esm/useSheetOpenState.native.js.map +1 -1
  160. package/dist/esm/useSheetProviderProps.mjs +101 -55
  161. package/dist/esm/useSheetProviderProps.mjs.map +1 -1
  162. package/dist/esm/useSheetProviderProps.native.js +137 -96
  163. package/dist/esm/useSheetProviderProps.native.js.map +1 -1
  164. package/dist/esm/useSheetScrollViewGestures.mjs +112 -71
  165. package/dist/esm/useSheetScrollViewGestures.mjs.map +1 -1
  166. package/dist/esm/useSheetScrollViewGestures.native.js +116 -69
  167. package/dist/esm/useSheetScrollViewGestures.native.js.map +1 -1
  168. package/dist/jsx/GestureDetectorWrapper.mjs +12 -8
  169. package/dist/jsx/GestureDetectorWrapper.mjs.map +1 -1
  170. package/dist/jsx/GestureDetectorWrapper.native.js +33 -28
  171. package/dist/jsx/GestureDetectorWrapper.native.js.map +1 -1
  172. package/dist/jsx/GestureSheetContext.native.js +29 -27
  173. package/dist/jsx/GestureSheetContext.native.js.map +1 -1
  174. package/dist/jsx/Sheet.mjs +70 -70
  175. package/dist/jsx/Sheet.mjs.map +1 -1
  176. package/dist/jsx/Sheet.native.js +88 -86
  177. package/dist/jsx/Sheet.native.js.map +1 -1
  178. package/dist/jsx/SheetContext.mjs +2 -2
  179. package/dist/jsx/SheetContext.mjs.map +1 -1
  180. package/dist/jsx/SheetContext.native.js +16 -14
  181. package/dist/jsx/SheetContext.native.js.map +1 -1
  182. package/dist/jsx/SheetController.mjs +12 -6
  183. package/dist/jsx/SheetController.mjs.map +1 -1
  184. package/dist/jsx/SheetController.native.js +62 -54
  185. package/dist/jsx/SheetController.native.js.map +1 -1
  186. package/dist/jsx/SheetImplementationCustom.mjs +526 -389
  187. package/dist/jsx/SheetImplementationCustom.mjs.map +1 -1
  188. package/dist/jsx/SheetImplementationCustom.native.js +592 -474
  189. package/dist/jsx/SheetImplementationCustom.native.js.map +1 -1
  190. package/dist/jsx/SheetScrollView.mjs +150 -103
  191. package/dist/jsx/SheetScrollView.mjs.map +1 -1
  192. package/dist/jsx/SheetScrollView.native.js +202 -163
  193. package/dist/jsx/SheetScrollView.native.js.map +1 -1
  194. package/dist/jsx/constants.mjs +4 -4
  195. package/dist/jsx/constants.mjs.map +1 -1
  196. package/dist/jsx/constants.native.js +16 -14
  197. package/dist/jsx/constants.native.js.map +1 -1
  198. package/dist/jsx/contexts.mjs +3 -3
  199. package/dist/jsx/contexts.mjs.map +1 -1
  200. package/dist/jsx/contexts.native.js +29 -27
  201. package/dist/jsx/contexts.native.js.map +1 -1
  202. package/dist/jsx/controller.native.js +14 -12
  203. package/dist/jsx/createSheet.mjs +130 -133
  204. package/dist/jsx/createSheet.mjs.map +1 -1
  205. package/dist/jsx/createSheet.native.js +172 -180
  206. package/dist/jsx/createSheet.native.js.map +1 -1
  207. package/dist/jsx/gestureState.native.js +12 -10
  208. package/dist/jsx/gestureState.native.js.map +1 -1
  209. package/dist/jsx/helpers.mjs +5 -3
  210. package/dist/jsx/helpers.mjs.map +1 -1
  211. package/dist/jsx/helpers.native.js +17 -13
  212. package/dist/jsx/helpers.native.js.map +1 -1
  213. package/dist/jsx/index.js +11 -11
  214. package/dist/jsx/index.js.map +1 -6
  215. package/dist/jsx/index.native.js +7 -5
  216. package/dist/jsx/index.native.js.map +1 -1
  217. package/dist/jsx/keyboardAvoidance.mjs +17 -0
  218. package/dist/jsx/keyboardAvoidance.mjs.map +1 -0
  219. package/dist/jsx/keyboardAvoidance.native.js +46 -0
  220. package/dist/jsx/keyboardAvoidance.native.js.map +1 -0
  221. package/dist/jsx/nativeSheet.mjs +46 -38
  222. package/dist/jsx/nativeSheet.mjs.map +1 -1
  223. package/dist/jsx/nativeSheet.native.js +74 -68
  224. package/dist/jsx/nativeSheet.native.js.map +1 -1
  225. package/dist/jsx/setupGestureHandler.mjs +12 -8
  226. package/dist/jsx/setupGestureHandler.mjs.map +1 -1
  227. package/dist/jsx/setupGestureHandler.native.js +24 -19
  228. package/dist/jsx/setupGestureHandler.native.js.map +1 -1
  229. package/dist/jsx/types.native.js +7 -5
  230. package/dist/jsx/useGestureHandlerPan.mjs +167 -99
  231. package/dist/jsx/useGestureHandlerPan.mjs.map +1 -1
  232. package/dist/jsx/useGestureHandlerPan.native.js +183 -115
  233. package/dist/jsx/useGestureHandlerPan.native.js.map +1 -1
  234. package/dist/jsx/useKeyboardControllerSheet.mjs +3 -3
  235. package/dist/jsx/useKeyboardControllerSheet.mjs.map +1 -1
  236. package/dist/jsx/useKeyboardControllerSheet.native.js +100 -82
  237. package/dist/jsx/useKeyboardControllerSheet.native.js.map +1 -1
  238. package/dist/jsx/useSheet.native.js +16 -14
  239. package/dist/jsx/useSheetController.mjs +11 -11
  240. package/dist/jsx/useSheetController.mjs.map +1 -1
  241. package/dist/jsx/useSheetController.native.js +37 -35
  242. package/dist/jsx/useSheetController.native.js.map +1 -1
  243. package/dist/jsx/useSheetOffscreenSize.mjs +23 -13
  244. package/dist/jsx/useSheetOffscreenSize.mjs.map +1 -1
  245. package/dist/jsx/useSheetOffscreenSize.native.js +36 -27
  246. package/dist/jsx/useSheetOffscreenSize.native.js.map +1 -1
  247. package/dist/jsx/useSheetOpenState.mjs +14 -13
  248. package/dist/jsx/useSheetOpenState.mjs.map +1 -1
  249. package/dist/jsx/useSheetOpenState.native.js +39 -37
  250. package/dist/jsx/useSheetOpenState.native.js.map +1 -1
  251. package/dist/jsx/useSheetProviderProps.mjs +101 -55
  252. package/dist/jsx/useSheetProviderProps.mjs.map +1 -1
  253. package/dist/jsx/useSheetProviderProps.native.js +165 -122
  254. package/dist/jsx/useSheetProviderProps.native.js.map +1 -1
  255. package/dist/jsx/useSheetScrollViewGestures.mjs +112 -71
  256. package/dist/jsx/useSheetScrollViewGestures.mjs.map +1 -1
  257. package/dist/jsx/useSheetScrollViewGestures.native.js +128 -79
  258. package/dist/jsx/useSheetScrollViewGestures.native.js.map +1 -1
  259. package/next.md +78 -0
  260. package/package.json +29 -39
  261. package/setup-gesture-handler/index.cjs +2 -0
  262. package/setup-gesture-handler/index.js +2 -0
  263. package/setup-gesture-handler/index.native.cjs +2 -0
  264. package/setup-gesture-handler/index.native.js +2 -0
  265. package/src/GestureDetectorWrapper.tsx +0 -3
  266. package/src/SheetController.tsx +4 -1
  267. package/src/SheetImplementationCustom.tsx +131 -45
  268. package/src/SheetScrollView.tsx +33 -7
  269. package/src/keyboardAvoidance.ts +30 -0
  270. package/src/nativeSheet.tsx +6 -1
  271. package/src/types.tsx +5 -0
  272. package/src/useGestureHandlerPan.tsx +5 -15
  273. package/src/useSheetController.tsx +4 -0
  274. package/src/useSheetProviderProps.tsx +1 -0
  275. package/test/keyboardAvoidance.test.ts +53 -0
  276. package/tsconfig.json +57 -0
  277. package/types/GestureDetectorWrapper.d.ts.map +1 -1
  278. package/types/Sheet.d.ts +3 -0
  279. package/types/Sheet.d.ts.map +1 -1
  280. package/types/SheetContext.d.ts +1 -0
  281. package/types/SheetContext.d.ts.map +1 -1
  282. package/types/SheetController.d.ts +1 -1
  283. package/types/SheetController.d.ts.map +1 -1
  284. package/types/SheetImplementationCustom.d.ts +3 -0
  285. package/types/SheetImplementationCustom.d.ts.map +1 -1
  286. package/types/SheetScrollView.d.ts.map +1 -1
  287. package/types/createSheet.d.ts +3 -0
  288. package/types/createSheet.d.ts.map +1 -1
  289. package/types/keyboardAvoidance.d.ts +8 -0
  290. package/types/keyboardAvoidance.d.ts.map +1 -0
  291. package/types/nativeSheet.d.ts.map +1 -1
  292. package/types/types.d.ts +6 -0
  293. package/types/types.d.ts.map +1 -1
  294. package/types/useGestureHandlerPan.d.ts.map +1 -1
  295. package/types/useSheetController.d.ts +3 -0
  296. package/types/useSheetController.d.ts.map +1 -1
  297. package/types/useSheetProviderProps.d.ts +1 -0
  298. package/types/useSheetProviderProps.d.ts.map +1 -1
  299. package/dist/cjs/GestureDetectorWrapper.js +0 -29
  300. package/dist/cjs/GestureDetectorWrapper.js.map +0 -6
  301. package/dist/cjs/GestureSheetContext.js +0 -43
  302. package/dist/cjs/GestureSheetContext.js.map +0 -6
  303. package/dist/cjs/Sheet.js +0 -104
  304. package/dist/cjs/Sheet.js.map +0 -6
  305. package/dist/cjs/SheetContext.js +0 -28
  306. package/dist/cjs/SheetContext.js.map +0 -6
  307. package/dist/cjs/SheetController.js +0 -52
  308. package/dist/cjs/SheetController.js.map +0 -6
  309. package/dist/cjs/SheetImplementationCustom.js +0 -393
  310. package/dist/cjs/SheetImplementationCustom.js.map +0 -6
  311. package/dist/cjs/SheetScrollView.js +0 -137
  312. package/dist/cjs/SheetScrollView.js.map +0 -6
  313. package/dist/cjs/constants.js +0 -24
  314. package/dist/cjs/constants.js.map +0 -6
  315. package/dist/cjs/contexts.js +0 -33
  316. package/dist/cjs/contexts.js.map +0 -6
  317. package/dist/cjs/controller.js +0 -23
  318. package/dist/cjs/controller.js.map +0 -6
  319. package/dist/cjs/createSheet.js +0 -152
  320. package/dist/cjs/createSheet.js.map +0 -6
  321. package/dist/cjs/gestureState.js +0 -34
  322. package/dist/cjs/gestureState.js.map +0 -6
  323. package/dist/cjs/helpers.js +0 -26
  324. package/dist/cjs/helpers.js.map +0 -6
  325. package/dist/cjs/index.js +0 -25
  326. package/dist/cjs/index.js.map +0 -6
  327. package/dist/cjs/nativeSheet.js +0 -56
  328. package/dist/cjs/nativeSheet.js.map +0 -6
  329. package/dist/cjs/setupGestureHandler.js +0 -38
  330. package/dist/cjs/setupGestureHandler.js.map +0 -6
  331. package/dist/cjs/types.js +0 -14
  332. package/dist/cjs/types.js.map +0 -6
  333. package/dist/cjs/useGestureHandlerPan.js +0 -126
  334. package/dist/cjs/useGestureHandlerPan.js.map +0 -6
  335. package/dist/cjs/useKeyboardControllerSheet.js +0 -34
  336. package/dist/cjs/useKeyboardControllerSheet.js.map +0 -6
  337. package/dist/cjs/useSheet.js +0 -22
  338. package/dist/cjs/useSheet.js.map +0 -6
  339. package/dist/cjs/useSheetController.js +0 -39
  340. package/dist/cjs/useSheetController.js.map +0 -6
  341. package/dist/cjs/useSheetOffscreenSize.js +0 -43
  342. package/dist/cjs/useSheetOffscreenSize.js.map +0 -6
  343. package/dist/cjs/useSheetOpenState.js +0 -37
  344. package/dist/cjs/useSheetOpenState.js.map +0 -6
  345. package/dist/cjs/useSheetProviderProps.js +0 -130
  346. package/dist/cjs/useSheetProviderProps.js.map +0 -6
  347. package/dist/cjs/useSheetScrollViewGestures.js +0 -102
  348. package/dist/cjs/useSheetScrollViewGestures.js.map +0 -6
  349. package/dist/esm/GestureDetectorWrapper.js +0 -15
  350. package/dist/esm/GestureDetectorWrapper.js.map +0 -6
  351. package/dist/esm/GestureSheetContext.js +0 -28
  352. package/dist/esm/GestureSheetContext.js.map +0 -6
  353. package/dist/esm/Sheet.js +0 -92
  354. package/dist/esm/Sheet.js.map +0 -6
  355. package/dist/esm/SheetContext.js +0 -13
  356. package/dist/esm/SheetContext.js.map +0 -6
  357. package/dist/esm/SheetController.js +0 -31
  358. package/dist/esm/SheetController.js.map +0 -6
  359. package/dist/esm/SheetImplementationCustom.js +0 -395
  360. package/dist/esm/SheetImplementationCustom.js.map +0 -6
  361. package/dist/esm/SheetScrollView.js +0 -122
  362. package/dist/esm/SheetScrollView.js.map +0 -6
  363. package/dist/esm/constants.js +0 -8
  364. package/dist/esm/constants.js.map +0 -6
  365. package/dist/esm/contexts.js +0 -9
  366. package/dist/esm/contexts.js.map +0 -6
  367. package/dist/esm/controller.js +0 -11
  368. package/dist/esm/controller.js.map +0 -6
  369. package/dist/esm/createSheet.js +0 -153
  370. package/dist/esm/createSheet.js.map +0 -6
  371. package/dist/esm/gestureState.js +0 -18
  372. package/dist/esm/gestureState.js.map +0 -6
  373. package/dist/esm/helpers.js +0 -10
  374. package/dist/esm/helpers.js.map +0 -6
  375. package/dist/esm/nativeSheet.js +0 -46
  376. package/dist/esm/nativeSheet.js.map +0 -6
  377. package/dist/esm/setupGestureHandler.js +0 -22
  378. package/dist/esm/setupGestureHandler.js.map +0 -6
  379. package/dist/esm/types.js +0 -1
  380. package/dist/esm/types.js.map +0 -6
  381. package/dist/esm/useGestureHandlerPan.js +0 -111
  382. package/dist/esm/useGestureHandlerPan.js.map +0 -6
  383. package/dist/esm/useKeyboardControllerSheet.js +0 -18
  384. package/dist/esm/useKeyboardControllerSheet.js.map +0 -6
  385. package/dist/esm/useSheet.js +0 -6
  386. package/dist/esm/useSheet.js.map +0 -6
  387. package/dist/esm/useSheetController.js +0 -15
  388. package/dist/esm/useSheetController.js.map +0 -6
  389. package/dist/esm/useSheetOffscreenSize.js +0 -27
  390. package/dist/esm/useSheetOffscreenSize.js.map +0 -6
  391. package/dist/esm/useSheetOpenState.js +0 -22
  392. package/dist/esm/useSheetOpenState.js.map +0 -6
  393. package/dist/esm/useSheetProviderProps.js +0 -109
  394. package/dist/esm/useSheetProviderProps.js.map +0 -6
  395. package/dist/esm/useSheetScrollViewGestures.js +0 -86
  396. package/dist/esm/useSheetScrollViewGestures.js.map +0 -6
  397. package/dist/jsx/GestureDetectorWrapper.js +0 -15
  398. package/dist/jsx/GestureDetectorWrapper.js.map +0 -6
  399. package/dist/jsx/GestureSheetContext.js +0 -28
  400. package/dist/jsx/GestureSheetContext.js.map +0 -6
  401. package/dist/jsx/Sheet.js +0 -92
  402. package/dist/jsx/Sheet.js.map +0 -6
  403. package/dist/jsx/SheetContext.js +0 -13
  404. package/dist/jsx/SheetContext.js.map +0 -6
  405. package/dist/jsx/SheetController.js +0 -31
  406. package/dist/jsx/SheetController.js.map +0 -6
  407. package/dist/jsx/SheetImplementationCustom.js +0 -395
  408. package/dist/jsx/SheetImplementationCustom.js.map +0 -6
  409. package/dist/jsx/SheetScrollView.js +0 -122
  410. package/dist/jsx/SheetScrollView.js.map +0 -6
  411. package/dist/jsx/constants.js +0 -8
  412. package/dist/jsx/constants.js.map +0 -6
  413. package/dist/jsx/contexts.js +0 -9
  414. package/dist/jsx/contexts.js.map +0 -6
  415. package/dist/jsx/controller.js +0 -11
  416. package/dist/jsx/controller.js.map +0 -6
  417. package/dist/jsx/createSheet.js +0 -153
  418. package/dist/jsx/createSheet.js.map +0 -6
  419. package/dist/jsx/gestureState.js +0 -18
  420. package/dist/jsx/gestureState.js.map +0 -6
  421. package/dist/jsx/helpers.js +0 -10
  422. package/dist/jsx/helpers.js.map +0 -6
  423. package/dist/jsx/nativeSheet.js +0 -46
  424. package/dist/jsx/nativeSheet.js.map +0 -6
  425. package/dist/jsx/setupGestureHandler.js +0 -22
  426. package/dist/jsx/setupGestureHandler.js.map +0 -6
  427. package/dist/jsx/types.js +0 -1
  428. package/dist/jsx/types.js.map +0 -6
  429. package/dist/jsx/useGestureHandlerPan.js +0 -111
  430. package/dist/jsx/useGestureHandlerPan.js.map +0 -6
  431. package/dist/jsx/useKeyboardControllerSheet.js +0 -18
  432. package/dist/jsx/useKeyboardControllerSheet.js.map +0 -6
  433. package/dist/jsx/useSheet.js +0 -6
  434. package/dist/jsx/useSheet.js.map +0 -6
  435. package/dist/jsx/useSheetController.js +0 -15
  436. package/dist/jsx/useSheetController.js.map +0 -6
  437. package/dist/jsx/useSheetOffscreenSize.js +0 -27
  438. package/dist/jsx/useSheetOffscreenSize.js.map +0 -6
  439. package/dist/jsx/useSheetOpenState.js +0 -22
  440. package/dist/jsx/useSheetOpenState.js.map +0 -6
  441. package/dist/jsx/useSheetProviderProps.js +0 -109
  442. package/dist/jsx/useSheetProviderProps.js.map +0 -6
  443. package/dist/jsx/useSheetScrollViewGestures.js +0 -86
  444. package/dist/jsx/useSheetScrollViewGestures.js.map +0 -6
  445. package/types/GestureDetectorWrapper.native.d.ts +0 -14
  446. package/types/gestureState.native.d.ts +0 -12
  447. package/types/setupGestureHandler.native.d.ts +0 -41
  448. package/types/useGestureHandlerPan.native.d.ts +0 -33
  449. package/types/useSheetScrollViewGestures.web.d.ts +0 -15
  450. package/types/useSheetScrollViewGestures.web.d.ts.map +0 -1
@@ -5,7 +5,6 @@ import { isWeb, useIsomorphicLayoutEffect } from '@tamagui/constants'
5
5
  import {
6
6
  LayoutMeasurementController,
7
7
  View as TamaguiView,
8
- Theme,
9
8
  useConfiguration,
10
9
  useDidFinishSSR,
11
10
  useEvent,
@@ -23,8 +22,10 @@ import type {
23
22
  import { Dimensions, PanResponder, View } from 'react-native'
24
23
  import { ParentSheetContext, SheetInsideSheetContext } from './contexts'
25
24
  import { GestureDetectorWrapper } from './GestureDetectorWrapper'
25
+ import { getGestureHandlerState } from './gestureState'
26
26
  import { GestureSheetProvider } from './GestureSheetContext'
27
27
  import { resisted } from './helpers'
28
+ import { getKeyboardOccludedHeight } from './keyboardAvoidance'
28
29
  import { SheetProvider } from './SheetContext'
29
30
  import type { SheetProps, SnapPointsMode } from './types'
30
31
  import { useGestureHandlerPan } from './useGestureHandlerPan'
@@ -34,6 +35,14 @@ import { useSheetProviderProps } from './useSheetProviderProps'
34
35
 
35
36
  const hiddenSize = 10_000.1
36
37
 
38
+ // the re-established rngh root for a modal sheet (see modal branch below).
39
+ // GestureHandlerRootView does its own native touch interception and ignores
40
+ // pointerEvents, so it would block the whole app while the sheet sits closed
41
+ // but mounted. instead it stays full-width for correct child layout/measurement
42
+ // and collapses to 0 height when closed so it has no hit area.
43
+ const rnghRootStyleOpen = { width: '100%', height: '100%' } as const
44
+ const rnghRootStyleClosed = { width: '100%', height: 0 } as const
45
+
37
46
  // safe area top inset, cached per-session (device-constant value)
38
47
  let _cachedSafeAreaTop: number | undefined
39
48
  function getSafeAreaTopInset(): number {
@@ -61,6 +70,7 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
61
70
  unmountChildrenWhenHidden = false,
62
71
  portalProps,
63
72
  containerComponent: ContainerComponent = React.Fragment,
73
+ onAnimationComplete,
64
74
  } = props
65
75
 
66
76
  const state = useSheetOpenState(props)
@@ -83,6 +93,8 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
83
93
  maxSnapPoint,
84
94
  } = providerProps
85
95
  const { open, controller, isHidden } = state
96
+ const openRef = React.useRef(open)
97
+ openRef.current = open
86
98
 
87
99
  const sheetRef = React.useRef<View>(undefined as unknown as View)
88
100
  const ref = useComposedRefs(forwardedRef, sheetRef, providerProps.contentRef as any)
@@ -220,6 +232,14 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
220
232
  return result
221
233
  }, [positions, isKeyboardVisible, keyboardHeight, screenSize, isDragging])
222
234
 
235
+ const keyboardOccludedHeight = getKeyboardOccludedHeight({
236
+ frameSize,
237
+ isKeyboardVisible: !isWeb && isKeyboardVisible,
238
+ keyboardHeight,
239
+ screenSize,
240
+ sheetY: position >= 0 ? activePositions[position] : undefined,
241
+ })
242
+
223
243
  const { useAnimatedNumber, useAnimatedNumberStyle, useAnimatedNumberReaction } =
224
244
  animationDriver
225
245
  const AnimatedView = (animationDriver.View ?? TamaguiView) as typeof Animated.View
@@ -254,6 +274,9 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
254
274
 
255
275
  const hasScrollView = React.useRef(false)
256
276
 
277
+ // safety fallback timer for sheet close opacity
278
+ const opacityFallbackTimer = React.useRef<ReturnType<typeof setTimeout> | null>(null)
279
+
257
280
  useAnimatedNumberReaction(
258
281
  {
259
282
  value: animatedNumber,
@@ -273,6 +296,12 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
273
296
  // when reaching top, enable scroll; when leaving top, disable scroll
274
297
  // this preemptively sets scroll state before any gestures start
275
298
  if (nowAtTop) {
299
+ // if scroll drifted during drag (e.g. fast swipe from position 1),
300
+ // reset it to 0 before enabling free scroll
301
+ if (scrollBridge.y > 0) {
302
+ scrollBridge.forceScrollTo?.(0)
303
+ scrollBridge.y = 0
304
+ }
276
305
  scrollBridge.scrollLockY = undefined
277
306
  scrollBridge.setScrollEnabled?.(true)
278
307
  } else {
@@ -303,10 +332,50 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
303
332
  at.current = toValue
304
333
  stopSpring()
305
334
 
335
+ const isOpenAnimation = position !== -1 && !isHidden
336
+
337
+ // clear any pending fallback timer
338
+ if (opacityFallbackTimer.current) {
339
+ clearTimeout(opacityFallbackTimer.current)
340
+ opacityFallbackTimer.current = null
341
+ }
342
+
343
+ const animationCompleteCallback = () => {
344
+ if (opacityFallbackTimer.current) {
345
+ clearTimeout(opacityFallbackTimer.current)
346
+ opacityFallbackTimer.current = null
347
+ }
348
+ // use openRef (live) not open (stale closure) — if the sheet
349
+ // was reopened before this callback fires (e.g. cancelled close
350
+ // animation), we must not hide it
351
+ if (!isOpenAnimation && !openRef.current) {
352
+ setOpacity(0)
353
+ }
354
+ onAnimationComplete?.({ open: isOpenAnimation })
355
+ // also notify the SheetController so a parent (e.g. Dialog adapt)
356
+ // can hold the sheet's children mounted until the slide-out is done
357
+ controller?.onAnimationComplete?.({ open: isOpenAnimation })
358
+ }
359
+
360
+ // safety fallback: if animation callback never fires, still hide the sheet
361
+ if (!isOpenAnimation) {
362
+ opacityFallbackTimer.current = setTimeout(() => {
363
+ opacityFallbackTimer.current = null
364
+ // check live open state via ref — sheet may have reopened (e.g. adapt handoff)
365
+ if (!openRef.current) {
366
+ setOpacity(0)
367
+ }
368
+ }, 1000)
369
+ }
370
+
306
371
  // skip animation when adapting from dialog to sheet
307
372
  if (skipAdaptAnimation.current) {
308
373
  skipAdaptAnimation.current = false
309
- animatedNumber.setValue(toValue, { type: 'timing', duration: 0 })
374
+ animatedNumber.setValue(
375
+ toValue,
376
+ { type: 'timing', duration: 0 },
377
+ animationCompleteCallback
378
+ )
310
379
  return
311
380
  }
312
381
 
@@ -315,7 +384,8 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
315
384
  animationOverride || {
316
385
  type: 'spring',
317
386
  ...transitionConfig,
318
- }
387
+ },
388
+ animationCompleteCallback
319
389
  )
320
390
  })
321
391
 
@@ -601,24 +671,21 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
601
671
  pauseKeyboardHandler,
602
672
  })
603
673
 
604
- const handleAnimationViewLayout = React.useCallback(
605
- (e: LayoutChangeEvent) => {
606
- // FIX: Don't update frameSize during exit animation to prevent position jumps
607
- if (!open && stableFrameSize.current !== 0) {
608
- return
609
- }
674
+ const handleAnimationViewLayout = useEvent((e: LayoutChangeEvent) => {
675
+ // don't update frameSize during exit animation to prevent position jumps
676
+ if (!open && stableFrameSize.current !== 0) {
677
+ return
678
+ }
610
679
 
611
- // avoid bugs where it grows forever for whatever reason
612
- // For inline mode (non-modal), don't cap at window height - use actual layout
613
- const layoutHeight = e.nativeEvent?.layout.height
614
- const next = modal
615
- ? Math.min(layoutHeight, Dimensions.get(relativeDimensionTo).height)
616
- : layoutHeight
617
- if (!next) return
618
- setFrameSize(next)
619
- },
620
- [open, modal]
621
- )
680
+ // avoid bugs where it grows forever for whatever reason
681
+ // For inline mode (non-modal), don't cap at window height - use actual layout
682
+ const layoutHeight = e.nativeEvent?.layout.height
683
+ const next = modal
684
+ ? Math.min(layoutHeight, Dimensions.get(relativeDimensionTo).height)
685
+ : layoutHeight
686
+ if (!next) return
687
+ setFrameSize(next)
688
+ })
622
689
 
623
690
  const handleMaxContentViewLayout = React.useCallback((e: LayoutChangeEvent) => {
624
691
  // avoid bugs where it grows forever for whatever reason
@@ -630,32 +697,31 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
630
697
  setMaxContentSize(next)
631
698
  }, [])
632
699
 
633
- const animatedStyle = useAnimatedNumberStyle(animatedNumber, (val) => {
634
- 'worklet'
635
- const translateY = frameSize === 0 ? hiddenSize : val
700
+ const getAnimatedNumberStyle = React.useCallback(
701
+ (val: number) => {
702
+ 'worklet'
703
+ const translateY = frameSize === 0 ? hiddenSize : val
636
704
 
637
- return {
638
- transform: [{ translateY }],
639
- }
640
- })
705
+ return {
706
+ transform: [{ translateY }],
707
+ }
708
+ },
709
+ [frameSize]
710
+ )
711
+
712
+ const animatedStyle = useAnimatedNumberStyle(animatedNumber, getAnimatedNumberStyle)
641
713
 
642
714
  // we need to set this *after* fully closed to 0, to avoid it overlapping
643
715
  // the page when resizing quickly on web for example
644
716
  const [opacity, setOpacity] = React.useState(open ? 1 : 0)
645
717
  if (open && opacity === 0) {
646
718
  setOpacity(1)
647
- }
648
- React.useEffect(() => {
649
- if (!open) {
650
- // need to wait for animation complete, for now lets just do it naively
651
- const tm = setTimeout(() => {
652
- setOpacity(0)
653
- }, 400)
654
- return () => {
655
- clearTimeout(tm)
656
- }
719
+ // cancel any pending close fallback — sheet is reopening
720
+ if (opacityFallbackTimer.current) {
721
+ clearTimeout(opacityFallbackTimer.current)
722
+ opacityFallbackTimer.current = null
657
723
  }
658
- }, [open])
724
+ }
659
725
 
660
726
  const forcedContentHeight = hasFit
661
727
  ? undefined
@@ -676,7 +742,11 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
676
742
  let contents = (
677
743
  <LayoutMeasurementController disable={!open}>
678
744
  <ParentSheetContext.Provider value={nextParentContext}>
679
- <SheetProvider {...providerProps} setHasScrollView={setHasScrollView}>
745
+ <SheetProvider
746
+ {...providerProps}
747
+ keyboardOccludedHeight={keyboardOccludedHeight}
748
+ setHasScrollView={setHasScrollView}
749
+ >
680
750
  <GestureSheetProvider
681
751
  isDragging={isDragging}
682
752
  blockPan={blockPan}
@@ -761,14 +831,30 @@ export const SheetImplementationCustom = React.forwardRef<View, SheetProps>(
761
831
  const shouldMountChildren = unmountChildrenWhenHidden ? !!opacity : true
762
832
 
763
833
  if (modal) {
834
+ // a modal sheet is teleported through <Portal> to the root portal host.
835
+ // that host is mounted by TamaguiProvider, which may sit ABOVE the app's
836
+ // GestureHandlerRootView - so the teleported content lands outside any
837
+ // rngh root and every gesture inside the sheet (the drag pan, pressables
838
+ // on the rngh press path) silently goes dead. re-establish an rngh root
839
+ // around the teleported content so it works regardless of where the app
840
+ // mounts GestureHandlerRootView.
841
+ //
842
+ // the root stays mounted and full-width whenever the sheet content is
843
+ // (so child layout/measurement/close-animation are unaffected) and only
844
+ // collapses to 0 height while closed so it occupies no hit area - see
845
+ // rnghRootStyleOpen/Closed above for why pointerEvents can't be used.
846
+ const RNGHRoot = getGestureHandlerState().RootView
847
+ const mountedContents = shouldMountChildren ? (
848
+ <ContainerComponent>{contents}</ContainerComponent>
849
+ ) : null
764
850
  const modalContents = (
765
851
  <Portal stackZIndex={zIndex} {...portalProps}>
766
- {shouldMountChildren && (
767
- <ContainerComponent>
768
- <Theme contain forceClassName name={themeName}>
769
- {contents}
770
- </Theme>
771
- </ContainerComponent>
852
+ {mountedContents && RNGHRoot ? (
853
+ <RNGHRoot style={open ? rnghRootStyleOpen : rnghRootStyleClosed}>
854
+ {mountedContents}
855
+ </RNGHRoot>
856
+ ) : (
857
+ mountedContents
772
858
  )}
773
859
  </Portal>
774
860
  )
@@ -29,13 +29,36 @@ export const SheetScrollView = React.forwardRef<
29
29
  ) => {
30
30
  const context = useSheetContext(SHEET_SCROLL_VIEW_NAME, __scopeSheet)
31
31
  const gestureContext = useGestureSheetContext()
32
- const { scrollBridge, setHasScrollView } = context
32
+ const { scrollBridge, setHasScrollView, hasFit, screenSize } = context
33
+ const keyboardOccludedHeight = Math.max(0, context.keyboardOccludedHeight || 0)
33
34
  const [scrollEnabled] = useControllableState({
34
35
  prop: scrollEnabledProp,
35
36
  defaultProp: true,
36
37
  })
37
38
  const scrollRef = React.useRef<RNScrollView | null>(null)
38
39
 
40
+ const [hasScrollableContent, setHasScrollableContent] = useState(true)
41
+ const parentHeight = useRef(0)
42
+ const contentHeight = useRef(0)
43
+
44
+ // with snapPointsMode="fit", Frame is content-sized (flex: 0, flex-basis: auto, height: undefined).
45
+ // a flex: 1 child can't grow inside a content-sized parent, so the ScrollView (and the Frame
46
+ // around it) collapse to 0 height. instead, let the ScrollView size to its content and cap it
47
+ // at the available viewport (screenSize / maxContentSize) so scrolling kicks in for tall content.
48
+ // when the keyboard forces the sheet against the top safe area, preserve the measured viewport
49
+ // height while adding scrollable tail padding so content can move above the keyboard.
50
+ const keyboardFrozenHeight =
51
+ hasFit && keyboardOccludedHeight > 0 && parentHeight.current
52
+ ? parentHeight.current
53
+ : undefined
54
+ const fitSizingStyle = hasFit
55
+ ? {
56
+ flex: undefined as undefined,
57
+ height: keyboardFrozenHeight,
58
+ maxHeight: screenSize || undefined,
59
+ }
60
+ : { flex: 1 }
61
+
39
62
  const panGestureRef = gestureContext?.panGestureRef
40
63
  const { ScrollView: RNGHScrollView } = getGestureHandlerState()
41
64
  const useRNGHScrollView = isGestureHandlerEnabled() && RNGHScrollView && panGestureRef
@@ -73,10 +96,6 @@ export const SheetScrollView = React.forwardRef<
73
96
  }
74
97
  }, [])
75
98
 
76
- const [hasScrollableContent, setHasScrollableContent] = useState(true)
77
- const parentHeight = useRef(0)
78
- const contentHeight = useRef(0)
79
-
80
99
  const updateScrollable = () => {
81
100
  if (parentHeight.current && contentHeight.current) {
82
101
  setHasScrollableContent(contentHeight.current > parentHeight.current)
@@ -108,6 +127,13 @@ export const SheetScrollView = React.forwardRef<
108
127
  }}
109
128
  >
110
129
  {children}
130
+ {keyboardOccludedHeight > 0 && (
131
+ <View
132
+ data-sheet-keyboard-scroll-pad
133
+ height={keyboardOccludedHeight}
134
+ width="100%"
135
+ />
136
+ )}
111
137
  </View>
112
138
  )
113
139
 
@@ -117,7 +143,7 @@ export const SheetScrollView = React.forwardRef<
117
143
  return (
118
144
  <RNGHComponent
119
145
  ref={composeRefs(scrollRef as any, ref)}
120
- style={{ flex: 1 }}
146
+ style={fitSizingStyle}
121
147
  scrollEventThrottle={1}
122
148
  scrollEnabled={scrollEnabled}
123
149
  simultaneousHandlers={[panGestureRef]}
@@ -174,7 +200,7 @@ export const SheetScrollView = React.forwardRef<
174
200
  updateScrollable()
175
201
  }}
176
202
  ref={composeRefs(scrollRef as any, ref)}
177
- flex={1}
203
+ {...fitSizingStyle}
178
204
  scrollEventThrottle={1}
179
205
  className="_ovs-contain"
180
206
  scrollEnabled={scrollEnabled}
@@ -0,0 +1,30 @@
1
+ export function getKeyboardOccludedHeight({
2
+ frameSize,
3
+ isKeyboardVisible,
4
+ keyboardHeight,
5
+ screenSize,
6
+ sheetY,
7
+ }: {
8
+ frameSize: number
9
+ isKeyboardVisible: boolean
10
+ keyboardHeight: number
11
+ screenSize: number
12
+ sheetY: number | undefined
13
+ }) {
14
+ if (
15
+ !isKeyboardVisible ||
16
+ keyboardHeight <= 0 ||
17
+ screenSize <= 0 ||
18
+ frameSize <= 0 ||
19
+ sheetY === undefined ||
20
+ sheetY >= screenSize
21
+ ) {
22
+ return 0
23
+ }
24
+
25
+ const keyboardTop = screenSize - keyboardHeight
26
+ const sheetBottom = sheetY + frameSize
27
+ const occludedHeight = Math.ceil(sheetBottom - keyboardTop)
28
+
29
+ return Math.min(frameSize, Math.max(0, occludedHeight))
30
+ }
@@ -59,7 +59,12 @@ export function setupNativeSheet(
59
59
 
60
60
  return (
61
61
  <>
62
- <SheetProvider setHasScrollView={emptyFn} {...providerProps} onlyShowFrame>
62
+ <SheetProvider
63
+ setHasScrollView={emptyFn}
64
+ keyboardOccludedHeight={0}
65
+ {...providerProps}
66
+ onlyShowFrame
67
+ >
63
68
  <ModalSheetView ref={ref} onModalDidDismiss={() => setOpenInternal(false)}>
64
69
  <ModalSheetViewMainContent>
65
70
  <View style={{ flex: 1 }}>{props.children}</View>
package/src/types.tsx CHANGED
@@ -79,6 +79,11 @@ export type SheetProps = ScopedProps<
79
79
  */
80
80
  moveOnKeyboardChange?: boolean
81
81
  containerComponent?: React.ComponentType<any>
82
+
83
+ /**
84
+ * Called when the sheet open/close animation completes.
85
+ */
86
+ onAnimationComplete?: (info: { open: boolean }) => void
82
87
  },
83
88
  'Sheet'
84
89
  >
@@ -122,7 +122,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
122
122
 
123
123
  // simultaneousHandlers pattern from react-native-actions-sheet
124
124
  // both gestures run simultaneously, we use blockPan to decide who handles
125
- // console.warn('[RNGH-Pan] CREATING gesture, minY:', minY, 'frameSize:', frameSize)
126
125
  const gesture = Gesture.Pan()
127
126
  .withRef(panGestureRef)
128
127
  // NO manualActivation - let both gestures run via simultaneousHandlers
@@ -148,7 +147,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
148
147
  const pos = getCurrentPosition()
149
148
  const atTop = pos <= minY + AT_TOP_THRESHOLD
150
149
  const currentScrollY = scrollBridge.y
151
- // console.warn('[RNGH-Pan] onBegin', { pos, minY, atTop, currentScrollY })
152
150
  gs.startY = pos
153
151
  gs.lastPanTranslationY = 0
154
152
  gs.accumulatedOffset = 0
@@ -171,7 +169,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
171
169
  gs.panStarted = true
172
170
  setIsDragging(true)
173
171
 
174
- // console.warn('[RNGH-Pan] onStart', { startY: gs.startY, minY })
175
172
  scrollBridge.initialPosition = gs.startY
176
173
  onStart()
177
174
  })
@@ -195,8 +192,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
195
192
  const isCurrentlyAtTop = currentPos <= minY + AT_TOP_THRESHOLD
196
193
  const nodeIsScrolling = scrollY > 0
197
194
 
198
- // console.warn('[RNGH-Pan] onChange', { translationY: translationY.toFixed(1), deltaY: deltaY.toFixed(1), currentPos: currentPos.toFixed(1), minY, isCurrentlyAtTop, isSwipingDown, scrollY, scrollEngaged: gs.scrollEngaged })
199
-
200
195
  // decision matrix (from react-native-actions-sheet pattern)
201
196
  // each frame, decide who handles the movement based on current state
202
197
  //
@@ -229,7 +224,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
229
224
  } else if (gs.scrollEngaged && hasScrollableContent) {
230
225
  // scroll WAS > 0 but now is 0 -> handoff from scroll to pan
231
226
  // pan takes over to drag sheet down
232
- // console.warn('[RNGH-Pan] *** HANDOFF FROM SCROLL TO PAN ***')
233
227
  panHandles = true
234
228
  } else {
235
229
  // scroll never engaged OR content not scrollable, just drag sheet down
@@ -249,13 +243,13 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
249
243
  }
250
244
  }
251
245
 
252
- // console.warn('[RNGH-Pan] decision', { panHandles, isCurrentlyAtTop, isSwipingDown, nodeIsScrolling, scrollEngaged: gs.scrollEngaged, hasScrollableContent, currentPos: currentPos.toFixed(1), minY })
253
-
254
246
  if (panHandles) {
255
247
  // pan handles - disable scroll and move sheet
256
- // when not at top: lock scroll to 0 (sheet is being dragged)
257
- // when at top: lock at current position (handoff from scroll to pan)
258
- const lockTo = isCurrentlyAtTop ? undefined : 0
248
+ // when swiping down at top after scroll was engaged: lock at current scroll position
249
+ // (handoff from scroll to pan — preserve scroll offset)
250
+ // otherwise: always lock scroll to 0 (prevents scroll from firing during sheet drag)
251
+ const lockTo =
252
+ isCurrentlyAtTop && isSwipingDown && gs.scrollEngaged ? undefined : 0
259
253
  scrollBridge.setScrollEnabled?.(false, lockTo)
260
254
 
261
255
  // accumulate the delta for position calculation
@@ -276,8 +270,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
276
270
  const { velocityY } = event
277
271
  const currentPos = gs.startY + gs.accumulatedOffset
278
272
 
279
- // console.warn('[RNGH-Pan] onEnd', { velocityY, currentPos, accumulatedOffset: gs.accumulatedOffset, scrollY: scrollBridge.y })
280
-
281
273
  // clear scroll lock
282
274
  scrollBridge.scrollLockY = undefined
283
275
 
@@ -315,7 +307,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
315
307
  onEnd(closestPoint)
316
308
  })
317
309
  .onFinalize(() => {
318
- // console.warn('[RNGH-Pan] onFinalize', { panStarted: gs.panStarted })
319
310
  // clear scroll lock on finalize too (safety)
320
311
  scrollBridge.scrollLockY = undefined
321
312
  if (gs.panStarted) {
@@ -334,7 +325,6 @@ export function useGestureHandlerPan(config: GesturePanConfig): GesturePanResult
334
325
  // if we have a scroll gesture ref, make pan simultaneous with it
335
326
  // this allows both gestures to run and we decide in onChange who handles it
336
327
  if (scrollGestureRef?.current) {
337
- // console.warn('[RNGH-Pan] adding simultaneousWithExternalGesture for scroll')
338
328
  return gesture.simultaneousWithExternalGesture(scrollGestureRef.current)
339
329
  }
340
330
 
@@ -22,6 +22,10 @@ export type SheetControllerContextValue = {
22
22
  // hide without "closing" to prevent re-animation when shown again
23
23
  hidden?: boolean
24
24
  onOpenChange?: React.Dispatch<React.SetStateAction<boolean>> | ((val: boolean) => void)
25
+ // fired by the sheet after its open/close animation finishes. used by
26
+ // Dialog adapt to know when it's safe to tear down adapted children
27
+ // without cutting off the slide-out mid-animation.
28
+ onAnimationComplete?: (state: { open: boolean }) => void
25
29
  // when true, the sheet should skip its open animation (used for adapt handoff)
26
30
  skipNextAnimation?: boolean
27
31
  }
@@ -8,6 +8,7 @@ import type { ScrollBridge, SheetProps } from './types'
8
8
  import type { SheetOpenState } from './useSheetOpenState'
9
9
 
10
10
  export type SheetContextValue = ReturnType<typeof useSheetProviderProps> & {
11
+ keyboardOccludedHeight: number
11
12
  setHasScrollView: (val: boolean) => void
12
13
  }
13
14
 
@@ -0,0 +1,53 @@
1
+ import { describe, expect, test } from 'vitest'
2
+
3
+ import { getKeyboardOccludedHeight } from '../src/keyboardAvoidance'
4
+
5
+ describe('getKeyboardOccludedHeight', () => {
6
+ const base = {
7
+ frameSize: 700,
8
+ isKeyboardVisible: true,
9
+ keyboardHeight: 300,
10
+ screenSize: 844,
11
+ sheetY: 59,
12
+ }
13
+
14
+ test('returns overflow below the keyboard top after the sheet is clamped', () => {
15
+ expect(getKeyboardOccludedHeight(base)).toBe(215)
16
+ })
17
+
18
+ test('returns zero when the keyboard-adjusted sheet clears the keyboard', () => {
19
+ expect(
20
+ getKeyboardOccludedHeight({
21
+ ...base,
22
+ frameSize: 400,
23
+ sheetY: 144,
24
+ })
25
+ ).toBe(0)
26
+ })
27
+
28
+ test('ignores hidden keyboard and offscreen sheet positions', () => {
29
+ expect(
30
+ getKeyboardOccludedHeight({
31
+ ...base,
32
+ isKeyboardVisible: false,
33
+ })
34
+ ).toBe(0)
35
+ expect(
36
+ getKeyboardOccludedHeight({
37
+ ...base,
38
+ sheetY: base.screenSize,
39
+ })
40
+ ).toBe(0)
41
+ })
42
+
43
+ test('clamps occlusion to the frame height', () => {
44
+ expect(
45
+ getKeyboardOccludedHeight({
46
+ ...base,
47
+ frameSize: 120,
48
+ keyboardHeight: 1000,
49
+ sheetY: 0,
50
+ })
51
+ ).toBe(120)
52
+ })
53
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "composite": true,
5
+ "strict": true
6
+ },
7
+ "references": [
8
+ {
9
+ "path": "../../core/animations-react-native"
10
+ },
11
+ {
12
+ "path": "../../core/compose-refs"
13
+ },
14
+ {
15
+ "path": "../../core/constants"
16
+ },
17
+ {
18
+ "path": "../../core/core"
19
+ },
20
+ {
21
+ "path": "../../core/create-context"
22
+ },
23
+ {
24
+ "path": "../../core/helpers"
25
+ },
26
+ {
27
+ "path": "../../core/use-constant"
28
+ },
29
+ {
30
+ "path": "../../core/use-controllable-state"
31
+ },
32
+ {
33
+ "path": "../../core/use-keyboard-visible"
34
+ },
35
+ {
36
+ "path": "../animate-presence"
37
+ },
38
+ {
39
+ "path": "../portal"
40
+ },
41
+ {
42
+ "path": "../remove-scroll"
43
+ },
44
+ {
45
+ "path": "../scroll-view"
46
+ },
47
+ {
48
+ "path": "../stacks"
49
+ }
50
+ ],
51
+ "exclude": [
52
+ "types",
53
+ "dist",
54
+ "test",
55
+ "**/__tests__"
56
+ ]
57
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"GestureDetectorWrapper.d.ts","sourceRoot":"","sources":["../src/GestureDetectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAGnD,UAAU,2BAA2B;IACnC,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,2BAA2B,2CAsB7B"}
1
+ {"version":3,"file":"GestureDetectorWrapper.d.ts","sourceRoot":"","sources":["../src/GestureDetectorWrapper.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAA;AAGnD,UAAU,2BAA2B;IACnC,OAAO,EAAE,GAAG,CAAA;IACZ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,KAAK,CAAC,EAAE,SAAS,CAAA;CAClB;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,EACrC,OAAO,EACP,QAAQ,EACR,KAAK,GACN,EAAE,2BAA2B,2CAmB7B"}
package/types/Sheet.d.ts CHANGED
@@ -43,6 +43,9 @@ export declare const Sheet: import("react").ForwardRefExoticComponent<{
43
43
  portalProps?: import("@tamagui/portal").PortalProps;
44
44
  moveOnKeyboardChange?: boolean;
45
45
  containerComponent?: React.ComponentType<any>;
46
+ onAnimationComplete?: (info: {
47
+ open: boolean;
48
+ }) => void;
46
49
  } & {
47
50
  __scopeSheet?: import("@tamagui/create-context").Scope<any>;
48
51
  } & import("react").RefAttributes<import("react-native").View>> & {
@@ -1 +1 @@
1
- {"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../src/Sheet.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,cAAc,SAAS,CAAA;AAMvB,eAAO,MAAM,MAAM;;;;;8CAmCjB,CAAA;AAMF,eAAO,MAAM,OAAO;;;;;8CA2BlB,CAAA;AAMF,eAAO,MAAM,KAAK;;;;8CAoBhB,CAAA;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhB,CAAA"}
1
+ {"version":3,"file":"Sheet.d.ts","sourceRoot":"","sources":["../src/Sheet.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AACjD,cAAc,SAAS,CAAA;AAMvB,eAAO,MAAM,MAAM;;;;;8CAmCjB,CAAA;AAMF,eAAO,MAAM,OAAO;;;;;8CA2BlB,CAAA;AAMF,eAAO,MAAM,KAAK;;;;8CAoBhB,CAAA;AAEF,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIhB,CAAA"}
@@ -32,6 +32,7 @@ export declare const SheetProvider: (props: {
32
32
  setPositionImmediate: import("react").Dispatch<import("react").SetStateAction<number>>;
33
33
  onlyShowFrame: boolean;
34
34
  } & {
35
+ keyboardOccludedHeight: number;
35
36
  setHasScrollView: (val: boolean) => void;
36
37
  } & {
37
38
  scope: import("@tamagui/create-context").Scope<SheetContextValue>;