@lodev09/react-native-true-sheet 4.0.0-beta.0 → 4.0.0-beta.10

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 (430) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +62 -30
  3. package/RNTrueSheet.podspec +10 -2
  4. package/android/build.gradle +24 -2
  5. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerView.kt +189 -47
  6. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContainerViewManager.kt +7 -0
  7. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentView.kt +401 -19
  8. package/android/src/main/java/com/lodev09/truesheet/TrueSheetContentViewManager.kt +18 -0
  9. package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterView.kt +145 -21
  10. package/android/src/main/java/com/lodev09/truesheet/TrueSheetFooterViewManager.kt +14 -0
  11. package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderView.kt +38 -0
  12. package/android/src/main/java/com/lodev09/truesheet/TrueSheetHeaderViewManager.kt +28 -0
  13. package/android/src/main/java/com/lodev09/truesheet/TrueSheetModule.kt +84 -24
  14. package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayView.kt +106 -0
  15. package/android/src/main/java/com/lodev09/truesheet/TrueSheetOverlayViewManager.kt +45 -0
  16. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPackage.kt +6 -4
  17. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekView.kt +72 -0
  18. package/android/src/main/java/com/lodev09/truesheet/TrueSheetPeekViewManager.kt +33 -0
  19. package/android/src/main/java/com/lodev09/truesheet/TrueSheetStateUpdater.kt +63 -0
  20. package/android/src/main/java/com/lodev09/truesheet/TrueSheetView.kt +564 -226
  21. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewController.kt +1399 -598
  22. package/android/src/main/java/com/lodev09/truesheet/TrueSheetViewManager.kt +161 -29
  23. package/android/src/main/java/com/lodev09/truesheet/core/RNScreensEventObserver.kt +63 -0
  24. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetBehavior.kt +36 -0
  25. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetBottomSheetView.kt +255 -0
  26. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetCoordinatorLayout.kt +375 -0
  27. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDetentCalculator.kt +299 -0
  28. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetDimView.kt +162 -0
  29. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetGrabberView.kt +180 -0
  30. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetKeyboardObserver.kt +207 -0
  31. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetOverlayRootView.kt +137 -0
  32. package/android/src/main/java/com/lodev09/truesheet/core/TrueSheetStackManager.kt +220 -0
  33. package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetDragEvents.kt +71 -0
  34. package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetFocusEvents.kt +65 -0
  35. package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetLifecycleEvents.kt +127 -0
  36. package/android/src/main/java/com/lodev09/truesheet/events/TrueSheetStateEvents.kt +56 -0
  37. package/android/src/main/java/com/lodev09/truesheet/utils/KeyboardUtils.kt +84 -0
  38. package/android/src/main/java/com/lodev09/truesheet/utils/ScreenUtils.kt +93 -67
  39. package/android/src/main/java/com/lodev09/truesheet/utils/TouchEventDeduper.kt +31 -0
  40. package/android/src/main/java/com/lodev09/truesheet/utils/ViewUtils.kt +42 -0
  41. package/android/src/main/jni/CMakeLists.txt +63 -0
  42. package/android/src/main/jni/TrueSheetSpec.h +20 -0
  43. package/android/src/main/jni/TrueSheetStateUpdater.cpp +96 -0
  44. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewComponentDescriptor.h +16 -0
  45. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.cpp +68 -0
  46. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewShadowNode.h +33 -0
  47. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.cpp +11 -0
  48. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetContentViewState.h +39 -0
  49. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewComponentDescriptor.h +24 -0
  50. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.cpp +63 -0
  51. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewShadowNode.h +28 -0
  52. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.cpp +11 -0
  53. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetFooterViewState.h +41 -0
  54. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.cpp +18 -0
  55. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetInsets.h +16 -0
  56. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetLayoutUtils.h +46 -0
  57. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewComponentDescriptor.h +21 -0
  58. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.cpp +17 -0
  59. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetOverlayViewShadowNode.h +36 -0
  60. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewComponentDescriptor.h +28 -0
  61. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.cpp +30 -0
  62. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewShadowNode.h +45 -0
  63. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.cpp +23 -0
  64. package/common/cpp/react/renderer/components/TrueSheetSpec/TrueSheetViewState.h +52 -0
  65. package/ios/TrueSheetContainerView.h +88 -6
  66. package/ios/TrueSheetContainerView.mm +278 -21
  67. package/ios/TrueSheetContentView.h +54 -1
  68. package/ios/TrueSheetContentView.mm +371 -47
  69. package/ios/TrueSheetFooterView.h +33 -2
  70. package/ios/TrueSheetFooterView.mm +187 -35
  71. package/ios/{events/OnWillDismissEvent.h → TrueSheetHeaderView.h} +10 -7
  72. package/ios/TrueSheetHeaderView.mm +64 -0
  73. package/ios/TrueSheetModule.h +2 -7
  74. package/ios/TrueSheetModule.mm +98 -20
  75. package/ios/TrueSheetOverlayView.h +32 -0
  76. package/ios/TrueSheetOverlayView.mm +161 -0
  77. package/ios/TrueSheetPeekView.h +32 -0
  78. package/ios/TrueSheetPeekView.mm +99 -0
  79. package/ios/TrueSheetView.h +7 -15
  80. package/ios/TrueSheetView.mm +775 -215
  81. package/ios/TrueSheetViewController.h +94 -16
  82. package/ios/TrueSheetViewController.mm +1316 -331
  83. package/ios/core/RNScreensEventObserver.h +46 -0
  84. package/ios/core/RNScreensEventObserver.mm +280 -0
  85. package/ios/core/TrueSheetBlurView.h +27 -0
  86. package/ios/core/TrueSheetBlurView.mm +82 -0
  87. package/ios/core/TrueSheetDetentCalculator.h +107 -0
  88. package/ios/core/TrueSheetDetentCalculator.mm +197 -0
  89. package/ios/core/TrueSheetGrabberView.h +72 -0
  90. package/ios/core/TrueSheetGrabberView.mm +188 -0
  91. package/ios/core/TrueSheetKeyboardObserver.h +39 -0
  92. package/ios/core/TrueSheetKeyboardObserver.mm +112 -0
  93. package/ios/core/TrueSheetOverlayContainerView.h +31 -0
  94. package/ios/core/TrueSheetOverlayContainerView.mm +35 -0
  95. package/ios/events/TrueSheetDragEvents.h +39 -0
  96. package/ios/events/TrueSheetDragEvents.mm +62 -0
  97. package/ios/events/{OnPositionChangeEvent.h → TrueSheetFocusEvents.h} +8 -5
  98. package/ios/events/TrueSheetFocusEvents.mm +49 -0
  99. package/ios/events/TrueSheetLifecycleEvents.h +42 -0
  100. package/ios/events/TrueSheetLifecycleEvents.mm +79 -0
  101. package/ios/events/TrueSheetStateEvents.h +35 -0
  102. package/ios/events/TrueSheetStateEvents.mm +49 -0
  103. package/ios/tvos/TrueSheetStubs.mm +166 -0
  104. package/ios/{events/OnMountEvent.h → utils/BlurUtil.h} +5 -7
  105. package/ios/utils/BlurUtil.mm +69 -0
  106. package/ios/utils/GestureUtil.h +7 -0
  107. package/ios/utils/GestureUtil.mm +12 -0
  108. package/ios/utils/PlatformUtil.h +15 -0
  109. package/ios/utils/UIView+FirstResponder.h +15 -0
  110. package/ios/utils/UIView+FirstResponder.mm +26 -0
  111. package/ios/utils/UIView+ScrollEdgeInteraction.h +26 -0
  112. package/ios/utils/UIView+ScrollEdgeInteraction.mm +84 -0
  113. package/ios/utils/WindowUtil.mm +17 -1
  114. package/lib/module/TrueSheet.js +349 -74
  115. package/lib/module/TrueSheet.js.map +1 -1
  116. package/lib/module/TrueSheet.web.js +1270 -0
  117. package/lib/module/TrueSheet.web.js.map +1 -0
  118. package/lib/module/TrueSheetOverlay.js +30 -0
  119. package/lib/module/TrueSheetOverlay.js.map +1 -0
  120. package/lib/module/TrueSheetOverlay.web.js +35 -0
  121. package/lib/module/TrueSheetOverlay.web.js.map +1 -0
  122. package/lib/module/TrueSheetPeek.js +15 -0
  123. package/lib/module/TrueSheetPeek.js.map +1 -0
  124. package/lib/module/TrueSheetPeek.web.js +55 -0
  125. package/lib/module/TrueSheetPeek.web.js.map +1 -0
  126. package/lib/module/TrueSheetProvider.js +28 -0
  127. package/lib/module/TrueSheetProvider.js.map +1 -0
  128. package/lib/module/TrueSheetProvider.web.js +157 -0
  129. package/lib/module/TrueSheetProvider.web.js.map +1 -0
  130. package/lib/module/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
  131. package/lib/module/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
  132. package/lib/module/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
  133. package/lib/module/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
  134. package/lib/module/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
  135. package/lib/module/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
  136. package/lib/module/fabric/TrueSheetViewNativeComponent.ts +110 -18
  137. package/lib/module/index.js +4 -3
  138. package/lib/module/index.js.map +1 -1
  139. package/lib/module/mocks/index.js +103 -0
  140. package/lib/module/mocks/index.js.map +1 -0
  141. package/lib/module/mocks/navigation.js +95 -0
  142. package/lib/module/mocks/navigation.js.map +1 -0
  143. package/lib/module/mocks/navigationExpoRouter.js +21 -0
  144. package/lib/module/mocks/navigationExpoRouter.js.map +1 -0
  145. package/lib/module/mocks/reanimated.js +91 -0
  146. package/lib/module/mocks/reanimated.js.map +1 -0
  147. package/lib/module/navigation/TrueSheetNavigatorContent.js +73 -0
  148. package/lib/module/navigation/TrueSheetNavigatorContent.js.map +1 -0
  149. package/lib/module/navigation/actions.js +50 -0
  150. package/lib/module/navigation/actions.js.map +1 -0
  151. package/lib/module/navigation/base-types.js +2 -0
  152. package/lib/module/navigation/base-types.js.map +1 -0
  153. package/lib/module/navigation/createTrueSheetRouter.js +157 -0
  154. package/lib/module/navigation/createTrueSheetRouter.js.map +1 -0
  155. package/lib/module/navigation/expo-router/base-types.js +2 -0
  156. package/lib/module/navigation/expo-router/base-types.js.map +1 -0
  157. package/lib/module/navigation/expo-router/index.js +50 -0
  158. package/lib/module/navigation/expo-router/index.js.map +1 -0
  159. package/lib/module/navigation/expo-router/types.js +4 -0
  160. package/lib/module/navigation/expo-router/types.js.map +1 -0
  161. package/lib/module/navigation/index.js +47 -0
  162. package/lib/module/navigation/index.js.map +1 -0
  163. package/lib/module/navigation/navigator.js +10 -0
  164. package/lib/module/navigation/navigator.js.map +1 -0
  165. package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js +56 -0
  166. package/lib/module/navigation/screen/ReanimatedTrueSheetScreen.js.map +1 -0
  167. package/lib/module/navigation/screen/TrueSheetScreen.js +49 -0
  168. package/lib/module/navigation/screen/TrueSheetScreen.js.map +1 -0
  169. package/lib/module/navigation/screen/index.js +5 -0
  170. package/lib/module/navigation/screen/index.js.map +1 -0
  171. package/lib/module/navigation/screen/types.js +4 -0
  172. package/lib/module/navigation/screen/types.js.map +1 -0
  173. package/lib/module/navigation/screen/useSheetScreenState.js +69 -0
  174. package/lib/module/navigation/screen/useSheetScreenState.js.map +1 -0
  175. package/lib/module/navigation/types.js +4 -0
  176. package/lib/module/navigation/types.js.map +1 -0
  177. package/lib/module/navigation/useTrueSheetNavigation.js +24 -0
  178. package/lib/module/navigation/useTrueSheetNavigation.js.map +1 -0
  179. package/lib/module/reanimated/ReanimatedTrueSheet.js +15 -9
  180. package/lib/module/reanimated/ReanimatedTrueSheet.js.map +1 -1
  181. package/lib/module/reanimated/ReanimatedTrueSheet.web.js +81 -0
  182. package/lib/module/reanimated/ReanimatedTrueSheet.web.js.map +1 -0
  183. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js +4 -2
  184. package/lib/module/reanimated/ReanimatedTrueSheetProvider.js.map +1 -1
  185. package/lib/module/reanimated/index.js +2 -2
  186. package/lib/module/reanimated/index.js.map +1 -1
  187. package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js +20 -0
  188. package/lib/module/reanimated/useReanimatedPositionChangeHandler.web.js.map +1 -0
  189. package/lib/module/specs/NativeTrueSheetModule.js.map +1 -1
  190. package/lib/module/web/constants.js +16 -0
  191. package/lib/module/web/constants.js.map +1 -0
  192. package/lib/module/web/dom.js +10 -0
  193. package/lib/module/web/dom.js.map +1 -0
  194. package/lib/module/web/vaul/README.md +9 -0
  195. package/lib/module/web/vaul/browser.js +30 -0
  196. package/lib/module/web/vaul/browser.js.map +1 -0
  197. package/lib/module/web/vaul/constants.js +19 -0
  198. package/lib/module/web/vaul/constants.js.map +1 -0
  199. package/lib/module/web/vaul/context.js +59 -0
  200. package/lib/module/web/vaul/context.js.map +1 -0
  201. package/lib/module/web/vaul/helpers.js +99 -0
  202. package/lib/module/web/vaul/helpers.js.map +1 -0
  203. package/lib/module/web/vaul/index.js +1342 -0
  204. package/lib/module/web/vaul/index.js.map +1 -0
  205. package/lib/module/web/vaul/style.css +287 -0
  206. package/lib/module/web/vaul/style.css.d.js +2 -0
  207. package/lib/module/web/vaul/style.css.d.js.map +1 -0
  208. package/lib/module/web/vaul/types.js +2 -0
  209. package/lib/module/web/vaul/types.js.map +1 -0
  210. package/lib/module/web/vaul/use-composed-refs.js +34 -0
  211. package/lib/module/web/vaul/use-composed-refs.js.map +1 -0
  212. package/lib/module/web/vaul/use-controllable-state.js +54 -0
  213. package/lib/module/web/vaul/use-controllable-state.js.map +1 -0
  214. package/lib/module/web/vaul/use-position-fixed.js +123 -0
  215. package/lib/module/web/vaul/use-position-fixed.js.map +1 -0
  216. package/lib/module/web/vaul/use-prevent-scroll.js +258 -0
  217. package/lib/module/web/vaul/use-prevent-scroll.js.map +1 -0
  218. package/lib/module/web/vaul/use-scale-background.js +57 -0
  219. package/lib/module/web/vaul/use-scale-background.js.map +1 -0
  220. package/lib/module/web/vaul/use-snap-points.js +305 -0
  221. package/lib/module/web/vaul/use-snap-points.js.map +1 -0
  222. package/lib/typescript/src/TrueSheet.d.ts +57 -14
  223. package/lib/typescript/src/TrueSheet.d.ts.map +1 -1
  224. package/lib/typescript/src/TrueSheet.types.d.ts +535 -55
  225. package/lib/typescript/src/TrueSheet.types.d.ts.map +1 -1
  226. package/lib/typescript/src/TrueSheet.web.d.ts +5 -0
  227. package/lib/typescript/src/TrueSheet.web.d.ts.map +1 -0
  228. package/lib/typescript/src/TrueSheetOverlay.d.ts +8 -0
  229. package/lib/typescript/src/TrueSheetOverlay.d.ts.map +1 -0
  230. package/lib/typescript/src/TrueSheetOverlay.web.d.ts +8 -0
  231. package/lib/typescript/src/TrueSheetOverlay.web.d.ts.map +1 -0
  232. package/lib/typescript/src/TrueSheetPeek.d.ts +9 -0
  233. package/lib/typescript/src/TrueSheetPeek.d.ts.map +1 -0
  234. package/lib/typescript/src/TrueSheetPeek.web.d.ts +28 -0
  235. package/lib/typescript/src/TrueSheetPeek.web.d.ts.map +1 -0
  236. package/lib/typescript/src/TrueSheetProvider.d.ts +18 -0
  237. package/lib/typescript/src/TrueSheetProvider.d.ts.map +1 -0
  238. package/lib/typescript/src/TrueSheetProvider.web.d.ts +27 -0
  239. package/lib/typescript/src/TrueSheetProvider.web.d.ts.map +1 -0
  240. package/lib/typescript/src/fabric/TrueSheetContainerViewNativeComponent.d.ts.map +1 -1
  241. package/lib/typescript/src/fabric/TrueSheetContentViewNativeComponent.d.ts.map +1 -1
  242. package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts +2 -0
  243. package/lib/typescript/src/fabric/TrueSheetFooterViewNativeComponent.d.ts.map +1 -1
  244. package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts +6 -0
  245. package/lib/typescript/src/fabric/TrueSheetHeaderViewNativeComponent.d.ts.map +1 -0
  246. package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts +6 -0
  247. package/lib/typescript/src/fabric/TrueSheetOverlayViewNativeComponent.d.ts.map +1 -0
  248. package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts +6 -0
  249. package/lib/typescript/src/fabric/TrueSheetPeekViewNativeComponent.d.ts.map +1 -0
  250. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts +71 -16
  251. package/lib/typescript/src/fabric/TrueSheetViewNativeComponent.d.ts.map +1 -1
  252. package/lib/typescript/src/index.d.ts +3 -2
  253. package/lib/typescript/src/index.d.ts.map +1 -1
  254. package/lib/typescript/src/mocks/index.d.ts +47 -0
  255. package/lib/typescript/src/mocks/index.d.ts.map +1 -0
  256. package/lib/typescript/src/mocks/navigation.d.ts +70 -0
  257. package/lib/typescript/src/mocks/navigation.d.ts.map +1 -0
  258. package/lib/typescript/src/mocks/navigationExpoRouter.d.ts +22 -0
  259. package/lib/typescript/src/mocks/navigationExpoRouter.d.ts.map +1 -0
  260. package/lib/typescript/src/mocks/reanimated.d.ts +48 -0
  261. package/lib/typescript/src/mocks/reanimated.d.ts.map +1 -0
  262. package/lib/typescript/src/navigation/TrueSheetNavigatorContent.d.ts +5 -0
  263. package/lib/typescript/src/navigation/TrueSheetNavigatorContent.d.ts.map +1 -0
  264. package/lib/typescript/src/navigation/actions.d.ts +71 -0
  265. package/lib/typescript/src/navigation/actions.d.ts.map +1 -0
  266. package/lib/typescript/src/navigation/base-types.d.ts +9 -0
  267. package/lib/typescript/src/navigation/base-types.d.ts.map +1 -0
  268. package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts +3 -0
  269. package/lib/typescript/src/navigation/createTrueSheetRouter.d.ts.map +1 -0
  270. package/lib/typescript/src/navigation/expo-router/base-types.d.ts +8 -0
  271. package/lib/typescript/src/navigation/expo-router/base-types.d.ts.map +1 -0
  272. package/lib/typescript/src/navigation/expo-router/index.d.ts +37 -0
  273. package/lib/typescript/src/navigation/expo-router/index.d.ts.map +1 -0
  274. package/lib/typescript/src/navigation/expo-router/types.d.ts +44 -0
  275. package/lib/typescript/src/navigation/expo-router/types.d.ts.map +1 -0
  276. package/lib/typescript/src/navigation/index.d.ts +45 -0
  277. package/lib/typescript/src/navigation/index.d.ts.map +1 -0
  278. package/lib/typescript/src/navigation/navigator.d.ts +7 -0
  279. package/lib/typescript/src/navigation/navigator.d.ts.map +1 -0
  280. package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts +3 -0
  281. package/lib/typescript/src/navigation/screen/ReanimatedTrueSheetScreen.d.ts.map +1 -0
  282. package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts +3 -0
  283. package/lib/typescript/src/navigation/screen/TrueSheetScreen.d.ts.map +1 -0
  284. package/lib/typescript/src/navigation/screen/index.d.ts +4 -0
  285. package/lib/typescript/src/navigation/screen/index.d.ts.map +1 -0
  286. package/lib/typescript/src/navigation/screen/types.d.ts +14 -0
  287. package/lib/typescript/src/navigation/screen/types.d.ts.map +1 -0
  288. package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts +34 -0
  289. package/lib/typescript/src/navigation/screen/useSheetScreenState.d.ts.map +1 -0
  290. package/lib/typescript/src/navigation/types.d.ts +213 -0
  291. package/lib/typescript/src/navigation/types.d.ts.map +1 -0
  292. package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts +23 -0
  293. package/lib/typescript/src/navigation/useTrueSheetNavigation.d.ts.map +1 -0
  294. package/lib/typescript/src/reanimated/ReanimatedTrueSheet.d.ts.map +1 -1
  295. package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts +41 -0
  296. package/lib/typescript/src/reanimated/ReanimatedTrueSheet.web.d.ts.map +1 -0
  297. package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts +8 -2
  298. package/lib/typescript/src/reanimated/ReanimatedTrueSheetProvider.d.ts.map +1 -1
  299. package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts +15 -0
  300. package/lib/typescript/src/reanimated/useReanimatedPositionChangeHandler.web.d.ts.map +1 -0
  301. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts +25 -3
  302. package/lib/typescript/src/specs/NativeTrueSheetModule.d.ts.map +1 -1
  303. package/lib/typescript/src/web/constants.d.ts +14 -0
  304. package/lib/typescript/src/web/constants.d.ts.map +1 -0
  305. package/lib/typescript/src/web/dom.d.ts +7 -0
  306. package/lib/typescript/src/web/dom.d.ts.map +1 -0
  307. package/lib/typescript/src/web/vaul/browser.d.ts +8 -0
  308. package/lib/typescript/src/web/vaul/browser.d.ts.map +1 -0
  309. package/lib/typescript/src/web/vaul/constants.d.ts +14 -0
  310. package/lib/typescript/src/web/vaul/constants.d.ts.map +1 -0
  311. package/lib/typescript/src/web/vaul/context.d.ts +54 -0
  312. package/lib/typescript/src/web/vaul/context.d.ts.map +1 -0
  313. package/lib/typescript/src/web/vaul/helpers.d.ts +17 -0
  314. package/lib/typescript/src/web/vaul/helpers.d.ts.map +1 -0
  315. package/lib/typescript/src/web/vaul/index.d.ts +234 -0
  316. package/lib/typescript/src/web/vaul/index.d.ts.map +1 -0
  317. package/lib/typescript/src/web/vaul/types.d.ts +7 -0
  318. package/lib/typescript/src/web/vaul/types.d.ts.map +1 -0
  319. package/lib/typescript/src/web/vaul/use-composed-refs.d.ts +14 -0
  320. package/lib/typescript/src/web/vaul/use-composed-refs.d.ts.map +1 -0
  321. package/lib/typescript/src/web/vaul/use-controllable-state.d.ts +9 -0
  322. package/lib/typescript/src/web/vaul/use-controllable-state.d.ts.map +1 -0
  323. package/lib/typescript/src/web/vaul/use-position-fixed.d.ts +19 -0
  324. package/lib/typescript/src/web/vaul/use-position-fixed.d.ts.map +1 -0
  325. package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts +18 -0
  326. package/lib/typescript/src/web/vaul/use-prevent-scroll.d.ts.map +1 -0
  327. package/lib/typescript/src/web/vaul/use-scale-background.d.ts +2 -0
  328. package/lib/typescript/src/web/vaul/use-scale-background.d.ts.map +1 -0
  329. package/lib/typescript/src/web/vaul/use-snap-points.d.ts +38 -0
  330. package/lib/typescript/src/web/vaul/use-snap-points.d.ts.map +1 -0
  331. package/package.json +104 -37
  332. package/react-native.config.js +10 -2
  333. package/src/TrueSheet.tsx +424 -70
  334. package/src/TrueSheet.types.ts +602 -72
  335. package/src/TrueSheet.web.tsx +1437 -0
  336. package/src/TrueSheetOverlay.tsx +24 -0
  337. package/src/TrueSheetOverlay.web.tsx +33 -0
  338. package/src/TrueSheetPeek.tsx +11 -0
  339. package/src/TrueSheetPeek.web.tsx +64 -0
  340. package/src/TrueSheetProvider.tsx +33 -0
  341. package/src/TrueSheetProvider.web.tsx +220 -0
  342. package/src/fabric/TrueSheetContainerViewNativeComponent.ts +1 -1
  343. package/src/fabric/TrueSheetContentViewNativeComponent.ts +5 -1
  344. package/src/fabric/TrueSheetFooterViewNativeComponent.ts +10 -2
  345. package/src/fabric/TrueSheetHeaderViewNativeComponent.ts +8 -0
  346. package/src/fabric/TrueSheetOverlayViewNativeComponent.ts +12 -0
  347. package/src/fabric/TrueSheetPeekViewNativeComponent.ts +8 -0
  348. package/src/fabric/TrueSheetViewNativeComponent.ts +110 -18
  349. package/src/index.ts +3 -2
  350. package/src/mocks/index.ts +96 -0
  351. package/src/mocks/navigation.ts +79 -0
  352. package/src/mocks/navigationExpoRouter.ts +41 -0
  353. package/src/mocks/reanimated.ts +100 -0
  354. package/src/navigation/TrueSheetNavigatorContent.tsx +106 -0
  355. package/src/navigation/actions.ts +78 -0
  356. package/src/navigation/base-types.ts +20 -0
  357. package/src/navigation/createTrueSheetRouter.ts +194 -0
  358. package/src/navigation/expo-router/base-types.ts +18 -0
  359. package/src/navigation/expo-router/index.ts +90 -0
  360. package/src/navigation/expo-router/types.ts +116 -0
  361. package/src/navigation/index.ts +80 -0
  362. package/src/navigation/navigator.ts +18 -0
  363. package/src/navigation/screen/ReanimatedTrueSheetScreen.tsx +61 -0
  364. package/src/navigation/screen/TrueSheetScreen.tsx +54 -0
  365. package/src/navigation/screen/index.ts +3 -0
  366. package/src/navigation/screen/types.ts +19 -0
  367. package/src/navigation/screen/useSheetScreenState.ts +102 -0
  368. package/src/navigation/types.ts +302 -0
  369. package/src/navigation/useTrueSheetNavigation.ts +26 -0
  370. package/src/reanimated/ReanimatedTrueSheet.tsx +12 -7
  371. package/src/reanimated/ReanimatedTrueSheet.web.tsx +75 -0
  372. package/src/reanimated/ReanimatedTrueSheetProvider.tsx +12 -8
  373. package/src/reanimated/useReanimatedPositionChangeHandler.web.ts +31 -0
  374. package/src/specs/NativeTrueSheetModule.ts +28 -3
  375. package/src/web/constants.ts +13 -0
  376. package/src/web/dom.ts +9 -0
  377. package/src/web/vaul/README.md +9 -0
  378. package/src/web/vaul/browser.ts +38 -0
  379. package/src/web/vaul/constants.ts +24 -0
  380. package/src/web/vaul/context.ts +102 -0
  381. package/src/web/vaul/helpers.ts +131 -0
  382. package/src/web/vaul/index.tsx +1785 -0
  383. package/src/web/vaul/style.css +287 -0
  384. package/src/web/vaul/style.css.d.ts +1 -0
  385. package/src/web/vaul/types.ts +7 -0
  386. package/src/web/vaul/use-composed-refs.ts +35 -0
  387. package/src/web/vaul/use-controllable-state.ts +66 -0
  388. package/src/web/vaul/use-position-fixed.ts +147 -0
  389. package/src/web/vaul/use-prevent-scroll.ts +309 -0
  390. package/src/web/vaul/use-scale-background.ts +64 -0
  391. package/src/web/vaul/use-snap-points.ts +455 -0
  392. package/android/src/main/java/com/lodev09/truesheet/events/DetentChangeEvent.kt +0 -26
  393. package/android/src/main/java/com/lodev09/truesheet/events/DidDismissEvent.kt +0 -20
  394. package/android/src/main/java/com/lodev09/truesheet/events/DidPresentEvent.kt +0 -26
  395. package/android/src/main/java/com/lodev09/truesheet/events/DragBeginEvent.kt +0 -26
  396. package/android/src/main/java/com/lodev09/truesheet/events/DragChangeEvent.kt +0 -26
  397. package/android/src/main/java/com/lodev09/truesheet/events/DragEndEvent.kt +0 -26
  398. package/android/src/main/java/com/lodev09/truesheet/events/MountEvent.kt +0 -20
  399. package/android/src/main/java/com/lodev09/truesheet/events/PositionChangeEvent.kt +0 -32
  400. package/android/src/main/java/com/lodev09/truesheet/events/SizeChangeEvent.kt +0 -27
  401. package/android/src/main/java/com/lodev09/truesheet/events/WillDismissEvent.kt +0 -20
  402. package/android/src/main/java/com/lodev09/truesheet/events/WillPresentEvent.kt +0 -26
  403. package/android/src/main/res/values/styles.xml +0 -8
  404. package/ios/events/OnDetentChangeEvent.h +0 -28
  405. package/ios/events/OnDetentChangeEvent.mm +0 -30
  406. package/ios/events/OnDidDismissEvent.h +0 -26
  407. package/ios/events/OnDidDismissEvent.mm +0 -25
  408. package/ios/events/OnDidPresentEvent.h +0 -28
  409. package/ios/events/OnDidPresentEvent.mm +0 -30
  410. package/ios/events/OnDragBeginEvent.h +0 -28
  411. package/ios/events/OnDragBeginEvent.mm +0 -30
  412. package/ios/events/OnDragChangeEvent.h +0 -28
  413. package/ios/events/OnDragChangeEvent.mm +0 -30
  414. package/ios/events/OnDragEndEvent.h +0 -28
  415. package/ios/events/OnDragEndEvent.mm +0 -30
  416. package/ios/events/OnMountEvent.mm +0 -25
  417. package/ios/events/OnPositionChangeEvent.mm +0 -32
  418. package/ios/events/OnSizeChangeEvent.h +0 -28
  419. package/ios/events/OnSizeChangeEvent.mm +0 -30
  420. package/ios/events/OnWillDismissEvent.mm +0 -25
  421. package/ios/events/OnWillPresentEvent.h +0 -28
  422. package/ios/events/OnWillPresentEvent.mm +0 -30
  423. package/ios/utils/LayoutUtil.h +0 -44
  424. package/ios/utils/LayoutUtil.mm +0 -50
  425. package/lib/module/TrueSheetGrabber.js +0 -51
  426. package/lib/module/TrueSheetGrabber.js.map +0 -1
  427. package/lib/typescript/src/TrueSheetGrabber.d.ts +0 -39
  428. package/lib/typescript/src/TrueSheetGrabber.d.ts.map +0 -1
  429. package/src/TrueSheetGrabber.tsx +0 -82
  430. package/src/__mocks__/index.js +0 -67
