@nivaro/react 0.3.35 → 0.3.37

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.
Files changed (106) hide show
  1. package/dist/components/slots/CommentsSlot.js +44 -36
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useSessionRecorder.js +1 -1
  4. package/dist/index.d.ts +13 -4
  5. package/dist/shared/components/AgentBadge.js +26 -0
  6. package/dist/shared/components/AgentQuestionsCard.js +198 -0
  7. package/dist/shared/components/ItemEditForm.js +3329 -3263
  8. package/dist/shared/components/McpConnectionScope.js +480 -0
  9. package/dist/shared/components/MyWorkView.js +223 -208
  10. package/dist/shared/components/RecordReadView.js +620 -572
  11. package/dist/shared/components/chat/ChatPanel.js +683 -671
  12. package/dist/shared/components/imports/DownloadSampleButton.js +69 -0
  13. package/dist/shared/components/imports/ImportConsole.js +106 -104
  14. package/dist/shared/components/imports/RunDetailSheet.js +11 -10
  15. package/dist/shared/components/item-edit/FieldAffordances.js +32 -32
  16. package/dist/shared/components/item-edit/FormTour.js +279 -0
  17. package/dist/shared/components/item-edit/GroupSection.js +377 -360
  18. package/dist/shared/components/item-edit/PersonalDefaultControl.js +80 -63
  19. package/dist/shared/components/item-edit/entry/EntryStrip.js +30 -26
  20. package/dist/shared/components/item-edit/form-density.js +36 -0
  21. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -46
  22. package/dist/shared/components/item-edit/usePersonalDefaults.js +312 -296
  23. package/dist/shared/components/layout-editor/AddPanel.js +349 -192
  24. package/dist/shared/components/layout-editor/DesignNode.js +146 -131
  25. package/dist/shared/components/layout-editor/EditorCanvas.js +25 -17
  26. package/dist/shared/components/layout-editor/EditorTopBar.js +268 -206
  27. package/dist/shared/components/layout-editor/LayoutEditor.js +810 -731
  28. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  29. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  30. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  31. package/dist/shared/components/layout-editor/add-target.js +54 -43
  32. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  33. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  34. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  35. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +379 -185
  36. package/dist/shared/components/layout-editor/dnd/TrashZone.js +96 -0
  37. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  38. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  39. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  40. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  41. package/dist/shared/components/layout-editor/dnd/rail-drop.js +4 -4
  42. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  43. package/dist/shared/components/layout-editor/dnd/trash-drop.js +58 -0
  44. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  45. package/dist/shared/components/layout-editor/even-row.js +86 -0
  46. package/dist/shared/components/layout-editor/field-list.js +99 -0
  47. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  48. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  49. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  50. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  51. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  52. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  53. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  54. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  55. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  56. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  57. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  58. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  59. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  60. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  61. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  62. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  63. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  64. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  65. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  66. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  67. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  68. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  69. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  70. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  71. package/dist/shared/components/layout-editor/panel-frame.js +1 -1
  72. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  73. package/dist/shared/components/layout-editor/personal-default-marks.js +40 -0
  74. package/dist/shared/components/layout-editor/pin.js +37 -19
  75. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  76. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  77. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +149 -118
  78. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  79. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  80. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  81. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  82. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  83. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  84. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  85. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  86. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  87. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  88. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  89. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  90. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  91. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  92. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  93. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  94. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  95. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  96. package/dist/shared/components/panels/CommentPanel.js +47 -45
  97. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  98. package/dist/shared/components/panels/TaskPanel.js +395 -332
  99. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  100. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  101. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  102. package/dist/shared/lib/entry-config.js +22 -22
  103. package/dist/shared/lib/form-usage-beacon.js +91 -55
  104. package/dist/shared/lib/layout-lint.js +530 -284
  105. package/dist/shared/lib/layout-resolve.js +58 -44
  106. package/package.json +1 -1
