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