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