@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
@@ -0,0 +1,140 @@
1
+ var I = Object.defineProperty;
2
+ var N = (i, r, o) => r in i ? I(i, r, { enumerable: !0, configurable: !0, writable: !0, value: o }) : i[r] = o;
3
+ var c = (i, r, o) => N(i, typeof r != "symbol" ? r + "" : r, o);
4
+ import { UNGROUPED_KEY as $, applyLayoutOps as P, isCanvasSlot as v, HEADER_GROUP_KEY as _ } from "../../lib/layout-ops.js";
5
+ import { titleCase as y } from "../../lib/utils.js";
6
+ import { sectionLabel as T } from "./canvas-diff.js";
7
+ import { normalizedBundle as w } from "./field-zones.js";
8
+ import { restorePieceOps as a } from "./restore-piece.js";
9
+ import { slotName as U } from "./slot-names.js";
10
+ import { refuse as k, checked as z } from "./structure-ops.js";
11
+ import { humanizeOpError as G } from "./useLayoutDraft.js";
12
+ const L = (i, r) => i.sort - r.sort, u = (i, r) => i.placements.filter((o) => o.group_key === r && !v(o)).sort(L), M = (i) => i.kind === "header" ? _ : i.group_key;
13
+ class E {
14
+ constructor(r) {
15
+ c(this, "list", []);
16
+ /** The baseline does not have it: the revert takes it off. */
17
+ c(this, "isNew", !1);
18
+ /** Where it ends up, to select afterwards. */
19
+ c(this, "select");
20
+ this.w = r;
21
+ }
22
+ push(...r) {
23
+ for (const o of r)
24
+ this.w = P(this.w, [o]), this.list.push(o);
25
+ }
26
+ }
27
+ const x = (i, r) => r === null || r === _ || i.groups.some((o) => o.key === r);
28
+ function h(i, r, o, e) {
29
+ if (i.select = e.group_key === _ ? { kind: "header", field: e.field } : {
30
+ kind: e.field.startsWith("__") ? "slot" : "field",
31
+ field: e.field,
32
+ group_key: e.group_key
33
+ }, e.group_key !== o.group_key) {
34
+ if (!x(i.w, e.group_key))
35
+ throw new Error(
36
+ `Its saved section “${T(r.groups, e.group_key)}” is not on the form — put that back first`
37
+ );
38
+ i.push({
39
+ op: "move",
40
+ from: { field: o.field, group_key: o.group_key },
41
+ to_group_key: e.group_key,
42
+ index: Math.max(
43
+ 0,
44
+ u(r, e.group_key).findIndex((t) => t.field === e.field)
45
+ )
46
+ });
47
+ }
48
+ i.push(
49
+ ...a(i.w, r, {
50
+ kind: "field",
51
+ field: e.field,
52
+ group_key: e.group_key
53
+ })
54
+ );
55
+ const f = u(r, e.group_key).findIndex((t) => t.field === e.field), s = u(i.w, e.group_key).findIndex((t) => t.field === e.field);
56
+ if (!v(e) && f >= 0 && s >= 0 && f !== s) {
57
+ const t = u(i.w, e.group_key).length;
58
+ i.push({
59
+ op: "move",
60
+ from: { field: e.field, group_key: e.group_key },
61
+ to_group_key: e.group_key,
62
+ index: Math.min(f, t - 1)
63
+ });
64
+ }
65
+ }
66
+ function R(i, r, o) {
67
+ const e = M(o), f = i.placements.find((n) => n.field === o.field && n.group_key === e);
68
+ if (!f) throw new Error("That is no longer on this form");
69
+ const s = new E(i), t = r.placements.find((n) => n.field === o.field && n.group_key === e);
70
+ if (t)
71
+ return h(s, r, f, t), s;
72
+ const d = r.placements.filter((n) => n.field === o.field).find(
73
+ (n) => !i.placements.some((p) => p.field === n.field && p.group_key === n.group_key)
74
+ );
75
+ return d ? (h(s, r, f, d), s) : (s.isNew = !0, s.push({ op: "remove", at: { field: f.field, group_key: f.group_key } }), s);
76
+ }
77
+ function B(i, r, o) {
78
+ if (o === $) throw new Error("Ungrouped is not a section");
79
+ if (!i.groups.some((t) => t.key === o)) throw new Error("That section is no longer here");
80
+ const e = new E(i);
81
+ if (r.groups.some((t) => t.key === o))
82
+ return e.push(...a(i, r, { kind: "group", key: o })), e.select = { kind: "group", key: o }, e;
83
+ e.isNew = !0;
84
+ const f = [], s = (t) => {
85
+ for (const l of i.groups) l.parent_key === t && s(l.key);
86
+ f.push(t);
87
+ };
88
+ s(o);
89
+ for (const t of f) {
90
+ if (r.groups.some((l) => l.key === t)) {
91
+ e.push(...a(e.w, r, { kind: "group", key: t }));
92
+ continue;
93
+ }
94
+ for (const l of u(e.w, t)) {
95
+ const d = r.placements.find(
96
+ (n) => n.field === l.field && !e.w.placements.some((p) => p.field === n.field && p.group_key === n.group_key) && x(e.w, n.group_key) && !f.includes(n.group_key ?? "")
97
+ );
98
+ d ? e.push({
99
+ op: "move",
100
+ from: { field: l.field, group_key: t },
101
+ to_group_key: d.group_key,
102
+ index: Math.max(
103
+ 0,
104
+ u(r, d.group_key).findIndex((n) => n.field === d.field)
105
+ )
106
+ }) : e.push({ op: "remove", at: { field: l.field, group_key: t } });
107
+ }
108
+ e.push({ op: "group_remove", key: t, placements: "delete" });
109
+ }
110
+ return e;
111
+ }
112
+ function j(i, r, o, e = {}) {
113
+ var m;
114
+ if (!o) return k("Select a field or section first");
115
+ if (!r) return k("The saved form is still loading");
116
+ const f = e.baseline === "opened" ? "as it was when you opened the form" : "as saved", s = w(i), t = w(r), l = o.kind === "group" ? (() => {
117
+ const g = s.groups.find((O) => O.key === o.key);
118
+ return g ? g.label || y(g.key) : y(o.key);
119
+ })() : o.field.startsWith("__") ? U(o.field) : ((m = e.fieldLabel) == null ? void 0 : m.call(e, o.field)) ?? y(o.field);
120
+ let d;
121
+ try {
122
+ d = o.kind === "group" ? B(s, t, o.key) : R(s, t, o);
123
+ } catch (g) {
124
+ return k(G(g.message));
125
+ }
126
+ if (d.list.length === 0) return k(`${l} is already ${f}`);
127
+ const n = d.isNew, p = n ? [
128
+ e.baseline === "opened" ? "It was not on the form when you opened it: it comes off" : "It is not on the saved form: it comes off"
129
+ ] : [];
130
+ return z(s, {
131
+ ok: !0,
132
+ ops: d.list,
133
+ label: n ? `Take ${l} off (not ${f})` : `Put ${l} back ${f}`,
134
+ notes: p,
135
+ select: n ? void 0 : d.select
136
+ });
137
+ }
138
+ export {
139
+ j as revertPlan
140
+ };
@@ -1,241 +1,264 @@
1
- import { readGroupStructure as m, withGroupStructure as _, isFolded as E, FOLD_KEY as G, rowOf as L } from "../../lib/form-structure.js";
2
- import { GROUP_PATCH_KEYS as A, applyLayoutOps as M } from "../../lib/layout-ops.js";
1
+ import { readGroupStructure as g, withGroupStructure as w, isFolded as E, FOLD_KEY as G, rowOf as L } from "../../lib/form-structure.js";
2
+ import { GROUP_PATCH_KEYS as M, applyLayoutOps as W } from "../../lib/layout-ops.js";
3
3
  import { titleCase as N } from "../../lib/utils.js";
