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