@@ -0,0 +1,1270 @@
1
+ "use strict";
2
+
3
+ /// <reference lib="dom" />
4
+ import { createElement, forwardRef, isValidElement, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';
5
+ import { StyleSheet, useColorScheme, useWindowDimensions, View } from 'react-native';
6
+ import { measurePeekContentHeight, TrueSheetPeekContext } from "./TrueSheetPeek.web.js";
7
+ import { usePortalContainer, useRegisterSheet, useSheetStack } from "./TrueSheetProvider.web.js";
8
+ import { COLOR_SURFACE_CONTAINER_LOW_DARK, COLOR_SURFACE_CONTAINER_LOW_LIGHT, DEFAULT_ANCHOR_OFFSET, DEFAULT_CORNER_RADIUS, DEFAULT_DETACHED_OFFSET, DEFAULT_FORM_SHEET_HEIGHT_RATIO, DEFAULT_FORM_SHEET_WIDTH, DEFAULT_GRABBER_COLOR_DARK, DEFAULT_GRABBER_COLOR_LIGHT, DEFAULT_GRABBER_HEIGHT, DEFAULT_GRABBER_TOP_MARGIN, DEFAULT_GRABBER_WIDTH, DEFAULT_MAX_WIDTH } from "./web/constants.js";
9
+ import { getDOMElement } from "./web/dom.js";
10
+ import { Drawer } from "./web/vaul/index.js";
11
+ import { DEFAULT_PEEK_HEIGHT, DRAG_CLASS, TRANSITIONS } from "./web/vaul/constants.js";
12
+
13
+ // Resolves the user's `scrollableRef` to its scrollable DOM element — RN-web
14
+ // ScrollView refs expose the scroll node directly (with helpers attached);
15
+ // list refs (e.g. FlatList) expose it via getScrollableNode(). The node's
16
+ // first child is the content container.
17
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
18
+ const getScrollableElement = scrollable => {
19
+ if (!scrollable) return null;
20
+ if (scrollable instanceof HTMLElement) return scrollable;
21
+ const node = scrollable.getScrollableNode?.();
22
+ return node instanceof HTMLElement ? node : null;
23
+ };
24
+ const TrueSheetComponent = /*#__PURE__*/forwardRef((props, ref) => {
25
+ const {
26
+ children,
27
+ name,
28
+ dismissible = true,
29
+ draggable = true,
30
+ cornerRadius,
31
+ style,
32
+ backgroundColor: backgroundColorProp,
33
+ maxContentHeight,
34
+ maxContentWidth,
35
+ anchor = 'center',
36
+ anchorOffset = DEFAULT_ANCHOR_OFFSET,
37
+ scrollableRef,
38
+ scrollableOptions,
39
+ grabber = true,
40
+ grabberOptions,
41
+ accessibilityOptions,
42
+ detents = [0.5, 1],
43
+ dimmed = true,
44
+ dimmedDetentIndex = 0,
45
+ initialDetentIndex = -1,
46
+ header,
47
+ headerStyle,
48
+ headerOptions,
49
+ footer,
50
+ footerStyle,
51
+ footerOptions,
52
+ presentation = 'page',
53
+ detached = false,
54
+ detachedOffset = DEFAULT_DETACHED_OFFSET,
55
+ elevation = 4,
56
+ insetAdjustment = 'automatic',
57
+ initialDetentAnimated = true,
58
+ onPositionChange,
59
+ onWillPresent,
60
+ onDidPresent,
61
+ onWillDismiss,
62
+ onDidDismiss,
63
+ onDismissAttempt,
64
+ onDetentChange,
65
+ onDragBegin,
66
+ onDragChange,
67
+ onDragEnd,
68
+ onMount,
69
+ onWillFocus,
70
+ onDidFocus,
71
+ onWillBlur,
72
+ onDidBlur
73
+ } = props;
74
+ const validDetents = useMemo(() => detents.filter(d => typeof d === 'number' || d === 'auto' || d === 'peek'), [detents]);
75
+ const snapPointsProps = useMemo(() => {
76
+ if (validDetents.length === 0) return {};
77
+ return {
78
+ snapPoints: validDetents,
79
+ fadeFromIndex: Math.min(dimmedDetentIndex, validDetents.length - 1)
80
+ };
81
+ }, [validDetents, dimmedDetentIndex]);
82
+ const {
83
+ width: windowWidth,
84
+ height: windowHeight
85
+ } = useWindowDimensions();
86
+ const isLandscapeOrTablet = windowWidth >= 600 || windowWidth > windowHeight;
87
+ const isFormSheet = isLandscapeOrTablet && presentation === 'form';
88
+
89
+ // A form sheet floats (detached) only on tablet/landscape — mirrors iOS where
90
+ // a form sheet is a centered card on iPad but an edge-attached bottom sheet on
91
+ // a compact iPhone. On mobile portrait it stays edge-attached unless `detached`
92
+ // is explicitly set.
93
+ const effectiveDetached = isFormSheet || detached;
94
+ const colorScheme = useColorScheme();
95
+ const backgroundColor = backgroundColorProp ?? (colorScheme === 'dark' ? COLOR_SURFACE_CONTAINER_LOW_DARK : COLOR_SURFACE_CONTAINER_LOW_LIGHT);
96
+ const shouldAutoPresent = initialDetentIndex >= 0 && initialDetentIndex < validDetents.length;
97
+ const [isOpen, setIsOpen] = useState(shouldAutoPresent);
98
+ const [activeSnapPoint, setActiveSnapPoint] = useState(() => validDetents[shouldAutoPresent ? initialDetentIndex : 0] ?? null);
99
+
100
+ // Keep activeSnapPoint valid if detents change (e.g., prop updates).
101
+ useEffect(() => {
102
+ if (validDetents.length === 0) return;
103
+ setActiveSnapPoint(current => current != null && validDetents.includes(current) ? current : validDetents[0]);
104
+ }, [validDetents]);
105
+ const validDetentsRef = useRef(validDetents);
106
+ validDetentsRef.current = validDetents;
107
+ const hasAutoDetent = validDetents.includes('auto');
108
+ const handleSetActiveSnapPoint = useCallback(snapPoint => {
109
+ setActiveSnapPoint(snapPoint == null ? null : typeof snapPoint === 'number' || snapPoint === 'auto' || snapPoint === 'peek' ? snapPoint : null);
110
+ }, []);
111
+ const handleOpenChange = useCallback(open => {
112
+ if (!open && isOpen) {
113
+ setIsOpen(false);
114
+ }
115
+ }, [isOpen]);
116
+ const portalContainer = usePortalContainer();
117
+ const handlePointerDownOutside = e => {
118
+ const target = e.target;
119
+ if (!(target instanceof Node)) return;
120
+ // Pointer down that landed outside this sheet's portal container (e.g.,
121
+ // in another screen's tree when navigating) should not close the drawer.
122
+ if (portalContainer && !portalContainer.contains(target)) {
123
+ e.preventDefault();
124
+ return;
125
+ }
126
+ if (!(target instanceof Element)) return;
127
+ const wrapper = drawerContentRef.current?.closest('[data-vaul-detached-wrapper]');
128
+ if (!wrapper) return;
129
+ // The footer is rendered via vaul's `detachedSiblings` as a sibling of
130
+ // Drawer.Content inside [data-vaul-detached-wrapper], so Radix treats
131
+ // clicks on it as "outside" the content. Don't dismiss for clicks that
132
+ // landed inside the wrapper.
133
+ if (wrapper.contains(target)) {
134
+ e.preventDefault();
135
+ return;
136
+ }
137
+ // Every sheet runs Radix non-modal and portals its overlay + wrapper as
138
+ // siblings into the shared container, so a press on a sheet stacked above
139
+ // this one (its content or its dim overlay) is also delivered here as
140
+ // "outside". Sheets present in document order, so anything after our
141
+ // wrapper belongs to a descendant. Radix may dispatch on the deferred
142
+ // click (touch), after a dismissing descendant has left the DOM — treat
143
+ // disconnected as above too.
144
+ /* eslint-disable no-bitwise */
145
+ const above = Node.DOCUMENT_POSITION_FOLLOWING | Node.DOCUMENT_POSITION_DISCONNECTED;
146
+ if (wrapper.compareDocumentPosition(target) & above) {
147
+ e.preventDefault();
148
+ }
149
+ /* eslint-enable no-bitwise */
150
+ };
151
+ const dismissAboveRef = useRef(async () => {});
152
+ const dismissDescendantsRef = useRef(() => {});
153
+ const methods = useMemo(() => ({
154
+ present: async (index = 0) => {
155
+ const detent = validDetentsRef.current[index];
156
+ if (detent === undefined) {
157
+ throw new Error(`TrueSheet: present index (${index}) is out of bounds. detents array has ${validDetentsRef.current.length} item(s)`);
158
+ }
159
+ setActiveSnapPoint(detent);
160
+ setIsOpen(true);
161
+ },
162
+ dismiss: async () => {
163
+ setIsOpen(false);
164
+ },
165
+ resize: async index => {
166
+ const detent = validDetentsRef.current[index];
167
+ if (detent === undefined) {
168
+ throw new Error(`TrueSheet: resize index (${index}) is out of bounds. detents array has ${validDetentsRef.current.length} item(s)`);
169
+ }
170
+ setActiveSnapPoint(detent);
171
+ },
172
+ dismissStack: async animated => {
173
+ await dismissAboveRef.current(animated);
174
+ }
175
+ }), []);
176
+ useImperativeHandle(ref, () => methods, [methods]);
177
+ const methodsRef = useRef(methods);
178
+ useRegisterSheet(name, methodsRef);
179
+ const drawerContentRef = useRef(null);
180
+
181
+ // Measured header/footer heights drive the 'peek' snap point — mirrors
182
+ // native, where the controller tracks headerHeight/footerHeight.
183
+ const [headerHeight, setHeaderHeight] = useState(0);
184
+ const [footerHeight, setFooterHeight] = useState(0);
185
+ const handleHeaderLayout = useCallback(e => {
186
+ setHeaderHeight(e.nativeEvent.layout.height);
187
+ }, []);
188
+ const handleFooterLayout = useCallback(e => {
189
+ setFooterHeight(e.nativeEvent.layout.height);
190
+ }, []);
191
+
192
+ // DOM refs for live 'peek' measurement in computeDetentGeometry — the
193
+ // state above (which drives vaul's `peekHeight` prop) comes from RN-web
194
+ // `onLayout`, which dispatches a frame after mount: too late for the first
195
+ // willPresent.
196
+ const headerElRef = useRef(null);
197
+ const footerElRef = useRef(null);
198
+
199
+ // Distance from the content top to the bottom of a `TrueSheetPeek` rendered
200
+ // within the content — measured by the peek against `contentRef`.
201
+ const [peekContentHeight, setPeekContentHeight] = useState(0);
202
+ const contentRef = useRef(null);
203
+ const peekElRef = useRef(null);
204
+ const peekContext = useMemo(() => ({
205
+ contentRef,
206
+ peekRef: peekElRef,
207
+ setPeekContentHeight
208
+ }), []);
209
+
210
+ // The peek's own onLayout only fires when *it* resizes. Content added above
211
+ // it moves it without resizing it, so re-measure its offset whenever the
212
+ // content view's layout changes.
213
+ const handleContentLayout = useCallback(() => {
214
+ const peekEl = getDOMElement(peekElRef.current);
215
+ const contentEl = getDOMElement(contentRef.current);
216
+ if (peekEl && contentEl) {
217
+ setPeekContentHeight(measurePeekContentHeight(peekEl, contentEl));
218
+ }
219
+ }, []);
220
+
221
+ // An absolute (floating) header overlaps the content, so it contributes no
222
+ // height to the 'auto' detent measurement.
223
+ const absoluteHeader = headerOptions?.position === 'absolute';
224
+ const absoluteHeaderRef = useRef(absoluteHeader);
225
+ absoluteHeaderRef.current = absoluteHeader;
226
+ const resolvedHeaderStyle = absoluteHeader ? [absoluteHeaderStyle, headerStyle] : headerStyle;
227
+
228
+ // Same for an absolute (floating) footer — rendered via vaul's
229
+ // `detachedSiblings` instead of in the content flow.
230
+ const absoluteFooter = footerOptions?.position === 'absolute';
231
+ const absoluteFooterRef = useRef(absoluteFooter);
232
+ absoluteFooterRef.current = absoluteFooter;
233
+
234
+ // The footer owns the sheet's bottom edge, so it absorbs the bottom
235
+ // safe-area inset as padding (on top of its own) — mirrors native, where the
236
+ // footer shadow node pads the inset so its background fills it.
237
+ const footerOwnsInset = Boolean(footer) && insetAdjustment === 'automatic';
238
+ const resolvedFooterStyle = useMemo(() => {
239
+ if (!footerOwnsInset) return footerStyle;
240
+ const flat = StyleSheet.flatten(footerStyle);
241
+ const base = flat?.paddingBottom ?? flat?.paddingVertical ?? flat?.padding;
242
+ const baseCss = typeof base === 'number' ? `${base}px` : typeof base === 'string' ? base : '0px';
243
+ return [footerStyle, {
244
+ // RN types don't model CSS calc(), but RN-web passes it through
245
+ paddingBottom: `calc(${baseCss} + env(safe-area-inset-bottom, 0px))`
246
+ }];
247
+ }, [footerOwnsInset, footerStyle]);
248
+
249
+ // A relative footer is laid out below the content, so it's pushed off-screen
250
+ // at the peek detent and contributes no height.
251
+ const peekHeight = (header ? headerHeight : 0) + (footer && absoluteFooter ? footerHeight : 0) + peekContentHeight || DEFAULT_PEEK_HEIGHT;
252
+
253
+ // Web mirror of native's scrollable handling for 'auto' detents: a plugged
254
+ // scrollable keeps the sized (bounded) layout so its viewport is capped to
255
+ // the visible sheet and can scroll, while the 'auto' height is measured with
256
+ // the viewport replaced by the scrollable's content size — mirrors native
257
+ // `naturalHeight`.
258
+ const [hasBoundedScrollable, setHasBoundedScrollable] = useState(false);
259
+ const [scrollableAutoHeight, setScrollableAutoHeight] = useState(0);
260
+ const detectedScrollerRef = useRef(null);
261
+
262
+ // Natural content height (header + content + footer, with a detected
263
+ // scrollable's viewport replaced by its content size) — the height the
264
+ // content wants regardless of the sheet's bounds.
265
+ const measureNaturalHeight = useCallback(() => {
266
+ const contentEl = getDOMElement(contentRef.current);
267
+ if (!contentEl || !contentEl.isConnected) return 0;
268
+ const headerEl = absoluteHeaderRef.current ? null : getDOMElement(headerElRef.current);
269
+ const footerEl = absoluteFooterRef.current ? null : getDOMElement(footerElRef.current);
270
+ let height = (headerEl?.offsetHeight ?? 0) + (footerEl?.offsetHeight ?? 0) + contentEl.offsetHeight;
271
+ const scroller = detectedScrollerRef.current;
272
+ const scrollContent = scroller?.firstElementChild;
273
+ if (scroller?.isConnected && scrollContent instanceof HTMLElement) {
274
+ height += scrollContent.offsetHeight - scroller.clientHeight;
275
+ }
276
+ return Math.max(0, height);
277
+ }, []);
278
+ useEffect(() => {
279
+ if (!isOpen || !hasAutoDetent) return undefined;
280
+ let canceled = false;
281
+ let rafId = 0;
282
+ let mutationObserver = null;
283
+ let resizeObserver = null;
284
+ const attach = () => {
285
+ if (canceled) return;
286
+ const drawerEl = drawerContentRef.current;
287
+ if (!drawerEl || !drawerEl.isConnected) {
288
+ // Radix Presence defers the portal mount; poll until the drawer is live.
289
+ rafId = window.requestAnimationFrame(attach);
290
+ return;
291
+ }
292
+ const measure = () => setScrollableAutoHeight(measureNaturalHeight());
293
+ let observed = null;
294
+
295
+ // (Re)resolve the plugged scrollable and observe the nodes whose size
296
+ // feeds the natural height — content growth inside a bounded scroller is
297
+ // invisible to the sheet's own layout (mirrors native's contentSize
298
+ // observation). Resolves the content node live: the layout-branch swap
299
+ // (natural flow ↔ sized) remounts it.
300
+ const observe = () => {
301
+ const contentEl = getDOMElement(contentRef.current);
302
+ const headerEl = getDOMElement(headerElRef.current);
303
+
304
+ // Skip mutations that don't change the observed topology — e.g. a
305
+ // virtualized list mounting rows inside the plugged scroller. Size
306
+ // changes are already covered by the ResizeObserver.
307
+ if (observed && observed.contentEl === contentEl && contentEl?.isConnected && observed.headerEl === headerEl && observed.scroller.isConnected && observed.scrollContent === observed.scroller.firstElementChild) {
308
+ return;
309
+ }
310
+ const resolved = contentEl && contentEl.isConnected ? getScrollableElement(scrollableRef?.current) : null;
311
+ const scroller = resolved?.isConnected ? resolved : null;
312
+ detectedScrollerRef.current = scroller;
313
+ setHasBoundedScrollable(scroller != null);
314
+ observed = scroller ? {
315
+ contentEl,
316
+ headerEl,
317
+ scroller,
318
+ scrollContent: scroller.firstElementChild
319
+ } : null;
320
+ resizeObserver?.disconnect();
321
+ resizeObserver = new ResizeObserver(measure);
322
+ if (contentEl?.isConnected) resizeObserver.observe(contentEl);
323
+ if (headerEl) resizeObserver.observe(headerEl);
324
+ if (scroller) {
325
+ resizeObserver.observe(scroller);
326
+ if (scroller.firstElementChild) resizeObserver.observe(scroller.firstElementChild);
327
+ }
328
+ measure();
329
+ };
330
+ observe();
331
+ // Watch the whole drawer subtree — catches the scrollable mounting/
332
+ // unmounting AND the layout-branch swap, which remounts the content node
333
+ // (a content-scoped observer would go stale after the swap).
334
+ mutationObserver = new MutationObserver(observe);
335
+ mutationObserver.observe(drawerEl, {
336
+ childList: true,
337
+ subtree: true
338
+ });
339
+ };
340
+ rafId = window.requestAnimationFrame(attach);
341
+ return () => {
342
+ canceled = true;
343
+ window.cancelAnimationFrame(rafId);
344
+ mutationObserver?.disconnect();
345
+ resizeObserver?.disconnect();
346
+ };
347
+ }, [isOpen, hasAutoDetent, measureNaturalHeight, scrollableRef]);
348
+
349
+ // Below the last detent a vertical touch pan moves the sheet, not the
350
+ // content — `[data-vaul-scroll-locked]` disables vertical touch panning on
351
+ // the scroll container and everything inside it (see vaul/style.css).
352
+ const isScrollLocked = validDetents.length > 0 && activeSnapPoint !== validDetents[validDetents.length - 1];
353
+
354
+ // Vaul measures the auto-size wrapper's offsetHeight (always, post fork).
355
+ // Track it here so the form sheet can size its card to fit content,
356
+ // clamped between a minimum ratio of the viewport and a maximum derived
357
+ // from `detachedOffset` (the breathing room left at top + bottom of the
358
+ // floating card).
359
+ const [measuredContentHeight, setMeasuredContentHeight] = useState(0);
360
+ const effectiveMaxContentHeight = useMemo(() => {
361
+ if (maxContentHeight !== undefined) return maxContentHeight;
362
+ if (!isFormSheet) return undefined;
363
+ const min = windowHeight * DEFAULT_FORM_SHEET_HEIGHT_RATIO;
364
+ const max = Math.max(min, windowHeight - 2 * detachedOffset);
365
+ if (measuredContentHeight <= 0) return min;
366
+ return Math.max(min, Math.min(measuredContentHeight, max));
367
+ }, [maxContentHeight, isFormSheet, windowHeight, detachedOffset, measuredContentHeight]);
368
+
369
+ // Center the form sheet using the actual visible drawer height. Vaul
370
+ // auto-sizes to content (capped by `maxContentHeight`), so when content is
371
+ // shorter than `effectiveMaxContentHeight`'s min-clamped floor, using that
372
+ // for the offset would push a small sheet below the viewport center.
373
+ const effectiveDetachedOffset = useMemo(() => {
374
+ if (!isFormSheet) return detachedOffset;
375
+ const max = Math.max(0, windowHeight - 2 * detachedOffset);
376
+ const visibleHeight = measuredContentHeight > 0 ? Math.min(measuredContentHeight, max) : effectiveMaxContentHeight ?? 0;
377
+ return Math.max(0, (windowHeight - visibleHeight) / 2);
378
+ }, [isFormSheet, windowHeight, detachedOffset, measuredContentHeight, effectiveMaxContentHeight]);
379
+
380
+ // Present/dismiss events. The sheet settles via a CSS `transform` transition
381
+ // on either the drawer (snap-points on autopresent) or the wrapper (whole-
382
+ // card slide on reopen/dismiss). `Animation.finished` from the Web Animations
383
+ // API tracks whichever is actually running — reflects what the browser is
384
+ // doing, doesn't miss when no transition runs (same-value change), and
385
+ // handles interruptions correctly (a drag/resnap mid-present resolves only
386
+ // once all transform animations drain).
387
+ const onWillPresentRef = useRef(onWillPresent);
388
+ const onDidPresentRef = useRef(onDidPresent);
389
+ const onWillDismissRef = useRef(onWillDismiss);
390
+ const onDidDismissRef = useRef(onDidDismiss);
391
+ const onDetentChangeRef = useRef(onDetentChange);
392
+ const onDragBeginRef = useRef(onDragBegin);
393
+ const onDragChangeRef = useRef(onDragChange);
394
+ const onDragEndRef = useRef(onDragEnd);
395
+ const onPositionChangeRef = useRef(onPositionChange);
396
+ const activeSnapPointRef = useRef(activeSnapPoint);
397
+ useEffect(() => {
398
+ onWillPresentRef.current = onWillPresent;
399
+ onDidPresentRef.current = onDidPresent;
400
+ onWillDismissRef.current = onWillDismiss;
401
+ onDidDismissRef.current = onDidDismiss;
402
+ onDetentChangeRef.current = onDetentChange;
403
+ onDragBeginRef.current = onDragBegin;
404
+ onDragChangeRef.current = onDragChange;
405
+ onDragEndRef.current = onDragEnd;
406
+ onPositionChangeRef.current = onPositionChange;
407
+ activeSnapPointRef.current = activeSnapPoint;
408
+ });
409
+
410
+ // Detent geometry — target top-Y (`positions`) and height ratio (`values`)
411
+ // per detent. Mirrors vaul's snap-offset math exactly (same effective
412
+ // height, ceiling, and 'auto'/'peek' resolution) so computed targets match
413
+ // where the drawer actually settles. Numeric detent d → top-Y =
414
+ // (1 - d) * effectiveH. 'auto' and 'peek' are measured live from the DOM
415
+ // (see below). Inputs live in a render-synced ref so the compute callbacks
416
+ // stay referentially stable for the event effects.
417
+ const geometryInputsRef = useRef({
418
+ effectiveDetached,
419
+ effectiveDetachedOffset,
420
+ effectiveMaxContentHeight,
421
+ peekHeight,
422
+ peekContentHeight,
423
+ measuredContentHeight
424
+ });
425
+ geometryInputsRef.current = {
426
+ effectiveDetached,
427
+ effectiveDetachedOffset,
428
+ effectiveMaxContentHeight,
429
+ peekHeight,
430
+ peekContentHeight,
431
+ measuredContentHeight
432
+ };
433
+ const computeDetentGeometry = useCallback(() => {
434
+ const inputs = geometryInputsRef.current;
435
+ const windowH = window.innerHeight;
436
+ const effectiveH = inputs.effectiveDetached ? windowH - inputs.effectiveDetachedOffset : windowH;
437
+ // Matches vaul's height ceiling: min(effectiveH, maxContentHeight).
438
+ const ceiling = inputs.effectiveMaxContentHeight !== undefined ? Math.min(effectiveH, inputs.effectiveMaxContentHeight) : effectiveH;
439
+ // 'auto' resolves to the content's natural height. Read it live — the
440
+ // `measuredContentHeight` state lags mount by a frame (vaul's initial
441
+ // ref-callback measure runs while the portal subtree is still detached,
442
+ // so it reads 0 until the ResizeObserver fires). Falls back to the state
443
+ // value, then to vaul's pre-measure fallback (effectiveHeight / 2).
444
+ const measuredHeight = measureNaturalHeight() || inputs.measuredContentHeight;
445
+ const autoHeight = Math.min(measuredHeight > 0 ? measuredHeight : effectiveH / 2, ceiling);
446
+
447
+ // 'peek' is measured live from the DOM (offsetHeight is layout-based, so
448
+ // in-flight transforms don't skew it): the state-driven `peekHeight` prop
449
+ // comes from RN-web onLayout, which dispatches a frame after mount — too
450
+ // late for the first willPresent on autopresent. Ref callbacks can't
451
+ // measure either: they fire while the portal subtree is still detached.
452
+ // Geometry only runs while the drawer is mounted, so the elements are
453
+ // measurable here; fall back to the state value when they're absent.
454
+ const headerEl = getDOMElement(headerElRef.current);
455
+ // A relative footer is pushed off-screen at the peek detent — excluded
456
+ const footerEl = absoluteFooterRef.current ? getDOMElement(footerElRef.current) : null;
457
+ const peekEl = getDOMElement(peekElRef.current);
458
+ const contentEl = getDOMElement(contentRef.current);
459
+ const livePeekContentHeight = peekEl && contentEl ? measurePeekContentHeight(peekEl, contentEl) : inputs.peekContentHeight;
460
+ const livePeekHeight = headerEl || footerEl || peekEl ? (headerEl?.offsetHeight ?? 0) + (footerEl?.offsetHeight ?? 0) + livePeekContentHeight || DEFAULT_PEEK_HEIGHT : inputs.peekHeight;
461
+ const positions = [];
462
+ const values = [];
463
+ for (const d of validDetentsRef.current) {
464
+ const h = typeof d === 'number' ? Math.min(d * effectiveH, ceiling) : d === 'peek' ? Math.min(livePeekHeight, ceiling) : autoHeight;
465
+ positions.push(effectiveH - h);
466
+ values.push(effectiveH > 0 ? h / effectiveH : 0);
467
+ }
468
+ return {
469
+ windowH,
470
+ effectiveH,
471
+ ceiling,
472
+ positions,
473
+ values
474
+ };
475
+ }, [measureNaturalHeight]);
476
+
477
+ // Detent info for lifecycle events. Position/detent come from the active
478
+ // detent's target geometry — not the live DOM rect — so willPresent (drawer
479
+ // not mounted yet), detentChange (animation just started), and didPresent
480
+ // all emit the settled detent position, matching iOS/Android. Drag events
481
+ // pass `live: true` to report the in-flight rect position instead, also
482
+ // matching native.
483
+ const computeDetentInfo = useCallback((live = false) => {
484
+ const snap = activeSnapPointRef.current;
485
+ const index = snap != null ? validDetentsRef.current.indexOf(snap) : -1;
486
+ const {
487
+ windowH,
488
+ positions,
489
+ values
490
+ } = computeDetentGeometry();
491
+ const target = index >= 0 ? positions[index] : undefined;
492
+ const position = live ? drawerContentRef.current?.getBoundingClientRect().top ?? target ?? windowH : target ?? windowH;
493
+ return {
494
+ index,
495
+ position,
496
+ detent: index >= 0 ? values[index] ?? 0 : 0
497
+ };
498
+ }, [computeDetentGeometry]);
499
+
500
+ // Mirror Android: interpolate fractional index and detent from the drawer's
501
+ // top-Y so continuous position updates (drag, animation) carry smooth values
502
+ // between detent boundaries.
503
+ const interpolateFromPosition = useCallback(position => {
504
+ const {
505
+ windowH,
506
+ positions,
507
+ values
508
+ } = computeDetentGeometry();
509
+ const count = positions.length;
510
+ if (count === 0) return {
511
+ index: -1,
512
+ detent: 0
513
+ };
514
+
515
+ // Absorb subpixel drift from getBoundingClientRect so at-rest positions
516
+ // don't sneak into the below-first branch and emit near-zero negatives
517
+ // like `-1e-8` (which render as "-1" via JS scientific-notation toString).
518
+ const epsilon = 0.5;
519
+ const firstPos = positions[0];
520
+ const lastPos = positions[count - 1];
521
+ if (position > firstPos + epsilon) {
522
+ // Two ranges: index spans the full animation (windowH of wrapper
523
+ // travel) so it's smooth for driving dependent animations end-to-end;
524
+ // detent tracks the sheet's visible-height ratio (windowH - firstPos)
525
+ // so its 0–values[0] fade has fine resolution while the sheet is still
526
+ // in view. Both clamp to keep outputs in [-1, 0].
527
+ const indexRaw = (position - firstPos) / windowH;
528
+ const detentRaw = (position - firstPos) / Math.max(1, windowH - firstPos);
529
+ const indexProgress = Math.max(0, Math.min(1, indexRaw));
530
+ const detentProgress = Math.max(0, Math.min(1, detentRaw));
531
+ return {
532
+ index: -indexProgress,
533
+ detent: Math.max(0, values[0] * (1 - detentProgress))
534
+ };
535
+ }
536
+ if (count === 1) return {
537
+ index: 0,
538
+ detent: values[0]
539
+ };
540
+
541
+ // Clamp into the segment range so subpixel drift at the boundaries
542
+ // resolves cleanly to the nearest segment edge (index 0 or count-1).
543
+ const clamped = Math.max(lastPos, Math.min(firstPos, position));
544
+ for (let i = 0; i < count - 1; i++) {
545
+ const pos = positions[i];
546
+ const nextPos = positions[i + 1];
547
+ if (clamped >= nextPos && clamped <= pos) {
548
+ const range = pos - nextPos;
549
+ const progress = range > 0 ? (pos - clamped) / range : 0;
550
+ const clampedProgress = Math.max(0, Math.min(1, progress));
551
+ return {
552
+ index: i + clampedProgress,
553
+ detent: values[i] + clampedProgress * (values[i + 1] - values[i])
554
+ };
555
+ }
556
+ }
557
+ return {
558
+ index: count - 1,
559
+ detent: values[count - 1]
560
+ };
561
+ }, [computeDetentGeometry]);
562
+
563
+ // Mirror native synchronous layout: while dragging (and through the post-
564
+ // release settle) the sized layout tracks the sheet's visible height in
565
+ // realtime, clamped to the smallest detent — dragging below it slides the
566
+ // sheet out without resizing. Once settled, the inline height is cleared so
567
+ // the CSS calc() owns sizing again (adapts to viewport resizes at rest).
568
+ const sizedLayoutRef = useRef(null);
569
+ const isDraggingRef = useRef(false);
570
+ const isSettlingAfterDragRef = useRef(false);
571
+ const updateSizedLayoutHeight = useCallback(position => {
572
+ const node = sizedLayoutRef.current;
573
+ if (!node) return;
574
+ const {
575
+ effectiveH,
576
+ ceiling,
577
+ positions
578
+ } = computeDetentGeometry();
579
+ if (positions.length === 0) return;
580
+ if (isSettlingAfterDragRef.current) {
581
+ const snap = activeSnapPointRef.current;
582
+ const index = snap != null ? validDetentsRef.current.indexOf(snap) : -1;
583
+ const target = index >= 0 ? positions[index] : null;
584
+ if (target != null && Math.abs(position - target) < 1) {
585
+ isSettlingAfterDragRef.current = false;
586
+ // Restore the calc — height is an inline style, so clearing it would
587
+ // leave the div unsized (React won't re-apply it without a render)
588
+ node.style.height = SIZED_LAYOUT_HEIGHT;
589
+ return;
590
+ }
591
+ }
592
+
593
+ // positions[0] is the smallest detent's top-Y — its height is the clamp floor.
594
+ const minHeight = effectiveH - positions[0];
595
+ const height = Math.min(Math.max(effectiveH - position, minHeight), ceiling);
596
+ node.style.height = `${height}px`;
597
+ }, [computeDetentGeometry]);
598
+ const handlePositionChange = useCallback(position => {
599
+ if (isDraggingRef.current || isSettlingAfterDragRef.current) {
600
+ updateSizedLayoutHeight(position);
601
+ }
602
+ const {
603
+ index,
604
+ detent
605
+ } = interpolateFromPosition(position);
606
+ onPositionChangeRef.current?.({
607
+ nativeEvent: {
608
+ index,
609
+ position,
610
+ detent,
611
+ realtime: true
612
+ }
613
+ });
614
+ }, [interpolateFromPosition, updateSizedLayoutHeight]);
615
+
616
+ // Fire onMount once after first render. React-mount is the earliest point
617
+ // the component is ready for imperative calls, matching the native
618
+ // "ready for present" contract. Declared before the present/dismiss effect
619
+ // so it fires first during autopresent (onMount → onWillPresent).
620
+ const onMountRef = useRef(onMount);
621
+ useEffect(() => {
622
+ onMountRef.current = onMount;
623
+ });
624
+ useEffect(() => {
625
+ onMountRef.current?.({
626
+ nativeEvent: null
627
+ });
628
+ }, []);
629
+
630
+ // Start at `false` so a mount with `isOpen=true` (autopresent via
631
+ // `initialDetentIndex`) is detected as a false→true transition and fires
632
+ // `onWillPresent`.
633
+ const wasOpenRef = useRef(false);
634
+ useEffect(() => {
635
+ const wasOpen = wasOpenRef.current;
636
+ wasOpenRef.current = isOpen;
637
+ if (isOpen === wasOpen) return undefined;
638
+ const present = isOpen;
639
+ if (!present) {
640
+ // Mirror native: dismissing a sheet takes every sheet stacked above it
641
+ // (iOS dismisses from the presenter; Android runs dismissStack first).
642
+ dismissDescendantsRef.current();
643
+ // Pair willBlur with willDismiss on dismiss — mirrors native iOS
644
+ // emitWillDismissEvents (blur fires before dismiss). willPresent is
645
+ // deferred to `start()` below (needs the mounted drawer's geometry).
646
+ onWillBlurRef.current?.({
647
+ nativeEvent: null
648
+ });
649
+ onWillDismissRef.current?.({
650
+ nativeEvent: null
651
+ });
652
+ }
653
+ const fireDone = () => {
654
+ if (present) {
655
+ onDidPresentRef.current?.({
656
+ nativeEvent: computeDetentInfo()
657
+ });
658
+ onDidFocusRef.current?.({
659
+ nativeEvent: null
660
+ });
661
+ } else {
662
+ onDidBlurRef.current?.({
663
+ nativeEvent: null
664
+ });
665
+ onDidDismissRef.current?.({
666
+ nativeEvent: null
667
+ });
668
+ }
669
+ };
670
+ let canceled = false;
671
+ let rafId = 0;
672
+ const start = () => {
673
+ if (canceled) return;
674
+ const drawer = drawerContentRef.current;
675
+ if (!drawer || !drawer.isConnected) {
676
+ // Drawer hasn't mounted yet (Radix Presence defers the portal mount
677
+ // past the first effect pass), or its subtree isn't attached to the
678
+ // document yet (autopresent commits the portal before the app tree
679
+ // attaches, so nothing is measurable). Poll until it's live.
680
+ rafId = window.requestAnimationFrame(start);
681
+ return;
682
+ }
683
+ if (present) {
684
+ // Emit will-events only once the drawer is mounted and attached —
685
+ // detent geometry ('auto' height, 'peek', form-sheet sizing) is
686
+ // measurable from the DOM here; a synchronous emission would use the
687
+ // pre-measure fallbacks on first present. Pairing willFocus with
688
+ // willPresent mirrors native iOS where viewWillAppear dispatches
689
+ // both; the descendant-stack focus effect handles subsequent
690
+ // transitions.
691
+ onWillPresentRef.current?.({
692
+ nativeEvent: computeDetentInfo()
693
+ });
694
+ onWillFocusRef.current?.({
695
+ nativeEvent: null
696
+ });
697
+ }
698
+ const wrapper = drawer.closest('[data-vaul-detached-wrapper]') ?? null;
699
+ const targets = wrapper ? [drawer, wrapper] : [drawer];
700
+ const waitForSettle = () => {
701
+ if (canceled) return;
702
+ // Force style recalc so transitions queued by vaul's effects this
703
+ // commit are registered in `getAnimations()`. RAF callbacks run BEFORE
704
+ // the frame's style recalc, and ignoring this returns a stale empty
705
+ // list — we'd fire `did` immediately with nothing queued.
706
+
707
+ drawer.offsetHeight;
708
+ const pending = targets.flatMap(el => el.getAnimations().filter(a => a.playState !== 'finished'));
709
+ if (pending.length === 0) {
710
+ fireDone();
711
+ return;
712
+ }
713
+ // allSettled: resolve even when a transition is canceled (drag /
714
+ // resnap), then re-check — a replacement transition may have started.
715
+ Promise.allSettled(pending.map(a => a.finished)).then(() => {
716
+ if (!canceled) waitForSettle();
717
+ });
718
+ };
719
+ waitForSettle();
720
+ };
721
+ rafId = window.requestAnimationFrame(start);
722
+ return () => {
723
+ canceled = true;
724
+ window.cancelAnimationFrame(rafId);
725
+ };
726
+ }, [isOpen, computeDetentInfo]);
727
+
728
+ // Fire onDetentChange only while open→open. Present/dismiss have their own
729
+ // events and carry detent info via onDidPresent, so we skip those edges.
730
+ const detentChangeStateRef = useRef({
731
+ isOpen,
732
+ activeSnapPoint
733
+ });
734
+ useEffect(() => {
735
+ const prev = detentChangeStateRef.current;
736
+ detentChangeStateRef.current = {
737
+ isOpen,
738
+ activeSnapPoint
739
+ };
740
+ if (!prev.isOpen || !isOpen) return;
741
+ if (prev.activeSnapPoint === activeSnapPoint) return;
742
+ onDetentChangeRef.current?.({
743
+ nativeEvent: computeDetentInfo()
744
+ });
745
+ }, [isOpen, activeSnapPoint, computeDetentInfo]);
746
+
747
+ // Vaul's `onDrag` fires once per pointermove while dragging; the first tick
748
+ // after an idle gap marks the drag boundary, so track it via a ref.
749
+ const handleDrag = useCallback(() => {
750
+ if (!isDraggingRef.current) {
751
+ isDraggingRef.current = true;
752
+ onDragBeginRef.current?.({
753
+ nativeEvent: computeDetentInfo(true)
754
+ });
755
+ }
756
+ onDragChangeRef.current?.({
757
+ nativeEvent: computeDetentInfo(true)
758
+ });
759
+ }, [computeDetentInfo]);
760
+ const handleRelease = useCallback((_event, open) => {
761
+ if (!isDraggingRef.current) return;
762
+ isDraggingRef.current = false;
763
+ // Track the sized layout through the settle animation only when the sheet
764
+ // stays open — a dismissal slides out at the min-clamped height.
765
+ isSettlingAfterDragRef.current = open;
766
+ onDragEndRef.current?.({
767
+ nativeEvent: computeDetentInfo(true)
768
+ });
769
+ }, [computeDetentInfo]);
770
+ const {
771
+ isNested,
772
+ dismissAbove,
773
+ descendants
774
+ } = useSheetStack(methodsRef, drawerContentRef, isOpen, isFormSheet);
775
+ dismissAboveRef.current = dismissAbove;
776
+ // Captured per render: by the time the dismiss effect runs, this sheet has
777
+ // already been popped from the stack, so `dismissAbove` can't find it.
778
+ dismissDescendantsRef.current = () => {
779
+ for (let i = descendants.length - 1; i >= 0; i--) {
780
+ descendants[i].ref.current?.dismiss();
781
+ }
782
+ };
783
+
784
+ // Mirror Android: translate this sheet down to match the deepest descendant's
785
+ // top so the whole stack visually aligns. Cascades because every ancestor
786
+ // re-runs whenever the stack (and thus its descendants) changes.
787
+ useEffect(() => {
788
+ const parent = drawerContentRef.current;
789
+ if (!parent) return;
790
+ // Skip while dismissing: this sheet's stack pop changes `descendants`,
791
+ // which would re-fire the effect and write `wrapper.style.transition =
792
+ // 'clip-path …'`, clobbering vaul's just-written `'transform …'` for the
793
+ // dismiss animation. Vaul fully owns this sheet's transitions on the way
794
+ // out — nothing to align with anymore.
795
+ if (!isOpen) return;
796
+ const parentWrapper = parent.closest('[data-vaul-detached-wrapper]');
797
+ const transition = `transform ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`;
798
+ const wrapperTransition = `clip-path ${TRANSITIONS.DURATION}s cubic-bezier(${TRANSITIONS.EASE.join(',')})`;
799
+ const CLIP_NONE = 'inset(0px round 0px)';
800
+
801
+ // Animate clip-path on the wrapper. Dedupes via DOM read so repeat ticks
802
+ // (mutation observer) skip identical writes. Seeds CLIP_NONE before the
803
+ // first inset() so the browser interpolates between two inset() shapes —
804
+ // `none → inset()` interpolates inconsistently.
805
+ const setClip = next => {
806
+ if (!parentWrapper) return;
807
+ const current = parentWrapper.style.clipPath;
808
+ if (current === next) return;
809
+ if (next === CLIP_NONE && !current) return;
810
+ if (!current) {
811
+ parentWrapper.style.transition = '';
812
+ parentWrapper.style.clipPath = CLIP_NONE;
813
+ // eslint-disable-next-line no-void
814
+ void parentWrapper.offsetHeight;
815
+ }
816
+ parentWrapper.style.transition = wrapperTransition;
817
+ parentWrapper.style.clipPath = next;
818
+ };
819
+ if (descendants.length === 0) {
820
+ parent.style.transition = transition;
821
+ parent.style.transform = '';
822
+ setClip(CLIP_NONE);
823
+ return;
824
+ }
825
+
826
+ // Track the immediate child's *actual* top: its cascade transform when it
827
+ // was itself pushed behind a grandchild, else its own snap point. Mirrors
828
+ // Android's addTranslation propagating extra translation up the stack —
829
+ // a grandchild opening pushes this sheet only as far as our child moved.
830
+ const readTranslateY = el => {
831
+ const match = el.style.transform.match(/translate3d\([^,]*,\s*(-?\d*\.?\d+)px/);
832
+ return match ? Number.parseFloat(match[1]) : null;
833
+ };
834
+ const computeTargetY = () => {
835
+ const parentSnap = Number.parseFloat(parent.style.getPropertyValue('--snap-point-height')) || 0;
836
+ const node = descendants[0]?.nodeRef.current;
837
+ if (!node) return parentSnap;
838
+ const childTop = readTranslateY(node) ?? (Number.parseFloat(node.style.getPropertyValue('--snap-point-height')) || 0);
839
+ return Math.max(parentSnap, childTop);
840
+ };
841
+
842
+ // When a form-sheet parent has a form-sheet descendant, clip the parent to
843
+ // the child card's viewport box so it doesn't peek above/around. Only
844
+ // applies when this sheet is itself form — a page parent should remain
845
+ // visible behind/around a floating form child. Geometry comes from the
846
+ // child's inline styles (not getBoundingClientRect) to read the at-rest
847
+ // box, unskewed by vaul's slide-in.
848
+ const applyFormClip = () => {
849
+ const form = isFormSheet ? descendants.find(d => d.isFormSheetRef.current) : undefined;
850
+ if (!form) {
851
+ setClip(CLIP_NONE);
852
+ return;
853
+ }
854
+ const childDrawer = form.nodeRef.current;
855
+ const childWrapper = childDrawer?.closest('[data-vaul-detached-wrapper]');
856
+ if (!parentWrapper || !childDrawer || !childWrapper) return;
857
+ const snapY = Number.parseFloat(childDrawer.style.getPropertyValue('--snap-point-height')) || 0;
858
+ const childBottomGap = Number.parseFloat(childWrapper.style.bottom) || 0;
859
+ const childMaxW = Number.parseFloat(childWrapper.style.maxWidth) || window.innerWidth;
860
+ const formLeft = (window.innerWidth - childMaxW) / 2;
861
+ const formRight = (window.innerWidth + childMaxW) / 2;
862
+ const formBottom = window.innerHeight - childBottomGap;
863
+ const rect = parentWrapper.getBoundingClientRect();
864
+ const top = Math.max(0, snapY - rect.top);
865
+ const left = Math.max(0, formLeft - rect.left);
866
+ const right = Math.max(0, rect.right - formRight);
867
+ const bottom = Math.max(0, rect.bottom - formBottom);
868
+ const radius = cornerRadius ?? DEFAULT_CORNER_RADIUS;
869
+ setClip(`inset(${top}px ${right}px ${bottom}px ${left}px round ${radius}px)`);
870
+ };
871
+ const apply = () => {
872
+ applyFormClip();
873
+ // Mirror iPad/Android (`isExpanded`): a parent at full height (detent 1)
874
+ // stays put and the child simply overlays it. Full height is the sheet's
875
+ // own ceiling — the viewport for a page sheet, the capped content-fit
876
+ // height for a form sheet — so compare against where detent 1 lands.
877
+ const parentSnap = Number.parseFloat(parent.style.getPropertyValue('--snap-point-height')) || 0;
878
+ const {
879
+ effectiveH,
880
+ ceiling
881
+ } = computeDetentGeometry();
882
+ if (parentSnap <= effectiveH - ceiling + 0.5) {
883
+ parent.style.transition = transition;
884
+ parent.style.transform = '';
885
+ return;
886
+ }
887
+ // Mirror Android: stay put while the child is being dragged (its live
888
+ // transform would drag us along during drag-to-dismiss). The release
889
+ // snap rewrites the child's style and re-applies.
890
+ if (descendants[0]?.nodeRef.current?.classList.contains(DRAG_CLASS)) return;
891
+ const targetY = computeTargetY();
892
+ const currentY = readTranslateY(parent) ?? 0;
893
+ if (Math.abs(currentY - targetY) < 0.5) return;
894
+ parent.style.transition = transition;
895
+ parent.style.transform = `translate3d(0, ${targetY}px, 0)`;
896
+ };
897
+ const raf = requestAnimationFrame(apply);
898
+ // Vaul re-runs snapToPoint on window resize (e.g., mobile keyboard open)
899
+ // which clobbers the cascade transform. Re-apply whenever the parent's
900
+ // inline style changes.
901
+ const observer = new MutationObserver(apply);
902
+ observer.observe(parent, {
903
+ attributes: true,
904
+ attributeFilter: ['style']
905
+ });
906
+ // The child's own cascade lands in a later frame — follow it when it moves.
907
+ const childNode = descendants[0]?.nodeRef.current;
908
+ if (childNode) observer.observe(childNode, {
909
+ attributes: true,
910
+ attributeFilter: ['style']
911
+ });
912
+ return () => {
913
+ cancelAnimationFrame(raf);
914
+ observer.disconnect();
915
+ };
916
+ }, [descendants, activeSnapPoint, cornerRadius, isFormSheet, isOpen, computeDetentGeometry]);
917
+
918
+ // Focus/blur events fire when a descendant sheet appears on top of this one
919
+ // (blur) or when all descendants are dismissed (focus). will-events fire
920
+ // synchronously at the transition boundary; did-events fire once the cascade
921
+ // transform drains. Intermediate count changes (1↔2) don't re-fire — this
922
+ // sheet stays blurred throughout.
923
+ const onWillBlurRef = useRef(onWillBlur);
924
+ const onDidBlurRef = useRef(onDidBlur);
925
+ const onWillFocusRef = useRef(onWillFocus);
926
+ const onDidFocusRef = useRef(onDidFocus);
927
+ const onDismissAttemptRef = useRef(onDismissAttempt);
928
+ useEffect(() => {
929
+ onWillBlurRef.current = onWillBlur;
930
+ onDidBlurRef.current = onDidBlur;
931
+ onWillFocusRef.current = onWillFocus;
932
+ onDidFocusRef.current = onDidFocus;
933
+ onDismissAttemptRef.current = onDismissAttempt;
934
+ });
935
+ const handleDismissAttempt = useCallback(() => {
936
+ onDismissAttemptRef.current?.({
937
+ nativeEvent: null
938
+ });
939
+ }, []);
940
+ const prevDescendantCountRef = useRef(0);
941
+ useEffect(() => {
942
+ const prevCount = prevDescendantCountRef.current;
943
+ const count = descendants.length;
944
+ prevDescendantCountRef.current = count;
945
+ if (!isOpen) return;
946
+ const gained = count > 0 && prevCount === 0;
947
+ const lost = count === 0 && prevCount > 0;
948
+ if (!gained && !lost) return;
949
+ if (gained) {
950
+ onWillBlurRef.current?.({
951
+ nativeEvent: null
952
+ });
953
+ } else {
954
+ onWillFocusRef.current?.({
955
+ nativeEvent: null
956
+ });
957
+ }
958
+ const drawer = drawerContentRef.current;
959
+ if (!drawer) return;
960
+ let canceled = false;
961
+ const fireDone = () => {
962
+ if (canceled) return;
963
+ if (gained) onDidBlurRef.current?.({
964
+ nativeEvent: null
965
+ });else onDidFocusRef.current?.({
966
+ nativeEvent: null
967
+ });
968
+ };
969
+ const rafId = window.requestAnimationFrame(() => {
970
+ if (canceled) return;
971
+ // Force style recalc so the cascade effect's queued transform registers.
972
+
973
+ drawer.offsetHeight;
974
+ const pending = drawer.getAnimations().filter(a => a.playState !== 'finished');
975
+ if (pending.length === 0) {
976
+ fireDone();
977
+ return;
978
+ }
979
+ Promise.allSettled(pending.map(a => a.finished)).then(() => {
980
+ if (!canceled) fireDone();
981
+ });
982
+ });
983
+ return () => {
984
+ canceled = true;
985
+ window.cancelAnimationFrame(rafId);
986
+ };
987
+ }, [isOpen, descendants.length]);
988
+
989
+ // Definite-height flex layout (per-detent sizing) unless content must be
990
+ // measured in natural flow: 'auto' detents (without a plugged scrollable —
991
+ // those measure via `measureNaturalHeight`) and form-sheet content-fit sizing.
992
+ const useSizedLayout = (!hasAutoDetent || hasBoundedScrollable) && !isFormSheet;
993
+ const effectiveCornerRadius = cornerRadius ?? DEFAULT_CORNER_RADIUS;
994
+
995
+ // Shadow cast upward from the sheet's top edge toward the background. Matches
996
+ // Android's `elevation` semantics roughly — the sheet "lifts" off whatever is
997
+ // behind it. Scales linearly so higher elevation reads as more separation.
998
+ // Applied to the vaul wrapper (not the drawer) as `filter: drop-shadow`: the
999
+ // wrapper clips the drawer (overflow: hidden + contain: paint), which would
1000
+ // cut off `box-shadow` on the drawer at the wrapper edges — visible in
1001
+ // detached mode (bottom blur clipped in the floating gap) and when the
1002
+ // wrapper is narrowed by maxWidth/anchor margins (lateral blur clipped at
1003
+ // wrapper edges). drop-shadow on the wrapper follows the post-clip silhouette
1004
+ // and isn't clipped by the wrapper itself.
1005
+ const dropShadow = elevation > 0 ? `drop-shadow(0 ${-elevation}px ${elevation * 3}px rgba(0, 0, 0, 0.15))` : undefined;
1006
+ const mergedContentStyle = useMemo(() => ({
1007
+ position: 'fixed',
1008
+ top: 0,
1009
+ left: 0,
1010
+ right: 0,
1011
+ bottom: 0,
1012
+ display: 'flex',
1013
+ flexDirection: 'column',
1014
+ borderTopLeftRadius: effectiveCornerRadius,
1015
+ borderTopRightRadius: effectiveCornerRadius,
1016
+ backgroundColor: backgroundColor,
1017
+ // Clip children to the rounded top so headers/content with their own
1018
+ // background don't bleed past the corners. `clip` (not `hidden`): a
1019
+ // hidden box is still a scroll container, so browser focus-reveal (e.g.
1020
+ // tapping a button near the sheet bottom) can scroll-offset the drawer —
1021
+ // shifting content and blocking vaul's shouldDrag walk (scrollTop > 0).
1022
+ overflow: 'clip',
1023
+ // Lift content above iOS home indicator / bottom safe area when enabled.
1024
+ // A relative footer owns the inset instead (see resolvedFooterStyle); an
1025
+ // absolute footer floats over the content, so the content keeps its lift.
1026
+ // A plugged scrollable keeps the lift too (contentInsetAdjustmentBehavior,
1027
+ // default on) — disable it to scroll edge-to-edge behind the indicator
1028
+ // with user-applied content padding.
1029
+ paddingBottom: insetAdjustment === 'automatic' && !(footerOwnsInset && !absoluteFooter) && (!scrollableRef || (scrollableOptions?.contentInsetAdjustmentBehavior ?? true)) ? 'env(safe-area-inset-bottom, 0px)' : 0
1030
+ }), [backgroundColor, effectiveCornerRadius, insetAdjustment, footerOwnsInset, absoluteFooter, scrollableRef, scrollableOptions]);
1031
+ const defaultGrabberColor = colorScheme === 'dark' ? DEFAULT_GRABBER_COLOR_DARK : DEFAULT_GRABBER_COLOR_LIGHT;
1032
+ const grabberHeight = grabberOptions?.height ?? DEFAULT_GRABBER_HEIGHT;
1033
+
1034
+ // Footer is rendered inside the wrapper via `detachedSiblings`, so it
1035
+ // follows the wrapper on dismiss and drag-overshoot. Positioning is
1036
+ // relative to the wrapper (contain: paint creates the containing block).
1037
+ const footerFloatStyle = useMemo(() => ({
1038
+ position: 'fixed',
1039
+ left: 0,
1040
+ right: 0,
1041
+ bottom: 0,
1042
+ // Wrapper has `pointer-events: none` to let clicks fall through; the
1043
+ // footer must opt back in.
1044
+ pointerEvents: 'auto'
1045
+ }), []);
1046
+
1047
+ // Form-sheet style (presentation='form'): centered floating card with a
1048
+ // default width and a height fit to content. We reuse the existing detached
1049
+ // mechanic so drag/snap math stays correct — the wrapper is bottom-attached
1050
+ // with a computed offset (`effectiveDetachedOffset`, declared above) that
1051
+ // centers it vertically. `presentation` is absolute: when 'form',
1052
+ // `maxContentWidth` is ignored and the card uses DEFAULT_FORM_SHEET_WIDTH.
1053
+
1054
+ // The wrapper holds all horizontal sizing/anchoring so its rounded-bottom
1055
+ // clip (when detached) aligns with the drawer's horizontal bounds on
1056
+ // desktop — otherwise its corners sit at the far viewport edges.
1057
+ // - presentation='form' → DEFAULT_FORM_SHEET_WIDTH on tablet/landscape;
1058
+ // `maxContentWidth` is ignored ('form' is absolute).
1059
+ // - presentation='page' → `maxContentWidth` (any viewport) or
1060
+ // DEFAULT_MAX_WIDTH (tablet/landscape readability cap).
1061
+ // Detached without a width constraint applies anchorOffset on both edges so
1062
+ // the floating card breathes from the viewport sides.
1063
+ const wrapperStyle = useMemo(() => {
1064
+ // Mobile portrait ignores width sizing entirely (matches iOS/Android:
1065
+ // both apply `maxContentWidth` only when not on a portrait phone).
1066
+ // `detached` + `detachedOffset` are still respected via the wrapper.
1067
+ const maxWidth = isLandscapeOrTablet ? presentation === 'form' ? DEFAULT_FORM_SHEET_WIDTH : maxContentWidth ?? DEFAULT_MAX_WIDTH : undefined;
1068
+ const needsMargins = maxWidth != null || effectiveDetached;
1069
+ if (!needsMargins && !dropShadow) return undefined;
1070
+ const next = {};
1071
+ if (dropShadow) next.filter = dropShadow;
1072
+ if (!needsMargins) return next;
1073
+ let marginLeft;
1074
+ let marginRight;
1075
+ if (isFormSheet) {
1076
+ marginLeft = 'auto';
1077
+ marginRight = 'auto';
1078
+ } else if (maxWidth == null) {
1079
+ marginLeft = anchorOffset;
1080
+ marginRight = anchorOffset;
1081
+ } else {
1082
+ marginLeft = anchor === 'left' ? anchorOffset : 'auto';
1083
+ marginRight = anchor === 'right' ? anchorOffset : 'auto';
1084
+ }
1085
+ if (maxWidth != null) next.maxWidth = maxWidth;
1086
+ next.marginLeft = marginLeft;
1087
+ next.marginRight = marginRight;
1088
+ return next;
1089
+ }, [isLandscapeOrTablet, isFormSheet, maxContentWidth, presentation, anchor, anchorOffset, effectiveDetached, dropShadow]);
1090
+
1091
+ // Absolute-position the grabber so it overlays the content top-edge
1092
+ // instead of consuming flow height — mirrors native iOS/Android, where
1093
+ // the grabber sits in the rounded corner zone above the content and
1094
+ // doesn't push the header down or inflate the 'auto' detent measurement.
1095
+ const handleStyle = useMemo(() => ({
1096
+ position: 'absolute',
1097
+ top: grabberOptions?.topMargin ?? DEFAULT_GRABBER_TOP_MARGIN,
1098
+ left: '50%',
1099
+ transform: 'translateX(-50%)',
1100
+ height: grabberHeight,
1101
+ width: grabberOptions?.width ?? DEFAULT_GRABBER_WIDTH,
1102
+ borderRadius: grabberOptions?.cornerRadius ?? grabberHeight / 2,
1103
+ backgroundColor: grabberOptions?.color ?? defaultGrabberColor,
1104
+ opacity: 1,
1105
+ // Above absolute-positioned headers (which often use zIndex:1 to overlay
1106
+ // scroll content) so the grabber stays draggable — critical when
1107
+ // `handleOnly` mode means only the grabber can drag the sheet.
1108
+ zIndex: 2
1109
+ }), [grabberOptions, grabberHeight, defaultGrabberColor]);
1110
+ return /*#__PURE__*/_jsx(TrueSheetPeekContext.Provider, {
1111
+ value: peekContext,
1112
+ children: /*#__PURE__*/_jsx(Drawer.Root, {
1113
+ open: isOpen,
1114
+ onOpenChange: handleOpenChange,
1115
+ onPositionChange: handlePositionChange,
1116
+ onDrag: handleDrag,
1117
+ onRelease: handleRelease,
1118
+ dismissible: dismissible,
1119
+ onDismissAttempt: handleDismissAttempt,
1120
+ draggable: draggable,
1121
+ repositionInputs: false,
1122
+ modal: dimmed,
1123
+ nested: isNested,
1124
+ detached: effectiveDetached,
1125
+ detachedOffset: effectiveDetachedOffset,
1126
+ detachedRadius: effectiveCornerRadius,
1127
+ maxContentHeight: effectiveMaxContentHeight,
1128
+ peekHeight: peekHeight,
1129
+ initialAnimated: initialDetentAnimated,
1130
+ detachedWrapperStyle: wrapperStyle,
1131
+ onContentHeightChange: setMeasuredContentHeight,
1132
+ contentHeight:
1133
+ // Bounded scrollable → the auto-size wrapper measures 0 (sized
1134
+ // layout is absolute), so feed vaul the natural height instead.
1135
+ hasAutoDetent && hasBoundedScrollable && scrollableAutoHeight > 0 ? scrollableAutoHeight : undefined,
1136
+ activeSnapPoint: activeSnapPoint,
1137
+ setActiveSnapPoint: handleSetActiveSnapPoint,
1138
+ ...snapPointsProps,
1139
+ children: /*#__PURE__*/_jsxs(Drawer.Portal, {
1140
+ container: portalContainer ?? undefined,
1141
+ children: [/*#__PURE__*/_jsx(Drawer.Overlay, {
1142
+ style: overlayStyle
1143
+ }), /*#__PURE__*/_jsxs(Drawer.Content, {
1144
+ ref: drawerContentRef,
1145
+ style: mergedContentStyle,
1146
+ onPointerDownOutside: handlePointerDownOutside,
1147
+ detachedSiblings: footer && absoluteFooter ? /*#__PURE__*/_jsx("div", {
1148
+ style: footerFloatStyle,
1149
+ children: /*#__PURE__*/_jsx(View, {
1150
+ ref: footerElRef,
1151
+ style: resolvedFooterStyle,
1152
+ onLayout: handleFooterLayout,
1153
+ children: /*#__PURE__*/isValidElement(footer) ? footer : /*#__PURE__*/createElement(footer)
1154
+ })
1155
+ }) : undefined,
1156
+ children: [/*#__PURE__*/_jsx(Drawer.Title, {
1157
+ style: visuallyHiddenStyle,
1158
+ children: accessibilityOptions?.paneTitle ?? 'Sheet'
1159
+ }), grabber && /*#__PURE__*/_jsx(Drawer.Handle, {
1160
+ style: handleStyle
1161
+ }), useSizedLayout ?
1162
+ /*#__PURE__*/
1163
+ // vaul wraps children in `[data-vaul-auto-size-wrapper]` (display:
1164
+ // flow-root) which doesn't honor descendant flex layout. Use an
1165
+ // absolute fill sized to the visible portion (via vaul's
1166
+ // `--snap-point-height` var) so the inner flex column has a
1167
+ // definite height for flex layouts to fill — mirrors native, where
1168
+ // the container is sized to the sheet's visible height per detent.
1169
+ _jsxs("div", {
1170
+ ref: sizedLayoutRef,
1171
+ style: sizedLayoutStyle,
1172
+ "data-vaul-scroll-locked": isScrollLocked ? '' : undefined,
1173
+ children: [header && /*#__PURE__*/_jsx(View, {
1174
+ ref: headerElRef,
1175
+ style: resolvedHeaderStyle,
1176
+ onLayout: handleHeaderLayout,
1177
+ children: /*#__PURE__*/isValidElement(header) ? header : /*#__PURE__*/createElement(header)
1178
+ }), /*#__PURE__*/_jsx(View, {
1179
+ ref: contentRef,
1180
+ style: hasAutoDetent && hasBoundedScrollable ? [contentFillStyle, style] : style,
1181
+ onLayout: handleContentLayout,
1182
+ children: children
1183
+ }), footer && !absoluteFooter && /*#__PURE__*/_jsx(View, {
1184
+ ref: footerElRef,
1185
+ style: [relativeFooterStyle, resolvedFooterStyle],
1186
+ onLayout: handleFooterLayout,
1187
+ children: /*#__PURE__*/isValidElement(footer) ? footer : /*#__PURE__*/createElement(footer)
1188
+ })]
1189
+ }) :
1190
+ /*#__PURE__*/
1191
+ // Natural flow so vaul can measure content height — required for
1192
+ // 'auto' detents and form-sheet content-fit sizing.
1193
+ _jsxs(_Fragment, {
1194
+ children: [header && /*#__PURE__*/_jsx(View, {
1195
+ ref: headerElRef,
1196
+ style: resolvedHeaderStyle,
1197
+ onLayout: handleHeaderLayout,
1198
+ children: /*#__PURE__*/isValidElement(header) ? header : /*#__PURE__*/createElement(header)
1199
+ }), /*#__PURE__*/_jsx(View, {
1200
+ ref: contentRef,
1201
+ style: style,
1202
+ onLayout: handleContentLayout,
1203
+ children: children
1204
+ }), footer && !absoluteFooter && /*#__PURE__*/_jsx(View, {
1205
+ ref: footerElRef,
1206
+ style: resolvedFooterStyle,
1207
+ onLayout: handleFooterLayout,
1208
+ children: /*#__PURE__*/isValidElement(footer) ? footer : /*#__PURE__*/createElement(footer)
1209
+ })]
1210
+ })]
1211
+ })]
1212
+ })
1213
+ })
1214
+ });
1215
+ });
1216
+ const overlayStyle = {
1217
+ position: 'fixed',
1218
+ inset: 0,
1219
+ backgroundColor: 'rgba(0, 0, 0, 0.5)'
1220
+ };
1221
+
1222
+ // Pinned to the sheet's bottom edge — takes up layout space below the content
1223
+ const relativeFooterStyle = {
1224
+ marginTop: 'auto'
1225
+ };
1226
+
1227
+ // Floats over the content so it doesn't take up layout space
1228
+ const absoluteHeaderStyle = {
1229
+ position: 'absolute',
1230
+ top: 0,
1231
+ left: 0,
1232
+ right: 0,
1233
+ zIndex: 1
1234
+ };
1235
+ const SIZED_LAYOUT_HEIGHT = 'calc(100% - var(--snap-point-height, 0px))';
1236
+ const sizedLayoutStyle = {
1237
+ position: 'absolute',
1238
+ top: 0,
1239
+ left: 0,
1240
+ right: 0,
1241
+ height: SIZED_LAYOUT_HEIGHT,
1242
+ display: 'flex',
1243
+ flexDirection: 'column'
1244
+ };
1245
+ const contentFillStyle = {
1246
+ flex: 1,
1247
+ minHeight: 0
1248
+ };
1249
+ const visuallyHiddenStyle = {
1250
+ position: 'absolute',
1251
+ width: 1,
1252
+ height: 1,
1253
+ padding: 0,
1254
+ margin: -1,
1255
+ overflow: 'hidden',
1256
+ clip: 'rect(0, 0, 0, 0)',
1257
+ whiteSpace: 'nowrap',
1258
+ border: 0
1259
+ };
1260
+ const STATIC_METHOD_ERROR = 'Static methods are not supported on web. Use the useTrueSheet() hook instead.';
1261
+ export const TrueSheet = TrueSheetComponent;
1262
+ const rejectStatic = async () => {
1263
+ throw new Error(STATIC_METHOD_ERROR);
1264
+ };
1265
+ TrueSheet.present = rejectStatic;
1266
+ TrueSheet.dismiss = rejectStatic;
1267
+ TrueSheet.dismissStack = rejectStatic;
1268
+ TrueSheet.resize = rejectStatic;
1269
+ TrueSheet.dismissAll = rejectStatic;
1270
+ //# sourceMappingURL=TrueSheet.web.js.map