@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,92 @@
1
+ import { jsxs as l, Fragment as g, jsx as e } from "react/jsx-runtime";
2
+ import { ChevronRight as x } from "lucide-react";
3
+ import { useState as p } from "react";
4
+ import { cn as h } from "../../../lib/utils.js";
5
+ import { labelText as b } from "../panel-style.js";
6
+ import { quietText as v } from "../settings/controls.js";
7
+ import { ChangeRequestsPanel as y } from "./ChangeRequestsPanel.js";
8
+ import { DependencyDiagram as k } from "./DependencyDiagram.js";
9
+ import { useChangeRequests as N } from "./ops-api.js";
10
+ import { PromotePanel as q } from "./PromotePanel.js";
11
+ function W({
12
+ collection: n,
13
+ layoutId: t,
14
+ name: i
15
+ }) {
16
+ const { data: o = [], isError: a } = N(n), s = o.filter((r) => r.layout_id === t).length;
17
+ return /* @__PURE__ */ l(g, { children: [
18
+ /* @__PURE__ */ e(
19
+ m,
20
+ {
21
+ id: "change_requests",
22
+ label: "Suggested changes · from people",
23
+ count: s,
24
+ effect: "What people asked to change on this form, from a record’s More menu.",
25
+ defaultOpen: s > 0 || a,
26
+ children: /* @__PURE__ */ e(y, { collection: n, layoutId: t })
27
+ }
28
+ ),
29
+ /* @__PURE__ */ e(
30
+ m,
31
+ {
32
+ id: "dependencies",
33
+ label: "What relies on this form",
34
+ effect: "Queues, grids, links, forms, files and extension code that open this form.",
35
+ children: /* @__PURE__ */ e(k, { layoutId: t, compact: !0 })
36
+ }
37
+ ),
38
+ /* @__PURE__ */ e(
39
+ m,
40
+ {
41
+ id: "promote",
42
+ label: "Compare with another environment",
43
+ effect: "Bring another environment’s copy of this form here, after seeing what changes.",
44
+ children: /* @__PURE__ */ e(q, { layoutId: t, layoutName: i })
45
+ }
46
+ )
47
+ ] });
48
+ }
49
+ function m({
50
+ id: n,
51
+ label: t,
52
+ effect: i,
53
+ count: o,
54
+ defaultOpen: a,
55
+ children: s
56
+ }) {
57
+ const [r, c] = p(!!a), [d, f] = p(!1);
58
+ return a && !r && !d && (f(!0), c(!0)), /* @__PURE__ */ l("div", { "data-layout-tool": n, className: "space-y-1.5", children: [
59
+ /* @__PURE__ */ l(
60
+ "button",
61
+ {
62
+ type: "button",
63
+ "aria-expanded": r,
64
+ onClick: () => {
65
+ f(!0), c((u) => !u);
66
+ },
67
+ className: h(b, "flex w-full items-center gap-1 text-left"),
68
+ children: [
69
+ /* @__PURE__ */ e(
70
+ x,
71
+ {
72
+ className: h("h-3.5 w-3.5 shrink-0 transition-transform", r && "rotate-90")
73
+ }
74
+ ),
75
+ t,
76
+ o ? /* @__PURE__ */ e(
77
+ "span",
78
+ {
79
+ className: "ml-1 rounded-full bg-nvr-cyan/10 px-1.5 text-[11px] font-semibold text-nvr-navy dark:text-nvr-cyan",
80
+ "data-count": !0,
81
+ children: o
82
+ }
83
+ ) : null
84
+ ]
85
+ }
86
+ ),
87
+ r ? s : /* @__PURE__ */ e("p", { className: v, children: i })
88
+ ] });
89
+ }
90
+ export {
91
+ W as LayoutOpsBlocks
92
+ };
@@ -0,0 +1,287 @@
1
+ import { jsxs as r, jsx as a, Fragment as _ } from "react/jsx-runtime";
2
+ import { useQueryClient as H } from "@tanstack/react-query";
3
+ import { Loader2 as N, Upload as J, Download as M, Shuffle as z, Plus as G, Minus as V, Pencil as X } from "lucide-react";
4
+ import { useRef as Y, useState as i } from "react";
5
+ import { toast as q } from "sonner";
6
+ import { useNivaroClient as Z } from "../../../context.js";
7
+ import { cn as d } from "../../../lib/utils.js";
8
+ import { apiFailure as w } from "../overview/overview-api.js";
9
+ import { layoutDraftKeys as D } from "../useLayoutDraft.js";
10
+ import { usePromoteSources as ee, downloadLayout as te, previewPromotion as ae, trimUploadedFile as re, applyPromotion as ne } from "./ops-api.js";
11
+ const C = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-full border px-2.5 text-[12px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50", $ = "border-slate-200 bg-white text-slate-700 hover:border-slate-300 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", E = "border-nvr-cyan/60 bg-nvr-cyan/10 text-nvr-navy dark:text-nvr-cyan", oe = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-md border border-slate-200 bg-white px-2 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 disabled:opacity-50 dark:border-border dark:bg-card dark:text-foreground dark:hover:bg-muted", I = "inline-flex h-7 items-center gap-1 whitespace-nowrap rounded-md bg-nvr-cyan px-2.5 text-[12px] font-semibold text-white hover:opacity-90 disabled:opacity-50", se = {
12
+ setting: "Settings",
13
+ section: "Sections and tabs",
14
+ field: "Fields",
15
+ order: "Order"
16
+ };
17
+ function le({ c: s }) {
18
+ const l = "mt-[3px] h-3 w-3 shrink-0";
19
+ return s.kind === "order" ? /* @__PURE__ */ a(z, { className: l }) : s.action === "add" ? /* @__PURE__ */ a(G, { className: d(l, "text-emerald-600 dark:text-emerald-400") }) : s.action === "remove" ? /* @__PURE__ */ a(V, { className: d(l, "text-red-600 dark:text-red-400") }) : /* @__PURE__ */ a(X, { className: l });
20
+ }
21
+ const O = (s) => s == null || s === "" ? "empty" : typeof s == "object" ? JSON.stringify(s).slice(0, 60) : String(s);
22
+ function be({
23
+ layoutId: s,
24
+ layoutName: l,
25
+ onApplied: g,
26
+ className: Q
27
+ }) {
28
+ var L;
29
+ const b = Z(), y = H(), h = ee(), P = Y(null), [o, S] = i(null), [R, U] = i(null), [n, k] = i(null), [c, f] = i(null), [F, m] = i(null), [T, p] = i(!1), x = async (e, t) => {
30
+ S(e), U(t ?? null), k(null), p(!1), m(null), f("preview");
31
+ try {
32
+ k(await ae(b, s, e.body, t ?? null));
33
+ } catch (v) {
34
+ m(w(v, "Could not compare").message);
35
+ } finally {
36
+ f(null);
37
+ }
38
+ }, W = async (e) => {
39
+ if (e)
40
+ try {
41
+ const t = re(await e.text());
42
+ x({ key: `file:${e.name}`, body: { file: t }, label: e.name });
43
+ } catch (t) {
44
+ m(t.message);
45
+ }
46
+ }, A = async () => {
47
+ if (!(!o || !n)) {
48
+ f("apply"), m(null);
49
+ try {
50
+ const e = await ne(b, s, o.body, n.base_rev, R);
51
+ q.success(
52
+ e.applied ? `Brought over from ${n.source.label}. History has the version from before.` : "Already the same"
53
+ ), y.invalidateQueries({ queryKey: D.bundle(s) }), y.invalidateQueries({ queryKey: D.versions(s) }), y.invalidateQueries({ queryKey: ["layout-editor", "overview"] }), p(!1), k(null), S(null), g == null || g();
54
+ } catch (e) {
55
+ const t = w(e, "Could not apply");
56
+ m(t.message), p(!1);
57
+ } finally {
58
+ f(null);
59
+ }
60
+ }
61
+ }, j = ((L = n == null ? void 0 : n.plan) == null ? void 0 : L.changes) ?? [], u = j.filter((e) => e.action !== "skip"), K = j.filter((e) => e.action === "skip"), B = ["setting", "section", "field", "order"].map((e) => ({ k: e, list: u.filter((t) => t.kind === e) })).filter((e) => e.list.length);
62
+ return /* @__PURE__ */ r("div", { className: d("space-y-3 text-[12.5px]", Q), "data-promote-panel": s, children: [
63
+ /* @__PURE__ */ r("div", { children: [
64
+ /* @__PURE__ */ a("p", { className: "font-semibold text-slate-900 dark:text-foreground", children: "Compare with another environment" }),
65
+ /* @__PURE__ */ a("p", { className: "mt-0.5 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Reads that environment’s copy of this layout and shows what would change here. Nothing is sent from here." })
66
+ ] }),
67
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-1.5", "data-promote-sources": !0, children: [
68
+ h.isLoading && /* @__PURE__ */ a(N, { className: "h-3.5 w-3.5 animate-spin text-slate-400" }),
69
+ (h.data ?? []).map((e) => {
70
+ const t = `env:${e.id}`;
71
+ return /* @__PURE__ */ a(
72
+ "button",
73
+ {
74
+ type: "button",
75
+ disabled: !e.has_token || c != null,
76
+ "data-tip": e.has_token ? void 0 : "Add an API token to this component on Environments",
77
+ "data-promote-source": e.id,
78
+ "aria-pressed": (o == null ? void 0 : o.key) === t,
79
+ onClick: () => void x({
80
+ key: t,
81
+ body: { component_id: e.id },
82
+ label: `${e.environment ?? "Environment"} · ${e.name}`
83
+ }),
84
+ className: d(C, (o == null ? void 0 : o.key) === t ? E : $),
85
+ children: e.environment ? `${e.environment} · ${e.name}` : e.name
86
+ },
87
+ e.id
88
+ );
89
+ }),
90
+ /* @__PURE__ */ r(
91
+ "button",
92
+ {
93
+ type: "button",
94
+ className: d(C, o != null && o.key.startsWith("file:") ? E : $),
95
+ disabled: c != null,
96
+ onClick: () => {
97
+ var e;
98
+ return (e = P.current) == null ? void 0 : e.click();
99
+ },
100
+ "data-promote-upload": !0,
101
+ children: [
102
+ /* @__PURE__ */ a(J, { className: "h-3 w-3" }),
103
+ o != null && o.key.startsWith("file:") ? o.label : "Upload a file…"
104
+ ]
105
+ }
106
+ ),
107
+ /* @__PURE__ */ a(
108
+ "input",
109
+ {
110
+ ref: P,
111
+ type: "file",
112
+ accept: ".json,application/json",
113
+ className: "hidden",
114
+ onChange: (e) => {
115
+ var t;
116
+ W((t = e.target.files) == null ? void 0 : t[0]), e.target.value = "";
117
+ }
118
+ }
119
+ )
120
+ ] }),
121
+ !h.isLoading && (h.data ?? []).length === 0 && /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "No other environment is registered with an API address. Upload a form file or a Config Diff snapshot instead." }),
122
+ /* @__PURE__ */ r("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: [
123
+ "For an environment that cannot reach this one:",
124
+ " ",
125
+ /* @__PURE__ */ r(
126
+ "button",
127
+ {
128
+ type: "button",
129
+ className: "inline-flex items-center gap-1 font-medium text-[#0089ad] hover:underline dark:text-nvr-cyan",
130
+ onClick: () => void te(b, s, l).catch(
131
+ (e) => q.error(w(e, "Could not download").message)
132
+ ),
133
+ "data-promote-download": !0,
134
+ children: [
135
+ /* @__PURE__ */ a(M, { className: "h-3 w-3" }),
136
+ "download this form"
137
+ ]
138
+ }
139
+ ),
140
+ " ",
141
+ "and upload it there."
142
+ ] }),
143
+ c === "preview" && /* @__PURE__ */ r("p", { className: "flex items-center gap-1.5 text-slate-500 dark:text-muted-foreground", children: [
144
+ /* @__PURE__ */ a(N, { className: "h-3.5 w-3.5 animate-spin" }),
145
+ "Comparing…"
146
+ ] }),
147
+ F && /* @__PURE__ */ a("p", { className: "text-[12px] text-red-600 dark:text-red-400", role: "alert", children: F }),
148
+ n && !n.theirs && o && /* @__PURE__ */ r("div", { "data-promote-nomatch": !0, className: "space-y-1.5", children: [
149
+ /* @__PURE__ */ r("p", { className: "text-slate-700 dark:text-foreground", children: [
150
+ n.source.label,
151
+ " has no layout with this link name or name. Pick the one to compare with:"
152
+ ] }),
153
+ /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-1.5", children: [
154
+ n.candidates.length === 0 && /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: "It has no layouts for this collection." }),
155
+ n.candidates.map((e) => /* @__PURE__ */ a(
156
+ "button",
157
+ {
158
+ type: "button",
159
+ className: d(C, $),
160
+ onClick: () => void x(o, e.id),
161
+ children: e.name
162
+ },
163
+ e.id
164
+ ))
165
+ ] })
166
+ ] }),
167
+ (n == null ? void 0 : n.theirs) && n.plan && /* @__PURE__ */ r(
168
+ "div",
169
+ {
170
+ className: "space-y-2 rounded-lg border border-slate-200 bg-slate-50 p-3 dark:border-border dark:bg-background",
171
+ "data-promote-diff": !0,
172
+ children: [
173
+ /* @__PURE__ */ r("p", { className: "text-slate-700 dark:text-foreground", children: [
174
+ /* @__PURE__ */ r("span", { className: "font-semibold", children: [
175
+ "“",
176
+ n.theirs.name,
177
+ "”"
178
+ ] }),
179
+ " in ",
180
+ n.source.label,
181
+ n.source.version ? ` (${n.source.version})` : "",
182
+ n.candidates.length > 1 && /* @__PURE__ */ r(_, { children: [
183
+ " · ",
184
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: "compare with " }),
185
+ n.candidates.filter((e) => {
186
+ var t;
187
+ return e.id !== ((t = n.theirs) == null ? void 0 : t.id);
188
+ }).slice(0, 6).map((e, t) => /* @__PURE__ */ r("span", { children: [
189
+ t > 0 ? ", " : "",
190
+ /* @__PURE__ */ a(
191
+ "button",
192
+ {
193
+ type: "button",
194
+ className: "text-[#0089ad] hover:underline dark:text-nvr-cyan",
195
+ onClick: () => o && void x(o, e.id),
196
+ children: e.name
197
+ }
198
+ )
199
+ ] }, e.id))
200
+ ] })
201
+ ] }),
202
+ u.length === 0 ? /* @__PURE__ */ a("p", { className: "text-slate-600 dark:text-muted-foreground", "data-promote-same": !0, children: "The same as here — nothing to bring over." }) : B.map((e) => /* @__PURE__ */ r("div", { children: [
203
+ /* @__PURE__ */ r("p", { className: "mb-0.5 text-[11.5px] font-medium text-slate-500 dark:text-muted-foreground", children: [
204
+ se[e.k],
205
+ " · ",
206
+ e.list.length
207
+ ] }),
208
+ /* @__PURE__ */ r("ul", { className: "space-y-0.5", children: [
209
+ e.list.slice(0, 40).map((t, v) => /* @__PURE__ */ r(
210
+ "li",
211
+ {
212
+ className: "flex items-start gap-1.5 text-slate-700 dark:text-foreground",
213
+ children: [
214
+ /* @__PURE__ */ a(le, { c: t }),
215
+ /* @__PURE__ */ a("span", { className: "min-w-0 break-words", children: t.kind === "setting" ? /* @__PURE__ */ r(_, { children: [
216
+ /* @__PURE__ */ a("code", { className: "font-mono text-[11.5px]", children: t.target }),
217
+ ":",
218
+ " ",
219
+ /* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: O(t.from) }),
220
+ " → ",
221
+ O(t.to)
222
+ ] }) : t.text })
223
+ ]
224
+ },
225
+ `${t.kind}:${t.target}:${t.where ?? ""}:${v}`
226
+ )),
227
+ e.list.length > 40 && /* @__PURE__ */ r("li", { className: "text-slate-500 dark:text-muted-foreground", children: [
228
+ "and ",
229
+ e.list.length - 40,
230
+ " more"
231
+ ] })
232
+ ] })
233
+ ] }, e.k)),
234
+ K.length > 0 && /* @__PURE__ */ a(
235
+ "div",
236
+ {
237
+ className: "rounded-md border border-amber-300 bg-amber-50 p-2 text-[12px] text-amber-900 dark:border-amber-400/30 dark:bg-amber-400/10 dark:text-amber-200",
238
+ "data-promote-skipped": !0,
239
+ children: K.map((e, t) => /* @__PURE__ */ r("p", { children: [
240
+ e.kind === "setting" ? /* @__PURE__ */ a("code", { className: "font-mono", children: e.target }) : null,
241
+ e.kind === "setting" ? " — " : "",
242
+ e.text
243
+ ] }, `${e.target}:${t}`))
244
+ }
245
+ ),
246
+ /* @__PURE__ */ a("p", { className: "text-[11.5px] text-slate-500 dark:text-muted-foreground", children: "Which layout is the default, and its place in the list, stay as they are here." }),
247
+ u.length > 0 && (T ? /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", "data-promote-confirm": !0, children: [
248
+ /* @__PURE__ */ r("span", { className: "text-slate-700 dark:text-foreground", children: [
249
+ "Save a version of this layout, then apply ",
250
+ u.length,
251
+ " ",
252
+ u.length === 1 ? "change" : "changes",
253
+ "? History → Restore undoes it."
254
+ ] }),
255
+ /* @__PURE__ */ r(
256
+ "button",
257
+ {
258
+ type: "button",
259
+ className: I,
260
+ disabled: c != null,
261
+ onClick: () => void A(),
262
+ "data-promote-apply-confirm": !0,
263
+ children: [
264
+ c === "apply" && /* @__PURE__ */ a(N, { className: "h-3 w-3 animate-spin" }),
265
+ "Apply here"
266
+ ]
267
+ }
268
+ ),
269
+ /* @__PURE__ */ a("button", { type: "button", className: oe, onClick: () => p(!1), children: "Cancel" })
270
+ ] }) : /* @__PURE__ */ a(
271
+ "button",
272
+ {
273
+ type: "button",
274
+ className: I,
275
+ onClick: () => p(!0),
276
+ "data-promote-apply": !0,
277
+ children: "Apply here…"
278
+ }
279
+ ))
280
+ ]
281
+ }
282
+ )
283
+ ] });
284
+ }
285
+ export {
286
+ be as PromotePanel
287
+ };
@@ -0,0 +1,122 @@
1
+ import { useQuery as l } from "@tanstack/react-query";
2
+ import { useNivaroClient as y } from "../../../context.js";
3
+ import { get as i, post as c } from "../../../lib/commands.js";
4
+ const p = {
5
+ deps: (e) => ["layout-editor", "dependencies", e],
6
+ sources: () => ["layout-editor", "promote-sources"],
7
+ requests: (e) => ["layout-editor", "change-requests", e]
8
+ }, s = (e) => {
9
+ const o = e;
10
+ return o && typeof o == "object" && "data" in o ? o.data : e;
11
+ };
12
+ function q(e, o = !0) {
13
+ const r = y();
14
+ return l({
15
+ queryKey: p.deps(e ?? 0),
16
+ queryFn: async () => {
17
+ const t = s(
18
+ await r.request(i(`/collection-layouts/${e}/dependencies`))
19
+ );
20
+ if (!t || typeof t != "object" || !t.layout || !Array.isArray(t.nodes))
21
+ throw new Error("No dependency data");
22
+ return {
23
+ ...t,
24
+ groups: Array.isArray(t.groups) ? t.groups : [],
25
+ extensions: t.extensions ?? { declaring: 0, note: "" }
26
+ };
27
+ },
28
+ enabled: o && e != null,
29
+ staleTime: 15e3
30
+ });
31
+ }
32
+ function b(e = !0) {
33
+ const o = y();
34
+ return l({
35
+ queryKey: p.sources(),
36
+ queryFn: async () => {
37
+ const r = s(
38
+ await o.request(i("/collection-layouts/promote/sources"))
39
+ );
40
+ return Array.isArray(r) ? r : [];
41
+ },
42
+ enabled: e,
43
+ staleTime: 6e4
44
+ });
45
+ }
46
+ async function w(e, o, r, t) {
47
+ return s(
48
+ await e.request(
49
+ c(`/collection-layouts/${o}/promote/preview`, {
50
+ ...r,
51
+ ...t != null ? { remote_layout_id: t } : {}
52
+ })
53
+ )
54
+ );
55
+ }
56
+ async function g(e, o, r, t, a) {
57
+ return s(
58
+ await e.request(
59
+ c(`/collection-layouts/${o}/promote/apply`, {
60
+ ...r,
61
+ base_rev: t,
62
+ ...a != null ? { remote_layout_id: a } : {}
63
+ })
64
+ )
65
+ );
66
+ }
67
+ async function h(e, o, r) {
68
+ const t = await e.request(i(`/collection-layouts/${o}/export`)), a = new Blob([JSON.stringify(t, null, 2)], { type: "application/json" }), n = URL.createObjectURL(a), u = document.createElement("a");
69
+ u.href = n, u.download = `layout-${r.toLowerCase().replace(/[^a-z0-9_-]+/g, "-") || o}.json`, document.body.appendChild(u), u.click(), u.remove(), setTimeout(() => URL.revokeObjectURL(n), 1e3);
70
+ }
71
+ function _(e) {
72
+ let o;
73
+ try {
74
+ o = JSON.parse(e);
75
+ } catch {
76
+ throw new Error("That file is not JSON");
77
+ }
78
+ const r = (o == null ? void 0 : o.data) ?? o, t = r;
79
+ return t && t.format === 1 && t.tables && typeof t.tables == "object" ? {
80
+ ...t,
81
+ classification: void 0,
82
+ tables: Object.fromEntries([
83
+ "nivaro_collection_layouts",
84
+ "nivaro_field_groups",
85
+ "nivaro_layout_field_assignments"
86
+ ].filter((n) => n in t.tables).map((n) => [n, t.tables[n]]))
87
+ } : r;
88
+ }
89
+ function v(e, o = !0) {
90
+ const r = y();
91
+ return l({
92
+ queryKey: p.requests(e),
93
+ queryFn: async () => {
94
+ const t = s(
95
+ await r.request(i("/layout-change-requests", { collection: e }))
96
+ );
97
+ return Array.isArray(t) ? t : [];
98
+ },
99
+ enabled: o && !!e,
100
+ staleTime: 3e4
101
+ });
102
+ }
103
+ async function j(e, o, r, t) {
104
+ return e.request(c(`/layout-change-requests/${o}/resolve`, { decision: r, note: t }));
105
+ }
106
+ async function A(e, o) {
107
+ return s(
108
+ await e.request(c("/layout-change-requests", o))
109
+ );
110
+ }
111
+ export {
112
+ g as applyPromotion,
113
+ h as downloadLayout,
114
+ p as opsKeys,
115
+ w as previewPromotion,
116
+ j as resolveChangeRequest,
117
+ A as sendChangeRequest,
118
+ _ as trimUploadedFile,
119
+ v as useChangeRequests,
120
+ q as useLayoutDependencies,
121
+ b as usePromoteSources
122
+ };
@@ -2,14 +2,26 @@ import "react/jsx-runtime";
2
2
  import "lucide-react";
