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.
- package/dist/{FloatingPanelFrame-SgYLc6Ud.js → FloatingPanelFrame-3eU9AwPo.js} +2 -2
- package/dist/{FloatingPanelFrame-SgYLc6Ud.js.map → FloatingPanelFrame-3eU9AwPo.js.map} +1 -1
- package/dist/FloatingWindow-Bw2djgpz.js +1542 -0
- package/dist/FloatingWindow-Bw2djgpz.js.map +1 -0
- package/dist/FloatingWindow-Cvyokf0m.cjs +2 -0
- package/dist/FloatingWindow-Cvyokf0m.cjs.map +1 -0
- package/dist/GridLayout-B4aCqSyd.js +947 -0
- package/dist/{GridLayout-BltqeCPK.js.map → GridLayout-B4aCqSyd.js.map} +1 -1
- package/dist/GridLayout-DNOClFzz.cjs +2 -0
- package/dist/{GridLayout-B4VRsC0r.cjs.map → GridLayout-DNOClFzz.cjs.map} +1 -1
- package/dist/{HorizontalDivider-WF1k_qND.js → HorizontalDivider-DdxzfV0l.js} +3 -3
- package/dist/{HorizontalDivider-WF1k_qND.js.map → HorizontalDivider-DdxzfV0l.js.map} +1 -1
- package/dist/{HorizontalDivider-B5Z-KZLk.cjs → HorizontalDivider-_pgV4Mcv.cjs} +2 -2
- package/dist/{HorizontalDivider-B5Z-KZLk.cjs.map → HorizontalDivider-_pgV4Mcv.cjs.map} +1 -1
- package/dist/PanelSystem-B8Igvnb2.cjs +3 -0
- package/dist/PanelSystem-B8Igvnb2.cjs.map +1 -0
- package/dist/{PanelSystem-Dr1TBhxM.js → PanelSystem-DDUSFjXD.js} +209 -248
- package/dist/PanelSystem-DDUSFjXD.js.map +1 -0
- package/dist/ResizeHandle-CBcAS918.cjs +2 -0
- package/dist/{ResizeHandle-CScipO5l.cjs.map → ResizeHandle-CBcAS918.cjs.map} +1 -1
- package/dist/{ResizeHandle-CdA_JYfN.js → ResizeHandle-CXjc1meV.js} +28 -29
- package/dist/{ResizeHandle-CdA_JYfN.js.map → ResizeHandle-CXjc1meV.js.map} +1 -1
- package/dist/SwipePivotTabBar-DWrCuwEI.js +411 -0
- package/dist/SwipePivotTabBar-DWrCuwEI.js.map +1 -0
- package/dist/SwipePivotTabBar-fjjXkpj7.cjs +2 -0
- package/dist/SwipePivotTabBar-fjjXkpj7.cjs.map +1 -0
- package/dist/components/gesture/SwipeSafeZone.d.ts +40 -0
- package/dist/components/window/Drawer.d.ts +4 -1
- package/dist/components/window/DrawerLayers.d.ts +1 -1
- package/dist/components/window/DrawerRevealContext.d.ts +61 -0
- package/dist/components/window/drawerRevealAnimationUtils.d.ts +212 -0
- package/dist/components/window/drawerStyles.d.ts +74 -0
- package/dist/components/window/drawerSwipeConfig.d.ts +29 -0
- package/dist/components/window/useDrawerSwipeTransform.d.ts +29 -0
- package/dist/components/window/useDrawerTransform.d.ts +68 -0
- package/dist/components/window/useRevealDrawerTransform.d.ts +56 -0
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +9 -8
- package/dist/config.js.map +1 -1
- package/dist/constants/styles.d.ts +17 -0
- package/dist/dialog/index.d.ts +69 -0
- package/dist/floating.js +1 -1
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +2 -2
- package/dist/hooks/gesture/testing/createGestureSimulator.d.ts +7 -0
- package/dist/hooks/gesture/types.d.ts +48 -5
- package/dist/hooks/gesture/utils.d.ts +19 -0
- package/dist/hooks/useAnimationFrame.d.ts +2 -0
- package/dist/hooks/useOperationContinuity.d.ts +64 -0
- package/dist/hooks/useResizeObserver.d.ts +33 -1
- package/dist/hooks/useSharedElementTransition.d.ts +112 -0
- package/dist/hooks/useSwipeContentTransform.d.ts +9 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/dist/modules/dialog/AlertDialog.d.ts +9 -0
- package/dist/modules/dialog/DialogContainer.d.ts +37 -0
- package/dist/modules/dialog/Modal.d.ts +26 -0
- package/dist/modules/dialog/SwipeDialogContainer.d.ts +16 -0
- package/dist/modules/dialog/dialogAnimationUtils.d.ts +113 -0
- package/dist/modules/dialog/types.d.ts +183 -0
- package/dist/modules/dialog/useDialog.d.ts +39 -0
- package/dist/modules/dialog/useDialogContainer.d.ts +47 -0
- package/dist/modules/dialog/useDialogSwipeInput.d.ts +70 -0
- package/dist/modules/dialog/useDialogTransform.d.ts +82 -0
- package/dist/modules/drawer/drawerStateMachine.d.ts +168 -0
- package/dist/modules/drawer/revealDrawerConstants.d.ts +33 -0
- package/dist/modules/drawer/revealDrawerStateMachine.d.ts +146 -0
- package/dist/modules/drawer/strategies/index.d.ts +8 -0
- package/dist/modules/drawer/strategies/overlayStrategy.d.ts +12 -0
- package/dist/modules/drawer/strategies/revealStrategy.d.ts +12 -0
- package/dist/modules/drawer/strategies/types.d.ts +116 -0
- package/dist/modules/drawer/types.d.ts +74 -0
- package/dist/modules/drawer/useDrawerSwipeInput.d.ts +24 -0
- package/dist/modules/pivot/SwipePivotTabBar.d.ts +3 -0
- package/dist/modules/stack/SwipeStackContent.d.ts +6 -3
- package/dist/modules/stack/SwipeStackOutlet.d.ts +4 -4
- package/dist/modules/stack/computeSwipeStackTransform.d.ts +1 -1
- package/dist/panels.cjs +1 -1
- package/dist/panels.js +1 -1
- package/dist/pivot.cjs +1 -1
- package/dist/pivot.js +1 -1
- package/dist/resizer.cjs +1 -1
- package/dist/resizer.js +2 -2
- package/dist/stack.cjs +1 -1
- package/dist/stack.cjs.map +1 -1
- package/dist/stack.js +480 -780
- package/dist/stack.js.map +1 -1
- package/dist/sticky-header/calculateStickyMetrics.d.ts +28 -0
- package/dist/sticky-header.cjs +1 -1
- package/dist/sticky-header.cjs.map +1 -1
- package/dist/sticky-header.js +59 -51
- package/dist/sticky-header.js.map +1 -1
- package/dist/{styles-DPPuJ0sf.js → styles-NkjuMOVS.js} +13 -13
- package/dist/{styles-DPPuJ0sf.js.map → styles-NkjuMOVS.js.map} +1 -1
- package/dist/styles-qf6ptVLD.cjs.map +1 -1
- package/dist/types.d.ts +30 -0
- package/dist/useAnimationFrame-BZ6D2lMq.cjs +2 -0
- package/dist/useAnimationFrame-BZ6D2lMq.cjs.map +1 -0
- package/dist/useAnimationFrame-Bg4e-H8O.js +394 -0
- package/dist/useAnimationFrame-Bg4e-H8O.js.map +1 -0
- package/dist/useDocumentPointerEvents-DXxw3qWj.js +54 -0
- package/dist/useDocumentPointerEvents-DXxw3qWj.js.map +1 -0
- package/dist/useDocumentPointerEvents-DxDSOtip.cjs +2 -0
- package/dist/useDocumentPointerEvents-DxDSOtip.cjs.map +1 -0
- package/dist/window/index.d.ts +2 -0
- package/dist/window.cjs +1 -1
- package/dist/window.cjs.map +1 -1
- package/dist/window.js +114 -103
- package/dist/window.js.map +1 -1
- package/package.json +6 -1
- package/src/components/gesture/SwipeSafeZone.tsx +70 -0
- package/src/components/grid/GridLayout.tsx +110 -38
- package/src/components/window/Drawer.tsx +353 -162
- package/src/components/window/DrawerLayers.tsx +54 -11
- package/src/components/window/DrawerRevealContext.spec.ts +20 -0
- package/src/components/window/DrawerRevealContext.tsx +99 -0
- package/src/components/window/drawerRevealAnimationUtils.spec.ts +375 -0
- package/src/components/window/drawerRevealAnimationUtils.ts +415 -0
- package/src/components/window/drawerStyles.spec.ts +302 -0
- package/src/components/window/drawerStyles.ts +252 -0
- package/src/components/window/drawerSwipeConfig.spec.ts +131 -0
- package/src/components/window/drawerSwipeConfig.ts +112 -0
- package/src/components/window/useDrawerSwipeTransform.ts +67 -0
- package/src/components/window/useDrawerTransform.ts +505 -0
- package/src/components/window/useRevealDrawerTransform.spec.ts +1936 -0
- package/src/components/window/useRevealDrawerTransform.ts +105 -0
- package/src/constants/styles.ts +19 -0
- package/src/demo/components/FullscreenDemoPage.tsx +47 -0
- package/src/demo/fullscreenRoutes.tsx +32 -0
- package/src/demo/index.tsx +5 -0
- package/src/demo/pages/Dialog/alerts/index.tsx +22 -0
- package/src/demo/pages/Dialog/card/index.tsx +22 -0
- package/src/demo/pages/Dialog/components/AlertDialogDemo.tsx +124 -0
- package/src/demo/pages/Dialog/components/CardExpandDemo.module.css +243 -0
- package/src/demo/pages/Dialog/components/CardExpandDemo.tsx +219 -0
- package/src/demo/pages/Dialog/components/CustomAlertDialogDemo.tsx +219 -0
- package/src/demo/pages/Dialog/components/DialogDemos.module.css +77 -0
- package/src/demo/pages/Dialog/components/ModalBasics.tsx +45 -0
- package/src/demo/pages/Dialog/components/SwipeDialogDemo.module.css +77 -0
- package/src/demo/pages/Dialog/components/SwipeDialogDemo.tsx +181 -0
- package/src/demo/pages/Dialog/custom-alert/index.tsx +22 -0
- package/src/demo/pages/Dialog/modal/index.tsx +17 -0
- package/src/demo/pages/Dialog/swipe/index.tsx +22 -0
- package/src/demo/pages/Drawer/components/DrawerBasics.module.css +6 -1
- package/src/demo/pages/Drawer/components/DrawerBasics.tsx +14 -4
- package/src/demo/pages/Drawer/components/DrawerReveal.module.css +157 -0
- package/src/demo/pages/Drawer/components/DrawerReveal.tsx +128 -0
- package/src/demo/pages/Drawer/components/DrawerSwipe.module.css +316 -0
- package/src/demo/pages/Drawer/components/DrawerSwipe.tsx +178 -0
- package/src/demo/pages/Drawer/reveal/index.tsx +17 -0
- package/src/demo/pages/Drawer/reveal-fullscreen/index.tsx +135 -0
- package/src/demo/pages/Drawer/reveal-fullscreen/styles.module.css +233 -0
- package/src/demo/pages/Drawer/swipe/index.tsx +17 -0
- package/src/demo/pages/Pivot/components/SwipeTabsPivot.tsx +54 -23
- package/src/demo/pages/Pivot/swipe-debug/index.tsx +1 -1
- package/src/demo/pages/Stack/components/StackBasics.spec.tsx +156 -0
- package/src/demo/pages/Stack/components/StackBasics.tsx +179 -95
- package/src/demo/pages/Stack/components/StackTablet.spec.tsx +110 -0
- package/src/demo/pages/Stack/components/StackTablet.tsx +42 -21
- package/src/demo/routes.tsx +24 -1
- package/src/dialog/index.ts +85 -0
- package/src/hooks/gesture/testing/createGestureSimulator.spec.ts +68 -64
- package/src/hooks/gesture/testing/createGestureSimulator.ts +113 -37
- package/src/hooks/gesture/types.ts +83 -6
- package/src/hooks/gesture/useEdgeSwipeInput.spec.ts +22 -14
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +99 -31
- package/src/hooks/gesture/useNativeGestureGuard.ts +3 -1
- package/src/hooks/gesture/utils.ts +102 -0
- package/src/hooks/useAnimatedVisibility.spec.ts +44 -24
- package/src/hooks/useAnimatedVisibility.ts +28 -2
- package/src/hooks/useAnimationFrame.ts +8 -0
- package/src/hooks/useOperationContinuity.spec.ts +394 -0
- package/src/hooks/useOperationContinuity.ts +135 -0
- package/src/hooks/useResizeObserver.spec.tsx +277 -0
- package/src/hooks/useResizeObserver.tsx +108 -39
- package/src/hooks/useScrollContainer.ts +4 -10
- package/src/hooks/useSharedElementTransition.ts +354 -0
- package/src/hooks/useSwipeContentTransform.spec.ts +18 -18
- package/src/hooks/useSwipeContentTransform.ts +166 -28
- package/src/modules/dialog/AlertDialog.spec.tsx +387 -0
- package/src/modules/dialog/AlertDialog.tsx +221 -0
- package/src/modules/dialog/DialogContainer.spec.tsx +228 -0
- package/src/modules/dialog/DialogContainer.tsx +188 -0
- package/src/modules/dialog/Modal.spec.tsx +220 -0
- package/src/modules/dialog/Modal.tsx +182 -0
- package/src/modules/dialog/SwipeDialogContainer.tsx +208 -0
- package/src/modules/dialog/dialogAnimationUtils.spec.ts +252 -0
- package/src/modules/dialog/dialogAnimationUtils.ts +297 -0
- package/src/modules/dialog/types.ts +186 -0
- package/src/modules/dialog/useDialog.spec.tsx +447 -0
- package/src/modules/dialog/useDialog.ts +214 -0
- package/src/modules/dialog/useDialogContainer.spec.ts +339 -0
- package/src/modules/dialog/useDialogContainer.ts +150 -0
- package/src/modules/dialog/useDialogSwipeInput.spec.ts +178 -0
- package/src/modules/dialog/useDialogSwipeInput.ts +350 -0
- package/src/modules/dialog/useDialogTransform.spec.ts +403 -0
- package/src/modules/dialog/useDialogTransform.ts +407 -0
- package/src/modules/drawer/drawerStateMachine.ts +500 -0
- package/src/modules/drawer/revealDrawerConstants.ts +38 -0
- package/src/modules/drawer/revealDrawerStateMachine.spec.ts +558 -0
- package/src/modules/drawer/revealDrawerStateMachine.ts +197 -0
- package/src/modules/drawer/strategies/index.ts +9 -0
- package/src/modules/drawer/strategies/overlayStrategy.ts +133 -0
- package/src/modules/drawer/strategies/revealStrategy.ts +111 -0
- package/src/modules/drawer/strategies/types.ts +160 -0
- package/src/modules/drawer/types.ts +102 -0
- package/src/modules/drawer/useDrawerSwipeInput.spec.ts +566 -0
- package/src/modules/drawer/useDrawerSwipeInput.ts +402 -0
- package/src/modules/panels/rendering/ContentRegistry.spec.tsx +21 -14
- package/src/modules/pivot/SwipePivotContent.position.spec.tsx +12 -8
- package/src/modules/pivot/SwipePivotContent.spec.tsx +66 -25
- package/src/modules/pivot/SwipePivotContent.tsx +2 -2
- package/src/modules/pivot/SwipePivotTabBar.spec.tsx +85 -68
- package/src/modules/pivot/SwipePivotTabBar.tsx +75 -15
- package/src/modules/pivot/scaleInputState.spec.ts +11 -2
- package/src/modules/pivot/usePivot.spec.ts +17 -3
- package/src/modules/pivot/usePivotSwipeInput.spec.ts +182 -123
- package/src/modules/stack/SwipeStackContent.spec.tsx +387 -100
- package/src/modules/stack/SwipeStackContent.tsx +43 -33
- package/src/modules/stack/SwipeStackOutlet.spec.tsx +14 -16
- package/src/modules/stack/SwipeStackOutlet.tsx +6 -6
- package/src/modules/stack/computeSwipeStackTransform.spec.ts +5 -5
- package/src/modules/stack/computeSwipeStackTransform.ts +3 -3
- package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1133 -0
- package/src/modules/stack/useStackAnimationState.spec.ts +3 -1
- package/src/modules/stack/useStackAnimationState.ts +18 -13
- package/src/modules/stack/useStackNavigation.spec.ts +198 -3
- package/src/modules/stack/useStackNavigation.tsx +113 -56
- package/src/modules/stack/useStackSwipeInput.spec.ts +65 -32
- package/src/modules/stack/useStackSwipeInput.ts +1 -1
- package/src/sticky-header/StickyArea.tsx +29 -57
- package/src/sticky-header/calculateStickyMetrics.spec.ts +105 -0
- package/src/sticky-header/calculateStickyMetrics.ts +50 -0
- package/src/types.ts +33 -0
- package/src/window/index.ts +2 -0
- package/dist/FloatingWindow-BpdOpg_L.js +0 -400
- package/dist/FloatingWindow-BpdOpg_L.js.map +0 -1
- package/dist/FloatingWindow-TCDNY5gE.cjs +0 -2
- package/dist/FloatingWindow-TCDNY5gE.cjs.map +0 -1
- package/dist/GridLayout-B4VRsC0r.cjs +0 -2
- package/dist/GridLayout-BltqeCPK.js +0 -927
- package/dist/PanelSystem-Bs8bQwQF.cjs +0 -3
- package/dist/PanelSystem-Bs8bQwQF.cjs.map +0 -1
- package/dist/PanelSystem-Dr1TBhxM.js.map +0 -1
- package/dist/ResizeHandle-CScipO5l.cjs +0 -2
- package/dist/SwipePivotTabBar-BGO9X94m.js +0 -407
- package/dist/SwipePivotTabBar-BGO9X94m.js.map +0 -1
- package/dist/SwipePivotTabBar-BrQismcZ.cjs +0 -2
- package/dist/SwipePivotTabBar-BrQismcZ.cjs.map +0 -1
- package/dist/useDocumentPointerEvents-CKdhGXd0.js +0 -46
- package/dist/useDocumentPointerEvents-CKdhGXd0.js.map +0 -1
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs +0 -2
- package/dist/useDocumentPointerEvents-ChqrKXDk.cjs.map +0 -1
- package/dist/useEffectEvent-Dp7HLCf0.js +0 -13
- package/dist/useEffectEvent-Dp7HLCf0.js.map +0 -1
- package/dist/useEffectEvent-huSsGUnl.cjs +0 -2
- package/dist/useEffectEvent-huSsGUnl.cjs.map +0 -1
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Generic state machine for drawer animations.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a React-independent state machine for managing drawer
|
|
5
|
+
* transitions. It handles swipe gestures, button operations, and animations through
|
|
6
|
+
* a reducer pattern with typed actions.
|
|
7
|
+
*
|
|
8
|
+
* The position type is generic, allowing different drawer modes (reveal, overlay)
|
|
9
|
+
* to use the same state machine logic with mode-specific position calculations.
|
|
10
|
+
*
|
|
11
|
+
* Key design principles:
|
|
12
|
+
* - Pure functions: same input → same output
|
|
13
|
+
* - No React/DOM dependencies
|
|
14
|
+
* - Testable in isolation
|
|
15
|
+
* - Deterministic state transitions
|
|
16
|
+
*/
|
|
17
|
+
import type { DrawerTransformStrategy, DrawerStrategyConfig } from "./strategies/types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Phase of drawer animation lifecycle.
|
|
20
|
+
* - closed: Drawer is hidden
|
|
21
|
+
* - opening: Drawer is animating open
|
|
22
|
+
* - open: Drawer is fully visible
|
|
23
|
+
* - closing: Drawer is animating closed
|
|
24
|
+
*/
|
|
25
|
+
export type DrawerPhase = "closed" | "opening" | "open" | "closing";
|
|
26
|
+
/**
|
|
27
|
+
* Direction of swipe gesture.
|
|
28
|
+
*/
|
|
29
|
+
export type SwipeDirection = "opening" | "closing" | null;
|
|
30
|
+
/**
|
|
31
|
+
* Animation state tracking from/to positions.
|
|
32
|
+
*/
|
|
33
|
+
export type AnimationState<TPosition> = {
|
|
34
|
+
/** Animation type */
|
|
35
|
+
type: "opening" | "closing";
|
|
36
|
+
/** Starting position */
|
|
37
|
+
from: TPosition;
|
|
38
|
+
/** Target position */
|
|
39
|
+
to: TPosition;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Complete state for drawer.
|
|
43
|
+
*/
|
|
44
|
+
export type DrawerState<TPosition> = {
|
|
45
|
+
/** Current animation phase */
|
|
46
|
+
phase: DrawerPhase;
|
|
47
|
+
/** Target open state (what the drawer should be after current operation) */
|
|
48
|
+
targetOpen: boolean;
|
|
49
|
+
/** Current position */
|
|
50
|
+
position: TPosition;
|
|
51
|
+
/** Whether a swipe operation is active */
|
|
52
|
+
isOperating: boolean;
|
|
53
|
+
/** Direction of current swipe */
|
|
54
|
+
swipeDirection: SwipeDirection;
|
|
55
|
+
/** Current swipe displacement in pixels */
|
|
56
|
+
displacement: number;
|
|
57
|
+
/** Animation state if animating */
|
|
58
|
+
animation: AnimationState<TPosition> | null;
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
* Compute progress (0-1) from displacement.
|
|
62
|
+
*
|
|
63
|
+
* @param displacement - Current swipe displacement in pixels
|
|
64
|
+
* @param drawerSize - Size of the drawer in pixels
|
|
65
|
+
* @param direction - Swipe direction ("opening" or "closing")
|
|
66
|
+
* @returns Progress value between 0 and 1
|
|
67
|
+
*/
|
|
68
|
+
export declare function computeProgressFromDisplacement(displacement: number, drawerSize: number, direction: SwipeDirection): number;
|
|
69
|
+
/**
|
|
70
|
+
* Determine if drawer should open or close after swipe ends.
|
|
71
|
+
*
|
|
72
|
+
* @param displacement - Final swipe displacement in pixels
|
|
73
|
+
* @param drawerSize - Size of the drawer in pixels
|
|
74
|
+
* @param direction - Swipe direction
|
|
75
|
+
* @returns true if drawer should be open, false if closed
|
|
76
|
+
*/
|
|
77
|
+
export declare function computeSwipeEndTarget(displacement: number, drawerSize: number, direction: SwipeDirection): boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Action creators for drawer state machine.
|
|
80
|
+
*/
|
|
81
|
+
export declare const drawerActions: {
|
|
82
|
+
/** Start swipe operation */
|
|
83
|
+
readonly swipeStart: ((direction: "opening" | "closing") => {
|
|
84
|
+
type: "SWIPE_START";
|
|
85
|
+
payload: {
|
|
86
|
+
direction: "opening" | "closing";
|
|
87
|
+
};
|
|
88
|
+
}) & {
|
|
89
|
+
readonly type: "SWIPE_START";
|
|
90
|
+
};
|
|
91
|
+
/** Update swipe displacement */
|
|
92
|
+
readonly swipeUpdate: ((displacement: number) => {
|
|
93
|
+
type: "SWIPE_UPDATE";
|
|
94
|
+
payload: {
|
|
95
|
+
displacement: number;
|
|
96
|
+
};
|
|
97
|
+
}) & {
|
|
98
|
+
readonly type: "SWIPE_UPDATE";
|
|
99
|
+
};
|
|
100
|
+
/** End swipe operation */
|
|
101
|
+
readonly swipeEnd: (() => {
|
|
102
|
+
type: "SWIPE_END";
|
|
103
|
+
}) & {
|
|
104
|
+
readonly type: "SWIPE_END";
|
|
105
|
+
};
|
|
106
|
+
/** Animation frame update */
|
|
107
|
+
readonly animationFrame: ((easedProgress: number) => {
|
|
108
|
+
type: "ANIMATION_FRAME";
|
|
109
|
+
payload: {
|
|
110
|
+
easedProgress: number;
|
|
111
|
+
};
|
|
112
|
+
}) & {
|
|
113
|
+
readonly type: "ANIMATION_FRAME";
|
|
114
|
+
};
|
|
115
|
+
/** Animation complete */
|
|
116
|
+
readonly animationComplete: (() => {
|
|
117
|
+
type: "ANIMATION_COMPLETE";
|
|
118
|
+
}) & {
|
|
119
|
+
readonly type: "ANIMATION_COMPLETE";
|
|
120
|
+
};
|
|
121
|
+
/** Button open */
|
|
122
|
+
readonly buttonOpen: (() => {
|
|
123
|
+
type: "BUTTON_OPEN";
|
|
124
|
+
}) & {
|
|
125
|
+
readonly type: "BUTTON_OPEN";
|
|
126
|
+
};
|
|
127
|
+
/** Button close */
|
|
128
|
+
readonly buttonClose: (() => {
|
|
129
|
+
type: "BUTTON_CLOSE";
|
|
130
|
+
}) & {
|
|
131
|
+
readonly type: "BUTTON_CLOSE";
|
|
132
|
+
};
|
|
133
|
+
/** Sync open state from external prop */
|
|
134
|
+
readonly syncOpenState: ((isOpen: boolean) => {
|
|
135
|
+
type: "SYNC_OPEN_STATE";
|
|
136
|
+
payload: {
|
|
137
|
+
isOpen: boolean;
|
|
138
|
+
};
|
|
139
|
+
}) & {
|
|
140
|
+
readonly type: "SYNC_OPEN_STATE";
|
|
141
|
+
};
|
|
142
|
+
/** Initialize state */
|
|
143
|
+
readonly initialize: ((isOpen: boolean) => {
|
|
144
|
+
type: "INITIALIZE";
|
|
145
|
+
payload: {
|
|
146
|
+
isOpen: boolean;
|
|
147
|
+
};
|
|
148
|
+
}) & {
|
|
149
|
+
readonly type: "INITIALIZE";
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export type DrawerAction = ReturnType<(typeof drawerActions)[keyof typeof drawerActions]>;
|
|
153
|
+
/**
|
|
154
|
+
* Create initial state for drawer.
|
|
155
|
+
*
|
|
156
|
+
* @param isOpen - Initial open state
|
|
157
|
+
* @param strategy - Transform strategy
|
|
158
|
+
* @param config - Drawer configuration
|
|
159
|
+
* @returns Initial state
|
|
160
|
+
*/
|
|
161
|
+
export declare function createDrawerInitialState<TPosition>(isOpen: boolean, strategy: DrawerTransformStrategy<TPosition>, config: DrawerStrategyConfig): DrawerState<TPosition>;
|
|
162
|
+
/**
|
|
163
|
+
* Create a drawer reducer for a specific strategy.
|
|
164
|
+
*
|
|
165
|
+
* @param strategy - Transform strategy to use for position calculations
|
|
166
|
+
* @returns Reducer function for the drawer state machine
|
|
167
|
+
*/
|
|
168
|
+
export declare function createDrawerReducer<TPosition>(strategy: DrawerTransformStrategy<TPosition>): (state: DrawerState<TPosition>, action: DrawerAction, config: DrawerStrategyConfig) => DrawerState<TPosition>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Constants for reveal drawer state machine.
|
|
3
|
+
*
|
|
4
|
+
* Centralizes all threshold values used in reveal drawer behavior.
|
|
5
|
+
* These values control swipe gestures, animations, and state transitions.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Minimum swipe distance in pixels to trigger drawer open.
|
|
9
|
+
* Used when opening via edge swipe gesture.
|
|
10
|
+
* ~27% of a 375px mobile screen width.
|
|
11
|
+
*/
|
|
12
|
+
export declare const REVEAL_DRAWER_OPEN_DISTANCE_THRESHOLD = 100;
|
|
13
|
+
/**
|
|
14
|
+
* Ratio of drawer size that must be swiped to dismiss (close) the drawer.
|
|
15
|
+
* Value between 0 and 1. When swiping to close, if displacement exceeds
|
|
16
|
+
* this ratio of the drawer size, the drawer will close.
|
|
17
|
+
*/
|
|
18
|
+
export declare const REVEAL_DRAWER_DISMISS_RATIO = 0.3;
|
|
19
|
+
/**
|
|
20
|
+
* Percentage offset for drawer when closed.
|
|
21
|
+
* The drawer is positioned at -30% (or +30% for right/bottom) when closed,
|
|
22
|
+
* creating a "pull out" parallax effect during the reveal animation.
|
|
23
|
+
*/
|
|
24
|
+
export declare const REVEAL_DRAWER_CLOSED_OFFSET_PERCENT = 30;
|
|
25
|
+
/**
|
|
26
|
+
* Animation duration in milliseconds for reveal transitions.
|
|
27
|
+
*/
|
|
28
|
+
export declare const REVEAL_DRAWER_ANIMATION_DURATION = 300;
|
|
29
|
+
/**
|
|
30
|
+
* Threshold in pixels below which positions are considered equal.
|
|
31
|
+
* Used to determine if animation is needed between two positions.
|
|
32
|
+
*/
|
|
33
|
+
export declare const REVEAL_DRAWER_SNAP_THRESHOLD = 1;
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
import type { DrawerPlacement } from "../../components/window/drawerStyles.js";
|
|
11
|
+
import type { RevealPosition } from "./strategies/types.js";
|
|
12
|
+
import { computeProgressFromDisplacement as genericComputeProgress, computeSwipeEndTarget as genericComputeSwipeEndTarget, type DrawerPhase, type SwipeDirection, type AnimationState, type DrawerState, type DrawerAction } from "./drawerStateMachine.js";
|
|
13
|
+
import { getPlacementConfig } from "./strategies/types.js";
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use DrawerPhase from drawerStateMachine.ts
|
|
16
|
+
*/
|
|
17
|
+
export type RevealDrawerPhase = DrawerPhase;
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use RevealPosition from strategies/types.ts
|
|
20
|
+
*/
|
|
21
|
+
export type RevealPositionPx = RevealPosition;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Use AnimationState<RevealPosition>
|
|
24
|
+
*/
|
|
25
|
+
export type { AnimationState };
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated Use DrawerState<RevealPosition>
|
|
28
|
+
*/
|
|
29
|
+
export type RevealDrawerState = DrawerState<RevealPosition>;
|
|
30
|
+
/**
|
|
31
|
+
* Configuration for the reveal drawer state machine.
|
|
32
|
+
*/
|
|
33
|
+
export type RevealDrawerConfig = {
|
|
34
|
+
placement: DrawerPlacement;
|
|
35
|
+
drawerSize: number;
|
|
36
|
+
};
|
|
37
|
+
export type { SwipeDirection };
|
|
38
|
+
export { getPlacementConfig };
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated Use drawerActions from drawerStateMachine.ts
|
|
41
|
+
*/
|
|
42
|
+
export declare const revealDrawerActions: {
|
|
43
|
+
readonly swipeStart: ((direction: "opening" | "closing") => {
|
|
44
|
+
type: "SWIPE_START";
|
|
45
|
+
payload: {
|
|
46
|
+
direction: "opening" | "closing";
|
|
47
|
+
};
|
|
48
|
+
}) & {
|
|
49
|
+
readonly type: "SWIPE_START";
|
|
50
|
+
};
|
|
51
|
+
readonly swipeUpdate: ((displacement: number) => {
|
|
52
|
+
type: "SWIPE_UPDATE";
|
|
53
|
+
payload: {
|
|
54
|
+
displacement: number;
|
|
55
|
+
};
|
|
56
|
+
}) & {
|
|
57
|
+
readonly type: "SWIPE_UPDATE";
|
|
58
|
+
};
|
|
59
|
+
readonly swipeEnd: (() => {
|
|
60
|
+
type: "SWIPE_END";
|
|
61
|
+
}) & {
|
|
62
|
+
readonly type: "SWIPE_END";
|
|
63
|
+
};
|
|
64
|
+
readonly animationFrame: ((easedProgress: number) => {
|
|
65
|
+
type: "ANIMATION_FRAME";
|
|
66
|
+
payload: {
|
|
67
|
+
easedProgress: number;
|
|
68
|
+
};
|
|
69
|
+
}) & {
|
|
70
|
+
readonly type: "ANIMATION_FRAME";
|
|
71
|
+
};
|
|
72
|
+
readonly animationComplete: (() => {
|
|
73
|
+
type: "ANIMATION_COMPLETE";
|
|
74
|
+
}) & {
|
|
75
|
+
readonly type: "ANIMATION_COMPLETE";
|
|
76
|
+
};
|
|
77
|
+
readonly buttonOpen: (() => {
|
|
78
|
+
type: "BUTTON_OPEN";
|
|
79
|
+
}) & {
|
|
80
|
+
readonly type: "BUTTON_OPEN";
|
|
81
|
+
};
|
|
82
|
+
readonly buttonClose: (() => {
|
|
83
|
+
type: "BUTTON_CLOSE";
|
|
84
|
+
}) & {
|
|
85
|
+
readonly type: "BUTTON_CLOSE";
|
|
86
|
+
};
|
|
87
|
+
readonly syncOpenState: ((isOpen: boolean) => {
|
|
88
|
+
type: "SYNC_OPEN_STATE";
|
|
89
|
+
payload: {
|
|
90
|
+
isOpen: boolean;
|
|
91
|
+
};
|
|
92
|
+
}) & {
|
|
93
|
+
readonly type: "SYNC_OPEN_STATE";
|
|
94
|
+
};
|
|
95
|
+
readonly initialize: ((isOpen: boolean) => {
|
|
96
|
+
type: "INITIALIZE";
|
|
97
|
+
payload: {
|
|
98
|
+
isOpen: boolean;
|
|
99
|
+
};
|
|
100
|
+
}) & {
|
|
101
|
+
readonly type: "INITIALIZE";
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
export type RevealDrawerAction = DrawerAction;
|
|
105
|
+
/**
|
|
106
|
+
* Compute progress from displacement.
|
|
107
|
+
* @deprecated Use computeProgressFromDisplacement from drawerStateMachine.ts
|
|
108
|
+
*/
|
|
109
|
+
export declare const computeProgressFromDisplacement: typeof genericComputeProgress;
|
|
110
|
+
/**
|
|
111
|
+
* Compute swipe end target.
|
|
112
|
+
* @deprecated Use computeSwipeEndTarget from drawerStateMachine.ts
|
|
113
|
+
*/
|
|
114
|
+
export declare const computeSwipeEndTarget: typeof genericComputeSwipeEndTarget;
|
|
115
|
+
/**
|
|
116
|
+
* Compute drawer offset in pixels from progress.
|
|
117
|
+
*/
|
|
118
|
+
export declare function computeDrawerOffsetPx(progress: number, drawerSize: number, placement: DrawerPlacement): number;
|
|
119
|
+
/**
|
|
120
|
+
* Compute content offset in pixels from progress.
|
|
121
|
+
*/
|
|
122
|
+
export declare function computeContentOffsetPx(progress: number, drawerSize: number, placement: DrawerPlacement): number;
|
|
123
|
+
/**
|
|
124
|
+
* Compute position from progress.
|
|
125
|
+
*/
|
|
126
|
+
export declare function computePositionFromProgress(progress: number, config: RevealDrawerConfig): RevealPosition;
|
|
127
|
+
/**
|
|
128
|
+
* Compute target position for open or closed state.
|
|
129
|
+
*/
|
|
130
|
+
export declare function computeTargetPosition(isOpen: boolean, config: RevealDrawerConfig): RevealPosition;
|
|
131
|
+
/**
|
|
132
|
+
* Determine if animation is needed between two positions.
|
|
133
|
+
*/
|
|
134
|
+
export declare function shouldAnimate(from: RevealPosition, to: RevealPosition): boolean;
|
|
135
|
+
/**
|
|
136
|
+
* Interpolate between two positions.
|
|
137
|
+
*/
|
|
138
|
+
export declare function interpolatePosition(from: RevealPosition, to: RevealPosition, progress: number): RevealPosition;
|
|
139
|
+
/**
|
|
140
|
+
* Create initial state for reveal drawer.
|
|
141
|
+
*/
|
|
142
|
+
export declare function createInitialState(isOpen: boolean, config: RevealDrawerConfig): RevealDrawerState;
|
|
143
|
+
/**
|
|
144
|
+
* Reveal drawer reducer function.
|
|
145
|
+
*/
|
|
146
|
+
export declare function revealDrawerReducer(state: RevealDrawerState, action: RevealDrawerAction, config: RevealDrawerConfig): RevealDrawerState;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Drawer transform strategies module.
|
|
3
|
+
*
|
|
4
|
+
* Exports strategy implementations for different drawer animation modes.
|
|
5
|
+
*/
|
|
6
|
+
export * from "./types.js";
|
|
7
|
+
export { revealStrategy } from "./revealStrategy.js";
|
|
8
|
+
export { overlayStrategy } from "./overlayStrategy.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
import type { DrawerTransformStrategy, OverlayPosition } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Overlay mode drawer transform strategy.
|
|
11
|
+
*/
|
|
12
|
+
export declare const overlayStrategy: DrawerTransformStrategy<OverlayPosition>;
|
|
@@ -0,0 +1,12 @@
|
|
|
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
|
+
import type { DrawerTransformStrategy, RevealPosition } from "./types.js";
|
|
9
|
+
/**
|
|
10
|
+
* Reveal mode drawer transform strategy.
|
|
11
|
+
*/
|
|
12
|
+
export declare const revealStrategy: DrawerTransformStrategy<RevealPosition>;
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import type { DrawerPlacement } from "../../../components/window/drawerStyles.js";
|
|
9
|
+
/**
|
|
10
|
+
* Position values for reveal mode.
|
|
11
|
+
* - Drawer moves from -30% to 0%
|
|
12
|
+
* - Content moves from 0 to +drawerSize
|
|
13
|
+
*/
|
|
14
|
+
export type RevealPosition = {
|
|
15
|
+
/** Drawer offset in pixels */
|
|
16
|
+
drawerPx: number;
|
|
17
|
+
/** Content offset in pixels */
|
|
18
|
+
contentPx: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Position values for overlay mode.
|
|
22
|
+
* - Drawer moves from ±100% to 0%
|
|
23
|
+
* - Backdrop opacity changes from 0 to 1
|
|
24
|
+
*/
|
|
25
|
+
export type OverlayPosition = {
|
|
26
|
+
/** Drawer offset in pixels */
|
|
27
|
+
drawerPx: number;
|
|
28
|
+
/** Backdrop opacity (0-1) */
|
|
29
|
+
backdropOpacity: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Configuration for drawer strategy calculations.
|
|
33
|
+
*/
|
|
34
|
+
export type DrawerStrategyConfig = {
|
|
35
|
+
/** Drawer placement (left, right, top, bottom) */
|
|
36
|
+
placement: DrawerPlacement;
|
|
37
|
+
/** Drawer size in pixels */
|
|
38
|
+
drawerSize: number;
|
|
39
|
+
/** Content background color (reveal mode) */
|
|
40
|
+
contentBackground?: string;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* DOM elements used by drawer strategies.
|
|
44
|
+
*/
|
|
45
|
+
export type DrawerElements = {
|
|
46
|
+
/** Drawer element */
|
|
47
|
+
drawer: HTMLElement | null;
|
|
48
|
+
/** Content element (reveal mode) */
|
|
49
|
+
content: HTMLElement | null;
|
|
50
|
+
/** Backdrop element (overlay mode) */
|
|
51
|
+
backdrop: HTMLElement | null;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Placement configuration for transform calculations.
|
|
55
|
+
*/
|
|
56
|
+
export type PlacementConfig = {
|
|
57
|
+
/** Transform axis (X or Y) */
|
|
58
|
+
axis: "X" | "Y";
|
|
59
|
+
/** Sign for transform direction (1 or -1) */
|
|
60
|
+
sign: 1 | -1;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Lookup table for placement configuration.
|
|
64
|
+
*/
|
|
65
|
+
export declare const PLACEMENT_CONFIG: Record<DrawerPlacement, PlacementConfig>;
|
|
66
|
+
/**
|
|
67
|
+
* Get placement configuration for a drawer placement.
|
|
68
|
+
*/
|
|
69
|
+
export declare function getPlacementConfig(placement: DrawerPlacement): PlacementConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Strategy interface for drawer transform calculations.
|
|
72
|
+
*
|
|
73
|
+
* Each drawer mode (reveal, overlay) implements this interface to provide
|
|
74
|
+
* mode-specific position calculations and DOM operations while sharing
|
|
75
|
+
* the common state machine logic.
|
|
76
|
+
*
|
|
77
|
+
* @typeParam TPosition - The position type used by this strategy
|
|
78
|
+
*/
|
|
79
|
+
export type DrawerTransformStrategy<TPosition> = {
|
|
80
|
+
/**
|
|
81
|
+
* Get the closed position (progress = 0).
|
|
82
|
+
*/
|
|
83
|
+
getClosedPosition: (config: DrawerStrategyConfig) => TPosition;
|
|
84
|
+
/**
|
|
85
|
+
* Get the open position (progress = 1).
|
|
86
|
+
*/
|
|
87
|
+
getOpenPosition: (config: DrawerStrategyConfig) => TPosition;
|
|
88
|
+
/**
|
|
89
|
+
* Compute position from progress (0 = closed, 1 = open).
|
|
90
|
+
*/
|
|
91
|
+
computePositionFromProgress: (progress: number, config: DrawerStrategyConfig) => TPosition;
|
|
92
|
+
/**
|
|
93
|
+
* Interpolate between two positions.
|
|
94
|
+
*/
|
|
95
|
+
interpolatePosition: (from: TPosition, to: TPosition, progress: number) => TPosition;
|
|
96
|
+
/**
|
|
97
|
+
* Determine if animation is needed between two positions.
|
|
98
|
+
*/
|
|
99
|
+
shouldAnimate: (from: TPosition, to: TPosition) => boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Apply position to DOM elements.
|
|
102
|
+
*/
|
|
103
|
+
applyToDOM: (position: TPosition, elements: DrawerElements, config: DrawerStrategyConfig) => void;
|
|
104
|
+
/**
|
|
105
|
+
* Clear transforms from DOM elements.
|
|
106
|
+
*/
|
|
107
|
+
clearFromDOM: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
|
|
108
|
+
/**
|
|
109
|
+
* Called when opening animation starts (optional).
|
|
110
|
+
*/
|
|
111
|
+
onOpeningStart?: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
|
|
112
|
+
/**
|
|
113
|
+
* Called when closing animation completes (optional).
|
|
114
|
+
*/
|
|
115
|
+
onClosingComplete?: (elements: DrawerElements, config: DrawerStrategyConfig) => void;
|
|
116
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type definitions for Drawer swipe gesture handling.
|
|
3
|
+
*/
|
|
4
|
+
import type * as React from "react";
|
|
5
|
+
import type { ContinuousOperationState } from "../../hooks/gesture/types.js";
|
|
6
|
+
/**
|
|
7
|
+
* Direction for drawer anchor (same as anchor edge).
|
|
8
|
+
*/
|
|
9
|
+
export type DrawerSwipeDirection = "left" | "right" | "top" | "bottom";
|
|
10
|
+
/**
|
|
11
|
+
* Options for useDrawerSwipeInput hook.
|
|
12
|
+
*/
|
|
13
|
+
export type UseDrawerSwipeInputOptions = {
|
|
14
|
+
/** Container ref for edge detection zone (e.g., GridLayout container) */
|
|
15
|
+
edgeContainerRef: React.RefObject<HTMLElement | null>;
|
|
16
|
+
/** Drawer content ref (for close gesture) */
|
|
17
|
+
drawerContentRef: React.RefObject<HTMLElement | null>;
|
|
18
|
+
/** Drawer direction (anchor edge) */
|
|
19
|
+
direction: DrawerSwipeDirection;
|
|
20
|
+
/** Whether the drawer is currently open */
|
|
21
|
+
isOpen: boolean;
|
|
22
|
+
/** Callback when swipe should open the drawer */
|
|
23
|
+
onSwipeOpen: () => void;
|
|
24
|
+
/** Callback when swipe should close the drawer */
|
|
25
|
+
onSwipeClose: () => void;
|
|
26
|
+
/** Whether edge swipe to open is enabled. @default true */
|
|
27
|
+
enableEdgeSwipeOpen?: boolean;
|
|
28
|
+
/** Whether swipe to close is enabled. @default true */
|
|
29
|
+
enableSwipeClose?: boolean;
|
|
30
|
+
/** Width of edge detection zone in pixels. @default 20 */
|
|
31
|
+
edgeWidth?: number;
|
|
32
|
+
/** Dismiss threshold ratio (0-1). @default 0.3 */
|
|
33
|
+
dismissThreshold?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Result from useDrawerSwipeInput hook.
|
|
37
|
+
*/
|
|
38
|
+
export type UseDrawerSwipeInputResult = {
|
|
39
|
+
/** Current operation state */
|
|
40
|
+
state: ContinuousOperationState;
|
|
41
|
+
/** Whether currently opening via edge swipe */
|
|
42
|
+
isOpening: boolean;
|
|
43
|
+
/** Whether currently closing via drag */
|
|
44
|
+
isClosing: boolean;
|
|
45
|
+
/** Progress (0-1) towards open/close threshold */
|
|
46
|
+
progress: number;
|
|
47
|
+
/** Displacement in pixels (primary axis) */
|
|
48
|
+
displacement: number;
|
|
49
|
+
/** Props for edge container (open gesture zone) */
|
|
50
|
+
edgeContainerProps: React.HTMLAttributes<HTMLElement> & {
|
|
51
|
+
style: React.CSSProperties;
|
|
52
|
+
};
|
|
53
|
+
/** Props for drawer content (close gesture zone) */
|
|
54
|
+
drawerContentProps: React.HTMLAttributes<HTMLElement> & {
|
|
55
|
+
style: React.CSSProperties;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Get animation axis from direction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getDrawerAnimationAxis(direction: DrawerSwipeDirection): "x" | "y";
|
|
62
|
+
/**
|
|
63
|
+
* Get the sign for the close swipe direction.
|
|
64
|
+
* Left drawer closes by swiping left (-1).
|
|
65
|
+
* Right drawer closes by swiping right (+1).
|
|
66
|
+
* Top drawer closes by swiping up (-1).
|
|
67
|
+
* Bottom drawer closes by swiping down (+1).
|
|
68
|
+
*/
|
|
69
|
+
export declare function getDrawerCloseSwipeSign(direction: DrawerSwipeDirection): 1 | -1;
|
|
70
|
+
/**
|
|
71
|
+
* Get the sign for the open swipe direction.
|
|
72
|
+
* This is the opposite of the close direction.
|
|
73
|
+
*/
|
|
74
|
+
export declare function getDrawerOpenSwipeSign(direction: DrawerSwipeDirection): 1 | -1;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { UseDrawerSwipeInputOptions, UseDrawerSwipeInputResult } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook for detecting swipe gestures to open/close a drawer.
|
|
4
|
+
*
|
|
5
|
+
* When drawer is closed:
|
|
6
|
+
* - Detects edge swipe from the anchor edge to trigger open
|
|
7
|
+
*
|
|
8
|
+
* When drawer is open:
|
|
9
|
+
* - Detects drag gesture within drawer to trigger close
|
|
10
|
+
* - Respects scrollable content boundaries
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const { state, edgeContainerProps, drawerContentProps } = useDrawerSwipeInput({
|
|
15
|
+
* edgeContainerRef: gridLayoutRef,
|
|
16
|
+
* drawerContentRef: drawerRef,
|
|
17
|
+
* direction: "left",
|
|
18
|
+
* isOpen,
|
|
19
|
+
* onSwipeOpen: () => setOpen(true),
|
|
20
|
+
* onSwipeClose: () => setOpen(false),
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useDrawerSwipeInput(options: UseDrawerSwipeInputOptions): UseDrawerSwipeInputResult;
|
|
@@ -86,4 +86,7 @@ export type SwipePivotTabBarProps<TId extends string = string> = {
|
|
|
86
86
|
*/
|
|
87
87
|
renderIndicator?: (props: IndicatorRenderProps) => React.ReactNode;
|
|
88
88
|
};
|
|
89
|
+
/**
|
|
90
|
+
* Swipeable tab bar for pivot navigation.
|
|
91
|
+
*/
|
|
89
92
|
export declare function SwipePivotTabBar<TId extends string = string>({ items, activeId, activeIndex, itemCount, inputState, tabWidth, viewportWidth, navigationMode, axis, renderTab, animationDuration, fixedTabs, renderIndicator, }: SwipePivotTabBarProps<TId>): React.ReactElement;
|
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
* Uses useSwipeContentTransform for immediate DOM updates.
|
|
9
9
|
*/
|
|
10
10
|
import * as React from "react";
|
|
11
|
-
import type {
|
|
11
|
+
import type { ContinuousOperationState, GestureAxis } from "../../hooks/gesture/types.js";
|
|
12
12
|
import type { StackDisplayMode } from "./types.js";
|
|
13
13
|
/**
|
|
14
14
|
* Props for SwipeStackContent component.
|
|
15
|
+
*
|
|
16
|
+
* This component accepts ContinuousOperationState, meaning it responds uniformly
|
|
17
|
+
* to any continuous operation (whether human gesture or system animation).
|
|
15
18
|
*/
|
|
16
19
|
export type SwipeStackContentProps = {
|
|
17
20
|
/** Panel ID */
|
|
@@ -22,8 +25,8 @@ export type SwipeStackContentProps = {
|
|
|
22
25
|
navigationDepth: number;
|
|
23
26
|
/** Whether this panel is currently active */
|
|
24
27
|
isActive: boolean;
|
|
25
|
-
/**
|
|
26
|
-
|
|
28
|
+
/** Continuous operation state (from gesture input or animation system) */
|
|
29
|
+
operationState: ContinuousOperationState;
|
|
27
30
|
/** Container size in pixels (width for horizontal, height for vertical) */
|
|
28
31
|
containerSize: number;
|
|
29
32
|
/** Gesture axis. @default "horizontal" */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* providing iOS-style smooth swipe-to-go-back behavior.
|
|
6
6
|
*/
|
|
7
7
|
import * as React from "react";
|
|
8
|
-
import type {
|
|
8
|
+
import type { ContinuousOperationState } from "../../hooks/gesture/types.js";
|
|
9
9
|
import type { StackPanel, StackNavigationState } from "./types.js";
|
|
10
10
|
/**
|
|
11
11
|
* Props for SwipeStackOutlet component.
|
|
@@ -15,8 +15,8 @@ export type SwipeStackOutletProps = {
|
|
|
15
15
|
panels: ReadonlyArray<StackPanel>;
|
|
16
16
|
/** Current navigation state */
|
|
17
17
|
navigationState: StackNavigationState;
|
|
18
|
-
/**
|
|
19
|
-
|
|
18
|
+
/** Continuous operation state (from gesture input or animation system) */
|
|
19
|
+
operationState: ContinuousOperationState;
|
|
20
20
|
/** Container size in pixels (width for horizontal swipe) */
|
|
21
21
|
containerSize: number;
|
|
22
22
|
/** Function to get cached content for a panel */
|
|
@@ -70,7 +70,7 @@ export type SwipeStackOutletProps = {
|
|
|
70
70
|
* <SwipeStackOutlet
|
|
71
71
|
* panels={navigation.panels}
|
|
72
72
|
* navigationState={navigation.state}
|
|
73
|
-
*
|
|
73
|
+
* operationState={toContinuousOperationState(swipeInput.inputState)}
|
|
74
74
|
* containerSize={containerWidth}
|
|
75
75
|
* />
|
|
76
76
|
* </div>
|
|
@@ -48,7 +48,7 @@ export type ComputeSwipeVisibilityInput = {
|
|
|
48
48
|
/** Whether this panel is currently active */
|
|
49
49
|
isActive: boolean;
|
|
50
50
|
/** Whether swipe gesture is active */
|
|
51
|
-
|
|
51
|
+
isOperating: boolean;
|
|
52
52
|
/** Whether snap-back animation is running */
|
|
53
53
|
isAnimating: boolean;
|
|
54
54
|
};
|
package/dist/panels.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PanelSystem-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./PanelSystem-B8Igvnb2.cjs");exports.DropSuggestOverlay=e.DropSuggestOverlay;exports.PanelGroupView=e.PanelGroupView;exports.PanelSystem=e.PanelSystem;exports.PanelSystemProvider=e.PanelSystemProvider;exports.addTabToGroup=e.addTabToGroup;exports.addTabToGroupAtIndex=e.addTabToGroupAtIndex;exports.buildInitialState=e.buildInitialState;exports.closeLeaf=e.closeLeaf;exports.collectGroupsInOrder=e.collectGroupsInOrder;exports.createEmptyGroup=e.createEmptyGroup;exports.focusGroupIndex=e.focusGroupIndex;exports.isGroup=e.isGroup;exports.moveTab=e.moveTab;exports.nextGroup=e.nextGroup;exports.prevGroup=e.prevGroup;exports.refreshGroupOrder=e.refreshGroupOrder;exports.removeTabFromGroup=e.removeTabFromGroup;exports.reorderTabWithinGroup=e.reorderTabWithinGroup;exports.setActiveTab=e.setActiveTab;exports.setFocusedGroup=e.setFocusedGroup;exports.setSplitRatio=e.setSplitRatio;exports.splitGroup=e.splitGroup;exports.splitLeaf=e.splitLeaf;exports.usePanelSystem=e.usePanelSystem;
|
|
2
2
|
//# sourceMappingURL=panels.cjs.map
|