@nivaro/react 0.2.52 → 0.2.54

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 (191) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +116 -2
  4. package/dist/layout-editor.d.ts +248 -2
  5. package/dist/shared/components/FormWhatsNew.js +60 -0
  6. package/dist/shared/components/ItemEditForm.js +3994 -3876
  7. package/dist/shared/components/RecordReadView.js +219 -211
  8. package/dist/shared/components/TipLayer.js +27 -27
  9. package/dist/shared/components/help-videos/api.js +51 -41
  10. package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
  11. package/dist/shared/components/item-edit/FieldAffordances.js +7 -6
  12. package/dist/shared/components/item-edit/FieldRow.js +353 -304
  13. package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
  14. package/dist/shared/components/item-edit/GroupSection.js +419 -396
  15. package/dist/shared/components/item-edit/HeaderTools.js +59 -56
  16. package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
  17. package/dist/shared/components/item-edit/lock-why.js +87 -0
  18. package/dist/shared/components/item-edit/useFormUsageBeacon.js +59 -0
  19. package/dist/shared/components/layout-editor/AddPanel.js +204 -146
  20. package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
  21. package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
  22. package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
  23. package/dist/shared/components/layout-editor/ChangeNote.js +146 -0
  24. package/dist/shared/components/layout-editor/CollabParts.js +170 -0
  25. package/dist/shared/components/layout-editor/DesignNode.js +304 -115
  26. package/dist/shared/components/layout-editor/EditorCanvas.js +21 -20
  27. package/dist/shared/components/layout-editor/EditorTopBar.js +452 -175
  28. package/dist/shared/components/layout-editor/FindReplace.js +188 -0
  29. package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
  30. package/dist/shared/components/layout-editor/HistoryPanel.js +234 -109
  31. package/dist/shared/components/layout-editor/LayoutEditor.js +1101 -307
  32. package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
  33. package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
  34. package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
  35. package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
  36. package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
  37. package/dist/shared/components/layout-editor/StructureMenu.js +413 -0
  38. package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
  39. package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
  40. package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
  41. package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
  42. package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
  43. package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
  44. package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
  45. package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
  46. package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
  47. package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
  48. package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
  49. package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
  50. package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
  51. package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
  52. package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
  53. package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
  54. package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
  55. package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
  56. package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
  57. package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
  58. package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
  59. package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
  60. package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
  61. package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
  62. package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
  63. package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
  64. package/dist/shared/components/layout-editor/assist/jump.js +142 -0
  65. package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
  66. package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
  67. package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
  68. package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
  69. package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
  70. package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
  71. package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
  72. package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
  73. package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
  74. package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
  75. package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
  76. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +342 -0
  77. package/dist/shared/components/layout-editor/collab/collab-api.js +77 -0
  78. package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
  79. package/dist/shared/components/layout-editor/commands/intents.js +214 -0
  80. package/dist/shared/components/layout-editor/commands/parse.js +242 -0
  81. package/dist/shared/components/layout-editor/design-context.js +26 -6
  82. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +179 -163
  83. package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
  84. package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
  85. package/dist/shared/components/layout-editor/draft-recovery.js +61 -0
  86. package/dist/shared/components/layout-editor/editor-notes.js +78 -0
  87. package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
  88. package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
  89. package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
  90. package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
  91. package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
  92. package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
  93. package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
  94. package/dist/shared/components/layout-editor/field-zones.js +116 -0
  95. package/dist/shared/components/layout-editor/form-map.js +138 -0
  96. package/dist/shared/components/layout-editor/history-api.js +87 -0
  97. package/dist/shared/components/layout-editor/inheritance.js +55 -0
  98. package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
  99. package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
  100. package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
  101. package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
  102. package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
  103. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +175 -0
  104. package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
  105. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +146 -92
  106. package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
  107. package/dist/shared/components/layout-editor/inspector/Inspector.js +256 -175
  108. package/dist/shared/components/layout-editor/inspector/LookTab.js +46 -40
  109. package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
  110. package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
  111. package/dist/shared/components/layout-editor/inspector/PickerTab.js +167 -141
  112. package/dist/shared/components/layout-editor/inspector/RulesTab.js +175 -128
  113. package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
  114. package/dist/shared/components/layout-editor/inspector/kit.js +3 -3
  115. package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
  116. package/dist/shared/components/layout-editor/is-typing.js +9 -0
  117. package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
  118. package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
  119. package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
  120. package/dist/shared/components/layout-editor/load-error.js +37 -0
  121. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
  122. package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
  123. package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
  124. package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
  125. package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
  126. package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
  127. package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
  128. package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
  129. package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
  130. package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
  131. package/dist/shared/components/layout-editor/nav/find.js +20 -0
  132. package/dist/shared/components/layout-editor/nav/tree.js +142 -0
  133. package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
  134. package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
  135. package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
  136. package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
  137. package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
  138. package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
  139. package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
  140. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
  141. package/dist/shared/components/layout-editor/overview/describe-conditions.js +18 -14
  142. package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
  143. package/dist/shared/components/layout-editor/panel-style.js +8 -7
  144. package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
  145. package/dist/shared/components/layout-editor/pin.js +25 -0
  146. package/dist/shared/components/layout-editor/presence.js +111 -0
  147. package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
  148. package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
  149. package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
  150. package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
  151. package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
  152. package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
  153. package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
  154. package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
  155. package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
  156. package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
  157. package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
  158. package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
  159. package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
  160. package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
  161. package/dist/shared/components/layout-editor/settings/FormSettings.js +123 -103
  162. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
  163. package/dist/shared/components/layout-editor/settings/ToolsSection.js +174 -100
  164. package/dist/shared/components/layout-editor/settings/WhoSection.js +136 -100
  165. package/dist/shared/components/layout-editor/settings/controls.js +8 -8
  166. package/dist/shared/components/layout-editor/settings/settings-registry.js +35 -11
  167. package/dist/shared/components/layout-editor/shortcuts.js +88 -0
  168. package/dist/shared/components/layout-editor/show-when.js +35 -0
  169. package/dist/shared/components/layout-editor/slot-names.js +4 -3
  170. package/dist/shared/components/layout-editor/structure-ops.js +399 -0
  171. package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
  172. package/dist/shared/components/layout-editor/testing/TestingPanels.js +551 -0
  173. package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
  174. package/dist/shared/components/layout-editor/testing/testing-model.js +393 -0
  175. package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
  176. package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
  177. package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
  178. package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
  179. package/dist/shared/components/layout-editor/usage/UsagePanel.js +158 -0
  180. package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
  181. package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
  182. package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -307
  183. package/dist/shared/components/support/SuggestFormChange.js +143 -0
  184. package/dist/shared/lib/ai-fill.js +37 -0
  185. package/dist/shared/lib/form-usage-beacon.js +84 -0
  186. package/dist/shared/lib/layout-i18n.js +66 -0
  187. package/dist/shared/lib/layout-lint.js +490 -0
  188. package/dist/shared/lib/layout-ops.js +110 -106
  189. package/dist/shared/lib/screenshot.js +54 -28
  190. package/dist/shared/lib/visible-when.js +34 -0
  191. package/package.json +1 -1
