@nivaro/react 0.2.50 → 0.2.52

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 (121) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +1 -1
  3. package/dist/index.d.ts +204 -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 +4117 -3882
  8. package/dist/shared/components/RecordDrilldownSheet.js +114 -97
  9. package/dist/shared/components/RecordReadView.js +662 -596
  10. package/dist/shared/components/ai/ExplainButton.js +1 -1
  11. package/dist/shared/components/chat/ChatPanel.js +1053 -993
  12. package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
  13. package/dist/shared/components/item-edit/GroupSection.js +489 -466
  14. package/dist/shared/components/item-edit/HeaderBand.js +47 -44
  15. package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
  16. package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
  17. package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
  18. package/dist/shared/components/item-edit/StepsBar.js +49 -43
  19. package/dist/shared/components/item-edit/SummaryPanel.js +2 -1
  20. package/dist/shared/components/item-edit/config-update.js +6 -0
  21. package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
  22. package/dist/shared/components/layout-editor/AddPanel.js +301 -0
  23. package/dist/shared/components/layout-editor/DesignNode.js +173 -0
  24. package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
  25. package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
  26. package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
  27. package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
  28. package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
  29. package/dist/shared/components/layout-editor/add-target.js +103 -0
  30. package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
  31. package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
  32. package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
  33. package/dist/shared/components/layout-editor/collection-meta.js +22 -0
  34. package/dist/shared/components/layout-editor/design-canvas.js +81 -0
  35. package/dist/shared/components/layout-editor/design-context.js +21 -0
  36. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
  37. package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
  38. package/dist/shared/components/layout-editor/dnd/node.js +164 -0
  39. package/dist/shared/components/layout-editor/dnd/order.js +122 -0
  40. package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
  41. package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
  42. package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
  43. package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
  44. package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
  45. package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
  46. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
  47. package/dist/shared/components/layout-editor/editors/controls.js +73 -0
  48. package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
  49. package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
  50. package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
  51. package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
  52. package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
  53. package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
  54. package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
  55. package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
  56. package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
  57. package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
  58. package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
  59. package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
  60. package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
  61. package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
  62. package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
  63. package/dist/shared/components/layout-editor/host.js +15 -0
  64. package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
  65. package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
  66. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
  67. package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
  68. package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
  69. package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
  70. package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
  71. package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
  72. package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
  73. package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
  74. package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
  75. package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
  76. package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
  77. package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
  78. package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
  79. package/dist/shared/components/layout-editor/inspector/model.js +307 -0
  80. package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
  81. package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
  82. package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
  83. package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
  84. package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
  85. package/dist/shared/components/layout-editor/panel-frame.js +99 -0
  86. package/dist/shared/components/layout-editor/panel-style.js +19 -0
  87. package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
  88. package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
  89. package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
  90. package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
  91. package/dist/shared/components/layout-editor/record-queries.js +15 -0
  92. package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
  93. package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
  94. package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
  95. package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
  96. package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
  97. package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
  98. package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
  99. package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
  100. package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
  101. package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
  102. package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
  103. package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
  104. package/dist/shared/components/layout-editor/settings/controls.js +214 -0
  105. package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
  106. package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
  107. package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
  108. package/dist/shared/components/layout-editor/slot-names.js +20 -0
  109. package/dist/shared/components/layout-editor/summary-pref.js +21 -0
  110. package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
  111. package/dist/shared/components/pipeline/relations.js +28 -23
  112. package/dist/shared/components/ui/dialog.js +11 -11
  113. package/dist/shared/components/ui/popover.js +17 -17
  114. package/dist/shared/components/ui/scroll-area.js +38 -0
  115. package/dist/shared/hooks/useRelationOptions.js +60 -0
  116. package/dist/shared/lib/layout-grants.js +9 -0
  117. package/dist/shared/lib/layout-ops.js +348 -0
  118. package/dist/shared/lib/layout-slots.js +11 -7
  119. package/dist/shared/lib/presence-state.js +43 -13
  120. package/dist/shared/lib/request-gate.js +1 -1
  121. package/package.json +5 -1
