react-panel-layout 0.6.0 → 0.7.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 (258) hide show
  1. package/dist/{FloatingPanelFrame-SgYLc6Ud.js → FloatingPanelFrame-3eU9AwPo.js} +2 -2
  2. package/dist/{FloatingPanelFrame-SgYLc6Ud.js.map → FloatingPanelFrame-3eU9AwPo.js.map} +1 -1
  3. package/dist/FloatingWindow-Bw2djgpz.js +1542 -0
  4. package/dist/FloatingWindow-Bw2djgpz.js.map +1 -0
  5. package/dist/FloatingWindow-Cvyokf0m.cjs +2 -0
  6. package/dist/FloatingWindow-Cvyokf0m.cjs.map +1 -0
  7. package/dist/GridLayout-B4aCqSyd.js +947 -0
  8. package/dist/{GridLayout-BltqeCPK.js.map → GridLayout-B4aCqSyd.js.map} +1 -1
  9. package/dist/GridLayout-DNOClFzz.cjs +2 -0
  10. package/dist/{GridLayout-B4VRsC0r.cjs.map → GridLayout-DNOClFzz.cjs.map} +1 -1
  11. package/dist/{HorizontalDivider-WF1k_qND.js → HorizontalDivider-DdxzfV0l.js} +3 -3
  12. package/dist/{HorizontalDivider-WF1k_qND.js.map → HorizontalDivider-DdxzfV0l.js.map} +1 -1
  13. package/dist/{HorizontalDivider-B5Z-KZLk.cjs → HorizontalDivider-_pgV4Mcv.cjs} +2 -2
  14. package/dist/{HorizontalDivider-B5Z-KZLk.cjs.map → HorizontalDivider-_pgV4Mcv.cjs.map} +1 -1
  15. package/dist/PanelSystem-B8Igvnb2.cjs +3 -0
  16. package/dist/PanelSystem-B8Igvnb2.cjs.map +1 -0
  17. package/dist/{PanelSystem-Dr1TBhxM.js → PanelSystem-DDUSFjXD.js} +209 -248
  18. package/dist/PanelSystem-DDUSFjXD.js.map +1 -0
  19. package/dist/ResizeHandle-CBcAS918.cjs +2 -0
  20. package/dist/{ResizeHandle-CScipO5l.cjs.map → ResizeHandle-CBcAS918.cjs.map} +1 -1
  21. package/dist/{ResizeHandle-CdA_JYfN.js → ResizeHandle-CXjc1meV.js} +28 -29
  22. package/dist/{ResizeHandle-CdA_JYfN.js.map → ResizeHandle-CXjc1meV.js.map} +1 -1
  23. package/dist/SwipePivotTabBar-DWrCuwEI.js +411 -0
  24. package/dist/SwipePivotTabBar-DWrCuwEI.js.map +1 -0
  25. package/dist/SwipePivotTabBar-fjjXkpj7.cjs +2 -0
  26. package/dist/SwipePivotTabBar-fjjXkpj7.cjs.map +1 -0
  27. package/dist/components/gesture/SwipeSafeZone.d.ts +40 -0
  28. package/dist/components/window/Drawer.d.ts +4 -1
  29. package/dist/components/window/DrawerLayers.d.ts +1 -1
  30. package/dist/components/window/DrawerRevealContext.d.ts +61 -0
  31. package/dist/components/window/drawerRevealAnimationUtils.d.ts +212 -0
  32. package/dist/components/window/drawerStyles.d.ts +74 -0
  33. package/dist/components/window/drawerSwipeConfig.d.ts +29 -0
  34. package/dist/components/window/useDrawerSwipeTransform.d.ts +29 -0
  35. package/dist/components/window/useDrawerTransform.d.ts +68 -0
  36. package/dist/components/window/useRevealDrawerTransform.d.ts +56 -0
  37. package/dist/config.cjs +1 -1
  38. package/dist/config.cjs.map +1 -1
  39. package/dist/config.js +9 -8
  40. package/dist/config.js.map +1 -1
  41. package/dist/constants/styles.d.ts +17 -0
  42. package/dist/dialog/index.d.ts +69 -0
  43. package/dist/floating.js +1 -1
  44. package/dist/grid.cjs +1 -1
  45. package/dist/grid.js +2 -2
  46. package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +7 -0
  47. package/dist/hooks/gesture/types.d.ts +48 -5
  48. package/dist/hooks/gesture/utils.d.ts +19 -0
  49. package/dist/hooks/useAnimationFrame.d.ts +2 -0
  50. package/dist/hooks/useOperationContinuity.d.ts +64 -0
  51. package/dist/hooks/useResizeObserver.d.ts +33 -1
  52. package/dist/hooks/useSharedElementTransition.d.ts +112 -0
  53. package/dist/hooks/useSwipeContentTransform.d.ts +9 -2
  54. package/dist/index.cjs +1 -1
  55. package/dist/index.js +7 -7
  56. package/dist/modules/dialog/AlertDialog.d.ts +9 -0
  57. package/dist/modules/dialog/DialogContainer.d.ts +37 -0
  58. package/dist/modules/dialog/Modal.d.ts +26 -0
  59. package/dist/modules/dialog/SwipeDialogContainer.d.ts +16 -0
  60. package/dist/modules/dialog/dialogAnimationUtils.d.ts +113 -0
  61. package/dist/modules/dialog/types.d.ts +183 -0
  62. package/dist/modules/dialog/useDialog.d.ts +39 -0
  63. package/dist/modules/dialog/useDialogContainer.d.ts +47 -0
  64. package/dist/modules/dialog/useDialogSwipeInput.d.ts +70 -0
  65. package/dist/modules/dialog/useDialogTransform.d.ts +82 -0
  66. package/dist/modules/drawer/drawerStateMachine.d.ts +168 -0
  67. package/dist/modules/drawer/revealDrawerConstants.d.ts +33 -0
  68. package/dist/modules/drawer/revealDrawerStateMachine.d.ts +146 -0
  69. package/dist/modules/drawer/strategies/index.d.ts +8 -0
  70. package/dist/modules/drawer/strategies/overlayStrategy.d.ts +12 -0
  71. package/dist/modules/drawer/strategies/revealStrategy.d.ts +12 -0
  72. package/dist/modules/drawer/strategies/types.d.ts +116 -0
  73. package/dist/modules/drawer/types.d.ts +74 -0
  74. package/dist/modules/drawer/useDrawerSwipeInput.d.ts +24 -0
  75. package/dist/modules/pivot/SwipePivotTabBar.d.ts +3 -0
  76. package/dist/modules/stack/SwipeStackContent.d.ts +6 -3
  77. package/dist/modules/stack/SwipeStackOutlet.d.ts +4 -4
  78. package/dist/modules/stack/computeSwipeStackTransform.d.ts +1 -1
  79. package/dist/panels.cjs +1 -1
  80. package/dist/panels.js +1 -1
  81. package/dist/pivot.cjs +1 -1
  82. package/dist/pivot.js +1 -1
  83. package/dist/resizer.cjs +1 -1
  84. package/dist/resizer.js +2 -2
  85. package/dist/stack.cjs +1 -1
  86. package/dist/stack.cjs.map +1 -1
  87. package/dist/stack.js +480 -780
  88. package/dist/stack.js.map +1 -1
  89. package/dist/sticky-header/calculateStickyMetrics.d.ts +28 -0
  90. package/dist/sticky-header.cjs +1 -1
  91. package/dist/sticky-header.cjs.map +1 -1
  92. package/dist/sticky-header.js +59 -51
  93. package/dist/sticky-header.js.map +1 -1
  94. package/dist/{styles-DPPuJ0sf.js → styles-NkjuMOVS.js} +13 -13
  95. package/dist/{styles-DPPuJ0sf.js.map → styles-NkjuMOVS.js.map} +1 -1
  96. package/dist/styles-qf6ptVLD.cjs.map +1 -1
  97. package/dist/types.d.ts +30 -0
  98. package/dist/useAnimationFrame-BZ6D2lMq.cjs +2 -0
  99. package/dist/useAnimationFrame-BZ6D2lMq.cjs.map +1 -0
  100. package/dist/useAnimationFrame-Bg4e-H8O.js +394 -0
  101. package/dist/useAnimationFrame-Bg4e-H8O.js.map +1 -0
  102. package/dist/useDocumentPointerEvents-DXxw3qWj.js +54 -0
  103. package/dist/useDocumentPointerEvents-DXxw3qWj.js.map +1 -0
  104. package/dist/useDocumentPointerEvents-DxDSOtip.cjs +2 -0
  105. package/dist/useDocumentPointerEvents-DxDSOtip.cjs.map +1 -0
  106. package/dist/window/index.d.ts +2 -0
  107. package/dist/window.cjs +1 -1
  108. package/dist/window.cjs.map +1 -1
  109. package/dist/window.js +114 -103
  110. package/dist/window.js.map +1 -1
  111. package/package.json +6 -1
  112. package/src/components/gesture/SwipeSafeZone.tsx +70 -0
  113. package/src/components/grid/GridLayout.tsx +110 -38
  114. package/src/components/window/Drawer.tsx +353 -162
  115. package/src/components/window/DrawerLayers.tsx +54 -11
  116. package/src/components/window/DrawerRevealContext.spec.ts +20 -0
  117. package/src/components/window/DrawerRevealContext.tsx +99 -0
  118. package/src/components/window/drawerRevealAnimationUtils.spec.ts +375 -0
  119. package/src/components/window/drawerRevealAnimationUtils.ts +415 -0
  120. package/src/components/window/drawerStyles.spec.ts +302 -0
  121. package/src/components/window/drawerStyles.ts +252 -0
  122. package/src/components/window/drawerSwipeConfig.spec.ts +131 -0
  123. package/src/components/window/drawerSwipeConfig.ts +112 -0
  124. package/src/components/window/useDrawerSwipeTransform.ts +67 -0
  125. package/src/components/window/useDrawerTransform.ts +505 -0
  126. package/src/components/window/useRevealDrawerTransform.spec.ts +1936 -0
  127. package/src/components/window/useRevealDrawerTransform.ts +105 -0
  128. package/src/constants/styles.ts +19 -0
  129. package/src/demo/components/FullscreenDemoPage.tsx +47 -0
  130. package/src/demo/fullscreenRoutes.tsx +32 -0
  131. package/src/demo/index.tsx +5 -0
  132. package/src/demo/pages/Dialog/alerts/index.tsx +22 -0
  133. package/src/demo/pages/Dialog/card/index.tsx +22 -0
  134. package/src/demo/pages/Dialog/components/AlertDialogDemo.tsx +124 -0
  135. package/src/demo/pages/Dialog/components/CardExpandDemo.module.css +243 -0
  136. package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +219 -0
  137. package/src/demo/pages/Dialog/components/CustomAlertDialogDemo.tsx +219 -0
  138. package/src/demo/pages/Dialog/components/DialogDemos.module.css +77 -0
  139. package/src/demo/pages/Dialog/components/ModalBasics.tsx +45 -0
  140. package/src/demo/pages/Dialog/components/SwipeDialogDemo.module.css +77 -0
  141. package/src/demo/pages/Dialog/components/SwipeDialogDemo.tsx +181 -0
  142. package/src/demo/pages/Dialog/custom-alert/index.tsx +22 -0
  143. package/src/demo/pages/Dialog/modal/index.tsx +17 -0
  144. package/src/demo/pages/Dialog/swipe/index.tsx +22 -0
  145. package/src/demo/pages/Drawer/components/DrawerBasics.module.css +6 -1
  146. package/src/demo/pages/Drawer/components/DrawerBasics.tsx +14 -4
  147. package/src/demo/pages/Drawer/components/DrawerReveal.module.css +157 -0
  148. package/src/demo/pages/Drawer/components/DrawerReveal.tsx +128 -0
  149. package/src/demo/pages/Drawer/components/DrawerSwipe.module.css +316 -0
  150. package/src/demo/pages/Drawer/components/DrawerSwipe.tsx +178 -0
  151. package/src/demo/pages/Drawer/reveal/index.tsx +17 -0
  152. package/src/demo/pages/Drawer/reveal-fullscreen/index.tsx +135 -0
  153. package/src/demo/pages/Drawer/reveal-fullscreen/styles.module.css +233 -0
  154. package/src/demo/pages/Drawer/swipe/index.tsx +17 -0
  155. package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +54 -23
  156. package/src/demo/pages/Pivot/swipe-debug/index.tsx +1 -1
  157. package/src/demo/pages/Stack/components/StackBasics.spec.tsx +156 -0
  158. package/src/demo/pages/Stack/components/StackBasics.tsx +179 -95
  159. package/src/demo/pages/Stack/components/StackTablet.spec.tsx +110 -0
  160. package/src/demo/pages/Stack/components/StackTablet.tsx +42 -21
  161. package/src/demo/routes.tsx +24 -1
  162. package/src/dialog/index.ts +85 -0
  163. package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +68 -64
  164. package/src/hooks/gesture/testing/createGestureSimulator.ts +113 -37
  165. package/src/hooks/gesture/types.ts +83 -6
  166. package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +22 -14
  167. package/src/hooks/gesture/useNativeGestureGuard.spec.ts +99 -31
  168. package/src/hooks/gesture/useNativeGestureGuard.ts +3 -1
  169. package/src/hooks/gesture/utils.ts +102 -0
  170. package/src/hooks/useAnimatedVisibility.spec.ts +44 -24
  171. package/src/hooks/useAnimatedVisibility.ts +28 -2
  172. package/src/hooks/useAnimationFrame.ts +8 -0
  173. package/src/hooks/useOperationContinuity.spec.ts +394 -0
  174. package/src/hooks/useOperationContinuity.ts +135 -0
  175. package/src/hooks/useResizeObserver.spec.tsx +277 -0
  176. package/src/hooks/useResizeObserver.tsx +108 -39
  177. package/src/hooks/useScrollContainer.ts +4 -10
  178. package/src/hooks/useSharedElementTransition.ts +354 -0
  179. package/src/hooks/useSwipeContentTransform.spec.ts +18 -18
  180. package/src/hooks/useSwipeContentTransform.ts +166 -28
  181. package/src/modules/dialog/AlertDialog.spec.tsx +387 -0
  182. package/src/modules/dialog/AlertDialog.tsx +221 -0
  183. package/src/modules/dialog/DialogContainer.spec.tsx +228 -0
  184. package/src/modules/dialog/DialogContainer.tsx +188 -0
  185. package/src/modules/dialog/Modal.spec.tsx +220 -0
  186. package/src/modules/dialog/Modal.tsx +182 -0
  187. package/src/modules/dialog/SwipeDialogContainer.tsx +208 -0
  188. package/src/modules/dialog/dialogAnimationUtils.spec.ts +252 -0
  189. package/src/modules/dialog/dialogAnimationUtils.ts +297 -0
  190. package/src/modules/dialog/types.ts +186 -0
  191. package/src/modules/dialog/useDialog.spec.tsx +447 -0
  192. package/src/modules/dialog/useDialog.ts +214 -0
  193. package/src/modules/dialog/useDialogContainer.spec.ts +339 -0
  194. package/src/modules/dialog/useDialogContainer.ts +150 -0
  195. package/src/modules/dialog/useDialogSwipeInput.spec.ts +178 -0
  196. package/src/modules/dialog/useDialogSwipeInput.ts +350 -0
  197. package/src/modules/dialog/useDialogTransform.spec.ts +403 -0
  198. package/src/modules/dialog/useDialogTransform.ts +407 -0
  199. package/src/modules/drawer/drawerStateMachine.ts +500 -0
  200. package/src/modules/drawer/revealDrawerConstants.ts +38 -0
  201. package/src/modules/drawer/revealDrawerStateMachine.spec.ts +558 -0
  202. package/src/modules/drawer/revealDrawerStateMachine.ts +197 -0
  203. package/src/modules/drawer/strategies/index.ts +9 -0
  204. package/src/modules/drawer/strategies/overlayStrategy.ts +133 -0
  205. package/src/modules/drawer/strategies/revealStrategy.ts +111 -0
  206. package/src/modules/drawer/strategies/types.ts +160 -0
  207. package/src/modules/drawer/types.ts +102 -0
  208. package/src/modules/drawer/useDrawerSwipeInput.spec.ts +566 -0
  209. package/src/modules/drawer/useDrawerSwipeInput.ts +402 -0
  210. package/src/modules/panels/rendering/ContentRegistry.spec.tsx +21 -14
  211. package/src/modules/pivot/SwipePivotContent.position.spec.tsx +12 -8
  212. package/src/modules/pivot/SwipePivotContent.spec.tsx +66 -25
  213. package/src/modules/pivot/SwipePivotContent.tsx +2 -2
  214. package/src/modules/pivot/SwipePivotTabBar.spec.tsx +85 -68
  215. package/src/modules/pivot/SwipePivotTabBar.tsx +75 -15
  216. package/src/modules/pivot/scaleInputState.spec.ts +11 -2
  217. package/src/modules/pivot/usePivot.spec.ts +17 -3
  218. package/src/modules/pivot/usePivotSwipeInput.spec.ts +182 -123
  219. package/src/modules/stack/SwipeStackContent.spec.tsx +387 -100
  220. package/src/modules/stack/SwipeStackContent.tsx +43 -33
  221. package/src/modules/stack/SwipeStackOutlet.spec.tsx +14 -16
  222. package/src/modules/stack/SwipeStackOutlet.tsx +6 -6
  223. package/src/modules/stack/computeSwipeStackTransform.spec.ts +5 -5
  224. package/src/modules/stack/computeSwipeStackTransform.ts +3 -3
  225. package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1133 -0
  226. package/src/modules/stack/useStackAnimationState.spec.ts +3 -1
  227. package/src/modules/stack/useStackAnimationState.ts +18 -13
  228. package/src/modules/stack/useStackNavigation.spec.ts +198 -3
  229. package/src/modules/stack/useStackNavigation.tsx +113 -56
  230. package/src/modules/stack/useStackSwipeInput.spec.ts +65 -32
  231. package/src/modules/stack/useStackSwipeInput.ts +1 -1
  232. package/src/sticky-header/StickyArea.tsx +29 -57
  233. package/src/sticky-header/calculateStickyMetrics.spec.ts +105 -0
  234. package/src/sticky-header/calculateStickyMetrics.ts +50 -0
  235. package/src/types.ts +33 -0
  236. package/src/window/index.ts +2 -0
  237. package/dist/FloatingWindow-BpdOpg_L.js +0 -400
  238. package/dist/FloatingWindow-BpdOpg_L.js.map +0 -1
  239. package/dist/FloatingWindow-TCDNY5gE.cjs +0 -2
  240. package/dist/FloatingWindow-TCDNY5gE.cjs.map +0 -1
  241. package/dist/GridLayout-B4VRsC0r.cjs +0 -2
  242. package/dist/GridLayout-BltqeCPK.js +0 -927
  243. package/dist/PanelSystem-Bs8bQwQF.cjs +0 -3
  244. package/dist/PanelSystem-Bs8bQwQF.cjs.map +0 -1
  245. package/dist/PanelSystem-Dr1TBhxM.js.map +0 -1
  246. package/dist/ResizeHandle-CScipO5l.cjs +0 -2
  247. package/dist/SwipePivotTabBar-BGO9X94m.js +0 -407
  248. package/dist/SwipePivotTabBar-BGO9X94m.js.map +0 -1
  249. package/dist/SwipePivotTabBar-BrQismcZ.cjs +0 -2
  250. package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +0 -1
  251. package/dist/useDocumentPointerEvents-CKdhGXd0.js +0 -46
  252. package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +0 -1
  253. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +0 -2
  254. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +0 -1
  255. package/dist/useEffectEvent-Dp7HLCf0.js +0 -13
  256. package/dist/useEffectEvent-Dp7HLCf0.js.map +0 -1
  257. package/dist/useEffectEvent-huSsGUnl.cjs +0 -2
  258. package/dist/useEffectEvent-huSsGUnl.cjs.map +0 -1
