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