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,197 @@
1
+ /**
2
+ * @file Reveal drawer state machine (backward-compatible re-export).
3
+ *
4
+ * This module provides backward compatibility by re-exporting the generic
5
+ * drawer state machine configured with the reveal strategy.
6
+ *
7
+ * For new code, prefer importing from drawerStateMachine.ts directly
8
+ * with the appropriate strategy.
9
+ */
10
+
11
+ import type { DrawerPlacement } from "../../components/window/drawerStyles.js";
12
+ import { revealStrategy } from "./strategies/revealStrategy.js";
13
+ import type { RevealPosition } from "./strategies/types.js";
14
+ import {
15
+ createDrawerReducer,
16
+ createDrawerInitialState,
17
+ drawerActions,
18
+ computeProgressFromDisplacement as genericComputeProgress,
19
+ computeSwipeEndTarget as genericComputeSwipeEndTarget,
20
+ type DrawerPhase,
21
+ type SwipeDirection,
22
+ type AnimationState,
23
+ type DrawerState,
24
+ type DrawerAction,
25
+ } from "./drawerStateMachine.js";
26
+ import {
27
+ REVEAL_DRAWER_CLOSED_OFFSET_PERCENT,
28
+ REVEAL_DRAWER_SNAP_THRESHOLD,
29
+ } from "./revealDrawerConstants.js";
30
+ import { getPlacementConfig } from "./strategies/types.js";
31
+
32
+ // ============================================================================
33
+ // Backward-Compatible Type Aliases
34
+ // ============================================================================
35
+
36
+ /**
37
+ * @deprecated Use DrawerPhase from drawerStateMachine.ts
38
+ */
39
+ export type RevealDrawerPhase = DrawerPhase;
40
+
41
+ /**
42
+ * @deprecated Use RevealPosition from strategies/types.ts
43
+ */
44
+ export type RevealPositionPx = RevealPosition;
45
+
46
+ /**
47
+ * @deprecated Use AnimationState<RevealPosition>
48
+ */
49
+ export type { AnimationState };
50
+
51
+ /**
52
+ * @deprecated Use DrawerState<RevealPosition>
53
+ */
54
+ export type RevealDrawerState = DrawerState<RevealPosition>;
55
+
56
+ /**
57
+ * Configuration for the reveal drawer state machine.
58
+ */
59
+ export type RevealDrawerConfig = {
60
+ placement: DrawerPlacement;
61
+ drawerSize: number;
62
+ };
63
+
64
+ // Re-export SwipeDirection
65
+ export type { SwipeDirection };
66
+
67
+ // Re-export getPlacementConfig
68
+ export { getPlacementConfig };
69
+
70
+ // ============================================================================
71
+ // Backward-Compatible Action Creators
72
+ // ============================================================================
73
+
74
+ /**
75
+ * @deprecated Use drawerActions from drawerStateMachine.ts
76
+ */
77
+ export const revealDrawerActions = drawerActions;
78
+
79
+ export type RevealDrawerAction = DrawerAction;
80
+
81
+ // ============================================================================
82
+ // Backward-Compatible Pure Functions
83
+ // ============================================================================
84
+
85
+ /**
86
+ * Compute progress from displacement.
87
+ * @deprecated Use computeProgressFromDisplacement from drawerStateMachine.ts
88
+ */
89
+ export const computeProgressFromDisplacement = genericComputeProgress;
90
+
91
+ /**
92
+ * Compute swipe end target.
93
+ * @deprecated Use computeSwipeEndTarget from drawerStateMachine.ts
94
+ */
95
+ export const computeSwipeEndTarget = genericComputeSwipeEndTarget;
96
+
97
+ /**
98
+ * Compute drawer offset in pixels from progress.
99
+ */
100
+ export function computeDrawerOffsetPx(
101
+ progress: number,
102
+ drawerSize: number,
103
+ placement: DrawerPlacement,
104
+ ): number {
105
+ const { sign } = getPlacementConfig(placement);
106
+ const maxOffsetPx = drawerSize * (REVEAL_DRAWER_CLOSED_OFFSET_PERCENT / 100);
107
+ const offsetPx = maxOffsetPx * (1 - progress);
108
+ return sign > 0 ? -offsetPx : offsetPx;
109
+ }
110
+
111
+ /**
112
+ * Compute content offset in pixels from progress.
113
+ */
114
+ export function computeContentOffsetPx(
115
+ progress: number,
116
+ drawerSize: number,
117
+ placement: DrawerPlacement,
118
+ ): number {
119
+ const { sign } = getPlacementConfig(placement);
120
+ return sign * drawerSize * progress;
121
+ }
122
+
123
+ /**
124
+ * Compute position from progress.
125
+ */
126
+ export function computePositionFromProgress(
127
+ progress: number,
128
+ config: RevealDrawerConfig,
129
+ ): RevealPosition {
130
+ return revealStrategy.computePositionFromProgress(progress, config);
131
+ }
132
+
133
+ /**
134
+ * Compute target position for open or closed state.
135
+ */
136
+ export function computeTargetPosition(
137
+ isOpen: boolean,
138
+ config: RevealDrawerConfig,
139
+ ): RevealPosition {
140
+ if (isOpen) {
141
+ return revealStrategy.getOpenPosition(config);
142
+ }
143
+ return revealStrategy.getClosedPosition(config);
144
+ }
145
+
146
+ /**
147
+ * Determine if animation is needed between two positions.
148
+ */
149
+ export function shouldAnimate(from: RevealPosition, to: RevealPosition): boolean {
150
+ const distance = Math.abs(from.contentPx - to.contentPx);
151
+ return distance > REVEAL_DRAWER_SNAP_THRESHOLD;
152
+ }
153
+
154
+ /**
155
+ * Interpolate between two positions.
156
+ */
157
+ export function interpolatePosition(
158
+ from: RevealPosition,
159
+ to: RevealPosition,
160
+ progress: number,
161
+ ): RevealPosition {
162
+ return revealStrategy.interpolatePosition(from, to, progress);
163
+ }
164
+
165
+ // ============================================================================
166
+ // Backward-Compatible Initial State
167
+ // ============================================================================
168
+
169
+ /**
170
+ * Create initial state for reveal drawer.
171
+ */
172
+ export function createInitialState(
173
+ isOpen: boolean,
174
+ config: RevealDrawerConfig,
175
+ ): RevealDrawerState {
176
+ return createDrawerInitialState(isOpen, revealStrategy, config);
177
+ }
178
+
179
+ // ============================================================================
180
+ // Backward-Compatible Reducer
181
+ // ============================================================================
182
+
183
+ /**
184
+ * Pre-configured reveal drawer reducer.
185
+ */
186
+ const revealReducer = createDrawerReducer(revealStrategy);
187
+
188
+ /**
189
+ * Reveal drawer reducer function.
190
+ */
191
+ export function revealDrawerReducer(
192
+ state: RevealDrawerState,
193
+ action: RevealDrawerAction,
194
+ config: RevealDrawerConfig,
195
+ ): RevealDrawerState {
196
+ return revealReducer(state, action, config);
197
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file Drawer transform strategies module.
3
+ *
4
+ * Exports strategy implementations for different drawer animation modes.
5
+ */
6
+
7
+ export * from "./types.js";
8
+ export { revealStrategy } from "./revealStrategy.js";
9
+ export { overlayStrategy } from "./overlayStrategy.js";
@@ -0,0 +1,133 @@
1
+ /**
2
+ * @file Overlay mode drawer transform strategy.
3
+ *
4
+ * Implements the overlay animation where:
5
+ * - Drawer slides from ±100% to 0% (slides over content)
6
+ * - Backdrop opacity changes from 0 to 1
7
+ */
8
+
9
+ import type {
10
+ DrawerTransformStrategy,
11
+ OverlayPosition,
12
+ DrawerStrategyConfig,
13
+ } from "./types.js";
14
+ import { getPlacementConfig } from "./types.js";
15
+
16
+ /**
17
+ * Snap threshold for overlay mode (in pixels).
18
+ */
19
+ const OVERLAY_SNAP_THRESHOLD = 1;
20
+
21
+ // ============================================================================
22
+ // Overlay Strategy Implementation
23
+ // ============================================================================
24
+
25
+ /**
26
+ * Overlay mode drawer transform strategy.
27
+ */
28
+ export const overlayStrategy: DrawerTransformStrategy<OverlayPosition> = {
29
+ getClosedPosition(config) {
30
+ const { sign } = getPlacementConfig(config.placement);
31
+ // For overlay mode, drawer starts off-screen on its anchor side:
32
+ // - LEFT drawer: closed at -drawerSize (off-screen left)
33
+ // - RIGHT drawer: closed at +drawerSize (off-screen right)
34
+ // The sign in PLACEMENT_CONFIG is for content movement direction,
35
+ // so we negate it for overlay drawer position.
36
+ return {
37
+ drawerPx: -sign * config.drawerSize,
38
+ backdropOpacity: 0,
39
+ };
40
+ },
41
+
42
+ getOpenPosition() {
43
+ return {
44
+ drawerPx: 0,
45
+ backdropOpacity: 1,
46
+ };
47
+ },
48
+
49
+ computePositionFromProgress(progress, config) {
50
+ const { sign } = getPlacementConfig(config.placement);
51
+ // Negate sign for overlay mode (see getClosedPosition comment)
52
+ const closedOffset = -sign * config.drawerSize;
53
+ return {
54
+ drawerPx: closedOffset * (1 - progress),
55
+ backdropOpacity: progress,
56
+ };
57
+ },
58
+
59
+ interpolatePosition(from, to, progress) {
60
+ return {
61
+ drawerPx: from.drawerPx + (to.drawerPx - from.drawerPx) * progress,
62
+ backdropOpacity: from.backdropOpacity + (to.backdropOpacity - from.backdropOpacity) * progress,
63
+ };
64
+ },
65
+
66
+ shouldAnimate(from, to) {
67
+ return Math.abs(from.drawerPx - to.drawerPx) > OVERLAY_SNAP_THRESHOLD;
68
+ },
69
+
70
+ applyToDOM(position, elements, config) {
71
+ const { drawer, backdrop } = elements;
72
+ const { axis } = getPlacementConfig(config.placement);
73
+
74
+ if (drawer) {
75
+ drawer.style.transition = "none";
76
+ drawer.style.transform = `translate${axis}(${position.drawerPx}px)`;
77
+ }
78
+ if (backdrop) {
79
+ backdrop.style.opacity = String(position.backdropOpacity);
80
+ backdrop.style.pointerEvents = position.backdropOpacity > 0 ? "auto" : "none";
81
+ }
82
+ },
83
+
84
+ clearFromDOM(elements) {
85
+ const { drawer, backdrop } = elements;
86
+
87
+ // Clear all inline styles to restore CSS defaults
88
+ if (drawer) {
89
+ drawer.style.transform = "";
90
+ drawer.style.transition = "";
91
+ }
92
+ if (backdrop) {
93
+ backdrop.style.opacity = "";
94
+ backdrop.style.pointerEvents = "";
95
+ }
96
+ },
97
+
98
+ onOpeningStart() {
99
+ // Overlay mode doesn't need special handling on opening start
100
+ // The drawer is already positioned via CSS
101
+ },
102
+
103
+ onClosingComplete(elements, config) {
104
+ const { drawer, backdrop } = elements;
105
+ const closedTransform = getClosedTransformForPlacement(config);
106
+
107
+ // Set to closed state (not clearing - that's clearFromDOM's job)
108
+ if (drawer) {
109
+ drawer.style.transform = closedTransform;
110
+ drawer.style.transition = "";
111
+ }
112
+ if (backdrop) {
113
+ backdrop.style.opacity = "0";
114
+ backdrop.style.pointerEvents = "none";
115
+ }
116
+ },
117
+ };
118
+
119
+ /**
120
+ * Get the closed transform string for a placement.
121
+ */
122
+ function getClosedTransformForPlacement(config: DrawerStrategyConfig): string {
123
+ switch (config.placement) {
124
+ case "left":
125
+ return "translateX(-100%)";
126
+ case "right":
127
+ return "translateX(100%)";
128
+ case "top":
129
+ return "translateY(-100%)";
130
+ case "bottom":
131
+ return "translateY(100%)";
132
+ }
133
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * @file Reveal mode drawer transform strategy.
3
+ *
4
+ * Implements the reveal animation where:
5
+ * - Drawer slides from -30% to 0% (parallax effect)
6
+ * - Content slides from 0 to +drawerSize (reveals drawer behind)
7
+ */
8
+
9
+ import type {
10
+ DrawerTransformStrategy,
11
+ RevealPosition,
12
+ } from "./types.js";
13
+ import { getPlacementConfig } from "./types.js";
14
+ import {
15
+ REVEAL_DRAWER_CLOSED_OFFSET_PERCENT,
16
+ REVEAL_DRAWER_SNAP_THRESHOLD,
17
+ } from "../revealDrawerConstants.js";
18
+ import {
19
+ showDrawer,
20
+ hideDrawer,
21
+ clearStackingContext,
22
+ applyStackingContextWithBackground,
23
+ } from "../../../components/window/drawerRevealAnimationUtils.js";
24
+
25
+ // ============================================================================
26
+ // Reveal Strategy Implementation
27
+ // ============================================================================
28
+
29
+ /**
30
+ * Reveal mode drawer transform strategy.
31
+ */
32
+ export const revealStrategy: DrawerTransformStrategy<RevealPosition> = {
33
+ getClosedPosition(config) {
34
+ return this.computePositionFromProgress(0, config);
35
+ },
36
+
37
+ getOpenPosition(config) {
38
+ return this.computePositionFromProgress(1, config);
39
+ },
40
+
41
+ computePositionFromProgress(progress, config) {
42
+ const { sign } = getPlacementConfig(config.placement);
43
+ const maxOffsetPx = config.drawerSize * (REVEAL_DRAWER_CLOSED_OFFSET_PERCENT / 100);
44
+ const offsetPx = maxOffsetPx * (1 - progress);
45
+ const drawerPx = sign > 0 ? -offsetPx : offsetPx;
46
+ const contentPx = sign * config.drawerSize * progress;
47
+
48
+ return { drawerPx, contentPx };
49
+ },
50
+
51
+ interpolatePosition(from, to, progress) {
52
+ return {
53
+ drawerPx: from.drawerPx + (to.drawerPx - from.drawerPx) * progress,
54
+ contentPx: from.contentPx + (to.contentPx - from.contentPx) * progress,
55
+ };
56
+ },
57
+
58
+ shouldAnimate(from, to) {
59
+ return Math.abs(from.contentPx - to.contentPx) > REVEAL_DRAWER_SNAP_THRESHOLD;
60
+ },
61
+
62
+ applyToDOM(position, elements, config) {
63
+ const { drawer, content } = elements;
64
+ const { axis } = getPlacementConfig(config.placement);
65
+
66
+ if (drawer) {
67
+ drawer.style.transition = "none";
68
+ drawer.style.transform = `translate${axis}(${position.drawerPx}px)`;
69
+ }
70
+ if (content) {
71
+ applyStackingContextWithBackground(content, config.contentBackground);
72
+ content.style.transition = "none";
73
+ content.style.transform = `translate${axis}(${position.contentPx}px)`;
74
+ }
75
+ },
76
+
77
+ clearFromDOM(elements) {
78
+ const { drawer, content } = elements;
79
+
80
+ if (drawer) {
81
+ drawer.style.transform = "";
82
+ drawer.style.transition = "";
83
+ }
84
+ if (content) {
85
+ content.style.transform = "";
86
+ content.style.transition = "";
87
+ clearStackingContext(content);
88
+ }
89
+ },
90
+
91
+ onOpeningStart(elements) {
92
+ if (elements.drawer) {
93
+ showDrawer(elements.drawer);
94
+ }
95
+ },
96
+
97
+ onClosingComplete(elements) {
98
+ const { drawer, content } = elements;
99
+
100
+ if (drawer) {
101
+ hideDrawer(drawer);
102
+ drawer.style.transform = "";
103
+ drawer.style.transition = "";
104
+ }
105
+ if (content) {
106
+ content.style.transform = "";
107
+ content.style.transition = "";
108
+ clearStackingContext(content);
109
+ }
110
+ },
111
+ };
@@ -0,0 +1,160 @@
1
+ /**
2
+ * @file Drawer transform strategy types.
3
+ *
4
+ * Defines the strategy pattern interface for different drawer animation modes.
5
+ * Each mode (reveal, overlay) implements this interface with mode-specific
6
+ * position calculations and DOM operations.
7
+ */
8
+
9
+ import type { DrawerPlacement } from "../../../components/window/drawerStyles.js";
10
+
11
+ // ============================================================================
12
+ // Position Types
13
+ // ============================================================================
14
+
15
+ /**
16
+ * Position values for reveal mode.
17
+ * - Drawer moves from -30% to 0%
18
+ * - Content moves from 0 to +drawerSize
19
+ */
20
+ export type RevealPosition = {
21
+ /** Drawer offset in pixels */
22
+ drawerPx: number;
23
+ /** Content offset in pixels */
24
+ contentPx: number;
25
+ };
26
+
27
+ /**
28
+ * Position values for overlay mode.
29
+ * - Drawer moves from ±100% to 0%
30
+ * - Backdrop opacity changes from 0 to 1
31
+ */
32
+ export type OverlayPosition = {
33
+ /** Drawer offset in pixels */
34
+ drawerPx: number;
35
+ /** Backdrop opacity (0-1) */
36
+ backdropOpacity: number;
37
+ };
38
+
39
+ // ============================================================================
40
+ // Configuration Types
41
+ // ============================================================================
42
+
43
+ /**
44
+ * Configuration for drawer strategy calculations.
45
+ */
46
+ export type DrawerStrategyConfig = {
47
+ /** Drawer placement (left, right, top, bottom) */
48
+ placement: DrawerPlacement;
49
+ /** Drawer size in pixels */
50
+ drawerSize: number;
51
+ /** Content background color (reveal mode) */
52
+ contentBackground?: string;
53
+ };
54
+
55
+ /**
56
+ * DOM elements used by drawer strategies.
57
+ */
58
+ export type DrawerElements = {
59
+ /** Drawer element */
60
+ drawer: HTMLElement | null;
61
+ /** Content element (reveal mode) */
62
+ content: HTMLElement | null;
63
+ /** Backdrop element (overlay mode) */
64
+ backdrop: HTMLElement | null;
65
+ };
66
+
67
+ // ============================================================================
68
+ // Placement Configuration
69
+ // ============================================================================
70
+
71
+ /**
72
+ * Placement configuration for transform calculations.
73
+ */
74
+ export type PlacementConfig = {
75
+ /** Transform axis (X or Y) */
76
+ axis: "X" | "Y";
77
+ /** Sign for transform direction (1 or -1) */
78
+ sign: 1 | -1;
79
+ };
80
+
81
+ /**
82
+ * Lookup table for placement configuration.
83
+ */
84
+ export const PLACEMENT_CONFIG: Record<DrawerPlacement, PlacementConfig> = {
85
+ left: { axis: "X", sign: 1 },
86
+ right: { axis: "X", sign: -1 },
87
+ top: { axis: "Y", sign: 1 },
88
+ bottom: { axis: "Y", sign: -1 },
89
+ };
90
+
91
+ /**
92
+ * Get placement configuration for a drawer placement.
93
+ */
94
+ export function getPlacementConfig(placement: DrawerPlacement): PlacementConfig {
95
+ return PLACEMENT_CONFIG[placement];
96
+ }
97
+
98
+ // ============================================================================
99
+ // Strategy Interface
100
+ // ============================================================================
101
+
102
+ /**
103
+ * Strategy interface for drawer transform calculations.
104
+ *
105
+ * Each drawer mode (reveal, overlay) implements this interface to provide
106
+ * mode-specific position calculations and DOM operations while sharing
107
+ * the common state machine logic.
108
+ *
109
+ * @typeParam TPosition - The position type used by this strategy
110
+ */
111
+ export type DrawerTransformStrategy<TPosition> = {
112
+ /**
113
+ * Get the closed position (progress = 0).
114
+ */
115
+ getClosedPosition: (config: DrawerStrategyConfig) => TPosition;
116
+
117
+ /**
118
+ * Get the open position (progress = 1).
119
+ */
120
+ getOpenPosition: (config: DrawerStrategyConfig) => TPosition;
121
+
122
+ /**
123
+ * Compute position from progress (0 = closed, 1 = open).
124
+ */
125
+ computePositionFromProgress: (progress: number, config: DrawerStrategyConfig) => TPosition;
126
+
127
+ /**
128
+ * Interpolate between two positions.
129
+ */
130
+ interpolatePosition: (from: TPosition, to: TPosition, progress: number) => TPosition;
131
+
132
+ /**
133
+ * Determine if animation is needed between two positions.
134
+ */
135
+ shouldAnimate: (from: TPosition, to: TPosition) => boolean;
136
+
137
+ /**
138
+ * Apply position to DOM elements.
139
+ */
140
+ applyToDOM: (
141
+ position: TPosition,
142
+ elements: DrawerElements,
143
+ config: DrawerStrategyConfig,
144
+ ) => void;
145
+
146
+ /**
147
+ * Clear transforms from DOM elements.
148
+ */
149
+ clearFromDOM: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
150
+
151
+ /**
152
+ * Called when opening animation starts (optional).
153
+ */
154
+ onOpeningStart?: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
155
+
156
+ /**
157
+ * Called when closing animation completes (optional).
158
+ */
159
+ onClosingComplete?: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
160
+ };