@nivaro/react 0.2.53 → 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 +113 -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 +4058 -3942
  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,305 @@
1
+ import { jsxs as h, jsx as r, Fragment as J } from "react/jsx-runtime";
2
+ import { useState as Q, useMemo as P } from "react";
3
+ import { toast as O } from "sonner";
4
+ import { HEADER_GROUP_KEY as _ } from "../../../lib/layout-ops.js";
5
+ import { cn as F } from "../../../lib/utils.js";
6
+ import { Skeleton as X } from "../../ui/skeleton.js";
7
+ import { targetOfKey as ee, keyOf as te, isFieldRow as T, fieldZones as re, zoneItems as oe } from "../field-zones.js";
8
+ import { resetPlacementOps as ne } from "../inheritance.js";
9
+ import { useCollectionMeta as le } from "../inspector/field-context.js";
10
+ import { overridePlacementOps as ae, describeField as se } from "../inspector/model.js";
11
+ import { LoadError as ie } from "../load-error.js";
12
+ import { useCollectionPipelines as de } from "../preview/preview-api.js";
13
+ import { useCellMenu as ce, MatrixMenu as me, matrixCorner as ue, matrixTh as H, matrixRowHead as he, InheritChip as fe, matrixCellTd as Z, MatrixCellButton as j, matrixZoneTd as we } from "./MatrixGrid.js";
14
+ import { useSaveRequirements as pe } from "./matrix-api.js";
15
+ import { CELL_KINDS as z, stateCell as K, movesFrom as be, everyStateValue as L, everyStateOps as ge, cellChange as xe } from "./state-matrix.js";
16
+ const x = {
17
+ normal: "Editable",
18
+ readonly: "Read-only",
19
+ required: "Required",
20
+ hidden: "Hidden"
21
+ }, S = {
22
+ normal: "normal",
23
+ readonly: "readonly",
24
+ required: "required",
25
+ hidden: "hidden"
26
+ }, D = "*", A = (o) => `${o.field}${o.group_key ?? ""}`;
27
+ function ye(o, a) {
28
+ const f = new Set((a == null ? void 0 : a.placements.map((n) => n.field)) ?? []), w = (n) => ({
29
+ row: n,
30
+ source: f.has(n.field) ? "override" : "own"
31
+ }), v = [], g = o.placements.filter((n) => n.group_key === _ && T(n)).sort((n, p) => n.sort - p.sort);
32
+ g.length && v.push({ key: _, label: "Header strip", rows: g.map(w) });
33
+ for (const n of re(o)) {
34
+ const p = oe(o, n.key).filter(T);
35
+ p.length && v.push({ key: n.key ?? "", label: n.label, rows: p.map(w) });
36
+ }
37
+ if (a) {
38
+ const n = new Set(o.placements.map((b) => b.field)), p = /* @__PURE__ */ new Set(), C = a.placements.filter((b) => !T(b) || n.has(b.field) || p.has(b.field) ? !1 : (p.add(b.field), !0));
39
+ C.length && v.push({
40
+ key: "parent",
41
+ label: `From ${String(a.layout.name ?? "the parent layout")}`,
42
+ rows: C.map((b) => ({ row: b, source: "inherited" }))
43
+ });
44
+ }
45
+ return v;
46
+ }
47
+ function Pe({
48
+ bundle: o,
49
+ parent: a,
50
+ collection: f,
51
+ apply: w,
52
+ onSelect: v
53
+ }) {
54
+ const { data: g } = le(f), {
55
+ data: n = [],
56
+ isLoading: p,
57
+ isError: C,
58
+ refetch: b
59
+ } = de(f, !0), [V, W] = Q(null), s = n.find((e) => e.id === V) ?? n[0] ?? null, k = (s == null ? void 0 : s.states) ?? [], N = (s == null ? void 0 : s.transitions) ?? [], I = pe(f), y = ce(), R = P(() => ye(o, a), [o, a]), q = String((a == null ? void 0 : a.layout.name) ?? "the parent layout"), E = (e) => se(e.field, (g == null ? void 0 : g.fields) ?? [], (g == null ? void 0 : g.relations) ?? [], e).label, l = P(() => {
60
+ if (!y.open) return null;
61
+ const e = y.open.lastIndexOf("|"), t = y.open.slice(0, e), d = y.open.slice(e + 1);
62
+ for (const c of R)
63
+ for (const m of c.rows)
64
+ if (A(m.row) === t && m.source !== "inherited")
65
+ return { row: m.row, state: d === D ? null : k.find((i) => i.key === d) };
66
+ return null;
67
+ }, [y.open, R, k]), Y = l ? l.state == null ? z.map((e) => ({
68
+ value: e,
69
+ label: x[e],
70
+ tone: S[e],
71
+ effect: e === "normal" ? "No rule of its own on this form" : e === "readonly" ? "Read-only on this form, in every state" : e === "required" ? "The form will not save without a value" : "Not shown on this form",
72
+ blocked: null
73
+ })) : (() => {
74
+ var m;
75
+ const e = l.state, t = K(l.row, e, N), d = be(N, e), c = d.length === 1 ? `"${(m = d[0]) == null ? void 0 : m.label}"` : `the ${d.length} moves out`;
76
+ return z.map((i) => {
77
+ const u = t.options[i];
78
+ return {
79
+ value: i,
80
+ label: x[i],
81
+ tone: S[i],
82
+ effect: i === "normal" ? `Editable in ${e.label}` : i === "readonly" ? `Locked while the record is in ${e.label}` : i === "required" ? L(l.row) === "required" ? "Required on every state" : `${c} will ask for it — saved to the ${(s == null ? void 0 : s.name) ?? ""} pipeline at once, for every form` : "",
83
+ blocked: u.ok ? null : u.why
84
+ };
85
+ });
86
+ })() : [], B = l ? l.state == null ? L(l.row) : K(l.row, l.state, N).value : null, G = async (e) => {
87
+ if (!l) return;
88
+ const t = E(l.row);
89
+ if (l.state == null) {
90
+ const m = ge(l.row, e);
91
+ m.length && w(m, { label: `${t}: ${x[e].toLowerCase()} on every state` });
92
+ return;
93
+ }
94
+ if (!s) return;
95
+ const d = l.state, c = xe(l.row, d, s.id, N, e);
96
+ if (c && (c.ops.length && w(c.ops, { label: `${t}: ${x[e].toLowerCase()} in ${d.label}` }), c.requirements.length !== 0))
97
+ try {
98
+ await I(c.requirements);
99
+ const m = c.requirements.map((i) => `"${i.label}"`).join(", ");
100
+ O.success(
101
+ e === "required" ? `${m} now ${c.requirements.length === 1 ? "asks" : "ask"} for ${t}` : `${m} no longer ${c.requirements.length === 1 ? "asks" : "ask"} for ${t}`,
102
+ {
103
+ description: `Saved to the ${s.name} pipeline`,
104
+ action: {
105
+ label: "Undo",
106
+ onClick: () => void I(c.requirements, "before").catch(
107
+ (i) => O.error(U(i))
108
+ )
109
+ }
110
+ }
111
+ );
112
+ } catch (m) {
113
+ O.error(`The pipeline was not changed: ${U(m)}`);
114
+ }
115
+ }, M = R.reduce((e, t) => e + t.rows.length, 0);
116
+ return /* @__PURE__ */ h("div", { "data-field-state-matrix": "", className: "flex min-h-full flex-col gap-2 p-4", children: [
117
+ /* @__PURE__ */ h("div", { className: "flex flex-wrap items-center gap-2", children: [
118
+ /* @__PURE__ */ h("p", { className: "m-0 min-w-0 flex-1 text-[12px] text-slate-500 dark:text-muted-foreground", children: [
119
+ M,
120
+ " ",
121
+ M === 1 ? "field" : "fields",
122
+ " by workflow state. Read-only uses the field's Read-only when; Required asks for the value before the record leaves the state."
123
+ ] }),
124
+ n.length > 1 && /* @__PURE__ */ r(
125
+ "fieldset",
126
+ {
127
+ "aria-label": "Pipeline",
128
+ className: "m-0 inline-flex h-8 items-center gap-0.5 rounded-md border-0 bg-slate-100 p-0.5 dark:bg-muted",
129
+ children: n.map((e) => /* @__PURE__ */ r(
130
+ "button",
131
+ {
132
+ type: "button",
133
+ "aria-pressed": e.id === (s == null ? void 0 : s.id),
134
+ onClick: () => W(e.id),
135
+ className: F(
136
+ "inline-flex h-7 items-center rounded px-2 text-[12px] font-medium transition-colors",
137
+ e.id === (s == null ? void 0 : s.id) ? "bg-white text-slate-900 shadow-sm dark:bg-background dark:text-foreground" : "text-slate-500 hover:text-slate-800 dark:text-muted-foreground dark:hover:text-foreground"
138
+ ),
139
+ children: e.name
140
+ },
141
+ e.id
142
+ ))
143
+ }
144
+ )
145
+ ] }),
146
+ C ? /* @__PURE__ */ r(ie, { what: "the workflow states", onRetry: () => void b() }) : !p && !s && /* @__PURE__ */ r(
147
+ "p",
148
+ {
149
+ role: "note",
150
+ className: "m-0 rounded-md bg-slate-100 px-3 py-2 text-[12px] text-slate-600 dark:bg-muted dark:text-muted-foreground",
151
+ children: "No pipeline runs on this collection, so only Every state applies."
152
+ }
153
+ ),
154
+ p ? /* @__PURE__ */ r(X, { className: "h-48 w-full rounded-lg" }) : /* @__PURE__ */ r(
155
+ me,
156
+ {
157
+ menu: y,
158
+ title: l ? `${E(l.row)} · ${l.state ? l.state.label : "Every state"}` : "",
159
+ choices: Y,
160
+ current: B,
161
+ onPick: (e) => void G(e),
162
+ children: /* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-auto rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ h("table", { className: "border-separate border-spacing-0 text-[12.5px]", children: [
163
+ /* @__PURE__ */ r("thead", { children: /* @__PURE__ */ h("tr", { children: [
164
+ /* @__PURE__ */ r("th", { className: ue, children: "Field" }),
165
+ /* @__PURE__ */ r(
166
+ "th",
167
+ {
168
+ className: F(H, "text-center"),
169
+ "data-tip": "The field on this form, whatever the state",
170
+ children: "Every state"
171
+ }
172
+ ),
173
+ k.map((e) => /* @__PURE__ */ r(
174
+ "th",
175
+ {
176
+ className: F(H, "text-center"),
177
+ "data-matrix-state": e.key,
178
+ children: /* @__PURE__ */ h("span", { className: "inline-flex items-center gap-1.5", children: [
179
+ /* @__PURE__ */ r(
180
+ "span",
181
+ {
182
+ "aria-hidden": !0,
183
+ className: "h-2 w-2 shrink-0 rounded-full bg-slate-300 dark:bg-slate-600",
184
+ style: e.color ? { backgroundColor: e.color } : void 0
185
+ }
186
+ ),
187
+ e.label
188
+ ] })
189
+ },
190
+ e.key
191
+ ))
192
+ ] }) }),
193
+ /* @__PURE__ */ h("tbody", { children: [
194
+ R.map((e) => /* @__PURE__ */ r(
195
+ ve,
196
+ {
197
+ zone: e,
198
+ colSpan: k.length + 1,
199
+ render: (t) => {
200
+ const d = E(t.row), c = A(t.row), m = t.source === "inherited" ? `From ${q} — override it to change it here` : null, i = L(t.row);
201
+ return /* @__PURE__ */ h("tr", { "data-matrix-row": t.row.field, children: [
202
+ /* @__PURE__ */ h("th", { scope: "row", className: he, children: [
203
+ /* @__PURE__ */ r(
204
+ "button",
205
+ {
206
+ type: "button",
207
+ onClick: (u) => v(ee(te(t.row)), {
208
+ additive: u.shiftKey || u.metaKey || u.ctrlKey
209
+ }),
210
+ "data-tip": "Select it on the form",
211
+ className: "block max-w-full truncate text-left font-medium text-slate-800 hover:underline dark:text-foreground",
212
+ children: d
213
+ }
214
+ ),
215
+ t.source !== "own" && a && /* @__PURE__ */ r(
216
+ fe,
217
+ {
218
+ kind: t.source === "inherited" ? "inherited" : "override",
219
+ parentName: q,
220
+ action: t.source === "inherited" ? "override" : "reset",
221
+ actionLabel: t.source === "inherited" ? `Override ${d} on this form` : `Reset ${d} to ${q}`,
222
+ actionTip: t.source === "inherited" ? "Copy it onto this form to change it here" : `Take ${q}'s placement of it again`,
223
+ onAction: () => t.source === "inherited" ? w(ae(o, a, t.row), {
224
+ label: `Override ${d} on this form`
225
+ }) : w(ne(o, t.row.field), {
226
+ label: `Reset ${d} to ${q}`
227
+ })
228
+ }
229
+ )
230
+ ] }),
231
+ /* @__PURE__ */ r("td", { className: Z, children: /* @__PURE__ */ r(
232
+ j,
233
+ {
234
+ cellKey: `${c}|${D}`,
235
+ tone: S[i],
236
+ word: x[i],
237
+ tip: i === "normal" ? "No rule of its own" : `${x[i]} on every state`,
238
+ locked: m,
239
+ label: `${d}, every state: ${x[i]}`,
240
+ menu: y
241
+ }
242
+ ) }),
243
+ k.map((u) => {
244
+ const $ = K(t.row, u, N);
245
+ return /* @__PURE__ */ r("td", { className: Z, children: /* @__PURE__ */ r(
246
+ j,
247
+ {
248
+ cellKey: `${c}|${u.key}`,
249
+ tone: S[$.value],
250
+ word: x[$.value],
251
+ tip: $.conflict ?? $.because,
252
+ conflict: $.conflict,
253
+ locked: m,
254
+ label: `${d} in ${u.label}: ${x[$.value]}`,
255
+ menu: y
256
+ }
257
+ ) }, u.key);
258
+ })
259
+ ] }, c);
260
+ }
261
+ },
262
+ e.key
263
+ )),
264
+ R.length === 0 && /* @__PURE__ */ r("tr", { children: /* @__PURE__ */ r(
265
+ "td",
266
+ {
267
+ colSpan: k.length + 2,
268
+ className: "px-3 py-6 text-center text-[12.5px] text-slate-500 dark:text-muted-foreground",
269
+ children: "No fields on this form yet."
270
+ }
271
+ ) })
272
+ ] })
273
+ ] }) })
274
+ }
275
+ )
276
+ ] });
277
+ }
278
+ function ve({
279
+ zone: o,
280
+ colSpan: a,
281
+ render: f
282
+ }) {
283
+ return /* @__PURE__ */ h(J, { children: [
284
+ /* @__PURE__ */ h("tr", { "data-matrix-zone": o.key, children: [
285
+ /* @__PURE__ */ r("td", { className: we, children: o.label }),
286
+ /* @__PURE__ */ r(
287
+ "td",
288
+ {
289
+ colSpan: a,
290
+ className: "border-b border-slate-200 bg-slate-100 dark:border-border dark:bg-muted"
291
+ }
292
+ )
293
+ ] }),
294
+ o.rows.map(f)
295
+ ] });
296
+ }
297
+ function U(o) {
298
+ var f, w;
299
+ const a = (w = (f = o == null ? void 0 : o.response) == null ? void 0 : f.data) == null ? void 0 : w.error;
300
+ return typeof a == "string" ? a : o instanceof Error ? o.message : "Something went wrong";
301
+ }
302
+ export {
303
+ Pe as FieldStateMatrix,
304
+ ye as matrixZones
305
+ };
@@ -0,0 +1,181 @@
1
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
2
+ import { Check as p, Lock as f, Asterisk as h, EyeOff as g, PenLine as v } from "lucide-react";
3
+ import { useState as k, useRef as y, useCallback as N } from "react";
4
+ import { cn as u } from "../../../lib/utils.js";
5
+ import { Popover as w, PopoverContent as C, PopoverAnchor as O } from "../../ui/popover.js";
6
+ const T = {
7
+ normal: "text-slate-500 hover:bg-slate-100 dark:text-muted-foreground dark:hover:bg-muted",
8
+ readonly: "bg-amber-50 text-amber-800 hover:bg-amber-100 dark:bg-amber-500/15 dark:text-amber-200 dark:hover:bg-amber-500/25",
9
+ required: "bg-rose-50 text-rose-700 hover:bg-rose-100 dark:bg-rose-500/15 dark:text-rose-200 dark:hover:bg-rose-500/25",
10
+ hidden: "bg-slate-100 text-slate-600 hover:bg-slate-200 dark:bg-slate-800 dark:text-slate-300 dark:hover:bg-slate-700"
11
+ };
12
+ function m({ tone: t, className: a }) {
13
+ const n = u("h-3.5 w-3.5 shrink-0", a);
14
+ return t === "readonly" ? /* @__PURE__ */ r(f, { "aria-hidden": !0, className: n }) : t === "required" ? /* @__PURE__ */ r(h, { "aria-hidden": !0, className: n }) : t === "hidden" ? /* @__PURE__ */ r(g, { "aria-hidden": !0, className: n }) : /* @__PURE__ */ r(v, { "aria-hidden": !0, className: u(n, "opacity-60") });
15
+ }
16
+ const z = "sticky top-0 z-20 h-9 border-b border-slate-200 bg-slate-50 px-2 text-left text-[11.5px] font-semibold text-slate-600 dark:border-border dark:bg-card dark:text-muted-foreground", q = u(z, "left-0 z-30 min-w-[220px]"), R = "sticky left-0 z-10 min-w-[220px] max-w-[300px] border-b border-r border-slate-100 bg-white px-3 py-1 text-left align-middle dark:border-border/60 dark:bg-card", $ = "border-b border-slate-100 px-1 py-1 text-center align-middle dark:border-border/60", E = "sticky left-0 z-10 border-b border-slate-200 bg-slate-100 px-3 py-1.5 text-left text-[12px] font-semibold text-slate-700 dark:border-border dark:bg-muted dark:text-foreground";
17
+ function I() {
18
+ const [t, a] = k(null);
19
+ return { open: t, setOpen: a };
20
+ }
21
+ function L({
22
+ cellKey: t,
23
+ tone: a,
24
+ word: n,
25
+ tip: c,
26
+ conflict: i,
27
+ locked: o,
28
+ label: d,
29
+ menu: x
30
+ }) {
31
+ const e = x.open === t, l = /* @__PURE__ */ s(
32
+ "button",
33
+ {
34
+ type: "button",
35
+ "data-matrix-cell": t,
36
+ "data-tone": a,
37
+ "aria-label": d,
38
+ "aria-haspopup": o ? void 0 : "dialog",
39
+ "aria-expanded": o ? void 0 : e,
40
+ "aria-disabled": o ? !0 : void 0,
41
+ "data-tip": o ?? c,
42
+ onClick: () => {
43
+ o || x.setOpen(e ? null : t);
44
+ },
45
+ className: u(
46
+ "relative inline-flex h-7 w-full min-w-[96px] items-center justify-center gap-1 rounded-md px-2 text-[12px] font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-nvr-cyan",
47
+ T[a],
48
+ o && "cursor-not-allowed opacity-55",
49
+ e && "outline outline-2 outline-nvr-cyan"
50
+ ),
51
+ children: [
52
+ /* @__PURE__ */ r(m, { tone: a }),
53
+ /* @__PURE__ */ r("span", { className: "truncate", children: n }),
54
+ i && /* @__PURE__ */ r(
55
+ "span",
56
+ {
57
+ "data-matrix-conflict": "",
58
+ className: "absolute right-1 top-1 h-1.5 w-1.5 rounded-full bg-amber-500",
59
+ children: /* @__PURE__ */ r("span", { className: "sr-only", children: i })
60
+ }
61
+ )
62
+ ]
63
+ }
64
+ );
65
+ return e ? /* @__PURE__ */ r(O, { asChild: !0, children: l }) : l;
66
+ }
67
+ function B({
68
+ menu: t,
69
+ title: a,
70
+ choices: n,
71
+ current: c,
72
+ onPick: i,
73
+ children: o
74
+ }) {
75
+ const d = y(null);
76
+ t.open && (d.current = t.open);
77
+ const x = N(() => t.setOpen(null), [t]);
78
+ return /* @__PURE__ */ s(w, { open: t.open != null, onOpenChange: (e) => !e && x(), children: [
79
+ o,
80
+ /* @__PURE__ */ s(
81
+ C,
82
+ {
83
+ align: "center",
84
+ className: "w-[280px] p-1.5",
85
+ "data-matrix-menu": "",
86
+ onCloseAutoFocus: (e) => {
87
+ e.preventDefault();
88
+ const l = d.current;
89
+ if (l) {
90
+ for (const b of document.querySelectorAll("[data-matrix-cell]"))
91
+ if (b.dataset.matrixCell === l) return b.focus({ preventScroll: !0 });
92
+ }
93
+ },
94
+ children: [
95
+ /* @__PURE__ */ r("p", { className: "px-2 pb-1 pt-0.5 text-[11.5px] text-slate-500 dark:text-muted-foreground", children: a }),
96
+ /* @__PURE__ */ r("div", { role: "listbox", "aria-label": "Set to", className: "flex flex-col", children: n.map((e) => {
97
+ const l = e.value === c;
98
+ return /* @__PURE__ */ s(
99
+ "button",
100
+ {
101
+ type: "button",
102
+ role: "option",
103
+ "aria-selected": l,
104
+ "aria-disabled": e.blocked ? !0 : void 0,
105
+ "data-matrix-choice": e.value,
106
+ "data-tip": e.blocked ?? void 0,
107
+ onClick: () => {
108
+ e.blocked || (i(e.value), x());
109
+ },
110
+ className: u(
111
+ "flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left transition-colors",
112
+ e.blocked ? "cursor-not-allowed opacity-45" : "hover:bg-muted",
113
+ l && "bg-accent"
114
+ ),
115
+ children: [
116
+ /* @__PURE__ */ r(m, { tone: e.tone, className: "mt-0.5" }),
117
+ /* @__PURE__ */ s("span", { className: "min-w-0 flex-1", children: [
118
+ /* @__PURE__ */ r("span", { className: "block text-[12.5px] font-medium text-slate-800 dark:text-foreground", children: e.label }),
119
+ /* @__PURE__ */ r("span", { className: "block text-[11.5px] leading-snug text-slate-500 dark:text-muted-foreground", children: e.blocked ?? e.effect })
120
+ ] }),
121
+ l && /* @__PURE__ */ r(p, { "aria-hidden": !0, className: "mt-0.5 h-3.5 w-3.5 text-nvr-cyan" })
122
+ ]
123
+ },
124
+ e.value
125
+ );
126
+ }) })
127
+ ]
128
+ }
129
+ )
130
+ ] });
131
+ }
132
+ function D({
133
+ kind: t,
134
+ parentName: a,
135
+ action: n,
136
+ actionLabel: c,
137
+ actionTip: i,
138
+ blocked: o = !1,
139
+ onAction: d
140
+ }) {
141
+ return /* @__PURE__ */ s("span", { className: "mt-0.5 flex items-center gap-1.5", "data-inherit": t, children: [
142
+ /* @__PURE__ */ r(
143
+ "span",
144
+ {
145
+ "data-tip": t === "inherited" ? `Comes from ${a}` : `Changed on this form; ${a} has its own`,
146
+ className: "inline-flex items-center rounded bg-slate-100 px-1 text-[11px] text-slate-600 dark:bg-slate-800 dark:text-slate-300",
147
+ children: t === "inherited" ? `from ${a}` : "overrides parent"
148
+ }
149
+ ),
150
+ /* @__PURE__ */ r(
151
+ "button",
152
+ {
153
+ type: "button",
154
+ "data-inherit-action": n,
155
+ "aria-label": c,
156
+ "data-tip": i,
157
+ "aria-disabled": o ? !0 : void 0,
158
+ onClick: () => {
159
+ o || d();
160
+ },
161
+ className: u(
162
+ "text-[11px] font-medium text-slate-500 underline-offset-2 dark:text-muted-foreground",
163
+ o ? "cursor-not-allowed opacity-50" : "hover:text-slate-900 hover:underline dark:hover:text-foreground"
164
+ ),
165
+ children: n === "reset" ? "Reset" : "Override"
166
+ }
167
+ )
168
+ ] });
169
+ }
170
+ export {
171
+ D as InheritChip,
172
+ L as MatrixCellButton,
173
+ B as MatrixMenu,
174
+ m as ToneIcon,
175
+ $ as matrixCellTd,
176
+ q as matrixCorner,
177
+ R as matrixRowHead,
178
+ z as matrixTh,
179
+ E as matrixZoneTd,
180
+ I as useCellMenu
181
+ };
@@ -0,0 +1,147 @@
1
+ import { jsxs as g, jsx as i } from "react/jsx-runtime";
2
+ import { useMemo as b } from "react";
3
+ import { cn as A, titleCase as L } from "../../../lib/utils.js";
4
+ import { Skeleton as O } from "../../ui/skeleton.js";
5
+ import { fieldZones as R } from "../field-zones.js";
6
+ import { resetGroupPlan as T } from "../inheritance.js";
7
+ import { overrideGroupOps as _ } from "../inspector/model.js";
8
+ import { LoadError as M } from "../load-error.js";
9
+ import { useCellMenu as F, MatrixMenu as I, matrixCorner as P, matrixTh as j, matrixRowHead as B, InheritChip as G, matrixCellTd as K, MatrixCellButton as z } from "./MatrixGrid.js";
10
+ import { useMatrixRoles as D } from "./matrix-api.js";
11
+ import { roleAccess as $, ACCESS_LABEL as w, roleAccessOps as H, roleAccessLabel as U, ROLE_ACCESS as W, ROLE_SECTION_TYPES as Y } from "./role-matrix.js";
12
+ const v = {
13
+ edit: "normal",
14
+ readonly: "readonly",
15
+ hidden: "hidden"
16
+ }, C = {
17
+ edit: "Sees the section; their field permissions decide the rest",
18
+ readonly: "Sees it but cannot change it; the server drops their writes",
19
+ hidden: "Does not see the section at all"
20
+ };
21
+ function Z(r, o) {
22
+ const m = new Set((o == null ? void 0 : o.groups.map((l) => l.key)) ?? []), y = [], u = (l, h) => {
23
+ for (const k of R(l)) {
24
+ if (k.key == null) continue;
25
+ const c = l.groups.find((f) => f.key === k.key);
26
+ if (!c || !Y.has(c.type)) continue;
27
+ const p = h(c);
28
+ p && y.push({ group: c, label: k.label, source: p });
29
+ }
30
+ };
31
+ if (u(r, (l) => m.has(l.key) ? "override" : "own"), o) {
32
+ const l = new Set(r.groups.map((h) => h.key));
33
+ u(o, (h) => l.has(h.key) ? null : "inherited");
34
+ }
35
+ return y;
36
+ }
37
+ function le({ bundle: r, parent: o, apply: m, onSelect: y }) {
38
+ const { data: u = [], isLoading: l, isError: h, refetch: k } = D(), c = F(), p = b(() => Z(r, o), [r, o]), f = String((o == null ? void 0 : o.layout.name) ?? "the parent layout"), x = (e) => e.label || L(e.key), n = b(() => {
39
+ if (!c.open) return null;
40
+ const [e, a] = c.open.split("|"), t = p.find((d) => d.group.key === e && d.source !== "inherited"), s = u.find((d) => d.id === a);
41
+ return t && s ? { row: t, role: s } : null;
42
+ }, [c.open, p, u]), S = W.map((e) => ({
43
+ value: e,
44
+ label: w[e],
45
+ tone: v[e],
46
+ effect: C[e],
47
+ blocked: null
48
+ })), N = (e) => {
49
+ if (!n) return;
50
+ const a = H(n.row.group, n.role.id, e);
51
+ a.length && m(a, { label: U(x(n.row.group), n.role.name, e) });
52
+ };
53
+ return /* @__PURE__ */ g("div", { "data-role-section-matrix": "", className: "flex min-h-full flex-col gap-2 p-4", children: [
54
+ /* @__PURE__ */ i("p", { className: "m-0 text-[12px] text-slate-500 dark:text-muted-foreground", children: "Who sees and edits each section. Field permissions still apply inside a section; administrators always see and edit everything." }),
55
+ l ? /* @__PURE__ */ i(O, { className: "h-48 w-full rounded-lg" }) : h ? /* @__PURE__ */ i(M, { what: "the roles", onRetry: () => void k() }) : /* @__PURE__ */ i(
56
+ I,
57
+ {
58
+ menu: c,
59
+ title: n ? `${x(n.row.group)} · ${n.role.name}` : "",
60
+ choices: S,
61
+ current: n ? $(n.row.group, n.role.id) : null,
62
+ onPick: N,
63
+ children: /* @__PURE__ */ i("div", { className: "min-h-0 flex-1 overflow-auto rounded-lg border border-slate-200 bg-white dark:border-border dark:bg-card", children: /* @__PURE__ */ g("table", { className: "border-separate border-spacing-0 text-[12.5px]", children: [
64
+ /* @__PURE__ */ i("thead", { children: /* @__PURE__ */ g("tr", { children: [
65
+ /* @__PURE__ */ i("th", { className: P, children: "Section" }),
66
+ u.map((e) => /* @__PURE__ */ i(
67
+ "th",
68
+ {
69
+ "data-matrix-role": e.id,
70
+ className: A(j, "text-center"),
71
+ "data-tip": e.admin_access ? "Administrators see and edit every section" : void 0,
72
+ children: e.name
73
+ },
74
+ e.id
75
+ ))
76
+ ] }) }),
77
+ /* @__PURE__ */ g("tbody", { children: [
78
+ p.map((e) => {
79
+ const a = x(e.group), t = e.source === "override" && o ? T(r, o, e.group.key) : null;
80
+ return /* @__PURE__ */ g("tr", { "data-matrix-row": e.group.key, children: [
81
+ /* @__PURE__ */ g("th", { scope: "row", className: B, children: [
82
+ /* @__PURE__ */ i(
83
+ "button",
84
+ {
85
+ type: "button",
86
+ onClick: () => y({ kind: "group", key: e.group.key }),
87
+ "data-tip": "Select it on the form",
88
+ className: "block max-w-full truncate text-left font-medium text-slate-800 hover:underline dark:text-foreground",
89
+ children: e.label
90
+ }
91
+ ),
92
+ e.source !== "own" && o && /* @__PURE__ */ i(
93
+ G,
94
+ {
95
+ kind: e.source === "inherited" ? "inherited" : "override",
96
+ parentName: f,
97
+ action: e.source === "inherited" ? "override" : "reset",
98
+ actionLabel: e.source === "inherited" ? `Override ${a} on this form` : `Reset ${a} to ${f}`,
99
+ actionTip: e.source === "inherited" ? "Copy the section onto this form to change it here" : t != null && t.ok ? q(t.ungrouped.length, f) : (t == null ? void 0 : t.why) ?? "",
100
+ blocked: e.source === "override" && !(t != null && t.ok),
101
+ onAction: () => {
102
+ e.source === "inherited" ? m(_(r, o, e.group), {
103
+ label: `Override ${a} on this form`
104
+ }) : t != null && t.ok && m(t.ops, { label: `Reset ${a} to ${f}` });
105
+ }
106
+ }
107
+ )
108
+ ] }),
109
+ u.map((s) => {
110
+ const d = $(e.group, s.id), E = s.admin_access ? "Administrators see and edit every section" : e.source === "inherited" ? `From ${f} — override it to change it here` : null;
111
+ return /* @__PURE__ */ i("td", { className: K, children: /* @__PURE__ */ i(
112
+ z,
113
+ {
114
+ cellKey: `${e.group.key}|${s.id}`,
115
+ tone: s.admin_access ? "normal" : v[d],
116
+ word: s.admin_access ? "Can edit" : w[d],
117
+ tip: `${s.name}: ${C[d].toLowerCase()}`,
118
+ locked: E,
119
+ label: `${a} for ${s.name}: ${w[d]}`,
120
+ menu: c
121
+ }
122
+ ) }, s.id);
123
+ })
124
+ ] }, `${e.source}:${e.group.key}`);
125
+ }),
126
+ p.length === 0 && /* @__PURE__ */ i("tr", { children: /* @__PURE__ */ i(
127
+ "td",
128
+ {
129
+ colSpan: u.length + 1,
130
+ className: "px-3 py-6 text-center text-[12.5px] text-slate-500 dark:text-muted-foreground",
131
+ children: "No sections on this form. Fields outside sections follow field permissions only."
132
+ }
133
+ ) })
134
+ ] })
135
+ ] }) })
136
+ }
137
+ )
138
+ ] });
139
+ }
140
+ function q(r, o) {
141
+ const m = `Take ${o}'s section again`;
142
+ return r ? `${m}; ${r} ${r === 1 ? "field" : "fields"} only this form places move to Ungrouped` : m;
143
+ }
144
+ export {
145
+ le as RoleSectionMatrix,
146
+ Z as sectionRows
147
+ };
@@ -0,0 +1,48 @@
1
+ import { useQueryClient as o, useQuery as u } from "@tanstack/react-query";
2
+ import { useCallback as m } from "react";
3
+ import { useNivaroClient as s } from "../../../context.js";
4
+ import { patch as l, get as c } from "../../../lib/commands.js";
5
+ import { previewKeys as y } from "../preview/preview-api.js";
6
+ const p = {
7
+ roles: () => ["layout-editor", "matrix-roles"]
8
+ };
9
+ function C(t = !0) {
10
+ const r = s();
11
+ return u({
12
+ queryKey: p.roles(),
13
+ queryFn: () => r.request(
14
+ c("/roles")
15
+ ).then(
16
+ (e) => (Array.isArray(e == null ? void 0 : e.data) ? e.data : []).map((i) => ({
17
+ id: String(i.id),
18
+ name: String(i.name ?? i.id),
19
+ admin_access: !!i.admin_access
20
+ }))
21
+ ),
22
+ enabled: t,
23
+ staleTime: 5 * 6e4
24
+ });
25
+ }
26
+ function Q(t) {
27
+ const r = s(), e = o();
28
+ return m(
29
+ async (i, a = "after") => {
30
+ try {
31
+ for (const n of i)
32
+ await r.request(
33
+ l(`/pipelines/transitions/${encodeURIComponent(n.transitionId)}`, {
34
+ requirements: n[a]
35
+ })
36
+ );
37
+ } finally {
38
+ e.invalidateQueries({ queryKey: y.pipelines(t) }), e.invalidateQueries({ queryKey: ["pipeline-detail-lock"] });
39
+ }
40
+ },
41
+ [r, e, t]
42
+ );
43
+ }
44
+ export {
45
+ p as matrixKeys,
46
+ C as useMatrixRoles,
47
+ Q as useSaveRequirements
48
+ };