@nivaro/react 0.3.49 → 0.3.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/InlineGridField.js +166 -105
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +38 -4
- package/dist/shared/components/ItemEditForm.js +5258 -5034
- package/dist/shared/components/QueryTable.js +489 -347
- 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 +1230 -1175
- package/dist/shared/components/item-edit/CloneDialog.js +192 -142
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +58 -53
- package/dist/shared/components/item-edit/FieldRenderer.js +249 -244
- package/dist/shared/components/item-edit/FieldRow.js +402 -370
- package/dist/shared/components/item-edit/FilePickerField.js +315 -307
- package/dist/shared/components/item-edit/InlineGridField.js +92 -90
- package/dist/shared/components/item-edit/InlineTableField.js +3119 -2951
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +175 -0
- package/dist/shared/components/item-edit/PlanGrid.js +162 -162
- package/dist/shared/components/item-edit/PolishFields.js +169 -162
- 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 +198 -191
- package/dist/shared/components/item-edit/SummaryPanel.js +282 -259
- package/dist/shared/components/item-edit/UserChip.js +233 -200
- package/dist/shared/components/item-edit/ValidationSummary.js +64 -47
- package/dist/shared/components/item-edit/header-midair.js +51 -0
- package/dist/shared/components/item-edit/helpers.js +181 -155
- package/dist/shared/components/item-edit/line-midair.js +207 -0
- package/dist/shared/components/item-edit/soft-rules.js +27 -0
- package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
- package/dist/shared/components/panels/CommentPanel.js +290 -284
- package/dist/shared/components/panels/ItemLockBanner.js +414 -358
- package/dist/shared/components/panels/PipelinePanel.js +1241 -992
- package/dist/shared/components/panels/RecordIntegrityBanner.js +1 -1
- 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 +925 -871
- package/dist/shared/components/queue/column-chooser.js +21 -0
- package/dist/shared/components/queue/live-state-aspect.js +6 -0
- package/dist/shared/components/ui/number-draft-input.js +93 -0
- package/dist/shared/components/widgets/ReviewListWidget.js +191 -166
- package/dist/shared/lib/draft-store.js +48 -34
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/query-stats.js +60 -60
- package/package.json +1 -1
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { jsxs as c, jsx as s, Fragment as
|
|
2
|
-
import { useQueryClient as
|
|
3
|
-
import { Search as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { createPortal as
|
|
6
|
-
import { useNivaroClient as
|
|
7
|
-
import { canOpenCatalogItem as
|
|
8
|
-
import { get as
|
|
9
|
-
import { evaluateBoolean as
|
|
10
|
-
import { useLiveRefetchInterval as
|
|
11
|
-
import { tokenize as
|
|
12
|
-
import { submissionLineErrors as
|
|
13
|
-
import { titleCase as
|
|
14
|
-
import { ImportFromFileButton as
|
|
15
|
-
import { SearchHighlight as
|
|
16
|
-
import { useOverflowTip as
|
|
17
|
-
import { Popover as
|
|
18
|
-
import { useColumnWidths as
|
|
19
|
-
import { orderCatalogMatches as
|
|
20
|
-
import { applyDisplayTemplate as
|
|
21
|
-
import { evalClientFormula as
|
|
22
|
-
import { isIntegerFieldType as
|
|
23
|
-
import { resolveM2MRelatedCollection as
|
|
24
|
-
import { useO2MStaging as
|
|
25
|
-
import { RelationCombobox as
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
for (const
|
|
29
|
-
if (
|
|
30
|
-
|
|
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
|
+
import { canOpenCatalogItem as Zr, openCatalogItem as Gr } from "../../lib/catalog-item-open.js";
|
|
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
|
+
import { SearchHighlight as ir } from "../SearchHighlight.js";
|
|
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
|
+
import { applyDisplayTemplate as Je } from "./helpers.js";
|
|
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
|
|
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
|
|
45
|
-
const a = (
|
|
46
|
-
if (typeof
|
|
47
|
-
const
|
|
48
|
-
return
|
|
42
|
+
function De(u, x) {
|
|
43
|
+
const w = {};
|
|
44
|
+
let N = !1;
|
|
45
|
+
const a = (p) => {
|
|
46
|
+
if (typeof p == "string" && p.startsWith("$parent.")) {
|
|
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(
|
|
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 [
|
|
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 Hr(
|
|
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 (
|
|
70
|
+
if (p !== String(k)) return !1;
|
|
71
71
|
break;
|
|
72
72
|
case "_neq":
|
|
73
|
-
if (
|
|
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
|
-
if (
|
|
82
|
+
if (p !== null) return !1;
|
|
83
83
|
break;
|
|
84
84
|
case "_nnull":
|
|
85
|
-
if (
|
|
85
|
+
if (p === null) return !1;
|
|
86
86
|
break;
|
|
87
87
|
default:
|
|
88
88
|
return !1;
|
|
@@ -90,621 +90,641 @@ function Hr(m, 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
|
-
readOnly:
|
|
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 h =
|
|
168
|
-
return d == null || d === "" ? (e.push(h),
|
|
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
|
-
name: String(
|
|
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
|
-
}),
|
|
245
|
-
const e = new Map(
|
|
246
|
-
for (const r of
|
|
264
|
+
}), cr = F(() => {
|
|
265
|
+
const e = new Map(it.map((r) => [r.id, r.name])), t = /* @__PURE__ */ new Map();
|
|
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
|
-
}, [
|
|
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
|
-
() =>
|
|
269
|
-
const t =
|
|
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) => {
|
|
289
|
+
const t = dt.get(String(e.id));
|
|
270
290
|
return t ? { ...e, ...t } : e;
|
|
271
291
|
}),
|
|
272
|
-
[Fe,
|
|
273
|
-
),
|
|
292
|
+
[Fe, nn]
|
|
293
|
+
), ut = !z && k ? k.getPendingDeletes(u, x) : /* @__PURE__ */ new Set(), Ue = F(() => {
|
|
274
294
|
const e = /* @__PURE__ */ new Map();
|
|
275
|
-
for (const t of
|
|
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
|
-
}, [
|
|
300
|
+
}, [ct, a.item_field]), mt = F(() => {
|
|
281
301
|
const e = /* @__PURE__ */ new Map();
|
|
282
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
|
-
}, [Te, a.item_field]),
|
|
306
|
+
}, [Te, a.item_field]), pe = F(() => {
|
|
287
307
|
const e = Te.filter((n) => n[a.item_field] != null).map((n) => ({ key: String(n[a.item_field]), row: n }));
|
|
288
|
-
if (
|
|
289
|
-
const t =
|
|
308
|
+
if (z) return e;
|
|
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
|
-
|
|
298
|
-
filter: JSON.stringify({ id: { _in:
|
|
299
|
-
fields:
|
|
300
|
-
limit:
|
|
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}`, {
|
|
318
|
+
filter: JSON.stringify({ id: { _in: ft } }),
|
|
319
|
+
fields: T,
|
|
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
|
-
}),
|
|
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
|
-
}), [
|
|
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
|
-
title:
|
|
341
|
-
disabled:
|
|
360
|
+
title: Pt.has(e) ? "Remove from favorites" : "Add to favorites",
|
|
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:
|
|
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]), X =
|
|
400
|
+
}, [a.related_columns]), X = Ye === -1 ? null : (a.related_columns ?? [])[Ye] ?? null, $e = X ? De(X.match, i) : null, Ae = F(() => {
|
|
381
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
|
-
}, [X]),
|
|
385
|
-
|
|
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(() => {
|
|
386
406
|
if (Ie)
|
|
387
407
|
try {
|
|
388
|
-
|
|
408
|
+
kr(localStorage.getItem(Ie) === "1");
|
|
389
409
|
} catch {
|
|
390
410
|
}
|
|
391
411
|
}, [Ie]);
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
412
|
+
const Lt = (e) => {
|
|
413
|
+
if (kr(e), !!Ie)
|
|
394
414
|
try {
|
|
395
415
|
e ? localStorage.setItem(Ie, "1") : localStorage.removeItem(Ie);
|
|
396
416
|
} catch {
|
|
397
417
|
}
|
|
398
|
-
}, ee = !!X &&
|
|
418
|
+
}, ee = !!X && gr && $e !== null, At = F(() => {
|
|
399
419
|
if (!X) return null;
|
|
400
|
-
const e = ((
|
|
401
|
-
(t) => t.many_collection === X.collection && t.many_field === X.item_field && t.one_collection ===
|
|
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
|
-
}, [X,
|
|
405
|
-
() => ee &&
|
|
406
|
-
[ee,
|
|
407
|
-
),
|
|
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
|
-
},
|
|
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
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
439
|
+
It,
|
|
440
|
+
zt,
|
|
441
|
+
Ze,
|
|
442
|
+
pt
|
|
423
443
|
],
|
|
424
444
|
queryFn: async () => {
|
|
425
|
-
const e = new Date(Date.now() -
|
|
426
|
-
|
|
427
|
-
const r = await
|
|
428
|
-
|
|
445
|
+
const e = new Date(Date.now() - pt * 864e5).toISOString(), t = { [zt]: { _eq: It } };
|
|
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
|
|
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;
|
|
438
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
|
-
enabled:
|
|
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
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
467
|
+
b,
|
|
468
|
+
T,
|
|
469
|
+
me,
|
|
470
|
+
Le,
|
|
471
|
+
Ct,
|
|
472
|
+
bt
|
|
453
473
|
],
|
|
454
|
-
queryFn: () =>
|
|
455
|
-
|
|
456
|
-
`/items/${
|
|
457
|
-
|
|
458
|
-
search:
|
|
459
|
-
search_fields:
|
|
474
|
+
queryFn: () => g.request(
|
|
475
|
+
O(
|
|
476
|
+
`/items/${b}`,
|
|
477
|
+
Jt({
|
|
478
|
+
search: me,
|
|
479
|
+
search_fields: Le.join(","),
|
|
460
480
|
search_rank: "1",
|
|
461
|
-
fields:
|
|
462
|
-
limit:
|
|
463
|
-
sort:
|
|
481
|
+
fields: T,
|
|
482
|
+
limit: bt,
|
|
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
|
-
}),
|
|
490
|
+
}), xt = xr.join(","), { data: wr = [], isFetching: cn } = A({
|
|
471
491
|
queryKey: [
|
|
472
492
|
"catalog-full-search",
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
493
|
+
b,
|
|
494
|
+
T,
|
|
495
|
+
me,
|
|
496
|
+
xt,
|
|
497
|
+
Ct,
|
|
498
|
+
bt
|
|
479
499
|
],
|
|
480
|
-
queryFn: () =>
|
|
481
|
-
|
|
482
|
-
`/items/${
|
|
483
|
-
|
|
484
|
-
search:
|
|
485
|
-
fields: [
|
|
486
|
-
limit:
|
|
487
|
-
sort:
|
|
500
|
+
queryFn: () => g.request(
|
|
501
|
+
O(
|
|
502
|
+
`/items/${b}`,
|
|
503
|
+
Jt({
|
|
504
|
+
search: me,
|
|
505
|
+
fields: [T, xt].filter(Boolean).join(","),
|
|
506
|
+
limit: bt,
|
|
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
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
517
|
+
b,
|
|
518
|
+
T,
|
|
519
|
+
me,
|
|
520
|
+
xt,
|
|
521
|
+
un,
|
|
522
|
+
Ct
|
|
503
523
|
],
|
|
504
|
-
queryFn: () =>
|
|
505
|
-
|
|
506
|
-
`/items/${
|
|
507
|
-
|
|
524
|
+
queryFn: () => g.request(
|
|
525
|
+
O(
|
|
526
|
+
`/items/${b}`,
|
|
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
|
-
}),
|
|
522
|
-
() =>
|
|
523
|
-
shown:
|
|
524
|
-
other:
|
|
525
|
-
recent:
|
|
526
|
-
shownFields:
|
|
527
|
-
q:
|
|
541
|
+
}), Wt = dn || cn, ze = F(
|
|
542
|
+
() => as({
|
|
543
|
+
shown: Bt,
|
|
544
|
+
other: wr,
|
|
545
|
+
recent: Nr,
|
|
546
|
+
shownFields: Le,
|
|
547
|
+
q: me
|
|
528
548
|
}),
|
|
529
|
-
[
|
|
530
|
-
),
|
|
531
|
-
if (
|
|
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
|
-
},
|
|
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
|
|
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);
|
|
546
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",
|
|
554
574
|
e.key,
|
|
555
575
|
e.collection,
|
|
556
576
|
JSON.stringify(t),
|
|
557
|
-
|
|
577
|
+
yt.join(",")
|
|
558
578
|
],
|
|
559
579
|
queryFn: async () => {
|
|
560
|
-
const r = {}, n = e.aggregate === "sum",
|
|
561
|
-
for (let
|
|
562
|
-
const h =
|
|
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
|
|
566
|
-
|
|
585
|
+
const m = await g.request(
|
|
586
|
+
O(`/items/${e.collection}`, {
|
|
567
587
|
limit: n ? 1e3 : h.length,
|
|
568
588
|
...n ? { page: d } : {},
|
|
569
589
|
fields: `${e.item_field},${e.value_field}`,
|
|
570
590
|
filter: JSON.stringify({ ...t, [e.item_field]: { _in: h } })
|
|
571
591
|
})
|
|
572
592
|
).then((f) => f.data ?? []);
|
|
573
|
-
for (const f of
|
|
574
|
-
const
|
|
575
|
-
if (
|
|
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
|
-
if (!n ||
|
|
602
|
+
if (!n || m.length < 1e3) break;
|
|
583
603
|
d += 1;
|
|
584
604
|
}
|
|
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
|
-
}),
|
|
593
|
-
var n,
|
|
594
|
-
const r = (a.related_columns ?? []).findIndex((
|
|
612
|
+
}), kt = (e, t) => {
|
|
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 (!ee ||
|
|
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
|
-
const n = (a.related_columns ?? []).findIndex((
|
|
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
|
|
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);
|
|
612
632
|
return Number.isNaN(h) ? null : r > h ? { available: h, qty: r } : null;
|
|
613
|
-
},
|
|
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
|
-
}, Vt = a.qty_warning ? a.qty_warning.label ?? ((
|
|
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 = (
|
|
642
|
-
return !e || e.status !== "failed" ? null :
|
|
643
|
-
}, [
|
|
644
|
-
queryKey: ["catalog-suberr-idents",
|
|
659
|
+
refetchInterval: pn
|
|
660
|
+
}), Ut = F(() => {
|
|
661
|
+
const e = (_r ?? [])[0];
|
|
662
|
+
return !e || e.status !== "failed" ? null : Hn(e.payload, e.last_error);
|
|
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
|
-
fields: ["id", ...
|
|
671
|
+
fields: ["id", ...wt].join(","),
|
|
652
672
|
filter: JSON.stringify({ id: { _in: e } })
|
|
653
673
|
})
|
|
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
|
-
|
|
663
|
-
...
|
|
664
|
-
const
|
|
665
|
-
return
|
|
679
|
+
}), yn = (e) => {
|
|
680
|
+
if (!Ut) return null;
|
|
681
|
+
const t = Ht == null ? void 0 : Ht[e], r = [
|
|
682
|
+
Er(e),
|
|
683
|
+
...wt.map((n) => {
|
|
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
|
-
},
|
|
670
|
-
queries:
|
|
671
|
-
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction,
|
|
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({
|
|
690
|
+
queries: Nt.filter((e) => e.m2m).map((e) => ({
|
|
691
|
+
queryKey: ["catalog-summary-m2m", e.field, e.m2m.junction, gn],
|
|
672
692
|
queryFn: async () => {
|
|
673
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((f) => f.data ?? []).catch(() => []),
|
|
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((f) => f.data ?? []).catch(() => []) : [], d = new Map(h.map((f) => [String(f.id), String(f[
|
|
707
|
+
).then((f) => f.data ?? []).catch(() => []) : [], d = new Map(h.map((f) => [String(f.id), String(f[l] ?? f.id)])), m = {};
|
|
688
708
|
for (const f of n) {
|
|
689
|
-
const
|
|
690
|
-
|
|
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
|
-
return
|
|
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 =
|
|
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 As({
|
|
|
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,92 +759,92 @@ function As({
|
|
|
739
759
|
}
|
|
740
760
|
t = t.parentElement;
|
|
741
761
|
}
|
|
742
|
-
},
|
|
743
|
-
|
|
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,
|
|
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
|
-
},
|
|
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
800
|
onResize: (h) => e.setWidth(t, h),
|
|
781
|
-
onFit: () =>
|
|
801
|
+
onFit: () => Sn(e, t)
|
|
782
802
|
}
|
|
783
803
|
)
|
|
784
804
|
] }, t);
|
|
785
|
-
},
|
|
786
|
-
|
|
787
|
-
const [
|
|
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: [
|
|
806
|
+
vt.map((n) => {
|
|
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
|
-
...
|
|
813
|
+
...Oe.box(n.field, o, K("text-slate-500 dark:text-slate-400", l))
|
|
794
814
|
},
|
|
795
815
|
n.field
|
|
796
816
|
);
|
|
797
817
|
}),
|
|
798
|
-
|
|
818
|
+
Yt.map((n) => /* @__PURE__ */ s(
|
|
799
819
|
"span",
|
|
800
820
|
{
|
|
801
|
-
...
|
|
821
|
+
...Oe.box(
|
|
802
822
|
`rel:${n.key}`,
|
|
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 As({
|
|
|
833
853
|
),
|
|
834
854
|
r
|
|
835
855
|
] });
|
|
836
|
-
},
|
|
837
|
-
const t =
|
|
838
|
-
return t ?
|
|
839
|
-
},
|
|
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
|
|
843
|
-
const r =
|
|
844
|
-
return r === void 0 ? null : Number(((n = Te[r]) == null ? void 0 : n[
|
|
845
|
-
},
|
|
861
|
+
const t = z ? void 0 : Ue.get(e);
|
|
862
|
+
if (t) return ut.has(String(t.id)) ? null : Number(t[ae] ?? 0);
|
|
863
|
+
const r = mt.get(e);
|
|
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
|
-
},
|
|
853
|
-
if (
|
|
854
|
-
|
|
872
|
+
}, $t = F(() => {
|
|
873
|
+
if (lt) return [];
|
|
874
|
+
V.trim().toLowerCase();
|
|
855
875
|
const e = /* @__PURE__ */ new Map();
|
|
856
|
-
for (const t of
|
|
857
|
-
if (ee &&
|
|
858
|
-
const r =
|
|
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
|
-
|
|
878
|
-
|
|
879
|
-
|
|
896
|
+
P,
|
|
897
|
+
cr,
|
|
898
|
+
lt,
|
|
899
|
+
W,
|
|
880
900
|
ee,
|
|
881
|
-
|
|
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
|
-
for (const t of
|
|
887
|
-
t.items.some((n) => (
|
|
888
|
-
|
|
906
|
+
for (const t of $t)
|
|
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
|
-
let n =
|
|
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((
|
|
924
|
+
).then((l) => {
|
|
905
925
|
var h, d;
|
|
906
|
-
return (d = (h =
|
|
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,228 +931,258 @@ function As({
|
|
|
911
931
|
}
|
|
912
932
|
return t;
|
|
913
933
|
}
|
|
914
|
-
|
|
915
|
-
|
|
934
|
+
const Tn = (e, t) => {
|
|
935
|
+
var n;
|
|
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;
|
|
940
|
+
}
|
|
941
|
+
const r = (n = a.copy_fields) == null ? void 0 : n[t];
|
|
942
|
+
return r ? Ke(e)[r] : void 0;
|
|
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);
|
|
947
|
+
return r == null || r === "" || !(Number(r) > 0);
|
|
948
|
+
};
|
|
949
|
+
function Qe(e, t, r, n = {}) {
|
|
950
|
+
const o = {
|
|
916
951
|
[a.item_field]: r.id ?? e,
|
|
917
|
-
[
|
|
952
|
+
[ae]: t
|
|
918
953
|
};
|
|
919
|
-
for (const [
|
|
920
|
-
r[h] !== void 0 && (l
|
|
921
|
-
Object.assign(
|
|
922
|
-
for (const [
|
|
923
|
-
const d =
|
|
924
|
-
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);
|
|
925
960
|
}
|
|
926
|
-
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
|
+
});
|
|
927
973
|
}
|
|
928
974
|
async function tt(e, t, r, n = {}) {
|
|
929
|
-
const
|
|
930
|
-
if (!
|
|
931
|
-
|
|
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 } }));
|
|
932
978
|
return;
|
|
933
979
|
}
|
|
934
|
-
const
|
|
935
|
-
if ((
|
|
936
|
-
if (
|
|
937
|
-
|
|
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 } }));
|
|
938
984
|
return;
|
|
939
985
|
}
|
|
940
|
-
if (
|
|
941
|
-
const
|
|
942
|
-
if (
|
|
943
|
-
|
|
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: _ } }));
|
|
944
990
|
return;
|
|
945
991
|
}
|
|
946
992
|
}
|
|
947
|
-
const d =
|
|
948
|
-
if (Ve &&
|
|
949
|
-
const
|
|
950
|
-
if ((
|
|
951
|
-
const f = String(
|
|
952
|
-
if (
|
|
953
|
-
|
|
993
|
+
const d = l > 0 ? await Fn(e) : {};
|
|
994
|
+
if (Ve && k) {
|
|
995
|
+
const m = Ue.get(e);
|
|
996
|
+
if ((m == null ? void 0 : m.id) != null) {
|
|
997
|
+
const f = String(m.id);
|
|
998
|
+
if (l === 0) {
|
|
999
|
+
k.cancelPendingEdit(u, x, f), k.queueDelete(u, x, f);
|
|
954
1000
|
return;
|
|
955
1001
|
}
|
|
956
|
-
|
|
957
|
-
const
|
|
958
|
-
for (const
|
|
959
|
-
|
|
960
|
-
for (const [
|
|
961
|
-
const
|
|
962
|
-
|
|
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);
|
|
963
1009
|
}
|
|
964
|
-
const
|
|
965
|
-
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] ?? ""))
|
|
966
1012
|
);
|
|
967
|
-
Object.keys(
|
|
1013
|
+
Object.keys(E).length === 0 ? k.cancelPendingEdit(u, x, f) : (k.cancelPendingEdit(u, x, f), k.queueEdit(u, x, f, E));
|
|
968
1014
|
return;
|
|
969
1015
|
}
|
|
970
1016
|
}
|
|
971
|
-
if (
|
|
972
|
-
const
|
|
973
|
-
|
|
974
|
-
m,
|
|
975
|
-
k,
|
|
1017
|
+
if (z || Ve) {
|
|
1018
|
+
const m = mt.get(e);
|
|
1019
|
+
l === 0 ? m !== void 0 && (k == null || k.removeRow(u, x, m)) : m !== void 0 ? k == null || k.updateRow(
|
|
976
1020
|
u,
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1021
|
+
x,
|
|
1022
|
+
m,
|
|
1023
|
+
ls(
|
|
1024
|
+
Te[m],
|
|
1025
|
+
Qe(e, l, r, d),
|
|
1026
|
+
te,
|
|
981
1027
|
a.compute_fields
|
|
982
1028
|
)
|
|
983
|
-
) :
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
1029
|
+
) : k == null || k.queueRow(
|
|
1030
|
+
u,
|
|
1031
|
+
x,
|
|
1032
|
+
Qe(e, l, r, d)
|
|
987
1033
|
);
|
|
988
1034
|
return;
|
|
989
1035
|
}
|
|
990
|
-
|
|
1036
|
+
se((m) => new Set(m).add(e));
|
|
991
1037
|
try {
|
|
992
|
-
const
|
|
993
|
-
if (
|
|
994
|
-
(
|
|
995
|
-
else if ((
|
|
996
|
-
const f =
|
|
997
|
-
for (const
|
|
998
|
-
|
|
999
|
-
for (const [
|
|
1000
|
-
const
|
|
1001
|
-
|
|
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}`));
|
|
1041
|
+
else if ((m == null ? void 0 : m.id) != 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);
|
|
1002
1048
|
}
|
|
1003
|
-
const
|
|
1004
|
-
await
|
|
1049
|
+
const _ = { ...m, ...f }, { id: S, ...E } = _;
|
|
1050
|
+
await g.request(Mr(`/items/${u}/${m.id}${re}`, E));
|
|
1005
1051
|
} else
|
|
1006
|
-
await
|
|
1007
|
-
|
|
1008
|
-
[
|
|
1009
|
-
...
|
|
1052
|
+
await g.request(
|
|
1053
|
+
Vr(`/items/${u}${re}`, {
|
|
1054
|
+
[x]: w,
|
|
1055
|
+
...Qe(e, l, r, d)
|
|
1010
1056
|
})
|
|
1011
1057
|
);
|
|
1012
|
-
|
|
1058
|
+
j.invalidateQueries({ queryKey: ["o2m-rows", u, x, w] });
|
|
1013
1059
|
} catch {
|
|
1014
1060
|
} finally {
|
|
1015
|
-
|
|
1016
|
-
const f = new Set(
|
|
1061
|
+
se((m) => {
|
|
1062
|
+
const f = new Set(m);
|
|
1017
1063
|
return f.delete(e), f;
|
|
1018
1064
|
});
|
|
1019
1065
|
}
|
|
1020
1066
|
}
|
|
1021
|
-
async function
|
|
1067
|
+
async function Pn(e, t, r) {
|
|
1022
1068
|
const n = r.trim() === "" ? null : Number(r);
|
|
1023
1069
|
if (r.trim() !== "" && Number.isNaN(n)) return;
|
|
1024
|
-
const
|
|
1070
|
+
const o = (h) => {
|
|
1025
1071
|
const d = { ...h, [t]: n };
|
|
1026
|
-
for (const [
|
|
1027
|
-
const
|
|
1028
|
-
|
|
1072
|
+
for (const [m, f] of Object.entries(a.compute_fields ?? {})) {
|
|
1073
|
+
const _ = Be(f, d);
|
|
1074
|
+
_ !== null && (d[m] = _);
|
|
1029
1075
|
}
|
|
1030
1076
|
return d;
|
|
1031
|
-
},
|
|
1032
|
-
if ((
|
|
1033
|
-
const h =
|
|
1077
|
+
}, l = z ? void 0 : Ue.get(e);
|
|
1078
|
+
if ((l == null ? void 0 : l.id) == null) {
|
|
1079
|
+
const h = mt.get(e);
|
|
1034
1080
|
if (h === void 0) return;
|
|
1035
|
-
|
|
1081
|
+
k == null || k.updateRow(u, x, h, o(Te[h]));
|
|
1036
1082
|
return;
|
|
1037
1083
|
}
|
|
1038
|
-
if (Ve &&
|
|
1039
|
-
const h = l
|
|
1084
|
+
if (Ve && k) {
|
|
1085
|
+
const h = o(l), d = Fe.find((f) => String(f.id) === String(l.id)) ?? {}, m = Object.fromEntries(
|
|
1040
1086
|
Object.entries(h).filter(
|
|
1041
|
-
([f,
|
|
1087
|
+
([f, _]) => f !== "id" && String(_ ?? "") !== String(d[f] ?? "")
|
|
1042
1088
|
)
|
|
1043
1089
|
);
|
|
1044
|
-
|
|
1090
|
+
k.cancelPendingEdit(u, x, String(l.id)), Object.keys(m).length > 0 && k.queueEdit(u, x, String(l.id), m);
|
|
1045
1091
|
return;
|
|
1046
1092
|
}
|
|
1047
|
-
|
|
1093
|
+
se((h) => new Set(h).add(e));
|
|
1048
1094
|
try {
|
|
1049
|
-
const { id: h, ...d } = l
|
|
1050
|
-
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] });
|
|
1051
1097
|
} catch {
|
|
1052
1098
|
} finally {
|
|
1053
|
-
|
|
1099
|
+
se((h) => {
|
|
1054
1100
|
const d = new Set(h);
|
|
1055
1101
|
return d.delete(e), d;
|
|
1056
1102
|
});
|
|
1057
1103
|
}
|
|
1058
1104
|
}
|
|
1059
|
-
async function
|
|
1060
|
-
if (e == null || e === "" || !
|
|
1061
|
-
const t = String(e), r =
|
|
1105
|
+
async function En(e) {
|
|
1106
|
+
if (e == null || e === "" || !b) return;
|
|
1107
|
+
const t = String(e), r = Ke(t);
|
|
1062
1108
|
let n = r;
|
|
1063
|
-
Object.keys(r).length <= 1 && (n = await
|
|
1064
|
-
|
|
1109
|
+
Object.keys(r).length <= 1 && (n = await g.request(
|
|
1110
|
+
O(`/items/${b}`, {
|
|
1065
1111
|
filter: JSON.stringify({ id: { _eq: e } }),
|
|
1066
|
-
fields:
|
|
1112
|
+
fields: T,
|
|
1067
1113
|
limit: 1
|
|
1068
1114
|
})
|
|
1069
|
-
).then((
|
|
1115
|
+
).then((l) => {
|
|
1070
1116
|
var h;
|
|
1071
|
-
return ((h =
|
|
1117
|
+
return ((h = l.data) == null ? void 0 : h[0]) ?? { id: e };
|
|
1072
1118
|
}).catch(() => ({ id: e })));
|
|
1073
|
-
const
|
|
1074
|
-
await tt(t, String(
|
|
1119
|
+
const o = (we(t) ?? 0) + 1;
|
|
1120
|
+
await tt(t, String(o), n);
|
|
1075
1121
|
}
|
|
1076
|
-
const
|
|
1077
|
-
const r =
|
|
1078
|
-
if (
|
|
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);
|
|
1124
|
+
if (p)
|
|
1079
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 : "—" });
|
|
1080
|
-
const n =
|
|
1081
|
-
if (!(e in
|
|
1082
|
-
const f = { ...
|
|
1126
|
+
const n = ye[e], o = n !== void 0 ? n : r && r > 0 ? String(r) : "", l = Y[e], h = () => G((m) => {
|
|
1127
|
+
if (!(e in m)) return m;
|
|
1128
|
+
const f = { ...m };
|
|
1083
1129
|
return delete f[e], f;
|
|
1084
1130
|
}), d = /* @__PURE__ */ s(
|
|
1085
1131
|
"input",
|
|
1086
1132
|
{
|
|
1087
1133
|
type: "number",
|
|
1088
1134
|
min: 0,
|
|
1089
|
-
step:
|
|
1090
|
-
disabled:
|
|
1091
|
-
value:
|
|
1135
|
+
step: lr(le) ? 1 : "any",
|
|
1136
|
+
disabled: p,
|
|
1137
|
+
value: o,
|
|
1092
1138
|
placeholder: "0",
|
|
1093
|
-
"aria-invalid": (
|
|
1139
|
+
"aria-invalid": (l == null ? void 0 : l.kind) === "error" || void 0,
|
|
1094
1140
|
onFocus: h,
|
|
1095
|
-
onChange: (
|
|
1096
|
-
onBlur: (
|
|
1097
|
-
const f =
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
return
|
|
1141
|
+
onChange: (m) => he((f) => ({ ...f, [e]: m.target.value })),
|
|
1142
|
+
onBlur: (m) => {
|
|
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;
|
|
1101
1151
|
}), tt(e, f, t);
|
|
1102
1152
|
},
|
|
1103
|
-
onKeyDown: (
|
|
1104
|
-
|
|
1153
|
+
onKeyDown: (m) => {
|
|
1154
|
+
m.key === "Enter" && m.currentTarget.blur();
|
|
1105
1155
|
},
|
|
1106
|
-
className:
|
|
1156
|
+
className: K(
|
|
1107
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",
|
|
1108
|
-
(
|
|
1158
|
+
(l == null ? void 0 : l.kind) === "error" && "border-red-400 dark:border-red-600"
|
|
1109
1159
|
)
|
|
1110
1160
|
}
|
|
1111
1161
|
);
|
|
1112
|
-
return /* @__PURE__ */ c(
|
|
1113
|
-
/* @__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: [
|
|
1114
1164
|
d,
|
|
1115
|
-
(
|
|
1165
|
+
(l == null ? void 0 : l.kind) === "error" && /* @__PURE__ */ c(
|
|
1116
1166
|
"span",
|
|
1117
1167
|
{
|
|
1118
1168
|
role: "alert",
|
|
1119
1169
|
className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
|
|
1120
1170
|
"data-catalog-qty-error": !0,
|
|
1121
1171
|
children: [
|
|
1122
|
-
/* @__PURE__ */ s(
|
|
1123
|
-
|
|
1172
|
+
/* @__PURE__ */ s(rr, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1173
|
+
l.message,
|
|
1124
1174
|
r && r > 0 ? ` — still ${r}` : ""
|
|
1125
1175
|
]
|
|
1126
1176
|
}
|
|
1127
1177
|
)
|
|
1128
1178
|
] }) }),
|
|
1129
1179
|
/* @__PURE__ */ s(
|
|
1130
|
-
|
|
1180
|
+
rs,
|
|
1131
1181
|
{
|
|
1132
1182
|
align: "end",
|
|
1133
1183
|
side: "bottom",
|
|
1134
1184
|
className: "w-auto max-w-[260px] p-2.5 text-[12px]",
|
|
1135
|
-
children: (
|
|
1185
|
+
children: (l == null ? void 0 : l.kind) === "remove" && /* @__PURE__ */ c("div", { "data-catalog-qty-remove": !0, children: [
|
|
1136
1186
|
/* @__PURE__ */ s("p", { className: "text-slate-700 dark:text-slate-200", children: "Remove this line?" }),
|
|
1137
1187
|
/* @__PURE__ */ c("div", { className: "mt-2 flex justify-end gap-1.5", children: [
|
|
1138
1188
|
/* @__PURE__ */ s(
|
|
@@ -1149,8 +1199,8 @@ function As({
|
|
|
1149
1199
|
{
|
|
1150
1200
|
type: "button",
|
|
1151
1201
|
onClick: () => {
|
|
1152
|
-
const
|
|
1153
|
-
h(), tt(e, "0",
|
|
1202
|
+
const m = l.row;
|
|
1203
|
+
h(), tt(e, "0", m, { confirmedRemove: !0 });
|
|
1154
1204
|
},
|
|
1155
1205
|
className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
|
|
1156
1206
|
children: "Remove"
|
|
@@ -1161,11 +1211,11 @@ function As({
|
|
|
1161
1211
|
}
|
|
1162
1212
|
)
|
|
1163
1213
|
] });
|
|
1164
|
-
},
|
|
1165
|
-
const n = `${e}:${t}`,
|
|
1214
|
+
}, An = (e, t, r) => {
|
|
1215
|
+
const n = `${e}:${t}`, o = _e[n], l = () => fe((d) => {
|
|
1166
1216
|
if (!(n in d)) return d;
|
|
1167
|
-
const
|
|
1168
|
-
return delete
|
|
1217
|
+
const m = { ...d };
|
|
1218
|
+
return delete m[n], m;
|
|
1169
1219
|
}), h = r[t] == null ? "" : String(r[t]);
|
|
1170
1220
|
return /* @__PURE__ */ c("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
|
|
1171
1221
|
/* @__PURE__ */ s(
|
|
@@ -1175,60 +1225,60 @@ function As({
|
|
|
1175
1225
|
min: 0,
|
|
1176
1226
|
step: "any",
|
|
1177
1227
|
defaultValue: h,
|
|
1178
|
-
"aria-invalid": !!
|
|
1179
|
-
onFocus:
|
|
1228
|
+
"aria-invalid": !!o || void 0,
|
|
1229
|
+
onFocus: l,
|
|
1180
1230
|
onBlur: (d) => {
|
|
1181
|
-
const
|
|
1182
|
-
if (
|
|
1183
|
-
const f =
|
|
1231
|
+
const m = d.target.value;
|
|
1232
|
+
if (m !== h) {
|
|
1233
|
+
const f = L.find((E) => E.field === t), _ = or(m, {
|
|
1184
1234
|
type: f == null ? void 0 : f.type,
|
|
1185
|
-
label: (f == null ? void 0 : f.label) ||
|
|
1186
|
-
}),
|
|
1187
|
-
if (
|
|
1188
|
-
d.target.value = h,
|
|
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 }));
|
|
1189
1239
|
return;
|
|
1190
1240
|
}
|
|
1191
1241
|
}
|
|
1192
|
-
|
|
1242
|
+
Pn(e, t, m);
|
|
1193
1243
|
},
|
|
1194
1244
|
onKeyDown: (d) => {
|
|
1195
1245
|
d.key === "Enter" && d.currentTarget.blur();
|
|
1196
1246
|
},
|
|
1197
|
-
className:
|
|
1247
|
+
className: K(
|
|
1198
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",
|
|
1199
|
-
|
|
1249
|
+
o && "border-red-400 dark:border-red-600"
|
|
1200
1250
|
)
|
|
1201
1251
|
},
|
|
1202
1252
|
`${n}:${h}`
|
|
1203
1253
|
),
|
|
1204
|
-
|
|
1254
|
+
o && /* @__PURE__ */ c(
|
|
1205
1255
|
"span",
|
|
1206
1256
|
{
|
|
1207
1257
|
role: "alert",
|
|
1208
1258
|
className: "mt-0.5 flex max-w-[220px] items-start gap-1 text-right text-[11px] leading-snug text-red-600 dark:text-red-400",
|
|
1209
1259
|
"data-catalog-cell-error": !0,
|
|
1210
1260
|
children: [
|
|
1211
|
-
/* @__PURE__ */ s(
|
|
1212
|
-
|
|
1261
|
+
/* @__PURE__ */ s(rr, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1262
|
+
o,
|
|
1213
1263
|
h !== "" ? ` — still ${h}` : ""
|
|
1214
1264
|
]
|
|
1215
1265
|
}
|
|
1216
1266
|
)
|
|
1217
1267
|
] }, n);
|
|
1218
1268
|
};
|
|
1219
|
-
return !
|
|
1269
|
+
return !b && q ? /* @__PURE__ */ c("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
|
|
1220
1270
|
/* @__PURE__ */ s("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
|
|
1221
1271
|
/* @__PURE__ */ s("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
1222
|
-
] }) :
|
|
1223
|
-
!
|
|
1272
|
+
] }) : b ? /* @__PURE__ */ c("div", { ref: Or, className: "space-y-3", children: [
|
|
1273
|
+
!p && /* @__PURE__ */ c(Ne, { children: [
|
|
1224
1274
|
/* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1225
1275
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-2 border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
1226
|
-
/* @__PURE__ */ s(
|
|
1276
|
+
/* @__PURE__ */ s(Ft, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
1227
1277
|
/* @__PURE__ */ s(
|
|
1228
1278
|
"input",
|
|
1229
1279
|
{
|
|
1230
|
-
value:
|
|
1231
|
-
onChange: (e) =>
|
|
1280
|
+
value: V,
|
|
1281
|
+
onChange: (e) => Pe(e.target.value),
|
|
1232
1282
|
placeholder: "Search catalog…",
|
|
1233
1283
|
className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
|
|
1234
1284
|
}
|
|
@@ -1238,28 +1288,28 @@ function As({
|
|
|
1238
1288
|
{
|
|
1239
1289
|
type: "button",
|
|
1240
1290
|
"aria-pressed": ee,
|
|
1241
|
-
"aria-disabled":
|
|
1291
|
+
"aria-disabled": $e === null ? "true" : void 0,
|
|
1242
1292
|
onClick: () => {
|
|
1243
|
-
|
|
1293
|
+
$e !== null && Lt(!gr);
|
|
1244
1294
|
},
|
|
1245
1295
|
"data-catalog-in-stock": ee ? "on" : "off",
|
|
1246
|
-
"data-tip":
|
|
1247
|
-
className:
|
|
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(
|
|
1248
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",
|
|
1249
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"
|
|
1250
1300
|
),
|
|
1251
1301
|
children: [
|
|
1252
|
-
|
|
1302
|
+
fn ? /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ s(Cn, { className: "h-3 w-3 shrink-0" }),
|
|
1253
1303
|
/* @__PURE__ */ c("span", { className: "truncate", children: [
|
|
1254
1304
|
"In stock",
|
|
1255
|
-
|
|
1305
|
+
$e !== null && Ae && yr != null && /* @__PURE__ */ c(Ne, { children: [
|
|
1256
1306
|
" at ",
|
|
1257
1307
|
/* @__PURE__ */ s(
|
|
1258
|
-
|
|
1308
|
+
ys,
|
|
1259
1309
|
{
|
|
1260
|
-
parentCollection:
|
|
1261
|
-
field:
|
|
1262
|
-
id:
|
|
1310
|
+
parentCollection: N,
|
|
1311
|
+
field: Ae,
|
|
1312
|
+
id: yr
|
|
1263
1313
|
}
|
|
1264
1314
|
)
|
|
1265
1315
|
] })
|
|
@@ -1267,40 +1317,40 @@ function As({
|
|
|
1267
1317
|
]
|
|
1268
1318
|
}
|
|
1269
1319
|
),
|
|
1270
|
-
X &&
|
|
1320
|
+
X && $e === null && /* @__PURE__ */ s("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
|
|
1271
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: [
|
|
1272
|
-
|
|
1322
|
+
Ln,
|
|
1273
1323
|
" picked"
|
|
1274
1324
|
] }),
|
|
1275
|
-
/* @__PURE__ */ s(
|
|
1325
|
+
/* @__PURE__ */ s(nr, { show: Oe.customized, onReset: Oe.reset })
|
|
1276
1326
|
] }),
|
|
1277
|
-
|
|
1327
|
+
Fr && // Sticky: the catalog list is tall and the page scroller carries it —
|
|
1278
1328
|
// without this the labels scroll away and favorites/section rows
|
|
1279
1329
|
// read as headerless columns. Opaque bg (not the /60 tint) so rows
|
|
1280
1330
|
// never bleed through while pinned.
|
|
1281
1331
|
/* @__PURE__ */ c(
|
|
1282
1332
|
"div",
|
|
1283
1333
|
{
|
|
1284
|
-
ref:
|
|
1334
|
+
ref: _n,
|
|
1285
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",
|
|
1286
1336
|
children: [
|
|
1287
1337
|
a.favorites && /* @__PURE__ */ s("span", { className: "w-[18px] shrink-0" }),
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
const [t, r] =
|
|
1291
|
-
return
|
|
1292
|
-
|
|
1338
|
+
qt(Oe, "item", "Item", "w-36 shrink-0"),
|
|
1339
|
+
vt.map((e) => {
|
|
1340
|
+
const [t, r] = Rr(e);
|
|
1341
|
+
return qt(
|
|
1342
|
+
Oe,
|
|
1293
1343
|
e.field,
|
|
1294
|
-
e.label ??
|
|
1344
|
+
e.label ?? M(e.field.split(".")[0]),
|
|
1295
1345
|
t,
|
|
1296
1346
|
r
|
|
1297
1347
|
);
|
|
1298
1348
|
}),
|
|
1299
|
-
|
|
1300
|
-
(e) =>
|
|
1301
|
-
|
|
1349
|
+
Yt.map(
|
|
1350
|
+
(e) => qt(
|
|
1351
|
+
Oe,
|
|
1302
1352
|
`rel:${e.key}`,
|
|
1303
|
-
e.label ??
|
|
1353
|
+
e.label ?? M(e.key),
|
|
1304
1354
|
"w-20 shrink-0",
|
|
1305
1355
|
"text-right"
|
|
1306
1356
|
)
|
|
@@ -1311,20 +1361,20 @@ function As({
|
|
|
1311
1361
|
]
|
|
1312
1362
|
}
|
|
1313
1363
|
),
|
|
1314
|
-
|
|
1315
|
-
/* @__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" }),
|
|
1316
1366
|
" Searching the catalog…"
|
|
1317
1367
|
] }),
|
|
1318
|
-
|
|
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: [
|
|
1319
1369
|
'Nothing in stock matches "',
|
|
1320
|
-
|
|
1370
|
+
V.trim(),
|
|
1321
1371
|
'" —',
|
|
1322
1372
|
" ",
|
|
1323
1373
|
/* @__PURE__ */ c(
|
|
1324
1374
|
"button",
|
|
1325
1375
|
{
|
|
1326
1376
|
type: "button",
|
|
1327
|
-
onClick: () =>
|
|
1377
|
+
onClick: () => Lt(!1),
|
|
1328
1378
|
className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
1329
1379
|
children: [
|
|
1330
1380
|
"show ",
|
|
@@ -1333,99 +1383,99 @@ function As({
|
|
|
1333
1383
|
]
|
|
1334
1384
|
}
|
|
1335
1385
|
)
|
|
1336
|
-
] }) : /* @__PURE__ */ c(
|
|
1386
|
+
] }) : /* @__PURE__ */ c(Ne, { children: [
|
|
1337
1387
|
'No items match "',
|
|
1338
|
-
|
|
1388
|
+
V.trim(),
|
|
1339
1389
|
'"'
|
|
1340
1390
|
] }) }),
|
|
1341
|
-
|
|
1391
|
+
V.trim().length > 0 && et.length > 0 && /* @__PURE__ */ c(rt, { children: [
|
|
1342
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: [
|
|
1343
|
-
/* @__PURE__ */ s(
|
|
1393
|
+
/* @__PURE__ */ s(Ft, { className: "h-3 w-3 shrink-0 text-sky-500" }),
|
|
1344
1394
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
|
|
1345
|
-
/* @__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 }),
|
|
1346
1396
|
/* @__PURE__ */ c("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
1347
1397
|
"across the entire catalog",
|
|
1348
1398
|
ee ? ", in stock only" : "",
|
|
1349
1399
|
" — enter a quantity to add"
|
|
1350
1400
|
] }),
|
|
1351
|
-
|
|
1401
|
+
Wt && /* @__PURE__ */ s(ce, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
|
|
1352
1402
|
] }),
|
|
1353
|
-
|
|
1354
|
-
const r = String(e.id), n =
|
|
1403
|
+
et.map((e, t) => {
|
|
1404
|
+
const r = String(e.id), n = we(r);
|
|
1355
1405
|
return /* @__PURE__ */ c(
|
|
1356
1406
|
"div",
|
|
1357
1407
|
{
|
|
1358
|
-
className:
|
|
1408
|
+
className: K(
|
|
1359
1409
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1360
1410
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1361
1411
|
(n ?? 0) > 0 && "bg-nvr-cyan/5"
|
|
1362
1412
|
),
|
|
1363
1413
|
children: [
|
|
1364
|
-
|
|
1365
|
-
|
|
1414
|
+
Et(r),
|
|
1415
|
+
Xt(
|
|
1366
1416
|
r,
|
|
1367
|
-
|
|
1417
|
+
Je(C, e),
|
|
1368
1418
|
(() => {
|
|
1369
|
-
const
|
|
1370
|
-
return !
|
|
1371
|
-
|
|
1419
|
+
const o = mn(e), l = on.has(r);
|
|
1420
|
+
return !o && !l ? null : /* @__PURE__ */ c(Ne, { children: [
|
|
1421
|
+
l && /* @__PURE__ */ s(
|
|
1372
1422
|
"span",
|
|
1373
1423
|
{
|
|
1374
1424
|
"data-catalog-recent": !0,
|
|
1375
|
-
"data-tip": `You added this in the last ${
|
|
1425
|
+
"data-tip": `You added this in the last ${pt} days`,
|
|
1376
1426
|
className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-slate-400",
|
|
1377
1427
|
children: "Recent"
|
|
1378
1428
|
}
|
|
1379
1429
|
),
|
|
1380
|
-
|
|
1430
|
+
o && /* @__PURE__ */ s(
|
|
1381
1431
|
"span",
|
|
1382
1432
|
{
|
|
1383
1433
|
"data-catalog-match-why": !0,
|
|
1384
|
-
"data-tip": `Matched on ${
|
|
1434
|
+
"data-tip": `Matched on ${o}`,
|
|
1385
1435
|
"data-cpf-fit": !0,
|
|
1386
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",
|
|
1387
|
-
children:
|
|
1437
|
+
children: o
|
|
1388
1438
|
}
|
|
1389
1439
|
)
|
|
1390
1440
|
] });
|
|
1391
1441
|
})(),
|
|
1392
|
-
|
|
1442
|
+
me
|
|
1393
1443
|
),
|
|
1394
|
-
|
|
1395
|
-
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children:
|
|
1396
|
-
|
|
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" }) }),
|
|
1446
|
+
jt(r, e)
|
|
1397
1447
|
]
|
|
1398
1448
|
},
|
|
1399
1449
|
r
|
|
1400
1450
|
);
|
|
1401
1451
|
})
|
|
1402
1452
|
] }),
|
|
1403
|
-
|
|
1453
|
+
D.length > 0 && !V.trim() && /* @__PURE__ */ c("p", { className: "px-3 py-6 text-center text-slate-400", children: [
|
|
1404
1454
|
"Search the full catalog above, or select",
|
|
1405
1455
|
" ",
|
|
1406
|
-
|
|
1456
|
+
D.map((e) => {
|
|
1407
1457
|
var t;
|
|
1408
|
-
return ((t =
|
|
1458
|
+
return ((t = R == null ? void 0 : R.fieldLabels) == null ? void 0 : t[e]) ?? M(e);
|
|
1409
1459
|
}).join(", "),
|
|
1410
1460
|
" ",
|
|
1411
1461
|
"to browse by category"
|
|
1412
1462
|
] }),
|
|
1413
|
-
|
|
1414
|
-
/* @__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" }),
|
|
1415
1465
|
" Loading catalog…"
|
|
1416
1466
|
] }),
|
|
1417
|
-
|
|
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: [
|
|
1418
1468
|
"Nothing in this catalog is in stock here —",
|
|
1419
1469
|
" ",
|
|
1420
1470
|
/* @__PURE__ */ c(
|
|
1421
1471
|
"button",
|
|
1422
1472
|
{
|
|
1423
1473
|
type: "button",
|
|
1424
|
-
onClick: () =>
|
|
1474
|
+
onClick: () => Lt(!1),
|
|
1425
1475
|
className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
1426
1476
|
children: [
|
|
1427
1477
|
"show all ",
|
|
1428
|
-
|
|
1478
|
+
de.length
|
|
1429
1479
|
]
|
|
1430
1480
|
}
|
|
1431
1481
|
)
|
|
@@ -1436,71 +1486,71 @@ function As({
|
|
|
1436
1486
|
"button",
|
|
1437
1487
|
{
|
|
1438
1488
|
type: "button",
|
|
1439
|
-
onClick: () =>
|
|
1489
|
+
onClick: () => xe((e) => {
|
|
1440
1490
|
const t = new Set(e);
|
|
1441
1491
|
return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
|
|
1442
1492
|
}),
|
|
1443
1493
|
className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
|
|
1444
1494
|
children: [
|
|
1445
1495
|
/* @__PURE__ */ s(
|
|
1446
|
-
|
|
1496
|
+
ar,
|
|
1447
1497
|
{
|
|
1448
|
-
className:
|
|
1498
|
+
className: K(
|
|
1449
1499
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1450
|
-
!
|
|
1500
|
+
!ne.has("__favorites__") && "rotate-90"
|
|
1451
1501
|
)
|
|
1452
1502
|
}
|
|
1453
1503
|
),
|
|
1454
|
-
/* @__PURE__ */ s(
|
|
1504
|
+
/* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
1455
1505
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
|
|
1456
|
-
/* @__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:
|
|
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 })
|
|
1457
1507
|
]
|
|
1458
1508
|
}
|
|
1459
1509
|
),
|
|
1460
1510
|
/* @__PURE__ */ s(
|
|
1461
1511
|
"button",
|
|
1462
1512
|
{
|
|
1463
|
-
ref:
|
|
1513
|
+
ref: br,
|
|
1464
1514
|
type: "button",
|
|
1465
|
-
onClick: () =>
|
|
1515
|
+
onClick: () => hr(!0),
|
|
1466
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",
|
|
1467
1517
|
children: "Manage"
|
|
1468
1518
|
}
|
|
1469
1519
|
)
|
|
1470
1520
|
] }),
|
|
1471
|
-
!
|
|
1472
|
-
!
|
|
1473
|
-
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);
|
|
1474
1524
|
return /* @__PURE__ */ c(
|
|
1475
1525
|
"div",
|
|
1476
1526
|
{
|
|
1477
|
-
className:
|
|
1527
|
+
className: K(
|
|
1478
1528
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1479
1529
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1480
1530
|
(n ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1481
|
-
|
|
1531
|
+
o && "bg-amber-50 dark:bg-amber-900/15"
|
|
1482
1532
|
),
|
|
1483
1533
|
children: [
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children:
|
|
1488
|
-
|
|
1534
|
+
Et(r),
|
|
1535
|
+
Xt(r, Je(C, e)),
|
|
1536
|
+
Gt(r, e),
|
|
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,
|
|
1489
1539
|
{
|
|
1490
1540
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1491
|
-
"aria-label": `${Vt} ${
|
|
1541
|
+
"aria-label": `${Vt} ${o.available} — ${o.qty} requested`
|
|
1492
1542
|
}
|
|
1493
1543
|
) }),
|
|
1494
|
-
|
|
1544
|
+
jt(r, e)
|
|
1495
1545
|
]
|
|
1496
1546
|
},
|
|
1497
1547
|
r
|
|
1498
1548
|
);
|
|
1499
1549
|
})
|
|
1500
1550
|
] }),
|
|
1501
|
-
|
|
1502
|
-
const t =
|
|
1503
|
-
(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),
|
|
1504
1554
|
0
|
|
1505
1555
|
);
|
|
1506
1556
|
return /* @__PURE__ */ c(rt, { children: [
|
|
@@ -1508,16 +1558,16 @@ function As({
|
|
|
1508
1558
|
"button",
|
|
1509
1559
|
{
|
|
1510
1560
|
type: "button",
|
|
1511
|
-
onClick: () =>
|
|
1512
|
-
const
|
|
1513
|
-
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;
|
|
1514
1564
|
}),
|
|
1515
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",
|
|
1516
1566
|
children: [
|
|
1517
1567
|
/* @__PURE__ */ s(
|
|
1518
|
-
|
|
1568
|
+
ar,
|
|
1519
1569
|
{
|
|
1520
|
-
className:
|
|
1570
|
+
className: K(
|
|
1521
1571
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1522
1572
|
!t && "rotate-90"
|
|
1523
1573
|
)
|
|
@@ -1532,29 +1582,29 @@ function As({
|
|
|
1532
1582
|
]
|
|
1533
1583
|
}
|
|
1534
1584
|
),
|
|
1535
|
-
!t && e.items.map((n,
|
|
1536
|
-
const
|
|
1585
|
+
!t && e.items.map((n, o) => {
|
|
1586
|
+
const l = we(n.id), h = Mt(n.id);
|
|
1537
1587
|
return /* @__PURE__ */ c(
|
|
1538
1588
|
"div",
|
|
1539
1589
|
{
|
|
1540
|
-
className:
|
|
1590
|
+
className: K(
|
|
1541
1591
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1542
|
-
|
|
1543
|
-
(
|
|
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",
|
|
1544
1594
|
h && "bg-amber-50 dark:bg-amber-900/15"
|
|
1545
1595
|
),
|
|
1546
1596
|
children: [
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
/* @__PURE__ */ s("span", { className: "flex w-3.5 shrink-0 items-center justify-center", children:
|
|
1551
|
-
|
|
1597
|
+
Et(n.id),
|
|
1598
|
+
Xt(n.id, n.label),
|
|
1599
|
+
Gt(n.id, n.row),
|
|
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,
|
|
1552
1602
|
{
|
|
1553
1603
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1554
1604
|
"aria-label": `${Vt} ${h.available} — ${h.qty} requested`
|
|
1555
1605
|
}
|
|
1556
1606
|
) }),
|
|
1557
|
-
|
|
1607
|
+
jt(n.id, n.row)
|
|
1558
1608
|
]
|
|
1559
1609
|
},
|
|
1560
1610
|
n.id
|
|
@@ -1563,18 +1613,18 @@ function As({
|
|
|
1563
1613
|
] }, e.name);
|
|
1564
1614
|
})
|
|
1565
1615
|
] }),
|
|
1566
|
-
(a.builders ?? []).filter((e) => Hr(e.show_when,
|
|
1567
|
-
|
|
1616
|
+
(a.builders ?? []).filter((e) => Hr(e.show_when, i)).map((e) => /* @__PURE__ */ s(
|
|
1617
|
+
xs,
|
|
1568
1618
|
{
|
|
1569
1619
|
builder: e,
|
|
1570
1620
|
defaultItemField: a.item_field,
|
|
1571
|
-
catalogCol:
|
|
1572
|
-
catalogFields:
|
|
1573
|
-
tmpl:
|
|
1574
|
-
currentQty:
|
|
1621
|
+
catalogCol: b,
|
|
1622
|
+
catalogFields: T,
|
|
1623
|
+
tmpl: C,
|
|
1624
|
+
currentQty: we,
|
|
1575
1625
|
addQty: (t, r, n) => tt(t, String(r), n),
|
|
1576
|
-
qtyStep:
|
|
1577
|
-
readOnly:
|
|
1626
|
+
qtyStep: lr(le) ? 1 : "any",
|
|
1627
|
+
readOnly: p
|
|
1578
1628
|
},
|
|
1579
1629
|
e.label
|
|
1580
1630
|
))
|
|
@@ -1582,11 +1632,11 @@ function As({
|
|
|
1582
1632
|
/* @__PURE__ */ c("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1583
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: [
|
|
1584
1634
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
|
|
1585
|
-
!
|
|
1586
|
-
a.upload_template && !
|
|
1587
|
-
|
|
1635
|
+
!p && /* @__PURE__ */ c("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
|
|
1636
|
+
a.upload_template && !z && Z && N && /* @__PURE__ */ s(
|
|
1637
|
+
Gn,
|
|
1588
1638
|
{
|
|
1589
|
-
collection:
|
|
1639
|
+
collection: N,
|
|
1590
1640
|
templateFilter: (e) => {
|
|
1591
1641
|
var t;
|
|
1592
1642
|
return e.name === a.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
|
|
@@ -1595,74 +1645,74 @@ function As({
|
|
|
1595
1645
|
var t;
|
|
1596
1646
|
return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
|
|
1597
1647
|
},
|
|
1598
|
-
onParsed: (e, t) =>
|
|
1648
|
+
onParsed: (e, t) => Z(e, t),
|
|
1599
1649
|
compact: !0
|
|
1600
1650
|
}
|
|
1601
1651
|
),
|
|
1602
1652
|
/* @__PURE__ */ s("div", { className: "w-64", children: /* @__PURE__ */ s(
|
|
1603
|
-
|
|
1653
|
+
us,
|
|
1604
1654
|
{
|
|
1605
|
-
collection:
|
|
1655
|
+
collection: b,
|
|
1606
1656
|
value: null,
|
|
1607
|
-
onChange: (e) => void
|
|
1657
|
+
onChange: (e) => void En(e),
|
|
1608
1658
|
placeholder: "+ Add any item…"
|
|
1609
1659
|
}
|
|
1610
1660
|
) })
|
|
1611
1661
|
] })
|
|
1612
1662
|
] }),
|
|
1613
|
-
|
|
1614
|
-
const e =
|
|
1615
|
-
|
|
1616
|
-
|
|
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,
|
|
1666
|
+
m,
|
|
1617
1667
|
d,
|
|
1618
1668
|
"w-20 shrink-0",
|
|
1619
1669
|
"text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
|
|
1620
|
-
) : /* @__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) =>
|
|
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}`;
|
|
1621
1671
|
return /* @__PURE__ */ c("div", { children: [
|
|
1622
1672
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
|
|
1623
1673
|
/* @__PURE__ */ c("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
|
|
1624
1674
|
"Item",
|
|
1625
|
-
|
|
1626
|
-
|
|
1675
|
+
p && /* @__PURE__ */ s(
|
|
1676
|
+
nr,
|
|
1627
1677
|
{
|
|
1628
|
-
show:
|
|
1629
|
-
onReset:
|
|
1678
|
+
show: ke.customized,
|
|
1679
|
+
onReset: ke.reset,
|
|
1630
1680
|
className: "-my-1"
|
|
1631
1681
|
}
|
|
1632
1682
|
)
|
|
1633
1683
|
] }),
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
!
|
|
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 }) })
|
|
1638
1688
|
] }),
|
|
1639
|
-
|
|
1640
|
-
const f = d.row.id != null ? String(d.row.id) : null,
|
|
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);
|
|
1641
1691
|
return /* @__PURE__ */ c(
|
|
1642
1692
|
"div",
|
|
1643
1693
|
{
|
|
1644
|
-
className:
|
|
1694
|
+
className: K(
|
|
1645
1695
|
"border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1696
|
+
m % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1697
|
+
S && "bg-amber-50 dark:bg-amber-900/15",
|
|
1698
|
+
E && "bg-red-50/70 dark:bg-red-900/15",
|
|
1699
|
+
_ && "opacity-60"
|
|
1650
1700
|
),
|
|
1651
1701
|
children: [
|
|
1652
1702
|
/* @__PURE__ */ c(
|
|
1653
1703
|
"div",
|
|
1654
1704
|
{
|
|
1655
|
-
className:
|
|
1705
|
+
className: K(
|
|
1656
1706
|
"flex items-center gap-4",
|
|
1657
|
-
|
|
1707
|
+
_ && "line-through decoration-slate-400"
|
|
1658
1708
|
),
|
|
1659
1709
|
children: [
|
|
1660
|
-
|
|
1710
|
+
Pr(
|
|
1661
1711
|
d.key,
|
|
1662
|
-
|
|
1712
|
+
Er(d.key),
|
|
1663
1713
|
"shrink-0 font-semibold text-slate-800 dark:text-slate-100"
|
|
1664
1714
|
),
|
|
1665
|
-
Ve && !
|
|
1715
|
+
Ve && !_ && (f == null || dt.has(f)) && /* @__PURE__ */ s(
|
|
1666
1716
|
"span",
|
|
1667
1717
|
{
|
|
1668
1718
|
"data-catalog-staged": f == null ? "new" : "edited",
|
|
@@ -1671,214 +1721,216 @@ function As({
|
|
|
1671
1721
|
children: f == null ? "New" : "Edited"
|
|
1672
1722
|
}
|
|
1673
1723
|
),
|
|
1674
|
-
|
|
1724
|
+
E && /* @__PURE__ */ s(
|
|
1675
1725
|
"span",
|
|
1676
1726
|
{
|
|
1677
1727
|
className: "shrink-0",
|
|
1678
1728
|
"data-tip": `This line was in the failed submission
|
|
1679
|
-
${
|
|
1729
|
+
${E}`,
|
|
1680
1730
|
"data-submission-error": !0,
|
|
1681
|
-
children: /* @__PURE__ */ s(
|
|
1731
|
+
children: /* @__PURE__ */ s(rr, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
|
|
1682
1732
|
}
|
|
1683
1733
|
),
|
|
1684
1734
|
t && /* @__PURE__ */ s(
|
|
1685
|
-
|
|
1735
|
+
Yr,
|
|
1686
1736
|
{
|
|
1687
|
-
text:
|
|
1737
|
+
text: ge(_t(Ke(d.key), t.field), void 0),
|
|
1688
1738
|
className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
|
|
1689
1739
|
}
|
|
1690
1740
|
),
|
|
1691
1741
|
!t && /* @__PURE__ */ s("span", { className: "flex-1" }),
|
|
1692
|
-
r.map((
|
|
1693
|
-
const
|
|
1694
|
-
return
|
|
1742
|
+
r.map((y) => {
|
|
1743
|
+
const I = _t(Ke(d.key), y.field);
|
|
1744
|
+
return I == null || I === "" ? null : /* @__PURE__ */ s(
|
|
1695
1745
|
"span",
|
|
1696
1746
|
{
|
|
1697
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",
|
|
1698
|
-
children: String(
|
|
1748
|
+
children: String(I)
|
|
1699
1749
|
},
|
|
1700
|
-
|
|
1750
|
+
y.field
|
|
1701
1751
|
);
|
|
1702
1752
|
}),
|
|
1703
|
-
|
|
1704
|
-
(
|
|
1705
|
-
var
|
|
1706
|
-
return
|
|
1753
|
+
er.map(
|
|
1754
|
+
(y) => {
|
|
1755
|
+
var I;
|
|
1756
|
+
return On(d.key, y) ? An(d.key, y, d.row) : /* @__PURE__ */ s(
|
|
1707
1757
|
"span",
|
|
1708
1758
|
{
|
|
1709
|
-
|
|
1710
|
-
|
|
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}`,
|
|
1711
1763
|
"w-20 shrink-0",
|
|
1712
1764
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1713
1765
|
),
|
|
1714
|
-
children:
|
|
1766
|
+
children: ge(d.row[y], (I = a.field_formats) == null ? void 0 : I[y])
|
|
1715
1767
|
},
|
|
1716
|
-
|
|
1768
|
+
y
|
|
1717
1769
|
);
|
|
1718
1770
|
}
|
|
1719
1771
|
),
|
|
1720
1772
|
/* @__PURE__ */ c("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
|
|
1721
|
-
|
|
1722
|
-
|
|
1773
|
+
ie.has(d.key) && /* @__PURE__ */ s(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
1774
|
+
jt(d.key, Ke(d.key))
|
|
1723
1775
|
] }),
|
|
1724
|
-
|
|
1725
|
-
var
|
|
1726
|
-
if (
|
|
1776
|
+
tr.map((y) => {
|
|
1777
|
+
var Br, Wr;
|
|
1778
|
+
if (_)
|
|
1727
1779
|
return /* @__PURE__ */ s(
|
|
1728
1780
|
"span",
|
|
1729
1781
|
{
|
|
1730
1782
|
"data-tip": "Not counted — this line is removed when you save",
|
|
1731
|
-
...
|
|
1732
|
-
`s:${
|
|
1783
|
+
...ke.box(
|
|
1784
|
+
`s:${y}`,
|
|
1733
1785
|
"w-20 shrink-0",
|
|
1734
1786
|
"text-right tabular-nums text-slate-400 dark:text-slate-500"
|
|
1735
1787
|
),
|
|
1736
1788
|
children: "—"
|
|
1737
1789
|
},
|
|
1738
|
-
|
|
1790
|
+
y
|
|
1739
1791
|
);
|
|
1740
|
-
const
|
|
1792
|
+
const I = d.row[y], Ce = I != null && I !== "" ? I : Be(((Br = a.compute_fields) == null ? void 0 : Br[y]) ?? "", d.row);
|
|
1741
1793
|
return /* @__PURE__ */ s(
|
|
1742
1794
|
"span",
|
|
1743
1795
|
{
|
|
1744
|
-
...
|
|
1745
|
-
`s:${
|
|
1796
|
+
...ke.box(
|
|
1797
|
+
`s:${y}`,
|
|
1746
1798
|
"w-20 shrink-0",
|
|
1747
1799
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1748
1800
|
),
|
|
1749
|
-
children:
|
|
1801
|
+
children: ge(Ce, (Wr = a.field_formats) == null ? void 0 : Wr[y])
|
|
1750
1802
|
},
|
|
1751
|
-
|
|
1803
|
+
y
|
|
1752
1804
|
);
|
|
1753
1805
|
}),
|
|
1754
|
-
!
|
|
1806
|
+
!p && _ && /* @__PURE__ */ s(
|
|
1755
1807
|
"button",
|
|
1756
1808
|
{
|
|
1757
1809
|
type: "button",
|
|
1758
|
-
onClick: () =>
|
|
1810
|
+
onClick: () => k == null ? void 0 : k.cancelPendingDelete(u, x, f),
|
|
1759
1811
|
className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
|
|
1760
1812
|
children: "Undo"
|
|
1761
1813
|
}
|
|
1762
1814
|
),
|
|
1763
|
-
!
|
|
1815
|
+
!p && !_ && /* @__PURE__ */ s(
|
|
1764
1816
|
"button",
|
|
1765
1817
|
{
|
|
1766
1818
|
type: "button",
|
|
1767
1819
|
title: "Remove (applies on Save)",
|
|
1768
1820
|
onClick: () => {
|
|
1769
|
-
if (!
|
|
1770
|
-
|
|
1821
|
+
if (!z && k && f != null) {
|
|
1822
|
+
k.queueDelete(u, x, f);
|
|
1771
1823
|
return;
|
|
1772
1824
|
}
|
|
1773
1825
|
tt(d.key, "0", {}, { confirmedRemove: !0 });
|
|
1774
1826
|
},
|
|
1775
1827
|
className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
|
|
1776
|
-
children: /* @__PURE__ */ s(
|
|
1828
|
+
children: /* @__PURE__ */ s(Tt, { className: "mx-auto h-3.5 w-3.5" })
|
|
1777
1829
|
}
|
|
1778
1830
|
)
|
|
1779
1831
|
]
|
|
1780
1832
|
}
|
|
1781
1833
|
),
|
|
1782
|
-
(n.length > 0 ||
|
|
1783
|
-
n.map((
|
|
1784
|
-
/* @__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]) }),
|
|
1785
1837
|
" ",
|
|
1786
|
-
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children:
|
|
1787
|
-
] },
|
|
1788
|
-
|
|
1789
|
-
/* @__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) }),
|
|
1790
1842
|
" ",
|
|
1791
|
-
/* @__PURE__ */ s("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children:
|
|
1792
|
-
] },
|
|
1793
|
-
|
|
1794
|
-
|
|
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(
|
|
1795
1847
|
"span",
|
|
1796
1848
|
{
|
|
1797
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",
|
|
1798
|
-
"data-catalog-row-flag":
|
|
1850
|
+
"data-catalog-row-flag": y,
|
|
1799
1851
|
children: [
|
|
1800
|
-
/* @__PURE__ */ s(
|
|
1801
|
-
|
|
1852
|
+
/* @__PURE__ */ s(nt, { className: "h-3 w-3" }),
|
|
1853
|
+
y
|
|
1802
1854
|
]
|
|
1803
1855
|
},
|
|
1804
|
-
|
|
1856
|
+
y
|
|
1805
1857
|
)),
|
|
1806
|
-
|
|
1807
|
-
const
|
|
1858
|
+
Nt.map((y) => {
|
|
1859
|
+
const I = wn(y, d);
|
|
1808
1860
|
return /* @__PURE__ */ c("span", { className: "whitespace-nowrap", children: [
|
|
1809
|
-
/* @__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) }),
|
|
1810
1862
|
" ",
|
|
1811
|
-
/* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children:
|
|
1812
|
-
] },
|
|
1863
|
+
/* @__PURE__ */ s("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: o(I, y.format) })
|
|
1864
|
+
] }, y.field);
|
|
1813
1865
|
})
|
|
1814
1866
|
] }),
|
|
1815
|
-
|
|
1816
|
-
/* @__PURE__ */ s(
|
|
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" }),
|
|
1817
1869
|
Vt,
|
|
1818
1870
|
" is ",
|
|
1819
|
-
|
|
1871
|
+
ge(S.available, "number"),
|
|
1820
1872
|
" —",
|
|
1821
1873
|
" ",
|
|
1822
|
-
|
|
1874
|
+
ge(S.qty, "number"),
|
|
1823
1875
|
" requested"
|
|
1824
1876
|
] }),
|
|
1825
|
-
|
|
1877
|
+
_ && /* @__PURE__ */ s("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
|
|
1826
1878
|
]
|
|
1827
1879
|
},
|
|
1828
1880
|
d.key
|
|
1829
1881
|
);
|
|
1830
1882
|
}),
|
|
1831
1883
|
(() => {
|
|
1832
|
-
const d =
|
|
1833
|
-
const
|
|
1834
|
-
return !(
|
|
1835
|
-
}),
|
|
1836
|
-
const
|
|
1837
|
-
return
|
|
1838
|
-
}, 0), f = (
|
|
1839
|
-
var
|
|
1840
|
-
return ((
|
|
1841
|
-
},
|
|
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(
|
|
1842
1894
|
"span",
|
|
1843
1895
|
{
|
|
1844
|
-
...
|
|
1845
|
-
`s:${
|
|
1896
|
+
...ke.box(
|
|
1897
|
+
`s:${S}`,
|
|
1846
1898
|
"w-20 shrink-0",
|
|
1847
1899
|
"truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
|
|
1848
1900
|
),
|
|
1849
|
-
children:
|
|
1901
|
+
children: ge(m(S), f(S))
|
|
1850
1902
|
},
|
|
1851
|
-
|
|
1903
|
+
S
|
|
1852
1904
|
);
|
|
1853
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: [
|
|
1854
1906
|
/* @__PURE__ */ s("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
|
|
1855
|
-
|
|
1856
|
-
const
|
|
1857
|
-
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);
|
|
1858
1910
|
}),
|
|
1859
|
-
/* @__PURE__ */ s("span", { className: "w-20 shrink-0 text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100", children:
|
|
1860
|
-
|
|
1861
|
-
!
|
|
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(_),
|
|
1913
|
+
!p && /* @__PURE__ */ s("span", { className: "w-6 shrink-0" })
|
|
1862
1914
|
] });
|
|
1863
1915
|
})()
|
|
1864
1916
|
] });
|
|
1865
1917
|
})()
|
|
1866
1918
|
] }),
|
|
1867
|
-
|
|
1868
|
-
|
|
1919
|
+
sn && b && /* @__PURE__ */ s(
|
|
1920
|
+
ks,
|
|
1869
1921
|
{
|
|
1870
|
-
catalogCol:
|
|
1871
|
-
tmpl:
|
|
1922
|
+
catalogCol: b,
|
|
1923
|
+
tmpl: C,
|
|
1872
1924
|
sectionBy: a.section_by,
|
|
1873
|
-
sectionM2M:
|
|
1874
|
-
pinnedSet:
|
|
1875
|
-
pinnedIds:
|
|
1876
|
-
savingIds:
|
|
1925
|
+
sectionM2M: B,
|
|
1926
|
+
pinnedSet: Pt,
|
|
1927
|
+
pinnedIds: qe,
|
|
1928
|
+
savingIds: ht,
|
|
1877
1929
|
relatedCols: (a.favorites_manager_columns ?? []).map((e) => (a.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
|
|
1878
|
-
parentDraft:
|
|
1879
|
-
onToggle: (e) => void
|
|
1880
|
-
onClose: () =>
|
|
1881
|
-
anchor:
|
|
1930
|
+
parentDraft: i,
|
|
1931
|
+
onToggle: (e) => void fr(e),
|
|
1932
|
+
onClose: () => hr(!1),
|
|
1933
|
+
anchor: br.current
|
|
1882
1934
|
}
|
|
1883
1935
|
)
|
|
1884
1936
|
] }) : /* @__PURE__ */ c("p", { className: "py-1 text-[12px] text-slate-400", children: [
|
|
@@ -1886,85 +1938,85 @@ ${J}`,
|
|
|
1886
1938
|
a.item_field,
|
|
1887
1939
|
'" does not resolve to an M2O relation on',
|
|
1888
1940
|
" ",
|
|
1889
|
-
|
|
1941
|
+
u
|
|
1890
1942
|
] });
|
|
1891
1943
|
}
|
|
1892
|
-
function
|
|
1893
|
-
builder:
|
|
1894
|
-
defaultItemField:
|
|
1895
|
-
catalogCol:
|
|
1896
|
-
catalogFields:
|
|
1944
|
+
function xs({
|
|
1945
|
+
builder: u,
|
|
1946
|
+
defaultItemField: x,
|
|
1947
|
+
catalogCol: w,
|
|
1948
|
+
catalogFields: N,
|
|
1897
1949
|
tmpl: a,
|
|
1898
|
-
currentQty:
|
|
1899
|
-
addQty:
|
|
1900
|
-
qtyStep:
|
|
1901
|
-
readOnly:
|
|
1950
|
+
currentQty: p,
|
|
1951
|
+
addQty: g,
|
|
1952
|
+
qtyStep: j,
|
|
1953
|
+
readOnly: k
|
|
1902
1954
|
}) {
|
|
1903
|
-
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(
|
|
1904
1956
|
() => [
|
|
1905
1957
|
"id",
|
|
1906
|
-
|
|
1907
|
-
...
|
|
1958
|
+
Z,
|
|
1959
|
+
...u.attributes.flatMap((q) => [`${q.field}.id`, `${q.field}.${q.label_field}`])
|
|
1908
1960
|
].join(","),
|
|
1909
|
-
[
|
|
1910
|
-
), { data:
|
|
1961
|
+
[Z, u.attributes]
|
|
1962
|
+
), { data: V = [], isLoading: Pe } = A({
|
|
1911
1963
|
queryKey: [
|
|
1912
1964
|
"catalog-builder",
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
JSON.stringify(
|
|
1965
|
+
u.collection,
|
|
1966
|
+
je,
|
|
1967
|
+
JSON.stringify(u.filter ?? null)
|
|
1916
1968
|
],
|
|
1917
|
-
queryFn: () =>
|
|
1918
|
-
|
|
1969
|
+
queryFn: () => R.request(
|
|
1970
|
+
O(`/items/${u.collection}`, {
|
|
1919
1971
|
limit: 2e3,
|
|
1920
|
-
fields:
|
|
1921
|
-
...
|
|
1972
|
+
fields: je,
|
|
1973
|
+
...u.filter ? { filter: JSON.stringify(u.filter) } : {}
|
|
1922
1974
|
})
|
|
1923
|
-
).then((
|
|
1924
|
-
enabled:
|
|
1975
|
+
).then((q) => q.data ?? []),
|
|
1976
|
+
enabled: te,
|
|
1925
1977
|
staleTime: 6e4
|
|
1926
|
-
}),
|
|
1927
|
-
var
|
|
1928
|
-
const
|
|
1929
|
-
if (
|
|
1930
|
-
if (typeof
|
|
1931
|
-
const
|
|
1932
|
-
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 ?? "") };
|
|
1933
1985
|
}
|
|
1934
|
-
return { id: String(
|
|
1935
|
-
}, he = (
|
|
1936
|
-
(
|
|
1937
|
-
var
|
|
1938
|
-
const
|
|
1939
|
-
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;
|
|
1940
1992
|
})
|
|
1941
|
-
),
|
|
1942
|
-
(
|
|
1943
|
-
var
|
|
1944
|
-
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];
|
|
1945
1997
|
})
|
|
1946
|
-
) : void 0,
|
|
1947
|
-
queryKey: ["catalog-builder-item",
|
|
1948
|
-
queryFn: () =>
|
|
1949
|
-
|
|
1950
|
-
filter: JSON.stringify({ id: { _eq:
|
|
1951
|
-
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,
|
|
1952
2004
|
limit: 1
|
|
1953
2005
|
})
|
|
1954
|
-
).then((
|
|
1955
|
-
var
|
|
1956
|
-
return ((
|
|
2006
|
+
).then((q) => {
|
|
2007
|
+
var b;
|
|
2008
|
+
return ((b = q.data) == null ? void 0 : b[0]) ?? null;
|
|
1957
2009
|
}),
|
|
1958
|
-
enabled: !!
|
|
2010
|
+
enabled: !!Y,
|
|
1959
2011
|
staleTime: 6e4
|
|
1960
|
-
}),
|
|
1961
|
-
async function
|
|
1962
|
-
if (!(!
|
|
1963
|
-
|
|
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);
|
|
1964
2016
|
try {
|
|
1965
|
-
await
|
|
2017
|
+
await g(Y, (p(Y) ?? 0) + _e, G), z({}), ae("1");
|
|
1966
2018
|
} finally {
|
|
1967
|
-
|
|
2019
|
+
xe(!1);
|
|
1968
2020
|
}
|
|
1969
2021
|
}
|
|
1970
2022
|
}
|
|
@@ -1973,73 +2025,73 @@ function os({
|
|
|
1973
2025
|
"button",
|
|
1974
2026
|
{
|
|
1975
2027
|
type: "button",
|
|
1976
|
-
onClick: () =>
|
|
2028
|
+
onClick: () => ve((q) => !q),
|
|
1977
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",
|
|
1978
2030
|
children: [
|
|
1979
2031
|
/* @__PURE__ */ s(
|
|
1980
|
-
|
|
2032
|
+
ar,
|
|
1981
2033
|
{
|
|
1982
|
-
className:
|
|
2034
|
+
className: K(
|
|
1983
2035
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1984
|
-
|
|
2036
|
+
te && "rotate-90"
|
|
1985
2037
|
)
|
|
1986
2038
|
}
|
|
1987
2039
|
),
|
|
1988
|
-
/* @__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 })
|
|
1989
2041
|
]
|
|
1990
2042
|
}
|
|
1991
2043
|
),
|
|
1992
|
-
|
|
1993
|
-
/* @__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" }),
|
|
1994
2046
|
" Loading options…"
|
|
1995
2047
|
] }) : /* @__PURE__ */ c("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
1996
|
-
|
|
1997
|
-
const
|
|
1998
|
-
for (const
|
|
1999
|
-
const
|
|
2000
|
-
|
|
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);
|
|
2001
2053
|
}
|
|
2002
|
-
const
|
|
2003
|
-
([,
|
|
2054
|
+
const le = [...L.entries()].sort(
|
|
2055
|
+
([, Q], [, $]) => Q.localeCompare($, void 0, { numeric: !0 })
|
|
2004
2056
|
);
|
|
2005
2057
|
return /* @__PURE__ */ s(
|
|
2006
|
-
|
|
2058
|
+
gs,
|
|
2007
2059
|
{
|
|
2008
|
-
label:
|
|
2009
|
-
value:
|
|
2010
|
-
valueLabel:
|
|
2011
|
-
options:
|
|
2012
|
-
disabled:
|
|
2013
|
-
onChange: (
|
|
2014
|
-
const
|
|
2015
|
-
for (let
|
|
2016
|
-
const
|
|
2017
|
-
|
|
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]);
|
|
2018
2070
|
}
|
|
2019
|
-
return
|
|
2071
|
+
return Q && (C[q.field] = Q), C;
|
|
2020
2072
|
})
|
|
2021
2073
|
},
|
|
2022
|
-
|
|
2074
|
+
q.field
|
|
2023
2075
|
);
|
|
2024
2076
|
}),
|
|
2025
|
-
/* @__PURE__ */ s("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children:
|
|
2026
|
-
/* @__PURE__ */ s("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children:
|
|
2027
|
-
(
|
|
2028
|
-
|
|
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),
|
|
2029
2081
|
" in summary"
|
|
2030
2082
|
] }),
|
|
2031
|
-
!
|
|
2083
|
+
!k && /* @__PURE__ */ c(Ne, { children: [
|
|
2032
2084
|
/* @__PURE__ */ s(
|
|
2033
2085
|
"input",
|
|
2034
2086
|
{
|
|
2035
2087
|
type: "number",
|
|
2036
2088
|
min: 0,
|
|
2037
|
-
step:
|
|
2038
|
-
value:
|
|
2089
|
+
step: j,
|
|
2090
|
+
value: re,
|
|
2039
2091
|
"aria-label": "Quantity to add",
|
|
2040
|
-
onChange: (
|
|
2041
|
-
onKeyDown: (
|
|
2042
|
-
|
|
2092
|
+
onChange: (q) => ae(q.target.value),
|
|
2093
|
+
onKeyDown: (q) => {
|
|
2094
|
+
q.key === "Enter" && (q.preventDefault(), Ee());
|
|
2043
2095
|
},
|
|
2044
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"
|
|
2045
2097
|
}
|
|
@@ -2048,315 +2100,315 @@ function os({
|
|
|
2048
2100
|
"button",
|
|
2049
2101
|
{
|
|
2050
2102
|
type: "button",
|
|
2051
|
-
onClick: () => void
|
|
2052
|
-
disabled: !
|
|
2103
|
+
onClick: () => void Ee(),
|
|
2104
|
+
disabled: !fe,
|
|
2053
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",
|
|
2054
2106
|
children: [
|
|
2055
|
-
|
|
2107
|
+
ne ? /* @__PURE__ */ s(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ s(Jn, { className: "h-3.5 w-3.5" }),
|
|
2056
2108
|
"Add"
|
|
2057
2109
|
]
|
|
2058
2110
|
}
|
|
2059
2111
|
)
|
|
2060
2112
|
] })
|
|
2061
|
-
] }) :
|
|
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" }) })
|
|
2062
2114
|
] }) })
|
|
2063
2115
|
] });
|
|
2064
2116
|
}
|
|
2065
|
-
function
|
|
2066
|
-
parentCollection:
|
|
2067
|
-
field:
|
|
2068
|
-
id:
|
|
2117
|
+
function ys({
|
|
2118
|
+
parentCollection: u,
|
|
2119
|
+
field: x,
|
|
2120
|
+
id: w
|
|
2069
2121
|
}) {
|
|
2070
|
-
var
|
|
2071
|
-
const
|
|
2072
|
-
queryKey: ["collection-relations",
|
|
2073
|
-
queryFn: () =>
|
|
2074
|
-
var
|
|
2075
|
-
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) ?? [];
|
|
2076
2128
|
}),
|
|
2077
|
-
enabled: !!
|
|
2129
|
+
enabled: !!u,
|
|
2078
2130
|
staleTime: 10 * 6e4
|
|
2079
|
-
}),
|
|
2080
|
-
(
|
|
2081
|
-
)) == null ? void 0 :
|
|
2082
|
-
queryKey: ["col-meta",
|
|
2083
|
-
queryFn: () =>
|
|
2084
|
-
enabled: !!
|
|
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({
|
|
2134
|
+
queryKey: ["col-meta", p],
|
|
2135
|
+
queryFn: () => N.request(O(`/collections/${p}`)).then((k) => k.data),
|
|
2136
|
+
enabled: !!p,
|
|
2085
2137
|
staleTime: 3e5
|
|
2086
2138
|
});
|
|
2087
|
-
return
|
|
2139
|
+
return p ? /* @__PURE__ */ s(ms, { collection: p, id: w, displayTemplate: g == null ? void 0 : g.display_template }) : /* @__PURE__ */ c(Ne, { children: [
|
|
2088
2140
|
"this ",
|
|
2089
|
-
|
|
2141
|
+
M(x)
|
|
2090
2142
|
] });
|
|
2091
2143
|
}
|
|
2092
|
-
function
|
|
2093
|
-
text:
|
|
2094
|
-
highlight:
|
|
2095
|
-
className:
|
|
2096
|
-
...
|
|
2144
|
+
function Yr({
|
|
2145
|
+
text: u,
|
|
2146
|
+
highlight: x,
|
|
2147
|
+
className: w,
|
|
2148
|
+
...N
|
|
2097
2149
|
}) {
|
|
2098
|
-
const a =
|
|
2099
|
-
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 });
|
|
2100
2152
|
}
|
|
2101
|
-
function
|
|
2102
|
-
label:
|
|
2103
|
-
value:
|
|
2104
|
-
valueLabel:
|
|
2105
|
-
options:
|
|
2153
|
+
function gs({
|
|
2154
|
+
label: u,
|
|
2155
|
+
value: x,
|
|
2156
|
+
valueLabel: w,
|
|
2157
|
+
options: N,
|
|
2106
2158
|
disabled: a,
|
|
2107
|
-
onChange:
|
|
2159
|
+
onChange: p
|
|
2108
2160
|
}) {
|
|
2109
|
-
const [
|
|
2110
|
-
return
|
|
2111
|
-
if (!
|
|
2112
|
-
const
|
|
2113
|
-
|
|
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);
|
|
2114
2166
|
};
|
|
2115
|
-
return document.addEventListener("mousedown",
|
|
2116
|
-
}, [
|
|
2117
|
-
/* @__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 }),
|
|
2118
2170
|
/* @__PURE__ */ c(
|
|
2119
2171
|
"button",
|
|
2120
2172
|
{
|
|
2121
2173
|
type: "button",
|
|
2122
2174
|
disabled: a,
|
|
2123
|
-
onClick: () =>
|
|
2175
|
+
onClick: () => j((R) => !R),
|
|
2124
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",
|
|
2125
2177
|
children: [
|
|
2126
|
-
/* @__PURE__ */ s("span", { className:
|
|
2127
|
-
/* @__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" })
|
|
2128
2180
|
]
|
|
2129
2181
|
}
|
|
2130
2182
|
),
|
|
2131
|
-
|
|
2132
|
-
|
|
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(
|
|
2133
2185
|
"button",
|
|
2134
2186
|
{
|
|
2135
2187
|
type: "button",
|
|
2136
2188
|
onClick: () => {
|
|
2137
|
-
|
|
2189
|
+
p(null), j(!1);
|
|
2138
2190
|
},
|
|
2139
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",
|
|
2140
2192
|
children: [
|
|
2141
|
-
/* @__PURE__ */ s(
|
|
2193
|
+
/* @__PURE__ */ s(Tt, { className: "h-3 w-3 text-slate-400" }),
|
|
2142
2194
|
" Clear"
|
|
2143
2195
|
]
|
|
2144
2196
|
}
|
|
2145
2197
|
),
|
|
2146
|
-
|
|
2198
|
+
N.map(([R, Z]) => /* @__PURE__ */ s(
|
|
2147
2199
|
"button",
|
|
2148
2200
|
{
|
|
2149
2201
|
type: "button",
|
|
2150
2202
|
onClick: () => {
|
|
2151
|
-
|
|
2203
|
+
p(R), j(!1);
|
|
2152
2204
|
},
|
|
2153
|
-
className:
|
|
2205
|
+
className: K(
|
|
2154
2206
|
"block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
2155
|
-
|
|
2207
|
+
R === x ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
2156
2208
|
),
|
|
2157
|
-
children:
|
|
2209
|
+
children: Z
|
|
2158
2210
|
},
|
|
2159
|
-
|
|
2211
|
+
R
|
|
2160
2212
|
))
|
|
2161
2213
|
] })
|
|
2162
2214
|
] });
|
|
2163
2215
|
}
|
|
2164
|
-
function
|
|
2165
|
-
catalogCol:
|
|
2166
|
-
tmpl:
|
|
2167
|
-
sectionBy:
|
|
2168
|
-
sectionM2M:
|
|
2216
|
+
function ks({
|
|
2217
|
+
catalogCol: u,
|
|
2218
|
+
tmpl: x,
|
|
2219
|
+
sectionBy: w,
|
|
2220
|
+
sectionM2M: N,
|
|
2169
2221
|
pinnedSet: a,
|
|
2170
|
-
pinnedIds:
|
|
2171
|
-
savingIds:
|
|
2172
|
-
relatedCols:
|
|
2173
|
-
parentDraft:
|
|
2174
|
-
onToggle:
|
|
2175
|
-
onClose:
|
|
2176
|
-
anchor:
|
|
2222
|
+
pinnedIds: p,
|
|
2223
|
+
savingIds: g,
|
|
2224
|
+
relatedCols: j,
|
|
2225
|
+
parentDraft: k,
|
|
2226
|
+
onToggle: R,
|
|
2227
|
+
onClose: Z,
|
|
2228
|
+
anchor: te
|
|
2177
2229
|
}) {
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
const i = setTimeout(() =>
|
|
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);
|
|
2181
2233
|
return () => clearTimeout(i);
|
|
2182
|
-
}, [
|
|
2234
|
+
}, [H]), Re(() => xe(1), [re]), Re(() => {
|
|
2183
2235
|
var i;
|
|
2184
|
-
(i =
|
|
2185
|
-
}, []),
|
|
2186
|
-
const i = (
|
|
2187
|
-
|
|
2236
|
+
(i = je.current) == null || i.focus();
|
|
2237
|
+
}, []), Re(() => {
|
|
2238
|
+
const i = (v) => {
|
|
2239
|
+
v.key === "Escape" && (v.stopPropagation(), Z());
|
|
2188
2240
|
};
|
|
2189
2241
|
return window.addEventListener("keydown", i, !0), () => window.removeEventListener("keydown", i, !0);
|
|
2190
|
-
}, [
|
|
2191
|
-
const
|
|
2192
|
-
var
|
|
2193
|
-
const i = (
|
|
2242
|
+
}, [Z]);
|
|
2243
|
+
const V = F(() => {
|
|
2244
|
+
var v;
|
|
2245
|
+
const i = (v = [...(x ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : v[1];
|
|
2194
2246
|
return i && !i.includes(".") ? i : "id";
|
|
2195
|
-
}, [
|
|
2196
|
-
queryKey: ["favorites-manager-list",
|
|
2197
|
-
queryFn: () =>
|
|
2198
|
-
|
|
2199
|
-
fields:
|
|
2200
|
-
limit:
|
|
2201
|
-
page:
|
|
2202
|
-
sort:
|
|
2203
|
-
...
|
|
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 } : {}
|
|
2204
2256
|
})
|
|
2205
2257
|
),
|
|
2206
2258
|
staleTime: 3e4,
|
|
2207
2259
|
placeholderData: (i) => i
|
|
2208
|
-
}),
|
|
2209
|
-
queryKey: ["favorites-manager-pinned",
|
|
2210
|
-
queryFn: () =>
|
|
2211
|
-
|
|
2212
|
-
filter: JSON.stringify({ id: { _in:
|
|
2213
|
-
fields:
|
|
2214
|
-
limit:
|
|
2215
|
-
sort:
|
|
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}`, {
|
|
2264
|
+
filter: JSON.stringify({ id: { _in: p } }),
|
|
2265
|
+
fields: Pe,
|
|
2266
|
+
limit: p.length,
|
|
2267
|
+
sort: V
|
|
2216
2268
|
})
|
|
2217
2269
|
).then((i) => i.data ?? []),
|
|
2218
|
-
enabled:
|
|
2270
|
+
enabled: p.length > 0,
|
|
2219
2271
|
staleTime: 3e4
|
|
2220
|
-
}),
|
|
2272
|
+
}), fe = F(() => {
|
|
2221
2273
|
const i = /* @__PURE__ */ new Set();
|
|
2222
|
-
for (const
|
|
2223
|
-
for (const
|
|
2274
|
+
for (const v of se) i.add(String(v.id));
|
|
2275
|
+
for (const v of p) i.add(v);
|
|
2224
2276
|
return [...i];
|
|
2225
|
-
}, [
|
|
2226
|
-
queryKey: ["favorites-manager-sections",
|
|
2277
|
+
}, [se, p]), { data: Ee = /* @__PURE__ */ new Map() } = A({
|
|
2278
|
+
queryKey: ["favorites-manager-sections", N == null ? void 0 : N.junction, fe.join(",")],
|
|
2227
2279
|
queryFn: async () => {
|
|
2228
|
-
const i =
|
|
2280
|
+
const i = N, v = await Ot(ve, `/items/${i.junction}`, {
|
|
2229
2281
|
fields: `${i.fkToItem},${i.fkToSection}`,
|
|
2230
|
-
filter: JSON.stringify({ [i.fkToItem]: { _in:
|
|
2231
|
-
}),
|
|
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}`, {
|
|
2232
2284
|
fields: `id,${i.labelPath}`,
|
|
2233
|
-
filter: JSON.stringify({ id: { _in:
|
|
2234
|
-
}) : [],
|
|
2235
|
-
|
|
2236
|
-
),
|
|
2237
|
-
for (const
|
|
2238
|
-
const
|
|
2239
|
-
if (!
|
|
2240
|
-
const
|
|
2241
|
-
|
|
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);
|
|
2242
2294
|
}
|
|
2243
|
-
return
|
|
2295
|
+
return ue;
|
|
2244
2296
|
},
|
|
2245
|
-
enabled: !!
|
|
2297
|
+
enabled: !!N && fe.length > 0,
|
|
2246
2298
|
staleTime: 6e4
|
|
2247
|
-
}),
|
|
2248
|
-
const
|
|
2249
|
-
return typeof
|
|
2250
|
-
},
|
|
2251
|
-
if (
|
|
2252
|
-
if (!
|
|
2253
|
-
const
|
|
2254
|
-
return
|
|
2255
|
-
},
|
|
2256
|
-
if (
|
|
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")
|
|
2257
2309
|
return i == null || i === "" || Number(i) === 0 ? "No" : "Yes";
|
|
2258
2310
|
if (i == null || i === "") return "—";
|
|
2259
|
-
const
|
|
2260
|
-
return
|
|
2261
|
-
},
|
|
2262
|
-
queries:
|
|
2263
|
-
const
|
|
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);
|
|
2264
2316
|
return {
|
|
2265
2317
|
queryKey: [
|
|
2266
2318
|
"favorites-manager-related",
|
|
2267
2319
|
i.key,
|
|
2268
2320
|
i.collection,
|
|
2269
|
-
JSON.stringify(
|
|
2270
|
-
|
|
2321
|
+
JSON.stringify(v),
|
|
2322
|
+
fe.join(",")
|
|
2271
2323
|
],
|
|
2272
2324
|
queryFn: async () => {
|
|
2273
|
-
const
|
|
2274
|
-
|
|
2275
|
-
filter: JSON.stringify({ [i.item_field]: { _in:
|
|
2325
|
+
const J = await ve.request(
|
|
2326
|
+
O(`/items/${i.collection}`, {
|
|
2327
|
+
filter: JSON.stringify({ [i.item_field]: { _in: fe }, ...v ?? {} }),
|
|
2276
2328
|
fields: `${i.item_field},${i.value_field}`,
|
|
2277
2329
|
limit: 1e3
|
|
2278
2330
|
})
|
|
2279
|
-
).then((
|
|
2280
|
-
for (const
|
|
2281
|
-
const
|
|
2282
|
-
|
|
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));
|
|
2283
2335
|
}
|
|
2284
|
-
return
|
|
2336
|
+
return W;
|
|
2285
2337
|
},
|
|
2286
|
-
enabled:
|
|
2338
|
+
enabled: fe.length > 0 && (i.match === void 0 || v !== null),
|
|
2287
2339
|
staleTime: 3e4
|
|
2288
2340
|
};
|
|
2289
2341
|
})
|
|
2290
|
-
}),
|
|
2291
|
-
(i) => i.match !== void 0 &&
|
|
2292
|
-
),
|
|
2293
|
-
const
|
|
2342
|
+
}), $ = j.filter(
|
|
2343
|
+
(i) => i.match !== void 0 && De(i.match, k) === null
|
|
2344
|
+
), C = (i) => {
|
|
2345
|
+
const v = a.has(i);
|
|
2294
2346
|
return /* @__PURE__ */ s(
|
|
2295
2347
|
"button",
|
|
2296
2348
|
{
|
|
2297
2349
|
type: "button",
|
|
2298
|
-
title:
|
|
2299
|
-
disabled:
|
|
2300
|
-
onClick: () =>
|
|
2350
|
+
title: v ? "Remove from favorites" : "Add to favorites",
|
|
2351
|
+
disabled: g.has(i),
|
|
2352
|
+
onClick: () => R(i),
|
|
2301
2353
|
className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
|
|
2302
|
-
children:
|
|
2303
|
-
|
|
2354
|
+
children: g.has(i) ? /* @__PURE__ */ s(ce, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ s(
|
|
2355
|
+
st,
|
|
2304
2356
|
{
|
|
2305
|
-
className:
|
|
2357
|
+
className: K(
|
|
2306
2358
|
"h-4 w-4",
|
|
2307
|
-
|
|
2359
|
+
v ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
2308
2360
|
)
|
|
2309
2361
|
}
|
|
2310
2362
|
)
|
|
2311
2363
|
}
|
|
2312
2364
|
);
|
|
2313
|
-
},
|
|
2314
|
-
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);
|
|
2315
2367
|
return /* @__PURE__ */ c(
|
|
2316
2368
|
"tr",
|
|
2317
2369
|
{
|
|
2318
|
-
className:
|
|
2370
|
+
className: K(
|
|
2319
2371
|
"border-b border-slate-100 dark:border-border/50",
|
|
2320
|
-
|
|
2372
|
+
v % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
|
|
2321
2373
|
),
|
|
2322
2374
|
children: [
|
|
2323
|
-
/* @__PURE__ */ s("td", { className: "px-2 py-1", children:
|
|
2324
|
-
/* @__PURE__ */ s("td", { className: "px-2 py-1 font-medium tabular-nums text-slate-700 dark:text-slate-200", children:
|
|
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(
|
|
2325
2377
|
"button",
|
|
2326
2378
|
{
|
|
2327
2379
|
type: "button",
|
|
2328
|
-
onClick: () =>
|
|
2380
|
+
onClick: () => Gr(u, J, k),
|
|
2329
2381
|
title: "View stock & planning detail",
|
|
2330
2382
|
className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
|
|
2331
|
-
children:
|
|
2383
|
+
children: q(i)
|
|
2332
2384
|
}
|
|
2333
|
-
) :
|
|
2334
|
-
/* @__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":
|
|
2335
|
-
/* @__PURE__ */ s("td", { className: "px-2 py-1", children: /* @__PURE__ */ s("p", { className: "truncate text-slate-500 dark:text-slate-400", children:
|
|
2336
|
-
|
|
2337
|
-
var
|
|
2338
|
-
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);
|
|
2339
2391
|
return /* @__PURE__ */ s(
|
|
2340
2392
|
"td",
|
|
2341
2393
|
{
|
|
2342
2394
|
className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
2343
|
-
children:
|
|
2395
|
+
children: T ? "—" : le(be, D.format)
|
|
2344
2396
|
},
|
|
2345
|
-
|
|
2397
|
+
D.key
|
|
2346
2398
|
);
|
|
2347
2399
|
})
|
|
2348
2400
|
]
|
|
2349
2401
|
},
|
|
2350
|
-
|
|
2402
|
+
J
|
|
2351
2403
|
);
|
|
2352
|
-
},
|
|
2353
|
-
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(
|
|
2354
2406
|
/* @__PURE__ */ c("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
|
|
2355
2407
|
/* @__PURE__ */ s(
|
|
2356
2408
|
"div",
|
|
2357
2409
|
{
|
|
2358
2410
|
className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
|
|
2359
|
-
onClick:
|
|
2411
|
+
onClick: Z
|
|
2360
2412
|
}
|
|
2361
2413
|
),
|
|
2362
2414
|
/* @__PURE__ */ c(
|
|
@@ -2368,7 +2420,7 @@ function us({
|
|
|
2368
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",
|
|
2369
2421
|
children: [
|
|
2370
2422
|
/* @__PURE__ */ c("div", { className: "flex items-start gap-2.5 border-b border-slate-200 px-4 py-3 dark:border-border", children: [
|
|
2371
|
-
/* @__PURE__ */ s(
|
|
2423
|
+
/* @__PURE__ */ s(st, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2372
2424
|
/* @__PURE__ */ c("div", { className: "min-w-0 flex-1", children: [
|
|
2373
2425
|
/* @__PURE__ */ s("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
|
|
2374
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." })
|
|
@@ -2377,40 +2429,40 @@ function us({
|
|
|
2377
2429
|
"button",
|
|
2378
2430
|
{
|
|
2379
2431
|
type: "button",
|
|
2380
|
-
onClick:
|
|
2432
|
+
onClick: Z,
|
|
2381
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]",
|
|
2382
2434
|
"aria-label": "Close",
|
|
2383
|
-
children: /* @__PURE__ */ s(
|
|
2435
|
+
children: /* @__PURE__ */ s(Tt, { className: "h-4 w-4" })
|
|
2384
2436
|
}
|
|
2385
2437
|
)
|
|
2386
2438
|
] }),
|
|
2387
2439
|
/* @__PURE__ */ c("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
2388
2440
|
/* @__PURE__ */ c("div", { className: "flex items-center gap-2 rounded-md border border-slate-200 bg-slate-50 px-2.5 py-1.5 focus-within:border-nvr-cyan focus-within:bg-white dark:border-border dark:bg-muted/40 dark:focus-within:bg-background", children: [
|
|
2389
|
-
/* @__PURE__ */ s(
|
|
2441
|
+
/* @__PURE__ */ s(Ft, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
2390
2442
|
/* @__PURE__ */ s(
|
|
2391
2443
|
"input",
|
|
2392
2444
|
{
|
|
2393
|
-
ref:
|
|
2394
|
-
value:
|
|
2395
|
-
onChange: (i) =>
|
|
2445
|
+
ref: je,
|
|
2446
|
+
value: H,
|
|
2447
|
+
onChange: (i) => z(i.target.value),
|
|
2396
2448
|
placeholder: "Search by number or description…",
|
|
2397
2449
|
className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
|
|
2398
2450
|
}
|
|
2399
2451
|
),
|
|
2400
|
-
|
|
2452
|
+
H && /* @__PURE__ */ s(
|
|
2401
2453
|
"button",
|
|
2402
2454
|
{
|
|
2403
2455
|
type: "button",
|
|
2404
|
-
onClick: () =>
|
|
2456
|
+
onClick: () => z(""),
|
|
2405
2457
|
className: "shrink-0 text-slate-400 hover:text-slate-600",
|
|
2406
2458
|
"aria-label": "Clear search",
|
|
2407
|
-
children: /* @__PURE__ */ s(
|
|
2459
|
+
children: /* @__PURE__ */ s(Tt, { className: "h-3.5 w-3.5" })
|
|
2408
2460
|
}
|
|
2409
2461
|
)
|
|
2410
2462
|
] }),
|
|
2411
|
-
|
|
2412
|
-
/* @__PURE__ */ s(
|
|
2413
|
-
|
|
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(", "),
|
|
2414
2466
|
" fill in once the form's warehouse selection is made."
|
|
2415
2467
|
] })
|
|
2416
2468
|
] }),
|
|
@@ -2420,63 +2472,63 @@ function us({
|
|
|
2420
2472
|
/* @__PURE__ */ s("col", { className: "w-[88px]" }),
|
|
2421
2473
|
/* @__PURE__ */ s("col", {}),
|
|
2422
2474
|
/* @__PURE__ */ s("col", { className: "w-[130px]" }),
|
|
2423
|
-
|
|
2475
|
+
j.map((i) => /* @__PURE__ */ s("col", { className: "w-[86px]" }, i.key))
|
|
2424
2476
|
] }),
|
|
2425
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: [
|
|
2426
2478
|
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
|
|
2427
2479
|
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "CIFA #" }),
|
|
2428
2480
|
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Description" }),
|
|
2429
2481
|
/* @__PURE__ */ s("th", { className: "px-2 py-1.5", children: "Category" }),
|
|
2430
|
-
|
|
2482
|
+
j.map((i) => /* @__PURE__ */ s("th", { className: "px-2 py-1.5 text-right", children: i.label ?? M(i.key) }, i.key))
|
|
2431
2483
|
] }) }),
|
|
2432
|
-
/* @__PURE__ */ c("tbody", { className:
|
|
2433
|
-
|
|
2484
|
+
/* @__PURE__ */ c("tbody", { className: K(ie && "opacity-50 transition-opacity"), children: [
|
|
2485
|
+
P(
|
|
2434
2486
|
/* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
|
|
2435
|
-
/* @__PURE__ */ s(
|
|
2487
|
+
/* @__PURE__ */ s(st, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2436
2488
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
|
|
2437
|
-
/* @__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:
|
|
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 })
|
|
2438
2490
|
] }),
|
|
2439
2491
|
"border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
|
|
2440
2492
|
),
|
|
2441
|
-
|
|
2493
|
+
B.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
|
|
2442
2494
|
"td",
|
|
2443
2495
|
{
|
|
2444
|
-
colSpan: 4 +
|
|
2496
|
+
colSpan: 4 + j.length,
|
|
2445
2497
|
className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
|
|
2446
|
-
children:
|
|
2498
|
+
children: p.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
|
|
2447
2499
|
}
|
|
2448
2500
|
) }),
|
|
2449
|
-
|
|
2450
|
-
|
|
2501
|
+
B.map((i, v) => oe(i, v)),
|
|
2502
|
+
P(
|
|
2451
2503
|
/* @__PURE__ */ c("span", { className: "flex items-center gap-1.5", children: [
|
|
2452
|
-
/* @__PURE__ */ s(
|
|
2504
|
+
/* @__PURE__ */ s(Ft, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
2453
2505
|
/* @__PURE__ */ s("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
|
|
2454
|
-
/* @__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:
|
|
2455
|
-
|
|
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" })
|
|
2456
2508
|
] }),
|
|
2457
2509
|
"border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
|
|
2458
2510
|
),
|
|
2459
|
-
!
|
|
2511
|
+
!ie && se.length === 0 && /* @__PURE__ */ s("tr", { children: /* @__PURE__ */ s(
|
|
2460
2512
|
"td",
|
|
2461
2513
|
{
|
|
2462
|
-
colSpan: 4 +
|
|
2514
|
+
colSpan: 4 + j.length,
|
|
2463
2515
|
className: "px-4 py-4 text-center text-[11px] text-slate-400",
|
|
2464
|
-
children:
|
|
2516
|
+
children: re.trim() ? `No CIFAs match "${re}".` : "No catalog items."
|
|
2465
2517
|
}
|
|
2466
2518
|
) }),
|
|
2467
|
-
|
|
2519
|
+
se.map((i, v) => oe(i, v))
|
|
2468
2520
|
] })
|
|
2469
2521
|
] }) }),
|
|
2470
|
-
|
|
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: [
|
|
2471
2523
|
/* @__PURE__ */ c("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
|
|
2472
|
-
(
|
|
2524
|
+
(ne - 1) * ye + 1,
|
|
2473
2525
|
"–",
|
|
2474
|
-
Math.min(
|
|
2526
|
+
Math.min(ne * ye, Y),
|
|
2475
2527
|
" of",
|
|
2476
2528
|
" ",
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
/* @__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" }),
|
|
2480
2532
|
" Loading…"
|
|
2481
2533
|
] })
|
|
2482
2534
|
] }),
|
|
@@ -2485,23 +2537,23 @@ function us({
|
|
|
2485
2537
|
"button",
|
|
2486
2538
|
{
|
|
2487
2539
|
type: "button",
|
|
2488
|
-
disabled:
|
|
2489
|
-
onClick: () =>
|
|
2540
|
+
disabled: ne <= 1 || ie,
|
|
2541
|
+
onClick: () => xe((i) => Math.max(1, i - 1)),
|
|
2490
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]",
|
|
2491
2543
|
children: "‹ Prev"
|
|
2492
2544
|
}
|
|
2493
2545
|
),
|
|
2494
2546
|
/* @__PURE__ */ c("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
|
|
2495
|
-
|
|
2547
|
+
ne,
|
|
2496
2548
|
" / ",
|
|
2497
|
-
|
|
2549
|
+
G.toLocaleString()
|
|
2498
2550
|
] }),
|
|
2499
2551
|
/* @__PURE__ */ s(
|
|
2500
2552
|
"button",
|
|
2501
2553
|
{
|
|
2502
2554
|
type: "button",
|
|
2503
|
-
disabled:
|
|
2504
|
-
onClick: () =>
|
|
2555
|
+
disabled: ne >= G || ie,
|
|
2556
|
+
onClick: () => xe((i) => Math.min(G, i + 1)),
|
|
2505
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]",
|
|
2506
2558
|
children: "Next ›"
|
|
2507
2559
|
}
|
|
@@ -2512,10 +2564,13 @@ function us({
|
|
|
2512
2564
|
}
|
|
2513
2565
|
)
|
|
2514
2566
|
] }),
|
|
2515
|
-
|
|
2567
|
+
at
|
|
2516
2568
|
);
|
|
2517
2569
|
}
|
|
2518
2570
|
export {
|
|
2519
|
-
|
|
2520
|
-
|
|
2571
|
+
Ms as CatalogPickerField,
|
|
2572
|
+
hs as MAX_LINE_MONEY,
|
|
2573
|
+
ps as lineComputeError,
|
|
2574
|
+
Hr as matchesShowWhen,
|
|
2575
|
+
bs as qtyEntryProblem
|
|
2521
2576
|
};
|