@nivaro/react 0.2.51 → 0.2.53

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 (117) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +207 -6
  4. package/dist/index.js +442 -439
  5. package/dist/layout-editor.d.ts +80 -0
  6. package/dist/layout-editor.js +11 -0
  7. package/dist/shared/components/ItemEditForm.js +4015 -3835
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +637 -570
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  12. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  13. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  14. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  15. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  16. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  17. package/dist/shared/components/item-edit/SummaryPanel.js +1 -1
  18. package/dist/shared/components/item-edit/config-update.js +6 -0
  19. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  20. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  21. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  22. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  23. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  24. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  25. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  26. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  27. package/dist/shared/components/layout-editor/add-target.js +103 -0
  28. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  29. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  30. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  31. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  32. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  33. package/dist/shared/components/layout-editor/design-context.js +21 -0
  34. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  35. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  36. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  37. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  38. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  39. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  40. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  41. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  42. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  43. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  44. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  45. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  46. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  47. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  48. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  49. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  50. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  51. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  52. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  53. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  54. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  55. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  56. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  57. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  58. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  59. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  60. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  61. package/dist/shared/components/layout-editor/host.js +15 -0
  62. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  63. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  64. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  65. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  66. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  67. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  68. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  69. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  70. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  71. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  72. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  73. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  74. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  75. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  76. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  77. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  78. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  79. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  80. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  81. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  82. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  83. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  84. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  85. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  86. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  87. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  88. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  89. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  90. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  91. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  92. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  93. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  94. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  95. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  96. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  97. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  98. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  99. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  100. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  101. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  102. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  103. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  104. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  105. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  106. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  107. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  108. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  109. package/dist/shared/components/pipeline/relations.js +28 -23
  110. package/dist/shared/components/ui/popover.js +17 -17
  111. package/dist/shared/components/ui/scroll-area.js +38 -0
  112. package/dist/shared/hooks/useRelationOptions.js +60 -0
  113. package/dist/shared/lib/layout-grants.js +9 -0
  114. package/dist/shared/lib/layout-ops.js +348 -0
  115. package/dist/shared/lib/layout-slots.js +11 -7
  116. package/dist/shared/lib/request-gate.js +1 -1
  117. package/package.json +5 -1
