react-panel-layout 0.4.1 → 0.4.2
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/README.md +291 -0
- package/dist/FloatingPanelFrame-SOrLGjZd.js +67 -0
- package/dist/FloatingPanelFrame-SOrLGjZd.js.map +1 -0
- package/dist/FloatingPanelFrame-XtBcHANI.cjs +2 -0
- package/dist/FloatingPanelFrame-XtBcHANI.cjs.map +1 -0
- package/dist/{GridLayout-DZCV1X-3.js → GridLayout-CLvW8jID.js} +516 -502
- package/dist/GridLayout-CLvW8jID.js.map +1 -0
- package/dist/GridLayout-qufTyOQM.cjs +2 -0
- package/dist/GridLayout-qufTyOQM.cjs.map +1 -0
- package/dist/components/pivot/PivotLayer.d.ts +14 -0
- package/dist/config/PanelContentDeclaration.d.ts +20 -0
- package/dist/config/panelRouter.d.ts +3 -1
- package/dist/config.cjs +1 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +125 -76
- package/dist/config.js.map +1 -1
- package/dist/constants/styles.d.ts +8 -0
- package/dist/floating.cjs +1 -1
- package/dist/floating.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +573 -500
- package/dist/index.js.map +1 -1
- package/dist/modules/panels/rendering/ContentRegistry.d.ts +50 -0
- package/dist/modules/panels/rendering/RenderContext.d.ts +1 -0
- package/dist/modules/panels/state/types.d.ts +2 -2
- package/dist/modules/pivot/PivotContent.d.ts +29 -0
- package/dist/modules/pivot/index.d.ts +5 -0
- package/dist/modules/pivot/types.d.ts +62 -0
- package/dist/modules/pivot/usePivot.d.ts +28 -0
- package/dist/pivot/index.d.ts +8 -0
- package/dist/pivot.cjs +2 -0
- package/dist/pivot.cjs.map +1 -0
- package/dist/pivot.js +5 -0
- package/dist/pivot.js.map +1 -0
- package/dist/styles-DcG3aIFx.cjs +2 -0
- package/dist/styles-DcG3aIFx.cjs.map +1 -0
- package/dist/styles-w0ZixggV.js +51 -0
- package/dist/styles-w0ZixggV.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/usePivot-C8q0pMgW.cjs +2 -0
- package/dist/usePivot-C8q0pMgW.cjs.map +1 -0
- package/dist/usePivot-z9gumDf-.js +97 -0
- package/dist/usePivot-z9gumDf-.js.map +1 -0
- package/package.json +6 -1
- package/dist/FloatingPanelFrame-BeP9z8EI.js +0 -98
- package/dist/FloatingPanelFrame-BeP9z8EI.js.map +0 -1
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs +0 -2
- package/dist/FloatingPanelFrame-Cu50Y9xg.cjs.map +0 -1
- package/dist/GridLayout-CwuQEP7k.cjs +0 -2
- package/dist/GridLayout-CwuQEP7k.cjs.map +0 -1
- package/dist/GridLayout-DZCV1X-3.js.map +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as G, Fragment as N, jsx as h } from "react/jsx-runtime";
|
|
2
2
|
import * as i from "react";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
3
|
+
import { F as _t, e as $t, a as Gt, b as Ft } from "./FloatingPanelFrame-SOrLGjZd.js";
|
|
4
|
+
import { C as Ot, D as Wt, m as Bt, n as Yt, o as Xt, p as Vt, q as Ut, r as jt, G as B, s as D, t as Zt, u as Kt, v as qt, R as ct, w as Jt, x as J } from "./styles-w0ZixggV.js";
|
|
5
|
+
import { createPortal as Qt } from "react-dom";
|
|
6
|
+
import { u as te, a as Rt } from "./usePivot-z9gumDf-.js";
|
|
7
|
+
const ee = () => {
|
|
6
8
|
const t = /* @__PURE__ */ new Map();
|
|
7
9
|
return (e) => {
|
|
8
10
|
if (!e)
|
|
@@ -10,24 +12,24 @@ const Kt = () => {
|
|
|
10
12
|
const n = t.get(e);
|
|
11
13
|
if (n !== void 0)
|
|
12
14
|
return n;
|
|
13
|
-
const
|
|
14
|
-
return t.set(e,
|
|
15
|
+
const r = t.size;
|
|
16
|
+
return t.set(e, r), r;
|
|
15
17
|
};
|
|
16
|
-
},
|
|
17
|
-
const e = `ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${
|
|
18
|
+
}, ne = ee(), Q = /* @__PURE__ */ new Map(), re = (t) => {
|
|
19
|
+
const e = `ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${ne(t.root)}`;
|
|
18
20
|
if (Q.has(e))
|
|
19
21
|
return Q.get(e);
|
|
20
22
|
const n = new class {
|
|
21
23
|
#t = /* @__PURE__ */ new Map();
|
|
22
|
-
#e = new IntersectionObserver((
|
|
23
|
-
|
|
24
|
-
const s = this.#t.get(
|
|
25
|
-
s && s(
|
|
24
|
+
#e = new IntersectionObserver((r) => {
|
|
25
|
+
r.forEach((o) => {
|
|
26
|
+
const s = this.#t.get(o.target);
|
|
27
|
+
s && s(o);
|
|
26
28
|
});
|
|
27
29
|
}, t);
|
|
28
|
-
observe(
|
|
29
|
-
return this.#t.set(
|
|
30
|
-
this.#t.delete(
|
|
30
|
+
observe(r, o) {
|
|
31
|
+
return this.#t.set(r, o), this.#e.observe(r), () => {
|
|
32
|
+
this.#t.delete(r), this.#e.unobserve(r);
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
35
|
}();
|
|
@@ -42,14 +44,14 @@ const Kt = () => {
|
|
|
42
44
|
bottom: 0,
|
|
43
45
|
left: 0
|
|
44
46
|
});
|
|
45
|
-
function
|
|
46
|
-
const [
|
|
47
|
+
function oe(t, { threshold: e = 0, rootMargin: n = "0px", root: r = null }) {
|
|
48
|
+
const [o, s] = i.useState(null);
|
|
47
49
|
return i.useEffect(() => {
|
|
48
50
|
const c = t.current;
|
|
49
|
-
return c ?
|
|
51
|
+
return c ? re({
|
|
50
52
|
threshold: e,
|
|
51
53
|
rootMargin: n,
|
|
52
|
-
root:
|
|
54
|
+
root: r
|
|
53
55
|
}).observe(c, (a) => {
|
|
54
56
|
s({
|
|
55
57
|
isIntersecting: a.isIntersecting,
|
|
@@ -61,21 +63,21 @@ function Qt(t, { threshold: e = 0, rootMargin: n = "0px", root: o = null }) {
|
|
|
61
63
|
time: a.time
|
|
62
64
|
});
|
|
63
65
|
}) : void 0;
|
|
64
|
-
}, [t, e, n,
|
|
65
|
-
isIntersecting:
|
|
66
|
-
boundingClientRect:
|
|
67
|
-
intersectionRatio:
|
|
68
|
-
intersectionRect:
|
|
69
|
-
rootBounds:
|
|
70
|
-
target:
|
|
71
|
-
time:
|
|
72
|
-
}), [
|
|
66
|
+
}, [t, e, n, r]), i.useMemo(() => ({
|
|
67
|
+
isIntersecting: o?.isIntersecting ?? !1,
|
|
68
|
+
boundingClientRect: o?.boundingClientRect ?? ut,
|
|
69
|
+
intersectionRatio: o?.intersectionRatio ?? 0,
|
|
70
|
+
intersectionRect: o?.intersectionRect ?? ut,
|
|
71
|
+
rootBounds: o?.rootBounds ?? null,
|
|
72
|
+
target: o?.target ?? t.current,
|
|
73
|
+
time: o?.time ?? 0
|
|
74
|
+
}), [o, t]);
|
|
73
75
|
}
|
|
74
76
|
const lt = {
|
|
75
77
|
position: "fixed",
|
|
76
78
|
inset: 0,
|
|
77
|
-
background:
|
|
78
|
-
},
|
|
79
|
+
background: Ot
|
|
80
|
+
}, se = {
|
|
79
81
|
willChange: "transform"
|
|
80
82
|
}, dt = {
|
|
81
83
|
left: {
|
|
@@ -102,41 +104,41 @@ const lt = {
|
|
|
102
104
|
right: 0,
|
|
103
105
|
transform: "translateY(100%)"
|
|
104
106
|
}
|
|
105
|
-
},
|
|
107
|
+
}, ie = (t, e, n) => t === "none" ? void 0 : `transform ${e ?? Wt} ${n ?? Bt}`, ae = (t, e) => t ? e : !1, ce = {
|
|
106
108
|
marginLeft: "auto",
|
|
107
109
|
border: "none",
|
|
108
110
|
background: "transparent",
|
|
109
111
|
cursor: "pointer",
|
|
110
|
-
fontSize:
|
|
111
|
-
},
|
|
112
|
+
fontSize: jt
|
|
113
|
+
}, ue = ({ header: t, dismissible: e, onClose: n }) => {
|
|
112
114
|
if (!t)
|
|
113
115
|
return null;
|
|
114
|
-
const
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
+
const r = t.showCloseButton ?? !0, o = ae(e, r);
|
|
117
|
+
return /* @__PURE__ */ h(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ G(
|
|
116
118
|
Gt,
|
|
117
119
|
{
|
|
118
|
-
style: { padding: `${
|
|
120
|
+
style: { padding: `${Vt} ${Ut}`, gap: Xt },
|
|
119
121
|
children: [
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ h(i.Activity, { mode: t ? "visible" : "hidden", children: /* @__PURE__ */ h(Ft, { children: t.title }) }),
|
|
123
|
+
/* @__PURE__ */ h(i.Activity, { mode: o ? "visible" : "hidden", children: /* @__PURE__ */ h("button", { style: ce, onClick: n, "aria-label": "Close drawer", type: "button", children: "×" }) })
|
|
122
124
|
]
|
|
123
125
|
}
|
|
124
126
|
) });
|
|
125
|
-
},
|
|
126
|
-
/* @__PURE__ */
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
127
|
+
}, le = ({ header: t, dismissible: e, onClose: n, chrome: r, children: o }) => r ? /* @__PURE__ */ G(_t, { style: { height: "100%", borderRadius: 0 }, children: [
|
|
128
|
+
/* @__PURE__ */ h(ue, { header: t, dismissible: e, onClose: n }),
|
|
129
|
+
/* @__PURE__ */ h(
|
|
130
|
+
$t,
|
|
129
131
|
{
|
|
130
|
-
style: { padding:
|
|
131
|
-
children:
|
|
132
|
+
style: { padding: Yt, flex: 1, display: "flex", flexDirection: "column" },
|
|
133
|
+
children: o
|
|
132
134
|
}
|
|
133
135
|
)
|
|
134
|
-
] }) : /* @__PURE__ */
|
|
136
|
+
] }) : /* @__PURE__ */ h(N, { children: o }), de = ({
|
|
135
137
|
id: t,
|
|
136
138
|
config: e,
|
|
137
139
|
isOpen: n,
|
|
138
|
-
onClose:
|
|
139
|
-
children:
|
|
140
|
+
onClose: r,
|
|
141
|
+
children: o,
|
|
140
142
|
zIndex: s,
|
|
141
143
|
width: c,
|
|
142
144
|
height: u,
|
|
@@ -144,28 +146,28 @@ const lt = {
|
|
|
144
146
|
}) => {
|
|
145
147
|
const {
|
|
146
148
|
dismissible: d = !0,
|
|
147
|
-
header:
|
|
149
|
+
header: g,
|
|
148
150
|
chrome: f = !0,
|
|
149
|
-
inline:
|
|
151
|
+
inline: m = !1,
|
|
150
152
|
transitionMode: w = "css",
|
|
151
153
|
transitionDuration: E,
|
|
152
154
|
transitionEasing: z
|
|
153
|
-
} = e,
|
|
155
|
+
} = e, L = i.useCallback((y) => y ? y.left !== void 0 ? "left" : y.right !== void 0 ? "right" : y.top !== void 0 ? "top" : y.bottom !== void 0 ? "bottom" : "right" : "right", [])(a), F = {
|
|
154
156
|
left: "translateX(0)",
|
|
155
157
|
right: "translateX(0)",
|
|
156
158
|
top: "translateY(0)",
|
|
157
159
|
bottom: "translateY(0)"
|
|
158
160
|
}, T = i.useMemo(() => {
|
|
159
|
-
const y =
|
|
160
|
-
...
|
|
161
|
-
...
|
|
162
|
-
...dt[
|
|
163
|
-
transform: n ? F[
|
|
161
|
+
const y = ie(w, E, z), I = {
|
|
162
|
+
...se,
|
|
163
|
+
...m ? { position: "absolute" } : { position: "fixed" },
|
|
164
|
+
...dt[L],
|
|
165
|
+
transform: n ? F[L] : dt[L].transform,
|
|
164
166
|
transition: y
|
|
165
167
|
};
|
|
166
168
|
return s !== void 0 && (I.zIndex = s), c !== void 0 && (I.width = typeof c == "number" ? `${c}px` : c), u !== void 0 && (I.height = typeof u == "number" ? `${u}px` : u), I;
|
|
167
|
-
}, [u,
|
|
168
|
-
const y =
|
|
169
|
+
}, [u, m, n, L, E, z, w, c, s]), M = g?.title ?? e.ariaLabel ?? "Drawer", k = i.useMemo(() => {
|
|
170
|
+
const y = m ? { ...lt, position: "absolute" } : lt, I = w === "none" ? void 0 : `opacity ${E ?? "220ms"} ease`;
|
|
169
171
|
return {
|
|
170
172
|
...y,
|
|
171
173
|
opacity: n ? 1 : 0,
|
|
@@ -173,139 +175,139 @@ const lt = {
|
|
|
173
175
|
transition: I,
|
|
174
176
|
zIndex: s !== void 0 ? s - 1 : void 0
|
|
175
177
|
};
|
|
176
|
-
}, [
|
|
177
|
-
return /* @__PURE__ */
|
|
178
|
-
/* @__PURE__ */
|
|
179
|
-
/* @__PURE__ */
|
|
178
|
+
}, [m, n, E, w, s]);
|
|
179
|
+
return /* @__PURE__ */ G(N, { children: [
|
|
180
|
+
/* @__PURE__ */ h("div", { style: k, onClick: d ? r : void 0 }),
|
|
181
|
+
/* @__PURE__ */ h(
|
|
180
182
|
"div",
|
|
181
183
|
{
|
|
182
184
|
"data-layer-id": t,
|
|
183
|
-
"data-placement":
|
|
185
|
+
"data-placement": L,
|
|
184
186
|
style: T,
|
|
185
187
|
role: "dialog",
|
|
186
188
|
"aria-modal": d ? !0 : void 0,
|
|
187
189
|
"aria-hidden": n ? void 0 : !0,
|
|
188
|
-
"aria-label":
|
|
189
|
-
children: /* @__PURE__ */
|
|
190
|
+
"aria-label": M,
|
|
191
|
+
children: /* @__PURE__ */ h(le, { header: g, dismissible: d, onClose: r, chrome: f, children: o })
|
|
190
192
|
}
|
|
191
193
|
)
|
|
192
194
|
] });
|
|
193
|
-
},
|
|
194
|
-
let
|
|
195
|
-
const
|
|
196
|
-
|
|
195
|
+
}, fe = (t, e) => new Promise((n) => {
|
|
196
|
+
let r = !1;
|
|
197
|
+
const o = () => {
|
|
198
|
+
r || (r = !0, t.removeEventListener("transitionend", s), n());
|
|
197
199
|
}, s = (c) => {
|
|
198
|
-
c.target === t &&
|
|
200
|
+
c.target === t && o();
|
|
199
201
|
};
|
|
200
|
-
t.addEventListener("transitionend", s), setTimeout(
|
|
201
|
-
}),
|
|
202
|
+
t.addEventListener("transitionend", s), setTimeout(o, e + 50);
|
|
203
|
+
}), Pt = async (t, e, n, r) => {
|
|
202
204
|
switch (e) {
|
|
203
205
|
case "none":
|
|
204
206
|
t();
|
|
205
207
|
return;
|
|
206
208
|
case "css":
|
|
207
|
-
t(), n && await
|
|
209
|
+
t(), n && await fe(n, r);
|
|
208
210
|
return;
|
|
209
211
|
}
|
|
210
|
-
},
|
|
211
|
-
const [e, n] = i.useState({}),
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
async (a, d,
|
|
215
|
-
const { mode: f = "none", element:
|
|
216
|
-
await
|
|
212
|
+
}, kn = (t) => {
|
|
213
|
+
const [e, n] = i.useState({}), r = i.useRef(t);
|
|
214
|
+
r.current = t;
|
|
215
|
+
const o = i.useCallback(
|
|
216
|
+
async (a, d, g) => {
|
|
217
|
+
const { mode: f = "none", element: m, duration: w = 300 } = g ?? {};
|
|
218
|
+
await Pt(() => {
|
|
217
219
|
n((P) => P[a] === d ? P : { ...P, [a]: d });
|
|
218
|
-
}, f,
|
|
219
|
-
const z =
|
|
220
|
+
}, f, m?.current, w);
|
|
221
|
+
const z = r.current;
|
|
220
222
|
d ? z?.onOpen?.(a) : z?.onClose?.(a), z?.onTransitionEnd?.(a, d);
|
|
221
223
|
},
|
|
222
224
|
[]
|
|
223
225
|
), s = i.useCallback((a) => e[a] ?? !1, [e]), c = i.useCallback(
|
|
224
|
-
(a, d) =>
|
|
225
|
-
[
|
|
226
|
+
(a, d) => o(a, !0, d),
|
|
227
|
+
[o]
|
|
226
228
|
), u = i.useCallback(
|
|
227
|
-
(a, d) =>
|
|
228
|
-
[
|
|
229
|
+
(a, d) => o(a, !1, d),
|
|
230
|
+
[o]
|
|
229
231
|
);
|
|
230
232
|
return { state: s, open: c, close: u };
|
|
231
|
-
},
|
|
233
|
+
}, pe = (t) => {
|
|
232
234
|
if (!t)
|
|
233
235
|
return 300;
|
|
234
236
|
const e = t.match(/(\d+)/);
|
|
235
237
|
return e ? parseInt(e[1], 10) : 300;
|
|
236
|
-
},
|
|
238
|
+
}, ge = (t) => {
|
|
237
239
|
const [e, n] = i.useState(() => {
|
|
238
240
|
const a = {};
|
|
239
241
|
return t.forEach((d) => {
|
|
240
242
|
d.drawer && (a[d.id] = d.drawer.defaultOpen ?? !1);
|
|
241
243
|
}), a;
|
|
242
|
-
}),
|
|
244
|
+
}), r = i.useMemo(() => {
|
|
243
245
|
const a = /* @__PURE__ */ new Map();
|
|
244
246
|
return t.forEach((d) => a.set(d.id, d)), a;
|
|
245
|
-
}, [t]),
|
|
246
|
-
async (a, d,
|
|
247
|
-
const f =
|
|
247
|
+
}, [t]), o = i.useCallback(
|
|
248
|
+
async (a, d, g) => {
|
|
249
|
+
const f = r.get(a);
|
|
248
250
|
if (!f?.drawer)
|
|
249
251
|
return;
|
|
250
|
-
const
|
|
251
|
-
await
|
|
252
|
+
const m = g?.mode ?? f.drawer.transitionMode ?? "css", w = g?.duration ?? pe(f.drawer.transitionDuration), E = g?.element?.current;
|
|
253
|
+
await Pt(() => {
|
|
252
254
|
f.drawer?.open === void 0 && n((P) => P[a] === d ? P : { ...P, [a]: d }), f.drawer?.onStateChange?.(d);
|
|
253
|
-
},
|
|
255
|
+
}, m, E, w);
|
|
254
256
|
},
|
|
255
|
-
[
|
|
257
|
+
[r]
|
|
256
258
|
), s = i.useCallback(
|
|
257
259
|
(a) => {
|
|
258
|
-
const d =
|
|
260
|
+
const d = r.get(a);
|
|
259
261
|
return d?.drawer?.open !== void 0 ? d.drawer.open : e[a] ?? !1;
|
|
260
262
|
},
|
|
261
|
-
[
|
|
263
|
+
[r, e]
|
|
262
264
|
), c = i.useCallback(
|
|
263
|
-
(a, d) =>
|
|
264
|
-
[
|
|
265
|
+
(a, d) => o(a, !0, d),
|
|
266
|
+
[o]
|
|
265
267
|
), u = i.useCallback(
|
|
266
|
-
(a, d) =>
|
|
267
|
-
[
|
|
268
|
+
(a, d) => o(a, !1, d),
|
|
269
|
+
[o]
|
|
268
270
|
);
|
|
269
271
|
return { state: s, open: c, close: u };
|
|
270
|
-
},
|
|
271
|
-
const e =
|
|
272
|
-
const
|
|
272
|
+
}, he = ({ layers: t }) => {
|
|
273
|
+
const e = ge(t), n = i.useMemo(() => t.filter((o) => o.drawer), [t]), r = i.useMemo(() => {
|
|
274
|
+
const o = /* @__PURE__ */ new Map();
|
|
273
275
|
return n.forEach((s) => {
|
|
274
|
-
|
|
275
|
-
}),
|
|
276
|
+
o.set(s.id, () => e.close(s.id));
|
|
277
|
+
}), o;
|
|
276
278
|
}, [n, e.close]);
|
|
277
|
-
return /* @__PURE__ */
|
|
278
|
-
if (!
|
|
279
|
+
return /* @__PURE__ */ h(N, { children: n.map((o) => {
|
|
280
|
+
if (!o.drawer)
|
|
279
281
|
return null;
|
|
280
|
-
const s = e.state(
|
|
281
|
-
return c ? /* @__PURE__ */
|
|
282
|
-
|
|
282
|
+
const s = e.state(o.id), c = r.get(o.id);
|
|
283
|
+
return c ? /* @__PURE__ */ h(
|
|
284
|
+
de,
|
|
283
285
|
{
|
|
284
|
-
id:
|
|
285
|
-
config:
|
|
286
|
+
id: o.id,
|
|
287
|
+
config: o.drawer,
|
|
286
288
|
isOpen: s,
|
|
287
289
|
onClose: c,
|
|
288
|
-
zIndex:
|
|
289
|
-
width:
|
|
290
|
-
height:
|
|
291
|
-
position:
|
|
292
|
-
children:
|
|
290
|
+
zIndex: o.zIndex,
|
|
291
|
+
width: o.width,
|
|
292
|
+
height: o.height,
|
|
293
|
+
position: o.position,
|
|
294
|
+
children: o.component
|
|
293
295
|
},
|
|
294
|
-
|
|
296
|
+
o.id
|
|
295
297
|
) : null;
|
|
296
298
|
}) });
|
|
297
|
-
},
|
|
298
|
-
const t = i.useContext(
|
|
299
|
+
}, yt = i.createContext(null), me = ({ value: t, children: e }) => /* @__PURE__ */ h(yt.Provider, { value: t, children: e }), Lt = () => {
|
|
300
|
+
const t = i.useContext(yt);
|
|
299
301
|
if (!t)
|
|
300
302
|
throw new Error("useGridLayoutContext must be used within a GridLayoutProvider.");
|
|
301
303
|
return t;
|
|
302
|
-
},
|
|
303
|
-
const t = i.useContext(
|
|
304
|
+
}, Mt = i.createContext(null), be = () => {
|
|
305
|
+
const t = i.useContext(Mt);
|
|
304
306
|
if (!t)
|
|
305
307
|
throw new Error("usePanelSystem must be used within a PanelSystemProvider.");
|
|
306
308
|
return t;
|
|
307
|
-
},
|
|
308
|
-
const
|
|
309
|
+
}, we = ({ config: t, layers: e, style: n, children: r }) => {
|
|
310
|
+
const o = i.useMemo(() => {
|
|
309
311
|
const c = /* @__PURE__ */ new Map();
|
|
310
312
|
return e.forEach((u) => {
|
|
311
313
|
c.set(u.id, u);
|
|
@@ -316,16 +318,16 @@ const lt = {
|
|
|
316
318
|
style: n,
|
|
317
319
|
layers: {
|
|
318
320
|
defs: e,
|
|
319
|
-
layerById:
|
|
321
|
+
layerById: o
|
|
320
322
|
}
|
|
321
323
|
}),
|
|
322
|
-
[t, n, e,
|
|
324
|
+
[t, n, e, o]
|
|
323
325
|
);
|
|
324
|
-
return /* @__PURE__ */
|
|
325
|
-
}, Dt = i.createContext(null),
|
|
326
|
+
return /* @__PURE__ */ h(Mt.Provider, { value: s, children: r });
|
|
327
|
+
}, Dt = i.createContext(null), Tt = ({ layerId: t, children: e }) => {
|
|
326
328
|
const n = i.useMemo(() => ({ layerId: t }), [t]);
|
|
327
|
-
return /* @__PURE__ */
|
|
328
|
-
},
|
|
329
|
+
return /* @__PURE__ */ h(Dt.Provider, { value: n, children: e });
|
|
330
|
+
}, An = () => {
|
|
329
331
|
const t = i.useContext(Dt);
|
|
330
332
|
if (!t)
|
|
331
333
|
throw new Error("useLayerInstance must be used within a LayerInstanceProvider.");
|
|
@@ -334,43 +336,43 @@ const lt = {
|
|
|
334
336
|
if (typeof t == "number" && Number.isFinite(t))
|
|
335
337
|
return t;
|
|
336
338
|
throw new Error(`Popup layer "${n}" requires a numeric "${e}" value.`);
|
|
337
|
-
},
|
|
339
|
+
}, It = (t, e) => {
|
|
338
340
|
if (!t)
|
|
339
341
|
throw new Error(`Popup layer "${e}" must define position (left/top).`);
|
|
340
342
|
return {
|
|
341
343
|
left: ft(t.left, "left", e),
|
|
342
344
|
top: ft(t.top, "top", e)
|
|
343
345
|
};
|
|
344
|
-
}, Y = (t) => `${Math.round(t)}`,
|
|
346
|
+
}, Y = (t) => `${Math.round(t)}`, _ = (t) => {
|
|
345
347
|
if (t !== void 0)
|
|
346
348
|
return t ? "yes" : "no";
|
|
347
|
-
},
|
|
348
|
-
const s = {}, c =
|
|
349
|
-
if (typeof n != "number" || typeof
|
|
349
|
+
}, ve = (t, e, n, r, o) => {
|
|
350
|
+
const s = {}, c = It(e, t);
|
|
351
|
+
if (typeof n != "number" || typeof r != "number")
|
|
350
352
|
throw new Error(`Popup layer "${t}" requires numeric width/height.`);
|
|
351
|
-
s.width = Y(n), s.height = Y(
|
|
352
|
-
const u =
|
|
353
|
+
s.width = Y(n), s.height = Y(r), s.left = Y(c.left), s.top = Y(c.top);
|
|
354
|
+
const u = o?.features;
|
|
353
355
|
if (u) {
|
|
354
|
-
const a =
|
|
355
|
-
a !== void 0 && (s.toolbar = a), d !== void 0 && (s.menubar = d),
|
|
356
|
+
const a = _(u.toolbar), d = _(u.menubar), g = _(u.location), f = _(u.status), m = _(u.resizable), w = _(u.scrollbars);
|
|
357
|
+
a !== void 0 && (s.toolbar = a), d !== void 0 && (s.menubar = d), g !== void 0 && (s.location = g), f !== void 0 && (s.status = f), m !== void 0 && (s.resizable = m), w !== void 0 && (s.scrollbars = w);
|
|
356
358
|
}
|
|
357
359
|
return Object.entries(s).map(([a, d]) => `${a}=${d}`).join(",");
|
|
358
|
-
}, pt = (t, e, n,
|
|
359
|
-
const s =
|
|
360
|
-
if (typeof
|
|
360
|
+
}, pt = (t, e, n, r, o) => {
|
|
361
|
+
const s = It(n, e);
|
|
362
|
+
if (typeof r != "number" || typeof o != "number")
|
|
361
363
|
throw new Error(`Popup layer "${e}" requires numeric width/height.`);
|
|
362
|
-
t.moveTo(Math.round(s.left), Math.round(s.top)), t.resizeTo(Math.round(
|
|
363
|
-
},
|
|
364
|
+
t.moveTo(Math.round(s.left), Math.round(s.top)), t.resizeTo(Math.round(r), Math.round(o));
|
|
365
|
+
}, Ee = ({ layer: t }) => {
|
|
364
366
|
const e = t.floating;
|
|
365
367
|
if (!e)
|
|
366
368
|
throw new Error(`Layer "${t.id}" is missing floating configuration required for popup mode.`);
|
|
367
369
|
if ((e.mode ?? "embedded") !== "popup")
|
|
368
370
|
throw new Error(`PopupLayerPortal received layer "${t.id}" that is not configured for popup mode.`);
|
|
369
|
-
const
|
|
371
|
+
const r = i.useRef(null), o = i.useRef(null), [s, c] = i.useState(!1);
|
|
370
372
|
return i.useEffect(() => {
|
|
371
373
|
if (typeof window > "u")
|
|
372
374
|
return;
|
|
373
|
-
const u =
|
|
375
|
+
const u = ve(t.id, t.position, t.width, t.height, e.popup), a = e.popup?.name ?? t.id, d = Se(
|
|
374
376
|
a,
|
|
375
377
|
u,
|
|
376
378
|
{
|
|
@@ -381,15 +383,15 @@ const lt = {
|
|
|
381
383
|
);
|
|
382
384
|
if (!d)
|
|
383
385
|
throw new Error(`Failed to open popup window for layer "${t.id}".`);
|
|
384
|
-
const
|
|
385
|
-
|
|
386
|
-
const f =
|
|
387
|
-
f.dataset.layerId = t.id,
|
|
388
|
-
const
|
|
389
|
-
|
|
386
|
+
const g = d;
|
|
387
|
+
o.current = g, e.popup?.focus !== !1 && g.focus(), g.document.title || (g.document.title = t.id), g.document.body.innerHTML = "";
|
|
388
|
+
const f = g.document.createElement("div");
|
|
389
|
+
f.dataset.layerId = t.id, g.document.body.appendChild(f), r.current = f, c(!0), pt(g, t.id, t.position, t.width, t.height);
|
|
390
|
+
const m = () => {
|
|
391
|
+
o.current = null, r.current = null, c(!1);
|
|
390
392
|
};
|
|
391
|
-
return
|
|
392
|
-
|
|
393
|
+
return g.addEventListener("beforeunload", m), () => {
|
|
394
|
+
g.removeEventListener("beforeunload", m), e.popup?.closeOnUnmount !== !1 && g.close(), o.current = null, r.current = null, c(!1);
|
|
393
395
|
};
|
|
394
396
|
}, [
|
|
395
397
|
e.popup?.closeOnUnmount,
|
|
@@ -403,27 +405,27 @@ const lt = {
|
|
|
403
405
|
e.popup?.name,
|
|
404
406
|
t.id
|
|
405
407
|
]), i.useEffect(() => {
|
|
406
|
-
const u =
|
|
408
|
+
const u = o.current;
|
|
407
409
|
u && pt(u, t.id, t.position, t.width, t.height);
|
|
408
|
-
}, [t.position?.left, t.position?.top, t.height, t.width, t.id]), !s || !
|
|
409
|
-
},
|
|
410
|
-
const
|
|
411
|
-
return
|
|
412
|
-
},
|
|
410
|
+
}, [t.position?.left, t.position?.top, t.height, t.width, t.id]), !s || !r.current ? null : Qt(/* @__PURE__ */ h(Tt, { layerId: t.id, children: t.component }), r.current);
|
|
411
|
+
}, Se = (t, e, n, r) => {
|
|
412
|
+
const o = r?.createWindow;
|
|
413
|
+
return o ? o({ name: t, features: e, bounds: n }) : window.open("", t, e);
|
|
414
|
+
}, xt = {
|
|
413
415
|
position: "absolute",
|
|
414
416
|
pointerEvents: "auto",
|
|
415
417
|
boxSizing: "border-box",
|
|
416
418
|
background: "transparent",
|
|
417
419
|
border: "none"
|
|
418
|
-
},
|
|
419
|
-
...
|
|
420
|
-
width:
|
|
421
|
-
height:
|
|
420
|
+
}, Ce = {
|
|
421
|
+
...xt,
|
|
422
|
+
width: D,
|
|
423
|
+
height: D,
|
|
422
424
|
zIndex: 2
|
|
423
|
-
},
|
|
424
|
-
...
|
|
425
|
+
}, ze = {
|
|
426
|
+
...xt,
|
|
425
427
|
zIndex: 1
|
|
426
|
-
},
|
|
428
|
+
}, Re = {
|
|
427
429
|
"top-left": {
|
|
428
430
|
top: 0,
|
|
429
431
|
left: 0,
|
|
@@ -448,40 +450,40 @@ const lt = {
|
|
|
448
450
|
transform: "translate(50%, 50%)",
|
|
449
451
|
cursor: "nwse-resize"
|
|
450
452
|
}
|
|
451
|
-
},
|
|
453
|
+
}, Pe = {
|
|
452
454
|
left: {
|
|
453
|
-
top:
|
|
454
|
-
bottom:
|
|
455
|
+
top: D,
|
|
456
|
+
bottom: D,
|
|
455
457
|
left: 0,
|
|
456
458
|
width: B,
|
|
457
459
|
transform: "translateX(-50%)",
|
|
458
460
|
cursor: "ew-resize"
|
|
459
461
|
},
|
|
460
462
|
right: {
|
|
461
|
-
top:
|
|
462
|
-
bottom:
|
|
463
|
+
top: D,
|
|
464
|
+
bottom: D,
|
|
463
465
|
right: 0,
|
|
464
466
|
width: B,
|
|
465
467
|
transform: "translateX(50%)",
|
|
466
468
|
cursor: "ew-resize"
|
|
467
469
|
},
|
|
468
470
|
top: {
|
|
469
|
-
left:
|
|
470
|
-
right:
|
|
471
|
+
left: D,
|
|
472
|
+
right: D,
|
|
471
473
|
top: 0,
|
|
472
474
|
height: B,
|
|
473
475
|
transform: "translateY(-50%)",
|
|
474
476
|
cursor: "ns-resize"
|
|
475
477
|
},
|
|
476
478
|
bottom: {
|
|
477
|
-
left:
|
|
478
|
-
right:
|
|
479
|
+
left: D,
|
|
480
|
+
right: D,
|
|
479
481
|
bottom: 0,
|
|
480
482
|
height: B,
|
|
481
483
|
transform: "translateY(50%)",
|
|
482
484
|
cursor: "ns-resize"
|
|
483
485
|
}
|
|
484
|
-
},
|
|
486
|
+
}, ye = [
|
|
485
487
|
{ key: "top-left", variant: "corner", horizontal: "left", vertical: "top" },
|
|
486
488
|
{ key: "top-right", variant: "corner", horizontal: "right", vertical: "top" },
|
|
487
489
|
{ key: "bottom-left", variant: "corner", horizontal: "left", vertical: "bottom" },
|
|
@@ -490,9 +492,9 @@ const lt = {
|
|
|
490
492
|
{ key: "right", variant: "edge", horizontal: "right" },
|
|
491
493
|
{ key: "top", variant: "edge", vertical: "top" },
|
|
492
494
|
{ key: "bottom", variant: "edge", vertical: "bottom" }
|
|
493
|
-
],
|
|
494
|
-
const
|
|
495
|
-
return /* @__PURE__ */
|
|
495
|
+
], Le = ({ layerId: t, onPointerDown: e }) => /* @__PURE__ */ h(N, { children: ye.map((n) => {
|
|
496
|
+
const r = n.variant === "corner" ? Ce : ze, o = n.variant === "corner" ? Re[n.key] : Pe[n.key], s = { ...r, ...o }, c = n.variant === "corner" ? { "data-resize-corner": n.key } : { "data-resize-edge": n.key };
|
|
497
|
+
return /* @__PURE__ */ h(
|
|
496
498
|
"div",
|
|
497
499
|
{
|
|
498
500
|
role: "presentation",
|
|
@@ -504,140 +506,153 @@ const lt = {
|
|
|
504
506
|
},
|
|
505
507
|
n.key
|
|
506
508
|
);
|
|
507
|
-
}) }),
|
|
508
|
-
const {
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
509
|
+
}) }), Me = ({ pivot: t }) => {
|
|
510
|
+
const { Outlet: e } = te({
|
|
511
|
+
items: t.items,
|
|
512
|
+
activeId: t.activeId,
|
|
513
|
+
defaultActiveId: t.defaultActiveId,
|
|
514
|
+
onActiveChange: t.onActiveChange,
|
|
515
|
+
transitionMode: t.transitionMode
|
|
516
|
+
});
|
|
517
|
+
return /* @__PURE__ */ h(e, {});
|
|
518
|
+
}, kt = i.memo(({ layer: t }) => t.pivot ? /* @__PURE__ */ h(Me, { pivot: t.pivot }) : /* @__PURE__ */ h(N, { children: t.component }));
|
|
519
|
+
kt.displayName = "LayerContent";
|
|
520
|
+
const At = i.memo(({ layerId: t, isResizable: e, onPointerDown: n }) => e ? /* @__PURE__ */ h(Le, { layerId: t, onPointerDown: n }) : null);
|
|
521
|
+
At.displayName = "LayerResizeHandles";
|
|
522
|
+
const Ht = i.memo(({ layer: t, handleLayerPointerDown: e }) => {
|
|
523
|
+
const { getLayerRenderState: n } = Lt(), { style: r, isResizable: o, isResizing: s, onResizeHandlePointerDown: c } = n(t), u = i.useMemo(() => {
|
|
524
|
+
const d = {};
|
|
525
|
+
return t.gridArea && (d.gridArea = t.gridArea), t.gridRow && (d.gridRow = t.gridRow), t.gridColumn && (d.gridColumn = t.gridColumn), d;
|
|
526
|
+
}, [t.gridArea, t.gridRow, t.gridColumn]), a = i.useMemo(() => {
|
|
527
|
+
const d = { ...r, ...u };
|
|
528
|
+
return o ? { ...d, position: "relative" } : d;
|
|
529
|
+
}, [r, u, o]);
|
|
530
|
+
return /* @__PURE__ */ G(
|
|
531
|
+
"div",
|
|
532
|
+
{
|
|
533
|
+
"data-layer-id": t.id,
|
|
534
|
+
"data-draggable": !!t.floating?.draggable,
|
|
535
|
+
"data-resizable": o,
|
|
536
|
+
"data-resizing": s,
|
|
537
|
+
style: a,
|
|
538
|
+
onPointerDown: e,
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ h(Tt, { layerId: t.id, children: /* @__PURE__ */ h(kt, { layer: t }) }),
|
|
541
|
+
/* @__PURE__ */ h(At, { layerId: t.id, isResizable: o, onPointerDown: c })
|
|
542
|
+
]
|
|
543
|
+
}
|
|
544
|
+
);
|
|
545
|
+
});
|
|
546
|
+
Ht.displayName = "EmbeddedLayer";
|
|
547
|
+
const De = ({ layers: t }) => {
|
|
548
|
+
const { handleLayerPointerDown: e } = Lt();
|
|
549
|
+
return /* @__PURE__ */ h(N, { children: t.map((n) => {
|
|
550
|
+
const r = n.floating?.mode ?? "embedded";
|
|
551
|
+
return n.floating && r === "popup" ? /* @__PURE__ */ h(Ee, { layer: n }, n.id) : /* @__PURE__ */ h(Ht, { layer: n, handleLayerPointerDown: e }, n.id);
|
|
537
552
|
}) });
|
|
538
553
|
};
|
|
539
|
-
function
|
|
554
|
+
function $(t) {
|
|
540
555
|
const e = i.useRef(t);
|
|
541
556
|
return e.current = t, i.useCallback((...n) => {
|
|
542
|
-
const
|
|
543
|
-
if (
|
|
544
|
-
return
|
|
557
|
+
const r = e.current;
|
|
558
|
+
if (r)
|
|
559
|
+
return r(...n);
|
|
545
560
|
}, []);
|
|
546
561
|
}
|
|
547
562
|
function tt(t, e) {
|
|
548
|
-
const n =
|
|
563
|
+
const n = $(e.onMove), r = $(e.onUp), o = $(e.onCancel);
|
|
549
564
|
i.useEffect(() => {
|
|
550
565
|
if (t)
|
|
551
|
-
return e.onMove && document.addEventListener("pointermove", n, { passive: !1 }), e.onUp && document.addEventListener("pointerup",
|
|
552
|
-
e.onMove && document.removeEventListener("pointermove", n), e.onUp && document.removeEventListener("pointerup",
|
|
566
|
+
return e.onMove && document.addEventListener("pointermove", n, { passive: !1 }), e.onUp && document.addEventListener("pointerup", r), e.onCancel && document.addEventListener("pointercancel", o), () => {
|
|
567
|
+
e.onMove && document.removeEventListener("pointermove", n), e.onUp && document.removeEventListener("pointerup", r), e.onCancel && document.removeEventListener("pointercancel", o);
|
|
553
568
|
};
|
|
554
|
-
}, [t, e.onMove, e.onUp, e.onCancel, n,
|
|
569
|
+
}, [t, e.onMove, e.onUp, e.onCancel, n, r, o]);
|
|
555
570
|
}
|
|
556
|
-
function
|
|
571
|
+
function Te(t, e, n) {
|
|
557
572
|
i.useEffect(() => {
|
|
558
|
-
const
|
|
559
|
-
if (!(!e || !
|
|
560
|
-
return
|
|
561
|
-
|
|
573
|
+
const r = t.current;
|
|
574
|
+
if (!(!e || !r || n === void 0))
|
|
575
|
+
return r.setPointerCapture(n), () => {
|
|
576
|
+
r.hasPointerCapture && r.hasPointerCapture(n) && r.releasePointerCapture(n);
|
|
562
577
|
};
|
|
563
578
|
}, [t, e, n]);
|
|
564
579
|
}
|
|
565
|
-
function
|
|
580
|
+
function Ie(t, e, n = ["pointerdown", "pointermove", "pointerup"]) {
|
|
566
581
|
i.useEffect(() => {
|
|
567
|
-
const
|
|
568
|
-
if (!e || !
|
|
582
|
+
const r = t.current;
|
|
583
|
+
if (!e || !r)
|
|
569
584
|
return;
|
|
570
|
-
const
|
|
585
|
+
const o = (s) => {
|
|
571
586
|
s.preventDefault();
|
|
572
587
|
};
|
|
573
588
|
return n.forEach((s) => {
|
|
574
|
-
|
|
589
|
+
r.addEventListener(s, o, { passive: !1 });
|
|
575
590
|
}), () => {
|
|
576
591
|
n.forEach((s) => {
|
|
577
|
-
|
|
592
|
+
r.removeEventListener(s, o);
|
|
578
593
|
});
|
|
579
594
|
};
|
|
580
595
|
}, [t, e, n]);
|
|
581
596
|
}
|
|
582
|
-
function
|
|
583
|
-
const { onMove:
|
|
584
|
-
tt(e, { onMove:
|
|
597
|
+
function xe(t, e, n) {
|
|
598
|
+
const { onMove: r, onUp: o, onCancel: s, pointerId: c, capturePointer: u = !0, preventDefaults: a = !0 } = n;
|
|
599
|
+
tt(e, { onMove: r, onUp: o, onCancel: s }), Te(t, e ? u : !1, c), Ie(t, e ? a : !1);
|
|
585
600
|
}
|
|
586
|
-
const
|
|
587
|
-
const e = i.useRef(null), n = i.useRef(null),
|
|
601
|
+
const ke = (t) => {
|
|
602
|
+
const e = i.useRef(null), n = i.useRef(null), r = i.useRef(0), [o, s] = i.useState(!1), c = $((f) => {
|
|
588
603
|
t.onResize?.(f);
|
|
589
604
|
}), u = i.useCallback(
|
|
590
605
|
(f) => t.axis === "x" ? f.clientX : f.clientY,
|
|
591
606
|
[t.axis]
|
|
592
607
|
), a = i.useCallback(
|
|
593
608
|
(f) => {
|
|
594
|
-
f.preventDefault(), e.current = f.currentTarget, n.current = f.pointerId,
|
|
609
|
+
f.preventDefault(), e.current = f.currentTarget, n.current = f.pointerId, r.current = u(f), s(!0);
|
|
595
610
|
},
|
|
596
611
|
[u]
|
|
597
612
|
), d = i.useCallback(
|
|
598
613
|
(f) => {
|
|
599
|
-
const
|
|
600
|
-
w !== 0 && (
|
|
614
|
+
const m = u(f), w = m - r.current;
|
|
615
|
+
w !== 0 && (r.current = m, c(w));
|
|
601
616
|
},
|
|
602
617
|
[u, c]
|
|
603
|
-
),
|
|
618
|
+
), g = i.useCallback(() => {
|
|
604
619
|
s(!1), n.current = null;
|
|
605
620
|
}, []);
|
|
606
|
-
return
|
|
621
|
+
return xe(e, o, {
|
|
607
622
|
onMove: d,
|
|
608
|
-
onUp:
|
|
623
|
+
onUp: g,
|
|
609
624
|
pointerId: n.current ?? void 0,
|
|
610
625
|
capturePointer: !0,
|
|
611
626
|
preventDefaults: !1
|
|
612
627
|
}), {
|
|
613
628
|
ref: e,
|
|
614
629
|
onPointerDown: a,
|
|
615
|
-
isDragging:
|
|
630
|
+
isDragging: o
|
|
616
631
|
};
|
|
617
|
-
},
|
|
632
|
+
}, Ae = ({
|
|
618
633
|
element: t,
|
|
619
634
|
component: e
|
|
620
|
-
}) => i.forwardRef(({ children: n, ...
|
|
635
|
+
}) => i.forwardRef(({ children: n, ...r }, o) => t ? i.cloneElement(
|
|
621
636
|
t,
|
|
622
|
-
{ ...
|
|
637
|
+
{ ...r, ref: o },
|
|
623
638
|
n ?? t.props.children
|
|
624
|
-
) : e ? /* @__PURE__ */
|
|
625
|
-
function
|
|
639
|
+
) : e ? /* @__PURE__ */ h(e, { ...r, ref: o, children: n }) : /* @__PURE__ */ h("div", { ...r, ref: o, children: n }));
|
|
640
|
+
function He({
|
|
626
641
|
element: t,
|
|
627
642
|
component: e
|
|
628
643
|
}) {
|
|
629
644
|
return i.useMemo(
|
|
630
|
-
() =>
|
|
645
|
+
() => Ae({
|
|
631
646
|
element: t,
|
|
632
647
|
component: e
|
|
633
648
|
}),
|
|
634
649
|
[e, t]
|
|
635
650
|
);
|
|
636
651
|
}
|
|
637
|
-
const
|
|
652
|
+
const Ne = {
|
|
638
653
|
position: "absolute",
|
|
639
|
-
zIndex:
|
|
640
|
-
},
|
|
654
|
+
zIndex: Jt
|
|
655
|
+
}, _e = {
|
|
641
656
|
vertical: {
|
|
642
657
|
width: ct,
|
|
643
658
|
height: "100%",
|
|
@@ -650,31 +665,31 @@ const Ie = {
|
|
|
650
665
|
left: 0,
|
|
651
666
|
cursor: "row-resize"
|
|
652
667
|
}
|
|
653
|
-
},
|
|
654
|
-
idle:
|
|
655
|
-
hovered:
|
|
656
|
-
dragging:
|
|
657
|
-
},
|
|
668
|
+
}, $e = {
|
|
669
|
+
idle: qt,
|
|
670
|
+
hovered: Kt,
|
|
671
|
+
dragging: Zt
|
|
672
|
+
}, Ge = ({
|
|
658
673
|
direction: t,
|
|
659
674
|
onResize: e,
|
|
660
675
|
component: n,
|
|
661
|
-
element:
|
|
662
|
-
children:
|
|
676
|
+
element: r,
|
|
677
|
+
children: o
|
|
663
678
|
}) => {
|
|
664
|
-
const s = t === "vertical" ? "x" : "y", { ref: c, isDragging: u, onPointerDown: a } =
|
|
665
|
-
|
|
666
|
-
}, []),
|
|
667
|
-
|
|
668
|
-
}, []), w =
|
|
669
|
-
element:
|
|
679
|
+
const s = t === "vertical" ? "x" : "y", { ref: c, isDragging: u, onPointerDown: a } = ke({ axis: s, onResize: e }), [d, g] = i.useState(!1), f = i.useCallback(() => {
|
|
680
|
+
g(!0);
|
|
681
|
+
}, []), m = i.useCallback(() => {
|
|
682
|
+
g(!1);
|
|
683
|
+
}, []), w = He({
|
|
684
|
+
element: r,
|
|
670
685
|
component: n
|
|
671
686
|
}), E = i.useMemo(() => u ? "dragging" : d ? "hovered" : "idle", [u, d]), z = i.useMemo(() => ({
|
|
672
|
-
...
|
|
673
|
-
...
|
|
674
|
-
backgroundColor:
|
|
687
|
+
...Ne,
|
|
688
|
+
..._e[t],
|
|
689
|
+
backgroundColor: $e[E],
|
|
675
690
|
touchAction: "none"
|
|
676
691
|
}), [t, E]);
|
|
677
|
-
return /* @__PURE__ */
|
|
692
|
+
return /* @__PURE__ */ h(
|
|
678
693
|
w,
|
|
679
694
|
{
|
|
680
695
|
ref: c,
|
|
@@ -687,8 +702,8 @@ const Ie = {
|
|
|
687
702
|
"data-is-dragging": u ? "true" : void 0,
|
|
688
703
|
onPointerDown: a,
|
|
689
704
|
onPointerEnter: f,
|
|
690
|
-
onPointerLeave:
|
|
691
|
-
children:
|
|
705
|
+
onPointerLeave: m,
|
|
706
|
+
children: o
|
|
692
707
|
}
|
|
693
708
|
);
|
|
694
709
|
}, gt = {
|
|
@@ -698,24 +713,24 @@ const Ie = {
|
|
|
698
713
|
direction: t,
|
|
699
714
|
trackIndex: e,
|
|
700
715
|
align: n,
|
|
701
|
-
gap:
|
|
702
|
-
span:
|
|
716
|
+
gap: r,
|
|
717
|
+
span: o,
|
|
703
718
|
onResize: s
|
|
704
719
|
}) => {
|
|
705
720
|
const c = t === "col" ? "vertical" : "horizontal", u = i.useCallback(
|
|
706
|
-
(
|
|
707
|
-
const f = n === "start" ? -
|
|
721
|
+
(g) => {
|
|
722
|
+
const f = n === "start" ? -g : g;
|
|
708
723
|
s(t, e, f);
|
|
709
724
|
},
|
|
710
725
|
[n, t, e, s]
|
|
711
726
|
), a = i.useMemo(() => t === "col" ? {
|
|
712
727
|
gridColumn: `${e + 1} / ${e + 2}`,
|
|
713
|
-
gridRow: `${
|
|
728
|
+
gridRow: `${o.start} / ${o.end}`
|
|
714
729
|
} : {
|
|
715
730
|
gridRow: `${e + 1} / ${e + 2}`,
|
|
716
|
-
gridColumn: `${
|
|
717
|
-
}, [t, e,
|
|
718
|
-
const f = Math.max(0,
|
|
731
|
+
gridColumn: `${o.start} / ${o.end}`
|
|
732
|
+
}, [t, e, o]), d = i.useMemo(() => {
|
|
733
|
+
const f = Math.max(0, r) / 2 + J / 2;
|
|
719
734
|
return t === "col" ? {
|
|
720
735
|
...gt,
|
|
721
736
|
width: J,
|
|
@@ -731,19 +746,19 @@ const Ie = {
|
|
|
731
746
|
right: 0,
|
|
732
747
|
...n === "start" ? { top: -f } : { bottom: -f }
|
|
733
748
|
};
|
|
734
|
-
}, [n, t,
|
|
735
|
-
return /* @__PURE__ */
|
|
736
|
-
},
|
|
749
|
+
}, [n, t, r]);
|
|
750
|
+
return /* @__PURE__ */ h("div", { "data-resizable": "true", style: { ...a, position: "relative", pointerEvents: "none" }, children: /* @__PURE__ */ h("div", { "data-direction": c, "data-align": n, "data-handle": "true", style: d, children: /* @__PURE__ */ h(Ge, { direction: c, onResize: u }) }) });
|
|
751
|
+
}, Fe = (t) => {
|
|
737
752
|
const e = /* @__PURE__ */ new Map();
|
|
738
|
-
t.forEach((
|
|
739
|
-
|
|
753
|
+
t.forEach((r, o) => {
|
|
754
|
+
r.forEach((s, c) => {
|
|
740
755
|
if (!s || s === ".")
|
|
741
756
|
return;
|
|
742
757
|
const u = e.get(s);
|
|
743
758
|
if (u) {
|
|
744
759
|
const d = {
|
|
745
|
-
rowStart: Math.min(u.rowStart,
|
|
746
|
-
rowEnd: Math.max(u.rowEnd,
|
|
760
|
+
rowStart: Math.min(u.rowStart, o),
|
|
761
|
+
rowEnd: Math.max(u.rowEnd, o),
|
|
747
762
|
colStart: Math.min(u.colStart, c),
|
|
748
763
|
colEnd: Math.max(u.colEnd, c)
|
|
749
764
|
};
|
|
@@ -751,8 +766,8 @@ const Ie = {
|
|
|
751
766
|
return;
|
|
752
767
|
}
|
|
753
768
|
const a = {
|
|
754
|
-
rowStart:
|
|
755
|
-
rowEnd:
|
|
769
|
+
rowStart: o,
|
|
770
|
+
rowEnd: o,
|
|
756
771
|
colStart: c,
|
|
757
772
|
colEnd: c
|
|
758
773
|
};
|
|
@@ -760,172 +775,172 @@ const Ie = {
|
|
|
760
775
|
});
|
|
761
776
|
});
|
|
762
777
|
const n = /* @__PURE__ */ new Map();
|
|
763
|
-
return e.forEach((
|
|
764
|
-
const s =
|
|
765
|
-
gridArea:
|
|
778
|
+
return e.forEach((r, o) => {
|
|
779
|
+
const s = r.rowStart + 1, c = r.rowEnd + 2, u = r.colStart + 1, a = r.colEnd + 2, d = {
|
|
780
|
+
gridArea: o,
|
|
766
781
|
gridRow: `${s} / ${c}`,
|
|
767
782
|
gridColumn: `${u} / ${a}`
|
|
768
783
|
};
|
|
769
|
-
n.set(
|
|
784
|
+
n.set(o, d);
|
|
770
785
|
}), n;
|
|
771
|
-
},
|
|
786
|
+
}, Oe = (t, e) => {
|
|
772
787
|
if ((t.positionMode ?? "grid") !== "grid")
|
|
773
788
|
return t;
|
|
774
|
-
const
|
|
775
|
-
if (!
|
|
789
|
+
const r = t.gridArea ?? t.id, o = e.get(r);
|
|
790
|
+
if (!o)
|
|
776
791
|
return t;
|
|
777
792
|
const s = !t.gridArea, c = !t.gridRow, u = !t.gridColumn;
|
|
778
793
|
return !s && !c && !u ? t : {
|
|
779
794
|
...t,
|
|
780
|
-
gridArea: s ?
|
|
781
|
-
gridRow: c ?
|
|
782
|
-
gridColumn: u ?
|
|
795
|
+
gridArea: s ? o.gridArea : t.gridArea,
|
|
796
|
+
gridRow: c ? o.gridRow : t.gridRow,
|
|
797
|
+
gridColumn: u ? o.gridColumn : t.gridColumn
|
|
783
798
|
};
|
|
784
|
-
},
|
|
785
|
-
const n = i.useMemo(() =>
|
|
786
|
-
() =>
|
|
787
|
-
[o]
|
|
788
|
-
), s = i.useMemo(
|
|
789
|
-
() => r.filter((u) => !u.drawer),
|
|
799
|
+
}, We = (t, e) => {
|
|
800
|
+
const n = i.useMemo(() => Fe(t.areas), [t.areas]), r = i.useMemo(() => e.map((u) => Oe(u, n)), [e, n]), o = i.useMemo(
|
|
801
|
+
() => r.filter((u) => u.visible !== !1),
|
|
790
802
|
[r]
|
|
803
|
+
), s = i.useMemo(
|
|
804
|
+
() => o.filter((u) => !u.drawer),
|
|
805
|
+
[o]
|
|
791
806
|
), c = i.useMemo(() => {
|
|
792
807
|
const u = /* @__PURE__ */ new Map();
|
|
793
|
-
return
|
|
808
|
+
return r.forEach((a) => {
|
|
794
809
|
u.set(a.id, a);
|
|
795
810
|
}), u;
|
|
796
|
-
}, [
|
|
811
|
+
}, [r]);
|
|
797
812
|
return {
|
|
798
|
-
normalizedLayers:
|
|
799
|
-
visibleLayers:
|
|
813
|
+
normalizedLayers: r,
|
|
814
|
+
visibleLayers: o,
|
|
800
815
|
regularLayers: s,
|
|
801
816
|
layerById: c
|
|
802
817
|
};
|
|
803
|
-
},
|
|
804
|
-
const
|
|
818
|
+
}, j = (t, e) => `${t}-${e}`, Be = (t, e, n, r) => {
|
|
819
|
+
const o = j(n, r), s = e[o];
|
|
805
820
|
return s !== void 0 ? `${s}px` : t.size;
|
|
806
|
-
}, mt = (t, e, n) => t.map((
|
|
807
|
-
const
|
|
808
|
-
return n !== void 0 ? Math.min(
|
|
809
|
-
},
|
|
810
|
-
const
|
|
811
|
-
return
|
|
812
|
-
},
|
|
821
|
+
}, mt = (t, e, n) => t.map((r, o) => Be(r, e, n, o)).join(" "), X = (t, e) => t.reduce((n, r, o) => (r.resizable && r.size.endsWith("px") && (n[j(e, o)] = parseInt(r.size, 10)), n), {}), Ye = (t, e, n) => {
|
|
822
|
+
const r = e !== void 0 ? Math.max(t, e) : t;
|
|
823
|
+
return n !== void 0 ? Math.min(r, n) : r;
|
|
824
|
+
}, Xe = (t, e, n) => {
|
|
825
|
+
const r = t + e;
|
|
826
|
+
return Ye(r, n.minSize, n.maxSize);
|
|
827
|
+
}, Ve = (t, e, n, r, o) => {
|
|
813
828
|
const s = j(t, e);
|
|
814
829
|
return (c) => {
|
|
815
|
-
const u =
|
|
830
|
+
const u = Xe(n, r, o);
|
|
816
831
|
return { ...c, [s]: u };
|
|
817
832
|
};
|
|
818
833
|
}, bt = (t, e) => {
|
|
819
|
-
const n = t.length,
|
|
834
|
+
const n = t.length, r = [];
|
|
820
835
|
for (let c = 0; c < n; c++) {
|
|
821
836
|
const u = t[c], a = u[e], d = u[e + 1];
|
|
822
|
-
a !== d &&
|
|
837
|
+
a !== d && r.push(c);
|
|
823
838
|
}
|
|
824
|
-
if (
|
|
839
|
+
if (r.length === 0)
|
|
825
840
|
return { start: 1, end: n + 1 };
|
|
826
|
-
const
|
|
827
|
-
return { start:
|
|
841
|
+
const o = Math.min(...r), s = Math.max(...r);
|
|
842
|
+
return { start: o + 1, end: s + 2 };
|
|
828
843
|
}, wt = (t, e) => {
|
|
829
|
-
const n = t[e],
|
|
830
|
-
for (let a = 0; a <
|
|
831
|
-
const d = n?.[a],
|
|
832
|
-
d !==
|
|
844
|
+
const n = t[e], r = t[e + 1], o = n?.length ?? 0, s = [];
|
|
845
|
+
for (let a = 0; a < o; a++) {
|
|
846
|
+
const d = n?.[a], g = r?.[a];
|
|
847
|
+
d !== g && s.push(a);
|
|
833
848
|
}
|
|
834
849
|
if (s.length === 0)
|
|
835
|
-
return { start: 1, end:
|
|
850
|
+
return { start: 1, end: o + 1 };
|
|
836
851
|
const c = Math.min(...s), u = Math.max(...s);
|
|
837
852
|
return { start: c + 1, end: u + 2 };
|
|
838
|
-
},
|
|
853
|
+
}, Ue = (t, e) => {
|
|
839
854
|
if (t.length === 0)
|
|
840
855
|
return [];
|
|
841
856
|
const n = e.length;
|
|
842
857
|
if (t.length === 1)
|
|
843
858
|
return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
|
|
844
|
-
const
|
|
859
|
+
const r = [];
|
|
845
860
|
return Array.from({ length: t.length - 1 }, (s, c) => c).forEach((s) => {
|
|
846
861
|
const c = t[s];
|
|
847
862
|
if (t[s + 1]?.resizable) {
|
|
848
863
|
const a = bt(e, s);
|
|
849
|
-
|
|
864
|
+
r.push({ trackIndex: s + 1, align: "start", span: a });
|
|
850
865
|
return;
|
|
851
866
|
}
|
|
852
867
|
if (c?.resizable) {
|
|
853
868
|
const a = bt(e, s);
|
|
854
|
-
|
|
869
|
+
r.push({ trackIndex: s, align: "end", span: a });
|
|
855
870
|
}
|
|
856
|
-
}),
|
|
857
|
-
},
|
|
871
|
+
}), r;
|
|
872
|
+
}, je = (t, e) => {
|
|
858
873
|
if (t.length === 0)
|
|
859
874
|
return [];
|
|
860
875
|
const n = e[0]?.length ?? 0;
|
|
861
876
|
if (t.length === 1)
|
|
862
877
|
return t[0]?.resizable ? [{ trackIndex: 0, align: "end", span: { start: 1, end: n + 1 } }] : [];
|
|
863
|
-
const
|
|
878
|
+
const r = [];
|
|
864
879
|
return Array.from({ length: t.length - 1 }, (s, c) => c).forEach((s) => {
|
|
865
880
|
const c = t[s];
|
|
866
881
|
if (t[s + 1]?.resizable) {
|
|
867
882
|
const a = wt(e, s);
|
|
868
|
-
|
|
883
|
+
r.push({ trackIndex: s + 1, align: "start", span: a });
|
|
869
884
|
return;
|
|
870
885
|
}
|
|
871
886
|
if (c?.resizable) {
|
|
872
887
|
const a = wt(e, s);
|
|
873
|
-
|
|
888
|
+
r.push({ trackIndex: s, align: "end", span: a });
|
|
874
889
|
}
|
|
875
|
-
}),
|
|
876
|
-
},
|
|
890
|
+
}), r;
|
|
891
|
+
}, Ze = (t) => {
|
|
877
892
|
if (!t)
|
|
878
893
|
return { rowGap: 0, columnGap: 0 };
|
|
879
|
-
const e = t.split(/\s+/).map((
|
|
880
|
-
const
|
|
881
|
-
return
|
|
894
|
+
const e = t.split(/\s+/).map((r) => r.trim()).filter(Boolean), n = (r) => {
|
|
895
|
+
const o = r.match(/^(-?\d+(?:\.\d+)?)px$/);
|
|
896
|
+
return o ? Number.parseFloat(o[1]) : 0;
|
|
882
897
|
};
|
|
883
898
|
if (e.length === 1) {
|
|
884
|
-
const
|
|
885
|
-
return { rowGap:
|
|
899
|
+
const r = n(e[0]);
|
|
900
|
+
return { rowGap: r, columnGap: r };
|
|
886
901
|
}
|
|
887
902
|
return {
|
|
888
903
|
rowGap: n(e[0]),
|
|
889
904
|
columnGap: n(e[1])
|
|
890
905
|
};
|
|
891
|
-
},
|
|
892
|
-
const
|
|
906
|
+
}, Ke = (t) => t !== void 0 ? { gap: t } : {}, qe = (t, e, n, r) => {
|
|
907
|
+
const o = j(n, r), s = t[o];
|
|
893
908
|
return s !== void 0 ? s : e.size.endsWith("px") ? Number.parseInt(e.size, 10) : 300;
|
|
894
|
-
},
|
|
895
|
-
const [n,
|
|
909
|
+
}, Je = (t, e) => {
|
|
910
|
+
const [n, r] = i.useState(() => ({
|
|
896
911
|
...X(t.columns, "col"),
|
|
897
912
|
...X(t.rows, "row")
|
|
898
913
|
}));
|
|
899
|
-
|
|
900
|
-
const
|
|
914
|
+
Rt(() => {
|
|
915
|
+
const g = {
|
|
901
916
|
...X(t.columns, "col"),
|
|
902
917
|
...X(t.rows, "row")
|
|
903
918
|
};
|
|
904
|
-
|
|
905
|
-
const
|
|
906
|
-
return Array.from(
|
|
919
|
+
r((f) => {
|
|
920
|
+
const m = /* @__PURE__ */ new Set([...Object.keys(f), ...Object.keys(g)]);
|
|
921
|
+
return Array.from(m).some((E) => f[E] !== g[E]) ? g : f;
|
|
907
922
|
});
|
|
908
923
|
}, [t.columns, t.rows]);
|
|
909
|
-
const
|
|
910
|
-
() =>
|
|
924
|
+
const o = i.useMemo(() => t.areas.map((g) => `"${g.join(" ")}"`).join(" "), [t.areas]), s = i.useMemo(() => Ze(t.gap), [t.gap]), c = i.useMemo(
|
|
925
|
+
() => Ue(t.columns, t.areas),
|
|
911
926
|
[t.columns, t.areas]
|
|
912
927
|
), u = i.useMemo(
|
|
913
|
-
() =>
|
|
928
|
+
() => je(t.rows, t.areas),
|
|
914
929
|
[t.rows, t.areas]
|
|
915
930
|
), a = i.useMemo(() => ({
|
|
916
931
|
...t.style,
|
|
917
932
|
...e,
|
|
918
|
-
gridTemplateAreas:
|
|
933
|
+
gridTemplateAreas: o,
|
|
919
934
|
gridTemplateRows: mt(t.rows, n, "row"),
|
|
920
935
|
gridTemplateColumns: mt(t.columns, n, "col"),
|
|
921
|
-
...
|
|
922
|
-
}), [
|
|
923
|
-
(
|
|
924
|
-
const E = (
|
|
936
|
+
...Ke(t.gap)
|
|
937
|
+
}), [o, t.columns, t.gap, t.rows, t.style, e, n]), d = i.useCallback(
|
|
938
|
+
(g, f, m) => {
|
|
939
|
+
const E = (g === "row" ? t.rows : t.columns)[f];
|
|
925
940
|
if (!E || !E.resizable)
|
|
926
941
|
return;
|
|
927
|
-
const z =
|
|
928
|
-
|
|
942
|
+
const z = qe(n, E, g, f);
|
|
943
|
+
r(Ve(g, f, z, m, E));
|
|
929
944
|
},
|
|
930
945
|
[t.columns, t.rows, n]
|
|
931
946
|
);
|
|
@@ -936,38 +951,38 @@ const Ie = {
|
|
|
936
951
|
gridStyle: a,
|
|
937
952
|
handleResize: d
|
|
938
953
|
};
|
|
939
|
-
},
|
|
954
|
+
}, Qe = (t, e = Number.NEGATIVE_INFINITY, n = Number.POSITIVE_INFINITY) => Math.min(Math.max(t, e), n), Hn = (t, e) => typeof t != "number" || !Number.isFinite(t) ? e : t, tn = (t) => t.positionMode ? t.positionMode : t.floating ? (t.floating.mode ?? "embedded") === "embedded" ? "absolute" : "relative" : "grid", en = (t) => ({ position: t === "grid" ? "relative" : t }), nn = (t, e) => e !== "grid" ? {} : {
|
|
940
955
|
gridArea: t.gridArea,
|
|
941
956
|
gridRow: t.gridRow,
|
|
942
957
|
gridColumn: t.gridColumn
|
|
943
|
-
},
|
|
958
|
+
}, rn = (t) => t ? {
|
|
944
959
|
top: t.top,
|
|
945
960
|
right: t.right,
|
|
946
961
|
bottom: t.bottom,
|
|
947
962
|
left: t.left
|
|
948
|
-
} : {},
|
|
963
|
+
} : {}, on = (t) => t !== void 0 ? { zIndex: t } : {}, sn = (t, e) => ({
|
|
949
964
|
width: t,
|
|
950
965
|
height: e
|
|
951
|
-
}),
|
|
966
|
+
}), an = (t, e) => t.pointerEvents !== void 0 ? typeof t.pointerEvents == "boolean" ? { pointerEvents: t.pointerEvents ? "auto" : "none" } : { pointerEvents: t.pointerEvents } : e === "absolute" || e === "fixed" ? { pointerEvents: "auto" } : {}, cn = (t) => t.position, un = (t) => ({
|
|
952
967
|
width: t.width,
|
|
953
968
|
height: t.height
|
|
954
|
-
}),
|
|
955
|
-
const e =
|
|
969
|
+
}), ln = (t) => t.zIndex, dn = (t) => {
|
|
970
|
+
const e = tn(t), n = cn(t), r = un(t), o = ln(t);
|
|
956
971
|
return {
|
|
957
972
|
...t.style,
|
|
958
|
-
...
|
|
959
|
-
...
|
|
960
|
-
...
|
|
961
|
-
...
|
|
962
|
-
...
|
|
963
|
-
...
|
|
973
|
+
...en(e),
|
|
974
|
+
...nn(t, e),
|
|
975
|
+
...rn(n),
|
|
976
|
+
...on(o),
|
|
977
|
+
...sn(r.width, r.height),
|
|
978
|
+
...an(t, e)
|
|
964
979
|
};
|
|
965
|
-
},
|
|
980
|
+
}, fn = (t) => {
|
|
966
981
|
const e = t.floating;
|
|
967
982
|
return e ? e.mode ?? "embedded" : null;
|
|
968
|
-
}, H = (t) =>
|
|
969
|
-
const
|
|
970
|
-
return
|
|
983
|
+
}, H = (t) => fn(t) !== "embedded" ? null : t.floating ?? null, vt = (t) => t instanceof HTMLElement ? ["INPUT", "TEXTAREA", "SELECT", "BUTTON"].includes(t.tagName) : !1, Et = (t, e, n) => {
|
|
984
|
+
const r = e ?? Number.NEGATIVE_INFINITY, o = n ?? Number.POSITIVE_INFINITY;
|
|
985
|
+
return Qe(t, r, o);
|
|
971
986
|
}, St = (t, e, n) => {
|
|
972
987
|
if (typeof t == "number" && Number.isFinite(t))
|
|
973
988
|
return t;
|
|
@@ -984,10 +999,10 @@ const Ie = {
|
|
|
984
999
|
left: St(n.left, "left", t.id),
|
|
985
1000
|
top: St(n.top, "top", t.id)
|
|
986
1001
|
};
|
|
987
|
-
},
|
|
1002
|
+
}, pn = (t) => {
|
|
988
1003
|
const e = H(t);
|
|
989
1004
|
return e ? e.constraints ?? {} : {};
|
|
990
|
-
},
|
|
1005
|
+
}, gn = (t, e, n) => t ? t === "left" ? e - n : e + n : e, hn = (t, e, n) => t ? t === "top" ? e - n : e + n : e, mn = (t, e, n) => !t || t === "right" ? e : e + n, bn = (t, e, n) => !t || t === "bottom" ? e : e + n, et = (t, e) => t ? t.dataset.layerId === e ? t : et(t.parentElement, e) : null, nt = (t, e, n) => !t || n?.(t) ? null : e(t) ? t : nt(t.parentElement, e, n), wn = (t) => t instanceof HTMLElement ? nt(
|
|
991
1006
|
t,
|
|
992
1007
|
(e) => e.dataset.dragHandle === "true",
|
|
993
1008
|
(e) => e.dataset.dragIgnore === "true"
|
|
@@ -1000,53 +1015,53 @@ const Ie = {
|
|
|
1000
1015
|
}, U = (t) => {
|
|
1001
1016
|
if (!H(t))
|
|
1002
1017
|
return null;
|
|
1003
|
-
const n =
|
|
1018
|
+
const n = Sn(t);
|
|
1004
1019
|
if (!n)
|
|
1005
1020
|
throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);
|
|
1006
1021
|
return {
|
|
1007
1022
|
width: n.width,
|
|
1008
1023
|
height: n.height
|
|
1009
1024
|
};
|
|
1010
|
-
},
|
|
1011
|
-
const
|
|
1012
|
-
if (n ===
|
|
1013
|
-
const E = e[
|
|
1025
|
+
}, vn = (t, e, n) => {
|
|
1026
|
+
const r = t.filter(V).reduce((f, m) => {
|
|
1027
|
+
if (n === m.id) {
|
|
1028
|
+
const E = e[m.id];
|
|
1014
1029
|
if (E)
|
|
1015
|
-
return f[
|
|
1030
|
+
return f[m.id] = E, f;
|
|
1016
1031
|
}
|
|
1017
|
-
const w = U(
|
|
1018
|
-
return w && (f[
|
|
1019
|
-
}, {}),
|
|
1020
|
-
const
|
|
1021
|
-
return !
|
|
1032
|
+
const w = U(m);
|
|
1033
|
+
return w && (f[m.id] = w), f;
|
|
1034
|
+
}, {}), o = Object.keys(e), s = Object.keys(r), c = o.length !== s.length, u = o.some((f) => !Object.prototype.hasOwnProperty.call(r, f)), a = c ? !0 : u, d = s.some((f) => {
|
|
1035
|
+
const m = e[f], w = r[f];
|
|
1036
|
+
return !m || !w ? !0 : m.width !== w.width || m.height !== w.height;
|
|
1022
1037
|
});
|
|
1023
1038
|
return {
|
|
1024
|
-
sizes:
|
|
1039
|
+
sizes: r,
|
|
1025
1040
|
changed: a ? !0 : d
|
|
1026
1041
|
};
|
|
1027
|
-
},
|
|
1042
|
+
}, En = ({
|
|
1028
1043
|
layers: t,
|
|
1029
1044
|
layerById: e
|
|
1030
1045
|
}) => {
|
|
1031
|
-
const [n,
|
|
1032
|
-
e.get(
|
|
1033
|
-
}), w =
|
|
1034
|
-
e.get(
|
|
1046
|
+
const [n, r] = i.useState(null), [o, s] = i.useState(null), [c, u] = i.useState({}), [a, d] = i.useState({}), g = i.useRef(null), f = i.useRef(null), m = $((p, l) => {
|
|
1047
|
+
e.get(p)?.floating?.onMove?.(l);
|
|
1048
|
+
}), w = $((p, l) => {
|
|
1049
|
+
e.get(p)?.floating?.onResize?.(l);
|
|
1035
1050
|
});
|
|
1036
|
-
|
|
1037
|
-
const { sizes:
|
|
1038
|
-
l && d(
|
|
1039
|
-
}, [t,
|
|
1051
|
+
Rt(() => {
|
|
1052
|
+
const { sizes: p, changed: l } = vn(t, a, o);
|
|
1053
|
+
l && d(p);
|
|
1054
|
+
}, [t, o]);
|
|
1040
1055
|
const E = i.useCallback(
|
|
1041
|
-
(
|
|
1042
|
-
const S = Ct(l), R = c[
|
|
1056
|
+
(p, l, b, v) => {
|
|
1057
|
+
const S = Ct(l), R = c[p] ?? { x: 0, y: 0 }, C = {
|
|
1043
1058
|
pointerStartX: v.clientX,
|
|
1044
1059
|
pointerStartY: v.clientY,
|
|
1045
1060
|
initialTranslationX: R.x,
|
|
1046
1061
|
initialTranslationY: R.y,
|
|
1047
1062
|
baseLeft: S.left,
|
|
1048
1063
|
baseTop: S.top,
|
|
1049
|
-
layerId:
|
|
1064
|
+
layerId: p,
|
|
1050
1065
|
pointerId: v.pointerId,
|
|
1051
1066
|
target: b
|
|
1052
1067
|
};
|
|
@@ -1055,12 +1070,12 @@ const Ie = {
|
|
|
1055
1070
|
C.target.setPointerCapture(C.pointerId);
|
|
1056
1071
|
} catch {
|
|
1057
1072
|
}
|
|
1058
|
-
|
|
1073
|
+
g.current = C, r(p);
|
|
1059
1074
|
},
|
|
1060
1075
|
[c]
|
|
1061
1076
|
), z = i.useCallback(
|
|
1062
|
-
(
|
|
1063
|
-
const l =
|
|
1077
|
+
(p) => {
|
|
1078
|
+
const l = p.target, b = wn(l);
|
|
1064
1079
|
if (!b)
|
|
1065
1080
|
return;
|
|
1066
1081
|
const v = b.closest("[data-layer-id]")?.getAttribute("data-layer-id");
|
|
@@ -1070,40 +1085,40 @@ const Ie = {
|
|
|
1070
1085
|
if (!S)
|
|
1071
1086
|
return;
|
|
1072
1087
|
const R = H(S);
|
|
1073
|
-
if (!(!R || R.draggable !== !0) && !vt(
|
|
1088
|
+
if (!(!R || R.draggable !== !0) && !vt(p.target) && !zt(p.target) && b) {
|
|
1074
1089
|
const C = et(b, v);
|
|
1075
1090
|
if (!C)
|
|
1076
1091
|
return;
|
|
1077
|
-
E(v, S, C,
|
|
1092
|
+
E(v, S, C, p);
|
|
1078
1093
|
return;
|
|
1079
1094
|
}
|
|
1080
1095
|
},
|
|
1081
1096
|
[E, e]
|
|
1082
1097
|
), P = i.useCallback(
|
|
1083
|
-
(
|
|
1084
|
-
const b = e.get(
|
|
1098
|
+
(p, l) => {
|
|
1099
|
+
const b = e.get(p), v = b ? H(b) : null;
|
|
1085
1100
|
if (!b || !v || v.draggable !== !0 || vt(l.target) || zt(l.target))
|
|
1086
1101
|
return;
|
|
1087
|
-
const S = et(l.currentTarget,
|
|
1088
|
-
S && E(
|
|
1102
|
+
const S = et(l.currentTarget, p);
|
|
1103
|
+
S && E(p, b, S, l);
|
|
1089
1104
|
},
|
|
1090
1105
|
[E, e]
|
|
1091
|
-
),
|
|
1092
|
-
(
|
|
1093
|
-
const v = e.get(
|
|
1106
|
+
), L = i.useCallback(
|
|
1107
|
+
(p, l, b) => {
|
|
1108
|
+
const v = e.get(p);
|
|
1094
1109
|
if (!v || !V(v))
|
|
1095
1110
|
return;
|
|
1096
|
-
const S = a[
|
|
1111
|
+
const S = a[p] ?? U(v);
|
|
1097
1112
|
if (!S)
|
|
1098
1113
|
return;
|
|
1099
|
-
const R = Ct(v), C =
|
|
1114
|
+
const R = Ct(v), C = pn(v), x = c[p] ?? { x: 0, y: 0 };
|
|
1100
1115
|
if (b.stopPropagation(), b.preventDefault(), b.currentTarget.setPointerCapture)
|
|
1101
1116
|
try {
|
|
1102
1117
|
b.currentTarget.setPointerCapture(b.pointerId);
|
|
1103
1118
|
} catch {
|
|
1104
1119
|
}
|
|
1105
1120
|
f.current = {
|
|
1106
|
-
layerId:
|
|
1121
|
+
layerId: p,
|
|
1107
1122
|
pointerId: b.pointerId,
|
|
1108
1123
|
horizontalEdge: l.horizontal,
|
|
1109
1124
|
verticalEdge: l.vertical,
|
|
@@ -1111,7 +1126,7 @@ const Ie = {
|
|
|
1111
1126
|
startY: b.clientY,
|
|
1112
1127
|
startWidth: S.width,
|
|
1113
1128
|
startHeight: S.height,
|
|
1114
|
-
startPosition:
|
|
1129
|
+
startPosition: x,
|
|
1115
1130
|
baseLeft: R.left,
|
|
1116
1131
|
baseTop: R.top,
|
|
1117
1132
|
minWidth: C.minWidth,
|
|
@@ -1119,63 +1134,63 @@ const Ie = {
|
|
|
1119
1134
|
minHeight: C.minHeight,
|
|
1120
1135
|
maxHeight: C.maxHeight,
|
|
1121
1136
|
target: b.currentTarget
|
|
1122
|
-
}, s(
|
|
1137
|
+
}, s(p);
|
|
1123
1138
|
},
|
|
1124
1139
|
[e, c, a]
|
|
1125
1140
|
), F = i.useCallback(
|
|
1126
|
-
(
|
|
1127
|
-
const l =
|
|
1141
|
+
(p) => {
|
|
1142
|
+
const l = g.current;
|
|
1128
1143
|
if (!l)
|
|
1129
1144
|
return;
|
|
1130
|
-
const b =
|
|
1145
|
+
const b = p.clientX - l.pointerStartX, v = p.clientY - l.pointerStartY, S = {
|
|
1131
1146
|
x: l.initialTranslationX + b,
|
|
1132
1147
|
y: l.initialTranslationY + v
|
|
1133
1148
|
};
|
|
1134
|
-
u((R) => ({ ...R, [l.layerId]: S })),
|
|
1149
|
+
u((R) => ({ ...R, [l.layerId]: S })), m(l.layerId, {
|
|
1135
1150
|
left: l.baseLeft + S.x,
|
|
1136
1151
|
top: l.baseTop + S.y
|
|
1137
1152
|
});
|
|
1138
1153
|
},
|
|
1139
|
-
[
|
|
1154
|
+
[m]
|
|
1140
1155
|
), T = i.useCallback(
|
|
1141
|
-
(
|
|
1156
|
+
(p) => {
|
|
1142
1157
|
const l = f.current;
|
|
1143
|
-
if (!l || l.pointerId !==
|
|
1158
|
+
if (!l || l.pointerId !== p.pointerId || !e.get(l.layerId))
|
|
1144
1159
|
return;
|
|
1145
|
-
const v =
|
|
1160
|
+
const v = p.clientX - l.startX, S = p.clientY - l.startY, R = gn(l.horizontalEdge, l.startWidth, v), C = hn(l.verticalEdge, l.startHeight, S), x = Et(R, l.minWidth, l.maxWidth), A = Et(C, l.minHeight, l.maxHeight), O = l.startWidth - x, Z = l.startHeight - A, st = mn(
|
|
1146
1161
|
l.horizontalEdge,
|
|
1147
1162
|
l.startPosition.x,
|
|
1148
1163
|
O
|
|
1149
|
-
),
|
|
1150
|
-
(!K || K.width !==
|
|
1164
|
+
), Nt = bn(l.verticalEdge, l.startPosition.y, Z), K = a[l.layerId], it = { width: x, height: A };
|
|
1165
|
+
(!K || K.width !== x || K.height !== A) && (d((q) => ({
|
|
1151
1166
|
...q,
|
|
1152
1167
|
[l.layerId]: it
|
|
1153
1168
|
})), w(l.layerId, it));
|
|
1154
|
-
const at = c[l.layerId] ?? { x: 0, y: 0 }, W = { x: st, y:
|
|
1169
|
+
const at = c[l.layerId] ?? { x: 0, y: 0 }, W = { x: st, y: Nt };
|
|
1155
1170
|
(at.x !== W.x || at.y !== W.y) && (u((q) => ({
|
|
1156
1171
|
...q,
|
|
1157
1172
|
[l.layerId]: W
|
|
1158
|
-
})),
|
|
1173
|
+
})), m(l.layerId, {
|
|
1159
1174
|
left: l.baseLeft + W.x,
|
|
1160
1175
|
top: l.baseTop + W.y
|
|
1161
1176
|
}));
|
|
1162
1177
|
},
|
|
1163
|
-
[e, c, a,
|
|
1164
|
-
),
|
|
1165
|
-
const l =
|
|
1178
|
+
[e, c, a, m, w]
|
|
1179
|
+
), M = i.useCallback((p) => {
|
|
1180
|
+
const l = g.current;
|
|
1166
1181
|
if (l) {
|
|
1167
|
-
if (l.pointerId ===
|
|
1182
|
+
if (l.pointerId === p.pointerId && l.target.releasePointerCapture)
|
|
1168
1183
|
try {
|
|
1169
1184
|
l.target.releasePointerCapture(l.pointerId);
|
|
1170
1185
|
} catch {
|
|
1171
1186
|
}
|
|
1172
|
-
|
|
1187
|
+
g.current = null;
|
|
1173
1188
|
}
|
|
1174
|
-
|
|
1175
|
-
}, []),
|
|
1189
|
+
r(null);
|
|
1190
|
+
}, []), k = i.useCallback((p) => {
|
|
1176
1191
|
const l = f.current;
|
|
1177
1192
|
if (l) {
|
|
1178
|
-
if (l.pointerId ===
|
|
1193
|
+
if (l.pointerId === p.pointerId && l.target.releasePointerCapture)
|
|
1179
1194
|
try {
|
|
1180
1195
|
l.target.releasePointerCapture(l.pointerId);
|
|
1181
1196
|
} catch {
|
|
@@ -1186,19 +1201,19 @@ const Ie = {
|
|
|
1186
1201
|
}, []);
|
|
1187
1202
|
tt(n !== null, {
|
|
1188
1203
|
onMove: F,
|
|
1189
|
-
onUp:
|
|
1190
|
-
onCancel:
|
|
1191
|
-
}), tt(
|
|
1204
|
+
onUp: M,
|
|
1205
|
+
onCancel: M
|
|
1206
|
+
}), tt(o !== null, {
|
|
1192
1207
|
onMove: T,
|
|
1193
|
-
onUp:
|
|
1194
|
-
onCancel:
|
|
1208
|
+
onUp: k,
|
|
1209
|
+
onCancel: k
|
|
1195
1210
|
});
|
|
1196
1211
|
const y = i.useCallback(
|
|
1197
|
-
(
|
|
1198
|
-
const l =
|
|
1212
|
+
(p) => {
|
|
1213
|
+
const l = dn(p), b = H(p);
|
|
1199
1214
|
if (!b || b.draggable !== !0)
|
|
1200
1215
|
return l;
|
|
1201
|
-
const v = c[
|
|
1216
|
+
const v = c[p.id], S = n === p.id, R = o === p.id, C = v ? { transform: `translate(${v.x}px, ${v.y}px)` } : {}, x = a[p.id], A = V(p) ? U(p) : null, O = x ?? A, Z = O ? { width: `${O.width}px`, height: `${O.height}px` } : {};
|
|
1202
1217
|
return {
|
|
1203
1218
|
...l,
|
|
1204
1219
|
...Z,
|
|
@@ -1206,20 +1221,20 @@ const Ie = {
|
|
|
1206
1221
|
...S || R ? { cursor: "grabbing" } : {}
|
|
1207
1222
|
};
|
|
1208
1223
|
},
|
|
1209
|
-
[n, c, a,
|
|
1224
|
+
[n, c, a, o]
|
|
1210
1225
|
), I = i.useCallback(
|
|
1211
|
-
(
|
|
1212
|
-
if (!V(
|
|
1226
|
+
(p) => {
|
|
1227
|
+
if (!V(p))
|
|
1213
1228
|
return { isResizable: !1 };
|
|
1214
|
-
const b = a[
|
|
1215
|
-
return (b ?? v) !== null ? { isResizable: !0, onPointerDown: (
|
|
1216
|
-
|
|
1229
|
+
const b = a[p.id], v = U(p);
|
|
1230
|
+
return (b ?? v) !== null ? { isResizable: !0, onPointerDown: (x, A) => {
|
|
1231
|
+
L(p.id, x, A);
|
|
1217
1232
|
} } : { isResizable: !1 };
|
|
1218
1233
|
},
|
|
1219
|
-
[
|
|
1234
|
+
[L, a]
|
|
1220
1235
|
), rt = i.useCallback(
|
|
1221
|
-
(
|
|
1222
|
-
const { isResizable: l, onPointerDown: b } = I(
|
|
1236
|
+
(p) => {
|
|
1237
|
+
const { isResizable: l, onPointerDown: b } = I(p), v = y(p), S = o === p.id;
|
|
1223
1238
|
return {
|
|
1224
1239
|
style: v,
|
|
1225
1240
|
isResizable: l,
|
|
@@ -1229,15 +1244,15 @@ const Ie = {
|
|
|
1229
1244
|
}
|
|
1230
1245
|
};
|
|
1231
1246
|
},
|
|
1232
|
-
[y, I,
|
|
1247
|
+
[y, I, o]
|
|
1233
1248
|
), ot = i.useCallback(
|
|
1234
|
-
(
|
|
1249
|
+
(p) => ({
|
|
1235
1250
|
"data-drag-handle": "true",
|
|
1236
1251
|
role: "button",
|
|
1237
1252
|
"aria-roledescription": "Drag handle",
|
|
1238
1253
|
"aria-label": "Drag layer",
|
|
1239
1254
|
onPointerDown: (l) => {
|
|
1240
|
-
P(
|
|
1255
|
+
P(p, l);
|
|
1241
1256
|
}
|
|
1242
1257
|
}),
|
|
1243
1258
|
[P]
|
|
@@ -1252,34 +1267,34 @@ const Ie = {
|
|
|
1252
1267
|
[ot, rt, z]
|
|
1253
1268
|
),
|
|
1254
1269
|
draggingLayerId: n,
|
|
1255
|
-
resizingLayerId:
|
|
1270
|
+
resizingLayerId: o
|
|
1256
1271
|
};
|
|
1257
|
-
},
|
|
1272
|
+
}, Sn = (t) => {
|
|
1258
1273
|
if (typeof t.width == "number" && typeof t.height == "number")
|
|
1259
1274
|
return { width: t.width, height: t.height };
|
|
1260
|
-
},
|
|
1275
|
+
}, Cn = {
|
|
1261
1276
|
display: "grid",
|
|
1262
1277
|
width: "100%",
|
|
1263
1278
|
height: "100%"
|
|
1264
|
-
},
|
|
1279
|
+
}, zn = {
|
|
1265
1280
|
touchAction: "none",
|
|
1266
1281
|
WebkitTouchCallout: "none",
|
|
1267
1282
|
WebkitUserSelect: "none",
|
|
1268
1283
|
userSelect: "none"
|
|
1269
|
-
},
|
|
1270
|
-
const
|
|
1271
|
-
return /* @__PURE__ */
|
|
1272
|
-
},
|
|
1273
|
-
const { config: n, style:
|
|
1284
|
+
}, Nn = ({ config: t, layers: e, style: n }) => {
|
|
1285
|
+
const r = i.useRef(null), { isIntersecting: o } = oe(r, { threshold: 0 });
|
|
1286
|
+
return /* @__PURE__ */ h(we, { config: t, layers: e, style: n, children: /* @__PURE__ */ h(Rn, { gridRef: r, isIntersecting: o }) });
|
|
1287
|
+
}, Rn = ({ gridRef: t, isIntersecting: e }) => {
|
|
1288
|
+
const { config: n, style: r, layers: o } = be(), { normalizedLayers: s, visibleLayers: c, regularLayers: u, layerById: a } = We(n, o.defs), { columnHandles: d, rowHandles: g, gapSizes: f, gridStyle: m, handleResize: w } = Je(n, r), { providerValue: E, draggingLayerId: z, resizingLayerId: P } = En({
|
|
1274
1289
|
layers: s,
|
|
1275
1290
|
layerById: a
|
|
1276
|
-
}),
|
|
1277
|
-
...
|
|
1278
|
-
...
|
|
1279
|
-
...
|
|
1280
|
-
}), [
|
|
1281
|
-
return /* @__PURE__ */
|
|
1282
|
-
/* @__PURE__ */
|
|
1291
|
+
}), L = z ? !0 : !!P, F = i.useMemo(() => ({
|
|
1292
|
+
...Cn,
|
|
1293
|
+
...m,
|
|
1294
|
+
...L ? zn : {}
|
|
1295
|
+
}), [m, L]);
|
|
1296
|
+
return /* @__PURE__ */ G(N, { children: [
|
|
1297
|
+
/* @__PURE__ */ G(
|
|
1283
1298
|
"div",
|
|
1284
1299
|
{
|
|
1285
1300
|
ref: t,
|
|
@@ -1288,51 +1303,50 @@ const Ie = {
|
|
|
1288
1303
|
"data-resizing": !!P,
|
|
1289
1304
|
"data-visible": e,
|
|
1290
1305
|
children: [
|
|
1291
|
-
/* @__PURE__ */
|
|
1292
|
-
d.map(({ trackIndex: T, align:
|
|
1306
|
+
/* @__PURE__ */ h(me, { value: E, children: /* @__PURE__ */ h(De, { layers: u }) }),
|
|
1307
|
+
d.map(({ trackIndex: T, align: M, span: k }) => /* @__PURE__ */ h(
|
|
1293
1308
|
ht,
|
|
1294
1309
|
{
|
|
1295
1310
|
direction: "col",
|
|
1296
1311
|
trackIndex: T,
|
|
1297
|
-
align:
|
|
1312
|
+
align: M,
|
|
1298
1313
|
gap: f.columnGap,
|
|
1299
|
-
span:
|
|
1314
|
+
span: k,
|
|
1300
1315
|
onResize: w
|
|
1301
1316
|
},
|
|
1302
|
-
`col-${T}:${
|
|
1317
|
+
`col-${T}:${M}`
|
|
1303
1318
|
)),
|
|
1304
|
-
|
|
1319
|
+
g.map(({ trackIndex: T, align: M, span: k }) => /* @__PURE__ */ h(
|
|
1305
1320
|
ht,
|
|
1306
1321
|
{
|
|
1307
1322
|
direction: "row",
|
|
1308
1323
|
trackIndex: T,
|
|
1309
|
-
align:
|
|
1324
|
+
align: M,
|
|
1310
1325
|
gap: f.rowGap,
|
|
1311
|
-
span:
|
|
1326
|
+
span: k,
|
|
1312
1327
|
onResize: w
|
|
1313
1328
|
},
|
|
1314
|
-
`row-${T}:${
|
|
1329
|
+
`row-${T}:${M}`
|
|
1315
1330
|
))
|
|
1316
1331
|
]
|
|
1317
1332
|
}
|
|
1318
1333
|
),
|
|
1319
|
-
/* @__PURE__ */
|
|
1334
|
+
/* @__PURE__ */ h(he, { layers: c })
|
|
1320
1335
|
] });
|
|
1321
1336
|
};
|
|
1322
1337
|
export {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
Le as u
|
|
1338
|
+
de as D,
|
|
1339
|
+
Nn as G,
|
|
1340
|
+
Ge as R,
|
|
1341
|
+
An as a,
|
|
1342
|
+
Lt as b,
|
|
1343
|
+
$ as c,
|
|
1344
|
+
He as d,
|
|
1345
|
+
Qe as e,
|
|
1346
|
+
he as f,
|
|
1347
|
+
kn as g,
|
|
1348
|
+
Pt as r,
|
|
1349
|
+
Hn as t,
|
|
1350
|
+
ke as u
|
|
1337
1351
|
};
|
|
1338
|
-
//# sourceMappingURL=GridLayout-
|
|
1352
|
+
//# sourceMappingURL=GridLayout-CLvW8jID.js.map
|