@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.
@@ -1,242 +1,278 @@
1
- import { jsx as C, jsxs as W } from "react/jsx-runtime";
2
- import { useSensors as tt, useSensor as T, PointerSensor as et, KeyboardSensor as nt, KeyboardCode as D, DndContext as rt, MeasuringStrategy as ot, DragOverlay as st } from "@dnd-kit/core";
3
- import { getEventCoordinates as it } from "@dnd-kit/utilities";
4
- import { useState as _, useRef as K, useMemo as B, useCallback as at, createContext as lt, useLayoutEffect as dt, useContext as ct } from "react";
5
- import { createPortal as ut } from "react-dom";
6
- import { UNGROUPED_KEY as z } from "../../../lib/layout-ops.js";
7
- import { targetKey as m } from "../design-context.js";
8
- import { typedKeyboardCoordinates as ft, nodeData as k } from "./collision.js";
9
- import { DndStore as pt, DndStoreContext as gt, NO_DND as yt, IDLE as G } from "./node.js";
10
- import { railAwareCollision as ht, railDropData as q, copyableGroup as Y } from "./rail-drop.js";
11
- import { dropLabel as bt, landsOnCanvas as j, placeAfterDrop as mt, orderAfterDrop as Ct } from "./order.js";
12
- const F = lt(yt);
13
- function Gt() {
14
- return ct(F);
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 A = 3, P = 20;
17
- function St(u, t, e, p) {
18
- var o;
19
- if (u.body) {
20
- const S = e - 2 * P, b = p && S > 0 ? Math.min(p, S) : void 0, x = b ? { left: P, width: b } : { left: P, right: P };
21
- return u.side === "before" ? { top: (((o = t.headerHeight) == null ? void 0 : o.call(t)) ?? 0) + 4, height: A, ...x } : { bottom: 8, height: A, ...x };
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 (u.axis === "x")
24
- return { top: 0, bottom: 0, width: A, [u.side === "before" ? "left" : "right"]: -4 };
25
- const y = t.role.kind === "item" && p && e ? Math.min(p, e) : void 0;
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
- [u.side === "before" ? "top" : "bottom"]: -6,
28
- height: A,
29
+ [f.side === "before" ? "top" : "bottom"]: -6,
30
+ height: O,
29
31
  left: 0,
30
- ...y ? { width: y } : { right: 0 }
32
+ ...g ? { width: g } : { right: 0 }
31
33
  };
32
34
  }
33
- const wt = (u, t) => {
34
- var e, p;
35
- return ((p = (e = (u ?? []).find((y) => y.id === t)) == null ? void 0 : e.data) == null ? void 0 : p.hint) ?? null;
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 Dt(u) {
38
- for (let t = u; t && t !== document.documentElement; ) {
39
- const e = getComputedStyle(t);
40
- if (e.transform && e.transform !== "none" || e.perspective && e.perspective !== "none" || e.filter && e.filter !== "none" || /paint|layout|strict|content/.test(e.contain ?? "") || /transform|perspective|filter/.test(e.willChange ?? "")) {
41
- const y = t.getBoundingClientRect();
42
- return { x: y.left + t.clientLeft - t.scrollLeft, y: y.top + t.clientTop - t.scrollTop };
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
- t = t.parentElement;
46
+ n = n.parentElement;
45
47
  }
46
48
  return { x: 0, y: 0 };
47
49
  }
48
- function kt(u) {
49
- const t = u.cloneNode(!0);
50
- for (const e of [t, ...Array.from(t.querySelectorAll("*"))])
51
- for (const p of ["data-design-target", "data-selected", "data-drop-slot", "id"])
52
- e.removeAttribute(p);
53
- if (t.classList.remove("opacity-40"), t.style.clipPath) {
54
- t.style.clipPath = "none", t.style.transform = "none", t.style.overflow = "visible", t.style.borderRadius = "0", t.style.height = "100%";
55
- for (const e of Array.from(t.querySelectorAll("*")))
56
- e.style.clipPath && (e.style.clipPath = "none", e.style.borderRadius = "0");
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 e of Array.from(t.querySelectorAll("[data-design-drop-indicator]"))) e.remove();
59
- for (const e of ["role", "tabindex", "aria-describedby", "aria-pressed", "aria-hidden"])
60
- t.removeAttribute(e);
61
- return t.removeAttribute("data-header-folded"), t.setAttribute("inert", ""), Object.assign(t.style, { margin: "0", width: "100%", opacity: "1", outline: "none" }), t;
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 R = 320;
64
- function xt({ node: u }) {
65
- const t = K(null);
66
- return dt(() => {
67
- const e = t.current;
68
- if (e)
69
- return e.replaceChildren(kt(u)), () => e.replaceChildren();
70
- }, [u]), /* @__PURE__ */ C(
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: t,
79
+ ref: o,
74
80
  "aria-hidden": !0,
75
81
  "data-design-drag-preview": "",
76
- className: "pointer-events-none h-full w-full cursor-grabbing overflow-hidden rounded-lg bg-white shadow-xl ring-1 ring-slate-900/10 dark:bg-card dark:ring-white/10"
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: z }, Et = { droppable: { strategy: ot.Always } }, Ot = {
81
- start: [D.Space],
82
- cancel: [D.Esc],
83
- end: [D.Space, D.Enter, D.Tab]
84
- }, At = { threshold: { x: 0.08, y: 0.15 }, acceleration: 12 }, Pt = {
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 qt({
88
- bundle: u,
89
- apply: t,
90
- onDragActive: e,
91
- onDropOnLayout: p,
92
- children: y
99
+ function Wt({
100
+ bundle: f,
101
+ apply: n,
102
+ onDragActive: o,
103
+ onDropOnLayout: c,
104
+ children: g
93
105
  }) {
94
- const [o] = _(() => new pt());
95
- o.bundle = u;
96
- const S = K(t);
97
- S.current = t;
98
- const b = K(p);
99
- b.current = p;
100
- const [x] = _(
101
- () => ht((n) => !!b.current && Y(o.bundle, n) != null)
102
- ), H = B(
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: (n) => o.state.activeKey === m(n),
106
- dropSlot: (n) => o.state.overKey === m(n) ? o.state.side : null,
107
- dropIndicator: (n) => o.state.overKey === m(n) ? o.state.indicator : null
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
- [o]
110
- ), V = tt(
111
- T(et, { activationConstraint: { distance: 4 } }),
112
- T(nt, {
113
- coordinateGetter: ft,
114
- keyboardCodes: Ot
130
+ [r]
131
+ ), et = dt(
132
+ j(ct, { activationConstraint: { distance: 4 } }),
133
+ j(ut, {
134
+ coordinateGetter: Ct,
135
+ keyboardCodes: Tt
115
136
  })
116
- ), [w, M] = _(null), h = at(
117
- (n) => {
118
- var l, i, c, f;
119
- const r = k(n == null ? void 0 : n.data.current);
120
- if (!r) return "this";
121
- if (r.add) return r.add.label;
122
- const d = r.target;
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" : ((i = (l = o.bundle) == null ? void 0 : l.groups.find((g) => g.key === d.key)) == null ? void 0 : i.label) ?? "section";
125
- const a = o.nodes.get(m(d));
126
- return ((f = (c = a == null ? void 0 : a.querySelector("label, [data-header-label]")) == null ? void 0 : c.textContent) == null ? void 0 : f.trim()) || (d.kind === "slot" ? "panel" : "field");
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
- [o]
129
- ), X = B(
149
+ [r]
150
+ ), nt = H(
130
151
  () => ({
131
- onDragStart: ({ active: n }) => `Picked up ${h(n)}.`,
132
- onDragOver: ({ active: n, over: r }) => r ? `${h(n)} is over ${h(r)}.` : `${h(n)} is not over a place it can go.`,
133
- onDragEnd: ({ active: n, over: r }) => r ? `Dropped ${h(n)} by ${h(r)}.` : `Dropped ${h(n)}.`,
134
- onDragCancel: ({ active: n }) => `Cancelled. ${h(n)} stays where it was.`
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
- [h]
137
- ), $ = () => {
138
- o.set(G), M(null), e == null || e(!1);
139
- }, J = ({ active: n, activatorEvent: r }) => {
140
- e == null || e(!0);
141
- const d = k(n.data.current);
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 a = m(d.target);
144
- o.set({ ...G, activeKey: a });
145
- const s = o.nodes.get(a);
146
- if (!s || typeof document > "u") return;
147
- const l = s.closest("[role=dialog]") ?? document.body, i = Dt(l), c = s.getBoundingClientRect(), f = it(r), g = f ? f.y - c.top : 0, O = c.height > R && g > R - 32 ? g - R / 2 : 0, v = ({ transform: N }) => ({
148
- ...N,
149
- x: N.x - i.x,
150
- y: N.y - i.y + O
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
- M({ node: s, host: l, height: Math.min(c.height, R), shift: v });
153
- }, E = K({
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
- }), I = (n, r, d) => {
157
- const a = k(n.data.current), s = k(r == null ? void 0 : r.data.current), l = wt(d, r == null ? void 0 : r.id), i = o.bundle;
158
- if (!a || !s || !l || !i || !r) return null;
159
- E.current.bundle !== i && (E.current = { bundle: i, map: /* @__PURE__ */ new Map() });
160
- const c = `${n.id}|${r.id}|${l.side}`;
161
- let f = E.current.map.get(c);
162
- return f || (f = a.add ? mt(i, a.add.field, s.target, l.side, a.add.patch) : Ct(i, a.target, s.target, l.side), j(i, a.target, s.target) && !o.nodes.has(m(L)) && (f = []), E.current.map.set(c, f)), { a, o: s, hint: l, ops: f };
163
- }, U = ({ active: n, over: r, collisions: d }) => {
164
- var g, O;
165
- if (r && q(r.data.current)) {
166
- o.set({ overKey: String(r.id), side: null, indicator: null });
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 a = I(n, r, d);
170
- if (!a || a.ops.length === 0 || !r) {
171
- o.set({ overKey: null, side: null, indicator: null });
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: s, hint: l } = a, i = String(r.id);
175
- o.bundle && j(o.bundle, a.a.target, s.target) && (i = m(L), s = {
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: z, parent: null, body: !0 }
204
+ role: { kind: "group", key: Q, parent: null, body: !0 }
178
205
  }, l = { side: l.side, axis: "y", body: !1 });
179
- const c = ((g = o.nodes.get(i)) == null ? void 0 : g.getBoundingClientRect().width) ?? 0, f = ((O = n.rect.current.initial) == null ? void 0 : O.width) ?? null;
180
- o.set({
181
- overKey: i,
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: St(l, s, c, f)
210
+ indicator: Ot(l, a, p, u)
184
211
  });
185
- }, Q = ({ active: n, over: r, collisions: d }) => {
186
- var c, f;
187
- const a = q(r == null ? void 0 : r.data.current);
188
- if (a) {
189
- const g = Y(o.bundle, k(n.data.current));
190
- $(), g && ((c = b.current) == null || c.call(b, g, a.railLayoutId));
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 s = I(n, r, d), l = o.bundle;
194
- if ($(), !(s != null && s.ops.length) || !l) return;
195
- const i = s.a.add;
196
- S.current(s.ops, { label: i ? `Add ${i.label}` : bt(l, s.a.target) }), (f = i == null ? void 0 : i.onAdded) == null || f.call(i, s.ops);
197
- }, Z = (n) => {
198
- var d, a, s, l, i, c;
199
- if ((a = (d = n.target) == null ? void 0 : d.closest) != null && a.call(d, "[data-design-resize]")) return;
200
- const r = (l = (s = n.target) == null ? void 0 : s.closest) == null ? void 0 : l.call(s, "[data-design-target]");
201
- r && ((c = (i = o.activators.get(r)) == null ? void 0 : i()) == null || c(n));
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__ */ C(gt.Provider, { value: o, children: /* @__PURE__ */ C(F.Provider, { value: H, children: /* @__PURE__ */ W(
204
- rt,
235
+ return /* @__PURE__ */ D(wt.Provider, { value: r, children: /* @__PURE__ */ D(W.Provider, { value: tt, children: /* @__PURE__ */ lt(
236
+ ft,
205
237
  {
206
- sensors: V,
207
- collisionDetection: x,
208
- measuring: Et,
209
- autoScroll: At,
210
- accessibility: { announcements: X, screenReaderInstructions: Pt },
211
- onDragStart: J,
212
- onDragMove: U,
213
- onDragOver: U,
214
- onDragEnd: Q,
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__ */ C("div", { className: "contents", onPointerDownCapture: Z, children: y }),
218
- w && ut(
219
- /* @__PURE__ */ C(
220
- st,
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: [w.shift],
225
- style: { height: w.height },
226
- children: /* @__PURE__ */ C(xt, { node: w.node })
256
+ modifiers: [b.shift],
257
+ style: { height: b.height },
258
+ children: /* @__PURE__ */ D(It, { node: b.node, store: r })
227
259
  }
228
260
  ),
229
- w.host
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
- qt as LayoutDndProvider,
237
- yt as NO_DND,
238
- kt as designClone,
239
- Dt as fixedOrigin,
240
- St as indicatorStyle,
241
- Gt as useLayoutDnd
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 { nodeData as b, typedCollision as m, TABLE_FORM_ZONES as y } from "./collision.js";
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 || y.includes(t) ? null : e.groups.some((r) => r.key === t) ? t : null;
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(b(t.active.data.current)))
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 m(t);
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 }),