@nivaro/react 0.3.64 → 0.3.66
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 +62 -8
- package/dist/shared/components/CollectionBrowserView.js +3127 -3204
- package/dist/shared/components/ConformanceView.js +235 -221
- package/dist/shared/components/DataTable.js +478 -459
- package/dist/shared/components/ItemEditForm.js +4842 -4500
- package/dist/shared/components/MyWorkView.js +124 -113
- package/dist/shared/components/PageRenderer.js +146 -138
- package/dist/shared/components/ProfileView.js +483 -472
- package/dist/shared/components/RecordDrilldownSheet.js +73 -65
- package/dist/shared/components/ReportView.js +1100 -1094
- package/dist/shared/components/bulk/BulkActionButtons.js +72 -72
- package/dist/shared/components/bulk/BulkCompareButton.js +62 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +114 -103
- package/dist/shared/components/bulk/BulkFieldUpdateButton.js +73 -0
- package/dist/shared/components/bulk/MessageStakeholders.js +235 -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 +1535 -1440
- 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/GroupSection.js +555 -538
- package/dist/shared/components/item-edit/InlineTableField.js +2903 -2816
- package/dist/shared/components/item-edit/M2MCombobox.js +407 -338
- package/dist/shared/components/item-edit/MidairCollisionDialog.js +367 -116
- 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 +398 -364
- package/dist/shared/components/item-edit/SummaryPanel.js +146 -144
- package/dist/shared/components/item-edit/UserChip.js +264 -229
- package/dist/shared/components/item-edit/cascade-clear-notice.js +56 -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/header-path-preview.js +52 -0
- package/dist/shared/components/item-edit/line-merge.js +84 -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 +27 -16
- package/dist/shared/components/item-edit/rail-width.js +8 -0
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +126 -124
- 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 +1522 -1347
- 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/quick-filter-cascade.js +29 -19
- 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 _e } 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 _ = 1; _ <= 50; _++) {
|
|
37
|
+
const s = await i.request(R(m, { ...b, limit: 1e3, page: _ })).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 = { ...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 O = b(w);
|
|
48
|
+
O == null || O === "" || !j && String(O) === String(k) || (_[w] = O, s[w] = String(O));
|
|
49
|
+
}
|
|
50
|
+
return Object.keys(_).length > 0 ? { updates: _, 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) => {
|
|
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 && typeof s == "object" ? Object.fromEntries(Object.entries(s).map(([w, k]) => [w, _(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] = _(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 _ = m == null ? void 0 : m[b], s = _ == null ? null : String(_), 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 Ss = 2e3;
|
|
111
|
+
function _s(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) => {
|
|
121
|
+
const w = s[m], k = w != null && w !== "" ? w : b != null && b[m] ? Pe(b[m], s) : null, j = Number(k);
|
|
122
|
+
return _ + (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 _ = Pe(x, m);
|
|
134
|
+
if (_ === null) continue;
|
|
135
|
+
m[b] = _;
|
|
136
|
+
const s = i.ruleError(b, _, m);
|
|
137
|
+
if (s) return s;
|
|
138
|
+
if (Math.abs(_) > ys)
|
|
139
|
+
return `${i.labelOf(b)} would be ${_.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 _ = i.lookup(x.key);
|
|
149
|
+
if (_ != null && _ !== "") return _;
|
|
131
150
|
}
|
|
132
|
-
return
|
|
151
|
+
return i.catalogValue;
|
|
133
152
|
}
|
|
134
|
-
function
|
|
135
|
-
return
|
|
153
|
+
function Os(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 Ts(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 _ = b.find((w) => w in i);
|
|
167
|
+
if (!_) return !1;
|
|
168
|
+
const s = i[_];
|
|
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: _,
|
|
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 Mn, Bn, Dn, Hn, Yn, Zn, Gn, Xn;
|
|
181
|
+
const k = Kt(), j = Br(), v = ks(), O = 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
|
+
}), U = ((Mn = te.find((e) => e.field === J)) == null ? void 0 : Mn.type) ?? null, M = (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: T } = 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 = T == null ? void 0 : T.display_template, L = F(() => {
|
|
218
|
+
const e = s.section_by.split(".")[0];
|
|
219
|
+
return ((T == null ? void 0 : T.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
|
+
}, [T, 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 = O == null ? void 0 : O.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
|
+
T && !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, T, 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: Ss,
|
|
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 && !!T && 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
|
+
() => Os(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) => Ts(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: Oe = [] } = 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(Oe), [Oe]), { data: Xe = [] } = C({
|
|
411
|
+
queryKey: ["pinned-item-rows", g, A, Oe.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: Oe } }),
|
|
415
|
+
fields: A,
|
|
416
|
+
limit: Oe.length
|
|
397
417
|
})
|
|
398
418
|
).then((e) => e.data ?? []),
|
|
399
|
-
enabled: !!g && !!
|
|
419
|
+
enabled: !!g && !!s.favorites && Oe.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 Sn = 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: _n } = F(() => {
|
|
446
466
|
const e = new Set(
|
|
447
|
-
((
|
|
467
|
+
((T == null ? void 0 : T.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
|
+
((T == null ? void 0 : T.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
|
+
}, [T, 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, Te = 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 = O == null ? void 0 : O.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 && Te !== null, Wt = F(() => {
|
|
499
|
+
if (!se) return null;
|
|
500
|
+
const e = ((T == null ? void 0 : T.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, T, g]), Ut = F(
|
|
505
|
+
() => ae && Wt && se && Te ? { [Wt]: { _some: { ...Te, [se.value_field]: { _gt: 0 } } } } : null,
|
|
506
|
+
[ae, Wt, se, Te]
|
|
507
|
+
), Mt = JSON.stringify(Ut), gt = ae && !Ut ? 100 : 25, Bt = (e, t) => {
|
|
508
|
+
const n = [t, Ut].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
|
+
Mt,
|
|
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: Sn
|
|
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 = _n.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
|
+
Mt,
|
|
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: Sn
|
|
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: On = [] } = 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
|
+
Mt
|
|
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: On,
|
|
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, On, 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 _n) {
|
|
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 Oe) 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, Oe, 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 && _) {
|
|
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: _,
|
|
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 S = p[e.item_field];
|
|
696
|
+
if (S != null)
|
|
697
|
+
if (r) {
|
|
698
|
+
const q = Number(p[e.value_field]);
|
|
699
|
+
n[String(S)] = (Number(n[String(S)]) || 0) + (Number.isNaN(q) ? 0 : q);
|
|
659
700
|
} else
|
|
660
|
-
|
|
701
|
+
n[String(S)] = 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), Tn = (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) => Tn(String(e.id))) : Ve, Xt = ae ? Xe.filter((e) => Tn(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 = Se(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
|
+
}, Sr = (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) : "", _r = !!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: _r && !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,504 +772,548 @@ 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(","), Or = 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 S = String(p[n.fk_to_child]), q = c.get(String(p[n.related_field]));
|
|
811
|
+
q && (f[S] = f[S] ? `${f[S]}, ${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
|
+
}), Tr = (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 = Or[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",
|
|
798
|
-
|
|
839
|
+
// The header's ORDER STATUS word for the same order (army 11 a2 F8).
|
|
840
|
+
label: s.fulfilment.pending_label ?? "Order Sent",
|
|
841
|
+
key: "requested"
|
|
799
842
|
};
|
|
800
843
|
return /* @__PURE__ */ u(
|
|
801
844
|
"span",
|
|
802
845
|
{
|
|
803
846
|
className: "inline-flex items-center gap-1.5 whitespace-nowrap",
|
|
804
|
-
"data-catalog-fulfilment":
|
|
805
|
-
title: `${
|
|
847
|
+
"data-catalog-fulfilment": "key" in r ? r.key : r.label.split(" ")[0].toLowerCase(),
|
|
848
|
+
title: `${s.fulfilment.label ?? "Warehouse"} · ${n} of ${t} shipped`,
|
|
806
849
|
children: [
|
|
807
|
-
/* @__PURE__ */
|
|
808
|
-
/* @__PURE__ */
|
|
850
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: `h-1.5 w-1.5 rounded-full ${r.dot}` }),
|
|
851
|
+
/* @__PURE__ */ a("span", { className: `text-[11px] font-medium ${r.text}`, children: r.label })
|
|
809
852
|
]
|
|
810
853
|
}
|
|
811
854
|
);
|
|
812
|
-
},
|
|
855
|
+
}, Pn = s.columns ?? [], En = s.related_columns ?? [], St = 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 = St.length > 0 || sn.length > 0, an = pe(null), Cn = (e) => {
|
|
813
856
|
let t = e.parentElement;
|
|
814
857
|
for (; t; ) {
|
|
815
|
-
const
|
|
816
|
-
if (/(auto|scroll)/.test(
|
|
817
|
-
e.style.top = `-${Number.parseFloat(
|
|
858
|
+
const n = getComputedStyle(t);
|
|
859
|
+
if (/(auto|scroll)/.test(n.overflowY) && t.scrollHeight > t.clientHeight + 4) {
|
|
860
|
+
e.style.top = `-${Number.parseFloat(n.paddingTop) || 0}px`;
|
|
818
861
|
return;
|
|
819
862
|
}
|
|
820
863
|
t = t.parentElement;
|
|
821
864
|
}
|
|
822
|
-
},
|
|
823
|
-
|
|
865
|
+
}, Er = (e) => {
|
|
866
|
+
an.current = e, e && Cn(e);
|
|
824
867
|
};
|
|
825
|
-
|
|
868
|
+
xe(() => {
|
|
826
869
|
let e = 0;
|
|
827
870
|
const t = () => {
|
|
828
871
|
e || (e = requestAnimationFrame(() => {
|
|
829
|
-
e = 0,
|
|
872
|
+
e = 0, an.current && Cn(an.current);
|
|
830
873
|
}));
|
|
831
874
|
};
|
|
832
875
|
return window.addEventListener("scroll", t, !0), () => {
|
|
833
876
|
e && cancelAnimationFrame(e), window.removeEventListener("scroll", t, !0);
|
|
834
877
|
};
|
|
835
878
|
}, []);
|
|
836
|
-
const
|
|
837
|
-
let
|
|
838
|
-
for (const
|
|
839
|
-
if (
|
|
840
|
-
|
|
879
|
+
const _t = (e, t) => {
|
|
880
|
+
let n = e;
|
|
881
|
+
for (const r of t.split(".")) {
|
|
882
|
+
if (n == null || typeof n != "object") return;
|
|
883
|
+
n = n[r];
|
|
841
884
|
}
|
|
842
|
-
return
|
|
843
|
-
},
|
|
885
|
+
return n;
|
|
886
|
+
}, Ne = (e, t) => {
|
|
844
887
|
if (t === "presence")
|
|
845
888
|
return e == null || e === "" || Number(e) === 0 ? "No" : "Yes";
|
|
846
889
|
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
|
-
|
|
890
|
+
const n = Number(e);
|
|
891
|
+
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);
|
|
892
|
+
}, qt = g ? `${g}:${i}.${m}` : null, Le = ar(qt && `${qt}:catalog`), ve = ar(qt && `${qt}:summary`), Jn = pe(null), Lr = (e, t) => {
|
|
893
|
+
const n = ms(Jn.current, t);
|
|
894
|
+
n != null && e.setWidth(t, n);
|
|
895
|
+
}, $t = (e, t, n, r, l) => {
|
|
896
|
+
const o = e.box(t, r, l);
|
|
897
|
+
return /* @__PURE__ */ u("span", { ...o, className: I("relative", o.className), children: [
|
|
898
|
+
/* @__PURE__ */ a("span", { "data-cpf-fit": !0, className: "block truncate", children: n }),
|
|
899
|
+
/* @__PURE__ */ a(
|
|
900
|
+
us,
|
|
858
901
|
{
|
|
859
|
-
label:
|
|
860
|
-
onResize: (
|
|
861
|
-
onFit: () =>
|
|
902
|
+
label: n,
|
|
903
|
+
onResize: (h) => e.setWidth(t, h),
|
|
904
|
+
onFit: () => Lr(e, t)
|
|
862
905
|
}
|
|
863
906
|
)
|
|
864
907
|
] }, t);
|
|
865
|
-
},
|
|
866
|
-
|
|
867
|
-
const [l, o] =
|
|
868
|
-
return /* @__PURE__ */
|
|
869
|
-
|
|
908
|
+
}, Ar = (Xn = St.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(_e, { children: [
|
|
909
|
+
St.map((r) => {
|
|
910
|
+
const [l, o] = In(r);
|
|
911
|
+
return /* @__PURE__ */ a(
|
|
912
|
+
lr,
|
|
870
913
|
{
|
|
871
|
-
text:
|
|
872
|
-
|
|
873
|
-
field:
|
|
874
|
-
catalogValue:
|
|
875
|
-
copyFields:
|
|
876
|
-
related:
|
|
877
|
-
lookup: (
|
|
914
|
+
text: Ne(
|
|
915
|
+
Fs({
|
|
916
|
+
field: r.field,
|
|
917
|
+
catalogValue: _t(t, r.field),
|
|
918
|
+
copyFields: s.copy_fields,
|
|
919
|
+
related: s.related_columns,
|
|
920
|
+
lookup: (h) => st(h, e)
|
|
878
921
|
}),
|
|
879
|
-
|
|
922
|
+
r.format
|
|
880
923
|
),
|
|
881
|
-
highlight:
|
|
882
|
-
...
|
|
924
|
+
highlight: r.format ? void 0 : n,
|
|
925
|
+
...Le.box(r.field, l, I("text-slate-500 dark:text-slate-400", o))
|
|
883
926
|
},
|
|
884
|
-
|
|
927
|
+
r.field
|
|
885
928
|
);
|
|
886
929
|
}),
|
|
887
|
-
|
|
930
|
+
sn.map((r) => /* @__PURE__ */ a(
|
|
888
931
|
"span",
|
|
889
932
|
{
|
|
890
|
-
...
|
|
891
|
-
`rel:${
|
|
933
|
+
...Le.box(
|
|
934
|
+
`rel:${r.key}`,
|
|
892
935
|
"w-20 shrink-0",
|
|
893
936
|
"truncate text-right text-slate-500 dark:text-slate-400"
|
|
894
937
|
),
|
|
895
|
-
children:
|
|
938
|
+
children: Ne(st(r.key, e), r.format)
|
|
896
939
|
},
|
|
897
|
-
|
|
940
|
+
r.key
|
|
898
941
|
)),
|
|
899
|
-
/* @__PURE__ */
|
|
900
|
-
] }),
|
|
942
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" })
|
|
943
|
+
] }), Kr = or(g), zn = (e, t, n, r, l) => Kr ? /* @__PURE__ */ a(
|
|
901
944
|
"button",
|
|
902
945
|
{
|
|
903
946
|
type: "button",
|
|
904
|
-
"data-cpf-fit":
|
|
905
|
-
onClick: () => g &&
|
|
947
|
+
"data-cpf-fit": r || void 0,
|
|
948
|
+
onClick: () => g && dr(g, e, N),
|
|
906
949
|
title: "View stock & planning detail",
|
|
907
|
-
className:
|
|
908
|
-
|
|
950
|
+
className: I(
|
|
951
|
+
n,
|
|
909
952
|
"text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600"
|
|
910
953
|
),
|
|
911
|
-
children: l ? /* @__PURE__ */
|
|
954
|
+
children: l ? /* @__PURE__ */ a(fn, { text: t, query: l }) : t
|
|
912
955
|
}
|
|
913
|
-
) : /* @__PURE__ */
|
|
914
|
-
const l =
|
|
915
|
-
return /* @__PURE__ */ u("span", { ...l, className:
|
|
916
|
-
|
|
956
|
+
) : /* @__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) => {
|
|
957
|
+
const l = Le.box("item", Kn ? "w-36 shrink-0" : "min-w-0 flex-1");
|
|
958
|
+
return /* @__PURE__ */ u("span", { ...l, className: I("flex min-w-0 items-center gap-1.5", l.className), children: [
|
|
959
|
+
zn(
|
|
917
960
|
e,
|
|
918
961
|
t,
|
|
919
962
|
"min-w-0 truncate text-slate-700 dark:text-slate-200",
|
|
920
963
|
!0,
|
|
921
|
-
|
|
964
|
+
r
|
|
922
965
|
),
|
|
923
|
-
|
|
966
|
+
n
|
|
924
967
|
] });
|
|
925
|
-
},
|
|
926
|
-
const t =
|
|
927
|
-
return t ? ze(
|
|
928
|
-
},
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
968
|
+
}, jt = (e) => {
|
|
969
|
+
const t = mt.get(e) ?? It.find((n) => String(n.id) === e) ?? Xe.find((n) => String(n.id) === e);
|
|
970
|
+
return t ? ze(z, t) : `#${e}`;
|
|
971
|
+
}, Qn = pe(jt);
|
|
972
|
+
Qn.current = jt;
|
|
973
|
+
const Vn = pe(me);
|
|
974
|
+
Vn.current = me, xe(
|
|
975
|
+
() => as(i, (e) => {
|
|
976
|
+
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;
|
|
977
|
+
if (r == null || r === "") return null;
|
|
978
|
+
const l = Qn.current(String(r));
|
|
979
|
+
return l.startsWith("#") ? null : l;
|
|
980
|
+
}),
|
|
981
|
+
[i, s.item_field]
|
|
982
|
+
);
|
|
983
|
+
const Ie = (e) => mt.get(e) ?? It.find((t) => String(t.id) === e) ?? Xe.find((t) => String(t.id) === e) ?? { id: e }, Se = (e) => {
|
|
984
|
+
var r;
|
|
985
|
+
const t = P ? void 0 : Ge.get(e);
|
|
986
|
+
if (t) return bt.has(String(t.id)) ? null : Number(t[J] ?? 0);
|
|
987
|
+
const n = pt.get(e);
|
|
988
|
+
return n === void 0 ? null : Number(((r = we[n]) == null ? void 0 : r[J]) ?? 0);
|
|
989
|
+
}, Cr = (e) => {
|
|
935
990
|
let t = e;
|
|
936
|
-
for (const
|
|
991
|
+
for (const n of s.section_by.split(".")) {
|
|
937
992
|
if (t == null || typeof t != "object") return "";
|
|
938
|
-
t = t[
|
|
993
|
+
t = t[n];
|
|
939
994
|
}
|
|
940
995
|
return String(t ?? "").trim();
|
|
941
|
-
},
|
|
942
|
-
if (
|
|
943
|
-
|
|
996
|
+
}, Ft = F(() => {
|
|
997
|
+
if (ut) return [];
|
|
998
|
+
X.trim().toLowerCase();
|
|
944
999
|
const e = /* @__PURE__ */ new Map();
|
|
945
|
-
for (const t of
|
|
946
|
-
if (
|
|
947
|
-
const
|
|
948
|
-
if (!(
|
|
949
|
-
for (const l of
|
|
1000
|
+
for (const t of re) {
|
|
1001
|
+
if (ae && at !== void 0 && !(Number(at[String(t.id)]) > 0)) continue;
|
|
1002
|
+
const n = ze(z, t), r = L ? yn.get(String(t.id)) ?? [] : [Cr(t)];
|
|
1003
|
+
if (!(L && Q && r.length === 0))
|
|
1004
|
+
for (const l of r.length ? r : [""]) {
|
|
950
1005
|
const o = l || "Uncategorized";
|
|
951
|
-
e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label:
|
|
1006
|
+
e.has(o) || e.set(o, []), e.get(o).push({ id: String(t.id), label: n, row: t });
|
|
952
1007
|
}
|
|
953
1008
|
}
|
|
954
1009
|
return [...e.entries()].sort(
|
|
955
|
-
([t], [
|
|
956
|
-
).map(([t,
|
|
1010
|
+
([t], [n]) => t === "Uncategorized" ? 1 : n === "Uncategorized" ? -1 : t.localeCompare(n)
|
|
1011
|
+
).map(([t, n]) => ({
|
|
957
1012
|
name: t,
|
|
958
|
-
items:
|
|
1013
|
+
items: n.sort((r, l) => r.label.localeCompare(l.label))
|
|
959
1014
|
}));
|
|
960
1015
|
}, [
|
|
961
|
-
de,
|
|
962
|
-
J,
|
|
963
|
-
U,
|
|
964
|
-
a.section_by,
|
|
965
|
-
E,
|
|
966
|
-
mr,
|
|
967
|
-
dt,
|
|
968
|
-
W,
|
|
969
1016
|
re,
|
|
970
|
-
|
|
1017
|
+
z,
|
|
1018
|
+
X,
|
|
1019
|
+
s.section_by,
|
|
1020
|
+
L,
|
|
1021
|
+
yn,
|
|
1022
|
+
ut,
|
|
1023
|
+
Q,
|
|
1024
|
+
ae,
|
|
1025
|
+
at
|
|
971
1026
|
]);
|
|
972
|
-
if (!
|
|
973
|
-
|
|
1027
|
+
if (!je.current && Ft.length > 0) {
|
|
1028
|
+
je.current = !0;
|
|
974
1029
|
const e = /* @__PURE__ */ new Set();
|
|
975
|
-
for (const t of
|
|
976
|
-
t.items.some((
|
|
977
|
-
|
|
1030
|
+
for (const t of Ft)
|
|
1031
|
+
t.items.some((r) => (Se(r.id) ?? 0) > 0) || e.add(t.name);
|
|
1032
|
+
$e(e);
|
|
978
1033
|
}
|
|
979
|
-
async function
|
|
1034
|
+
async function Jr(e) {
|
|
980
1035
|
const t = {};
|
|
981
|
-
for (const
|
|
982
|
-
if (!
|
|
983
|
-
let
|
|
984
|
-
if (
|
|
985
|
-
const l =
|
|
1036
|
+
for (const n of s.related_columns ?? []) {
|
|
1037
|
+
if (!n.copy_to) continue;
|
|
1038
|
+
let r = st(n.key, e);
|
|
1039
|
+
if (r === void 0) {
|
|
1040
|
+
const l = De(n.match, N);
|
|
986
1041
|
if (l === null) continue;
|
|
987
|
-
|
|
988
|
-
R(`/items/${
|
|
1042
|
+
r = await k.request(
|
|
1043
|
+
R(`/items/${n.collection}`, {
|
|
989
1044
|
limit: 1,
|
|
990
|
-
fields: `${
|
|
991
|
-
filter: JSON.stringify({ ...l, [
|
|
1045
|
+
fields: `${n.item_field},${n.value_field}`,
|
|
1046
|
+
filter: JSON.stringify({ ...l, [n.item_field]: { _eq: e } })
|
|
992
1047
|
})
|
|
993
1048
|
).then((o) => {
|
|
994
|
-
var
|
|
995
|
-
return (c = (
|
|
1049
|
+
var h, c;
|
|
1050
|
+
return (c = (h = o.data) == null ? void 0 : h[0]) == null ? void 0 : c[n.value_field];
|
|
996
1051
|
}).catch(() => {
|
|
997
1052
|
});
|
|
998
1053
|
}
|
|
999
|
-
|
|
1054
|
+
r != null && (t[n.copy_to] = r);
|
|
1000
1055
|
}
|
|
1001
1056
|
return t;
|
|
1002
1057
|
}
|
|
1003
|
-
const
|
|
1004
|
-
var
|
|
1005
|
-
for (const l of
|
|
1058
|
+
const Wn = (e, t) => {
|
|
1059
|
+
var r;
|
|
1060
|
+
for (const l of s.related_columns ?? []) {
|
|
1006
1061
|
if (l.copy_to !== t) continue;
|
|
1007
|
-
const o =
|
|
1062
|
+
const o = st(l.key, e);
|
|
1008
1063
|
if (o != null && o !== "") return o;
|
|
1009
1064
|
}
|
|
1010
|
-
const
|
|
1011
|
-
return
|
|
1012
|
-
},
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1065
|
+
const n = (r = s.copy_fields) == null ? void 0 : r[t];
|
|
1066
|
+
return n ? Ie(e)[n] : void 0;
|
|
1067
|
+
}, Un = pe(/* @__PURE__ */ new Map()), Ot = F(() => {
|
|
1068
|
+
const e = new Set(Object.keys(s.copy_fields ?? {}));
|
|
1069
|
+
for (const t of s.related_columns ?? []) t.copy_to && e.add(t.copy_to);
|
|
1070
|
+
return [...e];
|
|
1071
|
+
}, [s.copy_fields, s.related_columns]), Ir = JSON.stringify([
|
|
1072
|
+
we.map((e) => [e[s.item_field], ...Ot.map((t) => e[t] ?? null)]),
|
|
1073
|
+
rt.map((e) => e.dataUpdatedAt),
|
|
1074
|
+
re.length,
|
|
1075
|
+
It.length
|
|
1076
|
+
]);
|
|
1077
|
+
xe(() => {
|
|
1078
|
+
w || !v || Ot.length === 0 || we.forEach((e, t) => {
|
|
1079
|
+
const n = e[s.item_field];
|
|
1080
|
+
if (n == null) return;
|
|
1081
|
+
const r = vs(
|
|
1082
|
+
e,
|
|
1083
|
+
Ot,
|
|
1084
|
+
(o) => Wn(String(n), o),
|
|
1085
|
+
Un.current.get(String(n))
|
|
1086
|
+
);
|
|
1087
|
+
if (!r) return;
|
|
1088
|
+
Un.current.set(String(n), r.auto);
|
|
1089
|
+
const l = { ...e, ...r.updates };
|
|
1090
|
+
for (const [o, h] of Object.entries(s.compute_fields ?? {})) {
|
|
1091
|
+
const c = Pe(h, l);
|
|
1092
|
+
c !== null && (l[o] = c);
|
|
1093
|
+
}
|
|
1094
|
+
v.updateRow(i, m, t, l);
|
|
1095
|
+
});
|
|
1096
|
+
}, [Ir, w, Ot]);
|
|
1097
|
+
const zr = (e, t) => {
|
|
1098
|
+
if (w || !Z.includes(t)) return !1;
|
|
1099
|
+
if (Ae || !G.includes(t)) return !0;
|
|
1100
|
+
const n = Wn(e, t);
|
|
1101
|
+
return n == null || n === "" || !(Number(n) > 0);
|
|
1017
1102
|
};
|
|
1018
|
-
function
|
|
1103
|
+
function Ue(e, t, n, r = {}) {
|
|
1019
1104
|
const l = {
|
|
1020
|
-
[
|
|
1021
|
-
[
|
|
1105
|
+
[s.item_field]: n.id ?? e,
|
|
1106
|
+
[J]: t
|
|
1022
1107
|
};
|
|
1023
|
-
for (const [o,
|
|
1024
|
-
|
|
1025
|
-
Object.assign(l,
|
|
1026
|
-
for (const [o,
|
|
1027
|
-
const c =
|
|
1108
|
+
for (const [o, h] of Object.entries(s.copy_fields ?? {}))
|
|
1109
|
+
n[h] !== void 0 && (l[o] = n[h]);
|
|
1110
|
+
Object.assign(l, r);
|
|
1111
|
+
for (const [o, h] of Object.entries(s.compute_fields ?? {})) {
|
|
1112
|
+
const c = Pe(h, l);
|
|
1028
1113
|
c !== null && (l[o] = c);
|
|
1029
1114
|
}
|
|
1030
1115
|
return l;
|
|
1031
1116
|
}
|
|
1032
|
-
function
|
|
1033
|
-
return
|
|
1034
|
-
compute:
|
|
1035
|
-
probe: { ...
|
|
1036
|
-
ruleError:
|
|
1117
|
+
function Qr(e, t, n, r) {
|
|
1118
|
+
return js({
|
|
1119
|
+
compute: s.compute_fields ?? {},
|
|
1120
|
+
probe: { ...Ue(e, t, n), ...r, [J]: t },
|
|
1121
|
+
ruleError: M,
|
|
1037
1122
|
labelOf: (l) => {
|
|
1038
1123
|
var o;
|
|
1039
|
-
return ((o =
|
|
1124
|
+
return ((o = te.find((h) => h.field === l)) == null ? void 0 : o.label) || D(l);
|
|
1040
1125
|
}
|
|
1041
1126
|
});
|
|
1042
1127
|
}
|
|
1043
|
-
async function
|
|
1044
|
-
const l =
|
|
1128
|
+
async function lt(e, t, n, r = {}) {
|
|
1129
|
+
const l = hn(t, { type: U, min: 0, label: "Quantity" });
|
|
1045
1130
|
if (!l.ok) {
|
|
1046
|
-
|
|
1131
|
+
de((f) => ({ ...f, [e]: { kind: "error", message: l.message } }));
|
|
1047
1132
|
return;
|
|
1048
1133
|
}
|
|
1049
1134
|
const o = l.value ?? 0;
|
|
1050
|
-
if ((
|
|
1051
|
-
if (o === 0 && !
|
|
1052
|
-
|
|
1135
|
+
if ((Se(e) ?? 0) === o) return;
|
|
1136
|
+
if (o === 0 && !r.confirmedRemove) {
|
|
1137
|
+
de((f) => ({ ...f, [e]: { kind: "remove", row: n } }));
|
|
1053
1138
|
return;
|
|
1054
1139
|
}
|
|
1055
1140
|
if (o > 0) {
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1058
|
-
|
|
1141
|
+
const f = pt.get(e), p = (P ? void 0 : Ge.get(e)) ?? (f !== void 0 ? we[f] : void 0) ?? {}, S = M(J, o, p) ?? Qr(e, o, n, p);
|
|
1142
|
+
if (S) {
|
|
1143
|
+
de((q) => ({ ...q, [e]: { kind: "error", message: S } }));
|
|
1059
1144
|
return;
|
|
1060
1145
|
}
|
|
1061
1146
|
}
|
|
1062
|
-
const c = o > 0 ? await
|
|
1063
|
-
if (
|
|
1064
|
-
const
|
|
1065
|
-
if ((
|
|
1066
|
-
const
|
|
1147
|
+
const c = o > 0 ? await Jr(e) : {};
|
|
1148
|
+
if (Ze && v) {
|
|
1149
|
+
const f = Ge.get(e);
|
|
1150
|
+
if ((f == null ? void 0 : f.id) != null) {
|
|
1151
|
+
const p = String(f.id);
|
|
1067
1152
|
if (o === 0) {
|
|
1068
|
-
|
|
1153
|
+
v.cancelPendingEdit(i, m, p), v.queueDelete(i, m, p);
|
|
1069
1154
|
return;
|
|
1070
1155
|
}
|
|
1071
|
-
|
|
1072
|
-
const
|
|
1073
|
-
for (const
|
|
1074
|
-
|
|
1075
|
-
for (const [
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1156
|
+
bt.has(p) && v.cancelPendingDelete(i, m, p);
|
|
1157
|
+
const S = Ue(e, o, n, c);
|
|
1158
|
+
for (const y of Z)
|
|
1159
|
+
f[y] != null && f[y] !== "" && (S[y] = f[y]);
|
|
1160
|
+
for (const [y, K] of Object.entries(s.compute_fields ?? {})) {
|
|
1161
|
+
const Re = Pe(K, { ...f, ...S });
|
|
1162
|
+
Re !== null && (S[y] = Re);
|
|
1078
1163
|
}
|
|
1079
|
-
const
|
|
1080
|
-
Object.entries(
|
|
1164
|
+
const q = me.find((y) => String(y.id) === p) ?? {}, E = Object.fromEntries(
|
|
1165
|
+
Object.entries(S).filter(([y, K]) => String(K ?? "") !== String(q[y] ?? ""))
|
|
1081
1166
|
);
|
|
1082
|
-
Object.keys(
|
|
1167
|
+
Object.keys(E).length === 0 ? v.cancelPendingEdit(i, m, p) : (v.cancelPendingEdit(i, m, p), v.queueEdit(i, m, p, E));
|
|
1083
1168
|
return;
|
|
1084
1169
|
}
|
|
1085
1170
|
}
|
|
1086
|
-
if (
|
|
1087
|
-
const
|
|
1088
|
-
o === 0 ?
|
|
1089
|
-
|
|
1090
|
-
h,
|
|
1171
|
+
if (P || Ze) {
|
|
1172
|
+
const f = pt.get(e);
|
|
1173
|
+
o === 0 ? f !== void 0 && (v == null || v.removeRow(i, m, f)) : f !== void 0 ? v == null || v.updateRow(
|
|
1174
|
+
i,
|
|
1091
1175
|
m,
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1176
|
+
f,
|
|
1177
|
+
bs(
|
|
1178
|
+
we[f],
|
|
1179
|
+
Ue(e, o, n, c),
|
|
1180
|
+
Z,
|
|
1181
|
+
s.compute_fields
|
|
1097
1182
|
)
|
|
1098
|
-
) :
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1183
|
+
) : v == null || v.queueRow(
|
|
1184
|
+
i,
|
|
1185
|
+
m,
|
|
1186
|
+
Ue(e, o, n, c)
|
|
1102
1187
|
);
|
|
1103
1188
|
return;
|
|
1104
1189
|
}
|
|
1105
|
-
|
|
1190
|
+
V((f) => new Set(f).add(e));
|
|
1106
1191
|
try {
|
|
1107
|
-
const
|
|
1192
|
+
const f = Ge.get(e);
|
|
1108
1193
|
if (o === 0)
|
|
1109
|
-
(
|
|
1110
|
-
else if ((
|
|
1111
|
-
const
|
|
1112
|
-
for (const
|
|
1113
|
-
|
|
1114
|
-
for (const [
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1194
|
+
(f == null ? void 0 : f.id) != null && await k.request(es(`/items/${i}/${f.id}${qe}`));
|
|
1195
|
+
else if ((f == null ? void 0 : f.id) != null) {
|
|
1196
|
+
const p = Ue(e, o, n, c);
|
|
1197
|
+
for (const y of Z)
|
|
1198
|
+
f[y] != null && f[y] !== "" && (p[y] = f[y]);
|
|
1199
|
+
for (const [y, K] of Object.entries(s.compute_fields ?? {})) {
|
|
1200
|
+
const Re = Pe(K, { ...f, ...p });
|
|
1201
|
+
Re !== null && (p[y] = Re);
|
|
1117
1202
|
}
|
|
1118
|
-
const
|
|
1119
|
-
await k.request(
|
|
1203
|
+
const S = { ...f, ...p }, { id: q, ...E } = S;
|
|
1204
|
+
await k.request(rr(`/items/${i}/${f.id}${qe}`, E));
|
|
1120
1205
|
} else
|
|
1121
1206
|
await k.request(
|
|
1122
|
-
|
|
1123
|
-
[
|
|
1124
|
-
...
|
|
1207
|
+
sr(`/items/${i}${qe}`, {
|
|
1208
|
+
[m]: b,
|
|
1209
|
+
...Ue(e, o, n, c)
|
|
1125
1210
|
})
|
|
1126
1211
|
);
|
|
1127
|
-
j.invalidateQueries({ queryKey: ["o2m-rows",
|
|
1212
|
+
j.invalidateQueries({ queryKey: ["o2m-rows", i, m, b] });
|
|
1128
1213
|
} catch {
|
|
1129
1214
|
} finally {
|
|
1130
|
-
|
|
1131
|
-
const
|
|
1132
|
-
return
|
|
1215
|
+
V((f) => {
|
|
1216
|
+
const p = new Set(f);
|
|
1217
|
+
return p.delete(e), p;
|
|
1133
1218
|
});
|
|
1134
1219
|
}
|
|
1135
1220
|
}
|
|
1136
|
-
async function
|
|
1137
|
-
const
|
|
1138
|
-
if (
|
|
1139
|
-
const l = (
|
|
1140
|
-
const c = { ...
|
|
1141
|
-
for (const [
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1221
|
+
async function Vr(e, t, n) {
|
|
1222
|
+
const r = n.trim() === "" ? null : Number(n);
|
|
1223
|
+
if (n.trim() !== "" && Number.isNaN(r)) return;
|
|
1224
|
+
const l = (h) => {
|
|
1225
|
+
const c = { ...h, [t]: r };
|
|
1226
|
+
for (const [f, p] of Object.entries(s.compute_fields ?? {})) {
|
|
1227
|
+
const S = Pe(p, c);
|
|
1228
|
+
S !== null && (c[f] = S);
|
|
1144
1229
|
}
|
|
1145
1230
|
return c;
|
|
1146
|
-
}, o =
|
|
1231
|
+
}, o = P ? void 0 : Ge.get(e);
|
|
1147
1232
|
if ((o == null ? void 0 : o.id) == null) {
|
|
1148
|
-
const
|
|
1149
|
-
if (
|
|
1150
|
-
|
|
1233
|
+
const h = pt.get(e);
|
|
1234
|
+
if (h === void 0) return;
|
|
1235
|
+
v == null || v.updateRow(i, m, h, l(we[h]));
|
|
1151
1236
|
return;
|
|
1152
1237
|
}
|
|
1153
|
-
if (
|
|
1154
|
-
const
|
|
1155
|
-
Object.entries(
|
|
1156
|
-
([
|
|
1238
|
+
if (Ze && v) {
|
|
1239
|
+
const h = l(o), c = me.find((p) => String(p.id) === String(o.id)) ?? {}, f = Object.fromEntries(
|
|
1240
|
+
Object.entries(h).filter(
|
|
1241
|
+
([p, S]) => p !== "id" && String(S ?? "") !== String(c[p] ?? "")
|
|
1157
1242
|
)
|
|
1158
1243
|
);
|
|
1159
|
-
|
|
1244
|
+
v.cancelPendingEdit(i, m, String(o.id)), Object.keys(f).length > 0 && v.queueEdit(i, m, String(o.id), f);
|
|
1160
1245
|
return;
|
|
1161
1246
|
}
|
|
1162
|
-
|
|
1247
|
+
V((h) => new Set(h).add(e));
|
|
1163
1248
|
try {
|
|
1164
|
-
const { id:
|
|
1165
|
-
await k.request(
|
|
1249
|
+
const { id: h, ...c } = l(o);
|
|
1250
|
+
await k.request(rr(`/items/${i}/${o.id}${qe}`, c)), j.invalidateQueries({ queryKey: ["o2m-rows", i, m, b] });
|
|
1166
1251
|
} catch {
|
|
1167
1252
|
} finally {
|
|
1168
|
-
|
|
1169
|
-
const c = new Set(
|
|
1253
|
+
V((h) => {
|
|
1254
|
+
const c = new Set(h);
|
|
1170
1255
|
return c.delete(e), c;
|
|
1171
1256
|
});
|
|
1172
1257
|
}
|
|
1173
1258
|
}
|
|
1174
|
-
async function
|
|
1259
|
+
async function Wr(e) {
|
|
1175
1260
|
if (e == null || e === "" || !g) return;
|
|
1176
|
-
const t = String(e),
|
|
1177
|
-
let
|
|
1178
|
-
Object.keys(
|
|
1261
|
+
const t = String(e), n = Ie(t);
|
|
1262
|
+
let r = n;
|
|
1263
|
+
Object.keys(n).length <= 1 && (r = await k.request(
|
|
1179
1264
|
R(`/items/${g}`, {
|
|
1180
1265
|
filter: JSON.stringify({ id: { _eq: e } }),
|
|
1181
|
-
fields:
|
|
1266
|
+
fields: A,
|
|
1182
1267
|
limit: 1
|
|
1183
1268
|
})
|
|
1184
1269
|
).then((o) => {
|
|
1185
|
-
var
|
|
1186
|
-
return ((
|
|
1270
|
+
var h;
|
|
1271
|
+
return ((h = o.data) == null ? void 0 : h[0]) ?? { id: e };
|
|
1187
1272
|
}).catch(() => ({ id: e })));
|
|
1188
|
-
const l = (
|
|
1189
|
-
await
|
|
1273
|
+
const l = (Se(t) ?? 0) + 1;
|
|
1274
|
+
await lt(t, String(l), r);
|
|
1190
1275
|
}
|
|
1191
|
-
const
|
|
1192
|
-
const
|
|
1193
|
-
if (
|
|
1194
|
-
return /* @__PURE__ */
|
|
1195
|
-
const
|
|
1196
|
-
if (!(e in
|
|
1197
|
-
const
|
|
1198
|
-
return delete
|
|
1199
|
-
}), c = /* @__PURE__ */
|
|
1276
|
+
const Ur = be.length, Tt = Object.keys(s.copy_fields ?? {}), Me = Object.keys(s.compute_fields ?? {}), Rt = (e, t) => {
|
|
1277
|
+
const n = Se(e);
|
|
1278
|
+
if (w)
|
|
1279
|
+
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.toLocaleString("en-US") : "—" });
|
|
1280
|
+
const r = ke[e], l = r !== void 0 ? r : n && n > 0 ? String(n) : "", o = oe[e], h = () => de((f) => {
|
|
1281
|
+
if (!(e in f)) return f;
|
|
1282
|
+
const p = { ...f };
|
|
1283
|
+
return delete p[e], p;
|
|
1284
|
+
}), c = /* @__PURE__ */ a(
|
|
1200
1285
|
"input",
|
|
1201
1286
|
{
|
|
1202
1287
|
type: "number",
|
|
1203
1288
|
min: 0,
|
|
1204
|
-
step:
|
|
1205
|
-
disabled:
|
|
1289
|
+
step: Pt(U) ? 1 : "any",
|
|
1290
|
+
disabled: w,
|
|
1206
1291
|
value: l,
|
|
1207
1292
|
placeholder: "0",
|
|
1208
1293
|
"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:
|
|
1294
|
+
onFocus: h,
|
|
1295
|
+
onChange: (f) => le((p) => ({ ...p, [e]: f.target.value })),
|
|
1296
|
+
onBlur: (f) => {
|
|
1297
|
+
const p = f.target.value, S = _s(p, U);
|
|
1298
|
+
if (S) {
|
|
1299
|
+
le((q) => {
|
|
1300
|
+
const E = { ...q };
|
|
1301
|
+
return delete E[e], E;
|
|
1302
|
+
}), de((q) => ({
|
|
1303
|
+
...q,
|
|
1304
|
+
[e]: { kind: "error", message: $s(S, p) }
|
|
1220
1305
|
}));
|
|
1221
1306
|
return;
|
|
1222
1307
|
}
|
|
1223
|
-
|
|
1224
|
-
const
|
|
1225
|
-
return delete
|
|
1226
|
-
}),
|
|
1308
|
+
le((q) => {
|
|
1309
|
+
const E = { ...q };
|
|
1310
|
+
return delete E[e], E;
|
|
1311
|
+
}), lt(e, p, t);
|
|
1227
1312
|
},
|
|
1228
|
-
onKeyDown: (
|
|
1229
|
-
|
|
1313
|
+
onKeyDown: (f) => {
|
|
1314
|
+
f.key === "Enter" && f.currentTarget.blur();
|
|
1230
1315
|
},
|
|
1231
|
-
className:
|
|
1316
|
+
className: I(
|
|
1232
1317
|
"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
1318
|
(o == null ? void 0 : o.kind) === "error" && "border-red-400 dark:border-red-600"
|
|
1234
1319
|
)
|
|
@@ -1243,9 +1328,9 @@ function Gs({
|
|
|
1243
1328
|
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
1329
|
"data-catalog-qty-error": !0,
|
|
1245
1330
|
children: [
|
|
1246
|
-
/* @__PURE__ */
|
|
1331
|
+
/* @__PURE__ */ a(dn, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1247
1332
|
o.message,
|
|
1248
|
-
|
|
1333
|
+
n && n > 0 ? ` — still ${n.toLocaleString("en-US")}` : ""
|
|
1249
1334
|
]
|
|
1250
1335
|
}
|
|
1251
1336
|
),
|
|
@@ -1256,23 +1341,23 @@ function Gs({
|
|
|
1256
1341
|
"data-catalog-qty-remove": !0,
|
|
1257
1342
|
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
1343
|
children: [
|
|
1259
|
-
/* @__PURE__ */
|
|
1260
|
-
/* @__PURE__ */
|
|
1344
|
+
/* @__PURE__ */ a("span", { children: "Remove this line?" }),
|
|
1345
|
+
/* @__PURE__ */ a(
|
|
1261
1346
|
"button",
|
|
1262
1347
|
{
|
|
1263
1348
|
type: "button",
|
|
1264
|
-
onClick:
|
|
1349
|
+
onClick: h,
|
|
1265
1350
|
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
1351
|
children: "Keep"
|
|
1267
1352
|
}
|
|
1268
1353
|
),
|
|
1269
|
-
/* @__PURE__ */
|
|
1354
|
+
/* @__PURE__ */ a(
|
|
1270
1355
|
"button",
|
|
1271
1356
|
{
|
|
1272
1357
|
type: "button",
|
|
1273
1358
|
onClick: () => {
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1359
|
+
const f = o.row;
|
|
1360
|
+
h(), lt(e, "0", f, { confirmedRemove: !0 });
|
|
1276
1361
|
},
|
|
1277
1362
|
className: "h-6 rounded bg-red-600 px-2 text-[11px] font-medium text-white hover:bg-red-700",
|
|
1278
1363
|
children: "Remove"
|
|
@@ -1282,42 +1367,42 @@ function Gs({
|
|
|
1282
1367
|
}
|
|
1283
1368
|
)
|
|
1284
1369
|
] });
|
|
1285
|
-
},
|
|
1286
|
-
const
|
|
1287
|
-
if (!(
|
|
1288
|
-
const
|
|
1289
|
-
return delete
|
|
1290
|
-
}),
|
|
1370
|
+
}, Mr = (e, t, n) => {
|
|
1371
|
+
const r = `${e}:${t}`, l = he[r], o = () => Ee((p) => {
|
|
1372
|
+
if (!(r in p)) return p;
|
|
1373
|
+
const S = { ...p };
|
|
1374
|
+
return delete S[r], S;
|
|
1375
|
+
}), h = n[t] == null ? "" : String(n[t]), c = te.find((p) => p.field === t), f = !Pt(c == null ? void 0 : c.type);
|
|
1291
1376
|
return /* @__PURE__ */ u("span", { className: "inline-flex shrink-0 flex-col items-end", children: [
|
|
1292
|
-
/* @__PURE__ */
|
|
1377
|
+
/* @__PURE__ */ a(
|
|
1293
1378
|
"input",
|
|
1294
1379
|
{
|
|
1295
1380
|
type: "number",
|
|
1296
1381
|
min: 0,
|
|
1297
|
-
step:
|
|
1298
|
-
defaultValue:
|
|
1382
|
+
step: f ? "0.01" : "any",
|
|
1383
|
+
defaultValue: h,
|
|
1299
1384
|
"aria-invalid": !!l || void 0,
|
|
1300
1385
|
onFocus: o,
|
|
1301
|
-
onBlur: (
|
|
1302
|
-
const
|
|
1303
|
-
if (
|
|
1304
|
-
const
|
|
1305
|
-
if (
|
|
1306
|
-
|
|
1386
|
+
onBlur: (p) => {
|
|
1387
|
+
const S = p.target.value;
|
|
1388
|
+
if (S !== h) {
|
|
1389
|
+
const q = c, E = (q == null ? void 0 : q.label) || D(t), y = hn(S, { type: q == null ? void 0 : q.type, label: E }), K = y.ok ? (f ? ps(S, E) : null) ?? M(t, y.value, n) : y.message;
|
|
1390
|
+
if (K) {
|
|
1391
|
+
p.target.value = h, Ee((Re) => ({ ...Re, [r]: K }));
|
|
1307
1392
|
return;
|
|
1308
1393
|
}
|
|
1309
1394
|
}
|
|
1310
|
-
|
|
1395
|
+
Vr(e, t, S);
|
|
1311
1396
|
},
|
|
1312
|
-
onKeyDown: (
|
|
1313
|
-
|
|
1397
|
+
onKeyDown: (p) => {
|
|
1398
|
+
p.key === "Enter" && p.currentTarget.blur();
|
|
1314
1399
|
},
|
|
1315
|
-
className:
|
|
1400
|
+
className: I(
|
|
1316
1401
|
"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
1402
|
l && "border-red-400 dark:border-red-600"
|
|
1318
1403
|
)
|
|
1319
1404
|
},
|
|
1320
|
-
`${
|
|
1405
|
+
`${r}:${h}`
|
|
1321
1406
|
),
|
|
1322
1407
|
l && /* @__PURE__ */ u(
|
|
1323
1408
|
"span",
|
|
@@ -1326,58 +1411,58 @@ function Gs({
|
|
|
1326
1411
|
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
1412
|
"data-catalog-cell-error": !0,
|
|
1328
1413
|
children: [
|
|
1329
|
-
/* @__PURE__ */
|
|
1414
|
+
/* @__PURE__ */ a(dn, { className: "mt-px h-3 w-3 shrink-0" }),
|
|
1330
1415
|
l,
|
|
1331
|
-
|
|
1416
|
+
h !== "" ? ` — still ${h}` : ""
|
|
1332
1417
|
]
|
|
1333
1418
|
}
|
|
1334
1419
|
)
|
|
1335
|
-
] },
|
|
1420
|
+
] }, r);
|
|
1336
1421
|
};
|
|
1337
|
-
return !g &&
|
|
1338
|
-
/* @__PURE__ */
|
|
1339
|
-
/* @__PURE__ */
|
|
1340
|
-
] }) : g ? /* @__PURE__ */ u("div", { ref:
|
|
1341
|
-
!
|
|
1422
|
+
return !g && W ? /* @__PURE__ */ u("div", { className: "space-y-2 py-1", "aria-busy": "true", children: [
|
|
1423
|
+
/* @__PURE__ */ a("div", { className: "h-8 w-full animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" }),
|
|
1424
|
+
/* @__PURE__ */ a("div", { className: "h-8 w-2/3 animate-pulse rounded bg-slate-100 dark:bg-[hsl(var(--nvr-skeleton))]" })
|
|
1425
|
+
] }) : g ? /* @__PURE__ */ u("div", { ref: Jn, className: "space-y-3", children: [
|
|
1426
|
+
!w && /* @__PURE__ */ u(_e, { children: [
|
|
1342
1427
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1343
1428
|
/* @__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__ */
|
|
1429
|
+
/* @__PURE__ */ a(Et, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
1430
|
+
/* @__PURE__ */ a(
|
|
1346
1431
|
"input",
|
|
1347
1432
|
{
|
|
1348
|
-
value:
|
|
1349
|
-
onChange: (e) =>
|
|
1433
|
+
value: X,
|
|
1434
|
+
onChange: (e) => ge(e.target.value),
|
|
1350
1435
|
placeholder: "Search catalog…",
|
|
1351
1436
|
className: "w-full bg-transparent text-[12px] outline-none placeholder:text-slate-400"
|
|
1352
1437
|
}
|
|
1353
1438
|
),
|
|
1354
|
-
|
|
1439
|
+
se && /* @__PURE__ */ u(
|
|
1355
1440
|
"button",
|
|
1356
1441
|
{
|
|
1357
1442
|
type: "button",
|
|
1358
|
-
"aria-pressed":
|
|
1359
|
-
"aria-disabled":
|
|
1443
|
+
"aria-pressed": ae,
|
|
1444
|
+
"aria-disabled": Te === null ? "true" : void 0,
|
|
1360
1445
|
onClick: () => {
|
|
1361
|
-
|
|
1446
|
+
Te !== null && Vt(!$n);
|
|
1362
1447
|
},
|
|
1363
|
-
"data-catalog-in-stock":
|
|
1364
|
-
"data-tip":
|
|
1365
|
-
className:
|
|
1448
|
+
"data-catalog-in-stock": ae ? "on" : "off",
|
|
1449
|
+
"data-tip": Te === 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",
|
|
1450
|
+
className: I(
|
|
1366
1451
|
"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
|
-
|
|
1452
|
+
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
1453
|
),
|
|
1369
1454
|
children: [
|
|
1370
|
-
|
|
1455
|
+
vr ? /* @__PURE__ */ a(ce, { className: "h-3 w-3 shrink-0 animate-spin" }) : /* @__PURE__ */ a(Dr, { className: "h-3 w-3 shrink-0" }),
|
|
1371
1456
|
/* @__PURE__ */ u("span", { className: "truncate", children: [
|
|
1372
1457
|
"In stock",
|
|
1373
|
-
|
|
1458
|
+
Te !== null && Je && qn != null && /* @__PURE__ */ u(_e, { children: [
|
|
1374
1459
|
" at ",
|
|
1375
|
-
/* @__PURE__ */
|
|
1376
|
-
|
|
1460
|
+
/* @__PURE__ */ a(
|
|
1461
|
+
Es,
|
|
1377
1462
|
{
|
|
1378
|
-
parentCollection:
|
|
1463
|
+
parentCollection: x,
|
|
1379
1464
|
field: Je,
|
|
1380
|
-
id:
|
|
1465
|
+
id: qn
|
|
1381
1466
|
}
|
|
1382
1467
|
)
|
|
1383
1468
|
] })
|
|
@@ -1385,117 +1470,117 @@ function Gs({
|
|
|
1385
1470
|
]
|
|
1386
1471
|
}
|
|
1387
1472
|
),
|
|
1388
|
-
|
|
1473
|
+
se && Te === null && /* @__PURE__ */ a("span", { className: "shrink-0 text-[11px] text-slate-500 dark:text-slate-400", children: "Pick a place first" }),
|
|
1389
1474
|
/* @__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
|
-
|
|
1475
|
+
Ur,
|
|
1391
1476
|
" picked"
|
|
1392
1477
|
] }),
|
|
1393
|
-
/* @__PURE__ */
|
|
1478
|
+
/* @__PURE__ */ a(cn, { show: Le.customized, onReset: Le.reset })
|
|
1394
1479
|
] }),
|
|
1395
|
-
|
|
1480
|
+
Kn && // Sticky: the catalog list is tall and the page scroller carries it —
|
|
1396
1481
|
// without this the labels scroll away and favorites/section rows
|
|
1397
1482
|
// read as headerless columns. Opaque bg (not the /60 tint) so rows
|
|
1398
1483
|
// never bleed through while pinned.
|
|
1399
1484
|
/* @__PURE__ */ u(
|
|
1400
1485
|
"div",
|
|
1401
1486
|
{
|
|
1402
|
-
ref:
|
|
1487
|
+
ref: Er,
|
|
1403
1488
|
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
1489
|
children: [
|
|
1405
|
-
|
|
1406
|
-
$t(
|
|
1407
|
-
|
|
1408
|
-
const [t,
|
|
1490
|
+
s.favorites && /* @__PURE__ */ a("span", { className: "w-[18px] shrink-0" }),
|
|
1491
|
+
$t(Le, "item", "Item", "w-36 shrink-0"),
|
|
1492
|
+
St.map((e) => {
|
|
1493
|
+
const [t, n] = In(e);
|
|
1409
1494
|
return $t(
|
|
1410
|
-
|
|
1495
|
+
Le,
|
|
1411
1496
|
e.field,
|
|
1412
|
-
e.label ??
|
|
1497
|
+
e.label ?? D(e.field.split(".")[0]),
|
|
1413
1498
|
t,
|
|
1414
|
-
|
|
1499
|
+
n
|
|
1415
1500
|
);
|
|
1416
1501
|
}),
|
|
1417
|
-
|
|
1502
|
+
sn.map(
|
|
1418
1503
|
(e) => $t(
|
|
1419
|
-
|
|
1504
|
+
Le,
|
|
1420
1505
|
`rel:${e.key}`,
|
|
1421
|
-
e.label ??
|
|
1506
|
+
e.label ?? D(e.key),
|
|
1422
1507
|
"w-20 shrink-0",
|
|
1423
1508
|
"text-right"
|
|
1424
1509
|
)
|
|
1425
1510
|
),
|
|
1426
|
-
/* @__PURE__ */
|
|
1427
|
-
/* @__PURE__ */
|
|
1428
|
-
/* @__PURE__ */
|
|
1511
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: "ml-auto" }),
|
|
1512
|
+
/* @__PURE__ */ a("span", { "aria-hidden": !0, className: "w-3.5 shrink-0" }),
|
|
1513
|
+
/* @__PURE__ */ a("span", { className: "w-20 shrink-0 text-right", children: "Qty" })
|
|
1429
1514
|
]
|
|
1430
1515
|
}
|
|
1431
1516
|
),
|
|
1432
|
-
|
|
1433
|
-
/* @__PURE__ */
|
|
1517
|
+
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: [
|
|
1518
|
+
/* @__PURE__ */ a(ce, { className: "h-3.5 w-3.5 animate-spin" }),
|
|
1434
1519
|
" Searching the catalog…"
|
|
1435
1520
|
] }),
|
|
1436
|
-
|
|
1521
|
+
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(_e, { children: [
|
|
1437
1522
|
'Nothing in stock matches "',
|
|
1438
|
-
|
|
1523
|
+
X.trim(),
|
|
1439
1524
|
'" —',
|
|
1440
1525
|
" ",
|
|
1441
1526
|
/* @__PURE__ */ u(
|
|
1442
1527
|
"button",
|
|
1443
1528
|
{
|
|
1444
1529
|
type: "button",
|
|
1445
|
-
onClick: () =>
|
|
1530
|
+
onClick: () => Vt(!1),
|
|
1446
1531
|
className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
1447
1532
|
children: [
|
|
1448
1533
|
"show ",
|
|
1449
|
-
|
|
1534
|
+
Ve.length,
|
|
1450
1535
|
" out of stock"
|
|
1451
1536
|
]
|
|
1452
1537
|
}
|
|
1453
1538
|
)
|
|
1454
|
-
] }) : /* @__PURE__ */ u(
|
|
1539
|
+
] }) : /* @__PURE__ */ u(_e, { children: [
|
|
1455
1540
|
'No items match "',
|
|
1456
|
-
|
|
1541
|
+
X.trim(),
|
|
1457
1542
|
'"'
|
|
1458
1543
|
] }) }),
|
|
1459
|
-
|
|
1544
|
+
X.trim().length > 0 && it.length > 0 && /* @__PURE__ */ u(ot, { children: [
|
|
1460
1545
|
/* @__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__ */
|
|
1546
|
+
/* @__PURE__ */ a(Et, { className: "h-3 w-3 shrink-0 text-sky-500" }),
|
|
1547
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Search results" }),
|
|
1548
|
+
/* @__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
1549
|
/* @__PURE__ */ u("span", { className: "text-[11px] text-slate-500 dark:text-slate-400", children: [
|
|
1465
1550
|
"across the entire catalog",
|
|
1466
|
-
|
|
1551
|
+
ae ? ", in stock only" : "",
|
|
1467
1552
|
" — enter a quantity to add"
|
|
1468
1553
|
] }),
|
|
1469
|
-
|
|
1554
|
+
Gt && /* @__PURE__ */ a(ce, { className: "h-3 w-3 shrink-0 animate-spin text-slate-400" })
|
|
1470
1555
|
] }),
|
|
1471
|
-
|
|
1472
|
-
const
|
|
1556
|
+
it.map((e, t) => {
|
|
1557
|
+
const n = String(e.id), r = Se(n);
|
|
1473
1558
|
return /* @__PURE__ */ u(
|
|
1474
1559
|
"div",
|
|
1475
1560
|
{
|
|
1476
|
-
className:
|
|
1561
|
+
className: I(
|
|
1477
1562
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1478
1563
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1479
|
-
(
|
|
1564
|
+
(r ?? 0) > 0 && "bg-nvr-cyan/5"
|
|
1480
1565
|
),
|
|
1481
1566
|
children: [
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
ze(
|
|
1567
|
+
Qt(n),
|
|
1568
|
+
on(
|
|
1569
|
+
n,
|
|
1570
|
+
ze(z, e),
|
|
1486
1571
|
(() => {
|
|
1487
|
-
const l =
|
|
1488
|
-
return !l && !o ? null : /* @__PURE__ */ u(
|
|
1489
|
-
o && /* @__PURE__ */
|
|
1572
|
+
const l = Nr(e), o = yr.has(n);
|
|
1573
|
+
return !l && !o ? null : /* @__PURE__ */ u(_e, { children: [
|
|
1574
|
+
o && /* @__PURE__ */ a(
|
|
1490
1575
|
"span",
|
|
1491
1576
|
{
|
|
1492
1577
|
"data-catalog-recent": !0,
|
|
1493
|
-
"data-tip": `You added this in the last ${
|
|
1578
|
+
"data-tip": `You added this in the last ${kt} days`,
|
|
1494
1579
|
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
1580
|
children: "Recent"
|
|
1496
1581
|
}
|
|
1497
1582
|
),
|
|
1498
|
-
l && /* @__PURE__ */
|
|
1583
|
+
l && /* @__PURE__ */ a(
|
|
1499
1584
|
"span",
|
|
1500
1585
|
{
|
|
1501
1586
|
"data-catalog-match-why": !0,
|
|
@@ -1507,611 +1592,612 @@ function Gs({
|
|
|
1507
1592
|
)
|
|
1508
1593
|
] });
|
|
1509
1594
|
})(),
|
|
1510
|
-
|
|
1595
|
+
ue
|
|
1511
1596
|
),
|
|
1512
|
-
|
|
1513
|
-
/* @__PURE__ */
|
|
1514
|
-
|
|
1597
|
+
ln(n, e, ue),
|
|
1598
|
+
/* @__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" }) }),
|
|
1599
|
+
Rt(n, e)
|
|
1515
1600
|
]
|
|
1516
1601
|
},
|
|
1517
|
-
|
|
1602
|
+
n
|
|
1518
1603
|
);
|
|
1519
1604
|
})
|
|
1520
1605
|
] }),
|
|
1521
|
-
|
|
1606
|
+
ee.length > 0 && !X.trim() && /* @__PURE__ */ u("p", { className: "px-3 py-6 text-center text-slate-400", children: [
|
|
1522
1607
|
"Search the full catalog above, or select",
|
|
1523
1608
|
" ",
|
|
1524
|
-
|
|
1609
|
+
ee.map((e) => {
|
|
1525
1610
|
var t;
|
|
1526
|
-
return ((t =
|
|
1611
|
+
return ((t = O == null ? void 0 : O.fieldLabels) == null ? void 0 : t[e]) ?? D(e);
|
|
1527
1612
|
}).join(", "),
|
|
1528
1613
|
" ",
|
|
1529
1614
|
"to browse by category"
|
|
1530
1615
|
] }),
|
|
1531
|
-
|
|
1532
|
-
/* @__PURE__ */
|
|
1616
|
+
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: [
|
|
1617
|
+
/* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin" }),
|
|
1533
1618
|
" Loading catalog…"
|
|
1534
1619
|
] }),
|
|
1535
|
-
|
|
1620
|
+
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(_e, { children: [
|
|
1536
1621
|
"Nothing in this catalog is in stock here —",
|
|
1537
1622
|
" ",
|
|
1538
1623
|
/* @__PURE__ */ u(
|
|
1539
1624
|
"button",
|
|
1540
1625
|
{
|
|
1541
1626
|
type: "button",
|
|
1542
|
-
onClick: () =>
|
|
1627
|
+
onClick: () => Vt(!1),
|
|
1543
1628
|
className: "font-medium text-[#00728d] underline-offset-2 hover:underline dark:text-nvr-cyan",
|
|
1544
1629
|
children: [
|
|
1545
1630
|
"show all ",
|
|
1546
|
-
|
|
1631
|
+
re.length
|
|
1547
1632
|
]
|
|
1548
1633
|
}
|
|
1549
1634
|
)
|
|
1550
1635
|
] }) : "No catalog items" }),
|
|
1551
|
-
|
|
1636
|
+
s.favorites && /* @__PURE__ */ u(ot, { children: [
|
|
1552
1637
|
/* @__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
1638
|
/* @__PURE__ */ u(
|
|
1554
1639
|
"button",
|
|
1555
1640
|
{
|
|
1556
1641
|
type: "button",
|
|
1557
|
-
onClick: () =>
|
|
1642
|
+
onClick: () => $e((e) => {
|
|
1558
1643
|
const t = new Set(e);
|
|
1559
1644
|
return t.has("__favorites__") ? t.delete("__favorites__") : t.add("__favorites__"), t;
|
|
1560
1645
|
}),
|
|
1561
1646
|
className: "flex min-w-0 flex-1 items-center gap-1.5 py-0.5 text-left",
|
|
1562
1647
|
children: [
|
|
1563
|
-
/* @__PURE__ */
|
|
1564
|
-
|
|
1648
|
+
/* @__PURE__ */ a(
|
|
1649
|
+
mn,
|
|
1565
1650
|
{
|
|
1566
|
-
className:
|
|
1651
|
+
className: I(
|
|
1567
1652
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1568
|
-
!
|
|
1653
|
+
!fe.has("__favorites__") && "rotate-90"
|
|
1569
1654
|
)
|
|
1570
1655
|
}
|
|
1571
1656
|
),
|
|
1572
|
-
/* @__PURE__ */
|
|
1573
|
-
/* @__PURE__ */
|
|
1574
|
-
/* @__PURE__ */
|
|
1657
|
+
/* @__PURE__ */ a(dt, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
1658
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Favorites" }),
|
|
1659
|
+
/* @__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
1660
|
]
|
|
1576
1661
|
}
|
|
1577
1662
|
),
|
|
1578
|
-
/* @__PURE__ */
|
|
1663
|
+
/* @__PURE__ */ a(
|
|
1579
1664
|
"button",
|
|
1580
1665
|
{
|
|
1581
|
-
ref:
|
|
1666
|
+
ref: vn,
|
|
1582
1667
|
type: "button",
|
|
1583
|
-
onClick: () =>
|
|
1668
|
+
onClick: () => Nn(!0),
|
|
1584
1669
|
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
1670
|
children: "Manage"
|
|
1586
1671
|
}
|
|
1587
1672
|
)
|
|
1588
1673
|
] }),
|
|
1589
|
-
!
|
|
1590
|
-
!
|
|
1591
|
-
const
|
|
1674
|
+
!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." }),
|
|
1675
|
+
!fe.has("__favorites__") && Xt.map((e, t) => {
|
|
1676
|
+
const n = String(e.id), r = Se(n), l = en(n);
|
|
1592
1677
|
return /* @__PURE__ */ u(
|
|
1593
1678
|
"div",
|
|
1594
1679
|
{
|
|
1595
|
-
className:
|
|
1680
|
+
className: I(
|
|
1596
1681
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1597
1682
|
t % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1598
|
-
(
|
|
1683
|
+
(r ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1599
1684
|
l && "bg-amber-50 dark:bg-amber-900/15"
|
|
1600
1685
|
),
|
|
1601
1686
|
children: [
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
/* @__PURE__ */
|
|
1606
|
-
|
|
1687
|
+
Qt(n),
|
|
1688
|
+
on(n, ze(z, e)),
|
|
1689
|
+
ln(n, e),
|
|
1690
|
+
/* @__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(
|
|
1691
|
+
Be,
|
|
1607
1692
|
{
|
|
1608
1693
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1609
|
-
"aria-label": `${
|
|
1694
|
+
"aria-label": `${tn} ${l.available} — ${l.qty} requested`
|
|
1610
1695
|
}
|
|
1611
1696
|
) }),
|
|
1612
|
-
|
|
1697
|
+
Rt(n, e)
|
|
1613
1698
|
]
|
|
1614
1699
|
},
|
|
1615
|
-
|
|
1700
|
+
n
|
|
1616
1701
|
);
|
|
1617
1702
|
})
|
|
1618
1703
|
] }),
|
|
1619
|
-
|
|
1620
|
-
const t =
|
|
1621
|
-
(
|
|
1704
|
+
ee.length === 0 && Ft.map((e) => {
|
|
1705
|
+
const t = fe.has(e.name), n = e.items.reduce(
|
|
1706
|
+
(r, l) => r + ((Se(l.id) ?? 0) > 0 ? 1 : 0),
|
|
1622
1707
|
0
|
|
1623
1708
|
);
|
|
1624
|
-
return /* @__PURE__ */ u(
|
|
1709
|
+
return /* @__PURE__ */ u(ot, { children: [
|
|
1625
1710
|
/* @__PURE__ */ u(
|
|
1626
1711
|
"button",
|
|
1627
1712
|
{
|
|
1628
1713
|
type: "button",
|
|
1629
|
-
onClick: () =>
|
|
1630
|
-
const l = new Set(
|
|
1714
|
+
onClick: () => $e((r) => {
|
|
1715
|
+
const l = new Set(r);
|
|
1631
1716
|
return l.has(e.name) ? l.delete(e.name) : l.add(e.name), l;
|
|
1632
1717
|
}),
|
|
1633
1718
|
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
1719
|
children: [
|
|
1635
|
-
/* @__PURE__ */
|
|
1636
|
-
|
|
1720
|
+
/* @__PURE__ */ a(
|
|
1721
|
+
mn,
|
|
1637
1722
|
{
|
|
1638
|
-
className:
|
|
1723
|
+
className: I(
|
|
1639
1724
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
1640
1725
|
!t && "rotate-90"
|
|
1641
1726
|
)
|
|
1642
1727
|
}
|
|
1643
1728
|
),
|
|
1644
|
-
/* @__PURE__ */
|
|
1645
|
-
/* @__PURE__ */
|
|
1646
|
-
|
|
1647
|
-
|
|
1729
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: e.name }),
|
|
1730
|
+
/* @__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 }),
|
|
1731
|
+
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: [
|
|
1732
|
+
n,
|
|
1648
1733
|
" picked"
|
|
1649
1734
|
] })
|
|
1650
1735
|
]
|
|
1651
1736
|
}
|
|
1652
1737
|
),
|
|
1653
|
-
!t && e.items.map((
|
|
1654
|
-
const o =
|
|
1738
|
+
!t && e.items.map((r, l) => {
|
|
1739
|
+
const o = Se(r.id), h = en(r.id);
|
|
1655
1740
|
return /* @__PURE__ */ u(
|
|
1656
1741
|
"div",
|
|
1657
1742
|
{
|
|
1658
|
-
className:
|
|
1743
|
+
className: I(
|
|
1659
1744
|
"flex items-center gap-4 border-b border-slate-100 px-3 py-1 dark:border-border/50",
|
|
1660
1745
|
l % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1661
1746
|
(o ?? 0) > 0 && "bg-nvr-cyan/5",
|
|
1662
|
-
|
|
1747
|
+
h && "bg-amber-50 dark:bg-amber-900/15"
|
|
1663
1748
|
),
|
|
1664
1749
|
children: [
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
/* @__PURE__ */
|
|
1669
|
-
|
|
1750
|
+
Qt(r.id),
|
|
1751
|
+
on(r.id, r.label),
|
|
1752
|
+
ln(r.id, r.row),
|
|
1753
|
+
/* @__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(
|
|
1754
|
+
Be,
|
|
1670
1755
|
{
|
|
1671
1756
|
className: "h-3.5 w-3.5 text-amber-500",
|
|
1672
|
-
"aria-label": `${
|
|
1757
|
+
"aria-label": `${tn} ${h.available} — ${h.qty} requested`
|
|
1673
1758
|
}
|
|
1674
1759
|
) }),
|
|
1675
|
-
|
|
1760
|
+
Rt(r.id, r.row)
|
|
1676
1761
|
]
|
|
1677
1762
|
},
|
|
1678
|
-
|
|
1763
|
+
r.id
|
|
1679
1764
|
);
|
|
1680
1765
|
})
|
|
1681
1766
|
] }, e.name);
|
|
1682
1767
|
})
|
|
1683
1768
|
] }),
|
|
1684
|
-
(
|
|
1685
|
-
|
|
1769
|
+
(s.builders ?? []).filter((e) => ir(e.show_when, N)).map((e) => /* @__PURE__ */ a(
|
|
1770
|
+
Ps,
|
|
1686
1771
|
{
|
|
1687
1772
|
builder: e,
|
|
1688
|
-
defaultItemField:
|
|
1773
|
+
defaultItemField: s.item_field,
|
|
1689
1774
|
catalogCol: g,
|
|
1690
|
-
catalogFields:
|
|
1691
|
-
tmpl:
|
|
1692
|
-
currentQty:
|
|
1693
|
-
addQty: (t,
|
|
1694
|
-
qtyStep:
|
|
1695
|
-
readOnly:
|
|
1775
|
+
catalogFields: A,
|
|
1776
|
+
tmpl: z,
|
|
1777
|
+
currentQty: Se,
|
|
1778
|
+
addQty: (t, n, r) => lt(t, String(n), r),
|
|
1779
|
+
qtyStep: Pt(U) ? 1 : "any",
|
|
1780
|
+
readOnly: w
|
|
1696
1781
|
},
|
|
1697
1782
|
e.label
|
|
1698
1783
|
))
|
|
1699
1784
|
] }),
|
|
1700
1785
|
/* @__PURE__ */ u("div", { className: "rounded-lg border border-slate-200 text-[12px] dark:border-border", children: [
|
|
1701
1786
|
/* @__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
|
-
|
|
1787
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Summary" }),
|
|
1788
|
+
!w && /* @__PURE__ */ u("div", { className: "flex items-center gap-2", onClick: (e) => e.stopPropagation(), children: [
|
|
1789
|
+
s.upload_template && !P && ye && x && /* @__PURE__ */ a(
|
|
1790
|
+
ds,
|
|
1706
1791
|
{
|
|
1707
|
-
collection:
|
|
1792
|
+
collection: x,
|
|
1708
1793
|
templateFilter: (e) => {
|
|
1709
1794
|
var t;
|
|
1710
|
-
return e.name ===
|
|
1795
|
+
return e.name === s.upload_template && ((t = e.reimport) == null ? void 0 : t.enabled) === !0;
|
|
1711
1796
|
},
|
|
1712
1797
|
getLabel: (e) => {
|
|
1713
1798
|
var t;
|
|
1714
1799
|
return ((t = e.reimport) == null ? void 0 : t.button_label) ?? e.button_label;
|
|
1715
1800
|
},
|
|
1716
|
-
onParsed: (e, t) =>
|
|
1801
|
+
onParsed: (e, t) => ye(e, t),
|
|
1717
1802
|
compact: !0
|
|
1718
1803
|
}
|
|
1719
1804
|
),
|
|
1720
|
-
/* @__PURE__ */
|
|
1721
|
-
|
|
1805
|
+
/* @__PURE__ */ a("div", { className: "w-64", children: /* @__PURE__ */ a(
|
|
1806
|
+
ws,
|
|
1722
1807
|
{
|
|
1723
1808
|
collection: g,
|
|
1724
1809
|
value: null,
|
|
1725
|
-
onChange: (e) => void
|
|
1726
|
-
placeholder: "+ Add any item…"
|
|
1810
|
+
onChange: (e) => void Wr(e),
|
|
1811
|
+
placeholder: "+ Add any item…",
|
|
1812
|
+
displayTemplate: Ks(z, s.columns)
|
|
1727
1813
|
}
|
|
1728
1814
|
) })
|
|
1729
1815
|
] })
|
|
1730
1816
|
] }),
|
|
1731
|
-
|
|
1732
|
-
const e =
|
|
1733
|
-
|
|
1734
|
-
|
|
1817
|
+
be.length === 0 ? /* @__PURE__ */ a("p", { className: "px-3 py-4 text-center text-slate-400", children: "Nothing picked yet" }) : (() => {
|
|
1818
|
+
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(
|
|
1819
|
+
ve,
|
|
1820
|
+
f,
|
|
1735
1821
|
c,
|
|
1736
1822
|
"w-20 shrink-0",
|
|
1737
1823
|
"text-right text-[11px] font-medium text-slate-500 dark:text-slate-400"
|
|
1738
|
-
) : /* @__PURE__ */
|
|
1824
|
+
) : /* @__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
1825
|
return /* @__PURE__ */ u("div", { children: [
|
|
1740
1826
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-4 border-b border-slate-200 px-3 py-1.5 dark:border-border", children: [
|
|
1741
1827
|
/* @__PURE__ */ u("span", { className: "flex flex-1 items-center gap-1 text-[11px] font-medium text-slate-500 dark:text-slate-400", children: [
|
|
1742
1828
|
"Item",
|
|
1743
|
-
|
|
1744
|
-
|
|
1829
|
+
w && /* @__PURE__ */ a(
|
|
1830
|
+
cn,
|
|
1745
1831
|
{
|
|
1746
|
-
show:
|
|
1747
|
-
onReset:
|
|
1832
|
+
show: ve.customized,
|
|
1833
|
+
onReset: ve.reset,
|
|
1748
1834
|
className: "-my-1"
|
|
1749
1835
|
}
|
|
1750
1836
|
)
|
|
1751
1837
|
] }),
|
|
1752
|
-
|
|
1753
|
-
o(
|
|
1754
|
-
|
|
1755
|
-
!
|
|
1838
|
+
Tt.map((c) => /* @__PURE__ */ a(ot, { children: o(D(c), h(c)) }, c)),
|
|
1839
|
+
o(D(J)),
|
|
1840
|
+
Me.map((c) => /* @__PURE__ */ a(ot, { children: o(D(c), `s:${c}`) }, c)),
|
|
1841
|
+
!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
1842
|
] }),
|
|
1757
|
-
|
|
1758
|
-
const
|
|
1843
|
+
be.map((c, f) => {
|
|
1844
|
+
const p = c.row.id != null ? String(c.row.id) : null, S = p != null && bt.has(p), q = S ? null : en(c.key), E = S ? null : jr(c.key);
|
|
1759
1845
|
return /* @__PURE__ */ u(
|
|
1760
1846
|
"div",
|
|
1761
1847
|
{
|
|
1762
|
-
className:
|
|
1848
|
+
className: I(
|
|
1763
1849
|
"border-b border-slate-100 px-3 py-2 last:border-b-0 dark:border-border/50",
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1850
|
+
f % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30",
|
|
1851
|
+
q && "bg-amber-50 dark:bg-amber-900/15",
|
|
1852
|
+
E && "bg-red-50/70 dark:bg-red-900/15",
|
|
1853
|
+
S && "opacity-60"
|
|
1768
1854
|
),
|
|
1769
1855
|
children: [
|
|
1770
1856
|
/* @__PURE__ */ u(
|
|
1771
1857
|
"div",
|
|
1772
1858
|
{
|
|
1773
|
-
className:
|
|
1859
|
+
className: I(
|
|
1774
1860
|
"flex items-center gap-4",
|
|
1775
|
-
|
|
1861
|
+
S && "line-through decoration-slate-400"
|
|
1776
1862
|
),
|
|
1777
1863
|
children: [
|
|
1778
|
-
|
|
1864
|
+
zn(
|
|
1779
1865
|
c.key,
|
|
1780
|
-
|
|
1866
|
+
jt(c.key),
|
|
1781
1867
|
"shrink-0 font-semibold text-slate-800 dark:text-slate-100"
|
|
1782
1868
|
),
|
|
1783
|
-
|
|
1869
|
+
Ze && !S && (p == null || ft.has(p)) && /* @__PURE__ */ a(
|
|
1784
1870
|
"span",
|
|
1785
1871
|
{
|
|
1786
|
-
"data-catalog-staged":
|
|
1872
|
+
"data-catalog-staged": p == null ? "new" : "edited",
|
|
1787
1873
|
"data-tip": "Applies when you save the record",
|
|
1788
1874
|
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:
|
|
1875
|
+
children: p == null ? "New" : "Edited"
|
|
1790
1876
|
}
|
|
1791
1877
|
),
|
|
1792
|
-
|
|
1878
|
+
E && /* @__PURE__ */ a(
|
|
1793
1879
|
"span",
|
|
1794
1880
|
{
|
|
1795
1881
|
className: "shrink-0",
|
|
1796
1882
|
"data-tip": `This line was in the failed submission
|
|
1797
|
-
${
|
|
1883
|
+
${E}`,
|
|
1798
1884
|
"data-submission-error": !0,
|
|
1799
|
-
children: /* @__PURE__ */
|
|
1885
|
+
children: /* @__PURE__ */ a(dn, { className: "h-3.5 w-3.5 text-red-500", strokeWidth: 2 })
|
|
1800
1886
|
}
|
|
1801
1887
|
),
|
|
1802
|
-
t && /* @__PURE__ */
|
|
1803
|
-
|
|
1888
|
+
t && /* @__PURE__ */ a(
|
|
1889
|
+
lr,
|
|
1804
1890
|
{
|
|
1805
|
-
text:
|
|
1891
|
+
text: Ne(_t(Ie(c.key), t.field), void 0),
|
|
1806
1892
|
className: "min-w-0 flex-1 text-slate-600 dark:text-slate-300"
|
|
1807
1893
|
}
|
|
1808
1894
|
),
|
|
1809
|
-
!t && /* @__PURE__ */
|
|
1810
|
-
|
|
1811
|
-
const
|
|
1812
|
-
return
|
|
1895
|
+
!t && /* @__PURE__ */ a("span", { className: "flex-1" }),
|
|
1896
|
+
n.map((y) => {
|
|
1897
|
+
const K = _t(Ie(c.key), y.field);
|
|
1898
|
+
return K == null || K === "" ? null : /* @__PURE__ */ a(
|
|
1813
1899
|
"span",
|
|
1814
1900
|
{
|
|
1815
1901
|
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(
|
|
1902
|
+
children: String(K)
|
|
1817
1903
|
},
|
|
1818
|
-
|
|
1904
|
+
y.field
|
|
1819
1905
|
);
|
|
1820
1906
|
}),
|
|
1821
|
-
|
|
1822
|
-
(
|
|
1823
|
-
var
|
|
1824
|
-
return
|
|
1907
|
+
Tt.map(
|
|
1908
|
+
(y) => {
|
|
1909
|
+
var K;
|
|
1910
|
+
return zr(c.key, y) ? Mr(c.key, y, c.row) : /* @__PURE__ */ a(
|
|
1825
1911
|
"span",
|
|
1826
1912
|
{
|
|
1827
|
-
"data-catalog-locked": !
|
|
1828
|
-
"data-tip": !
|
|
1829
|
-
...
|
|
1830
|
-
`s:${
|
|
1913
|
+
"data-catalog-locked": !w && Z.includes(y) ? y : void 0,
|
|
1914
|
+
"data-tip": !w && Z.includes(y) ? "Set by the catalog — only an administrator can change it" : void 0,
|
|
1915
|
+
...ve.box(
|
|
1916
|
+
`s:${y}`,
|
|
1831
1917
|
"w-20 shrink-0",
|
|
1832
1918
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1833
1919
|
),
|
|
1834
|
-
children:
|
|
1920
|
+
children: Ne(c.row[y], (K = s.field_formats) == null ? void 0 : K[y])
|
|
1835
1921
|
},
|
|
1836
|
-
|
|
1922
|
+
y
|
|
1837
1923
|
);
|
|
1838
1924
|
}
|
|
1839
1925
|
),
|
|
1840
1926
|
/* @__PURE__ */ u("span", { className: "inline-flex w-20 shrink-0 items-center justify-end gap-1", children: [
|
|
1841
|
-
ie.has(c.key) && /* @__PURE__ */
|
|
1842
|
-
|
|
1927
|
+
ie.has(c.key) && /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" }),
|
|
1928
|
+
Rt(c.key, Ie(c.key))
|
|
1843
1929
|
] }),
|
|
1844
|
-
|
|
1845
|
-
var
|
|
1846
|
-
if (
|
|
1847
|
-
return /* @__PURE__ */
|
|
1930
|
+
Me.map((y) => {
|
|
1931
|
+
var er, tr;
|
|
1932
|
+
if (S)
|
|
1933
|
+
return /* @__PURE__ */ a(
|
|
1848
1934
|
"span",
|
|
1849
1935
|
{
|
|
1850
1936
|
"data-tip": "Not counted — this line is removed when you save",
|
|
1851
|
-
...
|
|
1852
|
-
`s:${
|
|
1937
|
+
...ve.box(
|
|
1938
|
+
`s:${y}`,
|
|
1853
1939
|
"w-20 shrink-0",
|
|
1854
1940
|
"text-right tabular-nums text-slate-400 dark:text-slate-500"
|
|
1855
1941
|
),
|
|
1856
1942
|
children: "—"
|
|
1857
1943
|
},
|
|
1858
|
-
|
|
1944
|
+
y
|
|
1859
1945
|
);
|
|
1860
|
-
const
|
|
1861
|
-
return /* @__PURE__ */
|
|
1946
|
+
const K = c.row[y], Re = K != null && K !== "" ? K : Pe(((er = s.compute_fields) == null ? void 0 : er[y]) ?? "", c.row);
|
|
1947
|
+
return /* @__PURE__ */ a(
|
|
1862
1948
|
"span",
|
|
1863
1949
|
{
|
|
1864
|
-
...
|
|
1865
|
-
`s:${
|
|
1950
|
+
...ve.box(
|
|
1951
|
+
`s:${y}`,
|
|
1866
1952
|
"w-20 shrink-0",
|
|
1867
1953
|
"truncate text-right tabular-nums text-slate-600 dark:text-slate-300"
|
|
1868
1954
|
),
|
|
1869
|
-
children:
|
|
1955
|
+
children: Ne(Re, (tr = s.field_formats) == null ? void 0 : tr[y])
|
|
1870
1956
|
},
|
|
1871
|
-
|
|
1957
|
+
y
|
|
1872
1958
|
);
|
|
1873
1959
|
}),
|
|
1874
|
-
!
|
|
1960
|
+
!w && S && /* @__PURE__ */ a(
|
|
1875
1961
|
"button",
|
|
1876
1962
|
{
|
|
1877
1963
|
type: "button",
|
|
1878
|
-
onClick: () =>
|
|
1964
|
+
onClick: () => v == null ? void 0 : v.cancelPendingDelete(i, m, p),
|
|
1879
1965
|
className: "shrink-0 rounded px-1.5 py-0.5 text-[11px] font-medium text-nvr-navy underline dark:text-nvr-cyan",
|
|
1880
1966
|
children: "Undo"
|
|
1881
1967
|
}
|
|
1882
1968
|
),
|
|
1883
|
-
!
|
|
1969
|
+
!w && !S && /* @__PURE__ */ a(
|
|
1884
1970
|
"button",
|
|
1885
1971
|
{
|
|
1886
1972
|
type: "button",
|
|
1887
1973
|
title: "Remove (applies on Save)",
|
|
1888
1974
|
onClick: () => {
|
|
1889
|
-
if (!
|
|
1890
|
-
|
|
1975
|
+
if (!P && v && p != null) {
|
|
1976
|
+
v.queueDelete(i, m, p);
|
|
1891
1977
|
return;
|
|
1892
1978
|
}
|
|
1893
|
-
|
|
1979
|
+
lt(c.key, "0", {}, { confirmedRemove: !0 });
|
|
1894
1980
|
},
|
|
1895
1981
|
className: "w-6 shrink-0 rounded p-0.5 text-slate-300 transition-colors hover:text-red-500",
|
|
1896
|
-
children: /* @__PURE__ */
|
|
1982
|
+
children: /* @__PURE__ */ a(Lt, { className: "mx-auto h-3.5 w-3.5" })
|
|
1897
1983
|
}
|
|
1898
1984
|
)
|
|
1899
1985
|
]
|
|
1900
1986
|
}
|
|
1901
1987
|
),
|
|
1902
|
-
(
|
|
1903
|
-
|
|
1904
|
-
/* @__PURE__ */
|
|
1988
|
+
(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: [
|
|
1989
|
+
r.map((y) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1990
|
+
/* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.field.split(".")[0]) }),
|
|
1905
1991
|
" ",
|
|
1906
|
-
/* @__PURE__ */
|
|
1907
|
-
] },
|
|
1908
|
-
|
|
1909
|
-
/* @__PURE__ */
|
|
1992
|
+
/* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(_t(Ie(c.key), y.field), y.format) })
|
|
1993
|
+
] }, y.field)),
|
|
1994
|
+
An.map((y) => /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1995
|
+
/* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.key) }),
|
|
1910
1996
|
" ",
|
|
1911
|
-
/* @__PURE__ */
|
|
1912
|
-
] },
|
|
1913
|
-
|
|
1914
|
-
|
|
1997
|
+
/* @__PURE__ */ a("span", { className: "font-medium tabular-nums text-slate-700 dark:text-slate-200", children: l(st(y.key, c.key), y.format) })
|
|
1998
|
+
] }, y.key)),
|
|
1999
|
+
Pr(c.row),
|
|
2000
|
+
Sr(c.row).map((y) => /* @__PURE__ */ u(
|
|
1915
2001
|
"span",
|
|
1916
2002
|
{
|
|
1917
2003
|
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":
|
|
2004
|
+
"data-catalog-row-flag": y,
|
|
1919
2005
|
children: [
|
|
1920
|
-
/* @__PURE__ */
|
|
1921
|
-
|
|
2006
|
+
/* @__PURE__ */ a(Be, { className: "h-3 w-3" }),
|
|
2007
|
+
y
|
|
1922
2008
|
]
|
|
1923
2009
|
},
|
|
1924
|
-
|
|
2010
|
+
y
|
|
1925
2011
|
)),
|
|
1926
|
-
vt.map((
|
|
1927
|
-
const
|
|
2012
|
+
vt.map((y) => {
|
|
2013
|
+
const K = Tr(y, c);
|
|
1928
2014
|
return /* @__PURE__ */ u("span", { className: "whitespace-nowrap", children: [
|
|
1929
|
-
/* @__PURE__ */
|
|
2015
|
+
/* @__PURE__ */ a("span", { className: "text-slate-500 dark:text-muted-foreground", children: y.label ?? D(y.field) }),
|
|
1930
2016
|
" ",
|
|
1931
|
-
/* @__PURE__ */
|
|
1932
|
-
] },
|
|
2017
|
+
/* @__PURE__ */ a("span", { className: "font-medium text-slate-700 dark:text-slate-200", children: l(K, y.format) })
|
|
2018
|
+
] }, y.field);
|
|
1933
2019
|
})
|
|
1934
2020
|
] }),
|
|
1935
|
-
|
|
1936
|
-
/* @__PURE__ */
|
|
1937
|
-
|
|
2021
|
+
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: [
|
|
2022
|
+
/* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
|
|
2023
|
+
tn,
|
|
1938
2024
|
" is ",
|
|
1939
|
-
|
|
2025
|
+
Ne(q.available, "number"),
|
|
1940
2026
|
" —",
|
|
1941
2027
|
" ",
|
|
1942
|
-
|
|
2028
|
+
Ne(q.qty, "number"),
|
|
1943
2029
|
" requested"
|
|
1944
2030
|
] }),
|
|
1945
|
-
!
|
|
2031
|
+
!S && Rs(
|
|
1946
2032
|
{
|
|
1947
2033
|
...c.row,
|
|
1948
2034
|
...Object.fromEntries(
|
|
1949
|
-
|
|
1950
|
-
var
|
|
2035
|
+
Me.filter((y) => c.row[y] == null || c.row[y] === "").map((y) => {
|
|
2036
|
+
var K;
|
|
1951
2037
|
return [
|
|
1952
|
-
|
|
1953
|
-
|
|
2038
|
+
y,
|
|
2039
|
+
Pe(((K = s.compute_fields) == null ? void 0 : K[y]) ?? "", c.row)
|
|
1954
2040
|
];
|
|
1955
2041
|
})
|
|
1956
2042
|
)
|
|
1957
2043
|
},
|
|
1958
|
-
|
|
1959
|
-
|
|
2044
|
+
J,
|
|
2045
|
+
Me.length > 0 ? Me : Tt
|
|
1960
2046
|
) && /* @__PURE__ */ u(
|
|
1961
2047
|
"p",
|
|
1962
2048
|
{
|
|
1963
2049
|
"data-catalog-unpriced": !0,
|
|
1964
2050
|
className: "mt-1 flex items-center gap-1 pl-0.5 text-[11px] font-medium text-amber-600 dark:text-amber-400",
|
|
1965
2051
|
children: [
|
|
1966
|
-
/* @__PURE__ */
|
|
2052
|
+
/* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
|
|
1967
2053
|
"No catalog price: check the price or hand-price it"
|
|
1968
2054
|
]
|
|
1969
2055
|
}
|
|
1970
2056
|
),
|
|
1971
|
-
|
|
2057
|
+
S && /* @__PURE__ */ a("p", { className: "mt-1 pl-0.5 text-[11px] text-red-500", children: "Removed — applies when you save" })
|
|
1972
2058
|
]
|
|
1973
2059
|
},
|
|
1974
2060
|
c.key
|
|
1975
2061
|
);
|
|
1976
2062
|
}),
|
|
1977
2063
|
(() => {
|
|
1978
|
-
const c =
|
|
1979
|
-
const
|
|
1980
|
-
return !(
|
|
1981
|
-
}),
|
|
1982
|
-
c.map((
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
),
|
|
1986
|
-
var
|
|
1987
|
-
return ((
|
|
1988
|
-
},
|
|
2064
|
+
const c = be.filter((q) => {
|
|
2065
|
+
const E = q.row.id != null ? String(q.row.id) : null;
|
|
2066
|
+
return !(E != null && bt.has(E));
|
|
2067
|
+
}), f = (q) => qs(
|
|
2068
|
+
c.map((E) => E.row),
|
|
2069
|
+
q,
|
|
2070
|
+
s.compute_fields
|
|
2071
|
+
), p = (q) => {
|
|
2072
|
+
var E;
|
|
2073
|
+
return ((E = s.field_formats) == null ? void 0 : E[q]) ?? "number";
|
|
2074
|
+
}, S = (q) => /* @__PURE__ */ a(
|
|
1989
2075
|
"span",
|
|
1990
2076
|
{
|
|
1991
|
-
...
|
|
1992
|
-
`s:${
|
|
2077
|
+
...ve.box(
|
|
2078
|
+
`s:${q}`,
|
|
1993
2079
|
"w-20 shrink-0",
|
|
1994
2080
|
"truncate text-right text-[12px] font-semibold tabular-nums text-slate-800 dark:text-slate-100"
|
|
1995
2081
|
),
|
|
1996
|
-
children:
|
|
2082
|
+
children: Ne(f(q), p(q))
|
|
1997
2083
|
},
|
|
1998
|
-
|
|
2084
|
+
q
|
|
1999
2085
|
);
|
|
2000
2086
|
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
|
|
2087
|
+
/* @__PURE__ */ a("span", { className: "flex-1 text-[11px] font-semibold uppercase tracking-wide text-slate-500 dark:text-slate-400", children: "Total" }),
|
|
2088
|
+
Tt.map((q) => {
|
|
2089
|
+
const E = h(q);
|
|
2090
|
+
return E ? /* @__PURE__ */ a("span", { ...ve.box(E, "w-20 shrink-0") }, q) : /* @__PURE__ */ a("span", { className: "w-20 shrink-0" }, q);
|
|
2005
2091
|
}),
|
|
2006
|
-
/* @__PURE__ */
|
|
2007
|
-
|
|
2008
|
-
!
|
|
2092
|
+
/* @__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") }),
|
|
2093
|
+
Me.map(S),
|
|
2094
|
+
!w && /* @__PURE__ */ a("span", { className: "w-6 shrink-0" })
|
|
2009
2095
|
] });
|
|
2010
2096
|
})()
|
|
2011
2097
|
] });
|
|
2012
2098
|
})()
|
|
2013
2099
|
] }),
|
|
2014
|
-
|
|
2015
|
-
|
|
2100
|
+
br && g && /* @__PURE__ */ a(
|
|
2101
|
+
As,
|
|
2016
2102
|
{
|
|
2017
2103
|
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:
|
|
2104
|
+
tmpl: z,
|
|
2105
|
+
sectionBy: s.section_by,
|
|
2106
|
+
sectionM2M: d,
|
|
2107
|
+
pinnedSet: zt,
|
|
2108
|
+
pinnedIds: Oe,
|
|
2109
|
+
savingIds: yt,
|
|
2110
|
+
relatedCols: (s.favorites_manager_columns ?? []).map((e) => (s.related_columns ?? []).find((t) => t.key === e)).filter((e) => !!e),
|
|
2111
|
+
parentDraft: N,
|
|
2112
|
+
onToggle: (e) => void wn(e),
|
|
2113
|
+
onClose: () => Nn(!1),
|
|
2114
|
+
anchor: vn.current
|
|
2029
2115
|
}
|
|
2030
2116
|
)
|
|
2031
2117
|
] }) : /* @__PURE__ */ u("p", { className: "py-1 text-[12px] text-slate-400", children: [
|
|
2032
2118
|
'Catalog picker: field "',
|
|
2033
|
-
|
|
2119
|
+
s.item_field,
|
|
2034
2120
|
'" does not resolve to an M2O relation on',
|
|
2035
2121
|
" ",
|
|
2036
|
-
|
|
2122
|
+
i
|
|
2037
2123
|
] });
|
|
2038
2124
|
}
|
|
2039
|
-
function
|
|
2040
|
-
builder:
|
|
2041
|
-
defaultItemField:
|
|
2042
|
-
catalogCol:
|
|
2043
|
-
catalogFields:
|
|
2044
|
-
tmpl:
|
|
2045
|
-
currentQty:
|
|
2046
|
-
addQty:
|
|
2047
|
-
qtyStep:
|
|
2048
|
-
readOnly:
|
|
2125
|
+
function Ps({
|
|
2126
|
+
builder: i,
|
|
2127
|
+
defaultItemField: m,
|
|
2128
|
+
catalogCol: b,
|
|
2129
|
+
catalogFields: x,
|
|
2130
|
+
tmpl: _,
|
|
2131
|
+
currentQty: s,
|
|
2132
|
+
addQty: w,
|
|
2133
|
+
qtyStep: k,
|
|
2134
|
+
readOnly: j
|
|
2049
2135
|
}) {
|
|
2050
|
-
const
|
|
2136
|
+
const v = Kt(), O = i.item_field ?? m, [ye, Z] = Y(!1), [G, Ae] = Y({}), [P, qe] = Y("1"), [J, fe] = Y(!1), $e = F(
|
|
2051
2137
|
() => [
|
|
2052
2138
|
"id",
|
|
2053
|
-
|
|
2054
|
-
...
|
|
2139
|
+
O,
|
|
2140
|
+
...i.attributes.flatMap(($) => [`${$.field}.id`, `${$.field}.${$.label_field}`])
|
|
2055
2141
|
].join(","),
|
|
2056
|
-
[
|
|
2057
|
-
), { data:
|
|
2142
|
+
[O, i.attributes]
|
|
2143
|
+
), { data: je = [], isLoading: X } = C({
|
|
2058
2144
|
queryKey: [
|
|
2059
2145
|
"catalog-builder",
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
JSON.stringify(
|
|
2146
|
+
i.collection,
|
|
2147
|
+
$e,
|
|
2148
|
+
JSON.stringify(i.filter ?? null)
|
|
2063
2149
|
],
|
|
2064
|
-
queryFn: () =>
|
|
2065
|
-
R(`/items/${
|
|
2150
|
+
queryFn: () => v.request(
|
|
2151
|
+
R(`/items/${i.collection}`, {
|
|
2066
2152
|
limit: 2e3,
|
|
2067
|
-
fields:
|
|
2068
|
-
...
|
|
2153
|
+
fields: $e,
|
|
2154
|
+
...i.filter ? { filter: JSON.stringify(i.filter) } : {}
|
|
2069
2155
|
})
|
|
2070
|
-
).then((
|
|
2071
|
-
enabled:
|
|
2156
|
+
).then(($) => $.data ?? []),
|
|
2157
|
+
enabled: ye,
|
|
2072
2158
|
staleTime: 6e4
|
|
2073
|
-
}),
|
|
2074
|
-
var
|
|
2075
|
-
const
|
|
2076
|
-
if (
|
|
2077
|
-
if (typeof
|
|
2078
|
-
const
|
|
2079
|
-
return { id: String(
|
|
2159
|
+
}), ge = ($, W) => {
|
|
2160
|
+
var te;
|
|
2161
|
+
const g = $[W];
|
|
2162
|
+
if (g == null) return null;
|
|
2163
|
+
if (typeof g == "object") {
|
|
2164
|
+
const U = g, M = ((te = i.attributes.find((T) => T.field === W)) == null ? void 0 : te.label_field) ?? "id";
|
|
2165
|
+
return { id: String(U.id ?? ""), label: String(U[M] ?? U.id ?? "") };
|
|
2080
2166
|
}
|
|
2081
|
-
return { id: String(
|
|
2082
|
-
},
|
|
2083
|
-
(
|
|
2084
|
-
var
|
|
2085
|
-
const
|
|
2086
|
-
return
|
|
2167
|
+
return { id: String(g), label: String(g) };
|
|
2168
|
+
}, ke = ($) => je.filter(
|
|
2169
|
+
(W) => i.attributes.slice(0, $).every((g) => {
|
|
2170
|
+
var U;
|
|
2171
|
+
const te = G[g.field];
|
|
2172
|
+
return te ? ((U = ge(W, g.field)) == null ? void 0 : U.id) === te : !0;
|
|
2087
2173
|
})
|
|
2088
|
-
),
|
|
2089
|
-
(
|
|
2090
|
-
var
|
|
2091
|
-
return ((
|
|
2174
|
+
), le = i.attributes.every(($) => G[$.field]), ie = le ? je.find(
|
|
2175
|
+
($) => i.attributes.every((W) => {
|
|
2176
|
+
var g;
|
|
2177
|
+
return ((g = ge($, W.field)) == null ? void 0 : g.id) === G[W.field];
|
|
2092
2178
|
})
|
|
2093
|
-
) : void 0,
|
|
2094
|
-
queryKey: ["catalog-builder-item",
|
|
2095
|
-
queryFn: () =>
|
|
2096
|
-
R(`/items/${
|
|
2097
|
-
filter: JSON.stringify({ id: { _eq:
|
|
2098
|
-
fields:
|
|
2179
|
+
) : void 0, V = (ie == null ? void 0 : ie[O]) != null ? String(ie[O]) : null, { data: oe } = C({
|
|
2180
|
+
queryKey: ["catalog-builder-item", b, x, V],
|
|
2181
|
+
queryFn: () => v.request(
|
|
2182
|
+
R(`/items/${b}`, {
|
|
2183
|
+
filter: JSON.stringify({ id: { _eq: V } }),
|
|
2184
|
+
fields: x,
|
|
2099
2185
|
limit: 1
|
|
2100
2186
|
})
|
|
2101
|
-
).then((
|
|
2102
|
-
var
|
|
2103
|
-
return ((
|
|
2187
|
+
).then(($) => {
|
|
2188
|
+
var W;
|
|
2189
|
+
return ((W = $.data) == null ? void 0 : W[0]) ?? null;
|
|
2104
2190
|
}),
|
|
2105
|
-
enabled: !!
|
|
2191
|
+
enabled: !!V,
|
|
2106
2192
|
staleTime: 6e4
|
|
2107
|
-
}),
|
|
2108
|
-
async function
|
|
2109
|
-
if (!(!
|
|
2110
|
-
|
|
2193
|
+
}), de = Number(P), he = !!V && !!oe && !J && P.trim() !== "" && Number.isFinite(de) && de > 0 && (k === "any" || Number.isInteger(de));
|
|
2194
|
+
async function Ee() {
|
|
2195
|
+
if (!(!he || !V || !oe)) {
|
|
2196
|
+
fe(!0);
|
|
2111
2197
|
try {
|
|
2112
|
-
await
|
|
2198
|
+
await w(V, (s(V) ?? 0) + de, oe), Ae({}), qe("1");
|
|
2113
2199
|
} finally {
|
|
2114
|
-
|
|
2200
|
+
fe(!1);
|
|
2115
2201
|
}
|
|
2116
2202
|
}
|
|
2117
2203
|
}
|
|
@@ -2120,73 +2206,73 @@ function _s({
|
|
|
2120
2206
|
"button",
|
|
2121
2207
|
{
|
|
2122
2208
|
type: "button",
|
|
2123
|
-
onClick: () =>
|
|
2209
|
+
onClick: () => Z(($) => !$),
|
|
2124
2210
|
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
2211
|
children: [
|
|
2126
|
-
/* @__PURE__ */
|
|
2127
|
-
|
|
2212
|
+
/* @__PURE__ */ a(
|
|
2213
|
+
mn,
|
|
2128
2214
|
{
|
|
2129
|
-
className:
|
|
2215
|
+
className: I(
|
|
2130
2216
|
"h-3 w-3 shrink-0 text-slate-400 transition-transform",
|
|
2131
|
-
|
|
2217
|
+
ye && "rotate-90"
|
|
2132
2218
|
)
|
|
2133
2219
|
}
|
|
2134
2220
|
),
|
|
2135
|
-
/* @__PURE__ */
|
|
2221
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: i.label })
|
|
2136
2222
|
]
|
|
2137
2223
|
}
|
|
2138
2224
|
),
|
|
2139
|
-
|
|
2140
|
-
/* @__PURE__ */
|
|
2225
|
+
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: [
|
|
2226
|
+
/* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin" }),
|
|
2141
2227
|
" Loading options…"
|
|
2142
2228
|
] }) : /* @__PURE__ */ u("div", { className: "flex flex-wrap items-end gap-3", children: [
|
|
2143
|
-
|
|
2144
|
-
const
|
|
2145
|
-
for (const
|
|
2146
|
-
const
|
|
2147
|
-
|
|
2229
|
+
i.attributes.map(($, W) => {
|
|
2230
|
+
const g = /* @__PURE__ */ new Map();
|
|
2231
|
+
for (const U of ke(W)) {
|
|
2232
|
+
const M = ge(U, $.field);
|
|
2233
|
+
M != null && M.id && g.set(M.id, M.label);
|
|
2148
2234
|
}
|
|
2149
|
-
const
|
|
2150
|
-
([,
|
|
2235
|
+
const te = [...g.entries()].sort(
|
|
2236
|
+
([, U], [, M]) => U.localeCompare(M, void 0, { numeric: !0 })
|
|
2151
2237
|
);
|
|
2152
|
-
return /* @__PURE__ */
|
|
2153
|
-
|
|
2238
|
+
return /* @__PURE__ */ a(
|
|
2239
|
+
Ls,
|
|
2154
2240
|
{
|
|
2155
|
-
label:
|
|
2156
|
-
value:
|
|
2157
|
-
valueLabel:
|
|
2158
|
-
options:
|
|
2159
|
-
disabled:
|
|
2160
|
-
onChange: (
|
|
2161
|
-
const
|
|
2162
|
-
for (let
|
|
2163
|
-
const
|
|
2164
|
-
|
|
2241
|
+
label: D($.field),
|
|
2242
|
+
value: G[$.field] ?? null,
|
|
2243
|
+
valueLabel: G[$.field] ? g.get(G[$.field]) ?? G[$.field] : null,
|
|
2244
|
+
options: te,
|
|
2245
|
+
disabled: W > 0 && !G[i.attributes[W - 1].field],
|
|
2246
|
+
onChange: (U) => Ae((M) => {
|
|
2247
|
+
const T = {};
|
|
2248
|
+
for (let z = 0; z < W; z++) {
|
|
2249
|
+
const L = i.attributes[z].field;
|
|
2250
|
+
M[L] && (T[L] = M[L]);
|
|
2165
2251
|
}
|
|
2166
|
-
return
|
|
2252
|
+
return U && (T[$.field] = U), T;
|
|
2167
2253
|
})
|
|
2168
2254
|
},
|
|
2169
|
-
|
|
2255
|
+
$.field
|
|
2170
2256
|
);
|
|
2171
2257
|
}),
|
|
2172
|
-
/* @__PURE__ */
|
|
2173
|
-
/* @__PURE__ */
|
|
2174
|
-
(
|
|
2175
|
-
|
|
2258
|
+
/* @__PURE__ */ a("div", { className: "flex min-h-[28px] flex-1 items-center gap-2", children: V && oe ? /* @__PURE__ */ u(_e, { children: [
|
|
2259
|
+
/* @__PURE__ */ a("span", { className: "min-w-0 flex-1 truncate text-slate-700 dark:text-slate-200", children: ze(_, oe) }),
|
|
2260
|
+
(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: [
|
|
2261
|
+
s(V),
|
|
2176
2262
|
" in summary"
|
|
2177
2263
|
] }),
|
|
2178
|
-
!
|
|
2179
|
-
/* @__PURE__ */
|
|
2264
|
+
!j && /* @__PURE__ */ u(_e, { children: [
|
|
2265
|
+
/* @__PURE__ */ a(
|
|
2180
2266
|
"input",
|
|
2181
2267
|
{
|
|
2182
2268
|
type: "number",
|
|
2183
2269
|
min: 0,
|
|
2184
|
-
step:
|
|
2185
|
-
value:
|
|
2270
|
+
step: k,
|
|
2271
|
+
value: P,
|
|
2186
2272
|
"aria-label": "Quantity to add",
|
|
2187
|
-
onChange: (
|
|
2188
|
-
onKeyDown: (
|
|
2189
|
-
|
|
2273
|
+
onChange: ($) => qe($.target.value),
|
|
2274
|
+
onKeyDown: ($) => {
|
|
2275
|
+
$.key === "Enter" && ($.preventDefault(), Ee());
|
|
2190
2276
|
},
|
|
2191
2277
|
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
2278
|
}
|
|
@@ -2195,315 +2281,315 @@ function _s({
|
|
|
2195
2281
|
"button",
|
|
2196
2282
|
{
|
|
2197
2283
|
type: "button",
|
|
2198
|
-
onClick: () => void
|
|
2199
|
-
disabled: !
|
|
2284
|
+
onClick: () => void Ee(),
|
|
2285
|
+
disabled: !he,
|
|
2200
2286
|
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
2287
|
children: [
|
|
2202
|
-
|
|
2288
|
+
J ? /* @__PURE__ */ a(ce, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ a(Hr, { className: "h-3.5 w-3.5" }),
|
|
2203
2289
|
"Add"
|
|
2204
2290
|
]
|
|
2205
2291
|
}
|
|
2206
2292
|
)
|
|
2207
2293
|
] })
|
|
2208
|
-
] }) :
|
|
2294
|
+
] }) : 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
2295
|
] }) })
|
|
2210
2296
|
] });
|
|
2211
2297
|
}
|
|
2212
|
-
function
|
|
2213
|
-
parentCollection:
|
|
2214
|
-
field:
|
|
2215
|
-
id:
|
|
2298
|
+
function Es({
|
|
2299
|
+
parentCollection: i,
|
|
2300
|
+
field: m,
|
|
2301
|
+
id: b
|
|
2216
2302
|
}) {
|
|
2217
|
-
var
|
|
2218
|
-
const
|
|
2219
|
-
queryKey: ["collection-relations",
|
|
2220
|
-
queryFn: () =>
|
|
2221
|
-
var
|
|
2222
|
-
return ((
|
|
2303
|
+
var k;
|
|
2304
|
+
const x = Kt(), { data: _ = [] } = C({
|
|
2305
|
+
queryKey: ["collection-relations", i],
|
|
2306
|
+
queryFn: () => x.request(R(`/collections/${i}`)).then((j) => {
|
|
2307
|
+
var v;
|
|
2308
|
+
return ((v = j.data) == null ? void 0 : v.relations) ?? [];
|
|
2223
2309
|
}),
|
|
2224
|
-
enabled: !!
|
|
2310
|
+
enabled: !!i,
|
|
2225
2311
|
staleTime: 10 * 6e4
|
|
2226
|
-
}),
|
|
2227
|
-
(
|
|
2228
|
-
)) == null ? void 0 :
|
|
2229
|
-
queryKey: ["col-meta",
|
|
2230
|
-
queryFn: () =>
|
|
2231
|
-
enabled: !!
|
|
2312
|
+
}), s = ((k = _.find(
|
|
2313
|
+
(j) => j.many_collection === i && j.many_field === m && !j.junction_field
|
|
2314
|
+
)) == null ? void 0 : k.one_collection) ?? null, { data: w } = C({
|
|
2315
|
+
queryKey: ["col-meta", s],
|
|
2316
|
+
queryFn: () => x.request(R(`/collections/${s}`)).then((j) => j.data),
|
|
2317
|
+
enabled: !!s,
|
|
2232
2318
|
staleTime: 3e5
|
|
2233
2319
|
});
|
|
2234
|
-
return
|
|
2320
|
+
return s ? /* @__PURE__ */ a(Ns, { collection: s, id: b, displayTemplate: w == null ? void 0 : w.display_template }) : /* @__PURE__ */ u(_e, { children: [
|
|
2235
2321
|
"this ",
|
|
2236
|
-
|
|
2322
|
+
D(m)
|
|
2237
2323
|
] });
|
|
2238
2324
|
}
|
|
2239
|
-
function
|
|
2240
|
-
text:
|
|
2241
|
-
highlight:
|
|
2242
|
-
className:
|
|
2243
|
-
...
|
|
2325
|
+
function lr({
|
|
2326
|
+
text: i,
|
|
2327
|
+
highlight: m,
|
|
2328
|
+
className: b,
|
|
2329
|
+
...x
|
|
2244
2330
|
}) {
|
|
2245
|
-
const
|
|
2246
|
-
return /* @__PURE__ */
|
|
2331
|
+
const _ = cs(i);
|
|
2332
|
+
return /* @__PURE__ */ a("span", { ref: _, className: I("truncate", b), ...x, children: m ? /* @__PURE__ */ a(fn, { text: i, query: m }) : i });
|
|
2247
2333
|
}
|
|
2248
|
-
function
|
|
2249
|
-
label:
|
|
2250
|
-
value:
|
|
2251
|
-
valueLabel:
|
|
2252
|
-
options:
|
|
2253
|
-
disabled:
|
|
2254
|
-
onChange:
|
|
2334
|
+
function Ls({
|
|
2335
|
+
label: i,
|
|
2336
|
+
value: m,
|
|
2337
|
+
valueLabel: b,
|
|
2338
|
+
options: x,
|
|
2339
|
+
disabled: _,
|
|
2340
|
+
onChange: s
|
|
2255
2341
|
}) {
|
|
2256
|
-
const [
|
|
2257
|
-
return
|
|
2258
|
-
if (!
|
|
2259
|
-
const
|
|
2260
|
-
|
|
2342
|
+
const [w, k] = Y(!1), j = pe(null);
|
|
2343
|
+
return xe(() => {
|
|
2344
|
+
if (!w) return;
|
|
2345
|
+
const v = (O) => {
|
|
2346
|
+
j.current && !j.current.contains(O.target) && k(!1);
|
|
2261
2347
|
};
|
|
2262
|
-
return document.addEventListener("mousedown",
|
|
2263
|
-
}, [
|
|
2264
|
-
/* @__PURE__ */
|
|
2348
|
+
return document.addEventListener("mousedown", v), () => document.removeEventListener("mousedown", v);
|
|
2349
|
+
}, [w]), /* @__PURE__ */ u("div", { ref: j, className: "relative", children: [
|
|
2350
|
+
/* @__PURE__ */ a("p", { className: "mb-1 text-[10px] font-medium text-slate-500 dark:text-slate-400", children: i }),
|
|
2265
2351
|
/* @__PURE__ */ u(
|
|
2266
2352
|
"button",
|
|
2267
2353
|
{
|
|
2268
2354
|
type: "button",
|
|
2269
|
-
disabled:
|
|
2270
|
-
onClick: () =>
|
|
2355
|
+
disabled: _,
|
|
2356
|
+
onClick: () => k((v) => !v),
|
|
2271
2357
|
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
2358
|
children: [
|
|
2273
|
-
/* @__PURE__ */
|
|
2274
|
-
/* @__PURE__ */
|
|
2359
|
+
/* @__PURE__ */ a("span", { className: I("truncate", !b && "text-slate-400"), children: b ?? "Select…" }),
|
|
2360
|
+
/* @__PURE__ */ a(Yr, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" })
|
|
2275
2361
|
]
|
|
2276
2362
|
}
|
|
2277
2363
|
),
|
|
2278
|
-
|
|
2279
|
-
|
|
2364
|
+
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: [
|
|
2365
|
+
m && /* @__PURE__ */ u(
|
|
2280
2366
|
"button",
|
|
2281
2367
|
{
|
|
2282
2368
|
type: "button",
|
|
2283
2369
|
onClick: () => {
|
|
2284
|
-
|
|
2370
|
+
s(null), k(!1);
|
|
2285
2371
|
},
|
|
2286
2372
|
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
2373
|
children: [
|
|
2288
|
-
/* @__PURE__ */
|
|
2374
|
+
/* @__PURE__ */ a(Lt, { className: "h-3 w-3 text-slate-400" }),
|
|
2289
2375
|
" Clear"
|
|
2290
2376
|
]
|
|
2291
2377
|
}
|
|
2292
2378
|
),
|
|
2293
|
-
|
|
2379
|
+
x.map(([v, O]) => /* @__PURE__ */ a(
|
|
2294
2380
|
"button",
|
|
2295
2381
|
{
|
|
2296
2382
|
type: "button",
|
|
2297
2383
|
onClick: () => {
|
|
2298
|
-
|
|
2384
|
+
s(v), k(!1);
|
|
2299
2385
|
},
|
|
2300
|
-
className:
|
|
2386
|
+
className: I(
|
|
2301
2387
|
"block w-full truncate px-2 py-1 text-left text-[12px] hover:bg-muted",
|
|
2302
|
-
|
|
2388
|
+
v === m ? "font-medium text-nvr-cyan" : "text-slate-700 dark:text-slate-200"
|
|
2303
2389
|
),
|
|
2304
|
-
children:
|
|
2390
|
+
children: O
|
|
2305
2391
|
},
|
|
2306
|
-
|
|
2392
|
+
v
|
|
2307
2393
|
))
|
|
2308
2394
|
] })
|
|
2309
2395
|
] });
|
|
2310
2396
|
}
|
|
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:
|
|
2397
|
+
function As({
|
|
2398
|
+
catalogCol: i,
|
|
2399
|
+
tmpl: m,
|
|
2400
|
+
sectionBy: b,
|
|
2401
|
+
sectionM2M: x,
|
|
2402
|
+
pinnedSet: _,
|
|
2403
|
+
pinnedIds: s,
|
|
2404
|
+
savingIds: w,
|
|
2405
|
+
relatedCols: k,
|
|
2406
|
+
parentDraft: j,
|
|
2407
|
+
onToggle: v,
|
|
2408
|
+
onClose: O,
|
|
2409
|
+
anchor: ye
|
|
2324
2410
|
}) {
|
|
2325
|
-
const
|
|
2326
|
-
|
|
2327
|
-
const
|
|
2328
|
-
return () => clearTimeout(
|
|
2329
|
-
}, [
|
|
2330
|
-
var
|
|
2331
|
-
(
|
|
2332
|
-
}, []),
|
|
2333
|
-
const
|
|
2334
|
-
|
|
2411
|
+
const Z = Kt(), [G, Ae] = Y(""), [P, qe] = Y(""), [J, fe] = Y(1), $e = pe(null);
|
|
2412
|
+
xe(() => {
|
|
2413
|
+
const d = setTimeout(() => qe(G), 300);
|
|
2414
|
+
return () => clearTimeout(d);
|
|
2415
|
+
}, [G]), xe(() => fe(1), [P]), xe(() => {
|
|
2416
|
+
var d;
|
|
2417
|
+
(d = $e.current) == null || d.focus();
|
|
2418
|
+
}, []), xe(() => {
|
|
2419
|
+
const d = (N) => {
|
|
2420
|
+
N.key === "Escape" && (N.stopPropagation(), O());
|
|
2335
2421
|
};
|
|
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
|
-
...
|
|
2422
|
+
return window.addEventListener("keydown", d, !0), () => window.removeEventListener("keydown", d, !0);
|
|
2423
|
+
}, [O]);
|
|
2424
|
+
const je = F(() => {
|
|
2425
|
+
var N;
|
|
2426
|
+
const d = (N = [...(m ?? "").matchAll(/\{\{([\w.]+)\}\}/g)][0]) == null ? void 0 : N[1];
|
|
2427
|
+
return d && !d.includes(".") ? d : "id";
|
|
2428
|
+
}, [m]), X = !x && b.includes(".") ? `*,${b}` : "*", ge = 50, { data: ke, isFetching: le } = C({
|
|
2429
|
+
queryKey: ["favorites-manager-list", i, P, je, J],
|
|
2430
|
+
queryFn: () => Z.request(
|
|
2431
|
+
R(`/items/${i}`, {
|
|
2432
|
+
fields: X,
|
|
2433
|
+
limit: ge,
|
|
2434
|
+
page: J,
|
|
2435
|
+
sort: je,
|
|
2436
|
+
...P.trim() ? { search: P } : {}
|
|
2351
2437
|
})
|
|
2352
2438
|
),
|
|
2353
2439
|
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:
|
|
2440
|
+
placeholderData: (d) => d
|
|
2441
|
+
}), ie = ((ke == null ? void 0 : ke.data) ?? []).filter((d) => !_.has(String(d.id))), V = (ke == null ? void 0 : ke.total) ?? ie.length, oe = Math.max(1, Math.ceil(V / ge)), { data: de = [] } = C({
|
|
2442
|
+
queryKey: ["favorites-manager-pinned", i, X, s.join(",")],
|
|
2443
|
+
queryFn: () => Z.request(
|
|
2444
|
+
R(`/items/${i}`, {
|
|
2445
|
+
filter: JSON.stringify({ id: { _in: s } }),
|
|
2446
|
+
fields: X,
|
|
2447
|
+
limit: s.length,
|
|
2448
|
+
sort: je
|
|
2363
2449
|
})
|
|
2364
|
-
).then((
|
|
2365
|
-
enabled:
|
|
2450
|
+
).then((d) => d.data ?? []),
|
|
2451
|
+
enabled: s.length > 0,
|
|
2366
2452
|
staleTime: 3e4
|
|
2367
|
-
}),
|
|
2368
|
-
const
|
|
2369
|
-
for (const
|
|
2370
|
-
for (const
|
|
2371
|
-
return [...
|
|
2372
|
-
}, [
|
|
2373
|
-
queryKey: ["favorites-manager-sections",
|
|
2453
|
+
}), he = F(() => {
|
|
2454
|
+
const d = /* @__PURE__ */ new Set();
|
|
2455
|
+
for (const N of ie) d.add(String(N.id));
|
|
2456
|
+
for (const N of s) d.add(N);
|
|
2457
|
+
return [...d];
|
|
2458
|
+
}, [ie, s]), { data: Ee = /* @__PURE__ */ new Map() } = C({
|
|
2459
|
+
queryKey: ["favorites-manager-sections", x == null ? void 0 : x.junction, he.join(",")],
|
|
2374
2460
|
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
|
-
|
|
2461
|
+
const d = x, N = await At(Z, `/items/${d.junction}`, {
|
|
2462
|
+
fields: `${d.fkToItem},${d.fkToSection}`,
|
|
2463
|
+
filter: JSON.stringify({ [d.fkToItem]: { _in: he } })
|
|
2464
|
+
}), B = [...new Set(N.map((H) => String(H[d.fkToSection])))], ne = B.length ? await At(Z, `/items/${d.target}`, {
|
|
2465
|
+
fields: `id,${d.labelPath}`,
|
|
2466
|
+
filter: JSON.stringify({ id: { _in: B } })
|
|
2467
|
+
}) : [], Q = new Map(
|
|
2468
|
+
ne.map((H) => [String(H.id), String(cr(H, d.labelPath) ?? "")])
|
|
2469
|
+
), ee = /* @__PURE__ */ new Map();
|
|
2470
|
+
for (const H of N) {
|
|
2471
|
+
const A = Q.get(String(H[d.fkToSection]));
|
|
2472
|
+
if (!A) continue;
|
|
2473
|
+
const Ke = String(H[d.fkToItem]), re = ee.get(Ke) ?? [];
|
|
2474
|
+
re.includes(A) || re.push(A), ee.set(Ke, re);
|
|
2389
2475
|
}
|
|
2390
|
-
return
|
|
2476
|
+
return ee;
|
|
2391
2477
|
},
|
|
2392
|
-
enabled: !!
|
|
2478
|
+
enabled: !!x && he.length > 0,
|
|
2393
2479
|
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
|
|
2480
|
+
}), $ = (d) => m ? ze(m, d) : String(d.cifa_number ?? d.name ?? `#${d.id}`), W = (d) => {
|
|
2481
|
+
const N = d.description ?? d.long_description ?? d.name;
|
|
2482
|
+
return typeof N == "string" && N.trim() && N.trim() !== $(d) ? N : "";
|
|
2483
|
+
}, g = (d) => {
|
|
2484
|
+
if (x) return (Ee.get(String(d.id)) ?? []).join(", ");
|
|
2485
|
+
if (!b) return "";
|
|
2486
|
+
const N = ze(`{{${b}}}`, d);
|
|
2487
|
+
return N === `{{${b}}}` ? "" : N;
|
|
2488
|
+
}, te = (d, N) => {
|
|
2489
|
+
if (N === "presence")
|
|
2490
|
+
return d == null || d === "" || Number(d) === 0 ? "No" : "Yes";
|
|
2491
|
+
if (d == null || d === "") return "—";
|
|
2492
|
+
const B = Number(d);
|
|
2493
|
+
return N === "currency" && Number.isFinite(B) ? B.toLocaleString("en-US", { style: "currency", currency: "USD" }) : N === "number" && Number.isFinite(B) ? B.toLocaleString() : String(d);
|
|
2494
|
+
}, U = un({
|
|
2495
|
+
queries: k.map((d) => {
|
|
2496
|
+
const N = De(d.match, j);
|
|
2411
2497
|
return {
|
|
2412
2498
|
queryKey: [
|
|
2413
2499
|
"favorites-manager-related",
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
JSON.stringify(
|
|
2417
|
-
|
|
2500
|
+
d.key,
|
|
2501
|
+
d.collection,
|
|
2502
|
+
JSON.stringify(N),
|
|
2503
|
+
he.join(",")
|
|
2418
2504
|
],
|
|
2419
2505
|
queryFn: async () => {
|
|
2420
|
-
const
|
|
2421
|
-
R(`/items/${
|
|
2422
|
-
filter: JSON.stringify({ [
|
|
2423
|
-
fields: `${
|
|
2506
|
+
const B = await Z.request(
|
|
2507
|
+
R(`/items/${d.collection}`, {
|
|
2508
|
+
filter: JSON.stringify({ [d.item_field]: { _in: he }, ...N ?? {} }),
|
|
2509
|
+
fields: `${d.item_field},${d.value_field}`,
|
|
2424
2510
|
limit: 1e3
|
|
2425
2511
|
})
|
|
2426
|
-
).then((
|
|
2427
|
-
for (const
|
|
2428
|
-
const
|
|
2429
|
-
|
|
2512
|
+
).then((Q) => Q.data ?? []), ne = /* @__PURE__ */ new Map();
|
|
2513
|
+
for (const Q of B) {
|
|
2514
|
+
const ee = String(Q[d.item_field]), H = Q[d.value_field], A = ne.get(ee);
|
|
2515
|
+
A === void 0 ? ne.set(ee, H) : Number.isFinite(Number(A)) && Number.isFinite(Number(H)) && ne.set(ee, Number(A) + Number(H));
|
|
2430
2516
|
}
|
|
2431
|
-
return
|
|
2517
|
+
return ne;
|
|
2432
2518
|
},
|
|
2433
|
-
enabled:
|
|
2519
|
+
enabled: he.length > 0 && (d.match === void 0 || N !== null),
|
|
2434
2520
|
staleTime: 3e4
|
|
2435
2521
|
};
|
|
2436
2522
|
})
|
|
2437
|
-
}),
|
|
2438
|
-
(
|
|
2439
|
-
),
|
|
2440
|
-
const
|
|
2441
|
-
return /* @__PURE__ */
|
|
2523
|
+
}), M = k.filter(
|
|
2524
|
+
(d) => d.match !== void 0 && De(d.match, j) === null
|
|
2525
|
+
), T = (d) => {
|
|
2526
|
+
const N = _.has(d);
|
|
2527
|
+
return /* @__PURE__ */ a(
|
|
2442
2528
|
"button",
|
|
2443
2529
|
{
|
|
2444
2530
|
type: "button",
|
|
2445
|
-
title:
|
|
2446
|
-
disabled:
|
|
2447
|
-
onClick: () =>
|
|
2531
|
+
title: N ? "Remove from favorites" : "Add to favorites",
|
|
2532
|
+
disabled: w.has(d),
|
|
2533
|
+
onClick: () => v(d),
|
|
2448
2534
|
className: "shrink-0 rounded p-1 transition-colors hover:bg-amber-100/60 dark:hover:bg-amber-400/10",
|
|
2449
|
-
children:
|
|
2450
|
-
|
|
2535
|
+
children: w.has(d) ? /* @__PURE__ */ a(ce, { className: "h-4 w-4 animate-spin text-amber-400" }) : /* @__PURE__ */ a(
|
|
2536
|
+
dt,
|
|
2451
2537
|
{
|
|
2452
|
-
className:
|
|
2538
|
+
className: I(
|
|
2453
2539
|
"h-4 w-4",
|
|
2454
|
-
|
|
2540
|
+
N ? "fill-amber-400 text-amber-400" : "text-slate-300 hover:text-amber-400"
|
|
2455
2541
|
)
|
|
2456
2542
|
}
|
|
2457
2543
|
)
|
|
2458
2544
|
}
|
|
2459
2545
|
);
|
|
2460
|
-
},
|
|
2461
|
-
const
|
|
2546
|
+
}, 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) => {
|
|
2547
|
+
const B = String(d.id), ne = W(d);
|
|
2462
2548
|
return /* @__PURE__ */ u(
|
|
2463
2549
|
"tr",
|
|
2464
2550
|
{
|
|
2465
|
-
className:
|
|
2551
|
+
className: I(
|
|
2466
2552
|
"border-b border-slate-100 dark:border-border/50",
|
|
2467
|
-
|
|
2553
|
+
N % 2 === 0 ? "bg-white dark:bg-background" : "bg-slate-50/50 dark:bg-muted/30"
|
|
2468
2554
|
),
|
|
2469
2555
|
children: [
|
|
2470
|
-
/* @__PURE__ */
|
|
2471
|
-
/* @__PURE__ */
|
|
2556
|
+
/* @__PURE__ */ a("td", { className: "px-2 py-1", children: T(B) }),
|
|
2557
|
+
/* @__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
2558
|
"button",
|
|
2473
2559
|
{
|
|
2474
2560
|
type: "button",
|
|
2475
|
-
onClick: () =>
|
|
2561
|
+
onClick: () => dr(i, B, j),
|
|
2476
2562
|
title: "View stock & planning detail",
|
|
2477
2563
|
className: "text-left underline decoration-slate-300 decoration-1 underline-offset-2 hover:text-[#009abe] hover:decoration-[#009abe] dark:decoration-slate-600",
|
|
2478
|
-
children:
|
|
2564
|
+
children: $(d)
|
|
2479
2565
|
}
|
|
2480
|
-
) :
|
|
2481
|
-
/* @__PURE__ */
|
|
2482
|
-
/* @__PURE__ */
|
|
2483
|
-
|
|
2484
|
-
var
|
|
2485
|
-
const
|
|
2486
|
-
return /* @__PURE__ */
|
|
2566
|
+
) : $(d) }),
|
|
2567
|
+
/* @__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 || "—" }) }),
|
|
2568
|
+
/* @__PURE__ */ a("td", { className: "px-2 py-1", children: /* @__PURE__ */ a("p", { className: "truncate text-slate-500 dark:text-slate-400", children: g(d) || "—" }) }),
|
|
2569
|
+
k.map((Q, ee) => {
|
|
2570
|
+
var Ke, re;
|
|
2571
|
+
const H = Q.match !== void 0 && De(Q.match, j) === null, A = H || (re = (Ke = U[ee]) == null ? void 0 : Ke.data) == null ? void 0 : re.get(B);
|
|
2572
|
+
return /* @__PURE__ */ a(
|
|
2487
2573
|
"td",
|
|
2488
2574
|
{
|
|
2489
2575
|
className: "whitespace-nowrap px-2 py-1 text-right tabular-nums text-slate-600 dark:text-slate-300",
|
|
2490
|
-
children:
|
|
2576
|
+
children: H ? "—" : te(A, Q.format)
|
|
2491
2577
|
},
|
|
2492
|
-
|
|
2578
|
+
Q.key
|
|
2493
2579
|
);
|
|
2494
2580
|
})
|
|
2495
2581
|
]
|
|
2496
2582
|
},
|
|
2497
|
-
|
|
2583
|
+
B
|
|
2498
2584
|
);
|
|
2499
|
-
},
|
|
2500
|
-
return
|
|
2585
|
+
}, 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;
|
|
2586
|
+
return Zr(
|
|
2501
2587
|
/* @__PURE__ */ u("div", { className: "fixed inset-0 z-[125]", role: "presentation", children: [
|
|
2502
|
-
/* @__PURE__ */
|
|
2588
|
+
/* @__PURE__ */ a(
|
|
2503
2589
|
"div",
|
|
2504
2590
|
{
|
|
2505
2591
|
className: "absolute inset-0 bg-slate-900/30 motion-safe:animate-in motion-safe:fade-in",
|
|
2506
|
-
onClick:
|
|
2592
|
+
onClick: O
|
|
2507
2593
|
}
|
|
2508
2594
|
),
|
|
2509
2595
|
/* @__PURE__ */ u(
|
|
@@ -2515,140 +2601,140 @@ function $s({
|
|
|
2515
2601
|
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
2602
|
children: [
|
|
2517
2603
|
/* @__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__ */
|
|
2604
|
+
/* @__PURE__ */ a(dt, { className: "mt-0.5 h-4 w-4 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2519
2605
|
/* @__PURE__ */ u("div", { className: "min-w-0 flex-1", children: [
|
|
2520
|
-
/* @__PURE__ */
|
|
2521
|
-
/* @__PURE__ */
|
|
2606
|
+
/* @__PURE__ */ a("p", { className: "text-[13px] font-semibold text-slate-800 dark:text-slate-100", children: "CIFA favorites" }),
|
|
2607
|
+
/* @__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
2608
|
] }),
|
|
2523
|
-
/* @__PURE__ */
|
|
2609
|
+
/* @__PURE__ */ a(
|
|
2524
2610
|
"button",
|
|
2525
2611
|
{
|
|
2526
2612
|
type: "button",
|
|
2527
|
-
onClick:
|
|
2613
|
+
onClick: O,
|
|
2528
2614
|
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
2615
|
"aria-label": "Close",
|
|
2530
|
-
children: /* @__PURE__ */
|
|
2616
|
+
children: /* @__PURE__ */ a(Lt, { className: "h-4 w-4" })
|
|
2531
2617
|
}
|
|
2532
2618
|
)
|
|
2533
2619
|
] }),
|
|
2534
2620
|
/* @__PURE__ */ u("div", { className: "border-b border-slate-200 px-3 py-2 dark:border-border", children: [
|
|
2535
2621
|
/* @__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__ */
|
|
2622
|
+
/* @__PURE__ */ a(Et, { className: "h-3.5 w-3.5 shrink-0 text-slate-400" }),
|
|
2623
|
+
/* @__PURE__ */ a(
|
|
2538
2624
|
"input",
|
|
2539
2625
|
{
|
|
2540
|
-
ref:
|
|
2541
|
-
value:
|
|
2542
|
-
onChange: (
|
|
2626
|
+
ref: $e,
|
|
2627
|
+
value: G,
|
|
2628
|
+
onChange: (d) => Ae(d.target.value),
|
|
2543
2629
|
placeholder: "Search by number or description…",
|
|
2544
2630
|
className: "min-w-0 flex-1 bg-transparent text-[12px] text-slate-700 outline-none placeholder:text-slate-400 dark:text-slate-200"
|
|
2545
2631
|
}
|
|
2546
2632
|
),
|
|
2547
|
-
|
|
2633
|
+
G && /* @__PURE__ */ a(
|
|
2548
2634
|
"button",
|
|
2549
2635
|
{
|
|
2550
2636
|
type: "button",
|
|
2551
|
-
onClick: () =>
|
|
2637
|
+
onClick: () => Ae(""),
|
|
2552
2638
|
className: "shrink-0 text-slate-400 hover:text-slate-600",
|
|
2553
2639
|
"aria-label": "Clear search",
|
|
2554
|
-
children: /* @__PURE__ */
|
|
2640
|
+
children: /* @__PURE__ */ a(Lt, { className: "h-3.5 w-3.5" })
|
|
2555
2641
|
}
|
|
2556
2642
|
)
|
|
2557
2643
|
] }),
|
|
2558
|
-
|
|
2559
|
-
/* @__PURE__ */
|
|
2560
|
-
|
|
2644
|
+
M.length > 0 && /* @__PURE__ */ u("p", { className: "mt-1.5 flex items-center gap-1 text-[10px] text-amber-600 dark:text-amber-400", children: [
|
|
2645
|
+
/* @__PURE__ */ a(Be, { className: "h-3 w-3 shrink-0" }),
|
|
2646
|
+
M.map((d) => d.label ?? D(d.key)).join(", "),
|
|
2561
2647
|
" fill in once the form's warehouse selection is made."
|
|
2562
2648
|
] })
|
|
2563
2649
|
] }),
|
|
2564
|
-
/* @__PURE__ */
|
|
2650
|
+
/* @__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
2651
|
/* @__PURE__ */ u("colgroup", { children: [
|
|
2566
|
-
/* @__PURE__ */
|
|
2567
|
-
/* @__PURE__ */
|
|
2568
|
-
/* @__PURE__ */
|
|
2569
|
-
/* @__PURE__ */
|
|
2570
|
-
|
|
2652
|
+
/* @__PURE__ */ a("col", { className: "w-9" }),
|
|
2653
|
+
/* @__PURE__ */ a("col", { className: "w-[88px]" }),
|
|
2654
|
+
/* @__PURE__ */ a("col", {}),
|
|
2655
|
+
/* @__PURE__ */ a("col", { className: "w-[130px]" }),
|
|
2656
|
+
k.map((d) => /* @__PURE__ */ a("col", { className: "w-[86px]" }, d.key))
|
|
2571
2657
|
] }),
|
|
2572
|
-
/* @__PURE__ */
|
|
2573
|
-
/* @__PURE__ */
|
|
2574
|
-
/* @__PURE__ */
|
|
2575
|
-
/* @__PURE__ */
|
|
2576
|
-
/* @__PURE__ */
|
|
2577
|
-
|
|
2658
|
+
/* @__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: [
|
|
2659
|
+
/* @__PURE__ */ a("th", { className: "px-2 py-1.5", "aria-label": "Favorite" }),
|
|
2660
|
+
/* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "CIFA #" }),
|
|
2661
|
+
/* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Description" }),
|
|
2662
|
+
/* @__PURE__ */ a("th", { className: "px-2 py-1.5", children: "Category" }),
|
|
2663
|
+
k.map((d) => /* @__PURE__ */ a("th", { className: "px-2 py-1.5 text-right", children: d.label ?? D(d.key) }, d.key))
|
|
2578
2664
|
] }) }),
|
|
2579
|
-
/* @__PURE__ */ u("tbody", { className:
|
|
2580
|
-
|
|
2665
|
+
/* @__PURE__ */ u("tbody", { className: I(le && "opacity-50 transition-opacity"), children: [
|
|
2666
|
+
z(
|
|
2581
2667
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2582
|
-
/* @__PURE__ */
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2668
|
+
/* @__PURE__ */ a(dt, { className: "h-3 w-3 shrink-0 fill-amber-400 text-amber-400" }),
|
|
2669
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "Your favorites" }),
|
|
2670
|
+
/* @__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
2671
|
] }),
|
|
2586
2672
|
"border-slate-200 bg-amber-50/70 dark:border-border dark:bg-amber-900/10"
|
|
2587
2673
|
),
|
|
2588
|
-
|
|
2674
|
+
He.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
|
|
2589
2675
|
"td",
|
|
2590
2676
|
{
|
|
2591
|
-
colSpan: 4 +
|
|
2677
|
+
colSpan: 4 + k.length,
|
|
2592
2678
|
className: "border-b border-slate-100 px-4 py-3 text-center text-[11px] text-slate-400 dark:border-border/50",
|
|
2593
|
-
children:
|
|
2679
|
+
children: s.length === 0 ? "No favorites yet — star the items you order most." : "No favorites match your search."
|
|
2594
2680
|
}
|
|
2595
2681
|
) }),
|
|
2596
|
-
|
|
2597
|
-
|
|
2682
|
+
He.map((d, N) => L(d, N)),
|
|
2683
|
+
z(
|
|
2598
2684
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-1.5", children: [
|
|
2599
|
-
/* @__PURE__ */
|
|
2600
|
-
/* @__PURE__ */
|
|
2601
|
-
/* @__PURE__ */
|
|
2602
|
-
|
|
2685
|
+
/* @__PURE__ */ a(Et, { className: "h-3 w-3 shrink-0 text-slate-400" }),
|
|
2686
|
+
/* @__PURE__ */ a("span", { className: "text-[11px] font-semibold text-slate-600 dark:text-slate-300", children: "All CIFAs" }),
|
|
2687
|
+
/* @__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() }),
|
|
2688
|
+
le && /* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin text-slate-400" })
|
|
2603
2689
|
] }),
|
|
2604
2690
|
"border-t border-slate-200 bg-slate-50 dark:border-border dark:bg-muted/40"
|
|
2605
2691
|
),
|
|
2606
|
-
!
|
|
2692
|
+
!le && ie.length === 0 && /* @__PURE__ */ a("tr", { children: /* @__PURE__ */ a(
|
|
2607
2693
|
"td",
|
|
2608
2694
|
{
|
|
2609
|
-
colSpan: 4 +
|
|
2695
|
+
colSpan: 4 + k.length,
|
|
2610
2696
|
className: "px-4 py-4 text-center text-[11px] text-slate-400",
|
|
2611
|
-
children:
|
|
2697
|
+
children: P.trim() ? `No CIFAs match "${P}".` : "No catalog items."
|
|
2612
2698
|
}
|
|
2613
2699
|
) }),
|
|
2614
|
-
|
|
2700
|
+
ie.map((d, N) => L(d, N))
|
|
2615
2701
|
] })
|
|
2616
2702
|
] }) }),
|
|
2617
|
-
|
|
2703
|
+
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
2704
|
/* @__PURE__ */ u("span", { className: "flex items-center gap-2 text-[10px] tabular-nums text-slate-400", children: [
|
|
2619
|
-
(
|
|
2705
|
+
(J - 1) * ge + 1,
|
|
2620
2706
|
"–",
|
|
2621
|
-
Math.min(
|
|
2707
|
+
Math.min(J * ge, V),
|
|
2622
2708
|
" of",
|
|
2623
2709
|
" ",
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
/* @__PURE__ */
|
|
2710
|
+
V.toLocaleString(),
|
|
2711
|
+
le && /* @__PURE__ */ u("span", { className: "flex items-center gap-1 text-slate-500", children: [
|
|
2712
|
+
/* @__PURE__ */ a(ce, { className: "h-3 w-3 animate-spin" }),
|
|
2627
2713
|
" Loading…"
|
|
2628
2714
|
] })
|
|
2629
2715
|
] }),
|
|
2630
2716
|
/* @__PURE__ */ u("div", { className: "flex items-center gap-1", children: [
|
|
2631
|
-
/* @__PURE__ */
|
|
2717
|
+
/* @__PURE__ */ a(
|
|
2632
2718
|
"button",
|
|
2633
2719
|
{
|
|
2634
2720
|
type: "button",
|
|
2635
|
-
disabled:
|
|
2636
|
-
onClick: () =>
|
|
2721
|
+
disabled: J <= 1 || le,
|
|
2722
|
+
onClick: () => fe((d) => Math.max(1, d - 1)),
|
|
2637
2723
|
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
2724
|
children: "‹ Prev"
|
|
2639
2725
|
}
|
|
2640
2726
|
),
|
|
2641
2727
|
/* @__PURE__ */ u("span", { className: "px-1 text-[10px] tabular-nums text-slate-400", children: [
|
|
2642
|
-
|
|
2728
|
+
J,
|
|
2643
2729
|
" / ",
|
|
2644
|
-
|
|
2730
|
+
oe.toLocaleString()
|
|
2645
2731
|
] }),
|
|
2646
|
-
/* @__PURE__ */
|
|
2732
|
+
/* @__PURE__ */ a(
|
|
2647
2733
|
"button",
|
|
2648
2734
|
{
|
|
2649
2735
|
type: "button",
|
|
2650
|
-
disabled:
|
|
2651
|
-
onClick: () =>
|
|
2736
|
+
disabled: J >= oe || le,
|
|
2737
|
+
onClick: () => fe((d) => Math.min(oe, d + 1)),
|
|
2652
2738
|
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
2739
|
children: "Next ›"
|
|
2654
2740
|
}
|
|
@@ -2659,19 +2745,28 @@ function $s({
|
|
|
2659
2745
|
}
|
|
2660
2746
|
)
|
|
2661
2747
|
] }),
|
|
2662
|
-
|
|
2748
|
+
Fe
|
|
2663
2749
|
);
|
|
2664
2750
|
}
|
|
2751
|
+
function Ks(i, m) {
|
|
2752
|
+
var x;
|
|
2753
|
+
if (!i) return null;
|
|
2754
|
+
const b = (x = (m ?? []).find((_) => !_.format && !_.sections_only)) == null ? void 0 : x.field;
|
|
2755
|
+
return !b || i.includes(`{{${b}}}`) ? i : `${i} · {{${b}}}`;
|
|
2756
|
+
}
|
|
2665
2757
|
export {
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2758
|
+
da as CatalogPickerField,
|
|
2759
|
+
ys as MAX_LINE_MONEY,
|
|
2760
|
+
Ks as catalogOptionTemplate,
|
|
2761
|
+
qs as footerSum,
|
|
2762
|
+
Fs as gridPriceValue,
|
|
2763
|
+
Rs as isUnpricedLine,
|
|
2764
|
+
Ts as issuesAfterLinesChanged,
|
|
2765
|
+
js as lineComputeError,
|
|
2766
|
+
ir as matchesShowWhen,
|
|
2767
|
+
_s as qtyEntryProblem,
|
|
2768
|
+
$s as refusedQtyNote,
|
|
2769
|
+
bn as relatedParentTokens,
|
|
2770
|
+
Os as savedLinesSignature,
|
|
2771
|
+
vs as stagedCatalogFill
|
|
2677
2772
|
};
|