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,947 @@
|
|
|
1
|
+
import { jsx as z, Fragment as U, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
import * as d from "react";
|
|
3
|
+
import { e as vt, F as xt, u as Ct, L as kt, P as Ht, f as Dt, g as Nt, h as Gt, i as at, G as At, b as W } from "./FloatingWindow-CE-WzkNv.js";
|
|
4
|
+
import { G as X, v as I, w as tt } from "./styles-NkjuMOVS.js";
|
|
5
|
+
import { u as $t } from "./SwipePivotTabBar-DWrCuwEI.js";
|
|
6
|
+
import { R as Ft } from "./ResizeHandle-CXjc1meV.js";
|
|
7
|
+
import { u as Rt } from "./useIsomorphicLayoutEffect-DhmEnmZ_.js";
|
|
8
|
+
import { u as ct, b as lt } from "./useDocumentPointerEvents-DXxw3qWj.js";
|
|
9
|
+
const Ot = () => {
|
|
10
|
+
const t = /* @__PURE__ */ new Map();
|
|
11
|
+
return (e) => {
|
|
12
|
+
if (!e)
|
|
13
|
+
return;
|
|
14
|
+
const n = t.get(e);
|
|
15
|
+
if (n !== void 0)
|
|
16
|
+
return n;
|
|
17
|
+
const r = t.size;
|
|
18
|
+
return t.set(e, r), r;
|
|
19
|
+
};
|
|
20
|
+
}, Yt = Ot(), et = /* @__PURE__ */ new Map(), _t = (t) => {
|
|
21
|
+
const e = `ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${Yt(t.root)}`;
|
|
22
|
+
if (et.has(e))
|
|
23
|
+
return et.get(e);
|
|
24
|
+
const n = new class {
|
|
25
|
+
#t = /* @__PURE__ */ new Map();
|
|
26
|
+
#e = new IntersectionObserver((r) => {
|
|
27
|
+
r.forEach((o) => {
|
|
28
|
+
const s = this.#t.get(o.target);
|
|
29
|
+
s && s(o);
|
|
30
|
+
});
|
|
31
|
+
}, t);
|
|
32
|
+
observe(r, o) {
|
|
33
|
+
return this.#t.set(r, o), this.#e.observe(r), () => {
|
|
34
|
+
this.#t.delete(r), this.#e.unobserve(r);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}();
|
|
38
|
+
return et.set(e, n), n;
|
|
39
|
+
}, ut = Object.freeze({
|
|
40
|
+
x: 0,
|
|
41
|
+
y: 0,
|
|
42
|
+
width: 0,
|
|
43
|
+
height: 0,
|
|
44
|
+
top: 0,
|
|
45
|
+
right: 0,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: 0
|
|
48
|
+
});
|
|
49
|
+
function Bt(t, { threshold: e = 0, rootMargin: n = "0px", root: r = null }) {
|
|
50
|
+
const [o, s] = d.useState(null);
|
|
51
|
+
return d.useEffect(() => {
|
|
52
|
+
const l = t.current;
|
|
53
|
+
return l ? _t({
|
|
54
|
+
threshold: e,
|
|
55
|
+
rootMargin: n,
|
|
56
|
+
root: r
|
|
57
|
+
}).observe(l, (u) => {
|
|
58
|
+
s({
|
|
59
|
+
isIntersecting: u.isIntersecting,
|
|
60
|
+
boundingClientRect: u.boundingClientRect,
|
|
61
|
+
intersectionRatio: u.intersectionRatio,
|
|
62
|
+
intersectionRect: u.intersectionRect,
|
|
63
|
+
rootBounds: u.rootBounds,
|
|
64
|
+
target: u.target,
|
|
65
|
+
time: u.time
|
|
66
|
+
});
|
|
67
|
+
}) : void 0;
|
|
68
|
+
}, [t, e, n, r]), d.useMemo(() => ({
|
|
69
|
+
isIntersecting: o?.isIntersecting ?? !1,
|
|
70
|
+
boundingClientRect: o?.boundingClientRect ?? ut,
|
|
71
|
+
intersectionRatio: o?.intersectionRatio ?? 0,
|
|
72
|
+
intersectionRect: o?.intersectionRect ?? ut,
|
|
73
|
+
rootBounds: o?.rootBounds ?? null,
|
|
74
|
+
target: o?.target ?? t.current,
|
|
75
|
+
time: o?.time ?? 0
|
|
76
|
+
}), [o, t]);
|
|
77
|
+
}
|
|
78
|
+
const yt = {
|
|
79
|
+
position: "absolute",
|
|
80
|
+
pointerEvents: "auto",
|
|
81
|
+
boxSizing: "border-box",
|
|
82
|
+
background: "transparent",
|
|
83
|
+
border: "none"
|
|
84
|
+
}, Wt = {
|
|
85
|
+
...yt,
|
|
86
|
+
width: I,
|
|
87
|
+
height: I,
|
|
88
|
+
zIndex: 2
|
|
89
|
+
}, Xt = {
|
|
90
|
+
...yt,
|
|
91
|
+
zIndex: 1
|
|
92
|
+
}, jt = {
|
|
93
|
+
"top-left": {
|
|
94
|
+
top: 0,
|
|
95
|
+
left: 0,
|
|
96
|
+
transform: "translate(-50%, -50%)",
|
|
97
|
+
cursor: "nwse-resize"
|
|
98
|
+
},
|
|
99
|
+
"top-right": {
|
|
100
|
+
top: 0,
|
|
101
|
+
right: 0,
|
|
102
|
+
transform: "translate(50%, -50%)",
|
|
103
|
+
cursor: "nesw-resize"
|
|
104
|
+
},
|
|
105
|
+
"bottom-left": {
|
|
106
|
+
bottom: 0,
|
|
107
|
+
left: 0,
|
|
108
|
+
transform: "translate(-50%, 50%)",
|
|
109
|
+
cursor: "nesw-resize"
|
|
110
|
+
},
|
|
111
|
+
"bottom-right": {
|
|
112
|
+
bottom: 0,
|
|
113
|
+
right: 0,
|
|
114
|
+
transform: "translate(50%, 50%)",
|
|
115
|
+
cursor: "nwse-resize"
|
|
116
|
+
}
|
|
117
|
+
}, Vt = {
|
|
118
|
+
left: {
|
|
119
|
+
top: I,
|
|
120
|
+
bottom: I,
|
|
121
|
+
left: 0,
|
|
122
|
+
width: X,
|
|
123
|
+
transform: "translateX(-50%)",
|
|
124
|
+
cursor: "ew-resize"
|
|
125
|
+
},
|
|
126
|
+
right: {
|
|
127
|
+
top: I,
|
|
128
|
+
bottom: I,
|
|
129
|
+
right: 0,
|
|
130
|
+
width: X,
|
|
131
|
+
transform: "translateX(50%)",
|
|
132
|
+
cursor: "ew-resize"
|
|
133
|
+
},
|
|
134
|
+
top: {
|
|
135
|
+
left: I,
|
|
136
|
+
right: I,
|
|
137
|
+
top: 0,
|
|
138
|
+
height: X,
|
|
139
|
+
transform: "translateY(-50%)",
|
|
140
|
+
cursor: "ns-resize"
|
|
141
|
+
},
|
|
142
|
+
bottom: {
|
|
143
|
+
left: I,
|
|
144
|
+
right: I,
|
|
145
|
+
bottom: 0,
|
|
146
|
+
height: X,
|
|
147
|
+
transform: "translateY(50%)",
|
|
148
|
+
cursor: "ns-resize"
|
|
149
|
+
}
|
|
150
|
+
}, Kt = [
|
|
151
|
+
{ key: "top-left", variant: "corner", horizontal: "left", vertical: "top" },
|
|
152
|
+
{ key: "top-right", variant: "corner", horizontal: "right", vertical: "top" },
|
|
153
|
+
{ key: "bottom-left", variant: "corner", horizontal: "left", vertical: "bottom" },
|
|
154
|
+
{ key: "bottom-right", variant: "corner", horizontal: "right", vertical: "bottom" },
|
|
155
|
+
{ key: "left", variant: "edge", horizontal: "left" },
|
|
156
|
+
{ key: "right", variant: "edge", horizontal: "right" },
|
|
157
|
+
{ key: "top", variant: "edge", vertical: "top" },
|
|
158
|
+
{ key: "bottom", variant: "edge", vertical: "bottom" }
|
|
159
|
+
], Ut = ({ layerId: t, onPointerDown: e }) => /* @__PURE__ */ z(U, { children: Kt.map((n) => {
|
|
160
|
+
const r = n.variant === "corner" ? Wt : Xt, o = n.variant === "corner" ? jt[n.key] : Vt[n.key], s = { ...r, ...o }, l = n.variant === "corner" ? { "data-resize-corner": n.key } : { "data-resize-edge": n.key };
|
|
161
|
+
return /* @__PURE__ */ z(
|
|
162
|
+
"div",
|
|
163
|
+
{
|
|
164
|
+
role: "presentation",
|
|
165
|
+
"aria-hidden": "true",
|
|
166
|
+
style: s,
|
|
167
|
+
...l,
|
|
168
|
+
"data-layer-id": t,
|
|
169
|
+
onPointerDown: (a) => e(n, a)
|
|
170
|
+
},
|
|
171
|
+
n.key
|
|
172
|
+
);
|
|
173
|
+
}) }), Zt = ({ pivot: t }) => {
|
|
174
|
+
const { Outlet: e } = $t({
|
|
175
|
+
items: t.items,
|
|
176
|
+
activeId: t.activeId,
|
|
177
|
+
defaultActiveId: t.defaultActiveId,
|
|
178
|
+
onActiveChange: t.onActiveChange,
|
|
179
|
+
transitionMode: t.transitionMode
|
|
180
|
+
});
|
|
181
|
+
return /* @__PURE__ */ z(e, {});
|
|
182
|
+
}, qt = (t, e) => t.pivot ? /* @__PURE__ */ z(Zt, { pivot: t.pivot }) : t.cache ? e(t.id) : t.component, Et = d.memo(({ layer: t, onClose: e }) => {
|
|
183
|
+
const { getCachedContent: n } = vt(), r = qt(t, n);
|
|
184
|
+
return t.floating?.chrome ? /* @__PURE__ */ z(xt, { id: t.id, config: t.floating, onClose: e, children: r }) : r;
|
|
185
|
+
});
|
|
186
|
+
Et.displayName = "LayerContentRenderer";
|
|
187
|
+
const It = d.memo(({ layerId: t, isResizable: e, onPointerDown: n }) => e ? /* @__PURE__ */ z(Ut, { layerId: t, onPointerDown: n }) : null);
|
|
188
|
+
It.displayName = "LayerResizeHandles";
|
|
189
|
+
const Jt = (t, e) => t ? "auto" : e ? "visible" : "hidden", Mt = d.memo(({ layer: t, handleLayerPointerDown: e }) => {
|
|
190
|
+
const { getLayerRenderState: n } = Ct(), { style: r, isResizable: o, isResizing: s, onResizeHandlePointerDown: l } = n(t), a = d.useMemo(() => {
|
|
191
|
+
const f = {};
|
|
192
|
+
return t.gridArea && (f.gridArea = t.gridArea), t.gridRow && (f.gridRow = t.gridRow), t.gridColumn && (f.gridColumn = t.gridColumn), f;
|
|
193
|
+
}, [t.gridArea, t.gridRow, t.gridColumn]), u = d.useMemo(() => {
|
|
194
|
+
const f = !!t.floating, g = Jt(t.scrollable, f), b = {
|
|
195
|
+
...r,
|
|
196
|
+
...a,
|
|
197
|
+
minWidth: 0,
|
|
198
|
+
minHeight: 0,
|
|
199
|
+
overflow: g
|
|
200
|
+
};
|
|
201
|
+
return o ? { ...b, position: "relative" } : b;
|
|
202
|
+
}, [r, a, o, t.scrollable, t.floating]), p = d.useCallback(() => {
|
|
203
|
+
t.floating?.onClose?.();
|
|
204
|
+
}, [t.floating]);
|
|
205
|
+
return /* @__PURE__ */ _(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
"data-layer-id": t.id,
|
|
209
|
+
"data-draggable": !!t.floating?.draggable,
|
|
210
|
+
"data-resizable": o,
|
|
211
|
+
"data-resizing": s,
|
|
212
|
+
style: u,
|
|
213
|
+
onPointerDown: e,
|
|
214
|
+
children: [
|
|
215
|
+
/* @__PURE__ */ z(kt, { layerId: t.id, children: /* @__PURE__ */ z(Et, { layer: t, onClose: p }) }),
|
|
216
|
+
/* @__PURE__ */ z(It, { layerId: t.id, isResizable: o, onPointerDown: l })
|
|
217
|
+
]
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
Mt.displayName = "EmbeddedLayer";
|
|
222
|
+
const Qt = ({ layers: t }) => {
|
|
223
|
+
const { handleLayerPointerDown: e } = Ct();
|
|
224
|
+
return /* @__PURE__ */ z(U, { children: t.map((n) => {
|
|
225
|
+
const r = n.floating?.mode ?? "embedded";
|
|
226
|
+
return n.floating && r === "popup" ? /* @__PURE__ */ z(Ht, { layer: n }, n.id) : /* @__PURE__ */ z(Mt, { layer: n, handleLayerPointerDown: e }, n.id);
|
|
227
|
+
}) });
|
|
228
|
+
}, dt = {
|
|
229
|
+
position: "absolute",
|
|
230
|
+
pointerEvents: "auto"
|
|
231
|
+
}, gt = ({
|
|
232
|
+
direction: t,
|
|
233
|
+
trackIndex: e,
|
|
234
|
+
align: n,
|
|
235
|
+
gap: r,
|
|
236
|
+
span: o,
|
|
237
|
+
onResize: s
|
|
238
|
+
}) => {
|
|
239
|
+
const l = t === "col" ? "vertical" : "horizontal", a = d.useCallback(
|
|
240
|
+
(f) => {
|
|
241
|
+
const g = n === "start" ? -f : f;
|
|
242
|
+
s(t, e, g);
|
|
243
|
+
},
|
|
244
|
+
[n, t, e, s]
|
|
245
|
+
), u = d.useMemo(() => t === "col" ? {
|
|
246
|
+
gridColumn: `${e + 1} / ${e + 2}`,
|
|
247
|
+
gridRow: `${o.start} / ${o.end}`
|
|
248
|
+
} : {
|
|
249
|
+
gridRow: `${e + 1} / ${e + 2}`,
|
|
250
|
+
gridColumn: `${o.start} / ${o.end}`
|
|
251
|
+
}, [t, e, o]), p = d.useMemo(() => {
|
|
252
|
+
const g = Math.max(0, r) / 2 + tt / 2;
|
|
253
|
+
return t === "col" ? {
|
|
254
|
+
...dt,
|
|
255
|
+
width: tt,
|
|
256
|
+
height: "100%",
|
|
257
|
+
top: 0,
|
|
258
|
+
bottom: 0,
|
|
259
|
+
...n === "start" ? { left: -g } : { right: -g }
|
|
260
|
+
} : {
|
|
261
|
+
...dt,
|
|
262
|
+
width: "100%",
|
|
263
|
+
height: tt,
|
|
264
|
+
left: 0,
|
|
265
|
+
right: 0,
|
|
266
|
+
...n === "start" ? { top: -g } : { bottom: -g }
|
|
267
|
+
};
|
|
268
|
+
}, [n, t, r]);
|
|
269
|
+
return /* @__PURE__ */ z("div", { "data-resizable": "true", style: { ...u, position: "relative", pointerEvents: "none" }, children: /* @__PURE__ */ z("div", { "data-direction": l, "data-align": n, "data-handle": "true", style: p, children: /* @__PURE__ */ z(Ft, { direction: l, onResize: a }) }) });
|
|
270
|
+
}, te = (t) => {
|
|
271
|
+
const e = /* @__PURE__ */ new Map();
|
|
272
|
+
t.forEach((r, o) => {
|
|
273
|
+
r.forEach((s, l) => {
|
|
274
|
+
if (!s || s === ".")
|
|
275
|
+
return;
|
|
276
|
+
const a = e.get(s);
|
|
277
|
+
if (a) {
|
|
278
|
+
const p = {
|
|
279
|
+
rowStart: Math.min(a.rowStart, o),
|
|
280
|
+
rowEnd: Math.max(a.rowEnd, o),
|
|
281
|
+
colStart: Math.min(a.colStart, l),
|
|
282
|
+
colEnd: Math.max(a.colEnd, l)
|
|
283
|
+
};
|
|
284
|
+
e.set(s, p);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const u = {
|
|
288
|
+
rowStart: o,
|
|
289
|
+
rowEnd: o,
|
|
290
|
+
colStart: l,
|
|
291
|
+
colEnd: l
|
|
292
|
+
};
|
|
293
|
+
e.set(s, u);
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
const n = /* @__PURE__ */ new Map();
|
|
297
|
+
return e.forEach((r, o) => {
|
|
298
|
+
const s = r.rowStart + 1, l = r.rowEnd + 2, a = r.colStart + 1, u = r.colEnd + 2, p = {
|
|
299
|
+
gridArea: o,
|
|
300
|
+
gridRow: `${s} / ${l}`,
|
|
301
|
+
gridColumn: `${a} / ${u}`
|
|
302
|
+
};
|
|
303
|
+
n.set(o, p);
|
|
304
|
+
}), n;
|
|
305
|
+
}, ee = (t, e) => {
|
|
306
|
+
if ((t.positionMode ?? "grid") !== "grid")
|
|
307
|
+
return t;
|
|
308
|
+
const r = t.gridArea ?? t.id, o = e.get(r);
|
|
309
|
+
if (!o)
|
|
310
|
+
return t;
|
|
311
|
+
const s = !t.gridArea, l = !t.gridRow, a = !t.gridColumn;
|
|
312
|
+
return !s && !l && !a ? t : {
|
|
313
|
+
...t,
|
|
314
|
+
gridArea: s ? o.gridArea : t.gridArea,
|
|
315
|
+
gridRow: l ? o.gridRow : t.gridRow,
|
|
316
|
+
gridColumn: a ? o.gridColumn : t.gridColumn
|
|
317
|
+
};
|
|
318
|
+
}, ne = (t, e) => {
|
|
319
|
+
const n = d.useMemo(() => te(t.areas), [t.areas]), r = d.useMemo(() => e.map((a) => ee(a, n)), [e, n]), o = d.useMemo(
|
|
320
|
+
() => r.filter((a) => a.visible !== !1),
|
|
321
|
+
[r]
|
|
322
|
+
), s = d.useMemo(
|
|
323
|
+
() => o.filter((a) => !a.drawer),
|
|
324
|
+
[o]
|
|
325
|
+
), l = d.useMemo(() => {
|
|
326
|
+
const a = /* @__PURE__ */ new Map();
|
|
327
|
+
return r.forEach((u) => {
|
|
328
|
+
a.set(u.id, u);
|
|
329
|
+
}), a;
|
|
330
|
+
}, [r]);
|
|
331
|
+
return {
|
|
332
|
+
normalizedLayers: r,
|
|
333
|
+
visibleLayers: o,
|
|
334
|
+
regularLayers: s,
|
|
335
|
+
layerById: l
|
|
336
|
+
};
|
|
337
|
+
}, re = (t) => {
|
|
338
|
+
if (!t)
|
|
339
|
+
return { rowGap: 0, columnGap: 0 };
|
|
340
|
+
const e = t.split(/\s+/).map((r) => r.trim()).filter(Boolean), n = (r) => {
|
|
341
|
+
const o = r.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
342
|
+
return o ? Number.parseFloat(o[1]) : 0;
|
|
343
|
+
};
|
|
344
|
+
if (e.length === 1) {
|
|
345
|
+
const r = n(e[0]);
|
|
346
|
+
return { rowGap: r, columnGap: r };
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
rowGap: n(e[0]),
|
|
350
|
+
columnGap: n(e[1])
|
|
351
|
+
};
|
|
352
|
+
}, oe = (t, e) => {
|
|
353
|
+
if (!t)
|
|
354
|
+
return [];
|
|
355
|
+
const n = getComputedStyle(t);
|
|
356
|
+
return (e === "col" ? n.gridTemplateColumns : n.gridTemplateRows).split(/\s+/).map((o) => parseFloat(o)).filter((o) => !Number.isNaN(o));
|
|
357
|
+
}, Lt = (t, e = Number.NEGATIVE_INFINITY, n = Number.POSITIVE_INFINITY) => Math.min(Math.max(t, e), n), Ue = (t, e) => typeof t != "number" || !Number.isFinite(t) ? e : t, Z = (t, e) => `${t}-${e}`, se = (t, e, n, r) => {
|
|
358
|
+
const o = Z(n, r), s = e[o];
|
|
359
|
+
return s !== void 0 ? `minmax(${t.minSize ?? 0}px, ${s}px)` : t.size;
|
|
360
|
+
}, ht = (t, e, n) => t.map((r, o) => se(r, e, n, o)).join(" "), j = (t, e) => t.reduce((n, r, o) => (r.resizable && r.size.endsWith("px") && (n[Z(e, o)] = parseInt(r.size, 10)), n), {}), ie = ({
|
|
361
|
+
trackSizes: t,
|
|
362
|
+
track: e,
|
|
363
|
+
direction: n,
|
|
364
|
+
trackIndex: r,
|
|
365
|
+
containerRef: o
|
|
366
|
+
}) => {
|
|
367
|
+
const s = Z(n, r), l = t[s];
|
|
368
|
+
if (l !== void 0)
|
|
369
|
+
return l;
|
|
370
|
+
const u = oe(o?.current ?? null, n)[r];
|
|
371
|
+
return u !== void 0 && u > 0 ? u : e.size.endsWith("px") ? Number.parseInt(e.size, 10) : 300;
|
|
372
|
+
}, ae = (t, e) => t.reduce((n, r, o) => o === e ? n : r.size.includes("fr") ? n + 100 : n + (r.minSize ?? 50), 0), ce = ({
|
|
373
|
+
track: t,
|
|
374
|
+
tracks: e,
|
|
375
|
+
trackIndex: n,
|
|
376
|
+
direction: r,
|
|
377
|
+
containerRef: o,
|
|
378
|
+
gapSizes: s
|
|
379
|
+
}) => {
|
|
380
|
+
if (!o?.current)
|
|
381
|
+
return t.maxSize;
|
|
382
|
+
const l = r === "col" ? o.current.offsetWidth : o.current.offsetHeight, a = ae(e, n), u = e.length - 1, p = r === "col" ? s.columnGap : s.rowGap, f = u * p, g = l - a - f;
|
|
383
|
+
return t.maxSize !== void 0 ? Math.min(t.maxSize, g) : g;
|
|
384
|
+
}, le = (t, e, n) => Lt(t, e ?? Number.NEGATIVE_INFINITY, n ?? Number.POSITIVE_INFINITY), ft = (t, e) => {
|
|
385
|
+
const n = t.length, r = [];
|
|
386
|
+
for (let l = 0; l < n; l++) {
|
|
387
|
+
const a = t[l], u = a[e], p = a[e + 1];
|
|
388
|
+
u !== p && r.push(l);
|
|
389
|
+
}
|
|
390
|
+
if (r.length === 0)
|
|
391
|
+
return { start: 1, end: n + 1 };
|
|
392
|
+
const o = Math.min(...r), s = Math.max(...r);
|
|
393
|
+
return { start: o + 1, end: s + 2 };
|
|
394
|
+
}, mt = (t, e) => {
|
|
395
|
+
const n = t[e], r = t[e + 1], o = n?.length ?? 0, s = [];
|
|
396
|
+
for (let u = 0; u < o; u++) {
|
|
397
|
+
const p = n?.[u], f = r?.[u];
|
|
398
|
+
p !== f && s.push(u);
|
|
399
|
+
}
|
|
400
|
+
if (s.length === 0)
|
|
401
|
+
return { start: 1, end: o + 1 };
|
|
402
|
+
const l = Math.min(...s), a = Math.max(...s);
|
|
403
|
+
return { start: l + 1, end: a + 2 };
|
|
404
|
+
}, ue = (t, e) => {
|
|
405
|
+
if (t.length === 0)
|
|
406
|
+
return [];
|
|
407
|
+
const n = e.length;
|
|
408
|
+
if (t.length === 1)
|
|
409
|
+
return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
|
|
410
|
+
const r = [];
|
|
411
|
+
return Array.from({ length: t.length - 1 }, (s, l) => l).forEach((s) => {
|
|
412
|
+
const l = t[s];
|
|
413
|
+
if (t[s + 1]?.resizable) {
|
|
414
|
+
const u = ft(e, s);
|
|
415
|
+
r.push({ trackIndex: s + 1, align: "start", span: u });
|
|
416
|
+
return;
|
|
417
|
+
}
|
|
418
|
+
if (l?.resizable) {
|
|
419
|
+
const u = ft(e, s);
|
|
420
|
+
r.push({ trackIndex: s, align: "end", span: u });
|
|
421
|
+
}
|
|
422
|
+
}), r;
|
|
423
|
+
}, de = (t, e) => {
|
|
424
|
+
if (t.length === 0)
|
|
425
|
+
return [];
|
|
426
|
+
const n = e[0]?.length ?? 0;
|
|
427
|
+
if (t.length === 1)
|
|
428
|
+
return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
|
|
429
|
+
const r = [];
|
|
430
|
+
return Array.from({ length: t.length - 1 }, (s, l) => l).forEach((s) => {
|
|
431
|
+
const l = t[s];
|
|
432
|
+
if (t[s + 1]?.resizable) {
|
|
433
|
+
const u = mt(e, s);
|
|
434
|
+
r.push({ trackIndex: s + 1, align: "start", span: u });
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
if (l?.resizable) {
|
|
438
|
+
const u = mt(e, s);
|
|
439
|
+
r.push({ trackIndex: s, align: "end", span: u });
|
|
440
|
+
}
|
|
441
|
+
}), r;
|
|
442
|
+
}, ge = (t) => t !== void 0 ? { gap: t } : {}, he = (t, e) => {
|
|
443
|
+
const n = Object.keys(e), r = {};
|
|
444
|
+
for (const f of n)
|
|
445
|
+
r[f] = t[f] ?? e[f];
|
|
446
|
+
const o = Object.keys(t), s = o.length !== n.length, l = o.some(
|
|
447
|
+
(f) => !Object.prototype.hasOwnProperty.call(r, f)
|
|
448
|
+
), a = s ? !0 : l, u = n.some((f) => t[f] !== r[f]);
|
|
449
|
+
return (a ? !0 : u) ? r : null;
|
|
450
|
+
}, fe = (t, e, n) => {
|
|
451
|
+
const [r, o] = d.useState(() => ({
|
|
452
|
+
...j(t.columns, "col"),
|
|
453
|
+
...j(t.rows, "row")
|
|
454
|
+
}));
|
|
455
|
+
Rt(() => {
|
|
456
|
+
const g = {
|
|
457
|
+
...j(t.columns, "col"),
|
|
458
|
+
...j(t.rows, "row")
|
|
459
|
+
};
|
|
460
|
+
o((b) => he(b, g) ?? b);
|
|
461
|
+
}, [t.columns, t.rows]);
|
|
462
|
+
const s = d.useMemo(() => t.areas.map((g) => `"${g.join(" ")}"`).join(" "), [t.areas]), l = d.useMemo(() => re(t.gap), [t.gap]), a = d.useMemo(
|
|
463
|
+
() => ue(t.columns, t.areas),
|
|
464
|
+
[t.columns, t.areas]
|
|
465
|
+
), u = d.useMemo(
|
|
466
|
+
() => de(t.rows, t.areas),
|
|
467
|
+
[t.rows, t.areas]
|
|
468
|
+
), p = d.useMemo(() => ({
|
|
469
|
+
...t.style,
|
|
470
|
+
...e,
|
|
471
|
+
gridTemplateAreas: s,
|
|
472
|
+
gridTemplateRows: ht(t.rows, r, "row"),
|
|
473
|
+
gridTemplateColumns: ht(t.columns, r, "col"),
|
|
474
|
+
...ge(t.gap)
|
|
475
|
+
}), [s, t.columns, t.gap, t.rows, t.style, e, r]), f = d.useCallback(
|
|
476
|
+
(g, b, C) => {
|
|
477
|
+
const E = g === "row" ? t.rows : t.columns, y = E[b];
|
|
478
|
+
if (!y || !y.resizable)
|
|
479
|
+
return;
|
|
480
|
+
const T = ie({
|
|
481
|
+
trackSizes: r,
|
|
482
|
+
track: y,
|
|
483
|
+
direction: g,
|
|
484
|
+
trackIndex: b,
|
|
485
|
+
containerRef: n
|
|
486
|
+
}), P = ce({
|
|
487
|
+
track: y,
|
|
488
|
+
tracks: E,
|
|
489
|
+
trackIndex: b,
|
|
490
|
+
direction: g,
|
|
491
|
+
containerRef: n,
|
|
492
|
+
gapSizes: l
|
|
493
|
+
}), L = Z(g, b);
|
|
494
|
+
o((H) => {
|
|
495
|
+
const G = T + C, D = le(G, y.minSize, P);
|
|
496
|
+
return { ...H, [L]: D };
|
|
497
|
+
});
|
|
498
|
+
},
|
|
499
|
+
[t.columns, t.rows, r, n, l]
|
|
500
|
+
);
|
|
501
|
+
return {
|
|
502
|
+
columnHandles: a,
|
|
503
|
+
rowHandles: u,
|
|
504
|
+
gapSizes: l,
|
|
505
|
+
gridStyle: p,
|
|
506
|
+
handleResize: f
|
|
507
|
+
};
|
|
508
|
+
}, me = (t) => t.positionMode ? t.positionMode : t.floating ? (t.floating.mode ?? "embedded") === "embedded" ? "absolute" : "relative" : "grid", pe = (t) => ({ position: t === "grid" ? "relative" : t }), be = (t, e) => e !== "grid" ? {} : {
|
|
509
|
+
gridArea: t.gridArea,
|
|
510
|
+
gridRow: t.gridRow,
|
|
511
|
+
gridColumn: t.gridColumn
|
|
512
|
+
}, ze = (t) => t ? {
|
|
513
|
+
top: t.top,
|
|
514
|
+
right: t.right,
|
|
515
|
+
bottom: t.bottom,
|
|
516
|
+
left: t.left
|
|
517
|
+
} : {}, we = (t) => t !== void 0 ? { zIndex: t } : {}, Se = (t, e) => ({
|
|
518
|
+
width: t,
|
|
519
|
+
height: e
|
|
520
|
+
}), ve = (t, e) => t.pointerEvents !== void 0 ? typeof t.pointerEvents == "boolean" ? { pointerEvents: t.pointerEvents ? "auto" : "none" } : { pointerEvents: t.pointerEvents } : e === "absolute" || e === "fixed" ? { pointerEvents: "auto" } : {}, Ce = (t) => t.floating ? t.floating.position ?? t.floating.defaultPosition ?? t.position : t.position, Re = (t) => {
|
|
521
|
+
if (t.floating) {
|
|
522
|
+
const e = t.floating.size ?? t.floating.defaultSize;
|
|
523
|
+
if (e)
|
|
524
|
+
return {
|
|
525
|
+
width: e.width,
|
|
526
|
+
height: e.height
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
return {
|
|
530
|
+
width: t.width,
|
|
531
|
+
height: t.height
|
|
532
|
+
};
|
|
533
|
+
}, ye = (t) => t.floating?.zIndex !== void 0 ? t.floating.zIndex : t.zIndex, Ee = (t) => {
|
|
534
|
+
const e = me(t), n = Ce(t), r = Re(t), o = ye(t);
|
|
535
|
+
return {
|
|
536
|
+
...t.style,
|
|
537
|
+
...pe(e),
|
|
538
|
+
...be(t, e),
|
|
539
|
+
...ze(n),
|
|
540
|
+
...we(o),
|
|
541
|
+
...Se(r.width, r.height),
|
|
542
|
+
...ve(t, e)
|
|
543
|
+
};
|
|
544
|
+
}, Ie = (t) => {
|
|
545
|
+
const e = t.floating;
|
|
546
|
+
return e ? e.mode ?? "embedded" : null;
|
|
547
|
+
}, k = (t) => Ie(t) !== "embedded" ? null : t.floating ?? null, pt = (t) => t instanceof HTMLElement ? ["INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(t.tagName) : !1, bt = (t, e, n) => {
|
|
548
|
+
const r = e ?? Number.NEGATIVE_INFINITY, o = n ?? Number.POSITIVE_INFINITY;
|
|
549
|
+
return Lt(t, r, o);
|
|
550
|
+
}, zt = (t, e, n) => {
|
|
551
|
+
if (typeof t == "number" && Number.isFinite(t))
|
|
552
|
+
return t;
|
|
553
|
+
throw new Error(
|
|
554
|
+
`Floating layer "${n}" must provide a numeric "${e}" value when draggable mode is enabled.`
|
|
555
|
+
);
|
|
556
|
+
}, wt = (t) => {
|
|
557
|
+
const e = k(t);
|
|
558
|
+
if (!e)
|
|
559
|
+
throw new Error(`Floating layer "${t.id}" is missing floating configuration required for dragging.`);
|
|
560
|
+
const n = e.position ?? e.defaultPosition ?? t.position;
|
|
561
|
+
if (!n)
|
|
562
|
+
throw new Error(`Floating layer "${t.id}" must define position with left and top values.`);
|
|
563
|
+
return {
|
|
564
|
+
left: zt(n.left, "left", t.id),
|
|
565
|
+
top: zt(n.top, "top", t.id)
|
|
566
|
+
};
|
|
567
|
+
}, Me = (t) => {
|
|
568
|
+
const e = k(t);
|
|
569
|
+
return e ? e.constraints ?? {} : {};
|
|
570
|
+
}, Le = (t, e, n) => t ? t === "left" ? e - n : e + n : e, Te = (t, e, n) => t ? t === "top" ? e - n : e + n : e, Pe = (t, e, n) => !t || t === "right" ? e : e + n, xe = (t, e, n) => !t || t === "bottom" ? e : e + n, nt = (t, e) => t ? t.dataset.layerId === e ? t : nt(t.parentElement, e) : null, rt = (t, e, n) => !t || n?.(t) ? null : e(t) ? t : rt(t.parentElement, e, n), ke = (t) => t instanceof HTMLElement ? rt(
|
|
571
|
+
t,
|
|
572
|
+
(e) => e.dataset.dragHandle === "true",
|
|
573
|
+
(e) => e.dataset.dragIgnore === "true"
|
|
574
|
+
) : null, St = (t) => t instanceof HTMLElement ? rt(
|
|
575
|
+
t,
|
|
576
|
+
(e) => e.dataset.resizeCorner !== void 0 || e.dataset.resizeEdge !== void 0
|
|
577
|
+
) !== null : !1, V = (t) => {
|
|
578
|
+
const e = k(t);
|
|
579
|
+
return e ? e.resizable === !0 : !1;
|
|
580
|
+
}, K = (t) => {
|
|
581
|
+
if (!k(t))
|
|
582
|
+
return null;
|
|
583
|
+
const n = Ne(t);
|
|
584
|
+
if (!n)
|
|
585
|
+
throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);
|
|
586
|
+
return {
|
|
587
|
+
width: n.width,
|
|
588
|
+
height: n.height
|
|
589
|
+
};
|
|
590
|
+
}, He = (t, e, n) => {
|
|
591
|
+
const r = t.filter(V).reduce((g, b) => {
|
|
592
|
+
if (n === b.id) {
|
|
593
|
+
const E = e[b.id];
|
|
594
|
+
if (E)
|
|
595
|
+
return g[b.id] = E, g;
|
|
596
|
+
}
|
|
597
|
+
const C = K(b);
|
|
598
|
+
return C && (g[b.id] = C), g;
|
|
599
|
+
}, {}), o = Object.keys(e), s = Object.keys(r), l = o.length !== s.length, a = o.some((g) => !Object.prototype.hasOwnProperty.call(r, g)), u = l ? !0 : a, p = s.some((g) => {
|
|
600
|
+
const b = e[g], C = r[g];
|
|
601
|
+
return !b || !C ? !0 : b.width !== C.width || b.height !== C.height;
|
|
602
|
+
});
|
|
603
|
+
return {
|
|
604
|
+
sizes: r,
|
|
605
|
+
changed: u ? !0 : p
|
|
606
|
+
};
|
|
607
|
+
}, De = ({
|
|
608
|
+
layers: t,
|
|
609
|
+
layerById: e,
|
|
610
|
+
isRootLevel: n
|
|
611
|
+
}) => {
|
|
612
|
+
const [r, o] = d.useState(null), [s, l] = d.useState(null), [a, u] = d.useState({}), [p, f] = d.useState({}), g = d.useRef(null), b = d.useRef(null), C = ct((c, i) => {
|
|
613
|
+
e.get(c)?.floating?.onMove?.(i);
|
|
614
|
+
}), E = ct((c, i) => {
|
|
615
|
+
e.get(c)?.floating?.onResize?.(i);
|
|
616
|
+
});
|
|
617
|
+
Rt(() => {
|
|
618
|
+
const { sizes: c, changed: i } = He(t, p, s);
|
|
619
|
+
i && f(c);
|
|
620
|
+
}, [t, s]);
|
|
621
|
+
const y = d.useCallback(
|
|
622
|
+
(c, i, h, m) => {
|
|
623
|
+
const w = wt(i), R = a[c] ?? { x: 0, y: 0 }, S = {
|
|
624
|
+
pointerStartX: m.clientX,
|
|
625
|
+
pointerStartY: m.clientY,
|
|
626
|
+
initialTranslationX: R.x,
|
|
627
|
+
initialTranslationY: R.y,
|
|
628
|
+
baseLeft: w.left,
|
|
629
|
+
baseTop: w.top,
|
|
630
|
+
layerId: c,
|
|
631
|
+
pointerId: m.pointerId,
|
|
632
|
+
target: h
|
|
633
|
+
};
|
|
634
|
+
if (S.target.setPointerCapture)
|
|
635
|
+
try {
|
|
636
|
+
S.target.setPointerCapture(S.pointerId);
|
|
637
|
+
} catch {
|
|
638
|
+
}
|
|
639
|
+
g.current = S, o(c);
|
|
640
|
+
},
|
|
641
|
+
[a]
|
|
642
|
+
), T = d.useCallback(
|
|
643
|
+
(c) => {
|
|
644
|
+
const i = c.target, h = ke(i);
|
|
645
|
+
if (!h)
|
|
646
|
+
return;
|
|
647
|
+
const m = h.closest("[data-layer-id]")?.getAttribute("data-layer-id");
|
|
648
|
+
if (!m)
|
|
649
|
+
return;
|
|
650
|
+
const w = e.get(m);
|
|
651
|
+
if (!w)
|
|
652
|
+
return;
|
|
653
|
+
const R = k(w);
|
|
654
|
+
if (!(!R || R.draggable !== !0) && !pt(c.target) && !St(c.target) && h) {
|
|
655
|
+
const S = nt(h, m);
|
|
656
|
+
if (!S)
|
|
657
|
+
return;
|
|
658
|
+
y(m, w, S, c);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
},
|
|
662
|
+
[y, e]
|
|
663
|
+
), P = d.useCallback(
|
|
664
|
+
(c, i) => {
|
|
665
|
+
const h = e.get(c), m = h ? k(h) : null;
|
|
666
|
+
if (!h || !m || m.draggable !== !0 || pt(i.target) || St(i.target))
|
|
667
|
+
return;
|
|
668
|
+
const w = nt(i.currentTarget, c);
|
|
669
|
+
w && y(c, h, w, i);
|
|
670
|
+
},
|
|
671
|
+
[y, e]
|
|
672
|
+
), L = d.useCallback(
|
|
673
|
+
(c, i, h) => {
|
|
674
|
+
const m = e.get(c);
|
|
675
|
+
if (!m || !V(m))
|
|
676
|
+
return;
|
|
677
|
+
const w = p[c] ?? K(m);
|
|
678
|
+
if (!w)
|
|
679
|
+
return;
|
|
680
|
+
const R = wt(m), S = Me(m), M = a[c] ?? { x: 0, y: 0 };
|
|
681
|
+
if (h.stopPropagation(), h.preventDefault(), h.currentTarget.setPointerCapture)
|
|
682
|
+
try {
|
|
683
|
+
h.currentTarget.setPointerCapture(h.pointerId);
|
|
684
|
+
} catch {
|
|
685
|
+
}
|
|
686
|
+
b.current = {
|
|
687
|
+
layerId: c,
|
|
688
|
+
pointerId: h.pointerId,
|
|
689
|
+
horizontalEdge: i.horizontal,
|
|
690
|
+
verticalEdge: i.vertical,
|
|
691
|
+
startX: h.clientX,
|
|
692
|
+
startY: h.clientY,
|
|
693
|
+
startWidth: w.width,
|
|
694
|
+
startHeight: w.height,
|
|
695
|
+
startPosition: M,
|
|
696
|
+
baseLeft: R.left,
|
|
697
|
+
baseTop: R.top,
|
|
698
|
+
minWidth: S.minWidth,
|
|
699
|
+
maxWidth: S.maxWidth,
|
|
700
|
+
minHeight: S.minHeight,
|
|
701
|
+
maxHeight: S.maxHeight,
|
|
702
|
+
target: h.currentTarget
|
|
703
|
+
}, l(c);
|
|
704
|
+
},
|
|
705
|
+
[e, a, p]
|
|
706
|
+
), H = d.useCallback(
|
|
707
|
+
(c) => {
|
|
708
|
+
const i = g.current;
|
|
709
|
+
if (!i)
|
|
710
|
+
return;
|
|
711
|
+
const h = c.clientX - i.pointerStartX, m = c.clientY - i.pointerStartY, w = {
|
|
712
|
+
x: i.initialTranslationX + h,
|
|
713
|
+
y: i.initialTranslationY + m
|
|
714
|
+
};
|
|
715
|
+
u((R) => ({ ...R, [i.layerId]: w })), C(i.layerId, {
|
|
716
|
+
left: i.baseLeft + w.x,
|
|
717
|
+
top: i.baseTop + w.y
|
|
718
|
+
});
|
|
719
|
+
},
|
|
720
|
+
[C]
|
|
721
|
+
), G = d.useCallback(
|
|
722
|
+
(c) => {
|
|
723
|
+
const i = b.current;
|
|
724
|
+
if (!i || i.pointerId !== c.pointerId || !e.get(i.layerId))
|
|
725
|
+
return;
|
|
726
|
+
const m = c.clientX - i.startX, w = c.clientY - i.startY, R = Le(i.horizontalEdge, i.startWidth, m), S = Te(i.verticalEdge, i.startHeight, w), M = bt(R, i.minWidth, i.maxWidth), x = bt(S, i.minHeight, i.maxHeight), O = i.startWidth - M, q = i.startHeight - x, ot = Pe(
|
|
727
|
+
i.horizontalEdge,
|
|
728
|
+
i.startPosition.x,
|
|
729
|
+
O
|
|
730
|
+
), Pt = xe(i.verticalEdge, i.startPosition.y, q), J = p[i.layerId], st = { width: M, height: x };
|
|
731
|
+
(!J || J.width !== M || J.height !== x) && (f((Q) => ({
|
|
732
|
+
...Q,
|
|
733
|
+
[i.layerId]: st
|
|
734
|
+
})), E(i.layerId, st));
|
|
735
|
+
const it = a[i.layerId] ?? { x: 0, y: 0 }, Y = { x: ot, y: Pt };
|
|
736
|
+
(it.x !== Y.x || it.y !== Y.y) && (u((Q) => ({
|
|
737
|
+
...Q,
|
|
738
|
+
[i.layerId]: Y
|
|
739
|
+
})), C(i.layerId, {
|
|
740
|
+
left: i.baseLeft + Y.x,
|
|
741
|
+
top: i.baseTop + Y.y
|
|
742
|
+
}));
|
|
743
|
+
},
|
|
744
|
+
[e, a, p, C, E]
|
|
745
|
+
), D = d.useCallback((c) => {
|
|
746
|
+
const i = g.current;
|
|
747
|
+
if (i) {
|
|
748
|
+
if (i.pointerId === c.pointerId && i.target.releasePointerCapture)
|
|
749
|
+
try {
|
|
750
|
+
i.target.releasePointerCapture(i.pointerId);
|
|
751
|
+
} catch {
|
|
752
|
+
}
|
|
753
|
+
g.current = null;
|
|
754
|
+
}
|
|
755
|
+
o(null);
|
|
756
|
+
}, []), A = d.useCallback((c) => {
|
|
757
|
+
const i = b.current;
|
|
758
|
+
if (i) {
|
|
759
|
+
if (i.pointerId === c.pointerId && i.target.releasePointerCapture)
|
|
760
|
+
try {
|
|
761
|
+
i.target.releasePointerCapture(i.pointerId);
|
|
762
|
+
} catch {
|
|
763
|
+
}
|
|
764
|
+
b.current = null;
|
|
765
|
+
}
|
|
766
|
+
l(null);
|
|
767
|
+
}, []);
|
|
768
|
+
lt(r !== null, {
|
|
769
|
+
onMove: H,
|
|
770
|
+
onUp: D,
|
|
771
|
+
onCancel: D
|
|
772
|
+
}), lt(s !== null, {
|
|
773
|
+
onMove: G,
|
|
774
|
+
onUp: A,
|
|
775
|
+
onCancel: A
|
|
776
|
+
});
|
|
777
|
+
const $ = d.useCallback(
|
|
778
|
+
(c) => {
|
|
779
|
+
const i = Ee(c), h = k(c);
|
|
780
|
+
if (!h || h.draggable !== !0)
|
|
781
|
+
return i;
|
|
782
|
+
const m = a[c.id], w = r === c.id, R = s === c.id, S = m ? { transform: `translate(${m.x}px, ${m.y}px)` } : {}, M = p[c.id], x = V(c) ? K(c) : null, O = M ?? x, q = O ? { width: `${O.width}px`, height: `${O.height}px` } : {};
|
|
783
|
+
return {
|
|
784
|
+
...i,
|
|
785
|
+
...q,
|
|
786
|
+
...S,
|
|
787
|
+
...w || R ? { cursor: "grabbing" } : {}
|
|
788
|
+
};
|
|
789
|
+
},
|
|
790
|
+
[r, a, p, s]
|
|
791
|
+
), B = d.useCallback(
|
|
792
|
+
(c) => {
|
|
793
|
+
if (!V(c))
|
|
794
|
+
return { isResizable: !1 };
|
|
795
|
+
const h = p[c.id], m = K(c);
|
|
796
|
+
return (h ?? m) !== null ? { isResizable: !0, onPointerDown: (M, x) => {
|
|
797
|
+
L(c.id, M, x);
|
|
798
|
+
} } : { isResizable: !1 };
|
|
799
|
+
},
|
|
800
|
+
[L, p]
|
|
801
|
+
), F = d.useCallback(
|
|
802
|
+
(c) => {
|
|
803
|
+
const { isResizable: i, onPointerDown: h } = B(c), m = $(c), w = s === c.id;
|
|
804
|
+
return {
|
|
805
|
+
style: m,
|
|
806
|
+
isResizable: i,
|
|
807
|
+
isResizing: w,
|
|
808
|
+
onResizeHandlePointerDown: (R, S) => {
|
|
809
|
+
h && h(R, S);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
},
|
|
813
|
+
[$, B, s]
|
|
814
|
+
), v = d.useCallback(
|
|
815
|
+
(c) => ({
|
|
816
|
+
"data-drag-handle": "true",
|
|
817
|
+
role: "button",
|
|
818
|
+
"aria-roledescription": "Drag handle",
|
|
819
|
+
"aria-label": "Drag layer",
|
|
820
|
+
onPointerDown: (i) => {
|
|
821
|
+
P(c, i);
|
|
822
|
+
}
|
|
823
|
+
}),
|
|
824
|
+
[P]
|
|
825
|
+
);
|
|
826
|
+
return {
|
|
827
|
+
providerValue: d.useMemo(
|
|
828
|
+
() => ({
|
|
829
|
+
handleLayerPointerDown: T,
|
|
830
|
+
getLayerRenderState: F,
|
|
831
|
+
getLayerHandleProps: v,
|
|
832
|
+
isRootLevel: n
|
|
833
|
+
}),
|
|
834
|
+
[v, F, T, n]
|
|
835
|
+
),
|
|
836
|
+
draggingLayerId: r,
|
|
837
|
+
resizingLayerId: s
|
|
838
|
+
};
|
|
839
|
+
}, Ne = (t) => {
|
|
840
|
+
if (t.floating) {
|
|
841
|
+
const e = t.floating.size ?? t.floating.defaultSize;
|
|
842
|
+
if (e)
|
|
843
|
+
return { width: e.width, height: e.height };
|
|
844
|
+
}
|
|
845
|
+
if (typeof t.width == "number" && typeof t.height == "number")
|
|
846
|
+
return { width: t.width, height: t.height };
|
|
847
|
+
}, Tt = {
|
|
848
|
+
display: "grid",
|
|
849
|
+
width: "100%",
|
|
850
|
+
height: "100%",
|
|
851
|
+
overflow: "hidden",
|
|
852
|
+
position: "relative"
|
|
853
|
+
}, Ge = {
|
|
854
|
+
touchAction: "none",
|
|
855
|
+
WebkitTouchCallout: "none",
|
|
856
|
+
WebkitUserSelect: "none",
|
|
857
|
+
userSelect: "none"
|
|
858
|
+
}, Ae = {
|
|
859
|
+
...Tt,
|
|
860
|
+
overflow: "visible",
|
|
861
|
+
height: "auto",
|
|
862
|
+
minHeight: "100%"
|
|
863
|
+
}, $e = (t) => t ? Ae : Tt, Ze = ({ config: t, layers: e, style: n, root: r = !1 }) => {
|
|
864
|
+
const o = d.useRef(null), { isIntersecting: s } = Bt(o, { threshold: 0 });
|
|
865
|
+
return /* @__PURE__ */ z(Dt, { config: t, layers: e, style: n, children: /* @__PURE__ */ z(Nt, { children: /* @__PURE__ */ z(Fe, { gridRef: o, isIntersecting: s, isRoot: r }) }) });
|
|
866
|
+
}, Fe = ({ gridRef: t, isIntersecting: e, isRoot: n }) => {
|
|
867
|
+
const { config: r, style: o, layers: s } = vt(), { normalizedLayers: l, visibleLayers: a, regularLayers: u, layerById: p } = ne(r, s.defs), { columnHandles: f, rowHandles: g, gapSizes: b, gridStyle: C, handleResize: E } = fe(r, o, t), { providerValue: y, draggingLayerId: T, resizingLayerId: P } = De({
|
|
868
|
+
layers: l,
|
|
869
|
+
layerById: p,
|
|
870
|
+
isRootLevel: n
|
|
871
|
+
}), { setGridRef: L } = Gt();
|
|
872
|
+
d.useLayoutEffect(() => (L(t), () => {
|
|
873
|
+
L(null);
|
|
874
|
+
}), [t, L]);
|
|
875
|
+
const H = T ? !0 : !!P, G = d.useMemo(() => ({
|
|
876
|
+
...$e(n),
|
|
877
|
+
...C,
|
|
878
|
+
...H ? Ge : {}
|
|
879
|
+
}), [C, H, n]), D = d.useMemo(
|
|
880
|
+
() => a.filter((v) => v.drawer?.inline ? !at(v.drawer.animationMode) : !1),
|
|
881
|
+
[a]
|
|
882
|
+
), A = d.useMemo(
|
|
883
|
+
() => a.filter((v) => v.drawer?.inline ? at(v.drawer.animationMode) : !1),
|
|
884
|
+
[a]
|
|
885
|
+
), $ = d.useMemo(
|
|
886
|
+
() => a.filter((v) => v.drawer ? !v.drawer.inline : !1),
|
|
887
|
+
[a]
|
|
888
|
+
), B = A.length > 0, F = /* @__PURE__ */ _(
|
|
889
|
+
"div",
|
|
890
|
+
{
|
|
891
|
+
ref: t,
|
|
892
|
+
style: G,
|
|
893
|
+
"data-dragging": !!T,
|
|
894
|
+
"data-resizing": !!P,
|
|
895
|
+
"data-visible": e,
|
|
896
|
+
children: [
|
|
897
|
+
/* @__PURE__ */ z(At, { value: y, children: /* @__PURE__ */ z(Qt, { layers: u }) }),
|
|
898
|
+
f.map(({ trackIndex: v, align: N, span: c }) => /* @__PURE__ */ z(
|
|
899
|
+
gt,
|
|
900
|
+
{
|
|
901
|
+
direction: "col",
|
|
902
|
+
trackIndex: v,
|
|
903
|
+
align: N,
|
|
904
|
+
gap: b.columnGap,
|
|
905
|
+
span: c,
|
|
906
|
+
onResize: E
|
|
907
|
+
},
|
|
908
|
+
`col-${v}:${N}`
|
|
909
|
+
)),
|
|
910
|
+
g.map(({ trackIndex: v, align: N, span: c }) => /* @__PURE__ */ z(
|
|
911
|
+
gt,
|
|
912
|
+
{
|
|
913
|
+
direction: "row",
|
|
914
|
+
trackIndex: v,
|
|
915
|
+
align: N,
|
|
916
|
+
gap: b.rowGap,
|
|
917
|
+
span: c,
|
|
918
|
+
onResize: E
|
|
919
|
+
},
|
|
920
|
+
`row-${v}:${N}`
|
|
921
|
+
)),
|
|
922
|
+
/* @__PURE__ */ z(W, { layers: D })
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
);
|
|
926
|
+
return B ? /* @__PURE__ */ _(U, { children: [
|
|
927
|
+
/* @__PURE__ */ _("div", { style: { position: "relative", width: "100%", height: "100%" }, children: [
|
|
928
|
+
F,
|
|
929
|
+
/* @__PURE__ */ z(W, { layers: A })
|
|
930
|
+
] }),
|
|
931
|
+
/* @__PURE__ */ z(W, { layers: $ })
|
|
932
|
+
] }) : /* @__PURE__ */ _(U, { children: [
|
|
933
|
+
F,
|
|
934
|
+
/* @__PURE__ */ z(W, { layers: $ })
|
|
935
|
+
] });
|
|
936
|
+
};
|
|
937
|
+
export {
|
|
938
|
+
Ze as G,
|
|
939
|
+
Qt as a,
|
|
940
|
+
Ut as b,
|
|
941
|
+
gt as c,
|
|
942
|
+
fe as d,
|
|
943
|
+
Lt as e,
|
|
944
|
+
Ue as t,
|
|
945
|
+
ne as u
|
|
946
|
+
};
|
|
947
|
+
//# sourceMappingURL=GridLayout-kiWdpMLQ.js.map
|