react-panel-layout 0.6.1 → 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/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-UWNxXw77.js.map → GridLayout-B4aCqSyd.js.map} +1 -1
- package/dist/GridLayout-DNOClFzz.cjs +2 -0
- package/dist/{GridLayout-DKTg_N61.cjs.map → GridLayout-DNOClFzz.cjs.map} +1 -1
- package/dist/PanelSystem-B8Igvnb2.cjs +3 -0
- package/dist/PanelSystem-B8Igvnb2.cjs.map +1 -0
- package/dist/{PanelSystem-BqUzNtf2.js → PanelSystem-DDUSFjXD.js} +208 -247
- package/dist/PanelSystem-DDUSFjXD.js.map +1 -0
- package/dist/components/window/Drawer.d.ts +1 -0
- 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 +5 -0
- package/dist/components/window/useDrawerSwipeTransform.d.ts +8 -2
- 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 +8 -7
- package/dist/config.js.map +1 -1
- package/dist/grid.cjs +1 -1
- package/dist/grid.js +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -4
- 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/panels.cjs +1 -1
- package/dist/panels.js +1 -1
- package/dist/stack.cjs +1 -1
- package/dist/stack.cjs.map +1 -1
- package/dist/stack.js +306 -347
- package/dist/stack.js.map +1 -1
- package/dist/types.d.ts +14 -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/window.cjs +1 -1
- package/dist/window.js +1 -1
- package/package.json +1 -1
- package/src/components/gesture/SwipeSafeZone.tsx +1 -0
- package/src/components/grid/GridLayout.tsx +110 -38
- package/src/components/window/Drawer.tsx +114 -10
- package/src/components/window/DrawerLayers.tsx +48 -15
- 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 +39 -0
- package/src/components/window/drawerStyles.ts +24 -0
- package/src/components/window/useDrawerSwipeTransform.ts +28 -90
- 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/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/components/CardExpandDemo.tsx +23 -8
- 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/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/Stack/components/StackBasics.spec.tsx +56 -52
- package/src/demo/pages/Stack/components/StackTablet.spec.tsx +39 -49
- package/src/demo/routes.tsx +2 -0
- package/src/hooks/gesture/testing/createGestureSimulator.ts +1 -0
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +10 -2
- package/src/hooks/gesture/utils.ts +15 -4
- package/src/hooks/useAnimatedVisibility.spec.ts +3 -3
- package/src/hooks/useOperationContinuity.spec.ts +17 -10
- package/src/hooks/useOperationContinuity.ts +5 -5
- package/src/hooks/useSharedElementTransition.ts +28 -7
- package/src/modules/dialog/dialogAnimationUtils.spec.ts +0 -1
- package/src/modules/dialog/useDialogContainer.spec.ts +11 -3
- package/src/modules/dialog/useDialogSwipeInput.spec.ts +49 -28
- package/src/modules/dialog/useDialogSwipeInput.ts +37 -6
- package/src/modules/dialog/useDialogTransform.spec.ts +63 -30
- 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/useDrawerSwipeInput.ts +7 -4
- package/src/modules/pivot/SwipePivotContent.spec.tsx +48 -37
- package/src/modules/pivot/usePivotSwipeInput.spec.ts +8 -8
- package/src/modules/stack/swipeTransitionContinuity.spec.tsx +1 -1
- package/src/types.ts +15 -0
- package/dist/FloatingWindow-CUXnEtrb.js +0 -827
- package/dist/FloatingWindow-CUXnEtrb.js.map +0 -1
- package/dist/FloatingWindow-DMwyK0eK.cjs +0 -2
- package/dist/FloatingWindow-DMwyK0eK.cjs.map +0 -1
- package/dist/GridLayout-DKTg_N61.cjs +0 -2
- package/dist/GridLayout-UWNxXw77.js +0 -926
- package/dist/PanelSystem-BqUzNtf2.js.map +0 -1
- package/dist/PanelSystem-D603LKKv.cjs +0 -3
- package/dist/PanelSystem-D603LKKv.cjs.map +0 -1
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs +0 -2
- package/dist/useNativeGestureGuard-C7TSqEkr.cjs.map +0 -1
- package/dist/useNativeGestureGuard-CGYo6O0r.js +0 -347
- package/dist/useNativeGestureGuard-CGYo6O0r.js.map +0 -1
- package/src/components/window/useDrawerSwipeTransform.spec.ts +0 -234
package/dist/stack.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as O, Fragment as Y, jsxs as j } from "react/jsx-runtime";
|
|
2
2
|
import * as r from "react";
|
|
3
|
-
import { S as J, s as
|
|
4
|
-
import { u as
|
|
5
|
-
import { u as
|
|
6
|
-
import { u as
|
|
7
|
-
function ce(
|
|
8
|
-
const { wasActive: e, isActive:
|
|
9
|
-
return i !== "css" || e ===
|
|
3
|
+
import { S as J, s as q, t as Q, u as Z } from "./styles-NkjuMOVS.js";
|
|
4
|
+
import { u as z } from "./useIsomorphicLayoutEffect-DhmEnmZ_.js";
|
|
5
|
+
import { u as ee } from "./useContentCache-CO3LYNmz.js";
|
|
6
|
+
import { u as te, a as ne, m as re, I as se, i as ie, b as oe, e as ae } from "./useAnimationFrame-Bg4e-H8O.js";
|
|
7
|
+
function ce(n) {
|
|
8
|
+
const { wasActive: e, isActive: t, transitionMode: i } = n;
|
|
9
|
+
return i !== "css" || e === t ? null : t ? "push" : "pop";
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function ue(n) {
|
|
12
12
|
const {
|
|
13
13
|
displayMode: e,
|
|
14
|
-
depth:
|
|
14
|
+
depth: t,
|
|
15
15
|
navigationDepth: i,
|
|
16
|
-
isActive:
|
|
17
|
-
isAnimatingOut:
|
|
16
|
+
isActive: c,
|
|
17
|
+
isAnimatingOut: o,
|
|
18
18
|
isRevealing: u,
|
|
19
19
|
revealDepth: s
|
|
20
|
-
} =
|
|
21
|
-
return e === "overlay" ?
|
|
20
|
+
} = n;
|
|
21
|
+
return e === "overlay" ? c || o || u && t === s ? "visible" : "hidden" : t <= i || o ? "visible" : "hidden";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const { depth: e, activeDepth:
|
|
25
|
-
if (
|
|
23
|
+
function le(n) {
|
|
24
|
+
const { depth: e, activeDepth: t, displayMode: i, isRevealing: c, revealDepth: o } = n, u = e === t, s = e < t;
|
|
25
|
+
if (c && u && o !== null)
|
|
26
26
|
return `translateX(${0.3 * 100}%)`;
|
|
27
27
|
if (u)
|
|
28
28
|
return "translateX(0)";
|
|
@@ -33,91 +33,91 @@ function ae(t) {
|
|
|
33
33
|
case "slide":
|
|
34
34
|
return "translateX(-30%)";
|
|
35
35
|
case "stack": {
|
|
36
|
-
const l = (
|
|
36
|
+
const l = (t - e) * -5, f = 1 - (t - e) * 0.05;
|
|
37
37
|
return `translateX(${l}%) scale(${f})`;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
return "translateX(100%)";
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return e === void 0 || e <= 0 || !
|
|
42
|
+
function fe(n, e, t) {
|
|
43
|
+
return e === void 0 || e <= 0 || !t ? n : `translateX(${e * 100}%)`;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
if (
|
|
47
|
-
return `transform ${J} ${
|
|
45
|
+
function pe(n) {
|
|
46
|
+
if (n === "css")
|
|
47
|
+
return `transform ${J} ${q}`;
|
|
48
48
|
}
|
|
49
|
-
function
|
|
49
|
+
function de(n) {
|
|
50
50
|
const {
|
|
51
51
|
depth: e,
|
|
52
|
-
isActive:
|
|
52
|
+
isActive: t,
|
|
53
53
|
wasActive: i,
|
|
54
|
-
currentAnimationType:
|
|
55
|
-
displayMode:
|
|
54
|
+
currentAnimationType: c,
|
|
55
|
+
displayMode: o,
|
|
56
56
|
transitionMode: u,
|
|
57
57
|
navigationState: s,
|
|
58
58
|
swipeProgress: l
|
|
59
|
-
} =
|
|
59
|
+
} = n, m = ce({
|
|
60
60
|
wasActive: i,
|
|
61
|
-
isActive:
|
|
61
|
+
isActive: t,
|
|
62
62
|
transitionMode: u
|
|
63
|
-
}) ??
|
|
64
|
-
displayMode:
|
|
63
|
+
}) ?? c, g = m === "pop", a = ue({
|
|
64
|
+
displayMode: o,
|
|
65
65
|
depth: e,
|
|
66
66
|
navigationDepth: s.depth,
|
|
67
|
-
isActive:
|
|
68
|
-
isAnimatingOut:
|
|
67
|
+
isActive: t,
|
|
68
|
+
isAnimatingOut: g,
|
|
69
69
|
isRevealing: s.isRevealing,
|
|
70
70
|
revealDepth: s.revealDepth
|
|
71
|
-
}),
|
|
71
|
+
}), v = le({
|
|
72
72
|
depth: e,
|
|
73
73
|
activeDepth: s.depth,
|
|
74
|
-
displayMode:
|
|
74
|
+
displayMode: o,
|
|
75
75
|
isRevealing: s.isRevealing,
|
|
76
76
|
revealDepth: s.revealDepth
|
|
77
|
-
}),
|
|
77
|
+
}), y = fe(v, l, t), A = (() => {
|
|
78
78
|
if (u === "css") {
|
|
79
79
|
if (m === "push")
|
|
80
|
-
return
|
|
80
|
+
return Q;
|
|
81
81
|
if (m === "pop")
|
|
82
|
-
return
|
|
82
|
+
return Z;
|
|
83
83
|
}
|
|
84
|
-
})(), d =
|
|
84
|
+
})(), d = pe(u);
|
|
85
85
|
return {
|
|
86
86
|
nextAnimationType: m,
|
|
87
87
|
visibility: a,
|
|
88
|
-
transform:
|
|
88
|
+
transform: y,
|
|
89
89
|
animation: A,
|
|
90
90
|
transition: d,
|
|
91
91
|
zIndex: e,
|
|
92
|
-
pointerEvents:
|
|
92
|
+
pointerEvents: t ? "auto" : "none"
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
|
-
const
|
|
95
|
+
const me = {
|
|
96
96
|
position: "absolute",
|
|
97
97
|
inset: 0,
|
|
98
98
|
width: "100%",
|
|
99
99
|
height: "100%"
|
|
100
|
-
},
|
|
101
|
-
({ id:
|
|
102
|
-
const l = r.useRef(null), f = r.useRef(
|
|
100
|
+
}, he = r.memo(
|
|
101
|
+
({ id: n, depth: e, isActive: t, displayMode: i, transitionMode: c, navigationState: o, swipeProgress: u, children: s }) => {
|
|
102
|
+
const l = r.useRef(null), f = r.useRef(t), [m, g] = r.useState(null), a = de({
|
|
103
103
|
depth: e,
|
|
104
|
-
isActive:
|
|
104
|
+
isActive: t,
|
|
105
105
|
wasActive: f.current,
|
|
106
106
|
currentAnimationType: m,
|
|
107
107
|
displayMode: i,
|
|
108
|
-
transitionMode:
|
|
109
|
-
navigationState:
|
|
108
|
+
transitionMode: c,
|
|
109
|
+
navigationState: o,
|
|
110
110
|
swipeProgress: u
|
|
111
111
|
});
|
|
112
|
-
|
|
112
|
+
z(() => {
|
|
113
113
|
const d = f.current;
|
|
114
|
-
f.current =
|
|
115
|
-
}, [
|
|
116
|
-
const
|
|
117
|
-
d.target === d.currentTarget &&
|
|
118
|
-
}, []),
|
|
114
|
+
f.current = t, d !== t && g(a.nextAnimationType);
|
|
115
|
+
}, [t, a.nextAnimationType]);
|
|
116
|
+
const v = r.useCallback((d) => {
|
|
117
|
+
d.target === d.currentTarget && g(null);
|
|
118
|
+
}, []), y = r.useMemo(() => {
|
|
119
119
|
const d = {
|
|
120
|
-
...
|
|
120
|
+
...me,
|
|
121
121
|
transform: a.transform,
|
|
122
122
|
pointerEvents: a.pointerEvents,
|
|
123
123
|
zIndex: a.zIndex,
|
|
@@ -131,120 +131,120 @@ const pe = {
|
|
|
131
131
|
a.visibility,
|
|
132
132
|
a.animation,
|
|
133
133
|
a.transition
|
|
134
|
-
]), A = /* @__PURE__ */
|
|
134
|
+
]), A = /* @__PURE__ */ O(
|
|
135
135
|
"div",
|
|
136
136
|
{
|
|
137
137
|
ref: l,
|
|
138
|
-
"data-stack-content":
|
|
138
|
+
"data-stack-content": n,
|
|
139
139
|
"data-depth": e,
|
|
140
|
-
"data-active":
|
|
141
|
-
style:
|
|
142
|
-
onAnimationEnd:
|
|
140
|
+
"data-active": t ? "true" : "false",
|
|
141
|
+
style: y,
|
|
142
|
+
onAnimationEnd: v,
|
|
143
143
|
children: s
|
|
144
144
|
}
|
|
145
145
|
);
|
|
146
|
-
return
|
|
146
|
+
return c === "none" ? /* @__PURE__ */ O(r.Activity, { mode: t ? "visible" : "hidden", children: A }) : A;
|
|
147
147
|
}
|
|
148
148
|
);
|
|
149
|
-
function
|
|
149
|
+
function ve(n, e) {
|
|
150
150
|
switch (e.type) {
|
|
151
151
|
case "push":
|
|
152
|
-
return [...
|
|
152
|
+
return [...n, e.id];
|
|
153
153
|
case "go": {
|
|
154
154
|
if (e.direction >= 0)
|
|
155
|
-
return
|
|
156
|
-
const i =
|
|
157
|
-
return i < 0 ?
|
|
155
|
+
return n;
|
|
156
|
+
const i = n.length - 1 + e.direction;
|
|
157
|
+
return i < 0 ? n : n.slice(0, i + 1);
|
|
158
158
|
}
|
|
159
159
|
case "move":
|
|
160
|
-
return e.targetDepth < 0 || e.targetDepth >=
|
|
160
|
+
return e.targetDepth < 0 || e.targetDepth >= n.length ? n : n.slice(0, e.targetDepth + 1);
|
|
161
161
|
case "replace":
|
|
162
|
-
return
|
|
162
|
+
return n.length === 0 ? [e.id] : [...n.slice(0, -1), e.id];
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
const G = r.createContext(null),
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
165
|
+
const G = r.createContext(null), ge = r.memo(() => {
|
|
166
|
+
const n = r.useContext(G);
|
|
167
|
+
if (!n)
|
|
168
168
|
throw new Error("StackOutlet must be used within useStackNavigation");
|
|
169
169
|
const [, e] = r.useReducer((s) => s + 1, 0);
|
|
170
|
-
r.useEffect(() =>
|
|
171
|
-
const { panels:
|
|
172
|
-
const f =
|
|
170
|
+
r.useEffect(() => n.subscribe(e), [n]);
|
|
171
|
+
const { panels: t, navigationState: i, displayMode: c, transitionMode: o } = n.getState(), u = r.useMemo(() => i.stack.map((s, l) => {
|
|
172
|
+
const f = t.find((m) => m.id === s);
|
|
173
173
|
return f ? { panel: f, depth: l } : null;
|
|
174
|
-
}).filter((s) => s !== null), [i.stack,
|
|
175
|
-
return /* @__PURE__ */
|
|
176
|
-
|
|
174
|
+
}).filter((s) => s !== null), [i.stack, t]);
|
|
175
|
+
return /* @__PURE__ */ O(Y, { children: u.map(({ panel: s, depth: l }) => /* @__PURE__ */ O(
|
|
176
|
+
he,
|
|
177
177
|
{
|
|
178
178
|
id: s.id,
|
|
179
179
|
depth: l,
|
|
180
180
|
isActive: l === i.depth,
|
|
181
|
-
displayMode:
|
|
182
|
-
transitionMode:
|
|
181
|
+
displayMode: c,
|
|
182
|
+
transitionMode: o,
|
|
183
183
|
navigationState: i,
|
|
184
|
-
children: s.cache ?
|
|
184
|
+
children: s.cache ? n.getCachedContent(s.id) : s.content
|
|
185
185
|
},
|
|
186
186
|
s.id
|
|
187
187
|
)) });
|
|
188
188
|
});
|
|
189
|
-
function
|
|
189
|
+
function Ge(n) {
|
|
190
190
|
const {
|
|
191
191
|
panels: e,
|
|
192
|
-
initialPanelId:
|
|
192
|
+
initialPanelId: t,
|
|
193
193
|
displayMode: i,
|
|
194
|
-
transitionMode:
|
|
195
|
-
onPanelChange:
|
|
196
|
-
} =
|
|
194
|
+
transitionMode: c = "css",
|
|
195
|
+
onPanelChange: o
|
|
196
|
+
} = n, u = t ?? e[0]?.id;
|
|
197
197
|
if (!u)
|
|
198
198
|
throw new Error("useStackNavigation: No panels provided");
|
|
199
199
|
const [s, l] = r.useReducer(
|
|
200
|
-
|
|
200
|
+
ve,
|
|
201
201
|
[u]
|
|
202
202
|
), f = r.useRef(s);
|
|
203
203
|
f.current = s;
|
|
204
204
|
const m = r.useRef(s);
|
|
205
205
|
r.useEffect(() => {
|
|
206
206
|
const p = m.current;
|
|
207
|
-
if (m.current = s,
|
|
208
|
-
const
|
|
209
|
-
b !== void 0 &&
|
|
207
|
+
if (m.current = s, o && s !== p) {
|
|
208
|
+
const k = s.length - 1, b = s[k];
|
|
209
|
+
b !== void 0 && o(b, k);
|
|
210
210
|
}
|
|
211
|
-
}, [s,
|
|
212
|
-
const [
|
|
211
|
+
}, [s, o]);
|
|
212
|
+
const [g, a] = r.useState({ isRevealing: !1, revealDepth: null }), v = s.length - 1, y = r.useMemo(() => ({
|
|
213
213
|
stack: s,
|
|
214
|
-
depth:
|
|
215
|
-
isRevealing:
|
|
216
|
-
revealDepth:
|
|
217
|
-
}), [s,
|
|
214
|
+
depth: v,
|
|
215
|
+
isRevealing: g.isRevealing,
|
|
216
|
+
revealDepth: g.revealDepth
|
|
217
|
+
}), [s, v, g.isRevealing, g.revealDepth]), A = s[v], d = v > 0 ? s[v - 1] : null, h = r.useCallback((p) => {
|
|
218
218
|
e.find((b) => b.id === p) && l({ type: "push", id: p });
|
|
219
|
-
}, [e]),
|
|
219
|
+
}, [e]), R = r.useCallback((p) => {
|
|
220
220
|
l({ type: "go", direction: p });
|
|
221
|
-
}, []),
|
|
221
|
+
}, []), C = r.useCallback((p) => {
|
|
222
222
|
l({ type: "move", targetDepth: p });
|
|
223
|
-
}, []),
|
|
223
|
+
}, []), w = r.useCallback((p) => {
|
|
224
224
|
e.find((b) => b.id === p) && l({ type: "replace", id: p });
|
|
225
|
-
}, [e]),
|
|
226
|
-
const
|
|
227
|
-
b < 0 || b >=
|
|
228
|
-
}, []),
|
|
225
|
+
}, [e]), M = r.useCallback((p) => p >= 0 ? !1 : f.current.length - 1 + p >= 0, []), _ = r.useCallback((p) => {
|
|
226
|
+
const k = f.current.length - 1, b = p ?? k - 1;
|
|
227
|
+
b < 0 || b >= k || a({ isRevealing: !0, revealDepth: b });
|
|
228
|
+
}, []), $ = r.useCallback(() => {
|
|
229
229
|
f.current.length - 1 !== 0 && a({ isRevealing: !0, revealDepth: 0 });
|
|
230
230
|
}, []), x = r.useCallback(() => {
|
|
231
231
|
a({ isRevealing: !1, revealDepth: null });
|
|
232
232
|
}, []), N = r.useCallback((p) => {
|
|
233
|
-
const
|
|
233
|
+
const k = f.current, b = k.indexOf(p), X = k.length - 1, F = b === X;
|
|
234
234
|
return {
|
|
235
235
|
"data-stack-panel": p,
|
|
236
236
|
"data-depth": b,
|
|
237
|
-
"data-active":
|
|
238
|
-
"aria-hidden": !
|
|
237
|
+
"data-active": F ? "true" : "false",
|
|
238
|
+
"aria-hidden": !F
|
|
239
239
|
};
|
|
240
240
|
}, []), T = r.useCallback(() => {
|
|
241
|
-
const p = f.current,
|
|
241
|
+
const p = f.current, k = p.length - 1, b = k > 0, X = k > 0 ? p[k - 1] : null, F = X ? e.find((H) => H.id === X) : null, W = F?.title ? `Back to ${F.title}` : "Go back";
|
|
242
242
|
return {
|
|
243
|
-
onClick: () =>
|
|
243
|
+
onClick: () => R(-1),
|
|
244
244
|
disabled: !b,
|
|
245
|
-
"aria-label":
|
|
245
|
+
"aria-label": W
|
|
246
246
|
};
|
|
247
|
-
}, [e,
|
|
247
|
+
}, [e, R]), S = r.useMemo(
|
|
248
248
|
() => ({
|
|
249
249
|
position: "relative",
|
|
250
250
|
width: "100%",
|
|
@@ -252,86 +252,86 @@ function Ve(t) {
|
|
|
252
252
|
overflow: "hidden"
|
|
253
253
|
}),
|
|
254
254
|
[]
|
|
255
|
-
),
|
|
255
|
+
), D = r.useRef({
|
|
256
256
|
panels: e,
|
|
257
|
-
navigationState:
|
|
257
|
+
navigationState: y,
|
|
258
258
|
displayMode: i,
|
|
259
|
-
transitionMode:
|
|
259
|
+
transitionMode: c
|
|
260
260
|
});
|
|
261
|
-
|
|
261
|
+
D.current = {
|
|
262
262
|
panels: e,
|
|
263
|
-
navigationState:
|
|
263
|
+
navigationState: y,
|
|
264
264
|
displayMode: i,
|
|
265
|
-
transitionMode:
|
|
265
|
+
transitionMode: c
|
|
266
266
|
};
|
|
267
267
|
const E = r.useRef(/* @__PURE__ */ new Set());
|
|
268
268
|
r.useEffect(() => {
|
|
269
269
|
E.current.forEach((p) => p());
|
|
270
|
-
}, [
|
|
270
|
+
}, [y, i, c]);
|
|
271
271
|
const U = r.useCallback(
|
|
272
|
-
(p) =>
|
|
272
|
+
(p) => D.current.panels.find((b) => b.id === p)?.content ?? null,
|
|
273
273
|
[]
|
|
274
|
-
),
|
|
274
|
+
), I = r.useMemo(() => e.map((p) => p.id), [e]), { getCachedContent: P } = ee({
|
|
275
275
|
resolveContent: U,
|
|
276
|
-
validIds:
|
|
277
|
-
}),
|
|
276
|
+
validIds: I
|
|
277
|
+
}), L = r.useMemo(
|
|
278
278
|
() => ({
|
|
279
|
-
getState: () =>
|
|
279
|
+
getState: () => D.current,
|
|
280
280
|
subscribe: (p) => (E.current.add(p), () => E.current.delete(p)),
|
|
281
|
-
getCachedContent:
|
|
281
|
+
getCachedContent: P
|
|
282
282
|
}),
|
|
283
|
-
[
|
|
284
|
-
),
|
|
285
|
-
const p = () => /* @__PURE__ */
|
|
283
|
+
[P]
|
|
284
|
+
), K = r.useMemo(() => {
|
|
285
|
+
const p = () => /* @__PURE__ */ O(G.Provider, { value: L, children: /* @__PURE__ */ O("div", { style: S, "data-stack-container": !0, children: /* @__PURE__ */ O(ge, {}) }) });
|
|
286
286
|
return p.displayName = "StackOutlet", p;
|
|
287
|
-
}, [
|
|
287
|
+
}, [L, S]);
|
|
288
288
|
return {
|
|
289
|
-
state:
|
|
289
|
+
state: y,
|
|
290
290
|
push: h,
|
|
291
|
-
go:
|
|
292
|
-
move:
|
|
293
|
-
replace:
|
|
291
|
+
go: R,
|
|
292
|
+
move: C,
|
|
293
|
+
replace: w,
|
|
294
294
|
revealParent: _,
|
|
295
|
-
revealRoot:
|
|
295
|
+
revealRoot: $,
|
|
296
296
|
dismissReveal: x,
|
|
297
297
|
getPanelProps: N,
|
|
298
298
|
getBackButtonProps: T,
|
|
299
|
-
canGo:
|
|
299
|
+
canGo: M,
|
|
300
300
|
currentPanelId: A,
|
|
301
301
|
previousPanelId: d,
|
|
302
|
-
Outlet:
|
|
302
|
+
Outlet: K
|
|
303
303
|
};
|
|
304
304
|
}
|
|
305
|
-
function
|
|
305
|
+
function Ve(n) {
|
|
306
306
|
const {
|
|
307
307
|
containerRef: e,
|
|
308
|
-
navigation:
|
|
308
|
+
navigation: t,
|
|
309
309
|
edge: i = "left",
|
|
310
|
-
edgeWidth:
|
|
311
|
-
enabled:
|
|
312
|
-
} =
|
|
310
|
+
edgeWidth: c = 20,
|
|
311
|
+
enabled: o = !0
|
|
312
|
+
} = n, [u, s] = r.useState(null), l = r.useCallback(
|
|
313
313
|
(d) => {
|
|
314
|
-
s(null), i === "left" && d.direction === 1 &&
|
|
314
|
+
s(null), i === "left" && d.direction === 1 && t.canGo(-1) && t.go(-1);
|
|
315
315
|
},
|
|
316
|
-
[i,
|
|
317
|
-
), { isEdgeGesture: f, state: m, containerProps:
|
|
316
|
+
[i, t]
|
|
317
|
+
), { isEdgeGesture: f, state: m, containerProps: g } = te({
|
|
318
318
|
containerRef: e,
|
|
319
319
|
edge: i,
|
|
320
|
-
edgeWidth:
|
|
321
|
-
enabled:
|
|
320
|
+
edgeWidth: c,
|
|
321
|
+
enabled: o ? t.canGo(-1) : !1,
|
|
322
322
|
// Only enable if can go back
|
|
323
323
|
onSwipeEnd: l
|
|
324
324
|
});
|
|
325
325
|
r.useEffect(() => {
|
|
326
326
|
f && (m.phase === "swiping" || m.phase === "tracking") ? s(m) : m.phase === "idle" && s(null);
|
|
327
327
|
}, [f, m]);
|
|
328
|
-
const { containerProps: a } =
|
|
328
|
+
const { containerProps: a } = ne({
|
|
329
329
|
containerRef: e,
|
|
330
330
|
active: f,
|
|
331
331
|
preventEdgeBack: !0,
|
|
332
332
|
preventOverscroll: !0,
|
|
333
|
-
edgeWidth:
|
|
334
|
-
}),
|
|
333
|
+
edgeWidth: c
|
|
334
|
+
}), v = r.useMemo(() => {
|
|
335
335
|
if (!u || !e.current)
|
|
336
336
|
return 0;
|
|
337
337
|
const d = e.current.clientWidth;
|
|
@@ -340,224 +340,183 @@ function Ke(t) {
|
|
|
340
340
|
const h = u.displacement.x;
|
|
341
341
|
if (i === "left" && h <= 0 || i === "right" && h >= 0)
|
|
342
342
|
return 0;
|
|
343
|
-
const
|
|
344
|
-
return Math.min(
|
|
345
|
-
}, [u, e, i]),
|
|
346
|
-
() =>
|
|
347
|
-
[
|
|
343
|
+
const R = Math.abs(h);
|
|
344
|
+
return Math.min(R / d, 1);
|
|
345
|
+
}, [u, e, i]), y = r.useMemo(
|
|
346
|
+
() => re(g, a),
|
|
347
|
+
[g, a]
|
|
348
348
|
);
|
|
349
349
|
return {
|
|
350
350
|
isEdgeSwiping: f,
|
|
351
|
-
progress:
|
|
352
|
-
inputState: f ? m :
|
|
353
|
-
containerProps:
|
|
351
|
+
progress: v,
|
|
352
|
+
inputState: f ? m : se,
|
|
353
|
+
containerProps: y
|
|
354
354
|
};
|
|
355
355
|
}
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
easeOutExpo: (t) => t === 1 ? 1 : 1 - Math.pow(2, -10 * t)
|
|
359
|
-
}, ve = 300;
|
|
360
|
-
function ge(t) {
|
|
361
|
-
const {
|
|
362
|
-
duration: e = ve,
|
|
363
|
-
easing: n = V.easeOutExpo,
|
|
364
|
-
onFrame: i,
|
|
365
|
-
onComplete: o
|
|
366
|
-
} = t, [c, u] = r.useState(!1), s = r.useRef(null), l = r.useRef(null), f = r.useRef(i), m = r.useRef(o);
|
|
367
|
-
r.useEffect(() => {
|
|
368
|
-
f.current = i, m.current = o;
|
|
369
|
-
}, [i, o]);
|
|
370
|
-
const v = r.useCallback(() => {
|
|
371
|
-
s.current !== null && (cancelAnimationFrame(s.current), s.current = null), l.current = null, u(!1);
|
|
372
|
-
}, []), a = r.useCallback(() => {
|
|
373
|
-
v(), u(!0), l.current = null;
|
|
374
|
-
const g = (R) => {
|
|
375
|
-
l.current === null && (l.current = R);
|
|
376
|
-
const A = R - l.current, d = Math.min(A / e, 1), h = n(d), y = d >= 1, k = {
|
|
377
|
-
progress: d,
|
|
378
|
-
easedProgress: h,
|
|
379
|
-
elapsed: A,
|
|
380
|
-
isComplete: y
|
|
381
|
-
};
|
|
382
|
-
f.current?.(k), y ? (s.current = null, l.current = null, u(!1), m.current?.()) : s.current = requestAnimationFrame(g);
|
|
383
|
-
};
|
|
384
|
-
s.current = requestAnimationFrame(g);
|
|
385
|
-
}, [e, n, v]);
|
|
386
|
-
return r.useEffect(() => () => {
|
|
387
|
-
s.current !== null && cancelAnimationFrame(s.current);
|
|
388
|
-
}, []), {
|
|
389
|
-
isAnimating: c,
|
|
390
|
-
start: a,
|
|
391
|
-
cancel: v
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
function Re(t, e, n) {
|
|
395
|
-
return t + (e - t) * n;
|
|
396
|
-
}
|
|
397
|
-
const Ae = 300, B = (t) => t === "horizontal" ? "translateX" : "translateY", ye = (t, e, n, i) => t || e === void 0 || e <= 0 || n === void 0 || n === i ? null : { from: n, to: i }, be = (t, e, n, i, o, c, u) => t === e ? { type: "none" } : i ? { type: "none" } : o ? { type: "none" } : c ? Math.abs(n - t) <= 1 ? { type: "snap", position: t } : u ? n > t ? { type: "snap", position: t } : { type: "animate", animation: { from: n, to: t } } : { type: "animate", animation: { from: n, to: t } } : { type: "snap", position: t }, Ce = (t, e, n) => t === void 0 || t === e || t <= 0 ? null : n;
|
|
398
|
-
function ke(t) {
|
|
356
|
+
const ye = 300, B = (n) => n === "horizontal" ? "translateX" : "translateY", Ae = (n, e, t, i) => n || e === void 0 || e <= 0 || t === void 0 || t === i ? null : { from: t, to: i }, Re = (n, e, t, i, c, o, u) => n === e ? { type: "none" } : i ? { type: "none" } : c ? { type: "none" } : o ? Math.abs(t - n) <= 1 ? { type: "snap", position: n } : u ? t > n ? { type: "snap", position: n } : { type: "animate", animation: { from: t, to: n } } : { type: "animate", animation: { from: t, to: n } } : { type: "snap", position: n }, be = (n, e, t) => n === void 0 || n === e || n <= 0 ? null : t;
|
|
357
|
+
function ke(n) {
|
|
399
358
|
const {
|
|
400
359
|
elementRef: e,
|
|
401
|
-
targetPx:
|
|
360
|
+
targetPx: t,
|
|
402
361
|
displacement: i,
|
|
403
|
-
isOperating:
|
|
404
|
-
axis:
|
|
405
|
-
animationDuration: u =
|
|
362
|
+
isOperating: c,
|
|
363
|
+
axis: o = "horizontal",
|
|
364
|
+
animationDuration: u = ye,
|
|
406
365
|
containerSize: s,
|
|
407
366
|
animateOnTargetChange: l = !1,
|
|
408
367
|
initialPx: f,
|
|
409
368
|
skipTargetChangeAnimation: m = !1
|
|
410
|
-
} =
|
|
369
|
+
} = n, g = f ?? t, a = r.useRef(g), v = r.useRef(null), y = r.useRef(t), A = r.useRef(s), d = r.useRef(null), h = r.useRef(!1), R = Ae(
|
|
411
370
|
h.current,
|
|
412
371
|
s,
|
|
413
372
|
f,
|
|
414
|
-
|
|
373
|
+
t
|
|
415
374
|
);
|
|
416
|
-
|
|
417
|
-
const
|
|
418
|
-
|
|
419
|
-
|
|
375
|
+
R !== null && (d.current = R, h.current = !0);
|
|
376
|
+
const C = Re(
|
|
377
|
+
t,
|
|
378
|
+
y.current,
|
|
420
379
|
a.current,
|
|
421
|
-
|
|
422
|
-
|
|
380
|
+
c,
|
|
381
|
+
v.current !== null,
|
|
423
382
|
l,
|
|
424
383
|
m
|
|
425
384
|
);
|
|
426
|
-
|
|
427
|
-
const
|
|
385
|
+
C.type === "animate" ? (d.current = C.animation, y.current = t) : C.type === "snap" && (a.current = C.position, y.current = t);
|
|
386
|
+
const w = be(
|
|
428
387
|
s,
|
|
429
388
|
A.current,
|
|
430
|
-
|
|
389
|
+
t
|
|
431
390
|
);
|
|
432
|
-
|
|
433
|
-
const
|
|
391
|
+
w !== null && (a.current = w, A.current = s);
|
|
392
|
+
const M = r.useCallback(
|
|
434
393
|
({ easedProgress: T }) => {
|
|
435
|
-
const
|
|
436
|
-
if (!
|
|
394
|
+
const S = e.current, D = v.current;
|
|
395
|
+
if (!S || !D)
|
|
437
396
|
return;
|
|
438
|
-
const E =
|
|
439
|
-
a.current = E,
|
|
397
|
+
const E = ie(D.from, D.to, T);
|
|
398
|
+
a.current = E, S.style.transform = `${B(o)}(${E}px)`;
|
|
440
399
|
},
|
|
441
|
-
[
|
|
400
|
+
[o, e]
|
|
442
401
|
), _ = r.useCallback(() => {
|
|
443
|
-
|
|
444
|
-
}, [
|
|
402
|
+
v.current = null, a.current = t, y.current = t;
|
|
403
|
+
}, [t]), { isAnimating: $, start: x, cancel: N } = oe({
|
|
445
404
|
duration: u,
|
|
446
|
-
easing:
|
|
447
|
-
onFrame:
|
|
405
|
+
easing: ae.easeOutExpo,
|
|
406
|
+
onFrame: M,
|
|
448
407
|
onComplete: _
|
|
449
408
|
});
|
|
450
409
|
return r.useLayoutEffect(() => {
|
|
451
|
-
if (
|
|
452
|
-
N(),
|
|
410
|
+
if (c) {
|
|
411
|
+
N(), v.current = null, d.current = null;
|
|
453
412
|
return;
|
|
454
413
|
}
|
|
455
414
|
if (d.current) {
|
|
456
|
-
const
|
|
457
|
-
|
|
415
|
+
const D = d.current;
|
|
416
|
+
v.current = D, d.current = null;
|
|
458
417
|
const E = e.current;
|
|
459
|
-
E && (E.style.transform = `${B(
|
|
418
|
+
E && (E.style.transform = `${B(o)}(${D.from}px)`), x();
|
|
460
419
|
return;
|
|
461
420
|
}
|
|
462
421
|
const T = a.current;
|
|
463
|
-
Math.abs(T -
|
|
464
|
-
}, [
|
|
422
|
+
Math.abs(T - t) > 1 ? (v.current = { from: T, to: t }, x()) : (a.current = t, y.current = t);
|
|
423
|
+
}, [c, t, x, N]), r.useLayoutEffect(() => {
|
|
465
424
|
const T = e.current;
|
|
466
|
-
if (!T ||
|
|
425
|
+
if (!T || $ || v.current !== null || d.current !== null)
|
|
467
426
|
return;
|
|
468
|
-
const
|
|
469
|
-
a.current =
|
|
470
|
-
}, [
|
|
471
|
-
isAnimating:
|
|
427
|
+
const S = t + i;
|
|
428
|
+
a.current = S, T.style.transform = `${B(o)}(${S}px)`;
|
|
429
|
+
}, [t, i, o, $, e]), {
|
|
430
|
+
isAnimating: $,
|
|
472
431
|
currentPx: a.current,
|
|
473
|
-
animationDirection:
|
|
432
|
+
animationDirection: v.current
|
|
474
433
|
};
|
|
475
434
|
}
|
|
476
|
-
function
|
|
477
|
-
const
|
|
435
|
+
function Ce(n, e) {
|
|
436
|
+
const t = r.useRef(e), i = r.useRef(n), c = r.useRef(!1), u = t.current ? !e : !1, s = n !== i.current, l = e ? s : !1, g = (c.current ? !0 : l) ? !0 : u ? s : !1, a = e ? i.current : n;
|
|
478
437
|
return r.useLayoutEffect(() => {
|
|
479
|
-
e ? l && (
|
|
438
|
+
e ? l && (c.current = !0) : (c.current = !1, i.current = n), t.current = e;
|
|
480
439
|
}), {
|
|
481
440
|
value: a,
|
|
482
|
-
changedDuringOperation:
|
|
441
|
+
changedDuringOperation: g,
|
|
483
442
|
operationJustEnded: u
|
|
484
443
|
};
|
|
485
444
|
}
|
|
486
|
-
const
|
|
487
|
-
function
|
|
488
|
-
return Math.max(0,
|
|
445
|
+
const V = -0.3;
|
|
446
|
+
function Te(n) {
|
|
447
|
+
return Math.max(0, n);
|
|
489
448
|
}
|
|
490
|
-
function
|
|
449
|
+
function Se(n, e, t = V) {
|
|
491
450
|
if (e <= 0)
|
|
492
451
|
return 0;
|
|
493
|
-
const i = Math.max(0,
|
|
494
|
-
return
|
|
452
|
+
const i = Math.max(0, n), c = Math.min(i / e, 1), o = t * e, u = Math.abs(t) * c * e;
|
|
453
|
+
return o + u;
|
|
495
454
|
}
|
|
496
|
-
function
|
|
497
|
-
const { depth: e, navigationDepth:
|
|
498
|
-
return !!(i || e ===
|
|
455
|
+
function De(n) {
|
|
456
|
+
const { depth: e, navigationDepth: t, isActive: i, isOperating: c, isAnimating: o } = n;
|
|
457
|
+
return !!(i || e === t - 1 && (c || o));
|
|
499
458
|
}
|
|
500
|
-
function
|
|
501
|
-
return
|
|
459
|
+
function Ie(n, e) {
|
|
460
|
+
return n === e ? "active" : n === e - 1 ? "behind" : "hidden";
|
|
502
461
|
}
|
|
503
|
-
const
|
|
462
|
+
const Ee = 300, we = 0.05, Me = 0.1, xe = {
|
|
504
463
|
position: "absolute",
|
|
505
464
|
inset: 0,
|
|
506
465
|
width: "100%",
|
|
507
466
|
height: "100%"
|
|
508
|
-
}, Pe = (
|
|
467
|
+
}, Pe = (n, e) => n.phase === "idle" ? 0 : e === "horizontal" ? n.displacement.x : n.displacement.y, Oe = "-5px 0 15px rgba(0, 0, 0, 0.1)", Ne = r.memo(
|
|
509
468
|
({
|
|
510
|
-
id:
|
|
469
|
+
id: n,
|
|
511
470
|
depth: e,
|
|
512
|
-
navigationDepth:
|
|
471
|
+
navigationDepth: t,
|
|
513
472
|
isActive: i,
|
|
514
|
-
operationState:
|
|
515
|
-
containerSize:
|
|
473
|
+
operationState: c,
|
|
474
|
+
containerSize: o,
|
|
516
475
|
axis: u = "horizontal",
|
|
517
|
-
behindOffset: s =
|
|
518
|
-
animationDuration: l =
|
|
476
|
+
behindOffset: s = V,
|
|
477
|
+
animationDuration: l = Ee,
|
|
519
478
|
animateOnMount: f = !1,
|
|
520
479
|
showShadow: m = !0,
|
|
521
|
-
displayMode:
|
|
480
|
+
displayMode: g = "overlay",
|
|
522
481
|
showDimming: a = !0,
|
|
523
|
-
children:
|
|
482
|
+
children: v
|
|
524
483
|
}) => {
|
|
525
|
-
const
|
|
484
|
+
const y = r.useRef(null), A = Pe(c, u), d = c.phase === "operating", h = Ie(e, t), { value: R, changedDuringOperation: C } = Ce(
|
|
526
485
|
h,
|
|
527
486
|
A > 0
|
|
528
|
-
),
|
|
529
|
-
switch (
|
|
487
|
+
), w = r.useMemo(() => {
|
|
488
|
+
switch (R) {
|
|
530
489
|
case "active":
|
|
531
490
|
return 0;
|
|
532
491
|
case "behind":
|
|
533
|
-
return s *
|
|
492
|
+
return s * o;
|
|
534
493
|
case "hidden":
|
|
535
|
-
return
|
|
494
|
+
return o;
|
|
536
495
|
}
|
|
537
|
-
}, [
|
|
496
|
+
}, [R, s, o]), M = r.useMemo(() => {
|
|
538
497
|
if (A <= 0)
|
|
539
498
|
return 0;
|
|
540
|
-
switch (
|
|
499
|
+
switch (R) {
|
|
541
500
|
case "active":
|
|
542
|
-
return
|
|
501
|
+
return Te(A);
|
|
543
502
|
case "behind": {
|
|
544
|
-
const
|
|
545
|
-
return
|
|
503
|
+
const I = Se(A, o, s), P = s * o;
|
|
504
|
+
return I - P;
|
|
546
505
|
}
|
|
547
506
|
case "hidden":
|
|
548
507
|
return 0;
|
|
549
508
|
}
|
|
550
|
-
}, [
|
|
509
|
+
}, [R, A, o, s]), _ = r.useMemo(() => {
|
|
551
510
|
if (f && h === "active" && e > 0)
|
|
552
|
-
return
|
|
553
|
-
}, [f, h, e,
|
|
554
|
-
elementRef:
|
|
555
|
-
targetPx:
|
|
556
|
-
displacement:
|
|
511
|
+
return o;
|
|
512
|
+
}, [f, h, e, o]), { isAnimating: $ } = ke({
|
|
513
|
+
elementRef: y,
|
|
514
|
+
targetPx: w,
|
|
515
|
+
displacement: M,
|
|
557
516
|
isOperating: d,
|
|
558
517
|
axis: u,
|
|
559
518
|
animationDuration: l,
|
|
560
|
-
containerSize:
|
|
519
|
+
containerSize: o,
|
|
561
520
|
// Animate when targetPx changes (button navigation)
|
|
562
521
|
animateOnTargetChange: !0,
|
|
563
522
|
// For push animation: start from off-screen
|
|
@@ -566,108 +525,108 @@ const Me = 300, we = 0.05, xe = 0.1, Oe = {
|
|
|
566
525
|
// This handles over-swipe where panel moves beyond 100% and needs to snap back.
|
|
567
526
|
// useSwipeContentTransform allows forward animations (normal swipe-to-complete)
|
|
568
527
|
// but skips backward animations (over-swipe snap).
|
|
569
|
-
skipTargetChangeAnimation:
|
|
570
|
-
}), x =
|
|
528
|
+
skipTargetChangeAnimation: C
|
|
529
|
+
}), x = De({
|
|
571
530
|
depth: e,
|
|
572
|
-
navigationDepth:
|
|
531
|
+
navigationDepth: t,
|
|
573
532
|
isActive: i,
|
|
574
533
|
isOperating: d,
|
|
575
|
-
isAnimating:
|
|
576
|
-
}), N = r.useMemo(() =>
|
|
577
|
-
if (
|
|
534
|
+
isAnimating: $
|
|
535
|
+
}), N = r.useMemo(() => o <= 0 || A <= 0 ? 0 : Math.min(A / o, 1), [A, o]), T = r.useMemo(() => {
|
|
536
|
+
if (g !== "stack")
|
|
578
537
|
return 1;
|
|
579
|
-
const
|
|
538
|
+
const I = t - e;
|
|
580
539
|
if (h === "active")
|
|
581
540
|
return 1;
|
|
582
541
|
if (h === "behind") {
|
|
583
|
-
const
|
|
584
|
-
return
|
|
542
|
+
const P = 1 - I * we;
|
|
543
|
+
return P + N * (1 - P);
|
|
585
544
|
}
|
|
586
545
|
return 1;
|
|
587
|
-
}, [
|
|
546
|
+
}, [g, h, e, t, N]), S = r.useMemo(() => !a || h !== "behind" ? 0 : Me * (1 - N), [a, h, N]);
|
|
588
547
|
r.useLayoutEffect(() => {
|
|
589
|
-
const
|
|
590
|
-
|
|
548
|
+
const I = y.current;
|
|
549
|
+
I && (I.style.visibility = x ? "visible" : "hidden");
|
|
591
550
|
}, [x]), r.useLayoutEffect(() => {
|
|
592
|
-
const
|
|
593
|
-
if (!
|
|
551
|
+
const I = y.current;
|
|
552
|
+
if (!I || g !== "stack")
|
|
594
553
|
return;
|
|
595
|
-
const
|
|
596
|
-
if (
|
|
597
|
-
const
|
|
598
|
-
|
|
554
|
+
const P = I.style.transform;
|
|
555
|
+
if (P.includes("translateX")) {
|
|
556
|
+
const L = P.match(/translateX\([^)]+\)/);
|
|
557
|
+
L && (I.style.transform = `${L[0]} scale(${T})`);
|
|
599
558
|
} else
|
|
600
|
-
|
|
601
|
-
}, [T,
|
|
602
|
-
const
|
|
559
|
+
I.style.transform = `scale(${T})`;
|
|
560
|
+
}, [T, g]);
|
|
561
|
+
const D = m ? e > 0 && h === "active" : !1, E = r.useMemo(
|
|
603
562
|
() => ({
|
|
604
|
-
...
|
|
563
|
+
...xe,
|
|
605
564
|
pointerEvents: i ? "auto" : "none",
|
|
606
565
|
willChange: "transform",
|
|
607
566
|
zIndex: e,
|
|
608
567
|
visibility: x ? "visible" : "hidden",
|
|
609
|
-
boxShadow:
|
|
568
|
+
boxShadow: D ? Oe : void 0
|
|
610
569
|
}),
|
|
611
|
-
[i, e, x,
|
|
612
|
-
), U = r.useMemo(() =>
|
|
570
|
+
[i, e, x, D]
|
|
571
|
+
), U = r.useMemo(() => S <= 0 ? null : {
|
|
613
572
|
position: "absolute",
|
|
614
573
|
inset: 0,
|
|
615
|
-
backgroundColor: `rgba(0, 0, 0, ${
|
|
574
|
+
backgroundColor: `rgba(0, 0, 0, ${S})`,
|
|
616
575
|
pointerEvents: "none",
|
|
617
576
|
zIndex: 1
|
|
618
|
-
}, [
|
|
619
|
-
return /* @__PURE__ */
|
|
577
|
+
}, [S]);
|
|
578
|
+
return /* @__PURE__ */ j(
|
|
620
579
|
"div",
|
|
621
580
|
{
|
|
622
|
-
ref:
|
|
623
|
-
"data-stack-content":
|
|
581
|
+
ref: y,
|
|
582
|
+
"data-stack-content": n,
|
|
624
583
|
"data-depth": e,
|
|
625
584
|
"data-active": i ? "true" : "false",
|
|
626
585
|
"data-role": h,
|
|
627
586
|
style: E,
|
|
628
587
|
children: [
|
|
629
|
-
|
|
630
|
-
U != null ? /* @__PURE__ */
|
|
588
|
+
v,
|
|
589
|
+
U != null ? /* @__PURE__ */ O("div", { style: U, "data-dimming-overlay": !0 }) : null
|
|
631
590
|
]
|
|
632
591
|
}
|
|
633
592
|
);
|
|
634
593
|
}
|
|
635
|
-
),
|
|
636
|
-
function $e(
|
|
637
|
-
const { stack: i, depth:
|
|
638
|
-
|
|
594
|
+
), _e = 300;
|
|
595
|
+
function $e(n, e, t) {
|
|
596
|
+
const { stack: i, depth: c } = e, o = [c];
|
|
597
|
+
c > 0 && o.push(c - 1);
|
|
639
598
|
const u = [];
|
|
640
|
-
for (const s of
|
|
641
|
-
const l = i[s], f =
|
|
599
|
+
for (const s of o) {
|
|
600
|
+
const l = i[s], f = n.find((m) => m.id === l);
|
|
642
601
|
f && u.push({ panel: f, depth: s, isExiting: !1 });
|
|
643
602
|
}
|
|
644
|
-
if (
|
|
645
|
-
const l =
|
|
646
|
-
l && u.push({ panel: l, depth:
|
|
603
|
+
if (t != null && !u.some((l) => l.panel.id === t)) {
|
|
604
|
+
const l = n.find((f) => f.id === t);
|
|
605
|
+
l && u.push({ panel: l, depth: c + 1, isExiting: !0 });
|
|
647
606
|
}
|
|
648
607
|
return u.sort((s, l) => s.depth - l.depth);
|
|
649
608
|
}
|
|
650
|
-
const
|
|
609
|
+
const Ke = r.memo(
|
|
651
610
|
({
|
|
652
|
-
panels:
|
|
611
|
+
panels: n,
|
|
653
612
|
navigationState: e,
|
|
654
|
-
operationState:
|
|
613
|
+
operationState: t,
|
|
655
614
|
containerSize: i,
|
|
656
|
-
getCachedContent:
|
|
657
|
-
behindOffset:
|
|
615
|
+
getCachedContent: c,
|
|
616
|
+
behindOffset: o,
|
|
658
617
|
animateOnMount: u = !1,
|
|
659
|
-
animationDuration: s =
|
|
618
|
+
animationDuration: s = _e,
|
|
660
619
|
showShadow: l,
|
|
661
620
|
displayMode: f,
|
|
662
621
|
showDimming: m
|
|
663
622
|
}) => {
|
|
664
|
-
const [
|
|
623
|
+
const [g, a] = r.useState(null), v = r.useRef(e.depth), y = r.useRef(e.stack);
|
|
665
624
|
r.useLayoutEffect(() => {
|
|
666
|
-
const h =
|
|
667
|
-
if (
|
|
668
|
-
const
|
|
669
|
-
if (
|
|
670
|
-
a(
|
|
625
|
+
const h = v.current, R = y.current, { depth: C, stack: w } = e;
|
|
626
|
+
if (v.current = C, y.current = w, C < h) {
|
|
627
|
+
const M = R[h];
|
|
628
|
+
if (M != null) {
|
|
629
|
+
a(M);
|
|
671
630
|
const _ = setTimeout(() => {
|
|
672
631
|
a(null);
|
|
673
632
|
}, s);
|
|
@@ -676,8 +635,8 @@ const We = r.memo(
|
|
|
676
635
|
}
|
|
677
636
|
}, [e.depth, e.stack, s]);
|
|
678
637
|
const A = r.useMemo(
|
|
679
|
-
() => $e(
|
|
680
|
-
[
|
|
638
|
+
() => $e(n, e, g),
|
|
639
|
+
[n, e, g]
|
|
681
640
|
), d = r.useMemo(
|
|
682
641
|
() => ({
|
|
683
642
|
position: "relative",
|
|
@@ -687,24 +646,24 @@ const We = r.memo(
|
|
|
687
646
|
}),
|
|
688
647
|
[]
|
|
689
648
|
);
|
|
690
|
-
return /* @__PURE__ */
|
|
691
|
-
const
|
|
692
|
-
return /* @__PURE__ */
|
|
693
|
-
|
|
649
|
+
return /* @__PURE__ */ O("div", { style: d, "data-swipe-stack-container": !0, children: A.map(({ panel: h, depth: R, isExiting: C }) => {
|
|
650
|
+
const w = R === e.depth && !C, M = c?.(h.id) ?? h.content;
|
|
651
|
+
return /* @__PURE__ */ O(
|
|
652
|
+
Ne,
|
|
694
653
|
{
|
|
695
654
|
id: h.id,
|
|
696
|
-
depth:
|
|
655
|
+
depth: R,
|
|
697
656
|
navigationDepth: e.depth,
|
|
698
|
-
isActive:
|
|
699
|
-
operationState:
|
|
657
|
+
isActive: w,
|
|
658
|
+
operationState: t,
|
|
700
659
|
containerSize: i,
|
|
701
|
-
behindOffset:
|
|
660
|
+
behindOffset: o,
|
|
702
661
|
animateOnMount: u,
|
|
703
662
|
animationDuration: s,
|
|
704
663
|
showShadow: l,
|
|
705
664
|
displayMode: f,
|
|
706
665
|
showDimming: m,
|
|
707
|
-
children:
|
|
666
|
+
children: M
|
|
708
667
|
},
|
|
709
668
|
h.id
|
|
710
669
|
);
|
|
@@ -712,10 +671,10 @@ const We = r.memo(
|
|
|
712
671
|
}
|
|
713
672
|
);
|
|
714
673
|
export {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
674
|
+
he as StackContent,
|
|
675
|
+
Ne as SwipeStackContent,
|
|
676
|
+
Ke as SwipeStackOutlet,
|
|
677
|
+
Ge as useStackNavigation,
|
|
678
|
+
Ve as useStackSwipeInput
|
|
720
679
|
};
|
|
721
680
|
//# sourceMappingURL=stack.js.map
|