@proveanything/smartlinks-utils-ui 0.3.1 → 0.3.2
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/chunk-4LHF5JB7.js +54 -0
- package/dist/chunk-4LHF5JB7.js.map +1 -0
- package/dist/{chunk-L7NSCOC7.js → chunk-7UBXTFZQ.js} +16 -62
- package/dist/chunk-7UBXTFZQ.js.map +1 -0
- package/dist/{chunk-S6KH3YV4.js → chunk-JQPS5XPJ.js} +2 -2
- package/dist/{chunk-S6KH3YV4.js.map → chunk-JQPS5XPJ.js.map} +1 -1
- package/dist/chunk-MZ6JSCXO.js +247 -0
- package/dist/chunk-MZ6JSCXO.js.map +1 -0
- package/dist/{chunk-4Z46C4MJ.js → chunk-OTJV62XV.js} +2 -2
- package/dist/{chunk-4Z46C4MJ.js.map → chunk-OTJV62XV.js.map} +1 -1
- package/dist/{chunk-YVZKCCYQ.js → chunk-UDYVH7QF.js} +2 -2
- package/dist/{chunk-YVZKCCYQ.js.map → chunk-UDYVH7QF.js.map} +1 -1
- package/dist/chunk-WFNEZQCD.js +28 -0
- package/dist/chunk-WFNEZQCD.js.map +1 -0
- package/dist/components/AssetPicker/index.js +2 -1
- package/dist/components/ConditionsEditor/index.d.ts +5 -130
- package/dist/components/ConditionsEditor/index.js +3 -1
- package/dist/components/FacetRuleEditor/index.d.ts +42 -0
- package/dist/components/FacetRuleEditor/index.js +5 -0
- package/dist/components/FacetRuleEditor/index.js.map +1 -0
- package/dist/components/FontPicker/index.js +2 -1
- package/dist/components/IconPicker/index.js +2 -1
- package/dist/components/RecordsAdmin/index.d.ts +115 -20
- package/dist/components/RecordsAdmin/index.js +217 -60
- package/dist/components/RecordsAdmin/index.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +7 -4
- package/dist/types-a2DdgZ2H.d.ts +128 -0
- package/package.json +11 -4
- package/dist/chunk-L7NSCOC7.js.map +0 -1
- package/dist/components/RecordsAdmin/index.css +0 -674
- package/dist/components/RecordsAdmin/index.css.map +0 -1
- package/dist/index.css +0 -1248
- package/dist/index.css.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { styleInject } from '../../chunk-WFNEZQCD.js';
|
|
1
2
|
import { cn } from '../../chunk-L7FQ52F5.js';
|
|
2
|
-
import { createContext, useMemo, useState, useEffect, useCallback, useRef, useContext, createElement
|
|
3
|
+
import { createContext, useMemo, useState, useEffect, useCallback, useRef, useContext, createElement } from 'react';
|
|
3
4
|
import { ChevronDown, Database, Lightbulb, SearchX, Inbox, LayoutGrid, Eye, MoreHorizontal, Download, Upload, Trash2, Copy, Pencil, Plus, CircleDashed, ArrowDownLeft, CheckCircle2, Globe, Tag, Boxes, Layers, Package, Rows3, Image, List, ChevronRight, Eraser, Box, AlertTriangle, Info, X, HelpCircle, Search, CornerDownLeft, Circle } from 'lucide-react';
|
|
4
5
|
import { useQueryClient, useInfiniteQuery, useQuery } from '@tanstack/react-query';
|
|
5
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
@@ -39,7 +40,10 @@ function mergeIcons(override) {
|
|
|
39
40
|
};
|
|
40
41
|
}
|
|
41
42
|
function pickHeaderIcon(icons, recordType) {
|
|
42
|
-
|
|
43
|
+
if (recordType && icons.header.byRecordType[recordType]) {
|
|
44
|
+
return icons.header.byRecordType[recordType];
|
|
45
|
+
}
|
|
46
|
+
return icons.header.default;
|
|
43
47
|
}
|
|
44
48
|
|
|
45
49
|
// src/components/RecordsAdmin/types/i18n.ts
|
|
@@ -198,7 +202,15 @@ var listRecords = async (ctx, params = {}) => {
|
|
|
198
202
|
const res = await ctx.SL.app.records.list(
|
|
199
203
|
ctx.collectionId,
|
|
200
204
|
ctx.appId,
|
|
201
|
-
{
|
|
205
|
+
{
|
|
206
|
+
...ctx.recordType ? { recordType: ctx.recordType } : {},
|
|
207
|
+
limit,
|
|
208
|
+
offset,
|
|
209
|
+
ref,
|
|
210
|
+
refPrefix,
|
|
211
|
+
q,
|
|
212
|
+
sort
|
|
213
|
+
},
|
|
202
214
|
true
|
|
203
215
|
);
|
|
204
216
|
return {
|
|
@@ -211,7 +223,7 @@ var getRecordByRef = async (ctx, ref) => {
|
|
|
211
223
|
const res = await ctx.SL.app.records.list(
|
|
212
224
|
ctx.collectionId,
|
|
213
225
|
ctx.appId,
|
|
214
|
-
{ recordType: ctx.recordType, ref, limit: 1 },
|
|
226
|
+
{ ...ctx.recordType ? { recordType: ctx.recordType } : {}, ref, limit: 1 },
|
|
215
227
|
true
|
|
216
228
|
);
|
|
217
229
|
return res?.data?.[0] ?? null;
|
|
@@ -220,7 +232,7 @@ var upsertRecord = async (ctx, write) => {
|
|
|
220
232
|
const ref = write.ref ?? deriveRefFromScope(write.scope);
|
|
221
233
|
const res = await ctx.SL.app.records.upsert(ctx.collectionId, ctx.appId, {
|
|
222
234
|
ref,
|
|
223
|
-
recordType: ctx.recordType,
|
|
235
|
+
...ctx.recordType ? { recordType: ctx.recordType } : {},
|
|
224
236
|
scope: write.scope,
|
|
225
237
|
data: write.data,
|
|
226
238
|
status: write.status,
|
|
@@ -243,7 +255,7 @@ var matchRecords = async (ctx, target, opts = {}) => ctx.SL.app.records.match(
|
|
|
243
255
|
ctx.appId,
|
|
244
256
|
{
|
|
245
257
|
target,
|
|
246
|
-
recordType: ctx.recordType,
|
|
258
|
+
...ctx.recordType ? { recordType: ctx.recordType } : {},
|
|
247
259
|
strategy: opts.strategy ?? "all",
|
|
248
260
|
at: opts.at,
|
|
249
261
|
includeScheduled: opts.includeScheduled,
|
|
@@ -260,7 +272,7 @@ var bulkUpsert = async (ctx, entries) => {
|
|
|
260
272
|
const slice = entries.slice(i, i + CHUNK);
|
|
261
273
|
const items = slice.map((e) => ({
|
|
262
274
|
ref: e.ref ?? deriveRefFromScope(e.scope),
|
|
263
|
-
recordType: ctx.recordType,
|
|
275
|
+
...ctx.recordType ? { recordType: ctx.recordType } : {},
|
|
264
276
|
scope: e.scope,
|
|
265
277
|
data: e.data,
|
|
266
278
|
status: e.status
|
|
@@ -276,7 +288,7 @@ var bulkDelete = async (ctx, input) => {
|
|
|
276
288
|
const res = await ctx.SL.app.records.bulkDelete(
|
|
277
289
|
ctx.collectionId,
|
|
278
290
|
ctx.appId,
|
|
279
|
-
{ scope: input.scope, recordType: ctx.recordType }
|
|
291
|
+
{ scope: input.scope, ...ctx.recordType ? { recordType: ctx.recordType } : {} }
|
|
280
292
|
);
|
|
281
293
|
return { removed: res.deleted ?? 0 };
|
|
282
294
|
}
|
|
@@ -287,7 +299,7 @@ var bulkDelete = async (ctx, input) => {
|
|
|
287
299
|
const res = await ctx.SL.app.records.bulkDelete(
|
|
288
300
|
ctx.collectionId,
|
|
289
301
|
ctx.appId,
|
|
290
|
-
{ refs: slice, recordType: ctx.recordType }
|
|
302
|
+
{ refs: slice, ...ctx.recordType ? { recordType: ctx.recordType } : {} }
|
|
291
303
|
);
|
|
292
304
|
removed += res.deleted ?? 0;
|
|
293
305
|
}
|
|
@@ -443,22 +455,27 @@ var resolveRecord = async (args) => {
|
|
|
443
455
|
if (records.length === 0) {
|
|
444
456
|
return { data: null, source: "empty" };
|
|
445
457
|
}
|
|
446
|
-
const
|
|
458
|
+
const winnerEntry = records[0];
|
|
459
|
+
const winner = winnerEntry.record;
|
|
447
460
|
const winnerIsSelf = scopesEqual(winner.scope, editingScope);
|
|
448
461
|
if (winnerIsSelf) {
|
|
449
|
-
const parent = records[1];
|
|
462
|
+
const parent = records[1]?.record;
|
|
450
463
|
return {
|
|
451
464
|
data: winner.data,
|
|
452
465
|
source: "self",
|
|
453
466
|
sourceRef: winner.ref ?? void 0,
|
|
454
|
-
parentValue: args.withParent && parent ? parent.data : void 0
|
|
467
|
+
parentValue: args.withParent && parent ? parent.data : void 0,
|
|
468
|
+
matchedAt: winnerEntry.matchedAt,
|
|
469
|
+
matchedRule: winnerEntry.matchedRule
|
|
455
470
|
};
|
|
456
471
|
}
|
|
457
472
|
return {
|
|
458
473
|
data: winner.data,
|
|
459
474
|
source: "inherited",
|
|
460
475
|
sourceRef: winner.ref ?? void 0,
|
|
461
|
-
parentValue: args.withParent ? winner.data : void 0
|
|
476
|
+
parentValue: args.withParent ? winner.data : void 0,
|
|
477
|
+
matchedAt: winnerEntry.matchedAt,
|
|
478
|
+
matchedRule: winnerEntry.matchedRule
|
|
462
479
|
};
|
|
463
480
|
};
|
|
464
481
|
|
|
@@ -469,7 +486,7 @@ var resolvedRecordQueryKey = (args) => [
|
|
|
469
486
|
"resolved",
|
|
470
487
|
args.collectionId,
|
|
471
488
|
args.appId,
|
|
472
|
-
args.recordType,
|
|
489
|
+
args.recordType ?? null,
|
|
473
490
|
args.productId ?? null,
|
|
474
491
|
args.variantId ?? null,
|
|
475
492
|
args.batchId ?? null,
|
|
@@ -658,7 +675,8 @@ function useRecordEditor(args) {
|
|
|
658
675
|
saveError
|
|
659
676
|
};
|
|
660
677
|
}
|
|
661
|
-
var
|
|
678
|
+
var RT_KEY = (recordType) => recordType ?? "_default";
|
|
679
|
+
var lsKey = (appId, recordType) => `ra:intro:${appId}:${RT_KEY(recordType)}`;
|
|
662
680
|
var useIntroDismissed = (SL, collectionId, appId, recordType) => {
|
|
663
681
|
const [dismissed, setDismissed] = useState(() => {
|
|
664
682
|
try {
|
|
@@ -673,7 +691,7 @@ var useIntroDismissed = (SL, collectionId, appId, recordType) => {
|
|
|
673
691
|
try {
|
|
674
692
|
const cfg = await SL?.appConfiguration?.getConfig?.({ collectionId, appId, admin: true });
|
|
675
693
|
if (cancelled) return;
|
|
676
|
-
const flag = cfg?._meta?.introDismissed?.[recordType];
|
|
694
|
+
const flag = cfg?._meta?.introDismissed?.[RT_KEY(recordType)];
|
|
677
695
|
if (flag) setDismissed(true);
|
|
678
696
|
} catch {
|
|
679
697
|
}
|
|
@@ -694,7 +712,7 @@ var useIntroDismissed = (SL, collectionId, appId, recordType) => {
|
|
|
694
712
|
...cfg ?? {},
|
|
695
713
|
_meta: {
|
|
696
714
|
...cfg?._meta ?? {},
|
|
697
|
-
introDismissed: { ...cfg?._meta?.introDismissed ?? {}, [recordType]: true }
|
|
715
|
+
introDismissed: { ...cfg?._meta?.introDismissed ?? {}, [RT_KEY(recordType)]: true }
|
|
698
716
|
}
|
|
699
717
|
};
|
|
700
718
|
await SL?.appConfiguration?.setConfig?.({ collectionId, appId, admin: true, config: next });
|
|
@@ -738,11 +756,11 @@ var toBrowseItem = (p) => ({
|
|
|
738
756
|
sortOrder: p.sortOrder ?? null
|
|
739
757
|
});
|
|
740
758
|
var useProductBrowse = (args) => {
|
|
741
|
-
const { SL, collectionId, search = "", pageSize = 50, enabled = true } = args;
|
|
759
|
+
const { SL, collectionId, search = "", pageSize = 50, enabled = true, admin = true } = args;
|
|
742
760
|
const queryClient = useQueryClient();
|
|
743
761
|
const queryKey = useMemo(
|
|
744
|
-
() => [...QK, collectionId, search.trim(), pageSize],
|
|
745
|
-
[collectionId, search, pageSize]
|
|
762
|
+
() => [...QK, collectionId, search.trim(), pageSize, admin],
|
|
763
|
+
[collectionId, search, pageSize, admin]
|
|
746
764
|
);
|
|
747
765
|
const query = useInfiniteQuery({
|
|
748
766
|
queryKey,
|
|
@@ -754,7 +772,7 @@ var useProductBrowse = (args) => {
|
|
|
754
772
|
sort: [{ field: "sortOrder", direction: "asc" }, { field: "name", direction: "asc" }]
|
|
755
773
|
};
|
|
756
774
|
if (search.trim()) body.query = { search: search.trim() };
|
|
757
|
-
const res = await SL.product.query(collectionId, body);
|
|
775
|
+
const res = await SL.product.query(collectionId, body, admin);
|
|
758
776
|
const items2 = (res?.items ?? []).map(toBrowseItem);
|
|
759
777
|
const page = res?.page ?? {};
|
|
760
778
|
return {
|
|
@@ -1298,7 +1316,7 @@ var safeWrite = (key, val) => {
|
|
|
1298
1316
|
};
|
|
1299
1317
|
function usePresentationPref(args) {
|
|
1300
1318
|
const { appId, recordType, options, defaultValue } = args;
|
|
1301
|
-
const key = `${KEY_PREFIX}:${appId}:${recordType}`;
|
|
1319
|
+
const key = `${KEY_PREFIX}:${appId}:${recordType ?? "_default"}`;
|
|
1302
1320
|
const initial = () => {
|
|
1303
1321
|
const stored = safeRead(key);
|
|
1304
1322
|
if (stored && options.includes(stored)) return stored;
|
|
@@ -2012,37 +2030,52 @@ function ShellHeader({
|
|
|
2012
2030
|
subtitle,
|
|
2013
2031
|
headerIcon,
|
|
2014
2032
|
headerActions,
|
|
2015
|
-
showStats =
|
|
2033
|
+
showStats = false,
|
|
2034
|
+
showHeaderIcon = true,
|
|
2016
2035
|
recordType,
|
|
2017
2036
|
icons,
|
|
2018
|
-
stats
|
|
2037
|
+
stats,
|
|
2038
|
+
statsItems
|
|
2019
2039
|
}) {
|
|
2020
|
-
let iconNode =
|
|
2021
|
-
if (
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2040
|
+
let iconNode = null;
|
|
2041
|
+
if (showHeaderIcon) {
|
|
2042
|
+
if (headerIcon) {
|
|
2043
|
+
iconNode = headerIcon;
|
|
2044
|
+
} else {
|
|
2045
|
+
const Icon = pickHeaderIcon(icons, recordType);
|
|
2046
|
+
iconNode = createElement(Icon, { className: "w-4 h-4", "aria-hidden": true });
|
|
2047
|
+
}
|
|
2048
|
+
}
|
|
2049
|
+
const resolvedItems = (() => {
|
|
2050
|
+
if (!showStats) return [];
|
|
2051
|
+
if (statsItems && statsItems.length > 0) return statsItems;
|
|
2052
|
+
const items = [];
|
|
2053
|
+
if (typeof stats?.shared === "number" && stats.shared > 0) {
|
|
2054
|
+
items.push({ label: "Shared", value: stats.shared });
|
|
2055
|
+
}
|
|
2056
|
+
if (typeof stats?.products === "number" && stats.products > 0) {
|
|
2057
|
+
items.push({ label: "Products", value: stats.products });
|
|
2058
|
+
}
|
|
2059
|
+
return items;
|
|
2060
|
+
})();
|
|
2061
|
+
const hasStats = resolvedItems.length > 0;
|
|
2026
2062
|
return /* @__PURE__ */ jsxs("header", { className: "ra-header", children: [
|
|
2027
2063
|
/* @__PURE__ */ jsxs("div", { className: "ra-header__main", children: [
|
|
2028
|
-
/* @__PURE__ */ jsx("div", { className: "ra-
|
|
2029
|
-
/* @__PURE__ */ jsxs("div", { className: "ra-
|
|
2030
|
-
/* @__PURE__ */ jsx("h1", { className: "ra-
|
|
2031
|
-
subtitle ? /* @__PURE__ */ jsx("p", { className: "ra-
|
|
2064
|
+
iconNode ? /* @__PURE__ */ jsx("div", { className: "ra-header-icon", "aria-hidden": "true", children: iconNode }) : null,
|
|
2065
|
+
/* @__PURE__ */ jsxs("div", { className: "ra-header-text", children: [
|
|
2066
|
+
/* @__PURE__ */ jsx("h1", { className: "ra-header-title", children: title }),
|
|
2067
|
+
subtitle ? /* @__PURE__ */ jsx("p", { className: "ra-header-subtitle", children: subtitle }) : null
|
|
2032
2068
|
] })
|
|
2033
2069
|
] }),
|
|
2034
|
-
/* @__PURE__ */ jsxs("div", { className: "ra-
|
|
2035
|
-
hasStats ? /* @__PURE__ */
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
/* @__PURE__ */ jsx("span", { className: "ra-
|
|
2039
|
-
|
|
2040
|
-
typeof stats.shared === "number" && /* @__PURE__ */ jsxs("span", { className: "ra-header__stat", children: [
|
|
2041
|
-
/* @__PURE__ */ jsx("span", { className: "ra-header__stat-value", children: stats.shared }),
|
|
2042
|
-
/* @__PURE__ */ jsx("span", { className: "ra-header__stat-label", children: "Shared" })
|
|
2070
|
+
/* @__PURE__ */ jsxs("div", { className: "ra-header-aside", children: [
|
|
2071
|
+
hasStats ? /* @__PURE__ */ jsx("div", { className: "ra-header-stats", role: "group", "aria-label": "Record counts", children: resolvedItems.map((item, idx) => /* @__PURE__ */ jsxs("span", { style: { display: "contents" }, children: [
|
|
2072
|
+
idx > 0 && /* @__PURE__ */ jsx("span", { className: "ra-stat-divider", "aria-hidden": "true" }),
|
|
2073
|
+
/* @__PURE__ */ jsxs("span", { className: "ra-stat", children: [
|
|
2074
|
+
/* @__PURE__ */ jsx("span", { className: "ra-stat-value", children: item.value }),
|
|
2075
|
+
/* @__PURE__ */ jsx("span", { className: "ra-stat-label", children: item.label })
|
|
2043
2076
|
] })
|
|
2044
|
-
] }) : null,
|
|
2045
|
-
headerActions ? /* @__PURE__ */ jsx("div", { className: "ra-
|
|
2077
|
+
] }, `${item.label}-${idx}`)) }) : null,
|
|
2078
|
+
headerActions ? /* @__PURE__ */ jsx("div", { className: "ra-header-actions", children: headerActions }) : null
|
|
2046
2079
|
] })
|
|
2047
2080
|
] });
|
|
2048
2081
|
}
|
|
@@ -2150,6 +2183,12 @@ var downloadBlob = (blob, filename) => {
|
|
|
2150
2183
|
document.body.removeChild(a);
|
|
2151
2184
|
URL.revokeObjectURL(url);
|
|
2152
2185
|
};
|
|
2186
|
+
|
|
2187
|
+
// src/components/RecordsAdmin/shell/tokens.css
|
|
2188
|
+
styleInject(':root {\n --ra-status-own: var(--ra-emerald, 142 71% 45%);\n --ra-status-shared: var(--ra-amber, 38 92% 50%);\n --ra-status-missing: var(--muted-foreground, 220 9% 46%);\n --ra-accent: var(--primary, 222 47% 11%);\n --ra-surface: var(--card, 0 0% 100%);\n --ra-border: var(--border, 220 13% 91%);\n --ra-text: var(--foreground, 222 47% 11%);\n --ra-muted: var(--muted, 220 14% 96%);\n --ra-muted-text: var(--muted-foreground, 220 9% 46%);\n --ra-radius: var(--radius, 0.625rem);\n --ra-dot-size: 0.5rem;\n --ra-page-bg: var(--background, 220 14% 98%);\n --ra-card-shadow: 0 1px 2px hsl(var(--ra-accent) / 0.04), 0 4px 12px hsl(var(--ra-accent) / 0.05);\n --ra-card-shadow-hover: 0 2px 4px hsl(var(--ra-accent) / 0.06), 0 8px 24px hsl(var(--ra-accent) / 0.08);\n --ra-row-hover: hsl(var(--ra-accent) / 0.05);\n --ra-row-active-bg: hsl(var(--ra-accent) / 0.10);\n --ra-row-active-bd: hsl(var(--ra-accent) / 0.45);\n --ra-focus-ring: hsl(var(--ra-accent) / 0.35);\n --ra-font-display: var(--font-display, var(--font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif));\n --ra-font-ui: var(--font-sans, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);\n --ra-title-weight: 600;\n --ra-display-weight: 700;\n --ra-info: var(--ra-blue, 214 95% 55%);\n --ra-success: var(--ra-emerald, 142 71% 45%);\n --ra-warning: var(--ra-amber, 38 92% 50%);\n --ra-danger: var(--destructive, 0 72% 51%);\n}\n.ra-status-dot {\n display: inline-block;\n width: var(--ra-dot-size);\n height: var(--ra-dot-size);\n border-radius: 9999px;\n flex-shrink: 0;\n}\n.ra-status-own {\n background: hsl(var(--ra-status-own));\n}\n.ra-status-shared {\n background: hsl(var(--ra-status-shared));\n}\n.ra-status-missing {\n background: hsl(var(--ra-status-missing) / 0.4);\n border: 1px solid hsl(var(--ra-status-missing) / 0.6);\n}\n.ra-row-active {\n background: var(--ra-row-active-bg);\n border-color: var(--ra-row-active-bd) !important;\n}\n');
|
|
2189
|
+
|
|
2190
|
+
// src/components/RecordsAdmin/shell/shell.css
|
|
2191
|
+
styleInject(".ra-shell {\n color: hsl(var(--ra-text));\n background: hsl(var(--ra-page-bg));\n font-family: var(--ra-font-ui);\n}\n.ra-shell *,\n.ra-shell *::before,\n.ra-shell *::after {\n box-sizing: border-box;\n}\n.ra-shell .ra-card {\n background: hsl(var(--ra-surface));\n border: 1px solid hsl(var(--ra-border));\n border-radius: var(--ra-radius);\n box-shadow: var(--ra-card-shadow);\n}\n.ra-shell .ra-card-hover {\n transition:\n box-shadow .18s ease,\n transform .18s ease,\n border-color .18s ease;\n}\n.ra-shell .ra-card-hover:hover {\n box-shadow: var(--ra-card-shadow-hover);\n}\n.ra-shell .ra-display {\n font-family: var(--ra-font-display);\n font-weight: var(--ra-display-weight);\n letter-spacing: -0.01em;\n}\n.ra-shell .ra-title {\n font-weight: var(--ra-title-weight);\n}\n.ra-shell :where(button, [role=button], input, select, textarea, a):focus-visible {\n outline: none;\n box-shadow: 0 0 0 3px var(--ra-focus-ring);\n border-radius: calc(var(--ra-radius) * 0.6);\n}\n.ra-shell .ra-header {\n position: relative;\n display: flex;\n align-items: center;\n gap: 0.75rem;\n padding: 0.65rem 0.9rem;\n border-radius: var(--ra-radius);\n border: 1px solid hsl(var(--ra-accent) / 0.12);\n background:\n linear-gradient(\n 135deg,\n hsl(var(--ra-accent) / 0.08),\n hsl(var(--ra-accent) / 0.02) 60%,\n hsl(var(--ra-surface)) 100%);\n box-shadow: var(--ra-card-shadow);\n}\n.ra-shell .ra-header__main {\n flex: 1;\n min-width: 0;\n display: flex;\n align-items: center;\n gap: 0.625rem;\n}\n.ra-shell .ra-header-aside {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n flex-shrink: 0;\n}\n.ra-shell .ra-header-icon {\n flex-shrink: 0;\n width: 2rem;\n height: 2rem;\n border-radius: calc(var(--ra-radius) * 0.9);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: hsl(var(--ra-accent) / 0.12);\n color: hsl(var(--ra-accent));\n border: 1px solid hsl(var(--ra-accent) / 0.18);\n}\n.ra-shell .ra-header-text {\n flex: 1;\n min-width: 0;\n}\n.ra-shell .ra-header-title {\n font-family: var(--ra-font-display);\n font-weight: var(--ra-display-weight);\n font-size: 1rem;\n line-height: 1.2;\n color: hsl(var(--ra-text));\n letter-spacing: -0.01em;\n margin: 0;\n}\n.ra-shell .ra-header-subtitle {\n font-size: 0.75rem;\n color: hsl(var(--ra-muted-text));\n margin-top: 0.125rem;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ra-shell .ra-header-stats {\n display: flex;\n align-items: stretch;\n gap: 0.15rem;\n padding: 0.15rem 0.4rem;\n border-radius: calc(var(--ra-radius) * 0.75);\n background: hsl(var(--ra-surface) / 0.7);\n border: 1px solid hsl(var(--ra-border));\n}\n.ra-shell .ra-stat {\n display: flex;\n flex-direction: column;\n align-items: center;\n padding: 0.15rem 0.45rem;\n min-width: 2.5rem;\n}\n.ra-shell .ra-stat-value {\n font-family: var(--ra-font-display);\n font-weight: var(--ra-display-weight);\n font-size: 0.85rem;\n color: hsl(var(--ra-text));\n line-height: 1;\n}\n.ra-shell .ra-stat-label {\n font-size: 0.6rem;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n color: hsl(var(--ra-muted-text));\n margin-top: 0.15rem;\n}\n.ra-shell .ra-stat-divider {\n width: 1px;\n background: hsl(var(--ra-border));\n margin: 0.25rem 0;\n}\n.ra-shell .ra-header-actions {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n}\n.ra-shell .ra-tabs {\n display: flex;\n gap: 0.25rem;\n padding: 0.25rem;\n background: hsl(var(--ra-muted));\n border-radius: calc(var(--ra-radius) * 0.85);\n border: 1px solid hsl(var(--ra-border));\n}\n.ra-shell .ra-tab {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n padding: 0.4rem 0.7rem;\n border-radius: calc(var(--ra-radius) * 0.65);\n font-size: 0.78rem;\n font-weight: 500;\n color: hsl(var(--ra-muted-text));\n background: transparent;\n border: 0;\n cursor: pointer;\n transition:\n background .15s ease,\n color .15s ease,\n transform .15s ease;\n white-space: nowrap;\n}\n.ra-shell .ra-tab:hover {\n background: hsl(var(--ra-surface));\n color: hsl(var(--ra-text));\n}\n.ra-shell .ra-tab[aria-selected=true] {\n background: hsl(var(--ra-surface));\n color: hsl(var(--ra-text));\n box-shadow: var(--ra-card-shadow);\n font-weight: var(--ra-title-weight);\n}\n.ra-shell .ra-tab[aria-selected=true] .ra-tab-icon {\n color: hsl(var(--ra-accent));\n}\n.ra-shell .ra-tab[disabled] {\n opacity: .5;\n cursor: not-allowed;\n}\n.ra-shell .ra-tab-count {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n min-width: 1.25rem;\n padding: 0 0.35rem;\n height: 1.1rem;\n border-radius: 999px;\n background: hsl(var(--ra-accent) / 0.12);\n color: hsl(var(--ra-accent));\n font-size: 0.625rem;\n font-weight: 600;\n line-height: 1;\n}\n.ra-shell .ra-tab[aria-selected=false] .ra-tab-count {\n background: hsl(var(--ra-muted-text) / 0.15);\n color: hsl(var(--ra-muted-text));\n}\n.ra-shell[data-density=compact] .ra-row {\n padding-block: 0.4rem;\n}\n.ra-shell[data-density=compact] .ra-header {\n padding: 0.75rem 1rem;\n}\n.ra-shell[data-density=compact] .ra-header-icon {\n width: 2.25rem;\n height: 2.25rem;\n}\n.ra-shell .ra-row {\n display: flex;\n align-items: center;\n gap: 0.65rem;\n width: 100%;\n text-align: left;\n padding: 0.65rem 0.85rem;\n border-left: 3px solid transparent;\n background: transparent;\n border-bottom: 1px solid transparent;\n transition: background .12s ease, border-color .12s ease;\n cursor: pointer;\n color: hsl(var(--ra-text));\n font-family: inherit;\n}\n.ra-shell .ra-row + .ra-row {\n border-top: 1px solid hsl(var(--ra-border) / 0.6);\n}\n.ra-shell .ra-row:hover {\n background: var(--ra-row-hover);\n}\n.ra-shell .ra-row[data-selected=true] {\n background: var(--ra-row-active-bg);\n border-left-color: var(--ra-row-active-bd);\n}\n.ra-shell .ra-row-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 1.75rem;\n height: 1.75rem;\n border-radius: calc(var(--ra-radius) * 0.6);\n background: hsl(var(--ra-muted));\n color: hsl(var(--ra-muted-text));\n flex-shrink: 0;\n}\n.ra-shell .ra-row[data-selected=true] .ra-row-icon {\n background: hsl(var(--ra-accent) / 0.15);\n color: hsl(var(--ra-accent));\n}\n.ra-shell .ra-row-body {\n flex: 1;\n min-width: 0;\n}\n.ra-shell .ra-row-title {\n font-weight: var(--ra-title-weight);\n font-size: 0.875rem;\n line-height: 1.25;\n color: hsl(var(--ra-text));\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ra-shell .ra-row-sub {\n font-size: 0.75rem;\n color: hsl(var(--ra-muted-text));\n margin-top: 0.15rem;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ra-shell .ra-row-actions {\n display: inline-flex;\n align-items: center;\n gap: 0.15rem;\n margin-left: auto;\n opacity: 0;\n transition: opacity .15s ease;\n}\n.ra-shell .ra-row:hover .ra-row-actions,\n.ra-shell .ra-row:focus-within .ra-row-actions {\n opacity: 1;\n}\n.ra-shell .ra-row-action {\n width: 1.6rem;\n height: 1.6rem;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n border-radius: 999px;\n background: transparent;\n color: hsl(var(--ra-muted-text));\n border: 0;\n cursor: pointer;\n transition: background .15s ease, color .15s ease;\n}\n.ra-shell .ra-row-action:hover {\n background: hsl(var(--ra-accent) / 0.10);\n color: hsl(var(--ra-text));\n}\n.ra-shell .ra-row-action[data-tone=danger]:hover {\n background: hsl(var(--ra-danger) / 0.12);\n color: hsl(var(--ra-danger));\n}\n.ra-shell .ra-chip {\n display: inline-flex;\n align-items: center;\n gap: 0.3rem;\n padding: 0.15rem 0.5rem;\n border-radius: 999px;\n font-size: 0.6875rem;\n font-weight: 500;\n background: hsl(var(--ra-muted));\n color: hsl(var(--ra-muted-text));\n border: 1px solid hsl(var(--ra-border));\n white-space: nowrap;\n max-width: 14rem;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ra-shell .ra-chip[data-tone=success] {\n background: hsl(var(--ra-success) / 0.12);\n color: hsl(var(--ra-success));\n border-color: hsl(var(--ra-success) / 0.30);\n}\n.ra-shell .ra-chip[data-tone=warning] {\n background: hsl(var(--ra-warning) / 0.14);\n color: hsl(var(--ra-warning));\n border-color: hsl(var(--ra-warning) / 0.35);\n}\n.ra-shell .ra-chip[data-tone=info] {\n background: hsl(var(--ra-info) / 0.10);\n color: hsl(var(--ra-info));\n border-color: hsl(var(--ra-info) / 0.30);\n}\n.ra-shell .ra-chip[data-tone=danger] {\n background: hsl(var(--ra-danger) / 0.10);\n color: hsl(var(--ra-danger));\n border-color: hsl(var(--ra-danger) / 0.30);\n}\n.ra-shell .ra-chip[data-tone=muted] {\n background: transparent;\n color: hsl(var(--ra-muted-text));\n border-style: dashed;\n}\n.ra-shell .ra-group {\n border-bottom: 1px solid hsl(var(--ra-border));\n}\n.ra-shell .ra-group:last-child {\n border-bottom: 0;\n}\n.ra-shell .ra-group-summary {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n width: 100%;\n padding: 0.5rem 0.85rem;\n background: hsl(var(--ra-muted) / 0.6);\n font-size: 0.7rem;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n color: hsl(var(--ra-muted-text));\n border: 0;\n cursor: pointer;\n transition: background .12s ease;\n}\n.ra-shell .ra-group-summary:hover {\n background: hsl(var(--ra-muted));\n}\n.ra-shell .ra-group-summary .ra-group-chevron {\n transition: transform .15s ease;\n}\n.ra-shell .ra-group[data-open=false] .ra-group-chevron {\n transform: rotate(-90deg);\n}\n.ra-shell .ra-group-name {\n flex: 1;\n text-align: left;\n}\n.ra-shell .ra-group-count {\n font-size: 0.65rem;\n font-weight: 600;\n color: hsl(var(--ra-muted-text));\n background: hsl(var(--ra-surface));\n border: 1px solid hsl(var(--ra-border));\n border-radius: 999px;\n padding: 0.05rem 0.4rem;\n}\n.ra-shell .ra-group[data-open=false] .ra-group-body {\n display: none;\n}\n.ra-shell .ra-empty {\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n text-align: center;\n padding: 2.5rem 1.5rem;\n gap: 0.75rem;\n}\n.ra-shell .ra-empty-icon {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 3.25rem;\n height: 3.25rem;\n border-radius: 999px;\n background: hsl(var(--ra-accent) / 0.08);\n color: hsl(var(--ra-accent));\n margin-bottom: 0.25rem;\n}\n.ra-shell .ra-empty-title {\n font-family: var(--ra-font-display);\n font-weight: var(--ra-display-weight);\n font-size: 1rem;\n color: hsl(var(--ra-text));\n margin: 0;\n letter-spacing: -0.01em;\n}\n.ra-shell .ra-empty-body {\n font-size: 0.8125rem;\n color: hsl(var(--ra-muted-text));\n max-width: 22rem;\n line-height: 1.45;\n}\n.ra-shell .ra-empty-actions {\n display: flex;\n align-items: center;\n gap: 0.5rem;\n margin-top: 0.25rem;\n flex-wrap: wrap;\n justify-content: center;\n}\n.ra-shell .ra-btn {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n padding: 0.45rem 0.85rem;\n border-radius: calc(var(--ra-radius) * 0.7);\n font-size: 0.8125rem;\n font-weight: 500;\n border: 1px solid hsl(var(--ra-border));\n background: hsl(var(--ra-surface));\n color: hsl(var(--ra-text));\n cursor: pointer;\n transition:\n background .15s ease,\n border-color .15s ease,\n box-shadow .15s ease,\n transform .1s ease;\n}\n.ra-shell .ra-btn:hover {\n background: hsl(var(--ra-muted));\n box-shadow: var(--ra-card-shadow);\n}\n.ra-shell .ra-btn:active {\n transform: translateY(1px);\n}\n.ra-shell .ra-btn[data-variant=primary] {\n background: hsl(var(--ra-accent));\n color: hsl(var(--ra-surface));\n border-color: hsl(var(--ra-accent));\n}\n.ra-shell .ra-btn[data-variant=primary]:hover {\n background: hsl(var(--ra-accent) / 0.92);\n}\n.ra-shell .ra-btn[data-variant=ghost] {\n background: transparent;\n border-color: transparent;\n color: hsl(var(--ra-muted-text));\n}\n.ra-shell .ra-btn[data-variant=ghost]:hover {\n background: hsl(var(--ra-muted));\n color: hsl(var(--ra-text));\n}\n.ra-shell .ra-btn[data-variant=danger] {\n color: hsl(var(--ra-danger));\n}\n.ra-shell .ra-btn[data-variant=danger]:hover {\n background: hsl(var(--ra-danger) / 0.10);\n border-color: hsl(var(--ra-danger) / 0.40);\n}\n.ra-shell .ra-intro {\n position: relative;\n display: flex;\n gap: 0.85rem;\n padding: 0.9rem 1rem;\n border-radius: var(--ra-radius);\n border: 1px solid hsl(var(--ra-info) / 0.30);\n background: hsl(var(--ra-info) / 0.08);\n margin-bottom: 1rem;\n}\n.ra-shell .ra-intro[data-tone=success] {\n border-color: hsl(var(--ra-success) / 0.30);\n background: hsl(var(--ra-success) / 0.08);\n}\n.ra-shell .ra-intro[data-tone=warning] {\n border-color: hsl(var(--ra-warning) / 0.35);\n background: hsl(var(--ra-warning) / 0.10);\n}\n.ra-shell .ra-intro-icon {\n flex-shrink: 0;\n width: 2rem;\n height: 2rem;\n border-radius: 999px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: hsl(var(--ra-info) / 0.18);\n color: hsl(var(--ra-info));\n}\n.ra-shell .ra-intro[data-tone=success] .ra-intro-icon {\n background: hsl(var(--ra-success) / 0.18);\n color: hsl(var(--ra-success));\n}\n.ra-shell .ra-intro[data-tone=warning] .ra-intro-icon {\n background: hsl(var(--ra-warning) / 0.20);\n color: hsl(var(--ra-warning));\n}\n.ra-shell .ra-intro-body {\n flex: 1;\n min-width: 0;\n}\n.ra-shell .ra-intro-title {\n font-family: var(--ra-font-display);\n font-weight: var(--ra-title-weight);\n font-size: 0.875rem;\n color: hsl(var(--ra-text));\n margin: 0 0 0.2rem 0;\n}\n.ra-shell .ra-intro-text {\n font-size: 0.8125rem;\n color: hsl(var(--ra-text) / 0.85);\n line-height: 1.45;\n}\n.ra-shell .ra-intro-dismiss {\n position: absolute;\n top: 0.5rem;\n right: 0.5rem;\n width: 1.6rem;\n height: 1.6rem;\n border-radius: 999px;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: 0;\n color: hsl(var(--ra-muted-text));\n cursor: pointer;\n}\n.ra-shell .ra-intro-dismiss:hover {\n background: hsl(var(--ra-text) / 0.06);\n color: hsl(var(--ra-text));\n}\n.ra-shell .ra-bulk-menu {\n min-width: 12rem;\n background: hsl(var(--ra-surface));\n border: 1px solid hsl(var(--ra-border));\n border-radius: calc(var(--ra-radius) * 0.85);\n box-shadow: var(--ra-card-shadow-hover);\n padding: 0.3rem;\n z-index: 30;\n}\n.ra-shell .ra-bulk-item {\n display: flex;\n align-items: center;\n gap: 0.55rem;\n width: 100%;\n padding: 0.45rem 0.6rem;\n border-radius: calc(var(--ra-radius) * 0.6);\n font-size: 0.8125rem;\n color: hsl(var(--ra-text));\n background: transparent;\n border: 0;\n cursor: pointer;\n text-align: left;\n transition: background .12s ease, color .12s ease;\n}\n.ra-shell .ra-bulk-item:hover {\n background: hsl(var(--ra-muted));\n}\n.ra-shell .ra-bulk-item[data-tone=danger] {\n color: hsl(var(--ra-danger));\n}\n.ra-shell .ra-bulk-item[data-tone=danger]:hover {\n background: hsl(var(--ra-danger) / 0.10);\n}\n.ra-shell .ra-bulk-divider {\n height: 1px;\n background: hsl(var(--ra-border));\n margin: 0.25rem 0;\n}\n.ra-shell .ra-preview-rail {\n background: hsl(var(--ra-surface));\n border-left: 1px solid hsl(var(--ra-border));\n box-shadow: -4px 0 16px hsl(var(--ra-accent) / 0.04);\n display: flex;\n flex-direction: column;\n height: 100%;\n overflow: hidden;\n}\n.ra-shell .ra-preview-rail-header {\n position: sticky;\n top: 0;\n z-index: 1;\n display: flex;\n align-items: center;\n gap: 0.5rem;\n padding: 0.75rem 1rem;\n background:\n linear-gradient(\n 180deg,\n hsl(var(--ra-surface)) 0%,\n hsl(var(--ra-surface) / 0.92) 100%);\n border-bottom: 1px solid hsl(var(--ra-border));\n backdrop-filter: blur(6px);\n}\n.ra-shell .ra-preview-rail-title {\n display: inline-flex;\n align-items: center;\n gap: 0.4rem;\n font-size: 0.7rem;\n font-weight: 600;\n text-transform: uppercase;\n letter-spacing: 0.06em;\n color: hsl(var(--ra-muted-text));\n}\n.ra-shell .ra-preview-rail-body {\n flex: 1;\n overflow-y: auto;\n padding: 1rem;\n}\n");
|
|
2153
2192
|
var TOP_LEVEL_SCOPES = ["product", "facet"];
|
|
2154
2193
|
var defaultItemId = () => {
|
|
2155
2194
|
const time = Date.now().toString(36);
|
|
@@ -2204,7 +2243,9 @@ function RecordsAdminShell(props) {
|
|
|
2204
2243
|
subtitle,
|
|
2205
2244
|
headerIcon,
|
|
2206
2245
|
headerActions,
|
|
2207
|
-
showStats =
|
|
2246
|
+
showStats = false,
|
|
2247
|
+
showHeaderIcon = true,
|
|
2248
|
+
statsItems,
|
|
2208
2249
|
icons: iconsOverride,
|
|
2209
2250
|
groupBy,
|
|
2210
2251
|
renderEmptyState,
|
|
@@ -2399,8 +2440,9 @@ function RecordsAdminShell(props) {
|
|
|
2399
2440
|
});
|
|
2400
2441
|
const handleExport = () => {
|
|
2401
2442
|
if (!csvSchema) return;
|
|
2443
|
+
const fileBase = recordType ?? (label.toLowerCase().replace(/\s+/g, "-") || "records");
|
|
2402
2444
|
const blob = exportCsv(recordList.items, csvSchema);
|
|
2403
|
-
downloadBlob(blob, `${
|
|
2445
|
+
downloadBlob(blob, `${fileBase}.csv`);
|
|
2404
2446
|
onTelemetry?.({ type: "csv.export", recordType, rows: recordList.items.length });
|
|
2405
2447
|
};
|
|
2406
2448
|
const handleImport = () => {
|
|
@@ -2414,7 +2456,8 @@ function RecordsAdminShell(props) {
|
|
|
2414
2456
|
const report = await importCsv(file, csvSchema, ctx);
|
|
2415
2457
|
onTelemetry?.({ type: "csv.import", recordType, rows: report.total, errors: report.failed });
|
|
2416
2458
|
if (report.failed > 0) {
|
|
2417
|
-
|
|
2459
|
+
const fileBase = recordType ?? (label.toLowerCase().replace(/\s+/g, "-") || "records");
|
|
2460
|
+
downloadBlob(new Blob([report.annotatedCsv], { type: "text/csv" }), `${fileBase}-errors.csv`);
|
|
2418
2461
|
}
|
|
2419
2462
|
refetchAll();
|
|
2420
2463
|
};
|
|
@@ -2554,12 +2597,14 @@ function RecordsAdminShell(props) {
|
|
|
2554
2597
|
headerIcon,
|
|
2555
2598
|
headerActions,
|
|
2556
2599
|
showStats,
|
|
2600
|
+
showHeaderIcon,
|
|
2557
2601
|
recordType,
|
|
2558
2602
|
icons,
|
|
2559
2603
|
stats: {
|
|
2560
2604
|
products: productBrowse.items.length,
|
|
2561
2605
|
shared: recordList.items.length
|
|
2562
|
-
}
|
|
2606
|
+
},
|
|
2607
|
+
statsItems
|
|
2563
2608
|
}
|
|
2564
2609
|
),
|
|
2565
2610
|
/* @__PURE__ */ jsx(
|
|
@@ -2721,7 +2766,7 @@ function RecordsAdminShell(props) {
|
|
|
2721
2766
|
EmptyState,
|
|
2722
2767
|
{
|
|
2723
2768
|
title: drillTab === "variant" ? "Pick a variant" : "Pick a batch",
|
|
2724
|
-
body: `Select a ${drillTab} on the left to edit its ${recordType}.`
|
|
2769
|
+
body: `Select a ${drillTab} on the left to edit its ${recordType ?? label.toLowerCase()}.`
|
|
2725
2770
|
}
|
|
2726
2771
|
)
|
|
2727
2772
|
}
|
|
@@ -2842,6 +2887,112 @@ var ResolvedPreview = ({ children }) => /* @__PURE__ */ jsxs("div", { className:
|
|
|
2842
2887
|
/* @__PURE__ */ jsx("div", { className: "text-[10px] uppercase tracking-wide mb-2", style: { color: "hsl(var(--ra-muted-text))" }, children: "Public preview" }),
|
|
2843
2888
|
children
|
|
2844
2889
|
] });
|
|
2890
|
+
var resolveAllQueryKey = (args) => [
|
|
2891
|
+
"records-admin",
|
|
2892
|
+
"resolve-all",
|
|
2893
|
+
args.collectionId,
|
|
2894
|
+
args.appId,
|
|
2895
|
+
args.recordType ?? null,
|
|
2896
|
+
args.context.productId ?? null,
|
|
2897
|
+
args.context.variantId ?? null,
|
|
2898
|
+
args.context.batchId ?? null,
|
|
2899
|
+
args.context.proofId ?? null,
|
|
2900
|
+
args.context.facets ?? null,
|
|
2901
|
+
args.tiers ?? null,
|
|
2902
|
+
args.limit ?? null,
|
|
2903
|
+
args.at ?? null,
|
|
2904
|
+
args.includeScheduled ?? false,
|
|
2905
|
+
args.includeExpired ?? false,
|
|
2906
|
+
args.admin ?? false
|
|
2907
|
+
];
|
|
2908
|
+
function useResolveAllRecords(args) {
|
|
2909
|
+
const {
|
|
2910
|
+
SL,
|
|
2911
|
+
collectionId,
|
|
2912
|
+
appId,
|
|
2913
|
+
recordType,
|
|
2914
|
+
context,
|
|
2915
|
+
tiers,
|
|
2916
|
+
limit,
|
|
2917
|
+
at,
|
|
2918
|
+
includeScheduled,
|
|
2919
|
+
includeExpired,
|
|
2920
|
+
admin = false,
|
|
2921
|
+
enabled = true,
|
|
2922
|
+
staleTime = 15e3
|
|
2923
|
+
} = args;
|
|
2924
|
+
const query = useQuery({
|
|
2925
|
+
queryKey: resolveAllQueryKey(args),
|
|
2926
|
+
enabled: enabled && !!collectionId && !!appId,
|
|
2927
|
+
staleTime,
|
|
2928
|
+
queryFn: () => SL.app.records.resolveAll(
|
|
2929
|
+
collectionId,
|
|
2930
|
+
appId,
|
|
2931
|
+
{
|
|
2932
|
+
context,
|
|
2933
|
+
...recordType ? { recordType } : {},
|
|
2934
|
+
...tiers ? { tiers } : {},
|
|
2935
|
+
...limit !== void 0 ? { limit } : {},
|
|
2936
|
+
...at ? { at } : {},
|
|
2937
|
+
...includeScheduled !== void 0 ? { includeScheduled } : {},
|
|
2938
|
+
...includeExpired !== void 0 ? { includeExpired } : {}
|
|
2939
|
+
},
|
|
2940
|
+
admin
|
|
2941
|
+
)
|
|
2942
|
+
});
|
|
2943
|
+
return {
|
|
2944
|
+
records: query.data?.records ?? [],
|
|
2945
|
+
truncated: query.data?.truncated ?? false,
|
|
2946
|
+
isLoading: query.isLoading,
|
|
2947
|
+
error: query.error ?? null,
|
|
2948
|
+
refetch: () => {
|
|
2949
|
+
void query.refetch();
|
|
2950
|
+
}
|
|
2951
|
+
};
|
|
2952
|
+
}
|
|
2953
|
+
var isRuleValid = (rule) => {
|
|
2954
|
+
if (!rule || !Array.isArray(rule.all) || rule.all.length === 0) return false;
|
|
2955
|
+
return rule.all.every(
|
|
2956
|
+
(c) => !!c.facetKey && Array.isArray(c.anyOf) && c.anyOf.length > 0
|
|
2957
|
+
);
|
|
2958
|
+
};
|
|
2959
|
+
function useRulePreview(args) {
|
|
2960
|
+
const {
|
|
2961
|
+
SL,
|
|
2962
|
+
collectionId,
|
|
2963
|
+
appId,
|
|
2964
|
+
rule,
|
|
2965
|
+
limit = 20,
|
|
2966
|
+
debounceMs = 350,
|
|
2967
|
+
enabled = true
|
|
2968
|
+
} = args;
|
|
2969
|
+
const [debouncedRule, setDebouncedRule] = useState(rule);
|
|
2970
|
+
const timer = useRef(null);
|
|
2971
|
+
useEffect(() => {
|
|
2972
|
+
if (timer.current) clearTimeout(timer.current);
|
|
2973
|
+
timer.current = setTimeout(() => setDebouncedRule(rule), debounceMs);
|
|
2974
|
+
return () => {
|
|
2975
|
+
if (timer.current) clearTimeout(timer.current);
|
|
2976
|
+
};
|
|
2977
|
+
}, [rule, debounceMs]);
|
|
2978
|
+
const valid = isRuleValid(debouncedRule);
|
|
2979
|
+
const query = useQuery({
|
|
2980
|
+
queryKey: ["records-admin", "preview-rule", collectionId, appId, debouncedRule, limit],
|
|
2981
|
+
enabled: enabled && !!collectionId && !!appId && valid,
|
|
2982
|
+
staleTime: 3e4,
|
|
2983
|
+
queryFn: () => SL.app.records.previewRule(collectionId, appId, {
|
|
2984
|
+
facetRule: debouncedRule,
|
|
2985
|
+
limit
|
|
2986
|
+
})
|
|
2987
|
+
});
|
|
2988
|
+
return {
|
|
2989
|
+
totalMatches: query.data?.totalMatches ?? null,
|
|
2990
|
+
sampleProductIds: query.data?.sampleProductIds ?? [],
|
|
2991
|
+
isLoading: query.isFetching,
|
|
2992
|
+
isStale: rule !== debouncedRule,
|
|
2993
|
+
error: query.error ?? null
|
|
2994
|
+
};
|
|
2995
|
+
}
|
|
2845
2996
|
var DEFAULT_SCOPES2 = ["batch", "variant", "product", "facet"];
|
|
2846
2997
|
var readField = (data, path) => {
|
|
2847
2998
|
if (data == null || typeof data !== "object") return void 0;
|
|
@@ -2882,7 +3033,7 @@ function useCollectedRecords(args) {
|
|
|
2882
3033
|
"collected",
|
|
2883
3034
|
collectionId,
|
|
2884
3035
|
appId,
|
|
2885
|
-
recordType,
|
|
3036
|
+
recordType ?? null,
|
|
2886
3037
|
productId ?? null,
|
|
2887
3038
|
variantId ?? null,
|
|
2888
3039
|
batchId ?? null,
|
|
@@ -2904,12 +3055,15 @@ function useCollectedRecords(args) {
|
|
|
2904
3055
|
const ctx = { SL, collectionId, appId, recordType };
|
|
2905
3056
|
const result = await matchRecords(ctx, parsedRefToTarget(target), { strategy: "all" }).catch(() => null);
|
|
2906
3057
|
const records = result?.records ?? [];
|
|
2907
|
-
const baseList = records.map((
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
3058
|
+
const baseList = records.map((entry, i) => {
|
|
3059
|
+
const rec = entry.record;
|
|
3060
|
+
return {
|
|
3061
|
+
ref: rec.ref ?? "",
|
|
3062
|
+
scope: parseRef(rec.ref ?? ""),
|
|
3063
|
+
data: rec.data,
|
|
3064
|
+
depth: i
|
|
3065
|
+
};
|
|
3066
|
+
});
|
|
2913
3067
|
const sortKind = sort?.kind ?? "specificity";
|
|
2914
3068
|
const direction = sort?.direction ?? (sortKind === "specificity" ? "desc" : "asc");
|
|
2915
3069
|
const sign = direction === "desc" ? -1 : 1;
|
|
@@ -2972,7 +3126,7 @@ function useMergedRecord(args) {
|
|
|
2972
3126
|
"merged",
|
|
2973
3127
|
collectionId,
|
|
2974
3128
|
appId,
|
|
2975
|
-
recordType,
|
|
3129
|
+
recordType ?? null,
|
|
2976
3130
|
productId ?? null,
|
|
2977
3131
|
variantId ?? null,
|
|
2978
3132
|
batchId ?? null,
|
|
@@ -2994,7 +3148,10 @@ function useMergedRecord(args) {
|
|
|
2994
3148
|
const result = await matchRecords(ctx, parsedRefToTarget(target), { strategy: "all" }).catch(() => null);
|
|
2995
3149
|
const records = result?.records ?? [];
|
|
2996
3150
|
if (records.length === 0) return { data: null, provenance: {}, layers: [] };
|
|
2997
|
-
const present = records.map((
|
|
3151
|
+
const present = records.map((entry) => ({
|
|
3152
|
+
ref: entry.record.ref ?? "",
|
|
3153
|
+
data: entry.record.data
|
|
3154
|
+
}));
|
|
2998
3155
|
const ordered = [...present].reverse();
|
|
2999
3156
|
let merged = null;
|
|
3000
3157
|
const provenance = {};
|
|
@@ -3016,6 +3173,6 @@ function useMergedRecord(args) {
|
|
|
3016
3173
|
};
|
|
3017
3174
|
}
|
|
3018
3175
|
|
|
3019
|
-
export { ALL_PRESENTATIONS, BatchList, BulkActionsMenu, DEFAULT_I18N, DEFAULT_ICONS, DefaultRecordCard, DefaultRecordRow, DeleteButton, DrawerPreview, EmptyState, ErrorState, FacetList, InheritanceMarker, InheritanceProvider, InlinePreview, IntroCard, LoadingState, PresentationSwitcher, PreviewScopePicker, PreviewToggleButton, ProductDrillDown, ProductList, RecordBrowser, RecordEditor, RecordList, RecordsAdminShell, ResolvedPreview, ScopeBreadcrumb, ScopeTabs, SidePreview, StatusDot, StatusFilterPills, TabbedPreview, UtilityRow, VariantList, buildRef, bulkDelete, bulkUpsert, deleteRecord, downloadBlob, exportCsv, getRecordByRef, importCsv, listRecords, matchRecords, mergeIcons, parseRef, parsedRefToScope, parsedRefToTarget, pickHeaderIcon, resolutionChain, resolveRecord, restoreRecord, scopesEqual, upsertRecord, useCollectedRecords, useDirtyNavigation, useIntroDismissed, useMergedRecord, usePresentationPref, useProductBrowse, useProductChildren, useRecordEditor, useRecordList, useResolvedRecord, useScopeProbe, useUnsavedGuard };
|
|
3176
|
+
export { ALL_PRESENTATIONS, BatchList, BulkActionsMenu, DEFAULT_I18N, DEFAULT_ICONS, DefaultRecordCard, DefaultRecordRow, DeleteButton, DrawerPreview, EmptyState, ErrorState, FacetList, InheritanceMarker, InheritanceProvider, InlinePreview, IntroCard, LoadingState, PresentationSwitcher, PreviewScopePicker, PreviewToggleButton, ProductDrillDown, ProductList, RecordBrowser, RecordEditor, RecordList, RecordsAdminShell, ResolvedPreview, ScopeBreadcrumb, ScopeTabs, SidePreview, StatusDot, StatusFilterPills, TabbedPreview, UtilityRow, VariantList, buildRef, bulkDelete, bulkUpsert, deleteRecord, downloadBlob, exportCsv, getRecordByRef, importCsv, listRecords, matchRecords, mergeIcons, parseRef, parsedRefToScope, parsedRefToTarget, pickHeaderIcon, resolutionChain, resolveRecord, restoreRecord, scopesEqual, upsertRecord, useCollectedRecords, useDirtyNavigation, useIntroDismissed, useMergedRecord, usePresentationPref, useProductBrowse, useProductChildren, useRecordEditor, useRecordList, useResolveAllRecords, useResolvedRecord, useRulePreview, useScopeProbe, useUnsavedGuard };
|
|
3020
3177
|
//# sourceMappingURL=index.js.map
|
|
3021
3178
|
//# sourceMappingURL=index.js.map
|