3
3
  import "react";
4
4
  import "sonner";
5
- const t = [
5
+ import { post as l } from "../../../lib/commands.js";
6
+ import { barBtn as n } from "../toolbar-kit.js";
7
+ const u = [
6
8
  { type: "grouped", label: "Form", detail: "What people fill in and edit" },
7
9
  { type: "summary", label: "Summary", detail: "Read mode for a saved record" },
8
10
  { type: "detail", label: "Detail", detail: "The panel a list opens when you drill in" },
9
11
  { type: "file", label: "PDF", detail: "A PDF generated from the record" },
10
12
  { type: "addendum", label: "Addendum", detail: "The form for a change to a saved record" },
11
13
  { type: "table", label: "Grid columns", detail: "Columns when shown as a grid in another record" }
12
- ];
14
+ ], y = n, b = "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:opacity-50";
15
+ async function h(o, i) {
16
+ var a;
17
+ const e = await o.request(
18
+ l("/collection-layouts", i)
19
+ ), t = ((a = e == null ? void 0 : e.data) == null ? void 0 : a.id) ?? (e == null ? void 0 : e.id);
20
+ return typeof t == "number" ? t : t != null ? Number(t) : null;
21
+ }
13
22
  export {
14
- t as LAYOUT_TYPES
23
+ u as LAYOUT_TYPES,
24
+ y as btnOutline,
25
+ b as btnPrimary,
26
+ h as createLayout
15
27
  };
