@nivaro/react 0.3.36 → 0.3.38

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 (102) 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 +9 -1
  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 -575
  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 +34 -32
  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 +28 -28
  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 +126 -112
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +123 -103
  26. package/dist/shared/components/layout-editor/LayoutEditor.js +829 -751
  27. package/dist/shared/components/layout-editor/PlaceTools.js +334 -0
  28. package/dist/shared/components/layout-editor/SlashInsert.js +252 -0
  29. package/dist/shared/components/layout-editor/StructureMenu.js +285 -242
  30. package/dist/shared/components/layout-editor/add-target.js +54 -43
  31. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +238 -155
  32. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +1 -1
  33. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +15 -12
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +347 -189
  35. package/dist/shared/components/layout-editor/dnd/TrashZone.js +60 -32
  36. package/dist/shared/components/layout-editor/dnd/UndoChip.js +76 -0
  37. package/dist/shared/components/layout-editor/dnd/merge-drop.js +33 -0
  38. package/dist/shared/components/layout-editor/dnd/multi-drop.js +87 -0
  39. package/dist/shared/components/layout-editor/dnd/node.js +115 -105
  40. package/dist/shared/components/layout-editor/dnd/sensors.js +23 -0
  41. package/dist/shared/components/layout-editor/dnd/trash-drop.js +34 -28
  42. package/dist/shared/components/layout-editor/dnd/trash-links.js +97 -0
  43. package/dist/shared/components/layout-editor/even-row.js +86 -0
  44. package/dist/shared/components/layout-editor/field-list.js +99 -0
  45. package/dist/shared/components/layout-editor/format-painter.js +102 -0
  46. package/dist/shared/components/layout-editor/grid-guides.js +15 -13
  47. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +150 -132
  48. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +57 -53
  49. package/dist/shared/components/layout-editor/inspector/EvenRowAction.js +31 -0
  50. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +154 -141
  51. package/dist/shared/components/layout-editor/inspector/Inspector.js +209 -178
  52. package/dist/shared/components/layout-editor/inspector/LookTab.js +106 -98
  53. package/dist/shared/components/layout-editor/inspector/RulesTab.js +38 -37
  54. package/dist/shared/components/layout-editor/inspector/kit.js +280 -223
  55. package/dist/shared/components/layout-editor/keyboard-move.js +15 -15
  56. package/dist/shared/components/layout-editor/lint/LabelStyle.js +201 -0
  57. package/dist/shared/components/layout-editor/lint/LintPanel.js +132 -84
  58. package/dist/shared/components/layout-editor/lint/lint-api.js +65 -28
  59. package/dist/shared/components/layout-editor/nav/NavTools.js +14 -12
  60. package/dist/shared/components/layout-editor/nav/ZoomControls.js +145 -0
  61. package/dist/shared/components/layout-editor/nav/useEditorNav.js +34 -32
  62. package/dist/shared/components/layout-editor/nav/view-prefs.js +100 -15
  63. package/dist/shared/components/layout-editor/outputs/LayoutFile.js +89 -0
  64. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +272 -195
  65. package/dist/shared/components/layout-editor/outputs/layout-file-plan.js +176 -0
  66. package/dist/shared/components/layout-editor/outputs/output-api.js +71 -37
  67. package/dist/shared/components/layout-editor/overview/describe-conditions.js +16 -11
  68. package/dist/shared/components/layout-editor/overview/purpose.js +5 -5
  69. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  70. package/dist/shared/components/layout-editor/pin.js +37 -19
  71. package/dist/shared/components/layout-editor/place-clip.js +257 -0
  72. package/dist/shared/components/layout-editor/preview/PreviewModes.js +27 -26
  73. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +148 -117
  74. package/dist/shared/components/layout-editor/preview/SampleRecord.js +113 -0
  75. package/dist/shared/components/layout-editor/preview/preview-model.js +79 -60
  76. package/dist/shared/components/layout-editor/preview/sample-record.js +105 -0
  77. package/dist/shared/components/layout-editor/removed-log.js +151 -0
  78. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +109 -78
  79. package/dist/shared/components/layout-editor/reuse/linked-sections.js +373 -0
  80. package/dist/shared/components/layout-editor/revert-element.js +140 -0
  81. package/dist/shared/components/layout-editor/section-structure.js +193 -170
  82. package/dist/shared/components/layout-editor/settings/EntrySection.js +63 -45
  83. package/dist/shared/components/layout-editor/settings/LayoutSection.js +63 -32
  84. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +179 -137
  85. package/dist/shared/components/layout-editor/settings/WhoSection.js +18 -17
  86. package/dist/shared/components/layout-editor/settings/settings-registry.js +24 -0
  87. package/dist/shared/components/layout-editor/shortcuts.js +21 -16
  88. package/dist/shared/components/layout-editor/structure-ops.js +221 -195
  89. package/dist/shared/components/layout-editor/usage/UsagePanel.js +133 -85
  90. package/dist/shared/components/layout-editor/usage/refusal-lens.js +130 -0
  91. package/dist/shared/components/layout-editor/usage/usage-api.js +12 -11
  92. package/dist/shared/components/panels/CommentPanel.js +47 -45
  93. package/dist/shared/components/panels/RevisionsPanel.js +66 -64
  94. package/dist/shared/components/panels/TaskPanel.js +395 -332
  95. package/dist/shared/components/profile/AgentsPanel.js +196 -147
  96. package/dist/shared/components/profile/ConnectionRollback.js +329 -0
  97. package/dist/shared/components/profile/MyDefaultsCard.js +526 -520
  98. package/dist/shared/lib/entry-config.js +22 -22
  99. package/dist/shared/lib/form-usage-beacon.js +91 -55
  100. package/dist/shared/lib/layout-lint.js +530 -284
  101. package/dist/shared/lib/layout-resolve.js +58 -44
  102. package/package.json +1 -1