@@ -1,229 +1,416 @@
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 S, jsxs as ae } from "react/jsx-runtime";
2
+ import { useSensors as Ue, useSensor as te, TouchSensor as _e, KeyboardSensor as ve, KeyboardCode as H, DndContext as Be, MeasuringStrategy as je, DragOverlay as He } from "@dnd-kit/core";
3
+ import { getEventCoordinates as ye } from "@dnd-kit/utilities";
4
+ import { Plus as Ge } from "lucide-react";
5
+ import { useState as I, useRef as E, useMemo as he, useCallback as G, useEffect as qe, createContext as Ye, useSyncExternalStore as be, useLayoutEffect as ze, useContext as Ve } from "react";
6
+ import { createPortal as ne } from "react-dom";
7
+ import { UNGROUPED_KEY as Ee } from "../../../lib/layout-ops.js";
8
+ import { targetKey as P } from "../design-context.js";
9
+ import { mergePlan as Fe, mergeBlocked as Xe } from "../section-structure.js";
10
+ import { typedKeyboardCoordinates as Ze, nodeData as L, dndRole as we } from "./collision.js";
11
+ import { mergeAwareCollision as Je, mergeIndicatorStyle as Qe } from "./merge-drop.js";
12
+ import { manyLabel as ke, carriedTargets as We, dropMany as et, copyAfterDrop as tt } from "./multi-drop.js";
13
+ import { DndStore as nt, DndStoreContext as rt, NO_DND as ot, IDLE as Ce } from "./node.js";
14
+ import { landsOnCanvas as Se, placeAfterDrop as at, orderAfterDrop as st, dropLabel as lt } from "./order.js";
15
+ import { railDropData as De, copyableGroup as xe, railAwareCollision as it } from "./rail-drop.js";
16
+ import { MousePointerSensor as ct, MOUSE_ACTIVATION as dt, TOUCH_ACTIVATION as ut } from "./sensors.js";
17
+ import { TrashZone as pt } from "./TrashZone.js";
18
+ import { trashAwareCollision as gt, TRASH_DROP_ID as se, trashDropData as F, trashPlan as re, trashPlanMany as $e } from "./trash-drop.js";
19
+ import { UndoChip as ft } from "./UndoChip.js";
20
+ const Oe = Ye(ot);
21
+ function Ht() {
22
+ return Ve(Oe);
15
23
  }
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 };
24
+ const X = 3, Z = 20;
25
+ function mt(g, n, o, d) {
26
+ var y, R;
27
+ if (g.merge) return Qe(((y = n.headerHeight) == null ? void 0 : y.call(n)) ?? 0);
28
+ if (g.body) {
29
+ const O = o - 2 * Z, r = d && O > 0 ? Math.min(d, O) : void 0, M = r ? { left: Z, width: r } : { left: Z, right: Z };
30
+ return g.side === "before" ? { top: (((R = n.headerHeight) == null ? void 0 : R.call(n)) ?? 0) + 4, height: X, ...M } : { bottom: 8, height: X, ...M };
22
31
  }
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;
32
+ if (g.axis === "x")
33
+ return { top: 0, bottom: 0, width: X, [g.side === "before" ? "left" : "right"]: -4 };
34
+ const m = n.role.kind === "item" && d && o ? Math.min(d, o) : void 0;
26
35
  return {
27
- [u.side === "before" ? "top" : "bottom"]: -6,
28
- height: A,
36
+ [g.side === "before" ? "top" : "bottom"]: -6,
37
+ height: X,
29
38
  left: 0,
30
- ...y ? { width: y } : { right: 0 }
39
+ ...m ? { width: m } : { right: 0 }
31
40
  };
32
41
  }
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;
42
+ const yt = (g, n) => {
43
+ var o, d;
44
+ return ((d = (o = (g ?? []).find((m) => m.id === n)) == null ? void 0 : o.data) == null ? void 0 : d.hint) ?? null;
36
45
  };
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 };
46
+ function Ae(g) {
47
+ for (let n = g; n && n !== document.documentElement; ) {
48
+ const o = getComputedStyle(n);
49
+ 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 ?? "")) {
50
+ const m = n.getBoundingClientRect();
51
+ return { x: m.left + n.clientLeft - n.scrollLeft, y: m.top + n.clientTop - n.scrollTop };
43
52
  }
44
- t = t.parentElement;
53
+ n = n.parentElement;
45
54
  }
46
55
  return { x: 0, y: 0 };