@@ -6,6 +6,9 @@ const $ = /^\{\{\s*([A-Za-z_][A-Za-z0-9_]*)\s*\}\}(?:\s*([*+])\s*(-?\d+(?:\.\d+)
6
6
  lte: "is at most",
7
7
  contains: "contains"
8
8
  };
9
+ function C(t) {
10
+ return t.map((e) => e.text).join("");
11
+ }
9
12
  function q(t) {
10
13
  if (!t) return null;
11
14
  if (typeof t == "object") return t;
@@ -17,7 +20,7 @@ function q(t) {
17
20
  return null;
18
21
  }
19
22
  }
20
- function C(t) {
23
+ function v(t) {
21
24
  var o;
22
25
  const e = {};
23
26
  for (const n of t) {
@@ -45,7 +48,7 @@ function S(t) {
45
48
  const e = /^(is|has)\s+(.+)$/i.exec(t), o = e && e[1].toLowerCase() === "has" ? "has" : "is", s = (e ? e[2] : t).split(/\s+/).map((r) => /^[A-Z][a-z][a-z-]*$/.test(r) ? r.toLowerCase() : r).join(" ");
46
49
  return { verb: o, name: s };
47
50
  }
48
- function E(t, e, o, n) {
51
+ function j(t, e, o, n) {
49
52
  var r;
50
53
  if (e == null || e === "") return "empty";
51
54
  if (typeof e == "string") {
@@ -57,7 +60,7 @@ function E(t, e, o, n) {
57
60
  }
58
61
  return ((r = n[t]) == null ? void 0 : r[String(e)]) ?? String(e);
59
62
  }
60
- function L(t, e, o) {
63
+ function E(t, e, o) {
61
64
  var l;
62
65
  const n = x(t.field, e), s = { text: n, strong: !0 };
63
66
  if (t.op === "nnull") return [s, { text: " is set" }];
@@ -70,7 +73,7 @@ function L(t, e, o) {
70
73
  const h = t.op === "eq" ? u : !u, { verb: p, name: a } = S(n), y = p === "has" ? `no ${a}` : `not ${a}`;
71
74
  return [{ text: `${p} ` }, { text: h ? a : y, strong: !0 }, ...i];
72
75
  }
73
- const f = E(t.field, t.value, e, o);
76
+ const f = j(t.field, t.value, e, o);
74
77
  if (t.op === "eq") return [{ text: `${n} is ` }, { text: f, strong: !0 }];
75
78
  if (t.op === "neq")
76
79
  return [{ text: `${n} is not ` }, { text: f, strong: !0 }, ...i];
@@ -83,23 +86,23 @@ function g(t) {
83
86
  n > 0 && e.push({ text: " and " }), e.push(...o);
84
87
  }), e;
85
88
  }
86
- function O(t, e, o) {
89
+ function L(t, e, o) {
87
90
  if (!(t != null && t.length)) return [];
88
91
  const n = new Map(e.map((s) => [s.field, s]));
89
- return g(t.map((s) => L(s, n, o)));
92
+ return g(t.map((s) => E(s, n, o)));
90
93
  }
91
- function R(t) {
94
+ function O(t) {
92
95
  return t.length ? [
93
96
  { text: "for " },
94
97
  ...g(t.map((e) => [{ text: e, strong: !0 }])),
95
98
  { text: " only" }
96
99
  ] : [];
97
100
  }
98
- function v(t, e, o) {
99
- const n = R(t.role_names ?? []);
101
+ function z(t, e, o) {
102
+ const n = O(t.role_names ?? []);
100
103
  switch (t.kind) {
101
104
  case "record_rule": {
102
- const s = O(t.rules, e, o);
105
+ const s = L(t.rules, e, o);
103
106
  return n.length ? s.length ? [...s, { text: ", " }, ...n] : n : s;
104
107
  }
105
108
  case "role":
@@ -114,8 +117,9 @@ function v(t, e, o) {
114
117
  }
115
118
  }
116
119
  export {
117
- C as choiceLabelsFrom,
118
- O as describeConditions,
119
- v as describeReason,
120
- R as describeRoles
120
+ v as choiceLabelsFrom,
121
+ L as describeConditions,
122
+ z as describeReason,
123
+ O as describeRoles,
124
+ C as segmentsText
121
125
  };