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