@@ -0,0 +1,268 @@
1
+ import { jsxs as p, jsx as e } from "react/jsx-runtime";
2
+ import { X as O } from "lucide-react";
3
+ import { useState as x, useEffect as w } from "react";
4
+ import { cn as v } from "../../../lib/utils.js";
5
+ import { effectText as f, inputBase as L, tintCard as T } from "../panel-style.js";
6
+ import { useInspectorEnv as A, Setting as c, TextInput as N, Choice as _, Segmented as k, AddButton as E, Section as J, JsonInput as R } from "./kit.js";
7
+ import { bindingValue as h, withStaticBinding as H } from "./model.js";
8
+ const P = [
9
+ { value: "text", label: "Text" },
10
+ { value: "currency", label: "Currency ($)" },
11
+ { value: "integer", label: "Whole number" },
12
+ { value: "decimal", label: "Decimal" },
13
+ { value: "percent", label: "Percent" },
14
+ { value: "date", label: "Date" },
15
+ { value: "datetime", label: "Date & time" }
16
+ ], C = [
17
+ { value: "", label: "Default" },
18
+ { value: "cyan", label: "Cyan" },
19
+ { value: "blue", label: "Blue" },
20
+ { value: "green", label: "Green" },
21
+ { value: "amber", label: "Amber" },
22
+ { value: "red", label: "Red" },
23
+ { value: "purple", label: "Purple" }
24
+ ], $ = [
25
+ { value: "", label: "Normal" },
26
+ { value: "medium", label: "Medium" },
27
+ { value: "semibold", label: "Semibold" },
28
+ { value: "bold", label: "Bold" }
29
+ ], D = [
30
+ { value: "", label: "Text" },
31
+ { value: "pill", label: "Pill" },
32
+ { value: "tag", label: "Tag" }
33
+ ], S = /* @__PURE__ */ new Set(["lt", "lte", "gt", "gte", "eq"]);
34
+ function I(t) {
35
+ if (!Array.isArray(t)) return 'Needs a list like [{ "op": "gt", "value": 0, "color": "red" }]';
36
+ for (const l of t) {
37
+ const o = l;
38
+ if (!o || !S.has(o.op ?? "") || o.value == null || !o.color)
39
+ return "Each needs op (lt, lte, gt, gte, eq), value and color";
40
+ }
41
+ return null;
42
+ }
43
+ const d = (t) => typeof t == "string" ? t : "", B = [
44
+ { value: "lt", label: "is below" },
45
+ { value: "lte", label: "is at most" },
46
+ { value: "gt", label: "is above" },
47
+ { value: "gte", label: "is at least" },
48
+ { value: "eq", label: "equals" }
49
+ ], g = (t) => Array.isArray(t) ? t.map((l) => {
50
+ const o = l ?? {};
51
+ return {
52
+ op: o.op ?? "gt",
53
+ value: o.value == null ? "" : String(o.value),
54
+ color: o.color ?? ""
55
+ };
56
+ }) : [], y = (t) => t.filter((l) => S.has(l.op) && l.value.trim() !== "" && l.color).map((l) => ({
57
+ op: l.op,
58
+ value: Number.isNaN(Number(l.value)) ? l.value : Number(l.value),
59
+ color: l.color
60
+ }));
61
+ function q({
62
+ value: t,
63
+ onChange: l
64
+ }) {
65
+ const o = JSON.stringify(y(g(t))), [u, s] = x(() => g(t));
66
+ w(() => {
67
+ s(
68
+ (r) => JSON.stringify(y(r)) === o ? r : g(JSON.parse(o))
69
+ );
70
+ }, [o]);
71
+ const m = (r) => {
72
+ s(r);
73
+ const n = y(r);
74
+ JSON.stringify(n) !== o && l(n.length ? n : null);
75
+ }, a = (r, n) => m(u.map((i, b) => b === r ? { ...i, ...n } : i));
76
+ return /* @__PURE__ */ p("div", { className: "space-y-2", children: [
77
+ u.length === 0 ? /* @__PURE__ */ e("p", { className: f, children: "No rules: the value keeps the colour above." }) : /* @__PURE__ */ e("ul", { className: "space-y-2", children: u.map((r, n) => (
78
+ // biome-ignore lint/suspicious/noArrayIndexKey: rules are positional
79
+ /* @__PURE__ */ p("li", { className: v(T, "space-y-1.5 p-2.5"), "data-threshold-row": "", children: [
80
+ /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5", children: [
81
+ /* @__PURE__ */ e("span", { className: v(f, "shrink-0"), children: "When it" }),
82
+ /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ e(
83
+ _,
84
+ {
85
+ ariaLabel: "Comparison",
86
+ value: r.op,
87
+ options: B,
88
+ onChange: (i) => a(n, { op: i })
89
+ }
90
+ ) }),
91
+ /* @__PURE__ */ e(
92
+ "button",
93
+ {
94
+ type: "button",
95
+ "aria-label": "Remove rule",
96
+ "data-tip": "Remove rule",
97
+ onClick: () => m(u.filter((i, b) => b !== n)),
98
+ className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
99
+ children: /* @__PURE__ */ e(O, { className: "h-3.5 w-3.5" })
100
+ }
101
+ )
102
+ ] }),
103
+ /* @__PURE__ */ p("div", { className: "flex items-center gap-1.5", children: [
104
+ /* @__PURE__ */ e(
105
+ "input",
106
+ {
107
+ "aria-label": "Value",
108
+ value: r.value,
109
+ placeholder: "0",
110
+ onChange: (i) => a(n, { value: i.target.value }),
111
+ className: v(L, "w-24 shrink-0")
112
+ }
113
+ ),
114
+ /* @__PURE__ */ e("span", { className: v(f, "shrink-0"), children: "show it" }),
115
+ /* @__PURE__ */ e("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ e(
116
+ _,
117
+ {
118
+ ariaLabel: "Colour",
119
+ value: r.color,
120
+ options: [{ value: "", label: "Pick a colour…" }, ...C.slice(1)],
121
+ onChange: (i) => a(n, { color: i })
122
+ }
123
+ ) })
124
+ ] })
125
+ ] }, n)
126
+ )) }),
127
+ /* @__PURE__ */ e(E, { onClick: () => s([...u, { op: "gt", value: "", color: "" }]), children: "+ Add a colour rule" }),
128
+ /* @__PURE__ */ e(J, { title: "Edit as JSON", collapsible: !0, className: "border-t-0 pt-1", children: /* @__PURE__ */ e(
129
+ R,
130
+ {
131
+ ariaLabel: "Colour by value as JSON",
132
+ rows: 3,
133
+ value: o === "[]" ? null : JSON.parse(o),
134
+ placeholder: '[{ "op": "gt", "value": 0, "color": "red" }]',
135
+ validate: I,
136
+ onCommit: (r) => l(Array.isArray(r) && r.length ? r : null)
137
+ }
138
+ ) })
139
+ ] });
140
+ }
141
+ function Y({ row: t, label: l }) {
142
+ const o = A(), u = { field: t.field, group_key: t.group_key }, s = (a, r, n, i) => o.apply(
143
+ [
144
+ {
145
+ op: "update_placement",
146
+ at: u,
147
+ patch: { input_bindings: H(t, a, r) }
148
+ }
149
+ ],
150
+ { label: n, text: i }
151
+ ), m = (() => {
152
+ const a = h(t, "__threshold__");
153
+ if (typeof a != "string") return a ?? null;
154
+ try {
155
+ return JSON.parse(a);
156
+ } catch {
157
+ return null;
158
+ }
159
+ })();
160
+ return /* @__PURE__ */ p("div", { className: "space-y-5", children: [
161
+ /* @__PURE__ */ e(c, { k: "header.label_override", label: "Label", effect: `Empty uses "${l}".`, children: /* @__PURE__ */ e(
162
+ N,
163
+ {
164
+ ariaLabel: "Label",
165
+ value: t.label_override ?? "",
166
+ placeholder: l,
167
+ onChange: (a) => o.apply([{ op: "update_placement", at: u, patch: { label_override: a || null } }], {
168
+ label: `Rename ${l} in the header`,
169
+ text: !0
170
+ })
171
+ }
172
+ ) }),
173
+ /* @__PURE__ */ e(
174
+ c,
175
+ {
176
+ k: "header.display_format",
177
+ label: "Format",
178
+ effect: "How the value is written in the header.",
179
+ children: /* @__PURE__ */ e(
180
+ _,
181
+ {
182
+ ariaLabel: "Format",
183
+ value: d(h(t, "__display_format__")) || "text",
184
+ options: P,
185
+ onChange: (a) => s("__display_format__", a === "text" ? null : a, `Change the format of ${l}`)
186
+ }
187
+ )
188
+ }
189
+ ),
190
+ /* @__PURE__ */ e(c, { k: "header.color", label: "Colour", effect: "The colour of the value in the header.", children: /* @__PURE__ */ e(
191
+ _,
192
+ {
193
+ ariaLabel: "Colour",
194
+ value: d(h(t, "__color__")),
195
+ options: C,
196
+ onChange: (a) => s("__color__", a || null, `Change the colour of ${l}`)
197
+ }
198
+ ) }),
199
+ /* @__PURE__ */ e(c, { k: "header.weight", label: "Weight", effect: "How bold the value is.", children: /* @__PURE__ */ e(
200
+ k,
201
+ {
202
+ value: d(h(t, "__weight__")),
203
+ options: $,
204
+ onChange: (a) => s("__weight__", a || null, `Change the weight of ${l}`)
205
+ }
206
+ ) }),
207
+ /* @__PURE__ */ e(
208
+ c,
209
+ {
210
+ k: "header.display_as",
211
+ label: "Shown as",
212
+ effect: "Plain text, a coloured pill or a tag.",
213
+ children: /* @__PURE__ */ e(
214
+ k,
215
+ {
216
+ value: d(h(t, "__display_as__")),
217
+ options: D,
218
+ onChange: (a) => s("__display_as__", a || null, `Change how ${l} shows`)
219
+ }
220
+ )
221
+ }
222
+ ),
223
+ /* @__PURE__ */ e(
224
+ c,
225
+ {
226
+ k: "header.link_template",
227
+ label: "Link",
228
+ effect: "Makes the value a link. {{value}} and any {{field}} are filled in.",
229
+ children: /* @__PURE__ */ e(
230
+ N,
231
+ {
232
+ ariaLabel: "Link",
233
+ mono: !0,
234
+ value: d(h(t, "__link_template__")),
235
+ placeholder: "https://…/{{value}}",
236
+ onChange: (a) => s("__link_template__", a || null, `Change the link of ${l}`, !0)
237
+ }
238
+ )
239
+ }
240
+ ),
241
+ /* @__PURE__ */ e(
242
+ c,
243
+ {
244
+ k: "header.threshold",
245
+ label: "Colour by value",
246
+ effect: "The first rule that matches picks the colour.",
247
+ children: /* @__PURE__ */ e(
248
+ q,
249
+ {
250
+ value: m,
251
+ onChange: (a) => s(
252
+ "__threshold__",
253
+ a == null ? null : JSON.stringify(a),
254
+ `Change the colours of ${l}`
255
+ )
256
+ }
257
+ )
258
+ }
259
+ )
260
+ ] });
261
+ }
262
+ export {
263
+ C as COLORS,
264
+ D as DISPLAY_AS,
265
+ P as HEADER_FORMATS,
266
+ Y as HeaderItemInspector,
267
+ $ as WEIGHTS
268
+ };
@@ -0,0 +1,332 @@
1
+ import { jsx as t, jsxs as d, Fragment as y } from "react/jsx-runtime";
2
+ import { MousePointerClick as V } from "lucide-react";
3
+ import { useMemo as J, useState as X, useId as q } from "react";
4
+ import { HEADER_GROUP_KEY as F, CANVAS_SLOT_KEYS as Q, UNGROUPED_KEY as Z } from "../../../lib/layout-ops.js";
5
+ import { cn as ee, titleCase as _ } from "../../../lib/utils.js";
6
+ import { TipLayer as te } from "../../TipLayer.js";
7
+ import { useLayoutDesign as ne, targetKey as le } from "../design-context.js";
8
+ import { PanelHeader as P, PanelBody as T, PanelTabs as re, tabId as ie, tabPanelId as oe } from "../panel-frame.js";
9
+ import { tintCard as de } from "../panel-style.js";
10
+ import { slotName as $ } from "../slot-names.js";
11
+ import { useLayoutBundle as ae } from "../useLayoutDraft.js";
12
+ import { AdvancedTab as se } from "./AdvancedTab.js";
13
+ import { useCollectionMeta as j, useGlobalWriter as ce, useFieldCtxValue as ue, FieldCtxContext as fe } from "./field-context.js";
14
+ import { GridTab as me } from "./GridTab.js";
15
+ import { GroupInspector as pe } from "./GroupInspector.js";
16
+ import { HeaderItemInspector as be } from "./HeaderItemInspector.js";
17
+ import { InspectorEnvContext as W, useInspectorEnv as K, ScopeLegend as G, GlobalWriterContext as he } from "./kit.js";
18
+ import { LookTab as ye } from "./LookTab.js";
19
+ import { isDefaultForm as ke, layoutTypeOf as _e, findPlacement as D, SUBTITLE_FIELD as O, overrideGroupOps as xe, overridePlacementOps as ge, describeField as U, asObject as H, NUMERIC_TYPES as ve } from "./model.js";
20
+ import { PickerTab as Ne } from "./PickerTab.js";
21
+ import { RulesTab as Pe } from "./RulesTab.js";
22
+ import { SlotInspector as Te } from "./SlotInspector.js";
23
+ import { SubtitleInspector as Ie } from "./SubtitleInspector.js";
24
+ import { WidgetInspector as Ee } from "./WidgetInspector.js";
25
+ const Se = /^__widget_\d+__$/, Le = /^__ext_[a-z][a-z0-9-]{1,60}__$/, Y = (e) => Q.includes(e) || e === "__owners__" || e === "__pdf__" || Le.test(e);
26
+ function z(e) {
27
+ switch (e.kind) {
28
+ case "field":
29
+ case "slot":
30
+ return { field: e.field, group_key: e.group_key };
31
+ case "header":
32
+ return {
33
+ field: e.field,
34
+ group_key: e.field === O ? null : F
35
+ };
36
+ default:
37
+ return null;
38
+ }
39
+ }
40
+ function ot(e) {
41
+ const { bundle: n, target: l, apply: o, collection: i } = e, a = ne(), c = J(
42
+ () => ({
43
+ bundle: n,
44
+ apply: o,
45
+ flush: e.flush ?? (() => {
46
+ }),
47
+ collection: i,
48
+ layoutType: _e(n.layout),
49
+ defaultForm: ke(n.layout)
50
+ }),
51
+ [n, o, e.flush, i]
52
+ ), r = l ? z(l) : null, p = r ? D(n, r.field, r.group_key) : null, x = (l == null ? void 0 : l.kind) === "group" ? n.groups.find((m) => m.key === l.key) ?? null : null, k = !!l && (l.kind === "group" ? !x : !p && !Y((r == null ? void 0 : r.field) ?? "") && (r == null ? void 0 : r.field) !== O), v = n.layout.parent_layout_id != null ? Number(n.layout.parent_layout_id) : null, N = e.inheritedFrom ?? (l ? (a == null ? void 0 : a.inheritedFrom(l)) ?? null : null), { data: s } = ae(v, k), b = k && s && r ? D(s, r.field, r.group_key) : null, u = k && s && (l == null ? void 0 : l.kind) === "group" ? s.groups.find((m) => m.key === l.key) ?? null : null, f = k && (!!b || !!u || !!N);
53
+ if (!l)
54
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ d("div", { className: "flex flex-1 flex-col items-center justify-center gap-2 px-8 pb-16 text-center", children: [
55
+ /* @__PURE__ */ t(V, { className: "h-5 w-5 text-slate-400" }),
56
+ /* @__PURE__ */ t("p", { className: "text-[13px] text-slate-500 dark:text-muted-foreground", children: "Select a field, section or panel on the form to change it." })
57
+ ] }) });
58
+ if (f) {
59
+ const m = s != null && s.layout.name ? String(s.layout.name) : N ?? "the parent form", I = { ...c, bundle: s ?? n, apply: () => {
60
+ } }, E = () => {
61
+ if (!s) return;
62
+ const h = u ? xe(n, s, u) : b ? ge(n, s, b) : [];
63
+ h.length && o(h, { label: `Override ${S(l)} on this form` });
64
+ }, g = /* @__PURE__ */ d("div", { "data-setting": "inspector.inherited_override", className: ee(de, "space-y-2.5 p-3"), children: [
65
+ /* @__PURE__ */ d("p", { className: "text-[12px] leading-snug text-slate-700 dark:text-foreground", children: [
66
+ "This comes from ",
67
+ /* @__PURE__ */ t("span", { className: "font-medium", children: m }),
68
+ ". Change it there for every form built on it, or override it on this form only."
69
+ ] }),
70
+ /* @__PURE__ */ d("div", { className: "flex flex-wrap gap-2", children: [
71
+ /* @__PURE__ */ t(
72
+ "button",
73
+ {
74
+ type: "button",
75
+ "data-override-here": "",
76
+ disabled: !s || !b && !u,
77
+ onClick: E,
78
+ className: "h-7 rounded-md bg-nvr-cyan px-2.5 text-[12px] font-medium text-white transition-colors hover:bg-[#00b8e0] disabled:opacity-40",
79
+ children: "Override here"
80
+ }
81
+ ),
82
+ v != null && e.openLayout && /* @__PURE__ */ d(
83
+ "button",
84
+ {
85
+ type: "button",
86
+ "data-edit-in-parent": "",
87
+ onClick: () => {
88
+ var h;
89
+ return (h = e.openLayout) == null ? void 0 : h.call(e, v);
90
+ },
91
+ className: "h-7 rounded-md border border-slate-200 bg-white px-2.5 text-[12px] font-medium text-slate-700 transition-colors hover:bg-slate-50 dark:border-border dark:bg-background dark:text-foreground dark:hover:bg-muted",
92
+ children: [
93
+ "Edit in ",
94
+ m
95
+ ]
96
+ }
97
+ )
98
+ ] })
99
+ ] });
100
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(W.Provider, { value: I, children: u ? /* @__PURE__ */ t(A, { group: u, notice: g, readOnly: !0 }) : b ? /* @__PURE__ */ t(B, { target: l, row: b, notice: g, readOnly: !0 }) : /* @__PURE__ */ d(y, { children: [
101
+ /* @__PURE__ */ t(P, { title: S(l) }),
102
+ /* @__PURE__ */ t(T, { children: g })
103
+ ] }) }) });
104
+ }
105
+ return /* @__PURE__ */ t(w, { children: /* @__PURE__ */ t(W.Provider, { value: c, children: l.kind === "group" ? x && /* @__PURE__ */ t(A, { group: x }, x.key) : k ? /* @__PURE__ */ d(y, { children: [
106
+ /* @__PURE__ */ t(P, { title: S(l) }),
107
+ /* @__PURE__ */ t(T, { children: /* @__PURE__ */ d("p", { className: "text-[13px] text-slate-500 dark:text-muted-foreground", children: [
108
+ S(l),
109
+ " is not on this form any more."
110
+ ] }) })
111
+ ] }) : /* @__PURE__ */ t(B, { target: l, row: p }, le(l)) }) });
112
+ }
113
+ function S(e) {
114
+ return e.kind === "group" ? _(e.key) : e.field.startsWith("__") ? $(e.field) : _(e.field.split(".").pop() ?? e.field);
115
+ }
116
+ function w({ children: e }) {
117
+ return /* @__PURE__ */ d("div", { "data-inspector": "", className: "flex h-full min-h-0 min-w-0 flex-col text-[12px]", children: [
118
+ /* @__PURE__ */ t(te, {}),
119
+ e
120
+ ] });
121
+ }
122
+ function Ce(e, n) {
123
+ if (!n || n === Z) return null;
124
+ if (n === F) return "Header strip";
125
+ const l = e.groups.find((o) => o.key === n);
126
+ return l ? l.label || _(l.key) : _(n);
127
+ }
128
+ const C = (e, n) => n ? `${e} · ${n}` : e;
129
+ function Ke(e) {
130
+ if (e.isPath) return "shows a linked value";
131
+ if (e.computedType) return "calculated";
132
+ if (e.relKind === "M2O") return "picks one record";
133
+ if (e.relKind === "M2M") return "picks several records";
134
+ if (e.relKind === "O2M")
135
+ return e.iface === "inline-table" ? "table of related rows" : "related rows";
136
+ if (e.relKind) return "related records";
137
+ if (ve.has(e.type)) return "number";
138
+ switch (e.type) {
139
+ case "boolean":
140
+ return "yes or no";
141
+ case "date":
142
+ return "date";
143
+ case "datetime":
144
+ case "timestamp":
145
+ return "date and time";
146
+ case "time":
147
+ return "time";
148
+ case "json":
149
+ return "JSON";
150
+ case "text":
151
+ return "long text";
152
+ case "uuid":
153
+ return "ID";
154
+ case "string":
155
+ return "text";
156
+ default:
157
+ return e.type;
158
+ }
159
+ }
160
+ function R({ words: e, k: n, setting: l }) {
161
+ return /* @__PURE__ */ d("span", { "data-setting": l, children: [
162
+ e && /* @__PURE__ */ d(y, { children: [
163
+ e,
164
+ " · "
165
+ ] }),
166
+ /* @__PURE__ */ t("span", { className: "font-mono text-[11px]", children: n })
167
+ ] });
168
+ }
169
+ function Me(e, n) {
170
+ const l = n.parent_key ? e.groups.find((i) => i.key === n.parent_key) ?? null : null, o = n.type === "tab" ? (l == null ? void 0 : l.tab_mode) === "steps" ? "Step" : "Tab" : n.type === "container" ? n.tab_mode === "steps" ? "Steps holder" : "Tabs holder" : n.type === "content" ? "Text block" : n.type === "metadata" ? "Record info" : "Section";
171
+ return C(o, l ? l.label || _(l.key) : null);
172
+ }
173
+ function A({
174
+ group: e,
175
+ notice: n,
176
+ readOnly: l = !1
177
+ }) {
178
+ const o = K(), i = /* @__PURE__ */ t(pe, { group: e, readOnly: l });
179
+ return /* @__PURE__ */ d(y, { children: [
180
+ /* @__PURE__ */ t(
181
+ P,
182
+ {
183
+ eyebrow: Me(o.bundle, e),
184
+ title: e.label || _(e.key),
185
+ sub: /* @__PURE__ */ t(R, { k: e.key, setting: "group.key" })
186
+ }
187
+ ),
188
+ /* @__PURE__ */ d(T, { children: [
189
+ n,
190
+ l ? (
191
+ // Inputs sit in a disabled fieldset and writes go nowhere.
192
+ /* @__PURE__ */ t("div", { "data-inherited-view": "", className: "opacity-70", children: i })
193
+ ) : /* @__PURE__ */ d(y, { children: [
194
+ /* @__PURE__ */ t(G, {}),
195
+ i
196
+ ] })
197
+ ] })
198
+ ] });
199
+ }
200
+ function L({
201
+ eyebrow: e,
202
+ title: n,
203
+ sub: l,
204
+ notice: o,
205
+ readOnly: i,
206
+ children: a
207
+ }) {
208
+ return /* @__PURE__ */ d(y, { children: [
209
+ /* @__PURE__ */ t(P, { eyebrow: e, title: n, sub: l }),
210
+ /* @__PURE__ */ d(T, { children: [
211
+ o,
212
+ i ? /* @__PURE__ */ t("div", { "data-inherited-view": "", className: "opacity-70", children: /* @__PURE__ */ t("fieldset", { disabled: !0, className: "min-w-0", children: a }) }) : /* @__PURE__ */ d(y, { children: [
213
+ /* @__PURE__ */ t(G, {}),
214
+ a
215
+ ] })
216
+ ] })
217
+ ] });
218
+ }
219
+ function B({
220
+ target: e,
221
+ row: n,
222
+ notice: l,
223
+ readOnly: o = !1
224
+ }) {
225
+ var p;
226
+ const i = K(), a = e.kind === "group" ? "" : e.field, c = (n == null ? void 0 : n.group_key) ?? (e.kind === "group" ? null : ((p = z(e)) == null ? void 0 : p.group_key) ?? null), r = Ce(i.bundle, c);
227
+ return a === O ? /* @__PURE__ */ t(L, { eyebrow: "Header", title: "Subtitle", notice: l, readOnly: o, children: /* @__PURE__ */ t(Ie, {}) }) : n && (Se.test(a) || n.widget_id != null) ? /* @__PURE__ */ t(
228
+ L,
229
+ {
230
+ eyebrow: C("Widget", r),
231
+ title: n.label_override || "Widget",
232
+ notice: l,
233
+ readOnly: o,
234
+ children: /* @__PURE__ */ t(Ee, { row: n })
235
+ }
236
+ ) : Y(a) ? /* @__PURE__ */ t(
237
+ L,
238
+ {
239
+ eyebrow: C("Panel", r),
240
+ title: $(a),
241
+ notice: l,
242
+ readOnly: o,
243
+ children: /* @__PURE__ */ t(Te, { field: a, groupKey: c, row: n })
244
+ }
245
+ ) : n ? e.kind === "header" || n.group_key === F ? /* @__PURE__ */ t(we, { row: n, notice: l, readOnly: o }) : /* @__PURE__ */ t(Ge, { row: n, where: r, notice: l, readOnly: o }) : null;
246
+ }
247
+ function we({
248
+ row: e,
249
+ notice: n,
250
+ readOnly: l
251
+ }) {
252
+ const o = K(), { data: i } = j(o.collection), a = U(e.field, (i == null ? void 0 : i.fields) ?? [], (i == null ? void 0 : i.relations) ?? [], null).label;
253
+ return /* @__PURE__ */ t(
254
+ L,
255
+ {
256
+ eyebrow: "Header strip",
257
+ title: e.label_override || a,
258
+ sub: /* @__PURE__ */ t(R, { k: e.field }),
259
+ notice: n,
260
+ readOnly: l,
261
+ children: /* @__PURE__ */ t(be, { row: e, label: a })
262
+ }
263
+ );
264
+ }
265
+ const Fe = { fields: [], relations: [], label: "" };
266
+ function Ge({
267
+ row: e,
268
+ where: n,
269
+ notice: l,
270
+ readOnly: o
271
+ }) {
272
+ var I, E, g, h;
273
+ const i = K(), { data: a } = j(i.collection), c = a ?? Fe, r = U(e.field, c.fields, c.relations, e), p = ce({
274
+ collection: i.collection,
275
+ collectionLabel: c.label || _(i.collection),
276
+ field: e.field,
277
+ fieldLabel: r.label,
278
+ stored: {
279
+ options: H((I = r.global) == null ? void 0 : I.options),
280
+ dependency_config: H((E = r.global) == null ? void 0 : E.dependency_config),
281
+ columns: {
282
+ deprecated: !!((g = r.global) != null && g.deprecated_at),
283
+ deprecation_note: ((h = r.global) == null ? void 0 : h.deprecation_note) || null
284
+ }
285
+ }
286
+ }), x = ue({ env: i, row: e, meta: c, writer: p, readOnly: o }), k = r.relKind === "M2O" || r.relKind === "M2M" || r.isPath || r.iface === "relation-path" || r.iface === "file-image" || r.iface === "files-m2m", v = r.relKind === "O2M" && (r.iface === "inline-grid" || r.iface === "inline-table"), N = [
287
+ { key: "look", label: "Look" },
288
+ { key: "rules", label: "Rules" },
289
+ ...k ? [{ key: "picker", label: "Picker" }] : [],
290
+ ...v ? [{ key: "grid", label: r.iface === "inline-table" ? "Table" : "Grid" }] : [],
291
+ { key: "advanced", label: "Advanced" }
292
+ ], [s, b] = X("look"), u = q(), f = N.some((M) => M.key === s) ? s : "look", m = /* @__PURE__ */ t("fieldset", { disabled: o, className: "min-w-0", children: a ? f === "look" ? /* @__PURE__ */ t(ye, {}) : f === "rules" ? /* @__PURE__ */ t(Pe, {}) : f === "picker" ? /* @__PURE__ */ t(Ne, {}) : f === "grid" ? /* @__PURE__ */ t(me, {}) : /* @__PURE__ */ t(se, {}) : /* @__PURE__ */ t("p", { className: "text-[13px] text-slate-500 dark:text-muted-foreground", children: "Loading the field…" }) });
293
+ return /* @__PURE__ */ t(fe.Provider, { value: x, children: /* @__PURE__ */ d(he.Provider, { value: p, children: [
294
+ /* @__PURE__ */ t(
295
+ P,
296
+ {
297
+ eyebrow: C("Field", n),
298
+ title: r.label,
299
+ sub: /* @__PURE__ */ t(R, { words: a ? Ke(r) : void 0, k: e.field }),
300
+ children: /* @__PURE__ */ t(
301
+ re,
302
+ {
303
+ idBase: u,
304
+ label: `Settings of ${r.label}`,
305
+ tabs: N,
306
+ active: f,
307
+ onChange: (M) => {
308
+ i.flush(), b(M);
309
+ }
310
+ }
311
+ )
312
+ }
313
+ ),
314
+ /* @__PURE__ */ d(
315
+ T,
316
+ {
317
+ tabpanel: { id: oe(u), labelledBy: ie(u, f) },
318
+ children: [
319
+ l,
320
+ o ? /* @__PURE__ */ t("div", { "data-inherited-view": "", className: "opacity-70", children: m }) : /* @__PURE__ */ d(y, { children: [
321
+ /* @__PURE__ */ t(G, { field: !0 }),
322
+ m
323
+ ] })
324
+ ]
325
+ },
326
+ f
327
+ )
328
+ ] }) });
329
+ }
330
+ export {
331
+ ot as Inspector
332
+ };