@nivaro/react 0.3.32 → 0.3.34
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 +89 -8
- package/dist/index.js +338 -328
- package/dist/shared/components/ForceReloadBanner.js +56 -46
- package/dist/shared/components/ItemEditForm.js +5637 -5442
- package/dist/shared/components/ProfileView.js +46 -44
- package/dist/shared/components/ReportView.js +208 -205
- package/dist/shared/components/SearchHighlight.js +30 -0
- package/dist/shared/components/TipLayer.js +39 -37
- package/dist/shared/components/item-edit/CatalogPickerField.js +1484 -1232
- package/dist/shared/components/item-edit/FieldAffordances.js +370 -203
- package/dist/shared/components/item-edit/FieldRow.js +396 -354
- package/dist/shared/components/item-edit/PersonalDefaultPill.js +50 -0
- package/dist/shared/components/item-edit/RelationCombobox.js +42 -41
- package/dist/shared/components/item-edit/catalog-search.js +34 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +34 -34
- package/dist/shared/components/item-edit/personal-default-checks.js +134 -0
- package/dist/shared/components/item-edit/usePersonalDefaults.js +358 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +130 -111
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +76 -75
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/profile/MyDefaultsCard.js +667 -0
- package/dist/shared/components/profile/PersonProfile.js +42 -40
- package/dist/shared/components/profile/my-defaults-labels.js +76 -0
- package/dist/shared/components/profile/primitives.js +72 -67
- package/dist/shared/lib/personal-defaults.js +76 -0
- package/dist/shared/lib/request-gate.js +78 -76
- package/dist/shared/lib/search-text.js +111 -0
- package/dist/shared/lib/unsaved-work.js +86 -38
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as c, jsx as
|
|
1
|
+
import { jsxs as c, jsx as l } from "react/jsx-runtime";
|
|
2
2
|
import { useQuery as j } from "@tanstack/react-query";
|
|
3
3
|
import { X as B } from "lucide-react";
|
|
4
|
-
import { useNivaroClient as
|
|
5
|
-
import { get as
|
|
6
|
-
import { cn as
|
|
4
|
+
import { useNivaroClient as D } from "../../../context.js";
|
|
5
|
+
import { get as E } from "../../../lib/commands.js";
|
|
6
|
+
import { cn as W, titleCase as G } from "../../../lib/utils.js";
|
|
7
7
|
import { FieldRuleWriter as Q } from "../ai-rules/FieldRuleWriter.js";
|
|
8
8
|
import { RuleWriter as H } from "../ai-rules/RuleWriter.js";
|
|
9
9
|
import { ValidationSuggest as X } from "../ai-rules/ValidationSuggest.js";
|
|
@@ -11,10 +11,10 @@ import { FieldDefaultValueControl as z } from "../editors/field-default-value.js
|
|
|
11
11
|
import { RoleConditionRow as J, PipelineStateConditionRow as U } from "../editors/lock-conditions.js";
|
|
12
12
|
import { useLayoutEditorHost as Y } from "../host.js";
|
|
13
13
|
import { tintCard as Z } from "../panel-style.js";
|
|
14
|
-
import { RecommendedToggle as ee, ConfirmChangeSetting as te, RepeatLastToggle as
|
|
15
|
-
import { useFieldCtx as
|
|
16
|
-
import { Toggle as g, Setting as
|
|
17
|
-
import { lockConditionsOf as
|
|
14
|
+
import { RecommendedToggle as ee, PersonalDefaultToggle as le, ConfirmChangeSetting as te, RepeatLastToggle as ie } from "./BehaviourSettings.js";
|
|
15
|
+
import { useFieldCtx as oe } from "./field-context.js";
|
|
16
|
+
import { Toggle as g, Setting as p, Segmented as ae, AddButton as ne, Section as R, TextInput as S, Choice as T } from "./kit.js";
|
|
17
|
+
import { lockConditionsOf as re, layoutGrids as de, asObject as se, defaultValuesOf as ce, withDefaultValue as ue, lockConditionsColumn as fe } from "./model.js";
|
|
18
18
|
const L = /* @__PURE__ */ new Set([
|
|
19
19
|
"inline-table",
|
|
20
20
|
"inline-grid",
|
|
@@ -26,25 +26,25 @@ const L = /* @__PURE__ */ new Set([
|
|
|
26
26
|
"relation-path"
|
|
27
27
|
]);
|
|
28
28
|
function pe(a, i) {
|
|
29
|
-
const u =
|
|
29
|
+
const u = D();
|
|
30
30
|
return j({
|
|
31
31
|
queryKey: ["layout-editor", "field-rows", a, i ?? null],
|
|
32
32
|
queryFn: () => u.request(
|
|
33
|
-
|
|
33
|
+
E(`/field-config/${a}`, i ? { layout_id: i } : void 0)
|
|
34
34
|
).then((m) => Array.isArray(m.data) ? m.data : []),
|
|
35
35
|
enabled: !!a,
|
|
36
36
|
staleTime: 6e4
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
const a =
|
|
41
|
-
b.map((d, h) => h === e ? { ...d, ...
|
|
39
|
+
function Te() {
|
|
40
|
+
const a = oe(), { info: i, ov: u, opts: m, env: s, row: f } = a, o = i.label, y = s.bundle.layout, v = f.field.startsWith("__") || i.isPath, b = re(f), _ = (e, t) => a.setPlacement({ lock_conditions: fe(e) }, t), w = (e, t, n) => _(
|
|
41
|
+
b.map((d, h) => h === e ? { ...d, ...t } : d),
|
|
42
42
|
n
|
|
43
|
-
), x =
|
|
43
|
+
), x = de(s.bundle, a.globals, a.relations), M = !v && i.relKind !== "M2M" && i.relKind !== "O2M" && !L.has(i.iface ?? "") && x.length > 0, r = se(u.apply_to_lines), $ = x.find((e) => e.field === r.grid) ?? null, { data: K = [] } = pe(M ? $ == null ? void 0 : $.childCollection : null), P = K.filter(
|
|
44
44
|
(e) => e.field !== "id" && !e.field.startsWith("__") && !e.field.includes(".") && !["alias", "o2m", "m2m"].includes(e.type ?? "")
|
|
45
|
-
), N = (e,
|
|
45
|
+
), N = (e, t) => a.setOverride("apply_to_lines", e ?? void 0, t), I = Y().isAdmin && !v && !i.relKind && !L.has(i.iface ?? "") && i.type !== "alias" && i.computedType !== "virtual", q = ce(y), A = typeof m.max_values == "number" ? m.max_values : null;
|
|
46
46
|
return /* @__PURE__ */ c("div", { className: "space-y-5", children: [
|
|
47
|
-
/* @__PURE__ */
|
|
47
|
+
/* @__PURE__ */ l(
|
|
48
48
|
g,
|
|
49
49
|
{
|
|
50
50
|
k: "field.required",
|
|
@@ -58,8 +58,8 @@ function Se() {
|
|
|
58
58
|
)
|
|
59
59
|
}
|
|
60
60
|
),
|
|
61
|
-
/* @__PURE__ */
|
|
62
|
-
/* @__PURE__ */
|
|
61
|
+
/* @__PURE__ */ l(ee, {}),
|
|
62
|
+
/* @__PURE__ */ l(
|
|
63
63
|
g,
|
|
64
64
|
{
|
|
65
65
|
k: "field.readonly",
|
|
@@ -73,9 +73,10 @@ function Se() {
|
|
|
73
73
|
)
|
|
74
74
|
}
|
|
75
75
|
),
|
|
76
|
-
/* @__PURE__ */
|
|
77
|
-
/* @__PURE__ */
|
|
78
|
-
|
|
76
|
+
/* @__PURE__ */ l(le, {}),
|
|
77
|
+
/* @__PURE__ */ l(te, {}),
|
|
78
|
+
/* @__PURE__ */ l(ie, {}),
|
|
79
|
+
(i.computedType === "rollup" || i.computedType === "write") && /* @__PURE__ */ l(
|
|
79
80
|
g,
|
|
80
81
|
{
|
|
81
82
|
k: "field.editable_computed",
|
|
@@ -89,21 +90,21 @@ function Se() {
|
|
|
89
90
|
)
|
|
90
91
|
}
|
|
91
92
|
),
|
|
92
|
-
/* @__PURE__ */
|
|
93
|
-
|
|
93
|
+
/* @__PURE__ */ l(
|
|
94
|
+
p,
|
|
94
95
|
{
|
|
95
96
|
k: "field.lock_conditions",
|
|
96
97
|
label: "Read-only when",
|
|
97
98
|
effect: "Locks the field while any of these holds. No conditions: always editable.",
|
|
98
99
|
children: /* @__PURE__ */ c("div", { className: "space-y-2", children: [
|
|
99
|
-
b.map((e,
|
|
100
|
+
b.map((e, t) => /* @__PURE__ */ c(
|
|
100
101
|
"div",
|
|
101
102
|
{
|
|
102
|
-
className:
|
|
103
|
+
className: W(Z, "space-y-3 p-3"),
|
|
103
104
|
children: [
|
|
104
105
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
|
|
105
|
-
/* @__PURE__ */
|
|
106
|
-
|
|
106
|
+
/* @__PURE__ */ l("div", { className: "flex-1", "data-setting": "field.lock_conditions.type", children: /* @__PURE__ */ l(
|
|
107
|
+
ae,
|
|
107
108
|
{
|
|
108
109
|
value: e.type,
|
|
109
110
|
options: [
|
|
@@ -112,54 +113,54 @@ function Se() {
|
|
|
112
113
|
],
|
|
113
114
|
onChange: (n) => _(
|
|
114
115
|
b.map(
|
|
115
|
-
(d, h) => h ===
|
|
116
|
+
(d, h) => h === t ? n === "role" ? { type: "role", role_ids: [] } : { type: "pipeline_state", state_keys: [] } : d
|
|
116
117
|
),
|
|
117
118
|
`Change a lock condition of ${o}`
|
|
118
119
|
)
|
|
119
120
|
}
|
|
120
121
|
) }),
|
|
121
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ l(
|
|
122
123
|
"button",
|
|
123
124
|
{
|
|
124
125
|
type: "button",
|
|
125
126
|
"aria-label": "Remove condition",
|
|
126
127
|
onClick: () => _(
|
|
127
|
-
b.filter((n, d) => d !==
|
|
128
|
+
b.filter((n, d) => d !== t),
|
|
128
129
|
`Remove a lock condition from ${o}`
|
|
129
130
|
),
|
|
130
131
|
"data-tip": "Remove condition",
|
|
131
132
|
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",
|
|
132
|
-
children: /* @__PURE__ */
|
|
133
|
+
children: /* @__PURE__ */ l(B, { className: "h-3.5 w-3.5" })
|
|
133
134
|
}
|
|
134
135
|
)
|
|
135
136
|
] }),
|
|
136
|
-
e.type === "role" ? /* @__PURE__ */
|
|
137
|
+
e.type === "role" ? /* @__PURE__ */ l("div", { "data-setting": "field.lock_conditions.role_ids", children: /* @__PURE__ */ l(
|
|
137
138
|
J,
|
|
138
139
|
{
|
|
139
140
|
roleIds: e.role_ids ?? [],
|
|
140
|
-
onRoleIdsChange: (n) => w(
|
|
141
|
+
onRoleIdsChange: (n) => w(t, { role_ids: n }, `Change the roles that lock ${o}`)
|
|
141
142
|
}
|
|
142
|
-
) }) : /* @__PURE__ */
|
|
143
|
+
) }) : /* @__PURE__ */ l(
|
|
143
144
|
U,
|
|
144
145
|
{
|
|
145
146
|
collection: s.collection,
|
|
146
147
|
pipelineId: e.pipeline_id,
|
|
147
148
|
stateKeys: e.state_keys ?? [],
|
|
148
149
|
onPipelineChange: (n) => w(
|
|
149
|
-
|
|
150
|
+
t,
|
|
150
151
|
{ pipeline_id: n, state_keys: [] },
|
|
151
152
|
`Change the pipeline that locks ${o}`
|
|
152
153
|
),
|
|
153
|
-
onStateKeysChange: (n) => w(
|
|
154
|
+
onStateKeysChange: (n) => w(t, { state_keys: n }, `Change the states that lock ${o}`)
|
|
154
155
|
}
|
|
155
156
|
)
|
|
156
157
|
]
|
|
157
158
|
},
|
|
158
|
-
|
|
159
|
+
t
|
|
159
160
|
)),
|
|
160
161
|
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
161
|
-
/* @__PURE__ */
|
|
162
|
-
|
|
162
|
+
/* @__PURE__ */ l(
|
|
163
|
+
ne,
|
|
163
164
|
{
|
|
164
165
|
onClick: () => _(
|
|
165
166
|
[...b, { type: "pipeline_state", state_keys: [] }],
|
|
@@ -168,13 +169,13 @@ function Se() {
|
|
|
168
169
|
children: "+ Add condition"
|
|
169
170
|
}
|
|
170
171
|
),
|
|
171
|
-
!v && /* @__PURE__ */
|
|
172
|
+
!v && /* @__PURE__ */ l(
|
|
172
173
|
H,
|
|
173
174
|
{
|
|
174
175
|
layoutId: Number(y.id),
|
|
175
|
-
target: { kind: "lock", field:
|
|
176
|
+
target: { kind: "lock", field: f.field },
|
|
176
177
|
bundle: s.bundle,
|
|
177
|
-
apply: (e,
|
|
178
|
+
apply: (e, t) => s.apply(e, t),
|
|
178
179
|
disabled: a.readOnly
|
|
179
180
|
}
|
|
180
181
|
)
|
|
@@ -183,24 +184,24 @@ function Se() {
|
|
|
183
184
|
}
|
|
184
185
|
),
|
|
185
186
|
!v && i.relKind !== "O2M" && /* @__PURE__ */ c(
|
|
186
|
-
|
|
187
|
+
p,
|
|
187
188
|
{
|
|
188
189
|
k: "field.default_value",
|
|
189
190
|
label: "Default for new records",
|
|
190
191
|
effect: "Filled in when someone creates a record on this form.",
|
|
191
192
|
children: [
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
+
/* @__PURE__ */ l("div", { onBlurCapture: () => s.flush(), children: /* @__PURE__ */ l(
|
|
193
194
|
z,
|
|
194
195
|
{
|
|
195
|
-
value: q[
|
|
196
|
-
onChange: (e,
|
|
196
|
+
value: q[f.field],
|
|
197
|
+
onChange: (e, t) => s.apply(
|
|
197
198
|
[
|
|
198
199
|
{
|
|
199
200
|
op: "layout_update",
|
|
200
|
-
patch: { default_values:
|
|
201
|
+
patch: { default_values: ue(y, f.field, e) }
|
|
201
202
|
}
|
|
202
203
|
],
|
|
203
|
-
{ label: `Change the default of ${o}`, text:
|
|
204
|
+
{ label: `Change the default of ${o}`, text: t }
|
|
204
205
|
),
|
|
205
206
|
isM2O: i.relKind === "M2O",
|
|
206
207
|
isM2M: i.relKind === "M2M",
|
|
@@ -209,32 +210,32 @@ function Se() {
|
|
|
209
210
|
abstractType: i.type
|
|
210
211
|
}
|
|
211
212
|
) }),
|
|
212
|
-
/* @__PURE__ */
|
|
213
|
+
/* @__PURE__ */ l("div", { className: "pt-1", children: /* @__PURE__ */ l(
|
|
213
214
|
Q,
|
|
214
215
|
{
|
|
215
216
|
layoutId: Number(y.id),
|
|
216
|
-
field:
|
|
217
|
+
field: f.field,
|
|
217
218
|
disabled: a.readOnly
|
|
218
219
|
}
|
|
219
220
|
) })
|
|
220
221
|
]
|
|
221
222
|
}
|
|
222
223
|
),
|
|
223
|
-
I && /* @__PURE__ */
|
|
224
|
-
|
|
224
|
+
I && /* @__PURE__ */ l(
|
|
225
|
+
p,
|
|
225
226
|
{
|
|
226
227
|
k: "field.validation_rules",
|
|
227
228
|
label: "Checks",
|
|
228
229
|
scope: "field",
|
|
229
230
|
effect: "Learned from the values stored today, each with how many existing values it would refuse.",
|
|
230
|
-
children: /* @__PURE__ */
|
|
231
|
+
children: /* @__PURE__ */ l(
|
|
231
232
|
X,
|
|
232
233
|
{
|
|
233
234
|
layoutId: Number(y.id),
|
|
234
|
-
field:
|
|
235
|
+
field: f.field,
|
|
235
236
|
disabled: a.readOnly,
|
|
236
|
-
onApply: (e,
|
|
237
|
-
const h = d.columns.validation_rules, O = Array.isArray(h) ? h :
|
|
237
|
+
onApply: (e, t, n) => a.proposeGlobal("field.validation_rules", e.length, n, (d) => {
|
|
238
|
+
const h = d.columns.validation_rules, O = Array.isArray(h) ? h : t, F = (k, C) => k.type === C.type && String(k.value ?? "") === String(C.value ?? ""), V = e.filter((k) => !O.some((C) => F(C, k)));
|
|
238
239
|
return { ...d, columns: { ...d.columns, validation_rules: [...O, ...V] } };
|
|
239
240
|
})
|
|
240
241
|
}
|
|
@@ -242,13 +243,13 @@ function Se() {
|
|
|
242
243
|
}
|
|
243
244
|
),
|
|
244
245
|
i.relKind === "M2M" && /* @__PURE__ */ c(R, { title: "How many", children: [
|
|
245
|
-
/* @__PURE__ */
|
|
246
|
-
|
|
246
|
+
/* @__PURE__ */ l(
|
|
247
|
+
p,
|
|
247
248
|
{
|
|
248
249
|
k: "field.max_values",
|
|
249
250
|
label: "Most values",
|
|
250
251
|
effect: "Empty: no limit. 1 makes it a single pick.",
|
|
251
|
-
children: /* @__PURE__ */
|
|
252
|
+
children: /* @__PURE__ */ l(
|
|
252
253
|
S,
|
|
253
254
|
{
|
|
254
255
|
type: "number",
|
|
@@ -256,14 +257,14 @@ function Se() {
|
|
|
256
257
|
value: A == null ? "" : String(A),
|
|
257
258
|
placeholder: "No limit",
|
|
258
259
|
onChange: (e) => {
|
|
259
|
-
const
|
|
260
|
-
|
|
260
|
+
const t = e === "" ? void 0 : Math.max(1, Math.round(Number(e)));
|
|
261
|
+
t !== void 0 && Number.isNaN(t) || a.setOption("max_values", t, `Limit how many ${o} can be picked`, !0);
|
|
261
262
|
}
|
|
262
263
|
}
|
|
263
264
|
)
|
|
264
265
|
}
|
|
265
266
|
),
|
|
266
|
-
A != null && /* @__PURE__ */
|
|
267
|
+
A != null && /* @__PURE__ */ l(
|
|
267
268
|
g,
|
|
268
269
|
{
|
|
269
270
|
k: "field.max_values_enforce_on_write",
|
|
@@ -280,14 +281,14 @@ function Se() {
|
|
|
280
281
|
)
|
|
281
282
|
] }),
|
|
282
283
|
M && /* @__PURE__ */ c(R, { title: "Apply to lines", children: [
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
/* @__PURE__ */
|
|
285
|
-
|
|
284
|
+
/* @__PURE__ */ l("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." }),
|
|
285
|
+
/* @__PURE__ */ l(
|
|
286
|
+
p,
|
|
286
287
|
{
|
|
287
288
|
k: "field.apply_to_lines.grid",
|
|
288
289
|
label: "Grid",
|
|
289
290
|
effect: "The grid whose lines get the value.",
|
|
290
|
-
children: /* @__PURE__ */
|
|
291
|
+
children: /* @__PURE__ */ l(
|
|
291
292
|
T,
|
|
292
293
|
{
|
|
293
294
|
ariaLabel: "Grid",
|
|
@@ -304,13 +305,13 @@ function Se() {
|
|
|
304
305
|
)
|
|
305
306
|
}
|
|
306
307
|
),
|
|
307
|
-
/* @__PURE__ */
|
|
308
|
-
|
|
308
|
+
/* @__PURE__ */ l(
|
|
309
|
+
p,
|
|
309
310
|
{
|
|
310
311
|
k: "field.apply_to_lines.target",
|
|
311
312
|
label: "Column",
|
|
312
313
|
effect: "The column of each line that receives the value.",
|
|
313
|
-
children: /* @__PURE__ */
|
|
314
|
+
children: /* @__PURE__ */ l(
|
|
314
315
|
T,
|
|
315
316
|
{
|
|
316
317
|
ariaLabel: "Column",
|
|
@@ -325,13 +326,13 @@ function Se() {
|
|
|
325
326
|
)
|
|
326
327
|
}
|
|
327
328
|
),
|
|
328
|
-
/* @__PURE__ */
|
|
329
|
-
|
|
329
|
+
/* @__PURE__ */ l(
|
|
330
|
+
p,
|
|
330
331
|
{
|
|
331
332
|
k: "field.apply_to_lines.label",
|
|
332
333
|
label: "Button label",
|
|
333
334
|
effect: "The words on the button.",
|
|
334
|
-
children: /* @__PURE__ */
|
|
335
|
+
children: /* @__PURE__ */ l(
|
|
335
336
|
S,
|
|
336
337
|
{
|
|
337
338
|
ariaLabel: "Button label",
|
|
@@ -339,7 +340,7 @@ function Se() {
|
|
|
339
340
|
value: r.label ?? "",
|
|
340
341
|
placeholder: "Apply to lines",
|
|
341
342
|
onChange: (e) => {
|
|
342
|
-
const { label:
|
|
343
|
+
const { label: t, ...n } = r;
|
|
343
344
|
a.setOverride(
|
|
344
345
|
"apply_to_lines",
|
|
345
346
|
e ? { ...n, label: e } : n,
|
|
@@ -352,7 +353,7 @@ function Se() {
|
|
|
352
353
|
}
|
|
353
354
|
)
|
|
354
355
|
] }),
|
|
355
|
-
s.layoutType === "addendum" && /* @__PURE__ */
|
|
356
|
+
s.layoutType === "addendum" && /* @__PURE__ */ l(
|
|
356
357
|
g,
|
|
357
358
|
{
|
|
358
359
|
k: "field.prefill_from_parent",
|
|
@@ -369,6 +370,6 @@ function Se() {
|
|
|
369
370
|
] });
|
|
370
371
|
}
|
|
371
372
|
export {
|
|
372
|
-
|
|
373
|
+
Te as RulesTab,
|
|
373
374
|
pe as useFieldRows
|
|
374
375
|
};
|