@@ -0,0 +1,252 @@
1
+ /**
2
+ * @file Drawer style computation utilities.
3
+ *
4
+ * Provides pure functions for computing drawer styles based on configuration.
5
+ */
6
+ import type * as React from "react";
7
+ import type { DrawerBehavior } from "../../types.js";
8
+ import {
9
+ COLOR_DRAWER_BACKDROP,
10
+ DRAWER_TRANSITION_DURATION,
11
+ DRAWER_TRANSITION_EASING,
12
+ } from "../../constants/styles.js";
13
+
14
+ /**
15
+ * Base backdrop style shared by backdrop and edge zone.
16
+ */
17
+ export const DRAWER_BACKDROP_BASE_STYLE: React.CSSProperties = {
18
+ position: "fixed",
19
+ inset: 0,
20
+ background: COLOR_DRAWER_BACKDROP,
21
+ };
22
+
23
+ /**
24
+ * Base drawer panel style.
25
+ */
26
+ export const DRAWER_PANEL_BASE_STYLE: React.CSSProperties = {
27
+ willChange: "transform",
28
+ };
29
+
30
+ /**
31
+ * Placement-specific styles for drawer positioning.
32
+ */
33
+ export type DrawerPlacement = "left" | "right" | "top" | "bottom";
34
+
35
+ const PLACEMENT_STYLES: Record<DrawerPlacement, React.CSSProperties> = {
36
+ left: {
37
+ top: 0,
38
+ bottom: 0,
39
+ left: 0,
40
+ transform: "translateX(-100%)",
41
+ },
42
+ right: {
43
+ top: 0,
44
+ bottom: 0,
45
+ right: 0,
46
+ transform: "translateX(100%)",
47
+ },
48
+ top: {
49
+ top: 0,
50
+ left: 0,
51
+ right: 0,
52
+ transform: "translateY(-100%)",
53
+ },
54
+ bottom: {
55
+ bottom: 0,
56
+ left: 0,
57
+ right: 0,
58
+ transform: "translateY(100%)",
59
+ },
60
+ };
61
+
62
+ const OPEN_TRANSFORMS: Record<DrawerPlacement, string> = {
63
+ left: "translateX(0)",
64
+ right: "translateX(0)",
65
+ top: "translateY(0)",
66
+ bottom: "translateY(0)",
67
+ };
68
+
69
+ /**
70
+ * Reveal mode: drawer starts partially hidden and slides in with content.
71
+ * This creates a "pull out" effect rather than just content sliding away.
72
+ */
73
+ const REVEAL_CLOSED_OFFSET_PERCENT = 30;
74
+
75
+ const REVEAL_CLOSED_TRANSFORMS: Record<DrawerPlacement, string> = {
76
+ left: `translateX(-${REVEAL_CLOSED_OFFSET_PERCENT}%)`,
77
+ right: `translateX(${REVEAL_CLOSED_OFFSET_PERCENT}%)`,
78
+ top: `translateY(-${REVEAL_CLOSED_OFFSET_PERCENT}%)`,
79
+ bottom: `translateY(${REVEAL_CLOSED_OFFSET_PERCENT}%)`,
80
+ };
81
+
82
+ /**
83
+ * Get placement-specific style.
84
+ */
85
+ export function getPlacementStyle(placement: DrawerPlacement): React.CSSProperties {
86
+ return PLACEMENT_STYLES[placement];
87
+ }
88
+
89
+ /**
90
+ * Get transform value for open state.
91
+ */
92
+ export function getOpenTransform(placement: DrawerPlacement): string {
93
+ return OPEN_TRANSFORMS[placement];
94
+ }
95
+
96
+ /**
97
+ * Get closed transform value.
98
+ */
99
+ export function getClosedTransform(placement: DrawerPlacement): string {
100
+ return PLACEMENT_STYLES[placement].transform as string;
101
+ }
102
+
103
+ /**
104
+ * Get reveal mode transform based on open state.
105
+ * When closed, drawer is partially hidden. When open, fully visible.
106
+ */
107
+ export function getRevealTransform(placement: DrawerPlacement, isOpen: boolean): string {
108
+ if (isOpen) {
109
+ return OPEN_TRANSFORMS[placement];
110
+ }
111
+ return REVEAL_CLOSED_TRANSFORMS[placement];
112
+ }
113
+
114
+ /**
115
+ * Compute CSS transition value.
116
+ */
117
+ export function computeTransitionValue(
118
+ mode: DrawerBehavior["transitionMode"] | undefined,
119
+ duration: DrawerBehavior["transitionDuration"],
120
+ easing: DrawerBehavior["transitionEasing"],
121
+ ): string | undefined {
122
+ if (mode === "none") {
123
+ return undefined;
124
+ }
125
+
126
+ const durationValue = duration ?? DRAWER_TRANSITION_DURATION;
127
+ const easingValue = easing ?? DRAWER_TRANSITION_EASING;
128
+
129
+ return `transform ${durationValue} ${easingValue}`;
130
+ }
131
+
132
+ /**
133
+ * Compute backdrop transition value.
134
+ */
135
+ export function computeBackdropTransition(
136
+ mode: DrawerBehavior["transitionMode"] | undefined,
137
+ duration: DrawerBehavior["transitionDuration"],
138
+ ): string | undefined {
139
+ if (mode === "none") {
140
+ return undefined;
141
+ }
142
+ return `opacity ${duration ?? "220ms"} ease`;
143
+ }
144
+
145
+ /**
146
+ * Check if placement is horizontal (left/right).
147
+ */
148
+ export function isHorizontalPlacement(placement: DrawerPlacement): boolean {
149
+ return placement === "left" || placement === "right";
150
+ }
151
+
152
+ /**
153
+ * Format dimension value to CSS string.
154
+ */
155
+ export function formatDimension(value: string | number | undefined): string | undefined {
156
+ if (value === undefined) {
157
+ return undefined;
158
+ }
159
+ if (typeof value === "number") {
160
+ return `${value}px`;
161
+ }
162
+ return value;
163
+ }
164
+
165
+ // ============================================================================
166
+ // Edge Zone Styles
167
+ // ============================================================================
168
+
169
+ /**
170
+ * Options for computing edge zone style.
171
+ */
172
+ export type EdgeZoneStyleOptions = {
173
+ placement: DrawerPlacement;
174
+ inline: boolean;
175
+ edgeWidth: number;
176
+ zIndex: number | undefined;
177
+ };
178
+
179
+ /**
180
+ * Compute edge zone style based on placement and positioning context.
181
+ *
182
+ * The edge zone is positioned at the edge where the drawer appears from:
183
+ * - left drawer: left edge of the container
184
+ * - right drawer: right edge of the container
185
+ * - top drawer: top edge of the container
186
+ * - bottom drawer: bottom edge of the container
187
+ *
188
+ * When inline=true, uses absolute positioning (relative to parent container).
189
+ * When inline=false, uses fixed positioning (relative to viewport).
190
+ */
191
+ export function computeEdgeZoneStyle(options: EdgeZoneStyleOptions): React.CSSProperties {
192
+ const { placement, inline, edgeWidth, zIndex } = options;
193
+ const position = inline ? "absolute" : "fixed";
194
+ const computedZIndex = zIndex !== undefined ? zIndex - 2 : 1000;
195
+
196
+ return getEdgeZoneStyleByPlacement(placement, position, edgeWidth, computedZIndex);
197
+ }
198
+
199
+ function getEdgeZoneStyleByPlacement(
200
+ placement: DrawerPlacement,
201
+ position: "absolute" | "fixed",
202
+ edgeWidth: number,
203
+ zIndex: number,
204
+ ): React.CSSProperties {
205
+ // Common base style
206
+ const base: React.CSSProperties = {
207
+ position,
208
+ zIndex,
209
+ background: "transparent",
210
+ pointerEvents: "auto",
211
+ };
212
+
213
+ // Placement-specific positioning
214
+ if (placement === "left") {
215
+ return {
216
+ ...base,
217
+ top: 0,
218
+ bottom: 0,
219
+ left: 0,
220
+ width: edgeWidth,
221
+ };
222
+ }
223
+
224
+ if (placement === "right") {
225
+ return {
226
+ ...base,
227
+ top: 0,
228
+ bottom: 0,
229
+ right: 0,
230
+ width: edgeWidth,
231
+ };
232
+ }
233
+
234
+ if (placement === "top") {
235
+ return {
236
+ ...base,
237
+ top: 0,
238
+ left: 0,
239
+ right: 0,
240
+ height: edgeWidth,
241
+ };
242
+ }
243
+
244
+ // bottom
245
+ return {
246
+ ...base,
247
+ bottom: 0,
248
+ left: 0,
249
+ right: 0,
250
+ height: edgeWidth,
251
+ };
252
+ }
@@ -0,0 +1,131 @@
1
+ /**
2
+ * @file Tests for drawerSwipeConfig utilities.
3
+ */
4
+ import {
5
+ parseSwipeGesturesConfig,
6
+ resolvePlacement,
7
+ shouldShowEdgeZone,
8
+ } from "./drawerSwipeConfig.js";
9
+
10
+ describe("drawerSwipeConfig", () => {
11
+ describe("parseSwipeGesturesConfig", () => {
12
+ it("returns disabled config for false", () => {
13
+ const config = parseSwipeGesturesConfig(false);
14
+ expect(config.enabled).toBe(false);
15
+ expect(config.edgeSwipeOpen).toBe(false);
16
+ expect(config.swipeClose).toBe(false);
17
+ });
18
+
19
+ it("returns disabled config for undefined", () => {
20
+ const config = parseSwipeGesturesConfig(undefined);
21
+ expect(config.enabled).toBe(false);
22
+ });
23
+
24
+ it("returns enabled defaults for true", () => {
25
+ const config = parseSwipeGesturesConfig(true);
26
+ expect(config.enabled).toBe(true);
27
+ expect(config.edgeSwipeOpen).toBe(true);
28
+ expect(config.swipeClose).toBe(true);
29
+ expect(config.edgeWidth).toBe(20);
30
+ expect(config.dismissThreshold).toBe(0.3);
31
+ });
32
+
33
+ it("parses object config with defaults", () => {
34
+ const config = parseSwipeGesturesConfig({});
35
+ expect(config.enabled).toBe(true);
36
+ expect(config.edgeSwipeOpen).toBe(true);
37
+ expect(config.swipeClose).toBe(true);
38
+ });
39
+
40
+ it("respects object config overrides", () => {
41
+ const config = parseSwipeGesturesConfig({
42
+ edgeSwipeOpen: false,
43
+ swipeClose: true,
44
+ edgeWidth: 40,
45
+ dismissThreshold: 0.5,
46
+ });
47
+ expect(config.enabled).toBe(true);
48
+ expect(config.edgeSwipeOpen).toBe(false);
49
+ expect(config.swipeClose).toBe(true);
50
+ expect(config.edgeWidth).toBe(40);
51
+ expect(config.dismissThreshold).toBe(0.5);
52
+ });
53
+ });
54
+
55
+ describe("resolvePlacement", () => {
56
+ it("returns anchor if provided", () => {
57
+ expect(resolvePlacement("left", undefined)).toBe("left");
58
+ expect(resolvePlacement("right", { left: 0 })).toBe("right");
59
+ });
60
+
61
+ it("returns right as default when no anchor or position", () => {
62
+ expect(resolvePlacement(undefined, undefined)).toBe("right");
63
+ });
64
+
65
+ it("infers left from position.left", () => {
66
+ expect(resolvePlacement(undefined, { left: 0 })).toBe("left");
67
+ });
68
+
69
+ it("infers right from position.right", () => {
70
+ expect(resolvePlacement(undefined, { right: 0 })).toBe("right");
71
+ });
72
+
73
+ it("infers top from position.top", () => {
74
+ expect(resolvePlacement(undefined, { top: 0 })).toBe("top");
75
+ });
76
+
77
+ it("infers bottom from position.bottom", () => {
78
+ expect(resolvePlacement(undefined, { bottom: 0 })).toBe("bottom");
79
+ });
80
+
81
+ it("prioritizes left over other positions", () => {
82
+ expect(resolvePlacement(undefined, { left: 0, right: 0 })).toBe("left");
83
+ });
84
+ });
85
+
86
+ describe("shouldShowEdgeZone", () => {
87
+ const enabledConfig = {
88
+ enabled: true,
89
+ edgeSwipeOpen: true,
90
+ swipeClose: true,
91
+ edgeWidth: 20,
92
+ dismissThreshold: 0.3,
93
+ };
94
+
95
+ const disabledConfig = {
96
+ enabled: false,
97
+ edgeSwipeOpen: false,
98
+ swipeClose: false,
99
+ edgeWidth: 20,
100
+ dismissThreshold: 0.3,
101
+ };
102
+
103
+ const noEdgeSwipeConfig = {
104
+ enabled: true,
105
+ edgeSwipeOpen: false,
106
+ swipeClose: true,
107
+ edgeWidth: 20,
108
+ dismissThreshold: 0.3,
109
+ };
110
+
111
+ it("returns false when config is disabled", () => {
112
+ expect(shouldShowEdgeZone(disabledConfig, false, false)).toBe(false);
113
+ });
114
+
115
+ it("returns false when edgeSwipeOpen is disabled", () => {
116
+ expect(shouldShowEdgeZone(noEdgeSwipeConfig, false, false)).toBe(false);
117
+ });
118
+
119
+ it("returns true when drawer is closed", () => {
120
+ expect(shouldShowEdgeZone(enabledConfig, false, false)).toBe(true);
121
+ });
122
+
123
+ it("returns true when actively opening", () => {
124
+ expect(shouldShowEdgeZone(enabledConfig, true, true)).toBe(true);
125
+ });
126
+
127
+ it("returns false when drawer is open and not opening", () => {
128
+ expect(shouldShowEdgeZone(enabledConfig, true, false)).toBe(false);
129
+ });
130
+ });
131
+ });
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @file Drawer swipe gesture configuration parsing.
3
+ *
4
+ * Normalizes swipeGestures config from DrawerBehavior into a consistent shape.
5
+ */
6
+ import type { DrawerBehavior, WindowPosition } from "../../types.js";
7
+ import type { DrawerPlacement } from "./drawerStyles.js";
8
+
9
+ /**
10
+ * Normalized swipe gesture configuration.
11
+ */
12
+ export type NormalizedSwipeConfig = {
13
+ enabled: boolean;
14
+ edgeSwipeOpen: boolean;
15
+ swipeClose: boolean;
16
+ edgeWidth: number;
17
+ dismissThreshold: number;
18
+ };
19
+
20
+ const DEFAULT_EDGE_WIDTH = 20;
21
+ const DEFAULT_DISMISS_THRESHOLD = 0.3;
22
+
23
+ const DISABLED_CONFIG: NormalizedSwipeConfig = {
24
+ enabled: false,
25
+ edgeSwipeOpen: false,
26
+ swipeClose: false,
27
+ edgeWidth: DEFAULT_EDGE_WIDTH,
28
+ dismissThreshold: DEFAULT_DISMISS_THRESHOLD,
29
+ };
30
+
31
+ const ENABLED_DEFAULT_CONFIG: NormalizedSwipeConfig = {
32
+ enabled: true,
33
+ edgeSwipeOpen: true,
34
+ swipeClose: true,
35
+ edgeWidth: DEFAULT_EDGE_WIDTH,
36
+ dismissThreshold: DEFAULT_DISMISS_THRESHOLD,
37
+ };
38
+
39
+ /**
40
+ * Parse swipeGestures config into normalized options.
41
+ */
42
+ export function parseSwipeGesturesConfig(
43
+ swipeGestures: DrawerBehavior["swipeGestures"],
44
+ ): NormalizedSwipeConfig {
45
+ if (swipeGestures === true) {
46
+ return ENABLED_DEFAULT_CONFIG;
47
+ }
48
+
49
+ if (swipeGestures === false || swipeGestures === undefined) {
50
+ return DISABLED_CONFIG;
51
+ }
52
+
53
+ return {
54
+ enabled: true,
55
+ edgeSwipeOpen: swipeGestures.edgeSwipeOpen ?? true,
56
+ swipeClose: swipeGestures.swipeClose ?? true,
57
+ edgeWidth: swipeGestures.edgeWidth ?? DEFAULT_EDGE_WIDTH,
58
+ dismissThreshold: swipeGestures.dismissThreshold ?? DEFAULT_DISMISS_THRESHOLD,
59
+ };
60
+ }
61
+
62
+ /**
63
+ * Resolve drawer placement from anchor and position.
64
+ */
65
+ export function resolvePlacement(
66
+ anchor: DrawerBehavior["anchor"],
67
+ position: WindowPosition | undefined,
68
+ ): DrawerPlacement {
69
+ if (anchor) {
70
+ return anchor;
71
+ }
72
+
73
+ if (!position) {
74
+ return "right";
75
+ }
76
+
77
+ if (position.left !== undefined) {
78
+ return "left";
79
+ }
80
+ if (position.right !== undefined) {
81
+ return "right";
82
+ }
83
+ if (position.top !== undefined) {
84
+ return "top";
85
+ }
86
+ if (position.bottom !== undefined) {
87
+ return "bottom";
88
+ }
89
+
90
+ return "right";
91
+ }
92
+
93
+ /**
94
+ * Determine if edge zone should be visible.
95
+ */
96
+ export function shouldShowEdgeZone(
97
+ config: NormalizedSwipeConfig,
98
+ isOpen: boolean,
99
+ isOpening: boolean,
100
+ ): boolean {
101
+ if (!config.enabled) {
102
+ return false;
103
+ }
104
+ if (!config.edgeSwipeOpen) {
105
+ return false;
106
+ }
107
+ // Show when closed or actively opening
108
+ if (!isOpen) {
109
+ return true;
110
+ }
111
+ return isOpening;
112
+ }
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @file Hook for applying real-time transform during drawer swipe gestures (backward-compatible wrapper).
3
+ *
4
+ * This hook is a thin wrapper around useDrawerTransform with mode="overlay".
5
+ * For new code, prefer using useDrawerTransform directly.
6
+ *
7
+ * @deprecated Use useDrawerTransform with mode="overlay" instead.
8
+ */
9
+ import * as React from "react";
10
+ import type { ContinuousOperationState } from "../../hooks/gesture/types.js";
11
+ import type { DrawerSwipeDirection } from "../../modules/drawer/types.js";
12
+ import { useDrawerTransform } from "./useDrawerTransform.js";
13
+
14
+ type UseDrawerSwipeTransformOptions = {
15
+ drawerRef: React.RefObject<HTMLDivElement | null>;
16
+ backdropRef: React.RefObject<HTMLDivElement | null>;
17
+ placement: DrawerSwipeDirection;
18
+ swipeState: ContinuousOperationState;
19
+ displacement: number;
20
+ isOpening: boolean;
21
+ isClosing: boolean;
22
+ isOpen: boolean;
23
+ enabled: boolean;
24
+ };
25
+
26
+ /**
27
+ * Apply real-time transform to drawer and backdrop during swipe.
28
+ *
29
+ * @deprecated Use useDrawerTransform with mode="overlay" instead.
30
+ */
31
+ export function useDrawerSwipeTransform(options: UseDrawerSwipeTransformOptions): void {
32
+ const {
33
+ drawerRef,
34
+ backdropRef,
35
+ placement,
36
+ swipeState,
37
+ displacement,
38
+ isOpening,
39
+ isClosing,
40
+ isOpen,
41
+ enabled,
42
+ } = options;
43
+
44
+ // Get drawer size from element
45
+ const drawerSizeRef = React.useRef(0);
46
+ React.useLayoutEffect(() => {
47
+ const drawer = drawerRef.current;
48
+ if (drawer) {
49
+ const isHorizontal = placement === "left" || placement === "right";
50
+ drawerSizeRef.current = isHorizontal ? drawer.clientWidth : drawer.clientHeight;
51
+ }
52
+ }, [drawerRef, placement]);
53
+
54
+ useDrawerTransform({
55
+ mode: "overlay",
56
+ drawerRef,
57
+ backdropRef,
58
+ placement,
59
+ drawerSize: drawerSizeRef.current,
60
+ isOpen,
61
+ swipeState,
62
+ displacement,
63
+ isOpening,
64
+ isClosing,
65
+ enabled,
66
+ });
67
+ }