4
- import { newGroupKey as W } from "./add-target.js";
5
- import { normalizedBundle as x, zoneItems as P, keyOf as v, plural as b, inPageOrder as Y, selectedPlacements as z } from "./field-zones.js";
6
- import { withKey as C, readOverrides as J } from "./inspector/model.js";
7
- import { isPinned as U } from "./pin.js";
8
- import { humanizeOpError as D } from "./useLayoutDraft.js";
9
- const y = (t) => ({ ok: !1, reason: t });
10
- function O(t, r) {
11
- if (r.ops.length === 0) return y("Nothing would change");
4
+ import { newGroupKey as Y } from "./add-target.js";
5
+ import { normalizedBundle as T, zoneItems as x, keyOf as O, plural as _, inPageOrder as D, selectedPlacements as z } from "./field-zones.js";
6
+ import { withKey as A, readOverrides as J } from "./inspector/model.js";
7
+ import { isPinned as P } from "./pin.js";
8
+ import { humanizeOpError as H } from "./useLayoutDraft.js";
9
+ const d = (t) => ({ ok: !1, reason: t });
10
+ function $(t, n) {
11
+ if (n.ops.length === 0) return d("Nothing would change");
12
12
  try {
13
- return M(t, r.ops), r;
13
+ return W(t, n.ops), n;
14
14
  } catch (e) {
15
- return y(D(e.message));
15
+ return d(H(e.message));
16
16
  }
17
17
  }
18
- const a = (t, r) => r ? t.groups.find((e) => e.key === r) ?? null : null, g = (t) => t.label || N(t.key), I = /* @__PURE__ */ new Set(["section", "tab"]), B = (t) => !t.field.startsWith("__");
19
- function K(t, r) {
20
- const e = new Map(t.map((s, n) => [s.field, n]));
21
- return t.map((s, n) => {
22
- const o = L(r, s.field);
23
- if (!o) return n;
24
- const i = o.fields.map((l) => e.get(l)).filter((l) => l != null);
25
- return i.length >= 2 ? Math.min(...i) : n;
18
+ const a = (t, n) => n ? t.groups.find((e) => e.key === n) ?? null : null, u = (t) => t.label || N(t.key), j = /* @__PURE__ */ new Set(["section", "tab"]), B = (t) => !t.field.startsWith("__");
19
+ function C(t, n) {
20
+ const e = new Map(t.map((o, s) => [o.field, s]));
21
+ return t.map((o, s) => {
22
+ const r = L(n, o.field);
23
+ if (!r) return s;
24
+ const i = r.fields.map((p) => e.get(p)).filter((p) => p != null);
25
+ return i.length >= 2 ? Math.min(...i) : s;
26
26
  });
27
27
  }
28
- const F = (t, r) => t.map((e) => ({ ...e, fields: e.fields.filter((s) => r.has(s)) })).filter((e) => e.fields.length > 0);
29
- function H(t, r) {
30
- const e = {}, s = /* @__PURE__ */ new Set(["label", "content", "content_tone", "summary_fields", "editor_note", "i18n"]);
31
- for (const n of A) !s.has(n) && n !== "swap_config" && (e[n] = t[n]);
32
- return e.swap_config = _(null, { rows: r }), e;
28
+ const I = (t, n) => t.map((e) => ({ ...e, fields: e.fields.filter((o) => n.has(o)) })).filter((e) => e.fields.length > 0);
29
+ function q(t, n) {
30
+ const e = {}, o = /* @__PURE__ */ new Set(["label", "content", "content_tone", "summary_fields", "editor_note", "i18n"]);
31
+ for (const s of M) !o.has(s) && s !== "swap_config" && (e[s] = t[s]);
32
+ return e.swap_config = w(null, { rows: n }), e;
33
33
  }
34
- function q(t, r) {
35
- if (!r || r.kind !== "field" && r.kind !== "slot") return "Select the field to split at";
36
- if (r.group_key === null) return "Ungrouped fields are not in a section";
37
- const e = a(t, r.group_key);
34
+ function Q(t, n) {
35
+ if (!n || n.kind !== "field" && n.kind !== "slot") return "Select the field to split at";
36
+ if (n.group_key === null) return "Ungrouped fields are not in a section";
37
+ const e = a(t, n.group_key);
38
38
  if (!e) return "This comes from the parent form: override it here first";
39
- if (!I.has(e.type)) return "Only sections, tabs and steps split";
40
- if (U(e) || U(a(t, e.parent_key))) return "Unpin it first";
41
- const s = x(t), n = P(s, e.key), o = n.findIndex((l) => l.field === r.field);
42
- return o < 0 ? "That field is no longer where it was" : K(n, m(e.swap_config).rows)[o] !== o ? "Split before or after the row it sits in" : o === 0 ? "It is already the first field: nothing above it would stay" : null;
43
- }
44
- function ie(t, r) {
45
- const e = q(t, r);
46
- if (e) return y(e);
47
- const s = r, n = x(t), o = a(n, s.group_key), i = m(o.swap_config), l = P(n, o.key), p = K(l, i.rows), k = l.findIndex((h) => h.field === s.field), w = l.filter((h, j) => p[j] >= k), u = new Set(w.map((h) => h.field)), S = new Set(l.filter((h) => !u.has(h.field)).map((h) => h.field)), d = W(n, `${o.key}_2`), $ = `${g(o)} (continued)`, f = [
39
+ if (!j.has(e.type)) return "Only sections, tabs and steps split";
40
+ if (P(e) || P(a(t, e.parent_key))) return "Unpin it first";
41
+ const o = T(t), s = x(o, e.key), r = s.findIndex((p) => p.field === n.field);
42
+ return r < 0 ? "That field is no longer where it was" : C(s, g(e.swap_config).rows)[r] !== r ? "Split before or after the row it sits in" : r === 0 ? "It is already the first field: nothing above it would stay" : null;
43
+ }
44
+ function pe(t, n) {
45
+ const e = Q(t, n);
46
+ if (e) return d(e);
47
+ const o = n, s = T(t), r = a(s, o.group_key), i = g(r.swap_config), p = x(s, r.key), f = C(p, i.rows), b = p.findIndex((h) => h.field === o.field), y = p.filter((h, U) => f[U] >= b), k = new Set(y.map((h) => h.field)), m = new Set(p.filter((h) => !k.has(h.field)).map((h) => h.field)), c = Y(s, `${r.key}_2`), S = `${u(r)} (continued)`, l = [
48
48
  {
49
49
  op: "group_create",
50
- key: d,
51
- label: $,
52
- group_type: o.type,
53
- parent_key: o.parent_key,
54
- index: o.sort + 1,
55
- patch: H(o, F(i.rows, u))
50
+ key: c,
51
+ label: S,
52
+ group_type: r.type,
53
+ parent_key: r.parent_key,
54
+ index: r.sort + 1,
55
+ patch: q(r, I(i.rows, k))
56
56
  },
57
- ...w.map((h, j) => ({ op: "move", from: v(h), to_group_key: d, index: j }))
58
- ], c = F(i.rows, S);
59
- JSON.stringify(c) !== JSON.stringify(i.rows) && f.push({
57
+ ...y.map((h, U) => ({ op: "move", from: O(h), to_group_key: c, index: U }))
58
+ ], v = I(i.rows, m);
59
+ JSON.stringify(v) !== JSON.stringify(i.rows) && l.push({
60
60
  op: "group_update",
61
- key: o.key,
62
- patch: { swap_config: _(o.swap_config, { rows: c }) }
61
+ key: r.key,
62
+ patch: { swap_config: w(r.swap_config, { rows: v }) }
63
63
  });
64
- const T = [`${b(w.length, "field")} move to ${$}`];
65
- return i.sticky && T.push("Only the first part stays pinned to the top"), O(t, {
64
+ const F = [`${_(y.length, "field")} move to ${S}`];
65
+ return i.sticky && F.push("Only the first part stays pinned to the top"), $(t, {
66
66
  ok: !0,
67
- ops: f,
68
- label: `Split ${g(o)}`,
69
- notes: T,
70
- select: { kind: "group", key: d }
67
+ ops: l,
68
+ label: `Split ${u(r)}`,
69
+ notes: F,
70
+ select: { kind: "group", key: c }
71
71
  });
72
72
  }
73
- function R(t, r) {
74
- const e = x(t), s = a(e, r);
75
- if (!s) return null;
76
- const o = e.groups.filter((i) => i.parent_key === s.parent_key).sort((i, l) => i.sort - l.sort).find((i) => i.sort > s.sort);
77
- return o && o.sort === s.sort + 1 && o.type === s.type ? o : null;
73
+ function K(t, n) {
74
+ const e = T(t), o = a(e, n);
75
+ if (!o) return null;
76
+ const r = e.groups.filter((i) => i.parent_key === o.parent_key).sort((i, p) => i.sort - p.sort).find((i) => i.sort > o.sort);
77
+ return r && r.sort === o.sort + 1 && r.type === o.type ? r : null;
78
78
  }
79
- function Q(t, r) {
80
- const e = a(t, r);
79
+ function V(t, n) {
80
+ const e = a(t, n);
81
81
  if (!e) return "This comes from the parent form: override it here first";
82
- if (!I.has(e.type)) return "Only sections, tabs and steps join";
83
- const s = R(t, r);
84
- return s ? [e, s].some((n) => U(n)) || U(a(t, e.parent_key)) ? "Unpin it first" : null : e.type === "tab" ? "No tab or step right after it" : "No section right below it";
85
- }
86
- function fe(t, r) {
87
- const e = Q(t, r);
88
- if (e) return y(e);
89
- const s = x(t), n = a(s, r), o = R(s, r), i = P(s, n.key), l = new Set(i.map((c) => c.field)), p = P(s, o.key), k = [];
90
- let w = i.length, u = 0;
91
- for (const c of p) {
92
- if (l.has(c.field)) {
93
- u++, k.push({ op: "remove", at: v(c) });
82
+ if (!j.has(e.type)) return "Only sections, tabs and steps join";
83
+ const o = K(t, n);
84
+ return o ? [e, o].some((s) => P(s)) || P(a(t, e.parent_key)) ? "Unpin it first" : null : e.type === "tab" ? "No tab or step right after it" : "No section right below it";
85
+ }
86
+ function ce(t, n) {
87
+ const e = V(t, n);
88
+ if (e) return d(e);
89
+ const o = T(t), s = a(o, n), r = K(o, n), { ops: i, notes: p } = R(o, s, r);
90
+ return $(t, {
91
+ ok: !0,
92
+ ops: i,
93
+ label: `Join ${u(s)} and ${u(r)}`,
94
+ notes: p,
95
+ select: { kind: "group", key: s.key }
96
+ });
97
+ }
98
+ function R(t, n, e) {
99
+ const o = x(t, n.key), s = new Set(o.map((c) => c.field)), r = x(t, e.key), i = [];
100
+ let p = o.length, f = 0;
101
+ for (const c of r) {
102
+ if (s.has(c.field)) {
103
+ f++, i.push({ op: "remove", at: O(c) });
94
104
  continue;
95
105
  }
96
- k.push({ op: "move", from: v(c), to_group_key: n.key, index: w++ });
106
+ i.push({ op: "move", from: O(c), to_group_key: n.key, index: p++ });
97
107
  }
98
- const S = m(n.swap_config), d = new Set(p.filter((c) => !l.has(c.field)).map((c) => c.field)), $ = F(m(o.swap_config).rows, d).map((c) => ({
108
+ const b = g(n.swap_config), y = new Set(r.filter((c) => !s.has(c.field)).map((c) => c.field)), k = I(g(e.swap_config).rows, y).map((c) => ({
99
109
  ...c,
100
- key: S.rows.some((T) => T.key === c.key) ? `${c.key}_${o.key}` : c.key
110
+ key: b.rows.some((S) => S.key === c.key) ? `${c.key}_${e.key}` : c.key
101
111
  }));
102
- $.length && k.push({
112
+ k.length && i.push({
103
113
  op: "group_update",
104
114
  key: n.key,
105
- patch: { swap_config: _(n.swap_config, { rows: [...S.rows, ...$] }) }
106
- }), k.push({ op: "group_remove", key: o.key, placements: "delete" });
107
- const f = [`${b(p.length, "field")} from ${g(o)} join ${g(n)}`];
108
- return f.push(`${g(n)} keeps its settings`), u && f.push(`${b(u, "field")} in both ${u === 1 ? "shows" : "show"} once`), O(t, {
115
+ patch: { swap_config: w(n.swap_config, { rows: [...b.rows, ...k] }) }
116
+ }), i.push({ op: "group_remove", key: e.key, placements: "delete" });
117
+ const m = [`${_(r.length, "field")} from ${u(e)} join ${u(n)}`];
118
+ return m.push(`${u(n)} keeps its settings`), f && m.push(`${_(f, "field")} in both ${f === 1 ? "shows" : "show"} once`), { ops: i, notes: m };
119
+ }
120
+ function X(t, n, e) {
121
+ if (n === e) return "It is the same section";
122
+ const o = a(t, n), s = a(t, e);
123
+ return !o || !s ? "This comes from the parent form: override it here first" : !j.has(o.type) || !j.has(s.type) ? "Only sections, tabs and steps join" : o.type !== s.type ? o.type === "tab" ? "A tab joins another tab" : "A section joins another section" : (o.parent_key ?? null) !== (s.parent_key ?? null) ? "They sit in different holders" : [o, s].some((r) => P(r)) || P(a(t, o.parent_key)) ? "Unpin it first" : null;
124
+ }
125
+ function le(t, n, e) {
126
+ const o = X(t, n, e);
127
+ if (o) return d(o);
128
+ const s = T(t), r = a(s, n), i = a(s, e), { ops: p, notes: f } = R(s, i, r);
129
+ return $(t, {
109
130
  ok: !0,
110
- ops: k,
111
- label: `Join ${g(n)} and ${g(o)}`,
131
+ ops: p,
132
+ label: `Join ${u(r)} into ${u(i)}`,
112
133
  notes: f,
113
- select: { kind: "group", key: n.key }
134
+ select: { kind: "group", key: i.key }
114
135
  });
115
136
  }
116
- function V(t, r) {
117
- const e = z(t, r).filter(B);
137
+ function Z(t, n) {
138
+ const e = z(t, n).filter(B);
118
139
  if (e.length < 2) return "Select two or more fields in one section";
119
- const s = e[0].group_key;
120
- if (e.some((o) => o.group_key !== s)) return "Pick fields from one section";
121
- if (s === null) return "Ungrouped fields are not in a section: wrap them first";
122
- const n = a(t, s);
123
- return n ? I.has(n.type) ? e.length > 6 ? "Six fields at most share one row" : null : "Only fields in sections, tabs and steps share a row" : "This comes from the parent form: override it here first";
124
- }
125
- function pe(t, r, e = N) {
126
- const s = V(t, r);
127
- if (s) return y(s);
128
- const n = x(t), o = Y(n, z(n, r).filter(B)), i = a(n, o[0].group_key), l = m(i.swap_config), p = o.map((f) => f.field), k = new Set(l.rows.map((f) => f.key));
129
- let w = "row";
130
- for (let f = 2; k.has(w); f++) w = `row_${f}`;
131
- const u = { key: w, label: p.map(e).join(" / "), fields: p }, S = [
132
- ...l.rows.map((f) => ({ ...f, fields: f.fields.filter((c) => !p.includes(c)) })).filter((f) => f.fields.length >= 2),
133
- u
134
- ], d = [], $ = P(n, i.key).findIndex((f) => f.field === p[0]);
135
- o.slice(1).forEach((f, c) => {
136
- d.push({ op: "move", from: v(f), to_group_key: i.key, index: $ + 1 + c });
140
+ const o = e[0].group_key;
141
+ if (e.some((r) => r.group_key !== o)) return "Pick fields from one section";
142
+ if (o === null) return "Ungrouped fields are not in a section: wrap them first";
143
+ const s = a(t, o);
144
+ return s ? j.has(s.type) ? e.length > 6 ? "Six fields at most share one row" : null : "Only fields in sections, tabs and steps share a row" : "This comes from the parent form: override it here first";
145
+ }
146
+ function ae(t, n, e = N) {
147
+ const o = Z(t, n);
148
+ if (o) return d(o);
149
+ const s = T(t), r = D(s, z(s, n).filter(B)), i = a(s, r[0].group_key), p = g(i.swap_config), f = r.map((l) => l.field), b = new Set(p.rows.map((l) => l.key));
150
+ let y = "row";
151
+ for (let l = 2; b.has(y); l++) y = `row_${l}`;
152
+ const k = { key: y, label: f.map(e).join(" / "), fields: f }, m = [
153
+ ...p.rows.map((l) => ({ ...l, fields: l.fields.filter((v) => !f.includes(v)) })).filter((l) => l.fields.length >= 2),
154
+ k
155
+ ], c = [], S = x(s, i.key).findIndex((l) => l.field === f[0]);
156
+ r.slice(1).forEach((l, v) => {
157
+ c.push({ op: "move", from: O(l), to_group_key: i.key, index: S + 1 + v });
137
158
  });
138
- for (const f of o)
139
- E(f.overrides) && d.push({
159
+ for (const l of r)
160
+ E(l.overrides) && c.push({
140
161
  op: "update_placement",
141
- at: v(f),
142
- patch: { overrides: C(J(f), G, void 0) }
162
+ at: O(l),
163
+ patch: { overrides: A(J(l), G, void 0) }
143
164
  });
144
- return d.push({
165
+ return c.push({
145
166
  op: "group_update",
146
167
  key: i.key,
147
- patch: { swap_config: _(i.swap_config, { rows: S }) }
148
- }), O(t, {
168
+ patch: { swap_config: w(i.swap_config, { rows: m }) }
169
+ }), $(t, {
149
170
  ok: !0,
150
- ops: d,
151
- label: `Put ${b(p.length, "field")} side by side`,
152
- notes: [`Under one label: “${u.label}”`],
153
- select: { kind: "field", field: p[0], group_key: i.key }
171
+ ops: c,
172
+ label: `Put ${_(f.length, "field")} side by side`,
173
+ notes: [`Under one label: “${k.label}”`],
174
+ select: { kind: "field", field: f[0], group_key: i.key }
154
175
  });
155
176
  }
156
- function ce(t, r, e, s) {
157
- const n = a(t, r);
158
- if (!n) return y("That section is no longer on this form");
159
- const o = m(n.swap_config), i = o.rows.find((p) => p.key === e);
160
- if (!i) return y("That row is no longer on this form");
161
- const l = s === null ? o.rows.filter((p) => p.key !== e) : o.rows.map((p) => p.key === e ? { ...p, ...s } : p).filter((p) => p.key !== e || p.fields.length >= 2);
162
- return O(t, {
177
+ function ue(t, n, e, o) {
178
+ const s = a(t, n);
179
+ if (!s) return d("That section is no longer on this form");
180
+ const r = g(s.swap_config), i = r.rows.find((f) => f.key === e);
181
+ if (!i) return d("That row is no longer on this form");
182
+ const p = o === null ? r.rows.filter((f) => f.key !== e) : r.rows.map((f) => f.key === e ? { ...f, ...o } : f).filter((f) => f.key !== e || f.fields.length >= 2);
183
+ return $(t, {
163
184
  ok: !0,
164
185
  ops: [
165
186
  {
166
187
  op: "group_update",
167
- key: n.key,
168
- patch: { swap_config: _(n.swap_config, { rows: l }) }
188
+ key: s.key,
189
+ patch: { swap_config: w(s.swap_config, { rows: p }) }
169
190
  }
170
191
  ],
171
- label: s === null ? `Take the row “${i.label}” apart` : `Change the row “${i.label}”`,
192
+ label: o === null ? `Take the row “${i.label}” apart` : `Change the row “${i.label}”`,
172
193
  notes: []
173
194
  });
174
195
  }
175
- function le(t, r, e) {
176
- const s = [];
177
- let n = 0;
178
- for (const o of r) {
179
- if (!B(o) || o.group_key === null) continue;
180
- const i = a(t, o.group_key);
181
- if (e && i && L(m(i.swap_config).rows, o.field)) {
182
- n++;
196
+ function de(t, n, e) {
197
+ const o = [];
198
+ let s = 0;
199
+ for (const r of n) {
200
+ if (!B(r) || r.group_key === null) continue;
201
+ const i = a(t, r.group_key);
202
+ if (e && i && L(g(i.swap_config).rows, r.field)) {
203
+ s++;
183
204
  continue;
184
205
  }
185
- E(o.overrides) !== e && s.push({
206
+ E(r.overrides) !== e && o.push({
186
207
  op: "update_placement",
187
- at: v(o),
188
- patch: { overrides: C(J(o), G, e ? !0 : void 0) }
208
+ at: O(r),
209
+ patch: { overrides: A(J(r), G, e ? !0 : void 0) }
189
210
  });
190
211
  }
191
- return s.length === 0 && n ? y("Fields in a row stay out of the fold") : O(t, {
212
+ return o.length === 0 && s ? d("Fields in a row stay out of the fold") : $(t, {
192
213
  ok: !0,
193
- ops: s,
194
- label: e ? `Put ${b(s.length, "field")} behind “Show more”` : `Show ${b(s.length, "field")} always`,
195
- notes: n ? [`${b(n, "field")} in a row ${n === 1 ? "stays" : "stay"} out`] : []
214
+ ops: o,
215
+ label: e ? `Put ${_(o.length, "field")} behind “Show more”` : `Show ${_(o.length, "field")} always`,
216
+ notes: s ? [`${_(s, "field")} in a row ${s === 1 ? "stays" : "stay"} out`] : []
196
217
  });
197
218
  }
198
- function ae(t, r, e) {
199
- const s = a(t, r);
200
- if (!s) return y("That section is no longer on this form");
201
- if (s.type !== "section" || s.parent_key !== null)
202
- return y("Only a section at the top level of the form sticks");
203
- const n = [], o = [];
219
+ function he(t, n, e) {
220
+ const o = a(t, n);
221
+ if (!o) return d("That section is no longer on this form");
222
+ if (o.type !== "section" || o.parent_key !== null)
223
+ return d("Only a section at the top level of the form sticks");
224
+ const s = [], r = [];
204
225
  if (e)
205
226
  for (const i of t.groups)
206
- i.key !== r && m(i.swap_config).sticky && (n.push({
227
+ i.key !== n && g(i.swap_config).sticky && (s.push({
207
228
  op: "group_update",
208
229
  key: i.key,
209
- patch: { swap_config: _(i.swap_config, { sticky: !1 }) }
210
- }), o.push(`${g(i)} stops sticking: one sticky section per form`));
211
- return m(s.swap_config).sticky !== e && n.push({
230
+ patch: { swap_config: w(i.swap_config, { sticky: !1 }) }
231
+ }), r.push(`${u(i)} stops sticking: one sticky section per form`));
232
+ return g(o.swap_config).sticky !== e && s.push({
212
233
  op: "group_update",
213
- key: r,
214
- patch: { swap_config: _(s.swap_config, { sticky: e }) }
215
- }), O(t, {
234
+ key: n,
235
+ patch: { swap_config: w(o.swap_config, { sticky: e }) }
236
+ }), $(t, {
216
237
  ok: !0,
217
- ops: n,
218
- label: e ? `Pin ${g(s)} to the top` : `Let ${g(s)} scroll`,
219
- notes: o
238
+ ops: s,
239
+ label: e ? `Pin ${u(o)} to the top` : `Let ${u(o)} scroll`,
240
+ notes: r
220
241
  });
221
242
  }
222
- function ue(t, r) {
243
+ function ye(t, n) {
223
244
  return {
224
245
  op: "group_update",
225
246
  key: t.key,
226
- patch: { swap_config: _(t.swap_config, { emptyText: r }) }
247
+ patch: { swap_config: w(t.swap_config, { emptyText: n }) }
227
248
  };
228
249
  }
229
250
  export {
230
- ue as emptyTextOp,
231
- le as foldPlan,
232
- Q as joinBlocked,
233
- fe as joinPlan,
234
- R as joinTarget,
235
- V as rowBlocked,
236
- pe as rowPlan,
237
- ce as rowUpdatePlan,
238
- q as splitBlocked,
239
- ie as splitPlan,
240
- ae as stickyPlan
251
+ ye as emptyTextOp,
252
+ de as foldPlan,
253
+ V as joinBlocked,
254
+ ce as joinPlan,
255
+ K as joinTarget,
256
+ X as mergeBlocked,
257
+ le as mergePlan,
258
+ Z as rowBlocked,
259
+ ae as rowPlan,
260
+ ue as rowUpdatePlan,
261
+ Q as splitBlocked,
262
+ pe as splitPlan,
263
+ he as stickyPlan
241
264
  };