@nivaro/react 0.2.51 → 0.2.52
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 +204 -6
- package/dist/index.js +442 -439
- package/dist/layout-editor.d.ts +80 -0
- package/dist/layout-editor.js +11 -0
- package/dist/shared/components/ItemEditForm.js +4044 -3866
- package/dist/shared/components/RecordDrilldownSheet.js +114 -97
- package/dist/shared/components/RecordReadView.js +637 -570
- package/dist/shared/components/ai/ExplainButton.js +1 -1
- package/dist/shared/components/item-edit/GroupSection.js +489 -466
- package/dist/shared/components/item-edit/HeaderBand.js +47 -44
- package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
- package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
- package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
- package/dist/shared/components/item-edit/StepsBar.js +49 -43
- package/dist/shared/components/item-edit/SummaryPanel.js +1 -1
- package/dist/shared/components/item-edit/config-update.js +6 -0
- package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
- package/dist/shared/components/layout-editor/AddPanel.js +301 -0
- package/dist/shared/components/layout-editor/DesignNode.js +173 -0
- package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
- package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
- package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
- package/dist/shared/components/layout-editor/add-target.js +103 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
- package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
- package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
- package/dist/shared/components/layout-editor/collection-meta.js +22 -0
- package/dist/shared/components/layout-editor/design-canvas.js +81 -0
- package/dist/shared/components/layout-editor/design-context.js +21 -0
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
- package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
- package/dist/shared/components/layout-editor/dnd/node.js +164 -0
- package/dist/shared/components/layout-editor/dnd/order.js +122 -0
- package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
- package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
- package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
- package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
- package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
- package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
- package/dist/shared/components/layout-editor/editors/controls.js +73 -0
- package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
- package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
- package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
- package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
- package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
- package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
- package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
- package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
- package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
- package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
- package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
- package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
- package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
- package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
- package/dist/shared/components/layout-editor/host.js +15 -0
- package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
- package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
- package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
- package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
- package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
- package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
- package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
- package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
- package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
- package/dist/shared/components/layout-editor/inspector/model.js +307 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
- package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
- package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
- package/dist/shared/components/layout-editor/panel-frame.js +99 -0
- package/dist/shared/components/layout-editor/panel-style.js +19 -0
- package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
- package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
- package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
- package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
- package/dist/shared/components/layout-editor/record-queries.js +15 -0
- package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
- package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
- package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
- package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
- package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
- package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
- package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
- package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
- package/dist/shared/components/layout-editor/settings/controls.js +214 -0
- package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
- package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
- package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
- package/dist/shared/components/layout-editor/slot-names.js +20 -0
- package/dist/shared/components/layout-editor/summary-pref.js +21 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
- package/dist/shared/components/pipeline/relations.js +28 -23
- package/dist/shared/components/ui/popover.js +17 -17
- package/dist/shared/components/ui/scroll-area.js +38 -0
- package/dist/shared/hooks/useRelationOptions.js +60 -0
- package/dist/shared/lib/layout-grants.js +9 -0
- package/dist/shared/lib/layout-ops.js +348 -0
- package/dist/shared/lib/layout-slots.js +11 -7
- package/dist/shared/lib/request-gate.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { jsx as m, jsxs as V } from "react/jsx-runtime";
|
|
2
|
+
import { useSensors as X, useSensor as U, PointerSensor as J, KeyboardSensor as Q, KeyboardCode as S, DndContext as Z, MeasuringStrategy as W, DragOverlay as ee } from "@dnd-kit/core";
|
|
3
|
+
import { getEventCoordinates as te } from "@dnd-kit/utilities";
|
|
4
|
+
import { useState as I, useRef as $, useMemo as v, useCallback as ne, createContext as oe, useLayoutEffect as re, useContext as se } from "react";
|
|
5
|
+
import { createPortal as ie } from "react-dom";
|
|
6
|
+
import { UNGROUPED_KEY as q } from "../../../lib/layout-ops.js";
|
|
7
|
+
import { targetKey as b } from "../design-context.js";
|
|
8
|
+
import { typedKeyboardCoordinates as ae, nodeData as O, typedCollision as le } from "./collision.js";
|
|
9
|
+
import { DndStore as de, DndStoreContext as ce, NO_DND as ue, IDLE as T } from "./node.js";
|
|
10
|
+
import { dropLabel as pe, landsOnCanvas as B, placeAfterDrop as fe, orderAfterDrop as ge } from "./order.js";
|
|
11
|
+
const G = oe(ue);
|
|
12
|
+
function _e() {
|
|
13
|
+
return se(G);
|
|
14
|
+
}
|
|
15
|
+
const E = 3, R = 20;
|
|
16
|
+
function ye(c, e, t, p) {
|
|
17
|
+
var C;
|
|
18
|
+
if (c.body) {
|
|
19
|
+
const w = t - 2 * R, D = p && w > 0 ? Math.min(p, w) : void 0, y = D ? { left: R, width: D } : { left: R, right: R };
|
|
20
|
+
return c.side === "before" ? { top: (((C = e.headerHeight) == null ? void 0 : C.call(e)) ?? 0) + 4, height: E, ...y } : { bottom: 8, height: E, ...y };
|
|
21
|
+
}
|
|
22
|
+
if (c.axis === "x")
|
|
23
|
+
return { top: 0, bottom: 0, width: E, [c.side === "before" ? "left" : "right"]: -4 };
|
|
24
|
+
const o = e.role.kind === "item" && p && t ? Math.min(p, t) : void 0;
|
|
25
|
+
return {
|
|
26
|
+
[c.side === "before" ? "top" : "bottom"]: -6,
|
|
27
|
+
height: E,
|
|
28
|
+
left: 0,
|
|
29
|
+
...o ? { width: o } : { right: 0 }
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const he = (c, e) => {
|
|
33
|
+
var t, p;
|
|
34
|
+
return ((p = (t = (c ?? []).find((o) => o.id === e)) == null ? void 0 : t.data) == null ? void 0 : p.hint) ?? null;
|
|
35
|
+
};
|
|
36
|
+
function be(c) {
|
|
37
|
+
for (let e = c; e && e !== document.documentElement; ) {
|
|
38
|
+
const t = getComputedStyle(e);
|
|
39
|
+
if (t.transform && t.transform !== "none" || t.perspective && t.perspective !== "none" || t.filter && t.filter !== "none" || /paint|layout|strict|content/.test(t.contain ?? "") || /transform|perspective|filter/.test(t.willChange ?? "")) {
|
|
40
|
+
const o = e.getBoundingClientRect();
|
|
41
|
+
return { x: o.left + e.clientLeft - e.scrollLeft, y: o.top + e.clientTop - e.scrollTop };
|
|
42
|
+
}
|
|
43
|
+
e = e.parentElement;
|
|
44
|
+
}
|
|
45
|
+
return { x: 0, y: 0 };
|
|
46
|
+
}
|
|
47
|
+
function me(c) {
|
|
48
|
+
const e = c.cloneNode(!0);
|
|
49
|
+
for (const t of [e, ...Array.from(e.querySelectorAll("*"))])
|
|
50
|
+
for (const p of ["data-design-target", "data-selected", "data-drop-slot", "id"])
|
|
51
|
+
t.removeAttribute(p);
|
|
52
|
+
if (e.classList.remove("opacity-40"), e.style.clipPath) {
|
|
53
|
+
e.style.clipPath = "none", e.style.transform = "none", e.style.overflow = "visible", e.style.borderRadius = "0", e.style.height = "100%";
|
|
54
|
+
for (const t of Array.from(e.querySelectorAll("*")))
|
|
55
|
+
t.style.clipPath && (t.style.clipPath = "none", t.style.borderRadius = "0");
|
|
56
|
+
}
|
|
57
|
+
for (const t of Array.from(e.querySelectorAll("[data-design-drop-indicator]"))) t.remove();
|
|
58
|
+
for (const t of ["role", "tabindex", "aria-describedby", "aria-pressed", "aria-hidden"])
|
|
59
|
+
e.removeAttribute(t);
|
|
60
|
+
return e.removeAttribute("data-header-folded"), e.setAttribute("inert", ""), Object.assign(e.style, { margin: "0", width: "100%", opacity: "1", outline: "none" }), e;
|
|
61
|
+
}
|
|
62
|
+
const P = 320;
|
|
63
|
+
function Ce({ node: c }) {
|
|
64
|
+
const e = $(null);
|
|
65
|
+
return re(() => {
|
|
66
|
+
const t = e.current;
|
|
67
|
+
if (t)
|
|
68
|
+
return t.replaceChildren(me(c)), () => t.replaceChildren();
|
|
69
|
+
}, [c]), /* @__PURE__ */ m(
|
|
70
|
+
"div",
|
|
71
|
+
{
|
|
72
|
+
ref: e,
|
|
73
|
+
"aria-hidden": !0,
|
|
74
|
+
"data-design-drag-preview": "",
|
|
75
|
+
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"
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
const K = { kind: "group", key: q }, Se = { droppable: { strategy: W.Always } }, we = {
|
|
80
|
+
start: [S.Space],
|
|
81
|
+
cancel: [S.Esc],
|
|
82
|
+
end: [S.Space, S.Enter, S.Tab]
|
|
83
|
+
}, De = { threshold: { x: 0.08, y: 0.15 }, acceleration: 12 }, ke = {
|
|
84
|
+
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."
|
|
85
|
+
};
|
|
86
|
+
function Me({
|
|
87
|
+
bundle: c,
|
|
88
|
+
apply: e,
|
|
89
|
+
onDragActive: t,
|
|
90
|
+
children: p
|
|
91
|
+
}) {
|
|
92
|
+
const [o] = I(() => new de());
|
|
93
|
+
o.bundle = c;
|
|
94
|
+
const C = $(e);
|
|
95
|
+
C.current = e;
|
|
96
|
+
const w = v(
|
|
97
|
+
() => ({
|
|
98
|
+
draggableProps: () => ({}),
|
|
99
|
+
isDragging: (n) => o.state.activeKey === b(n),
|
|
100
|
+
dropSlot: (n) => o.state.overKey === b(n) ? o.state.side : null,
|
|
101
|
+
dropIndicator: (n) => o.state.overKey === b(n) ? o.state.indicator : null
|
|
102
|
+
}),
|
|
103
|
+
[o]
|
|
104
|
+
), D = X(
|
|
105
|
+
U(J, { activationConstraint: { distance: 4 } }),
|
|
106
|
+
U(Q, {
|
|
107
|
+
coordinateGetter: ae,
|
|
108
|
+
keyboardCodes: we
|
|
109
|
+
})
|
|
110
|
+
), [y, L] = I(null), g = ne(
|
|
111
|
+
(n) => {
|
|
112
|
+
var i, d, f, u;
|
|
113
|
+
const r = O(n == null ? void 0 : n.data.current);
|
|
114
|
+
if (!r) return "this";
|
|
115
|
+
if (r.add) return r.add.label;
|
|
116
|
+
const l = r.target;
|
|
117
|
+
if (l.kind === "group")
|
|
118
|
+
return l.key === "__ungrouped__" ? "Ungrouped fields" : ((d = (i = o.bundle) == null ? void 0 : i.groups.find((h) => h.key === l.key)) == null ? void 0 : d.label) ?? "section";
|
|
119
|
+
const s = o.nodes.get(b(l));
|
|
120
|
+
return ((u = (f = s == null ? void 0 : s.querySelector("label, [data-header-label]")) == null ? void 0 : f.textContent) == null ? void 0 : u.trim()) || (l.kind === "slot" ? "panel" : "field");
|
|
121
|
+
},
|
|
122
|
+
[o]
|
|
123
|
+
), Y = v(
|
|
124
|
+
() => ({
|
|
125
|
+
onDragStart: ({ active: n }) => `Picked up ${g(n)}.`,
|
|
126
|
+
onDragOver: ({ active: n, over: r }) => r ? `${g(n)} is over ${g(r)}.` : `${g(n)} is not over a place it can go.`,
|
|
127
|
+
onDragEnd: ({ active: n, over: r }) => r ? `Dropped ${g(n)} by ${g(r)}.` : `Dropped ${g(n)}.`,
|
|
128
|
+
onDragCancel: ({ active: n }) => `Cancelled. ${g(n)} stays where it was.`
|
|
129
|
+
}),
|
|
130
|
+
[g]
|
|
131
|
+
), N = () => {
|
|
132
|
+
o.set(T), L(null), t == null || t(!1);
|
|
133
|
+
}, j = ({ active: n, activatorEvent: r }) => {
|
|
134
|
+
t == null || t(!0);
|
|
135
|
+
const l = O(n.data.current);
|
|
136
|
+
if (!l) return;
|
|
137
|
+
const s = b(l.target);
|
|
138
|
+
o.set({ ...T, activeKey: s });
|
|
139
|
+
const a = o.nodes.get(s);
|
|
140
|
+
if (!a || typeof document > "u") return;
|
|
141
|
+
const i = a.closest("[role=dialog]") ?? document.body, d = be(i), f = a.getBoundingClientRect(), u = te(r), h = u ? u.y - f.top : 0, x = f.height > P && h > P - 32 ? h - P / 2 : 0, z = ({ transform: A }) => ({
|
|
142
|
+
...A,
|
|
143
|
+
x: A.x - d.x,
|
|
144
|
+
y: A.y - d.y + x
|
|
145
|
+
});
|
|
146
|
+
L({ node: a, host: i, height: Math.min(f.height, P), shift: z });
|
|
147
|
+
}, k = $({
|
|
148
|
+
bundle: null,
|
|
149
|
+
map: /* @__PURE__ */ new Map()
|
|
150
|
+
}), _ = (n, r, l) => {
|
|
151
|
+
const s = O(n.data.current), a = O(r == null ? void 0 : r.data.current), i = he(l, r == null ? void 0 : r.id), d = o.bundle;
|
|
152
|
+
if (!s || !a || !i || !d || !r) return null;
|
|
153
|
+
k.current.bundle !== d && (k.current = { bundle: d, map: /* @__PURE__ */ new Map() });
|
|
154
|
+
const f = `${n.id}|${r.id}|${i.side}`;
|
|
155
|
+
let u = k.current.map.get(f);
|
|
156
|
+
return u || (u = s.add ? fe(d, s.add.field, a.target, i.side, s.add.patch) : ge(d, s.target, a.target, i.side), B(d, s.target, a.target) && !o.nodes.has(b(K)) && (u = []), k.current.map.set(f, u)), { a: s, o: a, hint: i, ops: u };
|
|
157
|
+
}, M = ({ active: n, over: r, collisions: l }) => {
|
|
158
|
+
var h, x;
|
|
159
|
+
const s = _(n, r, l);
|
|
160
|
+
if (!s || s.ops.length === 0 || !r) {
|
|
161
|
+
o.set({ overKey: null, side: null, indicator: null });
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
let { o: a, hint: i } = s, d = String(r.id);
|
|
165
|
+
o.bundle && B(o.bundle, s.a.target, a.target) && (d = b(K), a = {
|
|
166
|
+
target: K,
|
|
167
|
+
role: { kind: "group", key: q, parent: null, body: !0 }
|
|
168
|
+
}, i = { side: i.side, axis: "y", body: !1 });
|
|
169
|
+
const f = ((h = o.nodes.get(d)) == null ? void 0 : h.getBoundingClientRect().width) ?? 0, u = ((x = n.rect.current.initial) == null ? void 0 : x.width) ?? null;
|
|
170
|
+
o.set({
|
|
171
|
+
overKey: d,
|
|
172
|
+
side: i.side,
|
|
173
|
+
indicator: ye(i, a, f, u)
|
|
174
|
+
});
|
|
175
|
+
}, F = ({ active: n, over: r, collisions: l }) => {
|
|
176
|
+
var d;
|
|
177
|
+
const s = _(n, r, l), a = o.bundle;
|
|
178
|
+
if (N(), !(s != null && s.ops.length) || !a) return;
|
|
179
|
+
const i = s.a.add;
|
|
180
|
+
C.current(s.ops, { label: i ? `Add ${i.label}` : pe(a, s.a.target) }), (d = i == null ? void 0 : i.onAdded) == null || d.call(i, s.ops);
|
|
181
|
+
}, H = (n) => {
|
|
182
|
+
var l, s, a, i;
|
|
183
|
+
const r = (s = (l = n.target) == null ? void 0 : l.closest) == null ? void 0 : s.call(l, "[data-design-target]");
|
|
184
|
+
r && ((i = (a = o.activators.get(r)) == null ? void 0 : a()) == null || i(n));
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ m(ce.Provider, { value: o, children: /* @__PURE__ */ m(G.Provider, { value: w, children: /* @__PURE__ */ V(
|
|
187
|
+
Z,
|
|
188
|
+
{
|
|
189
|
+
sensors: D,
|
|
190
|
+
collisionDetection: le,
|
|
191
|
+
measuring: Se,
|
|
192
|
+
autoScroll: De,
|
|
193
|
+
accessibility: { announcements: Y, screenReaderInstructions: ke },
|
|
194
|
+
onDragStart: j,
|
|
195
|
+
onDragMove: M,
|
|
196
|
+
onDragOver: M,
|
|
197
|
+
onDragEnd: F,
|
|
198
|
+
onDragCancel: N,
|
|
199
|
+
children: [
|
|
200
|
+
/* @__PURE__ */ m("div", { className: "contents", onPointerDownCapture: H, children: p }),
|
|
201
|
+
y && ie(
|
|
202
|
+
/* @__PURE__ */ m(
|
|
203
|
+
ee,
|
|
204
|
+
{
|
|
205
|
+
dropAnimation: null,
|
|
206
|
+
zIndex: 1e3,
|
|
207
|
+
modifiers: [y.shift],
|
|
208
|
+
style: { height: y.height },
|
|
209
|
+
children: /* @__PURE__ */ m(Ce, { node: y.node })
|
|
210
|
+
}
|
|
211
|
+
),
|
|
212
|
+
y.host
|
|
213
|
+
)
|
|
214
|
+
]
|
|
215
|
+
}
|
|
216
|
+
) }) });
|
|
217
|
+
}
|
|
218
|
+
export {
|
|
219
|
+
Me as LayoutDndProvider,
|
|
220
|
+
ue as NO_DND,
|
|
221
|
+
me as designClone,
|
|
222
|
+
be as fixedOrigin,
|
|
223
|
+
ye as indicatorStyle,
|
|
224
|
+
_e as useLayoutDnd
|
|
225
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { UNGROUPED_KEY as w, isCanvasSlot as D } from "../../../lib/layout-ops.js";
|
|
2
|
+
const E = ["__apply_values__", "__create_with_defaults__"];
|
|
3
|
+
function G(t, e) {
|
|
4
|
+
switch (e.kind) {
|
|
5
|
+
case "field":
|
|
6
|
+
return { kind: "item", zone: e.group_key };
|
|
7
|
+
case "slot":
|
|
8
|
+
return D(e) ? { kind: "group", key: e.field, parent: null, body: !1 } : { kind: "item", zone: e.group_key };
|
|
9
|
+
case "header":
|
|
10
|
+
return { kind: "header" };
|
|
11
|
+
case "group": {
|
|
12
|
+
if (e.key === w) return { kind: "group", key: e.key, parent: null, body: !0 };
|
|
13
|
+
if (E.includes(e.key))
|
|
14
|
+
return { kind: "group", key: e.key, parent: null, body: !0 };
|
|
15
|
+
const n = t.groups.find((r) => r.key === e.key);
|
|
16
|
+
return n ? { kind: "group", key: n.key, parent: n.parent_key, body: n.type !== "container" } : null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function M(t, e) {
|
|
21
|
+
switch (t.kind) {
|
|
22
|
+
case "item":
|
|
23
|
+
return e.kind === "item" || e.kind === "body" || e.kind === "group" && e.body;
|
|
24
|
+
case "header":
|
|
25
|
+
return e.kind === "header";
|
|
26
|
+
case "group":
|
|
27
|
+
return e.kind === "group" && e.parent === t.parent;
|
|
28
|
+
case "body":
|
|
29
|
+
return !1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const S = (t) => t === w ? null : t;
|
|
33
|
+
function _(t) {
|
|
34
|
+
const e = t;
|
|
35
|
+
return e != null && e.target && e.role ? e : null;
|
|
36
|
+
}
|
|
37
|
+
const B = 24, h = (t) => ({ x: t.left + t.width / 2, y: t.top + t.height / 2 }), O = (t, e) => e.x >= t.left && e.x <= t.right && e.y >= t.top && e.y <= t.bottom, b = (t, e) => Math.hypot(Math.max(t.left - e.x, 0, e.x - t.right), Math.max(t.top - e.y, 0, e.y - t.bottom)), m = (t, e) => t.reduce(
|
|
38
|
+
(n, r) => !n || b(r.r, e) < b(n.r, e) ? r : n,
|
|
39
|
+
null
|
|
40
|
+
), K = (t, e) => t.kind === "item" && e.kind === "item" && t.zone === e.zone || t.kind === "group" && e.kind === "group" && t.parent === e.parent || t.kind === "header" && e.kind === "header";
|
|
41
|
+
function N(t, e) {
|
|
42
|
+
const n = t.r;
|
|
43
|
+
return e.some(
|
|
44
|
+
(o) => o !== t && K(o.d.role, t.d.role) && o.r.top < n.bottom - 1 && o.r.bottom > n.top + 1 && (o.r.left >= n.right - 1 || o.r.right <= n.left + 1)
|
|
45
|
+
) ? "x" : "y";
|
|
46
|
+
}
|
|
47
|
+
function U(t, e, n) {
|
|
48
|
+
const r = N(t, e), o = h(t.r);
|
|
49
|
+
return { axis: r, side: (r === "x" ? n.x < o.x : n.y < o.y) ? "before" : "after" };
|
|
50
|
+
}
|
|
51
|
+
function z(t, e, n) {
|
|
52
|
+
const r = [];
|
|
53
|
+
for (const o of t) {
|
|
54
|
+
if (o.disabled) continue;
|
|
55
|
+
const u = _(o.data.current), i = e.get(o.id);
|
|
56
|
+
u && i && M(n.role, u.role) && r.push({ c: o, d: u, r: i });
|
|
57
|
+
}
|
|
58
|
+
return r;
|
|
59
|
+
}
|
|
60
|
+
const g = (t, e) => ({
|
|
61
|
+
id: t.c.id,
|
|
62
|
+
data: { droppableContainer: t.c, hint: e }
|
|
63
|
+
}), H = (t) => {
|
|
64
|
+
var l, f;
|
|
65
|
+
const e = _(t.active.data.current);
|
|
66
|
+
if (!e) return [];
|
|
67
|
+
const n = t.pointerCoordinates ?? h(t.collisionRect), r = z(t.droppableContainers, t.droppableRects, e), o = (s) => e.role.kind === "item" && (s.d.role.kind === "group" || s.d.role.kind === "body");
|
|
68
|
+
let i = r.filter((s) => O(s.r, n)).sort((s, p) => s.r.width * s.r.height - p.r.width * p.r.height)[0] ?? null;
|
|
69
|
+
if (!i && (i = m(
|
|
70
|
+
r.filter((s) => !o(s)),
|
|
71
|
+
n
|
|
72
|
+
), !i || b(i.r, n) > B))
|
|
73
|
+
return [];
|
|
74
|
+
if (o(i) && (i.d.role.kind === "group" || i.d.role.kind === "body")) {
|
|
75
|
+
const s = ((f = (l = i.d).headerHeight) == null ? void 0 : f.call(l)) ?? 0;
|
|
76
|
+
if (s > 0 && n.y < i.r.top + s)
|
|
77
|
+
return [g(i, { side: "before", axis: "y", body: !0 })];
|
|
78
|
+
const p = S(i.d.role.key), c = r.filter((y) => y.d.role.kind === "item" && y.d.role.zone === p), a = m(c, n);
|
|
79
|
+
if (!a) return [g(i, { side: "after", axis: "y", body: !0 })];
|
|
80
|
+
i = a;
|
|
81
|
+
}
|
|
82
|
+
return [g(i, { ...U(i, r, n), body: !1 })];
|
|
83
|
+
}, F = ["ArrowDown", "ArrowRight"], L = ["ArrowUp", "ArrowLeft"], P = (t, e) => {
|
|
84
|
+
const n = F.includes(t.code);
|
|
85
|
+
if (!n && !L.includes(t.code)) return;
|
|
86
|
+
const { active: r, collisionRect: o, droppableRects: u, droppableContainers: i } = e.context, l = _(r == null ? void 0 : r.data.current);
|
|
87
|
+
if (!r || !o || !l) return;
|
|
88
|
+
t.preventDefault();
|
|
89
|
+
const f = z(i.getEnabled(), u, l), s = new Set(
|
|
90
|
+
f.flatMap((d) => d.d.role.kind === "item" ? [d.d.role.zone ?? w] : [])
|
|
91
|
+
), p = new Set(f.flatMap((d) => d.d.role.kind === "body" ? [d.d.role.key] : [])), c = f.filter((d) => l.role.kind !== "item" ? !0 : d.d.role.kind === "group" && p.has(d.d.role.key) ? !1 : d.d.role.kind !== "group" && d.d.role.kind !== "body" || !s.has(d.d.role.key)).sort((d, k) => d.r.top - k.r.top || d.r.left - k.r.left), a = h(o), y = c.filter((d) => O(d.r, a)).sort((d, k) => d.r.width * d.r.height - k.r.width * k.r.height)[0], x = y ? c.indexOf(y) : l.add ? n ? -1 : c.length : c.indexOf(m(c, a) ?? c[0]), C = c[x + (n ? 1 : -1)];
|
|
92
|
+
if (!C) return e.currentCoordinates;
|
|
93
|
+
const R = h(C.r), A = n ? 1 : -1;
|
|
94
|
+
return {
|
|
95
|
+
x: e.currentCoordinates.x + R.x + A - a.x,
|
|
96
|
+
y: e.currentCoordinates.y + R.y + A - a.y
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
export {
|
|
100
|
+
E as TABLE_FORM_ZONES,
|
|
101
|
+
M as accepts,
|
|
102
|
+
S as bodyZone,
|
|
103
|
+
G as dndRole,
|
|
104
|
+
_ as nodeData,
|
|
105
|
+
H as typedCollision,
|
|
106
|
+
P as typedKeyboardCoordinates
|
|
107
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var M = Object.defineProperty;
|
|
2
|
+
var P = (e, t, i) => t in e ? M(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var b = (e, t, i) => P(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { useDraggable as _, useDroppable as w } from "@dnd-kit/core";
|
|
5
|
+
import { createContext as H, useContext as S, useId as $, useRef as y, useCallback as R, useEffect as L, useSyncExternalStore as E } from "react";
|
|
6
|
+
import { isCanvasSlot as q } from "../../../lib/layout-ops.js";
|
|
7
|
+
import { targetKey as x } from "../design-context.js";
|
|
8
|
+
import { dndRole as B } from "./collision.js";
|
|
9
|
+
const z = { activeKey: null, overKey: null, side: null, indicator: null };
|
|
10
|
+
class Y {
|
|
11
|
+
constructor() {
|
|
12
|
+
b(this, "bundle", null);
|
|
13
|
+
b(this, "state", z);
|
|
14
|
+
/** Registered element → its pointer activator (dnd-kit's onPointerDown). */
|
|
15
|
+
b(this, "activators", /* @__PURE__ */ new WeakMap());
|
|
16
|
+
/** Droppable id → registered element (the overlay copies it, the drop line measures it). */
|
|
17
|
+
b(this, "nodes", /* @__PURE__ */ new Map());
|
|
18
|
+
b(this, "subs", /* @__PURE__ */ new Set());
|
|
19
|
+
b(this, "subscribe", (t) => (this.subs.add(t), () => {
|
|
20
|
+
this.subs.delete(t);
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
set(t) {
|
|
24
|
+
const i = { ...this.state, ...t }, n = this.state;
|
|
25
|
+
if (!(i.activeKey === n.activeKey && i.overKey === n.overKey && i.side === n.side && JSON.stringify(i.indicator) === JSON.stringify(n.indicator))) {
|
|
26
|
+
this.state = i;
|
|
27
|
+
for (const o of this.subs) o();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** What one node renders from: a node re-renders only when its slice changes. */
|
|
31
|
+
slice(t) {
|
|
32
|
+
const i = this.state, n = i.overKey === t ? `${i.side}${JSON.stringify(i.indicator)}` : "";
|
|
33
|
+
return `${i.activeKey === t ? 1 : 0}|${n}`;
|
|
34
|
+
}
|
|
35
|
+
/** Remember `el` under `id` (and forget the element it replaces). */
|
|
36
|
+
track(t, i, n) {
|
|
37
|
+
i && this.nodes.get(t) === i && this.nodes.delete(t), n && this.nodes.set(t, n);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const m = H(null), F = {
|
|
41
|
+
draggableProps: () => ({}),
|
|
42
|
+
isDragging: () => !1,
|
|
43
|
+
dropSlot: () => null
|
|
44
|
+
}, O = () => () => {
|
|
45
|
+
};
|
|
46
|
+
function G(e) {
|
|
47
|
+
if (!e) return 0;
|
|
48
|
+
if (e.hasAttribute("data-design-tab")) return e.getBoundingClientRect().height;
|
|
49
|
+
const t = Array.from(e.querySelectorAll("[data-design-group-header]")).find(
|
|
50
|
+
(i) => i.closest("[data-design-target]") === e
|
|
51
|
+
);
|
|
52
|
+
return t ? t.getBoundingClientRect().bottom - e.getBoundingClientRect().top : 0;
|
|
53
|
+
}
|
|
54
|
+
function tt(e, t, i = {}) {
|
|
55
|
+
var A, K;
|
|
56
|
+
const n = S(m), o = x(t), c = $(), l = y(null), s = n != null && n.bundle ? B(n.bundle, t) : null, a = !!n && !!s && !i.disabled && e !== F, u = a ? o : `${o}#${c}`, d = s ? {
|
|
57
|
+
target: t,
|
|
58
|
+
role: s,
|
|
59
|
+
headerHeight: s.kind === "group" ? () => G(l.current) : void 0
|
|
60
|
+
} : void 0, r = _({ id: u, data: d, disabled: !a }), v = w({ id: u, data: d, disabled: !a || !!i.noDrop });
|
|
61
|
+
E(
|
|
62
|
+
(n == null ? void 0 : n.subscribe) ?? O,
|
|
63
|
+
() => (n == null ? void 0 : n.slice(o)) ?? "",
|
|
64
|
+
() => ""
|
|
65
|
+
);
|
|
66
|
+
const D = y(r.listeners);
|
|
67
|
+
D.current = r.listeners;
|
|
68
|
+
const { setNodeRef: p, setActivatorNodeRef: k } = r, g = v.setNodeRef, J = R(
|
|
69
|
+
(f) => {
|
|
70
|
+
n == null || n.track(o, l.current, f), l.current = f, p(f), g(f), k(f), f && n && n.activators.set(
|
|
71
|
+
f,
|
|
72
|
+
() => {
|
|
73
|
+
var C;
|
|
74
|
+
return (C = D.current) == null ? void 0 : C.onPointerDown;
|
|
75
|
+
}
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
[o, k, p, g, n]
|
|
79
|
+
);
|
|
80
|
+
if (!n)
|
|
81
|
+
return {
|
|
82
|
+
props: e.draggableProps(t, i.disabled ? { disabled: !0 } : void 0),
|
|
83
|
+
dragging: e.isDragging(t),
|
|
84
|
+
slot: e.dropSlot(t),
|
|
85
|
+
indicator: ((A = e.dropIndicator) == null ? void 0 : A.call(e, t)) ?? null
|
|
86
|
+
};
|
|
87
|
+
const h = n.state, N = h.overKey === o;
|
|
88
|
+
return {
|
|
89
|
+
// The pointer activator is not spread here: LayoutDndProvider relays
|
|
90
|
+
// pointerdown to it. The keyboard one stays on the node.
|
|
91
|
+
props: a ? { ref: J, ...r.attributes, onKeyDown: (K = r.listeners) == null ? void 0 : K.onKeyDown } : {},
|
|
92
|
+
dragging: h.activeKey === o,
|
|
93
|
+
slot: N ? h.side : null,
|
|
94
|
+
indicator: N ? h.indicator : null
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function et(e) {
|
|
98
|
+
const t = S(m), i = `body:${e}`, n = t != null && t.bundle ? B(t.bundle, { kind: "group", key: e }) : null, o = (n == null ? void 0 : n.kind) === "group" && n.body, c = w({
|
|
99
|
+
id: i,
|
|
100
|
+
data: { target: { kind: "group", key: e }, role: { kind: "body", key: e } },
|
|
101
|
+
disabled: !o
|
|
102
|
+
});
|
|
103
|
+
E(
|
|
104
|
+
(t == null ? void 0 : t.subscribe) ?? O,
|
|
105
|
+
() => (t == null ? void 0 : t.slice(i)) ?? "",
|
|
106
|
+
() => ""
|
|
107
|
+
);
|
|
108
|
+
const l = y(null), s = c.setNodeRef, a = R(
|
|
109
|
+
(d) => {
|
|
110
|
+
const r = (d == null ? void 0 : d.parentElement) ?? null;
|
|
111
|
+
t == null || t.track(i, l.current, r), l.current = r, s(r), r && getComputedStyle(r).position === "static" && (r.style.position = "relative");
|
|
112
|
+
},
|
|
113
|
+
[i, s, t]
|
|
114
|
+
), u = (t == null ? void 0 : t.state.overKey) === i;
|
|
115
|
+
return {
|
|
116
|
+
ref: a,
|
|
117
|
+
slot: u ? (t == null ? void 0 : t.state.side) ?? null : null,
|
|
118
|
+
indicator: u ? (t == null ? void 0 : t.state.indicator) ?? null : null
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const I = "__add__";
|
|
122
|
+
function T(e, t) {
|
|
123
|
+
return t === "header" ? { kind: "header" } : q({ field: e, group_key: null }) ? { kind: "group", key: e, parent: null, body: !1 } : { kind: "item", zone: I };
|
|
124
|
+
}
|
|
125
|
+
const W = 400;
|
|
126
|
+
function nt(e) {
|
|
127
|
+
const t = S(m), i = $(), n = !!t && !!e, o = { kind: "field", field: (e == null ? void 0 : e.field) ?? i, group_key: I }, c = x(o), l = e ? {
|
|
128
|
+
target: o,
|
|
129
|
+
role: T(e.field, e.to),
|
|
130
|
+
add: {
|
|
131
|
+
field: e.field,
|
|
132
|
+
label: e.label,
|
|
133
|
+
patch: e.patch,
|
|
134
|
+
onAdded: e.onAdded
|
|
135
|
+
}
|
|
136
|
+
} : void 0, s = _({ id: n ? c : `${c}#${i}`, data: l, disabled: !n }), a = y(null), { setNodeRef: u, setActivatorNodeRef: d } = s, r = R(
|
|
137
|
+
(g) => {
|
|
138
|
+
t == null || t.track(c, a.current, g), a.current = g, u(g), d(g);
|
|
139
|
+
},
|
|
140
|
+
[c, d, u, t]
|
|
141
|
+
), v = y(0), D = y(!1);
|
|
142
|
+
L(() => {
|
|
143
|
+
D.current && !s.isDragging && (v.current = Date.now()), D.current = s.isDragging;
|
|
144
|
+
}, [s.isDragging]);
|
|
145
|
+
const p = s.isDragging, k = R(
|
|
146
|
+
() => p || Date.now() - v.current < W,
|
|
147
|
+
[p]
|
|
148
|
+
);
|
|
149
|
+
return {
|
|
150
|
+
props: n ? { ref: r, ...s.attributes, ...s.listeners } : {},
|
|
151
|
+
dragging: p,
|
|
152
|
+
clickBlocked: k
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
export {
|
|
156
|
+
Y as DndStore,
|
|
157
|
+
m as DndStoreContext,
|
|
158
|
+
z as IDLE,
|
|
159
|
+
F as NO_DND,
|
|
160
|
+
T as addRole,
|
|
161
|
+
nt as useAddDragSource,
|
|
162
|
+
tt as useDesignDndNode,
|
|
163
|
+
et as useDesignDropBody
|
|
164
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { UNGROUPED_KEY as h, isCanvasSlot as g, HEADER_GROUP_KEY as _, applyLayoutOps as D } from "../../../lib/layout-ops.js";
|
|
2
|
+
import { dndRole as m, bodyZone as E } from "./collision.js";
|
|
3
|
+
function I(t) {
|
|
4
|
+
try {
|
|
5
|
+
return D(t, [{ op: "layout_update", patch: {} }]);
|
|
6
|
+
} catch {
|
|
7
|
+
return t;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
const b = (t) => [...t].sort((e, n) => e.sort - n.sort);
|
|
11
|
+
function a(t, e) {
|
|
12
|
+
return b(t.placements.filter((n) => n.group_key === e && !g(n))).map((n) => ({
|
|
13
|
+
field: n.field,
|
|
14
|
+
group_key: n.group_key
|
|
15
|
+
}));
|
|
16
|
+
}
|
|
17
|
+
function M(t, e) {
|
|
18
|
+
const n = [
|
|
19
|
+
...t.groups.filter((r) => r.parent_key === e).map((r) => ({ key: r.key, sort: r.sort })),
|
|
20
|
+
...e === null ? t.placements.filter((r) => g(r)).map((r) => ({ key: r.field, sort: r.sort })) : []
|
|
21
|
+
];
|
|
22
|
+
return b(n).map((r) => r.key);
|
|
23
|
+
}
|
|
24
|
+
function K(t, e) {
|
|
25
|
+
const n = t.groups.find((r) => r.key === e);
|
|
26
|
+
return n ? n.parent_key : t.placements.some((r) => r.field === e && g(r)) ? null : void 0;
|
|
27
|
+
}
|
|
28
|
+
function O(t, e, n, r) {
|
|
29
|
+
const o = (l) => l.field === e.field && l.group_key === e.group_key, i = a(t, e.group_key);
|
|
30
|
+
if (!i.some(o)) return [];
|
|
31
|
+
if (n !== e.group_key && a(t, n).some((l) => l.field === e.field)) return [];
|
|
32
|
+
const u = a(t, n).filter((l) => !o(l)), d = r(u);
|
|
33
|
+
return d < 0 ? [] : n === e.group_key && d === i.findIndex(o) ? [] : [{ op: "move", from: e, to_group_key: n, index: d }];
|
|
34
|
+
}
|
|
35
|
+
function z(t, e, n) {
|
|
36
|
+
let r = e.kind === "group" ? e.key : e.kind === "item" ? e.zone ?? h : null;
|
|
37
|
+
for (let o = 0; r !== null && o < 8; o++) {
|
|
38
|
+
const i = K(t, r);
|
|
39
|
+
if (i === void 0) return null;
|
|
40
|
+
if (i === n) return r;
|
|
41
|
+
r = i;
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function R(t, e, n) {
|
|
46
|
+
if (e.kind !== "slot" || e.group_key === null || !g({ field: e.field, group_key: null })) return !1;
|
|
47
|
+
const r = m(t, n);
|
|
48
|
+
return (r == null ? void 0 : r.kind) === "item" && r.zone === null || (r == null ? void 0 : r.kind) === "group" && r.key === h;
|
|
49
|
+
}
|
|
50
|
+
function w(t, e, n, r) {
|
|
51
|
+
const o = I(t), i = m(o, e), u = m(o, n);
|
|
52
|
+
if (!i || !u) return [];
|
|
53
|
+
const d = r === "after" ? 1 : 0;
|
|
54
|
+
if (i.kind === "header") {
|
|
55
|
+
if (u.kind !== "header" || e.kind !== "header" || n.kind !== "header") return [];
|
|
56
|
+
const f = { field: e.field, group_key: _ };
|
|
57
|
+
return O(o, f, _, (k) => {
|
|
58
|
+
const p = k.findIndex((x) => x.field === n.field);
|
|
59
|
+
return p < 0 ? -1 : p + d;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
if (i.kind === "item") {
|
|
63
|
+
if (e.kind === "group" || e.kind === "header") return [];
|
|
64
|
+
const f = { field: e.field, group_key: i.zone };
|
|
65
|
+
if (R(o, e, n)) {
|
|
66
|
+
if (o.placements.some((p) => p.field === f.field && p.group_key === null)) return [];
|
|
67
|
+
const k = M(o, null).indexOf(h);
|
|
68
|
+
return k < 0 ? [] : [{ op: "move", from: f, to_group_key: null, index: k + d }];
|
|
69
|
+
}
|
|
70
|
+
return u.kind === "item" && (n.kind === "field" || n.kind === "slot") ? O(o, f, u.zone, (k) => {
|
|
71
|
+
const p = k.findIndex((x) => x.field === n.field);
|
|
72
|
+
return p < 0 ? -1 : p + d;
|
|
73
|
+
}) : u.kind === "group" && u.body ? O(o, f, E(u.key), (k) => d ? k.length : 0) : [];
|
|
74
|
+
}
|
|
75
|
+
if (i.kind !== "group") return [];
|
|
76
|
+
const l = M(o, i.parent), c = z(o, u, i.parent);
|
|
77
|
+
if (!c || c === i.key || !l.includes(i.key)) return [];
|
|
78
|
+
const y = l.filter((f) => f !== i.key).indexOf(c) + d;
|
|
79
|
+
return y === l.indexOf(i.key) ? [] : [{ op: "group_move", key: i.key, parent_key: i.parent, index: y }];
|
|
80
|
+
}
|
|
81
|
+
function C(t, e, n, r, o) {
|
|
82
|
+
const i = I(t), u = m(i, n);
|
|
83
|
+
if (!u) return [];
|
|
84
|
+
const d = r === "after" ? 1 : 0, l = (s, y) => y < 0 || i.placements.some((f) => f.field === e && f.group_key === s) ? [] : [{ op: "place", field: e, group_key: s, index: y, ...o ? { patch: o } : {} }], c = (s, y) => {
|
|
85
|
+
const f = a(i, s).findIndex((k) => k.field === y);
|
|
86
|
+
return f < 0 ? -1 : f + d;
|
|
87
|
+
};
|
|
88
|
+
if (u.kind === "header")
|
|
89
|
+
return n.kind === "header" ? l(_, c(_, n.field)) : [];
|
|
90
|
+
if (g({ field: e, group_key: null })) {
|
|
91
|
+
const s = z(i, u, null);
|
|
92
|
+
return s ? l(null, M(i, null).indexOf(s) + d) : [];
|
|
93
|
+
}
|
|
94
|
+
if (u.kind === "item" && (n.kind === "field" || n.kind === "slot"))
|
|
95
|
+
return l(u.zone, c(u.zone, n.field));
|
|
96
|
+
if (u.kind === "group" && u.body) {
|
|
97
|
+
const s = E(u.key);
|
|
98
|
+
return l(s, d ? a(i, s).length : 0);
|
|
99
|
+
}
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
function F(t, e) {
|
|
103
|
+
switch (e.kind) {
|
|
104
|
+
case "field":
|
|
105
|
+
return "Move field";
|
|
106
|
+
case "header":
|
|
107
|
+
return "Move header tile";
|
|
108
|
+
case "slot":
|
|
109
|
+
return e.group_key === null ? "Move panel" : "Move field";
|
|
110
|
+
case "group": {
|
|
111
|
+
if (e.key === h) return "Move ungrouped fields";
|
|
112
|
+
const n = t == null ? void 0 : t.groups.find((r) => r.key === e.key);
|
|
113
|
+
return n ? `Move ${n.type === "tab" ? "tab" : "section"} "${n.label}"` : "Move section";
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
export {
|
|
118
|
+
F as dropLabel,
|
|
119
|
+
R as landsOnCanvas,
|
|
120
|
+
w as orderAfterDrop,
|
|
121
|
+
C as placeAfterDrop
|
|
122
|
+
};
|