@@ -0,0 +1,237 @@
1
+ import { jsxs as n, jsx as a } from "react/jsx-runtime";
2
+ import { useQueryClient as O } from "@tanstack/react-query";
3
+ import { Check as X, AlertTriangle as D, Loader2 as P, Undo2 as G } from "lucide-react";
4
+ import { useState as x, useEffect as L } from "react";
5
+ import { toast as p } from "sonner";
6
+ import { cn as k } from "../../../lib/utils.js";
7
+ import { useInvalidateLayouts as M, apiFailure as U } from "../overview/overview-api.js";
8
+ import { effectText as B, tintCard as V } from "../panel-style.js";
9
+ import { barBtn as W } from "../toolbar-kit.js";
10
+ import { useBulkCalls as Y, bulkKeys as Z } from "./bulk-api.js";
11
+ const z = W, A = "inline-flex h-8 items-center gap-1.5 whitespace-nowrap rounded-md bg-nvr-cyan px-3 text-[12.5px] font-semibold text-white transition-opacity hover:opacity-90 disabled:pointer-events-none disabled:opacity-40", v = (s, l, h = `${l}s`) => `${s} ${s === 1 ? l : h}`, I = {
12
+ change: "Changes",
13
+ same: "Nothing to do",
14
+ skip: "Skipped"
15
+ };
16
+ function ue({
17
+ collection: s,
18
+ action: l,
19
+ labels: h,
20
+ applyLabel: w,
21
+ dirtyLayoutId: c,
22
+ extra: i,
23
+ onApplied: _
24
+ }) {
25
+ const $ = Y(), S = O(), E = M(s), [o, C] = x(null), [f, K] = x(/* @__PURE__ */ new Set()), [y, b] = x(null), [g, N] = x(null), [Q, T] = x(!1), H = JSON.stringify(l);
26
+ L(() => {
27
+ C(null), N(null), T(!1);
28
+ }, [H]);
29
+ const j = (e) => {
30
+ E(), S.invalidateQueries({ queryKey: Z.fields(s) });
31
+ for (const t of e)
32
+ S.invalidateQueries({ queryKey: ["layout-editor", "bundle", t] }), S.invalidateQueries({ queryKey: ["layout-editor", "versions", t] });
33
+ }, R = async () => {
34
+ if (l) {
35
+ b("preview"), N(null);
36
+ try {
37
+ const e = await $.preview({ collection: s, action: l, labels: h });
38
+ C(e), K(
39
+ new Set(
40
+ e.forms.filter((t) => t.status === "change" && t.layout_id !== c).map((t) => t.layout_id)
41
+ )
42
+ );
43
+ } catch (e) {
44
+ p.error(U(e, "The preview could not be made").message);
45
+ } finally {
46
+ b(null);
47
+ }
48
+ }
49
+ }, F = async () => {
50
+ if (!(!l || !o || f.size === 0)) {
51
+ b("apply");
52
+ try {
53
+ const e = {};
54
+ for (const d of o.forms) e[String(d.layout_id)] = d.rev;
55
+ const t = await $.apply({
56
+ collection: s,
57
+ action: l,
58
+ labels: h,
59
+ layout_ids: [...f],
60
+ revs: e
61
+ });
62
+ N(t.forms), T(!1);
63
+ const m = t.forms.filter((d) => d.status === "applied").length, r = t.forms.filter((d) => d.status === "skipped" || d.status === "failed").length;
64
+ m && p.success(`${t.label}: ${v(m, "form")} changed`), r && p.warning(`${v(r, "form")} could not be changed: see the list`), j(t.forms.map((d) => d.layout_id)), _ == null || _();
65
+ } catch (e) {
66
+ p.error(U(e, "The change could not be applied").message);
67
+ } finally {
68
+ b(null);
69
+ }
70
+ }
71
+ }, J = async () => {
72
+ if (g) {
73
+ b("undo");
74
+ try {
75
+ const e = await $.undo(s, g), t = e.forms.filter((r) => r.status === "restored").length, m = e.forms.filter((r) => r.status !== "restored");
76
+ T(!0), t && p.success(`${v(t, "form")} put back`), m.length && p.warning(
77
+ `${v(m.length, "form")} changed since: restore ${m.length === 1 ? "it" : "them"} from History`
78
+ ), j(e.forms.map((r) => r.layout_id));
79
+ } catch (e) {
80
+ p.error(U(e, "The change could not be undone").message);
81
+ } finally {
82
+ b(null);
83
+ }
84
+ }
85
+ }, u = o ? {
86
+ change: o.forms.filter((e) => e.status === "change").length,
87
+ same: o.forms.filter((e) => e.status === "same").length,
88
+ skip: o.forms.filter((e) => e.status === "skip").length
89
+ } : null, q = c != null && f.has(c);
90
+ if (g) {
91
+ const e = g.filter((t) => t.status === "applied");
92
+ return /* @__PURE__ */ n("div", { "data-bulk-result": "", className: "space-y-3", children: [
93
+ /* @__PURE__ */ a("ul", { className: "space-y-1", children: g.map((t) => /* @__PURE__ */ n("li", { className: "flex items-start gap-2 text-[12.5px]", children: [
94
+ t.status === "applied" ? /* @__PURE__ */ a(X, { className: "mt-0.5 h-3.5 w-3.5 shrink-0 text-emerald-600 dark:text-emerald-400" }) : /* @__PURE__ */ a(
95
+ D,
96
+ {
97
+ className: k(
98
+ "mt-0.5 h-3.5 w-3.5 shrink-0",
99
+ t.status === "same" ? "text-slate-400 dark:text-muted-foreground" : "text-amber-600 dark:text-amber-400"
100
+ )
101
+ }
102
+ ),
103
+ /* @__PURE__ */ n("span", { className: "min-w-0", children: [
104
+ /* @__PURE__ */ a("span", { className: "font-medium text-slate-800 dark:text-foreground", children: t.name }),
105
+ t.reason && /* @__PURE__ */ a("span", { className: k(B, "block"), children: t.reason })
106
+ ] })
107
+ ] }, t.layout_id)) }),
108
+ e.length > 0 && /* @__PURE__ */ n("div", { className: k(V, "space-y-2 p-2.5"), children: [
109
+ /* @__PURE__ */ a("p", { className: B, children: "Each changed form has its own History entry from just before this change; restore any one of them from History." }),
110
+ /* @__PURE__ */ n(
111
+ "button",
112
+ {
113
+ type: "button",
114
+ "data-bulk-undo": "",
115
+ className: z,
116
+ disabled: y !== null || Q,
117
+ onClick: () => void J(),
118
+ children: [
119
+ y === "undo" ? /* @__PURE__ */ a(P, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(G, { className: "h-3.5 w-3.5" }),
120
+ Q ? "Undone" : "Undo this bulk change"
121
+ ]
122
+ }
123
+ )
124
+ ] }),
125
+ /* @__PURE__ */ a(
126
+ "button",
127
+ {
128
+ type: "button",
129
+ className: "text-[12px] font-medium text-[#0089ad] hover:underline dark:text-nvr-cyan",
130
+ onClick: () => {
131
+ N(null), C(null);
132
+ },
133
+ children: "Start another change"
134
+ }
135
+ )
136
+ ] });
137
+ }
138
+ return /* @__PURE__ */ n("div", { className: "space-y-3", children: [
139
+ /* @__PURE__ */ n(
140
+ "button",
141
+ {
142
+ type: "button",
143
+ "data-bulk-preview": "",
144
+ className: z,
145
+ disabled: !l || y !== null,
146
+ onClick: () => void R(),
147
+ children: [
148
+ y === "preview" && /* @__PURE__ */ a(P, { className: "h-3.5 w-3.5 animate-spin" }),
149
+ o ? "Preview again" : "Preview"
150
+ ]
151
+ }
152
+ ),
153
+ o && u && /* @__PURE__ */ n("div", { "data-bulk-preview-list": "", className: "space-y-2", children: [
154
+ /* @__PURE__ */ a("p", { className: "text-[12.5px] text-slate-700 dark:text-foreground", children: o.forms.length === 0 ? "This collection has no forms." : [
155
+ u.change && `Changes ${v(u.change, "form")}`,
156
+ u.same && `${u.same} already like that`,
157
+ u.skip && `${u.skip} skipped`
158
+ ].filter(Boolean).join(" · ") }),
159
+ i == null ? void 0 : i(o),
160
+ /* @__PURE__ */ a("ul", { className: "divide-y divide-slate-100 rounded-md border border-slate-200 dark:divide-border dark:border-border", children: o.forms.map((e) => /* @__PURE__ */ a(
161
+ ee,
162
+ {
163
+ form: e,
164
+ picked: f.has(e.layout_id),
165
+ dirty: e.layout_id === c,
166
+ onPick: (t) => K((m) => {
167
+ const r = new Set(m);
168
+ return t ? r.add(e.layout_id) : r.delete(e.layout_id), r;
169
+ })
170
+ },
171
+ e.layout_id
172
+ )) }),
173
+ q && /* @__PURE__ */ a("p", { className: "text-[12px] text-amber-700 dark:text-amber-300", children: "Save or discard your changes to this form first." }),
174
+ u.change > 0 && /* @__PURE__ */ n(
175
+ "button",
176
+ {
177
+ type: "button",
178
+ "data-bulk-apply": "",
179
+ className: A,
180
+ disabled: y !== null || f.size === 0 || q,
181
+ onClick: () => void F(),
182
+ children: [
183
+ y === "apply" && /* @__PURE__ */ a(P, { className: "h-3.5 w-3.5 animate-spin" }),
184
+ w(f.size)
185
+ ]
186
+ }
187
+ )
188
+ ] })
189
+ ] });
190
+ }
191
+ function ee({
192
+ form: s,
193
+ picked: l,
194
+ dirty: h,
195
+ onPick: w
196
+ }) {
197
+ const c = s.status === "change";
198
+ return /* @__PURE__ */ a("li", { "data-bulk-form": s.layout_id, "data-status": s.status, className: "px-2.5 py-2", children: /* @__PURE__ */ n("label", { className: k("flex items-start gap-2", c && "cursor-pointer"), children: [
199
+ /* @__PURE__ */ a(
200
+ "input",
201
+ {
202
+ type: "checkbox",
203
+ className: "mt-0.5 h-3.5 w-3.5 shrink-0 accent-[#00a3cc]",
204
+ checked: c && l,
205
+ disabled: !c,
206
+ "aria-label": `Include ${s.name}`,
207
+ onChange: (i) => w(i.target.checked)
208
+ }
209
+ ),
210
+ /* @__PURE__ */ n("span", { className: "min-w-0 flex-1", children: [
211
+ /* @__PURE__ */ n("span", { className: "flex flex-wrap items-baseline gap-x-2", children: [
212
+ /* @__PURE__ */ a("span", { className: "font-medium text-[12.5px] text-slate-800 dark:text-foreground", children: s.name }),
213
+ /* @__PURE__ */ n(
214
+ "span",
215
+ {
216
+ className: k(
217
+ "text-[11.5px]",
218
+ s.status === "skip" ? "text-amber-700 dark:text-amber-300" : "text-slate-500 dark:text-muted-foreground"
219
+ ),
220
+ children: [
221
+ I[s.status],
222
+ h && c ? " · has unsaved changes here" : ""
223
+ ]
224
+ }
225
+ )
226
+ ] }),
227
+ s.changes.map((i) => /* @__PURE__ */ a("span", { className: "block text-[12px] text-slate-600 dark:text-muted-foreground", children: i }, i)),
228
+ s.reason && /* @__PURE__ */ a("span", { className: k(B, "block"), children: s.reason }),
229
+ s.notes.map((i) => /* @__PURE__ */ a("span", { className: "block text-[12px] text-amber-700 dark:text-amber-300", children: i }, i))
230
+ ] })
231
+ ] }) });
232
+ }
233
+ export {
234
+ ue as BulkRun,
235
+ z as btnQuiet,
236
+ A as btnSolid
237
+ };
@@ -0,0 +1,230 @@
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import { Loader2 as v, Square as R, Circle as D, Play as $, Trash2 as T } from "lucide-react";
3
+ import { useState as y } from "react";
4
+ import { toast as x } from "sonner";
5
+ import { cn as g, titleCase as B } from "../../../lib/utils.js";
6
+ import { apiFailure as w } from "../overview/overview-api.js";
7
+ import { effectText as b, labelText as F, tintCard as k, inputBase as O } from "../panel-style.js";
8
+ import { btnQuiet as N, btnSolid as E, BulkRun as K } from "./BulkRun.js";
9
+ import { useMacros as P, useBulkCalls as C } from "./bulk-api.js";
10
+ import { useFieldLabels as S } from "./field-labels.js";
11
+ import { describeStep as M } from "./macro-record.js";
12
+ function X({
13
+ collection: t,
14
+ layoutId: c,
15
+ dirty: r,
16
+ recorder: u,
17
+ onRecordStart: n
18
+ }) {
19
+ const { labels: h } = S(t), o = (s) => h[s] ?? B(s), { data: d = [], isLoading: i } = P(), [m, l] = y(null);
20
+ return /* @__PURE__ */ a("div", { "data-bulk-tab": "macros", className: "space-y-3", children: [
21
+ u ? /* @__PURE__ */ e(
22
+ j,
23
+ {
24
+ collection: t,
25
+ layoutId: c,
26
+ recorder: u,
27
+ labelOf: o,
28
+ onRecordStart: n
29
+ }
30
+ ) : /* @__PURE__ */ e("p", { className: b, children: "Record a macro in the layout editor: open a form, then Every form → Macros → Record." }),
31
+ /* @__PURE__ */ a("div", { className: "space-y-1.5", children: [
32
+ /* @__PURE__ */ e("span", { className: F, children: "Your macros" }),
33
+ i ? /* @__PURE__ */ e(v, { className: "h-4 w-4 animate-spin text-slate-400" }) : d.length === 0 ? /* @__PURE__ */ e("p", { className: b, children: "None kept yet." }) : /* @__PURE__ */ e("ul", { className: "divide-y divide-slate-100 rounded-md border border-slate-200 dark:divide-border dark:border-border", children: d.map((s) => /* @__PURE__ */ e(
34
+ _,
35
+ {
36
+ macro: s,
37
+ collection: t,
38
+ labels: h,
39
+ labelOf: o,
40
+ open: m === s.id,
41
+ onOpen: (f) => l(f ? s.id : null),
42
+ dirtyLayoutId: r ? c : null
43
+ },
44
+ s.id
45
+ )) })
46
+ ] })
47
+ ] });
48
+ }
49
+ function j({
50
+ collection: t,
51
+ layoutId: c,
52
+ recorder: r,
53
+ labelOf: u,
54
+ onRecordStart: n
55
+ }) {
56
+ const h = C(), [o, d] = y(""), [i, m] = y(!1), l = r.steps, s = async () => {
57
+ if (!(!o.trim() || l.length === 0)) {
58
+ m(!0);
59
+ try {
60
+ await h.saveMacro({
61
+ name: o.trim(),
62
+ collection: t,
63
+ steps: l,
64
+ source_layout_id: r.sourceLayoutId
65
+ }), x.success(`Macro "${o.trim()}" kept`), d(""), r.clear();
66
+ } catch (p) {
67
+ x.error(w(p, "The macro could not be kept").message);
68
+ } finally {
69
+ m(!1);
70
+ }
71
+ }
72
+ }, f = l.length > 0 ? /* @__PURE__ */ e("ol", { className: "list-decimal space-y-0.5 pl-5 text-[12px] text-slate-700 dark:text-foreground", children: l.map((p, L) => (
73
+ // biome-ignore lint/suspicious/noArrayIndexKey: steps are an ordered list without ids
74
+ /* @__PURE__ */ e("li", { children: M(p, u) }, L)
75
+ )) }) : null;
76
+ return r.recording ? /* @__PURE__ */ a("div", { "data-macro-recording": "", className: g(k, "space-y-2 p-2.5"), children: [
77
+ /* @__PURE__ */ a("p", { className: "flex items-center gap-1.5 text-[12.5px] font-medium text-rose-700 dark:text-rose-300", children: [
78
+ /* @__PURE__ */ e("span", { className: "h-2 w-2 animate-pulse rounded-full bg-rose-500" }),
79
+ "Recording · ",
80
+ l.length,
81
+ " step",
82
+ l.length === 1 ? "" : "s"
83
+ ] }),
84
+ /* @__PURE__ */ e("p", { className: b, children: "Keep editing the form; every change is written down. Undo takes the last one back off." }),
85
+ f,
86
+ /* @__PURE__ */ a("button", { type: "button", className: N, onClick: r.stop, "data-macro-stop": "", children: [
87
+ /* @__PURE__ */ e(R, { className: "h-3 w-3" }),
88
+ "Stop"
89
+ ] })
90
+ ] }) : l.length > 0 ? /* @__PURE__ */ a("div", { "data-macro-save": "", className: g(k, "space-y-2 p-2.5"), children: [
91
+ /* @__PURE__ */ a("p", { className: "text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: [
92
+ l.length,
93
+ " step",
94
+ l.length === 1 ? "" : "s",
95
+ " recorded"
96
+ ] }),
97
+ f,
98
+ /* @__PURE__ */ e(
99
+ "input",
100
+ {
101
+ className: O,
102
+ placeholder: 'Name, e.g. "Fusion block after PO Number"',
103
+ "aria-label": "Macro name",
104
+ value: o,
105
+ maxLength: 80,
106
+ onChange: (p) => d(p.target.value),
107
+ onKeyDown: (p) => {
108
+ p.key === "Enter" && s();
109
+ }
110
+ }
111
+ ),
112
+ /* @__PURE__ */ a("div", { className: "flex gap-2", children: [
113
+ /* @__PURE__ */ a(
114
+ "button",
115
+ {
116
+ type: "button",
117
+ className: E,
118
+ disabled: !o.trim() || i,
119
+ onClick: () => void s(),
120
+ "data-macro-keep": "",
121
+ children: [
122
+ i && /* @__PURE__ */ e(v, { className: "h-3.5 w-3.5 animate-spin" }),
123
+ "Keep macro"
124
+ ]
125
+ }
126
+ ),
127
+ /* @__PURE__ */ e("button", { type: "button", className: N, onClick: r.clear, children: "Discard" })
128
+ ] })
129
+ ] }) : /* @__PURE__ */ a("div", { className: g(k, "space-y-2 p-2.5"), children: [
130
+ /* @__PURE__ */ e("p", { className: b, children: "Record the changes you make to this form, then replay them on the other forms. Fields are matched by name and sections by label." }),
131
+ /* @__PURE__ */ a(
132
+ "button",
133
+ {
134
+ type: "button",
135
+ className: N,
136
+ disabled: c == null,
137
+ "data-macro-record": "",
138
+ onClick: () => {
139
+ c != null && (r.start(c), n == null || n(), x("Recording: make your changes, then Every form → Stop"));
140
+ },
141
+ children: [
142
+ /* @__PURE__ */ e(D, { className: "h-3 w-3 fill-rose-500 text-rose-500" }),
143
+ "Record"
144
+ ]
145
+ }
146
+ )
147
+ ] });
148
+ }
149
+ function _({
150
+ macro: t,
151
+ collection: c,
152
+ labels: r,
153
+ labelOf: u,
154
+ open: n,
155
+ onOpen: h,
156
+ dirtyLayoutId: o
157
+ }) {
158
+ const d = C(), [i, m] = y(!1), l = t.collection && t.collection !== c;
159
+ return /* @__PURE__ */ a("li", { "data-macro": t.id, className: "px-2.5 py-2", children: [
160
+ /* @__PURE__ */ a("div", { className: "flex items-center gap-2", children: [
161
+ /* @__PURE__ */ a("div", { className: "min-w-0 flex-1", children: [
162
+ /* @__PURE__ */ e("span", { className: "block truncate text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: t.name }),
163
+ /* @__PURE__ */ a("span", { className: b, children: [
164
+ t.steps.length,
165
+ " step",
166
+ t.steps.length === 1 ? "" : "s",
167
+ l ? ` · recorded on ${t.collection}` : ""
168
+ ] })
169
+ ] }),
170
+ /* @__PURE__ */ a(
171
+ "button",
172
+ {
173
+ type: "button",
174
+ className: N,
175
+ "aria-expanded": n,
176
+ onClick: () => h(!n),
177
+ "data-macro-replay": "",
178
+ children: [
179
+ /* @__PURE__ */ e($, { className: "h-3 w-3" }),
180
+ n ? "Close" : "Replay"
181
+ ]
182
+ }
183
+ ),
184
+ /* @__PURE__ */ a(
185
+ "button",
186
+ {
187
+ type: "button",
188
+ "aria-label": i ? `Delete ${t.name} for good` : `Delete ${t.name}`,
189
+ "data-tip": i ? "Click again to delete" : "Delete",
190
+ className: g(
191
+ "inline-flex h-8 items-center gap-1 rounded-md px-2 text-[12px] transition-colors",
192
+ i ? "bg-rose-50 font-medium text-rose-700 dark:bg-rose-500/15 dark:text-rose-300" : "text-slate-500 hover:bg-muted hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
193
+ ),
194
+ onBlur: () => m(!1),
195
+ onClick: async () => {
196
+ if (!i) return m(!0);
197
+ try {
198
+ await d.deleteMacro(t.id);
199
+ } catch (s) {
200
+ x.error(w(s, "The macro could not be deleted").message);
201
+ }
202
+ },
203
+ children: [
204
+ /* @__PURE__ */ e(T, { className: "h-3.5 w-3.5" }),
205
+ i && "Delete"
206
+ ]
207
+ }
208
+ )
209
+ ] }),
210
+ n && /* @__PURE__ */ a("div", { className: "mt-2 space-y-2", children: [
211
+ /* @__PURE__ */ e("ol", { className: "list-decimal space-y-0.5 pl-5 text-[12px] text-slate-600 dark:text-muted-foreground", children: t.steps.map((s, f) => (
212
+ // biome-ignore lint/suspicious/noArrayIndexKey: steps are an ordered list without ids
213
+ /* @__PURE__ */ e("li", { children: M(s, u) }, f)
214
+ )) }),
215
+ /* @__PURE__ */ e(
216
+ K,
217
+ {
218
+ collection: c,
219
+ action: { kind: "macro", name: t.name, steps: t.steps },
220
+ labels: r,
221
+ dirtyLayoutId: o,
222
+ applyLabel: (s) => `Replay on ${s} form${s === 1 ? "" : "s"}`
223
+ }
224
+ )
225
+ ] })
226
+ ] });
227
+ }
228
+ export {
229
+ X as MacrosPanel
230
+ };
@@ -0,0 +1,65 @@
1
+ import { useQuery as y, useQueryClient as w } from "@tanstack/react-query";
2
+ import { useCallback as r } from "react";
3
+ import { useNivaroClient as c } from "../../../context.js";
4
+ import { get as d, post as l } from "../../../lib/commands.js";
5
+ const i = {
6
+ fields: (e) => ["layout-editor", "bulk-fields", e],
7
+ macros: () => ["layout-editor", "macros"]
8
+ }, s = (e) => e.data;
9
+ function K(e, o = !0) {
10
+ const u = c();
11
+ return y({
12
+ queryKey: i.fields(e),
13
+ queryFn: async () => s(await u.request(d("/collection-layouts/bulk/fields", { collection: e }))) ?? [],
14
+ enabled: o,
15
+ staleTime: 15e3
16
+ });
17
+ }
18
+ function _(e = !0) {
19
+ const o = c();
20
+ return y({
21
+ queryKey: i.macros(),
22
+ queryFn: async () => s(await o.request(d("/collection-layouts/macros"))) ?? [],
23
+ enabled: e,
24
+ staleTime: 3e4
25
+ });
26
+ }
27
+ function Q() {
28
+ const e = c(), o = w(), u = r(
29
+ async (t) => s(await e.request(l("/collection-layouts/bulk/preview", t))),
30
+ [e]
31
+ ), m = r(
32
+ async (t) => s(await e.request(l("/collection-layouts/bulk/apply", t))),
33
+ [e]
34
+ ), p = r(
35
+ async (t, n) => s(
36
+ await e.request(
37
+ l("/collection-layouts/bulk/undo", {
38
+ collection: t,
39
+ items: n.filter((a) => a.status === "applied" && a.version_id != null && a.rev).map((a) => ({ layout_id: a.layout_id, version_id: a.version_id, rev: a.rev }))
40
+ })
41
+ )
42
+ ),
43
+ [e]
44
+ ), q = r(
45
+ async (t) => {
46
+ const n = s(
47
+ await e.request(l("/collection-layouts/macros", t))
48
+ );
49
+ return await o.invalidateQueries({ queryKey: i.macros() }), n;
50
+ },
51
+ [e, o]
52
+ ), v = r(
53
+ async (t) => {
54
+ await e.request(l(`/collection-layouts/macros/${encodeURIComponent(t)}/delete`)), await o.invalidateQueries({ queryKey: i.macros() });
55
+ },
56
+ [e, o]
57
+ );
58
+ return { preview: u, apply: m, undo: p, saveMacro: q, deleteMacro: v };
59
+ }
60
+ export {
61
+ i as bulkKeys,
62
+ Q as useBulkCalls,
63
+ _ as useMacros,
64
+ K as usePlacedFields
65
+ };
@@ -0,0 +1,22 @@
1
+ import { useMemo as p } from "react";
2
+ import { titleCase as i } from "../../../lib/utils.js";
3
+ import { useOverviewFields as u } from "../overview/overview-api.js";
4
+ import { usePlacedFields as b } from "./bulk-api.js";
5
+ function C(t) {
6
+ const { data: r } = u(t), { data: a } = b(t);
7
+ return p(() => {
8
+ var f;
9
+ const m = r ?? [], l = a ?? [], o = {};
10
+ for (const e of m) o[e.field] = e.label || i(e.field);
11
+ for (const e of l) o[f = e.field] ?? (o[f] = i(e.field));
12
+ const d = new Map(l.map((e) => [e.field, e.forms])), n = Object.keys(o).filter((e) => !e.startsWith("__")).map((e) => ({ value: e, label: o[e], hint: e })).sort((e, s) => e.label.localeCompare(s.label)), c = l.map((e) => ({
13
+ value: e.field,
14
+ label: o[e.field],
15
+ hint: `${e.forms} form${e.forms === 1 ? "" : "s"}`
16
+ })).sort((e, s) => e.label.localeCompare(s.label));
17
+ return { labels: o, all: n, onForms: c, formsOf: d };
18
+ }, [r, a]);
19
+ }
20
+ export {
21
+ C as useFieldLabels
22
+ };