@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.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +204 -6
- package/dist/index.js +442 -439
- package/dist/layout-editor.d.ts +80 -0
- package/dist/layout-editor.js +11 -0
- package/dist/shared/components/ItemEditForm.js +4117 -3882
- package/dist/shared/components/RecordDrilldownSheet.js +114 -97
- package/dist/shared/components/RecordReadView.js +662 -596
- package/dist/shared/components/ai/ExplainButton.js +1 -1
- package/dist/shared/components/chat/ChatPanel.js +1053 -993
- package/dist/shared/components/import/DocumentAutofillButton.js +141 -129
- package/dist/shared/components/item-edit/GroupSection.js +489 -466
- package/dist/shared/components/item-edit/HeaderBand.js +47 -44
- package/dist/shared/components/item-edit/M2MStagingContext.js +3 -3
- package/dist/shared/components/item-edit/O2MStagingContext.js +1 -1
- package/dist/shared/components/item-edit/RecordGrantTools.js +206 -0
- package/dist/shared/components/item-edit/StepsBar.js +49 -43
- package/dist/shared/components/item-edit/SummaryPanel.js +2 -1
- package/dist/shared/components/item-edit/config-update.js +6 -0
- package/dist/shared/components/item-edit/layout-editing-quiet.js +25 -0
- package/dist/shared/components/layout-editor/AddPanel.js +301 -0
- package/dist/shared/components/layout-editor/DesignNode.js +173 -0
- package/dist/shared/components/layout-editor/EditorCanvas.js +52 -0
- package/dist/shared/components/layout-editor/EditorTopBar.js +241 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +179 -0
- package/dist/shared/components/layout-editor/LayoutEditor.js +393 -0
- package/dist/shared/components/layout-editor/LayoutsRail.js +89 -0
- package/dist/shared/components/layout-editor/add-target.js +103 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +86 -0
- package/dist/shared/components/layout-editor/canvases/PdfCanvas.js +90 -0
- package/dist/shared/components/layout-editor/canvases/TableColumnsCanvas.js +246 -0
- package/dist/shared/components/layout-editor/collection-meta.js +22 -0
- package/dist/shared/components/layout-editor/design-canvas.js +81 -0
- package/dist/shared/components/layout-editor/design-context.js +21 -0
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +225 -0
- package/dist/shared/components/layout-editor/dnd/collision.js +107 -0
- package/dist/shared/components/layout-editor/dnd/node.js +164 -0
- package/dist/shared/components/layout-editor/dnd/order.js +122 -0
- package/dist/shared/components/layout-editor/editors/DefaultValuesEditor.js +223 -0
- package/dist/shared/components/layout-editor/editors/QuickPickerStepsEditor.js +129 -0
- package/dist/shared/components/layout-editor/editors/ReadPresentationEditor.js +134 -0
- package/dist/shared/components/layout-editor/editors/RecordConditionsEditor.js +249 -0
- package/dist/shared/components/layout-editor/editors/RolesPicker.js +77 -0
- package/dist/shared/components/layout-editor/editors/cascade-filters.js +556 -0
- package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +150 -0
- package/dist/shared/components/layout-editor/editors/controls.js +73 -0
- package/dist/shared/components/layout-editor/editors/editor-api.js +21 -0
- package/dist/shared/components/layout-editor/editors/editor-queries.js +25 -0
- package/dist/shared/components/layout-editor/editors/field-default-value.js +131 -0
- package/dist/shared/components/layout-editor/editors/grid-presets.js +310 -0
- package/dist/shared/components/layout-editor/editors/inline-display.js +157 -0
- package/dist/shared/components/layout-editor/editors/layout-picker.js +80 -0
- package/dist/shared/components/layout-editor/editors/layout-rows.js +55 -0
- package/dist/shared/components/layout-editor/editors/lock-conditions.js +109 -0
- package/dist/shared/components/layout-editor/editors/o2m-agg-field.js +25 -0
- package/dist/shared/components/layout-editor/editors/pdf-field-config.js +107 -0
- package/dist/shared/components/layout-editor/editors/report-widget-config.js +94 -0
- package/dist/shared/components/layout-editor/editors/row-rule-check.js +225 -0
- package/dist/shared/components/layout-editor/editors/row-rule-row.js +1353 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +245 -0
- package/dist/shared/components/layout-editor/focus-buffer.js +32 -0
- package/dist/shared/components/layout-editor/host.js +15 -0
- package/dist/shared/components/layout-editor/inspector/AdvancedTab.js +296 -0
- package/dist/shared/components/layout-editor/inspector/GridTab.js +767 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +456 -0
- package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +268 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +332 -0
- package/dist/shared/components/layout-editor/inspector/LookTab.js +310 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +333 -0
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +323 -0
- package/dist/shared/components/layout-editor/inspector/SlotInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/SubtitleInspector.js +154 -0
- package/dist/shared/components/layout-editor/inspector/WidgetInspector.js +262 -0
- package/dist/shared/components/layout-editor/inspector/applies.js +27 -0
- package/dist/shared/components/layout-editor/inspector/field-context.js +134 -0
- package/dist/shared/components/layout-editor/inspector/interfaces.js +126 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +595 -0
- package/dist/shared/components/layout-editor/inspector/model.js +307 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -0
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +121 -0
- package/dist/shared/components/layout-editor/overview/overview-api.js +141 -0
- package/dist/shared/components/layout-editor/overview/purpose.js +62 -0
- package/dist/shared/components/layout-editor/overview/record-count.js +65 -0
- package/dist/shared/components/layout-editor/panel-frame.js +99 -0
- package/dist/shared/components/layout-editor/panel-style.js +19 -0
- package/dist/shared/components/layout-editor/pickers/field-picker.js +230 -0
- package/dist/shared/components/layout-editor/pickers/icon-picker.js +233 -0
- package/dist/shared/components/layout-editor/pickers/relation-label.js +34 -0
- package/dist/shared/components/layout-editor/pickers/relation-picker.js +136 -0
- package/dist/shared/components/layout-editor/record-queries.js +15 -0
- package/dist/shared/components/layout-editor/settings/AddendumSection.js +52 -0
- package/dist/shared/components/layout-editor/settings/ButtonsSection.js +45 -0
- package/dist/shared/components/layout-editor/settings/DefaultsSection.js +67 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +146 -0
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +37 -0
- package/dist/shared/components/layout-editor/settings/LayoutSection.js +70 -0
- package/dist/shared/components/layout-editor/settings/PdfSection.js +176 -0
- package/dist/shared/components/layout-editor/settings/ReadSection.js +79 -0
- package/dist/shared/components/layout-editor/settings/TextSetting.js +55 -0
- package/dist/shared/components/layout-editor/settings/ToggleSetting.js +33 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +179 -0
- package/dist/shared/components/layout-editor/settings/WhoSection.js +213 -0
- package/dist/shared/components/layout-editor/settings/controls.js +214 -0
- package/dist/shared/components/layout-editor/settings/section-props.js +17 -0
- package/dist/shared/components/layout-editor/settings/settings-api.js +151 -0
- package/dist/shared/components/layout-editor/settings/settings-registry.js +445 -0
- package/dist/shared/components/layout-editor/slot-names.js +20 -0
- package/dist/shared/components/layout-editor/summary-pref.js +21 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +474 -0
- package/dist/shared/components/pipeline/relations.js +28 -23
- package/dist/shared/components/ui/dialog.js +11 -11
- package/dist/shared/components/ui/popover.js +17 -17
- package/dist/shared/components/ui/scroll-area.js +38 -0
- package/dist/shared/hooks/useRelationOptions.js +60 -0
- package/dist/shared/lib/layout-grants.js +9 -0
- package/dist/shared/lib/layout-ops.js +348 -0
- package/dist/shared/lib/layout-slots.js +11 -7
- package/dist/shared/lib/presence-state.js +43 -13
- package/dist/shared/lib/request-gate.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { jsxs as m, jsx as l } from "react/jsx-runtime";
|
|
2
|
+
import { InlineDisplaySection as V } from "../editors/inline-display.js";
|
|
3
|
+
import { showsNumbers as B, showsDateMode as K, showsInputMask as X } from "./applies.js";
|
|
4
|
+
import { useFieldCtx as q } from "./field-context.js";
|
|
5
|
+
import { interfaceOptions as z, interfaceLabel as J, currentInterface as Q } from "./interfaces.js";
|
|
6
|
+
import { useGlobalValue as f, Setting as n, TextInput as h, Toggle as D, Choice as I, Segmented as b, Section as T, Buffered as Y, DraftInput as g } from "./kit.js";
|
|
7
|
+
import { inlineDisplayOf as Z, withInlineDisplay as ee } from "./model.js";
|
|
8
|
+
const N = [
|
|
9
|
+
{ value: "12", label: "Full" },
|
|
10
|
+
{ value: "6", label: "½" },
|
|
11
|
+
{ value: "4", label: "⅓" },
|
|
12
|
+
{ value: "3", label: "¼" }
|
|
13
|
+
], G = [
|
|
14
|
+
{ value: "", label: "Default" },
|
|
15
|
+
{ value: "int", label: "Integer" },
|
|
16
|
+
{ value: "decimal", label: "Decimal" },
|
|
17
|
+
{ value: "currency", label: "Currency" }
|
|
18
|
+
], le = [
|
|
19
|
+
{ value: "", label: "None" },
|
|
20
|
+
{ value: "SUM", label: "Sum" },
|
|
21
|
+
{ value: "COUNT", label: "Count" },
|
|
22
|
+
{ value: "AVG", label: "Average" },
|
|
23
|
+
{ value: "MIN", label: "Smallest" },
|
|
24
|
+
{ value: "MAX", label: "Largest" }
|
|
25
|
+
], r = (t) => typeof t == "string" ? t : "";
|
|
26
|
+
function se() {
|
|
27
|
+
var $, O, L, x;
|
|
28
|
+
const t = q(), { info: o, ov: s, opts: u, env: _, row: p, globalOptions: c } = t, a = o.label, v = (($ = o.global) == null ? void 0 : $.label) || a, w = s.label === "", H = B(o), M = K(o), A = X(o), U = z(o.abstractType), C = J(o.abstractType, ((O = o.global) == null ? void 0 : O.interface) ?? null) ?? ((L = o.global) != null && L.interface ? "custom input" : null), k = r(s.interface), F = Q(o.abstractType, k) ?? k, y = f("field.format", r(c.format)), P = f("field.currency", r(c.currency)), R = f("field.aggregate", r(c.aggregate)), E = f("field.unit", r(c.unit)), W = f("field.input_mask", r(c.input_mask)), j = Z(p), S = (e) => t.setPlacement(
|
|
29
|
+
{ input_bindings: ee(p, e) },
|
|
30
|
+
`Change what shows under ${a}`,
|
|
31
|
+
!0
|
|
32
|
+
);
|
|
33
|
+
return /* @__PURE__ */ m("div", { className: "space-y-5", children: [
|
|
34
|
+
/* @__PURE__ */ l(
|
|
35
|
+
n,
|
|
36
|
+
{
|
|
37
|
+
k: "field.label",
|
|
38
|
+
label: "Label",
|
|
39
|
+
effect: `What this form calls the field. Empty uses the field's own label (${v}).`,
|
|
40
|
+
children: /* @__PURE__ */ l(
|
|
41
|
+
h,
|
|
42
|
+
{
|
|
43
|
+
ariaLabel: "Label",
|
|
44
|
+
value: w ? "" : r(s.label),
|
|
45
|
+
placeholder: v,
|
|
46
|
+
onChange: (e) => t.setOverride("label", e === "" ? void 0 : e, `Rename ${a}`, !0)
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
),
|
|
51
|
+
/* @__PURE__ */ l(
|
|
52
|
+
D,
|
|
53
|
+
{
|
|
54
|
+
k: "field.label_hidden",
|
|
55
|
+
label: "Hide the label",
|
|
56
|
+
effect: "Shows the value without its label on this form.",
|
|
57
|
+
checked: w,
|
|
58
|
+
onChange: (e) => t.setOverride(
|
|
59
|
+
"label",
|
|
60
|
+
e ? "" : void 0,
|
|
61
|
+
e ? `Hide the label of ${a}` : `Show the label of ${a}`
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ l(n, { k: "field.interface", label: "Input", effect: "How the field is edited on this form.", children: /* @__PURE__ */ l(
|
|
66
|
+
I,
|
|
67
|
+
{
|
|
68
|
+
ariaLabel: "Input",
|
|
69
|
+
value: F,
|
|
70
|
+
unknownLabel: (e) => `Custom input (${e})`,
|
|
71
|
+
options: [
|
|
72
|
+
{ value: "", label: C ? `Field's own (${C})` : "Field's own" },
|
|
73
|
+
...U
|
|
74
|
+
],
|
|
75
|
+
onChange: (e) => t.setOverride("interface", e || void 0, `Change how ${a} is edited`)
|
|
76
|
+
}
|
|
77
|
+
) }),
|
|
78
|
+
/* @__PURE__ */ l(n, { k: "field.placeholder", label: "Placeholder", effect: "Grey hint inside the empty input.", children: /* @__PURE__ */ l(
|
|
79
|
+
h,
|
|
80
|
+
{
|
|
81
|
+
ariaLabel: "Placeholder",
|
|
82
|
+
value: r(s.placeholder),
|
|
83
|
+
onChange: (e) => t.setOverride(
|
|
84
|
+
"placeholder",
|
|
85
|
+
e || void 0,
|
|
86
|
+
`Change the placeholder of ${a}`,
|
|
87
|
+
!0
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
) }),
|
|
91
|
+
/* @__PURE__ */ l(n, { k: "field.note", label: "Help text", effect: "A line of help under the field.", children: /* @__PURE__ */ l(
|
|
92
|
+
h,
|
|
93
|
+
{
|
|
94
|
+
ariaLabel: "Help text",
|
|
95
|
+
value: r(s.note),
|
|
96
|
+
placeholder: ((x = o.global) == null ? void 0 : x.note) ?? "",
|
|
97
|
+
onChange: (e) => t.setOverride("note", e || void 0, `Change the help text of ${a}`, !0)
|
|
98
|
+
}
|
|
99
|
+
) }),
|
|
100
|
+
/* @__PURE__ */ l(
|
|
101
|
+
D,
|
|
102
|
+
{
|
|
103
|
+
k: "field.hidden",
|
|
104
|
+
label: "Hidden",
|
|
105
|
+
effect: "Leaves the field off this form; its value is kept.",
|
|
106
|
+
checked: s.hidden === !0,
|
|
107
|
+
onChange: (e) => t.setOverride("hidden", e ? !0 : void 0, e ? `Hide ${a}` : `Show ${a}`)
|
|
108
|
+
}
|
|
109
|
+
),
|
|
110
|
+
_.layoutType !== "table" && /* @__PURE__ */ l(n, { k: "field.col_span", label: "Width", effect: "Share of the row the field takes.", children: /* @__PURE__ */ l(
|
|
111
|
+
b,
|
|
112
|
+
{
|
|
113
|
+
value: String(p.col_span ?? 12),
|
|
114
|
+
options: N,
|
|
115
|
+
onChange: (e) => {
|
|
116
|
+
var i;
|
|
117
|
+
return t.setPlacement(
|
|
118
|
+
{ col_span: e === "12" ? null : Number(e) },
|
|
119
|
+
`Set the width of ${a} to ${(i = N.find((d) => d.value === e)) == null ? void 0 : i.label}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
) }),
|
|
124
|
+
o.relKind === "M2O" && o.relatedCollection && /* @__PURE__ */ m(T, { title: "Show under the value", children: [
|
|
125
|
+
/* @__PURE__ */ l("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "Fields of the picked record shown with it on this form." }),
|
|
126
|
+
/* @__PURE__ */ l(Y, { value: j, children: (e, i) => /* @__PURE__ */ l(
|
|
127
|
+
V,
|
|
128
|
+
{
|
|
129
|
+
relatedCollection: o.relatedCollection,
|
|
130
|
+
entries: e.entries,
|
|
131
|
+
separator: e.separator,
|
|
132
|
+
onChange: (d) => S(i({ ...e, entries: d })),
|
|
133
|
+
onSeparatorChange: (d) => S(i({ ...e, separator: d }))
|
|
134
|
+
}
|
|
135
|
+
) })
|
|
136
|
+
] }),
|
|
137
|
+
M && /* @__PURE__ */ l(
|
|
138
|
+
n,
|
|
139
|
+
{
|
|
140
|
+
k: "field.date_mode",
|
|
141
|
+
label: "Show",
|
|
142
|
+
effect: "Date only hides the time in the picker and wherever this form shows the value.",
|
|
143
|
+
children: /* @__PURE__ */ l(
|
|
144
|
+
b,
|
|
145
|
+
{
|
|
146
|
+
value: u.date_mode === "date" ? "date" : "datetime",
|
|
147
|
+
options: [
|
|
148
|
+
{ value: "datetime", label: "Date & time" },
|
|
149
|
+
{ value: "date", label: "Date only" }
|
|
150
|
+
],
|
|
151
|
+
onChange: (e) => t.setOption(
|
|
152
|
+
"date_mode",
|
|
153
|
+
e === "date" ? "date" : void 0,
|
|
154
|
+
e === "date" ? `Show ${a} as a date only` : `Show ${a} with its time`
|
|
155
|
+
)
|
|
156
|
+
}
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
),
|
|
160
|
+
H && /* @__PURE__ */ m(T, { title: "Numbers", children: [
|
|
161
|
+
/* @__PURE__ */ l(
|
|
162
|
+
n,
|
|
163
|
+
{
|
|
164
|
+
k: "field.precision",
|
|
165
|
+
label: "Decimal places",
|
|
166
|
+
effect: "Rounds entry and display on this form.",
|
|
167
|
+
children: /* @__PURE__ */ l(
|
|
168
|
+
h,
|
|
169
|
+
{
|
|
170
|
+
type: "number",
|
|
171
|
+
ariaLabel: "Decimal places",
|
|
172
|
+
value: u.precision == null ? "" : String(u.precision),
|
|
173
|
+
placeholder: "2",
|
|
174
|
+
onChange: (e) => {
|
|
175
|
+
const i = e === "" ? void 0 : Math.max(0, Math.min(10, Math.round(Number(e))));
|
|
176
|
+
i !== void 0 && Number.isNaN(i) || t.setOption("precision", i, `Set the decimal places of ${a}`, !0);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ l(
|
|
183
|
+
n,
|
|
184
|
+
{
|
|
185
|
+
k: "field.format",
|
|
186
|
+
label: "Number format",
|
|
187
|
+
scope: "field",
|
|
188
|
+
effect: "How the value is written everywhere it shows.",
|
|
189
|
+
children: /* @__PURE__ */ l(
|
|
190
|
+
b,
|
|
191
|
+
{
|
|
192
|
+
value: y,
|
|
193
|
+
options: G,
|
|
194
|
+
onChange: (e) => {
|
|
195
|
+
var i;
|
|
196
|
+
return t.proposeGlobalOption(
|
|
197
|
+
"field.format",
|
|
198
|
+
"format",
|
|
199
|
+
e || void 0,
|
|
200
|
+
`Show ${a} as ${(i = G.find((d) => d.value === e)) == null ? void 0 : i.label.toLowerCase()}`,
|
|
201
|
+
e
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
)
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
y === "currency" && /* @__PURE__ */ l(
|
|
209
|
+
n,
|
|
210
|
+
{
|
|
211
|
+
k: "field.currency",
|
|
212
|
+
label: "Currency",
|
|
213
|
+
scope: "field",
|
|
214
|
+
effect: "Three-letter code, for example USD.",
|
|
215
|
+
children: /* @__PURE__ */ l(
|
|
216
|
+
g,
|
|
217
|
+
{
|
|
218
|
+
ariaLabel: "Currency",
|
|
219
|
+
value: P,
|
|
220
|
+
placeholder: "USD",
|
|
221
|
+
mono: !0,
|
|
222
|
+
onCommit: (e) => t.proposeGlobalOption(
|
|
223
|
+
"field.currency",
|
|
224
|
+
"currency",
|
|
225
|
+
e.trim().toUpperCase() || void 0,
|
|
226
|
+
`Show ${a} in ${e.trim().toUpperCase() || "USD"}`,
|
|
227
|
+
e
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
),
|
|
233
|
+
/* @__PURE__ */ l(
|
|
234
|
+
n,
|
|
235
|
+
{
|
|
236
|
+
k: "field.aggregate",
|
|
237
|
+
label: "Grid footer",
|
|
238
|
+
scope: "field",
|
|
239
|
+
effect: "The figure under this column wherever it shows in a grid.",
|
|
240
|
+
children: /* @__PURE__ */ l(
|
|
241
|
+
I,
|
|
242
|
+
{
|
|
243
|
+
ariaLabel: "Grid footer",
|
|
244
|
+
value: R,
|
|
245
|
+
options: le,
|
|
246
|
+
onChange: (e) => t.proposeGlobalOption(
|
|
247
|
+
"field.aggregate",
|
|
248
|
+
"aggregate",
|
|
249
|
+
e || void 0,
|
|
250
|
+
`Change the grid footer of ${a}`,
|
|
251
|
+
e
|
|
252
|
+
)
|
|
253
|
+
}
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
),
|
|
257
|
+
/* @__PURE__ */ l(
|
|
258
|
+
n,
|
|
259
|
+
{
|
|
260
|
+
k: "field.unit",
|
|
261
|
+
label: "Unit",
|
|
262
|
+
scope: "field",
|
|
263
|
+
effect: '"$" shows currency, "%" a percent; other text follows the number. A number format wins.',
|
|
264
|
+
children: /* @__PURE__ */ l(
|
|
265
|
+
g,
|
|
266
|
+
{
|
|
267
|
+
ariaLabel: "Unit",
|
|
268
|
+
value: E,
|
|
269
|
+
onCommit: (e) => t.proposeGlobalOption(
|
|
270
|
+
"field.unit",
|
|
271
|
+
"unit",
|
|
272
|
+
e || void 0,
|
|
273
|
+
`Set the unit of ${a}`,
|
|
274
|
+
e
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
)
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
] }),
|
|
281
|
+
A && /* @__PURE__ */ l(
|
|
282
|
+
n,
|
|
283
|
+
{
|
|
284
|
+
k: "field.input_mask",
|
|
285
|
+
label: "Input mask",
|
|
286
|
+
scope: "field",
|
|
287
|
+
effect: "# a digit, A a letter, * anything. The value is stored without the mask.",
|
|
288
|
+
children: /* @__PURE__ */ l(
|
|
289
|
+
g,
|
|
290
|
+
{
|
|
291
|
+
ariaLabel: "Input mask",
|
|
292
|
+
value: W,
|
|
293
|
+
mono: !0,
|
|
294
|
+
placeholder: "(###) ###-####",
|
|
295
|
+
onCommit: (e) => t.proposeGlobalOption(
|
|
296
|
+
"field.input_mask",
|
|
297
|
+
"input_mask",
|
|
298
|
+
e || void 0,
|
|
299
|
+
`Set the input mask of ${a}`,
|
|
300
|
+
e
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
)
|
|
304
|
+
}
|
|
305
|
+
)
|
|
306
|
+
] });
|
|
307
|
+
}
|
|
308
|
+
export {
|
|
309
|
+
se as LookTab
|
|
310
|
+
};
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { jsxs as s, Fragment as X, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as A } from "@tanstack/react-query";
|
|
3
|
+
import { useState as Y, useEffect as Z, useContext as ee } from "react";
|
|
4
|
+
import { useNivaroClient as M } from "../../../context.js";
|
|
5
|
+
import { get as L } from "../../../lib/commands.js";
|
|
6
|
+
import { CascadeFiltersEditor as le } from "../editors/cascade-filters.js";
|
|
7
|
+
import { editorQueryKeys as oe } from "../editors/editor-queries.js";
|
|
8
|
+
import { useFieldCtx as te } from "./field-context.js";
|
|
9
|
+
import { useGlobalValue as g, GlobalWriterContext as ie, Toggle as p, Setting as u, TextInput as ne, Section as O, Choice as $ } from "./kit.js";
|
|
10
|
+
import { asObject as ae, asArray as re, relKindOf as de, describeField as se, withKey as ce } from "./model.js";
|
|
11
|
+
function fe(l) {
|
|
12
|
+
const o = M();
|
|
13
|
+
return A({
|
|
14
|
+
queryKey: oe.relationsFor(l),
|
|
15
|
+
queryFn: () => o.request(L(`/data-model/relations/for/${l}`)).then((r) => Array.isArray(r.data) ? r.data : []),
|
|
16
|
+
enabled: !!l,
|
|
17
|
+
staleTime: 5 * 6e4
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function pe(l) {
|
|
21
|
+
const o = M();
|
|
22
|
+
return A({
|
|
23
|
+
queryKey: ["layout-editor", "layouts-of", l],
|
|
24
|
+
queryFn: () => o.request(
|
|
25
|
+
L("/collection-layouts", { collection: l })
|
|
26
|
+
).then((r) => Array.isArray(r.data) ? r.data : []),
|
|
27
|
+
enabled: !!l,
|
|
28
|
+
staleTime: 6e4
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function x(l) {
|
|
32
|
+
const o = l.trim();
|
|
33
|
+
if (!o) return null;
|
|
34
|
+
const r = /^(\d{1,3})%$/.exec(o);
|
|
35
|
+
if (r) {
|
|
36
|
+
const a = Number(r[1]);
|
|
37
|
+
return a >= 10 && a <= 96 ? `${a}%` : "invalid";
|
|
38
|
+
}
|
|
39
|
+
if (/^\d+$/.test(o)) {
|
|
40
|
+
const a = Number(o);
|
|
41
|
+
return a >= 320 && a <= 2e3 ? a : "invalid";
|
|
42
|
+
}
|
|
43
|
+
return "invalid";
|
|
44
|
+
}
|
|
45
|
+
function Ce() {
|
|
46
|
+
var P;
|
|
47
|
+
const l = te(), { info: o, ov: r, opts: a, env: b, globalOptions: d, globalDependency: E } = l, i = o.label, c = o.relKind === "M2O", h = o.relKind === "M2M", _ = o.iface === "relation-path" || o.isPath, S = o.iface === "file-image" || o.iface === "files-m2m", F = o.iface === "relation-grouped", f = ae(r.drilldown), m = f.enabled ?? _, K = o.relatedCollection ?? (typeof d.path_target_collection == "string" ? d.path_target_collection : null), { data: q = [] } = pe(c || h || _ ? K : null), j = q.filter((e) => e.layout_type === "detail"), y = f.width == null ? "" : String(f.width), [G, T] = Y(y);
|
|
48
|
+
Z(() => {
|
|
49
|
+
T((e) => {
|
|
50
|
+
const n = x(e);
|
|
51
|
+
return (n === null ? "" : String(n)) === y ? e : y;
|
|
52
|
+
});
|
|
53
|
+
}, [y]);
|
|
54
|
+
const D = x(G), k = (e, n, w) => l.setOverride("drilldown", { ...f, enabled: m, ...e }, n, w), { data: W = [] } = fe(F ? o.relatedCollection : null), N = W.filter(
|
|
55
|
+
(e) => e.many_collection === o.relatedCollection && e.many_field && !e.junction_field
|
|
56
|
+
).map((e) => ({ value: e.many_field, label: `${e.many_field} → ${e.one_collection}` })), R = g(
|
|
57
|
+
"field.group_field",
|
|
58
|
+
typeof d.group_field == "string" ? d.group_field : ""
|
|
59
|
+
), Q = g(
|
|
60
|
+
"field.option_field",
|
|
61
|
+
typeof d.option_field == "string" ? d.option_field : ""
|
|
62
|
+
), B = (P = ee(ie)) == null ? void 0 : P.draft.dependency_config, I = re((B ?? E).cascade_filters), v = new Set(l.globals.map((e) => e.field));
|
|
63
|
+
for (const e of l.relations)
|
|
64
|
+
e.one_field && e.one_field !== "id" && e.one_collection === b.collection && v.add(e.one_field), e.many_field && e.many_collection === b.collection && v.add(e.many_field);
|
|
65
|
+
const U = [...v].filter((e) => e !== o.field).map((e) => ({ f: e, kind: de(e, l.relations) })).filter((e) => e.kind === "M2O" || e.kind === "M2M").map(({ f: e, kind: n }) => {
|
|
66
|
+
const w = b.bundle.placements.find((J) => J.field === e) ?? null;
|
|
67
|
+
return {
|
|
68
|
+
field: e,
|
|
69
|
+
label: se(e, l.globals, l.relations, w).label,
|
|
70
|
+
kind: n
|
|
71
|
+
};
|
|
72
|
+
}).sort((e, n) => e.label.localeCompare(n.label)), C = (e, n) => typeof d[e] == "boolean" ? d[e] : n, V = g("field.allow_upload", C("allow_upload", !0)), z = g("field.allow_pick", C("allow_pick", !0)), H = g("field.pending_save", C("pending_save", !1));
|
|
73
|
+
return /* @__PURE__ */ s("div", { className: "space-y-5", children: [
|
|
74
|
+
(c || h) && /* @__PURE__ */ s(X, { children: [
|
|
75
|
+
/* @__PURE__ */ t(
|
|
76
|
+
p,
|
|
77
|
+
{
|
|
78
|
+
k: "field.inline_relation",
|
|
79
|
+
label: "Edit the related record here",
|
|
80
|
+
effect: "Shows the picked record’s fields inline so people can change them without leaving.",
|
|
81
|
+
checked: a.inline_relation === !0,
|
|
82
|
+
onChange: (e) => l.setOption(
|
|
83
|
+
"inline_relation",
|
|
84
|
+
e ? !0 : void 0,
|
|
85
|
+
e ? `Edit ${i} inline` : `Stop editing ${i} inline`
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ t(
|
|
90
|
+
u,
|
|
91
|
+
{
|
|
92
|
+
k: "field.option_sort",
|
|
93
|
+
label: "Order of the options",
|
|
94
|
+
effect: 'Columns of the related record, "-" for descending; "label" sorts by what people read.',
|
|
95
|
+
children: /* @__PURE__ */ t(
|
|
96
|
+
ne,
|
|
97
|
+
{
|
|
98
|
+
ariaLabel: "Order of the options",
|
|
99
|
+
mono: !0,
|
|
100
|
+
value: typeof a.option_sort == "string" ? a.option_sort : "",
|
|
101
|
+
placeholder: "-year, name",
|
|
102
|
+
onChange: (e) => l.setOption(
|
|
103
|
+
"option_sort",
|
|
104
|
+
e.trim() ? e : void 0,
|
|
105
|
+
`Change the order of ${i} options`,
|
|
106
|
+
!0
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
)
|
|
110
|
+
}
|
|
111
|
+
)
|
|
112
|
+
] }),
|
|
113
|
+
c && /* @__PURE__ */ t(
|
|
114
|
+
p,
|
|
115
|
+
{
|
|
116
|
+
k: "field.enforce_picker_rules",
|
|
117
|
+
label: "Refuse values the picker would not offer",
|
|
118
|
+
effect: "The server rejects a value outside the cascade filters and option filters, from any writer.",
|
|
119
|
+
enforced: !0,
|
|
120
|
+
checked: a.enforce_picker_rules === !0,
|
|
121
|
+
onChange: (e) => l.setOption(
|
|
122
|
+
"enforce_picker_rules",
|
|
123
|
+
e ? !0 : void 0,
|
|
124
|
+
e ? `Enforce the picker rules of ${i}` : `Stop enforcing the picker rules of ${i}`
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
),
|
|
128
|
+
(c || h || _) && /* @__PURE__ */ s(O, { title: "Detail panel", children: [
|
|
129
|
+
/* @__PURE__ */ t(
|
|
130
|
+
p,
|
|
131
|
+
{
|
|
132
|
+
k: "field.drilldown.enabled",
|
|
133
|
+
label: "Click the value to open it",
|
|
134
|
+
effect: "Opens the related record in a side panel.",
|
|
135
|
+
checked: m,
|
|
136
|
+
onChange: (e) => k(
|
|
137
|
+
{ enabled: e },
|
|
138
|
+
e ? `Open ${i} in a panel` : `Stop opening ${i} in a panel`
|
|
139
|
+
)
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
/* @__PURE__ */ t(
|
|
143
|
+
u,
|
|
144
|
+
{
|
|
145
|
+
k: "field.drilldown.layout_id",
|
|
146
|
+
label: "Panel layout",
|
|
147
|
+
effect: "The layout the side panel shows the record with.",
|
|
148
|
+
children: /* @__PURE__ */ t(
|
|
149
|
+
$,
|
|
150
|
+
{
|
|
151
|
+
ariaLabel: "Panel layout",
|
|
152
|
+
disabled: !m,
|
|
153
|
+
value: f.layout_id == null ? "" : String(f.layout_id),
|
|
154
|
+
options: [
|
|
155
|
+
{ value: "", label: "The default detail view" },
|
|
156
|
+
...j.map((e) => ({ value: String(e.id), label: e.name }))
|
|
157
|
+
],
|
|
158
|
+
onChange: (e) => k({ layout_id: e ? Number(e) : null }, `Change the panel layout of ${i}`)
|
|
159
|
+
}
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
),
|
|
163
|
+
/* @__PURE__ */ s(
|
|
164
|
+
u,
|
|
165
|
+
{
|
|
166
|
+
k: "field.drilldown.width",
|
|
167
|
+
label: "Panel width",
|
|
168
|
+
effect: "A percent of the window (10–96%) or pixels (320–2000). Empty: the default.",
|
|
169
|
+
children: [
|
|
170
|
+
/* @__PURE__ */ t(
|
|
171
|
+
"input",
|
|
172
|
+
{
|
|
173
|
+
"aria-label": "Panel width",
|
|
174
|
+
disabled: !m,
|
|
175
|
+
value: G,
|
|
176
|
+
placeholder: "60%",
|
|
177
|
+
onChange: (e) => {
|
|
178
|
+
T(e.target.value);
|
|
179
|
+
const n = x(e.target.value);
|
|
180
|
+
n !== "invalid" && k({ width: n }, `Change the panel width of ${i}`, !0);
|
|
181
|
+
},
|
|
182
|
+
onBlur: () => b.flush(),
|
|
183
|
+
className: "h-7 w-full rounded-md border border-slate-200 bg-white px-2 font-mono text-[12px] focus:border-nvr-cyan focus:outline-none disabled:opacity-40 dark:border-border dark:bg-card"
|
|
184
|
+
}
|
|
185
|
+
),
|
|
186
|
+
D === "invalid" && /* @__PURE__ */ t("p", { className: "text-[11px] text-red-600 dark:text-red-400", children: "Not a width — nothing saved" })
|
|
187
|
+
]
|
|
188
|
+
}
|
|
189
|
+
)
|
|
190
|
+
] }),
|
|
191
|
+
F && /* @__PURE__ */ s(O, { title: "Grouped list", children: [
|
|
192
|
+
/* @__PURE__ */ t(
|
|
193
|
+
u,
|
|
194
|
+
{
|
|
195
|
+
k: "field.group_field",
|
|
196
|
+
label: "Group options by",
|
|
197
|
+
scope: "field",
|
|
198
|
+
effect: "A field of the related record whose value heads each group.",
|
|
199
|
+
children: /* @__PURE__ */ t(
|
|
200
|
+
$,
|
|
201
|
+
{
|
|
202
|
+
ariaLabel: "Group options by",
|
|
203
|
+
value: R,
|
|
204
|
+
options: [{ value: "", label: "Not grouped" }, ...N],
|
|
205
|
+
onChange: (e) => l.proposeGlobalOption(
|
|
206
|
+
"field.group_field",
|
|
207
|
+
"group_field",
|
|
208
|
+
e || void 0,
|
|
209
|
+
`Group the ${i} options`,
|
|
210
|
+
e
|
|
211
|
+
)
|
|
212
|
+
}
|
|
213
|
+
)
|
|
214
|
+
}
|
|
215
|
+
),
|
|
216
|
+
/* @__PURE__ */ t(
|
|
217
|
+
u,
|
|
218
|
+
{
|
|
219
|
+
k: "field.option_field",
|
|
220
|
+
label: "Option field",
|
|
221
|
+
scope: "field",
|
|
222
|
+
effect: "The field whose records are the options inside each group.",
|
|
223
|
+
children: /* @__PURE__ */ t(
|
|
224
|
+
$,
|
|
225
|
+
{
|
|
226
|
+
ariaLabel: "Option field",
|
|
227
|
+
value: Q,
|
|
228
|
+
options: [{ value: "", label: "The related record itself" }, ...N],
|
|
229
|
+
onChange: (e) => l.proposeGlobalOption(
|
|
230
|
+
"field.option_field",
|
|
231
|
+
"option_field",
|
|
232
|
+
e || void 0,
|
|
233
|
+
`Change the ${i} options`,
|
|
234
|
+
e
|
|
235
|
+
)
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
] }),
|
|
241
|
+
(c || h) && /* @__PURE__ */ t(
|
|
242
|
+
u,
|
|
243
|
+
{
|
|
244
|
+
k: "field.cascade_filters",
|
|
245
|
+
label: "Narrow the options by another field",
|
|
246
|
+
scope: "field",
|
|
247
|
+
effect: "Only options matching the value picked in a parent field are offered.",
|
|
248
|
+
children: /* @__PURE__ */ t(
|
|
249
|
+
le,
|
|
250
|
+
{
|
|
251
|
+
rules: I,
|
|
252
|
+
m2oFields: U,
|
|
253
|
+
relatedCollection: o.relatedCollection,
|
|
254
|
+
onChange: (e) => l.proposeGlobal(
|
|
255
|
+
"field.cascade_filters",
|
|
256
|
+
e,
|
|
257
|
+
`Change how ${i} options are narrowed`,
|
|
258
|
+
(n) => ({
|
|
259
|
+
...n,
|
|
260
|
+
dependency_config: ce(
|
|
261
|
+
n.dependency_config,
|
|
262
|
+
"cascade_filters",
|
|
263
|
+
e.length ? e : void 0
|
|
264
|
+
) ?? {}
|
|
265
|
+
})
|
|
266
|
+
)
|
|
267
|
+
}
|
|
268
|
+
)
|
|
269
|
+
}
|
|
270
|
+
),
|
|
271
|
+
S && /* @__PURE__ */ s(O, { title: "Files", children: [
|
|
272
|
+
/* @__PURE__ */ t(
|
|
273
|
+
p,
|
|
274
|
+
{
|
|
275
|
+
k: "field.allow_upload",
|
|
276
|
+
label: "Allow uploads",
|
|
277
|
+
effect: "People can upload new files into this field.",
|
|
278
|
+
scope: "field",
|
|
279
|
+
checked: V,
|
|
280
|
+
onChange: (e) => l.proposeGlobalOption(
|
|
281
|
+
"field.allow_upload",
|
|
282
|
+
"allow_upload",
|
|
283
|
+
e,
|
|
284
|
+
e ? `Allow uploads to ${i}` : `Stop uploads to ${i}`
|
|
285
|
+
)
|
|
286
|
+
}
|
|
287
|
+
),
|
|
288
|
+
/* @__PURE__ */ t(
|
|
289
|
+
p,
|
|
290
|
+
{
|
|
291
|
+
k: "field.allow_pick",
|
|
292
|
+
label: "Allow picking existing files",
|
|
293
|
+
effect: "People can attach files that are already stored.",
|
|
294
|
+
scope: "field",
|
|
295
|
+
checked: z,
|
|
296
|
+
onChange: (e) => l.proposeGlobalOption(
|
|
297
|
+
"field.allow_pick",
|
|
298
|
+
"allow_pick",
|
|
299
|
+
e,
|
|
300
|
+
`Change file picking for ${i}`
|
|
301
|
+
)
|
|
302
|
+
}
|
|
303
|
+
),
|
|
304
|
+
o.iface === "files-m2m" && /* @__PURE__ */ t(
|
|
305
|
+
p,
|
|
306
|
+
{
|
|
307
|
+
k: "field.pending_save",
|
|
308
|
+
label: "Save files with the form",
|
|
309
|
+
scope: "field",
|
|
310
|
+
effect: "Links wait for the record’s Save instead of saving at once.",
|
|
311
|
+
checked: H,
|
|
312
|
+
onChange: (e) => l.proposeGlobalOption(
|
|
313
|
+
"field.pending_save",
|
|
314
|
+
"pending_save",
|
|
315
|
+
e || void 0,
|
|
316
|
+
`Change when ${i} files save`,
|
|
317
|
+
e
|
|
318
|
+
)
|
|
319
|
+
}
|
|
320
|
+
)
|
|
321
|
+
] }),
|
|
322
|
+
!(c || h || _ || S) && /* @__PURE__ */ s("p", { className: "text-[12px] text-muted-foreground", children: [
|
|
323
|
+
i,
|
|
324
|
+
" is not a picker. Nothing to set here."
|
|
325
|
+
] })
|
|
326
|
+
] });
|
|
327
|
+
}
|
|
328
|
+
export {
|
|
329
|
+
Ce as PickerTab,
|
|
330
|
+
x as parsePanelWidth,
|
|
331
|
+
pe as useLayoutsOf,
|
|
332
|
+
fe as useRelationsFor
|
|
333
|
+
};
|