@nivaro/react 0.3.29 → 0.3.30
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/components/slots/pipeline/OwnersSection.js +59 -47
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +11 -10
- package/dist/shared/components/item-edit/CatalogPickerField.js +816 -776
- package/dist/shared/components/item-edit/HeaderFreshness.js +58 -57
- package/dist/shared/components/layout-editor/inspector/HeaderItemInspector.js +56 -46
- package/dist/shared/components/panels/PipelinePanel.js +313 -282
- package/package.json +1 -1
|
@@ -1,83 +1,84 @@
|
|
|
1
|
-
import { jsxs as m, jsx as n, Fragment as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Search as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as Ft, useParentDraft as
|
|
7
|
-
import { canOpenCatalogItem as
|
|
8
|
-
import { get as
|
|
9
|
-
import { evaluateBoolean as
|
|
10
|
-
import { useLiveRefetchInterval as
|
|
11
|
-
import { submissionLineErrors as
|
|
12
|
-
import { titleCase as
|
|
13
|
-
import { ImportFromFileButton as
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
1
|
+
import { jsxs as m, jsx as n, Fragment as lt } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Pr, useQuery as V, useQueries as $t } from "@tanstack/react-query";
|
|
3
|
+
import { Search as ot, Loader2 as ne, ChevronRight as jt, Star as Be, AlertTriangle as ze, AlertCircle as qt, X as dt, Plus as Rr, ChevronDown as Er } from "lucide-react";
|
|
4
|
+
import { useState as W, useRef as Ve, useMemo as E, useEffect as Fe, Fragment as Je } from "react";
|
|
5
|
+
import { createPortal as Ar } from "react-dom";
|
|
6
|
+
import { useNivaroClient as Ft, useParentDraft as Cr, useReimportHandler as Lr } from "../../context.js";
|
|
7
|
+
import { canOpenCatalogItem as sr, openCatalogItem as ar } from "../../lib/catalog-item-open.js";
|
|
8
|
+
import { get as A, del as Kr, patch as Gt, post as Xt } from "../../lib/commands.js";
|
|
9
|
+
import { evaluateBoolean as Jr } from "../../lib/expression.js";
|
|
10
|
+
import { useLiveRefetchInterval as Qr } from "../../lib/live-queries.js";
|
|
11
|
+
import { submissionLineErrors as zr, normalizeIdent as Br } from "../../lib/submission-errors.js";
|
|
12
|
+
import { titleCase as Z, cn as Q, matchesAllTokens as Vr } from "../../lib/utils.js";
|
|
13
|
+
import { ImportFromFileButton as Dr } from "../import/ImportFromFileButton.js";
|
|
14
|
+
import { useOverflowTip as Ur } from "../TipLayer.js";
|
|
15
|
+
import { Popover as Hr, PopoverAnchor as Mr, PopoverContent as Wr } from "../ui/popover.js";
|
|
16
|
+
import { applyDisplayTemplate as Te } from "./helpers.js";
|
|
16
17
|
import { evalClientFormula as Qe } from "./InlineTableField.js";
|
|
17
|
-
import { isIntegerFieldType as
|
|
18
|
-
import { resolveM2MRelatedCollection as
|
|
19
|
-
import { useO2MStaging as
|
|
20
|
-
import { RelationCombobox as
|
|
21
|
-
const
|
|
18
|
+
import { isIntegerFieldType as er, checkNumberEntry as tr, mergePendingQtyRow as Ir, lineRuleErrors as Yr } from "./line-qty.js";
|
|
19
|
+
import { resolveM2MRelatedCollection as Zr } from "./M2MCombobox.js";
|
|
20
|
+
import { useO2MStaging as Gr } from "./O2MStagingContext.js";
|
|
21
|
+
import { RelationCombobox as Xr } from "./RelationCombobox.js";
|
|
22
|
+
const ir = (f, g) => {
|
|
22
23
|
let _ = f;
|
|
23
|
-
for (const
|
|
24
|
+
for (const $ of g.split(".")) {
|
|
24
25
|
if (_ == null || typeof _ != "object") return;
|
|
25
|
-
_ = _[
|
|
26
|
+
_ = _[$];
|
|
26
27
|
}
|
|
27
28
|
return _;
|
|
28
29
|
};
|
|
29
|
-
async function
|
|
30
|
-
const
|
|
30
|
+
async function ct(f, g, _) {
|
|
31
|
+
const $ = [];
|
|
31
32
|
for (let l = 1; l <= 50; l++) {
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
33
|
+
const h = await f.request(A(g, { ..._, limit: 1e3, page: l })).then((p) => p.data ?? []);
|
|
34
|
+
if ($.push(...h), h.length < 1e3) break;
|
|
34
35
|
}
|
|
35
|
-
return
|
|
36
|
+
return $;
|
|
36
37
|
}
|
|
37
|
-
function
|
|
38
|
+
function De(f, g) {
|
|
38
39
|
const _ = {};
|
|
39
|
-
let
|
|
40
|
-
const l = (
|
|
41
|
-
if (typeof
|
|
42
|
-
const
|
|
43
|
-
return
|
|
40
|
+
let $ = !1;
|
|
41
|
+
const l = (h) => {
|
|
42
|
+
if (typeof h == "string" && h.startsWith("$parent.")) {
|
|
43
|
+
const p = g == null ? void 0 : g[h.slice(8)];
|
|
44
|
+
return p == null || p === "" ? ($ = !0, h) : p;
|
|
44
45
|
}
|
|
45
|
-
return Array.isArray(
|
|
46
|
+
return Array.isArray(h) ? h.map(l) : h && typeof h == "object" ? Object.fromEntries(Object.entries(h).map(([p, j]) => [p, l(j)])) : h;
|
|
46
47
|
};
|
|
47
|
-
for (const [
|
|
48
|
-
if (typeof
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
51
|
-
|
|
48
|
+
for (const [h, p] of Object.entries(f ?? {}))
|
|
49
|
+
if (typeof p == "string" && p.startsWith("$parent.")) {
|
|
50
|
+
const j = g == null ? void 0 : g[p.slice(8)];
|
|
51
|
+
if (j == null || j === "") {
|
|
52
|
+
$ = !0;
|
|
52
53
|
continue;
|
|
53
54
|
}
|
|
54
|
-
_[
|
|
55
|
-
} else
|
|
56
|
-
return
|
|
55
|
+
_[h] = { _eq: j };
|
|
56
|
+
} else p && typeof p == "object" ? _[h] = l(p) : _[h] = { _eq: p };
|
|
57
|
+
return $ ? null : _;
|
|
57
58
|
}
|
|
58
|
-
function
|
|
59
|
+
function rr(f, g) {
|
|
59
60
|
if (!f) return !0;
|
|
60
|
-
for (const [_,
|
|
61
|
-
const l =
|
|
62
|
-
for (const [
|
|
63
|
-
switch (
|
|
61
|
+
for (const [_, $] of Object.entries(f)) {
|
|
62
|
+
const l = g == null ? void 0 : g[_], h = l == null ? null : String(l), p = $ && typeof $ == "object" ? $ : { _eq: $ };
|
|
63
|
+
for (const [j, x] of Object.entries(p))
|
|
64
|
+
switch (j) {
|
|
64
65
|
case "_eq":
|
|
65
|
-
if (
|
|
66
|
+
if (h !== String(x)) return !1;
|
|
66
67
|
break;
|
|
67
68
|
case "_neq":
|
|
68
|
-
if (
|
|
69
|
+
if (h === String(x)) return !1;
|
|
69
70
|
break;
|
|
70
71
|
case "_in":
|
|
71
|
-
if (!Array.isArray(
|
|
72
|
+
if (!Array.isArray(x) || !x.map(String).includes(h ?? "")) return !1;
|
|
72
73
|
break;
|
|
73
74
|
case "_nin":
|
|
74
|
-
if (Array.isArray(
|
|
75
|
+
if (Array.isArray(x) && x.map(String).includes(h ?? "")) return !1;
|
|
75
76
|
break;
|
|
76
77
|
case "_null":
|
|
77
|
-
if (
|
|
78
|
+
if (h !== null) return !1;
|
|
78
79
|
break;
|
|
79
80
|
case "_nnull":
|
|
80
|
-
if (
|
|
81
|
+
if (h === null) return !1;
|
|
81
82
|
break;
|
|
82
83
|
default:
|
|
83
84
|
return !1;
|
|
@@ -85,83 +86,83 @@ function Xt(f, y) {
|
|
|
85
86
|
}
|
|
86
87
|
return !0;
|
|
87
88
|
}
|
|
88
|
-
const
|
|
89
|
-
function
|
|
89
|
+
const en = 2e3;
|
|
90
|
+
function qn({
|
|
90
91
|
relatedCollection: f,
|
|
91
|
-
manyField:
|
|
92
|
+
manyField: g,
|
|
92
93
|
parentId: _,
|
|
93
|
-
parentCollection:
|
|
94
|
+
parentCollection: $,
|
|
94
95
|
config: l,
|
|
95
|
-
readOnly:
|
|
96
|
+
readOnly: h = !1
|
|
96
97
|
}) {
|
|
97
|
-
var
|
|
98
|
-
const
|
|
98
|
+
var Mt, Wt, It, Yt;
|
|
99
|
+
const p = Ft(), j = Pr(), x = Gr(), z = Cr(), I = Lr(), se = l.editable_fields ?? [], C = _ === "new", O = l.qty_field ?? "quantity", [oe, G] = W(/* @__PURE__ */ new Set()), Se = Ve(!1), [L, ye] = W(""), [qe, pe] = W({}), [de, ee] = W(/* @__PURE__ */ new Set()), [ce, X] = W({}), [ae, D] = W({}), { data: te = [], isPending: he } = V({
|
|
99
100
|
queryKey: ["collection-relations", f],
|
|
100
|
-
queryFn: () =>
|
|
101
|
+
queryFn: () => p.request(A(`/collections/${f}`)).then((e) => {
|
|
101
102
|
var t;
|
|
102
103
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
103
104
|
}),
|
|
104
105
|
staleTime: 10 * 6e4
|
|
105
|
-
}),
|
|
106
|
+
}), y = E(
|
|
106
107
|
() => {
|
|
107
108
|
var e;
|
|
108
|
-
return ((e =
|
|
109
|
+
return ((e = te.find(
|
|
109
110
|
(t) => t.many_collection === f && t.many_field === l.item_field && !t.junction_field
|
|
110
111
|
)) == null ? void 0 : e.one_collection) ?? null;
|
|
111
112
|
},
|
|
112
|
-
[
|
|
113
|
-
), { data:
|
|
113
|
+
[te, f, l.item_field]
|
|
114
|
+
), { data: ke = [] } = V({
|
|
114
115
|
queryKey: ["field-config", f, null],
|
|
115
|
-
queryFn: () =>
|
|
116
|
+
queryFn: () => p.request(A(`/field-config/${f}`)).then((e) => e.data ?? []),
|
|
116
117
|
staleTime: 6e4
|
|
117
|
-
}),
|
|
118
|
+
}), v = ((Mt = ke.find((e) => e.field === O)) == null ? void 0 : Mt.type) ?? null, K = (e, t, r) => {
|
|
118
119
|
var s;
|
|
119
|
-
return ((s =
|
|
120
|
-
|
|
120
|
+
return ((s = Yr(
|
|
121
|
+
ke.filter((c) => c.field === e).map((c) => ({
|
|
121
122
|
field: c.field,
|
|
122
|
-
label: c.label ||
|
|
123
|
+
label: c.label || Z(c.field),
|
|
123
124
|
type: c.type,
|
|
124
125
|
validation_rules: c.validation_rules
|
|
125
126
|
})),
|
|
126
127
|
{ [e]: t },
|
|
127
128
|
{ ...r, [e]: t }
|
|
128
129
|
)[0]) == null ? void 0 : s.message) ?? null;
|
|
129
|
-
}, { data:
|
|
130
|
-
queryKey: ["col-meta",
|
|
131
|
-
queryFn: () =>
|
|
132
|
-
|
|
130
|
+
}, { data: F } = V({
|
|
131
|
+
queryKey: ["col-meta", y],
|
|
132
|
+
queryFn: () => p.request(
|
|
133
|
+
A(`/collections/${y}`)
|
|
133
134
|
).then((e) => e.data),
|
|
134
|
-
enabled: !!
|
|
135
|
+
enabled: !!y,
|
|
135
136
|
staleTime: 3e5
|
|
136
|
-
}),
|
|
137
|
+
}), J = F == null ? void 0 : F.display_template, S = E(() => {
|
|
137
138
|
const e = l.section_by.split(".")[0];
|
|
138
|
-
return ((
|
|
139
|
-
(t) => t.one_collection ===
|
|
139
|
+
return ((F == null ? void 0 : F.relations) ?? []).find(
|
|
140
|
+
(t) => t.one_collection === y && t.one_field === e && !!t.junction_field
|
|
140
141
|
) ?? null;
|
|
141
|
-
}, [
|
|
142
|
-
queryKey: ["collection-relations",
|
|
143
|
-
queryFn: () =>
|
|
142
|
+
}, [F, y, l.section_by]), P = (S == null ? void 0 : S.many_collection) ?? null, { data: me = [] } = V({
|
|
143
|
+
queryKey: ["collection-relations", P],
|
|
144
|
+
queryFn: () => p.request(A(`/collections/${P}`)).then((e) => {
|
|
144
145
|
var t;
|
|
145
146
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
146
147
|
}),
|
|
147
|
-
enabled: !!
|
|
148
|
+
enabled: !!P,
|
|
148
149
|
staleTime: 10 * 6e4
|
|
149
|
-
}),
|
|
150
|
-
if (!(
|
|
151
|
-
const e = String(
|
|
152
|
-
(s) => s.many_collection ===
|
|
153
|
-
), r =
|
|
150
|
+
}), R = E(() => {
|
|
151
|
+
if (!(S != null && S.many_field) || !P) return null;
|
|
152
|
+
const e = String(S.junction_field), t = me.find(
|
|
153
|
+
(s) => s.many_collection === P && s.many_field === e
|
|
154
|
+
), r = Zr(t);
|
|
154
155
|
return r ? {
|
|
155
|
-
junction:
|
|
156
|
-
fkToItem:
|
|
156
|
+
junction: P,
|
|
157
|
+
fkToItem: S.many_field,
|
|
157
158
|
fkToSection: e,
|
|
158
159
|
target: r,
|
|
159
160
|
labelPath: l.section_by.split(".").slice(1).join(".") || "id"
|
|
160
161
|
} : null;
|
|
161
|
-
}, [
|
|
162
|
+
}, [S, P, me, l.section_by]), H = z == null ? void 0 : z.draft, { resolvedFilter: Oe, resolvedSectionFilter: xe, resolvedLinkFilter: a, missingParents: k } = E(() => {
|
|
162
163
|
const e = [], t = (o) => {
|
|
163
164
|
if (typeof o == "string" && o.startsWith("$parent.")) {
|
|
164
|
-
const i = o.slice(8), b =
|
|
165
|
+
const i = o.slice(8), b = H == null ? void 0 : H[i];
|
|
165
166
|
return b == null || b === "" ? (e.push(i), o) : b;
|
|
166
167
|
}
|
|
167
168
|
return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([i, b]) => [i, t(b)])) : o;
|
|
@@ -172,60 +173,60 @@ function yn({
|
|
|
172
173
|
resolvedLinkFilter: c,
|
|
173
174
|
missingParents: [...new Set(e)]
|
|
174
175
|
};
|
|
175
|
-
}, [l.filter, l.section_filter, l.link_filter,
|
|
176
|
-
if (!
|
|
176
|
+
}, [l.filter, l.section_filter, l.link_filter, H]), U = E(() => {
|
|
177
|
+
if (!S || !xe && !a) return Oe;
|
|
177
178
|
const e = {
|
|
178
|
-
...
|
|
179
|
+
...xe ?? {},
|
|
179
180
|
...a ? { _link: a } : {}
|
|
180
|
-
}, t = { [
|
|
181
|
-
return
|
|
182
|
-
}, [
|
|
181
|
+
}, t = { [S.one_field]: { _some: e } };
|
|
182
|
+
return Oe ? { _and: [Oe, t] } : t;
|
|
183
|
+
}, [S, xe, a, Oe]), B = E(() => {
|
|
183
184
|
const e = /* @__PURE__ */ new Set(["id"]);
|
|
184
|
-
|
|
185
|
-
for (const t of [...(
|
|
185
|
+
F && !S && e.add(l.section_by);
|
|
186
|
+
for (const t of [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
|
|
186
187
|
for (const t of Object.values(l.copy_fields ?? {})) e.add(t);
|
|
187
188
|
for (const t of l.columns ?? []) e.add(t.field);
|
|
188
189
|
return [...e].join(",");
|
|
189
|
-
}, [
|
|
190
|
+
}, [J, F, S, l.section_by, l.copy_fields, l.columns]), re = JSON.stringify(U ?? null), { data: Y = [], isLoading: M } = V(
|
|
190
191
|
{
|
|
191
|
-
queryKey: ["catalog-picker",
|
|
192
|
-
queryFn: () =>
|
|
193
|
-
|
|
194
|
-
limit:
|
|
195
|
-
fields:
|
|
192
|
+
queryKey: ["catalog-picker", y, B, re],
|
|
193
|
+
queryFn: () => p.request(
|
|
194
|
+
A(`/items/${y}`, {
|
|
195
|
+
limit: en,
|
|
196
|
+
fields: B,
|
|
196
197
|
...U ? { filter: JSON.stringify(U) } : {}
|
|
197
198
|
})
|
|
198
199
|
).then((e) => e.data ?? []),
|
|
199
200
|
// Wait for the catalog meta: a to-many section path both narrows this
|
|
200
201
|
// read and must stay out of its `fields=`.
|
|
201
|
-
enabled: !!
|
|
202
|
+
enabled: !!y && !!F && k.length === 0 && (!S || !!R),
|
|
202
203
|
staleTime: 6e4
|
|
203
204
|
}
|
|
204
|
-
), ie = JSON.stringify(
|
|
205
|
-
queryKey: ["catalog-sections",
|
|
205
|
+
), ie = JSON.stringify(xe ?? null), { data: ue = [], isLoading: we } = V({
|
|
206
|
+
queryKey: ["catalog-sections", R == null ? void 0 : R.target, R == null ? void 0 : R.labelPath, ie],
|
|
206
207
|
queryFn: async () => {
|
|
207
|
-
const e =
|
|
208
|
-
return (await
|
|
208
|
+
const e = R;
|
|
209
|
+
return (await ct(p, `/items/${e.target}`, {
|
|
209
210
|
fields: `id,${e.labelPath}`,
|
|
210
|
-
...
|
|
211
|
+
...xe ? { filter: JSON.stringify(xe) } : {}
|
|
211
212
|
})).map((r) => ({
|
|
212
213
|
id: String(r.id),
|
|
213
|
-
name: String(
|
|
214
|
+
name: String(ir(r, e.labelPath) ?? "").trim()
|
|
214
215
|
}));
|
|
215
216
|
},
|
|
216
|
-
enabled: !!
|
|
217
|
+
enabled: !!R && k.length === 0,
|
|
217
218
|
staleTime: 6e4
|
|
218
|
-
}), Re =
|
|
219
|
+
}), Re = E(() => ue.map((e) => e.id), [ue]), { data: Tt = [], isLoading: lr } = V({
|
|
219
220
|
queryKey: [
|
|
220
221
|
"catalog-section-links",
|
|
221
|
-
|
|
222
|
+
R == null ? void 0 : R.junction,
|
|
222
223
|
Re.join(","),
|
|
223
224
|
JSON.stringify(a ?? null)
|
|
224
225
|
],
|
|
225
226
|
queryFn: async () => {
|
|
226
|
-
const e =
|
|
227
|
+
const e = R, t = [];
|
|
227
228
|
for (let r = 0; r < Re.length; r += 200) {
|
|
228
|
-
const s = Re.slice(r, r + 200), c = await
|
|
229
|
+
const s = Re.slice(r, r + 200), c = await ct(p, `/items/${e.junction}`, {
|
|
229
230
|
fields: `${e.fkToItem},${e.fkToSection}`,
|
|
230
231
|
filter: JSON.stringify(
|
|
231
232
|
a ? { _and: [{ [e.fkToSection]: { _in: s } }, a] } : { [e.fkToSection]: { _in: s } }
|
|
@@ -236,10 +237,10 @@ function yn({
|
|
|
236
237
|
}
|
|
237
238
|
return t;
|
|
238
239
|
},
|
|
239
|
-
enabled: !!
|
|
240
|
+
enabled: !!R && Re.length > 0,
|
|
240
241
|
staleTime: 6e4
|
|
241
|
-
}), Ot =
|
|
242
|
-
const e = new Map(
|
|
242
|
+
}), Ot = E(() => {
|
|
243
|
+
const e = new Map(ue.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
|
|
243
244
|
for (const r of Tt) {
|
|
244
245
|
const s = e.get(r.section);
|
|
245
246
|
if (!s) continue;
|
|
@@ -247,157 +248,157 @@ function yn({
|
|
|
247
248
|
c.includes(s) || c.push(s), t.set(r.item, c);
|
|
248
249
|
}
|
|
249
250
|
return t;
|
|
250
|
-
}, [
|
|
251
|
+
}, [ue, Tt]), Ue = !!S && (!R || we || Re.length > 0 && lr), He = E(() => {
|
|
251
252
|
const e = /* @__PURE__ */ new Map();
|
|
252
|
-
for (const t of
|
|
253
|
+
for (const t of Y) e.set(String(t.id), t);
|
|
253
254
|
return e;
|
|
254
|
-
}, [
|
|
255
|
-
queryKey: ["o2m-rows", f,
|
|
256
|
-
queryFn: () =>
|
|
257
|
-
|
|
258
|
-
filter: JSON.stringify({ [
|
|
255
|
+
}, [Y]), { data: Ne = [] } = V({
|
|
256
|
+
queryKey: ["o2m-rows", f, g, _],
|
|
257
|
+
queryFn: () => p.request(
|
|
258
|
+
A(`/items/${f}`, {
|
|
259
|
+
filter: JSON.stringify({ [g]: { _eq: _ } }),
|
|
259
260
|
limit: 1e3
|
|
260
261
|
})
|
|
261
262
|
).then((e) => e.data ?? []),
|
|
262
|
-
enabled: !
|
|
263
|
+
enabled: !C,
|
|
263
264
|
staleTime: 15e3
|
|
264
|
-
}),
|
|
265
|
-
() =>
|
|
266
|
-
const t =
|
|
265
|
+
}), Ee = !C && !!x, ve = x ? x.getPendingRows(f, g) : [], Me = Ee ? x.getPendingEdits(f, g) : /* @__PURE__ */ new Map(), or = JSON.stringify([...Me.entries()]), We = E(
|
|
266
|
+
() => Me.size === 0 ? Ne : Ne.map((e) => {
|
|
267
|
+
const t = Me.get(String(e.id));
|
|
267
268
|
return t ? { ...e, ...t } : e;
|
|
268
269
|
}),
|
|
269
|
-
[
|
|
270
|
-
),
|
|
270
|
+
[Ne, or]
|
|
271
|
+
), Ie = !C && x ? x.getPendingDeletes(f, g) : /* @__PURE__ */ new Set(), Ae = E(() => {
|
|
271
272
|
const e = /* @__PURE__ */ new Map();
|
|
272
|
-
for (const t of
|
|
273
|
+
for (const t of We) {
|
|
273
274
|
const r = t[l.item_field];
|
|
274
275
|
r != null && e.set(String(r), t);
|
|
275
276
|
}
|
|
276
277
|
return e;
|
|
277
|
-
}, [
|
|
278
|
+
}, [We, l.item_field]), Ye = E(() => {
|
|
278
279
|
const e = /* @__PURE__ */ new Map();
|
|
279
|
-
return
|
|
280
|
+
return ve.forEach((t, r) => {
|
|
280
281
|
const s = t[l.item_field];
|
|
281
282
|
s != null && e.set(String(s), r);
|
|
282
283
|
}), e;
|
|
283
|
-
}, [
|
|
284
|
-
const e =
|
|
285
|
-
if (
|
|
286
|
-
const t =
|
|
284
|
+
}, [ve, l.item_field]), le = E(() => {
|
|
285
|
+
const e = ve.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s }));
|
|
286
|
+
if (C) return e;
|
|
287
|
+
const t = We.filter((s) => s[l.item_field] != null).map((s) => ({ key: String(s[l.item_field]), row: s })), r = new Set(t.map((s) => s.key));
|
|
287
288
|
return [...t, ...e.filter((s) => !r.has(s.key))];
|
|
288
|
-
}, [
|
|
289
|
-
() => le.filter((e) => !
|
|
290
|
-
[le,
|
|
291
|
-
), { data:
|
|
292
|
-
queryKey: ["catalog-picker-labels",
|
|
293
|
-
queryFn: () =>
|
|
294
|
-
|
|
295
|
-
filter: JSON.stringify({ id: { _in:
|
|
296
|
-
fields:
|
|
297
|
-
limit:
|
|
289
|
+
}, [C, ve, We, l.item_field]), Ze = E(
|
|
290
|
+
() => le.filter((e) => !He.has(e.key)).map((e) => e.key),
|
|
291
|
+
[le, He]
|
|
292
|
+
), { data: Pt = [] } = V({
|
|
293
|
+
queryKey: ["catalog-picker-labels", y, B, Ze.join(",")],
|
|
294
|
+
queryFn: () => p.request(
|
|
295
|
+
A(`/items/${y}`, {
|
|
296
|
+
filter: JSON.stringify({ id: { _in: Ze } }),
|
|
297
|
+
fields: B,
|
|
298
|
+
limit: Ze.length
|
|
298
299
|
})
|
|
299
300
|
).then((e) => e.data ?? []),
|
|
300
|
-
enabled: !!
|
|
301
|
+
enabled: !!y && Ze.length > 0,
|
|
301
302
|
staleTime: 6e4
|
|
302
|
-
}), { data:
|
|
303
|
-
queryKey: ["pinned-items",
|
|
304
|
-
queryFn: () =>
|
|
305
|
-
enabled: !!
|
|
303
|
+
}), { data: ge = [] } = V({
|
|
304
|
+
queryKey: ["pinned-items", y],
|
|
305
|
+
queryFn: () => p.request(A(`/pinned/${y}`)).then((e) => e.data ?? []),
|
|
306
|
+
enabled: !!y && !!l.favorites,
|
|
306
307
|
staleTime: 6e4
|
|
307
|
-
}),
|
|
308
|
-
queryKey: ["pinned-item-rows",
|
|
309
|
-
queryFn: () =>
|
|
310
|
-
|
|
311
|
-
filter: JSON.stringify({ id: { _in:
|
|
312
|
-
fields:
|
|
313
|
-
limit:
|
|
308
|
+
}), mt = E(() => new Set(ge), [ge]), { data: Ce = [] } = V({
|
|
309
|
+
queryKey: ["pinned-item-rows", y, B, ge.join(",")],
|
|
310
|
+
queryFn: () => p.request(
|
|
311
|
+
A(`/items/${y}`, {
|
|
312
|
+
filter: JSON.stringify({ id: { _in: ge } }),
|
|
313
|
+
fields: B,
|
|
314
|
+
limit: ge.length
|
|
314
315
|
})
|
|
315
316
|
).then((e) => e.data ?? []),
|
|
316
|
-
enabled: !!
|
|
317
|
+
enabled: !!y && !!l.favorites && ge.length > 0,
|
|
317
318
|
staleTime: 6e4
|
|
318
|
-
}), [
|
|
319
|
+
}), [Ge, Rt] = W(/* @__PURE__ */ new Set());
|
|
319
320
|
async function Et(e) {
|
|
320
|
-
if (!(!
|
|
321
|
-
|
|
321
|
+
if (!(!y || Ge.has(e))) {
|
|
322
|
+
Rt((t) => new Set(t).add(e));
|
|
322
323
|
try {
|
|
323
|
-
await
|
|
324
|
-
}), await
|
|
324
|
+
await p.request(Xt(`/pinned/${y}/${e}/toggle`)).catch(() => {
|
|
325
|
+
}), await j.invalidateQueries({ queryKey: ["pinned-items", y] });
|
|
325
326
|
} finally {
|
|
326
|
-
|
|
327
|
+
Rt((t) => {
|
|
327
328
|
const r = new Set(t);
|
|
328
329
|
return r.delete(e), r;
|
|
329
330
|
});
|
|
330
331
|
}
|
|
331
332
|
}
|
|
332
333
|
}
|
|
333
|
-
const [
|
|
334
|
+
const [dr, At] = W(!1), Ct = Ve(null), ut = (e) => l.favorites ? /* @__PURE__ */ n(
|
|
334
335
|
"button",
|
|
335
336
|
{
|
|
336
337
|
type: "button",
|
|
337
|
-
title:
|
|
338
|
-
disabled:
|
|
338
|
+
title: mt.has(e) ? "Remove from favorites" : "Add to favorites",
|
|
339
|
+
disabled: Ge.has(e),
|
|
339
340
|
onClick: (t) => {
|
|
340
341
|
t.stopPropagation(), Et(e);
|
|
341
342
|
},
|
|
342
343
|
className: "shrink-0 rounded p-0.5 transition-colors",
|
|
343
|
-
children:
|
|
344
|
+
children: Ge.has(e) ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
|
|
344
345
|
Be,
|
|
345
346
|
{
|
|
346
|
-
className:
|
|
347
|
+
className: Q(
|
|
347
348
|
"h-3.5 w-3.5",
|
|
348
|
-
|
|
349
|
+
mt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
349
350
|
)
|
|
350
351
|
}
|
|
351
352
|
)
|
|
352
353
|
}
|
|
353
|
-
) : null, [
|
|
354
|
-
|
|
355
|
-
const e = setTimeout(() =>
|
|
354
|
+
) : null, [ft, cr] = W("");
|
|
355
|
+
Fe(() => {
|
|
356
|
+
const e = setTimeout(() => cr(L), 300);
|
|
356
357
|
return () => clearTimeout(e);
|
|
357
|
-
}, [
|
|
358
|
-
const
|
|
358
|
+
}, [L]);
|
|
359
|
+
const mr = E(() => {
|
|
359
360
|
var t;
|
|
360
|
-
const e = (t = [...(
|
|
361
|
+
const e = (t = [...(J ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
|
|
361
362
|
return e && !e.includes(".") ? e : "id";
|
|
362
|
-
}, [
|
|
363
|
-
queryKey: ["catalog-full-search",
|
|
364
|
-
queryFn: () =>
|
|
365
|
-
|
|
366
|
-
search:
|
|
367
|
-
fields:
|
|
363
|
+
}, [J]), { data: ur = [], isFetching: bt } = V({
|
|
364
|
+
queryKey: ["catalog-full-search", y, B, ft],
|
|
365
|
+
queryFn: () => p.request(
|
|
366
|
+
A(`/items/${y}`, {
|
|
367
|
+
search: ft,
|
|
368
|
+
fields: B,
|
|
368
369
|
limit: 25,
|
|
369
|
-
sort:
|
|
370
|
+
sort: mr
|
|
370
371
|
})
|
|
371
372
|
).then((e) => e.data ?? []),
|
|
372
|
-
enabled: !!
|
|
373
|
+
enabled: !!y && ft.trim().length > 0,
|
|
373
374
|
staleTime: 3e4,
|
|
374
375
|
placeholderData: (e) => e
|
|
375
|
-
}),
|
|
376
|
+
}), $e = ur, Xe = E(() => {
|
|
376
377
|
const e = /* @__PURE__ */ new Set();
|
|
377
|
-
for (const t of
|
|
378
|
+
for (const t of Y) e.add(String(t.id));
|
|
378
379
|
for (const t of le) e.add(t.key);
|
|
379
|
-
for (const t of
|
|
380
|
-
for (const t of
|
|
380
|
+
for (const t of ge) e.add(t);
|
|
381
|
+
for (const t of $e) e.add(String(t.id));
|
|
381
382
|
return [...e];
|
|
382
|
-
}, [
|
|
383
|
+
}, [Y, le, ge, $e]), Lt = $t({
|
|
383
384
|
queries: (l.related_columns ?? []).map((e) => {
|
|
384
|
-
const t =
|
|
385
|
+
const t = De(e.match, H);
|
|
385
386
|
return {
|
|
386
387
|
queryKey: [
|
|
387
388
|
"catalog-related",
|
|
388
389
|
e.key,
|
|
389
390
|
e.collection,
|
|
390
391
|
JSON.stringify(t),
|
|
391
|
-
|
|
392
|
+
Xe.join(",")
|
|
392
393
|
],
|
|
393
394
|
queryFn: async () => {
|
|
394
395
|
const r = {}, s = e.aggregate === "sum", c = s ? 150 : 400;
|
|
395
|
-
for (let o = 0; o <
|
|
396
|
-
const i =
|
|
396
|
+
for (let o = 0; o < Xe.length; o += c) {
|
|
397
|
+
const i = Xe.slice(o, o + c);
|
|
397
398
|
let b = 1;
|
|
398
399
|
for (; ; ) {
|
|
399
|
-
const d = await
|
|
400
|
-
|
|
400
|
+
const d = await p.request(
|
|
401
|
+
A(`/items/${e.collection}`, {
|
|
401
402
|
limit: s ? 1e3 : i.length,
|
|
402
403
|
...s ? { page: b } : {},
|
|
403
404
|
fields: `${e.item_field},${e.value_field}`,
|
|
@@ -408,8 +409,8 @@ function yn({
|
|
|
408
409
|
const w = u[e.item_field];
|
|
409
410
|
if (w != null)
|
|
410
411
|
if (s) {
|
|
411
|
-
const
|
|
412
|
-
r[String(w)] = (Number(r[String(w)]) || 0) + (Number.isNaN(
|
|
412
|
+
const T = Number(u[e.value_field]);
|
|
413
|
+
r[String(w)] = (Number(r[String(w)]) || 0) + (Number.isNaN(T) ? 0 : T);
|
|
413
414
|
} else
|
|
414
415
|
r[String(w)] = u[e.value_field];
|
|
415
416
|
}
|
|
@@ -419,28 +420,28 @@ function yn({
|
|
|
419
420
|
}
|
|
420
421
|
return r;
|
|
421
422
|
},
|
|
422
|
-
enabled: !!
|
|
423
|
+
enabled: !!y && t !== null && Xe.length > 0,
|
|
423
424
|
staleTime: 3e4
|
|
424
425
|
};
|
|
425
426
|
})
|
|
426
|
-
}),
|
|
427
|
+
}), pt = (e, t) => {
|
|
427
428
|
var s, c;
|
|
428
429
|
const r = (l.related_columns ?? []).findIndex((o) => o.key === e);
|
|
429
430
|
if (r !== -1)
|
|
430
|
-
return (c = (s =
|
|
431
|
-
},
|
|
431
|
+
return (c = (s = Lt[r]) == null ? void 0 : s.data) == null ? void 0 : c[t];
|
|
432
|
+
}, ht = (e) => {
|
|
432
433
|
var b;
|
|
433
434
|
const t = l.qty_warning;
|
|
434
435
|
if (!t) return null;
|
|
435
|
-
const r =
|
|
436
|
+
const r = be(e) ?? 0;
|
|
436
437
|
if (r <= 0) return null;
|
|
437
438
|
const s = (l.related_columns ?? []).findIndex((d) => d.key === t.column);
|
|
438
439
|
if (s === -1) return null;
|
|
439
|
-
const c = (b =
|
|
440
|
+
const c = (b = Lt[s]) == null ? void 0 : b.data;
|
|
440
441
|
if (c === void 0) return null;
|
|
441
442
|
const o = c[e], i = o == null || o === "" ? 0 : Number(o);
|
|
442
443
|
return Number.isNaN(i) ? null : r > i ? { available: i, qty: r } : null;
|
|
443
|
-
},
|
|
444
|
+
}, fr = (e) => {
|
|
444
445
|
const t = l.row_flags ?? [];
|
|
445
446
|
if (t.length === 0) return [];
|
|
446
447
|
const r = [];
|
|
@@ -448,93 +449,93 @@ function yn({
|
|
|
448
449
|
if (!(!(s != null && s.when) || !s.label))
|
|
449
450
|
try {
|
|
450
451
|
const c = s.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
|
|
451
|
-
|
|
452
|
+
Jr(c, e) && r.push(s.label);
|
|
452
453
|
} catch {
|
|
453
454
|
}
|
|
454
455
|
return r;
|
|
455
|
-
},
|
|
456
|
+
}, xt = l.qty_warning ? l.qty_warning.label ?? ((Wt = (l.related_columns ?? []).find((e) => {
|
|
456
457
|
var t;
|
|
457
458
|
return e.key === ((t = l.qty_warning) == null ? void 0 : t.column);
|
|
458
|
-
})) == null ? void 0 :
|
|
459
|
+
})) == null ? void 0 : Wt.label) ?? Z(l.qty_warning.column) : "", br = !!l.submission_errors, et = E(
|
|
459
460
|
() => {
|
|
460
461
|
var e;
|
|
461
462
|
return typeof l.submission_errors == "object" && Array.isArray((e = l.submission_errors) == null ? void 0 : e.match_fields) ? l.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
|
|
462
463
|
},
|
|
463
464
|
[l.submission_errors]
|
|
464
|
-
),
|
|
465
|
-
queryKey: ["erp-submissions",
|
|
466
|
-
queryFn: () =>
|
|
467
|
-
enabled:
|
|
465
|
+
), pr = Qr(6e4), { data: Kt } = V({
|
|
466
|
+
queryKey: ["erp-submissions", $ ?? "", String(_)],
|
|
467
|
+
queryFn: () => p.request(A(`/erp-submissions/${$}/${encodeURIComponent(_)}`)).then((e) => e.data ?? []),
|
|
468
|
+
enabled: br && !C && !!$,
|
|
468
469
|
staleTime: 15e3,
|
|
469
|
-
refetchInterval:
|
|
470
|
-
}),
|
|
470
|
+
refetchInterval: pr
|
|
471
|
+
}), gt = E(() => {
|
|
471
472
|
const e = (Kt ?? [])[0];
|
|
472
|
-
return !e || e.status !== "failed" ? null :
|
|
473
|
-
}, [Kt]),
|
|
474
|
-
queryKey: ["catalog-suberr-idents",
|
|
473
|
+
return !e || e.status !== "failed" ? null : zr(e.payload, e.last_error);
|
|
474
|
+
}, [Kt]), hr = le.map((e) => e.key).join(","), { data: yt } = V({
|
|
475
|
+
queryKey: ["catalog-suberr-idents", y, et.join(","), hr],
|
|
475
476
|
queryFn: async () => {
|
|
476
477
|
const e = le.map((r) => r.key);
|
|
477
478
|
if (e.length === 0) return {};
|
|
478
|
-
const t = await
|
|
479
|
-
|
|
479
|
+
const t = await p.request(
|
|
480
|
+
A(`/items/${y}`, {
|
|
480
481
|
limit: e.length,
|
|
481
|
-
fields: ["id", ...
|
|
482
|
+
fields: ["id", ...et].join(","),
|
|
482
483
|
filter: JSON.stringify({ id: { _in: e } })
|
|
483
484
|
})
|
|
484
485
|
).then((r) => r.data ?? []);
|
|
485
486
|
return Object.fromEntries(t.map((r) => [String(r.id), r]));
|
|
486
487
|
},
|
|
487
|
-
enabled: !!
|
|
488
|
+
enabled: !!y && !!gt && et.length > 0 && le.length > 0,
|
|
488
489
|
staleTime: 6e4
|
|
489
|
-
}),
|
|
490
|
-
if (!
|
|
491
|
-
const t =
|
|
492
|
-
|
|
493
|
-
...
|
|
494
|
-
const c = (t == null ? void 0 : t[s]) ??
|
|
490
|
+
}), xr = (e) => {
|
|
491
|
+
if (!gt) return null;
|
|
492
|
+
const t = yt == null ? void 0 : yt[e], r = [
|
|
493
|
+
Ht(e),
|
|
494
|
+
...et.map((s) => {
|
|
495
|
+
const c = (t == null ? void 0 : t[s]) ?? Pe(e)[s];
|
|
495
496
|
return c != null && c !== "" ? String(c) : null;
|
|
496
497
|
})
|
|
497
|
-
].filter((s) => !!s).map(
|
|
498
|
-
return
|
|
499
|
-
},
|
|
500
|
-
queries:
|
|
501
|
-
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction,
|
|
498
|
+
].filter((s) => !!s).map(Br);
|
|
499
|
+
return gt.reasonFor(r);
|
|
500
|
+
}, tt = l.summary_fields ?? [], gr = Ne.map((e) => String(e.id)).join(","), yr = $t({
|
|
501
|
+
queries: tt.filter((e) => e.m2m).map((e) => ({
|
|
502
|
+
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, gr],
|
|
502
503
|
queryFn: async () => {
|
|
503
|
-
const t =
|
|
504
|
+
const t = Ne.map((u) => String(u.id));
|
|
504
505
|
if (t.length === 0) return {};
|
|
505
|
-
const r = e.m2m, s = await
|
|
506
|
-
|
|
506
|
+
const r = e.m2m, s = await p.request(
|
|
507
|
+
A(`/items/${r.junction}`, {
|
|
507
508
|
limit: 1e3,
|
|
508
509
|
fields: `${r.fk_to_child},${r.related_field}`,
|
|
509
510
|
filter: JSON.stringify({ [r.fk_to_child]: { _in: t } })
|
|
510
511
|
})
|
|
511
|
-
).then((u) => u.data ?? []).catch(() => []), c = [...new Set(s.map((u) => String(u[r.related_field])))], o = r.label_field ?? "name", i = c.length ? await
|
|
512
|
-
|
|
512
|
+
).then((u) => u.data ?? []).catch(() => []), c = [...new Set(s.map((u) => String(u[r.related_field])))], o = r.label_field ?? "name", i = c.length ? await p.request(
|
|
513
|
+
A(`/items/${r.related_collection}`, {
|
|
513
514
|
limit: 500,
|
|
514
515
|
fields: `id,${o}`,
|
|
515
516
|
filter: JSON.stringify({ id: { _in: c } })
|
|
516
517
|
})
|
|
517
518
|
).then((u) => u.data ?? []).catch(() => []) : [], b = new Map(i.map((u) => [String(u.id), String(u[o] ?? u.id)])), d = {};
|
|
518
519
|
for (const u of s) {
|
|
519
|
-
const w = String(u[r.fk_to_child]),
|
|
520
|
-
|
|
520
|
+
const w = String(u[r.fk_to_child]), T = b.get(String(u[r.related_field]));
|
|
521
|
+
T && (d[w] = d[w] ? `${d[w]}, ${T}` : T);
|
|
521
522
|
}
|
|
522
523
|
return d;
|
|
523
524
|
},
|
|
524
|
-
enabled: !
|
|
525
|
+
enabled: !C && Ne.length > 0,
|
|
525
526
|
staleTime: 15e3
|
|
526
527
|
}))
|
|
527
|
-
}),
|
|
528
|
+
}), kr = (e, t) => {
|
|
528
529
|
var c, o;
|
|
529
530
|
if (!e.m2m) return t.row[e.field];
|
|
530
|
-
const r =
|
|
531
|
+
const r = tt.filter((i) => i.m2m).findIndex((i) => i.field === e.field);
|
|
531
532
|
if (r === -1) return;
|
|
532
533
|
const s = t.row.id;
|
|
533
534
|
if (s != null)
|
|
534
|
-
return (o = (c =
|
|
535
|
-
},
|
|
536
|
-
if (!
|
|
537
|
-
const t = Number(e[l.fulfilment.qty_field ??
|
|
535
|
+
return (o = (c = yr[r]) == null ? void 0 : c.data) == null ? void 0 : o[String(s)];
|
|
536
|
+
}, wr = !!((It = l.fulfilment) != null && It.shipped_field) && (l.fulfilment.show_when ? rr(l.fulfilment.show_when, H) : !0), Nr = (e) => {
|
|
537
|
+
if (!wr || !l.fulfilment) return null;
|
|
538
|
+
const t = Number(e[l.fulfilment.qty_field ?? O] ?? 0) || 0, r = Number(e[l.fulfilment.shipped_field] ?? 0) || 0, s = t > 0 && r >= t ? {
|
|
538
539
|
dot: "bg-emerald-500",
|
|
539
540
|
text: "text-emerald-700 dark:text-emerald-400",
|
|
540
541
|
label: "Shipped"
|
|
@@ -559,7 +560,7 @@ function yn({
|
|
|
559
560
|
]
|
|
560
561
|
}
|
|
561
562
|
);
|
|
562
|
-
}, Jt = l.columns ?? [], Qt = l.related_columns ?? [],
|
|
563
|
+
}, Jt = l.columns ?? [], Qt = l.related_columns ?? [], rt = Jt.filter((e) => !e.summary_only), kt = Qt.filter((e) => !e.summary_only), zt = Jt.filter((e) => !e.sections_only), Bt = Qt.filter((e) => !e.sections_only), Vt = rt.length > 0 || kt.length > 0, wt = Ve(null), Dt = (e) => {
|
|
563
564
|
let t = e.parentElement;
|
|
564
565
|
for (; t; ) {
|
|
565
566
|
const r = getComputedStyle(t);
|
|
@@ -569,88 +570,85 @@ function yn({
|
|
|
569
570
|
}
|
|
570
571
|
t = t.parentElement;
|
|
571
572
|
}
|
|
572
|
-
},
|
|
573
|
-
|
|
573
|
+
}, vr = (e) => {
|
|
574
|
+
wt.current = e, e && Dt(e);
|
|
574
575
|
};
|
|
575
|
-
|
|
576
|
+
Fe(() => {
|
|
576
577
|
let e = 0;
|
|
577
578
|
const t = () => {
|
|
578
579
|
e || (e = requestAnimationFrame(() => {
|
|
579
|
-
e = 0,
|
|
580
|
+
e = 0, wt.current && Dt(wt.current);
|
|
580
581
|
}));
|
|
581
582
|
};
|
|
582
583
|
return window.addEventListener("scroll", t, !0), () => {
|
|
583
584
|
e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
|
|
584
585
|
};
|
|
585
586
|
}, []);
|
|
586
|
-
const
|
|
587
|
+
const nt = (e, t) => {
|
|
587
588
|
let r = e;
|
|
588
589
|
for (const s of t.split(".")) {
|
|
589
590
|
if (r == null || typeof r != "object") return;
|
|
590
591
|
r = r[s];
|
|
591
592
|
}
|
|
592
593
|
return r;
|
|
593
|
-
},
|
|
594
|
+
}, fe = (e, t) => {
|
|
594
595
|
if (t === "presence")
|
|
595
596
|
return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
|
|
596
597
|
if (e == null || e === "") return "—";
|
|
597
598
|
const r = Number(e);
|
|
598
599
|
return t === "currency" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(r) ? String(e) : r.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
|
|
599
|
-
},
|
|
600
|
-
|
|
601
|
-
|
|
600
|
+
}, _r = (Yt = rt.find((e) => !e.format)) == null ? void 0 : Yt.field, Ut = (e) => e.format ? "w-20 shrink-0 text-right" : e.field === _r ? "min-w-0 flex-[3]" : "w-36 shrink-0", Nt = (e, t) => /* @__PURE__ */ m(lt, { children: [
|
|
601
|
+
rt.map((r) => /* @__PURE__ */ n(
|
|
602
|
+
nr,
|
|
602
603
|
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
r.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1"
|
|
606
|
-
),
|
|
607
|
-
children: ue(Ae(t, r.field), r.format)
|
|
604
|
+
text: fe(nt(t, r.field), r.format),
|
|
605
|
+
className: Q("text-slate-500 dark:text-slate-400", Ut(r))
|
|
608
606
|
},
|
|
609
607
|
r.field
|
|
610
608
|
)),
|
|
611
|
-
|
|
609
|
+
kt.map((r) => /* @__PURE__ */ n(
|
|
612
610
|
"span",
|
|
613
611
|
{
|
|
614
612
|
className: "w-20 shrink-0 truncate text-right text-slate-500 dark:text-slate-400",
|
|
615
|
-
children:
|
|
613
|
+
children: fe(pt(r.key, e), r.format)
|
|
616
614
|
},
|
|
617
615
|
r.key
|
|
618
616
|
))
|
|
619
|
-
] }),
|
|
617
|
+
] }), vt = Vt ? "w-36 shrink-0 truncate text-slate-700 dark:text-slate-200" : "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", Sr = sr(y), st = (e, t, r) => Sr ? /* @__PURE__ */ n(
|
|
620
618
|
"button",
|
|
621
619
|
{
|
|
622
620
|
type: "button",
|
|
623
|
-
onClick: () =>
|
|
621
|
+
onClick: () => y && ar(y, e, H),
|
|
624
622
|
title: "View stock & planning detail",
|
|
625
|
-
className:
|
|
623
|
+
className: Q(
|
|
626
624
|
r,
|
|
627
625
|
"text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
|
|
628
626
|
),
|
|
629
627
|
children: t
|
|
630
628
|
}
|
|
631
|
-
) : /* @__PURE__ */ n("span", { className: r, children: t }),
|
|
632
|
-
const t =
|
|
633
|
-
return t ?
|
|
634
|
-
},
|
|
629
|
+
) : /* @__PURE__ */ n("span", { className: r, children: t }), Ht = (e) => {
|
|
630
|
+
const t = He.get(e) ?? Pt.find((r) => String(r.id) === e) ?? Ce.find((r) => String(r.id) === e);
|
|
631
|
+
return t ? Te(J, t) : `#${e}`;
|
|
632
|
+
}, Pe = (e) => He.get(e) ?? Pt.find((t) => String(t.id) === e) ?? Ce.find((t) => String(t.id) === e) ?? { id: e }, be = (e) => {
|
|
635
633
|
var s;
|
|
636
|
-
const t =
|
|
637
|
-
if (t) return
|
|
638
|
-
const r =
|
|
639
|
-
return r === void 0 ? null : Number(((s =
|
|
640
|
-
},
|
|
634
|
+
const t = C ? void 0 : Ae.get(e);
|
|
635
|
+
if (t) return Ie.has(String(t.id)) ? null : Number(t[O] ?? 0);
|
|
636
|
+
const r = Ye.get(e);
|
|
637
|
+
return r === void 0 ? null : Number(((s = ve[r]) == null ? void 0 : s[O]) ?? 0);
|
|
638
|
+
}, qr = (e) => {
|
|
641
639
|
let t = e;
|
|
642
640
|
for (const r of l.section_by.split(".")) {
|
|
643
641
|
if (t == null || typeof t != "object") return "";
|
|
644
642
|
t = t[r];
|
|
645
643
|
}
|
|
646
644
|
return String(t ?? "").trim();
|
|
647
|
-
},
|
|
648
|
-
if (
|
|
649
|
-
|
|
645
|
+
}, at = E(() => {
|
|
646
|
+
if (Ue) return [];
|
|
647
|
+
L.trim().toLowerCase();
|
|
650
648
|
const e = /* @__PURE__ */ new Map();
|
|
651
|
-
for (const t of
|
|
652
|
-
const r =
|
|
653
|
-
if (!(
|
|
649
|
+
for (const t of Y) {
|
|
650
|
+
const r = Te(J, t), s = S ? Ot.get(String(t.id)) ?? [] : [qr(t)];
|
|
651
|
+
if (!(S && a && s.length === 0))
|
|
654
652
|
for (const c of s.length ? s : [""]) {
|
|
655
653
|
const o = c || "Uncategorized";
|
|
656
654
|
e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: r, row: t });
|
|
@@ -663,32 +661,32 @@ function yn({
|
|
|
663
661
|
items: r.sort((s, c) => s.label.localeCompare(c.label))
|
|
664
662
|
}));
|
|
665
663
|
}, [
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
664
|
+
Y,
|
|
665
|
+
J,
|
|
666
|
+
L,
|
|
669
667
|
l.section_by,
|
|
670
|
-
|
|
668
|
+
S,
|
|
671
669
|
Ot,
|
|
672
|
-
|
|
670
|
+
Ue,
|
|
673
671
|
a
|
|
674
672
|
]);
|
|
675
|
-
if (!
|
|
676
|
-
|
|
673
|
+
if (!Se.current && at.length > 0) {
|
|
674
|
+
Se.current = !0;
|
|
677
675
|
const e = /* @__PURE__ */ new Set();
|
|
678
|
-
for (const t of
|
|
679
|
-
t.items.some((s) => (
|
|
680
|
-
|
|
676
|
+
for (const t of at)
|
|
677
|
+
t.items.some((s) => (be(s.id) ?? 0) > 0) || e.add(t.name);
|
|
678
|
+
G(e);
|
|
681
679
|
}
|
|
682
|
-
async function
|
|
680
|
+
async function $r(e) {
|
|
683
681
|
const t = {};
|
|
684
682
|
for (const r of l.related_columns ?? []) {
|
|
685
683
|
if (!r.copy_to) continue;
|
|
686
|
-
let s =
|
|
684
|
+
let s = pt(r.key, e);
|
|
687
685
|
if (s === void 0) {
|
|
688
|
-
const c =
|
|
686
|
+
const c = De(r.match, H);
|
|
689
687
|
if (c === null) continue;
|
|
690
|
-
s = await
|
|
691
|
-
|
|
688
|
+
s = await p.request(
|
|
689
|
+
A(`/items/${r.collection}`, {
|
|
692
690
|
limit: 1,
|
|
693
691
|
fields: `${r.item_field},${r.value_field}`,
|
|
694
692
|
filter: JSON.stringify({ ...c, [r.item_field]: { _eq: e } })
|
|
@@ -703,10 +701,10 @@ function yn({
|
|
|
703
701
|
}
|
|
704
702
|
return t;
|
|
705
703
|
}
|
|
706
|
-
function
|
|
704
|
+
function Le(e, t, r, s = {}) {
|
|
707
705
|
const c = {
|
|
708
706
|
[l.item_field]: r.id ?? e,
|
|
709
|
-
[
|
|
707
|
+
[O]: t
|
|
710
708
|
};
|
|
711
709
|
for (const [o, i] of Object.entries(l.copy_fields ?? {}))
|
|
712
710
|
r[i] !== void 0 && (c[o] = r[i]);
|
|
@@ -717,100 +715,100 @@ function yn({
|
|
|
717
715
|
}
|
|
718
716
|
return c;
|
|
719
717
|
}
|
|
720
|
-
async function
|
|
721
|
-
const c =
|
|
718
|
+
async function Ke(e, t, r, s = {}) {
|
|
719
|
+
const c = tr(t, { type: v, min: 0, label: "Quantity" });
|
|
722
720
|
if (!c.ok) {
|
|
723
|
-
|
|
721
|
+
X((d) => ({ ...d, [e]: { kind: "error", message: c.message } }));
|
|
724
722
|
return;
|
|
725
723
|
}
|
|
726
724
|
const o = c.value ?? 0;
|
|
727
|
-
if ((
|
|
725
|
+
if ((be(e) ?? 0) === o) return;
|
|
728
726
|
if (o === 0 && !s.confirmedRemove) {
|
|
729
|
-
|
|
727
|
+
X((d) => ({ ...d, [e]: { kind: "remove", row: r } }));
|
|
730
728
|
return;
|
|
731
729
|
}
|
|
732
730
|
if (o > 0) {
|
|
733
|
-
const d =
|
|
731
|
+
const d = Ye.get(e), u = (C ? void 0 : Ae.get(e)) ?? (d !== void 0 ? ve[d] : void 0) ?? {}, w = K(O, o, u);
|
|
734
732
|
if (w) {
|
|
735
|
-
|
|
733
|
+
X((T) => ({ ...T, [e]: { kind: "error", message: w } }));
|
|
736
734
|
return;
|
|
737
735
|
}
|
|
738
736
|
}
|
|
739
|
-
const b = o > 0 ? await
|
|
740
|
-
if (
|
|
741
|
-
const d =
|
|
737
|
+
const b = o > 0 ? await $r(e) : {};
|
|
738
|
+
if (Ee && x) {
|
|
739
|
+
const d = Ae.get(e);
|
|
742
740
|
if ((d == null ? void 0 : d.id) != null) {
|
|
743
741
|
const u = String(d.id);
|
|
744
742
|
if (o === 0) {
|
|
745
|
-
|
|
743
|
+
x.cancelPendingEdit(f, g, u), x.queueDelete(f, g, u);
|
|
746
744
|
return;
|
|
747
745
|
}
|
|
748
|
-
|
|
749
|
-
const w =
|
|
750
|
-
for (const
|
|
751
|
-
d[
|
|
752
|
-
for (const [
|
|
753
|
-
const
|
|
754
|
-
|
|
746
|
+
Ie.has(u) && x.cancelPendingDelete(f, g, u);
|
|
747
|
+
const w = Le(e, o, r, b);
|
|
748
|
+
for (const q of se)
|
|
749
|
+
d[q] != null && d[q] !== "" && (w[q] = d[q]);
|
|
750
|
+
for (const [q, je] of Object.entries(l.compute_fields ?? {})) {
|
|
751
|
+
const _e = Qe(je, { ...d, ...w });
|
|
752
|
+
_e !== null && (w[q] = _e);
|
|
755
753
|
}
|
|
756
|
-
const
|
|
757
|
-
Object.entries(w).filter(([
|
|
754
|
+
const T = Ne.find((q) => String(q.id) === u) ?? {}, N = Object.fromEntries(
|
|
755
|
+
Object.entries(w).filter(([q, je]) => String(je ?? "") !== String(T[q] ?? ""))
|
|
758
756
|
);
|
|
759
|
-
Object.keys(N).length === 0 ?
|
|
757
|
+
Object.keys(N).length === 0 ? x.cancelPendingEdit(f, g, u) : (x.cancelPendingEdit(f, g, u), x.queueEdit(f, g, u, N));
|
|
760
758
|
return;
|
|
761
759
|
}
|
|
762
760
|
}
|
|
763
|
-
if (
|
|
764
|
-
const d =
|
|
765
|
-
o === 0 ? d !== void 0 && (
|
|
761
|
+
if (C || Ee) {
|
|
762
|
+
const d = Ye.get(e);
|
|
763
|
+
o === 0 ? d !== void 0 && (x == null || x.removeRow(f, g, d)) : d !== void 0 ? x == null || x.updateRow(
|
|
766
764
|
f,
|
|
767
|
-
|
|
765
|
+
g,
|
|
768
766
|
d,
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
767
|
+
Ir(
|
|
768
|
+
ve[d],
|
|
769
|
+
Le(e, o, r, b),
|
|
770
|
+
se,
|
|
773
771
|
l.compute_fields
|
|
774
772
|
)
|
|
775
|
-
) :
|
|
773
|
+
) : x == null || x.queueRow(
|
|
776
774
|
f,
|
|
777
|
-
|
|
778
|
-
|
|
775
|
+
g,
|
|
776
|
+
Le(e, o, r, b)
|
|
779
777
|
);
|
|
780
778
|
return;
|
|
781
779
|
}
|
|
782
|
-
|
|
780
|
+
ee((d) => new Set(d).add(e));
|
|
783
781
|
try {
|
|
784
|
-
const d =
|
|
782
|
+
const d = Ae.get(e);
|
|
785
783
|
if (o === 0)
|
|
786
|
-
(d == null ? void 0 : d.id) != null && await
|
|
784
|
+
(d == null ? void 0 : d.id) != null && await p.request(Kr(`/items/${f}/${d.id}`));
|
|
787
785
|
else if ((d == null ? void 0 : d.id) != null) {
|
|
788
|
-
const u =
|
|
789
|
-
for (const
|
|
790
|
-
d[
|
|
791
|
-
for (const [
|
|
792
|
-
const
|
|
793
|
-
|
|
786
|
+
const u = Le(e, o, r, b);
|
|
787
|
+
for (const q of se)
|
|
788
|
+
d[q] != null && d[q] !== "" && (u[q] = d[q]);
|
|
789
|
+
for (const [q, je] of Object.entries(l.compute_fields ?? {})) {
|
|
790
|
+
const _e = Qe(je, { ...d, ...u });
|
|
791
|
+
_e !== null && (u[q] = _e);
|
|
794
792
|
}
|
|
795
|
-
const w = { ...d, ...u }, { id:
|
|
796
|
-
await
|
|
793
|
+
const w = { ...d, ...u }, { id: T, ...N } = w;
|
|
794
|
+
await p.request(Gt(`/items/${f}/${d.id}`, N));
|
|
797
795
|
} else
|
|
798
|
-
await
|
|
799
|
-
|
|
800
|
-
[
|
|
801
|
-
...
|
|
796
|
+
await p.request(
|
|
797
|
+
Xt(`/items/${f}`, {
|
|
798
|
+
[g]: _,
|
|
799
|
+
...Le(e, o, r, b)
|
|
802
800
|
})
|
|
803
801
|
);
|
|
804
|
-
|
|
802
|
+
j.invalidateQueries({ queryKey: ["o2m-rows", f, g, _] });
|
|
805
803
|
} catch {
|
|
806
804
|
} finally {
|
|
807
|
-
|
|
805
|
+
ee((d) => {
|
|
808
806
|
const u = new Set(d);
|
|
809
807
|
return u.delete(e), u;
|
|
810
808
|
});
|
|
811
809
|
}
|
|
812
810
|
}
|
|
813
|
-
async function
|
|
811
|
+
async function jr(e, t, r) {
|
|
814
812
|
const s = r.trim() === "" ? null : Number(r);
|
|
815
813
|
if (r.trim() !== "" && Number.isNaN(s)) return;
|
|
816
814
|
const c = (i) => {
|
|
@@ -820,56 +818,56 @@ function yn({
|
|
|
820
818
|
w !== null && (b[d] = w);
|
|
821
819
|
}
|
|
822
820
|
return b;
|
|
823
|
-
}, o =
|
|
821
|
+
}, o = C ? void 0 : Ae.get(e);
|
|
824
822
|
if ((o == null ? void 0 : o.id) == null) {
|
|
825
|
-
const i =
|
|
823
|
+
const i = Ye.get(e);
|
|
826
824
|
if (i === void 0) return;
|
|
827
|
-
|
|
825
|
+
x == null || x.updateRow(f, g, i, c(ve[i]));
|
|
828
826
|
return;
|
|
829
827
|
}
|
|
830
|
-
if (
|
|
831
|
-
const i = c(o), b =
|
|
828
|
+
if (Ee && x) {
|
|
829
|
+
const i = c(o), b = Ne.find((u) => String(u.id) === String(o.id)) ?? {}, d = Object.fromEntries(
|
|
832
830
|
Object.entries(i).filter(
|
|
833
831
|
([u, w]) => u !== "id" && String(w ?? "") !== String(b[u] ?? "")
|
|
834
832
|
)
|
|
835
833
|
);
|
|
836
|
-
|
|
834
|
+
x.cancelPendingEdit(f, g, String(o.id)), Object.keys(d).length > 0 && x.queueEdit(f, g, String(o.id), d);
|
|
837
835
|
return;
|
|
838
836
|
}
|
|
839
|
-
|
|
837
|
+
ee((i) => new Set(i).add(e));
|
|
840
838
|
try {
|
|
841
839
|
const { id: i, ...b } = c(o);
|
|
842
|
-
await
|
|
840
|
+
await p.request(Gt(`/items/${f}/${o.id}`, b)), j.invalidateQueries({ queryKey: ["o2m-rows", f, g, _] });
|
|
843
841
|
} catch {
|
|
844
842
|
} finally {
|
|
845
|
-
|
|
843
|
+
ee((i) => {
|
|
846
844
|
const b = new Set(i);
|
|
847
845
|
return b.delete(e), b;
|
|
848
846
|
});
|
|
849
847
|
}
|
|
850
848
|
}
|
|
851
|
-
async function
|
|
852
|
-
if (e == null || e === "" || !
|
|
853
|
-
const t = String(e), r =
|
|
849
|
+
async function Fr(e) {
|
|
850
|
+
if (e == null || e === "" || !y) return;
|
|
851
|
+
const t = String(e), r = Pe(t);
|
|
854
852
|
let s = r;
|
|
855
|
-
Object.keys(r).length <= 1 && (s = await
|
|
856
|
-
|
|
853
|
+
Object.keys(r).length <= 1 && (s = await p.request(
|
|
854
|
+
A(`/items/${y}`, {
|
|
857
855
|
filter: JSON.stringify({ id: { _eq: e } }),
|
|
858
|
-
fields:
|
|
856
|
+
fields: B,
|
|
859
857
|
limit: 1
|
|
860
858
|
})
|
|
861
859
|
).then((o) => {
|
|
862
860
|
var i;
|
|
863
861
|
return ((i = o.data) == null ? void 0 : i[0]) ?? { id: e };
|
|
864
862
|
}).catch(() => ({ id: e })));
|
|
865
|
-
const c = (
|
|
866
|
-
await
|
|
863
|
+
const c = (be(t) ?? 0) + 1;
|
|
864
|
+
await Ke(t, String(c), s);
|
|
867
865
|
}
|
|
868
|
-
const
|
|
869
|
-
const r =
|
|
870
|
-
if (
|
|
866
|
+
const Tr = le.length, _t = Object.keys(l.copy_fields ?? {}), St = Object.keys(l.compute_fields ?? {}), it = (e, t) => {
|
|
867
|
+
const r = be(e);
|
|
868
|
+
if (h)
|
|
871
869
|
return /* @__PURE__ */ n("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: r && r > 0 ? r : "—" });
|
|
872
|
-
const s =
|
|
870
|
+
const s = qe[e], c = s !== void 0 ? s : r && r > 0 ? String(r) : "", o = ce[e], i = () => X((d) => {
|
|
873
871
|
if (!(e in d)) return d;
|
|
874
872
|
const u = { ...d };
|
|
875
873
|
return delete u[e], u;
|
|
@@ -878,31 +876,31 @@ function yn({
|
|
|
878
876
|
{
|
|
879
877
|
type: "number",
|
|
880
878
|
min: 0,
|
|
881
|
-
step:
|
|
882
|
-
disabled:
|
|
879
|
+
step: er(v) ? 1 : "any",
|
|
880
|
+
disabled: h,
|
|
883
881
|
value: c,
|
|
884
882
|
placeholder: "0",
|
|
885
883
|
"aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
|
|
886
884
|
onFocus: i,
|
|
887
|
-
onChange: (d) =>
|
|
885
|
+
onChange: (d) => pe((u) => ({ ...u, [e]: d.target.value })),
|
|
888
886
|
onBlur: (d) => {
|
|
889
887
|
const u = d.target.value;
|
|
890
|
-
|
|
891
|
-
const
|
|
892
|
-
return delete
|
|
893
|
-
}),
|
|
888
|
+
pe((w) => {
|
|
889
|
+
const T = { ...w };
|
|
890
|
+
return delete T[e], T;
|
|
891
|
+
}), Ke(e, u, t);
|
|
894
892
|
},
|
|
895
893
|
onKeyDown: (d) => {
|
|
896
894
|
d.key === "Enter" && d.currentTarget.blur();
|
|
897
895
|
},
|
|
898
|
-
className:
|
|
896
|
+
className: Q(
|
|
899
897
|
"h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan disabled:opacity-50 dark:border-border dark:bg-background",
|
|
900
898
|
(o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
|
|
901
899
|
)
|
|
902
900
|
}
|
|
903
901
|
);
|
|
904
|
-
return /* @__PURE__ */ m(
|
|
905
|
-
/* @__PURE__ */ n(
|
|
902
|
+
return /* @__PURE__ */ m(Hr, { open: (o == null ? void 0 : o.kind) === "remove", onOpenChange: (d) => !d && i(), children: [
|
|
903
|
+
/* @__PURE__ */ n(Mr, { asChild: !0, children: /* @__PURE__ */ m("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
|
|
906
904
|
b,
|
|
907
905
|
(o == null ? void 0 : o.kind) === "error" && /* @__PURE__ */ m(
|
|
908
906
|
"span",
|
|
@@ -911,7 +909,7 @@ function yn({
|
|
|
911
909
|
className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
|
|
912
910
|
"data-catalog-qty-error": !0,
|
|
913
911
|
children: [
|
|
914
|
-
/* @__PURE__ */ n(
|
|
912
|
+
/* @__PURE__ */ n(qt, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
915
913
|
o.message,
|
|
916
914
|
r && r > 0 ? ` — still ${r}` : ""
|
|
917
915
|
]
|
|
@@ -919,7 +917,7 @@ function yn({
|
|
|
919
917
|
)
|
|
920
918
|
] }) }),
|
|
921
919
|
/* @__PURE__ */ n(
|
|
922
|
-
|
|
920
|
+
Wr,
|
|
923
921
|
{
|
|
924
922
|
align: "end",
|
|
925
923
|
side: "bottom",
|
|
@@ -942,7 +940,7 @@ function yn({
|
|
|
942
940
|
type: "button",
|
|
943
941
|
onClick: () => {
|
|
944
942
|
const d = o.row;
|
|
945
|
-
i(),
|
|
943
|
+
i(), Ke(e, "0", d, { confirmedRemove: !0 });
|
|
946
944
|
},
|
|
947
945
|
className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
|
|
948
946
|
children: "Remove"
|
|
@@ -953,8 +951,8 @@ function yn({
|
|
|
953
951
|
}
|
|
954
952
|
)
|
|
955
953
|
] });
|
|
956
|
-
},
|
|
957
|
-
const s = `${e}:${t}`, c =
|
|
954
|
+
}, Or = (e, t, r) => {
|
|
955
|
+
const s = `${e}:${t}`, c = ae[s], o = () => D((b) => {
|
|
958
956
|
if (!(s in b)) return b;
|
|
959
957
|
const d = { ...b };
|
|
960
958
|
return delete d[s], d;
|
|
@@ -972,21 +970,21 @@ function yn({
|
|
|
972
970
|
onBlur: (b) => {
|
|
973
971
|
const d = b.target.value;
|
|
974
972
|
if (d !== i) {
|
|
975
|
-
const u =
|
|
973
|
+
const u = ke.find((N) => N.field === t), w = tr(d, {
|
|
976
974
|
type: u == null ? void 0 : u.type,
|
|
977
|
-
label: (u == null ? void 0 : u.label) ||
|
|
978
|
-
}),
|
|
979
|
-
if (
|
|
980
|
-
b.target.value = i,
|
|
975
|
+
label: (u == null ? void 0 : u.label) || Z(t)
|
|
976
|
+
}), T = w.ok ? K(t, w.value, r) : w.message;
|
|
977
|
+
if (T) {
|
|
978
|
+
b.target.value = i, D((N) => ({ ...N, [s]: T }));
|
|
981
979
|
return;
|
|
982
980
|
}
|
|
983
981
|
}
|
|
984
|
-
|
|
982
|
+
jr(e, t, d);
|
|
985
983
|
},
|
|
986
984
|
onKeyDown: (b) => {
|
|
987
985
|
b.key === "Enter" && b.currentTarget.blur();
|
|
988
986
|
},
|
|
989
|
-
className:
|
|
987
|
+
className: Q(
|
|
990
988
|
"h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background",
|
|
991
989
|
c && "border-red-400 dark:border-red-600"
|
|
992
990
|
)
|
|
@@ -1000,7 +998,7 @@ function yn({
|
|
|
1000
998
|
className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
|
|
1001
999
|
"data-catalog-cell-error": !0,
|
|
1002
1000
|
children: [
|
|
1003
|
-
/* @__PURE__ */ n(
|
|
1001
|
+
/* @__PURE__ */ n(qt, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1004
1002
|
c,
|
|
1005
1003
|
i !== "" ? ` — still ${i}` : ""
|
|
1006
1004
|
]
|
|
@@ -1008,25 +1006,25 @@ function yn({
|
|
|
1008
1006
|
)
|
|
1009
1007
|
] }, s);
|
|
1010
1008
|
};
|
|
1011
|
-
return !
|
|
1009
|
+
return !y && he ? /* @__PURE__ */ m("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
|
|
1012
1010
|
/* @__PURE__ */ n("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
|
|
1013
1011
|
/* @__PURE__ */ n("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
1014
|
-
] }) :
|
|
1015
|
-
!
|
|
1012
|
+
] }) : y ? /* @__PURE__ */ m("div", { className: "space-y-3", children: [
|
|
1013
|
+
!h && /* @__PURE__ */ m(lt, { children: [
|
|
1016
1014
|
/* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1017
1015
|
/* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1018
|
-
/* @__PURE__ */ n(
|
|
1016
|
+
/* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
1019
1017
|
/* @__PURE__ */ n(
|
|
1020
1018
|
"input",
|
|
1021
1019
|
{
|
|
1022
|
-
value:
|
|
1020
|
+
value: L,
|
|
1023
1021
|
onChange: (e) => ye(e.target.value),
|
|
1024
1022
|
placeholder: "Search catalog…",
|
|
1025
1023
|
className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
|
|
1026
1024
|
}
|
|
1027
1025
|
),
|
|
1028
1026
|
/* @__PURE__ */ m("span", { className: "shrink-0 rounded border border-slate-200 bg-slate-50 px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-muted dark:text-slate-400", children: [
|
|
1029
|
-
|
|
1027
|
+
Tr,
|
|
1030
1028
|
" picked"
|
|
1031
1029
|
] })
|
|
1032
1030
|
] }),
|
|
@@ -1037,85 +1035,78 @@ function yn({
|
|
|
1037
1035
|
/* @__PURE__ */ m(
|
|
1038
1036
|
"div",
|
|
1039
1037
|
{
|
|
1040
|
-
ref:
|
|
1038
|
+
ref: vr,
|
|
1041
1039
|
className: "sticky top-0 z-[5] flex items-center gap-2 border-b border-slate-200 bg-slate-50 px-3 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-400 dark:border-border dark:bg-muted",
|
|
1042
1040
|
children: [
|
|
1043
1041
|
l.favorites && /* @__PURE__ */ n("span", { className: "w-[18px] shrink-0" }),
|
|
1044
1042
|
/* @__PURE__ */ n("span", { className: "w-36 shrink-0", children: "Item" }),
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
{
|
|
1048
|
-
className: e.format ? "w-20 shrink-0 text-right" : "min-w-0 flex-1",
|
|
1049
|
-
children: e.label ?? I(e.field.split(".")[0])
|
|
1050
|
-
},
|
|
1051
|
-
e.field
|
|
1052
|
-
)),
|
|
1053
|
-
yt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? I(e.key) }, e.key)),
|
|
1043
|
+
rt.map((e) => /* @__PURE__ */ n("span", { className: Q("truncate", Ut(e)), children: e.label ?? Z(e.field.split(".")[0]) }, e.field)),
|
|
1044
|
+
kt.map((e) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: e.label ?? Z(e.key) }, e.key)),
|
|
1054
1045
|
/* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
|
|
1055
1046
|
]
|
|
1056
1047
|
}
|
|
1057
1048
|
),
|
|
1058
|
-
|
|
1059
|
-
/* @__PURE__ */ n(
|
|
1049
|
+
L.trim().length > 0 && $e.length === 0 && bt && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-400 dark:border-border/50", children: [
|
|
1050
|
+
/* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1060
1051
|
" Searching the catalog…"
|
|
1061
1052
|
] }),
|
|
1062
|
-
|
|
1053
|
+
L.trim().length > 0 && $e.length === 0 && !bt && /* @__PURE__ */ m("p", { className: "px-3 py-4 text-center text-slate-400", children: [
|
|
1063
1054
|
'No CIFAs match "',
|
|
1064
|
-
|
|
1055
|
+
L.trim(),
|
|
1065
1056
|
'"'
|
|
1066
1057
|
] }),
|
|
1067
|
-
|
|
1058
|
+
L.trim().length > 0 && $e.length > 0 && /* @__PURE__ */ m(Je, { children: [
|
|
1068
1059
|
/* @__PURE__ */ m("div", { className: "flex w-full items-center gap-1.5 border-b border-t border-slate-200 bg-sky-50/70 px-2 py-1.5 dark:border-border dark:bg-sky-900/10", children: [
|
|
1069
|
-
/* @__PURE__ */ n(
|
|
1060
|
+
/* @__PURE__ */ n(ot, { className: "h-3 w-3 shrink-0 text-sky-500" }),
|
|
1070
1061
|
/* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
|
|
1071
|
-
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children:
|
|
1062
|
+
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: $e.length }),
|
|
1072
1063
|
/* @__PURE__ */ n("span", { className: "text-[10px] text-slate-400", children: "across the entire catalog — enter a quantity to add" }),
|
|
1073
|
-
|
|
1064
|
+
bt && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
|
|
1074
1065
|
] }),
|
|
1075
|
-
|
|
1076
|
-
const r = String(e.id), s =
|
|
1066
|
+
$e.map((e, t) => {
|
|
1067
|
+
const r = String(e.id), s = be(r);
|
|
1077
1068
|
return /* @__PURE__ */ m(
|
|
1078
1069
|
"div",
|
|
1079
1070
|
{
|
|
1080
|
-
className:
|
|
1071
|
+
className: Q(
|
|
1081
1072
|
"flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1082
1073
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1083
1074
|
(s ?? 0) > 0 && "bg-nvr-cyan/5"
|
|
1084
1075
|
),
|
|
1085
1076
|
children: [
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1077
|
+
ut(r),
|
|
1078
|
+
st(r, Te(J, e), vt),
|
|
1079
|
+
Nt(r, e),
|
|
1080
|
+
de.has(r) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
|
|
1081
|
+
it(r, e)
|
|
1091
1082
|
]
|
|
1092
1083
|
},
|
|
1093
1084
|
r
|
|
1094
1085
|
);
|
|
1095
1086
|
})
|
|
1096
1087
|
] }),
|
|
1097
|
-
k.length > 0 && !
|
|
1088
|
+
k.length > 0 && !L.trim() && /* @__PURE__ */ m("p", { className: "px-3 py-6 text-center text-slate-400", children: [
|
|
1098
1089
|
"Search the full catalog above, or select",
|
|
1099
1090
|
" ",
|
|
1100
1091
|
k.map((e) => {
|
|
1101
1092
|
var t;
|
|
1102
|
-
return ((t =
|
|
1093
|
+
return ((t = z == null ? void 0 : z.fieldLabels) == null ? void 0 : t[e]) ?? Z(e);
|
|
1103
1094
|
}).join(", "),
|
|
1104
1095
|
" ",
|
|
1105
1096
|
"to browse by category"
|
|
1106
1097
|
] }),
|
|
1107
|
-
k.length === 0 && (
|
|
1108
|
-
/* @__PURE__ */ n(
|
|
1098
|
+
k.length === 0 && (M || Ue) && /* @__PURE__ */ m("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-400", children: [
|
|
1099
|
+
/* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin" }),
|
|
1109
1100
|
" Loading catalog…"
|
|
1110
1101
|
] }),
|
|
1111
|
-
k.length === 0 && !
|
|
1102
|
+
k.length === 0 && !M && !Ue && at.length === 0 && /* @__PURE__ */ n("p", { className: "px-3 py-6 text-center text-slate-400", children: "No catalog items" }),
|
|
1112
1103
|
l.favorites && /* @__PURE__ */ m(Je, { children: [
|
|
1113
1104
|
/* @__PURE__ */ m("div", { className: "flex w-full items-center gap-1.5 border-b border-slate-200 bg-amber-50/70 px-2 py-1 dark:border-border dark:bg-amber-900/10", children: [
|
|
1114
1105
|
/* @__PURE__ */ m(
|
|
1115
1106
|
"button",
|
|
1116
1107
|
{
|
|
1117
1108
|
type: "button",
|
|
1118
|
-
onClick: () =>
|
|
1109
|
+
onClick: () => G((e) => {
|
|
1119
1110
|
const t = new Set(e);
|
|
1120
1111
|
return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
|
|
1121
1112
|
}),
|
|
@@ -1124,7 +1115,7 @@ function yn({
|
|
|
1124
1115
|
/* @__PURE__ */ n(
|
|
1125
1116
|
jt,
|
|
1126
1117
|
{
|
|
1127
|
-
className:
|
|
1118
|
+
className: Q(
|
|
1128
1119
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1129
1120
|
!oe.has("__favorites__") && "rotate-90"
|
|
1130
1121
|
)
|
|
@@ -1132,55 +1123,55 @@ function yn({
|
|
|
1132
1123
|
),
|
|
1133
1124
|
/* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
1134
1125
|
/* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
|
|
1135
|
-
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children:
|
|
1126
|
+
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: Ce.length })
|
|
1136
1127
|
]
|
|
1137
1128
|
}
|
|
1138
1129
|
),
|
|
1139
1130
|
/* @__PURE__ */ n(
|
|
1140
1131
|
"button",
|
|
1141
1132
|
{
|
|
1142
|
-
ref:
|
|
1133
|
+
ref: Ct,
|
|
1143
1134
|
type: "button",
|
|
1144
|
-
onClick: () =>
|
|
1135
|
+
onClick: () => At(!0),
|
|
1145
1136
|
className: "shrink-0 rounded border border-amber-200 bg-white px-2 py-0.5 text-[10px] font-semibold text-amber-700 transition-colors hover:border-amber-300 hover:bg-amber-50 dark:border-amber-400/30 dark:bg-transparent dark:text-amber-300 dark:hover:bg-amber-400/10",
|
|
1146
1137
|
children: "Manage"
|
|
1147
1138
|
}
|
|
1148
1139
|
)
|
|
1149
1140
|
] }),
|
|
1150
|
-
!oe.has("__favorites__") &&
|
|
1151
|
-
!oe.has("__favorites__") &&
|
|
1152
|
-
const r = String(e.id), s =
|
|
1141
|
+
!oe.has("__favorites__") && Ce.length === 0 && /* @__PURE__ */ n("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: "No favorites yet — Manage lets you search the full catalog and star items." }),
|
|
1142
|
+
!oe.has("__favorites__") && Ce.map((e, t) => {
|
|
1143
|
+
const r = String(e.id), s = be(r), c = ht(r);
|
|
1153
1144
|
return /* @__PURE__ */ m(
|
|
1154
1145
|
"div",
|
|
1155
1146
|
{
|
|
1156
|
-
className:
|
|
1147
|
+
className: Q(
|
|
1157
1148
|
"flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1158
1149
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1159
1150
|
(s ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1160
1151
|
c && "bg-amber-50 dark:bg-amber-900/15"
|
|
1161
1152
|
),
|
|
1162
1153
|
children: [
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1154
|
+
ut(r),
|
|
1155
|
+
st(r, Te(J, e), vt),
|
|
1156
|
+
Nt(r, e),
|
|
1166
1157
|
c && /* @__PURE__ */ n(
|
|
1167
1158
|
ze,
|
|
1168
1159
|
{
|
|
1169
1160
|
className: "h-3.5 w-3.5 shrink-0 text-amber-500",
|
|
1170
|
-
"aria-label": `${
|
|
1161
|
+
"aria-label": `${xt} ${c.available} — ${c.qty} requested`
|
|
1171
1162
|
}
|
|
1172
1163
|
),
|
|
1173
|
-
|
|
1174
|
-
|
|
1164
|
+
de.has(r) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
|
|
1165
|
+
it(r, e)
|
|
1175
1166
|
]
|
|
1176
1167
|
},
|
|
1177
1168
|
r
|
|
1178
1169
|
);
|
|
1179
1170
|
})
|
|
1180
1171
|
] }),
|
|
1181
|
-
k.length === 0 &&
|
|
1172
|
+
k.length === 0 && at.map((e) => {
|
|
1182
1173
|
const t = oe.has(e.name), r = e.items.reduce(
|
|
1183
|
-
(s, c) => s + ((
|
|
1174
|
+
(s, c) => s + ((be(c.id) ?? 0) > 0 ? 1 : 0),
|
|
1184
1175
|
0
|
|
1185
1176
|
);
|
|
1186
1177
|
return /* @__PURE__ */ m(Je, { children: [
|
|
@@ -1188,7 +1179,7 @@ function yn({
|
|
|
1188
1179
|
"button",
|
|
1189
1180
|
{
|
|
1190
1181
|
type: "button",
|
|
1191
|
-
onClick: () =>
|
|
1182
|
+
onClick: () => G((s) => {
|
|
1192
1183
|
const c = new Set(s);
|
|
1193
1184
|
return c.has(e.name) ? c.delete(e.name) : c.add(e.name), c;
|
|
1194
1185
|
}),
|
|
@@ -1197,7 +1188,7 @@ function yn({
|
|
|
1197
1188
|
/* @__PURE__ */ n(
|
|
1198
1189
|
jt,
|
|
1199
1190
|
{
|
|
1200
|
-
className:
|
|
1191
|
+
className: Q(
|
|
1201
1192
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1202
1193
|
!t && "rotate-90"
|
|
1203
1194
|
)
|
|
@@ -1213,29 +1204,29 @@ function yn({
|
|
|
1213
1204
|
}
|
|
1214
1205
|
),
|
|
1215
1206
|
!t && e.items.map((s, c) => {
|
|
1216
|
-
const o =
|
|
1207
|
+
const o = be(s.id), i = ht(s.id);
|
|
1217
1208
|
return /* @__PURE__ */ m(
|
|
1218
1209
|
"div",
|
|
1219
1210
|
{
|
|
1220
|
-
className:
|
|
1211
|
+
className: Q(
|
|
1221
1212
|
"flex items-center gap-2 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1222
1213
|
c % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1223
1214
|
(o ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1224
1215
|
i && "bg-amber-50 dark:bg-amber-900/15"
|
|
1225
1216
|
),
|
|
1226
1217
|
children: [
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1218
|
+
ut(s.id),
|
|
1219
|
+
st(s.id, s.label, vt),
|
|
1220
|
+
Nt(s.id, s.row),
|
|
1230
1221
|
i && /* @__PURE__ */ n(
|
|
1231
1222
|
ze,
|
|
1232
1223
|
{
|
|
1233
1224
|
className: "h-3.5 w-3.5 shrink-0 text-amber-500",
|
|
1234
|
-
"aria-label": `${
|
|
1225
|
+
"aria-label": `${xt} ${i.available} — ${i.qty} requested`
|
|
1235
1226
|
}
|
|
1236
1227
|
),
|
|
1237
|
-
|
|
1238
|
-
|
|
1228
|
+
de.has(s.id) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" }),
|
|
1229
|
+
it(s.id, s.row)
|
|
1239
1230
|
]
|
|
1240
1231
|
},
|
|
1241
1232
|
s.id
|
|
@@ -1244,16 +1235,18 @@ function yn({
|
|
|
1244
1235
|
] }, e.name);
|
|
1245
1236
|
})
|
|
1246
1237
|
] }),
|
|
1247
|
-
(l.builders ?? []).filter((e) =>
|
|
1248
|
-
|
|
1238
|
+
(l.builders ?? []).filter((e) => rr(e.show_when, H)).map((e) => /* @__PURE__ */ n(
|
|
1239
|
+
tn,
|
|
1249
1240
|
{
|
|
1250
1241
|
builder: e,
|
|
1251
1242
|
defaultItemField: l.item_field,
|
|
1252
|
-
catalogCol:
|
|
1253
|
-
catalogFields:
|
|
1254
|
-
tmpl:
|
|
1255
|
-
|
|
1256
|
-
|
|
1243
|
+
catalogCol: y,
|
|
1244
|
+
catalogFields: B,
|
|
1245
|
+
tmpl: J,
|
|
1246
|
+
currentQty: be,
|
|
1247
|
+
addQty: (t, r, s) => Ke(t, String(r), s),
|
|
1248
|
+
qtyStep: er(v) ? 1 : "any",
|
|
1249
|
+
readOnly: h
|
|
1257
1250
|
},
|
|
1258
1251
|
e.label
|
|
1259
1252
|
))
|
|
@@ -1261,11 +1254,11 @@ function yn({
|
|
|
1261
1254
|
/* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1262
1255
|
/* @__PURE__ */ m("div", { className: "flex items-center justify-between gap-2 border-b border-slate-200 bg-slate-50 px-3 py-2 dark:border-border dark:bg-muted", children: [
|
|
1263
1256
|
/* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
|
|
1264
|
-
!
|
|
1265
|
-
l.upload_template && !
|
|
1266
|
-
|
|
1257
|
+
!h && /* @__PURE__ */ m("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
|
|
1258
|
+
l.upload_template && !C && I && $ && /* @__PURE__ */ n(
|
|
1259
|
+
Dr,
|
|
1267
1260
|
{
|
|
1268
|
-
collection:
|
|
1261
|
+
collection: $,
|
|
1269
1262
|
templateFilter: (e) => {
|
|
1270
1263
|
var t;
|
|
1271
1264
|
return e.name === l.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
|
|
@@ -1274,58 +1267,58 @@ function yn({
|
|
|
1274
1267
|
var t;
|
|
1275
1268
|
return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
|
|
1276
1269
|
},
|
|
1277
|
-
onParsed: (e, t) =>
|
|
1270
|
+
onParsed: (e, t) => I(e, t),
|
|
1278
1271
|
compact: !0
|
|
1279
1272
|
}
|
|
1280
1273
|
),
|
|
1281
1274
|
/* @__PURE__ */ n("div", { className: "w-64", children: /* @__PURE__ */ n(
|
|
1282
|
-
|
|
1275
|
+
Xr,
|
|
1283
1276
|
{
|
|
1284
|
-
collection:
|
|
1277
|
+
collection: y,
|
|
1285
1278
|
value: null,
|
|
1286
|
-
onChange: (e) => void
|
|
1279
|
+
onChange: (e) => void Fr(e),
|
|
1287
1280
|
placeholder: "+ Add any item…"
|
|
1288
1281
|
}
|
|
1289
1282
|
) })
|
|
1290
1283
|
] })
|
|
1291
1284
|
] }),
|
|
1292
1285
|
le.length === 0 ? /* @__PURE__ */ n("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
|
|
1293
|
-
const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, b) => b === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" :
|
|
1286
|
+
const e = zt.filter((i) => !i.format), t = e[0], r = e.slice(1), s = zt.filter((i) => !!i.format), c = (i, b) => b === "presence" ? i == null || i === "" || Number(i) === 0 ? "No" : "Yes" : i === !0 || i === "true" ? "✓" : i === !1 || i === "false" || i == null || i === "" ? "—" : fe(i, b), o = (i) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500", children: i });
|
|
1294
1287
|
return /* @__PURE__ */ m("div", { children: [
|
|
1295
1288
|
/* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
|
|
1296
1289
|
/* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-medium text-slate-500", children: "Item" }),
|
|
1297
|
-
|
|
1298
|
-
o(
|
|
1299
|
-
|
|
1300
|
-
!
|
|
1290
|
+
_t.map((i) => /* @__PURE__ */ n(Je, { children: o(Z(i)) }, i)),
|
|
1291
|
+
o(Z(O)),
|
|
1292
|
+
St.map((i) => /* @__PURE__ */ n(Je, { children: o(Z(i)) }, i)),
|
|
1293
|
+
!h && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
|
|
1301
1294
|
] }),
|
|
1302
1295
|
le.map((i, b) => {
|
|
1303
|
-
const d = i.row.id != null ? String(i.row.id) : null, u = d != null &&
|
|
1296
|
+
const d = i.row.id != null ? String(i.row.id) : null, u = d != null && Ie.has(d), w = u ? null : ht(i.key), T = u ? null : xr(i.key);
|
|
1304
1297
|
return /* @__PURE__ */ m(
|
|
1305
1298
|
"div",
|
|
1306
1299
|
{
|
|
1307
|
-
className:
|
|
1300
|
+
className: Q(
|
|
1308
1301
|
"border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
|
|
1309
1302
|
b % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1310
1303
|
w && "bg-amber-50 dark:bg-amber-900/15",
|
|
1311
|
-
|
|
1304
|
+
T && "bg-red-50/70 dark:bg-red-900/15",
|
|
1312
1305
|
u && "opacity-60"
|
|
1313
1306
|
),
|
|
1314
1307
|
children: [
|
|
1315
1308
|
/* @__PURE__ */ m(
|
|
1316
1309
|
"div",
|
|
1317
1310
|
{
|
|
1318
|
-
className:
|
|
1311
|
+
className: Q(
|
|
1319
1312
|
"flex items-center gap-2",
|
|
1320
1313
|
u && "line-through decoration-slate-400"
|
|
1321
1314
|
),
|
|
1322
1315
|
children: [
|
|
1323
|
-
|
|
1316
|
+
st(
|
|
1324
1317
|
i.key,
|
|
1325
|
-
|
|
1318
|
+
Ht(i.key),
|
|
1326
1319
|
"shrink-0 font-semibold text-slate-800 dark:text-slate-100"
|
|
1327
1320
|
),
|
|
1328
|
-
|
|
1321
|
+
Ee && !u && (d == null || Me.has(d)) && /* @__PURE__ */ n(
|
|
1329
1322
|
"span",
|
|
1330
1323
|
{
|
|
1331
1324
|
"data-catalog-staged": d == null ? "new" : "edited",
|
|
@@ -1334,55 +1327,54 @@ function yn({
|
|
|
1334
1327
|
children: d == null ? "New" : "Edited"
|
|
1335
1328
|
}
|
|
1336
1329
|
),
|
|
1337
|
-
|
|
1330
|
+
T && /* @__PURE__ */ n(
|
|
1338
1331
|
"span",
|
|
1339
1332
|
{
|
|
1340
1333
|
className: "shrink-0",
|
|
1341
1334
|
"data-tip": `This line was in the failed submission
|
|
1342
|
-
${
|
|
1335
|
+
${T}`,
|
|
1343
1336
|
"data-submission-error": !0,
|
|
1344
|
-
children: /* @__PURE__ */ n(
|
|
1337
|
+
children: /* @__PURE__ */ n(qt, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
|
|
1345
1338
|
}
|
|
1346
1339
|
),
|
|
1347
1340
|
t && /* @__PURE__ */ n(
|
|
1348
|
-
|
|
1341
|
+
nr,
|
|
1349
1342
|
{
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
children: ue(Ae(qe(i.key), t.field), void 0)
|
|
1343
|
+
text: fe(nt(Pe(i.key), t.field), void 0),
|
|
1344
|
+
className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
|
|
1353
1345
|
}
|
|
1354
1346
|
),
|
|
1355
1347
|
!t && /* @__PURE__ */ n("span", { className: "flex-1" }),
|
|
1356
1348
|
r.map((N) => {
|
|
1357
|
-
const
|
|
1358
|
-
return
|
|
1349
|
+
const q = nt(Pe(i.key), N.field);
|
|
1350
|
+
return q == null || q === "" ? null : /* @__PURE__ */ n(
|
|
1359
1351
|
"span",
|
|
1360
1352
|
{
|
|
1361
1353
|
className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10.5px] font-medium text-slate-600 dark:bg-muted dark:text-slate-300",
|
|
1362
|
-
children: String(
|
|
1354
|
+
children: String(q)
|
|
1363
1355
|
},
|
|
1364
1356
|
N.field
|
|
1365
1357
|
);
|
|
1366
1358
|
}),
|
|
1367
|
-
|
|
1359
|
+
_t.map(
|
|
1368
1360
|
(N) => {
|
|
1369
|
-
var
|
|
1370
|
-
return
|
|
1361
|
+
var q;
|
|
1362
|
+
return se.includes(N) && !h ? Or(i.key, N, i.row) : /* @__PURE__ */ n(
|
|
1371
1363
|
"span",
|
|
1372
1364
|
{
|
|
1373
1365
|
className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
1374
|
-
children:
|
|
1366
|
+
children: fe(i.row[N], (q = l.field_formats) == null ? void 0 : q[N])
|
|
1375
1367
|
},
|
|
1376
1368
|
N
|
|
1377
1369
|
);
|
|
1378
1370
|
}
|
|
1379
1371
|
),
|
|
1380
1372
|
/* @__PURE__ */ m("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
|
|
1381
|
-
|
|
1382
|
-
|
|
1373
|
+
de.has(i.key) && /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
1374
|
+
it(i.key, Pe(i.key))
|
|
1383
1375
|
] }),
|
|
1384
|
-
|
|
1385
|
-
var
|
|
1376
|
+
St.map((N) => {
|
|
1377
|
+
var _e, Zt;
|
|
1386
1378
|
if (u)
|
|
1387
1379
|
return /* @__PURE__ */ n(
|
|
1388
1380
|
"span",
|
|
@@ -1393,57 +1385,57 @@ ${j}`,
|
|
|
1393
1385
|
},
|
|
1394
1386
|
N
|
|
1395
1387
|
);
|
|
1396
|
-
const
|
|
1388
|
+
const q = i.row[N], je = q != null && q !== "" ? q : Qe(((_e = l.compute_fields) == null ? void 0 : _e[N]) ?? "", i.row);
|
|
1397
1389
|
return /* @__PURE__ */ n(
|
|
1398
1390
|
"span",
|
|
1399
1391
|
{
|
|
1400
1392
|
className: "w-20 shrink-0 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
1401
|
-
children:
|
|
1393
|
+
children: fe(je, (Zt = l.field_formats) == null ? void 0 : Zt[N])
|
|
1402
1394
|
},
|
|
1403
1395
|
N
|
|
1404
1396
|
);
|
|
1405
1397
|
}),
|
|
1406
|
-
!
|
|
1398
|
+
!h && u && /* @__PURE__ */ n(
|
|
1407
1399
|
"button",
|
|
1408
1400
|
{
|
|
1409
1401
|
type: "button",
|
|
1410
|
-
onClick: () =>
|
|
1402
|
+
onClick: () => x == null ? void 0 : x.cancelPendingDelete(f, g, d),
|
|
1411
1403
|
className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
|
|
1412
1404
|
children: "Undo"
|
|
1413
1405
|
}
|
|
1414
1406
|
),
|
|
1415
|
-
!
|
|
1407
|
+
!h && !u && /* @__PURE__ */ n(
|
|
1416
1408
|
"button",
|
|
1417
1409
|
{
|
|
1418
1410
|
type: "button",
|
|
1419
1411
|
title: "Remove (applies on Save)",
|
|
1420
1412
|
onClick: () => {
|
|
1421
|
-
if (!
|
|
1422
|
-
|
|
1413
|
+
if (!C && x && d != null) {
|
|
1414
|
+
x.queueDelete(f, g, d);
|
|
1423
1415
|
return;
|
|
1424
1416
|
}
|
|
1425
|
-
|
|
1417
|
+
Ke(i.key, "0", {}, { confirmedRemove: !0 });
|
|
1426
1418
|
},
|
|
1427
1419
|
className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
|
|
1428
|
-
children: /* @__PURE__ */ n(
|
|
1420
|
+
children: /* @__PURE__ */ n(dt, { className: "mx-auto h-3.5 w-3.5" })
|
|
1429
1421
|
}
|
|
1430
1422
|
)
|
|
1431
1423
|
]
|
|
1432
1424
|
}
|
|
1433
1425
|
),
|
|
1434
|
-
(s.length > 0 || Bt.length > 0 ||
|
|
1426
|
+
(s.length > 0 || Bt.length > 0 || tt.length > 0) && /* @__PURE__ */ m("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
|
|
1435
1427
|
s.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
|
|
1436
|
-
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ??
|
|
1428
|
+
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.field.split(".")[0]) }),
|
|
1437
1429
|
" ",
|
|
1438
|
-
/* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(
|
|
1430
|
+
/* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(nt(Pe(i.key), N.field), N.format) })
|
|
1439
1431
|
] }, N.field)),
|
|
1440
1432
|
Bt.map((N) => /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
|
|
1441
|
-
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ??
|
|
1433
|
+
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.key) }),
|
|
1442
1434
|
" ",
|
|
1443
|
-
/* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(
|
|
1435
|
+
/* @__PURE__ */ n("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: c(pt(N.key, i.key), N.format) })
|
|
1444
1436
|
] }, N.key)),
|
|
1445
|
-
|
|
1446
|
-
|
|
1437
|
+
Nr(i.row),
|
|
1438
|
+
fr(i.row).map((N) => /* @__PURE__ */ m(
|
|
1447
1439
|
"span",
|
|
1448
1440
|
{
|
|
1449
1441
|
className: "inline-flex items-center gap-1 whitespace-nowrap rounded bg-amber-50 px-1.5 py-px text-[10.5px] font-medium text-amber-700 dark:bg-amber-500/10 dark:text-amber-300",
|
|
@@ -1455,23 +1447,23 @@ ${j}`,
|
|
|
1455
1447
|
},
|
|
1456
1448
|
N
|
|
1457
1449
|
)),
|
|
1458
|
-
|
|
1459
|
-
const
|
|
1450
|
+
tt.map((N) => {
|
|
1451
|
+
const q = kr(N, i);
|
|
1460
1452
|
return /* @__PURE__ */ m("span", { className: "whitespace-nowrap", children: [
|
|
1461
|
-
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ??
|
|
1453
|
+
/* @__PURE__ */ n("span", { className: "text-slate-500 dark:text-muted-foreground", children: N.label ?? Z(N.field) }),
|
|
1462
1454
|
" ",
|
|
1463
|
-
/* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: c(
|
|
1455
|
+
/* @__PURE__ */ n("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: c(q, N.format) })
|
|
1464
1456
|
] }, N.field);
|
|
1465
1457
|
})
|
|
1466
1458
|
] }),
|
|
1467
1459
|
w && /* @__PURE__ */ m("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
|
|
1468
1460
|
/* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
|
|
1469
|
-
|
|
1461
|
+
xt,
|
|
1470
1462
|
" is ",
|
|
1471
|
-
|
|
1463
|
+
fe(w.available, "number"),
|
|
1472
1464
|
" —",
|
|
1473
1465
|
" ",
|
|
1474
|
-
|
|
1466
|
+
fe(w.qty, "number"),
|
|
1475
1467
|
" requested"
|
|
1476
1468
|
] }),
|
|
1477
1469
|
u && /* @__PURE__ */ n("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
|
|
@@ -1482,48 +1474,48 @@ ${j}`,
|
|
|
1482
1474
|
}),
|
|
1483
1475
|
(() => {
|
|
1484
1476
|
const i = le.filter((w) => {
|
|
1485
|
-
const
|
|
1486
|
-
return !(
|
|
1487
|
-
}), b = (w) => i.reduce((
|
|
1488
|
-
const
|
|
1489
|
-
return
|
|
1477
|
+
const T = w.row.id != null ? String(w.row.id) : null;
|
|
1478
|
+
return !(T != null && Ie.has(T));
|
|
1479
|
+
}), b = (w) => i.reduce((T, N) => {
|
|
1480
|
+
const q = Number(N.row[w]);
|
|
1481
|
+
return T + (Number.isFinite(q) ? q : 0);
|
|
1490
1482
|
}, 0), d = (w) => {
|
|
1491
|
-
var
|
|
1492
|
-
return ((
|
|
1483
|
+
var T;
|
|
1484
|
+
return ((T = l.field_formats) == null ? void 0 : T[w]) ?? "number";
|
|
1493
1485
|
}, u = (w) => /* @__PURE__ */ n(
|
|
1494
1486
|
"span",
|
|
1495
1487
|
{
|
|
1496
1488
|
className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100",
|
|
1497
|
-
children:
|
|
1489
|
+
children: fe(b(w), d(w))
|
|
1498
1490
|
},
|
|
1499
1491
|
w
|
|
1500
1492
|
);
|
|
1501
1493
|
return /* @__PURE__ */ m("div", { className: "flex items-center gap-2 border-t border-slate-200 bg-slate-50 px-3 py-1.5 dark:border-border dark:bg-muted/40", children: [
|
|
1502
1494
|
/* @__PURE__ */ n("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500", children: "Total" }),
|
|
1503
|
-
|
|
1504
|
-
/* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children:
|
|
1505
|
-
|
|
1506
|
-
!
|
|
1495
|
+
_t.map((w) => /* @__PURE__ */ n("span", { className: "w-20 shrink-0" }, w)),
|
|
1496
|
+
/* @__PURE__ */ n("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: fe(b(O), "number") }),
|
|
1497
|
+
St.map(u),
|
|
1498
|
+
!h && /* @__PURE__ */ n("span", { className: "w-6 shrink-0" })
|
|
1507
1499
|
] });
|
|
1508
1500
|
})()
|
|
1509
1501
|
] });
|
|
1510
1502
|
})()
|
|
1511
1503
|
] }),
|
|
1512
|
-
|
|
1513
|
-
|
|
1504
|
+
dr && y && /* @__PURE__ */ n(
|
|
1505
|
+
nn,
|
|
1514
1506
|
{
|
|
1515
|
-
catalogCol:
|
|
1516
|
-
tmpl:
|
|
1507
|
+
catalogCol: y,
|
|
1508
|
+
tmpl: J,
|
|
1517
1509
|
sectionBy: l.section_by,
|
|
1518
|
-
sectionM2M:
|
|
1519
|
-
pinnedSet:
|
|
1520
|
-
pinnedIds:
|
|
1521
|
-
savingIds:
|
|
1510
|
+
sectionM2M: R,
|
|
1511
|
+
pinnedSet: mt,
|
|
1512
|
+
pinnedIds: ge,
|
|
1513
|
+
savingIds: Ge,
|
|
1522
1514
|
relatedCols: (l.favorites_manager_columns ?? []).map((e) => (l.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
|
|
1523
|
-
parentDraft:
|
|
1515
|
+
parentDraft: H,
|
|
1524
1516
|
onToggle: (e) => void Et(e),
|
|
1525
|
-
onClose: () =>
|
|
1526
|
-
anchor:
|
|
1517
|
+
onClose: () => At(!1),
|
|
1518
|
+
anchor: Ct.current
|
|
1527
1519
|
}
|
|
1528
1520
|
)
|
|
1529
1521
|
] }) : /* @__PURE__ */ m("p", { className: "py-1 text-[12px] text-slate-400", children: [
|
|
@@ -1534,87 +1526,99 @@ ${j}`,
|
|
|
1534
1526
|
f
|
|
1535
1527
|
] });
|
|
1536
1528
|
}
|
|
1537
|
-
function
|
|
1529
|
+
function tn({
|
|
1538
1530
|
builder: f,
|
|
1539
|
-
defaultItemField:
|
|
1531
|
+
defaultItemField: g,
|
|
1540
1532
|
catalogCol: _,
|
|
1541
|
-
catalogFields:
|
|
1533
|
+
catalogFields: $,
|
|
1542
1534
|
tmpl: l,
|
|
1543
|
-
|
|
1544
|
-
|
|
1535
|
+
currentQty: h,
|
|
1536
|
+
addQty: p,
|
|
1537
|
+
qtyStep: j,
|
|
1538
|
+
readOnly: x
|
|
1545
1539
|
}) {
|
|
1546
|
-
const
|
|
1540
|
+
const z = Ft(), I = f.item_field ?? g, [se, C] = W(!1), [O, oe] = W({}), [G, Se] = W("1"), [L, ye] = W(!1), qe = E(
|
|
1547
1541
|
() => [
|
|
1548
1542
|
"id",
|
|
1549
|
-
|
|
1543
|
+
I,
|
|
1550
1544
|
...f.attributes.flatMap((v) => [`${v.field}.id`, `${v.field}.${v.label_field}`])
|
|
1551
1545
|
].join(","),
|
|
1552
|
-
[
|
|
1553
|
-
), { data:
|
|
1546
|
+
[I, f.attributes]
|
|
1547
|
+
), { data: pe = [], isLoading: de } = V({
|
|
1554
1548
|
queryKey: [
|
|
1555
1549
|
"catalog-builder",
|
|
1556
1550
|
f.collection,
|
|
1557
|
-
|
|
1551
|
+
qe,
|
|
1558
1552
|
JSON.stringify(f.filter ?? null)
|
|
1559
1553
|
],
|
|
1560
|
-
queryFn: () =>
|
|
1561
|
-
|
|
1554
|
+
queryFn: () => z.request(
|
|
1555
|
+
A(`/items/${f.collection}`, {
|
|
1562
1556
|
limit: 2e3,
|
|
1563
|
-
fields:
|
|
1557
|
+
fields: qe,
|
|
1564
1558
|
...f.filter ? { filter: JSON.stringify(f.filter) } : {}
|
|
1565
1559
|
})
|
|
1566
1560
|
).then((v) => v.data ?? []),
|
|
1567
|
-
enabled:
|
|
1561
|
+
enabled: se,
|
|
1568
1562
|
staleTime: 6e4
|
|
1569
|
-
}),
|
|
1570
|
-
var
|
|
1571
|
-
const F = v[
|
|
1563
|
+
}), ee = (v, K) => {
|
|
1564
|
+
var J;
|
|
1565
|
+
const F = v[K];
|
|
1572
1566
|
if (F == null) return null;
|
|
1573
1567
|
if (typeof F == "object") {
|
|
1574
|
-
const
|
|
1575
|
-
return { id: String(
|
|
1568
|
+
const S = F, P = ((J = f.attributes.find((me) => me.field === K)) == null ? void 0 : J.label_field) ?? "id";
|
|
1569
|
+
return { id: String(S.id ?? ""), label: String(S[P] ?? S.id ?? "") };
|
|
1576
1570
|
}
|
|
1577
1571
|
return { id: String(F), label: String(F) };
|
|
1578
|
-
},
|
|
1579
|
-
(
|
|
1580
|
-
var
|
|
1581
|
-
const
|
|
1582
|
-
return
|
|
1572
|
+
}, ce = (v) => pe.filter(
|
|
1573
|
+
(K) => f.attributes.slice(0, v).every((F) => {
|
|
1574
|
+
var S;
|
|
1575
|
+
const J = O[F.field];
|
|
1576
|
+
return J ? ((S = ee(K, F.field)) == null ? void 0 : S.id) === J : !0;
|
|
1583
1577
|
})
|
|
1584
|
-
),
|
|
1585
|
-
(v) => f.attributes.every((
|
|
1578
|
+
), X = f.attributes.every((v) => O[v.field]), ae = X ? pe.find(
|
|
1579
|
+
(v) => f.attributes.every((K) => {
|
|
1586
1580
|
var F;
|
|
1587
|
-
return ((F =
|
|
1581
|
+
return ((F = ee(v, K.field)) == null ? void 0 : F.id) === O[K.field];
|
|
1588
1582
|
})
|
|
1589
|
-
) : void 0,
|
|
1590
|
-
queryKey: ["catalog-builder-item", _,
|
|
1591
|
-
queryFn: () =>
|
|
1592
|
-
|
|
1593
|
-
filter: JSON.stringify({ id: { _eq:
|
|
1594
|
-
fields:
|
|
1583
|
+
) : void 0, D = (ae == null ? void 0 : ae[I]) != null ? String(ae[I]) : null, { data: te } = V({
|
|
1584
|
+
queryKey: ["catalog-builder-item", _, $, D],
|
|
1585
|
+
queryFn: () => z.request(
|
|
1586
|
+
A(`/items/${_}`, {
|
|
1587
|
+
filter: JSON.stringify({ id: { _eq: D } }),
|
|
1588
|
+
fields: $,
|
|
1595
1589
|
limit: 1
|
|
1596
1590
|
})
|
|
1597
1591
|
).then((v) => {
|
|
1598
|
-
var
|
|
1599
|
-
return ((
|
|
1592
|
+
var K;
|
|
1593
|
+
return ((K = v.data) == null ? void 0 : K[0]) ?? null;
|
|
1600
1594
|
}),
|
|
1601
|
-
enabled: !!
|
|
1595
|
+
enabled: !!D,
|
|
1602
1596
|
staleTime: 6e4
|
|
1603
|
-
});
|
|
1597
|
+
}), he = Number(G), y = !!D && !!te && !L && G.trim() !== "" && Number.isFinite(he) && he > 0 && (j === "any" || Number.isInteger(he));
|
|
1598
|
+
async function ke() {
|
|
1599
|
+
if (!(!y || !D || !te)) {
|
|
1600
|
+
ye(!0);
|
|
1601
|
+
try {
|
|
1602
|
+
await p(D, (h(D) ?? 0) + he, te), oe({}), Se("1");
|
|
1603
|
+
} finally {
|
|
1604
|
+
ye(!1);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
}
|
|
1604
1608
|
return /* @__PURE__ */ m("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1605
1609
|
/* @__PURE__ */ m(
|
|
1606
1610
|
"button",
|
|
1607
1611
|
{
|
|
1608
1612
|
type: "button",
|
|
1609
|
-
onClick: () =>
|
|
1613
|
+
onClick: () => C((v) => !v),
|
|
1610
1614
|
className: "flex w-full items-center gap-1.5 rounded-t-lg bg-slate-100/80 px-2 py-1.5 text-left dark:bg-muted",
|
|
1611
1615
|
children: [
|
|
1612
1616
|
/* @__PURE__ */ n(
|
|
1613
1617
|
jt,
|
|
1614
1618
|
{
|
|
1615
|
-
className:
|
|
1619
|
+
className: Q(
|
|
1616
1620
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1617
|
-
|
|
1621
|
+
se && "rotate-90"
|
|
1618
1622
|
)
|
|
1619
1623
|
}
|
|
1620
1624
|
),
|
|
@@ -1622,252 +1626,288 @@ function Ir({
|
|
|
1622
1626
|
]
|
|
1623
1627
|
}
|
|
1624
1628
|
),
|
|
1625
|
-
|
|
1626
|
-
/* @__PURE__ */ n(
|
|
1629
|
+
se && /* @__PURE__ */ n("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: de ? /* @__PURE__ */ m("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
|
|
1630
|
+
/* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin" }),
|
|
1627
1631
|
" Loading options…"
|
|
1628
1632
|
] }) : /* @__PURE__ */ m("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
1629
|
-
f.attributes.map((v,
|
|
1633
|
+
f.attributes.map((v, K) => {
|
|
1630
1634
|
const F = /* @__PURE__ */ new Map();
|
|
1631
|
-
for (const
|
|
1632
|
-
const
|
|
1633
|
-
|
|
1635
|
+
for (const S of ce(K)) {
|
|
1636
|
+
const P = ee(S, v.field);
|
|
1637
|
+
P != null && P.id && F.set(P.id, P.label);
|
|
1634
1638
|
}
|
|
1635
|
-
const
|
|
1636
|
-
([,
|
|
1639
|
+
const J = [...F.entries()].sort(
|
|
1640
|
+
([, S], [, P]) => S.localeCompare(P, void 0, { numeric: !0 })
|
|
1637
1641
|
);
|
|
1638
1642
|
return /* @__PURE__ */ n(
|
|
1639
|
-
|
|
1643
|
+
rn,
|
|
1640
1644
|
{
|
|
1641
|
-
label:
|
|
1642
|
-
value:
|
|
1643
|
-
valueLabel:
|
|
1644
|
-
options:
|
|
1645
|
-
disabled:
|
|
1646
|
-
onChange: (
|
|
1647
|
-
const
|
|
1648
|
-
for (let
|
|
1649
|
-
const
|
|
1650
|
-
|
|
1645
|
+
label: Z(v.field),
|
|
1646
|
+
value: O[v.field] ?? null,
|
|
1647
|
+
valueLabel: O[v.field] ? F.get(O[v.field]) ?? O[v.field] : null,
|
|
1648
|
+
options: J,
|
|
1649
|
+
disabled: K > 0 && !O[f.attributes[K - 1].field],
|
|
1650
|
+
onChange: (S) => oe((P) => {
|
|
1651
|
+
const me = {};
|
|
1652
|
+
for (let R = 0; R < K; R++) {
|
|
1653
|
+
const H = f.attributes[R].field;
|
|
1654
|
+
P[H] && (me[H] = P[H]);
|
|
1651
1655
|
}
|
|
1652
|
-
return
|
|
1656
|
+
return S && (me[v.field] = S), me;
|
|
1653
1657
|
})
|
|
1654
1658
|
},
|
|
1655
1659
|
v.field
|
|
1656
1660
|
);
|
|
1657
1661
|
}),
|
|
1658
|
-
/* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children:
|
|
1659
|
-
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children:
|
|
1660
|
-
(h(
|
|
1661
|
-
|
|
1662
|
-
|
|
1662
|
+
/* @__PURE__ */ n("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: D && te ? /* @__PURE__ */ m(lt, { children: [
|
|
1663
|
+
/* @__PURE__ */ n("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Te(l, te) }),
|
|
1664
|
+
(h(D) ?? 0) > 0 && /* @__PURE__ */ m("span", { className: "rounded bg-nvr-cyan/10 px-1.5 py-0.5 text-[10px] font-semibold text-[#009abe]", children: [
|
|
1665
|
+
h(D),
|
|
1666
|
+
" in summary"
|
|
1667
|
+
] }),
|
|
1668
|
+
!x && /* @__PURE__ */ m(lt, { children: [
|
|
1669
|
+
/* @__PURE__ */ n(
|
|
1670
|
+
"input",
|
|
1671
|
+
{
|
|
1672
|
+
type: "number",
|
|
1673
|
+
min: 0,
|
|
1674
|
+
step: j,
|
|
1675
|
+
value: G,
|
|
1676
|
+
"aria-label": "Quantity to add",
|
|
1677
|
+
onChange: (v) => Se(v.target.value),
|
|
1678
|
+
onKeyDown: (v) => {
|
|
1679
|
+
v.key === "Enter" && (v.preventDefault(), ke());
|
|
1680
|
+
},
|
|
1681
|
+
className: "h-7 w-20 shrink-0 rounded border border-slate-200 bg-white px-2 text-right text-[12px] outline-none focus:border-nvr-cyan dark:border-border dark:bg-background"
|
|
1682
|
+
}
|
|
1683
|
+
),
|
|
1684
|
+
/* @__PURE__ */ m(
|
|
1685
|
+
"button",
|
|
1686
|
+
{
|
|
1687
|
+
type: "button",
|
|
1688
|
+
onClick: () => void ke(),
|
|
1689
|
+
disabled: !y,
|
|
1690
|
+
className: "flex h-7 shrink-0 items-center gap-1 rounded bg-nvr-cyan px-2.5 text-[12px] font-medium text-white hover:bg-nvr-cyan/90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan focus-visible:ring-offset-1 disabled:opacity-50",
|
|
1691
|
+
children: [
|
|
1692
|
+
L ? /* @__PURE__ */ n(ne, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ n(Rr, { className: "h-3.5 w-3.5" }),
|
|
1693
|
+
"Add"
|
|
1694
|
+
]
|
|
1695
|
+
}
|
|
1696
|
+
)
|
|
1697
|
+
] })
|
|
1698
|
+
] }) : X ? /* @__PURE__ */ n("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ n("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
|
|
1663
1699
|
] }) })
|
|
1664
1700
|
] });
|
|
1665
1701
|
}
|
|
1666
|
-
function
|
|
1702
|
+
function nr({ text: f, className: g }) {
|
|
1703
|
+
const _ = Ur(f);
|
|
1704
|
+
return /* @__PURE__ */ n("span", { ref: _, className: Q("truncate", g), children: f });
|
|
1705
|
+
}
|
|
1706
|
+
function rn({
|
|
1667
1707
|
label: f,
|
|
1668
|
-
value:
|
|
1708
|
+
value: g,
|
|
1669
1709
|
valueLabel: _,
|
|
1670
|
-
options:
|
|
1710
|
+
options: $,
|
|
1671
1711
|
disabled: l,
|
|
1672
|
-
onChange:
|
|
1712
|
+
onChange: h
|
|
1673
1713
|
}) {
|
|
1674
|
-
const [
|
|
1675
|
-
return
|
|
1676
|
-
if (!
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1714
|
+
const [p, j] = W(!1), x = Ve(null);
|
|
1715
|
+
return Fe(() => {
|
|
1716
|
+
if (!p) return;
|
|
1717
|
+
const z = (I) => {
|
|
1718
|
+
x.current && !x.current.contains(I.target) && j(!1);
|
|
1679
1719
|
};
|
|
1680
|
-
return document.addEventListener("mousedown",
|
|
1681
|
-
}, [
|
|
1720
|
+
return document.addEventListener("mousedown", z), () => document.removeEventListener("mousedown", z);
|
|
1721
|
+
}, [p]), /* @__PURE__ */ m("div", { ref: x, className: "relative", children: [
|
|
1682
1722
|
/* @__PURE__ */ n("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: f }),
|
|
1683
1723
|
/* @__PURE__ */ m(
|
|
1684
1724
|
"button",
|
|
1685
1725
|
{
|
|
1686
1726
|
type: "button",
|
|
1687
1727
|
disabled: l,
|
|
1688
|
-
onClick: () =>
|
|
1728
|
+
onClick: () => j((z) => !z),
|
|
1689
1729
|
className: "flex w-44 items-center justify-between rounded border border-slate-200 bg-white px-2 py-1.5 text-left text-[12px] text-slate-700 hover:border-slate-300 disabled:opacity-50 dark:border-border dark:bg-background dark:text-slate-200",
|
|
1690
1730
|
children: [
|
|
1691
|
-
/* @__PURE__ */ n("span", { className:
|
|
1692
|
-
/* @__PURE__ */ n(
|
|
1731
|
+
/* @__PURE__ */ n("span", { className: Q("truncate", !_ && "text-slate-400"), children: _ ?? "Select…" }),
|
|
1732
|
+
/* @__PURE__ */ n(Er, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
1693
1733
|
]
|
|
1694
1734
|
}
|
|
1695
1735
|
),
|
|
1696
|
-
|
|
1697
|
-
|
|
1736
|
+
p && /* @__PURE__ */ m("div", { className: "absolute z-50 mt-1 max-h-52 w-44 overflow-y-auto rounded-md border border-border bg-popover py-1 shadow-md", children: [
|
|
1737
|
+
g && /* @__PURE__ */ m(
|
|
1698
1738
|
"button",
|
|
1699
1739
|
{
|
|
1700
1740
|
type: "button",
|
|
1701
1741
|
onClick: () => {
|
|
1702
|
-
|
|
1742
|
+
h(null), j(!1);
|
|
1703
1743
|
},
|
|
1704
1744
|
className: "flex w-full items-center gap-1.5 border-b border-slate-100 px-2 py-1 text-left text-[12px] text-slate-500 hover:bg-muted dark:border-border dark:text-slate-400",
|
|
1705
1745
|
children: [
|
|
1706
|
-
/* @__PURE__ */ n(
|
|
1746
|
+
/* @__PURE__ */ n(dt, { className: "h-3 w-3 text-slate-400" }),
|
|
1707
1747
|
" Clear"
|
|
1708
1748
|
]
|
|
1709
1749
|
}
|
|
1710
1750
|
),
|
|
1711
|
-
|
|
1751
|
+
$.map(([z, I]) => /* @__PURE__ */ n(
|
|
1712
1752
|
"button",
|
|
1713
1753
|
{
|
|
1714
1754
|
type: "button",
|
|
1715
1755
|
onClick: () => {
|
|
1716
|
-
|
|
1756
|
+
h(z), j(!1);
|
|
1717
1757
|
},
|
|
1718
|
-
className:
|
|
1758
|
+
className: Q(
|
|
1719
1759
|
"block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
1720
|
-
|
|
1760
|
+
z === g ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
1721
1761
|
),
|
|
1722
|
-
children:
|
|
1762
|
+
children: I
|
|
1723
1763
|
},
|
|
1724
|
-
|
|
1764
|
+
z
|
|
1725
1765
|
))
|
|
1726
1766
|
] })
|
|
1727
1767
|
] });
|
|
1728
1768
|
}
|
|
1729
|
-
function
|
|
1769
|
+
function nn({
|
|
1730
1770
|
catalogCol: f,
|
|
1731
|
-
tmpl:
|
|
1771
|
+
tmpl: g,
|
|
1732
1772
|
sectionBy: _,
|
|
1733
|
-
sectionM2M:
|
|
1773
|
+
sectionM2M: $,
|
|
1734
1774
|
pinnedSet: l,
|
|
1735
|
-
pinnedIds:
|
|
1736
|
-
savingIds:
|
|
1737
|
-
relatedCols:
|
|
1738
|
-
parentDraft:
|
|
1739
|
-
onToggle:
|
|
1740
|
-
onClose:
|
|
1741
|
-
anchor:
|
|
1775
|
+
pinnedIds: h,
|
|
1776
|
+
savingIds: p,
|
|
1777
|
+
relatedCols: j,
|
|
1778
|
+
parentDraft: x,
|
|
1779
|
+
onToggle: z,
|
|
1780
|
+
onClose: I,
|
|
1781
|
+
anchor: se
|
|
1742
1782
|
}) {
|
|
1743
|
-
const
|
|
1744
|
-
|
|
1745
|
-
const a = setTimeout(() =>
|
|
1783
|
+
const C = Ft(), [O, oe] = W(""), [G, Se] = W(""), [L, ye] = W(1), qe = Ve(null);
|
|
1784
|
+
Fe(() => {
|
|
1785
|
+
const a = setTimeout(() => Se(O), 300);
|
|
1746
1786
|
return () => clearTimeout(a);
|
|
1747
|
-
}, [
|
|
1787
|
+
}, [O]), Fe(() => ye(1), [G]), Fe(() => {
|
|
1748
1788
|
var a;
|
|
1749
|
-
(a =
|
|
1750
|
-
}, []),
|
|
1789
|
+
(a = qe.current) == null || a.focus();
|
|
1790
|
+
}, []), Fe(() => {
|
|
1751
1791
|
const a = (k) => {
|
|
1752
|
-
k.key === "Escape" && (k.stopPropagation(),
|
|
1792
|
+
k.key === "Escape" && (k.stopPropagation(), I());
|
|
1753
1793
|
};
|
|
1754
1794
|
return window.addEventListener("keydown", a, !0), () => window.removeEventListener("keydown", a, !0);
|
|
1755
|
-
}, [
|
|
1756
|
-
const
|
|
1795
|
+
}, [I]);
|
|
1796
|
+
const pe = E(() => {
|
|
1757
1797
|
var k;
|
|
1758
|
-
const a = (k = [...(
|
|
1798
|
+
const a = (k = [...(g ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : k[1];
|
|
1759
1799
|
return a && !a.includes(".") ? a : "id";
|
|
1760
|
-
}, [
|
|
1761
|
-
queryKey: ["favorites-manager-list", f,
|
|
1762
|
-
queryFn: () =>
|
|
1763
|
-
|
|
1764
|
-
fields:
|
|
1765
|
-
limit:
|
|
1766
|
-
page:
|
|
1767
|
-
sort:
|
|
1768
|
-
...
|
|
1800
|
+
}, [g]), de = !$ && _.includes(".") ? `*,${_}` : "*", ee = 50, { data: ce, isFetching: X } = V({
|
|
1801
|
+
queryKey: ["favorites-manager-list", f, G, pe, L],
|
|
1802
|
+
queryFn: () => C.request(
|
|
1803
|
+
A(`/items/${f}`, {
|
|
1804
|
+
fields: de,
|
|
1805
|
+
limit: ee,
|
|
1806
|
+
page: L,
|
|
1807
|
+
sort: pe,
|
|
1808
|
+
...G.trim() ? { search: G } : {}
|
|
1769
1809
|
})
|
|
1770
1810
|
),
|
|
1771
1811
|
staleTime: 3e4,
|
|
1772
1812
|
placeholderData: (a) => a
|
|
1773
|
-
}),
|
|
1774
|
-
queryKey: ["favorites-manager-pinned", f,
|
|
1775
|
-
queryFn: () =>
|
|
1776
|
-
|
|
1777
|
-
filter: JSON.stringify({ id: { _in:
|
|
1778
|
-
fields:
|
|
1779
|
-
limit:
|
|
1780
|
-
sort:
|
|
1813
|
+
}), ae = ((ce == null ? void 0 : ce.data) ?? []).filter((a) => !l.has(String(a.id))), D = (ce == null ? void 0 : ce.total) ?? ae.length, te = Math.max(1, Math.ceil(D / ee)), { data: he = [] } = V({
|
|
1814
|
+
queryKey: ["favorites-manager-pinned", f, de, h.join(",")],
|
|
1815
|
+
queryFn: () => C.request(
|
|
1816
|
+
A(`/items/${f}`, {
|
|
1817
|
+
filter: JSON.stringify({ id: { _in: h } }),
|
|
1818
|
+
fields: de,
|
|
1819
|
+
limit: h.length,
|
|
1820
|
+
sort: pe
|
|
1781
1821
|
})
|
|
1782
1822
|
).then((a) => a.data ?? []),
|
|
1783
|
-
enabled:
|
|
1823
|
+
enabled: h.length > 0,
|
|
1784
1824
|
staleTime: 3e4
|
|
1785
|
-
}),
|
|
1825
|
+
}), y = E(() => {
|
|
1786
1826
|
const a = /* @__PURE__ */ new Set();
|
|
1787
|
-
for (const k of
|
|
1788
|
-
for (const k of
|
|
1827
|
+
for (const k of ae) a.add(String(k.id));
|
|
1828
|
+
for (const k of h) a.add(k);
|
|
1789
1829
|
return [...a];
|
|
1790
|
-
}, [
|
|
1791
|
-
queryKey: ["favorites-manager-sections",
|
|
1830
|
+
}, [ae, h]), { data: ke = /* @__PURE__ */ new Map() } = V({
|
|
1831
|
+
queryKey: ["favorites-manager-sections", $ == null ? void 0 : $.junction, y.join(",")],
|
|
1792
1832
|
queryFn: async () => {
|
|
1793
|
-
const a =
|
|
1833
|
+
const a = $, k = await ct(C, `/items/${a.junction}`, {
|
|
1794
1834
|
fields: `${a.fkToItem},${a.fkToSection}`,
|
|
1795
|
-
filter: JSON.stringify({ [a.fkToItem]: { _in:
|
|
1796
|
-
}), U = [...new Set(k.map((
|
|
1835
|
+
filter: JSON.stringify({ [a.fkToItem]: { _in: y } })
|
|
1836
|
+
}), U = [...new Set(k.map((M) => String(M[a.fkToSection])))], B = U.length ? await ct(C, `/items/${a.target}`, {
|
|
1797
1837
|
fields: `id,${a.labelPath}`,
|
|
1798
1838
|
filter: JSON.stringify({ id: { _in: U } })
|
|
1799
1839
|
}) : [], re = new Map(
|
|
1800
|
-
|
|
1801
|
-
),
|
|
1802
|
-
for (const
|
|
1803
|
-
const ie = re.get(String(
|
|
1840
|
+
B.map((M) => [String(M.id), String(ir(M, a.labelPath) ?? "")])
|
|
1841
|
+
), Y = /* @__PURE__ */ new Map();
|
|
1842
|
+
for (const M of k) {
|
|
1843
|
+
const ie = re.get(String(M[a.fkToSection]));
|
|
1804
1844
|
if (!ie) continue;
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1845
|
+
const ue = String(M[a.fkToItem]), we = Y.get(ue) ?? [];
|
|
1846
|
+
we.includes(ie) || we.push(ie), Y.set(ue, we);
|
|
1807
1847
|
}
|
|
1808
|
-
return
|
|
1848
|
+
return Y;
|
|
1809
1849
|
},
|
|
1810
|
-
enabled:
|
|
1850
|
+
enabled: !!$ && y.length > 0,
|
|
1811
1851
|
staleTime: 6e4
|
|
1812
|
-
}),
|
|
1852
|
+
}), v = (a) => g ? Te(g, a) : String(a.cifa_number ?? a.name ?? `#${a.id}`), K = (a) => {
|
|
1813
1853
|
const k = a.description ?? a.long_description ?? a.name;
|
|
1814
|
-
return typeof k == "string" && k.trim() && k.trim() !==
|
|
1815
|
-
},
|
|
1816
|
-
if (
|
|
1854
|
+
return typeof k == "string" && k.trim() && k.trim() !== v(a) ? k : "";
|
|
1855
|
+
}, F = (a) => {
|
|
1856
|
+
if ($) return (ke.get(String(a.id)) ?? []).join(", ");
|
|
1817
1857
|
if (!_) return "";
|
|
1818
|
-
const k =
|
|
1858
|
+
const k = Te(`{{${_}}}`, a);
|
|
1819
1859
|
return k === `{{${_}}}` ? "" : k;
|
|
1820
|
-
},
|
|
1860
|
+
}, J = (a, k) => {
|
|
1821
1861
|
if (k === "presence")
|
|
1822
1862
|
return a == null || a === "" || Number(a) === 0 ? "No" : "Yes";
|
|
1823
1863
|
if (a == null || a === "") return "—";
|
|
1824
1864
|
const U = Number(a);
|
|
1825
1865
|
return k === "currency" && Number.isFinite(U) ? U.toLocaleString("en-US", { style: "currency", currency: "USD" }) : k === "number" && Number.isFinite(U) ? U.toLocaleString() : String(a);
|
|
1826
|
-
},
|
|
1827
|
-
queries:
|
|
1828
|
-
const k =
|
|
1866
|
+
}, S = $t({
|
|
1867
|
+
queries: j.map((a) => {
|
|
1868
|
+
const k = De(a.match, x);
|
|
1829
1869
|
return {
|
|
1830
1870
|
queryKey: [
|
|
1831
1871
|
"favorites-manager-related",
|
|
1832
1872
|
a.key,
|
|
1833
1873
|
a.collection,
|
|
1834
1874
|
JSON.stringify(k),
|
|
1835
|
-
|
|
1875
|
+
y.join(",")
|
|
1836
1876
|
],
|
|
1837
1877
|
queryFn: async () => {
|
|
1838
|
-
const U = await
|
|
1839
|
-
|
|
1840
|
-
filter: JSON.stringify({ [a.item_field]: { _in:
|
|
1878
|
+
const U = await C.request(
|
|
1879
|
+
A(`/items/${a.collection}`, {
|
|
1880
|
+
filter: JSON.stringify({ [a.item_field]: { _in: y }, ...k ?? {} }),
|
|
1841
1881
|
fields: `${a.item_field},${a.value_field}`,
|
|
1842
1882
|
limit: 1e3
|
|
1843
1883
|
})
|
|
1844
|
-
).then((re) => re.data ?? []),
|
|
1884
|
+
).then((re) => re.data ?? []), B = /* @__PURE__ */ new Map();
|
|
1845
1885
|
for (const re of U) {
|
|
1846
|
-
const
|
|
1847
|
-
ie === void 0 ?
|
|
1886
|
+
const Y = String(re[a.item_field]), M = re[a.value_field], ie = B.get(Y);
|
|
1887
|
+
ie === void 0 ? B.set(Y, M) : Number.isFinite(Number(ie)) && Number.isFinite(Number(M)) && B.set(Y, Number(ie) + Number(M));
|
|
1848
1888
|
}
|
|
1849
|
-
return
|
|
1889
|
+
return B;
|
|
1850
1890
|
},
|
|
1851
|
-
enabled:
|
|
1891
|
+
enabled: y.length > 0 && (a.match === void 0 || k !== null),
|
|
1852
1892
|
staleTime: 3e4
|
|
1853
1893
|
};
|
|
1854
1894
|
})
|
|
1855
|
-
}),
|
|
1856
|
-
(a) => a.match !== void 0 &&
|
|
1857
|
-
),
|
|
1895
|
+
}), P = j.filter(
|
|
1896
|
+
(a) => a.match !== void 0 && De(a.match, x) === null
|
|
1897
|
+
), me = (a) => {
|
|
1858
1898
|
const k = l.has(a);
|
|
1859
1899
|
return /* @__PURE__ */ n(
|
|
1860
1900
|
"button",
|
|
1861
1901
|
{
|
|
1862
1902
|
type: "button",
|
|
1863
1903
|
title: k ? "Remove from favorites" : "Add to favorites",
|
|
1864
|
-
disabled:
|
|
1865
|
-
onClick: () =>
|
|
1904
|
+
disabled: p.has(a),
|
|
1905
|
+
onClick: () => z(a),
|
|
1866
1906
|
className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
|
|
1867
|
-
children:
|
|
1907
|
+
children: p.has(a) ? /* @__PURE__ */ n(ne, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ n(
|
|
1868
1908
|
Be,
|
|
1869
1909
|
{
|
|
1870
|
-
className:
|
|
1910
|
+
className: Q(
|
|
1871
1911
|
"h-4 w-4",
|
|
1872
1912
|
k ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
1873
1913
|
)
|
|
@@ -1875,37 +1915,37 @@ function Zr({
|
|
|
1875
1915
|
)
|
|
1876
1916
|
}
|
|
1877
1917
|
);
|
|
1878
|
-
},
|
|
1879
|
-
const U = String(a.id),
|
|
1918
|
+
}, R = (a, k) => /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n("td", { colSpan: 4 + j.length, className: Q("border-b px-3 py-1.5", k), children: a }) }), H = (a, k) => {
|
|
1919
|
+
const U = String(a.id), B = K(a);
|
|
1880
1920
|
return /* @__PURE__ */ m(
|
|
1881
1921
|
"tr",
|
|
1882
1922
|
{
|
|
1883
|
-
className:
|
|
1923
|
+
className: Q(
|
|
1884
1924
|
"border-b border-slate-100 dark:border-border/50",
|
|
1885
1925
|
k % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
|
|
1886
1926
|
),
|
|
1887
1927
|
children: [
|
|
1888
|
-
/* @__PURE__ */ n("td", { className: "px-2 py-1", children:
|
|
1889
|
-
/* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children:
|
|
1928
|
+
/* @__PURE__ */ n("td", { className: "px-2 py-1", children: me(U) }),
|
|
1929
|
+
/* @__PURE__ */ n("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: sr(f) ? /* @__PURE__ */ n(
|
|
1890
1930
|
"button",
|
|
1891
1931
|
{
|
|
1892
1932
|
type: "button",
|
|
1893
|
-
onClick: () =>
|
|
1933
|
+
onClick: () => ar(f, U, x),
|
|
1894
1934
|
title: "View stock & planning detail",
|
|
1895
1935
|
className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
|
|
1896
|
-
children:
|
|
1936
|
+
children: v(a)
|
|
1897
1937
|
}
|
|
1898
|
-
) :
|
|
1899
|
-
/* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip":
|
|
1900
|
-
/* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children:
|
|
1901
|
-
|
|
1902
|
-
var
|
|
1903
|
-
const
|
|
1938
|
+
) : v(a) }),
|
|
1939
|
+
/* @__PURE__ */ n("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": B || void 0, children: B || "—" }) }),
|
|
1940
|
+
/* @__PURE__ */ n("td", { className: "px-2 py-1", children: /* @__PURE__ */ n("p", { className: "truncate text-slate-500 dark:text-slate-400", children: F(a) || "—" }) }),
|
|
1941
|
+
j.map((re, Y) => {
|
|
1942
|
+
var ue, we;
|
|
1943
|
+
const M = re.match !== void 0 && De(re.match, x) === null, ie = M || (we = (ue = S[Y]) == null ? void 0 : ue.data) == null ? void 0 : we.get(U);
|
|
1904
1944
|
return /* @__PURE__ */ n(
|
|
1905
1945
|
"td",
|
|
1906
1946
|
{
|
|
1907
1947
|
className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
1908
|
-
children:
|
|
1948
|
+
children: M ? "—" : J(ie, re.format)
|
|
1909
1949
|
},
|
|
1910
1950
|
re.key
|
|
1911
1951
|
);
|
|
@@ -1914,14 +1954,14 @@ function Zr({
|
|
|
1914
1954
|
},
|
|
1915
1955
|
U
|
|
1916
1956
|
);
|
|
1917
|
-
},
|
|
1918
|
-
return
|
|
1957
|
+
}, Oe = (se == null ? void 0 : se.closest('[role="dialog"]')) ?? document.body, xe = O.trim() ? he.filter((a) => Vr(`${v(a)} ${K(a)} ${F(a)}`, O)) : he;
|
|
1958
|
+
return Ar(
|
|
1919
1959
|
/* @__PURE__ */ m("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
|
|
1920
1960
|
/* @__PURE__ */ n(
|
|
1921
1961
|
"div",
|
|
1922
1962
|
{
|
|
1923
1963
|
className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
|
|
1924
|
-
onClick:
|
|
1964
|
+
onClick: I
|
|
1925
1965
|
}
|
|
1926
1966
|
),
|
|
1927
1967
|
/* @__PURE__ */ m(
|
|
@@ -1942,40 +1982,40 @@ function Zr({
|
|
|
1942
1982
|
"button",
|
|
1943
1983
|
{
|
|
1944
1984
|
type: "button",
|
|
1945
|
-
onClick:
|
|
1985
|
+
onClick: I,
|
|
1946
1986
|
className: "shrink-0 rounded p-1 text-slate-400 transition-colors hover:bg-slate-100 hover:text-slate-600 dark:hover:bg-white/[0.06]",
|
|
1947
1987
|
"aria-label": "Close",
|
|
1948
|
-
children: /* @__PURE__ */ n(
|
|
1988
|
+
children: /* @__PURE__ */ n(dt, { className: "h-4 w-4" })
|
|
1949
1989
|
}
|
|
1950
1990
|
)
|
|
1951
1991
|
] }),
|
|
1952
1992
|
/* @__PURE__ */ m("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1953
1993
|
/* @__PURE__ */ m("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
|
|
1954
|
-
/* @__PURE__ */ n(
|
|
1994
|
+
/* @__PURE__ */ n(ot, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
1955
1995
|
/* @__PURE__ */ n(
|
|
1956
1996
|
"input",
|
|
1957
1997
|
{
|
|
1958
|
-
ref:
|
|
1959
|
-
value:
|
|
1998
|
+
ref: qe,
|
|
1999
|
+
value: O,
|
|
1960
2000
|
onChange: (a) => oe(a.target.value),
|
|
1961
2001
|
placeholder: "Search by number or description…",
|
|
1962
2002
|
className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
|
|
1963
2003
|
}
|
|
1964
2004
|
),
|
|
1965
|
-
|
|
2005
|
+
O && /* @__PURE__ */ n(
|
|
1966
2006
|
"button",
|
|
1967
2007
|
{
|
|
1968
2008
|
type: "button",
|
|
1969
2009
|
onClick: () => oe(""),
|
|
1970
2010
|
className: "shrink-0 text-slate-400 hover:text-slate-600",
|
|
1971
2011
|
"aria-label": "Clear search",
|
|
1972
|
-
children: /* @__PURE__ */ n(
|
|
2012
|
+
children: /* @__PURE__ */ n(dt, { className: "h-3.5 w-3.5" })
|
|
1973
2013
|
}
|
|
1974
2014
|
)
|
|
1975
2015
|
] }),
|
|
1976
|
-
|
|
2016
|
+
P.length > 0 && /* @__PURE__ */ m("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
|
|
1977
2017
|
/* @__PURE__ */ n(ze, { className: "h-3 w-3 shrink-0" }),
|
|
1978
|
-
|
|
2018
|
+
P.map((a) => a.label ?? Z(a.key)).join(", "),
|
|
1979
2019
|
" fill in once the form's warehouse selection is made."
|
|
1980
2020
|
] })
|
|
1981
2021
|
] }),
|
|
@@ -1985,63 +2025,63 @@ function Zr({
|
|
|
1985
2025
|
/* @__PURE__ */ n("col", { className: "w-[88px]" }),
|
|
1986
2026
|
/* @__PURE__ */ n("col", {}),
|
|
1987
2027
|
/* @__PURE__ */ n("col", { className: "w-[130px]" }),
|
|
1988
|
-
|
|
2028
|
+
j.map((a) => /* @__PURE__ */ n("col", { className: "w-[86px]" }, a.key))
|
|
1989
2029
|
] }),
|
|
1990
2030
|
/* @__PURE__ */ n("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ m("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
|
|
1991
2031
|
/* @__PURE__ */ n("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
|
|
1992
2032
|
/* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "CIFA #" }),
|
|
1993
2033
|
/* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Description" }),
|
|
1994
2034
|
/* @__PURE__ */ n("th", { className: "px-2 py-1.5", children: "Category" }),
|
|
1995
|
-
|
|
2035
|
+
j.map((a) => /* @__PURE__ */ n("th", { className: "px-2 py-1.5 text-right", children: a.label ?? Z(a.key) }, a.key))
|
|
1996
2036
|
] }) }),
|
|
1997
|
-
/* @__PURE__ */ m("tbody", { className:
|
|
1998
|
-
|
|
2037
|
+
/* @__PURE__ */ m("tbody", { className: Q(X && "opacity-50 transition-opacity"), children: [
|
|
2038
|
+
R(
|
|
1999
2039
|
/* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
|
|
2000
2040
|
/* @__PURE__ */ n(Be, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2001
2041
|
/* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
|
|
2002
|
-
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children:
|
|
2042
|
+
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: h.length })
|
|
2003
2043
|
] }),
|
|
2004
2044
|
"border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
|
|
2005
2045
|
),
|
|
2006
|
-
|
|
2046
|
+
xe.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
|
|
2007
2047
|
"td",
|
|
2008
2048
|
{
|
|
2009
|
-
colSpan: 4 +
|
|
2049
|
+
colSpan: 4 + j.length,
|
|
2010
2050
|
className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
|
|
2011
|
-
children:
|
|
2051
|
+
children: h.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
|
|
2012
2052
|
}
|
|
2013
2053
|
) }),
|
|
2014
|
-
|
|
2015
|
-
|
|
2054
|
+
xe.map((a, k) => H(a, k)),
|
|
2055
|
+
R(
|
|
2016
2056
|
/* @__PURE__ */ m("span", { className: "flex items-center gap-1.5", children: [
|
|
2017
|
-
/* @__PURE__ */ n(
|
|
2057
|
+
/* @__PURE__ */ n(ot, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
2018
2058
|
/* @__PURE__ */ n("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
|
|
2019
|
-
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children:
|
|
2020
|
-
|
|
2059
|
+
/* @__PURE__ */ n("span", { className: "rounded border border-slate-200 bg-white px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-slate-500 dark:border-border dark:bg-background dark:text-slate-400", children: D.toLocaleString() }),
|
|
2060
|
+
X && /* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin text-slate-400" })
|
|
2021
2061
|
] }),
|
|
2022
2062
|
"border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
|
|
2023
2063
|
),
|
|
2024
|
-
!
|
|
2064
|
+
!X && ae.length === 0 && /* @__PURE__ */ n("tr", { children: /* @__PURE__ */ n(
|
|
2025
2065
|
"td",
|
|
2026
2066
|
{
|
|
2027
|
-
colSpan: 4 +
|
|
2067
|
+
colSpan: 4 + j.length,
|
|
2028
2068
|
className: "px-4 py-4 text-center text-[11px] text-slate-400",
|
|
2029
|
-
children:
|
|
2069
|
+
children: G.trim() ? `No CIFAs match "${G}".` : "No catalog items."
|
|
2030
2070
|
}
|
|
2031
2071
|
) }),
|
|
2032
|
-
|
|
2072
|
+
ae.map((a, k) => H(a, k))
|
|
2033
2073
|
] })
|
|
2034
2074
|
] }) }),
|
|
2035
|
-
|
|
2075
|
+
te > 1 && /* @__PURE__ */ m("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
2036
2076
|
/* @__PURE__ */ m("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
|
|
2037
|
-
(
|
|
2077
|
+
(L - 1) * ee + 1,
|
|
2038
2078
|
"–",
|
|
2039
|
-
Math.min(
|
|
2079
|
+
Math.min(L * ee, D),
|
|
2040
2080
|
" of",
|
|
2041
2081
|
" ",
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
/* @__PURE__ */ n(
|
|
2082
|
+
D.toLocaleString(),
|
|
2083
|
+
X && /* @__PURE__ */ m("span", { className: "flex items-center gap-1 text-slate-500", children: [
|
|
2084
|
+
/* @__PURE__ */ n(ne, { className: "h-3 w-3 animate-spin" }),
|
|
2045
2085
|
" Loading…"
|
|
2046
2086
|
] })
|
|
2047
2087
|
] }),
|
|
@@ -2050,23 +2090,23 @@ function Zr({
|
|
|
2050
2090
|
"button",
|
|
2051
2091
|
{
|
|
2052
2092
|
type: "button",
|
|
2053
|
-
disabled:
|
|
2093
|
+
disabled: L <= 1 || X,
|
|
2054
2094
|
onClick: () => ye((a) => Math.max(1, a - 1)),
|
|
2055
2095
|
className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
|
|
2056
2096
|
children: "‹ Prev"
|
|
2057
2097
|
}
|
|
2058
2098
|
),
|
|
2059
2099
|
/* @__PURE__ */ m("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
|
|
2060
|
-
|
|
2100
|
+
L,
|
|
2061
2101
|
" / ",
|
|
2062
|
-
|
|
2102
|
+
te.toLocaleString()
|
|
2063
2103
|
] }),
|
|
2064
2104
|
/* @__PURE__ */ n(
|
|
2065
2105
|
"button",
|
|
2066
2106
|
{
|
|
2067
2107
|
type: "button",
|
|
2068
|
-
disabled:
|
|
2069
|
-
onClick: () => ye((a) => Math.min(
|
|
2108
|
+
disabled: L >= te || X,
|
|
2109
|
+
onClick: () => ye((a) => Math.min(te, a + 1)),
|
|
2070
2110
|
className: "rounded border border-slate-200 px-2 py-0.5 text-[11px] text-slate-600 transition-colors hover:bg-slate-50 disabled:opacity-40 dark:border-border dark:text-slate-300 dark:hover:bg-white/[0.04]",
|
|
2071
2111
|
children: "Next ›"
|
|
2072
2112
|
}
|
|
@@ -2077,10 +2117,10 @@ function Zr({
|
|
|
2077
2117
|
}
|
|
2078
2118
|
)
|
|
2079
2119
|
] }),
|
|
2080
|
-
|
|
2120
|
+
Oe
|
|
2081
2121
|
);
|
|
2082
2122
|
}
|
|
2083
2123
|
export {
|
|
2084
|
-
|
|
2085
|
-
|
|
2124
|
+
qn as CatalogPickerField,
|
|
2125
|
+
rr as matchesShowWhen
|
|
2086
2126
|
};
|