@proveanything/smartlinks-utils-ui 0.12.23 → 0.12.24
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.
|
@@ -944,6 +944,22 @@ interface RecordsAdminShellProps<TData = unknown> {
|
|
|
944
944
|
label: string;
|
|
945
945
|
scopes: ScopeKind[];
|
|
946
946
|
defaultScope?: ScopeKind;
|
|
947
|
+
/**
|
|
948
|
+
* Hard ceiling on inheritance-chain drill-down depth, regardless of what
|
|
949
|
+
* the collection has enabled.
|
|
950
|
+
*
|
|
951
|
+
* - `'product'` — never expose variant or batch tabs even if the collection
|
|
952
|
+
* has those rungs turned on. Use when an app deliberately wants its
|
|
953
|
+
* records to stay product-level (e.g. editorial content that must be
|
|
954
|
+
* consistent across all variants).
|
|
955
|
+
* - `'variant'` — allow variant drill-down but hide batches.
|
|
956
|
+
* - `'batch'` (default) — allow the full chain when the collection supports it.
|
|
957
|
+
*
|
|
958
|
+
* Note: this is intentionally framed as a depth ceiling rather than a
|
|
959
|
+
* per-dimension list, so future sub-product dimensions are covered
|
|
960
|
+
* automatically. The `scopes` prop continues to define top-level tabs only.
|
|
961
|
+
*/
|
|
962
|
+
maxDrillDepth?: 'product' | 'variant' | 'batch';
|
|
947
963
|
/**
|
|
948
964
|
* Context from the host URL (productId/variantId/batchId).
|
|
949
965
|
* When provided, the browser is constrained to that subtree:
|
|
@@ -1827,6 +1843,10 @@ interface Props$a {
|
|
|
1827
1843
|
batches: ProductChildItem[];
|
|
1828
1844
|
variantsLoading: boolean;
|
|
1829
1845
|
batchesLoading: boolean;
|
|
1846
|
+
/** Variant ids that already have a record at this product. */
|
|
1847
|
+
variantsWithRecord?: Set<string>;
|
|
1848
|
+
/** Batch ids that already have a record at this product. */
|
|
1849
|
+
batchesWithRecord?: Set<string>;
|
|
1830
1850
|
/** Editor body rendered to the right of the picker. */
|
|
1831
1851
|
children: ReactNode;
|
|
1832
1852
|
/**
|
|
@@ -1838,7 +1858,7 @@ interface Props$a {
|
|
|
1838
1858
|
*/
|
|
1839
1859
|
hideSingleTab?: boolean;
|
|
1840
1860
|
}
|
|
1841
|
-
declare const ProductDrillDown: ({ productLabel, showVariants, showBatches, active, onChange, selectedChildId, onSelectChild, variants, batches, variantsLoading, batchesLoading, children, hideSingleTab, }: Props$a) => react_jsx_runtime.JSX.Element;
|
|
1861
|
+
declare const ProductDrillDown: ({ productLabel, showVariants, showBatches, active, onChange, selectedChildId, onSelectChild, variants, batches, variantsLoading, batchesLoading, variantsWithRecord, batchesWithRecord, children, hideSingleTab, }: Props$a) => react_jsx_runtime.JSX.Element;
|
|
1842
1862
|
|
|
1843
1863
|
type PreviewMode = 'inline' | 'side' | 'tab' | 'drawer';
|
|
1844
1864
|
interface CommonProps {
|
|
@@ -687,6 +687,60 @@ var useScopeProbe = ({ SL, collectionId, admin = true, enabled = true }) => {
|
|
|
687
687
|
error: query.error ?? null
|
|
688
688
|
};
|
|
689
689
|
};
|
|
690
|
+
var QK = ["records-admin", "product-sub-records"];
|
|
691
|
+
var useProductSubRecords = (args) => {
|
|
692
|
+
const { SL, collectionId, appId, recordType, productId, enabled = true } = args;
|
|
693
|
+
const queryClient = useQueryClient();
|
|
694
|
+
const queryKey = useMemo(
|
|
695
|
+
() => [...QK, collectionId, appId, recordType ?? null, productId ?? null],
|
|
696
|
+
[collectionId, appId, recordType, productId]
|
|
697
|
+
);
|
|
698
|
+
const query = useQuery({
|
|
699
|
+
queryKey,
|
|
700
|
+
enabled: enabled && !!collectionId && !!appId && !!productId,
|
|
701
|
+
staleTime: 15e3,
|
|
702
|
+
queryFn: async () => {
|
|
703
|
+
if (!productId) return { variantIds: [], batchIds: [] };
|
|
704
|
+
const variantIds = /* @__PURE__ */ new Set();
|
|
705
|
+
const batchIds = /* @__PURE__ */ new Set();
|
|
706
|
+
let offset = 0;
|
|
707
|
+
const limit = 200;
|
|
708
|
+
for (let i = 0; i < 20; i++) {
|
|
709
|
+
const res = await SL.app.records.list(
|
|
710
|
+
collectionId,
|
|
711
|
+
appId,
|
|
712
|
+
{
|
|
713
|
+
...recordType ? { recordType } : {},
|
|
714
|
+
limit,
|
|
715
|
+
offset
|
|
716
|
+
},
|
|
717
|
+
true
|
|
718
|
+
).catch(() => null);
|
|
719
|
+
const data = res?.data ?? [];
|
|
720
|
+
for (const rec of data) {
|
|
721
|
+
const pId = rec.productId;
|
|
722
|
+
if (pId !== productId) continue;
|
|
723
|
+
const vId = rec.variantId;
|
|
724
|
+
const bId = rec.batchId;
|
|
725
|
+
if (vId) variantIds.add(vId);
|
|
726
|
+
if (bId) batchIds.add(bId);
|
|
727
|
+
}
|
|
728
|
+
if (!res?.pagination?.hasMore || data.length === 0) break;
|
|
729
|
+
offset += data.length;
|
|
730
|
+
}
|
|
731
|
+
return { variantIds: [...variantIds], batchIds: [...batchIds] };
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
const refetch = () => queryClient.invalidateQueries({
|
|
735
|
+
queryKey: [...QK, collectionId, appId, recordType ?? null, productId ?? null]
|
|
736
|
+
});
|
|
737
|
+
return {
|
|
738
|
+
variantIds: new Set(query.data?.variantIds ?? []),
|
|
739
|
+
batchIds: new Set(query.data?.batchIds ?? []),
|
|
740
|
+
isLoading: query.isLoading,
|
|
741
|
+
refetch
|
|
742
|
+
};
|
|
743
|
+
};
|
|
690
744
|
var QK_BASE = ["records-admin", "scope-counts"];
|
|
691
745
|
var classify = (rec) => {
|
|
692
746
|
const hasRule = !!rec.facetRule;
|
|
@@ -1048,7 +1102,7 @@ var useRecordList = (args) => {
|
|
|
1048
1102
|
};
|
|
1049
1103
|
};
|
|
1050
1104
|
var LOG = "[RecordsAdmin/useFacetBrowse]";
|
|
1051
|
-
var
|
|
1105
|
+
var QK2 = ["records-admin", "facet-browse"];
|
|
1052
1106
|
var toScaffoldSummary = (facet, value) => {
|
|
1053
1107
|
const facetKey = facet.key ?? "";
|
|
1054
1108
|
const valueKey = value.key ?? "";
|
|
@@ -1077,7 +1131,7 @@ var useFacetBrowse = ({
|
|
|
1077
1131
|
const hasAnyList = hasAdminList || hasPublicList;
|
|
1078
1132
|
const queryEnabled = enabled && !!collectionId && hasAnyList;
|
|
1079
1133
|
const query = useQuery({
|
|
1080
|
-
queryKey: [...
|
|
1134
|
+
queryKey: [...QK2, collectionId],
|
|
1081
1135
|
enabled: queryEnabled,
|
|
1082
1136
|
staleTime: 3e4,
|
|
1083
1137
|
queryFn: async () => {
|
|
@@ -1151,7 +1205,7 @@ var useFacetBrowse = ({
|
|
|
1151
1205
|
empty: mergedItems.filter((item) => item.status === "empty").length
|
|
1152
1206
|
}), [mergedItems]);
|
|
1153
1207
|
const refetch = () => {
|
|
1154
|
-
queryClient.invalidateQueries({ queryKey: [...
|
|
1208
|
+
queryClient.invalidateQueries({ queryKey: [...QK2, collectionId] });
|
|
1155
1209
|
};
|
|
1156
1210
|
return {
|
|
1157
1211
|
items: filteredItems,
|
|
@@ -1168,7 +1222,7 @@ var useFacetBrowse = ({
|
|
|
1168
1222
|
vocabulary: query.data ?? []
|
|
1169
1223
|
};
|
|
1170
1224
|
};
|
|
1171
|
-
var
|
|
1225
|
+
var QK3 = ["records-admin", "product-browse"];
|
|
1172
1226
|
var toBrowseItem = (p) => ({
|
|
1173
1227
|
id: p.id ?? p.productId ?? "",
|
|
1174
1228
|
name: p.name ?? p.id ?? "Untitled",
|
|
@@ -1179,7 +1233,7 @@ var useProductBrowse = (args) => {
|
|
|
1179
1233
|
const { SL, collectionId, search = "", pageSize = 50, enabled = true, admin = true } = args;
|
|
1180
1234
|
const queryClient = useQueryClient();
|
|
1181
1235
|
const queryKey = useMemo(
|
|
1182
|
-
() => [...
|
|
1236
|
+
() => [...QK3, collectionId, search.trim(), pageSize, admin],
|
|
1183
1237
|
[collectionId, search, pageSize, admin]
|
|
1184
1238
|
);
|
|
1185
1239
|
const query = useInfiniteQuery({
|
|
@@ -1230,7 +1284,7 @@ var useProductBrowse = (args) => {
|
|
|
1230
1284
|
() => query.data?.pages.flatMap((p) => p.items) ?? [],
|
|
1231
1285
|
[query.data]
|
|
1232
1286
|
);
|
|
1233
|
-
const refetch = () => queryClient.invalidateQueries({ queryKey: [...
|
|
1287
|
+
const refetch = () => queryClient.invalidateQueries({ queryKey: [...QK3, collectionId] });
|
|
1234
1288
|
return {
|
|
1235
1289
|
items,
|
|
1236
1290
|
total: query.data?.pages[query.data.pages.length - 1]?.total,
|
|
@@ -1242,7 +1296,7 @@ var useProductBrowse = (args) => {
|
|
|
1242
1296
|
refetch
|
|
1243
1297
|
};
|
|
1244
1298
|
};
|
|
1245
|
-
var
|
|
1299
|
+
var QK4 = ["records-admin", "product-children"];
|
|
1246
1300
|
var variantToItem = (v) => ({
|
|
1247
1301
|
id: v.id ?? v.variantId ?? "",
|
|
1248
1302
|
name: v.name ?? v.label ?? v.id ?? "Untitled variant",
|
|
@@ -1257,7 +1311,7 @@ var useProductChildren = (args) => {
|
|
|
1257
1311
|
const { SL, collectionId, productId, kind, enabled = true } = args;
|
|
1258
1312
|
const queryClient = useQueryClient();
|
|
1259
1313
|
const queryKey = useMemo(
|
|
1260
|
-
() => [...
|
|
1314
|
+
() => [...QK4, collectionId, productId ?? null, kind],
|
|
1261
1315
|
[collectionId, productId, kind]
|
|
1262
1316
|
);
|
|
1263
1317
|
const query = useQuery({
|
|
@@ -1275,7 +1329,7 @@ var useProductChildren = (args) => {
|
|
|
1275
1329
|
}
|
|
1276
1330
|
});
|
|
1277
1331
|
const refetch = () => queryClient.invalidateQueries({
|
|
1278
|
-
queryKey: [...
|
|
1332
|
+
queryKey: [...QK4, collectionId, productId ?? null]
|
|
1279
1333
|
});
|
|
1280
1334
|
return {
|
|
1281
1335
|
items: query.data ?? [],
|
|
@@ -1387,7 +1441,7 @@ function useShellBrowser(opts) {
|
|
|
1387
1441
|
refetchAll
|
|
1388
1442
|
};
|
|
1389
1443
|
}
|
|
1390
|
-
var
|
|
1444
|
+
var QK5 = ["records-admin", "single-product"];
|
|
1391
1445
|
var toBrowseItem2 = (p, fallbackId) => ({
|
|
1392
1446
|
id: p?.id ?? p?.productId ?? fallbackId,
|
|
1393
1447
|
name: p?.name ?? fallbackId,
|
|
@@ -1397,7 +1451,7 @@ var toBrowseItem2 = (p, fallbackId) => ({
|
|
|
1397
1451
|
var useSingleProduct = (args) => {
|
|
1398
1452
|
const { SL, collectionId, productId, enabled = true, admin = true } = args;
|
|
1399
1453
|
const query = useQuery({
|
|
1400
|
-
queryKey: [...
|
|
1454
|
+
queryKey: [...QK5, collectionId, productId, admin],
|
|
1401
1455
|
enabled: enabled && !!collectionId && !!productId,
|
|
1402
1456
|
staleTime: 6e4,
|
|
1403
1457
|
queryFn: async () => {
|
|
@@ -6232,6 +6286,8 @@ var ProductDrillDown = ({
|
|
|
6232
6286
|
batches,
|
|
6233
6287
|
variantsLoading,
|
|
6234
6288
|
batchesLoading,
|
|
6289
|
+
variantsWithRecord,
|
|
6290
|
+
batchesWithRecord,
|
|
6235
6291
|
children,
|
|
6236
6292
|
hideSingleTab
|
|
6237
6293
|
}) => {
|
|
@@ -6242,6 +6298,7 @@ var ProductDrillDown = ({
|
|
|
6242
6298
|
const childList = active === "variant" ? variants : active === "batch" ? batches : [];
|
|
6243
6299
|
const childLoading = active === "variant" ? variantsLoading : active === "batch" ? batchesLoading : false;
|
|
6244
6300
|
const childEmptyLabel = active === "variant" ? "No variants" : "No batches";
|
|
6301
|
+
const childHasRecord = active === "variant" ? variantsWithRecord : active === "batch" ? batchesWithRecord : void 0;
|
|
6245
6302
|
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col h-full", children: [
|
|
6246
6303
|
showTabStrip && /* @__PURE__ */ jsx(
|
|
6247
6304
|
"div",
|
|
@@ -6291,7 +6348,8 @@ var ProductDrillDown = ({
|
|
|
6291
6348
|
!childLoading && childList.length === 0 && /* @__PURE__ */ jsx("div", { className: "p-4 text-xs", style: { color: "hsl(var(--ra-muted-text))" }, children: childEmptyLabel }),
|
|
6292
6349
|
!childLoading && childList.length > 0 && /* @__PURE__ */ jsx("ul", { className: "divide-y", style: { borderColor: "hsl(var(--ra-border))" }, children: childList.map((c) => {
|
|
6293
6350
|
const isActive2 = c.id === selectedChildId;
|
|
6294
|
-
|
|
6351
|
+
const hasRecord = childHasRecord?.has(c.id) ?? false;
|
|
6352
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
|
|
6295
6353
|
"button",
|
|
6296
6354
|
{
|
|
6297
6355
|
type: "button",
|
|
@@ -6300,10 +6358,20 @@ var ProductDrillDown = ({
|
|
|
6300
6358
|
"w-full text-left px-3 py-2 transition-colors hover:bg-[hsl(var(--ra-muted))]",
|
|
6301
6359
|
isActive2 && "ra-row-active"
|
|
6302
6360
|
),
|
|
6303
|
-
children: [
|
|
6304
|
-
/* @__PURE__ */ jsx(
|
|
6305
|
-
|
|
6306
|
-
|
|
6361
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 min-w-0", children: [
|
|
6362
|
+
hasRecord ? /* @__PURE__ */ jsx(
|
|
6363
|
+
CheckCircle2,
|
|
6364
|
+
{
|
|
6365
|
+
"aria-label": "Has record",
|
|
6366
|
+
className: "w-3.5 h-3.5 shrink-0 ra-status-own-icon",
|
|
6367
|
+
style: { color: "hsl(var(--ra-status-own, 142 71% 45%))" }
|
|
6368
|
+
}
|
|
6369
|
+
) : /* @__PURE__ */ jsx("span", { className: "w-3.5 h-3.5 shrink-0", "aria-hidden": "true" }),
|
|
6370
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
6371
|
+
/* @__PURE__ */ jsx("div", { className: "text-sm truncate", style: { color: "hsl(var(--ra-text))" }, children: c.name }),
|
|
6372
|
+
c.subtitle && /* @__PURE__ */ jsx("div", { className: "text-xs truncate", style: { color: "hsl(var(--ra-muted-text))" }, children: c.subtitle })
|
|
6373
|
+
] })
|
|
6374
|
+
] })
|
|
6307
6375
|
}
|
|
6308
6376
|
) }, c.id);
|
|
6309
6377
|
}) })
|
|
@@ -9245,6 +9313,7 @@ function RecordsAdminShellInner(props) {
|
|
|
9245
9313
|
defaultScope,
|
|
9246
9314
|
contextScope,
|
|
9247
9315
|
contextScopeMode = "strict",
|
|
9316
|
+
maxDrillDepth = "batch",
|
|
9248
9317
|
renderEditor,
|
|
9249
9318
|
intro,
|
|
9250
9319
|
csvSchema,
|
|
@@ -9438,13 +9507,15 @@ function RecordsAdminShellInner(props) {
|
|
|
9438
9507
|
if (!productPinnedFromContext || contextScopeMode !== "strict") return topLevelScopes;
|
|
9439
9508
|
return topLevelScopes.filter((s) => s !== "collection" && s !== "rule" && s !== "all");
|
|
9440
9509
|
}, [productPinnedFromContext, contextScopeMode, topLevelScopes]);
|
|
9510
|
+
const allowVariantDepth = maxDrillDepth === "variant" || maxDrillDepth === "batch";
|
|
9511
|
+
const allowBatchDepth = maxDrillDepth === "batch";
|
|
9441
9512
|
const drillVariantsAllowed = useMemo(
|
|
9442
|
-
() =>
|
|
9443
|
-
[
|
|
9513
|
+
() => allowVariantDepth && (probe.isLoading || probe.hasVariants),
|
|
9514
|
+
[allowVariantDepth, probe.isLoading, probe.hasVariants]
|
|
9444
9515
|
);
|
|
9445
9516
|
const drillBatchesAllowed = useMemo(
|
|
9446
|
-
() =>
|
|
9447
|
-
[
|
|
9517
|
+
() => allowBatchDepth && (probe.isLoading || probe.hasBatches),
|
|
9518
|
+
[allowBatchDepth, probe.isLoading, probe.hasBatches]
|
|
9448
9519
|
);
|
|
9449
9520
|
const initialScope = useMemo(() => {
|
|
9450
9521
|
if (contextScope?.productId && effectiveTopLevelScopes.includes("product")) return "product";
|
|
@@ -9563,6 +9634,14 @@ function RecordsAdminShellInner(props) {
|
|
|
9563
9634
|
productId: contextScope?.productId,
|
|
9564
9635
|
enabled: !!contextScope?.productId
|
|
9565
9636
|
});
|
|
9637
|
+
const productSubRecords = useProductSubRecords({
|
|
9638
|
+
SL,
|
|
9639
|
+
collectionId,
|
|
9640
|
+
appId,
|
|
9641
|
+
recordType,
|
|
9642
|
+
productId: selectedProductId,
|
|
9643
|
+
enabled: !!selectedProductId
|
|
9644
|
+
});
|
|
9566
9645
|
const productLookupItems = useMemo(() => {
|
|
9567
9646
|
if (pinnedProduct.item) return [pinnedProduct.item];
|
|
9568
9647
|
return productBrowse.items;
|
|
@@ -11612,61 +11691,70 @@ function RecordsAdminShellInner(props) {
|
|
|
11612
11691
|
}
|
|
11613
11692
|
),
|
|
11614
11693
|
ruleWizardStep === null && !isCollection && !editingScope && activeScope === "product" && !selectedProductId && /* @__PURE__ */ jsx(EmptyState, { title: i18n.emptyTitle, body: i18n.emptyBody }),
|
|
11615
|
-
ruleWizardStep === null && isProductTab && selectedProductId && (!isCollection || selectedItemId) &&
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
hideSingleTab: editorTabs === "off" || editorTabs === "multi",
|
|
11622
|
-
active: drillTab,
|
|
11623
|
-
onChange: (t) => {
|
|
11624
|
-
void runWithGuard(() => {
|
|
11625
|
-
setDrillTab(t);
|
|
11626
|
-
if (t === "product") {
|
|
11627
|
-
setSelectedVariantId(void 0);
|
|
11628
|
-
setSelectedBatchId(void 0);
|
|
11629
|
-
}
|
|
11630
|
-
});
|
|
11631
|
-
},
|
|
11632
|
-
selectedChildId: drillTab === "variant" ? selectedVariantId : drillTab === "batch" ? selectedBatchId : void 0,
|
|
11633
|
-
onSelectChild: (id) => {
|
|
11634
|
-
void runWithGuard(() => {
|
|
11635
|
-
if (drillTab === "variant") setSelectedVariantId(id);
|
|
11636
|
-
else if (drillTab === "batch") setSelectedBatchId(id);
|
|
11637
|
-
});
|
|
11638
|
-
},
|
|
11639
|
-
variants: variantChildren.items,
|
|
11640
|
-
batches: batchChildren.items,
|
|
11641
|
-
variantsLoading: variantChildren.isLoading,
|
|
11642
|
-
batchesLoading: batchChildren.isLoading,
|
|
11643
|
-
children: editingTargetScope ? renderEditorWithPreview() : /* @__PURE__ */ jsx(
|
|
11644
|
-
EmptyState,
|
|
11645
|
-
{
|
|
11646
|
-
title: drillTab === "variant" ? "Pick a variant" : "Pick a batch",
|
|
11647
|
-
body: `Select a ${drillTab} on the left to edit its ${recordType ?? label.toLowerCase()}.`
|
|
11648
|
-
}
|
|
11649
|
-
)
|
|
11650
|
-
}
|
|
11651
|
-
),
|
|
11652
|
-
ruleWizardStep === null && isProductTab && selectedProductId && !isCollection && editingTargetScope && resolved.source !== "self" && selectedRecordId !== DRAFT_ID3 ? (() => {
|
|
11653
|
-
const productName = productLookupItems.find((p) => p.id === selectedProductId)?.name ?? selectedProductId;
|
|
11694
|
+
ruleWizardStep === null && isProductTab && selectedProductId && (!isCollection || selectedItemId) && (() => {
|
|
11695
|
+
const productName = productLookupItems.find((p) => p.id === selectedProductId)?.name ?? productBrowse.items.find((p) => p.id === selectedProductId)?.name ?? selectedProductId;
|
|
11696
|
+
const variantName = drillTab === "variant" && selectedVariantId ? variantChildren.items.find((v) => v.id === selectedVariantId)?.name ?? selectedVariantId : void 0;
|
|
11697
|
+
const batchName = drillTab === "batch" && selectedBatchId ? batchChildren.items.find((b) => b.id === selectedBatchId)?.name ?? selectedBatchId : void 0;
|
|
11698
|
+
const targetKind = variantName ? "variant" : batchName ? "batch" : "product";
|
|
11699
|
+
const targetName = variantName ?? batchName ?? productName;
|
|
11654
11700
|
const pasteEntry = wizardClipboard.entry;
|
|
11655
11701
|
const pasteSourceLabel = pasteEntry?.sourceLabel ?? pasteEntry?.sourceScope.raw;
|
|
11702
|
+
const onlyNonActive = resolved.source === "self" && !!resolved.lifecycleStatus && !resolvedActiveStatuses.includes(resolved.lifecycleStatus);
|
|
11703
|
+
const needsChooser = !isCollection && editingTargetScope && selectedRecordId !== DRAFT_ID3 && (resolved.source !== "self" || onlyNonActive);
|
|
11704
|
+
const chooserTitle = onlyNonActive ? `No active ${itemNoun} for ${targetKind}: ${targetName}` : `No ${itemNoun} set for ${targetKind}: ${targetName}`;
|
|
11705
|
+
const chooserBody = onlyNonActive ? `The existing ${itemNoun} for this ${targetKind} is ${resolved.lifecycleStatus}. Start a fresh ${itemNoun} to replace it, or copy from the global default.` : `Choose whether to create a fresh ${itemNoun} for this ${targetKind} or start from the global default.`;
|
|
11656
11706
|
return /* @__PURE__ */ jsx(
|
|
11657
|
-
|
|
11707
|
+
ProductDrillDown,
|
|
11658
11708
|
{
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11709
|
+
productLabel: productName,
|
|
11710
|
+
showVariants: drillVariantsAllowed,
|
|
11711
|
+
showBatches: drillBatchesAllowed,
|
|
11712
|
+
hideSingleTab: editorTabs === "off" || editorTabs === "multi",
|
|
11713
|
+
active: drillTab,
|
|
11714
|
+
onChange: (t) => {
|
|
11715
|
+
void runWithGuard(() => {
|
|
11716
|
+
setDrillTab(t);
|
|
11717
|
+
if (t === "product") {
|
|
11718
|
+
setSelectedVariantId(void 0);
|
|
11719
|
+
setSelectedBatchId(void 0);
|
|
11720
|
+
}
|
|
11721
|
+
});
|
|
11722
|
+
},
|
|
11723
|
+
selectedChildId: drillTab === "variant" ? selectedVariantId : drillTab === "batch" ? selectedBatchId : void 0,
|
|
11724
|
+
onSelectChild: (id) => {
|
|
11725
|
+
void runWithGuard(() => {
|
|
11726
|
+
if (drillTab === "variant") setSelectedVariantId(id);
|
|
11727
|
+
else if (drillTab === "batch") setSelectedBatchId(id);
|
|
11728
|
+
});
|
|
11729
|
+
},
|
|
11730
|
+
variants: variantChildren.items,
|
|
11731
|
+
batches: batchChildren.items,
|
|
11732
|
+
variantsLoading: variantChildren.isLoading,
|
|
11733
|
+
batchesLoading: batchChildren.isLoading,
|
|
11734
|
+
variantsWithRecord: productSubRecords.variantIds,
|
|
11735
|
+
batchesWithRecord: productSubRecords.batchIds,
|
|
11736
|
+
children: needsChooser ? /* @__PURE__ */ jsx(
|
|
11737
|
+
CreateRecordChooser,
|
|
11738
|
+
{
|
|
11739
|
+
title: chooserTitle,
|
|
11740
|
+
body: chooserBody,
|
|
11741
|
+
primaryLabel: "Start blank",
|
|
11742
|
+
onPrimary: () => onCreateProductRecord("blank"),
|
|
11743
|
+
secondaryLabel: singletonGlobalSeedAvailable ? "Copy from global" : void 0,
|
|
11744
|
+
onSecondary: singletonGlobalSeedAvailable ? () => onCreateProductRecord("global") : void 0,
|
|
11745
|
+
tertiaryLabel: pasteEntry ? pasteSourceLabel ? `Paste from ${pasteSourceLabel}` : "Paste from clipboard" : void 0,
|
|
11746
|
+
onTertiary: pasteEntry ? () => onCreateProductRecord("paste") : void 0
|
|
11747
|
+
}
|
|
11748
|
+
) : editingTargetScope ? renderEditorWithPreview() : /* @__PURE__ */ jsx(
|
|
11749
|
+
EmptyState,
|
|
11750
|
+
{
|
|
11751
|
+
title: drillTab === "variant" ? "Pick a variant" : "Pick a batch",
|
|
11752
|
+
body: `Select a ${drillTab} on the left to edit its ${recordType ?? label.toLowerCase()}.`
|
|
11753
|
+
}
|
|
11754
|
+
)
|
|
11667
11755
|
}
|
|
11668
11756
|
);
|
|
11669
|
-
})()
|
|
11757
|
+
})(),
|
|
11670
11758
|
ruleWizardStep === null && !isProductTab && editingTargetScope && (!isCollection || selectedItemId) && renderEditorWithPreview()
|
|
11671
11759
|
] })
|
|
11672
11760
|
]
|