@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,767 @@
1
+ import { jsxs as u, jsx as t, Fragment as K } from "react/jsx-runtime";
2
+ import { useQueries as Ee } from "@tanstack/react-query";
3
+ import { ChevronUp as Le, ChevronDown as Te } from "lucide-react";
4
+ import { useMemo as x, useState as ne, useEffect as ie } from "react";
5
+ import { useNivaroClient as Me } from "../../../context.js";
6
+ import { get as De } from "../../../lib/commands.js";
7
+ import { titleCase as C } from "../../../lib/utils.js";
8
+ import { CascadeRuleRow as Ie } from "../editors/cascade-rule-row.js";
9
+ import { PRESET_NON_DISPLAY_TYPES as ae, isM2MIfacePreset as Ge, PRESET_SENTINEL_FIELDS as re, PRESET_SPECIAL_GROUP_KEYS as qe, ColumnPresetRow as Be, DrawerRelationRow as Je } from "../editors/grid-presets.js";
10
+ import { LayoutPicker as Ue } from "../editors/layout-picker.js";
11
+ import { RowRuleLint as Ye, RowRuleTester as Ke } from "../editors/row-rule-check.js";
12
+ import { ROW_RULE_SKIP_TYPES as ze, NUMERIC_FIELD_TYPES as je, RowRuleRow as We, reorder as E } from "../editors/row-rule-row.js";
13
+ import { useFieldCtx as He } from "./field-context.js";
14
+ import { useGlobalValue as z, Setting as h, Toggle as w, Section as v, Buffered as se, AddButton as L, FieldMultiPicker as de, Choice as ce, Segmented as Qe, TextInput as Ve, JsonInput as Xe } from "./kit.js";
15
+ import { relKindOf as Ze, asArray as $ } from "./model.js";
16
+ import { useRelationsFor as fe } from "./PickerTab.js";
17
+ import { useFieldRows as j } from "./RulesTab.js";
18
+ const b = (l) => !!l && typeof l == "object" && !Array.isArray(l), ue = /* @__PURE__ */ new Set(["alias", "o2m", "m2m", "m2a", "presentation", "group", "divider"]), he = /* @__PURE__ */ new Set(["inline-table", "inline-grid", "list-o2m", "relation-list"]), eo = [
19
+ {
20
+ key: "catalog_mode",
21
+ label: "Catalog picker",
22
+ effect: "Replaces the grid with the full catalog of item_field’s records under sections by section_by; a quantity creates the row.",
23
+ placeholder: '{ "item_field": "item", "section_by": "categories.name" }',
24
+ check: (l) => b(l) && l.item_field && l.section_by ? null : "Needs item_field and section_by"
25
+ },
26
+ {
27
+ key: "row_match_panel",
28
+ label: "Row match panel",
29
+ effect: "In the row editor, shows the record this row is matched to, or which key disagrees.",
30
+ placeholder: '{ "relation": "po_line_items", "columns": [{ "path": "number", "label": "PO #" }] }',
31
+ check: (l) => b(l) && l.relation && Array.isArray(l.columns) ? null : "Needs relation and columns[]"
32
+ },
33
+ {
34
+ key: "header_summary",
35
+ label: "Header figure",
36
+ effect: "A number over these rows shown in the record header; the formula runs per row.",
37
+ placeholder: '{ "label": "Unallocated", "formula": "item.amount - item.allocated_total" }',
38
+ check: (l) => b(l) && l.label && l.formula ? null : "Needs label and formula"
39
+ },
40
+ {
41
+ key: "line_sla",
42
+ label: "Line SLA",
43
+ effect: "Rows still missing a field N days after a state get a clock and a daily notice. Off until enabled is true.",
44
+ placeholder: '{ "enabled": false, "field": "requisition_id", "days": 5 }',
45
+ enforced: !0,
46
+ check: (l) => b(l) && l.field && typeof l.days == "number" ? null : "Needs field and a number of days"
47
+ },
48
+ {
49
+ key: "row_lints",
50
+ label: "Row checks",
51
+ effect: "When the first condition holds the second must too; failing rows get a marker.",
52
+ placeholder: '[{ "label": "…", "when": { "field": "a", "value": "1" }, "expect": { "field": "b", "op": "nnull" } }]',
53
+ enforced: !0,
54
+ check: (l) => Array.isArray(l) && l.length ? null : "Needs a list of checks"
55
+ },
56
+ {
57
+ key: "stats",
58
+ label: "Figure strip",
59
+ effect: "Figures above the grid. Tokens: {{$parent.field}}, {{$sum.column}}, {{$count}}.",
60
+ placeholder: '[{ "label": "Left", "value": "{{$parent.amount}} - {{$sum.total}}" }]',
61
+ check: (l) => Array.isArray(l) && l.length ? null : "Needs a list of figures"
62
+ },
63
+ {
64
+ key: "sum_cap",
65
+ label: "Sum cap",
66
+ effect: "A row cannot be saved when the column total would pass the cap (browser side).",
67
+ placeholder: '{ "field": "total", "cap": "{{$parent.amount}}" }',
68
+ rows: 3,
69
+ check: (l) => b(l) && l.field && l.cap != null ? null : "Needs field and cap"
70
+ },
71
+ {
72
+ key: "spread_remaining",
73
+ label: "Spread remaining",
74
+ effect: "A row-editor button that spreads the remaining amount over empty fields.",
75
+ placeholder: '{ "fields": ["january", "february"], "remaining": "{{$parent.amount}} - {{$sum.total}}" }',
76
+ rows: 3,
77
+ check: (l) => b(l) && Array.isArray(l.fields) && l.remaining ? null : "Needs fields[] and remaining"
78
+ },
79
+ {
80
+ key: "compare_series",
81
+ label: "Comparison series",
82
+ effect: "A read-only second line of figures under the cells, from an endpoint.",
83
+ placeholder: '{ "endpoint": "/my-extension/actuals/{{$parent.id}}", "label": "Actual" }',
84
+ rows: 3,
85
+ check: (l) => b(l) && typeof l.endpoint == "string" && l.endpoint ? null : "Needs endpoint"
86
+ },
87
+ {
88
+ key: "row_split",
89
+ label: "Plan grid",
90
+ effect: "Shows rows as a key × period plan grid with split and merge.",
91
+ placeholder: '{ "key_field": "year", "category_field": "category", "value_fields": ["january"] }',
92
+ check: (l) => b(l) && l.key_field && l.category_field && Array.isArray(l.value_fields) ? null : "Needs key_field, category_field and value_fields[]"
93
+ }
94
+ ];
95
+ function me(l) {
96
+ return l.map(
97
+ (s, y) => {
98
+ var d, A;
99
+ return typeof s == "string" ? { field: s, sumField: "", capField: "", _key: `d${y}` } : {
100
+ field: String((s == null ? void 0 : s.field) ?? ""),
101
+ sumField: String(((d = s == null ? void 0 : s.hint) == null ? void 0 : d.sum_field) ?? ""),
102
+ capField: String(((A = s == null ? void 0 : s.hint) == null ? void 0 : A.cap_field) ?? ""),
103
+ _key: `d${y}`
104
+ };
105
+ }
106
+ );
107
+ }
108
+ function pe(l) {
109
+ return l.filter((s) => s.field).map(
110
+ (s) => s.sumField && s.capField ? { field: s.field, hint: { sum_field: s.sumField, cap_field: s.capField } } : s.field
111
+ );
112
+ }
113
+ function go() {
114
+ var te;
115
+ const l = He(), s = Me(), { info: y, opts: d, env: A, row: T } = l, i = y.label, g = y.iface === "inline-table", m = y.relatedCollection, p = A.collection, { data: N = [] } = fe(m), { data: F = [] } = j(g ? m : null), { data: W = [] } = j(g ? p : null), { data: M = [] } = fe(g ? p : null), D = typeof d.layout_id == "number" ? d.layout_id : null, { data: _e = [] } = j(g ? m : null, D), we = N.filter((e) => e.many_collection === m && e.many_field && !e.junction_field).map((e) => ({ value: e.many_field, label: `${e.many_field} → ${e.one_collection}` })), ye = N.filter(
116
+ (e) => e.many_collection === m && e.many_field && e.one_collection && !e.junction_field
117
+ ).map((e) => ({
118
+ many_field: e.many_field,
119
+ one_collection: e.one_collection
120
+ })), H = N.filter((e) => e.one_collection === m && e.many_collection && !e.junction_field).map((e) => ({
121
+ one_field: !e.one_field || e.one_field === "id" ? e.many_collection : e.one_field,
122
+ many_collection: e.many_collection
123
+ })), I = H.map((e) => ({
124
+ value: e.one_field,
125
+ label: `${e.one_field} → ${e.many_collection}`,
126
+ collection: e.many_collection
127
+ })), ge = x(() => {
128
+ const e = /* @__PURE__ */ new Set();
129
+ for (const o of l.relations)
130
+ o.many_collection === p && o.many_field && o.one_collection && !o.junction_field && e.add(o.many_field);
131
+ return [...e].filter((o) => Ze(o, l.relations) === "M2O").map((o) => {
132
+ var n;
133
+ return {
134
+ value: o,
135
+ label: ((n = l.globals.find((a) => a.field === o)) == null ? void 0 : n.label) || C(o)
136
+ };
137
+ });
138
+ }, [l.relations, l.globals, p]), be = x(() => {
139
+ const e = {};
140
+ for (const o of M)
141
+ if (o.many_collection === p && o.many_field && o.one_collection && !o.junction_field && (e[o.many_field] = o.one_collection), o.one_collection === p && o.junction_field && o.many_collection && o.one_field) {
142
+ const n = M.find(
143
+ (a) => a.many_collection === o.many_collection && a.many_field === o.junction_field && a.one_collection !== p
144
+ );
145
+ n != null && n.one_collection && (e[o.one_field] = n.one_collection);
146
+ }
147
+ return e;
148
+ }, [M, p]), ke = x(() => {
149
+ const e = /* @__PURE__ */ new Map();
150
+ for (const o of F) {
151
+ if (o.hidden || o.field === "id" || o.field.startsWith("__") || ze.has(o.type ?? "") || he.has(o.interface ?? "")) continue;
152
+ const n = e.get(o.field);
153
+ (!n || !n.label && o.label) && e.set(o.field, o);
154
+ }
155
+ return [...e.values()];
156
+ }, [F]), G = F.filter(
157
+ (e) => !e.hidden && e.field !== "id" && !ue.has(e.type ?? "")
158
+ ), Ce = G.filter((e) => je.has(e.type ?? "")), ve = $(d.parent_cascades), q = (e, o, n) => l.setOption("parent_cascades", e.length ? e : void 0, o, n), S = $(d.row_rules).map((e, o) => ({ r: e, i: o })).sort((e, o) => (e.r.sort ?? e.i) - (o.r.sort ?? o.i)).map(({ r: e }) => e), $e = (e, o, n) => l.setOption(
159
+ "row_rules",
160
+ e.length ? e.map((a, r) => ({ ...a, sort: r })) : void 0,
161
+ o,
162
+ n
163
+ ), B = $(d.parent_context_fields), Se = B.map((e) => {
164
+ var o;
165
+ return {
166
+ field: e,
167
+ label: ((o = W.find((n) => n.field === e)) == null ? void 0 : o.label) || e,
168
+ one_collection: be[e] ?? null
169
+ };
170
+ }), Q = $(d.unique_by), V = typeof d.sort_field == "string" ? d.sort_field : "", X = d.sort_dir === "desc" ? "desc" : "asc", J = typeof d.section_group_by == "string" ? d.section_group_by : "", [U, Z] = ne(J);
171
+ ie(() => {
172
+ Z((e) => e.trim() && !e.includes(".") ? e : J);
173
+ }, [J]);
174
+ const ee = $(d.drawer_relations), P = JSON.stringify(ee), [k, Y] = ne(() => me(ee));
175
+ ie(() => {
176
+ Y(
177
+ (e) => JSON.stringify(pe(e)) === P ? e : me(JSON.parse(P))
178
+ );
179
+ }, [P]);
180
+ const oe = (e, o) => {
181
+ Y(e);
182
+ const n = pe(e);
183
+ JSON.stringify(n) !== P && l.setOption("drawer_relations", n.length ? n : void 0, o);
184
+ }, R = l.globalOptions, Re = z("field.grid_show_totals", R.grid_show_totals === !0), Oe = x(
185
+ () => $(R.column_presets).map((e, o) => ({
186
+ name: e.name ?? "",
187
+ columns: Array.isArray(e.columns) ? e.columns : [],
188
+ _key: `p${o}`
189
+ })),
190
+ [R.column_presets]
191
+ ), _ = z("field.column_presets", Oe), Ae = z(
192
+ "field.default_preset",
193
+ typeof R.default_preset == "string" ? R.default_preset : ""
194
+ ), O = (e) => {
195
+ const o = e.filter((n) => n.name.trim() && n.columns.length).map((n) => ({ name: n.name.trim(), columns: n.columns }));
196
+ l.proposeGlobalOption(
197
+ "field.column_presets",
198
+ "column_presets",
199
+ o.length ? o : void 0,
200
+ `Change the column presets of ${i}`,
201
+ e
202
+ );
203
+ }, Ne = (te = N.find(
204
+ (e) => e.many_collection === m && e.one_collection === p && !e.junction_field && (e.one_field === y.field || (!e.one_field || e.one_field === "id") && e.many_collection === y.field)
205
+ )) == null ? void 0 : te.many_field, le = [
206
+ ...new Set(
207
+ k.map((e) => {
208
+ var o;
209
+ return (o = I.find((n) => n.value === e.field)) == null ? void 0 : o.collection;
210
+ }).filter((e) => !!e)
211
+ )
212
+ ], Fe = Ee({
213
+ queries: le.map((e) => ({
214
+ queryKey: ["layout-editor", "field-rows", e, null],
215
+ queryFn: () => s.request(De(`/field-config/${e}`)).then((o) => Array.isArray(o.data) ? o.data : []),
216
+ staleTime: 6e4
217
+ }))
218
+ }), Pe = [
219
+ {
220
+ options: _e.filter(
221
+ (e) => !e.hidden && (!ae.has(String(e.type ?? "")) || Ge(e.interface)) && e.field !== Ne && e.field !== "id" && (!D || e.layout_assigned === !0) && !re.has(e.field) && !qe.has(String(e.group_key ?? ""))
222
+ ).map((e) => ({ field: e.field, label: String(e.label || C(e.field)) }))
223
+ },
224
+ ...k.flatMap((e) => {
225
+ var r, f;
226
+ const o = (r = I.find((c) => c.value === e.field)) == null ? void 0 : r.collection, a = (o ? ((f = Fe[le.indexOf(o)]) == null ? void 0 : f.data) ?? [] : []).filter(
227
+ (c) => !c.hidden && !ae.has(c.type ?? "") && c.field !== "id" && !re.has(c.field)
228
+ ).map((c) => ({
229
+ field: `${e.field}.${c.field}`,
230
+ label: `${e.field} → ${c.label || C(c.field)}`
231
+ }));
232
+ return a.length ? [{ heading: e.field, options: a }] : [];
233
+ })
234
+ ];
235
+ return m ? /* @__PURE__ */ u("div", { className: "space-y-5", children: [
236
+ /* @__PURE__ */ t(
237
+ h,
238
+ {
239
+ k: "field.grid_layout",
240
+ label: "Rows use the layout",
241
+ effect: g ? "A table layout of the row collection." : "A form layout of the row collection.",
242
+ children: /* @__PURE__ */ t(
243
+ Ue,
244
+ {
245
+ collection: m,
246
+ value: D,
247
+ onChange: (e, o) => l.setOptions(
248
+ { layout_id: e ?? void 0, layout_slug: o ?? void 0 },
249
+ `Change the row layout of ${i}`
250
+ ),
251
+ layoutType: g ? "table" : "grouped"
252
+ }
253
+ )
254
+ }
255
+ ),
256
+ !g && /* @__PURE__ */ t(
257
+ w,
258
+ {
259
+ k: "field.grid_show_totals",
260
+ label: "Column totals",
261
+ scope: "field",
262
+ effect: "A totals row under number columns.",
263
+ checked: Re,
264
+ onChange: (e) => l.proposeGlobalOption(
265
+ "field.grid_show_totals",
266
+ "grid_show_totals",
267
+ e || void 0,
268
+ `Change the totals of ${i}`,
269
+ e
270
+ )
271
+ }
272
+ ),
273
+ g && /* @__PURE__ */ u(K, { children: [
274
+ /* @__PURE__ */ t(
275
+ w,
276
+ {
277
+ k: "field.save_mode",
278
+ label: "Save rows with the form",
279
+ effect: "Row edits wait for the record’s Save.",
280
+ checked: d.save_mode === "pending",
281
+ onChange: (e) => l.setOption(
282
+ "save_mode",
283
+ e ? "pending" : "immediate",
284
+ e ? `Save ${i} with the form` : `Save ${i} rows at once`
285
+ )
286
+ }
287
+ ),
288
+ /* @__PURE__ */ t(
289
+ w,
290
+ {
291
+ k: "field.show_line_numbers",
292
+ label: "Line numbers",
293
+ effect: "A number at the start of each row.",
294
+ checked: d.show_line_numbers === !0,
295
+ onChange: (e) => l.setOption(
296
+ "show_line_numbers",
297
+ e || void 0,
298
+ `Change the line numbers of ${i}`
299
+ )
300
+ }
301
+ ),
302
+ /* @__PURE__ */ t(
303
+ w,
304
+ {
305
+ k: "field.enable_reorder",
306
+ label: "Drag rows to reorder",
307
+ effect: "People drag rows to change their order.",
308
+ checked: d.enable_reorder !== !1,
309
+ onChange: (e) => l.setOption("enable_reorder", e, `Change row reordering of ${i}`)
310
+ }
311
+ ),
312
+ /* @__PURE__ */ t(
313
+ w,
314
+ {
315
+ k: "field.row_comments",
316
+ label: "Line comments",
317
+ effect: "Comment threads on single rows, rolled into the record’s notes.",
318
+ checked: d.row_comments === !0,
319
+ onChange: (e) => l.setOption("row_comments", e || void 0, `Change line comments of ${i}`)
320
+ }
321
+ ),
322
+ /* @__PURE__ */ t(
323
+ w,
324
+ {
325
+ k: "field.freeze_first_column",
326
+ label: "Freeze the first column",
327
+ effect: "The grid scrolls sideways with the first column pinned.",
328
+ checked: d.freeze_first_column === !0,
329
+ onChange: (e) => l.setOption(
330
+ "freeze_first_column",
331
+ e || void 0,
332
+ `Change the first column of ${i}`
333
+ )
334
+ }
335
+ ),
336
+ /* @__PURE__ */ t(
337
+ w,
338
+ {
339
+ k: "field.show_row_revisions",
340
+ label: "Row history",
341
+ effect: "Each row shows who changed what.",
342
+ checked: T.show_row_revisions,
343
+ onChange: (e) => l.setPlacement(
344
+ { show_row_revisions: e },
345
+ e ? `Show row history of ${i}` : `Hide row history of ${i}`
346
+ )
347
+ }
348
+ ),
349
+ T.show_row_revisions && /* @__PURE__ */ t(
350
+ w,
351
+ {
352
+ k: "field.allow_revision_restore",
353
+ label: "Allow restoring a row",
354
+ effect: "Row history offers putting a row back as it was.",
355
+ checked: T.allow_revision_restore !== !1,
356
+ onChange: (e) => l.setPlacement({ allow_revision_restore: e }, `Change row restore of ${i}`)
357
+ }
358
+ ),
359
+ /* @__PURE__ */ t(v, { title: "Cascade from the record", children: /* @__PURE__ */ t(
360
+ h,
361
+ {
362
+ k: "field.parent_cascades",
363
+ label: "Narrow row pickers by a field of this record",
364
+ effect: "Parent: a picker on this form. Row field: a picker on each row.",
365
+ children: /* @__PURE__ */ t(se, { value: ve, className: "space-y-1.5", children: (e, o) => /* @__PURE__ */ u(K, { children: [
366
+ e.map((n, a) => /* @__PURE__ */ t(
367
+ Ie,
368
+ {
369
+ rule: n,
370
+ parentFields: ge,
371
+ childFields: we,
372
+ onChange: (r) => q(
373
+ o(e.map((f, c) => c === a ? r : f)),
374
+ `Change a cascade of ${i}`,
375
+ !0
376
+ ),
377
+ onRemove: () => q(
378
+ o(e.filter((r, f) => f !== a)),
379
+ `Remove a cascade from ${i}`
380
+ )
381
+ },
382
+ a
383
+ )),
384
+ /* @__PURE__ */ t(
385
+ L,
386
+ {
387
+ onClick: () => q(
388
+ o([...e, { parent_field: "", child_field: "" }]),
389
+ `Add a cascade to ${i}`
390
+ ),
391
+ children: "+ Add cascade"
392
+ }
393
+ )
394
+ ] }) })
395
+ }
396
+ ) }),
397
+ /* @__PURE__ */ u(v, { title: "Row rules", children: [
398
+ /* @__PURE__ */ t(
399
+ h,
400
+ {
401
+ k: "field.row_rules",
402
+ label: "Fill row fields automatically",
403
+ effect: "Each rule watches a row field and sets another when its condition holds.",
404
+ enforced: !0,
405
+ children: /* @__PURE__ */ t(se, { value: S, className: "space-y-1.5", children: (e, o) => {
406
+ const n = (a, r, f) => $e(o(a), r, f);
407
+ return /* @__PURE__ */ u(K, { children: [
408
+ e.map((a, r) => (
409
+ // biome-ignore lint/suspicious/noArrayIndexKey: rules are positional
410
+ /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t("div", { className: "min-w-0", children: /* @__PURE__ */ t(
411
+ We,
412
+ {
413
+ leading: /* @__PURE__ */ u(
414
+ "span",
415
+ {
416
+ className: "-my-1 flex shrink-0 flex-col",
417
+ "data-setting": "field.row_rules.sort",
418
+ children: [
419
+ /* @__PURE__ */ t(
420
+ "button",
421
+ {
422
+ type: "button",
423
+ "aria-label": "Move rule up",
424
+ disabled: r === 0,
425
+ onClick: (f) => {
426
+ f.stopPropagation(), n(E(e, r, r - 1), `Move a rule of ${i} up`);
427
+ },
428
+ className: "rounded text-slate-500 hover:text-slate-900 disabled:opacity-30 dark:hover:text-foreground",
429
+ children: /* @__PURE__ */ t(Le, { className: "h-3.5 w-3.5" })
430
+ }
431
+ ),
432
+ /* @__PURE__ */ t(
433
+ "button",
434
+ {
435
+ type: "button",
436
+ "aria-label": "Move rule down",
437
+ disabled: r === e.length - 1,
438
+ onClick: (f) => {
439
+ f.stopPropagation(), n(E(e, r, r + 1), `Move a rule of ${i} down`);
440
+ },
441
+ className: "rounded text-slate-500 hover:text-slate-900 disabled:opacity-30 dark:hover:text-foreground",
442
+ children: /* @__PURE__ */ t(Te, { className: "h-3.5 w-3.5" })
443
+ }
444
+ )
445
+ ]
446
+ }
447
+ ),
448
+ rule: a,
449
+ childFields: ke,
450
+ m2oRels: ye,
451
+ o2mRels: H,
452
+ parentContextFields: Se,
453
+ onChange: (f) => n(
454
+ e.map((c, xe) => xe === r ? f : c),
455
+ `Change a rule of ${i}`,
456
+ !0
457
+ ),
458
+ onRemove: () => n(
459
+ e.filter((f, c) => c !== r),
460
+ `Remove a rule from ${i}`
461
+ )
462
+ }
463
+ ) }) }, r)
464
+ )),
465
+ /* @__PURE__ */ t(
466
+ L,
467
+ {
468
+ onClick: () => n(
469
+ [
470
+ ...e,
471
+ {
472
+ trigger_field: null,
473
+ trigger_op: "nnull",
474
+ target_field: "",
475
+ target_type: "relation_field"
476
+ }
477
+ ],
478
+ `Add a rule to ${i}`
479
+ ),
480
+ children: "+ Add rule"
481
+ }
482
+ )
483
+ ] });
484
+ } })
485
+ }
486
+ ),
487
+ S.length > 0 && /* @__PURE__ */ t("div", { "data-setting": "field.row_rules_lint", children: /* @__PURE__ */ t(
488
+ Ye,
489
+ {
490
+ rules: S,
491
+ childFieldNames: new Set(F.map((e) => e.field))
492
+ }
493
+ ) }),
494
+ S.length > 0 && /* @__PURE__ */ t("div", { "data-setting": "field.row_rules_tester", children: /* @__PURE__ */ t(
495
+ Ke,
496
+ {
497
+ childCollection: m,
498
+ parentCollection: p,
499
+ rowRules: S,
500
+ parentContextFields: B
501
+ }
502
+ ) }),
503
+ /* @__PURE__ */ t(
504
+ h,
505
+ {
506
+ k: "field.parent_context_fields",
507
+ label: "Record fields rules can read",
508
+ effect: "Available to rules as $parent.field.",
509
+ children: /* @__PURE__ */ t(
510
+ de,
511
+ {
512
+ ariaLabel: "Record fields rules can read",
513
+ value: B,
514
+ options: W.filter(
515
+ (e) => e.field !== "id" && !ue.has(e.type ?? "") && !he.has(e.interface ?? "")
516
+ ).map((e) => ({ value: e.field, label: e.label || C(e.field) })),
517
+ onChange: (e) => l.setOption(
518
+ "parent_context_fields",
519
+ e.length ? e : void 0,
520
+ `Change the record fields ${i} rules read`
521
+ )
522
+ }
523
+ )
524
+ }
525
+ )
526
+ ] }),
527
+ /* @__PURE__ */ u(v, { title: "Rows", children: [
528
+ /* @__PURE__ */ t(
529
+ h,
530
+ {
531
+ k: "field.unique_by",
532
+ label: "No two rows alike by",
533
+ effect: "Blocks a row that repeats these values.",
534
+ children: /* @__PURE__ */ t(
535
+ de,
536
+ {
537
+ ariaLabel: "No two rows alike by",
538
+ placeholder: "Not checked",
539
+ value: Q,
540
+ options: G.map((e) => ({
541
+ value: e.field,
542
+ label: e.label || C(e.field),
543
+ hint: e.type
544
+ })),
545
+ onChange: (e) => l.setOption(
546
+ "unique_by",
547
+ e.length ? e : void 0,
548
+ `Change duplicate rows of ${i}`
549
+ )
550
+ }
551
+ )
552
+ }
553
+ ),
554
+ Q.length > 0 && /* @__PURE__ */ t(
555
+ w,
556
+ {
557
+ k: "field.unique_by_enforce_on_write",
558
+ label: "Refuse duplicates on the server too",
559
+ effect: "Binds every writer of these rows: other forms, imports and the API.",
560
+ checked: d.enforce_on_write === !0,
561
+ onChange: (e) => l.setOption(
562
+ "enforce_on_write",
563
+ e || void 0,
564
+ `Change duplicate checks of ${i}`
565
+ )
566
+ }
567
+ ),
568
+ /* @__PURE__ */ t(
569
+ h,
570
+ {
571
+ k: "field.sort_field",
572
+ label: "Sort rows by",
573
+ effect: "The order rows show in. Empty keeps the stored order.",
574
+ children: /* @__PURE__ */ t(
575
+ ce,
576
+ {
577
+ ariaLabel: "Sort rows by",
578
+ value: V,
579
+ options: [
580
+ { value: "", label: "Their saved order" },
581
+ ...G.map((e) => ({
582
+ value: e.field,
583
+ label: e.label || C(e.field)
584
+ }))
585
+ ],
586
+ onChange: (e) => l.setOptions(
587
+ { sort_field: e || void 0, sort_dir: e ? X : void 0 },
588
+ `Sort ${i} rows`
589
+ )
590
+ }
591
+ )
592
+ }
593
+ ),
594
+ /* @__PURE__ */ t(h, { k: "field.sort_dir", label: "Direction", effect: "Smallest first or largest first.", children: /* @__PURE__ */ t(
595
+ Qe,
596
+ {
597
+ disabled: !V,
598
+ value: X,
599
+ options: [
600
+ { value: "asc", label: "Ascending" },
601
+ { value: "desc", label: "Descending" }
602
+ ],
603
+ onChange: (e) => l.setOption("sort_dir", e, `Sort ${i} rows ${e === "asc" ? "up" : "down"}`)
604
+ }
605
+ ) }),
606
+ /* @__PURE__ */ u(
607
+ h,
608
+ {
609
+ k: "field.section_group_by",
610
+ label: "Group rows into sections by",
611
+ effect: "A dotted path on the row, e.g. item.category.name. Empty: no sections.",
612
+ children: [
613
+ /* @__PURE__ */ t(
614
+ Ve,
615
+ {
616
+ ariaLabel: "Group rows into sections by",
617
+ mono: !0,
618
+ value: U,
619
+ placeholder: "item.category.name",
620
+ onChange: (e) => {
621
+ Z(e), (!e.trim() || e.includes(".")) && l.setOption(
622
+ "section_group_by",
623
+ e.trim() || void 0,
624
+ `Group ${i} rows`,
625
+ !0
626
+ );
627
+ }
628
+ }
629
+ ),
630
+ U.trim() && !U.includes(".") && /* @__PURE__ */ t("p", { className: "text-[11px] text-red-600 dark:text-red-400", children: "Use a dotted path — nothing saved" })
631
+ ]
632
+ }
633
+ )
634
+ ] }),
635
+ /* @__PURE__ */ u(v, { title: "Column presets", children: [
636
+ /* @__PURE__ */ t(
637
+ h,
638
+ {
639
+ k: "field.column_presets",
640
+ label: "Sets of columns people can switch between",
641
+ effect: "Each preset is a named set of columns people pick above the grid.",
642
+ scope: "field",
643
+ children: /* @__PURE__ */ u("div", { className: "space-y-1.5", children: [
644
+ _.map((e, o) => /* @__PURE__ */ t(
645
+ Be,
646
+ {
647
+ preset: e,
648
+ optionGroups: Pe,
649
+ onChange: (n) => O(_.map((a, r) => r === o ? n : a)),
650
+ onRemove: () => O(_.filter((n, a) => a !== o)),
651
+ onMoveUp: () => O(E(_, o, o - 1)),
652
+ onMoveDown: () => O(E(_, o, o + 1)),
653
+ isFirst: o === 0,
654
+ isLast: o === _.length - 1
655
+ },
656
+ e._key
657
+ )),
658
+ /* @__PURE__ */ t(
659
+ L,
660
+ {
661
+ onClick: () => O([
662
+ ..._,
663
+ { name: "", columns: [], _key: `n${_.length}-${Date.now()}` }
664
+ ]),
665
+ children: "+ Add preset"
666
+ }
667
+ )
668
+ ] })
669
+ }
670
+ ),
671
+ _.length >= 2 && /* @__PURE__ */ t(
672
+ h,
673
+ {
674
+ k: "field.default_preset",
675
+ label: "Opens with",
676
+ effect: "The set of columns the grid opens with.",
677
+ scope: "field",
678
+ children: /* @__PURE__ */ t(
679
+ ce,
680
+ {
681
+ ariaLabel: "Opens with",
682
+ value: Ae,
683
+ options: [
684
+ { value: "", label: "The first preset" },
685
+ { value: "__all__", label: "All columns" },
686
+ ..._.filter((e) => e.name.trim()).map((e) => ({ value: e.name.trim(), label: e.name.trim() }))
687
+ ],
688
+ onChange: (e) => l.proposeGlobalOption(
689
+ "field.default_preset",
690
+ "default_preset",
691
+ e || void 0,
692
+ `Change the opening columns of ${i}`,
693
+ e
694
+ )
695
+ }
696
+ )
697
+ }
698
+ )
699
+ ] }),
700
+ /* @__PURE__ */ t(v, { title: "Row drawer", children: /* @__PURE__ */ t(
701
+ h,
702
+ {
703
+ k: "field.drawer_relations",
704
+ label: "Related lists inside each row",
705
+ effect: "Shown when a row opens. Sum / cap: a hint comparing a total with a row figure (pick both).",
706
+ children: /* @__PURE__ */ u("div", { className: "space-y-1.5", children: [
707
+ k.map((e, o) => /* @__PURE__ */ t(
708
+ Je,
709
+ {
710
+ entry: e,
711
+ relationOptions: I,
712
+ capFieldOptions: Ce,
713
+ onChange: (n) => oe(
714
+ k.map((a, r) => r === o ? n : a),
715
+ `Change the drawer of ${i}`
716
+ ),
717
+ onRemove: () => oe(
718
+ k.filter((n, a) => a !== o),
719
+ `Change the drawer of ${i}`
720
+ )
721
+ },
722
+ e._key
723
+ )),
724
+ /* @__PURE__ */ t(
725
+ L,
726
+ {
727
+ onClick: () => Y([
728
+ ...k,
729
+ { field: "", sumField: "", capField: "", _key: `n${Date.now()}` }
730
+ ]),
731
+ children: "+ Add relation"
732
+ }
733
+ )
734
+ ] })
735
+ }
736
+ ) }),
737
+ /* @__PURE__ */ t(v, { title: "More grid features (JSON)", collapsible: !0, children: eo.map((e) => /* @__PURE__ */ t(
738
+ h,
739
+ {
740
+ k: `field.${e.key}`,
741
+ label: e.label,
742
+ effect: e.effect,
743
+ enforced: e.enforced,
744
+ children: /* @__PURE__ */ t(
745
+ Xe,
746
+ {
747
+ ariaLabel: e.label,
748
+ value: d[e.key],
749
+ rows: e.rows,
750
+ placeholder: e.placeholder,
751
+ validate: e.check,
752
+ onCommit: (o) => l.setOption(e.key, o, `Change the ${e.label.toLowerCase()} of ${i}`)
753
+ }
754
+ )
755
+ },
756
+ e.key
757
+ )) })
758
+ ] })
759
+ ] }) : /* @__PURE__ */ u("p", { className: "text-[12px] text-muted-foreground", children: [
760
+ "No related collection found for ",
761
+ i,
762
+ "."
763
+ ] });
764
+ }
765
+ export {
766
+ go as GridTab
767
+ };