@@ -1,57 +1,64 @@
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);
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);
17
23
  }
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 };
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 };
24
31
  }
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;
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;
28
35
  return {
29
- [f.side === "before" ? "top" : "bottom"]: -6,
30
- height: O,
36
+ [g.side === "before" ? "top" : "bottom"]: -6,
37
+ height: X,
31
38
  left: 0,
32
- ...g ? { width: g } : { right: 0 }
39
+ ...m ? { width: m } : { right: 0 }
33
40
  };
34
41
  }
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;
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;
38
45
  };
39
- function _t(f) {
40
- for (let n = f; n && n !== document.documentElement; ) {
46
+ function Ae(g) {
47
+ for (let n = g; n && n !== document.documentElement; ) {
41
48
  const o = getComputedStyle(n);
42
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 ?? "")) {
43
- const g = n.getBoundingClientRect();
44
- return { x: g.left + n.clientLeft - n.scrollLeft, y: g.top + n.clientTop - n.scrollTop };
50
+ const m = n.getBoundingClientRect();
51
+ return { x: m.left + n.clientLeft - n.scrollLeft, y: m.top + n.clientTop - n.scrollTop };
45
52
  }
46
53
  n = n.parentElement;
47
54
  }
48
55
  return { x: 0, y: 0 };
49
56
  }
