@nivaro/react 0.3.35 → 0.3.36
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +5 -4
- package/dist/shared/components/RecordReadView.js +88 -85
- package/dist/shared/components/item-edit/PersonalDefaultControl.js +77 -60
- package/dist/shared/components/layout-editor/DesignNode.js +79 -78
- package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
- package/dist/shared/components/layout-editor/EditorTopBar.js +230 -188
- package/dist/shared/components/layout-editor/LayoutEditor.js +370 -369
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +218 -182
- package/dist/shared/components/layout-editor/dnd/TrashZone.js +68 -0
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
- package/dist/shared/components/layout-editor/dnd/trash-drop.js +52 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +1 -1
- package/dist/shared/components/layout-editor/panel-frame.js +1 -1
- package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +2 -2
- package/package.json +1 -1
|
@@ -1,242 +1,278 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useSensors as
|
|
3
|
-
import { getEventCoordinates as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { UNGROUPED_KEY as
|
|
7
|
-
import { targetKey as
|
|
8
|
-
import { typedKeyboardCoordinates as
|
|
9
|
-
import { DndStore as
|
|
10
|
-
import { railAwareCollision as
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { jsx as D, jsxs as lt } from "react/jsx-runtime";
|
|
2
|
+
import { useSensors as dt, useSensor as j, PointerSensor as ct, KeyboardSensor as ut, KeyboardCode as x, DndContext as ft, MeasuringStrategy as pt, DragOverlay as gt } from "@dnd-kit/core";
|
|
3
|
+
import { getEventCoordinates as mt } from "@dnd-kit/utilities";
|
|
4
|
+
import { useState as R, useRef as N, useMemo as H, useCallback as J, createContext as yt, useSyncExternalStore as ht, useLayoutEffect as bt, useContext as St } from "react";
|
|
5
|
+
import { createPortal as z } from "react-dom";
|
|
6
|
+
import { UNGROUPED_KEY as Q } from "../../../lib/layout-ops.js";
|
|
7
|
+
import { targetKey as C } from "../design-context.js";
|
|
8
|
+
import { typedKeyboardCoordinates as Ct, nodeData as k } from "./collision.js";
|
|
9
|
+
import { DndStore as Dt, DndStoreContext as wt, NO_DND as kt, IDLE as F } from "./node.js";
|
|
10
|
+
import { railAwareCollision as xt, railDropData as V, copyableGroup as X } from "./rail-drop.js";
|
|
11
|
+
import { TrashZone as Rt } from "./TrashZone.js";
|
|
12
|
+
import { trashAwareCollision as Et, TRASH_DROP_ID as U, trashDropData as K, trashPlan as T } from "./trash-drop.js";
|
|
13
|
+
import { dropLabel as Pt, landsOnCanvas as Z, placeAfterDrop as At, orderAfterDrop as Kt } from "./order.js";
|
|
14
|
+
const W = yt(kt);
|
|
15
|
+
function Qt() {
|
|
16
|
+
return St(W);
|
|
15
17
|
}
|
|
16
|
-
const
|
|
17
|
-
function
|
|
18
|
-
var
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
return
|
|
18
|
+
const O = 3, $ = 20;
|
|
19
|
+
function Ot(f, n, o, c) {
|
|
20
|
+
var r;
|
|
21
|
+
if (f.body) {
|
|
22
|
+
const w = o - 2 * $, h = c && w > 0 ? Math.min(c, w) : void 0, E = h ? { left: $, width: h } : { left: $, right: $ };
|
|
23
|
+
return f.side === "before" ? { top: (((r = n.headerHeight) == null ? void 0 : r.call(n)) ?? 0) + 4, height: O, ...E } : { bottom: 8, height: O, ...E };
|
|
22
24
|
}
|
|
23
|
-
if (
|
|
24
|
-
return { top: 0, bottom: 0, width:
|
|
25
|
-
const
|
|
25
|
+
if (f.axis === "x")
|
|
26
|
+
return { top: 0, bottom: 0, width: O, [f.side === "before" ? "left" : "right"]: -4 };
|
|
27
|
+
const g = n.role.kind === "item" && c && o ? Math.min(c, o) : void 0;
|
|
26
28
|
return {
|
|
27
|
-
[
|
|
28
|
-
height:
|
|
29
|
+
[f.side === "before" ? "top" : "bottom"]: -6,
|
|
30
|
+
height: O,
|
|
29
31
|
left: 0,
|
|
30
|
-
...
|
|
32
|
+
...g ? { width: g } : { right: 0 }
|
|
31
33
|
};
|
|
32
34
|
}
|
|
33
|
-
const
|
|
34
|
-
var
|
|
35
|
-
return ((
|
|
35
|
+
const $t = (f, n) => {
|
|
36
|
+
var o, c;
|
|
37
|
+
return ((c = (o = (f ?? []).find((g) => g.id === n)) == null ? void 0 : o.data) == null ? void 0 : c.hint) ?? null;
|
|
36
38
|
};
|
|
37
|
-
function
|
|
38
|
-
for (let
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
return { x:
|
|
39
|
+
function _t(f) {
|
|
40
|
+
for (let n = f; n && n !== document.documentElement; ) {
|
|
41
|
+
const o = getComputedStyle(n);
|
|
42
|
+
if (o.transform && o.transform !== "none" || o.perspective && o.perspective !== "none" || o.filter && o.filter !== "none" || /paint|layout|strict|content/.test(o.contain ?? "") || /transform|perspective|filter/.test(o.willChange ?? "")) {
|
|
43
|
+
const g = n.getBoundingClientRect();
|
|
44
|
+
return { x: g.left + n.clientLeft - n.scrollLeft, y: g.top + n.clientTop - n.scrollTop };
|
|
43
45
|
}
|
|
44
|
-
|
|
46
|
+
n = n.parentElement;
|
|
45
47
|
}
|
|
46
48
|
return { x: 0, y: 0 };
|
|
47
49
|
}
|
|
48
|
-
function
|
|
49
|
-
const
|
|
50
|
-
for (const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
for (const
|
|
56
|
-
|
|
50
|
+
function Nt(f) {
|
|
51
|
+
const n = f.cloneNode(!0);
|
|
52
|
+
for (const o of [n, ...Array.from(n.querySelectorAll("*"))])
|
|
53
|
+
for (const c of ["data-design-target", "data-selected", "data-drop-slot", "id"])
|
|
54
|
+
o.removeAttribute(c);
|
|
55
|
+
if (n.classList.remove("opacity-40"), n.style.clipPath) {
|
|
56
|
+
n.style.clipPath = "none", n.style.transform = "none", n.style.overflow = "visible", n.style.borderRadius = "0", n.style.height = "100%";
|
|
57
|
+
for (const o of Array.from(n.querySelectorAll("*")))
|
|
58
|
+
o.style.clipPath && (o.style.clipPath = "none", o.style.borderRadius = "0");
|
|
57
59
|
}
|
|
58
|
-
for (const
|
|
59
|
-
for (const
|
|
60
|
-
|
|
61
|
-
return
|
|
60
|
+
for (const o of Array.from(n.querySelectorAll("[data-design-drop-indicator]"))) o.remove();
|
|
61
|
+
for (const o of ["role", "tabindex", "aria-describedby", "aria-pressed", "aria-hidden"])
|
|
62
|
+
n.removeAttribute(o);
|
|
63
|
+
return n.removeAttribute("data-header-folded"), n.setAttribute("inert", ""), Object.assign(n.style, { margin: "0", width: "100%", opacity: "1", outline: "none" }), n;
|
|
62
64
|
}
|
|
63
|
-
const
|
|
64
|
-
function
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
const _ = 320;
|
|
66
|
+
function It({ node: f, store: n }) {
|
|
67
|
+
const o = N(null), c = ht(
|
|
68
|
+
n.subscribe,
|
|
69
|
+
J(() => n.state.overKey === U, [n]),
|
|
70
|
+
() => !1
|
|
71
|
+
);
|
|
72
|
+
return bt(() => {
|
|
73
|
+
const g = o.current;
|
|
74
|
+
if (g)
|
|
75
|
+
return g.replaceChildren(Nt(f)), () => g.replaceChildren();
|
|
76
|
+
}, [f]), /* @__PURE__ */ D(
|
|
71
77
|
"div",
|
|
72
78
|
{
|
|
73
|
-
ref:
|
|
79
|
+
ref: o,
|
|
74
80
|
"aria-hidden": !0,
|
|
75
81
|
"data-design-drag-preview": "",
|
|
76
|
-
|
|
82
|
+
"data-over-trash": c ? "" : void 0,
|
|
83
|
+
style: {
|
|
84
|
+
transformOrigin: "top left",
|
|
85
|
+
transform: c ? "scale(0.4)" : void 0,
|
|
86
|
+
opacity: c ? 0.45 : void 0
|
|
87
|
+
},
|
|
88
|
+
className: "pointer-events-none h-full w-full cursor-grabbing overflow-hidden rounded-lg bg-white shadow-xl ring-1 ring-slate-900/10 transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none dark:bg-card dark:ring-white/10"
|
|
77
89
|
}
|
|
78
90
|
);
|
|
79
91
|
}
|
|
80
|
-
const L = { kind: "group", key:
|
|
81
|
-
start: [
|
|
82
|
-
cancel: [
|
|
83
|
-
end: [
|
|
84
|
-
},
|
|
92
|
+
const L = { kind: "group", key: Q }, Mt = { droppable: { strategy: pt.Always } }, Tt = {
|
|
93
|
+
start: [x.Space],
|
|
94
|
+
cancel: [x.Esc],
|
|
95
|
+
end: [x.Space, x.Enter, x.Tab]
|
|
96
|
+
}, Lt = {
|
|
85
97
|
draggable: "Press space to pick this up. Use the arrow keys to choose where it goes, then space or enter to drop it, or escape to cancel."
|
|
86
98
|
};
|
|
87
|
-
function
|
|
88
|
-
bundle:
|
|
89
|
-
apply:
|
|
90
|
-
onDragActive:
|
|
91
|
-
onDropOnLayout:
|
|
92
|
-
children:
|
|
99
|
+
function Wt({
|
|
100
|
+
bundle: f,
|
|
101
|
+
apply: n,
|
|
102
|
+
onDragActive: o,
|
|
103
|
+
onDropOnLayout: c,
|
|
104
|
+
children: g
|
|
93
105
|
}) {
|
|
94
|
-
const [
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
const [
|
|
101
|
-
() =>
|
|
102
|
-
|
|
106
|
+
const [r] = R(() => new Dt());
|
|
107
|
+
r.bundle = f;
|
|
108
|
+
const w = N(n);
|
|
109
|
+
w.current = n;
|
|
110
|
+
const h = N(c);
|
|
111
|
+
h.current = c;
|
|
112
|
+
const [E] = R(
|
|
113
|
+
() => Et(
|
|
114
|
+
xt(
|
|
115
|
+
(e) => !!h.current && X(r.bundle, e) != null
|
|
116
|
+
),
|
|
117
|
+
(e) => T(r.bundle, e) != null
|
|
118
|
+
)
|
|
119
|
+
), [v] = R(() => ({
|
|
120
|
+
threshold: { x: 0.08, y: 0.15 },
|
|
121
|
+
acceleration: 12,
|
|
122
|
+
canScroll: () => r.state.overKey !== U
|
|
123
|
+
})), [I, B] = R(null), tt = H(
|
|
103
124
|
() => ({
|
|
104
125
|
draggableProps: () => ({}),
|
|
105
|
-
isDragging: (
|
|
106
|
-
dropSlot: (
|
|
107
|
-
dropIndicator: (
|
|
126
|
+
isDragging: (e) => r.state.activeKey === C(e),
|
|
127
|
+
dropSlot: (e) => r.state.overKey === C(e) ? r.state.side : null,
|
|
128
|
+
dropIndicator: (e) => r.state.overKey === C(e) ? r.state.indicator : null
|
|
108
129
|
}),
|
|
109
|
-
[
|
|
110
|
-
),
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
coordinateGetter:
|
|
114
|
-
keyboardCodes:
|
|
130
|
+
[r]
|
|
131
|
+
), et = dt(
|
|
132
|
+
j(ct, { activationConstraint: { distance: 4 } }),
|
|
133
|
+
j(ut, {
|
|
134
|
+
coordinateGetter: Ct,
|
|
135
|
+
keyboardCodes: Tt
|
|
115
136
|
})
|
|
116
|
-
), [
|
|
117
|
-
(
|
|
118
|
-
var l,
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
if (
|
|
122
|
-
const d =
|
|
137
|
+
), [b, G] = R(null), m = J(
|
|
138
|
+
(e) => {
|
|
139
|
+
var l, s, p, u;
|
|
140
|
+
const t = k(e == null ? void 0 : e.data.current);
|
|
141
|
+
if (!t) return "this";
|
|
142
|
+
if (t.add) return t.add.label;
|
|
143
|
+
const d = t.target;
|
|
123
144
|
if (d.kind === "group")
|
|
124
|
-
return d.key === "__ungrouped__" ? "Ungrouped fields" : ((
|
|
125
|
-
const
|
|
126
|
-
return ((
|
|
145
|
+
return d.key === "__ungrouped__" ? "Ungrouped fields" : ((s = (l = r.bundle) == null ? void 0 : l.groups.find((y) => y.key === d.key)) == null ? void 0 : s.label) ?? "section";
|
|
146
|
+
const i = r.nodes.get(C(d));
|
|
147
|
+
return ((u = (p = i == null ? void 0 : i.querySelector("label, [data-header-label]")) == null ? void 0 : p.textContent) == null ? void 0 : u.replace(/\s*\*\s*$/, "").trim()) || (d.kind === "slot" ? "panel" : "field");
|
|
127
148
|
},
|
|
128
|
-
[
|
|
129
|
-
),
|
|
149
|
+
[r]
|
|
150
|
+
), nt = H(
|
|
130
151
|
() => ({
|
|
131
|
-
onDragStart: ({ active:
|
|
132
|
-
onDragOver: ({ active:
|
|
133
|
-
onDragEnd: ({ active:
|
|
134
|
-
onDragCancel: ({ active:
|
|
152
|
+
onDragStart: ({ active: e }) => `Picked up ${m(e)}.`,
|
|
153
|
+
onDragOver: ({ active: e, over: t }) => t && K(t.data.current) ? `${m(e)} is over Remove. Drop it to take it off this form.` : t ? `${m(e)} is over ${m(t)}.` : `${m(e)} is not over a place it can go.`,
|
|
154
|
+
onDragEnd: ({ active: e, over: t }) => t && K(t.data.current) ? `Removed ${m(e)} from this form.` : t ? `Dropped ${m(e)} by ${m(t)}.` : `Dropped ${m(e)}.`,
|
|
155
|
+
onDragCancel: ({ active: e }) => `Cancelled. ${m(e)} stays where it was.`
|
|
135
156
|
}),
|
|
136
|
-
[
|
|
137
|
-
),
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
const d = k(
|
|
157
|
+
[m]
|
|
158
|
+
), P = () => {
|
|
159
|
+
r.set(F), G(null), B(null), o == null || o(!1);
|
|
160
|
+
}, rt = ({ active: e, activatorEvent: t }) => {
|
|
161
|
+
o == null || o(!0);
|
|
162
|
+
const d = k(e.data.current);
|
|
142
163
|
if (!d) return;
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
const l =
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
164
|
+
const i = C(d.target);
|
|
165
|
+
r.set({ ...F, activeKey: i });
|
|
166
|
+
const a = T(r.bundle, d);
|
|
167
|
+
B(a ? { plan: a, name: m(e) } : null);
|
|
168
|
+
const l = r.nodes.get(i);
|
|
169
|
+
if (!l || typeof document > "u") return;
|
|
170
|
+
const s = l.closest("[role=dialog]") ?? document.body, p = _t(s), u = l.getBoundingClientRect(), y = mt(t), S = y ? y.y - u.top : 0, at = u.height > _ && S > _ - 32 ? S - _ / 2 : 0, it = ({ transform: M }) => ({
|
|
171
|
+
...M,
|
|
172
|
+
x: M.x - p.x,
|
|
173
|
+
y: M.y - p.y + at
|
|
151
174
|
});
|
|
152
|
-
|
|
153
|
-
},
|
|
175
|
+
G({ node: l, host: s, height: Math.min(u.height, _), shift: it });
|
|
176
|
+
}, A = N({
|
|
154
177
|
bundle: null,
|
|
155
178
|
map: /* @__PURE__ */ new Map()
|
|
156
|
-
}),
|
|
157
|
-
const
|
|
158
|
-
if (!
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
let
|
|
162
|
-
return
|
|
163
|
-
},
|
|
164
|
-
var
|
|
165
|
-
if (
|
|
166
|
-
|
|
179
|
+
}), q = (e, t, d) => {
|
|
180
|
+
const i = k(e.data.current), a = k(t == null ? void 0 : t.data.current), l = $t(d, t == null ? void 0 : t.id), s = r.bundle;
|
|
181
|
+
if (!i || !a || !l || !s || !t) return null;
|
|
182
|
+
A.current.bundle !== s && (A.current = { bundle: s, map: /* @__PURE__ */ new Map() });
|
|
183
|
+
const p = `${e.id}|${t.id}|${l.side}`;
|
|
184
|
+
let u = A.current.map.get(p);
|
|
185
|
+
return u || (u = i.add ? At(s, i.add.field, a.target, l.side, i.add.patch) : Kt(s, i.target, a.target, l.side), Z(s, i.target, a.target) && !r.nodes.has(C(L)) && (u = []), A.current.map.set(p, u)), { a: i, o: a, hint: l, ops: u };
|
|
186
|
+
}, Y = ({ active: e, over: t, collisions: d }) => {
|
|
187
|
+
var y, S;
|
|
188
|
+
if (t && K(t.data.current)) {
|
|
189
|
+
r.set({ overKey: U, side: null, indicator: null });
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
if (t && V(t.data.current)) {
|
|
193
|
+
r.set({ overKey: String(t.id), side: null, indicator: null });
|
|
167
194
|
return;
|
|
168
195
|
}
|
|
169
|
-
const
|
|
170
|
-
if (!
|
|
171
|
-
|
|
196
|
+
const i = q(e, t, d);
|
|
197
|
+
if (!i || i.ops.length === 0 || !t) {
|
|
198
|
+
r.set({ overKey: null, side: null, indicator: null });
|
|
172
199
|
return;
|
|
173
200
|
}
|
|
174
|
-
let { o:
|
|
175
|
-
|
|
201
|
+
let { o: a, hint: l } = i, s = String(t.id);
|
|
202
|
+
r.bundle && Z(r.bundle, i.a.target, a.target) && (s = C(L), a = {
|
|
176
203
|
target: L,
|
|
177
|
-
role: { kind: "group", key:
|
|
204
|
+
role: { kind: "group", key: Q, parent: null, body: !0 }
|
|
178
205
|
}, l = { side: l.side, axis: "y", body: !1 });
|
|
179
|
-
const
|
|
180
|
-
|
|
181
|
-
overKey:
|
|
206
|
+
const p = ((y = r.nodes.get(s)) == null ? void 0 : y.getBoundingClientRect().width) ?? 0, u = ((S = e.rect.current.initial) == null ? void 0 : S.width) ?? null;
|
|
207
|
+
r.set({
|
|
208
|
+
overKey: s,
|
|
182
209
|
side: l.side,
|
|
183
|
-
indicator:
|
|
210
|
+
indicator: Ot(l, a, p, u)
|
|
184
211
|
});
|
|
185
|
-
},
|
|
186
|
-
var
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
212
|
+
}, ot = ({ active: e, over: t, collisions: d }) => {
|
|
213
|
+
var p, u;
|
|
214
|
+
if (K(t == null ? void 0 : t.data.current)) {
|
|
215
|
+
const y = T(r.bundle, k(e.data.current)), S = m(e);
|
|
216
|
+
P(), y && w.current(y.ops, { label: `Remove ${S}` });
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
const i = V(t == null ? void 0 : t.data.current);
|
|
220
|
+
if (i) {
|
|
221
|
+
const y = X(r.bundle, k(e.data.current));
|
|
222
|
+
P(), y && ((p = h.current) == null || p.call(h, y, i.railLayoutId));
|
|
191
223
|
return;
|
|
192
224
|
}
|
|
193
|
-
const
|
|
194
|
-
if (
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
},
|
|
198
|
-
var d,
|
|
199
|
-
if ((
|
|
200
|
-
const
|
|
201
|
-
|
|
225
|
+
const a = q(e, t, d), l = r.bundle;
|
|
226
|
+
if (P(), !(a != null && a.ops.length) || !l) return;
|
|
227
|
+
const s = a.a.add;
|
|
228
|
+
w.current(a.ops, { label: s ? `Add ${s.label}` : Pt(l, a.a.target) }), (u = s == null ? void 0 : s.onAdded) == null || u.call(s, a.ops);
|
|
229
|
+
}, st = (e) => {
|
|
230
|
+
var d, i, a, l, s, p;
|
|
231
|
+
if ((i = (d = e.target) == null ? void 0 : d.closest) != null && i.call(d, "[data-design-resize]")) return;
|
|
232
|
+
const t = (l = (a = e.target) == null ? void 0 : a.closest) == null ? void 0 : l.call(a, "[data-design-target]");
|
|
233
|
+
t && ((p = (s = r.activators.get(t)) == null ? void 0 : s()) == null || p(e));
|
|
202
234
|
};
|
|
203
|
-
return /* @__PURE__ */
|
|
204
|
-
|
|
235
|
+
return /* @__PURE__ */ D(wt.Provider, { value: r, children: /* @__PURE__ */ D(W.Provider, { value: tt, children: /* @__PURE__ */ lt(
|
|
236
|
+
ft,
|
|
205
237
|
{
|
|
206
|
-
sensors:
|
|
207
|
-
collisionDetection:
|
|
208
|
-
measuring:
|
|
209
|
-
autoScroll:
|
|
210
|
-
accessibility: { announcements:
|
|
211
|
-
onDragStart:
|
|
212
|
-
onDragMove:
|
|
213
|
-
onDragOver:
|
|
214
|
-
onDragEnd:
|
|
215
|
-
onDragCancel:
|
|
238
|
+
sensors: et,
|
|
239
|
+
collisionDetection: E,
|
|
240
|
+
measuring: Mt,
|
|
241
|
+
autoScroll: v,
|
|
242
|
+
accessibility: { announcements: nt, screenReaderInstructions: Lt },
|
|
243
|
+
onDragStart: rt,
|
|
244
|
+
onDragMove: Y,
|
|
245
|
+
onDragOver: Y,
|
|
246
|
+
onDragEnd: ot,
|
|
247
|
+
onDragCancel: P,
|
|
216
248
|
children: [
|
|
217
|
-
/* @__PURE__ */
|
|
218
|
-
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
|
|
249
|
+
/* @__PURE__ */ D("div", { className: "contents", onPointerDownCapture: st, children: g }),
|
|
250
|
+
b && z(
|
|
251
|
+
/* @__PURE__ */ D(
|
|
252
|
+
gt,
|
|
221
253
|
{
|
|
222
254
|
dropAnimation: null,
|
|
223
255
|
zIndex: 1e3,
|
|
224
|
-
modifiers: [
|
|
225
|
-
style: { height:
|
|
226
|
-
children: /* @__PURE__ */
|
|
256
|
+
modifiers: [b.shift],
|
|
257
|
+
style: { height: b.height },
|
|
258
|
+
children: /* @__PURE__ */ D(It, { node: b.node, store: r })
|
|
227
259
|
}
|
|
228
260
|
),
|
|
229
|
-
|
|
261
|
+
b.host
|
|
262
|
+
),
|
|
263
|
+
I && z(
|
|
264
|
+
/* @__PURE__ */ D(Rt, { store: r, plan: I.plan, name: I.name }),
|
|
265
|
+
(b == null ? void 0 : b.host) ?? document.body
|
|
230
266
|
)
|
|
231
267
|
]
|
|
232
268
|
}
|
|
233
269
|
) }) });
|
|
234
270
|
}
|
|
235
271
|
export {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
272
|
+
Wt as LayoutDndProvider,
|
|
273
|
+
kt as NO_DND,
|
|
274
|
+
Nt as designClone,
|
|
275
|
+
_t as fixedOrigin,
|
|
276
|
+
Ot as indicatorStyle,
|
|
277
|
+
Qt as useLayoutDnd
|
|
242
278
|
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { jsxs as s, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { useDroppable as c } from "@dnd-kit/core";
|
|
3
|
+
import { Trash2 as m } from "lucide-react";
|
|
4
|
+
import { useSyncExternalStore as h, useCallback as x } from "react";
|
|
5
|
+
import { cn as o } from "../../../lib/utils.js";
|
|
6
|
+
import { TRASH_DROP_ID as n } from "./trash-drop.js";
|
|
7
|
+
const b = `
|
|
8
|
+
@keyframes nvr-trash-in{from{opacity:0;transform:translate(-50%,12px)}to{opacity:1;transform:translate(-50%,0)}}
|
|
9
|
+
[data-layout-trash]{animation:nvr-trash-in 160ms cubic-bezier(0.25,1,0.5,1) both}
|
|
10
|
+
@media (prefers-reduced-motion: reduce){[data-layout-trash]{animation:none}}
|
|
11
|
+
`, p = (e, r) => `${e} ${r}${e === 1 ? "" : "s"}`;
|
|
12
|
+
function w({
|
|
13
|
+
store: e,
|
|
14
|
+
plan: r,
|
|
15
|
+
name: d
|
|
16
|
+
}) {
|
|
17
|
+
const { setNodeRef: i } = c({
|
|
18
|
+
id: n,
|
|
19
|
+
data: { layoutTrash: !0 }
|
|
20
|
+
}), t = h(
|
|
21
|
+
e.subscribe,
|
|
22
|
+
x(() => e.state.overKey === n, [e]),
|
|
23
|
+
() => !1
|
|
24
|
+
), l = r.kind === "section" ? r.holds > 0 ? `With its ${p(r.holds, "field")} · their data is kept` : "It holds no fields" : "Its data is kept";
|
|
25
|
+
return /* @__PURE__ */ s(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
ref: i,
|
|
29
|
+
"data-layout-trash": "",
|
|
30
|
+
"data-over": t ? "" : void 0,
|
|
31
|
+
style: { left: "50%", transform: "translateX(-50%)" },
|
|
32
|
+
className: o(
|
|
33
|
+
"pointer-events-auto fixed bottom-6 z-[1001] flex min-w-[240px] max-w-[min(420px,calc(100vw-32px))] items-center gap-3 rounded-xl border-2 px-4 py-3 shadow-lg transition-colors duration-150 motion-reduce:transition-none",
|
|
34
|
+
t ? "border-solid border-red-400 bg-red-50 text-red-800 dark:border-red-500/70 dark:bg-[#3b1219] dark:text-red-100" : "border-dashed border-slate-300 bg-white text-slate-600 dark:border-slate-600 dark:bg-card dark:text-slate-300"
|
|
35
|
+
),
|
|
36
|
+
children: [
|
|
37
|
+
/* @__PURE__ */ a("style", { children: b }),
|
|
38
|
+
/* @__PURE__ */ a(
|
|
39
|
+
"span",
|
|
40
|
+
{
|
|
41
|
+
"aria-hidden": !0,
|
|
42
|
+
className: o(
|
|
43
|
+
"flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150 motion-reduce:transition-none",
|
|
44
|
+
t ? "bg-red-600 text-white" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-300"
|
|
45
|
+
),
|
|
46
|
+
children: /* @__PURE__ */ a(m, { className: "h-4 w-4" })
|
|
47
|
+
}
|
|
48
|
+
),
|
|
49
|
+
/* @__PURE__ */ s("span", { className: "min-w-0", children: [
|
|
50
|
+
/* @__PURE__ */ a("span", { className: "block truncate text-[13px] font-semibold", children: t ? `Release to remove ${d}` : "Drop here to remove" }),
|
|
51
|
+
/* @__PURE__ */ a(
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
className: o(
|
|
55
|
+
"block truncate text-[11.5px]",
|
|
56
|
+
t ? "text-red-700 dark:text-red-200/90" : "text-slate-500 dark:text-slate-400"
|
|
57
|
+
),
|
|
58
|
+
children: t ? l : "From this form only · Undo brings it back"
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
w as TrashZone
|
|
68
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDroppable as d } from "@dnd-kit/core";
|
|
2
2
|
import { useContext as f, useSyncExternalStore as s, useCallback as c } from "react";
|
|
3
3
|
import { UNGROUPED_KEY as u } from "../../../lib/layout-ops.js";
|
|
4
|
-
import {
|
|
4
|
+
import { TABLE_FORM_ZONES as b, nodeData as m, typedCollision as y } from "./collision.js";
|
|
5
5
|
import { DndStoreContext as C } from "./node.js";
|
|
6
6
|
const D = "rail-layout:", k = (e) => `${D}${e}`;
|
|
7
7
|
function E(e) {
|
|
@@ -11,19 +11,19 @@ function E(e) {
|
|
|
11
11
|
function _(e, o) {
|
|
12
12
|
if (!e || !o || o.add || o.target.kind !== "group" || o.role.kind !== "group") return null;
|
|
13
13
|
const t = o.target.key;
|
|
14
|
-
return t === u ||
|
|
14
|
+
return t === u || b.includes(t) ? null : e.groups.some((r) => r.key === t) ? t : null;
|
|
15
15
|
}
|
|
16
16
|
const R = (e, o) => o.x >= e.left && o.x <= e.right && o.y >= e.top && o.y <= e.bottom;
|
|
17
17
|
function I(e) {
|
|
18
18
|
return (t) => {
|
|
19
19
|
const r = t.pointerCoordinates;
|
|
20
|
-
if (r && e(
|
|
20
|
+
if (r && e(m(t.active.data.current)))
|
|
21
21
|
for (const n of t.droppableContainers) {
|
|
22
22
|
if (n.disabled || !E(n.data.current)) continue;
|
|
23
23
|
const i = t.droppableRects.get(n.id);
|
|
24
24
|
if (i && R(i, r)) return [{ id: n.id, data: { droppableContainer: n } }];
|
|
25
25
|
}
|
|
26
|
-
return
|
|
26
|
+
return y(t);
|
|
27
27
|
};
|
|
28
28
|
}
|
|
29
29
|
const x = { subscribe: () => () => {
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { UNGROUPED_KEY as p, HEADER_GROUP_KEY as d } from "../../../lib/layout-ops.js";
|
|
2
|
+
import { nodeData as f, TABLE_FORM_ZONES as k } from "./collision.js";
|
|
3
|
+
const g = "layout-trash";
|
|
4
|
+
function y(o) {
|
|
5
|
+
const e = o;
|
|
6
|
+
return (e == null ? void 0 : e.layoutTrash) === !0 ? e : null;
|
|
7
|
+
}
|
|
8
|
+
function D(o, e) {
|
|
9
|
+
if (!o || !e || e.add) return null;
|
|
10
|
+
const t = e.target;
|
|
11
|
+
if (t.kind === "group") {
|
|
12
|
+
if (t.key === p || k.includes(t.key) || !o.groups.some((r) => r.key === t.key)) return null;
|
|
13
|
+
const n = [], l = (r) => {
|
|
14
|
+
for (const a of o.groups) a.parent_key === r && l(a.key);
|
|
15
|
+
n.push(r);
|
|
16
|
+
};
|
|
17
|
+
l(t.key);
|
|
18
|
+
const u = new Set(n), c = o.placements.filter((r) => r.group_key && u.has(r.group_key)).length;
|
|
19
|
+
return {
|
|
20
|
+
ops: n.map((r) => ({ op: "group_remove", key: r, placements: "delete" })),
|
|
21
|
+
kind: "section",
|
|
22
|
+
holds: c
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const s = t.kind === "header" ? d : t.group_key ?? null;
|
|
26
|
+
return o.placements.some(
|
|
27
|
+
(n) => n.field === t.field && (n.group_key ?? null) === s
|
|
28
|
+
) ? {
|
|
29
|
+
ops: [{ op: "remove", at: { field: t.field, group_key: s } }],
|
|
30
|
+
kind: "field",
|
|
31
|
+
holds: 0
|
|
32
|
+
} : null;
|
|
33
|
+
}
|
|
34
|
+
const _ = (o, e) => e.x >= o.left && e.x <= o.right && e.y >= o.top && e.y <= o.bottom;
|
|
35
|
+
function E(o, e) {
|
|
36
|
+
return (t) => {
|
|
37
|
+
const s = t.pointerCoordinates;
|
|
38
|
+
if (s && e(f(t.active.data.current)))
|
|
39
|
+
for (const i of t.droppableContainers) {
|
|
40
|
+
if (i.disabled || !y(i.data.current)) continue;
|
|
41
|
+
const n = t.droppableRects.get(i.id);
|
|
42
|
+
if (n && _(n, s)) return [{ id: i.id, data: { droppableContainer: i } }];
|
|
43
|
+
}
|
|
44
|
+
return o(t);
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
g as TRASH_DROP_ID,
|
|
49
|
+
E as trashAwareCollision,
|
|
50
|
+
y as trashDropData,
|
|
51
|
+
D as trashPlan
|
|
52
|
+
};
|
|
@@ -154,7 +154,7 @@ function ue({
|
|
|
154
154
|
}) {
|
|
155
155
|
var p;
|
|
156
156
|
const u = h(C);
|
|
157
|
-
return /* @__PURE__ */ d("div", { "data-setting": e, "data-setting-row": "", className: m("space-y-1.5", s), children: [
|
|
157
|
+
return /* @__PURE__ */ d("div", { "data-setting": e, "data-setting-row": "", className: m("relative space-y-1.5", s), children: [
|
|
158
158
|
/* @__PURE__ */ d("div", { className: "flex min-h-5 items-center justify-between gap-3", children: [
|
|
159
159
|
/* @__PURE__ */ d("span", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-0.5", children: [
|
|
160
160
|
/* @__PURE__ */ t("span", { className: ae, children: o }),
|