react-panel-layout 0.6.0 → 0.6.1

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 (216) 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-CUXnEtrb.js +827 -0
  4. package/dist/FloatingWindow-CUXnEtrb.js.map +1 -0
  5. package/dist/FloatingWindow-DMwyK0eK.cjs +2 -0
  6. package/dist/FloatingWindow-DMwyK0eK.cjs.map +1 -0
  7. package/dist/GridLayout-DKTg_N61.cjs +2 -0
  8. package/dist/{GridLayout-B4VRsC0r.cjs.map → GridLayout-DKTg_N61.cjs.map} +1 -1
  9. package/dist/{GridLayout-BltqeCPK.js → GridLayout-UWNxXw77.js} +34 -35
  10. package/dist/{GridLayout-BltqeCPK.js.map → GridLayout-UWNxXw77.js.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-Dr1TBhxM.js → PanelSystem-BqUzNtf2.js} +5 -5
  16. package/dist/{PanelSystem-Dr1TBhxM.js.map → PanelSystem-BqUzNtf2.js.map} +1 -1
  17. package/dist/{PanelSystem-Bs8bQwQF.cjs → PanelSystem-D603LKKv.cjs} +2 -2
  18. package/dist/{PanelSystem-Bs8bQwQF.cjs.map → PanelSystem-D603LKKv.cjs.map} +1 -1
  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 +3 -1
  29. package/dist/components/window/DrawerLayers.d.ts +1 -1
  30. package/dist/components/window/drawerStyles.d.ts +69 -0
  31. package/dist/components/window/drawerSwipeConfig.d.ts +29 -0
  32. package/dist/components/window/useDrawerSwipeTransform.d.ts +23 -0
  33. package/dist/config.cjs +1 -1
  34. package/dist/config.js +3 -3
  35. package/dist/constants/styles.d.ts +17 -0
  36. package/dist/dialog/index.d.ts +69 -0
  37. package/dist/floating.js +1 -1
  38. package/dist/grid.cjs +1 -1
  39. package/dist/grid.js +2 -2
  40. package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +7 -0
  41. package/dist/hooks/gesture/types.d.ts +48 -5
  42. package/dist/hooks/gesture/utils.d.ts +19 -0
  43. package/dist/hooks/useAnimationFrame.d.ts +2 -0
  44. package/dist/hooks/useOperationContinuity.d.ts +64 -0
  45. package/dist/hooks/useResizeObserver.d.ts +33 -1
  46. package/dist/hooks/useSharedElementTransition.d.ts +112 -0
  47. package/dist/hooks/useSwipeContentTransform.d.ts +9 -2
  48. package/dist/index.cjs +1 -1
  49. package/dist/index.js +7 -7
  50. package/dist/modules/dialog/AlertDialog.d.ts +9 -0
  51. package/dist/modules/dialog/DialogContainer.d.ts +37 -0
  52. package/dist/modules/dialog/Modal.d.ts +26 -0
  53. package/dist/modules/dialog/SwipeDialogContainer.d.ts +16 -0
  54. package/dist/modules/dialog/dialogAnimationUtils.d.ts +113 -0
  55. package/dist/modules/dialog/types.d.ts +183 -0
  56. package/dist/modules/dialog/useDialog.d.ts +39 -0
  57. package/dist/modules/dialog/useDialogContainer.d.ts +47 -0
  58. package/dist/modules/dialog/useDialogSwipeInput.d.ts +70 -0
  59. package/dist/modules/dialog/useDialogTransform.d.ts +82 -0
  60. package/dist/modules/drawer/types.d.ts +74 -0
  61. package/dist/modules/drawer/useDrawerSwipeInput.d.ts +24 -0
  62. package/dist/modules/pivot/SwipePivotTabBar.d.ts +3 -0
  63. package/dist/modules/stack/SwipeStackContent.d.ts +6 -3
  64. package/dist/modules/stack/SwipeStackOutlet.d.ts +4 -4
  65. package/dist/modules/stack/computeSwipeStackTransform.d.ts +1 -1
  66. package/dist/panels.cjs +1 -1
  67. package/dist/panels.js +1 -1
  68. package/dist/pivot.cjs +1 -1
  69. package/dist/pivot.js +1 -1
  70. package/dist/resizer.cjs +1 -1
  71. package/dist/resizer.js +2 -2
  72. package/dist/stack.cjs +1 -1
  73. package/dist/stack.cjs.map +1 -1
  74. package/dist/stack.js +503 -762
  75. package/dist/stack.js.map +1 -1
  76. package/dist/sticky-header/calculateStickyMetrics.d.ts +28 -0
  77. package/dist/sticky-header.cjs +1 -1
  78. package/dist/sticky-header.cjs.map +1 -1
  79. package/dist/sticky-header.js +59 -51
  80. package/dist/sticky-header.js.map +1 -1
  81. package/dist/{styles-DPPuJ0sf.js → styles-NkjuMOVS.js} +13 -13
  82. package/dist/{styles-DPPuJ0sf.js.map → styles-NkjuMOVS.js.map} +1 -1
  83. package/dist/styles-qf6ptVLD.cjs.map +1 -1
  84. package/dist/types.d.ts +16 -0
  85. package/dist/useDocumentPointerEvents-DXxw3qWj.js +54 -0
  86. package/dist/useDocumentPointerEvents-DXxw3qWj.js.map +1 -0
  87. package/dist/useDocumentPointerEvents-DxDSOtip.cjs +2 -0
  88. package/dist/useDocumentPointerEvents-DxDSOtip.cjs.map +1 -0
  89. package/dist/useNativeGestureGuard-C7TSqEkr.cjs +2 -0
  90. package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +1 -0
  91. package/dist/useNativeGestureGuard-CGYo6O0r.js +347 -0
  92. package/dist/useNativeGestureGuard-CGYo6O0r.js.map +1 -0
  93. package/dist/window/index.d.ts +2 -0
  94. package/dist/window.cjs +1 -1
  95. package/dist/window.cjs.map +1 -1
  96. package/dist/window.js +114 -103
  97. package/dist/window.js.map +1 -1
  98. package/package.json +6 -1
  99. package/src/components/gesture/SwipeSafeZone.tsx +69 -0
  100. package/src/components/window/Drawer.tsx +249 -162
  101. package/src/components/window/DrawerLayers.tsx +13 -3
  102. package/src/components/window/drawerStyles.spec.ts +263 -0
  103. package/src/components/window/drawerStyles.ts +228 -0
  104. package/src/components/window/drawerSwipeConfig.spec.ts +131 -0
  105. package/src/components/window/drawerSwipeConfig.ts +112 -0
  106. package/src/components/window/useDrawerSwipeTransform.spec.ts +234 -0
  107. package/src/components/window/useDrawerSwipeTransform.ts +129 -0
  108. package/src/constants/styles.ts +19 -0
  109. package/src/demo/pages/Dialog/alerts/index.tsx +22 -0
  110. package/src/demo/pages/Dialog/card/index.tsx +22 -0
  111. package/src/demo/pages/Dialog/components/AlertDialogDemo.tsx +124 -0
  112. package/src/demo/pages/Dialog/components/CardExpandDemo.module.css +243 -0
  113. package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +204 -0
  114. package/src/demo/pages/Dialog/components/CustomAlertDialogDemo.tsx +219 -0
  115. package/src/demo/pages/Dialog/components/DialogDemos.module.css +77 -0
  116. package/src/demo/pages/Dialog/components/ModalBasics.tsx +45 -0
  117. package/src/demo/pages/Dialog/components/SwipeDialogDemo.module.css +77 -0
  118. package/src/demo/pages/Dialog/components/SwipeDialogDemo.tsx +181 -0
  119. package/src/demo/pages/Dialog/custom-alert/index.tsx +22 -0
  120. package/src/demo/pages/Dialog/modal/index.tsx +17 -0
  121. package/src/demo/pages/Dialog/swipe/index.tsx +22 -0
  122. package/src/demo/pages/Drawer/components/DrawerSwipe.module.css +316 -0
  123. package/src/demo/pages/Drawer/components/DrawerSwipe.tsx +178 -0
  124. package/src/demo/pages/Drawer/swipe/index.tsx +17 -0
  125. package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +54 -23
  126. package/src/demo/pages/Pivot/swipe-debug/index.tsx +1 -1
  127. package/src/demo/pages/Stack/components/StackBasics.spec.tsx +152 -0
  128. package/src/demo/pages/Stack/components/StackBasics.tsx +179 -95
  129. package/src/demo/pages/Stack/components/StackTablet.spec.tsx +120 -0
  130. package/src/demo/pages/Stack/components/StackTablet.tsx +42 -21
  131. package/src/demo/routes.tsx +22 -1
  132. package/src/dialog/index.ts +85 -0
  133. package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +68 -64
  134. package/src/hooks/gesture/testing/createGestureSimulator.ts +112 -37
  135. package/src/hooks/gesture/types.ts +83 -6
  136. package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +22 -14
  137. package/src/hooks/gesture/useNativeGestureGuard.spec.ts +91 -31
  138. package/src/hooks/gesture/useNativeGestureGuard.ts +3 -1
  139. package/src/hooks/gesture/utils.ts +91 -0
  140. package/src/hooks/useAnimatedVisibility.spec.ts +44 -24
  141. package/src/hooks/useAnimatedVisibility.ts +28 -2
  142. package/src/hooks/useAnimationFrame.ts +8 -0
  143. package/src/hooks/useOperationContinuity.spec.ts +387 -0
  144. package/src/hooks/useOperationContinuity.ts +135 -0
  145. package/src/hooks/useResizeObserver.spec.tsx +277 -0
  146. package/src/hooks/useResizeObserver.tsx +108 -39
  147. package/src/hooks/useScrollContainer.ts +4 -10
  148. package/src/hooks/useSharedElementTransition.ts +333 -0
  149. package/src/hooks/useSwipeContentTransform.spec.ts +18 -18
  150. package/src/hooks/useSwipeContentTransform.ts +166 -28
  151. package/src/modules/dialog/AlertDialog.spec.tsx +387 -0
  152. package/src/modules/dialog/AlertDialog.tsx +221 -0
  153. package/src/modules/dialog/DialogContainer.spec.tsx +228 -0
  154. package/src/modules/dialog/DialogContainer.tsx +188 -0
  155. package/src/modules/dialog/Modal.spec.tsx +220 -0
  156. package/src/modules/dialog/Modal.tsx +182 -0
  157. package/src/modules/dialog/SwipeDialogContainer.tsx +208 -0
  158. package/src/modules/dialog/dialogAnimationUtils.spec.ts +253 -0
  159. package/src/modules/dialog/dialogAnimationUtils.ts +297 -0
  160. package/src/modules/dialog/types.ts +186 -0
  161. package/src/modules/dialog/useDialog.spec.tsx +447 -0
  162. package/src/modules/dialog/useDialog.ts +214 -0
  163. package/src/modules/dialog/useDialogContainer.spec.ts +331 -0
  164. package/src/modules/dialog/useDialogContainer.ts +150 -0
  165. package/src/modules/dialog/useDialogSwipeInput.spec.ts +157 -0
  166. package/src/modules/dialog/useDialogSwipeInput.ts +319 -0
  167. package/src/modules/dialog/useDialogTransform.spec.ts +370 -0
  168. package/src/modules/dialog/useDialogTransform.ts +407 -0
  169. package/src/modules/drawer/types.ts +102 -0
  170. package/src/modules/drawer/useDrawerSwipeInput.spec.ts +566 -0
  171. package/src/modules/drawer/useDrawerSwipeInput.ts +399 -0
  172. package/src/modules/panels/rendering/ContentRegistry.spec.tsx +21 -14
  173. package/src/modules/pivot/SwipePivotContent.position.spec.tsx +12 -8
  174. package/src/modules/pivot/SwipePivotContent.spec.tsx +55 -25
  175. package/src/modules/pivot/SwipePivotContent.tsx +2 -2
  176. package/src/modules/pivot/SwipePivotTabBar.spec.tsx +85 -68
  177. package/src/modules/pivot/SwipePivotTabBar.tsx +75 -15
  178. package/src/modules/pivot/scaleInputState.spec.ts +11 -2
  179. package/src/modules/pivot/usePivot.spec.ts +17 -3
  180. package/src/modules/pivot/usePivotSwipeInput.spec.ts +182 -123
  181. package/src/modules/stack/SwipeStackContent.spec.tsx +387 -100
  182. package/src/modules/stack/SwipeStackContent.tsx +43 -33
  183. package/src/modules/stack/SwipeStackOutlet.spec.tsx +14 -16
  184. package/src/modules/stack/SwipeStackOutlet.tsx +6 -6
  185. package/src/modules/stack/computeSwipeStackTransform.spec.ts +5 -5
  186. package/src/modules/stack/computeSwipeStackTransform.ts +3 -3
  187. package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1133 -0
  188. package/src/modules/stack/useStackAnimationState.spec.ts +3 -1
  189. package/src/modules/stack/useStackAnimationState.ts +18 -13
  190. package/src/modules/stack/useStackNavigation.spec.ts +198 -3
  191. package/src/modules/stack/useStackNavigation.tsx +113 -56
  192. package/src/modules/stack/useStackSwipeInput.spec.ts +65 -32
  193. package/src/modules/stack/useStackSwipeInput.ts +1 -1
  194. package/src/sticky-header/StickyArea.tsx +29 -57
  195. package/src/sticky-header/calculateStickyMetrics.spec.ts +105 -0
  196. package/src/sticky-header/calculateStickyMetrics.ts +50 -0
  197. package/src/types.ts +18 -0
  198. package/src/window/index.ts +2 -0
  199. package/dist/FloatingWindow-BpdOpg_L.js +0 -400
  200. package/dist/FloatingWindow-BpdOpg_L.js.map +0 -1
  201. package/dist/FloatingWindow-TCDNY5gE.cjs +0 -2
  202. package/dist/FloatingWindow-TCDNY5gE.cjs.map +0 -1
  203. package/dist/GridLayout-B4VRsC0r.cjs +0 -2
  204. package/dist/ResizeHandle-CScipO5l.cjs +0 -2
  205. package/dist/SwipePivotTabBar-BGO9X94m.js +0 -407
  206. package/dist/SwipePivotTabBar-BGO9X94m.js.map +0 -1
  207. package/dist/SwipePivotTabBar-BrQismcZ.cjs +0 -2
  208. package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +0 -1
  209. package/dist/useDocumentPointerEvents-CKdhGXd0.js +0 -46
  210. package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +0 -1
  211. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +0 -2
  212. package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +0 -1
  213. package/dist/useEffectEvent-Dp7HLCf0.js +0 -13
  214. package/dist/useEffectEvent-Dp7HLCf0.js.map +0 -1
  215. package/dist/useEffectEvent-huSsGUnl.cjs +0 -2
  216. package/dist/useEffectEvent-huSsGUnl.cjs.map +0 -1
