@nivaro/react 0.3.36 → 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 (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 +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 +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,68 +1,96 @@
1
- import { jsxs as s, jsx as a } from "react/jsx-runtime";
2
- import { useDroppable as c } from "@dnd-kit/core";
3
- import { Trash2 as m } from "lucide-react";
4
- import { useSyncExternalStore as h, useCallback as x } from "react";
5
- import { cn as o } from "../../../lib/utils.js";
6
- import { TRASH_DROP_ID as n } from "./trash-drop.js";
7
- const b = `
1
+ import { jsxs as s, jsx as r, Fragment as m } from "react/jsx-runtime";
2
+ import { useDroppable as h } from "@dnd-kit/core";
3
+ import { Trash2 as b, Link2 as x } from "lucide-react";
4
+ import { useSyncExternalStore as p, useCallback as u } from "react";
5
+ import { cn as d } from "../../../lib/utils.js";
6
+ import { TRASH_DROP_ID as i } from "./trash-drop.js";
7
+ const f = `
8
8
  @keyframes nvr-trash-in{from{opacity:0;transform:translate(-50%,12px)}to{opacity:1;transform:translate(-50%,0)}}
9
9
  [data-layout-trash]{animation:nvr-trash-in 160ms cubic-bezier(0.25,1,0.5,1) both}
10
10
  @media (prefers-reduced-motion: reduce){[data-layout-trash]{animation:none}}
11
- `, p = (e, r) => `${e} ${r}${e === 1 ? "" : "s"}`;
12
- function w({
11
+ `, k = (e, t) => `${e} ${t}${e === 1 ? "" : "s"}`, y = 3;
12
+ function j({
13
13
  store: e,
14
- plan: r,
15
- name: d
14
+ plan: t,
15
+ name: n,
16
+ warning: o = null
16
17
  }) {
17
- const { setNodeRef: i } = c({
18
- id: n,
18
+ const { setNodeRef: l } = h({
19
+ id: i,
19
20
  data: { layoutTrash: !0 }
20
- }), t = h(
21
+ }), a = p(
21
22
  e.subscribe,
22
- x(() => e.state.overKey === n, [e]),
23
+ u(() => e.state.overKey === i, [e]),
23
24
  () => !1
24
- ), l = r.kind === "section" ? r.holds > 0 ? `With its ${p(r.holds, "field")} · their data is kept` : "It holds no fields" : "Its data is kept";
25
+ ), c = t.kind === "section" ? t.holds > 0 ? `With its ${k(t.holds, "field")} · their data is kept` : "It holds no fields" : (t.count ?? 1) > 1 ? "Their data is kept" : "Its data is kept";
25
26
  return /* @__PURE__ */ s(
26
27
  "div",
27
28
  {
28
- ref: i,
29
+ ref: l,
29
30
  "data-layout-trash": "",
30
- "data-over": t ? "" : void 0,
31
+ "data-over": a ? "" : void 0,
31
32
  style: { left: "50%", transform: "translateX(-50%)" },
32
- className: o(
33
+ className: d(
33
34
  "pointer-events-auto fixed bottom-6 z-[1001] flex min-w-[240px] max-w-[min(420px,calc(100vw-32px))] items-center gap-3 rounded-xl border-2 px-4 py-3 shadow-lg transition-colors duration-150 motion-reduce:transition-none",
34
- t ? "border-solid border-red-400 bg-red-50 text-red-800 dark:border-red-500/70 dark:bg-[#3b1219] dark:text-red-100" : "border-dashed border-slate-300 bg-white text-slate-600 dark:border-slate-600 dark:bg-card dark:text-slate-300"
35
+ a ? "border-solid border-red-400 bg-red-50 text-red-800 dark:border-red-500/70 dark:bg-[#3b1219] dark:text-red-100" : "border-dashed border-slate-300 bg-white text-slate-600 dark:border-slate-600 dark:bg-card dark:text-slate-300"
35
36
  ),
36
37
  children: [
37
- /* @__PURE__ */ a("style", { children: b }),
38
- /* @__PURE__ */ a(
38
+ /* @__PURE__ */ r("style", { children: f }),
39
+ /* @__PURE__ */ r(
39
40
  "span",
40
41
  {
41
42
  "aria-hidden": !0,
42
- className: o(
43
+ className: d(
43
44
  "flex h-8 w-8 shrink-0 items-center justify-center rounded-lg transition-colors duration-150 motion-reduce:transition-none",
44
- t ? "bg-red-600 text-white" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-300"
45
+ a ? "bg-red-600 text-white" : "bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-300"
45
46
  ),
46
- children: /* @__PURE__ */ a(m, { className: "h-4 w-4" })
47
+ children: /* @__PURE__ */ r(b, { className: "h-4 w-4" })
47
48
  }
48
49
  ),
49
50
  /* @__PURE__ */ s("span", { className: "min-w-0", children: [
50
- /* @__PURE__ */ a("span", { className: "block truncate text-[13px] font-semibold", children: t ? `Release to remove ${d}` : "Drop here to remove" }),
51
- /* @__PURE__ */ a(
51
+ /* @__PURE__ */ r("span", { className: "block truncate text-[13px] font-semibold", children: a ? `Release to remove ${n}` : "Drop here to remove" }),
52
+ /* @__PURE__ */ r(
52
53
  "span",
53
54
  {
54
- className: o(
55
+ className: d(
55
56
  "block truncate text-[11.5px]",
56
- t ? "text-red-700 dark:text-red-200/90" : "text-slate-500 dark:text-slate-400"
57
+ a ? "text-red-700 dark:text-red-200/90" : "text-slate-500 dark:text-slate-400"
57
58
  ),
58
- children: t ? l : "From this form only · Undo brings it back"
59
+ children: a ? c : "From this form only · Undo brings it back"
59
60
  }
60
- )
61
+ ),
62
+ o && /* @__PURE__ */ r(N, { warning: o, over: a })
63
+ ] })
64
+ ]
65
+ }
66
+ );
67
+ }
68
+ function N({ warning: e, over: t }) {
69
+ const n = e.effects.slice(0, y), o = e.effects.length - n.length;
70
+ return /* @__PURE__ */ s(
71
+ "span",
72
+ {
73
+ "data-trash-links": e.count,
74
+ className: d(
75
+ "mt-1.5 block border-t pt-1.5 text-[11.5px]",
76
+ t ? "border-red-200 text-red-800 dark:border-red-500/30 dark:text-red-100" : "border-slate-200 text-amber-800 dark:border-slate-700 dark:text-amber-200"
77
+ ),
78
+ children: [
79
+ /* @__PURE__ */ s("span", { className: "flex items-center gap-1 font-medium", children: [
80
+ /* @__PURE__ */ r(x, { "aria-hidden": !0, className: "h-3 w-3 shrink-0" }),
81
+ /* @__PURE__ */ r("span", { className: "truncate", children: e.headline })
82
+ ] }),
83
+ t && /* @__PURE__ */ s(m, { children: [
84
+ /* @__PURE__ */ s("span", { className: "mt-0.5 block truncate", children: [
85
+ n.join(" · "),
86
+ o > 0 ? ` · +${o} more` : ""
87
+ ] }),
88
+ /* @__PURE__ */ r("span", { className: "block truncate text-red-700/90 dark:text-red-200/80", children: "Off the form, nobody can change it here" })
61
89
  ] })
62
90
  ]
63
91
  }
64
92
  );
65
93
  }
66
94
  export {
67
- w as TrashZone
95
+ j as TrashZone
68
96
  };
@@ -0,0 +1,76 @@
1
+ import { jsxs as c, jsx as s } from "react/jsx-runtime";
2
+ import { Undo2 as w } from "lucide-react";
3
+ import { useState as y, useRef as v, useEffect as u } from "react";
4
+ const g = 6e3, k = `
5
+ @keyframes nvr-undo-chip-in{from{opacity:0;transform:translate(-50%,calc(-100% + 6px))}to{opacity:1;transform:translate(-50%,-100%)}}
6
+ [data-trash-undo-chip]{animation:nvr-undo-chip-in 140ms cubic-bezier(0.25,1,0.5,1) both}
7
+ @media (prefers-reduced-motion: reduce){[data-trash-undo-chip]{animation:none}}
8
+ `;
9
+ function b(n, r, e = 120) {
10
+ const i = Math.min(Math.max(n.x, 16 + e), Math.max(16 + e, r.width - 16 - e)), d = Math.min(Math.max(n.y - 16, 56), r.height - 16);
11
+ return { left: i, top: d };
12
+ }
13
+ function P({
14
+ label: n,
15
+ point: r,
16
+ origin: e,
17
+ stillUndoable: i,
18
+ onUndo: d,
19
+ onClose: h
20
+ }) {
21
+ const [l, a] = y(!1), t = v(h);
22
+ t.current = h, u(() => {
23
+ i || t.current();
24
+ }, [i]), u(() => {
25
+ if (l) return;
26
+ const o = setTimeout(() => t.current(), g);
27
+ return () => clearTimeout(o);
28
+ }, [l]), u(() => {
29
+ const o = (x) => {
30
+ x.key === "Escape" && t.current();
31
+ };
32
+ return window.addEventListener("keydown", o), () => window.removeEventListener("keydown", o);
33
+ }, []);
34
+ const m = typeof window > "u" ? { width: 1024, height: 768 } : { width: window.innerWidth, height: window.innerHeight }, { left: p, top: f } = b(r, m);
35
+ return /* @__PURE__ */ c(
36
+ "div",
37
+ {
38
+ role: "status",
39
+ "data-trash-undo-chip": "",
40
+ onPointerEnter: () => a(!0),
41
+ onPointerLeave: () => a(!1),
42
+ onFocus: () => a(!0),
43
+ onBlur: () => a(!1),
44
+ style: { left: p - e.x, top: f - e.y, transform: "translate(-50%, -100%)" },
45
+ className: "pointer-events-auto fixed z-[1001] flex max-w-[240px] items-center gap-1 rounded-lg bg-white py-1 pl-2.5 pr-1 text-[12.5px] text-slate-700 shadow-lg ring-1 ring-slate-900/10 dark:bg-card dark:text-slate-200 dark:ring-white/10",
46
+ children: [
47
+ /* @__PURE__ */ s("style", { children: k }),
48
+ /* @__PURE__ */ c("span", { className: "min-w-0 truncate", children: [
49
+ "Removed ",
50
+ /* @__PURE__ */ s("span", { className: "font-medium text-slate-900 dark:text-foreground", children: n })
51
+ ] }),
52
+ /* @__PURE__ */ s("span", { "aria-hidden": !0, className: "text-slate-300 dark:text-slate-600", children: "·" }),
53
+ /* @__PURE__ */ c(
54
+ "button",
55
+ {
56
+ type: "button",
57
+ "data-trash-undo": "",
58
+ onClick: () => {
59
+ d(), t.current();
60
+ },
61
+ className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-md px-2 font-medium text-nvr-cyan hover:bg-nvr-cyan/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan [@media(pointer:coarse)]:h-9 [@media(pointer:coarse)]:px-3",
62
+ children: [
63
+ /* @__PURE__ */ s(w, { "aria-hidden": !0, className: "h-3.5 w-3.5" }),
64
+ "Undo"
65
+ ]
66
+ }
67
+ )
68
+ ]
69
+ }
70
+ );
71
+ }
72
+ export {
73
+ g as UNDO_CHIP_MS,
74
+ P as UndoChip,
75
+ b as chipPosition
76
+ };
@@ -0,0 +1,33 @@
1
+ import { nodeData as s } from "./collision.js";
2
+ const h = 12;
3
+ function b(t, i, o, n) {
4
+ return i <= 0 || n.y < t.top || n.y > t.top + i || n.x < t.left || n.x > t.left + t.width ? !1 : o === "x" ? n.x >= t.left + t.width / 4 && n.x <= t.left + t.width * 3 / 4 : n.y >= t.top + Math.min(h, i / 3);
5
+ }
6
+ function x(t, i) {
7
+ return (o) => {
8
+ var f, l;
9
+ const n = t(o), a = n[0], u = o.pointerCoordinates, c = s(o.active.data.current);
10
+ if (!a || !u || !c || c.add || c.role.kind !== "group") return n;
11
+ const e = a.data, r = s((f = e == null ? void 0 : e.droppableContainer) == null ? void 0 : f.data.current);
12
+ if ((r == null ? void 0 : r.role.kind) !== "group" || !e.hint) return n;
13
+ const d = o.droppableRects.get(a.id), g = ((l = r.headerHeight) == null ? void 0 : l.call(r)) ?? 0;
14
+ return !d || !b(d, g, e.hint.axis, u) || !i(c, r) ? n : [{ ...a, data: { ...e, hint: { ...e.hint, merge: !0 } } }, ...n.slice(1)];
15
+ };
16
+ }
17
+ function m(t) {
18
+ return {
19
+ top: 0,
20
+ left: 0,
21
+ right: 0,
22
+ height: t > 0 ? t : "100%",
23
+ borderRadius: 8,
24
+ backgroundColor: "rgb(var(--nvr-cyan-rgb, 0 206 255) / 0.1)",
25
+ boxShadow: "inset 0 0 0 2px rgb(var(--nvr-cyan-rgb, 0 206 255))"
26
+ };
27
+ }
28
+ export {
29
+ h as MERGE_EDGE,
30
+ b as inMergeZone,
31
+ x as mergeAwareCollision,
32
+ m as mergeIndicatorStyle
33
+ };
@@ -0,0 +1,87 @@
1
+ import { applyLayoutOps as g, UNGROUPED_KEY as P, isCanvasSlot as c } from "../../../lib/layout-ops.js";
2
+ import { isMultiSelectable as m, targetKey as k } from "../design-context.js";
3
+ import { plural as O, inPageOrder as w, selectedPlacements as z, normalizedBundle as a } from "../field-zones.js";
4
+ import { placementPatchOf as D } from "../inspector/model.js";
5
+ import { pinLocked as A, unpinnedPatch as C } from "../pin.js";
6
+ import { duplicatePlan as K } from "../structure-ops.js";
7
+ import { dndRole as L, bodyZone as M } from "./collision.js";
8
+ import { landsOnCanvas as b, orderAfterDrop as h, placeAfterDrop as E } from "./order.js";
9
+ function T(t, o, r) {
10
+ if (!t || o.length < 2 || !m(r)) return [r];
11
+ const u = k(r);
12
+ if (!o.some((n) => k(n) === u)) return [r];
13
+ if (!o.every(m)) return [r];
14
+ const d = w(t, z(t, o)), p = [];
15
+ for (const n of d) {
16
+ const e = o.find(
17
+ (f) => f.kind !== "group" && f.kind !== "header" && f.field === n.field && f.group_key === n.group_key
18
+ );
19
+ e && !A(t, e) && p.push(e);
20
+ }
21
+ return p.length > 1 && p.some((n) => k(n) === u) ? p : [r];
22
+ }
23
+ function _(t, o) {
24
+ const r = L(t, o);
25
+ if (r) {
26
+ if (r.kind === "item") return r.zone;
27
+ if (r.kind === "group" && r.body) return M(r.key);
28
+ }
29
+ }
30
+ function R(t, o, r, u) {
31
+ const d = a(t);
32
+ if (o.kind === "header") return [];
33
+ if (o.kind === "group") {
34
+ if (o.key === P) return [];
35
+ const e = K(d, o);
36
+ if (!e.ok) return [];
37
+ const f = e.ops[0];
38
+ if ((f == null ? void 0 : f.op) !== "group_create") return [];
39
+ let l;
40
+ try {
41
+ l = g(d, e.ops);
42
+ } catch {
43
+ return [];
44
+ }
45
+ const i = r.kind === "group" && r.key === o.key ? { kind: "group", key: o.key } : r, s = h(l, { kind: "group", key: f.key }, i, u);
46
+ return [...e.ops, ...s];
47
+ }
48
+ if (c(o)) return [];
49
+ const p = d.placements.find((e) => e.field === o.field && e.group_key === o.group_key);
50
+ if (!p) return [];
51
+ const n = _(d, r);
52
+ return n === void 0 || c({ field: o.field, group_key: n }) ? [] : E(d, o.field, r, u, C(D(p)));
53
+ }
54
+ function Y(t, o, r, u, d) {
55
+ const p = k(r);
56
+ if (o.some((i) => k(i) === p)) return [];
57
+ let n = a(t);
58
+ const e = _(n, r);
59
+ if (e === void 0) return [];
60
+ const f = [];
61
+ let l = { over: r, side: u };
62
+ for (const i of o) {
63
+ if (i.kind !== "field" && i.kind !== "slot" || b(n, i, l.over)) continue;
64
+ const s = d === "copy" ? R(n, i, l.over, l.side) : h(n, i, l.over, l.side);
65
+ let y = null;
66
+ if (s.length) {
67
+ try {
68
+ n = g(n, s);
69
+ } catch {
70
+ continue;
71
+ }
72
+ f.push(...s), y = { kind: i.kind, field: i.field, group_key: e };
73
+ } else d === "move" && i.group_key === e && (y = i);
74
+ y && (l = { over: y, side: "after" });
75
+ }
76
+ return f;
77
+ }
78
+ function j(t, o) {
79
+ const r = t.every((u) => u.kind === "field") ? "field" : "item";
80
+ return `${o === "copy" ? "Copy" : "Move"} ${O(t.length, r)}`;
81
+ }
82
+ export {
83
+ T as carriedTargets,
84
+ R as copyAfterDrop,
85
+ Y as dropMany,
86
+ j as manyLabel
87
+ };
@@ -1,37 +1,45 @@
1
- var J = Object.defineProperty;
2
- var M = (e, t, i) => t in e ? J(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
3
- var g = (e, t, i) => M(e, typeof t != "symbol" ? t + "" : t, i);
4
- import { useDraggable as _, useDroppable as w } from "@dnd-kit/core";
5
- import { createContext as P, useContext as S, useId as $, useRef as y, useCallback as R, useEffect as H, useSyncExternalStore as z } from "react";
1
+ var I = Object.defineProperty;
2
+ var J = (n, e, i) => e in n ? I(n, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : n[e] = i;
3
+ var g = (n, e, i) => J(n, typeof e != "symbol" ? e + "" : e, i);
4
+ import { useDraggable as K, useDroppable as _ } from "@dnd-kit/core";
5
+ import { createContext as M, useContext as S, useId as $, useRef as y, useCallback as m, useEffect as H, useSyncExternalStore as w } from "react";
6
6
  import { isCanvasSlot as L } from "../../../lib/layout-ops.js";
7
- import { targetKey as E } from "../design-context.js";
8
- import { dndRole as O } from "./collision.js";
9
- const q = { activeKey: null, overKey: null, side: null, indicator: null };
10
- class Y {
7
+ import { targetKey as z } from "../design-context.js";
8
+ import { dndRole as E } from "./collision.js";
9
+ const P = {
10
+ activeKey: null,
11
+ overKey: null,
12
+ side: null,
13
+ indicator: null,
14
+ carried: null,
15
+ copy: !1,
16
+ merge: null
17
+ };
18
+ class X {
11
19
  constructor() {
12
20
  g(this, "bundle", null);
13
- g(this, "state", q);
14
- /** Registered element → its pointer activator (dnd-kit's onPointerDown). */
21
+ g(this, "state", P);
22
+ /** Registered element → its activators (dnd-kit's onPointerDown, onTouchStart). */
15
23
  g(this, "activators", /* @__PURE__ */ new WeakMap());
16
24
  /** Droppable id → registered element (the overlay copies it, the drop line measures it). */
17
25
  g(this, "nodes", /* @__PURE__ */ new Map());
18
26
  /** A width is being dragged on the canvas (#2701): the column guides show. */
19
27
  g(this, "resizing", !1);
20
28
  g(this, "subs", /* @__PURE__ */ new Set());
21
- g(this, "subscribe", (t) => (this.subs.add(t), () => {
22
- this.subs.delete(t);
29
+ g(this, "subscribe", (e) => (this.subs.add(e), () => {
30
+ this.subs.delete(e);
23
31
  }));
24
32
  }
25
- set(t) {
26
- const i = { ...this.state, ...t }, n = this.state;
27
- if (!(i.activeKey === n.activeKey && i.overKey === n.overKey && i.side === n.side && JSON.stringify(i.indicator) === JSON.stringify(n.indicator))) {
33
+ set(e) {
34
+ const i = { ...this.state, ...e }, t = this.state;
35
+ if (!(i.activeKey === t.activeKey && i.overKey === t.overKey && i.side === t.side && i.copy === t.copy && i.merge === t.merge && i.carried === t.carried && JSON.stringify(i.indicator) === JSON.stringify(t.indicator))) {
28
36
  this.state = i;
29
37
  for (const r of this.subs) r();
30
38
  }
31
39
  }
32
- setResizing(t) {
33
- if (this.resizing !== t) {
34
- this.resizing = t;
40
+ setResizing(e) {
41
+ if (this.resizing !== e) {
42
+ this.resizing = e;
35
43
  for (const i of this.subs) i();
36
44
  }
37
45
  }
@@ -40,137 +48,139 @@ class Y {
40
48
  return this.state.activeKey !== null || this.resizing;
41
49
  }
42
50
  /** What one node renders from: a node re-renders only when its slice changes. */
43
- slice(t) {
44
- const i = this.state, n = i.overKey === t ? `${i.side}${JSON.stringify(i.indicator)}` : "";
45
- return `${i.activeKey === t ? 1 : 0}|${n}`;
51
+ slice(e) {
52
+ const i = this.state, t = i.overKey === e ? `${i.side}${i.merge ?? ""}${JSON.stringify(i.indicator)}` : "";
53
+ return `${this.isCarried(e) ? 1 : 0}|${t}`;
54
+ }
55
+ /** Is the node `key` part of the current drag (the dragged one, or carried with it)? */
56
+ isCarried(e) {
57
+ var t;
58
+ const i = this.state;
59
+ return i.activeKey === e || (((t = i.carried) == null ? void 0 : t.includes(e)) ?? !1);
46
60
  }
47
61
  /** Remember `el` under `id` (and forget the element it replaces). */
48
- track(t, i, n) {
49
- i && this.nodes.get(t) === i && this.nodes.delete(t), n && this.nodes.set(t, n);
62
+ track(e, i, t) {
63
+ i && this.nodes.get(e) === i && this.nodes.delete(e), t && this.nodes.set(e, t);
50
64
  }
51
65
  }
52
- const m = P(null), F = {
66
+ const C = M(null), q = {
53
67
  draggableProps: () => ({}),
54
68
  isDragging: () => !1,
55
69
  dropSlot: () => null
56
- }, x = () => () => {
70
+ }, O = () => () => {
57
71
  };
58
- function G(e) {
59
- if (!e) return 0;
60
- if (e.hasAttribute("data-design-tab")) return e.getBoundingClientRect().height;
61
- const t = Array.from(e.querySelectorAll("[data-design-group-header]")).find(
62
- (i) => i.closest("[data-design-target]") === e
72
+ function F(n) {
73
+ if (!n) return 0;
74
+ if (n.hasAttribute("data-design-tab")) return n.getBoundingClientRect().height;
75
+ const e = Array.from(n.querySelectorAll("[data-design-group-header]")).find(
76
+ (i) => i.closest("[data-design-target]") === n
63
77
  );
64
- return t ? t.getBoundingClientRect().bottom - e.getBoundingClientRect().top : 0;
78
+ return e ? e.getBoundingClientRect().bottom - n.getBoundingClientRect().top : 0;
65
79
  }
66
- function tt(e, t, i = {}) {
80
+ function Y(n, e, i = {}) {
67
81
  var N, A;
68
- const n = S(m), r = E(t), c = $(), l = y(null), s = n != null && n.bundle ? O(n.bundle, t) : null, a = !!n && !!s && !i.disabled && e !== F, u = a ? r : `${r}#${c}`, d = s ? {
69
- target: t,
82
+ const t = S(C), r = z(e), c = $(), l = y(null), s = t != null && t.bundle ? E(t.bundle, e) : null, a = !!t && !!s && !i.disabled && n !== q, u = a ? r : `${r}#${c}`, d = s ? {
83
+ target: e,
70
84
  role: s,
71
- headerHeight: s.kind === "group" ? () => G(l.current) : void 0
72
- } : void 0, o = _({ id: u, data: d, disabled: !a }), h = w({ id: u, data: d, disabled: !a || !!i.noDrop });
73
- z(
74
- (n == null ? void 0 : n.subscribe) ?? x,
75
- () => (n == null ? void 0 : n.slice(r)) ?? "",
85
+ headerHeight: s.kind === "group" ? () => F(l.current) : void 0
86
+ } : void 0, o = K({ id: u, data: d, disabled: !a }), D = _({ id: u, data: d, disabled: !a || !!i.noDrop });
87
+ w(
88
+ (t == null ? void 0 : t.subscribe) ?? O,
89
+ () => (t == null ? void 0 : t.slice(r)) ?? "",
76
90
  () => ""
77
91
  );
78
- const D = y(o.listeners);
79
- D.current = o.listeners;
80
- const { setNodeRef: p, setActivatorNodeRef: v } = o, f = h.setNodeRef, I = R(
81
- (b) => {
82
- n == null || n.track(r, l.current, b), l.current = b, p(b), f(b), v(b), b && n && n.activators.set(
83
- b,
84
- () => {
85
- var C;
86
- return (C = D.current) == null ? void 0 : C.onPointerDown;
87
- }
88
- );
92
+ const h = y(o.listeners);
93
+ h.current = o.listeners;
94
+ const { setNodeRef: b, setActivatorNodeRef: v } = o, f = D.setNodeRef, B = m(
95
+ (p) => {
96
+ t == null || t.track(r, l.current, p), l.current = p, b(p), f(p), v(p), p && t && t.activators.set(p, () => h.current);
89
97
  },
90
- [r, v, p, f, n]
98
+ [r, v, b, f, t]
91
99
  );
92
- if (!n)
100
+ if (!t)
93
101
  return {
94
- props: e.draggableProps(t, i.disabled ? { disabled: !0 } : void 0),
95
- dragging: e.isDragging(t),
96
- slot: e.dropSlot(t),
97
- indicator: ((N = e.dropIndicator) == null ? void 0 : N.call(e, t)) ?? null
102
+ props: n.draggableProps(e, i.disabled ? { disabled: !0 } : void 0),
103
+ dragging: n.isDragging(e),
104
+ slot: n.dropSlot(e),
105
+ indicator: ((N = n.dropIndicator) == null ? void 0 : N.call(n, e)) ?? null,
106
+ merge: null
98
107
  };
99
- const k = n.state, K = k.overKey === r;
108
+ const k = t.state, R = k.overKey === r;
100
109
  return {
101
- // The pointer activator is not spread here: LayoutDndProvider relays
102
- // pointerdown to it. The keyboard one stays on the node.
103
- props: a ? { ref: I, ...o.attributes, onKeyDown: (A = o.listeners) == null ? void 0 : A.onKeyDown } : {},
104
- dragging: k.activeKey === r,
105
- slot: K ? k.side : null,
106
- indicator: K ? k.indicator : null
110
+ // The pointer and touch activators are not spread here: LayoutDndProvider
111
+ // relays pointerdown and touchstart to them. The keyboard one stays on the node.
112
+ props: a ? { ref: B, ...o.attributes, onKeyDown: (A = o.listeners) == null ? void 0 : A.onKeyDown } : {},
113
+ dragging: t.isCarried(r),
114
+ slot: R ? k.side : null,
115
+ indicator: R ? k.indicator : null,
116
+ merge: R ? k.merge : null
107
117
  };
108
118
  }
109
- function et(e) {
110
- const t = S(m), i = `body:${e}`, n = t != null && t.bundle ? O(t.bundle, { kind: "group", key: e }) : null, r = (n == null ? void 0 : n.kind) === "group" && n.body, c = w({
119
+ function ee(n) {
120
+ const e = S(C), i = `body:${n}`, t = e != null && e.bundle ? E(e.bundle, { kind: "group", key: n }) : null, r = (t == null ? void 0 : t.kind) === "group" && t.body, c = _({
111
121
  id: i,
112
- data: { target: { kind: "group", key: e }, role: { kind: "body", key: e } },
122
+ data: { target: { kind: "group", key: n }, role: { kind: "body", key: n } },
113
123
  disabled: !r
114
124
  });
115
- z(
116
- (t == null ? void 0 : t.subscribe) ?? x,
117
- () => (t == null ? void 0 : t.slice(i)) ?? "",
125
+ w(
126
+ (e == null ? void 0 : e.subscribe) ?? O,
127
+ () => (e == null ? void 0 : e.slice(i)) ?? "",
118
128
  () => ""
119
129
  );
120
- const l = y(null), s = c.setNodeRef, a = R(
130
+ const l = y(null), s = c.setNodeRef, a = m(
121
131
  (d) => {
122
132
  const o = (d == null ? void 0 : d.parentElement) ?? null;
123
- t == null || t.track(i, l.current, o), l.current = o, s(o), o && getComputedStyle(o).position === "static" && (o.style.position = "relative");
133
+ e == null || e.track(i, l.current, o), l.current = o, s(o), o && getComputedStyle(o).position === "static" && (o.style.position = "relative");
124
134
  },
125
- [i, s, t]
126
- ), u = (t == null ? void 0 : t.state.overKey) === i;
135
+ [i, s, e]
136
+ ), u = (e == null ? void 0 : e.state.overKey) === i;
127
137
  return {
128
138
  ref: a,
129
- slot: u ? (t == null ? void 0 : t.state.side) ?? null : null,
130
- indicator: u ? (t == null ? void 0 : t.state.indicator) ?? null : null
139
+ slot: u ? (e == null ? void 0 : e.state.side) ?? null : null,
140
+ indicator: u ? (e == null ? void 0 : e.state.indicator) ?? null : null
131
141
  };
132
142
  }
133
- const B = "__add__";
134
- function T(e, t) {
135
- return t === "header" ? { kind: "header" } : L({ field: e, group_key: null }) ? { kind: "group", key: e, parent: null, body: !1 } : { kind: "item", zone: B };
143
+ const x = "__add__";
144
+ function G(n, e) {
145
+ return e === "header" ? { kind: "header" } : L({ field: n, group_key: null }) ? { kind: "group", key: n, parent: null, body: !1 } : { kind: "item", zone: x };
136
146
  }
137
- const W = 400;
138
- function nt(e) {
139
- const t = S(m), i = $(), n = !!t && !!e, r = { kind: "field", field: (e == null ? void 0 : e.field) ?? i, group_key: B }, c = E(r), l = e ? {
147
+ const T = 400;
148
+ function te(n) {
149
+ const e = S(C), i = $(), t = !!e && !!n, r = { kind: "field", field: (n == null ? void 0 : n.field) ?? i, group_key: x }, c = z(r), l = n ? {
140
150
  target: r,
141
- role: T(e.field, e.to),
151
+ role: G(n.field, n.to),
142
152
  add: {
143
- field: e.field,
144
- label: e.label,
145
- patch: e.patch,
146
- onAdded: e.onAdded
153
+ field: n.field,
154
+ label: n.label,
155
+ patch: n.patch,
156
+ onAdded: n.onAdded
147
157
  }
148
- } : void 0, s = _({ id: n ? c : `${c}#${i}`, data: l, disabled: !n }), a = y(null), { setNodeRef: u, setActivatorNodeRef: d } = s, o = R(
158
+ } : void 0, s = K({ id: t ? c : `${c}#${i}`, data: l, disabled: !t }), a = y(null), { setNodeRef: u, setActivatorNodeRef: d } = s, o = m(
149
159
  (f) => {
150
- t == null || t.track(c, a.current, f), a.current = f, u(f), d(f);
160
+ e == null || e.track(c, a.current, f), a.current = f, u(f), d(f);
151
161
  },
152
- [c, d, u, t]
153
- ), h = y(0), D = y(!1);
162
+ [c, d, u, e]
163
+ ), D = y(0), h = y(!1);
154
164
  H(() => {
155
- D.current && !s.isDragging && (h.current = Date.now()), D.current = s.isDragging;
165
+ h.current && !s.isDragging && (D.current = Date.now()), h.current = s.isDragging;
156
166
  }, [s.isDragging]);
157
- const p = s.isDragging, v = R(
158
- () => p || Date.now() - h.current < W,
159
- [p]
167
+ const b = s.isDragging, v = m(
168
+ () => b || Date.now() - D.current < T,
169
+ [b]
160
170
  );
161
171
  return {
162
- props: n ? { ref: o, ...s.attributes, ...s.listeners } : {},
163
- dragging: p,
172
+ props: t ? { ref: o, ...s.attributes, ...s.listeners } : {},
173
+ dragging: b,
164
174
  clickBlocked: v
165
175
  };
166
176
  }
167
177
  export {
168
- Y as DndStore,
169
- m as DndStoreContext,
170
- q as IDLE,
171
- F as NO_DND,
172
- T as addRole,
173
- nt as useAddDragSource,
174
- tt as useDesignDndNode,
175
- et as useDesignDropBody
178
+ X as DndStore,
179
+ C as DndStoreContext,
180
+ P as IDLE,
181
+ q as NO_DND,
182
+ G as addRole,
183
+ te as useAddDragSource,
184
+ Y as useDesignDndNode,
185
+ ee as useDesignDropBody
176
186
  };
@@ -0,0 +1,23 @@
1
+ var s = Object.defineProperty;
2
+ var c = (t, e, n) => e in t ? s(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var r = (t, e, n) => c(t, typeof e != "symbol" ? e + "" : e, n);
4
+ import { PointerSensor as a } from "@dnd-kit/core";
5
+ import { TouchSensor as h } from "@dnd-kit/core";
6
+ const d = { distance: 4 }, p = { delay: 250, tolerance: 8 };
7
+ class i extends a {
8
+ }
9
+ r(i, "activators", [
10
+ {
11
+ eventName: "onPointerDown",
12
+ handler: (e, n) => {
13
+ var o;
14
+ return ((o = e.nativeEvent) == null ? void 0 : o.pointerType) === "touch" ? !1 : a.activators[0].handler(e, n);
15
+ }
16
+ }
17
+ ]);
18
+ export {
19
+ d as MOUSE_ACTIVATION,
20
+ i as MousePointerSensor,
21
+ p as TOUCH_ACTIVATION,
22
+ h as TouchSensor
23
+ };