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