react-panel-layout 0.6.1 → 0.7.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.
- package/dist/FloatingWindow-CE-WzkNv.js +1542 -0
- package/dist/FloatingWindow-CE-WzkNv.js.map +1 -0
- package/dist/FloatingWindow-DpFpmX1f.cjs +2 -0
- package/dist/FloatingWindow-DpFpmX1f.cjs.map +1 -0
- package/dist/GridLayout-EwKszYBy.cjs +2 -0
- package/dist/{GridLayout-DKTg_N61.cjs.map → GridLayout-EwKszYBy.cjs.map} +1 -1
- package/dist/GridLayout-kiWdpMLQ.js +947 -0
- package/dist/{GridLayout-UWNxXw77.js.map → GridLayout-kiWdpMLQ.js.map} +1 -1
- package/dist/PanelSystem-Dmy5YI_6.cjs +3 -0
- package/dist/PanelSystem-Dmy5YI_6.cjs.map +1 -0
- package/dist/{PanelSystem-BqUzNtf2.js → PanelSystem-DrYsYwuV.js} +208 -247
- package/dist/PanelSystem-DrYsYwuV.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/dialog/index.d.ts +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/dialog/DialogContainer.d.ts +22 -2
- package/dist/modules/dialog/Modal.d.ts +23 -2
- package/dist/modules/dialog/SwipeDialogContainer.d.ts +6 -2
- package/dist/modules/dialog/types.d.ts +12 -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/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-CRuFlk5t.js +394 -0
- package/dist/useAnimationFrame-CRuFlk5t.js.map +1 -0
- package/dist/useAnimationFrame-XRpDXkwV.cjs +2 -0
- package/dist/useAnimationFrame-XRpDXkwV.cjs.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/dialog/index.ts +2 -0
- package/src/hooks/gesture/testing/createGestureSimulator.ts +1 -0
- package/src/hooks/gesture/useNativeGestureGuard.spec.ts +10 -2
- package/src/hooks/gesture/useSwipeInput.spec.ts +69 -0
- package/src/hooks/gesture/useSwipeInput.ts +2 -0
- 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/DialogContainer.tsx +39 -5
- package/src/modules/dialog/Modal.tsx +46 -4
- package/src/modules/dialog/SwipeDialogContainer.tsx +12 -2
- package/src/modules/dialog/dialogAnimationUtils.spec.ts +0 -1
- package/src/modules/dialog/types.ts +14 -0
- 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
|
@@ -0,0 +1,1542 @@
|
|
|
1
|
+
import { jsx as P, jsxs as U, Fragment as X } from "react/jsx-runtime";
|
|
2
|
+
import * as s from "react";
|
|
3
|
+
import * as Oe from "react-dom";
|
|
4
|
+
import { createPortal as Ce } from "react-dom";
|
|
5
|
+
import { F as ce, e as ue, a as le, b as de, f as pe, d as De } from "./FloatingPanelFrame-3eU9AwPo.js";
|
|
6
|
+
import { x as ve, y as Re, z as xe, A as Te, B as Ae, E as Me, I as _e } from "./styles-NkjuMOVS.js";
|
|
7
|
+
import { u as Le, a as ke, c as Ie, d as Fe, f as Ne, m as We, b as ze, e as He } from "./useAnimationFrame-CRuFlk5t.js";
|
|
8
|
+
import { u as Be } from "./useContentCache-CO3LYNmz.js";
|
|
9
|
+
const $e = "data-swipe-safe-zone", Sn = ({
|
|
10
|
+
children: e,
|
|
11
|
+
className: t,
|
|
12
|
+
style: n
|
|
13
|
+
}) => /* @__PURE__ */ P(
|
|
14
|
+
"div",
|
|
15
|
+
{
|
|
16
|
+
className: t,
|
|
17
|
+
style: n,
|
|
18
|
+
"data-swipe-safe-zone": "true",
|
|
19
|
+
children: e
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
function Ve(e, t) {
|
|
23
|
+
let n = e;
|
|
24
|
+
for (; n && n !== t; ) {
|
|
25
|
+
if (n.hasAttribute($e))
|
|
26
|
+
return !0;
|
|
27
|
+
n = n.parentElement;
|
|
28
|
+
}
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
function Ge(e) {
|
|
32
|
+
switch (e) {
|
|
33
|
+
case "left":
|
|
34
|
+
case "right":
|
|
35
|
+
return "x";
|
|
36
|
+
case "top":
|
|
37
|
+
case "bottom":
|
|
38
|
+
return "y";
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function fe(e) {
|
|
42
|
+
switch (e) {
|
|
43
|
+
case "left":
|
|
44
|
+
return -1;
|
|
45
|
+
case "right":
|
|
46
|
+
return 1;
|
|
47
|
+
case "top":
|
|
48
|
+
return -1;
|
|
49
|
+
case "bottom":
|
|
50
|
+
return 1;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function Ue(e) {
|
|
54
|
+
return fe(e) * -1;
|
|
55
|
+
}
|
|
56
|
+
const Ye = 0.3, Ze = 0.5;
|
|
57
|
+
function Xe(e, t) {
|
|
58
|
+
return t === "x" ? e.clientWidth : e.clientHeight;
|
|
59
|
+
}
|
|
60
|
+
function je(e, t, n) {
|
|
61
|
+
return n === "x" ? t.x - e.x : t.y - e.y;
|
|
62
|
+
}
|
|
63
|
+
const qe = {
|
|
64
|
+
idle: "idle",
|
|
65
|
+
ended: "ended"
|
|
66
|
+
};
|
|
67
|
+
function Ke(e) {
|
|
68
|
+
return qe[e] ?? "operating";
|
|
69
|
+
}
|
|
70
|
+
function Je(e, t, n) {
|
|
71
|
+
const r = e * n;
|
|
72
|
+
return t === "x" ? { x: r, y: 0 } : { x: 0, y: r };
|
|
73
|
+
}
|
|
74
|
+
function Qe(e, t, n) {
|
|
75
|
+
return t === "x" ? Math.max(0, n * e.x) : Math.max(0, n * e.y);
|
|
76
|
+
}
|
|
77
|
+
function et(e, t) {
|
|
78
|
+
return e ? !t : !1;
|
|
79
|
+
}
|
|
80
|
+
function tt(e, t) {
|
|
81
|
+
return e ? t : !1;
|
|
82
|
+
}
|
|
83
|
+
function nt(e, t) {
|
|
84
|
+
return e ? !t : !1;
|
|
85
|
+
}
|
|
86
|
+
function rt(e, t) {
|
|
87
|
+
return e === "idle" ? !1 : t;
|
|
88
|
+
}
|
|
89
|
+
function ot(e, t, n) {
|
|
90
|
+
if (!e || !t)
|
|
91
|
+
return 0;
|
|
92
|
+
const r = Math.max(1, t.timestamp - e.timestamp);
|
|
93
|
+
return n / r;
|
|
94
|
+
}
|
|
95
|
+
function it(e) {
|
|
96
|
+
const {
|
|
97
|
+
edgeContainerRef: t,
|
|
98
|
+
drawerContentRef: n,
|
|
99
|
+
direction: r,
|
|
100
|
+
isOpen: o,
|
|
101
|
+
onSwipeOpen: i,
|
|
102
|
+
onSwipeClose: a,
|
|
103
|
+
enableEdgeSwipeOpen: c = !0,
|
|
104
|
+
enableSwipeClose: u = !0,
|
|
105
|
+
edgeWidth: l = 20,
|
|
106
|
+
dismissThreshold: d = Ye
|
|
107
|
+
} = e, p = Ge(r), w = fe(r), O = Ue(r), C = s.useRef(0);
|
|
108
|
+
s.useLayoutEffect(() => {
|
|
109
|
+
const m = n.current;
|
|
110
|
+
if (!m)
|
|
111
|
+
return;
|
|
112
|
+
const y = () => {
|
|
113
|
+
C.current = Xe(m, p);
|
|
114
|
+
};
|
|
115
|
+
y();
|
|
116
|
+
const T = new ResizeObserver(y);
|
|
117
|
+
return T.observe(m), () => T.disconnect();
|
|
118
|
+
}, [n, p]);
|
|
119
|
+
const D = s.useCallback(
|
|
120
|
+
(m) => {
|
|
121
|
+
m.direction === O && i();
|
|
122
|
+
},
|
|
123
|
+
[O, i]
|
|
124
|
+
), {
|
|
125
|
+
isEdgeGesture: b,
|
|
126
|
+
state: f,
|
|
127
|
+
containerProps: g
|
|
128
|
+
} = Le({
|
|
129
|
+
containerRef: t,
|
|
130
|
+
edge: r,
|
|
131
|
+
edgeWidth: l,
|
|
132
|
+
enabled: et(c, o),
|
|
133
|
+
onSwipeEnd: D
|
|
134
|
+
}), { containerProps: $ } = ke({
|
|
135
|
+
containerRef: t,
|
|
136
|
+
active: b,
|
|
137
|
+
preventEdgeBack: !0,
|
|
138
|
+
preventOverscroll: !0,
|
|
139
|
+
edgeWidth: l
|
|
140
|
+
}), { state: S, onPointerDown: k } = Ie({
|
|
141
|
+
enabled: tt(u, o)
|
|
142
|
+
}), [x, R] = s.useState("idle"), M = s.useRef(0), N = s.useCallback(
|
|
143
|
+
(m) => {
|
|
144
|
+
if (!u || !o)
|
|
145
|
+
return;
|
|
146
|
+
const y = n.current;
|
|
147
|
+
if (!y)
|
|
148
|
+
return;
|
|
149
|
+
const T = m.target;
|
|
150
|
+
Ve(T, y) || Fe(T, y, p, w) || k(m);
|
|
151
|
+
},
|
|
152
|
+
[u, o, n, p, w, k]
|
|
153
|
+
), E = s.useMemo(() => {
|
|
154
|
+
if (!S.isDown || !S.start || !S.current)
|
|
155
|
+
return M.current;
|
|
156
|
+
const y = je(S.start, S.current, p) * w;
|
|
157
|
+
return Math.max(0, y);
|
|
158
|
+
}, [S.isDown, S.start, S.current, p, w]);
|
|
159
|
+
s.useEffect(() => {
|
|
160
|
+
S.isDown && S.current && (M.current = E);
|
|
161
|
+
}, [S.isDown, S.current, E]), s.useEffect(() => {
|
|
162
|
+
S.isDown && x === "idle" && R("operating");
|
|
163
|
+
}, [S.isDown, x]), s.useEffect(() => {
|
|
164
|
+
if (!S.isDown && x === "operating") {
|
|
165
|
+
const m = M.current;
|
|
166
|
+
if (m > 1) {
|
|
167
|
+
R("ended");
|
|
168
|
+
const T = C.current;
|
|
169
|
+
if (T > 0) {
|
|
170
|
+
const A = m / T, I = ot(S.start, S.current, m);
|
|
171
|
+
(A >= d || I >= Ze) && a();
|
|
172
|
+
}
|
|
173
|
+
} else
|
|
174
|
+
R("idle"), M.current = 0;
|
|
175
|
+
}
|
|
176
|
+
}, [S.isDown, x, d, a, S.start, S.current]), s.useEffect(() => {
|
|
177
|
+
x === "ended" && queueMicrotask(() => {
|
|
178
|
+
R("idle"), M.current = 0;
|
|
179
|
+
});
|
|
180
|
+
}, [x]), s.useEffect(() => {
|
|
181
|
+
o || (R("idle"), M.current = 0);
|
|
182
|
+
}, [o]);
|
|
183
|
+
const v = nt(b, o), _ = rt(x, o), W = s.useMemo(() => v ? Qe(f.displacement, p, O) : _ ? E : 0, [v, _, p, f.displacement, E, O]), L = s.useMemo(() => {
|
|
184
|
+
const m = C.current;
|
|
185
|
+
return m <= 0 ? 0 : Math.min(W / m, 1);
|
|
186
|
+
}, [W]), z = s.useMemo(() => v ? {
|
|
187
|
+
phase: Ke(f.phase),
|
|
188
|
+
displacement: f.displacement,
|
|
189
|
+
velocity: f.velocity
|
|
190
|
+
} : _ ? {
|
|
191
|
+
phase: x,
|
|
192
|
+
displacement: Je(w, p, E),
|
|
193
|
+
velocity: { x: 0, y: 0 }
|
|
194
|
+
} : Ne, [v, _, f, x, E, p, w]), H = s.useMemo(
|
|
195
|
+
() => We(g, $),
|
|
196
|
+
[g, $]
|
|
197
|
+
), h = s.useMemo(() => ({
|
|
198
|
+
onPointerDown: N,
|
|
199
|
+
style: {
|
|
200
|
+
touchAction: "none",
|
|
201
|
+
userSelect: "none",
|
|
202
|
+
WebkitUserSelect: "none"
|
|
203
|
+
}
|
|
204
|
+
}), [N]);
|
|
205
|
+
return {
|
|
206
|
+
state: z,
|
|
207
|
+
isOpening: v,
|
|
208
|
+
isClosing: _,
|
|
209
|
+
progress: L,
|
|
210
|
+
displacement: W,
|
|
211
|
+
edgeContainerProps: H,
|
|
212
|
+
drawerContentProps: h
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const ne = {
|
|
216
|
+
position: "fixed",
|
|
217
|
+
inset: 0,
|
|
218
|
+
background: ve
|
|
219
|
+
}, re = {
|
|
220
|
+
willChange: "transform"
|
|
221
|
+
}, st = {
|
|
222
|
+
left: {
|
|
223
|
+
top: 0,
|
|
224
|
+
bottom: 0,
|
|
225
|
+
left: 0,
|
|
226
|
+
transform: "translateX(-100%)"
|
|
227
|
+
},
|
|
228
|
+
right: {
|
|
229
|
+
top: 0,
|
|
230
|
+
bottom: 0,
|
|
231
|
+
right: 0,
|
|
232
|
+
transform: "translateX(100%)"
|
|
233
|
+
},
|
|
234
|
+
top: {
|
|
235
|
+
top: 0,
|
|
236
|
+
left: 0,
|
|
237
|
+
right: 0,
|
|
238
|
+
transform: "translateY(-100%)"
|
|
239
|
+
},
|
|
240
|
+
bottom: {
|
|
241
|
+
bottom: 0,
|
|
242
|
+
left: 0,
|
|
243
|
+
right: 0,
|
|
244
|
+
transform: "translateY(100%)"
|
|
245
|
+
}
|
|
246
|
+
}, at = {
|
|
247
|
+
left: "translateX(0)",
|
|
248
|
+
right: "translateX(0)",
|
|
249
|
+
top: "translateY(0)",
|
|
250
|
+
bottom: "translateY(0)"
|
|
251
|
+
};
|
|
252
|
+
function ct(e) {
|
|
253
|
+
return st[e];
|
|
254
|
+
}
|
|
255
|
+
function ut(e) {
|
|
256
|
+
return at[e];
|
|
257
|
+
}
|
|
258
|
+
function lt(e, t, n) {
|
|
259
|
+
return e === "none" ? void 0 : `transform ${t ?? Re} ${n ?? xe}`;
|
|
260
|
+
}
|
|
261
|
+
function dt(e, t) {
|
|
262
|
+
if (e !== "none")
|
|
263
|
+
return `opacity ${t ?? "220ms"} ease`;
|
|
264
|
+
}
|
|
265
|
+
function Y(e) {
|
|
266
|
+
if (e !== void 0)
|
|
267
|
+
return typeof e == "number" ? `${e}px` : e;
|
|
268
|
+
}
|
|
269
|
+
function pt(e) {
|
|
270
|
+
const { placement: t, inline: n, edgeWidth: r, zIndex: o } = e, i = n ? "absolute" : "fixed", a = o !== void 0 ? o - 2 : 1e3;
|
|
271
|
+
return ft(t, i, r, a);
|
|
272
|
+
}
|
|
273
|
+
function ft(e, t, n, r) {
|
|
274
|
+
const o = {
|
|
275
|
+
position: t,
|
|
276
|
+
zIndex: r,
|
|
277
|
+
background: "transparent",
|
|
278
|
+
pointerEvents: "auto"
|
|
279
|
+
};
|
|
280
|
+
return e === "left" ? {
|
|
281
|
+
...o,
|
|
282
|
+
top: 0,
|
|
283
|
+
bottom: 0,
|
|
284
|
+
left: 0,
|
|
285
|
+
width: n
|
|
286
|
+
} : e === "right" ? {
|
|
287
|
+
...o,
|
|
288
|
+
top: 0,
|
|
289
|
+
bottom: 0,
|
|
290
|
+
right: 0,
|
|
291
|
+
width: n
|
|
292
|
+
} : e === "top" ? {
|
|
293
|
+
...o,
|
|
294
|
+
top: 0,
|
|
295
|
+
left: 0,
|
|
296
|
+
right: 0,
|
|
297
|
+
height: n
|
|
298
|
+
} : {
|
|
299
|
+
...o,
|
|
300
|
+
bottom: 0,
|
|
301
|
+
left: 0,
|
|
302
|
+
right: 0,
|
|
303
|
+
height: n
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
const ee = 20, te = 0.3, mt = {
|
|
307
|
+
enabled: !1,
|
|
308
|
+
edgeSwipeOpen: !1,
|
|
309
|
+
swipeClose: !1,
|
|
310
|
+
edgeWidth: ee,
|
|
311
|
+
dismissThreshold: te
|
|
312
|
+
}, wt = {
|
|
313
|
+
enabled: !0,
|
|
314
|
+
edgeSwipeOpen: !0,
|
|
315
|
+
swipeClose: !0,
|
|
316
|
+
edgeWidth: ee,
|
|
317
|
+
dismissThreshold: te
|
|
318
|
+
};
|
|
319
|
+
function gt(e) {
|
|
320
|
+
return e === !0 ? wt : e === !1 || e === void 0 ? mt : {
|
|
321
|
+
enabled: !0,
|
|
322
|
+
edgeSwipeOpen: e.edgeSwipeOpen ?? !0,
|
|
323
|
+
swipeClose: e.swipeClose ?? !0,
|
|
324
|
+
edgeWidth: e.edgeWidth ?? ee,
|
|
325
|
+
dismissThreshold: e.dismissThreshold ?? te
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
function ht(e, t) {
|
|
329
|
+
return e || (t ? t.left !== void 0 ? "left" : t.right !== void 0 ? "right" : t.top !== void 0 ? "top" : t.bottom !== void 0 ? "bottom" : "right" : "right");
|
|
330
|
+
}
|
|
331
|
+
function St(e, t, n) {
|
|
332
|
+
return !e.enabled || !e.edgeSwipeOpen ? !1 : t ? n : !0;
|
|
333
|
+
}
|
|
334
|
+
function F(e, t) {
|
|
335
|
+
if (!t) {
|
|
336
|
+
const r = (() => ({ type: e }));
|
|
337
|
+
return Object.defineProperty(r, "type", {
|
|
338
|
+
value: e,
|
|
339
|
+
writable: !1,
|
|
340
|
+
enumerable: !0
|
|
341
|
+
}), r;
|
|
342
|
+
}
|
|
343
|
+
const n = ((...r) => {
|
|
344
|
+
const o = t(...r);
|
|
345
|
+
return typeof o > "u" ? { type: e } : { type: e, payload: o };
|
|
346
|
+
});
|
|
347
|
+
return Object.defineProperty(n, "type", {
|
|
348
|
+
value: e,
|
|
349
|
+
writable: !1,
|
|
350
|
+
enumerable: !0
|
|
351
|
+
}), n;
|
|
352
|
+
}
|
|
353
|
+
const bn = (e, t) => {
|
|
354
|
+
const n = {};
|
|
355
|
+
return Object.keys(e).forEach((r) => {
|
|
356
|
+
const o = e[r];
|
|
357
|
+
n[r] = ((...i) => {
|
|
358
|
+
const a = o(...i);
|
|
359
|
+
return t(a), a;
|
|
360
|
+
});
|
|
361
|
+
}), n;
|
|
362
|
+
}, bt = (e, t) => {
|
|
363
|
+
const n = {};
|
|
364
|
+
return Object.keys(t).forEach((r) => {
|
|
365
|
+
const o = t[r];
|
|
366
|
+
if (!o)
|
|
367
|
+
return;
|
|
368
|
+
const i = e[r];
|
|
369
|
+
if (!i)
|
|
370
|
+
throw new Error(`Missing action creator for key "${String(r)}"`);
|
|
371
|
+
n[i.type] = o;
|
|
372
|
+
}), n;
|
|
373
|
+
}, Et = 100, Pt = 0.3, yt = 30, Ot = 300, Ct = 1;
|
|
374
|
+
function Dt(e, t, n) {
|
|
375
|
+
if (t <= 0 || n === null)
|
|
376
|
+
return 0;
|
|
377
|
+
const r = Math.min(1, Math.max(0, e / t));
|
|
378
|
+
return n === "opening" ? r : 1 - r;
|
|
379
|
+
}
|
|
380
|
+
function vt(e, t, n) {
|
|
381
|
+
return n === "opening" ? e >= Et : n === "closing" ? (t > 0 ? e / t : 0) < Pt : !1;
|
|
382
|
+
}
|
|
383
|
+
const B = {
|
|
384
|
+
/** Start swipe operation */
|
|
385
|
+
swipeStart: F(
|
|
386
|
+
"SWIPE_START",
|
|
387
|
+
(e) => ({ direction: e })
|
|
388
|
+
),
|
|
389
|
+
/** Update swipe displacement */
|
|
390
|
+
swipeUpdate: F(
|
|
391
|
+
"SWIPE_UPDATE",
|
|
392
|
+
(e) => ({ displacement: e })
|
|
393
|
+
),
|
|
394
|
+
/** End swipe operation */
|
|
395
|
+
swipeEnd: F("SWIPE_END"),
|
|
396
|
+
/** Animation frame update */
|
|
397
|
+
animationFrame: F(
|
|
398
|
+
"ANIMATION_FRAME",
|
|
399
|
+
(e) => ({ easedProgress: e })
|
|
400
|
+
),
|
|
401
|
+
/** Animation complete */
|
|
402
|
+
animationComplete: F("ANIMATION_COMPLETE"),
|
|
403
|
+
/** Button open */
|
|
404
|
+
buttonOpen: F("BUTTON_OPEN"),
|
|
405
|
+
/** Button close */
|
|
406
|
+
buttonClose: F("BUTTON_CLOSE"),
|
|
407
|
+
/** Sync open state from external prop */
|
|
408
|
+
syncOpenState: F(
|
|
409
|
+
"SYNC_OPEN_STATE",
|
|
410
|
+
(e) => ({ isOpen: e })
|
|
411
|
+
),
|
|
412
|
+
/** Initialize state */
|
|
413
|
+
initialize: F(
|
|
414
|
+
"INITIALIZE",
|
|
415
|
+
(e) => ({ isOpen: e })
|
|
416
|
+
)
|
|
417
|
+
};
|
|
418
|
+
function J(e, t, n) {
|
|
419
|
+
return e ? t.getOpenPosition(n) : t.getClosedPosition(n);
|
|
420
|
+
}
|
|
421
|
+
function Q(e, t, n) {
|
|
422
|
+
const r = J(e, t, n);
|
|
423
|
+
return {
|
|
424
|
+
phase: e ? "open" : "closed",
|
|
425
|
+
targetOpen: e,
|
|
426
|
+
position: r,
|
|
427
|
+
isOperating: !1,
|
|
428
|
+
swipeDirection: null,
|
|
429
|
+
displacement: 0,
|
|
430
|
+
animation: null
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
function Rt(e) {
|
|
434
|
+
const t = bt(
|
|
435
|
+
B,
|
|
436
|
+
{
|
|
437
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- callback signature requires config
|
|
438
|
+
swipeStart: (n, r, o) => "payload" in r ? {
|
|
439
|
+
...n,
|
|
440
|
+
isOperating: !0,
|
|
441
|
+
swipeDirection: r.payload.direction,
|
|
442
|
+
displacement: 0,
|
|
443
|
+
animation: null
|
|
444
|
+
} : n,
|
|
445
|
+
swipeUpdate: (n, r, o) => {
|
|
446
|
+
if (!("payload" in r) || !n.isOperating)
|
|
447
|
+
return n;
|
|
448
|
+
const i = Dt(
|
|
449
|
+
r.payload.displacement,
|
|
450
|
+
o.drawerSize,
|
|
451
|
+
n.swipeDirection
|
|
452
|
+
), a = e.computePositionFromProgress(i, o);
|
|
453
|
+
return {
|
|
454
|
+
...n,
|
|
455
|
+
displacement: r.payload.displacement,
|
|
456
|
+
position: a
|
|
457
|
+
};
|
|
458
|
+
},
|
|
459
|
+
swipeEnd: (n, r, o) => {
|
|
460
|
+
if (!n.isOperating)
|
|
461
|
+
return n;
|
|
462
|
+
const i = vt(
|
|
463
|
+
n.displacement,
|
|
464
|
+
o.drawerSize,
|
|
465
|
+
n.swipeDirection
|
|
466
|
+
), a = J(
|
|
467
|
+
i,
|
|
468
|
+
e,
|
|
469
|
+
o
|
|
470
|
+
);
|
|
471
|
+
if (e.shouldAnimate(n.position, a)) {
|
|
472
|
+
const c = i ? "opening" : "closing";
|
|
473
|
+
return {
|
|
474
|
+
...n,
|
|
475
|
+
isOperating: !1,
|
|
476
|
+
swipeDirection: null,
|
|
477
|
+
displacement: 0,
|
|
478
|
+
targetOpen: i,
|
|
479
|
+
phase: c,
|
|
480
|
+
animation: {
|
|
481
|
+
type: c,
|
|
482
|
+
from: n.position,
|
|
483
|
+
to: a
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
return {
|
|
488
|
+
...n,
|
|
489
|
+
isOperating: !1,
|
|
490
|
+
swipeDirection: null,
|
|
491
|
+
displacement: 0,
|
|
492
|
+
targetOpen: i,
|
|
493
|
+
phase: i ? "open" : "closed",
|
|
494
|
+
position: a,
|
|
495
|
+
animation: null
|
|
496
|
+
};
|
|
497
|
+
},
|
|
498
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- callback signature requires config
|
|
499
|
+
animationFrame: (n, r, o) => {
|
|
500
|
+
if (!("payload" in r) || !n.animation)
|
|
501
|
+
return n;
|
|
502
|
+
const i = e.interpolatePosition(
|
|
503
|
+
n.animation.from,
|
|
504
|
+
n.animation.to,
|
|
505
|
+
r.payload.easedProgress
|
|
506
|
+
);
|
|
507
|
+
return {
|
|
508
|
+
...n,
|
|
509
|
+
position: i
|
|
510
|
+
};
|
|
511
|
+
},
|
|
512
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- callback signature requires action and config
|
|
513
|
+
animationComplete: (n, r, o) => {
|
|
514
|
+
if (!n.animation)
|
|
515
|
+
return n;
|
|
516
|
+
const i = n.animation.type === "opening";
|
|
517
|
+
return {
|
|
518
|
+
...n,
|
|
519
|
+
phase: i ? "open" : "closed",
|
|
520
|
+
position: n.animation.to,
|
|
521
|
+
animation: null
|
|
522
|
+
};
|
|
523
|
+
},
|
|
524
|
+
buttonOpen: (n, r, o) => {
|
|
525
|
+
if (n.phase === "open" || n.phase === "opening" || n.isOperating)
|
|
526
|
+
return n;
|
|
527
|
+
const i = e.getOpenPosition(o), a = n.position;
|
|
528
|
+
return e.shouldAnimate(a, i) ? {
|
|
529
|
+
...n,
|
|
530
|
+
targetOpen: !0,
|
|
531
|
+
phase: "opening",
|
|
532
|
+
animation: {
|
|
533
|
+
type: "opening",
|
|
534
|
+
from: a,
|
|
535
|
+
to: i
|
|
536
|
+
}
|
|
537
|
+
} : {
|
|
538
|
+
...n,
|
|
539
|
+
targetOpen: !0,
|
|
540
|
+
phase: "open",
|
|
541
|
+
position: i,
|
|
542
|
+
animation: null
|
|
543
|
+
};
|
|
544
|
+
},
|
|
545
|
+
buttonClose: (n, r, o) => {
|
|
546
|
+
if (n.phase === "closed" || n.phase === "closing" || n.isOperating)
|
|
547
|
+
return n;
|
|
548
|
+
const i = e.getClosedPosition(o), a = n.position;
|
|
549
|
+
return e.shouldAnimate(a, i) ? {
|
|
550
|
+
...n,
|
|
551
|
+
targetOpen: !1,
|
|
552
|
+
phase: "closing",
|
|
553
|
+
animation: {
|
|
554
|
+
type: "closing",
|
|
555
|
+
from: a,
|
|
556
|
+
to: i
|
|
557
|
+
}
|
|
558
|
+
} : {
|
|
559
|
+
...n,
|
|
560
|
+
targetOpen: !1,
|
|
561
|
+
phase: "closed",
|
|
562
|
+
position: i,
|
|
563
|
+
animation: null
|
|
564
|
+
};
|
|
565
|
+
},
|
|
566
|
+
syncOpenState: (n, r, o) => {
|
|
567
|
+
if (!("payload" in r))
|
|
568
|
+
return n;
|
|
569
|
+
const { isOpen: i } = r.payload;
|
|
570
|
+
if (n.targetOpen === i && !n.isOperating && !n.animation)
|
|
571
|
+
return n;
|
|
572
|
+
if (n.isOperating)
|
|
573
|
+
return {
|
|
574
|
+
...n,
|
|
575
|
+
targetOpen: i
|
|
576
|
+
};
|
|
577
|
+
if (n.animation && n.animation.type === "opening" === i)
|
|
578
|
+
return {
|
|
579
|
+
...n,
|
|
580
|
+
targetOpen: i
|
|
581
|
+
};
|
|
582
|
+
if ((n.phase === "open" || n.phase === "opening") === i)
|
|
583
|
+
return {
|
|
584
|
+
...n,
|
|
585
|
+
targetOpen: i
|
|
586
|
+
};
|
|
587
|
+
const c = J(
|
|
588
|
+
i,
|
|
589
|
+
e,
|
|
590
|
+
o
|
|
591
|
+
), u = n.position;
|
|
592
|
+
if (e.shouldAnimate(u, c)) {
|
|
593
|
+
const l = i ? "opening" : "closing";
|
|
594
|
+
return {
|
|
595
|
+
...n,
|
|
596
|
+
targetOpen: i,
|
|
597
|
+
phase: l,
|
|
598
|
+
animation: {
|
|
599
|
+
type: l,
|
|
600
|
+
from: u,
|
|
601
|
+
to: c
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
return {
|
|
606
|
+
...n,
|
|
607
|
+
targetOpen: i,
|
|
608
|
+
phase: i ? "open" : "closed",
|
|
609
|
+
position: c,
|
|
610
|
+
animation: null
|
|
611
|
+
};
|
|
612
|
+
},
|
|
613
|
+
initialize: (n, r, o) => "payload" in r ? Q(r.payload.isOpen, e, o) : n
|
|
614
|
+
}
|
|
615
|
+
);
|
|
616
|
+
return function(r, o, i) {
|
|
617
|
+
const a = t[o.type];
|
|
618
|
+
return a ? a(r, o, i) : r;
|
|
619
|
+
};
|
|
620
|
+
}
|
|
621
|
+
const xt = {
|
|
622
|
+
left: { axis: "X", sign: 1 },
|
|
623
|
+
right: { axis: "X", sign: -1 },
|
|
624
|
+
top: { axis: "Y", sign: 1 },
|
|
625
|
+
bottom: { axis: "Y", sign: -1 }
|
|
626
|
+
};
|
|
627
|
+
function G(e) {
|
|
628
|
+
return xt[e];
|
|
629
|
+
}
|
|
630
|
+
const q = {
|
|
631
|
+
position: "relative",
|
|
632
|
+
zIndex: "1",
|
|
633
|
+
background: "#fff"
|
|
634
|
+
};
|
|
635
|
+
function oe(e) {
|
|
636
|
+
e.style.position = "", e.style.zIndex = "", e.style.background = "";
|
|
637
|
+
}
|
|
638
|
+
function Tt() {
|
|
639
|
+
document.body.style.overflow = "hidden";
|
|
640
|
+
}
|
|
641
|
+
function K() {
|
|
642
|
+
document.body.style.overflow = "";
|
|
643
|
+
}
|
|
644
|
+
function me(e, t) {
|
|
645
|
+
return e ? t?.current ?? null : document.getElementById("root") ?? document.body.firstElementChild;
|
|
646
|
+
}
|
|
647
|
+
function At(e) {
|
|
648
|
+
e.style.visibility = "visible", e.style.pointerEvents = "auto";
|
|
649
|
+
}
|
|
650
|
+
function Mt(e) {
|
|
651
|
+
e.style.visibility = "hidden", e.style.pointerEvents = "none";
|
|
652
|
+
}
|
|
653
|
+
function _t(e) {
|
|
654
|
+
e.style.visibility = "", e.style.pointerEvents = "";
|
|
655
|
+
}
|
|
656
|
+
function Lt(e, t = q.background) {
|
|
657
|
+
e.style.position = q.position, e.style.zIndex = q.zIndex, e.style.background = t;
|
|
658
|
+
}
|
|
659
|
+
const kt = {
|
|
660
|
+
getClosedPosition(e) {
|
|
661
|
+
return this.computePositionFromProgress(0, e);
|
|
662
|
+
},
|
|
663
|
+
getOpenPosition(e) {
|
|
664
|
+
return this.computePositionFromProgress(1, e);
|
|
665
|
+
},
|
|
666
|
+
computePositionFromProgress(e, t) {
|
|
667
|
+
const { sign: n } = G(t.placement), o = t.drawerSize * (yt / 100) * (1 - e), i = n > 0 ? -o : o, a = n * t.drawerSize * e;
|
|
668
|
+
return { drawerPx: i, contentPx: a };
|
|
669
|
+
},
|
|
670
|
+
interpolatePosition(e, t, n) {
|
|
671
|
+
return {
|
|
672
|
+
drawerPx: e.drawerPx + (t.drawerPx - e.drawerPx) * n,
|
|
673
|
+
contentPx: e.contentPx + (t.contentPx - e.contentPx) * n
|
|
674
|
+
};
|
|
675
|
+
},
|
|
676
|
+
shouldAnimate(e, t) {
|
|
677
|
+
return Math.abs(e.contentPx - t.contentPx) > Ct;
|
|
678
|
+
},
|
|
679
|
+
applyToDOM(e, t, n) {
|
|
680
|
+
const { drawer: r, content: o } = t, { axis: i } = G(n.placement);
|
|
681
|
+
r && (r.style.transition = "none", r.style.transform = `translate${i}(${e.drawerPx}px)`), o && (Lt(o, n.contentBackground), o.style.transition = "none", o.style.transform = `translate${i}(${e.contentPx}px)`);
|
|
682
|
+
},
|
|
683
|
+
clearFromDOM(e) {
|
|
684
|
+
const { drawer: t, content: n } = e;
|
|
685
|
+
t && (t.style.transform = "", t.style.transition = ""), n && (n.style.transform = "", n.style.transition = "", oe(n));
|
|
686
|
+
},
|
|
687
|
+
onOpeningStart(e) {
|
|
688
|
+
e.drawer && At(e.drawer);
|
|
689
|
+
},
|
|
690
|
+
onClosingComplete(e) {
|
|
691
|
+
const { drawer: t, content: n } = e;
|
|
692
|
+
t && (Mt(t), t.style.transform = "", t.style.transition = ""), n && (n.style.transform = "", n.style.transition = "", oe(n));
|
|
693
|
+
}
|
|
694
|
+
}, It = 1, Ft = {
|
|
695
|
+
getClosedPosition(e) {
|
|
696
|
+
const { sign: t } = G(e.placement);
|
|
697
|
+
return {
|
|
698
|
+
drawerPx: -t * e.drawerSize,
|
|
699
|
+
backdropOpacity: 0
|
|
700
|
+
};
|
|
701
|
+
},
|
|
702
|
+
getOpenPosition() {
|
|
703
|
+
return {
|
|
704
|
+
drawerPx: 0,
|
|
705
|
+
backdropOpacity: 1
|
|
706
|
+
};
|
|
707
|
+
},
|
|
708
|
+
computePositionFromProgress(e, t) {
|
|
709
|
+
const { sign: n } = G(t.placement);
|
|
710
|
+
return {
|
|
711
|
+
drawerPx: -n * t.drawerSize * (1 - e),
|
|
712
|
+
backdropOpacity: e
|
|
713
|
+
};
|
|
714
|
+
},
|
|
715
|
+
interpolatePosition(e, t, n) {
|
|
716
|
+
return {
|
|
717
|
+
drawerPx: e.drawerPx + (t.drawerPx - e.drawerPx) * n,
|
|
718
|
+
backdropOpacity: e.backdropOpacity + (t.backdropOpacity - e.backdropOpacity) * n
|
|
719
|
+
};
|
|
720
|
+
},
|
|
721
|
+
shouldAnimate(e, t) {
|
|
722
|
+
return Math.abs(e.drawerPx - t.drawerPx) > It;
|
|
723
|
+
},
|
|
724
|
+
applyToDOM(e, t, n) {
|
|
725
|
+
const { drawer: r, backdrop: o } = t, { axis: i } = G(n.placement);
|
|
726
|
+
r && (r.style.transition = "none", r.style.transform = `translate${i}(${e.drawerPx}px)`), o && (o.style.opacity = String(e.backdropOpacity), o.style.pointerEvents = e.backdropOpacity > 0 ? "auto" : "none");
|
|
727
|
+
},
|
|
728
|
+
clearFromDOM(e) {
|
|
729
|
+
const { drawer: t, backdrop: n } = e;
|
|
730
|
+
t && (t.style.transform = "", t.style.transition = ""), n && (n.style.opacity = "", n.style.pointerEvents = "");
|
|
731
|
+
},
|
|
732
|
+
onOpeningStart() {
|
|
733
|
+
},
|
|
734
|
+
onClosingComplete(e, t) {
|
|
735
|
+
const { drawer: n, backdrop: r } = e, o = Nt(t);
|
|
736
|
+
n && (n.style.transform = o, n.style.transition = ""), r && (r.style.opacity = "0", r.style.pointerEvents = "none");
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
function Nt(e) {
|
|
740
|
+
switch (e.placement) {
|
|
741
|
+
case "left":
|
|
742
|
+
return "translateX(-100%)";
|
|
743
|
+
case "right":
|
|
744
|
+
return "translateX(100%)";
|
|
745
|
+
case "top":
|
|
746
|
+
return "translateY(-100%)";
|
|
747
|
+
case "bottom":
|
|
748
|
+
return "translateY(100%)";
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
function Wt(e) {
|
|
752
|
+
return e === "reveal" ? kt : Ft;
|
|
753
|
+
}
|
|
754
|
+
function we(e) {
|
|
755
|
+
const {
|
|
756
|
+
mode: t,
|
|
757
|
+
drawerRef: n,
|
|
758
|
+
contentRef: r,
|
|
759
|
+
backdropRef: o,
|
|
760
|
+
placement: i,
|
|
761
|
+
drawerSize: a,
|
|
762
|
+
isOpen: c,
|
|
763
|
+
swipeState: u,
|
|
764
|
+
displacement: l,
|
|
765
|
+
isOpening: d,
|
|
766
|
+
isClosing: p,
|
|
767
|
+
enabled: w,
|
|
768
|
+
inline: O = !1,
|
|
769
|
+
gridRef: C,
|
|
770
|
+
contentBackground: D = "#fff"
|
|
771
|
+
} = e, b = u.phase === "operating", f = Wt(t), g = s.useMemo(
|
|
772
|
+
() => ({ placement: i, drawerSize: a, contentBackground: D }),
|
|
773
|
+
[i, a, D]
|
|
774
|
+
), $ = s.useMemo(
|
|
775
|
+
() => Rt(f),
|
|
776
|
+
[f]
|
|
777
|
+
), S = s.useRef(
|
|
778
|
+
Q(c, f, g)
|
|
779
|
+
), [k, x] = s.useState(
|
|
780
|
+
c ? "open" : "closed"
|
|
781
|
+
), R = s.useRef({
|
|
782
|
+
isOperating: !1,
|
|
783
|
+
isOpening: !1,
|
|
784
|
+
isClosing: !1,
|
|
785
|
+
isOpen: c,
|
|
786
|
+
enabled: !1
|
|
787
|
+
}), M = () => t !== "reveal" ? null : r?.current ?? me(O, C), N = () => t !== "overlay" ? null : o?.current ?? null, E = s.useCallback(() => ({
|
|
788
|
+
drawer: n.current,
|
|
789
|
+
content: M(),
|
|
790
|
+
backdrop: N()
|
|
791
|
+
}), [t, n, r, o, O, C]), v = s.useCallback(
|
|
792
|
+
(h) => {
|
|
793
|
+
const m = $(S.current, h, g);
|
|
794
|
+
return S.current = m, x(m.phase), m;
|
|
795
|
+
},
|
|
796
|
+
[$, g]
|
|
797
|
+
), _ = s.useCallback(
|
|
798
|
+
({ easedProgress: h }) => {
|
|
799
|
+
const m = S.current;
|
|
800
|
+
if (!m.animation)
|
|
801
|
+
return;
|
|
802
|
+
const y = f.interpolatePosition(
|
|
803
|
+
m.animation.from,
|
|
804
|
+
m.animation.to,
|
|
805
|
+
h
|
|
806
|
+
);
|
|
807
|
+
S.current = { ...m, position: y };
|
|
808
|
+
const T = E();
|
|
809
|
+
f.applyToDOM(y, T, g);
|
|
810
|
+
},
|
|
811
|
+
[f, E, g]
|
|
812
|
+
), W = s.useCallback(() => {
|
|
813
|
+
const h = v(B.animationComplete()), m = E();
|
|
814
|
+
h.phase === "closed" && f.onClosingComplete?.(m, g);
|
|
815
|
+
}, [v, f, E, g]), { isAnimating: L, start: z, cancel: H } = ze({
|
|
816
|
+
duration: Ot,
|
|
817
|
+
easing: He.easeOutExpo,
|
|
818
|
+
onFrame: _,
|
|
819
|
+
onComplete: W
|
|
820
|
+
});
|
|
821
|
+
return s.useLayoutEffect(() => {
|
|
822
|
+
if (!w) {
|
|
823
|
+
R.current.enabled = !1;
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
if (R.current.enabled)
|
|
827
|
+
return;
|
|
828
|
+
R.current.enabled = !0, S.current = Q(c, f, g), x(c ? "open" : "closed");
|
|
829
|
+
const h = E();
|
|
830
|
+
c ? (f.onOpeningStart?.(h, g), f.applyToDOM(S.current.position, h, g)) : f.onClosingComplete?.(h, g);
|
|
831
|
+
}, [w, c, f, g, E]), s.useLayoutEffect(() => {
|
|
832
|
+
if (!w)
|
|
833
|
+
return;
|
|
834
|
+
const h = R.current, m = h.isOperating, y = h.isOpening, T = h.isClosing;
|
|
835
|
+
if (h.isOperating = b, h.isOpening = d, h.isClosing = p, !m && b) {
|
|
836
|
+
H();
|
|
837
|
+
const A = d ? "opening" : p ? "closing" : null;
|
|
838
|
+
A && v(B.swipeStart(A));
|
|
839
|
+
return;
|
|
840
|
+
}
|
|
841
|
+
if (m && !b) {
|
|
842
|
+
const A = v(B.swipeEnd()), I = E();
|
|
843
|
+
A.animation ? (f.onOpeningStart?.(I, g), z()) : A.phase === "open" ? (f.onOpeningStart?.(I, g), f.applyToDOM(A.position, I, g)) : A.phase === "closed" && f.onClosingComplete?.(I, g);
|
|
844
|
+
return;
|
|
845
|
+
}
|
|
846
|
+
if (b) {
|
|
847
|
+
const A = d ? "opening" : p ? "closing" : null;
|
|
848
|
+
A !== (y ? "opening" : T ? "closing" : null) && A && v(B.swipeStart(A));
|
|
849
|
+
}
|
|
850
|
+
}, [
|
|
851
|
+
w,
|
|
852
|
+
b,
|
|
853
|
+
d,
|
|
854
|
+
p,
|
|
855
|
+
v,
|
|
856
|
+
H,
|
|
857
|
+
z,
|
|
858
|
+
f,
|
|
859
|
+
g,
|
|
860
|
+
E
|
|
861
|
+
]), s.useLayoutEffect(() => {
|
|
862
|
+
if (!w || !b || !d && !p)
|
|
863
|
+
return;
|
|
864
|
+
const h = v(B.swipeUpdate(l)), m = E();
|
|
865
|
+
f.onOpeningStart?.(m, g), f.applyToDOM(h.position, m, g);
|
|
866
|
+
}, [
|
|
867
|
+
w,
|
|
868
|
+
b,
|
|
869
|
+
d,
|
|
870
|
+
p,
|
|
871
|
+
l,
|
|
872
|
+
v,
|
|
873
|
+
f,
|
|
874
|
+
g,
|
|
875
|
+
E
|
|
876
|
+
]), s.useLayoutEffect(() => {
|
|
877
|
+
if (!w)
|
|
878
|
+
return;
|
|
879
|
+
const h = R.current;
|
|
880
|
+
if (h.isOpen === c)
|
|
881
|
+
return;
|
|
882
|
+
if (h.isOpen = c, b) {
|
|
883
|
+
v(B.syncOpenState(c));
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
if (L && S.current.animation?.type === "opening" === c)
|
|
887
|
+
return;
|
|
888
|
+
const m = v(B.syncOpenState(c)), y = E();
|
|
889
|
+
m.animation ? (f.onOpeningStart?.(y, g), f.applyToDOM(m.animation.from, y, g), z()) : L || (m.phase === "open" ? (f.onOpeningStart?.(y, g), f.applyToDOM(m.position, y, g)) : m.phase === "closed" && f.onClosingComplete?.(y, g));
|
|
890
|
+
}, [
|
|
891
|
+
w,
|
|
892
|
+
c,
|
|
893
|
+
b,
|
|
894
|
+
L,
|
|
895
|
+
v,
|
|
896
|
+
z,
|
|
897
|
+
f,
|
|
898
|
+
g,
|
|
899
|
+
E
|
|
900
|
+
]), s.useLayoutEffect(() => {
|
|
901
|
+
if (w || !R.current.enabled)
|
|
902
|
+
return;
|
|
903
|
+
const h = E();
|
|
904
|
+
f.clearFromDOM(h, g), h.drawer && _t(h.drawer);
|
|
905
|
+
}, [w, f, g, E]), s.useLayoutEffect(() => {
|
|
906
|
+
if (!w || t !== "reveal") {
|
|
907
|
+
t === "reveal" && K();
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
return (c || b ? !0 : L) ? Tt() : K(), () => {
|
|
911
|
+
K();
|
|
912
|
+
};
|
|
913
|
+
}, [w, t, c, b, L]), s.useLayoutEffect(() => {
|
|
914
|
+
if (!(!w || t !== "reveal"))
|
|
915
|
+
return () => {
|
|
916
|
+
const h = E();
|
|
917
|
+
h.content && f.clearFromDOM({ drawer: null, content: h.content, backdrop: null }, g);
|
|
918
|
+
};
|
|
919
|
+
}, [w, t, f, g, E]), {
|
|
920
|
+
phase: k,
|
|
921
|
+
isAnimating: L
|
|
922
|
+
};
|
|
923
|
+
}
|
|
924
|
+
function zt(e) {
|
|
925
|
+
const {
|
|
926
|
+
drawerRef: t,
|
|
927
|
+
backdropRef: n,
|
|
928
|
+
placement: r,
|
|
929
|
+
swipeState: o,
|
|
930
|
+
displacement: i,
|
|
931
|
+
isOpening: a,
|
|
932
|
+
isClosing: c,
|
|
933
|
+
isOpen: u,
|
|
934
|
+
enabled: l
|
|
935
|
+
} = e, d = s.useRef(0);
|
|
936
|
+
s.useLayoutEffect(() => {
|
|
937
|
+
const p = t.current;
|
|
938
|
+
if (p) {
|
|
939
|
+
const w = r === "left" || r === "right";
|
|
940
|
+
d.current = w ? p.clientWidth : p.clientHeight;
|
|
941
|
+
}
|
|
942
|
+
}, [t, r]), we({
|
|
943
|
+
mode: "overlay",
|
|
944
|
+
drawerRef: t,
|
|
945
|
+
backdropRef: n,
|
|
946
|
+
placement: r,
|
|
947
|
+
drawerSize: d.current,
|
|
948
|
+
isOpen: u,
|
|
949
|
+
swipeState: o,
|
|
950
|
+
displacement: i,
|
|
951
|
+
isOpening: a,
|
|
952
|
+
isClosing: c,
|
|
953
|
+
enabled: l
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
const Ht = {
|
|
957
|
+
activeRevealDrawer: null,
|
|
958
|
+
setRevealState: () => {
|
|
959
|
+
},
|
|
960
|
+
gridRef: null,
|
|
961
|
+
setGridRef: () => {
|
|
962
|
+
}
|
|
963
|
+
}, ge = s.createContext(Ht), En = ({ children: e }) => {
|
|
964
|
+
const [t, n] = s.useState(null), [r, o] = s.useState(null), i = s.useCallback((u) => {
|
|
965
|
+
n(u);
|
|
966
|
+
}, []), a = s.useCallback((u) => {
|
|
967
|
+
o(u);
|
|
968
|
+
}, []), c = s.useMemo(
|
|
969
|
+
() => ({
|
|
970
|
+
activeRevealDrawer: t,
|
|
971
|
+
setRevealState: i,
|
|
972
|
+
gridRef: r,
|
|
973
|
+
setGridRef: a
|
|
974
|
+
}),
|
|
975
|
+
[t, i, r, a]
|
|
976
|
+
);
|
|
977
|
+
return /* @__PURE__ */ P(ge.Provider, { value: c, children: e });
|
|
978
|
+
};
|
|
979
|
+
function Bt() {
|
|
980
|
+
return s.useContext(ge);
|
|
981
|
+
}
|
|
982
|
+
function j(e) {
|
|
983
|
+
return e === "reveal";
|
|
984
|
+
}
|
|
985
|
+
function $t(e) {
|
|
986
|
+
const {
|
|
987
|
+
drawerRef: t,
|
|
988
|
+
placement: n,
|
|
989
|
+
drawerSize: r,
|
|
990
|
+
isOpen: o,
|
|
991
|
+
swipeState: i,
|
|
992
|
+
displacement: a,
|
|
993
|
+
isOpening: c,
|
|
994
|
+
isClosing: u,
|
|
995
|
+
enabled: l,
|
|
996
|
+
inline: d,
|
|
997
|
+
gridRef: p,
|
|
998
|
+
contentBackground: w = "#fff"
|
|
999
|
+
} = e, O = s.useRef(null);
|
|
1000
|
+
return s.useLayoutEffect(() => {
|
|
1001
|
+
O.current = me(d, p);
|
|
1002
|
+
}, [d, p]), we({
|
|
1003
|
+
mode: "reveal",
|
|
1004
|
+
drawerRef: t,
|
|
1005
|
+
contentRef: O,
|
|
1006
|
+
placement: n,
|
|
1007
|
+
drawerSize: r,
|
|
1008
|
+
isOpen: o,
|
|
1009
|
+
swipeState: i,
|
|
1010
|
+
displacement: a,
|
|
1011
|
+
isOpening: c,
|
|
1012
|
+
isClosing: u,
|
|
1013
|
+
enabled: l,
|
|
1014
|
+
inline: d,
|
|
1015
|
+
gridRef: p,
|
|
1016
|
+
contentBackground: w
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
const Vt = ({
|
|
1020
|
+
chrome: e,
|
|
1021
|
+
frameStyle: t,
|
|
1022
|
+
header: n,
|
|
1023
|
+
dismissible: r,
|
|
1024
|
+
onClose: o,
|
|
1025
|
+
children: i
|
|
1026
|
+
}) => e ? /* @__PURE__ */ U(ce, { style: t, children: [
|
|
1027
|
+
/* @__PURE__ */ P(Xt, { header: n, dismissible: r, onClose: o }),
|
|
1028
|
+
/* @__PURE__ */ P(
|
|
1029
|
+
ue,
|
|
1030
|
+
{
|
|
1031
|
+
style: { padding: Te, flex: 1, display: "flex", flexDirection: "column" },
|
|
1032
|
+
children: i
|
|
1033
|
+
}
|
|
1034
|
+
)
|
|
1035
|
+
] }) : /* @__PURE__ */ P(X, { children: i });
|
|
1036
|
+
function Gt(e, t) {
|
|
1037
|
+
return e ? t : !1;
|
|
1038
|
+
}
|
|
1039
|
+
function Ut(e, t) {
|
|
1040
|
+
return e ? /* @__PURE__ */ P(
|
|
1041
|
+
pe,
|
|
1042
|
+
{
|
|
1043
|
+
onClick: t,
|
|
1044
|
+
"aria-label": "Close drawer",
|
|
1045
|
+
style: { marginLeft: "auto" }
|
|
1046
|
+
}
|
|
1047
|
+
) : null;
|
|
1048
|
+
}
|
|
1049
|
+
function Yt(e, t, n, r, o) {
|
|
1050
|
+
return e ? /* @__PURE__ */ P(
|
|
1051
|
+
"div",
|
|
1052
|
+
{
|
|
1053
|
+
ref: t,
|
|
1054
|
+
style: n,
|
|
1055
|
+
onPointerDown: r,
|
|
1056
|
+
"data-drawer-edge-zone": o
|
|
1057
|
+
}
|
|
1058
|
+
) : null;
|
|
1059
|
+
}
|
|
1060
|
+
function Zt(e, t, n) {
|
|
1061
|
+
return e === "left" || e === "right" ? typeof t == "number" ? t : 0 : typeof n == "number" ? n : 0;
|
|
1062
|
+
}
|
|
1063
|
+
const Xt = ({ header: e, dismissible: t, onClose: n }) => {
|
|
1064
|
+
if (!e)
|
|
1065
|
+
return null;
|
|
1066
|
+
const r = e.showCloseButton ?? !0, o = Gt(t, r);
|
|
1067
|
+
return /* @__PURE__ */ U(
|
|
1068
|
+
le,
|
|
1069
|
+
{
|
|
1070
|
+
style: { padding: `${Me} ${_e}`, gap: Ae },
|
|
1071
|
+
children: [
|
|
1072
|
+
/* @__PURE__ */ P(de, { children: e.title }),
|
|
1073
|
+
Ut(o, n)
|
|
1074
|
+
]
|
|
1075
|
+
}
|
|
1076
|
+
);
|
|
1077
|
+
};
|
|
1078
|
+
function jt(e, t, n, r, o) {
|
|
1079
|
+
const i = j(r.animationMode);
|
|
1080
|
+
return s.useMemo(() => {
|
|
1081
|
+
const a = r.inline ? "absolute" : "fixed", c = ct(e);
|
|
1082
|
+
if (i)
|
|
1083
|
+
return {
|
|
1084
|
+
...re,
|
|
1085
|
+
position: a,
|
|
1086
|
+
// Only position properties from placementStyle, NOT transform
|
|
1087
|
+
top: c.top,
|
|
1088
|
+
bottom: c.bottom,
|
|
1089
|
+
left: c.left,
|
|
1090
|
+
right: c.right,
|
|
1091
|
+
// No transform here - hook manages it
|
|
1092
|
+
// No transition - hook uses requestAnimationFrame
|
|
1093
|
+
// z-index: 0 ensures drawer is behind #root (which has z-index: 1)
|
|
1094
|
+
zIndex: 0,
|
|
1095
|
+
// Hidden by default - hook will show when needed
|
|
1096
|
+
visibility: "hidden",
|
|
1097
|
+
pointerEvents: "none",
|
|
1098
|
+
width: Y(o.width),
|
|
1099
|
+
height: Y(o.height)
|
|
1100
|
+
};
|
|
1101
|
+
const u = n ? "none" : r.transitionMode, l = lt(
|
|
1102
|
+
u,
|
|
1103
|
+
r.transitionDuration,
|
|
1104
|
+
r.transitionEasing
|
|
1105
|
+
), d = t ? ut(e) : c.transform;
|
|
1106
|
+
return {
|
|
1107
|
+
...re,
|
|
1108
|
+
position: a,
|
|
1109
|
+
...c,
|
|
1110
|
+
transform: d,
|
|
1111
|
+
transition: l,
|
|
1112
|
+
zIndex: o.zIndex,
|
|
1113
|
+
width: Y(o.width),
|
|
1114
|
+
height: Y(o.height)
|
|
1115
|
+
};
|
|
1116
|
+
}, [e, t, n, r, o, i]);
|
|
1117
|
+
}
|
|
1118
|
+
function qt(e, t, n, r, o) {
|
|
1119
|
+
const i = j(n.animationMode);
|
|
1120
|
+
return s.useMemo(() => {
|
|
1121
|
+
if (i)
|
|
1122
|
+
return {
|
|
1123
|
+
display: "none"
|
|
1124
|
+
};
|
|
1125
|
+
const a = n.inline ? "absolute" : "fixed";
|
|
1126
|
+
if (o)
|
|
1127
|
+
return {
|
|
1128
|
+
...ne,
|
|
1129
|
+
position: a,
|
|
1130
|
+
// Initial state: hidden. Hook will manage opacity dynamically.
|
|
1131
|
+
opacity: 0,
|
|
1132
|
+
pointerEvents: "none",
|
|
1133
|
+
zIndex: r !== void 0 ? r - 1 : void 0
|
|
1134
|
+
};
|
|
1135
|
+
const c = t ? "none" : n.transitionMode, u = dt(c, n.transitionDuration);
|
|
1136
|
+
return {
|
|
1137
|
+
...ne,
|
|
1138
|
+
position: a,
|
|
1139
|
+
opacity: e ? 1 : 0,
|
|
1140
|
+
pointerEvents: e ? "auto" : "none",
|
|
1141
|
+
transition: u,
|
|
1142
|
+
zIndex: r !== void 0 ? r - 1 : void 0
|
|
1143
|
+
};
|
|
1144
|
+
}, [e, t, n, r, i, o]);
|
|
1145
|
+
}
|
|
1146
|
+
function Kt(e) {
|
|
1147
|
+
return s.useMemo(() => {
|
|
1148
|
+
const t = { borderRadius: 0 };
|
|
1149
|
+
return (e === "left" || e === "right") && (t.height = "100%"), t;
|
|
1150
|
+
}, [e]);
|
|
1151
|
+
}
|
|
1152
|
+
const Jt = ({
|
|
1153
|
+
id: e,
|
|
1154
|
+
config: t,
|
|
1155
|
+
isOpen: n,
|
|
1156
|
+
onClose: r,
|
|
1157
|
+
onOpen: o,
|
|
1158
|
+
children: i,
|
|
1159
|
+
zIndex: a,
|
|
1160
|
+
width: c,
|
|
1161
|
+
height: u,
|
|
1162
|
+
position: l
|
|
1163
|
+
}) => {
|
|
1164
|
+
const {
|
|
1165
|
+
dismissible: d = !0,
|
|
1166
|
+
header: p,
|
|
1167
|
+
chrome: w = !0,
|
|
1168
|
+
inline: O = !1
|
|
1169
|
+
} = t, C = gt(t.swipeGestures), D = ht(t.anchor, l), b = s.useRef(null), f = s.useRef(null), g = s.useRef(null), $ = s.useCallback(() => {
|
|
1170
|
+
o?.(), t.onStateChange?.(!0);
|
|
1171
|
+
}, [o, t]), S = s.useCallback(() => {
|
|
1172
|
+
r();
|
|
1173
|
+
}, [r]), {
|
|
1174
|
+
state: k,
|
|
1175
|
+
displacement: x,
|
|
1176
|
+
edgeContainerProps: R,
|
|
1177
|
+
drawerContentProps: M,
|
|
1178
|
+
isOpening: N,
|
|
1179
|
+
isClosing: E
|
|
1180
|
+
} = it({
|
|
1181
|
+
edgeContainerRef: g,
|
|
1182
|
+
drawerContentRef: b,
|
|
1183
|
+
direction: D,
|
|
1184
|
+
isOpen: n,
|
|
1185
|
+
onSwipeOpen: $,
|
|
1186
|
+
onSwipeClose: S,
|
|
1187
|
+
enableEdgeSwipeOpen: C.edgeSwipeOpen,
|
|
1188
|
+
enableSwipeClose: C.swipeClose,
|
|
1189
|
+
edgeWidth: C.edgeWidth,
|
|
1190
|
+
dismissThreshold: C.dismissThreshold
|
|
1191
|
+
}), v = k.phase === "operating" || k.phase === "ended", _ = j(t.animationMode), W = C.enabled ? !_ : !1;
|
|
1192
|
+
zt({
|
|
1193
|
+
drawerRef: b,
|
|
1194
|
+
backdropRef: f,
|
|
1195
|
+
placement: D,
|
|
1196
|
+
swipeState: k,
|
|
1197
|
+
displacement: x,
|
|
1198
|
+
isOpening: N,
|
|
1199
|
+
isClosing: E,
|
|
1200
|
+
isOpen: n,
|
|
1201
|
+
enabled: W
|
|
1202
|
+
});
|
|
1203
|
+
const L = Zt(D, c, u), { gridRef: z } = Bt();
|
|
1204
|
+
$t({
|
|
1205
|
+
drawerRef: b,
|
|
1206
|
+
placement: D,
|
|
1207
|
+
drawerSize: L,
|
|
1208
|
+
isOpen: n,
|
|
1209
|
+
swipeState: k,
|
|
1210
|
+
displacement: x,
|
|
1211
|
+
isOpening: N,
|
|
1212
|
+
isClosing: E,
|
|
1213
|
+
enabled: _,
|
|
1214
|
+
inline: O,
|
|
1215
|
+
gridRef: z ?? void 0,
|
|
1216
|
+
contentBackground: t.revealBackground
|
|
1217
|
+
});
|
|
1218
|
+
const H = jt(D, n, v, t, { width: c, height: u, zIndex: a }), h = qt(n, v, t, a, W), m = Kt(D), y = s.useMemo(() => ({ ...pt({
|
|
1219
|
+
placement: D,
|
|
1220
|
+
inline: O,
|
|
1221
|
+
edgeWidth: C.edgeWidth,
|
|
1222
|
+
zIndex: a
|
|
1223
|
+
}), ...R.style }), [D, O, C.edgeWidth, a, R.style]), T = s.useMemo(() => C.enabled ? { ...H, ...M.style } : H, [C.enabled, H, M.style]), A = St(C, n, N), I = p?.title ?? t.ariaLabel ?? "Drawer", ye = Yt(A, g, y, R.onPointerDown, D);
|
|
1224
|
+
return /* @__PURE__ */ U(X, { children: [
|
|
1225
|
+
ye,
|
|
1226
|
+
/* @__PURE__ */ P(
|
|
1227
|
+
"div",
|
|
1228
|
+
{
|
|
1229
|
+
ref: f,
|
|
1230
|
+
style: h,
|
|
1231
|
+
onClick: d ? r : void 0
|
|
1232
|
+
}
|
|
1233
|
+
),
|
|
1234
|
+
/* @__PURE__ */ P(
|
|
1235
|
+
"div",
|
|
1236
|
+
{
|
|
1237
|
+
ref: b,
|
|
1238
|
+
"data-layer-id": e,
|
|
1239
|
+
"data-placement": D,
|
|
1240
|
+
style: T,
|
|
1241
|
+
role: "dialog",
|
|
1242
|
+
"aria-modal": d ? !0 : void 0,
|
|
1243
|
+
"aria-hidden": n ? void 0 : !0,
|
|
1244
|
+
"aria-label": I,
|
|
1245
|
+
onPointerDown: C.enabled ? M.onPointerDown : void 0,
|
|
1246
|
+
children: /* @__PURE__ */ P(
|
|
1247
|
+
Vt,
|
|
1248
|
+
{
|
|
1249
|
+
chrome: w,
|
|
1250
|
+
frameStyle: m,
|
|
1251
|
+
header: p,
|
|
1252
|
+
dismissible: d,
|
|
1253
|
+
onClose: r,
|
|
1254
|
+
children: i
|
|
1255
|
+
}
|
|
1256
|
+
)
|
|
1257
|
+
}
|
|
1258
|
+
)
|
|
1259
|
+
] });
|
|
1260
|
+
}, Qt = (e, t) => new Promise((n) => {
|
|
1261
|
+
let r = !1;
|
|
1262
|
+
const o = () => {
|
|
1263
|
+
r || (r = !0, e.removeEventListener("transitionend", i), n());
|
|
1264
|
+
}, i = (a) => {
|
|
1265
|
+
a.target === e && o();
|
|
1266
|
+
};
|
|
1267
|
+
e.addEventListener("transitionend", i), setTimeout(o, t + 50);
|
|
1268
|
+
}), he = async (e, t, n, r) => {
|
|
1269
|
+
switch (t) {
|
|
1270
|
+
case "none":
|
|
1271
|
+
e();
|
|
1272
|
+
return;
|
|
1273
|
+
case "css":
|
|
1274
|
+
e(), n && await Qt(n, r);
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
}, Pn = (e) => {
|
|
1278
|
+
const [t, n] = s.useState({}), r = s.useRef(e);
|
|
1279
|
+
r.current = e;
|
|
1280
|
+
const o = s.useCallback(
|
|
1281
|
+
async (u, l, d) => {
|
|
1282
|
+
const { mode: p = "none", element: w, duration: O = 300 } = d ?? {};
|
|
1283
|
+
await he(() => {
|
|
1284
|
+
n((b) => b[u] === l ? b : { ...b, [u]: l });
|
|
1285
|
+
}, p, w?.current, O);
|
|
1286
|
+
const D = r.current;
|
|
1287
|
+
l ? D?.onOpen?.(u) : D?.onClose?.(u), D?.onTransitionEnd?.(u, l);
|
|
1288
|
+
},
|
|
1289
|
+
[]
|
|
1290
|
+
), i = s.useCallback((u) => t[u] ?? !1, [t]), a = s.useCallback(
|
|
1291
|
+
(u, l) => o(u, !0, l),
|
|
1292
|
+
[o]
|
|
1293
|
+
), c = s.useCallback(
|
|
1294
|
+
(u, l) => o(u, !1, l),
|
|
1295
|
+
[o]
|
|
1296
|
+
);
|
|
1297
|
+
return { state: i, open: a, close: c };
|
|
1298
|
+
}, en = (e) => {
|
|
1299
|
+
if (!e)
|
|
1300
|
+
return 300;
|
|
1301
|
+
const t = e.match(/(\d+)/);
|
|
1302
|
+
return t ? parseInt(t[1], 10) : 300;
|
|
1303
|
+
}, tn = (e) => {
|
|
1304
|
+
const [t, n] = s.useState(() => {
|
|
1305
|
+
const u = {};
|
|
1306
|
+
return e.forEach((l) => {
|
|
1307
|
+
l.drawer && (u[l.id] = l.drawer.defaultOpen ?? !1);
|
|
1308
|
+
}), u;
|
|
1309
|
+
}), r = s.useMemo(() => {
|
|
1310
|
+
const u = /* @__PURE__ */ new Map();
|
|
1311
|
+
return e.forEach((l) => u.set(l.id, l)), u;
|
|
1312
|
+
}, [e]), o = s.useCallback(
|
|
1313
|
+
async (u, l, d) => {
|
|
1314
|
+
const p = r.get(u);
|
|
1315
|
+
if (!p?.drawer)
|
|
1316
|
+
return;
|
|
1317
|
+
const w = d?.mode ?? p.drawer.transitionMode ?? "css", O = d?.duration ?? en(p.drawer.transitionDuration), C = d?.element?.current;
|
|
1318
|
+
await he(() => {
|
|
1319
|
+
p.drawer?.open === void 0 && n((b) => b[u] === l ? b : { ...b, [u]: l }), p.drawer?.onStateChange?.(l);
|
|
1320
|
+
}, w, C, O);
|
|
1321
|
+
},
|
|
1322
|
+
[r]
|
|
1323
|
+
), i = s.useCallback(
|
|
1324
|
+
(u) => {
|
|
1325
|
+
const l = r.get(u);
|
|
1326
|
+
return l?.drawer?.open !== void 0 ? l.drawer.open : t[u] ?? !1;
|
|
1327
|
+
},
|
|
1328
|
+
[r, t]
|
|
1329
|
+
), a = s.useCallback(
|
|
1330
|
+
(u, l) => o(u, !0, l),
|
|
1331
|
+
[o]
|
|
1332
|
+
), c = s.useCallback(
|
|
1333
|
+
(u, l) => o(u, !1, l),
|
|
1334
|
+
[o]
|
|
1335
|
+
);
|
|
1336
|
+
return { state: i, open: a, close: c };
|
|
1337
|
+
};
|
|
1338
|
+
function nn(e) {
|
|
1339
|
+
if (!e.drawer)
|
|
1340
|
+
return !1;
|
|
1341
|
+
const { animationMode: t, inline: n = !1 } = e.drawer;
|
|
1342
|
+
return j(t) ? !n : !1;
|
|
1343
|
+
}
|
|
1344
|
+
function ie(e, t) {
|
|
1345
|
+
const n = /* @__PURE__ */ new Map();
|
|
1346
|
+
return e.forEach((r) => {
|
|
1347
|
+
n.set(r.id, t(r.id));
|
|
1348
|
+
}), n;
|
|
1349
|
+
}
|
|
1350
|
+
const yn = ({ layers: e }) => {
|
|
1351
|
+
const t = tn(e), n = s.useMemo(() => e.filter((i) => i.drawer), [e]), r = s.useMemo(
|
|
1352
|
+
() => ie(n, (i) => () => t.close(i)),
|
|
1353
|
+
[n, t.close]
|
|
1354
|
+
), o = s.useMemo(
|
|
1355
|
+
() => ie(n, (i) => () => t.open(i)),
|
|
1356
|
+
[n, t.open]
|
|
1357
|
+
);
|
|
1358
|
+
return /* @__PURE__ */ P(X, { children: n.map((i) => {
|
|
1359
|
+
if (!i.drawer)
|
|
1360
|
+
return null;
|
|
1361
|
+
const a = t.state(i.id), c = r.get(i.id), u = o.get(i.id);
|
|
1362
|
+
if (!c)
|
|
1363
|
+
return null;
|
|
1364
|
+
const l = /* @__PURE__ */ P(
|
|
1365
|
+
Jt,
|
|
1366
|
+
{
|
|
1367
|
+
id: i.id,
|
|
1368
|
+
config: i.drawer,
|
|
1369
|
+
isOpen: a,
|
|
1370
|
+
onClose: c,
|
|
1371
|
+
onOpen: u,
|
|
1372
|
+
zIndex: i.zIndex,
|
|
1373
|
+
width: i.width,
|
|
1374
|
+
height: i.height,
|
|
1375
|
+
position: i.position,
|
|
1376
|
+
children: i.component
|
|
1377
|
+
},
|
|
1378
|
+
i.id
|
|
1379
|
+
);
|
|
1380
|
+
return nn(i) ? Oe.createPortal(l, document.body) : l;
|
|
1381
|
+
}) });
|
|
1382
|
+
}, Se = s.createContext(null), On = ({ value: e, children: t }) => /* @__PURE__ */ P(Se.Provider, { value: e, children: t }), Cn = () => {
|
|
1383
|
+
const e = s.useContext(Se);
|
|
1384
|
+
if (!e)
|
|
1385
|
+
throw new Error("useGridLayoutContext must be used within a GridLayoutProvider.");
|
|
1386
|
+
return e;
|
|
1387
|
+
}, be = s.createContext(null), Dn = () => {
|
|
1388
|
+
const e = s.useContext(be);
|
|
1389
|
+
if (!e)
|
|
1390
|
+
throw new Error("usePanelSystem must be used within a PanelSystemProvider.");
|
|
1391
|
+
return e;
|
|
1392
|
+
}, vn = ({ config: e, layers: t, style: n, children: r }) => {
|
|
1393
|
+
const o = s.useMemo(() => {
|
|
1394
|
+
const l = /* @__PURE__ */ new Map();
|
|
1395
|
+
return t.forEach((d) => {
|
|
1396
|
+
l.set(d.id, d);
|
|
1397
|
+
}), l;
|
|
1398
|
+
}, [t]), i = s.useCallback(
|
|
1399
|
+
(l) => o.get(l)?.component ?? null,
|
|
1400
|
+
[o]
|
|
1401
|
+
), a = s.useMemo(() => t.map((l) => l.id), [t]), { getCachedContent: c } = Be({
|
|
1402
|
+
resolveContent: i,
|
|
1403
|
+
validIds: a
|
|
1404
|
+
}), u = s.useMemo(
|
|
1405
|
+
() => ({
|
|
1406
|
+
config: e,
|
|
1407
|
+
style: n,
|
|
1408
|
+
layers: {
|
|
1409
|
+
defs: t,
|
|
1410
|
+
layerById: o
|
|
1411
|
+
},
|
|
1412
|
+
getCachedContent: c
|
|
1413
|
+
}),
|
|
1414
|
+
[e, n, t, o, c]
|
|
1415
|
+
);
|
|
1416
|
+
return /* @__PURE__ */ P(be.Provider, { value: u, children: r });
|
|
1417
|
+
}, Ee = s.createContext(null), rn = ({ layerId: e, children: t }) => {
|
|
1418
|
+
const n = s.useMemo(() => ({ layerId: e }), [e]);
|
|
1419
|
+
return /* @__PURE__ */ P(Ee.Provider, { value: n, children: t });
|
|
1420
|
+
}, Rn = () => {
|
|
1421
|
+
const e = s.useContext(Ee);
|
|
1422
|
+
if (!e)
|
|
1423
|
+
throw new Error("useLayerInstance must be used within a LayerInstanceProvider.");
|
|
1424
|
+
return e;
|
|
1425
|
+
}, se = (e, t, n) => {
|
|
1426
|
+
if (typeof e == "number" && Number.isFinite(e))
|
|
1427
|
+
return e;
|
|
1428
|
+
throw new Error(`Popup layer "${n}" requires a numeric "${t}" value.`);
|
|
1429
|
+
}, Pe = (e, t) => {
|
|
1430
|
+
if (!e)
|
|
1431
|
+
throw new Error(`Popup layer "${t}" must define position (left/top).`);
|
|
1432
|
+
return {
|
|
1433
|
+
left: se(e.left, "left", t),
|
|
1434
|
+
top: se(e.top, "top", t)
|
|
1435
|
+
};
|
|
1436
|
+
}, Z = (e) => `${Math.round(e)}`, V = (e) => {
|
|
1437
|
+
if (e !== void 0)
|
|
1438
|
+
return e ? "yes" : "no";
|
|
1439
|
+
}, on = (e, t, n, r, o) => {
|
|
1440
|
+
const i = {}, a = Pe(t, e);
|
|
1441
|
+
if (typeof n != "number" || typeof r != "number")
|
|
1442
|
+
throw new Error(`Popup layer "${e}" requires numeric width/height.`);
|
|
1443
|
+
i.width = Z(n), i.height = Z(r), i.left = Z(a.left), i.top = Z(a.top);
|
|
1444
|
+
const c = o?.features;
|
|
1445
|
+
if (c) {
|
|
1446
|
+
const u = V(c.toolbar), l = V(c.menubar), d = V(c.location), p = V(c.status), w = V(c.resizable), O = V(c.scrollbars);
|
|
1447
|
+
u !== void 0 && (i.toolbar = u), l !== void 0 && (i.menubar = l), d !== void 0 && (i.location = d), p !== void 0 && (i.status = p), w !== void 0 && (i.resizable = w), O !== void 0 && (i.scrollbars = O);
|
|
1448
|
+
}
|
|
1449
|
+
return Object.entries(i).map(([u, l]) => `${u}=${l}`).join(",");
|
|
1450
|
+
}, ae = (e, t, n, r, o) => {
|
|
1451
|
+
const i = Pe(n, t);
|
|
1452
|
+
if (typeof r != "number" || typeof o != "number")
|
|
1453
|
+
throw new Error(`Popup layer "${t}" requires numeric width/height.`);
|
|
1454
|
+
e.moveTo(Math.round(i.left), Math.round(i.top)), e.resizeTo(Math.round(r), Math.round(o));
|
|
1455
|
+
}, xn = ({ layer: e }) => {
|
|
1456
|
+
const t = e.floating;
|
|
1457
|
+
if (!t)
|
|
1458
|
+
throw new Error(`Layer "${e.id}" is missing floating configuration required for popup mode.`);
|
|
1459
|
+
if ((t.mode ?? "embedded") !== "popup")
|
|
1460
|
+
throw new Error(`PopupLayerPortal received layer "${e.id}" that is not configured for popup mode.`);
|
|
1461
|
+
const r = s.useRef(null), o = s.useRef(null), [i, a] = s.useState(!1);
|
|
1462
|
+
return s.useEffect(() => {
|
|
1463
|
+
if (typeof window > "u")
|
|
1464
|
+
return;
|
|
1465
|
+
const c = on(e.id, e.position, e.width, e.height, t.popup), u = t.popup?.name ?? e.id, l = sn(
|
|
1466
|
+
u,
|
|
1467
|
+
c,
|
|
1468
|
+
{
|
|
1469
|
+
position: e.position,
|
|
1470
|
+
size: { width: e.width, height: e.height }
|
|
1471
|
+
},
|
|
1472
|
+
t.popup
|
|
1473
|
+
);
|
|
1474
|
+
if (!l)
|
|
1475
|
+
throw new Error(`Failed to open popup window for layer "${e.id}".`);
|
|
1476
|
+
const d = l;
|
|
1477
|
+
o.current = d, t.popup?.focus !== !1 && d.focus(), d.document.title || (d.document.title = e.id), d.document.body.innerHTML = "";
|
|
1478
|
+
const p = d.document.createElement("div");
|
|
1479
|
+
p.dataset.layerId = e.id, d.document.body.appendChild(p), r.current = p, a(!0), ae(d, e.id, e.position, e.width, e.height);
|
|
1480
|
+
const w = () => {
|
|
1481
|
+
o.current = null, r.current = null, a(!1);
|
|
1482
|
+
};
|
|
1483
|
+
return d.addEventListener("beforeunload", w), () => {
|
|
1484
|
+
d.removeEventListener("beforeunload", w), t.popup?.closeOnUnmount !== !1 && d.close(), o.current = null, r.current = null, a(!1);
|
|
1485
|
+
};
|
|
1486
|
+
}, [
|
|
1487
|
+
t.popup?.closeOnUnmount,
|
|
1488
|
+
t.popup?.features?.location,
|
|
1489
|
+
t.popup?.features?.menubar,
|
|
1490
|
+
t.popup?.features?.resizable,
|
|
1491
|
+
t.popup?.features?.scrollbars,
|
|
1492
|
+
t.popup?.features?.status,
|
|
1493
|
+
t.popup?.features?.toolbar,
|
|
1494
|
+
t.popup?.focus,
|
|
1495
|
+
t.popup?.name,
|
|
1496
|
+
e.id
|
|
1497
|
+
]), s.useEffect(() => {
|
|
1498
|
+
const c = o.current;
|
|
1499
|
+
c && ae(c, e.id, e.position, e.width, e.height);
|
|
1500
|
+
}, [e.position?.left, e.position?.top, e.height, e.width, e.id]), !i || !r.current ? null : Ce(/* @__PURE__ */ P(rn, { layerId: e.id, children: e.component }), r.current);
|
|
1501
|
+
}, sn = (e, t, n, r) => {
|
|
1502
|
+
const o = r?.createWindow;
|
|
1503
|
+
return o ? o({ name: e, features: t, bounds: n }) : window.open("", e, t);
|
|
1504
|
+
}, an = ({ onClick: e }) => /* @__PURE__ */ P(De, { children: /* @__PURE__ */ P(pe, { onClick: e, "aria-label": "Close window", "data-drag-ignore": "true" }) }), cn = ({ header: e, draggable: t, onClose: n }) => {
|
|
1505
|
+
if (!e)
|
|
1506
|
+
return null;
|
|
1507
|
+
const r = e.showCloseButton ?? !1;
|
|
1508
|
+
return /* @__PURE__ */ U(le, { ...t ? { "data-drag-handle": "true" } : {}, style: { cursor: t ? "grab" : void 0 }, children: [
|
|
1509
|
+
e.title ? /* @__PURE__ */ P(de, { children: e.title }) : null,
|
|
1510
|
+
r ? /* @__PURE__ */ P(an, { onClick: n }) : null
|
|
1511
|
+
] });
|
|
1512
|
+
}, un = ({ header: e, draggable: t, chrome: n, onClose: r, children: o }) => n ? /* @__PURE__ */ U(ce, { style: { height: "100%", width: "100%" }, children: [
|
|
1513
|
+
/* @__PURE__ */ P(cn, { header: e, draggable: t, onClose: r }),
|
|
1514
|
+
/* @__PURE__ */ P(ue, { style: { flex: 1, display: "flex", flexDirection: "column" }, children: o })
|
|
1515
|
+
] }) : /* @__PURE__ */ P(X, { children: o }), ln = ({ id: e, config: t, onClose: n, children: r }) => {
|
|
1516
|
+
const o = t.chrome ?? !1, i = t.draggable ?? !1, a = t.header?.title ?? t.ariaLabel ?? "Floating window";
|
|
1517
|
+
return /* @__PURE__ */ P("div", { "data-floating-window": e, role: "dialog", "aria-label": a, style: { height: "100%", width: "100%" }, children: /* @__PURE__ */ P(un, { header: t.header, draggable: i, chrome: o, onClose: n, children: r }) });
|
|
1518
|
+
};
|
|
1519
|
+
ln.displayName = "FloatingWindow";
|
|
1520
|
+
export {
|
|
1521
|
+
Jt as D,
|
|
1522
|
+
ln as F,
|
|
1523
|
+
On as G,
|
|
1524
|
+
rn as L,
|
|
1525
|
+
xn as P,
|
|
1526
|
+
Sn as S,
|
|
1527
|
+
Rn as a,
|
|
1528
|
+
yn as b,
|
|
1529
|
+
Pn as c,
|
|
1530
|
+
tn as d,
|
|
1531
|
+
Dn as e,
|
|
1532
|
+
vn as f,
|
|
1533
|
+
En as g,
|
|
1534
|
+
Bt as h,
|
|
1535
|
+
j as i,
|
|
1536
|
+
bt as j,
|
|
1537
|
+
F as k,
|
|
1538
|
+
bn as l,
|
|
1539
|
+
he as r,
|
|
1540
|
+
Cn as u
|
|
1541
|
+
};
|
|
1542
|
+
//# sourceMappingURL=FloatingWindow-CE-WzkNv.js.map
|