@nivaro/react 0.2.51 → 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 +4044 -3866
- package/dist/shared/components/RecordDrilldownSheet.js +114 -97
- package/dist/shared/components/RecordReadView.js +637 -570
- package/dist/shared/components/ai/ExplainButton.js +1 -1
- 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 +1 -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/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/request-gate.js +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { jsxs as p, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useQuery as K } from "@tanstack/react-query";
|
|
3
|
+
import { X as L } from "lucide-react";
|
|
4
|
+
import { useNivaroClient as P } from "../../../context.js";
|
|
5
|
+
import { get as q } from "../../../lib/commands.js";
|
|
6
|
+
import { cn as F, titleCase as I } from "../../../lib/utils.js";
|
|
7
|
+
import { FieldDefaultValueControl as j } from "../editors/field-default-value.js";
|
|
8
|
+
import { RoleConditionRow as B, PipelineStateConditionRow as V } from "../editors/lock-conditions.js";
|
|
9
|
+
import { tintCard as D } from "../panel-style.js";
|
|
10
|
+
import { useFieldCtx as E } from "./field-context.js";
|
|
11
|
+
import { Toggle as m, Setting as f, Segmented as G, AddButton as Q, Section as O, TextInput as A, Choice as N } from "./kit.js";
|
|
12
|
+
import { lockConditionsOf as W, layoutGrids as H, asObject as X, defaultValuesOf as z, withDefaultValue as J, lockConditionsColumn as U } from "./model.js";
|
|
13
|
+
const Y = /* @__PURE__ */ new Set([
|
|
14
|
+
"inline-table",
|
|
15
|
+
"inline-grid",
|
|
16
|
+
"list-o2m",
|
|
17
|
+
"list-m2m",
|
|
18
|
+
"list-o2m-tree-view",
|
|
19
|
+
"m2m",
|
|
20
|
+
"o2m",
|
|
21
|
+
"relation-path"
|
|
22
|
+
]);
|
|
23
|
+
function Z(a, i) {
|
|
24
|
+
const d = P();
|
|
25
|
+
return K({
|
|
26
|
+
queryKey: ["layout-editor", "field-rows", a, i ?? null],
|
|
27
|
+
queryFn: () => d.request(
|
|
28
|
+
q(`/field-config/${a}`, i ? { layout_id: i } : void 0)
|
|
29
|
+
).then((s) => Array.isArray(s.data) ? s.data : []),
|
|
30
|
+
enabled: !!a,
|
|
31
|
+
staleTime: 6e4
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
function pe() {
|
|
35
|
+
const a = E(), { info: i, ov: d, opts: s, env: c, row: y } = a, l = i.label, w = c.bundle.layout, x = y.field.startsWith("__") || i.isPath, h = W(y), b = (e, o) => a.setPlacement({ lock_conditions: U(e) }, o), _ = (e, o, n) => b(
|
|
36
|
+
h.map((u, C) => C === e ? { ...u, ...o } : u),
|
|
37
|
+
n
|
|
38
|
+
), g = H(c.bundle, a.globals, a.relations), $ = !x && i.relKind !== "M2M" && i.relKind !== "O2M" && !Y.has(i.iface ?? "") && g.length > 0, r = X(d.apply_to_lines), v = g.find((e) => e.field === r.grid) ?? null, { data: R = [] } = Z($ ? v == null ? void 0 : v.childCollection : null), S = R.filter(
|
|
39
|
+
(e) => e.field !== "id" && !e.field.startsWith("__") && !e.field.includes(".") && !["alias", "o2m", "m2m"].includes(e.type ?? "")
|
|
40
|
+
), M = (e, o) => a.setOverride("apply_to_lines", e ?? void 0, o), T = z(w), k = typeof s.max_values == "number" ? s.max_values : null;
|
|
41
|
+
return /* @__PURE__ */ p("div", { className: "space-y-5", children: [
|
|
42
|
+
/* @__PURE__ */ t(
|
|
43
|
+
m,
|
|
44
|
+
{
|
|
45
|
+
k: "field.required",
|
|
46
|
+
label: "Required",
|
|
47
|
+
effect: "The form will not save without a value.",
|
|
48
|
+
checked: d.required === !0,
|
|
49
|
+
onChange: (e) => a.setOverride(
|
|
50
|
+
"required",
|
|
51
|
+
e ? !0 : void 0,
|
|
52
|
+
e ? `Make ${l} required` : `Make ${l} optional`
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
),
|
|
56
|
+
/* @__PURE__ */ t(
|
|
57
|
+
m,
|
|
58
|
+
{
|
|
59
|
+
k: "field.readonly",
|
|
60
|
+
label: "Read-only",
|
|
61
|
+
effect: "Shown but not editable on this form.",
|
|
62
|
+
checked: d.readonly === !0,
|
|
63
|
+
onChange: (e) => a.setOverride(
|
|
64
|
+
"readonly",
|
|
65
|
+
e ? !0 : void 0,
|
|
66
|
+
e ? `Make ${l} read-only` : `Make ${l} editable`
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
),
|
|
70
|
+
(i.computedType === "rollup" || i.computedType === "write") && /* @__PURE__ */ t(
|
|
71
|
+
m,
|
|
72
|
+
{
|
|
73
|
+
k: "field.editable_computed",
|
|
74
|
+
label: "Allow manual entry",
|
|
75
|
+
effect: "Lets people type over the calculated value here; the next recalculation still overwrites it.",
|
|
76
|
+
checked: d.editable_computed === !0,
|
|
77
|
+
onChange: (e) => a.setOverride(
|
|
78
|
+
"editable_computed",
|
|
79
|
+
e ? !0 : void 0,
|
|
80
|
+
e ? `Allow typing into ${l}` : `Keep ${l} calculated only`
|
|
81
|
+
)
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ t(
|
|
85
|
+
f,
|
|
86
|
+
{
|
|
87
|
+
k: "field.lock_conditions",
|
|
88
|
+
label: "Read-only when",
|
|
89
|
+
effect: "Locks the field while any of these holds. No conditions: always editable.",
|
|
90
|
+
children: /* @__PURE__ */ p("div", { className: "space-y-2", children: [
|
|
91
|
+
h.map((e, o) => /* @__PURE__ */ p(
|
|
92
|
+
"div",
|
|
93
|
+
{
|
|
94
|
+
className: F(D, "space-y-3 p-3"),
|
|
95
|
+
children: [
|
|
96
|
+
/* @__PURE__ */ p("div", { className: "flex items-center gap-1.5", children: [
|
|
97
|
+
/* @__PURE__ */ t("div", { className: "flex-1", "data-setting": "field.lock_conditions.type", children: /* @__PURE__ */ t(
|
|
98
|
+
G,
|
|
99
|
+
{
|
|
100
|
+
value: e.type,
|
|
101
|
+
options: [
|
|
102
|
+
{ value: "pipeline_state", label: "Pipeline state" },
|
|
103
|
+
{ value: "role", label: "Role" }
|
|
104
|
+
],
|
|
105
|
+
onChange: (n) => b(
|
|
106
|
+
h.map(
|
|
107
|
+
(u, C) => C === o ? n === "role" ? { type: "role", role_ids: [] } : { type: "pipeline_state", state_keys: [] } : u
|
|
108
|
+
),
|
|
109
|
+
`Change a lock condition of ${l}`
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
) }),
|
|
113
|
+
/* @__PURE__ */ t(
|
|
114
|
+
"button",
|
|
115
|
+
{
|
|
116
|
+
type: "button",
|
|
117
|
+
"aria-label": "Remove condition",
|
|
118
|
+
onClick: () => b(
|
|
119
|
+
h.filter((n, u) => u !== o),
|
|
120
|
+
`Remove a lock condition from ${l}`
|
|
121
|
+
),
|
|
122
|
+
"data-tip": "Remove condition",
|
|
123
|
+
className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
|
|
124
|
+
children: /* @__PURE__ */ t(L, { className: "h-3.5 w-3.5" })
|
|
125
|
+
}
|
|
126
|
+
)
|
|
127
|
+
] }),
|
|
128
|
+
e.type === "role" ? /* @__PURE__ */ t("div", { "data-setting": "field.lock_conditions.role_ids", children: /* @__PURE__ */ t(
|
|
129
|
+
B,
|
|
130
|
+
{
|
|
131
|
+
roleIds: e.role_ids ?? [],
|
|
132
|
+
onRoleIdsChange: (n) => _(o, { role_ids: n }, `Change the roles that lock ${l}`)
|
|
133
|
+
}
|
|
134
|
+
) }) : /* @__PURE__ */ t(
|
|
135
|
+
V,
|
|
136
|
+
{
|
|
137
|
+
collection: c.collection,
|
|
138
|
+
pipelineId: e.pipeline_id,
|
|
139
|
+
stateKeys: e.state_keys ?? [],
|
|
140
|
+
onPipelineChange: (n) => _(
|
|
141
|
+
o,
|
|
142
|
+
{ pipeline_id: n, state_keys: [] },
|
|
143
|
+
`Change the pipeline that locks ${l}`
|
|
144
|
+
),
|
|
145
|
+
onStateKeysChange: (n) => _(o, { state_keys: n }, `Change the states that lock ${l}`)
|
|
146
|
+
}
|
|
147
|
+
)
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
o
|
|
151
|
+
)),
|
|
152
|
+
/* @__PURE__ */ t(
|
|
153
|
+
Q,
|
|
154
|
+
{
|
|
155
|
+
onClick: () => b(
|
|
156
|
+
[...h, { type: "pipeline_state", state_keys: [] }],
|
|
157
|
+
`Add a lock condition to ${l}`
|
|
158
|
+
),
|
|
159
|
+
children: "+ Add condition"
|
|
160
|
+
}
|
|
161
|
+
)
|
|
162
|
+
] })
|
|
163
|
+
}
|
|
164
|
+
),
|
|
165
|
+
!x && i.relKind !== "O2M" && /* @__PURE__ */ t(
|
|
166
|
+
f,
|
|
167
|
+
{
|
|
168
|
+
k: "field.default_value",
|
|
169
|
+
label: "Default for new records",
|
|
170
|
+
effect: "Filled in when someone creates a record on this form.",
|
|
171
|
+
children: /* @__PURE__ */ t("div", { onBlurCapture: () => c.flush(), children: /* @__PURE__ */ t(
|
|
172
|
+
j,
|
|
173
|
+
{
|
|
174
|
+
value: T[y.field],
|
|
175
|
+
onChange: (e, o) => c.apply(
|
|
176
|
+
[
|
|
177
|
+
{
|
|
178
|
+
op: "layout_update",
|
|
179
|
+
patch: { default_values: J(w, y.field, e) }
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
{ label: `Change the default of ${l}`, text: o }
|
|
183
|
+
),
|
|
184
|
+
isM2O: i.relKind === "M2O",
|
|
185
|
+
isM2M: i.relKind === "M2M",
|
|
186
|
+
relatedCollection: i.relatedCollection,
|
|
187
|
+
settings: { options: a.globalOptions, interface: i.iface },
|
|
188
|
+
abstractType: i.type
|
|
189
|
+
}
|
|
190
|
+
) })
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
i.relKind === "M2M" && /* @__PURE__ */ p(O, { title: "How many", children: [
|
|
194
|
+
/* @__PURE__ */ t(
|
|
195
|
+
f,
|
|
196
|
+
{
|
|
197
|
+
k: "field.max_values",
|
|
198
|
+
label: "Most values",
|
|
199
|
+
effect: "Empty: no limit. 1 makes it a single pick.",
|
|
200
|
+
children: /* @__PURE__ */ t(
|
|
201
|
+
A,
|
|
202
|
+
{
|
|
203
|
+
type: "number",
|
|
204
|
+
ariaLabel: "Most values",
|
|
205
|
+
value: k == null ? "" : String(k),
|
|
206
|
+
placeholder: "No limit",
|
|
207
|
+
onChange: (e) => {
|
|
208
|
+
const o = e === "" ? void 0 : Math.max(1, Math.round(Number(e)));
|
|
209
|
+
o !== void 0 && Number.isNaN(o) || a.setOption("max_values", o, `Limit how many ${l} can be picked`, !0);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
),
|
|
215
|
+
k != null && /* @__PURE__ */ t(
|
|
216
|
+
m,
|
|
217
|
+
{
|
|
218
|
+
k: "field.max_values_enforce_on_write",
|
|
219
|
+
label: "Refuse more on the server too",
|
|
220
|
+
effect: "Imports, the API and other forms cannot store more than the limit.",
|
|
221
|
+
enforced: !0,
|
|
222
|
+
checked: s.enforce_on_write === !0,
|
|
223
|
+
onChange: (e) => a.setOption(
|
|
224
|
+
"enforce_on_write",
|
|
225
|
+
e ? !0 : void 0,
|
|
226
|
+
e ? `Enforce the limit of ${l} on the server` : `Stop enforcing the limit of ${l}`
|
|
227
|
+
)
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] }),
|
|
231
|
+
$ && /* @__PURE__ */ p(O, { title: "Apply to lines", children: [
|
|
232
|
+
/* @__PURE__ */ t("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "A button beside the field copies its value into one column of every line of a grid." }),
|
|
233
|
+
/* @__PURE__ */ t(
|
|
234
|
+
f,
|
|
235
|
+
{
|
|
236
|
+
k: "field.apply_to_lines.grid",
|
|
237
|
+
label: "Grid",
|
|
238
|
+
effect: "The grid whose lines get the value.",
|
|
239
|
+
children: /* @__PURE__ */ t(
|
|
240
|
+
N,
|
|
241
|
+
{
|
|
242
|
+
ariaLabel: "Grid",
|
|
243
|
+
value: r.grid ?? "",
|
|
244
|
+
options: [
|
|
245
|
+
{ value: "", label: "Off" },
|
|
246
|
+
...g.map((e) => ({ value: e.field, label: e.label }))
|
|
247
|
+
],
|
|
248
|
+
onChange: (e) => M(
|
|
249
|
+
e ? { grid: e, target: "", ...r.label ? { label: r.label } : {} } : null,
|
|
250
|
+
e ? `Copy ${l} into lines` : `Stop copying ${l} into lines`
|
|
251
|
+
)
|
|
252
|
+
}
|
|
253
|
+
)
|
|
254
|
+
}
|
|
255
|
+
),
|
|
256
|
+
/* @__PURE__ */ t(
|
|
257
|
+
f,
|
|
258
|
+
{
|
|
259
|
+
k: "field.apply_to_lines.target",
|
|
260
|
+
label: "Column",
|
|
261
|
+
effect: "The column of each line that receives the value.",
|
|
262
|
+
children: /* @__PURE__ */ t(
|
|
263
|
+
N,
|
|
264
|
+
{
|
|
265
|
+
ariaLabel: "Column",
|
|
266
|
+
disabled: !r.grid,
|
|
267
|
+
value: r.target ?? "",
|
|
268
|
+
options: [
|
|
269
|
+
{ value: "", label: r.grid ? "Pick a column…" : "Pick a grid first" },
|
|
270
|
+
...S.map((e) => ({ value: e.field, label: e.label || I(e.field) }))
|
|
271
|
+
],
|
|
272
|
+
onChange: (e) => M({ ...r, target: e }, `Copy ${l} into a column`)
|
|
273
|
+
}
|
|
274
|
+
)
|
|
275
|
+
}
|
|
276
|
+
),
|
|
277
|
+
/* @__PURE__ */ t(
|
|
278
|
+
f,
|
|
279
|
+
{
|
|
280
|
+
k: "field.apply_to_lines.label",
|
|
281
|
+
label: "Button label",
|
|
282
|
+
effect: "The words on the button.",
|
|
283
|
+
children: /* @__PURE__ */ t(
|
|
284
|
+
A,
|
|
285
|
+
{
|
|
286
|
+
ariaLabel: "Button label",
|
|
287
|
+
disabled: !r.grid,
|
|
288
|
+
value: r.label ?? "",
|
|
289
|
+
placeholder: "Apply to lines",
|
|
290
|
+
onChange: (e) => {
|
|
291
|
+
const { label: o, ...n } = r;
|
|
292
|
+
a.setOverride(
|
|
293
|
+
"apply_to_lines",
|
|
294
|
+
e ? { ...n, label: e } : n,
|
|
295
|
+
`Rename the apply-to-lines button of ${l}`,
|
|
296
|
+
!0
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
)
|
|
301
|
+
}
|
|
302
|
+
)
|
|
303
|
+
] }),
|
|
304
|
+
c.layoutType === "addendum" && /* @__PURE__ */ t(
|
|
305
|
+
m,
|
|
306
|
+
{
|
|
307
|
+
k: "field.prefill_from_parent",
|
|
308
|
+
label: "Prefill from the record",
|
|
309
|
+
effect: "A new addendum starts with the record's current value.",
|
|
310
|
+
checked: d.prefill_from_parent !== !1,
|
|
311
|
+
onChange: (e) => a.setOverride(
|
|
312
|
+
"prefill_from_parent",
|
|
313
|
+
e ? void 0 : !1,
|
|
314
|
+
e ? `Prefill ${l} from the record` : `Start ${l} empty on addendums`
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
)
|
|
318
|
+
] });
|
|
319
|
+
}
|
|
320
|
+
export {
|
|
321
|
+
pe as RulesTab,
|
|
322
|
+
Z as useFieldRows
|
|
323
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { jsxs as c, Fragment as m, jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { HEADER_GROUP_KEY as b, CANVAS_SLOT_KEYS as S } from "../../../lib/layout-ops.js";
|
|
3
|
+
import { PdfFieldConfig as y } from "../editors/pdf-field-config.js";
|
|
4
|
+
import { slotName as F } from "../slot-names.js";
|
|
5
|
+
import { useInspectorEnv as g, Setting as u, TextInput as D, Toggle as h, Section as v, Buffered as P, Choice as N, Segmented as O } from "./kit.js";
|
|
6
|
+
import { readOverrides as T, rowlessExpanded as $, placeSlotOps as A, withKey as E } from "./model.js";
|
|
7
|
+
import { useLayoutsOf as H } from "./PickerTab.js";
|
|
8
|
+
const R = [
|
|
9
|
+
{ value: "12", label: "Full" },
|
|
10
|
+
{ value: "6", label: "½" },
|
|
11
|
+
{ value: "4", label: "⅓" },
|
|
12
|
+
{ value: "3", label: "¼" }
|
|
13
|
+
];
|
|
14
|
+
function L(l, s, t) {
|
|
15
|
+
const r = g();
|
|
16
|
+
return (i, n, p) => r.apply(
|
|
17
|
+
t ? [{ op: "update_placement", at: { field: l, group_key: s }, patch: i }] : A(r.bundle, l, s, i),
|
|
18
|
+
{ label: n, text: p }
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
function M({
|
|
22
|
+
field: l,
|
|
23
|
+
groupKey: s,
|
|
24
|
+
row: t
|
|
25
|
+
}) {
|
|
26
|
+
const r = g(), i = L(l, s, t), n = F(l), p = S.includes(l), o = T(t), d = (e, f, _, x) => i({ overrides: E(o, e, f) }, _, x), { data: k = [] } = H(l === "__pdf__" ? r.collection : null), C = k.filter((e) => e.layout_type === "file");
|
|
27
|
+
return /* @__PURE__ */ c("div", { className: "space-y-5", children: [
|
|
28
|
+
p && /* @__PURE__ */ c(m, { children: [
|
|
29
|
+
/* @__PURE__ */ a(u, { k: "slot.label_override", label: "Title", effect: `Empty uses "${n}".`, children: /* @__PURE__ */ a(
|
|
30
|
+
D,
|
|
31
|
+
{
|
|
32
|
+
ariaLabel: "Title",
|
|
33
|
+
value: (t == null ? void 0 : t.label_override) ?? "",
|
|
34
|
+
placeholder: n,
|
|
35
|
+
onChange: (e) => i({ label_override: e.trim() && e !== n ? e : null }, `Rename ${n}`, !0)
|
|
36
|
+
}
|
|
37
|
+
) }),
|
|
38
|
+
/* @__PURE__ */ a(
|
|
39
|
+
h,
|
|
40
|
+
{
|
|
41
|
+
k: "slot.is_visible",
|
|
42
|
+
label: "Show on this form",
|
|
43
|
+
effect: "Off leaves the panel off this form.",
|
|
44
|
+
checked: (t == null ? void 0 : t.is_visible) ?? !0,
|
|
45
|
+
onChange: (e) => i({ is_visible: e }, e ? `Show ${n}` : `Hide ${n}`)
|
|
46
|
+
}
|
|
47
|
+
),
|
|
48
|
+
/* @__PURE__ */ a(
|
|
49
|
+
h,
|
|
50
|
+
{
|
|
51
|
+
k: "slot.default_expanded",
|
|
52
|
+
label: "Starts open",
|
|
53
|
+
effect: "Off shows the panel folded until someone opens it.",
|
|
54
|
+
checked: (t == null ? void 0 : t.default_expanded) ?? $(l),
|
|
55
|
+
onChange: (e) => i(
|
|
56
|
+
{ default_expanded: e },
|
|
57
|
+
e ? `Open ${n} at first` : `Collapse ${n} at first`
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] }),
|
|
62
|
+
l === "__pipeline__" && /* @__PURE__ */ c(v, { title: "Action buttons", children: [
|
|
63
|
+
/* @__PURE__ */ a("p", { className: "text-[12px] leading-snug text-slate-500 dark:text-muted-foreground", children: "The header can already show the transition buttons; hide them here to avoid doubles." }),
|
|
64
|
+
/* @__PURE__ */ a(
|
|
65
|
+
h,
|
|
66
|
+
{
|
|
67
|
+
k: "slot.pipeline.hide_actions_collapsed",
|
|
68
|
+
label: "Hide while collapsed",
|
|
69
|
+
effect: "No transition buttons while the panel is folded.",
|
|
70
|
+
checked: o.hide_actions_collapsed === !0,
|
|
71
|
+
onChange: (e) => d("hide_actions_collapsed", e || void 0, `Change the ${n} buttons`)
|
|
72
|
+
}
|
|
73
|
+
),
|
|
74
|
+
/* @__PURE__ */ a(
|
|
75
|
+
h,
|
|
76
|
+
{
|
|
77
|
+
k: "slot.pipeline.hide_actions_expanded",
|
|
78
|
+
label: "Hide while open",
|
|
79
|
+
effect: "No transition buttons while the panel is open.",
|
|
80
|
+
checked: o.hide_actions_expanded === !0,
|
|
81
|
+
onChange: (e) => d("hide_actions_expanded", e || void 0, `Change the ${n} buttons`)
|
|
82
|
+
}
|
|
83
|
+
),
|
|
84
|
+
/* @__PURE__ */ a(
|
|
85
|
+
h,
|
|
86
|
+
{
|
|
87
|
+
k: "slot.pipeline.show_approval_chain",
|
|
88
|
+
label: "Approval chain button",
|
|
89
|
+
effect: "A button that shows who approves next.",
|
|
90
|
+
checked: (t == null ? void 0 : t.show_approval_chain) ?? !1,
|
|
91
|
+
onChange: (e) => i(
|
|
92
|
+
{ show_approval_chain: e },
|
|
93
|
+
e ? "Show the approval chain button" : "Hide the approval chain button"
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
)
|
|
97
|
+
] }),
|
|
98
|
+
l === "__pdf__" && /* @__PURE__ */ c(m, { children: [
|
|
99
|
+
/* @__PURE__ */ a(P, { value: typeof o.filename_template == "string" ? o.filename_template : "", children: (e, f) => /* @__PURE__ */ a(
|
|
100
|
+
y,
|
|
101
|
+
{
|
|
102
|
+
tableName: r.collection,
|
|
103
|
+
value: typeof o.attach_to_field == "string" ? o.attach_to_field : null,
|
|
104
|
+
filenameTemplate: e || null,
|
|
105
|
+
onChange: (_) => d("attach_to_field", _ ?? void 0, "Change where the PDF is attached"),
|
|
106
|
+
onFilenameChange: (_) => d(
|
|
107
|
+
"filename_template",
|
|
108
|
+
f(_ ?? "") || void 0,
|
|
109
|
+
"Change the PDF file name",
|
|
110
|
+
!0
|
|
111
|
+
)
|
|
112
|
+
}
|
|
113
|
+
) }),
|
|
114
|
+
/* @__PURE__ */ c(v, { title: "Advanced", collapsible: !0, children: [
|
|
115
|
+
/* @__PURE__ */ a(
|
|
116
|
+
u,
|
|
117
|
+
{
|
|
118
|
+
k: "pdf_button.source_layout_id",
|
|
119
|
+
label: "Render from",
|
|
120
|
+
effect: "A PDF layout of this collection; otherwise the form itself.",
|
|
121
|
+
children: /* @__PURE__ */ a(
|
|
122
|
+
N,
|
|
123
|
+
{
|
|
124
|
+
ariaLabel: "Render from",
|
|
125
|
+
value: typeof o.source_layout_id == "number" ? String(o.source_layout_id) : "",
|
|
126
|
+
options: [
|
|
127
|
+
{ value: "", label: "This form" },
|
|
128
|
+
...C.map((e) => ({ value: String(e.id), label: e.name }))
|
|
129
|
+
],
|
|
130
|
+
onChange: (e) => d(
|
|
131
|
+
"source_layout_id",
|
|
132
|
+
e ? Number(e) : void 0,
|
|
133
|
+
"Change what the PDF renders"
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
),
|
|
139
|
+
/* @__PURE__ */ a(
|
|
140
|
+
h,
|
|
141
|
+
{
|
|
142
|
+
k: "pdf_button.auto_generate_on_save",
|
|
143
|
+
label: "Make the PDF on every save",
|
|
144
|
+
effect: "Each save of the record makes a new PDF.",
|
|
145
|
+
checked: o.auto_generate_on_save === !0,
|
|
146
|
+
onChange: (e) => d("auto_generate_on_save", e || void 0, "Change when the PDF is made")
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
/* @__PURE__ */ a(
|
|
150
|
+
h,
|
|
151
|
+
{
|
|
152
|
+
k: "pdf_button.overwrite_generated",
|
|
153
|
+
label: "Replace the last generated PDF",
|
|
154
|
+
effect: "Off keeps every generated file.",
|
|
155
|
+
checked: o.overwrite_generated !== !1,
|
|
156
|
+
onChange: (e) => d("overwrite_generated", e ? void 0 : !1, "Change how PDFs are kept")
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
] })
|
|
160
|
+
] }),
|
|
161
|
+
!p && s !== null && s !== b && /* @__PURE__ */ a(u, { k: "field.col_span", label: "Width", effect: "Share of the row it takes.", children: /* @__PURE__ */ a(
|
|
162
|
+
O,
|
|
163
|
+
{
|
|
164
|
+
value: String((t == null ? void 0 : t.col_span) ?? 12),
|
|
165
|
+
options: R,
|
|
166
|
+
onChange: (e) => i({ col_span: e === "12" ? null : Number(e) }, `Change the width of ${n}`)
|
|
167
|
+
}
|
|
168
|
+
) }),
|
|
169
|
+
!p && l !== "__pdf__" && (s === null || s === b) && /* @__PURE__ */ c("p", { className: "text-[13px] text-slate-500 dark:text-muted-foreground", children: [
|
|
170
|
+
n,
|
|
171
|
+
" has no settings beyond its place."
|
|
172
|
+
] })
|
|
173
|
+
] });
|
|
174
|
+
}
|
|
175
|
+
export {
|
|
176
|
+
M as SlotInspector,
|
|
177
|
+
R as WIDTHS,
|
|
178
|
+
L as useSlotWriter
|
|
179
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { jsxs as s, jsx as i, Fragment as m } from "react/jsx-runtime";
|
|
2
|
+
import { X as g } from "lucide-react";
|
|
3
|
+
import { cn as v } from "../../../lib/utils.js";
|
|
4
|
+
import { tintCard as y } from "../panel-style.js";
|
|
5
|
+
import { FieldPicker as w } from "../pickers/field-picker.js";
|
|
6
|
+
import { useCollectionMeta as C } from "./field-context.js";
|
|
7
|
+
import { COLORS as _, WEIGHTS as k, DISPLAY_AS as x } from "./HeaderItemInspector.js";
|
|
8
|
+
import { useInspectorEnv as L, Toggle as S, Setting as u, TextInput as I, Choice as f } from "./kit.js";
|
|
9
|
+
import { subtitleOf as N, findPlacement as j, SUBTITLE_FIELD as d, subtitleBindings as h } from "./model.js";
|
|
10
|
+
function D() {
|
|
11
|
+
const o = L(), { data: n } = C(o.collection), t = N(o.bundle), b = j(o.bundle, d, null), r = (e, a, l) => o.apply(
|
|
12
|
+
[
|
|
13
|
+
{
|
|
14
|
+
op: "update_placement",
|
|
15
|
+
at: { field: d, group_key: null },
|
|
16
|
+
patch: { input_bindings: h(e) }
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
{ label: a, text: l }
|
|
20
|
+
), c = (e, a) => t && r(
|
|
21
|
+
{ ...t, fields: t.fields.map((l, p) => p === e ? { ...l, ...a } : l) },
|
|
22
|
+
"Change the subtitle"
|
|
23
|
+
);
|
|
24
|
+
return /* @__PURE__ */ s("div", { className: "space-y-5", children: [
|
|
25
|
+
/* @__PURE__ */ i(
|
|
26
|
+
S,
|
|
27
|
+
{
|
|
28
|
+
k: "subtitle.enabled",
|
|
29
|
+
label: "Subtitle under the title",
|
|
30
|
+
effect: "Fields shown on one line below the record title.",
|
|
31
|
+
checked: !!b,
|
|
32
|
+
onChange: (e) => o.apply(
|
|
33
|
+
e ? [
|
|
34
|
+
{
|
|
35
|
+
op: "place",
|
|
36
|
+
field: d,
|
|
37
|
+
group_key: null,
|
|
38
|
+
index: 0,
|
|
39
|
+
patch: { input_bindings: h({ fields: [], separator: " | " }) }
|
|
40
|
+
}
|
|
41
|
+
] : [{ op: "remove", at: { field: d, group_key: null } }],
|
|
42
|
+
{ label: e ? "Add a subtitle" : "Remove the subtitle" }
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
t && /* @__PURE__ */ s(m, { children: [
|
|
47
|
+
/* @__PURE__ */ i(
|
|
48
|
+
u,
|
|
49
|
+
{
|
|
50
|
+
k: "subtitle.separator",
|
|
51
|
+
label: "Between fields",
|
|
52
|
+
effect: "The text placed between the subtitle fields.",
|
|
53
|
+
children: /* @__PURE__ */ i(
|
|
54
|
+
I,
|
|
55
|
+
{
|
|
56
|
+
ariaLabel: "Between fields",
|
|
57
|
+
value: t.separator,
|
|
58
|
+
placeholder: " | ",
|
|
59
|
+
onChange: (e) => r({ ...t, separator: e }, "Change the subtitle separator", !0)
|
|
60
|
+
}
|
|
61
|
+
)
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ i(
|
|
65
|
+
u,
|
|
66
|
+
{
|
|
67
|
+
k: "subtitle.fields",
|
|
68
|
+
label: "Fields",
|
|
69
|
+
effect: "Fields of related records are allowed.",
|
|
70
|
+
children: /* @__PURE__ */ s("div", { className: "space-y-2", children: [
|
|
71
|
+
t.fields.map((e, a) => /* @__PURE__ */ s("div", { className: v(y, "space-y-3 p-3"), children: [
|
|
72
|
+
/* @__PURE__ */ s("div", { className: "flex items-center justify-between gap-2", children: [
|
|
73
|
+
/* @__PURE__ */ i("span", { className: "truncate text-[12px] text-foreground", children: e.label ?? e.field }),
|
|
74
|
+
/* @__PURE__ */ i(
|
|
75
|
+
"button",
|
|
76
|
+
{
|
|
77
|
+
type: "button",
|
|
78
|
+
"aria-label": `Remove ${e.label ?? e.field}`,
|
|
79
|
+
onClick: () => r(
|
|
80
|
+
{ ...t, fields: t.fields.filter((l, p) => p !== a) },
|
|
81
|
+
"Remove a subtitle field"
|
|
82
|
+
),
|
|
83
|
+
"data-tip": "Remove",
|
|
84
|
+
className: "inline-flex h-7 w-7 shrink-0 items-center justify-center rounded text-slate-500 transition-colors hover:bg-slate-100 hover:text-red-600 dark:hover:bg-muted dark:hover:text-red-400",
|
|
85
|
+
children: /* @__PURE__ */ i(g, { className: "h-3.5 w-3.5" })
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ s("div", { className: "grid grid-cols-3 gap-1", "data-setting": "subtitle.field_style", children: [
|
|
90
|
+
/* @__PURE__ */ i(
|
|
91
|
+
f,
|
|
92
|
+
{
|
|
93
|
+
ariaLabel: "Colour",
|
|
94
|
+
value: e.color ?? "",
|
|
95
|
+
options: _,
|
|
96
|
+
onChange: (l) => c(a, { color: l || void 0 })
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
/* @__PURE__ */ i(
|
|
100
|
+
f,
|
|
101
|
+
{
|
|
102
|
+
ariaLabel: "Weight",
|
|
103
|
+
value: e.weight ?? "",
|
|
104
|
+
options: k,
|
|
105
|
+
onChange: (l) => c(a, { weight: l || void 0 })
|
|
106
|
+
}
|
|
107
|
+
),
|
|
108
|
+
/* @__PURE__ */ i(
|
|
109
|
+
f,
|
|
110
|
+
{
|
|
111
|
+
ariaLabel: "Shown as",
|
|
112
|
+
value: e.display_as ?? "",
|
|
113
|
+
options: x,
|
|
114
|
+
onChange: (l) => c(a, { display_as: l || void 0 })
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] })
|
|
118
|
+
] }, e.field)),
|
|
119
|
+
/* @__PURE__ */ i(
|
|
120
|
+
w,
|
|
121
|
+
{
|
|
122
|
+
collection: o.collection,
|
|
123
|
+
fields: ((n == null ? void 0 : n.fields) ?? []).filter(
|
|
124
|
+
(e) => !e.field.startsWith("__") && !t.fields.some((a) => a.field === e.field)
|
|
125
|
+
).map((e) => ({
|
|
126
|
+
field: e.field,
|
|
127
|
+
type: e.type ?? "string",
|
|
128
|
+
interface: e.interface ?? null,
|
|
129
|
+
hidden: !!e.hidden
|
|
130
|
+
})),
|
|
131
|
+
relations: (n == null ? void 0 : n.relations) ?? [],
|
|
132
|
+
value: "",
|
|
133
|
+
placeholder: "+ Add field…",
|
|
134
|
+
onChange: (e) => r(
|
|
135
|
+
{
|
|
136
|
+
...t,
|
|
137
|
+
fields: [
|
|
138
|
+
...t.fields,
|
|
139
|
+
{ field: e.path.join("."), label: e.pathLabels.join(" › ") }
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"Add a subtitle field"
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
)
|
|
146
|
+
] })
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] })
|
|
150
|
+
] });
|
|
151
|
+
}
|
|
152
|
+
export {
|
|
153
|
+
D as SubtitleInspector
|
|
154
|
+
};
|