47
56
  }
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");
57
+ function ht(g) {
58
+ const n = g.cloneNode(!0);
59
+ for (const o of [n, ...Array.from(n.querySelectorAll("*"))])
60
+ for (const d of ["data-design-target", "data-selected", "data-drop-slot", "id"])
61
+ o.removeAttribute(d);
62
+ if (n.classList.remove("opacity-40"), n.style.clipPath) {
63
+ n.style.clipPath = "none", n.style.transform = "none", n.style.overflow = "visible", n.style.borderRadius = "0", n.style.height = "100%";
64
+ for (const o of Array.from(n.querySelectorAll("*")))
65
+ o.style.clipPath && (o.style.clipPath = "none", o.style.borderRadius = "0");
57
66
  }
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;
67
+ for (const o of Array.from(n.querySelectorAll("[data-design-drop-indicator]"))) o.remove();
68
+ for (const o of ["role", "tabindex", "aria-describedby", "aria-pressed", "aria-hidden"])
69
+ n.removeAttribute(o);
70
+ return n.removeAttribute("data-header-folded"), n.setAttribute("inert", ""), Object.assign(n.style, { margin: "0", width: "100%", opacity: "1", outline: "none" }), n;
62
71
  }
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(
72
+ const J = 320;
73
+ function bt({
74
+ node: g,
75
+ store: n,
76
+ count: o
77
+ }) {
78
+ const d = E(null), m = be(
79
+ n.subscribe,
80
+ G(() => n.state.overKey === se, [n]),
81
+ () => !1
82
+ ), y = be(
83
+ n.subscribe,
84
+ G(() => n.state.copy, [n]),
85
+ () => !1
86
+ );
87
+ ze(() => {
88
+ const O = d.current;
89
+ if (O)
90
+ return O.replaceChildren(ht(g)), () => O.replaceChildren();
91
+ }, [g]);
92
+ const R = o > 1 || y ? /* @__PURE__ */ ae(
93
+ "span",
94
+ {
95
+ "data-design-drag-badge": y ? "copy" : "count",
96
+ className: "absolute -right-2 -top-2 z-10 inline-flex h-6 min-w-6 items-center justify-center gap-0.5 rounded-full bg-nvr-cyan px-1.5 text-[11.5px] font-semibold text-white shadow-md ring-2 ring-white dark:ring-[#0f172a]",
97
+ children: [
98
+ y && /* @__PURE__ */ S(Ge, { "aria-hidden": !0, className: "h-3 w-3" }),
99
+ o > 1 ? o : y ? "Copy" : null
100
+ ]
101
+ }
102
+ ) : null;
103
+ return /* @__PURE__ */ ae(
71
104
  "div",
72
105
  {
73
- ref: t,
74
106
  "aria-hidden": !0,
75
107
  "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"
108
+ "data-over-trash": m ? "" : void 0,
109
+ "data-copy": y ? "" : void 0,
110
+ style: {
111
+ transformOrigin: "top left",
112
+ transform: m ? "scale(0.4)" : void 0,
113
+ opacity: m ? 0.45 : void 0
114
+ },
115
+ className: "pointer-events-none relative h-full w-full cursor-grabbing transition-[transform,opacity] duration-150 ease-out motion-reduce:transition-none",
116
+ children: [
117
+ o > 1 && /* @__PURE__ */ S("span", { className: "absolute inset-0 translate-x-1.5 translate-y-1.5 rounded-lg bg-white shadow-lg ring-1 ring-slate-900/10 dark:bg-card dark:ring-white/10" }),
118
+ /* @__PURE__ */ S(
119
+ "div",
120
+ {
121
+ ref: d,
122
+ className: "relative h-full w-full overflow-hidden rounded-lg bg-white shadow-xl ring-1 ring-slate-900/10 dark:bg-card dark:ring-white/10"
123
+ }
124
+ ),
125
+ R,
126
+ y && /* @__PURE__ */ S("style", { children: "*{cursor:copy !important}" })
127
+ ]
77
128
  }
78
129
  );
79
130
  }
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 = {
85
- 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."
131
+ const oe = { kind: "group", key: Ee }, wt = { droppable: { strategy: je.Always } }, kt = {
132
+ start: [H.Space],
133
+ cancel: [H.Esc],
134
+ end: [H.Space, H.Enter, H.Tab]
135
+ }, Ct = {
136
+ 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. Hold Alt to copy instead of moving."
86
137
  };
87
- function qt({
88
- bundle: u,
89
- apply: t,
90
- onDragActive: e,
91
- onDropOnLayout: p,
92
- children: y
138
+ function Gt({
139
+ bundle: g,
140
+ apply: n,
141
+ onDragActive: o,
142
+ onDropOnLayout: d,
143
+ selection: m,
144
+ undo: y,
145
+ warnTrash: R,
146
+ children: O
93
147
  }) {
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(
148
+ const [r] = I(() => new nt());
149
+ r.bundle = g;
150
+ const M = E(n);
151
+ M.current = n;
152
+ const U = E(d);
153
+ U.current = d;
154
+ const le = E(m ?? []);
155
+ le.current = m ?? [];
156
+ const q = E(R);
157
+ q.current = R;
158
+ const Q = E(y);
159
+ Q.current = y;
160
+ const h = E([]), [Pe] = I(
161
+ () => gt(
162
+ Je(
163
+ it(
164
+ (e) => !!U.current && xe(r.bundle, e) != null
165
+ ),
166
+ (e, t) => !r.state.copy && e.target.kind === "group" && t.target.kind === "group" && !!r.bundle && Xe(r.bundle, e.target.key, t.target.key) === null
167
+ ),
168
+ (e) => re(r.bundle, e) != null
169
+ )
170
+ ), [Re] = I(() => ({
171
+ threshold: { x: 0.08, y: 0.15 },
172
+ acceleration: 12,
173
+ canScroll: () => r.state.overKey !== se
174
+ })), [_, ie] = I(null), [w, W] = I(null), Ke = he(
103
175
  () => ({
104
176
  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
177
+ isDragging: (e) => r.isCarried(P(e)),
178
+ dropSlot: (e) => r.state.overKey === P(e) ? r.state.side : null,
179
+ dropIndicator: (e) => r.state.overKey === P(e) ? r.state.indicator : null
108
180
  }),
109
- [o]
110
- ), V = tt(
111
- T(et, { activationConstraint: { distance: 4 } }),
112
- T(nt, {
113
- coordinateGetter: ft,
114
- keyboardCodes: Ot
181
+ [r]
182
+ ), Le = Ue(
183
+ te(ct, { activationConstraint: dt }),
184
+ te(_e, { activationConstraint: ut }),
185
+ te(ve, {
186
+ coordinateGetter: Ze,
187
+ keyboardCodes: kt
115
188
  })
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;
123
- 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");
189
+ ), [x, ce] = I(null), Y = G(
190
+ (e) => {
191
+ var s, c, l, p;
192
+ if (!e) return "this";
193
+ if (e.add) return e.add.label;
194
+ const t = e.target;
195
+ if (t.kind === "group")
196
+ return t.key === "__ungrouped__" ? "Ungrouped fields" : ((c = (s = r.bundle) == null ? void 0 : s.groups.find((f) => f.key === t.key)) == null ? void 0 : c.label) ?? "section";
197
+ const i = r.nodes.get(P(t));
198
+ return ((p = (l = i == null ? void 0 : i.querySelector("label, [data-header-label]")) == null ? void 0 : l.textContent) == null ? void 0 : p.replace(/\s*\*\s*$/, "").trim()) || (t.kind === "slot" ? "panel" : "field");
127
199
  },
128
- [o]
129
- ), X = B(
200
+ [r]
201
+ ), K = G(
202
+ (e) => Y(L(e == null ? void 0 : e.data.current)),
203
+ [Y]
204
+ ), k = G(
205
+ (e) => h.current.length > 1 ? ke(h.current, "move").replace(/^Move /, "") : K(e),
206
+ [K]
207
+ ), Me = he(
130
208
  () => ({
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.`
209
+ onDragStart: ({ active: e }) => `Picked up ${k(e)}.`,
210
+ onDragOver: ({ active: e, over: t }) => t && F(t.data.current) ? `${k(e)} is over Remove. Drop it to take it off this form.` : t && r.state.merge && r.state.overKey === String(t.id) ? `${k(e)} is over ${K(t)}. Drop it to join them.` : t ? `${k(e)} is over ${K(t)}${r.state.copy ? ". Dropping copies it" : ""}.` : `${k(e)} is not over a place it can go.`,
211
+ onDragEnd: ({ active: e, over: t }) => t && F(t.data.current) ? `Removed ${k(e)} from this form. Undo brings it back.` : t ? `Dropped ${k(e)} by ${K(t)}.` : `Dropped ${k(e)}.`,
212
+ onDragCancel: ({ active: e }) => `Cancelled. ${k(e)} stays where it was.`
135
213
  }),
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);
142
- 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
214
+ [K, k, r]
215
+ ), N = E(null), z = () => {
216
+ r.set(Ce), h.current = [], N.current = null, ce(null), ie(null), o == null || o(!1);
217
+ }, Ne = ({ active: e, activatorEvent: t }) => {
218
+ var T;
219
+ o == null || o(!0), W(null);
220
+ const i = L(e.data.current);
221
+ if (!i) return;
222
+ const a = P(i.target), s = r.bundle;
223
+ h.current = i.add ? [i.target] : We(s, le.current, i.target);
224
+ const c = h.current.length > 1, l = !i.add && !!(t != null && t.altKey);
225
+ r.set({
226
+ ...Ce,
227
+ activeKey: a,
228
+ carried: c ? h.current.map(P) : null,
229
+ copy: l
230
+ });
231
+ const p = c ? $e(
232
+ s,
233
+ h.current.map((D) => {
234
+ const j = s ? we(s, D) : null;
235
+ return j ? { target: D, role: j } : null;
236
+ })
237
+ ) : re(s, i);
238
+ ie(
239
+ p && s ? {
240
+ plan: p,
241
+ name: c ? k(e) : K(e),
242
+ warning: ((T = q.current) == null ? void 0 : T.call(q, s, p.ops)) ?? null
243
+ } : null
244
+ );
245
+ const f = r.nodes.get(a);
246
+ if (!f || typeof document > "u") return;
247
+ const C = f.closest("[role=dialog]") ?? document.body, b = Ae(C), u = f.getBoundingClientRect(), $ = ye(t), A = $ ? $.y - u.top : 0, V = u.height > J && A > J - 32 ? A - J / 2 : 0, B = ({ transform: D }) => ({
248
+ ...D,
249
+ x: D.x - b.x,
250
+ y: D.y - b.y + V
151
251
  });
152
- M({ node: s, host: l, height: Math.min(c.height, R), shift: v });
153
- }, E = K({
252
+ ce({ node: f, host: C, height: Math.min(u.height, J), shift: B });
253
+ }, v = E({
154
254
  bundle: null,
155
255
  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 });
256
+ }), de = (e, t, i) => {
257
+ const a = L(e.data.current), s = L(t == null ? void 0 : t.data.current), c = yt(i, t == null ? void 0 : t.id), l = r.bundle;
258
+ if (!a || !s || !c || !l || !t) return null;
259
+ v.current.bundle !== l && (v.current = { bundle: l, map: /* @__PURE__ */ new Map() });
260
+ const p = r.state.copy && !a.add ? "copy" : "move", f = h.current.length > 1, C = `${e.id}|${t.id}|${c.side}|${c.merge ? "join" : ""}|${p}|${f ? h.current.length : 1}`;
261
+ if (v.current.map.has(C)) return v.current.map.get(C) ?? null;
262
+ let b = [], u = "";
263
+ if (c.merge && a.target.kind === "group" && s.target.kind === "group") {
264
+ const A = Fe(l, a.target.key, s.target.key);
265
+ A.ok && (b = A.ops, u = A.label);
266
+ } else a.add ? (b = at(l, a.add.field, s.target, c.side, a.add.patch), u = `Add ${a.add.label}`) : f ? (b = et(l, h.current, s.target, c.side, p), u = ke(h.current, p)) : p === "copy" ? (b = tt(l, a.target, s.target, c.side), u = St(l, a.target, Y(a))) : (b = st(l, a.target, s.target, c.side), u = lt(l, a.target), Se(l, a.target, s.target) && !r.nodes.has(P(oe)) && (b = []));
267
+ const $ = { a, o: s, hint: c, ops: b, label: u };
268
+ return v.current.map.set(C, $), $;
269
+ }, ee = (e) => {
270
+ var u, $;
271
+ N.current = e;
272
+ const { active: t, over: i, collisions: a } = e;
273
+ if (i && F(i.data.current)) {
274
+ r.set({ overKey: se, side: null, indicator: null, merge: null });
275
+ return;
276
+ }
277
+ if (i && De(i.data.current)) {
278
+ r.set({ overKey: String(i.id), side: null, indicator: null, merge: null });
167
279
  return;
168
280
  }
169
- const a = I(n, r, d);
170
- if (!a || a.ops.length === 0 || !r) {
171
- o.set({ overKey: null, side: null, indicator: null });
281
+ const s = de(t, i, a);
282
+ if (!s || s.ops.length === 0 || !i) {
283
+ r.set({ overKey: null, side: null, indicator: null, merge: null });
172
284
  return;
173
285
  }
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 = {
176
- target: L,
177
- role: { kind: "group", key: z, parent: null, body: !0 }
286
+ let { o: c, hint: l } = s, p = String(i.id);
287
+ h.current.length <= 1 && !r.state.copy && !l.merge && r.bundle && Se(r.bundle, s.a.target, c.target) && (p = P(oe), c = {
288
+ target: oe,
289
+ role: { kind: "group", key: Ee, parent: null, body: !0 }
178
290
  }, 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,
291
+ const C = ((u = r.nodes.get(p)) == null ? void 0 : u.getBoundingClientRect().width) ?? 0, b = (($ = t.rect.current.initial) == null ? void 0 : $.width) ?? null;
292
+ r.set({
293
+ overKey: p,
182
294
  side: l.side,
183
- indicator: St(l, s, c, f)
295
+ indicator: mt(l, c, C, b),
296
+ merge: l.merge ? Y(c) : null
184
297
  });
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));
298
+ }, ue = x != null || _ != null;
299
+ qe(() => {
300
+ if (!ue) return;
301
+ const e = (a) => {
302
+ if (!r.state.activeKey || r.state.copy === a) return;
303
+ const s = N.current ? L(N.current.active.data.current) : null;
304
+ s != null && s.add || (r.set({ copy: a }), N.current && ee(N.current));
305
+ }, t = (a) => {
306
+ a.key === "Alt" && (a.preventDefault(), e(a.type === "keydown"));
307
+ }, i = (a) => e(a.altKey);
308
+ return window.addEventListener("keydown", t, !0), window.addEventListener("keyup", t, !0), window.addEventListener("pointermove", i, !0), () => {
309
+ window.removeEventListener("keydown", t, !0), window.removeEventListener("keyup", t, !0), window.removeEventListener("pointermove", i, !0);
310
+ };
311
+ }, [ue, r]);
312
+ const Te = ({ active: e, over: t, collisions: i, activatorEvent: a, delta: s }) => {
313
+ var C, b;
314
+ if (F(t == null ? void 0 : t.data.current)) {
315
+ const u = r.bundle, A = h.current.length > 1 ? $e(
316
+ u,
317
+ h.current.map((fe) => {
318
+ const me = u ? we(u, fe) : null;
319
+ return me ? { target: fe, role: me } : null;
320
+ })
321
+ ) : re(u, L(e.data.current)), V = k(e), B = r.nodes.get(String(e.id)), T = (B == null ? void 0 : B.closest("[role=dialog]")) ?? (typeof document > "u" ? null : document.body), D = ye(a);
322
+ if (z(), !A) return;
323
+ const j = `Remove ${V}`;
324
+ M.current(A.ops, { label: j }), Q.current && T && D && W({
325
+ label: V,
326
+ applied: j,
327
+ point: { x: D.x + s.x, y: D.y + s.y },
328
+ host: T,
329
+ origin: Ae(T),
330
+ armed: !1
331
+ });
191
332
  return;
192
333
  }
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));
334
+ const c = De(t == null ? void 0 : t.data.current);
335
+ if (c) {
336
+ const u = xe(r.bundle, L(e.data.current));
337
+ z(), u && ((C = U.current) == null || C.call(U, u, c.railLayoutId));
338
+ return;
339
+ }
340
+ const l = de(e, t, i), p = r.bundle;
341
+ if (z(), !(l != null && l.ops.length) || !p) return;
342
+ const f = l.a.add;
343
+ M.current(l.ops, { label: l.label }), (b = f == null ? void 0 : f.onAdded) == null || b.call(f, l.ops);
344
+ }, pe = (y == null ? void 0 : y.label) ?? null;
345
+ w && !w.armed && pe === w.applied && (w.armed = !0);
346
+ const Ie = !!w && (!w.armed || pe === w.applied), ge = (e) => {
347
+ var a, s, c, l, p, f;
348
+ if ((s = (a = e.target) == null ? void 0 : a.closest) != null && s.call(a, "[data-design-resize]")) return;
349
+ const t = (l = (c = e.target) == null ? void 0 : c.closest) == null ? void 0 : l.call(c, "[data-design-target]");
350
+ if (!t) return;
351
+ const i = (p = r.activators.get(t)) == null ? void 0 : p();
352
+ (f = i == null ? void 0 : i[e.type === "touchstart" ? "onTouchStart" : "onPointerDown"]) == null || f.call(i, e);
202
353
  };
203
- return /* @__PURE__ */ C(gt.Provider, { value: o, children: /* @__PURE__ */ C(F.Provider, { value: H, children: /* @__PURE__ */ W(
204
- rt,
354
+ return /* @__PURE__ */ S(rt.Provider, { value: r, children: /* @__PURE__ */ S(Oe.Provider, { value: Ke, children: /* @__PURE__ */ ae(
355
+ Be,
205
356
  {
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: $,
357
+ sensors: Le,
358
+ collisionDetection: Pe,
359
+ measuring: wt,
360
+ autoScroll: Re,
361
+ accessibility: { announcements: Me, screenReaderInstructions: Ct },
362
+ onDragStart: Ne,
363
+ onDragMove: ee,
364
+ onDragOver: ee,
365
+ onDragEnd: Te,
366
+ onDragCancel: z,
216
367
  children: [
217
- /* @__PURE__ */ C("div", { className: "contents", onPointerDownCapture: Z, children: y }),
218
- w && ut(
219
- /* @__PURE__ */ C(
220
- st,
368
+ /* @__PURE__ */ S("div", { className: "contents", onPointerDownCapture: ge, onTouchStartCapture: ge, children: O }),
369
+ x && ne(
370
+ /* @__PURE__ */ S(
371
+ He,
221
372
  {
222
373
  dropAnimation: null,
223
374
  zIndex: 1e3,
224
- modifiers: [w.shift],
225
- style: { height: w.height },
226
- children: /* @__PURE__ */ C(xt, { node: w.node })
375
+ modifiers: [x.shift],
376
+ style: { height: x.height },
377
+ children: /* @__PURE__ */ S(
378
+ bt,
379
+ {
380
+ node: x.node,
381
+ store: r,
382
+ count: Math.max(1, h.current.length)
383
+ }
384
+ )
385
+ }
386
+ ),
387
+ x.host
388
+ ),
389
+ _ && ne(
390
+ /* @__PURE__ */ S(
391
+ pt,
392
+ {
393
+ store: r,
394
+ plan: _.plan,
395
+ name: _.name,
396
+ warning: _.warning
397
+ }
398
+ ),
399
+ (x == null ? void 0 : x.host) ?? document.body
400
+ ),
401
+ w && y && ne(
402
+ /* @__PURE__ */ S(
403
+ ft,
404
+ {
405
+ label: w.label,
406
+ point: w.point,
407
+ origin: w.origin,
408
+ stillUndoable: Ie,
409
+ onUndo: () => {
410
+ var e;
411
+ return (e = Q.current) == null ? void 0 : e.run();
412
+ },
413
+ onClose: () => W(null)
227
414
  }
228
415
  ),
229
416
  w.host
@@ -232,11 +419,18 @@ function qt({
232
419
  }
233
420
  ) }) });
234
421
  }
422
+ function St(g, n, o) {
423
+ if (n.kind === "group") {
424
+ const d = g.groups.find((m) => m.key === n.key);
425
+ return `Copy ${(d == null ? void 0 : d.type) === "tab" ? "tab" : "section"} "${(d == null ? void 0 : d.label) || o}"`;
426
+ }
427
+ return `Copy ${o}`;
428
+ }
235
429
  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
430
+ Gt as LayoutDndProvider,
431
+ ot as NO_DND,
432
+ ht as designClone,
433
+ Ae as fixedOrigin,
434
+ mt as indicatorStyle,
435
+ Ht as useLayoutDnd
242
436
  };