@nivaro/react 0.3.68 → 0.3.69
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/shared/components/item-edit/FieldRenderer.js +186 -182
- package/dist/shared/components/item-edit/FileDownloadCount.js +94 -0
- package/dist/shared/components/item-edit/FilePickerField.js +319 -302
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +175 -138
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +53 -52
- package/dist/shared/lib/activity-sentence.js +154 -144
- package/dist/shared/lib/placement-behaviour.js +39 -31
- package/package.json +1 -1
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as m, jsx as n, Fragment as w } from "react/jsx-runtime";
|
|
2
2
|
import { X as S } from "lucide-react";
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { validateExpression as
|
|
5
|
-
import { displayFormulaOf as
|
|
6
|
-
import { cn as
|
|
7
|
-
import { RoleConditionRow as
|
|
8
|
-
import { useColumnFacts as
|
|
3
|
+
import { useMemo as O } from "react";
|
|
4
|
+
import { validateExpression as N } from "../../../lib/expression.js";
|
|
5
|
+
import { displayFormulaOf as T, textRulesOf as R, counterOf as M, confirmChangeOf as F } from "../../../lib/placement-behaviour.js";
|
|
6
|
+
import { cn as L } from "../../../lib/utils.js";
|
|
7
|
+
import { RoleConditionRow as A, PipelineStateConditionRow as $ } from "../editors/lock-conditions.js";
|
|
8
|
+
import { useColumnFacts as P, columnOf as D } from "../inspect/inspect-api.js";
|
|
9
9
|
import { effectText as I, tintCard as W } from "../panel-style.js";
|
|
10
10
|
import { isRelational as K } from "./applies.js";
|
|
11
|
-
import { useFieldCtx as
|
|
12
|
-
import { useInspectorEnv as j, Setting as p, TextInput as _, TextArea as q, Segmented as k, DraftInput as E, AddButton as H, Toggle as
|
|
11
|
+
import { useFieldCtx as b } from "./field-context.js";
|
|
12
|
+
import { useInspectorEnv as j, Setting as p, TextInput as _, TextArea as q, Segmented as k, DraftInput as E, AddButton as H, Toggle as g } from "./kit.js";
|
|
13
13
|
const U = "rounded p-0.5 text-slate-400 transition-colors hover:bg-muted hover:text-slate-700 dark:hover:text-foreground";
|
|
14
|
-
function z(
|
|
15
|
-
if (K(
|
|
16
|
-
const
|
|
17
|
-
return ["string", "text", "richtext", "rich_text", "markdown", "wysiwyg"].includes(
|
|
14
|
+
function z(t) {
|
|
15
|
+
if (K(t)) return !1;
|
|
16
|
+
const i = t.iface ?? "";
|
|
17
|
+
return ["string", "text", "richtext", "rich_text", "markdown", "wysiwyg"].includes(t.type) || /textarea|rich|wysiwyg|markdown/i.test(i);
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
const
|
|
21
|
-
return !
|
|
19
|
+
function C(t, i, o = {}) {
|
|
20
|
+
const s = o.allowM2M === !0 && t.relKind === "M2M";
|
|
21
|
+
return !i.startsWith("__") && !t.isPath && (s || t.type !== "alias" && t.relKind !== "M2M") && t.relKind !== "O2M" && t.computedType !== "virtual" && t.computedType !== "read";
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const
|
|
25
|
-
f.map((
|
|
23
|
+
function re() {
|
|
24
|
+
const t = b(), { ov: i, info: o, env: s, row: d } = t, c = o.label, f = R(i), u = (r, a, e) => t.setOverride("text_rules", r.length ? r : void 0, a, e), l = (r, a, e, h) => u(
|
|
25
|
+
f.map((v, y) => y === r ? { ...v, ...a } : v),
|
|
26
26
|
e,
|
|
27
|
-
|
|
27
|
+
h
|
|
28
28
|
);
|
|
29
|
-
return
|
|
29
|
+
return d.field.startsWith("__") ? null : /* @__PURE__ */ m(
|
|
30
30
|
p,
|
|
31
31
|
{
|
|
32
32
|
k: "field.text_rules",
|
|
33
33
|
label: "Label and help by state or role",
|
|
34
34
|
effect: "Different words in a workflow state or for a role: “Requested date” becomes “Delivered date” once Completed. The first rule that matches wins; the record page, read view and PDF follow it.",
|
|
35
35
|
children: [
|
|
36
|
-
f.map((r, a) => /* @__PURE__ */
|
|
36
|
+
f.map((r, a) => /* @__PURE__ */ m(
|
|
37
37
|
"div",
|
|
38
38
|
{
|
|
39
39
|
"data-text-rule": a,
|
|
40
|
-
className:
|
|
40
|
+
className: L(W, "space-y-2 px-2.5 py-2"),
|
|
41
41
|
children: [
|
|
42
|
-
/* @__PURE__ */
|
|
42
|
+
/* @__PURE__ */ m("div", { className: "flex items-center gap-2", children: [
|
|
43
43
|
/* @__PURE__ */ n("div", { className: "flex-1", children: /* @__PURE__ */ n(
|
|
44
44
|
k,
|
|
45
45
|
{
|
|
@@ -48,7 +48,7 @@ function oe() {
|
|
|
48
48
|
{ value: "pipeline_state", label: "In a state" },
|
|
49
49
|
{ value: "role", label: "For a role" }
|
|
50
50
|
],
|
|
51
|
-
onChange: (e) =>
|
|
51
|
+
onChange: (e) => l(
|
|
52
52
|
a,
|
|
53
53
|
e === "role" ? {
|
|
54
54
|
type: "role",
|
|
@@ -56,7 +56,7 @@ function oe() {
|
|
|
56
56
|
state_keys: void 0,
|
|
57
57
|
pipeline_id: void 0
|
|
58
58
|
} : { type: "pipeline_state", state_keys: [], role_ids: void 0 },
|
|
59
|
-
`Change when ${
|
|
59
|
+
`Change when ${c} reads differently`
|
|
60
60
|
)
|
|
61
61
|
}
|
|
62
62
|
) }),
|
|
@@ -68,27 +68,27 @@ function oe() {
|
|
|
68
68
|
"data-tip": "Remove this rule",
|
|
69
69
|
className: U,
|
|
70
70
|
onClick: () => u(
|
|
71
|
-
f.filter((e,
|
|
72
|
-
`Remove a label rule from ${
|
|
71
|
+
f.filter((e, h) => h !== a),
|
|
72
|
+
`Remove a label rule from ${c}`
|
|
73
73
|
),
|
|
74
74
|
children: /* @__PURE__ */ n(S, { className: "h-3.5 w-3.5" })
|
|
75
75
|
}
|
|
76
76
|
)
|
|
77
77
|
] }),
|
|
78
78
|
r.type === "role" ? /* @__PURE__ */ n(
|
|
79
|
-
|
|
79
|
+
A,
|
|
80
80
|
{
|
|
81
81
|
roleIds: r.role_ids ?? [],
|
|
82
|
-
onRoleIdsChange: (e) =>
|
|
82
|
+
onRoleIdsChange: (e) => l(a, { role_ids: e }, `Change the roles for ${c}`)
|
|
83
83
|
}
|
|
84
84
|
) : /* @__PURE__ */ n(
|
|
85
85
|
$,
|
|
86
86
|
{
|
|
87
|
-
collection:
|
|
87
|
+
collection: s.collection,
|
|
88
88
|
pipelineId: r.pipeline_id,
|
|
89
89
|
stateKeys: r.state_keys ?? [],
|
|
90
|
-
onPipelineChange: (e) =>
|
|
91
|
-
onStateKeysChange: (e) =>
|
|
90
|
+
onPipelineChange: (e) => l(a, { pipeline_id: e, state_keys: [] }, `Change the pipeline for ${c}`),
|
|
91
|
+
onStateKeysChange: (e) => l(a, { state_keys: e }, `Change the states for ${c}`)
|
|
92
92
|
}
|
|
93
93
|
),
|
|
94
94
|
/* @__PURE__ */ n(
|
|
@@ -96,8 +96,8 @@ function oe() {
|
|
|
96
96
|
{
|
|
97
97
|
ariaLabel: "Label in this case",
|
|
98
98
|
value: r.label ?? "",
|
|
99
|
-
placeholder: `Label (${
|
|
100
|
-
onChange: (e) =>
|
|
99
|
+
placeholder: `Label (${c})`,
|
|
100
|
+
onChange: (e) => l(a, { label: e || void 0 }, `Change a label rule of ${c}`, !0)
|
|
101
101
|
}
|
|
102
102
|
),
|
|
103
103
|
/* @__PURE__ */ n(
|
|
@@ -106,7 +106,7 @@ function oe() {
|
|
|
106
106
|
ariaLabel: "Help text in this case",
|
|
107
107
|
value: r.note ?? "",
|
|
108
108
|
placeholder: "Help text (unchanged when empty)",
|
|
109
|
-
onChange: (e) =>
|
|
109
|
+
onChange: (e) => l(a, { note: e || void 0 }, `Change a help rule of ${c}`, !0)
|
|
110
110
|
}
|
|
111
111
|
)
|
|
112
112
|
]
|
|
@@ -118,7 +118,7 @@ function oe() {
|
|
|
118
118
|
{
|
|
119
119
|
onClick: () => u(
|
|
120
120
|
[...f, { type: "pipeline_state", state_keys: [] }],
|
|
121
|
-
`Add a label rule to ${
|
|
121
|
+
`Add a label rule to ${c}`
|
|
122
122
|
),
|
|
123
123
|
children: "+ Add a rule"
|
|
124
124
|
}
|
|
@@ -127,29 +127,29 @@ function oe() {
|
|
|
127
127
|
}
|
|
128
128
|
);
|
|
129
129
|
}
|
|
130
|
-
function
|
|
131
|
-
const
|
|
132
|
-
if (!z(o) ||
|
|
133
|
-
const u = o.label,
|
|
134
|
-
return /* @__PURE__ */
|
|
130
|
+
function ie() {
|
|
131
|
+
const t = b(), { ov: i, info: o, env: s, row: d } = t, { data: c } = P(s.collection), f = D(c, d.field);
|
|
132
|
+
if (!z(o) || d.field.startsWith("__")) return null;
|
|
133
|
+
const u = o.label, l = M(i), r = (f == null ? void 0 : f.max_length) != null && f.max_length > 0 ? f.max_length : null, a = (e, h, v) => t.setOverride("counter", e, h, v);
|
|
134
|
+
return /* @__PURE__ */ m("div", { "data-setting": "field.counter", className: "space-y-3", children: [
|
|
135
135
|
/* @__PURE__ */ n(
|
|
136
|
-
|
|
136
|
+
g,
|
|
137
137
|
{
|
|
138
138
|
k: "field.counter.on",
|
|
139
139
|
label: "Counter and limit",
|
|
140
140
|
effect: r ? `Counts as people type. The limit starts at the column size (${r.toLocaleString()} characters); past it the form will not save.` : "Counts as people type; past a limit the form will not save.",
|
|
141
|
-
checked: !!
|
|
141
|
+
checked: !!l,
|
|
142
142
|
onChange: (e) => a(
|
|
143
143
|
e ? { unit: "characters", ...r ? { limit: r } : {} } : void 0,
|
|
144
144
|
e ? `Count the characters of ${u}` : `Stop counting ${u}`
|
|
145
145
|
)
|
|
146
146
|
}
|
|
147
147
|
),
|
|
148
|
-
|
|
148
|
+
l && /* @__PURE__ */ m(w, { children: [
|
|
149
149
|
/* @__PURE__ */ n(p, { k: "field.counter.unit", label: "Count", effect: "Characters or words.", children: /* @__PURE__ */ n(
|
|
150
150
|
k,
|
|
151
151
|
{
|
|
152
|
-
value:
|
|
152
|
+
value: l.unit,
|
|
153
153
|
options: [
|
|
154
154
|
{ value: "characters", label: "Characters" },
|
|
155
155
|
{ value: "words", label: "Words" }
|
|
@@ -157,7 +157,7 @@ function re() {
|
|
|
157
157
|
onChange: (e) => a(
|
|
158
158
|
{
|
|
159
159
|
unit: e,
|
|
160
|
-
...e === "words" ? {} :
|
|
160
|
+
...e === "words" ? {} : l.limit != null ? { limit: l.limit } : r ? { limit: r } : {}
|
|
161
161
|
},
|
|
162
162
|
`Count the ${e} of ${u}`
|
|
163
163
|
)
|
|
@@ -168,18 +168,18 @@ function re() {
|
|
|
168
168
|
{
|
|
169
169
|
k: "field.counter.limit",
|
|
170
170
|
label: "Limit",
|
|
171
|
-
effect:
|
|
171
|
+
effect: l.unit === "words" ? "Most words allowed. Empty counts without a limit." : `Most characters allowed. Empty counts without a limit${r ? `; the column holds ${r.toLocaleString()}` : ""}.`,
|
|
172
172
|
children: /* @__PURE__ */ n(
|
|
173
173
|
_,
|
|
174
174
|
{
|
|
175
175
|
type: "number",
|
|
176
176
|
ariaLabel: "Limit",
|
|
177
|
-
value:
|
|
178
|
-
placeholder:
|
|
177
|
+
value: l.limit == null ? "" : String(l.limit),
|
|
178
|
+
placeholder: l.unit === "characters" && r ? String(r) : "No limit",
|
|
179
179
|
onChange: (e) => {
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
{ unit:
|
|
180
|
+
const h = e === "" ? void 0 : Math.max(1, Math.floor(Number(e)));
|
|
181
|
+
h !== void 0 && !Number.isFinite(h) || a(
|
|
182
|
+
{ unit: l.unit, ...h ? { limit: h } : {} },
|
|
183
183
|
`Set the limit of ${u}`,
|
|
184
184
|
!0
|
|
185
185
|
);
|
|
@@ -191,20 +191,20 @@ function re() {
|
|
|
191
191
|
] })
|
|
192
192
|
] });
|
|
193
193
|
}
|
|
194
|
-
function
|
|
195
|
-
var
|
|
196
|
-
const
|
|
197
|
-
if (
|
|
198
|
-
const
|
|
194
|
+
function se() {
|
|
195
|
+
var c;
|
|
196
|
+
const t = b(), { ov: i, info: o, row: s } = t;
|
|
197
|
+
if (s.field.startsWith("__")) return null;
|
|
198
|
+
const d = i.required === !0 || i.required === void 0 && !!((c = o.global) != null && c.required);
|
|
199
199
|
return /* @__PURE__ */ n(
|
|
200
|
-
|
|
200
|
+
g,
|
|
201
201
|
{
|
|
202
202
|
k: "field.recommended",
|
|
203
203
|
label: "Recommended",
|
|
204
|
-
effect:
|
|
205
|
-
checked:
|
|
206
|
-
disabled:
|
|
207
|
-
onChange: (f) =>
|
|
204
|
+
effect: d ? "Required already wins; switch Required off to make this a recommendation." : "An amber marker and a reminder on save listing what is still empty. Saving is never blocked.",
|
|
205
|
+
checked: i.recommended === !0 && !d,
|
|
206
|
+
disabled: d,
|
|
207
|
+
onChange: (f) => t.setOverride(
|
|
208
208
|
"recommended",
|
|
209
209
|
f ? !0 : void 0,
|
|
210
210
|
f ? `Recommend ${o.label}` : `Stop recommending ${o.label}`
|
|
@@ -212,13 +212,13 @@ function ie() {
|
|
|
212
212
|
}
|
|
213
213
|
);
|
|
214
214
|
}
|
|
215
|
-
function
|
|
216
|
-
const
|
|
217
|
-
if (!
|
|
218
|
-
const
|
|
219
|
-
return /* @__PURE__ */
|
|
215
|
+
function de() {
|
|
216
|
+
const t = b(), { ov: i, info: o, env: s, row: d } = t;
|
|
217
|
+
if (!C(o, d.field)) return null;
|
|
218
|
+
const c = o.label, f = F(i), u = i.confirm_change && typeof i.confirm_change == "object" ? i.confirm_change : {}, l = typeof u.pipeline_id == "string" ? u.pipeline_id : void 0, r = (a, e) => t.setOverride("confirm_change", a, e);
|
|
219
|
+
return /* @__PURE__ */ m("div", { "data-setting": "field.confirm_change", className: "space-y-3", children: [
|
|
220
220
|
/* @__PURE__ */ n(
|
|
221
|
-
|
|
221
|
+
g,
|
|
222
222
|
{
|
|
223
223
|
k: "field.confirm_change.on",
|
|
224
224
|
label: "Confirm changes on saved records",
|
|
@@ -226,7 +226,7 @@ function se() {
|
|
|
226
226
|
checked: !!f,
|
|
227
227
|
onChange: (a) => r(
|
|
228
228
|
a ? { state_keys: [] } : void 0,
|
|
229
|
-
a ? `Confirm changes to ${
|
|
229
|
+
a ? `Confirm changes to ${c}` : `Stop confirming changes to ${c}`
|
|
230
230
|
)
|
|
231
231
|
}
|
|
232
232
|
),
|
|
@@ -239,16 +239,16 @@ function se() {
|
|
|
239
239
|
children: /* @__PURE__ */ n(
|
|
240
240
|
$,
|
|
241
241
|
{
|
|
242
|
-
collection:
|
|
243
|
-
pipelineId:
|
|
242
|
+
collection: s.collection,
|
|
243
|
+
pipelineId: l,
|
|
244
244
|
stateKeys: f.state_keys,
|
|
245
245
|
onPipelineChange: (a) => r(
|
|
246
246
|
{ ...a ? { pipeline_id: a } : {}, state_keys: [] },
|
|
247
|
-
`Change the pipeline that confirms ${
|
|
247
|
+
`Change the pipeline that confirms ${c}`
|
|
248
248
|
),
|
|
249
249
|
onStateKeysChange: (a) => r(
|
|
250
|
-
{ ...
|
|
251
|
-
`Change the states that confirm ${
|
|
250
|
+
{ ...l ? { pipeline_id: l } : {}, state_keys: a },
|
|
251
|
+
`Change the states that confirm ${c}`
|
|
252
252
|
)
|
|
253
253
|
}
|
|
254
254
|
)
|
|
@@ -257,69 +257,105 @@ function se() {
|
|
|
257
257
|
] });
|
|
258
258
|
}
|
|
259
259
|
function ce() {
|
|
260
|
-
const
|
|
261
|
-
return !
|
|
262
|
-
|
|
260
|
+
const t = b(), { ov: i, info: o, row: s } = t;
|
|
261
|
+
return !C(o, s.field) || o.computedType ? null : /* @__PURE__ */ n(
|
|
262
|
+
g,
|
|
263
263
|
{
|
|
264
264
|
k: "field.repeat_last",
|
|
265
265
|
label: "Repeat last value",
|
|
266
266
|
effect: "A “Repeat last” button beside the label fills in what this person entered on their previous record here.",
|
|
267
|
-
checked:
|
|
268
|
-
onChange: (
|
|
267
|
+
checked: i.repeat_last === !0,
|
|
268
|
+
onChange: (d) => t.setOverride(
|
|
269
269
|
"repeat_last",
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
d ? !0 : void 0,
|
|
271
|
+
d ? `Offer to repeat the last ${o.label}` : `Stop offering to repeat ${o.label}`
|
|
272
272
|
)
|
|
273
273
|
}
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const
|
|
278
|
-
return !
|
|
279
|
-
|
|
276
|
+
function fe() {
|
|
277
|
+
const t = b(), { ov: i, info: o, row: s } = t;
|
|
278
|
+
return !C(o, s.field, { allowM2M: !0 }) || o.computedType ? null : /* @__PURE__ */ n(
|
|
279
|
+
g,
|
|
280
280
|
{
|
|
281
281
|
k: "field.personal_default",
|
|
282
282
|
label: "Personal default",
|
|
283
283
|
effect: "On this form, people can save their own starting value for this field, and new records start with it.",
|
|
284
|
-
checked:
|
|
285
|
-
onChange: (
|
|
284
|
+
checked: i.personal_default === !0,
|
|
285
|
+
onChange: (d) => t.setOverride(
|
|
286
286
|
"personal_default",
|
|
287
|
-
|
|
288
|
-
|
|
287
|
+
d ? !0 : void 0,
|
|
288
|
+
d ? `Allow personal defaults for ${o.label}` : `Stop personal defaults for ${o.label}`
|
|
289
289
|
)
|
|
290
290
|
}
|
|
291
291
|
);
|
|
292
292
|
}
|
|
293
|
-
function
|
|
294
|
-
const
|
|
295
|
-
return
|
|
296
|
-
|
|
293
|
+
function ue() {
|
|
294
|
+
const t = b(), { ov: i, info: o } = t;
|
|
295
|
+
return i.personal_default !== !0 ? null : /* @__PURE__ */ n(
|
|
296
|
+
g,
|
|
297
297
|
{
|
|
298
298
|
k: "field.personal_default_inline",
|
|
299
299
|
label: "Make default on the form",
|
|
300
300
|
effect: "People can save, update and clear their default right beside this field. Off: they manage it only on their profile (My defaults); the form still fills it in.",
|
|
301
|
-
checked:
|
|
302
|
-
onChange: (
|
|
301
|
+
checked: i.personal_default_inline !== !1,
|
|
302
|
+
onChange: (s) => t.setOverride(
|
|
303
303
|
"personal_default_inline",
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
s ? void 0 : !1,
|
|
305
|
+
s ? `Offer Make default on the form for ${o.label}` : `Keep ${o.label}'s default to the profile`
|
|
306
306
|
)
|
|
307
307
|
}
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
function B(t) {
|
|
311
|
+
return ["file", "file-image", "files-m2m"].includes(t.iface ?? "");
|
|
312
|
+
}
|
|
313
|
+
function he() {
|
|
314
|
+
const t = b(), { ov: i, info: o } = t;
|
|
315
|
+
return B(o) ? /* @__PURE__ */ m(w, { children: [
|
|
316
|
+
/* @__PURE__ */ n(
|
|
317
|
+
g,
|
|
318
|
+
{
|
|
319
|
+
k: "field.file_used_in",
|
|
320
|
+
label: "Show where each file was used",
|
|
321
|
+
effect: "A small chip on each file lists the addendum, integration push, email or generated document on this record that carried it.",
|
|
322
|
+
checked: i.file_used_in !== !1,
|
|
323
|
+
onChange: (s) => t.setOverride(
|
|
324
|
+
"file_used_in",
|
|
325
|
+
s ? void 0 : !1,
|
|
326
|
+
s ? `Show where ${o.label} files were used` : `Hide where ${o.label} files were used`
|
|
327
|
+
)
|
|
328
|
+
}
|
|
329
|
+
),
|
|
330
|
+
/* @__PURE__ */ n(
|
|
331
|
+
g,
|
|
332
|
+
{
|
|
333
|
+
k: "field.file_downloads",
|
|
334
|
+
label: "Show who downloaded each file",
|
|
335
|
+
effect: "Administrators see how many people downloaded each file from this record; hover names them. Everyone else sees nothing.",
|
|
336
|
+
checked: i.file_downloads !== !1,
|
|
337
|
+
onChange: (s) => t.setOverride(
|
|
338
|
+
"file_downloads",
|
|
339
|
+
s ? void 0 : !1,
|
|
340
|
+
s ? `Show downloads for ${o.label}` : `Hide downloads for ${o.label}`
|
|
341
|
+
)
|
|
342
|
+
}
|
|
343
|
+
)
|
|
344
|
+
] }) : null;
|
|
345
|
+
}
|
|
346
|
+
const J = [
|
|
311
347
|
{ value: "", label: "Plain" },
|
|
312
348
|
{ value: "integer", label: "Whole" },
|
|
313
349
|
{ value: "number", label: "Decimal" },
|
|
314
350
|
{ value: "currency", label: "Money" },
|
|
315
351
|
{ value: "percent", label: "Percent" }
|
|
316
352
|
];
|
|
317
|
-
function
|
|
318
|
-
row:
|
|
319
|
-
fields:
|
|
353
|
+
function me({
|
|
354
|
+
row: t,
|
|
355
|
+
fields: i
|
|
320
356
|
}) {
|
|
321
|
-
const o = j(),
|
|
322
|
-
const e =
|
|
357
|
+
const o = j(), s = O(() => {
|
|
358
|
+
const e = t.overrides;
|
|
323
359
|
if (typeof e == "string")
|
|
324
360
|
try {
|
|
325
361
|
return JSON.parse(e) ?? {};
|
|
@@ -327,32 +363,32 @@ function ue({
|
|
|
327
363
|
return {};
|
|
328
364
|
}
|
|
329
365
|
return e && typeof e == "object" ? e : {};
|
|
330
|
-
}, [
|
|
331
|
-
const
|
|
332
|
-
for (const x of Object.keys(
|
|
333
|
-
o.apply([{ op: "update_placement", at: f, patch: { overrides:
|
|
334
|
-
label:
|
|
335
|
-
text:
|
|
366
|
+
}, [t.overrides]), d = T(s) ?? { expr: "", format: "", currency: null }, c = typeof s.label == "string" ? s.label : "", f = { field: t.field, group_key: t.group_key }, u = (e, h, v) => {
|
|
367
|
+
const y = { ...s, ...e };
|
|
368
|
+
for (const x of Object.keys(y)) y[x] === void 0 && delete y[x];
|
|
369
|
+
o.apply([{ op: "update_placement", at: f, patch: { overrides: y } }], {
|
|
370
|
+
label: h,
|
|
371
|
+
text: v
|
|
336
372
|
});
|
|
337
|
-
},
|
|
373
|
+
}, l = d.expr.trim() ? N(d.expr, i) : null, r = new Set(
|
|
338
374
|
o.bundle.placements.filter((e) => !e.field.startsWith("__")).map((e) => e.field)
|
|
339
|
-
), a =
|
|
340
|
-
return /* @__PURE__ */
|
|
375
|
+
), a = l != null && l.ok ? l.tokens.filter((e) => !r.has(e.split(".")[0])) : [];
|
|
376
|
+
return /* @__PURE__ */ m("div", { className: "space-y-5", children: [
|
|
341
377
|
/* @__PURE__ */ n(p, { k: "display_formula.label", label: "Label", effect: "What the form calls the value.", children: /* @__PURE__ */ n(
|
|
342
378
|
_,
|
|
343
379
|
{
|
|
344
380
|
ariaLabel: "Label",
|
|
345
|
-
value:
|
|
381
|
+
value: c,
|
|
346
382
|
placeholder: "Remaining",
|
|
347
383
|
onChange: (e) => u({ label: e || void 0 }, "Rename the formula", !0)
|
|
348
384
|
}
|
|
349
385
|
) }),
|
|
350
|
-
/* @__PURE__ */
|
|
386
|
+
/* @__PURE__ */ m(
|
|
351
387
|
p,
|
|
352
388
|
{
|
|
353
389
|
k: "display_formula.expr",
|
|
354
390
|
label: "Formula",
|
|
355
|
-
effect: /* @__PURE__ */
|
|
391
|
+
effect: /* @__PURE__ */ m(w, { children: [
|
|
356
392
|
"Fields in double braces, for example",
|
|
357
393
|
" ",
|
|
358
394
|
/* @__PURE__ */ n("code", { className: "font-mono text-[11.5px]", children: "{{budget}} - {{committed}}" }),
|
|
@@ -365,25 +401,25 @@ function ue({
|
|
|
365
401
|
ariaLabel: "Formula",
|
|
366
402
|
rows: 3,
|
|
367
403
|
mono: !0,
|
|
368
|
-
value:
|
|
369
|
-
onChange: (e) => u({ display_formula: { ...
|
|
404
|
+
value: d.expr,
|
|
405
|
+
onChange: (e) => u({ display_formula: { ...d, expr: e } }, "Change the formula", !0)
|
|
370
406
|
}
|
|
371
407
|
),
|
|
372
|
-
|
|
408
|
+
l && !l.ok && /* @__PURE__ */ n(
|
|
373
409
|
"p",
|
|
374
410
|
{
|
|
375
411
|
role: "alert",
|
|
376
412
|
"data-formula-error": "",
|
|
377
413
|
className: "text-[12px] text-red-700 dark:text-red-300",
|
|
378
|
-
children:
|
|
414
|
+
children: l.error
|
|
379
415
|
}
|
|
380
416
|
),
|
|
381
|
-
(
|
|
417
|
+
(l == null ? void 0 : l.ok) && l.unknownTokens.length > 0 && /* @__PURE__ */ m("p", { "data-formula-unknown": "", className: "text-[12px] text-amber-700 dark:text-amber-300", children: [
|
|
382
418
|
"Not fields of this collection:",
|
|
383
419
|
" ",
|
|
384
|
-
/* @__PURE__ */ n("span", { className: "font-mono", children:
|
|
420
|
+
/* @__PURE__ */ n("span", { className: "font-mono", children: l.unknownTokens.join(", ") })
|
|
385
421
|
] }),
|
|
386
|
-
(
|
|
422
|
+
(l == null ? void 0 : l.ok) && !l.unknownTokens.length && a.length > 0 && /* @__PURE__ */ m("p", { "data-formula-offform": "", className: I, children: [
|
|
387
423
|
"Not on this form, so they read as empty here:",
|
|
388
424
|
" ",
|
|
389
425
|
/* @__PURE__ */ n("span", { className: "font-mono", children: a.join(", ") })
|
|
@@ -394,12 +430,12 @@ function ue({
|
|
|
394
430
|
/* @__PURE__ */ n(p, { k: "display_formula.format", label: "Show as", effect: "How the number is written.", children: /* @__PURE__ */ n(
|
|
395
431
|
k,
|
|
396
432
|
{
|
|
397
|
-
value:
|
|
398
|
-
options:
|
|
399
|
-
onChange: (e) => u({ display_formula: { ...
|
|
433
|
+
value: d.format,
|
|
434
|
+
options: J,
|
|
435
|
+
onChange: (e) => u({ display_formula: { ...d, format: e } }, "Change how the formula shows")
|
|
400
436
|
}
|
|
401
437
|
) }),
|
|
402
|
-
|
|
438
|
+
d.format === "currency" && /* @__PURE__ */ n(
|
|
403
439
|
p,
|
|
404
440
|
{
|
|
405
441
|
k: "display_formula.currency",
|
|
@@ -409,13 +445,13 @@ function ue({
|
|
|
409
445
|
E,
|
|
410
446
|
{
|
|
411
447
|
ariaLabel: "Currency",
|
|
412
|
-
value:
|
|
448
|
+
value: d.currency ?? "",
|
|
413
449
|
mono: !0,
|
|
414
450
|
placeholder: "USD",
|
|
415
451
|
onCommit: (e) => {
|
|
416
|
-
const
|
|
417
|
-
|
|
418
|
-
{ display_formula: { ...
|
|
452
|
+
const h = e.trim().toUpperCase();
|
|
453
|
+
h && !/^[A-Z]{3}$/.test(h) || u(
|
|
454
|
+
{ display_formula: { ...d, currency: h || null } },
|
|
419
455
|
"Change the currency of the formula",
|
|
420
456
|
!0
|
|
421
457
|
);
|
|
@@ -427,13 +463,14 @@ function ue({
|
|
|
427
463
|
] });
|
|
428
464
|
}
|
|
429
465
|
export {
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
466
|
+
de as ConfirmChangeSetting,
|
|
467
|
+
ie as CounterSetting,
|
|
468
|
+
me as DisplayFormulaSettings,
|
|
469
|
+
he as FileChipToggles,
|
|
470
|
+
ue as PersonalDefaultInlineToggle,
|
|
471
|
+
fe as PersonalDefaultToggle,
|
|
472
|
+
se as RecommendedToggle,
|
|
436
473
|
ce as RepeatLastToggle,
|
|
437
|
-
|
|
474
|
+
re as TextRulesSetting,
|
|
438
475
|
z as takesText
|
|
439
476
|
};
|