50
- function Nt(f) {
51
- const n = f.cloneNode(!0);
57
+ function ht(g) {
58
+ const n = g.cloneNode(!0);
52
59
  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);
60
+ for (const d of ["data-design-target", "data-selected", "data-drop-slot", "id"])
61
+ o.removeAttribute(d);
55
62
  if (n.classList.remove("opacity-40"), n.style.clipPath) {
56
63
  n.style.clipPath = "none", n.style.transform = "none", n.style.overflow = "visible", n.style.borderRadius = "0", n.style.height = "100%";
57
64
  for (const o of Array.from(n.querySelectorAll("*")))
@@ -62,217 +69,368 @@ function Nt(f) {
62
69
  n.removeAttribute(o);
63
70
  return n.removeAttribute("data-header-folded"), n.setAttribute("inert", ""), Object.assign(n.style, { margin: "0", width: "100%", opacity: "1", outline: "none" }), n;
64
71
  }
65
- const _ = 320;
66
- function It({ node: f, store: n }) {
67
- const o = N(null), c = ht(
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(
68
83
  n.subscribe,
69
- J(() => n.state.overKey === U, [n]),
84
+ G(() => n.state.copy, [n]),
70
85
  () => !1
71
86
  );
72
- return bt(() => {
73
- const g = o.current;
74
- if (g)
75
- return g.replaceChildren(Nt(f)), () => g.replaceChildren();
76
- }, [f]), /* @__PURE__ */ D(
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(
77
104
  "div",
78
105
  {
79
- ref: o,
80
106
  "aria-hidden": !0,
81
107
  "data-design-drag-preview": "",
82
- "data-over-trash": c ? "" : void 0,
108
+ "data-over-trash": m ? "" : void 0,
109
+ "data-copy": y ? "" : void 0,
83
110
  style: {
84
111
  transformOrigin: "top left",
85
- transform: c ? "scale(0.4)" : void 0,
86
- opacity: c ? 0.45 : void 0
112
+ transform: m ? "scale(0.4)" : void 0,
113
+ opacity: m ? 0.45 : void 0
87
114
  },
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"
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
+ ]
89
128
  }
90
129
  );
91
130
  }
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 = {
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."
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."
98
137
  };
99
- function Wt({
100
- bundle: f,
138
+ function Gt({
139
+ bundle: g,
101
140
  apply: n,
102
141
  onDragActive: o,
103
- onDropOnLayout: c,
104
- children: g
142
+ onDropOnLayout: d,
143
+ selection: m,
144
+ undo: y,
145
+ warnTrash: R,
146
+ children: O
105
147
  }) {
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
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
116
167
  ),
117
- (e) => T(r.bundle, e) != null
168
+ (e) => re(r.bundle, e) != null
118
169
  )
119
- ), [v] = R(() => ({
170
+ ), [Re] = I(() => ({
120
171
  threshold: { x: 0.08, y: 0.15 },
121
172
  acceleration: 12,
122
- canScroll: () => r.state.overKey !== U
123
- })), [I, B] = R(null), tt = H(
173
+ canScroll: () => r.state.overKey !== se
174
+ })), [_, ie] = I(null), [w, W] = I(null), Ke = he(
124
175
  () => ({
125
176
  draggableProps: () => ({}),
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
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
129
180
  }),
130
181
  [r]
131
- ), et = dt(
132
- j(ct, { activationConstraint: { distance: 4 } }),
133
- j(ut, {
134
- coordinateGetter: Ct,
135
- keyboardCodes: Tt
182
+ ), Le = Ue(
183
+ te(ct, { activationConstraint: dt }),
184
+ te(_e, { activationConstraint: ut }),
185
+ te(ve, {
186
+ coordinateGetter: Ze,
187
+ keyboardCodes: kt
136
188
  })
137
- ), [b, G] = R(null), m = J(
189
+ ), [x, ce] = I(null), Y = G(
138
190
  (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;
144
- if (d.kind === "group")
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");
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");
148
199
  },
149
200
  [r]
150
- ), nt = H(
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(
151
208
  () => ({
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.`
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.`
156
213
  }),
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);
163
- if (!d) return;
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
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
174
251
  });
175
- G({ node: l, host: s, height: Math.min(u.height, _), shift: it });
176
- }, A = N({
252
+ ce({ node: f, host: C, height: Math.min(u.height, J), shift: B });
253
+ }, v = E({
177
254
  bundle: null,
178
255
  map: /* @__PURE__ */ new Map()
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 });
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 });
190
275
  return;
191
276
  }
192
- if (t && V(t.data.current)) {
193
- r.set({ overKey: String(t.id), side: null, indicator: null });
277
+ if (i && De(i.data.current)) {
278
+ r.set({ overKey: String(i.id), side: null, indicator: null, merge: null });
194
279
  return;
195
280
  }
196
- const i = q(e, t, d);
197
- if (!i || i.ops.length === 0 || !t) {
198
- r.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 });
199
284
  return;
200
285
  }
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 = {
203
- target: L,
204
- role: { kind: "group", key: Q, 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 }
205
290
  }, l = { side: l.side, axis: "y", body: !1 });
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;
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;
207
292
  r.set({
208
- overKey: s,
293
+ overKey: p,
209
294
  side: l.side,
210
- indicator: Ot(l, a, p, u)
295
+ indicator: mt(l, c, C, b),
296
+ merge: l.merge ? Y(c) : null
211
297
  });
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}` });
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
+ });
217
332
  return;
218
333
  }
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));
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));
223
338
  return;
224
339
  }
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));
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);
234
353
  };
235
- return /* @__PURE__ */ D(wt.Provider, { value: r, children: /* @__PURE__ */ D(W.Provider, { value: tt, children: /* @__PURE__ */ lt(
236
- ft,
354
+ return /* @__PURE__ */ S(rt.Provider, { value: r, children: /* @__PURE__ */ S(Oe.Provider, { value: Ke, children: /* @__PURE__ */ ae(
355
+ Be,
237
356
  {
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,
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,
248
367
  children: [
249
- /* @__PURE__ */ D("div", { className: "contents", onPointerDownCapture: st, children: g }),
250
- b && z(
251
- /* @__PURE__ */ D(
252
- gt,
368
+ /* @__PURE__ */ S("div", { className: "contents", onPointerDownCapture: ge, onTouchStartCapture: ge, children: O }),
369
+ x && ne(
370
+ /* @__PURE__ */ S(
371
+ He,
253
372
  {
254
373
  dropAnimation: null,
255
374
  zIndex: 1e3,
256
- modifiers: [b.shift],
257
- style: { height: b.height },
258
- children: /* @__PURE__ */ D(It, { node: b.node, store: r })
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
259
397
  }
260
398
  ),
261
- b.host
399
+ (x == null ? void 0 : x.host) ?? document.body
262
400
  ),
263
- I && z(
264
- /* @__PURE__ */ D(Rt, { store: r, plan: I.plan, name: I.name }),
265
- (b == null ? void 0 : b.host) ?? document.body
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)
414
+ }
415
+ ),
416
+ w.host
266
417
  )
267
418
  ]
268
419
  }
269
420
  ) }) });
270
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
+ }
271
429
  export {
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
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
278
436
  };