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