package/dist/grid.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GridLayout-B4VRsC0r.cjs"),r=require("./FloatingWindow-TCDNY5gE.cjs");exports.GridLayerList=e.GridLayerList;exports.GridLayerResizeHandles=e.GridLayerResizeHandles;exports.GridLayout=e.GridLayout;exports.GridTrackResizeHandle=e.GridTrackResizeHandle;exports.useGridPlacements=e.useGridPlacements;exports.useGridTracks=e.useGridTracks;exports.GridLayoutProvider=r.GridLayoutProvider;exports.useGridLayoutContext=r.useGridLayoutContext;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./GridLayout-DKTg_N61.cjs"),r=require("./FloatingWindow-DMwyK0eK.cjs");exports.GridLayerList=e.GridLayerList;exports.GridLayerResizeHandles=e.GridLayerResizeHandles;exports.GridLayout=e.GridLayout;exports.GridTrackResizeHandle=e.GridTrackResizeHandle;exports.useGridPlacements=e.useGridPlacements;exports.useGridTracks=e.useGridTracks;exports.GridLayoutProvider=r.GridLayoutProvider;exports.useGridLayoutContext=r.useGridLayoutContext;
2
2
  //# sourceMappingURL=grid.cjs.map
package/dist/grid.js CHANGED
@@ -1,5 +1,5 @@
1
- import { a as e, b as s, G as d, c as i, u as G, d as o } from "./GridLayout-BltqeCPK.js";
2
- import { G as u, u as L } from "./FloatingWindow-BpdOpg_L.js";
1
+ import { a as e, b as s, G as d, c as i, u as G, d as o } from "./GridLayout-UWNxXw77.js";
2
+ import { G as u, u as L } from "./FloatingWindow-CUXnEtrb.js";
3
3
  export {
4
4
  e as GridLayerList,
5
5
  s as GridLayerResizeHandles,
@@ -1,3 +1,10 @@
1
+ /**
2
+ * @file Test utility for simulating gesture events.
3
+ *
4
+ * Provides a fluent API for simulating pointer events in tests,
5
+ * making it easier to test swipe and drag gestures.
6
+ */
7
+ import type * as React from "react";
1
8
  /**
2
9
  * 2D point for gesture coordinates.
3
10
  */
@@ -6,17 +6,15 @@
6
6
  * - Input: how to command (swipe, click, keyboard)
7
7
  * - Presentation: how to show (animation, transition)
8
8
  *
9
- * This file defines types for the Input layer.
9
+ * This file defines types for the Input layer, including the abstract
10
+ * ContinuousOperationState that represents any continuous state transition
11
+ * (whether controlled by human gesture or system animation).
10
12
  */
11
13
  import type * as React from "react";
12
14
  /**
13
15
  * Axis for gesture detection.
14
16
  */
15
17
  export type GestureAxis = "horizontal" | "vertical";
16
- /**
17
- * Phase of swipe input lifecycle.
18
- */
19
- export type SwipeInputPhase = "idle" | "tracking" | "swiping" | "ended";
20
18
  /**
21
19
  * 2D vector for displacement and velocity.
22
20
  */
@@ -24,6 +22,51 @@ export type Vector2 = {
24
22
  x: number;
25
23
  y: number;
26
24
  };
25
+ /**
26
+ * Phase of a continuous operation lifecycle.
27
+ * - "idle": No operation in progress
28
+ * - "operating": Operation is in progress (human or system controlled)
29
+ * - "ended": Operation has completed
30
+ */
31
+ export type ContinuousOperationPhase = "idle" | "operating" | "ended";
32
+ /**
33
+ * State of a continuous operation.
34
+ *
35
+ * This is the abstract representation of any operation that occurs over time,
36
+ * whether controlled by human gesture or system animation. Components that
37
+ * accept this state can respond to both input types uniformly.
38
+ */
39
+ export type ContinuousOperationState = {
40
+ /** Current phase of the operation */
41
+ phase: ContinuousOperationPhase;
42
+ /** Displacement from start position in pixels */
43
+ displacement: Vector2;
44
+ /** Current velocity in pixels per millisecond */
45
+ velocity: Vector2;
46
+ };
47
+ /**
48
+ * Initial idle state for ContinuousOperationState.
49
+ */
50
+ export declare const IDLE_CONTINUOUS_OPERATION_STATE: ContinuousOperationState;
51
+ /**
52
+ * Convert SwipeInputPhase to ContinuousOperationPhase.
53
+ * - "idle" → "idle"
54
+ * - "tracking" | "swiping" → "operating"
55
+ * - "ended" → "ended"
56
+ */
57
+ export declare function toContinuousPhase(phase: SwipeInputPhase): ContinuousOperationPhase;
58
+ /**
59
+ * Convert SwipeInputState to ContinuousOperationState.
60
+ */
61
+ export declare function toContinuousOperationState(state: SwipeInputState): ContinuousOperationState;
62
+ /**
63
+ * Phase of swipe input lifecycle.
64
+ * - "idle": No swipe in progress
65
+ * - "tracking": Pointer down, tracking movement (direction not yet locked)
66
+ * - "swiping": Direction locked, actively swiping
67
+ * - "ended": Swipe gesture completed
68
+ */
69
+ export type SwipeInputPhase = "idle" | "tracking" | "swiping" | "ended";
27
70
  /**
28
71
  * Point with timestamp for velocity calculation.
29
72
  */
@@ -38,3 +38,22 @@ export type GestureContainerProps = React.HTMLAttributes<HTMLElement> & {
38
38
  * @returns Merged container props with combined styles and handlers
39
39
  */
40
40
  export declare const mergeGestureContainerProps: (...propsArray: GestureContainerProps[]) => GestureContainerProps;
41
+ /**
42
+ * Check if an element is scrollable in any direction.
43
+ */
44
+ export declare function isScrollableElement(element: HTMLElement): boolean;
45
+ /**
46
+ * Check if we should start drag based on scroll state.
47
+ * Returns false if the target is inside a scrollable element.
48
+ */
49
+ export declare function shouldStartDrag(event: React.PointerEvent, container: HTMLElement): boolean;
50
+ /**
51
+ * Check if an element or its ancestors are scrollable in the specified direction.
52
+ * Returns true if scrolling is possible and would block the swipe gesture.
53
+ *
54
+ * @param element - The target element to check
55
+ * @param container - The container boundary
56
+ * @param axis - The axis to check ("x" or "y")
57
+ * @param direction - The swipe direction (1 = right/down, -1 = left/up)
58
+ */
59
+ export declare function isScrollableInDirection(element: HTMLElement, container: HTMLElement, axis: "x" | "y", direction: 1 | -1): boolean;
@@ -17,6 +17,8 @@ export declare const easings: {
17
17
  readonly easeOutQuart: (t: number) => number;
18
18
  /** Ease in out cubic */
19
19
  readonly easeInOutCubic: (t: number) => number;
20
+ /** Ease in expo (accelerating, for "suck in" effect) */
21
+ readonly easeInExpo: (t: number) => number;
20
22
  };
21
23
  /**
22
24
  * Animation state passed to callbacks.
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Result from useOperationContinuity hook.
3
+ */
4
+ export type UseOperationContinuityResult<T> = {
5
+ /** The effective value (retained during operation, current after) */
6
+ value: T;
7
+ /**
8
+ * True if the value changed during the operation.
9
+ *
10
+ * This is useful for determining how to handle the transition when the
11
+ * operation ends. For example, if the role changed during a swipe,
12
+ * the target position change at operation end should snap rather than animate.
13
+ *
14
+ * This flag is true on the render where shouldRetainPrevious becomes false
15
+ * (operation end), allowing consumers to handle the transition appropriately.
16
+ * It resets to false on subsequent renders.
17
+ */
18
+ changedDuringOperation: boolean;
19
+ /**
20
+ * True on the render where the operation just ended.
21
+ *
22
+ * This is true when shouldRetainPrevious transitions from true to false,
23
+ * regardless of whether the value changed. Use this to detect the moment
24
+ * when an operation completes and delay any immediate animations.
25
+ *
26
+ * In the over-swipe case, this helps prevent unwanted snap-back animation
27
+ * in the intermediate render before navigation changes.
28
+ */
29
+ operationJustEnded: boolean;
30
+ };
31
+ /**
32
+ * Hook for maintaining value continuity during continuous operations.
33
+ *
34
+ * When an operation is in progress, this hook retains the previous value
35
+ * to prevent sudden visual changes from state updates. Once the operation
36
+ * ends (shouldRetainPrevious becomes false), the new value is accepted.
37
+ *
38
+ * Additionally, this hook tracks whether the value changed during the operation,
39
+ * which is useful for determining animation behavior at operation end.
40
+ *
41
+ * IMPORTANT: This hook is designed to be idempotent during render to work
42
+ * correctly with React StrictMode, which calls the render function twice.
43
+ * All ref mutations happen in useLayoutEffect, not during render.
44
+ *
45
+ * @param value - The current value from external state
46
+ * @param shouldRetainPrevious - Whether to retain the previous value (true during operation)
47
+ * @returns Object with effective value and whether it changed during operation
48
+ *
49
+ * @example
50
+ * ```tsx
51
+ * // Maintain role continuity during swipe
52
+ * const { value: effectiveRole, changedDuringOperation } = useOperationContinuity(
53
+ * role,
54
+ * displacement > 0,
55
+ * );
56
+ *
57
+ * // Use changedDuringOperation to skip animation on operation end
58
+ * useSwipeContentTransform({
59
+ * // ...
60
+ * skipTargetChangeAnimation: changedDuringOperation,
61
+ * });
62
+ * ```
63
+ */
64
+ export declare function useOperationContinuity<T>(value: T, shouldRetainPrevious: boolean): UseOperationContinuityResult<T>;
@@ -1,15 +1,47 @@
1
1
  /**
2
2
  * @file Shared useResizeObserver hook with cached observer instances.
3
+ *
4
+ * Provides element size observation with shared observers for memory efficiency.
5
+ * Size becomes available after the first useLayoutEffect cycle completes.
6
+ *
7
+ * Note: Due to React's effect execution order (children before parents),
8
+ * child components may see containerSize=0 on their first effect run.
9
+ * This is a React constraint, not a bug. Consumers should check for
10
+ * valid size before using it for calculations like animation positions.
3
11
  */
4
12
  import * as React from "react";
13
+ /**
14
+ * Clear observer cache. Exported for testing purposes.
15
+ */
16
+ export declare function clearObserverCache(): void;
5
17
  /**
6
18
  * Observe size changes for a given element reference using shared resize observers.
7
19
  *
8
20
  * @param ref - Ref holding the element whose size to monitor.
9
21
  * @param options - Resize observer configuration.
10
22
  * @returns Latest resize entry and a derived DOMRect snapshot.
23
+ *
24
+ * @remarks
25
+ * The `rect` will be `null` on the first render. After the initial
26
+ * useLayoutEffect runs and triggers a re-render, `rect` will contain
27
+ * the measured size.
28
+ *
29
+ * Due to React's effect execution order, child components' effects run
30
+ * before parent effects. If you pass `rect.width` to a child as a prop,
31
+ * the child's first effect will see `0` (or whatever default you use).
32
+ * This is expected React behavior.
33
+ *
34
+ * @example
35
+ * ```tsx
36
+ * const containerRef = useRef<HTMLDivElement>(null);
37
+ * const { rect } = useResizeObserver(containerRef, { box: "border-box" });
38
+ * const width = rect?.width ?? 0;
39
+ *
40
+ * // Check if size is ready before using for calculations
41
+ * const isReady = rect !== null;
42
+ * ```
11
43
  */
12
44
  export declare function useResizeObserver<T extends HTMLElement>(ref: React.RefObject<T | null>, { box }: ResizeObserverOptions): {
13
45
  entry: ResizeObserverEntry | null;
14
- rect: DOMRectReadOnly | null;
46
+ rect: DOMRect | null;
15
47
  };
@@ -0,0 +1,112 @@
1
+ /**
2
+ * @file Hook for View Transitions API shared element animations.
3
+ *
4
+ * Enables smooth morph animations between a source element (e.g., card)
5
+ * and a target element (e.g., expanded view) using CSS view-transition-name.
6
+ * Supports swipe-to-dismiss with the expanded view animating back to source.
7
+ */
8
+ import * as React from "react";
9
+ /**
10
+ * Check if View Transitions API is supported.
11
+ */
12
+ export declare function supportsViewTransitions(): boolean;
13
+ type ViewTransitionHandle = {
14
+ finished: Promise<void>;
15
+ ready: Promise<void>;
16
+ updateCallbackDone: Promise<void>;
17
+ skipTransition: () => void;
18
+ };
19
+ /**
20
+ * Start a view transition with the given callback.
21
+ */
22
+ export declare function startViewTransition(callback: () => void): ViewTransitionHandle | null;
23
+ /**
24
+ * Options for useSharedElementTransition hook.
25
+ */
26
+ export type UseSharedElementTransitionOptions<T> = {
27
+ /**
28
+ * Function to generate a unique transition name for an item.
29
+ * Multiple names can be returned for nested shared elements.
30
+ */
31
+ getTransitionName: (item: T) => string | string[];
32
+ /**
33
+ * Function to get a unique key for comparison.
34
+ * Defaults to using getTransitionName result.
35
+ */
36
+ getKey?: (item: T) => string;
37
+ /** Enable swipe to dismiss. @default true */
38
+ swipeDismissible?: boolean;
39
+ /** Threshold ratio (0-1) to trigger dismiss. @default 0.3 */
40
+ dismissThreshold?: number;
41
+ };
42
+ /** 2D vector */
43
+ type Vector2 = {
44
+ x: number;
45
+ y: number;
46
+ };
47
+ /**
48
+ * Result from useSharedElementTransition hook.
49
+ */
50
+ export type UseSharedElementTransitionResult<T> = {
51
+ /** Currently expanded item, or null if none */
52
+ expandedItem: T | null;
53
+ /** Expand an item with view transition */
54
+ expand: (item: T) => void;
55
+ /** Collapse the expanded item with view transition */
56
+ collapse: () => void;
57
+ /**
58
+ * Get style props for a source element (e.g., card).
59
+ */
60
+ getSourceProps: (item: T, nameIndex?: number) => {
61
+ style: React.CSSProperties;
62
+ };
63
+ /**
64
+ * Get style props for the target element (e.g., expanded view).
65
+ * Includes transform for swipe tracking.
66
+ */
67
+ getTargetProps: (nameIndex?: number) => {
68
+ style: React.CSSProperties;
69
+ };
70
+ /**
71
+ * Get swipe container props (onPointerDown, style).
72
+ * Apply to the swipeable container element.
73
+ */
74
+ getSwipeContainerProps: () => React.HTMLAttributes<HTMLElement> & {
75
+ style: React.CSSProperties;
76
+ };
77
+ /** Whether currently being swiped */
78
+ isSwiping: boolean;
79
+ /** Current displacement during swipe */
80
+ displacement: Vector2;
81
+ /** Whether View Transitions API is supported */
82
+ isSupported: boolean;
83
+ };
84
+ /**
85
+ * Hook for managing shared element transitions using View Transitions API.
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * const {
90
+ * expandedItem, expand, collapse,
91
+ * getSourceProps, getTargetProps, getSwipeContainerProps
92
+ * } = useSharedElementTransition({
93
+ * getTransitionName: (album) => [`album-${album.id}`, `album-art-${album.id}`],
94
+ * });
95
+ *
96
+ * // Source (card)
97
+ * <div {...getSourceProps(album, 0)}>
98
+ * <img {...getSourceProps(album, 1)} />
99
+ * </div>
100
+ *
101
+ * // Target (expanded view) - apply swipe props to container
102
+ * {expandedItem && (
103
+ * <div {...getSwipeContainerProps()}>
104
+ * <div {...getTargetProps(0)}>
105
+ * <img {...getTargetProps(1)} />
106
+ * </div>
107
+ * </div>
108
+ * )}
109
+ * ```
110
+ */
111
+ export declare function useSharedElementTransition<T>(options: UseSharedElementTransitionOptions<T>): UseSharedElementTransitionResult<T>;
112
+ export {};
@@ -19,7 +19,7 @@ export type UseSwipeContentTransformOptions = {
19
19
  /** Current swipe displacement in pixels */
20
20
  displacement: number;
21
21
  /** Whether swipe gesture is active */
22
- isSwiping: boolean;
22
+ isOperating: boolean;
23
23
  /** Axis of transformation */
24
24
  axis?: GestureAxis;
25
25
  /** Duration of snap animation in ms */
@@ -38,6 +38,13 @@ export type UseSwipeContentTransformOptions = {
38
38
  * Use this for push animations where new panel comes from off-screen.
39
39
  */
40
40
  initialPx?: number;
41
+ /**
42
+ * Skip animation when targetPx changes.
43
+ * Use this when the target changed during an operation (from useOperationContinuity).
44
+ * When true, target changes will snap instead of animate.
45
+ * @default false
46
+ */
47
+ skipTargetChangeAnimation?: boolean;
41
48
  };
42
49
  /**
43
50
  * Animation direction information.
@@ -72,7 +79,7 @@ export type UseSwipeContentTransformResult = {
72
79
  * elementRef: containerRef,
73
80
  * targetPx: 0,
74
81
  * displacement: inputState.displacement.x,
75
- * isSwiping: inputState.phase === "swiping",
82
+ * isOperating: inputState.phase === "swiping",
76
83
  * });
77
84
  * ```
78
85
  */
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./GridLayout-B4VRsC0r.cjs"),t=require("./FloatingWindow-TCDNY5gE.cjs"),s=require("./HorizontalDivider-B5Z-KZLk.cjs"),u=require("./ResizeHandle-CScipO5l.cjs"),l=require("react"),c=require("./useFloatingState-C4kRaW_R.cjs"),d=require("./styles-qf6ptVLD.cjs"),i=require("./PanelSystem-Bs8bQwQF.cjs");function y(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const S=y(l),g=()=>{const{layerId:e}=t.useLayerInstance(),{getLayerHandleProps:r}=t.useGridLayoutContext();return S.useMemo(()=>r(e),[r,e])};exports.GridLayout=o.GridLayout;exports.Drawer=t.Drawer;exports.DrawerLayers=t.DrawerLayers;exports.FloatingWindow=t.FloatingWindow;exports.runTransition=t.runTransition;exports.useTransitionState=t.useTransitionState;exports.HorizontalDivider=s.HorizontalDivider;exports.ResizeHandle=u.ResizeHandle;exports.useFloatingState=c.useFloatingState;exports.CSS_VAR_PREFIX=d.CSS_VAR_PREFIX;exports.PanelSystem=i.PanelSystem;exports.buildInitialState=i.buildInitialState;exports.useLayerDragHandle=g;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./GridLayout-DKTg_N61.cjs"),t=require("./FloatingWindow-DMwyK0eK.cjs"),s=require("./HorizontalDivider-_pgV4Mcv.cjs"),u=require("./ResizeHandle-CBcAS918.cjs"),l=require("react"),c=require("./useFloatingState-C4kRaW_R.cjs"),d=require("./styles-qf6ptVLD.cjs"),i=require("./PanelSystem-D603LKKv.cjs");function y(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const S=y(l),g=()=>{const{layerId:e}=t.useLayerInstance(),{getLayerHandleProps:r}=t.useGridLayoutContext();return S.useMemo(()=>r(e),[r,e])};exports.GridLayout=o.GridLayout;exports.Drawer=t.Drawer;exports.DrawerLayers=t.DrawerLayers;exports.FloatingWindow=t.FloatingWindow;exports.runTransition=t.runTransition;exports.useTransitionState=t.useTransitionState;exports.HorizontalDivider=s.HorizontalDivider;exports.ResizeHandle=u.ResizeHandle;exports.useFloatingState=c.useFloatingState;exports.CSS_VAR_PREFIX=d.CSS_VAR_PREFIX;exports.PanelSystem=i.PanelSystem;exports.buildInitialState=i.buildInitialState;exports.useLayerDragHandle=g;
2
2
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
- import { G as m } from "./GridLayout-BltqeCPK.js";
2
- import { a as e, u as t } from "./FloatingWindow-BpdOpg_L.js";
3
- import { D as l, b as d, F as f, r as x, c as y } from "./FloatingWindow-BpdOpg_L.js";
4
- import { H as L } from "./HorizontalDivider-WF1k_qND.js";
5
- import { R as D } from "./ResizeHandle-CdA_JYfN.js";
1
+ import { G as m } from "./GridLayout-UWNxXw77.js";
2
+ import { a as e, u as t } from "./FloatingWindow-CUXnEtrb.js";
3
+ import { D as l, b as d, F as f, r as x, c as y } from "./FloatingWindow-CUXnEtrb.js";
4
+ import { H as L } from "./HorizontalDivider-DdxzfV0l.js";
5
+ import { R as D } from "./ResizeHandle-CXjc1meV.js";
6
6
  import * as o from "react";
7
7
  import { u as R } from "./useFloatingState-tEfA_wbc.js";
8
- import { C as F } from "./styles-DPPuJ0sf.js";
9
- import { P, v as w } from "./PanelSystem-Dr1TBhxM.js";
8
+ import { C as F } from "./styles-NkjuMOVS.js";
9
+ import { P, v as w } from "./PanelSystem-BqUzNtf2.js";
10
10
  const n = () => {
11
11
  const { layerId: r } = e(), { getLayerHandleProps: a } = t();
12
12
  return o.useMemo(() => a(r), [a, r]);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @file AlertDialog component for alert, confirm, and prompt dialogs
3
+ */
4
+ import * as React from "react";
5
+ import type { AlertDialogProps } from "./types";
6
+ /**
7
+ * Internal component for alert, confirm, and prompt dialogs
8
+ */
9
+ export declare const AlertDialog: React.FC<AlertDialogProps>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @file Base dialog container component using native <dialog> element
3
+ */
4
+ import * as React from "react";
5
+ import type { DialogContainerProps } from "./types.js";
6
+ /**
7
+ * Base container for dialog-based overlays using native <dialog> element.
8
+ * Opens in the browser's top layer, ensuring it appears above all other content.
9
+ *
10
+ * Supports three transition modes:
11
+ * - "none": No animation
12
+ * - "css": CSS-based fade/scale animation (default)
13
+ * - "swipe": Swipeable with multi-phase animation
14
+ *
15
+ * @example
16
+ * ```tsx
17
+ * <DialogContainer
18
+ * visible={isOpen}
19
+ * onClose={() => setIsOpen(false)}
20
+ * >
21
+ * <div>Dialog content</div>
22
+ * </DialogContainer>
23
+ * ```
24
+ *
25
+ * @example Swipeable dialog
26
+ * ```tsx
27
+ * <DialogContainer
28
+ * visible={isOpen}
29
+ * onClose={() => setIsOpen(false)}
30
+ * transitionMode="swipe"
31
+ * openDirection="bottom"
32
+ * >
33
+ * <div>Swipe down to close</div>
34
+ * </DialogContainer>
35
+ * ```
36
+ */
37
+ export declare const DialogContainer: React.FC<DialogContainerProps>;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @file Modal component - Centered modal dialog with optional chrome
3
+ */
4
+ import * as React from "react";
5
+ import type { ModalProps } from "./types";
6
+ /**
7
+ * Modal component for displaying centered dialogs.
8
+ * Uses native <dialog> element for proper accessibility and top-layer rendering.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const [isOpen, setIsOpen] = useState(false);
13
+ *
14
+ * <Modal
15
+ * visible={isOpen}
16
+ * onClose={() => setIsOpen(false)}
17
+ * header={{ title: "Settings" }}
18
+ * >
19
+ * <form>
20
+ * <input type="text" placeholder="Name" />
21
+ * <button type="submit">Save</button>
22
+ * </form>
23
+ * </Modal>
24
+ * ```
25
+ */
26
+ export declare const Modal: React.FC<ModalProps>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @file Swipeable dialog container component.
3
+ *
4
+ * This component extends the base dialog functionality with swipe-to-dismiss
5
+ * and multi-phase animations. It uses native <dialog> element for top layer
6
+ * positioning and custom transform animations.
7
+ */
8
+ import * as React from "react";
9
+ import type { DialogContainerProps } from "./types.js";
10
+ /**
11
+ * Swipeable dialog container with multi-phase animation.
12
+ *
13
+ * Uses native <dialog> for top layer positioning and custom JS animations
14
+ * for swipe-to-dismiss functionality.
15
+ */
16
+ export declare const SwipeDialogContainer: React.FC<DialogContainerProps>;
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @file Dialog animation utilities
3
+ *
4
+ * Provides multi-phase animation calculations and viewTransition support
5
+ * for dialog open/close animations with "suck in" effect.
6
+ */
7
+ /**
8
+ * Direction from which the dialog opens.
9
+ * The close animation uses the opposite direction.
10
+ */
11
+ export type DialogOpenDirection = "center" | "top" | "bottom" | "left" | "right";
12
+ /**
13
+ * Transform values for dialog animation.
14
+ */
15
+ export type DialogTransform = {
16
+ /** Translate value in pixels (x or y depending on direction) */
17
+ translate: number;
18
+ /** Scale value (1 = normal, 0.85 = final suck-in) */
19
+ scale: number;
20
+ /** Backdrop opacity (1 = fully visible, 0 = transparent) */
21
+ backdropOpacity: number;
22
+ };
23
+ /**
24
+ * Axis for the dialog animation based on direction.
25
+ */
26
+ export type DialogAnimationAxis = "x" | "y";
27
+ /**
28
+ * Get the animation axis for a given direction.
29
+ */
30
+ export declare function getAnimationAxis(direction: DialogOpenDirection): DialogAnimationAxis;
31
+ /**
32
+ * Get the sign multiplier for translate based on direction.
33
+ * Positive means moving in the positive axis direction.
34
+ */
35
+ export declare function getDirectionSign(direction: DialogOpenDirection): number;
36
+ /**
37
+ * Compute the close animation transform values.
38
+ *
39
+ * The close animation has two phases:
40
+ * - Phase 1 (0-70%): Translate movement with easeOutExpo (natural deceleration)
41
+ * - Phase 2 (70-100%): Scale shrink + accelerated translate with easeInExpo ("suck in" effect)
42
+ *
43
+ * @param progress - Animation progress (0 = open, 1 = fully closed)
44
+ * @param containerSize - Size of the container in the animation direction (width or height)
45
+ * @param direction - Direction the dialog is closing towards
46
+ * @returns Transform values for the current progress
47
+ */
48
+ export declare function computeCloseTransform(progress: number, containerSize: number, direction?: DialogOpenDirection): DialogTransform;
49
+ /**
50
+ * Compute the open animation transform values.
51
+ * This is the reverse of the close animation.
52
+ *
53
+ * @param progress - Animation progress (0 = closed, 1 = fully open)
54
+ * @param containerSize - Size of the container in the animation direction
55
+ * @param direction - Direction the dialog is opening from
56
+ * @returns Transform values for the current progress
57
+ */
58
+ export declare function computeOpenTransform(progress: number, containerSize: number, direction?: DialogOpenDirection): DialogTransform;
59
+ /**
60
+ * Compute transform values during a swipe gesture.
61
+ * This provides real-time feedback as the user swipes.
62
+ *
63
+ * @param displacement - Current swipe displacement in pixels
64
+ * @param containerSize - Size of the container in the animation direction
65
+ * @returns Transform values for current swipe state
66
+ */
67
+ export declare function computeSwipeTransform(displacement: number, containerSize: number): DialogTransform;
68
+ /**
69
+ * Check if the swipe should trigger a dismiss action.
70
+ *
71
+ * @param displacement - Final swipe displacement in pixels
72
+ * @param velocity - Final swipe velocity in px/ms
73
+ * @param containerSize - Size of the container
74
+ * @param threshold - Threshold ratio (0-1) for dismiss (default: 0.3)
75
+ * @returns Whether the dialog should be dismissed
76
+ */
77
+ export declare function shouldDismiss(displacement: number, velocity: number, containerSize: number, threshold?: number): boolean;
78
+ /**
79
+ * Get the close direction based on swipe displacement.
80
+ * The dialog closes in the direction of the swipe.
81
+ *
82
+ * @param displacementX - Horizontal displacement
83
+ * @param displacementY - Vertical displacement
84
+ * @param defaultDirection - Default direction if no clear winner
85
+ * @returns The determined close direction
86
+ */
87
+ export declare function getCloseDirectionFromSwipe(displacementX: number, displacementY: number, defaultDirection?: DialogOpenDirection): DialogOpenDirection;
88
+ /**
89
+ * Check if View Transitions API is supported.
90
+ */
91
+ export declare function supportsViewTransitions(): boolean;
92
+ /**
93
+ * Execute a callback with View Transitions API, with fallback.
94
+ *
95
+ * @param callback - The DOM-changing callback to wrap
96
+ * @returns Promise<boolean> - true if viewTransition was used, false if fallback
97
+ */
98
+ export declare function safeViewTransition(callback: () => void): Promise<boolean>;
99
+ /**
100
+ * Build CSS transform string from transform values.
101
+ *
102
+ * @param transform - Transform values
103
+ * @param axis - Animation axis ('x' or 'y')
104
+ * @returns CSS transform string
105
+ */
106
+ export declare function buildTransformString(transform: DialogTransform, axis: DialogAnimationAxis): string;
107
+ /**
108
+ * Build CSS for backdrop based on transform values.
109
+ *
110
+ * @param transform - Transform values
111
+ * @returns CSS properties for backdrop
112
+ */
113
+ export declare function buildBackdropStyle(transform: DialogTransform): React.CSSProperties;