@nivaro/react 0.3.72 → 0.3.74
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/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/CollectionBrowserView.js +1493 -1469
- package/dist/shared/components/DataTable.js +315 -289
- package/dist/shared/components/RecordDrilldownSheet.js +57 -46
- package/dist/shared/components/RecordReadView.js +661 -573
- package/dist/shared/components/item-edit/RecordLiveSync.js +46 -46
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +183 -165
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +47 -46
- package/dist/shared/components/panels/ItemActionButtons.js +44 -44
- package/dist/shared/lib/record-loader.js +30 -24
- package/package.json +1 -1
|
@@ -13,10 +13,10 @@ import { FieldDefaultValueControl as Y } from "../editors/field-default-value.js
|
|
|
13
13
|
import { RoleConditionRow as Z, PipelineStateConditionRow as ee } from "../editors/lock-conditions.js";
|
|
14
14
|
import { useLayoutEditorHost as le } from "../host.js";
|
|
15
15
|
import { tintCard as te } from "../panel-style.js";
|
|
16
|
-
import { RecommendedToggle as ie, PersonalDefaultToggle as oe, PersonalDefaultInlineToggle as ae, ConfirmChangeSetting as ne, RepeatLastToggle as re, FileChipToggles as de } from "./BehaviourSettings.js";
|
|
17
|
-
import { useFieldCtx as
|
|
18
|
-
import { Toggle as v, Setting as
|
|
19
|
-
import { lockConditionsOf as fe, layoutGrids as pe, asObject as
|
|
16
|
+
import { RecommendedToggle as ie, PersonalDefaultToggle as oe, PersonalDefaultInlineToggle as ae, ConfirmChangeSetting as ne, RepeatLastToggle as re, FileChipToggles as de, SummaryToggleSetting as se } from "./BehaviourSettings.js";
|
|
17
|
+
import { useFieldCtx as ce } from "./field-context.js";
|
|
18
|
+
import { Toggle as v, Setting as f, Segmented as ue, AddButton as me, Section as T, TextInput as R, Choice as L } from "./kit.js";
|
|
19
|
+
import { lockConditionsOf as fe, layoutGrids as pe, asObject as he, defaultValuesOf as ye, withDefaultValue as ge, lockConditionsColumn as be } from "./model.js";
|
|
20
20
|
const P = /* @__PURE__ */ new Set([
|
|
21
21
|
"inline-table",
|
|
22
22
|
"inline-grid",
|
|
@@ -27,33 +27,33 @@ const P = /* @__PURE__ */ new Set([
|
|
|
27
27
|
"o2m",
|
|
28
28
|
"relation-path"
|
|
29
29
|
]);
|
|
30
|
-
function
|
|
31
|
-
const
|
|
30
|
+
function ve(t, o) {
|
|
31
|
+
const m = j();
|
|
32
32
|
return V({
|
|
33
33
|
queryKey: ["layout-editor", "field-rows", t, o ?? null],
|
|
34
|
-
queryFn: () =>
|
|
34
|
+
queryFn: () => m.request(
|
|
35
35
|
E(`/field-config/${t}`, o ? { layout_id: o } : void 0)
|
|
36
|
-
).then((
|
|
36
|
+
).then((p) => Array.isArray(p.data) ? p.data : []),
|
|
37
37
|
enabled: !!t,
|
|
38
38
|
staleTime: 6e4
|
|
39
39
|
});
|
|
40
40
|
}
|
|
41
|
-
function
|
|
42
|
-
const t =
|
|
43
|
-
|
|
41
|
+
function De() {
|
|
42
|
+
const t = ce(), { info: o, ov: m, opts: p, env: s, row: u } = t, a = o.label, y = s.bundle.layout, g = u.field.startsWith("__") || o.isPath, b = fe(u), _ = (e, i) => t.setPlacement({ lock_conditions: be(e) }, i), w = (e, i, n) => _(
|
|
43
|
+
b.map((d, h) => h === e ? { ...d, ...i } : d),
|
|
44
44
|
n
|
|
45
|
-
), x = pe(s.bundle, t.globals, t.relations), N = !
|
|
45
|
+
), x = pe(s.bundle, t.globals, t.relations), N = !g && o.relKind !== "M2M" && o.relKind !== "O2M" && !P.has(o.iface ?? "") && x.length > 0, r = he(m.apply_to_lines), $ = x.find((e) => e.field === r.grid) ?? null, { data: F = [] } = ve(N ? $ == null ? void 0 : $.childCollection : null), K = F.filter(
|
|
46
46
|
(e) => e.field !== "id" && !e.field.startsWith("__") && !e.field.includes(".") && !["alias", "o2m", "m2m"].includes(e.type ?? "")
|
|
47
|
-
),
|
|
47
|
+
), S = (e, i) => t.setOverride("apply_to_lines", e ?? void 0, i), I = le().isAdmin && !g && !o.relKind && !P.has(o.iface ?? "") && o.type !== "alias" && o.computedType !== "virtual", M = g ? null : X(t.globals, t.relations, s.collection)[u.field] ?? null, q = ye(y), A = typeof p.max_values == "number" ? p.max_values : null;
|
|
48
48
|
return /* @__PURE__ */ c("div", { className: "space-y-5", children: [
|
|
49
|
-
|
|
49
|
+
M && /* @__PURE__ */ c(
|
|
50
50
|
"div",
|
|
51
51
|
{
|
|
52
52
|
"data-setting": "field.source",
|
|
53
53
|
className: "rounded-md border border-slate-200 bg-slate-50 p-2.5 dark:border-border dark:bg-muted/40",
|
|
54
54
|
children: [
|
|
55
55
|
/* @__PURE__ */ l("p", { className: "mb-1 text-[11px] font-medium uppercase tracking-wide text-slate-400", children: "Where the value comes from" }),
|
|
56
|
-
/* @__PURE__ */ l(H, { source:
|
|
56
|
+
/* @__PURE__ */ l(H, { source: M })
|
|
57
57
|
]
|
|
58
58
|
}
|
|
59
59
|
),
|
|
@@ -63,7 +63,7 @@ function Be() {
|
|
|
63
63
|
k: "field.required",
|
|
64
64
|
label: "Required",
|
|
65
65
|
effect: "The form will not save without a value.",
|
|
66
|
-
checked:
|
|
66
|
+
checked: m.required === !0,
|
|
67
67
|
onChange: (e) => t.setOverride(
|
|
68
68
|
"required",
|
|
69
69
|
e ? !0 : void 0,
|
|
@@ -78,7 +78,7 @@ function Be() {
|
|
|
78
78
|
k: "field.readonly",
|
|
79
79
|
label: "Read-only",
|
|
80
80
|
effect: "Shown but not editable on this form.",
|
|
81
|
-
checked:
|
|
81
|
+
checked: m.readonly === !0,
|
|
82
82
|
onChange: (e) => t.setOverride(
|
|
83
83
|
"readonly",
|
|
84
84
|
e ? !0 : void 0,
|
|
@@ -91,13 +91,14 @@ function Be() {
|
|
|
91
91
|
/* @__PURE__ */ l(ne, {}),
|
|
92
92
|
/* @__PURE__ */ l(re, {}),
|
|
93
93
|
/* @__PURE__ */ l(de, {}),
|
|
94
|
+
/* @__PURE__ */ l(se, {}),
|
|
94
95
|
(o.computedType === "rollup" || o.computedType === "write") && /* @__PURE__ */ l(
|
|
95
96
|
v,
|
|
96
97
|
{
|
|
97
98
|
k: "field.editable_computed",
|
|
98
99
|
label: "Allow manual entry",
|
|
99
100
|
effect: "Lets people type over the calculated value here; the next recalculation still overwrites it.",
|
|
100
|
-
checked:
|
|
101
|
+
checked: m.editable_computed === !0,
|
|
101
102
|
onChange: (e) => t.setOverride(
|
|
102
103
|
"editable_computed",
|
|
103
104
|
e ? !0 : void 0,
|
|
@@ -106,20 +107,20 @@ function Be() {
|
|
|
106
107
|
}
|
|
107
108
|
),
|
|
108
109
|
/* @__PURE__ */ l(
|
|
109
|
-
|
|
110
|
+
f,
|
|
110
111
|
{
|
|
111
112
|
k: "field.lock_conditions",
|
|
112
113
|
label: "Read-only when",
|
|
113
114
|
effect: "Locks the field while any of these holds. No conditions: always editable.",
|
|
114
115
|
children: /* @__PURE__ */ c("div", { className: "space-y-2", children: [
|
|
115
|
-
|
|
116
|
+
b.map((e, i) => /* @__PURE__ */ c(
|
|
116
117
|
"div",
|
|
117
118
|
{
|
|
118
119
|
className: G(te, "space-y-3 p-3"),
|
|
119
120
|
children: [
|
|
120
121
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-1.5", children: [
|
|
121
122
|
/* @__PURE__ */ l("div", { className: "flex-1", "data-setting": "field.lock_conditions.type", children: /* @__PURE__ */ l(
|
|
122
|
-
|
|
123
|
+
ue,
|
|
123
124
|
{
|
|
124
125
|
value: e.type,
|
|
125
126
|
options: [
|
|
@@ -127,7 +128,7 @@ function Be() {
|
|
|
127
128
|
{ value: "role", label: "Role" }
|
|
128
129
|
],
|
|
129
130
|
onChange: (n) => _(
|
|
130
|
-
|
|
131
|
+
b.map(
|
|
131
132
|
(d, h) => h === i ? n === "role" ? { type: "role", role_ids: [] } : { type: "pipeline_state", state_keys: [] } : d
|
|
132
133
|
),
|
|
133
134
|
`Change a lock condition of ${a}`
|
|
@@ -140,7 +141,7 @@ function Be() {
|
|
|
140
141
|
type: "button",
|
|
141
142
|
"aria-label": "Remove condition",
|
|
142
143
|
onClick: () => _(
|
|
143
|
-
|
|
144
|
+
b.filter((n, d) => d !== i),
|
|
144
145
|
`Remove a lock condition from ${a}`
|
|
145
146
|
),
|
|
146
147
|
"data-tip": "Remove condition",
|
|
@@ -175,16 +176,16 @@ function Be() {
|
|
|
175
176
|
)),
|
|
176
177
|
/* @__PURE__ */ c("div", { className: "flex flex-wrap items-center gap-1.5", children: [
|
|
177
178
|
/* @__PURE__ */ l(
|
|
178
|
-
|
|
179
|
+
me,
|
|
179
180
|
{
|
|
180
181
|
onClick: () => _(
|
|
181
|
-
[...
|
|
182
|
+
[...b, { type: "pipeline_state", state_keys: [] }],
|
|
182
183
|
`Add a lock condition to ${a}`
|
|
183
184
|
),
|
|
184
185
|
children: "+ Add condition"
|
|
185
186
|
}
|
|
186
187
|
),
|
|
187
|
-
!
|
|
188
|
+
!g && /* @__PURE__ */ l(
|
|
188
189
|
J,
|
|
189
190
|
{
|
|
190
191
|
layoutId: Number(y.id),
|
|
@@ -198,8 +199,8 @@ function Be() {
|
|
|
198
199
|
] })
|
|
199
200
|
}
|
|
200
201
|
),
|
|
201
|
-
!
|
|
202
|
-
|
|
202
|
+
!g && o.relKind !== "O2M" && /* @__PURE__ */ c(
|
|
203
|
+
f,
|
|
203
204
|
{
|
|
204
205
|
k: "field.default_value",
|
|
205
206
|
label: "Default for new records",
|
|
@@ -213,7 +214,7 @@ function Be() {
|
|
|
213
214
|
[
|
|
214
215
|
{
|
|
215
216
|
op: "layout_update",
|
|
216
|
-
patch: { default_values:
|
|
217
|
+
patch: { default_values: ge(y, u.field, e) }
|
|
217
218
|
}
|
|
218
219
|
],
|
|
219
220
|
{ label: `Change the default of ${a}`, text: i }
|
|
@@ -237,7 +238,7 @@ function Be() {
|
|
|
237
238
|
}
|
|
238
239
|
),
|
|
239
240
|
I && /* @__PURE__ */ l(
|
|
240
|
-
|
|
241
|
+
f,
|
|
241
242
|
{
|
|
242
243
|
k: "field.validation_rules",
|
|
243
244
|
label: "Checks",
|
|
@@ -250,22 +251,22 @@ function Be() {
|
|
|
250
251
|
field: u.field,
|
|
251
252
|
disabled: t.readOnly,
|
|
252
253
|
onApply: (e, i, n) => t.proposeGlobal("field.validation_rules", e.length, n, (d) => {
|
|
253
|
-
const h = d.columns.validation_rules,
|
|
254
|
-
return { ...d, columns: { ...d.columns, validation_rules: [...
|
|
254
|
+
const h = d.columns.validation_rules, O = Array.isArray(h) ? h : i, B = (k, C) => k.type === C.type && String(k.value ?? "") === String(C.value ?? ""), D = e.filter((k) => !O.some((C) => B(C, k)));
|
|
255
|
+
return { ...d, columns: { ...d.columns, validation_rules: [...O, ...D] } };
|
|
255
256
|
})
|
|
256
257
|
}
|
|
257
258
|
)
|
|
258
259
|
}
|
|
259
260
|
),
|
|
260
|
-
o.relKind === "M2M" && /* @__PURE__ */ c(
|
|
261
|
+
o.relKind === "M2M" && /* @__PURE__ */ c(T, { title: "How many", children: [
|
|
261
262
|
/* @__PURE__ */ l(
|
|
262
|
-
|
|
263
|
+
f,
|
|
263
264
|
{
|
|
264
265
|
k: "field.max_values",
|
|
265
266
|
label: "Most values",
|
|
266
267
|
effect: "Empty: no limit. 1 makes it a single pick.",
|
|
267
268
|
children: /* @__PURE__ */ l(
|
|
268
|
-
|
|
269
|
+
R,
|
|
269
270
|
{
|
|
270
271
|
type: "number",
|
|
271
272
|
ariaLabel: "Most values",
|
|
@@ -286,7 +287,7 @@ function Be() {
|
|
|
286
287
|
label: "Refuse more on the server too",
|
|
287
288
|
effect: "Imports, the API and other forms cannot store more than the limit.",
|
|
288
289
|
enforced: !0,
|
|
289
|
-
checked:
|
|
290
|
+
checked: p.enforce_on_write === !0,
|
|
290
291
|
onChange: (e) => t.setOption(
|
|
291
292
|
"enforce_on_write",
|
|
292
293
|
e ? !0 : void 0,
|
|
@@ -295,10 +296,10 @@ function Be() {
|
|
|
295
296
|
}
|
|
296
297
|
)
|
|
297
298
|
] }),
|
|
298
|
-
N && /* @__PURE__ */ c(
|
|
299
|
+
N && /* @__PURE__ */ c(T, { title: "Apply to lines", children: [
|
|
299
300
|
/* @__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." }),
|
|
300
301
|
/* @__PURE__ */ l(
|
|
301
|
-
|
|
302
|
+
f,
|
|
302
303
|
{
|
|
303
304
|
k: "field.apply_to_lines.grid",
|
|
304
305
|
label: "Grid",
|
|
@@ -312,7 +313,7 @@ function Be() {
|
|
|
312
313
|
{ value: "", label: "Off" },
|
|
313
314
|
...x.map((e) => ({ value: e.field, label: e.label }))
|
|
314
315
|
],
|
|
315
|
-
onChange: (e) =>
|
|
316
|
+
onChange: (e) => S(
|
|
316
317
|
e ? { grid: e, target: "", ...r.label ? { label: r.label } : {} } : null,
|
|
317
318
|
e ? `Copy ${a} into lines` : `Stop copying ${a} into lines`
|
|
318
319
|
)
|
|
@@ -321,7 +322,7 @@ function Be() {
|
|
|
321
322
|
}
|
|
322
323
|
),
|
|
323
324
|
/* @__PURE__ */ l(
|
|
324
|
-
|
|
325
|
+
f,
|
|
325
326
|
{
|
|
326
327
|
k: "field.apply_to_lines.target",
|
|
327
328
|
label: "Column",
|
|
@@ -336,19 +337,19 @@ function Be() {
|
|
|
336
337
|
{ value: "", label: r.grid ? "Pick a column…" : "Pick a grid first" },
|
|
337
338
|
...K.map((e) => ({ value: e.field, label: e.label || Q(e.field) }))
|
|
338
339
|
],
|
|
339
|
-
onChange: (e) =>
|
|
340
|
+
onChange: (e) => S({ ...r, target: e }, `Copy ${a} into a column`)
|
|
340
341
|
}
|
|
341
342
|
)
|
|
342
343
|
}
|
|
343
344
|
),
|
|
344
345
|
/* @__PURE__ */ l(
|
|
345
|
-
|
|
346
|
+
f,
|
|
346
347
|
{
|
|
347
348
|
k: "field.apply_to_lines.label",
|
|
348
349
|
label: "Button label",
|
|
349
350
|
effect: "The words on the button.",
|
|
350
351
|
children: /* @__PURE__ */ l(
|
|
351
|
-
|
|
352
|
+
R,
|
|
352
353
|
{
|
|
353
354
|
ariaLabel: "Button label",
|
|
354
355
|
disabled: !r.grid,
|
|
@@ -374,7 +375,7 @@ function Be() {
|
|
|
374
375
|
k: "field.prefill_from_parent",
|
|
375
376
|
label: "Prefill from the record",
|
|
376
377
|
effect: "A new addendum starts with the record's current value.",
|
|
377
|
-
checked:
|
|
378
|
+
checked: m.prefill_from_parent !== !1,
|
|
378
379
|
onChange: (e) => t.setOverride(
|
|
379
380
|
"prefill_from_parent",
|
|
380
381
|
e ? void 0 : !1,
|
|
@@ -385,6 +386,6 @@ function Be() {
|
|
|
385
386
|
] });
|
|
386
387
|
}
|
|
387
388
|
export {
|
|
388
|
-
|
|
389
|
-
|
|
389
|
+
De as RulesTab,
|
|
390
|
+
ve as useFieldRows
|
|
390
391
|
};
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { jsxs as d,
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Loader2 as
|
|
4
|
-
import { useState as m } from "react";
|
|
5
|
-
import { createPortal as
|
|
1
|
+
import { jsxs as d, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as F, useQuery as L, useMutation as _ } from "@tanstack/react-query";
|
|
3
|
+
import { Loader2 as E, Play as M, X as O } from "lucide-react";
|
|
4
|
+
import { useState as m, useRef as T } from "react";
|
|
5
|
+
import { createPortal as X } from "react-dom";
|
|
6
6
|
import { toast as x } from "sonner";
|
|
7
|
-
import { useNivaroClient as
|
|
8
|
-
import { get as
|
|
9
|
-
import { PushReadinessChip as
|
|
7
|
+
import { useNivaroClient as D } from "../../context.js";
|
|
8
|
+
import { get as R, post as G } from "../../lib/commands.js";
|
|
9
|
+
import { PushReadinessChip as H } from "../integrations/RecordIntegrationPreview.js";
|
|
10
10
|
import { Button as g } from "../ui/button.js";
|
|
11
|
-
import { ItemActionChoiceList as
|
|
12
|
-
function
|
|
13
|
-
var
|
|
14
|
-
const f =
|
|
11
|
+
import { ItemActionChoiceList as J, itemActionChoiceStep as U } from "./ItemActionChoices.js";
|
|
12
|
+
function se({ collection: r, itemId: s }) {
|
|
13
|
+
var Q, K, S, j, A, z, P;
|
|
14
|
+
const f = D(), l = F(), [N, c] = m(null), k = T(null), { data: h } = L({
|
|
15
15
|
queryKey: ["item-actions", r, s],
|
|
16
16
|
queryFn: () => f.request(
|
|
17
|
-
|
|
17
|
+
R("/item-actions/registered", { collection: r, item: s })
|
|
18
18
|
).then((e) => e.data ?? []),
|
|
19
19
|
staleTime: 5 * 6e4
|
|
20
|
-
}), [t, p] = m(null), [b,
|
|
20
|
+
}), [t, p] = m(null), [b, q] = m(""), [y, $] = m(null), [v, C] = m(null), w = _({
|
|
21
21
|
mutationFn: ({
|
|
22
22
|
action: e,
|
|
23
23
|
message: i,
|
|
@@ -25,7 +25,7 @@ function re({ collection: r, itemId: s }) {
|
|
|
25
25
|
}) => {
|
|
26
26
|
const o = {};
|
|
27
27
|
return i != null && i.trim() && (o.message = i.trim()), e.choose && a != null && (o[e.choose.key] = a), f.request(
|
|
28
|
-
|
|
28
|
+
G(`/item-actions/${e.id}/execute`, {
|
|
29
29
|
collection: r,
|
|
30
30
|
itemId: s,
|
|
31
31
|
...Object.keys(o).length > 0 ? { payload: o } : {}
|
|
@@ -40,30 +40,30 @@ function re({ collection: r, itemId: s }) {
|
|
|
40
40
|
const a = e == null ? void 0 : e.response;
|
|
41
41
|
x.error((a == null ? void 0 : a.error) ?? `${i.label} failed`, { duration: 12e3 }), l.invalidateQueries({ queryKey: ["erp-submissions", r, String(s)] });
|
|
42
42
|
},
|
|
43
|
-
onSettled: () =>
|
|
44
|
-
}),
|
|
43
|
+
onSettled: () => c(null)
|
|
44
|
+
}), B = async (e) => {
|
|
45
45
|
let i = null, a = null;
|
|
46
46
|
if (e.choose) {
|
|
47
|
-
|
|
47
|
+
c(e.id);
|
|
48
48
|
try {
|
|
49
49
|
const o = await f.request(
|
|
50
|
-
|
|
51
|
-
),
|
|
52
|
-
|
|
50
|
+
R(`/item-actions/${e.id}/choices`, { collection: r, item: s })
|
|
51
|
+
), u = U(o.data ?? []);
|
|
52
|
+
u.ask ? a = o.data : i = u.value;
|
|
53
53
|
} catch (o) {
|
|
54
|
-
const
|
|
55
|
-
x.error((
|
|
54
|
+
const u = o == null ? void 0 : o.response;
|
|
55
|
+
x.error((u == null ? void 0 : u.error) ?? `${e.label}: could not load the options`), c(null);
|
|
56
56
|
return;
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
c(null);
|
|
59
59
|
}
|
|
60
60
|
if (e.confirm || a) {
|
|
61
|
-
|
|
61
|
+
q(""), $(a), C(i), p(e);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
c(e.id), w.mutate({ action: e, pick: i });
|
|
65
65
|
};
|
|
66
|
-
return !h || h.length === 0 ? null : /* @__PURE__ */ d(
|
|
66
|
+
return !h || h.length === 0 ? null : /* @__PURE__ */ d("span", { ref: k, className: "contents", children: [
|
|
67
67
|
h.map((e) => /* @__PURE__ */ d("span", { className: "relative inline-flex", children: [
|
|
68
68
|
/* @__PURE__ */ d(
|
|
69
69
|
g,
|
|
@@ -72,16 +72,16 @@ function re({ collection: r, itemId: s }) {
|
|
|
72
72
|
size: "sm",
|
|
73
73
|
variant: e.variant ?? "outline",
|
|
74
74
|
className: "gap-1.5",
|
|
75
|
-
disabled:
|
|
76
|
-
onClick: () => void
|
|
75
|
+
disabled: N !== null,
|
|
76
|
+
onClick: () => void B(e),
|
|
77
77
|
children: [
|
|
78
|
-
|
|
78
|
+
N === e.id ? /* @__PURE__ */ n(E, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(M, { className: "h-3.5 w-3.5" }),
|
|
79
79
|
e.label
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
83
|
e.has_preflight && /* @__PURE__ */ n(
|
|
84
|
-
|
|
84
|
+
H,
|
|
85
85
|
{
|
|
86
86
|
collection: r,
|
|
87
87
|
itemId: String(s),
|
|
@@ -91,10 +91,10 @@ function re({ collection: r, itemId: s }) {
|
|
|
91
91
|
}
|
|
92
92
|
)
|
|
93
93
|
] }, e.id)),
|
|
94
|
-
t &&
|
|
94
|
+
t && X(
|
|
95
95
|
/* @__PURE__ */ n("div", { className: "fixed inset-0 z-[130] flex items-center justify-center bg-black/40 p-4", children: /* @__PURE__ */ d("div", { className: "w-full max-w-md rounded-lg border border-slate-200 bg-white p-5 shadow-xl dark:border-border dark:bg-card", children: [
|
|
96
96
|
/* @__PURE__ */ d("div", { className: "flex items-start justify-between gap-3", children: [
|
|
97
|
-
/* @__PURE__ */ n("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: ((
|
|
97
|
+
/* @__PURE__ */ n("h3", { className: "text-[14px] font-semibold text-slate-900 dark:text-foreground", children: ((Q = t.confirm) == null ? void 0 : Q.title) ?? t.label }),
|
|
98
98
|
/* @__PURE__ */ n(
|
|
99
99
|
"button",
|
|
100
100
|
{
|
|
@@ -102,27 +102,27 @@ function re({ collection: r, itemId: s }) {
|
|
|
102
102
|
onClick: () => p(null),
|
|
103
103
|
className: "rounded p-1 text-slate-400 hover:text-slate-600",
|
|
104
104
|
"aria-label": "Close",
|
|
105
|
-
children: /* @__PURE__ */ n(
|
|
105
|
+
children: /* @__PURE__ */ n(O, { className: "h-4 w-4" })
|
|
106
106
|
}
|
|
107
107
|
)
|
|
108
108
|
] }),
|
|
109
|
-
((
|
|
109
|
+
((K = t.confirm) == null ? void 0 : K.body) && /* @__PURE__ */ n("p", { className: "mt-2 text-[12.5px] leading-relaxed text-slate-600 dark:text-muted-foreground", children: t.confirm.body }),
|
|
110
110
|
t.choose && y && /* @__PURE__ */ n(
|
|
111
|
-
|
|
111
|
+
J,
|
|
112
112
|
{
|
|
113
113
|
choose: t.choose,
|
|
114
114
|
options: y,
|
|
115
115
|
value: v,
|
|
116
|
-
onChange:
|
|
116
|
+
onChange: C
|
|
117
117
|
}
|
|
118
118
|
),
|
|
119
|
-
((
|
|
119
|
+
((S = t.confirm) == null ? void 0 : S.input) && /* @__PURE__ */ d("div", { className: "mt-3", children: [
|
|
120
120
|
/* @__PURE__ */ n("p", { className: "mb-1 text-[11.5px] font-medium text-slate-500", children: t.confirm.input.label }),
|
|
121
121
|
/* @__PURE__ */ n(
|
|
122
122
|
"textarea",
|
|
123
123
|
{
|
|
124
124
|
value: b,
|
|
125
|
-
onChange: (e) =>
|
|
125
|
+
onChange: (e) => q(e.target.value),
|
|
126
126
|
placeholder: t.confirm.input.placeholder,
|
|
127
127
|
rows: 3,
|
|
128
128
|
className: "w-full rounded-md border border-slate-200 bg-background px-2.5 py-1.5 text-[12.5px] dark:border-border"
|
|
@@ -136,20 +136,20 @@ function re({ collection: r, itemId: s }) {
|
|
|
136
136
|
{
|
|
137
137
|
type: "button",
|
|
138
138
|
size: "sm",
|
|
139
|
-
disabled: !!((
|
|
139
|
+
disabled: !!((A = (j = t.confirm) == null ? void 0 : j.input) != null && A.required) && !b.trim() || !!y && v == null,
|
|
140
140
|
onClick: () => {
|
|
141
141
|
const e = t;
|
|
142
|
-
p(null),
|
|
142
|
+
p(null), c(e.id), w.mutate({ action: e, message: b, pick: v });
|
|
143
143
|
},
|
|
144
|
-
children: ((
|
|
144
|
+
children: ((z = t.confirm) == null ? void 0 : z.confirm_label) ?? t.label
|
|
145
145
|
}
|
|
146
146
|
)
|
|
147
147
|
] })
|
|
148
148
|
] }) }),
|
|
149
|
-
document.body
|
|
149
|
+
((P = k.current) == null ? void 0 : P.closest('[role="dialog"]')) ?? document.body
|
|
150
150
|
)
|
|
151
151
|
] });
|
|
152
152
|
}
|
|
153
153
|
export {
|
|
154
|
-
|
|
154
|
+
se as ItemActionButtons
|
|
155
155
|
};
|
|
@@ -1,38 +1,44 @@
|
|
|
1
|
-
import { useQueryClient as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useOptionalNivaroClient as
|
|
4
|
-
import { get as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
1
|
+
import { useQueryClient as m } from "@tanstack/react-query";
|
|
2
|
+
import { useMemo as d } from "react";
|
|
3
|
+
import { useOptionalNivaroClient as y } from "../context.js";
|
|
4
|
+
import { get as c } from "./commands.js";
|
|
5
|
+
const l = "nvr-record-row", R = 1e4;
|
|
6
|
+
function p(r) {
|
|
7
7
|
if (r == null) return null;
|
|
8
|
-
const e = (Array.isArray(r) ? r : r.split(",")).map((
|
|
8
|
+
const e = (Array.isArray(r) ? r : r.split(",")).map((t) => t.trim()).filter(Boolean);
|
|
9
9
|
return e.length ? e : null;
|
|
10
10
|
}
|
|
11
|
-
async function v(r, e,
|
|
12
|
-
const o =
|
|
13
|
-
if (!e || !
|
|
11
|
+
async function v(r, e, t, i, s) {
|
|
12
|
+
const o = p(s), f = !o || o.every((n) => !n.includes(".") && !n.includes("*"));
|
|
13
|
+
if (!e || !f)
|
|
14
14
|
return r.request(
|
|
15
|
-
|
|
16
|
-
).then((
|
|
15
|
+
c(`/items/${t}/${i}`, o ? { fields: o.join(",") } : void 0)
|
|
16
|
+
).then((n) => n.data ?? null);
|
|
17
17
|
const u = await e.fetchQuery({
|
|
18
|
-
queryKey: [
|
|
19
|
-
queryFn: () => r.request(
|
|
20
|
-
staleTime:
|
|
18
|
+
queryKey: [l, t, String(i)],
|
|
19
|
+
queryFn: () => r.request(c(`/items/${t}/${i}`)).then((n) => n.data ?? null),
|
|
20
|
+
staleTime: R
|
|
21
21
|
});
|
|
22
22
|
if (!u || !o) return u;
|
|
23
|
-
const
|
|
24
|
-
for (const
|
|
25
|
-
return
|
|
23
|
+
const a = {};
|
|
24
|
+
for (const n of ["id", ...o]) n in u && (a[n] = u[n]);
|
|
25
|
+
return a;
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
const r =
|
|
29
|
-
return
|
|
30
|
-
() => (
|
|
27
|
+
function O() {
|
|
28
|
+
const r = y(), e = m();
|
|
29
|
+
return d(
|
|
30
|
+
() => (t, i, s) => r ? v(r, e, t, i, s) : Promise.resolve(null),
|
|
31
31
|
[r, e]
|
|
32
32
|
);
|
|
33
33
|
}
|
|
34
|
+
function S(r, e, t) {
|
|
35
|
+
r.invalidateQueries({
|
|
36
|
+
queryKey: t == null ? [l, e] : [l, e, String(t)]
|
|
37
|
+
});
|
|
38
|
+
}
|
|
34
39
|
export {
|
|
35
|
-
|
|
40
|
+
l as RECORD_ROW_KEY,
|
|
41
|
+
S as invalidateRecordRow,
|
|
36
42
|
v as readRecordRow,
|
|
37
|
-
|
|
43
|
+
O as useRecordReader
|
|
38
44
|
};
|