@nivaro/react 0.3.81 → 0.3.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/shared/components/ItemEditForm.js +454 -454
- package/dist/shared/components/item-edit/CatalogPickerField.js +1487 -1278
- package/dist/shared/components/item-edit/cascade-clear-notice.js +32 -28
- package/dist/shared/components/item-edit/catalog-facets.js +84 -0
- package/package.json +1 -1
|
@@ -1,105 +1,106 @@
|
|
|
1
|
-
import { jsxs as u, jsx 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 { tokenize as
|
|
12
|
-
import { registerStagedRowLabel as
|
|
13
|
-
import { submissionLineErrors as
|
|
14
|
-
import { titleCase as
|
|
15
|
-
import { ImportFromFileButton as
|
|
1
|
+
import { jsxs as u, jsx as s, Fragment as Ne } from "react/jsx-runtime";
|
|
2
|
+
import { useQueryClient as Hr, useQuery as Q, useQueries as mn } from "@tanstack/react-query";
|
|
3
|
+
import { Search as At, Loader2 as ue, PackageCheck as Yr, ChevronRight as Kt, Star as ct, AlertTriangle as He, AlertCircle as cn, X as ut, Plus as or, ChevronDown as Zr } from "lucide-react";
|
|
4
|
+
import { useState as D, useRef as qe, useMemo as E, useEffect as $e, Fragment as ot } from "react";
|
|
5
|
+
import { createPortal as Gr } from "react-dom";
|
|
6
|
+
import { useNivaroClient as mt, useParentDraft as Xr, useReimportHandler as es, useItemEditAuth as nr } from "../../context.js";
|
|
7
|
+
import { canOpenCatalogItem as dr, openCatalogItem as cr } from "../../lib/catalog-item-open.js";
|
|
8
|
+
import { get as K, del as ts, patch as rr, post as sr } from "../../lib/commands.js";
|
|
9
|
+
import { evaluateBoolean as ns } from "../../lib/expression.js";
|
|
10
|
+
import { useLiveRefetchInterval as rs } from "../../lib/live-queries.js";
|
|
11
|
+
import { tokenize as ss, matchesSearch as as } from "../../lib/search-text.js";
|
|
12
|
+
import { registerStagedRowLabel as is } from "../../lib/staged-row-labels.js";
|
|
13
|
+
import { submissionLineErrors as ls, normalizeIdent as os } from "../../lib/submission-errors.js";
|
|
14
|
+
import { titleCase as X, cn as W, matchesAllTokens as ds } from "../../lib/utils.js";
|
|
15
|
+
import { ImportFromFileButton as cs } from "../import/ImportFromFileButton.js";
|
|
16
16
|
import { SearchHighlight as fn } from "../SearchHighlight.js";
|
|
17
|
-
import { useOverflowTip as
|
|
18
|
-
import { useColumnWidths as ar, ResetColumnsButton as
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
import { useOverflowTip as us } from "../TipLayer.js";
|
|
18
|
+
import { useColumnWidths as ar, ResetColumnsButton as un, ColResizeHandle as ms, fitWidth as fs } from "./catalog-columns.js";
|
|
19
|
+
import { facetsComplete as hs, facetResults as ps, facetOptions as bs, setFacetPick as xs } from "./catalog-facets.js";
|
|
20
|
+
import { orderCatalogMatches as ys, rowMatchesFields as gs } from "./catalog-search.js";
|
|
21
|
+
import { applyDisplayTemplate as Ke } from "./helpers.js";
|
|
22
|
+
import { evalClientFormula as Ee } from "./InlineTableField.js";
|
|
23
|
+
import { isIntegerFieldType as dt, checkNumberEntry as hn, mergePendingQtyRow as ks, decimalPlacesProblem as ws, lineRuleErrors as Ns, MAX_LINE_MONEY as vs } from "./line-qty.js";
|
|
24
|
+
import { resolveM2MRelatedCollection as Ss } from "./M2MCombobox.js";
|
|
25
|
+
import { useO2MStaging as _s } from "./O2MStagingContext.js";
|
|
26
|
+
import { RelationCombobox as qs, RelatedItemLabel as $s } from "./RelationCombobox.js";
|
|
27
|
+
const ur = (i, m) => {
|
|
28
|
+
let f = i;
|
|
28
29
|
for (const x of m.split(".")) {
|
|
29
|
-
if (
|
|
30
|
-
|
|
30
|
+
if (f == null || typeof f != "object") return;
|
|
31
|
+
f = f[x];
|
|
31
32
|
}
|
|
32
|
-
return
|
|
33
|
+
return f;
|
|
33
34
|
};
|
|
34
|
-
async function
|
|
35
|
+
async function Ct(i, m, f) {
|
|
35
36
|
const x = [];
|
|
36
37
|
for (let _ = 1; _ <= 50; _++) {
|
|
37
|
-
const
|
|
38
|
-
if (x.push(...
|
|
38
|
+
const a = await i.request(K(m, { ...f, limit: 1e3, page: _ })).then((w) => w.data ?? []);
|
|
39
|
+
if (x.push(...a), a.length < 1e3) break;
|
|
39
40
|
}
|
|
40
41
|
return x;
|
|
41
42
|
}
|
|
42
|
-
function
|
|
43
|
-
const _ = {},
|
|
43
|
+
function js(i, m, f, x) {
|
|
44
|
+
const _ = {}, a = { ...x ?? {} };
|
|
44
45
|
for (const w of m) {
|
|
45
|
-
const k = i[w],
|
|
46
|
-
if (!
|
|
47
|
-
const
|
|
48
|
-
|
|
46
|
+
const k = i[w], F = k == null || k === "", N = !F && (x == null ? void 0 : x[w]) !== void 0 && x[w] === String(k);
|
|
47
|
+
if (!F && !N) continue;
|
|
48
|
+
const R = f(w);
|
|
49
|
+
R == null || R === "" || !F && String(R) === String(k) || (_[w] = R, a[w] = String(R));
|
|
49
50
|
}
|
|
50
|
-
return Object.keys(_).length > 0 ? { updates: _, auto:
|
|
51
|
+
return Object.keys(_).length > 0 ? { updates: _, auto: a } : null;
|
|
51
52
|
}
|
|
52
|
-
function
|
|
53
|
+
function pn(i, m = /* @__PURE__ */ new Set()) {
|
|
53
54
|
if (typeof i == "string" && i.startsWith("$parent.")) m.add(i.slice(8));
|
|
54
|
-
else if (Array.isArray(i)) for (const
|
|
55
|
+
else if (Array.isArray(i)) for (const f of i) pn(f, m);
|
|
55
56
|
else if (i && typeof i == "object")
|
|
56
|
-
for (const
|
|
57
|
+
for (const f of Object.values(i)) pn(f, m);
|
|
57
58
|
return m;
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
const
|
|
60
|
+
function Ye(i, m) {
|
|
61
|
+
const f = {};
|
|
61
62
|
let x = !1;
|
|
62
|
-
const _ = (
|
|
63
|
-
if (typeof
|
|
64
|
-
const w = m == null ? void 0 : m[
|
|
65
|
-
return w == null || w === "" ? (x = !0,
|
|
63
|
+
const _ = (a) => {
|
|
64
|
+
if (typeof a == "string" && a.startsWith("$parent.")) {
|
|
65
|
+
const w = m == null ? void 0 : m[a.slice(8)];
|
|
66
|
+
return w == null || w === "" ? (x = !0, a) : w;
|
|
66
67
|
}
|
|
67
|
-
return Array.isArray(
|
|
68
|
+
return Array.isArray(a) ? a.map(_) : a && typeof a == "object" ? Object.fromEntries(Object.entries(a).map(([w, k]) => [w, _(k)])) : a;
|
|
68
69
|
};
|
|
69
|
-
for (const [
|
|
70
|
+
for (const [a, w] of Object.entries(i ?? {}))
|
|
70
71
|
if (typeof w == "string" && w.startsWith("$parent.")) {
|
|
71
72
|
const k = m == null ? void 0 : m[w.slice(8)];
|
|
72
73
|
if (k == null || k === "") {
|
|
73
74
|
x = !0;
|
|
74
75
|
continue;
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
} else w && typeof w == "object" ?
|
|
78
|
-
return x ? null :
|
|
77
|
+
f[a] = { _eq: k };
|
|
78
|
+
} else w && typeof w == "object" ? f[a] = _(w) : f[a] = { _eq: w };
|
|
79
|
+
return x ? null : f;
|
|
79
80
|
}
|
|
80
81
|
function ir(i, m) {
|
|
81
82
|
if (!i) return !0;
|
|
82
|
-
for (const [
|
|
83
|
-
const _ = m == null ? void 0 : m[
|
|
84
|
-
for (const [k,
|
|
83
|
+
for (const [f, x] of Object.entries(i)) {
|
|
84
|
+
const _ = m == null ? void 0 : m[f], a = _ == null ? null : String(_), w = x && typeof x == "object" ? x : { _eq: x };
|
|
85
|
+
for (const [k, F] of Object.entries(w))
|
|
85
86
|
switch (k) {
|
|
86
87
|
case "_eq":
|
|
87
|
-
if (
|
|
88
|
+
if (a !== String(F)) return !1;
|
|
88
89
|
break;
|
|
89
90
|
case "_neq":
|
|
90
|
-
if (
|
|
91
|
+
if (a === String(F)) return !1;
|
|
91
92
|
break;
|
|
92
93
|
case "_in":
|
|
93
|
-
if (!Array.isArray(
|
|
94
|
+
if (!Array.isArray(F) || !F.map(String).includes(a ?? "")) return !1;
|
|
94
95
|
break;
|
|
95
96
|
case "_nin":
|
|
96
|
-
if (Array.isArray(
|
|
97
|
+
if (Array.isArray(F) && F.map(String).includes(a ?? "")) return !1;
|
|
97
98
|
break;
|
|
98
99
|
case "_null":
|
|
99
|
-
if (
|
|
100
|
+
if (a !== null) return !1;
|
|
100
101
|
break;
|
|
101
102
|
case "_nnull":
|
|
102
|
-
if (
|
|
103
|
+
if (a === null) return !1;
|
|
103
104
|
break;
|
|
104
105
|
default:
|
|
105
106
|
return !1;
|
|
@@ -107,209 +108,209 @@ function ir(i, m) {
|
|
|
107
108
|
}
|
|
108
109
|
return !0;
|
|
109
110
|
}
|
|
110
|
-
const
|
|
111
|
-
function
|
|
111
|
+
const Fs = 2e3;
|
|
112
|
+
function Ts(i, m) {
|
|
112
113
|
if (/e/i.test(i.trim())) return "Type the quantity in full digits";
|
|
113
|
-
const
|
|
114
|
-
if (
|
|
114
|
+
const f = Number(i);
|
|
115
|
+
if (dt(m) && i.trim() !== "" && !Number.isNaN(f) && !Number.isInteger(f))
|
|
115
116
|
return "Whole numbers only";
|
|
116
117
|
const x = hn(i, { type: m, min: 0, label: "Quantity" });
|
|
117
118
|
return x.ok ? null : x.message;
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
const x = i.reduce((_,
|
|
121
|
-
const w =
|
|
122
|
-
return _ + (k != null && Number.isFinite(
|
|
120
|
+
function Os(i, m, f) {
|
|
121
|
+
const x = i.reduce((_, a) => {
|
|
122
|
+
const w = a[m], k = w != null && w !== "" ? w : f != null && f[m] ? Ee(f[m], a) : null, F = Number(k);
|
|
123
|
+
return _ + (k != null && Number.isFinite(F) ? F : 0);
|
|
123
124
|
}, 0);
|
|
124
125
|
return Math.round(x * 1e6) / 1e6;
|
|
125
126
|
}
|
|
126
|
-
function
|
|
127
|
-
const
|
|
128
|
-
return
|
|
127
|
+
function Rs(i, m) {
|
|
128
|
+
const f = m.trim();
|
|
129
|
+
return f ? `${i} — ${f} not used` : i;
|
|
129
130
|
}
|
|
130
|
-
function
|
|
131
|
+
function Ps(i) {
|
|
131
132
|
const m = { ...i.probe };
|
|
132
|
-
for (const [
|
|
133
|
-
const _ =
|
|
133
|
+
for (const [f, x] of Object.entries(i.compute)) {
|
|
134
|
+
const _ = Ee(x, m);
|
|
134
135
|
if (_ === null) continue;
|
|
135
|
-
m[
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
if (Math.abs(_) >
|
|
139
|
-
return `${i.labelOf(
|
|
136
|
+
m[f] = _;
|
|
137
|
+
const a = i.ruleError(f, _, m);
|
|
138
|
+
if (a) return a;
|
|
139
|
+
if (Math.abs(_) > vs)
|
|
140
|
+
return `${i.labelOf(f)} would be ${_.toLocaleString(void 0, { maximumFractionDigits: 2 })} — too large to save`;
|
|
140
141
|
}
|
|
141
142
|
return null;
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
-
const m = Object.entries(i.copyFields ?? {}).filter(([,
|
|
145
|
-
for (const
|
|
144
|
+
function Ls(i) {
|
|
145
|
+
const m = Object.entries(i.copyFields ?? {}).filter(([, f]) => f === i.field).map(([f]) => f);
|
|
146
|
+
for (const f of m)
|
|
146
147
|
for (const x of i.related ?? []) {
|
|
147
|
-
if (x.copy_to !==
|
|
148
|
+
if (x.copy_to !== f) continue;
|
|
148
149
|
const _ = i.lookup(x.key);
|
|
149
150
|
if (_ != null && _ !== "") return _;
|
|
150
151
|
}
|
|
151
152
|
return i.catalogValue;
|
|
152
153
|
}
|
|
153
|
-
function
|
|
154
|
-
return i.map((
|
|
154
|
+
function Es(i, m) {
|
|
155
|
+
return i.map((f) => [f.id, ...m.map((x) => f[x])].map((x) => String(x ?? "")).join("")).join("");
|
|
155
156
|
}
|
|
156
|
-
function
|
|
157
|
+
function As(i) {
|
|
157
158
|
const m = Object.keys(i).filter((x) => i[x].kind === "error");
|
|
158
159
|
if (m.length === 0) return i;
|
|
159
|
-
const
|
|
160
|
-
for (const x of m) delete
|
|
161
|
-
return
|
|
160
|
+
const f = { ...i };
|
|
161
|
+
for (const x of m) delete f[x];
|
|
162
|
+
return f;
|
|
162
163
|
}
|
|
163
|
-
function
|
|
164
|
+
function Ks(i, m, f) {
|
|
164
165
|
const x = Number(i[m]);
|
|
165
166
|
if (!Number.isFinite(x) || x <= 0) return !1;
|
|
166
|
-
const _ =
|
|
167
|
+
const _ = f.find((w) => w in i);
|
|
167
168
|
if (!_) return !1;
|
|
168
|
-
const
|
|
169
|
-
return
|
|
169
|
+
const a = i[_];
|
|
170
|
+
return a == null || a === "" || Number(a) === 0;
|
|
170
171
|
}
|
|
171
|
-
function
|
|
172
|
+
function pa({
|
|
172
173
|
relatedCollection: i,
|
|
173
174
|
manyField: m,
|
|
174
|
-
parentId:
|
|
175
|
+
parentId: f,
|
|
175
176
|
parentCollection: x,
|
|
176
177
|
field: _,
|
|
177
|
-
config:
|
|
178
|
+
config: a,
|
|
178
179
|
readOnly: w = !1
|
|
179
180
|
}) {
|
|
180
|
-
var
|
|
181
|
-
const k =
|
|
181
|
+
var Un, Bn, Dn, Hn, Yn, Zn, Gn, Xn;
|
|
182
|
+
const k = mt(), F = Hr(), N = _s(), R = Xr(), H = es(), M = a.editable_fields ?? [], me = a.catalog_locked_fields ?? [], { isAdmin: fe } = nr(), P = f === "new", be = x && !P ? `?parent_collection=${encodeURIComponent(x)}&parent_id=${encodeURIComponent(f)}` : "", I = a.qty_field ?? "quantity", [he, ge] = D(/* @__PURE__ */ new Set()), ke = qe(!1), [U, je] = D(""), [pe, re] = D({}), [ee, Z] = D(/* @__PURE__ */ new Set()), [B, se] = D({}), [ie, ve] = D({}), { data: xe = [], isPending: T } = Q({
|
|
182
183
|
queryKey: ["collection-relations", i],
|
|
183
|
-
queryFn: () => k.request(
|
|
184
|
+
queryFn: () => k.request(K(`/collections/${i}`)).then((e) => {
|
|
184
185
|
var t;
|
|
185
186
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
186
187
|
}),
|
|
187
188
|
staleTime: 10 * 6e4
|
|
188
|
-
}),
|
|
189
|
+
}), y = E(
|
|
189
190
|
() => {
|
|
190
191
|
var e;
|
|
191
|
-
return ((e =
|
|
192
|
-
(t) => t.many_collection === i && t.many_field ===
|
|
192
|
+
return ((e = xe.find(
|
|
193
|
+
(t) => t.many_collection === i && t.many_field === a.item_field && !t.junction_field
|
|
193
194
|
)) == null ? void 0 : e.one_collection) ?? null;
|
|
194
195
|
},
|
|
195
|
-
[
|
|
196
|
-
), { data:
|
|
196
|
+
[xe, i, a.item_field]
|
|
197
|
+
), { data: v = [] } = Q({
|
|
197
198
|
queryKey: ["field-config", i, null],
|
|
198
|
-
queryFn: () => k.request(
|
|
199
|
+
queryFn: () => k.request(K(`/field-config/${i}`)).then((e) => e.data ?? []),
|
|
199
200
|
staleTime: 6e4
|
|
200
|
-
}),
|
|
201
|
+
}), L = ((Un = v.find((e) => e.field === I)) == null ? void 0 : Un.type) ?? null, O = (e, t, n) => {
|
|
201
202
|
var r;
|
|
202
|
-
return ((r =
|
|
203
|
-
|
|
203
|
+
return ((r = Ns(
|
|
204
|
+
v.filter((l) => l.field === e).map((l) => ({
|
|
204
205
|
field: l.field,
|
|
205
|
-
label: l.label ||
|
|
206
|
+
label: l.label || X(l.field),
|
|
206
207
|
type: l.type,
|
|
207
208
|
validation_rules: l.validation_rules
|
|
208
209
|
})),
|
|
209
210
|
{ [e]: t },
|
|
210
211
|
{ ...n, [e]: t }
|
|
211
212
|
)[0]) == null ? void 0 : r.message) ?? null;
|
|
212
|
-
}, { data:
|
|
213
|
-
queryKey: ["col-meta",
|
|
214
|
-
queryFn: () => k.request(
|
|
215
|
-
enabled: !!
|
|
213
|
+
}, { data: $ } = Q({
|
|
214
|
+
queryKey: ["col-meta", y],
|
|
215
|
+
queryFn: () => k.request(K(`/collections/${y}`)).then((e) => e.data),
|
|
216
|
+
enabled: !!y,
|
|
216
217
|
staleTime: 3e5
|
|
217
|
-
}),
|
|
218
|
-
const e =
|
|
219
|
-
return ((
|
|
220
|
-
(t) => t.one_collection ===
|
|
218
|
+
}), A = $ == null ? void 0 : $.display_template, C = E(() => {
|
|
219
|
+
const e = a.section_by.split(".")[0];
|
|
220
|
+
return (($ == null ? void 0 : $.relations) ?? []).find(
|
|
221
|
+
(t) => t.one_collection === y && t.one_field === e && !!t.junction_field
|
|
221
222
|
) ?? null;
|
|
222
|
-
}, [
|
|
223
|
-
queryKey: ["collection-relations",
|
|
224
|
-
queryFn: () => k.request(
|
|
223
|
+
}, [$, y, a.section_by]), te = (C == null ? void 0 : C.many_collection) ?? null, { data: Ce = [] } = Q({
|
|
224
|
+
queryKey: ["collection-relations", te],
|
|
225
|
+
queryFn: () => k.request(K(`/collections/${te}`)).then((e) => {
|
|
225
226
|
var t;
|
|
226
227
|
return ((t = e.data) == null ? void 0 : t.relations) ?? [];
|
|
227
228
|
}),
|
|
228
|
-
enabled: !!
|
|
229
|
+
enabled: !!te,
|
|
229
230
|
staleTime: 10 * 6e4
|
|
230
|
-
}), d =
|
|
231
|
-
if (!(
|
|
232
|
-
const e = String(
|
|
233
|
-
(r) => r.many_collection ===
|
|
234
|
-
), n =
|
|
231
|
+
}), d = E(() => {
|
|
232
|
+
if (!(C != null && C.many_field) || !te) return null;
|
|
233
|
+
const e = String(C.junction_field), t = Ce.find(
|
|
234
|
+
(r) => r.many_collection === te && r.many_field === e
|
|
235
|
+
), n = Ss(t);
|
|
235
236
|
return n ? {
|
|
236
|
-
junction:
|
|
237
|
-
fkToItem:
|
|
237
|
+
junction: te,
|
|
238
|
+
fkToItem: C.many_field,
|
|
238
239
|
fkToSection: e,
|
|
239
240
|
target: n,
|
|
240
|
-
labelPath:
|
|
241
|
+
labelPath: a.section_by.split(".").slice(1).join(".") || "id"
|
|
241
242
|
} : null;
|
|
242
|
-
}, [
|
|
243
|
+
}, [C, te, Ce, a.section_by]), S = R == null ? void 0 : R.draft, { resolvedFilter: G, resolvedSectionFilter: le, resolvedLinkFilter: Y, missingParents: ae } = E(() => {
|
|
243
244
|
const e = [], t = (o) => {
|
|
244
245
|
if (typeof o == "string" && o.startsWith("$parent.")) {
|
|
245
|
-
const
|
|
246
|
-
return c == null || c === "" ? (e.push(
|
|
246
|
+
const p = o.slice(8), c = S == null ? void 0 : S[p];
|
|
247
|
+
return c == null || c === "" ? (e.push(p), o) : c;
|
|
247
248
|
}
|
|
248
|
-
return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([
|
|
249
|
-
}, n =
|
|
249
|
+
return Array.isArray(o) ? o.map(t) : o && typeof o == "object" ? Object.fromEntries(Object.entries(o).map(([p, c]) => [p, t(c)])) : o;
|
|
250
|
+
}, n = a.filter ? t(a.filter) : void 0, r = a.section_filter ? t(a.section_filter) : void 0, l = a.link_filter ? t(a.link_filter) : void 0;
|
|
250
251
|
return {
|
|
251
252
|
resolvedFilter: n,
|
|
252
253
|
resolvedSectionFilter: r,
|
|
253
254
|
resolvedLinkFilter: l,
|
|
254
255
|
missingParents: [...new Set(e)]
|
|
255
256
|
};
|
|
256
|
-
}, [
|
|
257
|
-
if (!
|
|
257
|
+
}, [a.filter, a.section_filter, a.link_filter, S]), ne = E(() => {
|
|
258
|
+
if (!C || !le && !Y) return G;
|
|
258
259
|
const e = {
|
|
259
|
-
...
|
|
260
|
-
...
|
|
261
|
-
}, t = { [
|
|
262
|
-
return
|
|
263
|
-
}, [
|
|
260
|
+
...le ?? {},
|
|
261
|
+
...Y ? { _link: Y } : {}
|
|
262
|
+
}, t = { [C.one_field]: { _some: e } };
|
|
263
|
+
return G ? { _and: [G, t] } : t;
|
|
264
|
+
}, [C, le, Y, G]), z = E(() => {
|
|
264
265
|
const e = /* @__PURE__ */ new Set(["id"]);
|
|
265
|
-
|
|
266
|
-
for (const t of [...(
|
|
267
|
-
for (const t of Object.values(
|
|
268
|
-
for (const t of
|
|
266
|
+
$ && !C && e.add(a.section_by);
|
|
267
|
+
for (const t of [...(A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)]) e.add(t[1]);
|
|
268
|
+
for (const t of Object.values(a.copy_fields ?? {})) e.add(t);
|
|
269
|
+
for (const t of a.columns ?? []) e.add(t.field);
|
|
269
270
|
return [...e].join(",");
|
|
270
|
-
}, [
|
|
271
|
+
}, [A, $, C, a.section_by, a.copy_fields, a.columns]), Je = JSON.stringify(ne ?? null), { data: oe = [], isLoading: bn } = Q(
|
|
271
272
|
{
|
|
272
|
-
queryKey: ["catalog-picker",
|
|
273
|
+
queryKey: ["catalog-picker", y, z, Je],
|
|
273
274
|
queryFn: () => k.request(
|
|
274
|
-
|
|
275
|
-
limit:
|
|
276
|
-
fields:
|
|
277
|
-
...
|
|
275
|
+
K(`/items/${y}`, {
|
|
276
|
+
limit: Fs,
|
|
277
|
+
fields: z,
|
|
278
|
+
...ne ? { filter: JSON.stringify(ne) } : {}
|
|
278
279
|
})
|
|
279
280
|
).then((e) => e.data ?? []),
|
|
280
281
|
// Wait for the catalog meta: a to-many section path both narrows this
|
|
281
282
|
// read and must stay out of its `fields=`.
|
|
282
|
-
enabled: !!
|
|
283
|
+
enabled: !!y && !!$ && ae.length === 0 && (!C || !!d),
|
|
283
284
|
staleTime: 6e4
|
|
284
285
|
}
|
|
285
|
-
),
|
|
286
|
-
queryKey: ["catalog-sections", d == null ? void 0 : d.target, d == null ? void 0 : d.labelPath,
|
|
286
|
+
), fr = JSON.stringify(le ?? null), { data: ft = [], isLoading: hr } = Q({
|
|
287
|
+
queryKey: ["catalog-sections", d == null ? void 0 : d.target, d == null ? void 0 : d.labelPath, fr],
|
|
287
288
|
queryFn: async () => {
|
|
288
289
|
const e = d;
|
|
289
|
-
return (await
|
|
290
|
+
return (await Ct(k, `/items/${e.target}`, {
|
|
290
291
|
fields: `id,${e.labelPath}`,
|
|
291
|
-
...
|
|
292
|
+
...le ? { filter: JSON.stringify(le) } : {}
|
|
292
293
|
})).map((n) => ({
|
|
293
294
|
id: String(n.id),
|
|
294
|
-
name: String(
|
|
295
|
+
name: String(ur(n, e.labelPath) ?? "").trim()
|
|
295
296
|
}));
|
|
296
297
|
},
|
|
297
|
-
enabled: !!d &&
|
|
298
|
+
enabled: !!d && ae.length === 0,
|
|
298
299
|
staleTime: 6e4
|
|
299
|
-
}),
|
|
300
|
+
}), Ze = E(() => ft.map((e) => e.id), [ft]), { data: xn = [], isLoading: pr } = Q({
|
|
300
301
|
queryKey: [
|
|
301
302
|
"catalog-section-links",
|
|
302
303
|
d == null ? void 0 : d.junction,
|
|
303
|
-
|
|
304
|
-
JSON.stringify(
|
|
304
|
+
Ze.join(","),
|
|
305
|
+
JSON.stringify(Y ?? null)
|
|
305
306
|
],
|
|
306
307
|
queryFn: async () => {
|
|
307
308
|
const e = d, t = [];
|
|
308
|
-
for (let n = 0; n <
|
|
309
|
-
const r =
|
|
309
|
+
for (let n = 0; n < Ze.length; n += 200) {
|
|
310
|
+
const r = Ze.slice(n, n + 200), l = await Ct(k, `/items/${e.junction}`, {
|
|
310
311
|
fields: `${e.fkToItem},${e.fkToSection}`,
|
|
311
312
|
filter: JSON.stringify(
|
|
312
|
-
|
|
313
|
+
Y ? { _and: [{ [e.fkToSection]: { _in: r } }, Y] } : { [e.fkToSection]: { _in: r } }
|
|
313
314
|
)
|
|
314
315
|
});
|
|
315
316
|
for (const o of l)
|
|
@@ -317,10 +318,10 @@ function da({
|
|
|
317
318
|
}
|
|
318
319
|
return t;
|
|
319
320
|
},
|
|
320
|
-
enabled: !!d &&
|
|
321
|
+
enabled: !!d && Ze.length > 0,
|
|
321
322
|
staleTime: 6e4
|
|
322
|
-
}), yn =
|
|
323
|
-
const e = new Map(
|
|
323
|
+
}), yn = E(() => {
|
|
324
|
+
const e = new Map(ft.map((n) => [n.id, n.name])), t = /* @__PURE__ */ new Map();
|
|
324
325
|
for (const n of xn) {
|
|
325
326
|
const r = e.get(n.section);
|
|
326
327
|
if (!r) continue;
|
|
@@ -328,103 +329,103 @@ function da({
|
|
|
328
329
|
l.includes(r) || l.push(r), t.set(n.item, l);
|
|
329
330
|
}
|
|
330
331
|
return t;
|
|
331
|
-
}, [
|
|
332
|
+
}, [ft, xn]), ht = !!C && (!d || hr || Ze.length > 0 && pr), pt = E(() => {
|
|
332
333
|
const e = /* @__PURE__ */ new Map();
|
|
333
|
-
for (const t of
|
|
334
|
+
for (const t of oe) e.set(String(t.id), t);
|
|
334
335
|
return e;
|
|
335
|
-
}, [
|
|
336
|
-
queryKey: ["o2m-rows", i, m,
|
|
336
|
+
}, [oe]), { data: we = [] } = Q({
|
|
337
|
+
queryKey: ["o2m-rows", i, m, f],
|
|
337
338
|
queryFn: () => k.request(
|
|
338
|
-
|
|
339
|
-
filter: JSON.stringify({ [m]: { _eq:
|
|
339
|
+
K(`/items/${i}`, {
|
|
340
|
+
filter: JSON.stringify({ [m]: { _eq: f } }),
|
|
340
341
|
limit: 1e3
|
|
341
342
|
})
|
|
342
343
|
).then((e) => e.data ?? []),
|
|
343
344
|
enabled: !P,
|
|
344
345
|
staleTime: 15e3
|
|
345
|
-
}),
|
|
346
|
-
() =>
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
...
|
|
350
|
-
...Object.keys(
|
|
346
|
+
}), Jt = E(
|
|
347
|
+
() => Es(we, [
|
|
348
|
+
a.item_field,
|
|
349
|
+
I,
|
|
350
|
+
...M,
|
|
351
|
+
...Object.keys(a.compute_fields ?? {})
|
|
351
352
|
]),
|
|
352
|
-
[
|
|
353
|
-
), gn =
|
|
354
|
-
|
|
353
|
+
[we, a.item_field, I, M, a.compute_fields]
|
|
354
|
+
), gn = qe(null), It = qe(B);
|
|
355
|
+
It.current = B, $e(() => {
|
|
355
356
|
const e = gn.current;
|
|
356
|
-
if (gn.current =
|
|
357
|
-
const t = Object.keys(
|
|
358
|
-
(n) =>
|
|
357
|
+
if (gn.current = Jt, e === null || e === Jt) return;
|
|
358
|
+
const t = Object.keys(It.current).filter(
|
|
359
|
+
(n) => It.current[n].kind === "error"
|
|
359
360
|
);
|
|
360
|
-
|
|
361
|
+
se((n) => As(n)), ve((n) => Object.keys(n).length === 0 ? n : {}), t.length > 0 && re((n) => {
|
|
361
362
|
if (!t.some((l) => l in n)) return n;
|
|
362
363
|
const r = { ...n };
|
|
363
364
|
for (const l of t) delete r[l];
|
|
364
365
|
return r;
|
|
365
366
|
});
|
|
366
|
-
}, [
|
|
367
|
-
const
|
|
368
|
-
() =>
|
|
369
|
-
const t =
|
|
367
|
+
}, [Jt]);
|
|
368
|
+
const Ge = !P && !!N, Fe = N ? N.getPendingRows(i, m) : [], bt = Ge ? N.getPendingEdits(i, m) : /* @__PURE__ */ new Map(), br = JSON.stringify([...bt.entries()]), xt = E(
|
|
369
|
+
() => bt.size === 0 ? we : we.map((e) => {
|
|
370
|
+
const t = bt.get(String(e.id));
|
|
370
371
|
return t ? { ...e, ...t } : e;
|
|
371
372
|
}),
|
|
372
|
-
[
|
|
373
|
-
),
|
|
373
|
+
[we, br]
|
|
374
|
+
), yt = !P && N ? N.getPendingDeletes(i, m) : /* @__PURE__ */ new Set(), Xe = E(() => {
|
|
374
375
|
const e = /* @__PURE__ */ new Map();
|
|
375
|
-
for (const t of
|
|
376
|
-
const n = t[
|
|
376
|
+
for (const t of xt) {
|
|
377
|
+
const n = t[a.item_field];
|
|
377
378
|
n != null && e.set(String(n), t);
|
|
378
379
|
}
|
|
379
380
|
return e;
|
|
380
|
-
}, [
|
|
381
|
+
}, [xt, a.item_field]), gt = E(() => {
|
|
381
382
|
const e = /* @__PURE__ */ new Map();
|
|
382
|
-
return
|
|
383
|
-
const r = t[
|
|
383
|
+
return Fe.forEach((t, n) => {
|
|
384
|
+
const r = t[a.item_field];
|
|
384
385
|
r != null && e.set(String(r), n);
|
|
385
386
|
}), e;
|
|
386
|
-
}, [
|
|
387
|
-
const e =
|
|
387
|
+
}, [Fe, a.item_field]), Se = E(() => {
|
|
388
|
+
const e = Fe.filter((r) => r[a.item_field] != null).map((r) => ({ key: String(r[a.item_field]), row: r }));
|
|
388
389
|
if (P) return e;
|
|
389
|
-
const t =
|
|
390
|
+
const t = xt.filter((r) => r[a.item_field] != null).map((r) => ({ key: String(r[a.item_field]), row: r })), n = new Set(t.map((r) => r.key));
|
|
390
391
|
return [...t, ...e.filter((r) => !n.has(r.key))];
|
|
391
|
-
}, [P,
|
|
392
|
-
() =>
|
|
393
|
-
[
|
|
394
|
-
), { data:
|
|
395
|
-
queryKey: ["catalog-picker-labels",
|
|
392
|
+
}, [P, Fe, xt, a.item_field]), kt = E(
|
|
393
|
+
() => Se.filter((e) => !pt.has(e.key)).map((e) => e.key),
|
|
394
|
+
[Se, pt]
|
|
395
|
+
), { data: Qt = [] } = Q({
|
|
396
|
+
queryKey: ["catalog-picker-labels", y, z, kt.join(",")],
|
|
396
397
|
queryFn: () => k.request(
|
|
397
|
-
|
|
398
|
-
filter: JSON.stringify({ id: { _in:
|
|
399
|
-
fields:
|
|
400
|
-
limit:
|
|
398
|
+
K(`/items/${y}`, {
|
|
399
|
+
filter: JSON.stringify({ id: { _in: kt } }),
|
|
400
|
+
fields: z,
|
|
401
|
+
limit: kt.length
|
|
401
402
|
})
|
|
402
403
|
).then((e) => e.data ?? []),
|
|
403
|
-
enabled: !!
|
|
404
|
+
enabled: !!y && kt.length > 0,
|
|
404
405
|
staleTime: 6e4
|
|
405
|
-
}), { data:
|
|
406
|
-
queryKey: ["pinned-items",
|
|
407
|
-
queryFn: () => k.request(
|
|
408
|
-
enabled: !!
|
|
406
|
+
}), { data: Re = [] } = Q({
|
|
407
|
+
queryKey: ["pinned-items", y],
|
|
408
|
+
queryFn: () => k.request(K(`/pinned/${y}`)).then((e) => e.data ?? []),
|
|
409
|
+
enabled: !!y && !!a.favorites,
|
|
409
410
|
staleTime: 6e4
|
|
410
|
-
}), zt =
|
|
411
|
-
queryKey: ["pinned-item-rows",
|
|
411
|
+
}), zt = E(() => new Set(Re), [Re]), { data: et = [] } = Q({
|
|
412
|
+
queryKey: ["pinned-item-rows", y, z, Re.join(",")],
|
|
412
413
|
queryFn: () => k.request(
|
|
413
|
-
|
|
414
|
-
filter: JSON.stringify({ id: { _in:
|
|
415
|
-
fields:
|
|
416
|
-
limit:
|
|
414
|
+
K(`/items/${y}`, {
|
|
415
|
+
filter: JSON.stringify({ id: { _in: Re } }),
|
|
416
|
+
fields: z,
|
|
417
|
+
limit: Re.length
|
|
417
418
|
})
|
|
418
419
|
).then((e) => e.data ?? []),
|
|
419
|
-
enabled: !!
|
|
420
|
+
enabled: !!y && !!a.favorites && Re.length > 0,
|
|
420
421
|
staleTime: 6e4
|
|
421
|
-
}), [
|
|
422
|
+
}), [wt, kn] = D(/* @__PURE__ */ new Set());
|
|
422
423
|
async function wn(e) {
|
|
423
|
-
if (!(!
|
|
424
|
+
if (!(!y || wt.has(e))) {
|
|
424
425
|
kn((t) => new Set(t).add(e));
|
|
425
426
|
try {
|
|
426
|
-
await k.request(sr(`/pinned/${
|
|
427
|
-
}), await
|
|
427
|
+
await k.request(sr(`/pinned/${y}/${e}/toggle`)).catch(() => {
|
|
428
|
+
}), await F.invalidateQueries({ queryKey: ["pinned-items", y] });
|
|
428
429
|
} finally {
|
|
429
430
|
kn((t) => {
|
|
430
431
|
const n = new Set(t);
|
|
@@ -433,221 +434,221 @@ function da({
|
|
|
433
434
|
}
|
|
434
435
|
}
|
|
435
436
|
}
|
|
436
|
-
const [
|
|
437
|
+
const [xr, Nn] = D(!1), vn = qe(null), Mt = (e) => a.favorites ? /* @__PURE__ */ s(
|
|
437
438
|
"button",
|
|
438
439
|
{
|
|
439
440
|
type: "button",
|
|
440
441
|
title: zt.has(e) ? "Remove from favorites" : "Add to favorites",
|
|
441
|
-
disabled:
|
|
442
|
+
disabled: wt.has(e),
|
|
442
443
|
onClick: (t) => {
|
|
443
444
|
t.stopPropagation(), wn(e);
|
|
444
445
|
},
|
|
445
446
|
className: "shrink-0 rounded p-0.5 transition-colors",
|
|
446
|
-
children:
|
|
447
|
-
|
|
447
|
+
children: wt.has(e) ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
|
|
448
|
+
ct,
|
|
448
449
|
{
|
|
449
|
-
className:
|
|
450
|
+
className: W(
|
|
450
451
|
"h-3.5 w-3.5",
|
|
451
452
|
zt.has(e) ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
452
453
|
)
|
|
453
454
|
}
|
|
454
455
|
)
|
|
455
456
|
}
|
|
456
|
-
) : null, [
|
|
457
|
-
|
|
458
|
-
const e = setTimeout(() =>
|
|
457
|
+
) : null, [ye, yr] = D("");
|
|
458
|
+
$e(() => {
|
|
459
|
+
const e = setTimeout(() => yr(U), 300);
|
|
459
460
|
return () => clearTimeout(e);
|
|
460
|
-
}, [
|
|
461
|
-
const Sn =
|
|
461
|
+
}, [U]);
|
|
462
|
+
const Sn = E(() => {
|
|
462
463
|
var t;
|
|
463
|
-
const e = (t = [...(
|
|
464
|
+
const e = (t = [...(A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : t[1];
|
|
464
465
|
return e && !e.includes(".") ? e : "id";
|
|
465
|
-
}, [
|
|
466
|
+
}, [A]), { shownSearchFields: Ie, otherSearchFields: _n } = E(() => {
|
|
466
467
|
const e = new Set(
|
|
467
|
-
((
|
|
468
|
+
(($ == null ? void 0 : $.relations) ?? []).filter((r) => r.one_collection === y && r.one_field).map((r) => r.one_field)
|
|
468
469
|
), t = new Set(
|
|
469
|
-
((
|
|
470
|
+
(($ == null ? void 0 : $.fields) ?? []).filter((r) => (r.type === "string" || r.type === "text") && !e.has(r.field)).map((r) => r.field)
|
|
470
471
|
), n = /* @__PURE__ */ new Set();
|
|
471
|
-
for (const r of (
|
|
472
|
-
for (const r of
|
|
472
|
+
for (const r of (A ?? "").matchAll(/\{\{([\w.]+)\}\}/g)) t.has(r[1]) && n.add(r[1]);
|
|
473
|
+
for (const r of a.columns ?? []) t.has(r.field) && n.add(r.field);
|
|
473
474
|
return {
|
|
474
475
|
shownSearchFields: [...n],
|
|
475
476
|
otherSearchFields: [...t].filter((r) => !n.has(r))
|
|
476
477
|
};
|
|
477
|
-
}, [
|
|
478
|
-
const e =
|
|
478
|
+
}, [$, y, A, a.columns]), tt = E(() => {
|
|
479
|
+
const e = a.related_columns ?? [], t = e.findIndex((n) => n.stock === !0);
|
|
479
480
|
return t !== -1 ? t : e.findIndex((n) => n.key === "on_hand" && n.stock !== !1);
|
|
480
|
-
}, [
|
|
481
|
-
for (const e of Object.values((
|
|
481
|
+
}, [a.related_columns]), de = tt === -1 ? null : (a.related_columns ?? [])[tt] ?? null, Pe = de ? Ye(de.match, S) : null, Qe = E(() => {
|
|
482
|
+
for (const e of Object.values((de == null ? void 0 : de.match) ?? {}))
|
|
482
483
|
if (typeof e == "string" && e.startsWith("$parent.")) return e.slice(8);
|
|
483
484
|
return null;
|
|
484
|
-
}, [
|
|
485
|
-
|
|
486
|
-
if (
|
|
485
|
+
}, [de]), qn = Qe ? S == null ? void 0 : S[Qe] : null, gr = Qe ? ((Bn = R == null ? void 0 : R.fieldLabels) == null ? void 0 : Bn[Qe]) ?? X(Qe) : null, Me = y ? `nvr:catalog-in-stock:${y}:${i}.${m}` : null, [$n, jn] = D(!1);
|
|
486
|
+
$e(() => {
|
|
487
|
+
if (Me)
|
|
487
488
|
try {
|
|
488
|
-
jn(localStorage.getItem(
|
|
489
|
+
jn(localStorage.getItem(Me) === "1");
|
|
489
490
|
} catch {
|
|
490
491
|
}
|
|
491
|
-
}, [
|
|
492
|
+
}, [Me]);
|
|
492
493
|
const Vt = (e) => {
|
|
493
|
-
if (jn(e), !!
|
|
494
|
+
if (jn(e), !!Me)
|
|
494
495
|
try {
|
|
495
|
-
e ? localStorage.setItem(
|
|
496
|
+
e ? localStorage.setItem(Me, "1") : localStorage.removeItem(Me);
|
|
496
497
|
} catch {
|
|
497
498
|
}
|
|
498
|
-
},
|
|
499
|
-
if (!
|
|
500
|
-
const e = ((
|
|
501
|
-
(t) => t.many_collection ===
|
|
499
|
+
}, ce = !!de && $n && Pe !== null, Wt = E(() => {
|
|
500
|
+
if (!de) return null;
|
|
501
|
+
const e = (($ == null ? void 0 : $.relations) ?? []).find(
|
|
502
|
+
(t) => t.many_collection === de.collection && t.many_field === de.item_field && t.one_collection === y && !!t.one_field && !t.junction_field
|
|
502
503
|
);
|
|
503
504
|
return (e == null ? void 0 : e.one_field) ?? null;
|
|
504
|
-
}, [
|
|
505
|
-
() =>
|
|
506
|
-
[
|
|
507
|
-
),
|
|
505
|
+
}, [de, $, y]), Ut = E(
|
|
506
|
+
() => ce && Wt && de && Pe ? { [Wt]: { _some: { ...Pe, [de.value_field]: { _gt: 0 } } } } : null,
|
|
507
|
+
[ce, Wt, de, Pe]
|
|
508
|
+
), Bt = JSON.stringify(Ut), Nt = ce && !Ut ? 100 : 25, Dt = (e, t) => {
|
|
508
509
|
const n = [t, Ut].filter(Boolean);
|
|
509
510
|
return n.length === 0 ? e : { ...e, filter: JSON.stringify(n.length === 1 ? n[0] : { _and: n }) };
|
|
510
|
-
},
|
|
511
|
-
(e) =>
|
|
512
|
-
),
|
|
513
|
-
(e) =>
|
|
514
|
-
), { data:
|
|
511
|
+
}, Ht = nr().userId, vt = a.recent === !1 ? 0 : typeof a.recent == "object" && Number((Dn = a.recent) == null ? void 0 : Dn.days) || 30, Yt = ["user_created", "created_by", "creator"].find(
|
|
512
|
+
(e) => v.some((t) => t.field === e)
|
|
513
|
+
), nt = ["date_created", "created_at"].find(
|
|
514
|
+
(e) => v.some((t) => t.field === e)
|
|
515
|
+
), { data: rt = [] } = Q({
|
|
515
516
|
queryKey: [
|
|
516
517
|
"catalog-recent-picks",
|
|
517
518
|
i,
|
|
518
|
-
|
|
519
|
-
Dt,
|
|
519
|
+
a.item_field,
|
|
520
520
|
Ht,
|
|
521
|
-
|
|
522
|
-
|
|
521
|
+
Yt,
|
|
522
|
+
nt,
|
|
523
|
+
vt
|
|
523
524
|
],
|
|
524
525
|
queryFn: async () => {
|
|
525
|
-
const e = new Date(Date.now() -
|
|
526
|
-
|
|
526
|
+
const e = new Date(Date.now() - vt * 864e5).toISOString(), t = { [Yt]: { _eq: Ht } };
|
|
527
|
+
nt && (t[nt] = { _gte: e });
|
|
527
528
|
const n = await k.request(
|
|
528
|
-
|
|
529
|
-
fields:
|
|
529
|
+
K(`/items/${i}`, {
|
|
530
|
+
fields: a.item_field,
|
|
530
531
|
filter: JSON.stringify(t),
|
|
531
532
|
limit: 500,
|
|
532
533
|
count: "false",
|
|
533
|
-
...
|
|
534
|
+
...nt ? { sort: `-${nt}` } : {}
|
|
534
535
|
})
|
|
535
536
|
).then((l) => l.data ?? []).catch(() => []), r = [];
|
|
536
537
|
for (const l of n) {
|
|
537
|
-
const o = l[
|
|
538
|
-
if (
|
|
538
|
+
const o = l[a.item_field], p = o != null && typeof o == "object" ? o.id : o;
|
|
539
|
+
if (p != null && p !== "" && !r.includes(String(p)) && r.push(String(p)), r.length >= 150) break;
|
|
539
540
|
}
|
|
540
541
|
return r;
|
|
541
542
|
},
|
|
542
|
-
enabled:
|
|
543
|
+
enabled: vt > 0 && !!Ht && !!Yt && !w,
|
|
543
544
|
staleTime: 5 * 6e4
|
|
544
|
-
}),
|
|
545
|
+
}), kr = E(() => new Set(rt), [rt]), Zt = !!y && ye.trim().length > 0, { data: Gt = [], isFetching: wr } = Q({
|
|
545
546
|
queryKey: [
|
|
546
547
|
"catalog-shown-search",
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
548
|
+
y,
|
|
549
|
+
z,
|
|
550
|
+
ye,
|
|
551
|
+
Ie,
|
|
552
|
+
Bt,
|
|
553
|
+
Nt
|
|
553
554
|
],
|
|
554
555
|
queryFn: () => k.request(
|
|
555
|
-
|
|
556
|
-
`/items/${
|
|
557
|
-
|
|
558
|
-
search:
|
|
559
|
-
search_fields:
|
|
556
|
+
K(
|
|
557
|
+
`/items/${y}`,
|
|
558
|
+
Dt({
|
|
559
|
+
search: ye,
|
|
560
|
+
search_fields: Ie.join(","),
|
|
560
561
|
search_rank: "1",
|
|
561
|
-
fields:
|
|
562
|
-
limit:
|
|
562
|
+
fields: z,
|
|
563
|
+
limit: Nt,
|
|
563
564
|
sort: Sn
|
|
564
565
|
})
|
|
565
566
|
)
|
|
566
567
|
).then((e) => e.data ?? []),
|
|
567
|
-
enabled:
|
|
568
|
+
enabled: Zt && Ie.length > 0,
|
|
568
569
|
staleTime: 3e4,
|
|
569
570
|
placeholderData: (e) => e
|
|
570
|
-
}),
|
|
571
|
+
}), St = _n.join(","), { data: Fn = [], isFetching: Nr } = Q({
|
|
571
572
|
queryKey: [
|
|
572
573
|
"catalog-full-search",
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
574
|
+
y,
|
|
575
|
+
z,
|
|
576
|
+
ye,
|
|
577
|
+
St,
|
|
578
|
+
Bt,
|
|
579
|
+
Nt
|
|
579
580
|
],
|
|
580
581
|
queryFn: () => k.request(
|
|
581
|
-
|
|
582
|
-
`/items/${
|
|
583
|
-
|
|
584
|
-
search:
|
|
585
|
-
fields: [
|
|
586
|
-
limit:
|
|
582
|
+
K(
|
|
583
|
+
`/items/${y}`,
|
|
584
|
+
Dt({
|
|
585
|
+
search: ye,
|
|
586
|
+
fields: [z, St].filter(Boolean).join(","),
|
|
587
|
+
limit: Nt,
|
|
587
588
|
sort: Sn
|
|
588
589
|
})
|
|
589
590
|
)
|
|
590
591
|
).then((e) => e.data ?? []),
|
|
591
|
-
enabled:
|
|
592
|
+
enabled: Zt,
|
|
592
593
|
staleTime: 3e4,
|
|
593
594
|
placeholderData: (e) => e
|
|
594
|
-
}),
|
|
595
|
+
}), vr = rt.join(","), { data: Tn = [] } = Q({
|
|
595
596
|
queryKey: [
|
|
596
597
|
"catalog-recent-search",
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
598
|
+
y,
|
|
599
|
+
z,
|
|
600
|
+
ye,
|
|
601
|
+
St,
|
|
602
|
+
vr,
|
|
603
|
+
Bt
|
|
603
604
|
],
|
|
604
605
|
queryFn: () => k.request(
|
|
605
|
-
|
|
606
|
-
`/items/${
|
|
607
|
-
|
|
606
|
+
K(
|
|
607
|
+
`/items/${y}`,
|
|
608
|
+
Dt(
|
|
608
609
|
{
|
|
609
|
-
search:
|
|
610
|
-
fields: [
|
|
610
|
+
search: ye,
|
|
611
|
+
fields: [z, St].filter(Boolean).join(","),
|
|
611
612
|
limit: 10,
|
|
612
613
|
count: "false"
|
|
613
614
|
},
|
|
614
|
-
{ id: { _in:
|
|
615
|
+
{ id: { _in: rt } }
|
|
615
616
|
)
|
|
616
617
|
)
|
|
617
618
|
).then((e) => e.data ?? []).catch(() => []),
|
|
618
|
-
enabled:
|
|
619
|
+
enabled: Zt && rt.length > 0,
|
|
619
620
|
staleTime: 3e4,
|
|
620
621
|
placeholderData: (e) => e
|
|
621
|
-
}),
|
|
622
|
-
() =>
|
|
623
|
-
shown:
|
|
622
|
+
}), Xt = wr || Nr, Ve = E(
|
|
623
|
+
() => ys({
|
|
624
|
+
shown: Gt,
|
|
624
625
|
other: Fn,
|
|
625
|
-
recent:
|
|
626
|
-
shownFields:
|
|
627
|
-
q:
|
|
626
|
+
recent: Tn,
|
|
627
|
+
shownFields: Ie,
|
|
628
|
+
q: ye
|
|
628
629
|
}),
|
|
629
|
-
[
|
|
630
|
-
),
|
|
631
|
-
if (
|
|
632
|
-
const t =
|
|
630
|
+
[Gt, Fn, Tn, Ie, ye]
|
|
631
|
+
), Sr = (e) => {
|
|
632
|
+
if (Ie.length === 0 || Gt.some((n) => String(n.id) === String(e.id)) || gs(e, Ie, ye)) return null;
|
|
633
|
+
const t = ss(ye);
|
|
633
634
|
for (const n of _n) {
|
|
634
635
|
const r = e[n];
|
|
635
636
|
if (r == null || typeof r == "object") continue;
|
|
636
637
|
const l = String(r);
|
|
637
|
-
if (t.some((o) =>
|
|
638
|
-
return `${
|
|
638
|
+
if (t.some((o) => as(l, o)))
|
|
639
|
+
return `${X(n)}: ${l.length > 40 ? `${l.slice(0, 40)}…` : l}`;
|
|
639
640
|
}
|
|
640
641
|
return null;
|
|
641
|
-
}, We =
|
|
642
|
+
}, We = E(() => {
|
|
642
643
|
const e = /* @__PURE__ */ new Set();
|
|
643
|
-
for (const t of
|
|
644
|
-
for (const t of
|
|
645
|
-
for (const t of
|
|
644
|
+
for (const t of oe) e.add(String(t.id));
|
|
645
|
+
for (const t of Se) e.add(t.key);
|
|
646
|
+
for (const t of Re) e.add(t);
|
|
646
647
|
for (const t of Ve) e.add(String(t.id));
|
|
647
648
|
return [...e];
|
|
648
|
-
}, [
|
|
649
|
-
queries: (
|
|
650
|
-
const t =
|
|
649
|
+
}, [oe, Se, Re, Ve]), st = mn({
|
|
650
|
+
queries: (a.related_columns ?? []).map((e) => {
|
|
651
|
+
const t = Ye(e.match, S);
|
|
651
652
|
return {
|
|
652
653
|
queryKey: [
|
|
653
654
|
"catalog-related",
|
|
@@ -661,171 +662,171 @@ function da({
|
|
|
661
662
|
if (e.count_all && e.aggregate === "sum" && x && _) {
|
|
662
663
|
const o = {};
|
|
663
664
|
if (P)
|
|
664
|
-
for (const
|
|
665
|
-
o[
|
|
666
|
-
for (let
|
|
667
|
-
const c = We.slice(
|
|
668
|
-
|
|
665
|
+
for (const p of pn(e.match))
|
|
666
|
+
o[p] = (S == null ? void 0 : S[p]) ?? null;
|
|
667
|
+
for (let p = 0; p < We.length; p += 200) {
|
|
668
|
+
const c = We.slice(p, p + 200), h = await k.request(
|
|
669
|
+
K("/catalog-related/count-all", {
|
|
669
670
|
collection: x,
|
|
670
671
|
field: _,
|
|
671
672
|
key: e.key,
|
|
672
|
-
record: P ? "new" :
|
|
673
|
+
record: P ? "new" : f,
|
|
673
674
|
...P ? { parent: JSON.stringify(o) } : {},
|
|
674
675
|
ids: c.join(",")
|
|
675
676
|
})
|
|
676
677
|
);
|
|
677
|
-
Object.assign(n,
|
|
678
|
+
Object.assign(n, h.data ?? {});
|
|
678
679
|
}
|
|
679
680
|
return n;
|
|
680
681
|
}
|
|
681
682
|
const r = e.aggregate === "sum", l = r ? 150 : 400;
|
|
682
683
|
for (let o = 0; o < We.length; o += l) {
|
|
683
|
-
const
|
|
684
|
+
const p = We.slice(o, o + l);
|
|
684
685
|
let c = 1;
|
|
685
686
|
for (; ; ) {
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
limit: r ? 1e3 :
|
|
687
|
+
const h = await k.request(
|
|
688
|
+
K(`/items/${e.collection}`, {
|
|
689
|
+
limit: r ? 1e3 : p.length,
|
|
689
690
|
...r ? { page: c } : {},
|
|
690
691
|
fields: `${e.item_field},${e.value_field}`,
|
|
691
|
-
filter: JSON.stringify({ ...t, [e.item_field]: { _in:
|
|
692
|
+
filter: JSON.stringify({ ...t, [e.item_field]: { _in: p } })
|
|
692
693
|
})
|
|
693
|
-
).then((
|
|
694
|
-
for (const
|
|
695
|
-
const
|
|
696
|
-
if (
|
|
694
|
+
).then((b) => b.data ?? []);
|
|
695
|
+
for (const b of h) {
|
|
696
|
+
const q = b[e.item_field];
|
|
697
|
+
if (q != null)
|
|
697
698
|
if (r) {
|
|
698
|
-
const
|
|
699
|
-
n[String(
|
|
699
|
+
const j = Number(b[e.value_field]);
|
|
700
|
+
n[String(q)] = (Number(n[String(q)]) || 0) + (Number.isNaN(j) ? 0 : j);
|
|
700
701
|
} else
|
|
701
|
-
n[String(
|
|
702
|
+
n[String(q)] = b[e.value_field];
|
|
702
703
|
}
|
|
703
|
-
if (!r ||
|
|
704
|
+
if (!r || h.length < 1e3) break;
|
|
704
705
|
c += 1;
|
|
705
706
|
}
|
|
706
707
|
}
|
|
707
708
|
return n;
|
|
708
709
|
},
|
|
709
|
-
enabled: !!
|
|
710
|
+
enabled: !!y && t !== null && We.length > 0,
|
|
710
711
|
staleTime: 3e4
|
|
711
712
|
};
|
|
712
713
|
})
|
|
713
|
-
}),
|
|
714
|
+
}), at = (e, t) => {
|
|
714
715
|
var r, l;
|
|
715
|
-
const n = (
|
|
716
|
+
const n = (a.related_columns ?? []).findIndex((o) => o.key === e);
|
|
716
717
|
if (n !== -1)
|
|
717
|
-
return (l = (r =
|
|
718
|
-
},
|
|
719
|
-
if (!
|
|
720
|
-
const t = Number(
|
|
718
|
+
return (l = (r = st[n]) == null ? void 0 : r.data) == null ? void 0 : l[t];
|
|
719
|
+
}, it = tt === -1 || (Hn = st[tt]) == null ? void 0 : Hn.data, _r = ce && !!((Yn = st[tt]) != null && Yn.isFetching), On = (e) => {
|
|
720
|
+
if (!ce || it === void 0) return !0;
|
|
721
|
+
const t = Number(it[e]);
|
|
721
722
|
return Number.isFinite(t) && t > 0;
|
|
722
|
-
},
|
|
723
|
+
}, lt = ce ? Ve.filter((e) => On(String(e.id))) : Ve, en = ce ? et.filter((e) => On(String(e.id))) : et, tn = (e) => {
|
|
723
724
|
var c;
|
|
724
|
-
const t =
|
|
725
|
+
const t = a.qty_warning;
|
|
725
726
|
if (!t) return null;
|
|
726
|
-
const n =
|
|
727
|
+
const n = _e(e) ?? 0;
|
|
727
728
|
if (n <= 0) return null;
|
|
728
|
-
const r = (
|
|
729
|
+
const r = (a.related_columns ?? []).findIndex((h) => h.key === t.column);
|
|
729
730
|
if (r === -1) return null;
|
|
730
|
-
const l = (c =
|
|
731
|
+
const l = (c = st[r]) == null ? void 0 : c.data;
|
|
731
732
|
if (l === void 0) return null;
|
|
732
|
-
const o = l[e],
|
|
733
|
-
return Number.isNaN(
|
|
734
|
-
},
|
|
735
|
-
const t =
|
|
733
|
+
const o = l[e], p = o == null || o === "" ? 0 : Number(o);
|
|
734
|
+
return Number.isNaN(p) ? null : n > p ? { available: p, qty: n } : null;
|
|
735
|
+
}, qr = (e) => {
|
|
736
|
+
const t = a.row_flags ?? [];
|
|
736
737
|
if (t.length === 0) return [];
|
|
737
738
|
const n = [];
|
|
738
739
|
for (const r of t)
|
|
739
740
|
if (!(!(r != null && r.when) || !r.label))
|
|
740
741
|
try {
|
|
741
742
|
const l = r.when.replace(/\{\{\s*([A-Za-z_][A-Za-z0-9_.]*)\s*\}\}/g, "$1");
|
|
742
|
-
|
|
743
|
+
ns(l, e) && n.push(r.label);
|
|
743
744
|
} catch {
|
|
744
745
|
}
|
|
745
746
|
return n;
|
|
746
|
-
},
|
|
747
|
+
}, nn = a.qty_warning ? a.qty_warning.label ?? ((Zn = (a.related_columns ?? []).find((e) => {
|
|
747
748
|
var t;
|
|
748
|
-
return e.key === ((t =
|
|
749
|
-
})) == null ? void 0 : Zn.label) ??
|
|
749
|
+
return e.key === ((t = a.qty_warning) == null ? void 0 : t.column);
|
|
750
|
+
})) == null ? void 0 : Zn.label) ?? X(a.qty_warning.column) : "", $r = !!a.submission_errors, _t = E(
|
|
750
751
|
() => {
|
|
751
752
|
var e;
|
|
752
|
-
return typeof
|
|
753
|
+
return typeof a.submission_errors == "object" && Array.isArray((e = a.submission_errors) == null ? void 0 : e.match_fields) ? a.submission_errors.match_fields.filter((t) => /^[A-Za-z_][A-Za-z0-9_]*$/.test(t)) : [];
|
|
753
754
|
},
|
|
754
|
-
[
|
|
755
|
-
),
|
|
756
|
-
queryKey: ["erp-submissions", x ?? "", String(
|
|
757
|
-
queryFn: () => k.request(
|
|
758
|
-
enabled:
|
|
755
|
+
[a.submission_errors]
|
|
756
|
+
), jr = rs(6e4), { data: Rn } = Q({
|
|
757
|
+
queryKey: ["erp-submissions", x ?? "", String(f)],
|
|
758
|
+
queryFn: () => k.request(K(`/erp-submissions/${x}/${encodeURIComponent(f)}`)).then((e) => e.data ?? []),
|
|
759
|
+
enabled: $r && !P && !!x,
|
|
759
760
|
staleTime: 15e3,
|
|
760
|
-
refetchInterval:
|
|
761
|
-
}),
|
|
761
|
+
refetchInterval: jr
|
|
762
|
+
}), rn = E(() => {
|
|
762
763
|
const e = (Rn ?? [])[0];
|
|
763
|
-
return !e || e.status !== "failed" ? null :
|
|
764
|
-
}, [Rn]),
|
|
765
|
-
queryKey: ["catalog-suberr-idents",
|
|
764
|
+
return !e || e.status !== "failed" ? null : ls(e.payload, e.last_error);
|
|
765
|
+
}, [Rn]), Fr = Se.map((e) => e.key).join(","), { data: sn } = Q({
|
|
766
|
+
queryKey: ["catalog-suberr-idents", y, _t.join(","), Fr],
|
|
766
767
|
queryFn: async () => {
|
|
767
|
-
const e =
|
|
768
|
+
const e = Se.map((n) => n.key);
|
|
768
769
|
if (e.length === 0) return {};
|
|
769
770
|
const t = await k.request(
|
|
770
|
-
|
|
771
|
+
K(`/items/${y}`, {
|
|
771
772
|
limit: e.length,
|
|
772
|
-
fields: ["id", ...
|
|
773
|
+
fields: ["id", ..._t].join(","),
|
|
773
774
|
filter: JSON.stringify({ id: { _in: e } })
|
|
774
775
|
})
|
|
775
776
|
).then((n) => n.data ?? []);
|
|
776
777
|
return Object.fromEntries(t.map((n) => [String(n.id), n]));
|
|
777
778
|
},
|
|
778
|
-
enabled: !!
|
|
779
|
+
enabled: !!y && !!rn && _t.length > 0 && Se.length > 0,
|
|
779
780
|
staleTime: 6e4
|
|
780
|
-
}),
|
|
781
|
-
if (!
|
|
782
|
-
const t =
|
|
783
|
-
|
|
784
|
-
...
|
|
785
|
-
const l = (t == null ? void 0 : t[r]) ??
|
|
781
|
+
}), Tr = (e) => {
|
|
782
|
+
if (!rn) return null;
|
|
783
|
+
const t = sn == null ? void 0 : sn[e], n = [
|
|
784
|
+
Ot(e),
|
|
785
|
+
..._t.map((r) => {
|
|
786
|
+
const l = (t == null ? void 0 : t[r]) ?? ze(e)[r];
|
|
786
787
|
return l != null && l !== "" ? String(l) : null;
|
|
787
788
|
})
|
|
788
|
-
].filter((r) => !!r).map(
|
|
789
|
-
return
|
|
790
|
-
},
|
|
791
|
-
queries:
|
|
792
|
-
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction,
|
|
789
|
+
].filter((r) => !!r).map(os);
|
|
790
|
+
return rn.reasonFor(n);
|
|
791
|
+
}, qt = a.summary_fields ?? [], Or = we.map((e) => String(e.id)).join(","), Rr = mn({
|
|
792
|
+
queries: qt.filter((e) => e.m2m).map((e) => ({
|
|
793
|
+
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, Or],
|
|
793
794
|
queryFn: async () => {
|
|
794
|
-
const t =
|
|
795
|
+
const t = we.map((b) => String(b.id));
|
|
795
796
|
if (t.length === 0) return {};
|
|
796
797
|
const n = e.m2m, r = await k.request(
|
|
797
|
-
|
|
798
|
+
K(`/items/${n.junction}`, {
|
|
798
799
|
limit: 1e3,
|
|
799
800
|
fields: `${n.fk_to_child},${n.related_field}`,
|
|
800
801
|
filter: JSON.stringify({ [n.fk_to_child]: { _in: t } })
|
|
801
802
|
})
|
|
802
|
-
).then((
|
|
803
|
-
|
|
803
|
+
).then((b) => b.data ?? []).catch(() => []), l = [...new Set(r.map((b) => String(b[n.related_field])))], o = n.label_field ?? "name", p = l.length ? await k.request(
|
|
804
|
+
K(`/items/${n.related_collection}`, {
|
|
804
805
|
limit: 500,
|
|
805
806
|
fields: `id,${o}`,
|
|
806
807
|
filter: JSON.stringify({ id: { _in: l } })
|
|
807
808
|
})
|
|
808
|
-
).then((
|
|
809
|
-
for (const
|
|
810
|
-
const
|
|
811
|
-
|
|
809
|
+
).then((b) => b.data ?? []).catch(() => []) : [], c = new Map(p.map((b) => [String(b.id), String(b[o] ?? b.id)])), h = {};
|
|
810
|
+
for (const b of r) {
|
|
811
|
+
const q = String(b[n.fk_to_child]), j = c.get(String(b[n.related_field]));
|
|
812
|
+
j && (h[q] = h[q] ? `${h[q]}, ${j}` : j);
|
|
812
813
|
}
|
|
813
|
-
return
|
|
814
|
+
return h;
|
|
814
815
|
},
|
|
815
|
-
enabled: !P &&
|
|
816
|
+
enabled: !P && we.length > 0,
|
|
816
817
|
staleTime: 15e3
|
|
817
818
|
}))
|
|
818
|
-
}),
|
|
819
|
+
}), Pr = (e, t) => {
|
|
819
820
|
var l, o;
|
|
820
821
|
if (!e.m2m) return t.row[e.field];
|
|
821
|
-
const n =
|
|
822
|
+
const n = qt.filter((p) => p.m2m).findIndex((p) => p.field === e.field);
|
|
822
823
|
if (n === -1) return;
|
|
823
824
|
const r = t.row.id;
|
|
824
825
|
if (r != null)
|
|
825
|
-
return (o = (l =
|
|
826
|
-
},
|
|
827
|
-
if (!
|
|
828
|
-
const t = Number(e[
|
|
826
|
+
return (o = (l = Rr[n]) == null ? void 0 : l.data) == null ? void 0 : o[String(r)];
|
|
827
|
+
}, Lr = !!((Gn = a.fulfilment) != null && Gn.shipped_field) && (a.fulfilment.show_when ? ir(a.fulfilment.show_when, S) : !0), Er = (e) => {
|
|
828
|
+
if (!Lr || !a.fulfilment) return null;
|
|
829
|
+
const t = Number(e[a.fulfilment.qty_field ?? I] ?? 0) || 0, n = Number(e[a.fulfilment.shipped_field] ?? 0) || 0, r = t > 0 && n >= t ? {
|
|
829
830
|
dot: "bg-emerald-500",
|
|
830
831
|
text: "text-emerald-700 dark:text-emerald-400",
|
|
831
832
|
label: "Shipped"
|
|
@@ -837,7 +838,7 @@ function da({
|
|
|
837
838
|
dot: "bg-slate-300 dark:bg-slate-600",
|
|
838
839
|
text: "text-slate-500 dark:text-slate-400",
|
|
839
840
|
// The header's ORDER STATUS word for the same order (army 11 a2 F8).
|
|
840
|
-
label:
|
|
841
|
+
label: a.fulfilment.pending_label ?? "Order Sent",
|
|
841
842
|
key: "requested"
|
|
842
843
|
};
|
|
843
844
|
return /* @__PURE__ */ u(
|
|
@@ -845,14 +846,14 @@ function da({
|
|
|
845
846
|
{
|
|
846
847
|
className: "inline-flex items-center gap-1.5 whitespace-nowrap",
|
|
847
848
|
"data-catalog-fulfilment": "key" in r ? r.key : r.label.split(" ")[0].toLowerCase(),
|
|
848
|
-
title: `${
|
|
849
|
+
title: `${a.fulfilment.label ?? "Warehouse"} · ${n} of ${t} shipped`,
|
|
849
850
|
children: [
|
|
850
|
-
/* @__PURE__ */
|
|
851
|
-
/* @__PURE__ */
|
|
851
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${r.dot}` }),
|
|
852
|
+
/* @__PURE__ */ s("span", { className: `text-[11px] font-medium ${r.text}`, children: r.label })
|
|
852
853
|
]
|
|
853
854
|
}
|
|
854
855
|
);
|
|
855
|
-
}, Pn =
|
|
856
|
+
}, Pn = a.columns ?? [], Ln = a.related_columns ?? [], $t = Pn.filter((e) => !e.summary_only), an = Ln.filter((e) => !e.summary_only), En = Pn.filter((e) => !e.sections_only), An = Ln.filter((e) => !e.sections_only), Kn = $t.length > 0 || an.length > 0, ln = qe(null), Cn = (e) => {
|
|
856
857
|
let t = e.parentElement;
|
|
857
858
|
for (; t; ) {
|
|
858
859
|
const n = getComputedStyle(t);
|
|
@@ -862,101 +863,101 @@ function da({
|
|
|
862
863
|
}
|
|
863
864
|
t = t.parentElement;
|
|
864
865
|
}
|
|
865
|
-
},
|
|
866
|
-
|
|
866
|
+
}, Ar = (e) => {
|
|
867
|
+
ln.current = e, e && Cn(e);
|
|
867
868
|
};
|
|
868
|
-
|
|
869
|
+
$e(() => {
|
|
869
870
|
let e = 0;
|
|
870
871
|
const t = () => {
|
|
871
872
|
e || (e = requestAnimationFrame(() => {
|
|
872
|
-
e = 0,
|
|
873
|
+
e = 0, ln.current && Cn(ln.current);
|
|
873
874
|
}));
|
|
874
875
|
};
|
|
875
876
|
return window.addEventListener("scroll", t, !0), () => {
|
|
876
877
|
e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
|
|
877
878
|
};
|
|
878
879
|
}, []);
|
|
879
|
-
const
|
|
880
|
+
const jt = (e, t) => {
|
|
880
881
|
let n = e;
|
|
881
882
|
for (const r of t.split(".")) {
|
|
882
883
|
if (n == null || typeof n != "object") return;
|
|
883
884
|
n = n[r];
|
|
884
885
|
}
|
|
885
886
|
return n;
|
|
886
|
-
},
|
|
887
|
+
}, Te = (e, t) => {
|
|
887
888
|
if (t === "presence")
|
|
888
889
|
return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
|
|
889
890
|
if (e == null || e === "") return "—";
|
|
890
891
|
const n = Number(e);
|
|
891
892
|
return t === "currency" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { style: "currency", currency: "USD" }) : t === "number" ? Number.isNaN(n) ? String(e) : n.toLocaleString(void 0, { maximumFractionDigits: 2 }) : String(e);
|
|
892
|
-
},
|
|
893
|
-
const n =
|
|
893
|
+
}, Ft = y ? `${y}:${i}.${m}` : null, Ae = ar(Ft && `${Ft}:catalog`), Oe = ar(Ft && `${Ft}:summary`), Jn = qe(null), Kr = (e, t) => {
|
|
894
|
+
const n = fs(Jn.current, t);
|
|
894
895
|
n != null && e.setWidth(t, n);
|
|
895
|
-
},
|
|
896
|
+
}, Tt = (e, t, n, r, l) => {
|
|
896
897
|
const o = e.box(t, r, l);
|
|
897
|
-
return /* @__PURE__ */ u("span", { ...o, className:
|
|
898
|
-
/* @__PURE__ */
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
|
|
898
|
+
return /* @__PURE__ */ u("span", { ...o, className: W("relative", o.className), children: [
|
|
899
|
+
/* @__PURE__ */ s("span", { "data-cpf-fit": !0, className: "block truncate", children: n }),
|
|
900
|
+
/* @__PURE__ */ s(
|
|
901
|
+
ms,
|
|
901
902
|
{
|
|
902
903
|
label: n,
|
|
903
|
-
onResize: (
|
|
904
|
-
onFit: () =>
|
|
904
|
+
onResize: (p) => e.setWidth(t, p),
|
|
905
|
+
onFit: () => Kr(e, t)
|
|
905
906
|
}
|
|
906
907
|
)
|
|
907
908
|
] }, t);
|
|
908
|
-
},
|
|
909
|
-
|
|
909
|
+
}, Cr = (Xn = $t.find((e) => !e.format)) == null ? void 0 : Xn.field, In = (e) => e.format ? ["w-20 shrink-0", "text-right"] : e.field === Cr ? ["min-w-0 flex-[3]", ""] : ["w-36 shrink-0", ""], on = (e, t, n) => /* @__PURE__ */ u(Ne, { children: [
|
|
910
|
+
$t.map((r) => {
|
|
910
911
|
const [l, o] = In(r);
|
|
911
|
-
return /* @__PURE__ */
|
|
912
|
+
return /* @__PURE__ */ s(
|
|
912
913
|
lr,
|
|
913
914
|
{
|
|
914
|
-
text:
|
|
915
|
-
|
|
915
|
+
text: Te(
|
|
916
|
+
Ls({
|
|
916
917
|
field: r.field,
|
|
917
|
-
catalogValue:
|
|
918
|
-
copyFields:
|
|
919
|
-
related:
|
|
920
|
-
lookup: (
|
|
918
|
+
catalogValue: jt(t, r.field),
|
|
919
|
+
copyFields: a.copy_fields,
|
|
920
|
+
related: a.related_columns,
|
|
921
|
+
lookup: (p) => at(p, e)
|
|
921
922
|
}),
|
|
922
923
|
r.format
|
|
923
924
|
),
|
|
924
925
|
highlight: r.format ? void 0 : n,
|
|
925
|
-
...
|
|
926
|
+
...Ae.box(r.field, l, W("text-slate-500 dark:text-slate-400", o))
|
|
926
927
|
},
|
|
927
928
|
r.field
|
|
928
929
|
);
|
|
929
930
|
}),
|
|
930
|
-
|
|
931
|
+
an.map((r) => /* @__PURE__ */ s(
|
|
931
932
|
"span",
|
|
932
933
|
{
|
|
933
|
-
...
|
|
934
|
+
...Ae.box(
|
|
934
935
|
`rel:${r.key}`,
|
|
935
936
|
"w-20 shrink-0",
|
|
936
937
|
"truncate text-right text-slate-500 dark:text-slate-400"
|
|
937
938
|
),
|
|
938
|
-
children:
|
|
939
|
+
children: Te(at(r.key, e), r.format)
|
|
939
940
|
},
|
|
940
941
|
r.key
|
|
941
942
|
)),
|
|
942
|
-
/* @__PURE__ */
|
|
943
|
-
] }),
|
|
943
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" })
|
|
944
|
+
] }), Jr = dr(y), Qn = (e, t, n, r, l) => Jr ? /* @__PURE__ */ s(
|
|
944
945
|
"button",
|
|
945
946
|
{
|
|
946
947
|
type: "button",
|
|
947
948
|
"data-cpf-fit": r || void 0,
|
|
948
|
-
onClick: () =>
|
|
949
|
+
onClick: () => y && cr(y, e, S),
|
|
949
950
|
title: "View stock & planning detail",
|
|
950
|
-
className:
|
|
951
|
+
className: W(
|
|
951
952
|
n,
|
|
952
953
|
"text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
|
|
953
954
|
),
|
|
954
|
-
children: l ? /* @__PURE__ */
|
|
955
|
+
children: l ? /* @__PURE__ */ s(fn, { text: t, query: l }) : t
|
|
955
956
|
}
|
|
956
|
-
) : /* @__PURE__ */
|
|
957
|
-
const l =
|
|
958
|
-
return /* @__PURE__ */ u("span", { ...l, className:
|
|
959
|
-
|
|
957
|
+
) : /* @__PURE__ */ s("span", { className: n, "data-cpf-fit": r || void 0, children: l ? /* @__PURE__ */ s(fn, { text: t, query: l }) : t }), dn = (e, t, n, r) => {
|
|
958
|
+
const l = Ae.box("item", Kn ? "w-36 shrink-0" : "min-w-0 flex-1");
|
|
959
|
+
return /* @__PURE__ */ u("span", { ...l, className: W("flex min-w-0 items-center gap-1.5", l.className), children: [
|
|
960
|
+
Qn(
|
|
960
961
|
e,
|
|
961
962
|
t,
|
|
962
963
|
"min-w-0 truncate text-slate-700 dark:text-slate-200",
|
|
@@ -965,42 +966,42 @@ function da({
|
|
|
965
966
|
),
|
|
966
967
|
n
|
|
967
968
|
] });
|
|
968
|
-
},
|
|
969
|
-
const t =
|
|
970
|
-
return t ?
|
|
971
|
-
},
|
|
972
|
-
|
|
973
|
-
const
|
|
974
|
-
|
|
975
|
-
() =>
|
|
976
|
-
const t =
|
|
969
|
+
}, Ot = (e) => {
|
|
970
|
+
const t = pt.get(e) ?? Qt.find((n) => String(n.id) === e) ?? et.find((n) => String(n.id) === e);
|
|
971
|
+
return t ? Ke(A, t) : `#${e}`;
|
|
972
|
+
}, zn = qe(Ot);
|
|
973
|
+
zn.current = Ot;
|
|
974
|
+
const Mn = qe(we);
|
|
975
|
+
Mn.current = we, $e(
|
|
976
|
+
() => is(i, (e) => {
|
|
977
|
+
const t = Mn.current.find((o) => String(o.id) === String(e)), n = t == null ? void 0 : t[a.item_field], r = n && typeof n == "object" ? n.id : n;
|
|
977
978
|
if (r == null || r === "") return null;
|
|
978
|
-
const l =
|
|
979
|
+
const l = zn.current(String(r));
|
|
979
980
|
return l.startsWith("#") ? null : l;
|
|
980
981
|
}),
|
|
981
|
-
[i,
|
|
982
|
+
[i, a.item_field]
|
|
982
983
|
);
|
|
983
|
-
const
|
|
984
|
+
const ze = (e) => pt.get(e) ?? Qt.find((t) => String(t.id) === e) ?? et.find((t) => String(t.id) === e) ?? { id: e }, _e = (e) => {
|
|
984
985
|
var r;
|
|
985
|
-
const t = P ? void 0 :
|
|
986
|
-
if (t) return
|
|
987
|
-
const n =
|
|
988
|
-
return n === void 0 ? null : Number(((r =
|
|
989
|
-
},
|
|
986
|
+
const t = P ? void 0 : Xe.get(e);
|
|
987
|
+
if (t) return yt.has(String(t.id)) ? null : Number(t[I] ?? 0);
|
|
988
|
+
const n = gt.get(e);
|
|
989
|
+
return n === void 0 ? null : Number(((r = Fe[n]) == null ? void 0 : r[I]) ?? 0);
|
|
990
|
+
}, Ir = (e) => {
|
|
990
991
|
let t = e;
|
|
991
|
-
for (const n of
|
|
992
|
+
for (const n of a.section_by.split(".")) {
|
|
992
993
|
if (t == null || typeof t != "object") return "";
|
|
993
994
|
t = t[n];
|
|
994
995
|
}
|
|
995
996
|
return String(t ?? "").trim();
|
|
996
|
-
},
|
|
997
|
-
if (
|
|
998
|
-
|
|
997
|
+
}, Rt = E(() => {
|
|
998
|
+
if (ht) return [];
|
|
999
|
+
U.trim().toLowerCase();
|
|
999
1000
|
const e = /* @__PURE__ */ new Map();
|
|
1000
|
-
for (const t of
|
|
1001
|
-
if (
|
|
1002
|
-
const n =
|
|
1003
|
-
if (!(
|
|
1001
|
+
for (const t of oe) {
|
|
1002
|
+
if (ce && it !== void 0 && !(Number(it[String(t.id)]) > 0)) continue;
|
|
1003
|
+
const n = Ke(A, t), r = C ? yn.get(String(t.id)) ?? [] : [Ir(t)];
|
|
1004
|
+
if (!(C && Y && r.length === 0))
|
|
1004
1005
|
for (const l of r.length ? r : [""]) {
|
|
1005
1006
|
const o = l || "Uncategorized";
|
|
1006
1007
|
e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: n, row: t });
|
|
@@ -1013,41 +1014,41 @@ function da({
|
|
|
1013
1014
|
items: n.sort((r, l) => r.label.localeCompare(l.label))
|
|
1014
1015
|
}));
|
|
1015
1016
|
}, [
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1017
|
+
oe,
|
|
1018
|
+
A,
|
|
1019
|
+
U,
|
|
1020
|
+
a.section_by,
|
|
1021
|
+
C,
|
|
1021
1022
|
yn,
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1023
|
+
ht,
|
|
1024
|
+
Y,
|
|
1025
|
+
ce,
|
|
1026
|
+
it
|
|
1026
1027
|
]);
|
|
1027
|
-
if (!
|
|
1028
|
-
|
|
1028
|
+
if (!ke.current && Rt.length > 0) {
|
|
1029
|
+
ke.current = !0;
|
|
1029
1030
|
const e = /* @__PURE__ */ new Set();
|
|
1030
|
-
for (const t of
|
|
1031
|
-
t.items.some((r) => (
|
|
1032
|
-
|
|
1031
|
+
for (const t of Rt)
|
|
1032
|
+
t.items.some((r) => (_e(r.id) ?? 0) > 0) || e.add(t.name);
|
|
1033
|
+
ge(e);
|
|
1033
1034
|
}
|
|
1034
|
-
async function
|
|
1035
|
+
async function Qr(e) {
|
|
1035
1036
|
const t = {};
|
|
1036
|
-
for (const n of
|
|
1037
|
+
for (const n of a.related_columns ?? []) {
|
|
1037
1038
|
if (!n.copy_to) continue;
|
|
1038
|
-
let r =
|
|
1039
|
+
let r = at(n.key, e);
|
|
1039
1040
|
if (r === void 0) {
|
|
1040
|
-
const l =
|
|
1041
|
+
const l = Ye(n.match, S);
|
|
1041
1042
|
if (l === null) continue;
|
|
1042
1043
|
r = await k.request(
|
|
1043
|
-
|
|
1044
|
+
K(`/items/${n.collection}`, {
|
|
1044
1045
|
limit: 1,
|
|
1045
1046
|
fields: `${n.item_field},${n.value_field}`,
|
|
1046
1047
|
filter: JSON.stringify({ ...l, [n.item_field]: { _eq: e } })
|
|
1047
1048
|
})
|
|
1048
1049
|
).then((o) => {
|
|
1049
|
-
var
|
|
1050
|
-
return (c = (
|
|
1050
|
+
var p, c;
|
|
1051
|
+
return (c = (p = o.data) == null ? void 0 : p[0]) == null ? void 0 : c[n.value_field];
|
|
1051
1052
|
}).catch(() => {
|
|
1052
1053
|
});
|
|
1053
1054
|
}
|
|
@@ -1055,265 +1056,265 @@ function da({
|
|
|
1055
1056
|
}
|
|
1056
1057
|
return t;
|
|
1057
1058
|
}
|
|
1058
|
-
const
|
|
1059
|
+
const Vn = (e, t) => {
|
|
1059
1060
|
var r;
|
|
1060
|
-
for (const l of
|
|
1061
|
+
for (const l of a.related_columns ?? []) {
|
|
1061
1062
|
if (l.copy_to !== t) continue;
|
|
1062
|
-
const o =
|
|
1063
|
+
const o = at(l.key, e);
|
|
1063
1064
|
if (o != null && o !== "") return o;
|
|
1064
1065
|
}
|
|
1065
|
-
const n = (r =
|
|
1066
|
-
return n ?
|
|
1067
|
-
},
|
|
1068
|
-
const e = new Set(Object.keys(
|
|
1069
|
-
for (const t of
|
|
1066
|
+
const n = (r = a.copy_fields) == null ? void 0 : r[t];
|
|
1067
|
+
return n ? ze(e)[n] : void 0;
|
|
1068
|
+
}, Wn = qe(/* @__PURE__ */ new Map()), Pt = E(() => {
|
|
1069
|
+
const e = new Set(Object.keys(a.copy_fields ?? {}));
|
|
1070
|
+
for (const t of a.related_columns ?? []) t.copy_to && e.add(t.copy_to);
|
|
1070
1071
|
return [...e];
|
|
1071
|
-
}, [
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1072
|
+
}, [a.copy_fields, a.related_columns]), zr = JSON.stringify([
|
|
1073
|
+
Fe.map((e) => [e[a.item_field], ...Pt.map((t) => e[t] ?? null)]),
|
|
1074
|
+
st.map((e) => e.dataUpdatedAt),
|
|
1075
|
+
oe.length,
|
|
1076
|
+
Qt.length
|
|
1076
1077
|
]);
|
|
1077
|
-
|
|
1078
|
-
w || !
|
|
1079
|
-
const n = e[
|
|
1078
|
+
$e(() => {
|
|
1079
|
+
w || !N || Pt.length === 0 || Fe.forEach((e, t) => {
|
|
1080
|
+
const n = e[a.item_field];
|
|
1080
1081
|
if (n == null) return;
|
|
1081
|
-
const r =
|
|
1082
|
+
const r = js(
|
|
1082
1083
|
e,
|
|
1083
|
-
|
|
1084
|
-
(o) =>
|
|
1085
|
-
|
|
1084
|
+
Pt,
|
|
1085
|
+
(o) => Vn(String(n), o),
|
|
1086
|
+
Wn.current.get(String(n))
|
|
1086
1087
|
);
|
|
1087
1088
|
if (!r) return;
|
|
1088
|
-
|
|
1089
|
+
Wn.current.set(String(n), r.auto);
|
|
1089
1090
|
const l = { ...e, ...r.updates };
|
|
1090
|
-
for (const [o,
|
|
1091
|
-
const c =
|
|
1091
|
+
for (const [o, p] of Object.entries(a.compute_fields ?? {})) {
|
|
1092
|
+
const c = Ee(p, l);
|
|
1092
1093
|
c !== null && (l[o] = c);
|
|
1093
1094
|
}
|
|
1094
|
-
|
|
1095
|
+
N.updateRow(i, m, t, l);
|
|
1095
1096
|
});
|
|
1096
|
-
}, [
|
|
1097
|
-
const
|
|
1098
|
-
if (w || !
|
|
1099
|
-
if (
|
|
1100
|
-
const n =
|
|
1097
|
+
}, [zr, w, Pt]);
|
|
1098
|
+
const Mr = (e, t) => {
|
|
1099
|
+
if (w || !M.includes(t)) return !1;
|
|
1100
|
+
if (fe || !me.includes(t)) return !0;
|
|
1101
|
+
const n = Vn(e, t);
|
|
1101
1102
|
return n == null || n === "" || !(Number(n) > 0);
|
|
1102
1103
|
};
|
|
1103
1104
|
function Ue(e, t, n, r = {}) {
|
|
1104
1105
|
const l = {
|
|
1105
|
-
[
|
|
1106
|
-
[
|
|
1106
|
+
[a.item_field]: n.id ?? e,
|
|
1107
|
+
[I]: t
|
|
1107
1108
|
};
|
|
1108
|
-
for (const [o,
|
|
1109
|
-
n[
|
|
1109
|
+
for (const [o, p] of Object.entries(a.copy_fields ?? {}))
|
|
1110
|
+
n[p] !== void 0 && (l[o] = n[p]);
|
|
1110
1111
|
Object.assign(l, r);
|
|
1111
|
-
for (const [o,
|
|
1112
|
-
const c =
|
|
1112
|
+
for (const [o, p] of Object.entries(a.compute_fields ?? {})) {
|
|
1113
|
+
const c = Ee(p, l);
|
|
1113
1114
|
c !== null && (l[o] = c);
|
|
1114
1115
|
}
|
|
1115
1116
|
return l;
|
|
1116
1117
|
}
|
|
1117
|
-
function
|
|
1118
|
-
return
|
|
1119
|
-
compute:
|
|
1120
|
-
probe: { ...Ue(e, t, n), ...r, [
|
|
1121
|
-
ruleError:
|
|
1118
|
+
function Vr(e, t, n, r) {
|
|
1119
|
+
return Ps({
|
|
1120
|
+
compute: a.compute_fields ?? {},
|
|
1121
|
+
probe: { ...Ue(e, t, n), ...r, [I]: t },
|
|
1122
|
+
ruleError: O,
|
|
1122
1123
|
labelOf: (l) => {
|
|
1123
1124
|
var o;
|
|
1124
|
-
return ((o =
|
|
1125
|
+
return ((o = v.find((p) => p.field === l)) == null ? void 0 : o.label) || X(l);
|
|
1125
1126
|
}
|
|
1126
1127
|
});
|
|
1127
1128
|
}
|
|
1128
|
-
async function
|
|
1129
|
-
const l = hn(t, { type:
|
|
1129
|
+
async function Be(e, t, n, r = {}) {
|
|
1130
|
+
const l = hn(t, { type: L, min: 0, label: "Quantity" });
|
|
1130
1131
|
if (!l.ok) {
|
|
1131
|
-
|
|
1132
|
+
se((h) => ({ ...h, [e]: { kind: "error", message: l.message } }));
|
|
1132
1133
|
return;
|
|
1133
1134
|
}
|
|
1134
1135
|
const o = l.value ?? 0;
|
|
1135
|
-
if ((
|
|
1136
|
+
if ((_e(e) ?? 0) === o) return;
|
|
1136
1137
|
if (o === 0 && !r.confirmedRemove) {
|
|
1137
|
-
|
|
1138
|
+
se((h) => ({ ...h, [e]: { kind: "remove", row: n } }));
|
|
1138
1139
|
return;
|
|
1139
1140
|
}
|
|
1140
1141
|
if (o > 0) {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
|
|
1142
|
+
const h = gt.get(e), b = (P ? void 0 : Xe.get(e)) ?? (h !== void 0 ? Fe[h] : void 0) ?? {}, q = O(I, o, b) ?? Vr(e, o, n, b);
|
|
1143
|
+
if (q) {
|
|
1144
|
+
se((j) => ({ ...j, [e]: { kind: "error", message: q } }));
|
|
1144
1145
|
return;
|
|
1145
1146
|
}
|
|
1146
1147
|
}
|
|
1147
|
-
const c = o > 0 ? await
|
|
1148
|
-
if (
|
|
1149
|
-
const
|
|
1150
|
-
if ((
|
|
1151
|
-
const
|
|
1148
|
+
const c = o > 0 ? await Qr(e) : {};
|
|
1149
|
+
if (Ge && N) {
|
|
1150
|
+
const h = Xe.get(e);
|
|
1151
|
+
if ((h == null ? void 0 : h.id) != null) {
|
|
1152
|
+
const b = String(h.id);
|
|
1152
1153
|
if (o === 0) {
|
|
1153
|
-
|
|
1154
|
+
N.cancelPendingEdit(i, m, b), N.queueDelete(i, m, b);
|
|
1154
1155
|
return;
|
|
1155
1156
|
}
|
|
1156
|
-
|
|
1157
|
-
const
|
|
1158
|
-
for (const
|
|
1159
|
-
|
|
1160
|
-
for (const [
|
|
1161
|
-
const
|
|
1162
|
-
|
|
1157
|
+
yt.has(b) && N.cancelPendingDelete(i, m, b);
|
|
1158
|
+
const q = Ue(e, o, n, c);
|
|
1159
|
+
for (const g of M)
|
|
1160
|
+
h[g] != null && h[g] !== "" && (q[g] = h[g]);
|
|
1161
|
+
for (const [g, V] of Object.entries(a.compute_fields ?? {})) {
|
|
1162
|
+
const Le = Ee(V, { ...h, ...q });
|
|
1163
|
+
Le !== null && (q[g] = Le);
|
|
1163
1164
|
}
|
|
1164
|
-
const
|
|
1165
|
-
Object.entries(
|
|
1165
|
+
const j = we.find((g) => String(g.id) === b) ?? {}, J = Object.fromEntries(
|
|
1166
|
+
Object.entries(q).filter(([g, V]) => String(V ?? "") !== String(j[g] ?? ""))
|
|
1166
1167
|
);
|
|
1167
|
-
Object.keys(
|
|
1168
|
+
Object.keys(J).length === 0 ? N.cancelPendingEdit(i, m, b) : (N.cancelPendingEdit(i, m, b), N.queueEdit(i, m, b, J));
|
|
1168
1169
|
return;
|
|
1169
1170
|
}
|
|
1170
1171
|
}
|
|
1171
|
-
if (P ||
|
|
1172
|
-
const
|
|
1173
|
-
o === 0 ?
|
|
1172
|
+
if (P || Ge) {
|
|
1173
|
+
const h = gt.get(e);
|
|
1174
|
+
o === 0 ? h !== void 0 && (N == null || N.removeRow(i, m, h)) : h !== void 0 ? N == null || N.updateRow(
|
|
1174
1175
|
i,
|
|
1175
1176
|
m,
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1177
|
+
h,
|
|
1178
|
+
ks(
|
|
1179
|
+
Fe[h],
|
|
1179
1180
|
Ue(e, o, n, c),
|
|
1180
|
-
|
|
1181
|
-
|
|
1181
|
+
M,
|
|
1182
|
+
a.compute_fields
|
|
1182
1183
|
)
|
|
1183
|
-
) :
|
|
1184
|
+
) : N == null || N.queueRow(
|
|
1184
1185
|
i,
|
|
1185
1186
|
m,
|
|
1186
1187
|
Ue(e, o, n, c)
|
|
1187
1188
|
);
|
|
1188
1189
|
return;
|
|
1189
1190
|
}
|
|
1190
|
-
|
|
1191
|
+
Z((h) => new Set(h).add(e));
|
|
1191
1192
|
try {
|
|
1192
|
-
const
|
|
1193
|
+
const h = Xe.get(e);
|
|
1193
1194
|
if (o === 0)
|
|
1194
|
-
(
|
|
1195
|
-
else if ((
|
|
1196
|
-
const
|
|
1197
|
-
for (const
|
|
1198
|
-
|
|
1199
|
-
for (const [
|
|
1200
|
-
const
|
|
1201
|
-
|
|
1195
|
+
(h == null ? void 0 : h.id) != null && await k.request(ts(`/items/${i}/${h.id}${be}`));
|
|
1196
|
+
else if ((h == null ? void 0 : h.id) != null) {
|
|
1197
|
+
const b = Ue(e, o, n, c);
|
|
1198
|
+
for (const g of M)
|
|
1199
|
+
h[g] != null && h[g] !== "" && (b[g] = h[g]);
|
|
1200
|
+
for (const [g, V] of Object.entries(a.compute_fields ?? {})) {
|
|
1201
|
+
const Le = Ee(V, { ...h, ...b });
|
|
1202
|
+
Le !== null && (b[g] = Le);
|
|
1202
1203
|
}
|
|
1203
|
-
const
|
|
1204
|
-
await k.request(rr(`/items/${i}/${
|
|
1204
|
+
const q = { ...h, ...b }, { id: j, ...J } = q;
|
|
1205
|
+
await k.request(rr(`/items/${i}/${h.id}${be}`, J));
|
|
1205
1206
|
} else
|
|
1206
1207
|
await k.request(
|
|
1207
|
-
sr(`/items/${i}${
|
|
1208
|
-
[m]:
|
|
1208
|
+
sr(`/items/${i}${be}`, {
|
|
1209
|
+
[m]: f,
|
|
1209
1210
|
...Ue(e, o, n, c)
|
|
1210
1211
|
})
|
|
1211
1212
|
);
|
|
1212
|
-
|
|
1213
|
+
F.invalidateQueries({ queryKey: ["o2m-rows", i, m, f] });
|
|
1213
1214
|
} catch {
|
|
1214
1215
|
} finally {
|
|
1215
|
-
|
|
1216
|
-
const
|
|
1217
|
-
return
|
|
1216
|
+
Z((h) => {
|
|
1217
|
+
const b = new Set(h);
|
|
1218
|
+
return b.delete(e), b;
|
|
1218
1219
|
});
|
|
1219
1220
|
}
|
|
1220
1221
|
}
|
|
1221
|
-
async function
|
|
1222
|
+
async function Wr(e, t, n) {
|
|
1222
1223
|
const r = n.trim() === "" ? null : Number(n);
|
|
1223
1224
|
if (n.trim() !== "" && Number.isNaN(r)) return;
|
|
1224
|
-
const l = (
|
|
1225
|
-
const c = { ...
|
|
1226
|
-
for (const [
|
|
1227
|
-
const
|
|
1228
|
-
|
|
1225
|
+
const l = (p) => {
|
|
1226
|
+
const c = { ...p, [t]: r };
|
|
1227
|
+
for (const [h, b] of Object.entries(a.compute_fields ?? {})) {
|
|
1228
|
+
const q = Ee(b, c);
|
|
1229
|
+
q !== null && (c[h] = q);
|
|
1229
1230
|
}
|
|
1230
1231
|
return c;
|
|
1231
|
-
}, o = P ? void 0 :
|
|
1232
|
+
}, o = P ? void 0 : Xe.get(e);
|
|
1232
1233
|
if ((o == null ? void 0 : o.id) == null) {
|
|
1233
|
-
const
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1234
|
+
const p = gt.get(e);
|
|
1235
|
+
if (p === void 0) return;
|
|
1236
|
+
N == null || N.updateRow(i, m, p, l(Fe[p]));
|
|
1236
1237
|
return;
|
|
1237
1238
|
}
|
|
1238
|
-
if (
|
|
1239
|
-
const
|
|
1240
|
-
Object.entries(
|
|
1241
|
-
([
|
|
1239
|
+
if (Ge && N) {
|
|
1240
|
+
const p = l(o), c = we.find((b) => String(b.id) === String(o.id)) ?? {}, h = Object.fromEntries(
|
|
1241
|
+
Object.entries(p).filter(
|
|
1242
|
+
([b, q]) => b !== "id" && String(q ?? "") !== String(c[b] ?? "")
|
|
1242
1243
|
)
|
|
1243
1244
|
);
|
|
1244
|
-
|
|
1245
|
+
N.cancelPendingEdit(i, m, String(o.id)), Object.keys(h).length > 0 && N.queueEdit(i, m, String(o.id), h);
|
|
1245
1246
|
return;
|
|
1246
1247
|
}
|
|
1247
|
-
|
|
1248
|
+
Z((p) => new Set(p).add(e));
|
|
1248
1249
|
try {
|
|
1249
|
-
const { id:
|
|
1250
|
-
await k.request(rr(`/items/${i}/${o.id}${
|
|
1250
|
+
const { id: p, ...c } = l(o);
|
|
1251
|
+
await k.request(rr(`/items/${i}/${o.id}${be}`, c)), F.invalidateQueries({ queryKey: ["o2m-rows", i, m, f] });
|
|
1251
1252
|
} catch {
|
|
1252
1253
|
} finally {
|
|
1253
|
-
|
|
1254
|
-
const c = new Set(
|
|
1254
|
+
Z((p) => {
|
|
1255
|
+
const c = new Set(p);
|
|
1255
1256
|
return c.delete(e), c;
|
|
1256
1257
|
});
|
|
1257
1258
|
}
|
|
1258
1259
|
}
|
|
1259
|
-
async function
|
|
1260
|
-
if (e == null || e === "" || !
|
|
1261
|
-
const t = String(e), n =
|
|
1260
|
+
async function Ur(e) {
|
|
1261
|
+
if (e == null || e === "" || !y) return;
|
|
1262
|
+
const t = String(e), n = ze(t);
|
|
1262
1263
|
let r = n;
|
|
1263
1264
|
Object.keys(n).length <= 1 && (r = await k.request(
|
|
1264
|
-
|
|
1265
|
+
K(`/items/${y}`, {
|
|
1265
1266
|
filter: JSON.stringify({ id: { _eq: e } }),
|
|
1266
|
-
fields:
|
|
1267
|
+
fields: z,
|
|
1267
1268
|
limit: 1
|
|
1268
1269
|
})
|
|
1269
1270
|
).then((o) => {
|
|
1270
|
-
var
|
|
1271
|
-
return ((
|
|
1271
|
+
var p;
|
|
1272
|
+
return ((p = o.data) == null ? void 0 : p[0]) ?? { id: e };
|
|
1272
1273
|
}).catch(() => ({ id: e })));
|
|
1273
|
-
const l = (
|
|
1274
|
-
await
|
|
1274
|
+
const l = (_e(t) ?? 0) + 1;
|
|
1275
|
+
await Be(t, String(l), r);
|
|
1275
1276
|
}
|
|
1276
|
-
const
|
|
1277
|
-
const n =
|
|
1277
|
+
const Br = Se.length, Lt = Object.keys(a.copy_fields ?? {}), De = Object.keys(a.compute_fields ?? {}), Et = (e, t) => {
|
|
1278
|
+
const n = _e(e);
|
|
1278
1279
|
if (w)
|
|
1279
|
-
return /* @__PURE__ */
|
|
1280
|
-
const r =
|
|
1281
|
-
if (!(e in
|
|
1282
|
-
const
|
|
1283
|
-
return delete
|
|
1284
|
-
}), c = /* @__PURE__ */
|
|
1280
|
+
return /* @__PURE__ */ s("span", { className: "inline-block w-20 shrink-0 text-right tabular-nums text-slate-700 dark:text-slate-200", children: n && n > 0 ? n.toLocaleString("en-US") : "—" });
|
|
1281
|
+
const r = pe[e], l = r !== void 0 ? r : n && n > 0 ? String(n) : "", o = B[e], p = () => se((h) => {
|
|
1282
|
+
if (!(e in h)) return h;
|
|
1283
|
+
const b = { ...h };
|
|
1284
|
+
return delete b[e], b;
|
|
1285
|
+
}), c = /* @__PURE__ */ s(
|
|
1285
1286
|
"input",
|
|
1286
1287
|
{
|
|
1287
1288
|
type: "number",
|
|
1288
1289
|
min: 0,
|
|
1289
|
-
step:
|
|
1290
|
+
step: dt(L) ? 1 : "any",
|
|
1290
1291
|
disabled: w,
|
|
1291
1292
|
value: l,
|
|
1292
1293
|
placeholder: "0",
|
|
1293
1294
|
"aria-invalid": (o == null ? void 0 : o.kind) === "error" || void 0,
|
|
1294
|
-
onFocus:
|
|
1295
|
-
onChange: (
|
|
1296
|
-
onBlur: (
|
|
1297
|
-
const
|
|
1298
|
-
if (
|
|
1299
|
-
|
|
1300
|
-
const
|
|
1301
|
-
return delete
|
|
1302
|
-
}),
|
|
1303
|
-
...
|
|
1304
|
-
[e]: { kind: "error", message:
|
|
1295
|
+
onFocus: p,
|
|
1296
|
+
onChange: (h) => re((b) => ({ ...b, [e]: h.target.value })),
|
|
1297
|
+
onBlur: (h) => {
|
|
1298
|
+
const b = h.target.value, q = Ts(b, L);
|
|
1299
|
+
if (q) {
|
|
1300
|
+
re((j) => {
|
|
1301
|
+
const J = { ...j };
|
|
1302
|
+
return delete J[e], J;
|
|
1303
|
+
}), se((j) => ({
|
|
1304
|
+
...j,
|
|
1305
|
+
[e]: { kind: "error", message: Rs(q, b) }
|
|
1305
1306
|
}));
|
|
1306
1307
|
return;
|
|
1307
1308
|
}
|
|
1308
|
-
|
|
1309
|
-
const
|
|
1310
|
-
return delete
|
|
1311
|
-
}),
|
|
1309
|
+
re((j) => {
|
|
1310
|
+
const J = { ...j };
|
|
1311
|
+
return delete J[e], J;
|
|
1312
|
+
}), Be(e, b, t);
|
|
1312
1313
|
},
|
|
1313
|
-
onKeyDown: (
|
|
1314
|
-
|
|
1314
|
+
onKeyDown: (h) => {
|
|
1315
|
+
h.key === "Enter" && h.currentTarget.blur();
|
|
1315
1316
|
},
|
|
1316
|
-
className:
|
|
1317
|
+
className: W(
|
|
1317
1318
|
"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",
|
|
1318
1319
|
(o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
|
|
1319
1320
|
)
|
|
@@ -1328,7 +1329,7 @@ function da({
|
|
|
1328
1329
|
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",
|
|
1329
1330
|
"data-catalog-qty-error": !0,
|
|
1330
1331
|
children: [
|
|
1331
|
-
/* @__PURE__ */
|
|
1332
|
+
/* @__PURE__ */ s(cn, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1332
1333
|
o.message,
|
|
1333
1334
|
n && n > 0 ? ` — still ${n.toLocaleString("en-US")}` : ""
|
|
1334
1335
|
]
|
|
@@ -1341,23 +1342,23 @@ function da({
|
|
|
1341
1342
|
"data-catalog-qty-remove": !0,
|
|
1342
1343
|
className: "mt-1 flex max-w-[240px] flex-wrap items-center justify-end gap-1.5 text-right text-[11px] leading-snug text-slate-700 dark:text-slate-200",
|
|
1343
1344
|
children: [
|
|
1344
|
-
/* @__PURE__ */
|
|
1345
|
-
/* @__PURE__ */
|
|
1345
|
+
/* @__PURE__ */ s("span", { children: "Remove this line?" }),
|
|
1346
|
+
/* @__PURE__ */ s(
|
|
1346
1347
|
"button",
|
|
1347
1348
|
{
|
|
1348
1349
|
type: "button",
|
|
1349
|
-
onClick:
|
|
1350
|
+
onClick: p,
|
|
1350
1351
|
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",
|
|
1351
1352
|
children: "Keep"
|
|
1352
1353
|
}
|
|
1353
1354
|
),
|
|
1354
|
-
/* @__PURE__ */
|
|
1355
|
+
/* @__PURE__ */ s(
|
|
1355
1356
|
"button",
|
|
1356
1357
|
{
|
|
1357
1358
|
type: "button",
|
|
1358
1359
|
onClick: () => {
|
|
1359
|
-
const
|
|
1360
|
-
|
|
1360
|
+
const h = o.row;
|
|
1361
|
+
p(), Be(e, "0", h, { confirmedRemove: !0 });
|
|
1361
1362
|
},
|
|
1362
1363
|
className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
|
|
1363
1364
|
children: "Remove"
|
|
@@ -1367,42 +1368,42 @@ function da({
|
|
|
1367
1368
|
}
|
|
1368
1369
|
)
|
|
1369
1370
|
] });
|
|
1370
|
-
},
|
|
1371
|
-
const r = `${e}:${t}`, l =
|
|
1372
|
-
if (!(r in
|
|
1373
|
-
const
|
|
1374
|
-
return delete
|
|
1375
|
-
}),
|
|
1371
|
+
}, Dr = (e, t, n) => {
|
|
1372
|
+
const r = `${e}:${t}`, l = ie[r], o = () => ve((b) => {
|
|
1373
|
+
if (!(r in b)) return b;
|
|
1374
|
+
const q = { ...b };
|
|
1375
|
+
return delete q[r], q;
|
|
1376
|
+
}), p = n[t] == null ? "" : String(n[t]), c = v.find((b) => b.field === t), h = !dt(c == null ? void 0 : c.type);
|
|
1376
1377
|
return /* @__PURE__ */ u("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
|
|
1377
|
-
/* @__PURE__ */
|
|
1378
|
+
/* @__PURE__ */ s(
|
|
1378
1379
|
"input",
|
|
1379
1380
|
{
|
|
1380
1381
|
type: "number",
|
|
1381
1382
|
min: 0,
|
|
1382
|
-
step:
|
|
1383
|
-
defaultValue:
|
|
1383
|
+
step: h ? "0.01" : "any",
|
|
1384
|
+
defaultValue: p,
|
|
1384
1385
|
"aria-invalid": !!l || void 0,
|
|
1385
1386
|
onFocus: o,
|
|
1386
|
-
onBlur: (
|
|
1387
|
-
const
|
|
1388
|
-
if (
|
|
1389
|
-
const
|
|
1390
|
-
if (
|
|
1391
|
-
|
|
1387
|
+
onBlur: (b) => {
|
|
1388
|
+
const q = b.target.value;
|
|
1389
|
+
if (q !== p) {
|
|
1390
|
+
const j = c, J = (j == null ? void 0 : j.label) || X(t), g = hn(q, { type: j == null ? void 0 : j.type, label: J }), V = g.ok ? (h ? ws(q, J) : null) ?? O(t, g.value, n) : g.message;
|
|
1391
|
+
if (V) {
|
|
1392
|
+
b.target.value = p, ve((Le) => ({ ...Le, [r]: V }));
|
|
1392
1393
|
return;
|
|
1393
1394
|
}
|
|
1394
1395
|
}
|
|
1395
|
-
|
|
1396
|
+
Wr(e, t, q);
|
|
1396
1397
|
},
|
|
1397
|
-
onKeyDown: (
|
|
1398
|
-
|
|
1398
|
+
onKeyDown: (b) => {
|
|
1399
|
+
b.key === "Enter" && b.currentTarget.blur();
|
|
1399
1400
|
},
|
|
1400
|
-
className:
|
|
1401
|
+
className: W(
|
|
1401
1402
|
"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",
|
|
1402
1403
|
l && "border-red-400 dark:border-red-600"
|
|
1403
1404
|
)
|
|
1404
1405
|
},
|
|
1405
|
-
`${r}:${
|
|
1406
|
+
`${r}:${p}`
|
|
1406
1407
|
),
|
|
1407
1408
|
l && /* @__PURE__ */ u(
|
|
1408
1409
|
"span",
|
|
@@ -1411,57 +1412,57 @@ function da({
|
|
|
1411
1412
|
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",
|
|
1412
1413
|
"data-catalog-cell-error": !0,
|
|
1413
1414
|
children: [
|
|
1414
|
-
/* @__PURE__ */
|
|
1415
|
+
/* @__PURE__ */ s(cn, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1415
1416
|
l,
|
|
1416
|
-
|
|
1417
|
+
p !== "" ? ` — still ${p}` : ""
|
|
1417
1418
|
]
|
|
1418
1419
|
}
|
|
1419
1420
|
)
|
|
1420
1421
|
] }, r);
|
|
1421
1422
|
};
|
|
1422
|
-
return !
|
|
1423
|
-
/* @__PURE__ */
|
|
1424
|
-
/* @__PURE__ */
|
|
1425
|
-
] }) :
|
|
1426
|
-
!w && /* @__PURE__ */ u(
|
|
1423
|
+
return !y && T ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
|
|
1424
|
+
/* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
|
|
1425
|
+
/* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
1426
|
+
] }) : y ? /* @__PURE__ */ u("div", { ref: Jn, className: "space-y-3", children: [
|
|
1427
|
+
!w && /* @__PURE__ */ u(Ne, { children: [
|
|
1427
1428
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1428
1429
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1429
|
-
/* @__PURE__ */
|
|
1430
|
-
/* @__PURE__ */
|
|
1430
|
+
/* @__PURE__ */ s(At, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
1431
|
+
/* @__PURE__ */ s(
|
|
1431
1432
|
"input",
|
|
1432
1433
|
{
|
|
1433
|
-
value:
|
|
1434
|
-
onChange: (e) =>
|
|
1434
|
+
value: U,
|
|
1435
|
+
onChange: (e) => je(e.target.value),
|
|
1435
1436
|
placeholder: "Search catalog…",
|
|
1436
1437
|
className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
|
|
1437
1438
|
}
|
|
1438
1439
|
),
|
|
1439
|
-
|
|
1440
|
+
de && /* @__PURE__ */ u(
|
|
1440
1441
|
"button",
|
|
1441
1442
|
{
|
|
1442
1443
|
type: "button",
|
|
1443
|
-
"aria-pressed":
|
|
1444
|
-
"aria-disabled":
|
|
1444
|
+
"aria-pressed": ce,
|
|
1445
|
+
"aria-disabled": Pe === null ? "true" : void 0,
|
|
1445
1446
|
onClick: () => {
|
|
1446
|
-
|
|
1447
|
+
Pe !== null && Vt(!$n);
|
|
1447
1448
|
},
|
|
1448
|
-
"data-catalog-in-stock":
|
|
1449
|
-
"data-tip":
|
|
1450
|
-
className:
|
|
1449
|
+
"data-catalog-in-stock": ce ? "on" : "off",
|
|
1450
|
+
"data-tip": Pe === null ? `Choose ${gr ?? "where stock is counted"} to show only items in stock there` : ce ? "Showing only items with stock on hand — click to show everything" : "Show only items with stock on hand",
|
|
1451
|
+
className: W(
|
|
1451
1452
|
"inline-flex h-6 max-w-[220px] shrink-0 items-center gap-1 rounded border px-1.5 text-[11px] font-medium transition-colors duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-nvr-cyan aria-disabled:cursor-not-allowed aria-disabled:opacity-50",
|
|
1452
|
-
|
|
1453
|
+
ce ? "border-nvr-cyan/40 bg-nvr-cyan/10 text-[#00728d] dark:border-nvr-cyan/40 dark:bg-nvr-cyan/15 dark:text-nvr-cyan" : "border-slate-200 bg-white text-slate-600 hover:bg-muted dark:border-border dark:bg-background dark:text-slate-300"
|
|
1453
1454
|
),
|
|
1454
1455
|
children: [
|
|
1455
|
-
|
|
1456
|
+
_r ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(Yr, { className: "h-3 w-3 shrink-0" }),
|
|
1456
1457
|
/* @__PURE__ */ u("span", { className: "truncate", children: [
|
|
1457
1458
|
"In stock",
|
|
1458
|
-
|
|
1459
|
+
Pe !== null && Qe && qn != null && /* @__PURE__ */ u(Ne, { children: [
|
|
1459
1460
|
" at ",
|
|
1460
|
-
/* @__PURE__ */
|
|
1461
|
-
|
|
1461
|
+
/* @__PURE__ */ s(
|
|
1462
|
+
Is,
|
|
1462
1463
|
{
|
|
1463
1464
|
parentCollection: x,
|
|
1464
|
-
field:
|
|
1465
|
+
field: Qe,
|
|
1465
1466
|
id: qn
|
|
1466
1467
|
}
|
|
1467
1468
|
)
|
|
@@ -1470,12 +1471,12 @@ function da({
|
|
|
1470
1471
|
]
|
|
1471
1472
|
}
|
|
1472
1473
|
),
|
|
1473
|
-
|
|
1474
|
+
de && Pe === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
|
|
1474
1475
|
/* @__PURE__ */ u("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: [
|
|
1475
|
-
|
|
1476
|
+
Br,
|
|
1476
1477
|
" picked"
|
|
1477
1478
|
] }),
|
|
1478
|
-
/* @__PURE__ */
|
|
1479
|
+
/* @__PURE__ */ s(un, { show: Ae.customized, onReset: Ae.reset })
|
|
1479
1480
|
] }),
|
|
1480
1481
|
Kn && // Sticky: the catalog list is tall and the page scroller carries it —
|
|
1481
1482
|
// without this the labels scroll away and favorites/section rows
|
|
@@ -1484,43 +1485,43 @@ function da({
|
|
|
1484
1485
|
/* @__PURE__ */ u(
|
|
1485
1486
|
"div",
|
|
1486
1487
|
{
|
|
1487
|
-
ref:
|
|
1488
|
+
ref: Ar,
|
|
1488
1489
|
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",
|
|
1489
1490
|
children: [
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1491
|
+
a.favorites && /* @__PURE__ */ s("span", { className: "w-[18px] shrink-0" }),
|
|
1492
|
+
Tt(Ae, "item", "Item", "w-36 shrink-0"),
|
|
1493
|
+
$t.map((e) => {
|
|
1493
1494
|
const [t, n] = In(e);
|
|
1494
|
-
return
|
|
1495
|
-
|
|
1495
|
+
return Tt(
|
|
1496
|
+
Ae,
|
|
1496
1497
|
e.field,
|
|
1497
|
-
e.label ??
|
|
1498
|
+
e.label ?? X(e.field.split(".")[0]),
|
|
1498
1499
|
t,
|
|
1499
1500
|
n
|
|
1500
1501
|
);
|
|
1501
1502
|
}),
|
|
1502
|
-
|
|
1503
|
-
(e) =>
|
|
1504
|
-
|
|
1503
|
+
an.map(
|
|
1504
|
+
(e) => Tt(
|
|
1505
|
+
Ae,
|
|
1505
1506
|
`rel:${e.key}`,
|
|
1506
|
-
e.label ??
|
|
1507
|
+
e.label ?? X(e.key),
|
|
1507
1508
|
"w-20 shrink-0",
|
|
1508
1509
|
"text-right"
|
|
1509
1510
|
)
|
|
1510
1511
|
),
|
|
1511
|
-
/* @__PURE__ */
|
|
1512
|
-
/* @__PURE__ */
|
|
1513
|
-
/* @__PURE__ */
|
|
1512
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "ml-auto" }),
|
|
1513
|
+
/* @__PURE__ */ s("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
|
|
1514
|
+
/* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
|
|
1514
1515
|
]
|
|
1515
1516
|
}
|
|
1516
1517
|
),
|
|
1517
|
-
|
|
1518
|
-
/* @__PURE__ */
|
|
1518
|
+
U.trim().length > 0 && lt.length === 0 && Xt && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 border-b border-slate-100 px-3 py-3 text-slate-500 dark:border-border/50 dark:text-slate-400", children: [
|
|
1519
|
+
/* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1519
1520
|
" Searching the catalog…"
|
|
1520
1521
|
] }),
|
|
1521
|
-
|
|
1522
|
+
U.trim().length > 0 && lt.length === 0 && !Xt && /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-500 dark:text-slate-400", children: ce && Ve.length > 0 ? /* @__PURE__ */ u(Ne, { children: [
|
|
1522
1523
|
'Nothing in stock matches "',
|
|
1523
|
-
|
|
1524
|
+
U.trim(),
|
|
1524
1525
|
'" —',
|
|
1525
1526
|
" ",
|
|
1526
1527
|
/* @__PURE__ */ u(
|
|
@@ -1536,51 +1537,51 @@ function da({
|
|
|
1536
1537
|
]
|
|
1537
1538
|
}
|
|
1538
1539
|
)
|
|
1539
|
-
] }) : /* @__PURE__ */ u(
|
|
1540
|
+
] }) : /* @__PURE__ */ u(Ne, { children: [
|
|
1540
1541
|
'No items match "',
|
|
1541
|
-
|
|
1542
|
+
U.trim(),
|
|
1542
1543
|
'"'
|
|
1543
1544
|
] }) }),
|
|
1544
|
-
|
|
1545
|
+
U.trim().length > 0 && lt.length > 0 && /* @__PURE__ */ u(ot, { children: [
|
|
1545
1546
|
/* @__PURE__ */ u("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: [
|
|
1546
|
-
/* @__PURE__ */
|
|
1547
|
-
/* @__PURE__ */
|
|
1548
|
-
/* @__PURE__ */
|
|
1547
|
+
/* @__PURE__ */ s(At, { className: "h-3 w-3 shrink-0 text-sky-500" }),
|
|
1548
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
|
|
1549
|
+
/* @__PURE__ */ s("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: lt.length }),
|
|
1549
1550
|
/* @__PURE__ */ u("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
1550
1551
|
"across the entire catalog",
|
|
1551
|
-
|
|
1552
|
+
ce ? ", in stock only" : "",
|
|
1552
1553
|
" — enter a quantity to add"
|
|
1553
1554
|
] }),
|
|
1554
|
-
|
|
1555
|
+
Xt && /* @__PURE__ */ s(ue, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
|
|
1555
1556
|
] }),
|
|
1556
|
-
|
|
1557
|
-
const n = String(e.id), r =
|
|
1557
|
+
lt.map((e, t) => {
|
|
1558
|
+
const n = String(e.id), r = _e(n);
|
|
1558
1559
|
return /* @__PURE__ */ u(
|
|
1559
1560
|
"div",
|
|
1560
1561
|
{
|
|
1561
|
-
className:
|
|
1562
|
+
className: W(
|
|
1562
1563
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1563
1564
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1564
1565
|
(r ?? 0) > 0 && "bg-nvr-cyan/5"
|
|
1565
1566
|
),
|
|
1566
1567
|
children: [
|
|
1567
|
-
|
|
1568
|
-
|
|
1568
|
+
Mt(n),
|
|
1569
|
+
dn(
|
|
1569
1570
|
n,
|
|
1570
|
-
|
|
1571
|
+
Ke(A, e),
|
|
1571
1572
|
(() => {
|
|
1572
|
-
const l =
|
|
1573
|
-
return !l && !o ? null : /* @__PURE__ */ u(
|
|
1574
|
-
o && /* @__PURE__ */
|
|
1573
|
+
const l = Sr(e), o = kr.has(n);
|
|
1574
|
+
return !l && !o ? null : /* @__PURE__ */ u(Ne, { children: [
|
|
1575
|
+
o && /* @__PURE__ */ s(
|
|
1575
1576
|
"span",
|
|
1576
1577
|
{
|
|
1577
1578
|
"data-catalog-recent": !0,
|
|
1578
|
-
"data-tip": `You added this in the last ${
|
|
1579
|
+
"data-tip": `You added this in the last ${vt} days`,
|
|
1579
1580
|
className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-400",
|
|
1580
1581
|
children: "Recent"
|
|
1581
1582
|
}
|
|
1582
1583
|
),
|
|
1583
|
-
l && /* @__PURE__ */
|
|
1584
|
+
l && /* @__PURE__ */ s(
|
|
1584
1585
|
"span",
|
|
1585
1586
|
{
|
|
1586
1587
|
"data-catalog-match-why": !0,
|
|
@@ -1592,32 +1593,32 @@ function da({
|
|
|
1592
1593
|
)
|
|
1593
1594
|
] });
|
|
1594
1595
|
})(),
|
|
1595
|
-
|
|
1596
|
+
ye
|
|
1596
1597
|
),
|
|
1597
|
-
|
|
1598
|
-
/* @__PURE__ */
|
|
1599
|
-
|
|
1598
|
+
on(n, e, ye),
|
|
1599
|
+
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) }),
|
|
1600
|
+
Et(n, e)
|
|
1600
1601
|
]
|
|
1601
1602
|
},
|
|
1602
1603
|
n
|
|
1603
1604
|
);
|
|
1604
1605
|
})
|
|
1605
1606
|
] }),
|
|
1606
|
-
|
|
1607
|
+
ae.length > 0 && !U.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
|
|
1607
1608
|
"Search the full catalog above, or select",
|
|
1608
1609
|
" ",
|
|
1609
|
-
|
|
1610
|
+
ae.map((e) => {
|
|
1610
1611
|
var t;
|
|
1611
|
-
return ((t =
|
|
1612
|
+
return ((t = R == null ? void 0 : R.fieldLabels) == null ? void 0 : t[e]) ?? X(e);
|
|
1612
1613
|
}).join(", "),
|
|
1613
1614
|
" ",
|
|
1614
1615
|
"to browse by category"
|
|
1615
1616
|
] }),
|
|
1616
|
-
|
|
1617
|
-
/* @__PURE__ */
|
|
1617
|
+
ae.length === 0 && (bn || ht) && /* @__PURE__ */ u("div", { className: "flex items-center justify-center gap-2 py-6 text-slate-500 dark:text-slate-400", children: [
|
|
1618
|
+
/* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
|
|
1618
1619
|
" Loading catalog…"
|
|
1619
1620
|
] }),
|
|
1620
|
-
|
|
1621
|
+
ae.length === 0 && !bn && !ht && Rt.length === 0 && /* @__PURE__ */ s("p", { className: "px-3 py-6 text-center text-slate-500 dark:text-slate-400", children: ce && oe.length > 0 ? /* @__PURE__ */ u(Ne, { children: [
|
|
1621
1622
|
"Nothing in this catalog is in stock here —",
|
|
1622
1623
|
" ",
|
|
1623
1624
|
/* @__PURE__ */ u(
|
|
@@ -1628,39 +1629,39 @@ function da({
|
|
|
1628
1629
|
className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
1629
1630
|
children: [
|
|
1630
1631
|
"show all ",
|
|
1631
|
-
|
|
1632
|
+
oe.length
|
|
1632
1633
|
]
|
|
1633
1634
|
}
|
|
1634
1635
|
)
|
|
1635
1636
|
] }) : "No catalog items" }),
|
|
1636
|
-
|
|
1637
|
+
a.favorites && /* @__PURE__ */ u(ot, { children: [
|
|
1637
1638
|
/* @__PURE__ */ u("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: [
|
|
1638
1639
|
/* @__PURE__ */ u(
|
|
1639
1640
|
"button",
|
|
1640
1641
|
{
|
|
1641
1642
|
type: "button",
|
|
1642
|
-
onClick: () =>
|
|
1643
|
+
onClick: () => ge((e) => {
|
|
1643
1644
|
const t = new Set(e);
|
|
1644
1645
|
return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
|
|
1645
1646
|
}),
|
|
1646
1647
|
className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
|
|
1647
1648
|
children: [
|
|
1648
|
-
/* @__PURE__ */
|
|
1649
|
-
|
|
1649
|
+
/* @__PURE__ */ s(
|
|
1650
|
+
Kt,
|
|
1650
1651
|
{
|
|
1651
|
-
className:
|
|
1652
|
+
className: W(
|
|
1652
1653
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1653
|
-
!
|
|
1654
|
+
!he.has("__favorites__") && "rotate-90"
|
|
1654
1655
|
)
|
|
1655
1656
|
}
|
|
1656
1657
|
),
|
|
1657
|
-
/* @__PURE__ */
|
|
1658
|
-
/* @__PURE__ */
|
|
1659
|
-
/* @__PURE__ */
|
|
1658
|
+
/* @__PURE__ */ s(ct, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
1659
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
|
|
1660
|
+
/* @__PURE__ */ s("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: en.length })
|
|
1660
1661
|
]
|
|
1661
1662
|
}
|
|
1662
1663
|
),
|
|
1663
|
-
/* @__PURE__ */
|
|
1664
|
+
/* @__PURE__ */ s(
|
|
1664
1665
|
"button",
|
|
1665
1666
|
{
|
|
1666
1667
|
ref: vn,
|
|
@@ -1671,39 +1672,39 @@ function da({
|
|
|
1671
1672
|
}
|
|
1672
1673
|
)
|
|
1673
1674
|
] }),
|
|
1674
|
-
!
|
|
1675
|
-
!
|
|
1676
|
-
const n = String(e.id), r =
|
|
1675
|
+
!he.has("__favorites__") && en.length === 0 && /* @__PURE__ */ s("p", { className: "border-b border-slate-100 px-3 py-2 text-center text-[11px] text-slate-400 dark:border-border/50", children: et.length > 0 ? "None of your favorites are in stock here." : "No favorites yet — Manage lets you search the full catalog and star items." }),
|
|
1676
|
+
!he.has("__favorites__") && en.map((e, t) => {
|
|
1677
|
+
const n = String(e.id), r = _e(n), l = tn(n);
|
|
1677
1678
|
return /* @__PURE__ */ u(
|
|
1678
1679
|
"div",
|
|
1679
1680
|
{
|
|
1680
|
-
className:
|
|
1681
|
+
className: W(
|
|
1681
1682
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1682
1683
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1683
1684
|
(r ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1684
1685
|
l && "bg-amber-50 dark:bg-amber-900/15"
|
|
1685
1686
|
),
|
|
1686
1687
|
children: [
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
/* @__PURE__ */
|
|
1691
|
-
|
|
1688
|
+
Mt(n),
|
|
1689
|
+
dn(n, Ke(A, e)),
|
|
1690
|
+
on(n, e),
|
|
1691
|
+
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(n) ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : l && /* @__PURE__ */ s(
|
|
1692
|
+
He,
|
|
1692
1693
|
{
|
|
1693
1694
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1694
|
-
"aria-label": `${
|
|
1695
|
+
"aria-label": `${nn} ${l.available} — ${l.qty} requested`
|
|
1695
1696
|
}
|
|
1696
1697
|
) }),
|
|
1697
|
-
|
|
1698
|
+
Et(n, e)
|
|
1698
1699
|
]
|
|
1699
1700
|
},
|
|
1700
1701
|
n
|
|
1701
1702
|
);
|
|
1702
1703
|
})
|
|
1703
1704
|
] }),
|
|
1704
|
-
|
|
1705
|
-
const t =
|
|
1706
|
-
(r, l) => r + ((
|
|
1705
|
+
ae.length === 0 && Rt.map((e) => {
|
|
1706
|
+
const t = he.has(e.name), n = e.items.reduce(
|
|
1707
|
+
(r, l) => r + ((_e(l.id) ?? 0) > 0 ? 1 : 0),
|
|
1707
1708
|
0
|
|
1708
1709
|
);
|
|
1709
1710
|
return /* @__PURE__ */ u(ot, { children: [
|
|
@@ -1711,23 +1712,23 @@ function da({
|
|
|
1711
1712
|
"button",
|
|
1712
1713
|
{
|
|
1713
1714
|
type: "button",
|
|
1714
|
-
onClick: () =>
|
|
1715
|
+
onClick: () => ge((r) => {
|
|
1715
1716
|
const l = new Set(r);
|
|
1716
1717
|
return l.has(e.name) ? l.delete(e.name) : l.add(e.name), l;
|
|
1717
1718
|
}),
|
|
1718
1719
|
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",
|
|
1719
1720
|
children: [
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
|
|
1721
|
+
/* @__PURE__ */ s(
|
|
1722
|
+
Kt,
|
|
1722
1723
|
{
|
|
1723
|
-
className:
|
|
1724
|
+
className: W(
|
|
1724
1725
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1725
1726
|
!t && "rotate-90"
|
|
1726
1727
|
)
|
|
1727
1728
|
}
|
|
1728
1729
|
),
|
|
1729
|
-
/* @__PURE__ */
|
|
1730
|
-
/* @__PURE__ */
|
|
1730
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
|
|
1731
|
+
/* @__PURE__ */ s("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 }),
|
|
1731
1732
|
n > 0 && /* @__PURE__ */ u("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: [
|
|
1732
1733
|
n,
|
|
1733
1734
|
" picked"
|
|
@@ -1736,28 +1737,28 @@ function da({
|
|
|
1736
1737
|
}
|
|
1737
1738
|
),
|
|
1738
1739
|
!t && e.items.map((r, l) => {
|
|
1739
|
-
const o =
|
|
1740
|
+
const o = _e(r.id), p = tn(r.id);
|
|
1740
1741
|
return /* @__PURE__ */ u(
|
|
1741
1742
|
"div",
|
|
1742
1743
|
{
|
|
1743
|
-
className:
|
|
1744
|
+
className: W(
|
|
1744
1745
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1745
1746
|
l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1746
1747
|
(o ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1747
|
-
|
|
1748
|
+
p && "bg-amber-50 dark:bg-amber-900/15"
|
|
1748
1749
|
),
|
|
1749
1750
|
children: [
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
/* @__PURE__ */
|
|
1754
|
-
|
|
1751
|
+
Mt(r.id),
|
|
1752
|
+
dn(r.id, r.label),
|
|
1753
|
+
on(r.id, r.row),
|
|
1754
|
+
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children: ee.has(r.id) ? /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }) : p && /* @__PURE__ */ s(
|
|
1755
|
+
He,
|
|
1755
1756
|
{
|
|
1756
1757
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1757
|
-
"aria-label": `${
|
|
1758
|
+
"aria-label": `${nn} ${p.available} — ${p.qty} requested`
|
|
1758
1759
|
}
|
|
1759
1760
|
) }),
|
|
1760
|
-
|
|
1761
|
+
Et(r.id, r.row)
|
|
1761
1762
|
]
|
|
1762
1763
|
},
|
|
1763
1764
|
r.id
|
|
@@ -1766,349 +1767,367 @@ function da({
|
|
|
1766
1767
|
] }, e.name);
|
|
1767
1768
|
})
|
|
1768
1769
|
] }),
|
|
1769
|
-
(
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1770
|
+
(a.builders ?? []).filter((e) => ir(e.show_when, S)).map(
|
|
1771
|
+
(e) => {
|
|
1772
|
+
var t;
|
|
1773
|
+
return (t = e.facets) != null && t.length && e.source ? /* @__PURE__ */ s(
|
|
1774
|
+
Js,
|
|
1775
|
+
{
|
|
1776
|
+
builder: e,
|
|
1777
|
+
catalogCol: y,
|
|
1778
|
+
catalogFields: z,
|
|
1779
|
+
tmpl: A,
|
|
1780
|
+
currentQty: _e,
|
|
1781
|
+
addQty: (n, r, l) => Be(n, String(r), l),
|
|
1782
|
+
qtyStep: dt(L) ? 1 : "any",
|
|
1783
|
+
readOnly: w
|
|
1784
|
+
},
|
|
1785
|
+
e.label
|
|
1786
|
+
) : /* @__PURE__ */ s(
|
|
1787
|
+
Cs,
|
|
1788
|
+
{
|
|
1789
|
+
builder: e,
|
|
1790
|
+
defaultItemField: a.item_field,
|
|
1791
|
+
catalogCol: y,
|
|
1792
|
+
catalogFields: z,
|
|
1793
|
+
tmpl: A,
|
|
1794
|
+
currentQty: _e,
|
|
1795
|
+
addQty: (n, r, l) => Be(n, String(r), l),
|
|
1796
|
+
qtyStep: dt(L) ? 1 : "any",
|
|
1797
|
+
readOnly: w
|
|
1798
|
+
},
|
|
1799
|
+
e.label
|
|
1800
|
+
);
|
|
1801
|
+
}
|
|
1802
|
+
)
|
|
1784
1803
|
] }),
|
|
1785
1804
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1786
1805
|
/* @__PURE__ */ u("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: [
|
|
1787
|
-
/* @__PURE__ */
|
|
1806
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
|
|
1788
1807
|
!w && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
|
|
1789
|
-
|
|
1790
|
-
|
|
1808
|
+
a.upload_template && !P && H && x && /* @__PURE__ */ s(
|
|
1809
|
+
cs,
|
|
1791
1810
|
{
|
|
1792
1811
|
collection: x,
|
|
1793
1812
|
templateFilter: (e) => {
|
|
1794
1813
|
var t;
|
|
1795
|
-
return e.name ===
|
|
1814
|
+
return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
|
|
1796
1815
|
},
|
|
1797
1816
|
getLabel: (e) => {
|
|
1798
1817
|
var t;
|
|
1799
1818
|
return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
|
|
1800
1819
|
},
|
|
1801
|
-
onParsed: (e, t) =>
|
|
1820
|
+
onParsed: (e, t) => H(e, t),
|
|
1802
1821
|
compact: !0
|
|
1803
1822
|
}
|
|
1804
1823
|
),
|
|
1805
|
-
/* @__PURE__ */
|
|
1806
|
-
|
|
1824
|
+
/* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
|
|
1825
|
+
qs,
|
|
1807
1826
|
{
|
|
1808
|
-
collection:
|
|
1827
|
+
collection: y,
|
|
1809
1828
|
value: null,
|
|
1810
|
-
onChange: (e) => void
|
|
1829
|
+
onChange: (e) => void Ur(e),
|
|
1811
1830
|
placeholder: "+ Add any item…",
|
|
1812
|
-
displayTemplate:
|
|
1831
|
+
displayTemplate: zs(A, a.columns)
|
|
1813
1832
|
}
|
|
1814
1833
|
) })
|
|
1815
1834
|
] })
|
|
1816
1835
|
] }),
|
|
1817
|
-
|
|
1818
|
-
const e =
|
|
1819
|
-
|
|
1820
|
-
|
|
1836
|
+
Se.length === 0 ? /* @__PURE__ */ s("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
|
|
1837
|
+
const e = En.filter((c) => !c.format), t = e[0], n = e.slice(1), r = En.filter((c) => !!c.format), l = (c, h) => h === "presence" ? c == null || c === "" || Number(c) === 0 ? "No" : "Yes" : c === !0 || c === "true" ? "✓" : c === !1 || c === "false" || c == null || c === "" ? "—" : Te(c, h), o = (c, h) => h ? Tt(
|
|
1838
|
+
Oe,
|
|
1839
|
+
h,
|
|
1821
1840
|
c,
|
|
1822
1841
|
"w-20 shrink-0",
|
|
1823
1842
|
"text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
|
|
1824
|
-
) : /* @__PURE__ */
|
|
1843
|
+
) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[11px] font-medium text-slate-500 dark:text-slate-400", children: c }), p = (c) => M.includes(c) && !w ? void 0 : `s:${c}`;
|
|
1825
1844
|
return /* @__PURE__ */ u("div", { children: [
|
|
1826
1845
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
|
|
1827
1846
|
/* @__PURE__ */ u("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
|
|
1828
1847
|
"Item",
|
|
1829
|
-
w && /* @__PURE__ */
|
|
1830
|
-
|
|
1848
|
+
w && /* @__PURE__ */ s(
|
|
1849
|
+
un,
|
|
1831
1850
|
{
|
|
1832
|
-
show:
|
|
1833
|
-
onReset:
|
|
1851
|
+
show: Oe.customized,
|
|
1852
|
+
onReset: Oe.reset,
|
|
1834
1853
|
className: "-my-1"
|
|
1835
1854
|
}
|
|
1836
1855
|
)
|
|
1837
1856
|
] }),
|
|
1838
|
-
|
|
1839
|
-
o(
|
|
1840
|
-
|
|
1841
|
-
!w && /* @__PURE__ */
|
|
1857
|
+
Lt.map((c) => /* @__PURE__ */ s(ot, { children: o(X(c), p(c)) }, c)),
|
|
1858
|
+
o(X(I)),
|
|
1859
|
+
De.map((c) => /* @__PURE__ */ s(ot, { children: o(X(c), `s:${c}`) }, c)),
|
|
1860
|
+
!w && /* @__PURE__ */ s("span", { className: "-my-1 flex w-6 shrink-0 justify-end", children: /* @__PURE__ */ s(un, { show: Oe.customized, onReset: Oe.reset }) })
|
|
1842
1861
|
] }),
|
|
1843
|
-
|
|
1844
|
-
const
|
|
1862
|
+
Se.map((c, h) => {
|
|
1863
|
+
const b = c.row.id != null ? String(c.row.id) : null, q = b != null && yt.has(b), j = q ? null : tn(c.key), J = q ? null : Tr(c.key);
|
|
1845
1864
|
return /* @__PURE__ */ u(
|
|
1846
1865
|
"div",
|
|
1847
1866
|
{
|
|
1848
|
-
className:
|
|
1867
|
+
className: W(
|
|
1849
1868
|
"border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1869
|
+
h % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1870
|
+
j && "bg-amber-50 dark:bg-amber-900/15",
|
|
1871
|
+
J && "bg-red-50/70 dark:bg-red-900/15",
|
|
1872
|
+
q && "opacity-60"
|
|
1854
1873
|
),
|
|
1855
1874
|
children: [
|
|
1856
1875
|
/* @__PURE__ */ u(
|
|
1857
1876
|
"div",
|
|
1858
1877
|
{
|
|
1859
|
-
className:
|
|
1878
|
+
className: W(
|
|
1860
1879
|
"flex items-center gap-4",
|
|
1861
|
-
|
|
1880
|
+
q && "line-through decoration-slate-400"
|
|
1862
1881
|
),
|
|
1863
1882
|
children: [
|
|
1864
|
-
|
|
1883
|
+
Qn(
|
|
1865
1884
|
c.key,
|
|
1866
|
-
|
|
1885
|
+
Ot(c.key),
|
|
1867
1886
|
"shrink-0 font-semibold text-slate-800 dark:text-slate-100"
|
|
1868
1887
|
),
|
|
1869
|
-
|
|
1888
|
+
Ge && !q && (b == null || bt.has(b)) && /* @__PURE__ */ s(
|
|
1870
1889
|
"span",
|
|
1871
1890
|
{
|
|
1872
|
-
"data-catalog-staged":
|
|
1891
|
+
"data-catalog-staged": b == null ? "new" : "edited",
|
|
1873
1892
|
"data-tip": "Applies when you save the record",
|
|
1874
1893
|
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",
|
|
1875
|
-
children:
|
|
1894
|
+
children: b == null ? "New" : "Edited"
|
|
1876
1895
|
}
|
|
1877
1896
|
),
|
|
1878
|
-
|
|
1897
|
+
J && /* @__PURE__ */ s(
|
|
1879
1898
|
"span",
|
|
1880
1899
|
{
|
|
1881
1900
|
className: "shrink-0",
|
|
1882
1901
|
"data-tip": `This line was in the failed submission
|
|
1883
|
-
${
|
|
1902
|
+
${J}`,
|
|
1884
1903
|
"data-submission-error": !0,
|
|
1885
|
-
children: /* @__PURE__ */
|
|
1904
|
+
children: /* @__PURE__ */ s(cn, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
|
|
1886
1905
|
}
|
|
1887
1906
|
),
|
|
1888
|
-
t && /* @__PURE__ */
|
|
1907
|
+
t && /* @__PURE__ */ s(
|
|
1889
1908
|
lr,
|
|
1890
1909
|
{
|
|
1891
|
-
text:
|
|
1910
|
+
text: Te(jt(ze(c.key), t.field), void 0),
|
|
1892
1911
|
className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
|
|
1893
1912
|
}
|
|
1894
1913
|
),
|
|
1895
|
-
!t && /* @__PURE__ */
|
|
1896
|
-
n.map((
|
|
1897
|
-
const
|
|
1898
|
-
return
|
|
1914
|
+
!t && /* @__PURE__ */ s("span", { className: "flex-1" }),
|
|
1915
|
+
n.map((g) => {
|
|
1916
|
+
const V = jt(ze(c.key), g.field);
|
|
1917
|
+
return V == null || V === "" ? null : /* @__PURE__ */ s(
|
|
1899
1918
|
"span",
|
|
1900
1919
|
{
|
|
1901
1920
|
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",
|
|
1902
|
-
children: String(
|
|
1921
|
+
children: String(V)
|
|
1903
1922
|
},
|
|
1904
|
-
|
|
1923
|
+
g.field
|
|
1905
1924
|
);
|
|
1906
1925
|
}),
|
|
1907
|
-
|
|
1908
|
-
(
|
|
1909
|
-
var
|
|
1910
|
-
return
|
|
1926
|
+
Lt.map(
|
|
1927
|
+
(g) => {
|
|
1928
|
+
var V;
|
|
1929
|
+
return Mr(c.key, g) ? Dr(c.key, g, c.row) : /* @__PURE__ */ s(
|
|
1911
1930
|
"span",
|
|
1912
1931
|
{
|
|
1913
|
-
"data-catalog-locked": !w &&
|
|
1914
|
-
"data-tip": !w &&
|
|
1915
|
-
...
|
|
1916
|
-
`s:${
|
|
1932
|
+
"data-catalog-locked": !w && M.includes(g) ? g : void 0,
|
|
1933
|
+
"data-tip": !w && M.includes(g) ? "Set by the catalog — only an administrator can change it" : void 0,
|
|
1934
|
+
...Oe.box(
|
|
1935
|
+
`s:${g}`,
|
|
1917
1936
|
"w-20 shrink-0",
|
|
1918
1937
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1919
1938
|
),
|
|
1920
|
-
children:
|
|
1939
|
+
children: Te(c.row[g], (V = a.field_formats) == null ? void 0 : V[g])
|
|
1921
1940
|
},
|
|
1922
|
-
|
|
1941
|
+
g
|
|
1923
1942
|
);
|
|
1924
1943
|
}
|
|
1925
1944
|
),
|
|
1926
1945
|
/* @__PURE__ */ u("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
|
|
1927
|
-
|
|
1928
|
-
|
|
1946
|
+
ee.has(c.key) && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
1947
|
+
Et(c.key, ze(c.key))
|
|
1929
1948
|
] }),
|
|
1930
|
-
|
|
1949
|
+
De.map((g) => {
|
|
1931
1950
|
var er, tr;
|
|
1932
|
-
if (
|
|
1933
|
-
return /* @__PURE__ */
|
|
1951
|
+
if (q)
|
|
1952
|
+
return /* @__PURE__ */ s(
|
|
1934
1953
|
"span",
|
|
1935
1954
|
{
|
|
1936
1955
|
"data-tip": "Not counted — this line is removed when you save",
|
|
1937
|
-
...
|
|
1938
|
-
`s:${
|
|
1956
|
+
...Oe.box(
|
|
1957
|
+
`s:${g}`,
|
|
1939
1958
|
"w-20 shrink-0",
|
|
1940
1959
|
"text-right tabular-nums text-slate-400 dark:text-slate-500"
|
|
1941
1960
|
),
|
|
1942
1961
|
children: "—"
|
|
1943
1962
|
},
|
|
1944
|
-
|
|
1963
|
+
g
|
|
1945
1964
|
);
|
|
1946
|
-
const
|
|
1947
|
-
return /* @__PURE__ */
|
|
1965
|
+
const V = c.row[g], Le = V != null && V !== "" ? V : Ee(((er = a.compute_fields) == null ? void 0 : er[g]) ?? "", c.row);
|
|
1966
|
+
return /* @__PURE__ */ s(
|
|
1948
1967
|
"span",
|
|
1949
1968
|
{
|
|
1950
|
-
...
|
|
1951
|
-
`s:${
|
|
1969
|
+
...Oe.box(
|
|
1970
|
+
`s:${g}`,
|
|
1952
1971
|
"w-20 shrink-0",
|
|
1953
1972
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1954
1973
|
),
|
|
1955
|
-
children:
|
|
1974
|
+
children: Te(Le, (tr = a.field_formats) == null ? void 0 : tr[g])
|
|
1956
1975
|
},
|
|
1957
|
-
|
|
1976
|
+
g
|
|
1958
1977
|
);
|
|
1959
1978
|
}),
|
|
1960
|
-
!w &&
|
|
1979
|
+
!w && q && /* @__PURE__ */ s(
|
|
1961
1980
|
"button",
|
|
1962
1981
|
{
|
|
1963
1982
|
type: "button",
|
|
1964
|
-
onClick: () =>
|
|
1983
|
+
onClick: () => N == null ? void 0 : N.cancelPendingDelete(i, m, b),
|
|
1965
1984
|
className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
|
|
1966
1985
|
children: "Undo"
|
|
1967
1986
|
}
|
|
1968
1987
|
),
|
|
1969
|
-
!w && !
|
|
1988
|
+
!w && !q && /* @__PURE__ */ s(
|
|
1970
1989
|
"button",
|
|
1971
1990
|
{
|
|
1972
1991
|
type: "button",
|
|
1973
1992
|
title: "Remove (applies on Save)",
|
|
1974
1993
|
onClick: () => {
|
|
1975
|
-
if (!P &&
|
|
1976
|
-
|
|
1994
|
+
if (!P && N && b != null) {
|
|
1995
|
+
N.queueDelete(i, m, b);
|
|
1977
1996
|
return;
|
|
1978
1997
|
}
|
|
1979
|
-
|
|
1998
|
+
Be(c.key, "0", {}, { confirmedRemove: !0 });
|
|
1980
1999
|
},
|
|
1981
2000
|
className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
|
|
1982
|
-
children: /* @__PURE__ */
|
|
2001
|
+
children: /* @__PURE__ */ s(ut, { className: "mx-auto h-3.5 w-3.5" })
|
|
1983
2002
|
}
|
|
1984
2003
|
)
|
|
1985
2004
|
]
|
|
1986
2005
|
}
|
|
1987
2006
|
),
|
|
1988
|
-
(r.length > 0 || An.length > 0 ||
|
|
1989
|
-
r.map((
|
|
1990
|
-
/* @__PURE__ */
|
|
2007
|
+
(r.length > 0 || An.length > 0 || qt.length > 0) && /* @__PURE__ */ u("div", { className: "mt-1 flex flex-wrap items-baseline gap-x-4 gap-y-0.5 pl-0.5 text-[11px]", children: [
|
|
2008
|
+
r.map((g) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
2009
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.field.split(".")[0]) }),
|
|
1991
2010
|
" ",
|
|
1992
|
-
/* @__PURE__ */
|
|
1993
|
-
] },
|
|
1994
|
-
An.map((
|
|
1995
|
-
/* @__PURE__ */
|
|
2011
|
+
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(jt(ze(c.key), g.field), g.format) })
|
|
2012
|
+
] }, g.field)),
|
|
2013
|
+
An.map((g) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
2014
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.key) }),
|
|
1996
2015
|
" ",
|
|
1997
|
-
/* @__PURE__ */
|
|
1998
|
-
] },
|
|
1999
|
-
|
|
2000
|
-
|
|
2016
|
+
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(at(g.key, c.key), g.format) })
|
|
2017
|
+
] }, g.key)),
|
|
2018
|
+
Er(c.row),
|
|
2019
|
+
qr(c.row).map((g) => /* @__PURE__ */ u(
|
|
2001
2020
|
"span",
|
|
2002
2021
|
{
|
|
2003
2022
|
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",
|
|
2004
|
-
"data-catalog-row-flag":
|
|
2023
|
+
"data-catalog-row-flag": g,
|
|
2005
2024
|
children: [
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
|
|
2025
|
+
/* @__PURE__ */ s(He, { className: "h-3 w-3" }),
|
|
2026
|
+
g
|
|
2008
2027
|
]
|
|
2009
2028
|
},
|
|
2010
|
-
|
|
2029
|
+
g
|
|
2011
2030
|
)),
|
|
2012
|
-
|
|
2013
|
-
const
|
|
2031
|
+
qt.map((g) => {
|
|
2032
|
+
const V = Pr(g, c);
|
|
2014
2033
|
return /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
2015
|
-
/* @__PURE__ */
|
|
2034
|
+
/* @__PURE__ */ s("span", { className: "text-slate-500 dark:text-muted-foreground", children: g.label ?? X(g.field) }),
|
|
2016
2035
|
" ",
|
|
2017
|
-
/* @__PURE__ */
|
|
2018
|
-
] },
|
|
2036
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(V, g.format) })
|
|
2037
|
+
] }, g.field);
|
|
2019
2038
|
})
|
|
2020
2039
|
] }),
|
|
2021
|
-
|
|
2022
|
-
/* @__PURE__ */
|
|
2023
|
-
|
|
2040
|
+
j && /* @__PURE__ */ u("p", { className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400", children: [
|
|
2041
|
+
/* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
|
|
2042
|
+
nn,
|
|
2024
2043
|
" is ",
|
|
2025
|
-
|
|
2044
|
+
Te(j.available, "number"),
|
|
2026
2045
|
" —",
|
|
2027
2046
|
" ",
|
|
2028
|
-
|
|
2047
|
+
Te(j.qty, "number"),
|
|
2029
2048
|
" requested"
|
|
2030
2049
|
] }),
|
|
2031
|
-
!
|
|
2050
|
+
!q && Ks(
|
|
2032
2051
|
{
|
|
2033
2052
|
...c.row,
|
|
2034
2053
|
...Object.fromEntries(
|
|
2035
|
-
|
|
2036
|
-
var
|
|
2054
|
+
De.filter((g) => c.row[g] == null || c.row[g] === "").map((g) => {
|
|
2055
|
+
var V;
|
|
2037
2056
|
return [
|
|
2038
|
-
|
|
2039
|
-
|
|
2057
|
+
g,
|
|
2058
|
+
Ee(((V = a.compute_fields) == null ? void 0 : V[g]) ?? "", c.row)
|
|
2040
2059
|
];
|
|
2041
2060
|
})
|
|
2042
2061
|
)
|
|
2043
2062
|
},
|
|
2044
|
-
|
|
2045
|
-
|
|
2063
|
+
I,
|
|
2064
|
+
De.length > 0 ? De : Lt
|
|
2046
2065
|
) && /* @__PURE__ */ u(
|
|
2047
2066
|
"p",
|
|
2048
2067
|
{
|
|
2049
2068
|
"data-catalog-unpriced": !0,
|
|
2050
2069
|
className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",
|
|
2051
2070
|
children: [
|
|
2052
|
-
/* @__PURE__ */
|
|
2071
|
+
/* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
|
|
2053
2072
|
"No catalog price: check the price or hand-price it"
|
|
2054
2073
|
]
|
|
2055
2074
|
}
|
|
2056
2075
|
),
|
|
2057
|
-
|
|
2076
|
+
q && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
|
|
2058
2077
|
]
|
|
2059
2078
|
},
|
|
2060
2079
|
c.key
|
|
2061
2080
|
);
|
|
2062
2081
|
}),
|
|
2063
2082
|
(() => {
|
|
2064
|
-
const c =
|
|
2065
|
-
const
|
|
2066
|
-
return !(
|
|
2067
|
-
}),
|
|
2068
|
-
c.map((
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
),
|
|
2072
|
-
var
|
|
2073
|
-
return ((
|
|
2074
|
-
},
|
|
2083
|
+
const c = Se.filter((j) => {
|
|
2084
|
+
const J = j.row.id != null ? String(j.row.id) : null;
|
|
2085
|
+
return !(J != null && yt.has(J));
|
|
2086
|
+
}), h = (j) => Os(
|
|
2087
|
+
c.map((J) => J.row),
|
|
2088
|
+
j,
|
|
2089
|
+
a.compute_fields
|
|
2090
|
+
), b = (j) => {
|
|
2091
|
+
var J;
|
|
2092
|
+
return ((J = a.field_formats) == null ? void 0 : J[j]) ?? "number";
|
|
2093
|
+
}, q = (j) => /* @__PURE__ */ s(
|
|
2075
2094
|
"span",
|
|
2076
2095
|
{
|
|
2077
|
-
...
|
|
2078
|
-
`s:${
|
|
2096
|
+
...Oe.box(
|
|
2097
|
+
`s:${j}`,
|
|
2079
2098
|
"w-20 shrink-0",
|
|
2080
2099
|
"truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
|
|
2081
2100
|
),
|
|
2082
|
-
children:
|
|
2101
|
+
children: Te(h(j), b(j))
|
|
2083
2102
|
},
|
|
2084
|
-
|
|
2103
|
+
j
|
|
2085
2104
|
);
|
|
2086
2105
|
return /* @__PURE__ */ u("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: [
|
|
2087
|
-
/* @__PURE__ */
|
|
2088
|
-
|
|
2089
|
-
const
|
|
2090
|
-
return
|
|
2106
|
+
/* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
|
|
2107
|
+
Lt.map((j) => {
|
|
2108
|
+
const J = p(j);
|
|
2109
|
+
return J ? /* @__PURE__ */ s("span", { ...Oe.box(J, "w-20 shrink-0") }, j) : /* @__PURE__ */ s("span", { className: "w-20 shrink-0" }, j);
|
|
2091
2110
|
}),
|
|
2092
|
-
/* @__PURE__ */
|
|
2093
|
-
|
|
2094
|
-
!w && /* @__PURE__ */
|
|
2111
|
+
/* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children: Te(h(I), "number") }),
|
|
2112
|
+
De.map(q),
|
|
2113
|
+
!w && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
|
|
2095
2114
|
] });
|
|
2096
2115
|
})()
|
|
2097
2116
|
] });
|
|
2098
2117
|
})()
|
|
2099
2118
|
] }),
|
|
2100
|
-
|
|
2101
|
-
|
|
2119
|
+
xr && y && /* @__PURE__ */ s(
|
|
2120
|
+
Qs,
|
|
2102
2121
|
{
|
|
2103
|
-
catalogCol:
|
|
2104
|
-
tmpl:
|
|
2105
|
-
sectionBy:
|
|
2122
|
+
catalogCol: y,
|
|
2123
|
+
tmpl: A,
|
|
2124
|
+
sectionBy: a.section_by,
|
|
2106
2125
|
sectionM2M: d,
|
|
2107
2126
|
pinnedSet: zt,
|
|
2108
|
-
pinnedIds:
|
|
2109
|
-
savingIds:
|
|
2110
|
-
relatedCols: (
|
|
2111
|
-
parentDraft:
|
|
2127
|
+
pinnedIds: Re,
|
|
2128
|
+
savingIds: wt,
|
|
2129
|
+
relatedCols: (a.favorites_manager_columns ?? []).map((e) => (a.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
|
|
2130
|
+
parentDraft: S,
|
|
2112
2131
|
onToggle: (e) => void wn(e),
|
|
2113
2132
|
onClose: () => Nn(!1),
|
|
2114
2133
|
anchor: vn.current
|
|
@@ -2116,88 +2135,86 @@ ${E}`,
|
|
|
2116
2135
|
)
|
|
2117
2136
|
] }) : /* @__PURE__ */ u("p", { className: "py-1 text-[12px] text-slate-400", children: [
|
|
2118
2137
|
'Catalog picker: field "',
|
|
2119
|
-
|
|
2138
|
+
a.item_field,
|
|
2120
2139
|
'" does not resolve to an M2O relation on',
|
|
2121
2140
|
" ",
|
|
2122
2141
|
i
|
|
2123
2142
|
] });
|
|
2124
2143
|
}
|
|
2125
|
-
function
|
|
2144
|
+
function Cs({
|
|
2126
2145
|
builder: i,
|
|
2127
2146
|
defaultItemField: m,
|
|
2128
|
-
catalogCol:
|
|
2147
|
+
catalogCol: f,
|
|
2129
2148
|
catalogFields: x,
|
|
2130
2149
|
tmpl: _,
|
|
2131
|
-
currentQty:
|
|
2150
|
+
currentQty: a,
|
|
2132
2151
|
addQty: w,
|
|
2133
2152
|
qtyStep: k,
|
|
2134
|
-
readOnly:
|
|
2153
|
+
readOnly: F
|
|
2135
2154
|
}) {
|
|
2136
|
-
const
|
|
2155
|
+
const N = mt(), R = i.item_field ?? m, H = i.attributes ?? [], [M, me] = D(!1), [fe, P] = D({}), [be, I] = D("1"), [he, ge] = D(!1), ke = E(
|
|
2137
2156
|
() => [
|
|
2138
2157
|
"id",
|
|
2139
|
-
|
|
2140
|
-
...
|
|
2158
|
+
R,
|
|
2159
|
+
...H.flatMap((T) => [`${T.field}.id`, `${T.field}.${T.label_field}`])
|
|
2141
2160
|
].join(","),
|
|
2142
|
-
[
|
|
2143
|
-
), { data:
|
|
2161
|
+
[R, H]
|
|
2162
|
+
), { data: U = [], isLoading: je } = Q({
|
|
2144
2163
|
queryKey: [
|
|
2145
2164
|
"catalog-builder",
|
|
2146
2165
|
i.collection,
|
|
2147
|
-
|
|
2166
|
+
ke,
|
|
2148
2167
|
JSON.stringify(i.filter ?? null)
|
|
2149
2168
|
],
|
|
2150
|
-
queryFn: () =>
|
|
2151
|
-
|
|
2169
|
+
queryFn: () => N.request(
|
|
2170
|
+
K(`/items/${i.collection}`, {
|
|
2152
2171
|
limit: 2e3,
|
|
2153
|
-
fields:
|
|
2172
|
+
fields: ke,
|
|
2154
2173
|
...i.filter ? { filter: JSON.stringify(i.filter) } : {}
|
|
2155
2174
|
})
|
|
2156
|
-
).then((
|
|
2157
|
-
enabled:
|
|
2175
|
+
).then((T) => T.data ?? []),
|
|
2176
|
+
enabled: M,
|
|
2158
2177
|
staleTime: 6e4
|
|
2159
|
-
}),
|
|
2160
|
-
var
|
|
2161
|
-
const
|
|
2162
|
-
if (
|
|
2163
|
-
if (typeof
|
|
2164
|
-
const
|
|
2165
|
-
return { id: String(
|
|
2178
|
+
}), pe = (T, y) => {
|
|
2179
|
+
var L;
|
|
2180
|
+
const v = T[y];
|
|
2181
|
+
if (v == null) return null;
|
|
2182
|
+
if (typeof v == "object") {
|
|
2183
|
+
const O = v, $ = ((L = H.find((A) => A.field === y)) == null ? void 0 : L.label_field) ?? "id";
|
|
2184
|
+
return { id: String(O.id ?? ""), label: String(O[$] ?? O.id ?? "") };
|
|
2166
2185
|
}
|
|
2167
|
-
return { id: String(
|
|
2168
|
-
},
|
|
2169
|
-
(
|
|
2170
|
-
var
|
|
2171
|
-
const
|
|
2172
|
-
return
|
|
2186
|
+
return { id: String(v), label: String(v) };
|
|
2187
|
+
}, re = (T) => U.filter(
|
|
2188
|
+
(y) => H.slice(0, T).every((v) => {
|
|
2189
|
+
var O;
|
|
2190
|
+
const L = fe[v.field];
|
|
2191
|
+
return L ? ((O = pe(y, v.field)) == null ? void 0 : O.id) === L : !0;
|
|
2173
2192
|
})
|
|
2174
|
-
),
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
R(`/items/${b}`, {
|
|
2183
|
-
filter: JSON.stringify({ id: { _eq: V } }),
|
|
2193
|
+
), ee = H.every((T) => fe[T.field]), Z = ee ? U.find((T) => H.every((y) => {
|
|
2194
|
+
var v;
|
|
2195
|
+
return ((v = pe(T, y.field)) == null ? void 0 : v.id) === fe[y.field];
|
|
2196
|
+
})) : void 0, B = (Z == null ? void 0 : Z[R]) != null ? String(Z[R]) : null, { data: se } = Q({
|
|
2197
|
+
queryKey: ["catalog-builder-item", f, x, B],
|
|
2198
|
+
queryFn: () => N.request(
|
|
2199
|
+
K(`/items/${f}`, {
|
|
2200
|
+
filter: JSON.stringify({ id: { _eq: B } }),
|
|
2184
2201
|
fields: x,
|
|
2185
2202
|
limit: 1
|
|
2186
2203
|
})
|
|
2187
|
-
).then((
|
|
2188
|
-
var
|
|
2189
|
-
return ((
|
|
2204
|
+
).then((T) => {
|
|
2205
|
+
var y;
|
|
2206
|
+
return ((y = T.data) == null ? void 0 : y[0]) ?? null;
|
|
2190
2207
|
}),
|
|
2191
|
-
enabled: !!
|
|
2208
|
+
enabled: !!B,
|
|
2192
2209
|
staleTime: 6e4
|
|
2193
|
-
}),
|
|
2194
|
-
async function
|
|
2195
|
-
if (!(!
|
|
2196
|
-
|
|
2210
|
+
}), ie = Number(be), ve = !!B && !!se && !he && be.trim() !== "" && Number.isFinite(ie) && ie > 0 && (k === "any" || Number.isInteger(ie));
|
|
2211
|
+
async function xe() {
|
|
2212
|
+
if (!(!ve || !B || !se)) {
|
|
2213
|
+
ge(!0);
|
|
2197
2214
|
try {
|
|
2198
|
-
await w(
|
|
2215
|
+
await w(B, (a(B) ?? 0) + ie, se), P({}), I("1");
|
|
2199
2216
|
} finally {
|
|
2200
|
-
|
|
2217
|
+
ge(!1);
|
|
2201
2218
|
}
|
|
2202
2219
|
}
|
|
2203
2220
|
}
|
|
@@ -2206,73 +2223,73 @@ function Ps({
|
|
|
2206
2223
|
"button",
|
|
2207
2224
|
{
|
|
2208
2225
|
type: "button",
|
|
2209
|
-
onClick: () =>
|
|
2226
|
+
onClick: () => me((T) => !T),
|
|
2210
2227
|
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",
|
|
2211
2228
|
children: [
|
|
2212
|
-
/* @__PURE__ */
|
|
2213
|
-
|
|
2229
|
+
/* @__PURE__ */ s(
|
|
2230
|
+
Kt,
|
|
2214
2231
|
{
|
|
2215
|
-
className:
|
|
2232
|
+
className: W(
|
|
2216
2233
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
2217
|
-
|
|
2234
|
+
M && "rotate-90"
|
|
2218
2235
|
)
|
|
2219
2236
|
}
|
|
2220
2237
|
),
|
|
2221
|
-
/* @__PURE__ */
|
|
2238
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
|
|
2222
2239
|
]
|
|
2223
2240
|
}
|
|
2224
2241
|
),
|
|
2225
|
-
|
|
2226
|
-
/* @__PURE__ */
|
|
2242
|
+
M && /* @__PURE__ */ s("div", { className: "space-y-2 border-t border-slate-200 p-3 dark:border-border", children: je ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
|
|
2243
|
+
/* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
|
|
2227
2244
|
" Loading options…"
|
|
2228
2245
|
] }) : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
2229
|
-
|
|
2230
|
-
const
|
|
2231
|
-
for (const
|
|
2232
|
-
const
|
|
2233
|
-
|
|
2246
|
+
H.map((T, y) => {
|
|
2247
|
+
const v = /* @__PURE__ */ new Map();
|
|
2248
|
+
for (const O of re(y)) {
|
|
2249
|
+
const $ = pe(O, T.field);
|
|
2250
|
+
$ != null && $.id && v.set($.id, $.label);
|
|
2234
2251
|
}
|
|
2235
|
-
const
|
|
2236
|
-
([,
|
|
2252
|
+
const L = [...v.entries()].sort(
|
|
2253
|
+
([, O], [, $]) => O.localeCompare($, void 0, { numeric: !0 })
|
|
2237
2254
|
);
|
|
2238
|
-
return /* @__PURE__ */
|
|
2239
|
-
|
|
2255
|
+
return /* @__PURE__ */ s(
|
|
2256
|
+
mr,
|
|
2240
2257
|
{
|
|
2241
|
-
label:
|
|
2242
|
-
value:
|
|
2243
|
-
valueLabel:
|
|
2244
|
-
options:
|
|
2245
|
-
disabled:
|
|
2246
|
-
onChange: (
|
|
2247
|
-
const
|
|
2248
|
-
for (let
|
|
2249
|
-
const
|
|
2250
|
-
|
|
2258
|
+
label: X(T.field),
|
|
2259
|
+
value: fe[T.field] ?? null,
|
|
2260
|
+
valueLabel: fe[T.field] ? v.get(fe[T.field]) ?? fe[T.field] : null,
|
|
2261
|
+
options: L,
|
|
2262
|
+
disabled: y > 0 && !fe[H[y - 1].field],
|
|
2263
|
+
onChange: (O) => P(($) => {
|
|
2264
|
+
const A = {};
|
|
2265
|
+
for (let C = 0; C < y; C++) {
|
|
2266
|
+
const te = H[C].field;
|
|
2267
|
+
$[te] && (A[te] = $[te]);
|
|
2251
2268
|
}
|
|
2252
|
-
return
|
|
2269
|
+
return O && (A[T.field] = O), A;
|
|
2253
2270
|
})
|
|
2254
2271
|
},
|
|
2255
|
-
|
|
2272
|
+
T.field
|
|
2256
2273
|
);
|
|
2257
2274
|
}),
|
|
2258
|
-
/* @__PURE__ */
|
|
2259
|
-
/* @__PURE__ */
|
|
2260
|
-
(
|
|
2261
|
-
|
|
2275
|
+
/* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: B && se ? /* @__PURE__ */ u(Ne, { children: [
|
|
2276
|
+
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: Ke(_, se) }),
|
|
2277
|
+
(a(B) ?? 0) > 0 && /* @__PURE__ */ u("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: [
|
|
2278
|
+
a(B),
|
|
2262
2279
|
" in summary"
|
|
2263
2280
|
] }),
|
|
2264
|
-
!
|
|
2265
|
-
/* @__PURE__ */
|
|
2281
|
+
!F && /* @__PURE__ */ u(Ne, { children: [
|
|
2282
|
+
/* @__PURE__ */ s(
|
|
2266
2283
|
"input",
|
|
2267
2284
|
{
|
|
2268
2285
|
type: "number",
|
|
2269
2286
|
min: 0,
|
|
2270
2287
|
step: k,
|
|
2271
|
-
value:
|
|
2288
|
+
value: be,
|
|
2272
2289
|
"aria-label": "Quantity to add",
|
|
2273
|
-
onChange: (
|
|
2274
|
-
onKeyDown: (
|
|
2275
|
-
|
|
2290
|
+
onChange: (T) => I(T.target.value),
|
|
2291
|
+
onKeyDown: (T) => {
|
|
2292
|
+
T.key === "Enter" && (T.preventDefault(), xe());
|
|
2276
2293
|
},
|
|
2277
2294
|
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"
|
|
2278
2295
|
}
|
|
@@ -2281,83 +2298,274 @@ function Ps({
|
|
|
2281
2298
|
"button",
|
|
2282
2299
|
{
|
|
2283
2300
|
type: "button",
|
|
2284
|
-
onClick: () => void
|
|
2285
|
-
disabled: !
|
|
2301
|
+
onClick: () => void xe(),
|
|
2302
|
+
disabled: !ve,
|
|
2286
2303
|
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",
|
|
2287
2304
|
children: [
|
|
2288
|
-
|
|
2305
|
+
he ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(or, { className: "h-3.5 w-3.5" }),
|
|
2289
2306
|
"Add"
|
|
2290
2307
|
]
|
|
2291
2308
|
}
|
|
2292
2309
|
)
|
|
2293
2310
|
] })
|
|
2294
|
-
] }) :
|
|
2311
|
+
] }) : ee ? /* @__PURE__ */ s("span", { className: "text-slate-400", children: "No matching item for this combination" }) : /* @__PURE__ */ s("span", { className: "text-slate-400", children: "Pick each attribute to resolve an item" }) })
|
|
2295
2312
|
] }) })
|
|
2296
2313
|
] });
|
|
2297
2314
|
}
|
|
2298
|
-
function
|
|
2315
|
+
function Js({
|
|
2316
|
+
builder: i,
|
|
2317
|
+
catalogCol: m,
|
|
2318
|
+
catalogFields: f,
|
|
2319
|
+
tmpl: x,
|
|
2320
|
+
currentQty: _,
|
|
2321
|
+
addQty: a,
|
|
2322
|
+
qtyStep: w,
|
|
2323
|
+
readOnly: k
|
|
2324
|
+
}) {
|
|
2325
|
+
var ve, xe, T, y;
|
|
2326
|
+
const F = mt(), N = i.facets ?? [], R = i.item_key ?? "item", H = ((ve = i.result) == null ? void 0 : ve.key) ?? "label", M = i.symmetric ?? null, [me, fe] = D(!1), [P, be] = D({}), [I, he] = D({}), [ge, ke] = D(null), {
|
|
2327
|
+
data: U = [],
|
|
2328
|
+
isLoading: je,
|
|
2329
|
+
isError: pe
|
|
2330
|
+
} = Q({
|
|
2331
|
+
queryKey: ["catalog-facet-builder", i.source],
|
|
2332
|
+
queryFn: () => F.request(K(String(i.source))).then((v) => Array.isArray(v.data) ? v.data : []),
|
|
2333
|
+
enabled: me && !!i.source,
|
|
2334
|
+
staleTime: 5 * 6e4
|
|
2335
|
+
}), re = hs(P, N), ee = E(
|
|
2336
|
+
() => {
|
|
2337
|
+
var v;
|
|
2338
|
+
return re ? ps(U, P, N, {
|
|
2339
|
+
itemKey: R,
|
|
2340
|
+
labelKey: H,
|
|
2341
|
+
sortKey: (v = i.result) == null ? void 0 : v.sort,
|
|
2342
|
+
symmetric: M
|
|
2343
|
+
}) : [];
|
|
2344
|
+
},
|
|
2345
|
+
[re, U, P, N, R, H, (xe = i.result) == null ? void 0 : xe.sort, M]
|
|
2346
|
+
), Z = E(() => ee.map((v) => String(v[R])), [ee, R]), { data: B = /* @__PURE__ */ new Map() } = Q({
|
|
2347
|
+
queryKey: ["catalog-facet-items", m, f, Z.join(",")],
|
|
2348
|
+
queryFn: async () => {
|
|
2349
|
+
const v = /* @__PURE__ */ new Map();
|
|
2350
|
+
for (let L = 0; L < Z.length; L += 200) {
|
|
2351
|
+
const O = Z.slice(L, L + 200), $ = await F.request(
|
|
2352
|
+
K(`/items/${m}`, {
|
|
2353
|
+
filter: JSON.stringify({ id: { _in: O } }),
|
|
2354
|
+
fields: f,
|
|
2355
|
+
limit: O.length
|
|
2356
|
+
})
|
|
2357
|
+
);
|
|
2358
|
+
for (const A of $.data ?? []) v.set(String(A.id), A);
|
|
2359
|
+
}
|
|
2360
|
+
return v;
|
|
2361
|
+
},
|
|
2362
|
+
enabled: Z.length > 0,
|
|
2363
|
+
staleTime: 6e4
|
|
2364
|
+
}), se = N.filter((v) => P[v.key]).length;
|
|
2365
|
+
async function ie(v) {
|
|
2366
|
+
const L = I[v] ?? "1", O = Number(L), $ = B.get(v);
|
|
2367
|
+
if (!(!$ || !Number.isFinite(O) || O <= 0 || w !== "any" && !Number.isInteger(O))) {
|
|
2368
|
+
ke(v);
|
|
2369
|
+
try {
|
|
2370
|
+
await a(v, (_(v) ?? 0) + O, $), he((A) => ({ ...A, [v]: "1" }));
|
|
2371
|
+
} finally {
|
|
2372
|
+
ke(null);
|
|
2373
|
+
}
|
|
2374
|
+
}
|
|
2375
|
+
}
|
|
2376
|
+
return /* @__PURE__ */ u(
|
|
2377
|
+
"div",
|
|
2378
|
+
{
|
|
2379
|
+
className: "rounded-lg border border-slate-200 text-[12px] dark:border-border",
|
|
2380
|
+
"data-facet-builder": !0,
|
|
2381
|
+
children: [
|
|
2382
|
+
/* @__PURE__ */ u(
|
|
2383
|
+
"button",
|
|
2384
|
+
{
|
|
2385
|
+
type: "button",
|
|
2386
|
+
onClick: () => fe((v) => !v),
|
|
2387
|
+
"aria-expanded": me,
|
|
2388
|
+
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",
|
|
2389
|
+
children: [
|
|
2390
|
+
/* @__PURE__ */ s(
|
|
2391
|
+
Kt,
|
|
2392
|
+
{
|
|
2393
|
+
className: W(
|
|
2394
|
+
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
2395
|
+
me && "rotate-90"
|
|
2396
|
+
)
|
|
2397
|
+
}
|
|
2398
|
+
),
|
|
2399
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
|
|
2400
|
+
]
|
|
2401
|
+
}
|
|
2402
|
+
),
|
|
2403
|
+
me && /* @__PURE__ */ s("div", { className: "space-y-3 border-t border-slate-200 p-3 dark:border-border", children: je ? /* @__PURE__ */ u("div", { className: "flex items-center gap-2 py-2 text-slate-400", children: [
|
|
2404
|
+
/* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin" }),
|
|
2405
|
+
" Loading options…"
|
|
2406
|
+
] }) : pe ? /* @__PURE__ */ s("p", { className: "text-slate-500 dark:text-slate-400", children: "The options could not be loaded. Close and open this section to try again." }) : /* @__PURE__ */ u(Ne, { children: [
|
|
2407
|
+
/* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
2408
|
+
N.map((v) => {
|
|
2409
|
+
const L = bs(U, P, N, v.key, M);
|
|
2410
|
+
return /* @__PURE__ */ s(
|
|
2411
|
+
mr,
|
|
2412
|
+
{
|
|
2413
|
+
label: v.label,
|
|
2414
|
+
value: P[v.key] ?? null,
|
|
2415
|
+
valueLabel: P[v.key] ?? null,
|
|
2416
|
+
options: L.map((O) => [O, O]),
|
|
2417
|
+
onChange: (O) => be(($) => xs(U, $, N, v.key, O, M))
|
|
2418
|
+
},
|
|
2419
|
+
v.key
|
|
2420
|
+
);
|
|
2421
|
+
}),
|
|
2422
|
+
se > 0 && /* @__PURE__ */ u(
|
|
2423
|
+
"button",
|
|
2424
|
+
{
|
|
2425
|
+
type: "button",
|
|
2426
|
+
onClick: () => be({}),
|
|
2427
|
+
className: "mb-0.5 flex h-7 items-center gap-1 rounded px-2 text-[12px] text-slate-500 hover:bg-muted hover:text-slate-700 dark:text-slate-400 dark:hover:text-slate-200",
|
|
2428
|
+
children: [
|
|
2429
|
+
/* @__PURE__ */ s(ut, { className: "h-3 w-3" }),
|
|
2430
|
+
" Clear"
|
|
2431
|
+
]
|
|
2432
|
+
}
|
|
2433
|
+
)
|
|
2434
|
+
] }),
|
|
2435
|
+
re ? ee.length === 0 ? /* @__PURE__ */ s("p", { className: "text-slate-400", children: "Nothing matches this combination." }) : /* @__PURE__ */ u("div", { className: "divide-y divide-slate-100 rounded border border-slate-200 dark:divide-border dark:border-border", children: [
|
|
2436
|
+
/* @__PURE__ */ u("div", { className: "flex items-center gap-2 bg-slate-50 px-2 py-1 text-[10px] font-medium uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
|
|
2437
|
+
/* @__PURE__ */ s("span", { className: "flex-1", children: ((y = i.result) == null ? void 0 : y.label) ?? "Option" }),
|
|
2438
|
+
!k && /* @__PURE__ */ s("span", { className: "w-[124px] text-right", children: "Quantity" })
|
|
2439
|
+
] }),
|
|
2440
|
+
ee.map((v) => {
|
|
2441
|
+
var C;
|
|
2442
|
+
const L = String(v[R]), O = B.get(L), $ = _(L) ?? 0, A = (C = i.result) != null && C.detail ? String(v[i.result.detail] ?? "") : "";
|
|
2443
|
+
return /* @__PURE__ */ u(
|
|
2444
|
+
"div",
|
|
2445
|
+
{
|
|
2446
|
+
className: "flex items-center gap-2 px-2 py-1.5",
|
|
2447
|
+
"data-facet-result": L,
|
|
2448
|
+
children: [
|
|
2449
|
+
/* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
|
|
2450
|
+
/* @__PURE__ */ s("p", { className: "truncate font-medium tabular-nums text-slate-700 dark:text-slate-200", children: String(v[H] ?? "") }),
|
|
2451
|
+
/* @__PURE__ */ s("p", { className: "truncate text-[11px] text-slate-400", children: A || (O ? Ke(x, O) : "") })
|
|
2452
|
+
] }),
|
|
2453
|
+
$ > 0 && /* @__PURE__ */ u("span", { className: "shrink-0 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: [
|
|
2454
|
+
$,
|
|
2455
|
+
" in summary"
|
|
2456
|
+
] }),
|
|
2457
|
+
!k && /* @__PURE__ */ u(Ne, { children: [
|
|
2458
|
+
/* @__PURE__ */ s(
|
|
2459
|
+
"input",
|
|
2460
|
+
{
|
|
2461
|
+
type: "number",
|
|
2462
|
+
min: 0,
|
|
2463
|
+
step: w,
|
|
2464
|
+
value: I[L] ?? "1",
|
|
2465
|
+
"aria-label": `Quantity of ${String(v[H] ?? "")}`,
|
|
2466
|
+
onChange: (te) => he((Ce) => ({ ...Ce, [L]: te.target.value })),
|
|
2467
|
+
onKeyDown: (te) => {
|
|
2468
|
+
te.key === "Enter" && (te.preventDefault(), ie(L));
|
|
2469
|
+
},
|
|
2470
|
+
className: "h-7 w-16 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"
|
|
2471
|
+
}
|
|
2472
|
+
),
|
|
2473
|
+
/* @__PURE__ */ u(
|
|
2474
|
+
"button",
|
|
2475
|
+
{
|
|
2476
|
+
type: "button",
|
|
2477
|
+
onClick: () => void ie(L),
|
|
2478
|
+
disabled: !O || ge !== null,
|
|
2479
|
+
className: "flex h-7 w-[52px] shrink-0 items-center justify-center gap-1 rounded bg-nvr-cyan px-2 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",
|
|
2480
|
+
children: [
|
|
2481
|
+
ge === L ? /* @__PURE__ */ s(ue, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(or, { className: "h-3.5 w-3.5" }),
|
|
2482
|
+
"Add"
|
|
2483
|
+
]
|
|
2484
|
+
}
|
|
2485
|
+
)
|
|
2486
|
+
] })
|
|
2487
|
+
]
|
|
2488
|
+
},
|
|
2489
|
+
L
|
|
2490
|
+
);
|
|
2491
|
+
})
|
|
2492
|
+
] }) : /* @__PURE__ */ u("p", { className: "text-slate-400", children: [
|
|
2493
|
+
"Pick",
|
|
2494
|
+
" ",
|
|
2495
|
+
N.filter((v) => !P[v.key]).map((v) => v.label).join(", "),
|
|
2496
|
+
" ",
|
|
2497
|
+
"to see the ",
|
|
2498
|
+
(((T = i.result) == null ? void 0 : T.label) ?? "options").toLowerCase(),
|
|
2499
|
+
"."
|
|
2500
|
+
] })
|
|
2501
|
+
] }) })
|
|
2502
|
+
]
|
|
2503
|
+
}
|
|
2504
|
+
);
|
|
2505
|
+
}
|
|
2506
|
+
function Is({
|
|
2299
2507
|
parentCollection: i,
|
|
2300
2508
|
field: m,
|
|
2301
|
-
id:
|
|
2509
|
+
id: f
|
|
2302
2510
|
}) {
|
|
2303
2511
|
var k;
|
|
2304
|
-
const x =
|
|
2512
|
+
const x = mt(), { data: _ = [] } = Q({
|
|
2305
2513
|
queryKey: ["collection-relations", i],
|
|
2306
|
-
queryFn: () => x.request(
|
|
2307
|
-
var
|
|
2308
|
-
return ((
|
|
2514
|
+
queryFn: () => x.request(K(`/collections/${i}`)).then((F) => {
|
|
2515
|
+
var N;
|
|
2516
|
+
return ((N = F.data) == null ? void 0 : N.relations) ?? [];
|
|
2309
2517
|
}),
|
|
2310
2518
|
enabled: !!i,
|
|
2311
2519
|
staleTime: 10 * 6e4
|
|
2312
|
-
}),
|
|
2313
|
-
(
|
|
2314
|
-
)) == null ? void 0 : k.one_collection) ?? null, { data: w } =
|
|
2315
|
-
queryKey: ["col-meta",
|
|
2316
|
-
queryFn: () => x.request(
|
|
2317
|
-
enabled: !!
|
|
2520
|
+
}), a = ((k = _.find(
|
|
2521
|
+
(F) => F.many_collection === i && F.many_field === m && !F.junction_field
|
|
2522
|
+
)) == null ? void 0 : k.one_collection) ?? null, { data: w } = Q({
|
|
2523
|
+
queryKey: ["col-meta", a],
|
|
2524
|
+
queryFn: () => x.request(K(`/collections/${a}`)).then((F) => F.data),
|
|
2525
|
+
enabled: !!a,
|
|
2318
2526
|
staleTime: 3e5
|
|
2319
2527
|
});
|
|
2320
|
-
return
|
|
2528
|
+
return a ? /* @__PURE__ */ s($s, { collection: a, id: f, displayTemplate: w == null ? void 0 : w.display_template }) : /* @__PURE__ */ u(Ne, { children: [
|
|
2321
2529
|
"this ",
|
|
2322
|
-
|
|
2530
|
+
X(m)
|
|
2323
2531
|
] });
|
|
2324
2532
|
}
|
|
2325
2533
|
function lr({
|
|
2326
2534
|
text: i,
|
|
2327
2535
|
highlight: m,
|
|
2328
|
-
className:
|
|
2536
|
+
className: f,
|
|
2329
2537
|
...x
|
|
2330
2538
|
}) {
|
|
2331
|
-
const _ =
|
|
2332
|
-
return /* @__PURE__ */
|
|
2539
|
+
const _ = us(i);
|
|
2540
|
+
return /* @__PURE__ */ s("span", { ref: _, className: W("truncate", f), ...x, children: m ? /* @__PURE__ */ s(fn, { text: i, query: m }) : i });
|
|
2333
2541
|
}
|
|
2334
|
-
function
|
|
2542
|
+
function mr({
|
|
2335
2543
|
label: i,
|
|
2336
2544
|
value: m,
|
|
2337
|
-
valueLabel:
|
|
2545
|
+
valueLabel: f,
|
|
2338
2546
|
options: x,
|
|
2339
2547
|
disabled: _,
|
|
2340
|
-
onChange:
|
|
2548
|
+
onChange: a
|
|
2341
2549
|
}) {
|
|
2342
|
-
const [w, k] =
|
|
2343
|
-
return
|
|
2550
|
+
const [w, k] = D(!1), F = qe(null);
|
|
2551
|
+
return $e(() => {
|
|
2344
2552
|
if (!w) return;
|
|
2345
|
-
const
|
|
2346
|
-
|
|
2553
|
+
const N = (R) => {
|
|
2554
|
+
F.current && !F.current.contains(R.target) && k(!1);
|
|
2347
2555
|
};
|
|
2348
|
-
return document.addEventListener("mousedown",
|
|
2349
|
-
}, [w]), /* @__PURE__ */ u("div", { ref:
|
|
2350
|
-
/* @__PURE__ */
|
|
2556
|
+
return document.addEventListener("mousedown", N), () => document.removeEventListener("mousedown", N);
|
|
2557
|
+
}, [w]), /* @__PURE__ */ u("div", { ref: F, className: "relative", children: [
|
|
2558
|
+
/* @__PURE__ */ s("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: i }),
|
|
2351
2559
|
/* @__PURE__ */ u(
|
|
2352
2560
|
"button",
|
|
2353
2561
|
{
|
|
2354
2562
|
type: "button",
|
|
2355
2563
|
disabled: _,
|
|
2356
|
-
onClick: () => k((
|
|
2564
|
+
onClick: () => k((N) => !N),
|
|
2357
2565
|
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",
|
|
2358
2566
|
children: [
|
|
2359
|
-
/* @__PURE__ */
|
|
2360
|
-
/* @__PURE__ */
|
|
2567
|
+
/* @__PURE__ */ s("span", { className: W("truncate", !f && "text-slate-400"), children: f ?? "Select…" }),
|
|
2568
|
+
/* @__PURE__ */ s(Zr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
2361
2569
|
]
|
|
2362
2570
|
}
|
|
2363
2571
|
),
|
|
@@ -2367,229 +2575,229 @@ function Ls({
|
|
|
2367
2575
|
{
|
|
2368
2576
|
type: "button",
|
|
2369
2577
|
onClick: () => {
|
|
2370
|
-
|
|
2578
|
+
a(null), k(!1);
|
|
2371
2579
|
},
|
|
2372
2580
|
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",
|
|
2373
2581
|
children: [
|
|
2374
|
-
/* @__PURE__ */
|
|
2582
|
+
/* @__PURE__ */ s(ut, { className: "h-3 w-3 text-slate-400" }),
|
|
2375
2583
|
" Clear"
|
|
2376
2584
|
]
|
|
2377
2585
|
}
|
|
2378
2586
|
),
|
|
2379
|
-
x.map(([
|
|
2587
|
+
x.map(([N, R]) => /* @__PURE__ */ s(
|
|
2380
2588
|
"button",
|
|
2381
2589
|
{
|
|
2382
2590
|
type: "button",
|
|
2383
2591
|
onClick: () => {
|
|
2384
|
-
|
|
2592
|
+
a(N), k(!1);
|
|
2385
2593
|
},
|
|
2386
|
-
className:
|
|
2594
|
+
className: W(
|
|
2387
2595
|
"block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
2388
|
-
|
|
2596
|
+
N === m ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
2389
2597
|
),
|
|
2390
|
-
children:
|
|
2598
|
+
children: R
|
|
2391
2599
|
},
|
|
2392
|
-
|
|
2600
|
+
N
|
|
2393
2601
|
))
|
|
2394
2602
|
] })
|
|
2395
2603
|
] });
|
|
2396
2604
|
}
|
|
2397
|
-
function
|
|
2605
|
+
function Qs({
|
|
2398
2606
|
catalogCol: i,
|
|
2399
2607
|
tmpl: m,
|
|
2400
|
-
sectionBy:
|
|
2608
|
+
sectionBy: f,
|
|
2401
2609
|
sectionM2M: x,
|
|
2402
2610
|
pinnedSet: _,
|
|
2403
|
-
pinnedIds:
|
|
2611
|
+
pinnedIds: a,
|
|
2404
2612
|
savingIds: w,
|
|
2405
2613
|
relatedCols: k,
|
|
2406
|
-
parentDraft:
|
|
2407
|
-
onToggle:
|
|
2408
|
-
onClose:
|
|
2409
|
-
anchor:
|
|
2614
|
+
parentDraft: F,
|
|
2615
|
+
onToggle: N,
|
|
2616
|
+
onClose: R,
|
|
2617
|
+
anchor: H
|
|
2410
2618
|
}) {
|
|
2411
|
-
const
|
|
2412
|
-
|
|
2413
|
-
const d = setTimeout(() =>
|
|
2619
|
+
const M = mt(), [me, fe] = D(""), [P, be] = D(""), [I, he] = D(1), ge = qe(null);
|
|
2620
|
+
$e(() => {
|
|
2621
|
+
const d = setTimeout(() => be(me), 300);
|
|
2414
2622
|
return () => clearTimeout(d);
|
|
2415
|
-
}, [
|
|
2623
|
+
}, [me]), $e(() => he(1), [P]), $e(() => {
|
|
2416
2624
|
var d;
|
|
2417
|
-
(d =
|
|
2418
|
-
}, []),
|
|
2419
|
-
const d = (
|
|
2420
|
-
|
|
2625
|
+
(d = ge.current) == null || d.focus();
|
|
2626
|
+
}, []), $e(() => {
|
|
2627
|
+
const d = (S) => {
|
|
2628
|
+
S.key === "Escape" && (S.stopPropagation(), R());
|
|
2421
2629
|
};
|
|
2422
2630
|
return window.addEventListener("keydown", d, !0), () => window.removeEventListener("keydown", d, !0);
|
|
2423
|
-
}, [
|
|
2424
|
-
const
|
|
2425
|
-
var
|
|
2426
|
-
const d = (
|
|
2631
|
+
}, [R]);
|
|
2632
|
+
const ke = E(() => {
|
|
2633
|
+
var S;
|
|
2634
|
+
const d = (S = [...(m ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : S[1];
|
|
2427
2635
|
return d && !d.includes(".") ? d : "id";
|
|
2428
|
-
}, [m]),
|
|
2429
|
-
queryKey: ["favorites-manager-list", i, P,
|
|
2430
|
-
queryFn: () =>
|
|
2431
|
-
|
|
2432
|
-
fields:
|
|
2433
|
-
limit:
|
|
2434
|
-
page:
|
|
2435
|
-
sort:
|
|
2636
|
+
}, [m]), U = !x && f.includes(".") ? `*,${f}` : "*", je = 50, { data: pe, isFetching: re } = Q({
|
|
2637
|
+
queryKey: ["favorites-manager-list", i, P, ke, I],
|
|
2638
|
+
queryFn: () => M.request(
|
|
2639
|
+
K(`/items/${i}`, {
|
|
2640
|
+
fields: U,
|
|
2641
|
+
limit: je,
|
|
2642
|
+
page: I,
|
|
2643
|
+
sort: ke,
|
|
2436
2644
|
...P.trim() ? { search: P } : {}
|
|
2437
2645
|
})
|
|
2438
2646
|
),
|
|
2439
2647
|
staleTime: 3e4,
|
|
2440
2648
|
placeholderData: (d) => d
|
|
2441
|
-
}),
|
|
2442
|
-
queryKey: ["favorites-manager-pinned", i,
|
|
2443
|
-
queryFn: () =>
|
|
2444
|
-
|
|
2445
|
-
filter: JSON.stringify({ id: { _in:
|
|
2446
|
-
fields:
|
|
2447
|
-
limit:
|
|
2448
|
-
sort:
|
|
2649
|
+
}), ee = ((pe == null ? void 0 : pe.data) ?? []).filter((d) => !_.has(String(d.id))), Z = (pe == null ? void 0 : pe.total) ?? ee.length, B = Math.max(1, Math.ceil(Z / je)), { data: se = [] } = Q({
|
|
2650
|
+
queryKey: ["favorites-manager-pinned", i, U, a.join(",")],
|
|
2651
|
+
queryFn: () => M.request(
|
|
2652
|
+
K(`/items/${i}`, {
|
|
2653
|
+
filter: JSON.stringify({ id: { _in: a } }),
|
|
2654
|
+
fields: U,
|
|
2655
|
+
limit: a.length,
|
|
2656
|
+
sort: ke
|
|
2449
2657
|
})
|
|
2450
2658
|
).then((d) => d.data ?? []),
|
|
2451
|
-
enabled:
|
|
2659
|
+
enabled: a.length > 0,
|
|
2452
2660
|
staleTime: 3e4
|
|
2453
|
-
}),
|
|
2661
|
+
}), ie = E(() => {
|
|
2454
2662
|
const d = /* @__PURE__ */ new Set();
|
|
2455
|
-
for (const
|
|
2456
|
-
for (const
|
|
2663
|
+
for (const S of ee) d.add(String(S.id));
|
|
2664
|
+
for (const S of a) d.add(S);
|
|
2457
2665
|
return [...d];
|
|
2458
|
-
}, [
|
|
2459
|
-
queryKey: ["favorites-manager-sections", x == null ? void 0 : x.junction,
|
|
2666
|
+
}, [ee, a]), { data: ve = /* @__PURE__ */ new Map() } = Q({
|
|
2667
|
+
queryKey: ["favorites-manager-sections", x == null ? void 0 : x.junction, ie.join(",")],
|
|
2460
2668
|
queryFn: async () => {
|
|
2461
|
-
const d = x,
|
|
2669
|
+
const d = x, S = await Ct(M, `/items/${d.junction}`, {
|
|
2462
2670
|
fields: `${d.fkToItem},${d.fkToSection}`,
|
|
2463
|
-
filter: JSON.stringify({ [d.fkToItem]: { _in:
|
|
2464
|
-
}),
|
|
2671
|
+
filter: JSON.stringify({ [d.fkToItem]: { _in: ie } })
|
|
2672
|
+
}), G = [...new Set(S.map((ne) => String(ne[d.fkToSection])))], le = G.length ? await Ct(M, `/items/${d.target}`, {
|
|
2465
2673
|
fields: `id,${d.labelPath}`,
|
|
2466
|
-
filter: JSON.stringify({ id: { _in:
|
|
2467
|
-
}) : [],
|
|
2468
|
-
|
|
2469
|
-
),
|
|
2470
|
-
for (const
|
|
2471
|
-
const
|
|
2472
|
-
if (!
|
|
2473
|
-
const
|
|
2474
|
-
|
|
2674
|
+
filter: JSON.stringify({ id: { _in: G } })
|
|
2675
|
+
}) : [], Y = new Map(
|
|
2676
|
+
le.map((ne) => [String(ne.id), String(ur(ne, d.labelPath) ?? "")])
|
|
2677
|
+
), ae = /* @__PURE__ */ new Map();
|
|
2678
|
+
for (const ne of S) {
|
|
2679
|
+
const z = Y.get(String(ne[d.fkToSection]));
|
|
2680
|
+
if (!z) continue;
|
|
2681
|
+
const Je = String(ne[d.fkToItem]), oe = ae.get(Je) ?? [];
|
|
2682
|
+
oe.includes(z) || oe.push(z), ae.set(Je, oe);
|
|
2475
2683
|
}
|
|
2476
|
-
return
|
|
2684
|
+
return ae;
|
|
2477
2685
|
},
|
|
2478
|
-
enabled: !!x &&
|
|
2686
|
+
enabled: !!x && ie.length > 0,
|
|
2479
2687
|
staleTime: 6e4
|
|
2480
|
-
}),
|
|
2481
|
-
const
|
|
2482
|
-
return typeof
|
|
2483
|
-
},
|
|
2484
|
-
if (x) return (
|
|
2485
|
-
if (!
|
|
2486
|
-
const
|
|
2487
|
-
return
|
|
2488
|
-
},
|
|
2489
|
-
if (
|
|
2688
|
+
}), xe = (d) => m ? Ke(m, d) : String(d.cifa_number ?? d.name ?? `#${d.id}`), T = (d) => {
|
|
2689
|
+
const S = d.description ?? d.long_description ?? d.name;
|
|
2690
|
+
return typeof S == "string" && S.trim() && S.trim() !== xe(d) ? S : "";
|
|
2691
|
+
}, y = (d) => {
|
|
2692
|
+
if (x) return (ve.get(String(d.id)) ?? []).join(", ");
|
|
2693
|
+
if (!f) return "";
|
|
2694
|
+
const S = Ke(`{{${f}}}`, d);
|
|
2695
|
+
return S === `{{${f}}}` ? "" : S;
|
|
2696
|
+
}, v = (d, S) => {
|
|
2697
|
+
if (S === "presence")
|
|
2490
2698
|
return d == null || d === "" || Number(d) === 0 ? "No" : "Yes";
|
|
2491
2699
|
if (d == null || d === "") return "—";
|
|
2492
|
-
const
|
|
2493
|
-
return
|
|
2494
|
-
},
|
|
2700
|
+
const G = Number(d);
|
|
2701
|
+
return S === "currency" && Number.isFinite(G) ? G.toLocaleString("en-US", { style: "currency", currency: "USD" }) : S === "number" && Number.isFinite(G) ? G.toLocaleString() : String(d);
|
|
2702
|
+
}, L = mn({
|
|
2495
2703
|
queries: k.map((d) => {
|
|
2496
|
-
const
|
|
2704
|
+
const S = Ye(d.match, F);
|
|
2497
2705
|
return {
|
|
2498
2706
|
queryKey: [
|
|
2499
2707
|
"favorites-manager-related",
|
|
2500
2708
|
d.key,
|
|
2501
2709
|
d.collection,
|
|
2502
|
-
JSON.stringify(
|
|
2503
|
-
|
|
2710
|
+
JSON.stringify(S),
|
|
2711
|
+
ie.join(",")
|
|
2504
2712
|
],
|
|
2505
2713
|
queryFn: async () => {
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2508
|
-
filter: JSON.stringify({ [d.item_field]: { _in:
|
|
2714
|
+
const G = await M.request(
|
|
2715
|
+
K(`/items/${d.collection}`, {
|
|
2716
|
+
filter: JSON.stringify({ [d.item_field]: { _in: ie }, ...S ?? {} }),
|
|
2509
2717
|
fields: `${d.item_field},${d.value_field}`,
|
|
2510
2718
|
limit: 1e3
|
|
2511
2719
|
})
|
|
2512
|
-
).then((
|
|
2513
|
-
for (const
|
|
2514
|
-
const
|
|
2515
|
-
|
|
2720
|
+
).then((Y) => Y.data ?? []), le = /* @__PURE__ */ new Map();
|
|
2721
|
+
for (const Y of G) {
|
|
2722
|
+
const ae = String(Y[d.item_field]), ne = Y[d.value_field], z = le.get(ae);
|
|
2723
|
+
z === void 0 ? le.set(ae, ne) : Number.isFinite(Number(z)) && Number.isFinite(Number(ne)) && le.set(ae, Number(z) + Number(ne));
|
|
2516
2724
|
}
|
|
2517
|
-
return
|
|
2725
|
+
return le;
|
|
2518
2726
|
},
|
|
2519
|
-
enabled:
|
|
2727
|
+
enabled: ie.length > 0 && (d.match === void 0 || S !== null),
|
|
2520
2728
|
staleTime: 3e4
|
|
2521
2729
|
};
|
|
2522
2730
|
})
|
|
2523
|
-
}),
|
|
2524
|
-
(d) => d.match !== void 0 &&
|
|
2525
|
-
),
|
|
2526
|
-
const
|
|
2527
|
-
return /* @__PURE__ */
|
|
2731
|
+
}), O = k.filter(
|
|
2732
|
+
(d) => d.match !== void 0 && Ye(d.match, F) === null
|
|
2733
|
+
), $ = (d) => {
|
|
2734
|
+
const S = _.has(d);
|
|
2735
|
+
return /* @__PURE__ */ s(
|
|
2528
2736
|
"button",
|
|
2529
2737
|
{
|
|
2530
2738
|
type: "button",
|
|
2531
|
-
title:
|
|
2739
|
+
title: S ? "Remove from favorites" : "Add to favorites",
|
|
2532
2740
|
disabled: w.has(d),
|
|
2533
|
-
onClick: () =>
|
|
2741
|
+
onClick: () => N(d),
|
|
2534
2742
|
className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
|
|
2535
|
-
children: w.has(d) ? /* @__PURE__ */
|
|
2536
|
-
|
|
2743
|
+
children: w.has(d) ? /* @__PURE__ */ s(ue, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
|
|
2744
|
+
ct,
|
|
2537
2745
|
{
|
|
2538
|
-
className:
|
|
2746
|
+
className: W(
|
|
2539
2747
|
"h-4 w-4",
|
|
2540
|
-
|
|
2748
|
+
S ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
2541
2749
|
)
|
|
2542
2750
|
}
|
|
2543
2751
|
)
|
|
2544
2752
|
}
|
|
2545
2753
|
);
|
|
2546
|
-
},
|
|
2547
|
-
const
|
|
2754
|
+
}, A = (d, S) => /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s("td", { colSpan: 4 + k.length, className: W("border-b px-3 py-1.5", S), children: d }) }), C = (d, S) => {
|
|
2755
|
+
const G = String(d.id), le = T(d);
|
|
2548
2756
|
return /* @__PURE__ */ u(
|
|
2549
2757
|
"tr",
|
|
2550
2758
|
{
|
|
2551
|
-
className:
|
|
2759
|
+
className: W(
|
|
2552
2760
|
"border-b border-slate-100 dark:border-border/50",
|
|
2553
|
-
|
|
2761
|
+
S % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
|
|
2554
2762
|
),
|
|
2555
2763
|
children: [
|
|
2556
|
-
/* @__PURE__ */
|
|
2557
|
-
/* @__PURE__ */
|
|
2764
|
+
/* @__PURE__ */ s("td", { className: "px-2 py-1", children: $(G) }),
|
|
2765
|
+
/* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children: dr(i) ? /* @__PURE__ */ s(
|
|
2558
2766
|
"button",
|
|
2559
2767
|
{
|
|
2560
2768
|
type: "button",
|
|
2561
|
-
onClick: () =>
|
|
2769
|
+
onClick: () => cr(i, G, F),
|
|
2562
2770
|
title: "View stock & planning detail",
|
|
2563
2771
|
className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
|
|
2564
|
-
children:
|
|
2772
|
+
children: xe(d)
|
|
2565
2773
|
}
|
|
2566
|
-
) :
|
|
2567
|
-
/* @__PURE__ */
|
|
2568
|
-
/* @__PURE__ */
|
|
2569
|
-
k.map((
|
|
2570
|
-
var
|
|
2571
|
-
const
|
|
2572
|
-
return /* @__PURE__ */
|
|
2774
|
+
) : xe(d) }),
|
|
2775
|
+
/* @__PURE__ */ s("td", { className: "max-w-0 px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-600 dark:text-slate-300", "data-tip": le || void 0, children: le || "—" }) }),
|
|
2776
|
+
/* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children: y(d) || "—" }) }),
|
|
2777
|
+
k.map((Y, ae) => {
|
|
2778
|
+
var Je, oe;
|
|
2779
|
+
const ne = Y.match !== void 0 && Ye(Y.match, F) === null, z = ne || (oe = (Je = L[ae]) == null ? void 0 : Je.data) == null ? void 0 : oe.get(G);
|
|
2780
|
+
return /* @__PURE__ */ s(
|
|
2573
2781
|
"td",
|
|
2574
2782
|
{
|
|
2575
2783
|
className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
2576
|
-
children:
|
|
2784
|
+
children: ne ? "—" : v(z, Y.format)
|
|
2577
2785
|
},
|
|
2578
|
-
|
|
2786
|
+
Y.key
|
|
2579
2787
|
);
|
|
2580
2788
|
})
|
|
2581
2789
|
]
|
|
2582
2790
|
},
|
|
2583
|
-
|
|
2791
|
+
G
|
|
2584
2792
|
);
|
|
2585
|
-
},
|
|
2586
|
-
return
|
|
2793
|
+
}, te = (H == null ? void 0 : H.closest('[role="dialog"]')) ?? document.body, Ce = me.trim() ? se.filter((d) => ds(`${xe(d)} ${T(d)} ${y(d)}`, me)) : se;
|
|
2794
|
+
return Gr(
|
|
2587
2795
|
/* @__PURE__ */ u("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
|
|
2588
|
-
/* @__PURE__ */
|
|
2796
|
+
/* @__PURE__ */ s(
|
|
2589
2797
|
"div",
|
|
2590
2798
|
{
|
|
2591
2799
|
className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
|
|
2592
|
-
onClick:
|
|
2800
|
+
onClick: R
|
|
2593
2801
|
}
|
|
2594
2802
|
),
|
|
2595
2803
|
/* @__PURE__ */ u(
|
|
@@ -2601,95 +2809,95 @@ function As({
|
|
|
2601
2809
|
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",
|
|
2602
2810
|
children: [
|
|
2603
2811
|
/* @__PURE__ */ u("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
|
|
2604
|
-
/* @__PURE__ */
|
|
2812
|
+
/* @__PURE__ */ s(ct, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2605
2813
|
/* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
|
|
2606
|
-
/* @__PURE__ */
|
|
2607
|
-
/* @__PURE__ */
|
|
2814
|
+
/* @__PURE__ */ s("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
|
|
2815
|
+
/* @__PURE__ */ s("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." })
|
|
2608
2816
|
] }),
|
|
2609
|
-
/* @__PURE__ */
|
|
2817
|
+
/* @__PURE__ */ s(
|
|
2610
2818
|
"button",
|
|
2611
2819
|
{
|
|
2612
2820
|
type: "button",
|
|
2613
|
-
onClick:
|
|
2821
|
+
onClick: R,
|
|
2614
2822
|
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]",
|
|
2615
2823
|
"aria-label": "Close",
|
|
2616
|
-
children: /* @__PURE__ */
|
|
2824
|
+
children: /* @__PURE__ */ s(ut, { className: "h-4 w-4" })
|
|
2617
2825
|
}
|
|
2618
2826
|
)
|
|
2619
2827
|
] }),
|
|
2620
2828
|
/* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
2621
2829
|
/* @__PURE__ */ u("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: [
|
|
2622
|
-
/* @__PURE__ */
|
|
2623
|
-
/* @__PURE__ */
|
|
2830
|
+
/* @__PURE__ */ s(At, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
2831
|
+
/* @__PURE__ */ s(
|
|
2624
2832
|
"input",
|
|
2625
2833
|
{
|
|
2626
|
-
ref:
|
|
2627
|
-
value:
|
|
2628
|
-
onChange: (d) =>
|
|
2834
|
+
ref: ge,
|
|
2835
|
+
value: me,
|
|
2836
|
+
onChange: (d) => fe(d.target.value),
|
|
2629
2837
|
placeholder: "Search by number or description…",
|
|
2630
2838
|
className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
|
|
2631
2839
|
}
|
|
2632
2840
|
),
|
|
2633
|
-
|
|
2841
|
+
me && /* @__PURE__ */ s(
|
|
2634
2842
|
"button",
|
|
2635
2843
|
{
|
|
2636
2844
|
type: "button",
|
|
2637
|
-
onClick: () =>
|
|
2845
|
+
onClick: () => fe(""),
|
|
2638
2846
|
className: "shrink-0 text-slate-400 hover:text-slate-600",
|
|
2639
2847
|
"aria-label": "Clear search",
|
|
2640
|
-
children: /* @__PURE__ */
|
|
2848
|
+
children: /* @__PURE__ */ s(ut, { className: "h-3.5 w-3.5" })
|
|
2641
2849
|
}
|
|
2642
2850
|
)
|
|
2643
2851
|
] }),
|
|
2644
|
-
|
|
2645
|
-
/* @__PURE__ */
|
|
2646
|
-
|
|
2852
|
+
O.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
|
|
2853
|
+
/* @__PURE__ */ s(He, { className: "h-3 w-3 shrink-0" }),
|
|
2854
|
+
O.map((d) => d.label ?? X(d.key)).join(", "),
|
|
2647
2855
|
" fill in once the form's warehouse selection is made."
|
|
2648
2856
|
] })
|
|
2649
2857
|
] }),
|
|
2650
|
-
/* @__PURE__ */
|
|
2858
|
+
/* @__PURE__ */ s("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ u("table", { className: "w-full table-fixed border-collapse text-[11px]", children: [
|
|
2651
2859
|
/* @__PURE__ */ u("colgroup", { children: [
|
|
2652
|
-
/* @__PURE__ */
|
|
2653
|
-
/* @__PURE__ */
|
|
2654
|
-
/* @__PURE__ */
|
|
2655
|
-
/* @__PURE__ */
|
|
2656
|
-
k.map((d) => /* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ s("col", { className: "w-9" }),
|
|
2861
|
+
/* @__PURE__ */ s("col", { className: "w-[88px]" }),
|
|
2862
|
+
/* @__PURE__ */ s("col", {}),
|
|
2863
|
+
/* @__PURE__ */ s("col", { className: "w-[130px]" }),
|
|
2864
|
+
k.map((d) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, d.key))
|
|
2657
2865
|
] }),
|
|
2658
|
-
/* @__PURE__ */
|
|
2659
|
-
/* @__PURE__ */
|
|
2660
|
-
/* @__PURE__ */
|
|
2661
|
-
/* @__PURE__ */
|
|
2662
|
-
/* @__PURE__ */
|
|
2663
|
-
k.map((d) => /* @__PURE__ */
|
|
2866
|
+
/* @__PURE__ */ s("thead", { className: "sticky top-0 z-[1]", children: /* @__PURE__ */ u("tr", { className: "bg-slate-100 text-left text-[10px] font-semibold uppercase tracking-wide text-slate-500 dark:bg-muted dark:text-slate-400", children: [
|
|
2867
|
+
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
|
|
2868
|
+
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "CIFA #" }),
|
|
2869
|
+
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Description" }),
|
|
2870
|
+
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Category" }),
|
|
2871
|
+
k.map((d) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: d.label ?? X(d.key) }, d.key))
|
|
2664
2872
|
] }) }),
|
|
2665
|
-
/* @__PURE__ */ u("tbody", { className:
|
|
2666
|
-
|
|
2873
|
+
/* @__PURE__ */ u("tbody", { className: W(re && "opacity-50 transition-opacity"), children: [
|
|
2874
|
+
A(
|
|
2667
2875
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2668
|
-
/* @__PURE__ */
|
|
2669
|
-
/* @__PURE__ */
|
|
2670
|
-
/* @__PURE__ */
|
|
2876
|
+
/* @__PURE__ */ s(ct, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2877
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
|
|
2878
|
+
/* @__PURE__ */ s("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: a.length })
|
|
2671
2879
|
] }),
|
|
2672
2880
|
"border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
|
|
2673
2881
|
),
|
|
2674
|
-
|
|
2882
|
+
Ce.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
|
|
2675
2883
|
"td",
|
|
2676
2884
|
{
|
|
2677
2885
|
colSpan: 4 + k.length,
|
|
2678
2886
|
className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
|
|
2679
|
-
children:
|
|
2887
|
+
children: a.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
|
|
2680
2888
|
}
|
|
2681
2889
|
) }),
|
|
2682
|
-
|
|
2683
|
-
|
|
2890
|
+
Ce.map((d, S) => C(d, S)),
|
|
2891
|
+
A(
|
|
2684
2892
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2685
|
-
/* @__PURE__ */
|
|
2686
|
-
/* @__PURE__ */
|
|
2687
|
-
/* @__PURE__ */
|
|
2688
|
-
|
|
2893
|
+
/* @__PURE__ */ s(At, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
2894
|
+
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
|
|
2895
|
+
/* @__PURE__ */ s("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: Z.toLocaleString() }),
|
|
2896
|
+
re && /* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin text-slate-400" })
|
|
2689
2897
|
] }),
|
|
2690
2898
|
"border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
|
|
2691
2899
|
),
|
|
2692
|
-
!
|
|
2900
|
+
!re && ee.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
|
|
2693
2901
|
"td",
|
|
2694
2902
|
{
|
|
2695
2903
|
colSpan: 4 + k.length,
|
|
@@ -2697,44 +2905,44 @@ function As({
|
|
|
2697
2905
|
children: P.trim() ? `No CIFAs match "${P}".` : "No catalog items."
|
|
2698
2906
|
}
|
|
2699
2907
|
) }),
|
|
2700
|
-
|
|
2908
|
+
ee.map((d, S) => C(d, S))
|
|
2701
2909
|
] })
|
|
2702
2910
|
] }) }),
|
|
2703
|
-
|
|
2911
|
+
B > 1 && /* @__PURE__ */ u("div", { className: "flex shrink-0 items-center justify-between border-t border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
2704
2912
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
|
|
2705
|
-
(
|
|
2913
|
+
(I - 1) * je + 1,
|
|
2706
2914
|
"–",
|
|
2707
|
-
Math.min(
|
|
2915
|
+
Math.min(I * je, Z),
|
|
2708
2916
|
" of",
|
|
2709
2917
|
" ",
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
/* @__PURE__ */
|
|
2918
|
+
Z.toLocaleString(),
|
|
2919
|
+
re && /* @__PURE__ */ u("span", { className: "flex items-center gap-1 text-slate-500", children: [
|
|
2920
|
+
/* @__PURE__ */ s(ue, { className: "h-3 w-3 animate-spin" }),
|
|
2713
2921
|
" Loading…"
|
|
2714
2922
|
] })
|
|
2715
2923
|
] }),
|
|
2716
2924
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-1", children: [
|
|
2717
|
-
/* @__PURE__ */
|
|
2925
|
+
/* @__PURE__ */ s(
|
|
2718
2926
|
"button",
|
|
2719
2927
|
{
|
|
2720
2928
|
type: "button",
|
|
2721
|
-
disabled:
|
|
2722
|
-
onClick: () =>
|
|
2929
|
+
disabled: I <= 1 || re,
|
|
2930
|
+
onClick: () => he((d) => Math.max(1, d - 1)),
|
|
2723
2931
|
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]",
|
|
2724
2932
|
children: "‹ Prev"
|
|
2725
2933
|
}
|
|
2726
2934
|
),
|
|
2727
2935
|
/* @__PURE__ */ u("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
|
|
2728
|
-
|
|
2936
|
+
I,
|
|
2729
2937
|
" / ",
|
|
2730
|
-
|
|
2938
|
+
B.toLocaleString()
|
|
2731
2939
|
] }),
|
|
2732
|
-
/* @__PURE__ */
|
|
2940
|
+
/* @__PURE__ */ s(
|
|
2733
2941
|
"button",
|
|
2734
2942
|
{
|
|
2735
2943
|
type: "button",
|
|
2736
|
-
disabled:
|
|
2737
|
-
onClick: () =>
|
|
2944
|
+
disabled: I >= B || re,
|
|
2945
|
+
onClick: () => he((d) => Math.min(B, d + 1)),
|
|
2738
2946
|
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]",
|
|
2739
2947
|
children: "Next ›"
|
|
2740
2948
|
}
|
|
@@ -2745,28 +2953,29 @@ function As({
|
|
|
2745
2953
|
}
|
|
2746
2954
|
)
|
|
2747
2955
|
] }),
|
|
2748
|
-
|
|
2956
|
+
te
|
|
2749
2957
|
);
|
|
2750
2958
|
}
|
|
2751
|
-
function
|
|
2959
|
+
function zs(i, m) {
|
|
2752
2960
|
var x;
|
|
2753
2961
|
if (!i) return null;
|
|
2754
|
-
const
|
|
2755
|
-
return !
|
|
2962
|
+
const f = (x = (m ?? []).find((_) => !_.format && !_.sections_only)) == null ? void 0 : x.field;
|
|
2963
|
+
return !f || i.includes(`{{${f}}}`) ? i : `${i} · {{${f}}}`;
|
|
2756
2964
|
}
|
|
2757
2965
|
export {
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2966
|
+
pa as CatalogPickerField,
|
|
2967
|
+
Js as FacetBuilderCard,
|
|
2968
|
+
vs as MAX_LINE_MONEY,
|
|
2969
|
+
zs as catalogOptionTemplate,
|
|
2970
|
+
Os as footerSum,
|
|
2971
|
+
Ls as gridPriceValue,
|
|
2972
|
+
Ks as isUnpricedLine,
|
|
2973
|
+
As as issuesAfterLinesChanged,
|
|
2974
|
+
Ps as lineComputeError,
|
|
2766
2975
|
ir as matchesShowWhen,
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2976
|
+
Ts as qtyEntryProblem,
|
|
2977
|
+
Rs as refusedQtyNote,
|
|
2978
|
+
pn as relatedParentTokens,
|
|
2979
|
+
Es as savedLinesSignature,
|
|
2980
|
+
js as stagedCatalogFill
|
|
2772
2981
|
};
|