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