@nivaro/react 0.2.54 → 0.2.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +99 -98
- package/dist/index.d.ts +367 -2
- package/dist/index.js +645 -616
- package/dist/layout-editor.d.ts +4 -0
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/ItemEditForm.js +4066 -3832
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +599 -552
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +76 -73
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +292 -279
- package/dist/shared/components/item-edit/GroupSection.js +698 -574
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +39 -32
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
- package/dist/shared/components/layout-editor/AddPanel.js +134 -117
- package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
- package/dist/shared/components/layout-editor/CollabParts.js +80 -75
- package/dist/shared/components/layout-editor/DesignNode.js +126 -120
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
- package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
- package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
- package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
- package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
- package/dist/shared/components/layout-editor/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
- package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
- package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
- package/dist/shared/components/layout-editor/grid-guides.js +142 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
- package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
- package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
- package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/layout-editor/restore-piece.js +192 -0
- package/dist/shared/components/layout-editor/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
- package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
- package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
- package/dist/shared/components/layout-editor/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +81 -77
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
- package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
- package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
- package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +101 -52
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -0
- package/dist/shared/lib/layout-ops.js +84 -82
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/stale-chunk.js +60 -0
- package/dist/shared/lib/worker-socket.js +200 -0
- package/package.json +1 -1
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
var R = Object.defineProperty;
|
|
2
|
+
var I = (r, e, t) => e in r ? R(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
+
var w = (r, e, t) => I(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { UNGROUPED_KEY as E, RESERVED_FIELDS as P, isCanvasSlot as _, applyLayoutOps as S, PLACEMENT_PATCH_KEYS as m, newGroup as A, HEADER_GROUP_KEY as $, TABLE_FORM_GROUP_KEYS as N, GROUP_PATCH_KEYS as b } from "../../lib/layout-ops.js";
|
|
5
|
+
import { sectionLabel as g, sameValue as T } from "./canvas-diff.js";
|
|
6
|
+
import { slotName as G } from "./slot-names.js";
|
|
7
|
+
const k = (r, e) => r.sort - e.sort || (r.id ?? Number.MAX_SAFE_INTEGER) - (e.id ?? Number.MAX_SAFE_INTEGER);
|
|
8
|
+
function d(r, e) {
|
|
9
|
+
return r.placements.filter((t) => t.group_key === e && !_(t)).sort(k);
|
|
10
|
+
}
|
|
11
|
+
function O(r, e) {
|
|
12
|
+
const t = r.groups.filter(
|
|
13
|
+
(i) => (i.parent_key ?? null) === e
|
|
14
|
+
);
|
|
15
|
+
return e === null && t.push(...r.placements.filter(_)), t.sort(k);
|
|
16
|
+
}
|
|
17
|
+
const x = (r, e) => "key" in r && "key" in e ? r.key === e.key : "field" in r && "field" in e && r.field === e.field;
|
|
18
|
+
function y(r, e, t) {
|
|
19
|
+
const i = r, u = e, l = {};
|
|
20
|
+
for (const p of t) u[p] !== void 0 && !T(i[p], u[p]) && (l[p] = u[p]);
|
|
21
|
+
return l;
|
|
22
|
+
}
|
|
23
|
+
function j(r, e) {
|
|
24
|
+
return e === null || e === $ || r.layout.layout_type === "table" && N.includes(e) ? !0 : r.groups.some((t) => t.key === e && t.key !== E);
|
|
25
|
+
}
|
|
26
|
+
class C {
|
|
27
|
+
constructor(e, t) {
|
|
28
|
+
w(this, "ops", []);
|
|
29
|
+
this.w = e, this.version = t;
|
|
30
|
+
}
|
|
31
|
+
push(e) {
|
|
32
|
+
this.w = S(this.w, [e]), this.ops.push(e);
|
|
33
|
+
}
|
|
34
|
+
/** Where the version had this placement among its zone (slot cards: among the top level). */
|
|
35
|
+
versionIndex(e) {
|
|
36
|
+
const t = _(e) ? O(this.version, null) : d(this.version, e.group_key), i = t.findIndex((u) => x(u, e));
|
|
37
|
+
return i < 0 ? t.length : i;
|
|
38
|
+
}
|
|
39
|
+
/** A field as the version had it: settings, and the version's section when it is elsewhere. */
|
|
40
|
+
field(e) {
|
|
41
|
+
const t = { field: e.field, group_key: e.group_key }, i = this.w.placements.find((s) => s.field === e.field && s.group_key === e.group_key);
|
|
42
|
+
if (i) {
|
|
43
|
+
const s = y(i, e, m);
|
|
44
|
+
Object.keys(s).length && this.push({ op: "update_placement", at: t, patch: s });
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (!j(this.w, e.group_key))
|
|
48
|
+
throw new Error(
|
|
49
|
+
`Its section “${g(this.version.groups, e.group_key)}” is not on the form — restore the section instead`
|
|
50
|
+
);
|
|
51
|
+
const u = this.versionIndex(e), l = this.w.placements.filter((s) => s.field === e.field).sort((s, o) => (s.group_key ?? "").localeCompare(o.group_key ?? ""))[0];
|
|
52
|
+
if (l) {
|
|
53
|
+
this.push({
|
|
54
|
+
op: "move",
|
|
55
|
+
from: { field: l.field, group_key: l.group_key },
|
|
56
|
+
to_group_key: e.group_key,
|
|
57
|
+
index: u
|
|
58
|
+
});
|
|
59
|
+
const s = y(l, e, m);
|
|
60
|
+
Object.keys(s).length && this.push({ op: "update_placement", at: t, patch: s });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const p = {}, n = e;
|
|
64
|
+
for (const s of m) n[s] !== void 0 && (p[s] = n[s]);
|
|
65
|
+
this.push({ op: "place", field: e.field, group_key: e.group_key, index: u, patch: p });
|
|
66
|
+
}
|
|
67
|
+
/** A section as the version had it: its row, its tabs, then its fields in the version's order. */
|
|
68
|
+
group(e) {
|
|
69
|
+
if (e.key === E) throw new Error("Ungrouped is not a section");
|
|
70
|
+
const t = e.parent_key != null && this.w.groups.some((n) => n.key === e.parent_key) ? e.parent_key : null, i = O(this.version, e.parent_key ?? null), u = Math.max(
|
|
71
|
+
0,
|
|
72
|
+
i.findIndex((n) => x(n, e))
|
|
73
|
+
), l = this.w.groups.find((n) => n.key === e.key);
|
|
74
|
+
if (l) {
|
|
75
|
+
const n = y(l, e, b);
|
|
76
|
+
Object.keys(n).length && this.push({ op: "group_update", key: e.key, patch: n }), (l.parent_key ?? null) !== t && this.push({ op: "group_move", key: e.key, parent_key: t, index: u });
|
|
77
|
+
} else {
|
|
78
|
+
const n = A(e.key, e.label, e.type, t), s = y(n, e, b);
|
|
79
|
+
delete s.label, delete s.type, this.push({
|
|
80
|
+
op: "group_create",
|
|
81
|
+
key: e.key,
|
|
82
|
+
label: e.label,
|
|
83
|
+
group_type: e.type,
|
|
84
|
+
parent_key: t,
|
|
85
|
+
index: u,
|
|
86
|
+
patch: s
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
for (const n of this.version.groups.filter((s) => s.parent_key === e.key).sort(k))
|
|
90
|
+
this.group(n);
|
|
91
|
+
if (e.type === "container" || e.type === "content") return;
|
|
92
|
+
const p = d(this.version, e.key);
|
|
93
|
+
for (const n of p) this.field(n);
|
|
94
|
+
for (const n of d(this.w, e.key))
|
|
95
|
+
p.some((s) => s.field === n.field) || this.push({ op: "remove", at: { field: n.field, group_key: e.key } });
|
|
96
|
+
p.forEach((n, s) => {
|
|
97
|
+
var o;
|
|
98
|
+
((o = d(this.w, e.key)[s]) == null ? void 0 : o.field) !== n.field && this.push({
|
|
99
|
+
op: "move",
|
|
100
|
+
from: { field: n.field, group_key: e.key },
|
|
101
|
+
to_group_key: e.key,
|
|
102
|
+
index: s
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
function M(r, e, t) {
|
|
108
|
+
const i = new C(r, e);
|
|
109
|
+
if (t.kind === "group") {
|
|
110
|
+
const u = e.groups.find((l) => l.key === t.key);
|
|
111
|
+
if (!u) throw new Error("That version has no such section");
|
|
112
|
+
i.group(u);
|
|
113
|
+
} else {
|
|
114
|
+
const u = e.placements.find(
|
|
115
|
+
(l) => l.field === t.field && l.group_key === t.group_key
|
|
116
|
+
);
|
|
117
|
+
if (!u) throw new Error("That version has no such field");
|
|
118
|
+
i.field(u);
|
|
119
|
+
}
|
|
120
|
+
return i.ops;
|
|
121
|
+
}
|
|
122
|
+
const h = (r, e, t = `${e}s`) => `${r} ${r === 1 ? e : t}`;
|
|
123
|
+
function U(r, e) {
|
|
124
|
+
let t = 0, i = 0, u = 0, l = 0, p = 0, n = !1, s = 0, o = 0;
|
|
125
|
+
for (const c of r)
|
|
126
|
+
switch (c.op) {
|
|
127
|
+
case "place":
|
|
128
|
+
t++;
|
|
129
|
+
break;
|
|
130
|
+
case "move":
|
|
131
|
+
(c.from.group_key ?? null) === (c.to_group_key ?? null) ? u++ : i++;
|
|
132
|
+
break;
|
|
133
|
+
case "remove":
|
|
134
|
+
l++;
|
|
135
|
+
break;
|
|
136
|
+
case "update_placement":
|
|
137
|
+
p += Object.keys(c.patch ?? {}).length;
|
|
138
|
+
break;
|
|
139
|
+
case "group_create":
|
|
140
|
+
e.kind === "group" && c.key === e.key ? n = !0 : o++;
|
|
141
|
+
break;
|
|
142
|
+
case "group_update":
|
|
143
|
+
s += Object.keys(c.patch ?? {}).length;
|
|
144
|
+
break;
|
|
145
|
+
case "group_move":
|
|
146
|
+
s++;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
const f = [];
|
|
150
|
+
return n && f.push("Back on the form"), o && f.push(h(o, "tab")), e.kind === "field" ? (t && f.push("Back on the form"), i && f.push("Moves back"), p && f.push(h(p, "setting"))) : (s && f.push(h(s, "section setting")), t && f.push(`${h(t, "field")} back`), i && f.push(`${h(i, "field")} moved in`), l && f.push(`${h(l, "field")} removed`), p && f.push(h(p, "field setting")), u && !t && !i && !l && f.push("Order")), f.join(" · ") || "Nothing differs";
|
|
151
|
+
}
|
|
152
|
+
function D(r, e, t = (i) => i) {
|
|
153
|
+
var s;
|
|
154
|
+
const i = [], u = (o, f, c) => {
|
|
155
|
+
try {
|
|
156
|
+
const a = M(r, e, o);
|
|
157
|
+
if (a.length === 0) return;
|
|
158
|
+
i.push({ piece: o, label: f, where: c, summary: U(a, o), ops: a });
|
|
159
|
+
} catch (a) {
|
|
160
|
+
i.push({
|
|
161
|
+
piece: o,
|
|
162
|
+
label: f,
|
|
163
|
+
where: c,
|
|
164
|
+
summary: "",
|
|
165
|
+
ops: [],
|
|
166
|
+
error: a instanceof Error ? a.message : String(a)
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, l = [...e.groups].filter((o) => o.key !== E).sort(k), p = [
|
|
170
|
+
...l.filter((o) => o.parent_key == null),
|
|
171
|
+
...l.filter((o) => o.parent_key != null)
|
|
172
|
+
];
|
|
173
|
+
for (const o of p)
|
|
174
|
+
u(
|
|
175
|
+
{ kind: "group", key: o.key },
|
|
176
|
+
((s = o.label) == null ? void 0 : s.trim()) || o.key,
|
|
177
|
+
o.parent_key ? `in ${g(e.groups, o.parent_key)}` : null
|
|
178
|
+
);
|
|
179
|
+
const n = [...e.placements].filter((o) => !P.includes(o.field)).sort((o, f) => (o.group_key ?? "").localeCompare(f.group_key ?? "") || k(o, f));
|
|
180
|
+
for (const o of n)
|
|
181
|
+
u(
|
|
182
|
+
{ kind: "field", field: o.field, group_key: o.group_key },
|
|
183
|
+
o.field.startsWith("__") ? G(o.field) : t(o.field),
|
|
184
|
+
_(o) ? null : `in ${g(e.groups, o.group_key)}`
|
|
185
|
+
);
|
|
186
|
+
return i;
|
|
187
|
+
}
|
|
188
|
+
export {
|
|
189
|
+
D as restorablePieces,
|
|
190
|
+
M as restorePieceOps,
|
|
191
|
+
U as summarizeOps
|
|
192
|
+
};
|
|
@@ -0,0 +1,241 @@
|
|
|
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";
|
|
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");
|
|
12
|
+
try {
|
|
13
|
+
return M(t, r.ops), r;
|
|
14
|
+
} catch (e) {
|
|
15
|
+
return y(D(e.message));
|
|
16
|
+
}
|
|
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;
|
|
26
|
+
});
|
|
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;
|
|
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);
|
|
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 = [
|
|
48
|
+
{
|
|
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))
|
|
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({
|
|
60
|
+
op: "group_update",
|
|
61
|
+
key: o.key,
|
|
62
|
+
patch: { swap_config: _(o.swap_config, { rows: c }) }
|
|
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, {
|
|
66
|
+
ok: !0,
|
|
67
|
+
ops: f,
|
|
68
|
+
label: `Split ${g(o)}`,
|
|
69
|
+
notes: T,
|
|
70
|
+
select: { kind: "group", key: d }
|
|
71
|
+
});
|
|
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;
|
|
78
|
+
}
|
|
79
|
+
function Q(t, r) {
|
|
80
|
+
const e = a(t, r);
|
|
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) });
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
k.push({ op: "move", from: v(c), to_group_key: n.key, index: w++ });
|
|
97
|
+
}
|
|
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) => ({
|
|
99
|
+
...c,
|
|
100
|
+
key: S.rows.some((T) => T.key === c.key) ? `${c.key}_${o.key}` : c.key
|
|
101
|
+
}));
|
|
102
|
+
$.length && k.push({
|
|
103
|
+
op: "group_update",
|
|
104
|
+
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, {
|
|
109
|
+
ok: !0,
|
|
110
|
+
ops: k,
|
|
111
|
+
label: `Join ${g(n)} and ${g(o)}`,
|
|
112
|
+
notes: f,
|
|
113
|
+
select: { kind: "group", key: n.key }
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function V(t, r) {
|
|
117
|
+
const e = z(t, r).filter(B);
|
|
118
|
+
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 });
|
|
137
|
+
});
|
|
138
|
+
for (const f of o)
|
|
139
|
+
E(f.overrides) && d.push({
|
|
140
|
+
op: "update_placement",
|
|
141
|
+
at: v(f),
|
|
142
|
+
patch: { overrides: C(J(f), G, void 0) }
|
|
143
|
+
});
|
|
144
|
+
return d.push({
|
|
145
|
+
op: "group_update",
|
|
146
|
+
key: i.key,
|
|
147
|
+
patch: { swap_config: _(i.swap_config, { rows: S }) }
|
|
148
|
+
}), O(t, {
|
|
149
|
+
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 }
|
|
154
|
+
});
|
|
155
|
+
}
|
|
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, {
|
|
163
|
+
ok: !0,
|
|
164
|
+
ops: [
|
|
165
|
+
{
|
|
166
|
+
op: "group_update",
|
|
167
|
+
key: n.key,
|
|
168
|
+
patch: { swap_config: _(n.swap_config, { rows: l }) }
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
label: s === null ? `Take the row “${i.label}” apart` : `Change the row “${i.label}”`,
|
|
172
|
+
notes: []
|
|
173
|
+
});
|
|
174
|
+
}
|
|
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++;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
E(o.overrides) !== e && s.push({
|
|
186
|
+
op: "update_placement",
|
|
187
|
+
at: v(o),
|
|
188
|
+
patch: { overrides: C(J(o), G, e ? !0 : void 0) }
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
return s.length === 0 && n ? y("Fields in a row stay out of the fold") : O(t, {
|
|
192
|
+
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`] : []
|
|
196
|
+
});
|
|
197
|
+
}
|
|
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 = [];
|
|
204
|
+
if (e)
|
|
205
|
+
for (const i of t.groups)
|
|
206
|
+
i.key !== r && m(i.swap_config).sticky && (n.push({
|
|
207
|
+
op: "group_update",
|
|
208
|
+
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({
|
|
212
|
+
op: "group_update",
|
|
213
|
+
key: r,
|
|
214
|
+
patch: { swap_config: _(s.swap_config, { sticky: e }) }
|
|
215
|
+
}), O(t, {
|
|
216
|
+
ok: !0,
|
|
217
|
+
ops: n,
|
|
218
|
+
label: e ? `Pin ${g(s)} to the top` : `Let ${g(s)} scroll`,
|
|
219
|
+
notes: o
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function ue(t, r) {
|
|
223
|
+
return {
|
|
224
|
+
op: "group_update",
|
|
225
|
+
key: t.key,
|
|
226
|
+
patch: { swap_config: _(t.swap_config, { emptyText: r }) }
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
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
|
|
241
|
+
};
|