@@ -0,0 +1,262 @@
1
+ import { jsxs as d, jsx as n } from "react/jsx-runtime";
2
+ import { useQuery as q, useQueryClient as T } from "@tanstack/react-query";
3
+ import { useState as b } from "react";
4
+ import { toast as I } from "sonner";
5
+ import { useNivaroClient as $ } from "../../../context.js";
6
+ import { get as F, patch as W } from "../../../lib/commands.js";
7
+ import { ReportWidgetConfigSection as j } from "../editors/report-widget-config.js";
8
+ import { FieldPicker as w } from "../pickers/field-picker.js";
9
+ import { parseSaveFailure as K } from "../useLayoutDraft.js";
10
+ import { useCollectionMeta as P } from "./field-context.js";
11
+ import { useInspectorEnv as E, Setting as N, TextInput as R, Segmented as Q, Section as L } from "./kit.js";
12
+ import { bindingsOf as A } from "./model.js";
13
+ function B(t = !0) {
14
+ const r = $();
15
+ return q({
16
+ queryKey: ["layout-editor", "widgets"],
17
+ queryFn: () => r.request(F("/widgets-internal")).then((s) => Array.isArray(s.data) ? s.data : []),
18
+ enabled: t,
19
+ staleTime: 6e4
20
+ });
21
+ }
22
+ function S(t) {
23
+ var l;
24
+ const r = ((t == null ? void 0 : t.inputs) ?? []).filter((e) => e == null ? void 0 : e.key);
25
+ if (r.length) return r.map((e) => ({ key: e.key, label: e.label || e.key }));
26
+ if (["review_list", "rollup"].includes((t == null ? void 0 : t.widget_type) ?? ""))
27
+ return [{ key: "record_id", label: "Record" }];
28
+ if ((t == null ? void 0 : t.widget_type) === "report_widget")
29
+ return [{ key: "entity_filter_value", label: "Filter value" }];
30
+ const s = ((l = t == null ? void 0 : t.config) == null ? void 0 : l.param_bindings) ?? [];
31
+ return [...new Set(s.map((e) => e.input_key).filter((e) => !!e))].map((e) => ({
32
+ key: e,
33
+ label: e
34
+ }));
35
+ }
36
+ function te({ row: t }) {
37
+ const r = E(), { data: s = [] } = B(), { data: l } = P(r.collection), e = s.find((a) => a.id === t.widget_id), m = t.label_override || (e == null ? void 0 : e.name) || "Widget", p = { field: t.field, group_key: t.group_key }, u = A(t), [y, v] = b(!1), [x, g] = b(null), [f, k] = b(0), o = (a, c, h) => {
38
+ const _ = u.find((C) => C.key === a) ?? {
39
+ key: a,
40
+ binding_type: "item_field",
41
+ binding_value: ""
42
+ }, i = [...u.filter((C) => C.key !== a), { ..._, ...c }];
43
+ r.apply([{ op: "update_placement", at: p, patch: { input_bindings: i } }], {
44
+ label: `Change what ${m} shows`,
45
+ text: h
46
+ });
47
+ };
48
+ return /* @__PURE__ */ d("div", { className: "space-y-5", children: [
49
+ /* @__PURE__ */ n(
50
+ N,
51
+ {
52
+ k: "widget.label_override",
53
+ label: "Title",
54
+ effect: e ? `Empty uses "${e.name}".` : "Empty uses the widget's own name.",
55
+ children: /* @__PURE__ */ n(
56
+ R,
57
+ {
58
+ ariaLabel: "Title",
59
+ value: t.label_override ?? "",
60
+ placeholder: e == null ? void 0 : e.name,
61
+ onChange: (a) => r.apply([{ op: "update_placement", at: p, patch: { label_override: a || null } }], {
62
+ label: `Rename ${m}`,
63
+ text: !0
64
+ })
65
+ }
66
+ )
67
+ }
68
+ ),
69
+ S(e).length > 0 && /* @__PURE__ */ n(
70
+ N,
71
+ {
72
+ k: "widget.input_bindings",
73
+ label: "Inputs",
74
+ effect: "Where each input comes from: a field of the record, a fixed value or the page address.",
75
+ children: /* @__PURE__ */ n("div", { className: "space-y-2", onBlurCapture: () => r.flush(), children: S(e).map((a) => {
76
+ const c = u.find((i) => i.key === a.key), h = (c == null ? void 0 : c.binding_type) ?? "item_field", _ = typeof (c == null ? void 0 : c.binding_value) == "string" ? c.binding_value : "";
77
+ return /* @__PURE__ */ d("div", { className: "space-y-1", children: [
78
+ /* @__PURE__ */ n("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: a.label }),
79
+ /* @__PURE__ */ n(
80
+ Q,
81
+ {
82
+ value: h,
83
+ options: [
84
+ { value: "item_field", label: "Field" },
85
+ { value: "static", label: "Fixed value" },
86
+ { value: "url_param", label: "Page address" }
87
+ ],
88
+ onChange: (i) => o(a.key, { binding_type: i, binding_value: "" })
89
+ }
90
+ ),
91
+ h === "item_field" ? /* @__PURE__ */ n(
92
+ w,
93
+ {
94
+ collection: r.collection,
95
+ fields: ((l == null ? void 0 : l.fields) ?? []).map((i) => ({
96
+ field: i.field,
97
+ type: i.type ?? "string",
98
+ interface: i.interface ?? null,
99
+ hidden: !!i.hidden
100
+ })),
101
+ relations: (l == null ? void 0 : l.relations) ?? [],
102
+ value: _,
103
+ onChange: (i) => o(a.key, { binding_value: i.path.join(".") }),
104
+ onClear: () => o(a.key, { binding_value: "" }),
105
+ placeholder: "Pick a field…"
106
+ }
107
+ ) : /* @__PURE__ */ n(
108
+ R,
109
+ {
110
+ ariaLabel: a.label,
111
+ value: _,
112
+ placeholder: h === "url_param" ? "parameter name" : "value",
113
+ onChange: (i) => o(a.key, { binding_value: i }, !0)
114
+ }
115
+ )
116
+ ] }, a.key);
117
+ }) })
118
+ }
119
+ ),
120
+ (e == null ? void 0 : e.widget_type) === "report_widget" && /* @__PURE__ */ n(L, { title: "Report", children: /* @__PURE__ */ d(
121
+ N,
122
+ {
123
+ k: "widget.report_config",
124
+ label: "Report and figure",
125
+ scope: "field",
126
+ effect: "Saved on the widget itself: every form using this widget changes.",
127
+ children: [
128
+ /* @__PURE__ */ n(
129
+ j,
130
+ {
131
+ widgetId: e.id,
132
+ config: e.config ?? null,
133
+ onSave: g
134
+ },
135
+ `${JSON.stringify(e.config ?? null)}:${f}`
136
+ ),
137
+ x && /* @__PURE__ */ n(
138
+ O,
139
+ {
140
+ widget: e,
141
+ config: x,
142
+ onDone: () => {
143
+ g(null), k((a) => a + 1);
144
+ }
145
+ }
146
+ )
147
+ ]
148
+ }
149
+ ) }),
150
+ /* @__PURE__ */ n(
151
+ "div",
152
+ {
153
+ "data-setting": "widget.remove",
154
+ className: "border-t border-slate-200 pt-3 dark:border-border",
155
+ children: y ? /* @__PURE__ */ d("div", { className: "flex items-center gap-2 text-[12px]", children: [
156
+ /* @__PURE__ */ d("span", { children: [
157
+ "Remove ",
158
+ m,
159
+ " from this form?"
160
+ ] }),
161
+ /* @__PURE__ */ n(
162
+ "button",
163
+ {
164
+ type: "button",
165
+ onClick: () => r.apply([{ op: "remove", at: p }], { label: `Remove ${m}` }),
166
+ className: "rounded-md bg-red-600 px-2.5 py-1 font-medium text-white hover:bg-red-700",
167
+ children: "Remove"
168
+ }
169
+ ),
170
+ /* @__PURE__ */ n(
171
+ "button",
172
+ {
173
+ type: "button",
174
+ onClick: () => v(!1),
175
+ className: "rounded-md px-2.5 py-1 hover:bg-muted",
176
+ children: "Keep"
177
+ }
178
+ )
179
+ ] }) : /* @__PURE__ */ n(
180
+ "button",
181
+ {
182
+ type: "button",
183
+ onClick: () => v(!0),
184
+ className: "text-[12px] text-red-600 hover:underline dark:text-red-400",
185
+ children: "Remove from this form"
186
+ }
187
+ )
188
+ }
189
+ )
190
+ ] });
191
+ }
192
+ function O({
193
+ widget: t,
194
+ config: r,
195
+ onDone: s
196
+ }) {
197
+ const l = $(), e = T(), [m, p] = b(!1), [u, y] = b(null), { data: v, isLoading: x } = q({
198
+ queryKey: ["layout-editor", "widget-placements", t.id],
199
+ queryFn: () => l.request(
200
+ F(`/widgets-internal/${t.id}/placements`)
201
+ ).then((o) => o.data ?? []),
202
+ staleTime: 3e4
203
+ }), g = (v ?? []).map((o) => o.name), f = g.slice(0, 8), k = () => {
204
+ p(!0), y(null), l.request(W(`/widgets-internal/${t.id}`, { config: r })).then(() => (I.success(`${t.name} — saved for every form`), s(), Promise.all([
205
+ e.invalidateQueries({ queryKey: ["layout-editor", "widgets"] }),
206
+ e.invalidateQueries({ queryKey: ["widgets-internal"] })
207
+ ]))).catch((o) => y(K(o, "The widget could not be saved").message)).finally(() => p(!1));
208
+ };
209
+ return /* @__PURE__ */ d(
210
+ "div",
211
+ {
212
+ "data-widget-confirm": "",
213
+ className: "mt-1.5 space-y-2 rounded-md border border-amber-300 bg-amber-50 p-2.5 text-[12px] text-amber-900 dark:border-amber-700/60 dark:bg-amber-950/40 dark:text-amber-100",
214
+ children: [
215
+ /* @__PURE__ */ d("p", { className: "font-medium", children: [
216
+ "This changes ",
217
+ t.name,
218
+ " on every form that places it, not just this one."
219
+ ] }),
220
+ x ? /* @__PURE__ */ d("p", { className: "text-[11px] opacity-80", children: [
221
+ "Finding the forms that place ",
222
+ t.name,
223
+ "…"
224
+ ] }) : f.length > 0 && /* @__PURE__ */ d("p", { className: "text-[11px]", children: [
225
+ "Forms: ",
226
+ f.join(", "),
227
+ g.length > f.length && ` and ${g.length - f.length} more`
228
+ ] }),
229
+ /* @__PURE__ */ n("p", { className: "text-[11px] opacity-80", children: "Undo does not reverse this." }),
230
+ u && /* @__PURE__ */ n("p", { className: "text-[11px] text-red-700 dark:text-red-300", children: u }),
231
+ /* @__PURE__ */ d("div", { className: "flex gap-2", children: [
232
+ /* @__PURE__ */ n(
233
+ "button",
234
+ {
235
+ type: "button",
236
+ "data-widget-save": "",
237
+ disabled: m,
238
+ onClick: k,
239
+ className: "rounded-md bg-nvr-cyan px-2.5 py-1 text-[12px] font-medium text-nvr-navy hover:bg-[#00b8e0] disabled:opacity-40",
240
+ children: m ? "Saving…" : "Save for every form"
241
+ }
242
+ ),
243
+ /* @__PURE__ */ n(
244
+ "button",
245
+ {
246
+ type: "button",
247
+ "data-widget-cancel": "",
248
+ onClick: s,
249
+ className: "rounded-md px-2.5 py-1 text-[12px] text-amber-900 hover:bg-amber-100 dark:text-amber-100 dark:hover:bg-amber-900/40",
250
+ children: "Cancel"
251
+ }
252
+ )
253
+ ] })
254
+ ]
255
+ }
256
+ );
257
+ }
258
+ export {
259
+ te as WidgetInspector,
260
+ B as useWidgetCatalog,
261
+ S as widgetInputs
262
+ };
@@ -0,0 +1,27 @@
1
+ import { NUMERIC_TYPES as r } from "./model.js";
2
+ const o = (t) => !!t.relKind || t.isPath, e = (t) => t.relKind === "O2M" && (t.iface === "inline-grid" || t.iface === "inline-table"), i = (t) => t.relKind === "M2O" || t.relKind === "M2M" || t.iface === "relation-path", p = (t) => r.has(t.type) && !o(t), d = (t) => (t.type === "string" || t.type === "text") && !o(t), u = (t) => !o(t) && (["date", "datetime", "timestamp"].includes(t.type) || t.iface === "datetime"), c = {
3
+ row_bulk_actions: e,
4
+ row_filter: e,
5
+ row_defaults: e,
6
+ allocate_drawer: e,
7
+ auto_allocate: e,
8
+ upload_template: e,
9
+ picker_facets: i,
10
+ option_filter: i,
11
+ quick_create: i
12
+ };
13
+ function _(t, s, n) {
14
+ if (n != null) return !0;
15
+ const a = c[t];
16
+ return a ? a(s) : !0;
17
+ }
18
+ export {
19
+ c as RAW_OPTION_SCOPE,
20
+ e as isGrid,
21
+ i as isPicker,
22
+ o as isRelational,
23
+ u as showsDateMode,
24
+ d as showsInputMask,
25
+ p as showsNumbers,
26
+ _ as showsRawOption
27
+ };
@@ -0,0 +1,134 @@
1
+ import { useQueryClient as G } from "@tanstack/react-query";
2
+ import { useCallback as N, useState as C, useMemo as K, createContext as M, useContext as P } from "react";
3
+ import { toast as Q } from "sonner";
4
+ import { useNivaroClient as $ } from "../../../context.js";
5
+ import { patch as D } from "../../../lib/commands.js";
6
+ import { titleCase as E } from "../../../lib/utils.js";
7
+ import { useCollectionBody as J, collectionMetaKey as B } from "../collection-meta.js";
8
+ import { parseSaveFailure as I } from "../useLayoutDraft.js";
9
+ import { describeField as R, asObject as x, withKey as h, readOptions as b, readOverrides as j, withOption as T, withOverride as U } from "./model.js";
10
+ function ee(s) {
11
+ const n = N(
12
+ (e) => ({
13
+ fields: (e == null ? void 0 : e.fields) ?? [],
14
+ relations: (e == null ? void 0 : e.relations) ?? [],
15
+ label: (e == null ? void 0 : e.display_name) || E(s ?? "")
16
+ }),
17
+ [s]
18
+ );
19
+ return J(s, { select: n });
20
+ }
21
+ const V = M(null);
22
+ function ne() {
23
+ const s = P(V);
24
+ if (!s) throw new Error("Field inspector tabs render inside the field inspector");
25
+ return s;
26
+ }
27
+ function te({
28
+ collection: s,
29
+ collectionLabel: n,
30
+ field: e,
31
+ fieldLabel: a,
32
+ stored: f
33
+ }) {
34
+ const m = $(), c = G(), [t, g] = C(null), [y, i] = C(!1), [r, o] = C(null), l = { ...f, columns: {} }, u = (t == null ? void 0 : t.draft) ?? l, p = t ? {
35
+ key: t.key,
36
+ values: t.values,
37
+ labels: [...new Set(Object.values(t.labels))],
38
+ patch: v(f, t.draft)
39
+ } : null;
40
+ return {
41
+ collection: s,
42
+ collectionLabel: n,
43
+ field: e,
44
+ fieldLabel: a,
45
+ pending: p,
46
+ draft: u,
47
+ saving: y,
48
+ error: r,
49
+ propose: (O, F, S, q, _ = O) => {
50
+ o(null), g((d) => {
51
+ const k = q((d == null ? void 0 : d.draft) ?? l);
52
+ return Object.keys(v(f, k)).length === 0 ? null : {
53
+ draft: k,
54
+ values: { ...d == null ? void 0 : d.values, [O]: F },
55
+ labels: { ...d == null ? void 0 : d.labels, [_]: S },
56
+ key: _
57
+ };
58
+ });
59
+ },
60
+ cancel: () => {
61
+ o(null), g(null);
62
+ },
63
+ confirm: () => {
64
+ p && (i(!0), o(null), m.request(
65
+ D(`/field-config/${s}/${encodeURIComponent(e)}`, p.patch)
66
+ ).then(() => (g(null), Q.success(`${p.labels.join("; ")} — saved for every form`), Promise.all([
67
+ c.invalidateQueries({ queryKey: B(s) }),
68
+ c.invalidateQueries({
69
+ queryKey: ["layout-editor", "field-impact", s, e]
70
+ })
71
+ ]))).catch((O) => o(I(O, "The field could not be saved").message)).finally(() => i(!1)));
72
+ }
73
+ };
74
+ }
75
+ function v(s, n) {
76
+ const e = {}, a = (c, t) => JSON.stringify(c) === JSON.stringify(t), f = s.columns ?? {};
77
+ for (const [c, t] of Object.entries(n.columns)) (!(c in f) || !a(t, f[c])) && (e[c] = t);
78
+ const m = (c) => Object.keys(c).length ? c : null;
79
+ return a(n.options, s.options) || (e.options = m(n.options)), a(n.dependency_config, s.dependency_config) || (e.dependency_config = m(n.dependency_config)), e;
80
+ }
81
+ function oe({
82
+ env: s,
83
+ row: n,
84
+ meta: e,
85
+ writer: a,
86
+ readOnly: f
87
+ }) {
88
+ return K(() => {
89
+ const m = { field: n.field, group_key: n.group_key }, c = R(n.field, e.fields, e.relations, n), t = c.global, g = x(t == null ? void 0 : t.options), y = (i, r, o) => s.apply([{ op: "update_placement", at: m, patch: i }], { label: r, text: o });
90
+ return {
91
+ env: s,
92
+ row: n,
93
+ at: m,
94
+ info: c,
95
+ ov: j(n),
96
+ opts: b(n),
97
+ globals: e.fields,
98
+ relations: e.relations,
99
+ globalOptions: g,
100
+ globalDependency: x(t == null ? void 0 : t.dependency_config),
101
+ readOnly: f,
102
+ setOverride: (i, r, o, l) => y({ overrides: U(n, i, r) }, o, l),
103
+ setOption: (i, r, o, l) => y({ overrides: T(n, i, r) }, o, l),
104
+ setOptions: (i, r, o) => {
105
+ let l = b(n);
106
+ for (const [u, p] of Object.entries(i)) l = h(l ?? {}, u, p);
107
+ y(
108
+ { overrides: h(j(n), "options", l ?? void 0) },
109
+ r,
110
+ o
111
+ );
112
+ },
113
+ setPlacement: y,
114
+ proposeGlobalOption: (i, r, o, l, u = o) => a.propose(i, u, l, (p) => ({
115
+ ...p,
116
+ options: h(p.options, r, o) ?? {}
117
+ })),
118
+ proposeGlobalDependency: (i, r, o, l) => a.propose(i, o, l, (u) => ({
119
+ ...u,
120
+ dependency_config: h(u.dependency_config, r, o) ?? {}
121
+ })),
122
+ proposeGlobal: (i, r, o, l, u) => a.propose(i, r, o, l, u)
123
+ };
124
+ }, [s, n, e, a, f]);
125
+ }
126
+ export {
127
+ V as FieldCtxContext,
128
+ B as collectionMetaKey,
129
+ v as globalPatch,
130
+ ee as useCollectionMeta,
131
+ ne as useFieldCtx,
132
+ oe as useFieldCtxValue,
133
+ te as useGlobalWriter
134
+ };
@@ -0,0 +1,126 @@
1
+ const n = {
2
+ string: [
3
+ { value: "input", label: "Text input" },
4
+ { value: "input-multiline", label: "Textarea" },
5
+ { value: "input-rich-text-md", label: "Markdown" },
6
+ { value: "select-dropdown", label: "Dropdown" },
7
+ { value: "select-radio", label: "Radio buttons" },
8
+ { value: "select-multiple-checkbox", label: "Checkboxes (multi-select)" },
9
+ { value: "tags", label: "Tags" },
10
+ { value: "color", label: "Color picker" },
11
+ { value: "slug", label: "Slug" },
12
+ { value: "fiscal_period", label: "Fiscal period (FY/Q)" },
13
+ { value: "input-hash", label: "Password / hash" },
14
+ { value: "checklist", label: "Checklist (todo list)" },
15
+ { value: "phone", label: "Phone number" },
16
+ { value: "email", label: "Email address" },
17
+ { value: "address-autocomplete", label: "Address (autocomplete)" }
18
+ ],
19
+ text: [
20
+ { value: "input", label: "Text input" },
21
+ { value: "input-multiline", label: "Textarea" },
22
+ { value: "input-rich-text-md", label: "Markdown" },
23
+ { value: "input-rich-text-html", label: "WYSIWYG" },
24
+ { value: "input-code", label: "Code editor" },
25
+ { value: "checklist", label: "Checklist (todo list)" },
26
+ { value: "address", label: "Structured address" },
27
+ { value: "phone", label: "Phone number" },
28
+ { value: "email", label: "Email address" },
29
+ { value: "address-autocomplete", label: "Address (autocomplete)" }
30
+ ],
31
+ integer: [
32
+ { value: "input", label: "Number input" },
33
+ { value: "slider", label: "Slider" },
34
+ { value: "rating", label: "Rating (1-5 stars)" },
35
+ { value: "duration", label: "Duration (h:mm → minutes)" },
36
+ { value: "range_slider", label: "Range slider (paired)" },
37
+ { value: "select-dropdown", label: "Dropdown" },
38
+ { value: "select-radio", label: "Radio buttons" },
39
+ { value: "progress", label: "Progress (0–100 %)" }
40
+ ],
41
+ bigInteger: [{ value: "input", label: "Number input" }],
42
+ float: [
43
+ { value: "input", label: "Number input" },
44
+ { value: "slider", label: "Slider" }
45
+ ],
46
+ decimal: [{ value: "input", label: "Number input" }],
47
+ boolean: [
48
+ { value: "toggle", label: "Toggle" },
49
+ { value: "checkbox", label: "Checkbox" },
50
+ { value: "boolean", label: "Yes / no select" }
51
+ ],
52
+ date: [
53
+ { value: "datetime", label: "Date picker" },
54
+ { value: "date_range", label: "Date range (paired)" }
55
+ ],
56
+ datetime: [{ value: "datetime", label: "Date & time picker" }],
57
+ time: [{ value: "datetime", label: "Time picker" }],
58
+ timestamp: [{ value: "datetime", label: "Date & time picker" }],
59
+ uuid: [{ value: "input", label: "Text input (read-only)" }],
60
+ json: [
61
+ { value: "input-code", label: "Code editor" },
62
+ { value: "list", label: "Repeater list" },
63
+ { value: "repeater", label: "Repeater (schema rows)" },
64
+ { value: "checklist", label: "Checklist (todo list)" }
65
+ ],
66
+ csv: [{ value: "tags", label: "Tags" }],
67
+ hash: [{ value: "input-hash", label: "Password / hash" }],
68
+ alias: [
69
+ { value: "group-detail", label: "Group (accordion)" },
70
+ { value: "group-raw", label: "Group (always open)" },
71
+ { value: "presentation-divider", label: "Divider" },
72
+ { value: "presentation-notice", label: "Notice / banner" }
73
+ ],
74
+ m2o: [
75
+ { value: "relation-picker", label: "Relation picker" },
76
+ { value: "relation-grouped", label: "Grouped combobox" },
77
+ { value: "file-image", label: "File picker" },
78
+ { value: "input", label: "Plain text (stored id)" }
79
+ ],
80
+ m2m: [
81
+ { value: "relation-m2m", label: "Tags picker" },
82
+ { value: "select-multiple-m2m", label: "Multiselect combobox" },
83
+ { value: "files-m2m", label: "File picker" }
84
+ ],
85
+ o2m: [
86
+ { value: "relation-list", label: "Related items list" },
87
+ { value: "inline-grid", label: "Inline grid" },
88
+ { value: "inline-table", label: "Inline table" }
89
+ ]
90
+ }, o = {
91
+ "select-dropdown-m2o": "relation-picker",
92
+ "many-to-one": "relation-picker",
93
+ "list-m2m": "relation-m2m",
94
+ "many-to-many": "relation-m2m",
95
+ "list-o2m": "relation-list",
96
+ "one-to-many": "relation-list",
97
+ "list-o2m-tree-view": "relation-list",
98
+ files: "files-m2m",
99
+ file: "file-image",
100
+ "text-input": "input",
101
+ textarea: "input-multiline",
102
+ wysiwyg: "input-rich-text-html",
103
+ markdown: "input-rich-text-md",
104
+ dropdown: "select-dropdown",
105
+ "datetime-picker": "datetime"
106
+ };
107
+ function u(e) {
108
+ return n[e] ?? [{ value: "input", label: "Text input" }];
109
+ }
110
+ function r(e, l) {
111
+ if (!l) return null;
112
+ const t = u(e);
113
+ if (t.some((i) => i.value === l)) return l;
114
+ const a = o[l];
115
+ return a && t.some((i) => i.value === a) ? a : null;
116
+ }
117
+ function s(e, l) {
118
+ var a;
119
+ const t = r(e, l);
120
+ return t ? ((a = u(e).find((i) => i.value === t)) == null ? void 0 : a.label) ?? null : null;
121
+ }
122
+ export {
123
+ r as currentInterface,
124
+ s as interfaceLabel,
125
+ u as interfaceOptions
126
+ };