@proveanything/smartlinks-utils-ui 1.14.2 → 1.14.4

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.
@@ -1820,6 +1820,12 @@ interface UseProductChildrenArgs {
1820
1820
  /** Which child kind to fetch. Hooks only fire when both productId and kind are set. */
1821
1821
  kind: 'variant' | 'batch' | null;
1822
1822
  enabled?: boolean;
1823
+ /**
1824
+ * When true, include children whose `deleted` flag is true. Defaults to
1825
+ * false — the admin API returns deleted rows and we filter them out so
1826
+ * the rail matches what non-admin surfaces show.
1827
+ */
1828
+ includeDeleted?: boolean;
1823
1829
  }
1824
1830
  /**
1825
1831
  * Lazy children loader. When `kind` is `null` or `productId` is missing the
@@ -1303,22 +1303,33 @@ var useProductBrowse = (args) => {
1303
1303
  };
1304
1304
  };
1305
1305
  var QK4 = ["records-admin", "product-children"];
1306
- var variantToItem = (v) => ({
1307
- id: v.id ?? v.variantId ?? "",
1308
- name: v.name ?? v.label ?? v.id ?? "Untitled variant",
1309
- subtitle: v.sku ?? v.size ?? void 0
1310
- });
1311
- var batchToItem = (b) => ({
1312
- id: b.id ?? b.batchId ?? "",
1313
- name: b.name ?? b.id ?? "Untitled batch",
1314
- subtitle: b.expiryDate?.iso ?? b.expiry ?? b.lotCode ?? void 0
1315
- });
1306
+ var nonEmpty = (s) => {
1307
+ if (typeof s !== "string") return void 0;
1308
+ const t = s.trim();
1309
+ return t.length > 0 ? t : void 0;
1310
+ };
1311
+ var variantToItem = (v) => {
1312
+ const id = v.id ?? v.variantId ?? "";
1313
+ return {
1314
+ id,
1315
+ name: nonEmpty(v.name) ?? nonEmpty(v.label) ?? nonEmpty(id) ?? "Untitled variant",
1316
+ subtitle: v.sku ?? v.size ?? void 0
1317
+ };
1318
+ };
1319
+ var batchToItem = (b) => {
1320
+ const id = b.id ?? b.batchId ?? "";
1321
+ return {
1322
+ id,
1323
+ name: nonEmpty(b.name) ?? nonEmpty(id) ?? "Untitled batch",
1324
+ subtitle: b.expiryDate?.iso ?? b.expiry ?? b.lotCode ?? void 0
1325
+ };
1326
+ };
1316
1327
  var useProductChildren = (args) => {
1317
- const { SL, collectionId, productId, kind, enabled = true } = args;
1328
+ const { SL, collectionId, productId, kind, enabled = true, includeDeleted = false } = args;
1318
1329
  const queryClient = useQueryClient();
1319
1330
  const queryKey = useMemo(
1320
- () => [...QK4, collectionId, productId ?? null, kind],
1321
- [collectionId, productId, kind]
1331
+ () => [...QK4, collectionId, productId ?? null, kind, includeDeleted],
1332
+ [collectionId, productId, kind, includeDeleted]
1322
1333
  );
1323
1334
  const query = useQuery({
1324
1335
  queryKey,
@@ -1326,12 +1337,13 @@ var useProductChildren = (args) => {
1326
1337
  staleTime: 3e4,
1327
1338
  queryFn: async () => {
1328
1339
  if (!productId || !kind) return [];
1340
+ const keep = (row) => includeDeleted || row?.deleted !== true;
1329
1341
  if (kind === "variant") {
1330
1342
  const res2 = await SL.variant.list(collectionId, productId);
1331
- return (res2 ?? []).map(variantToItem);
1343
+ return (res2 ?? []).filter(keep).map(variantToItem);
1332
1344
  }
1333
1345
  const res = await SL.batch.list(collectionId, productId);
1334
- return (res ?? []).map(batchToItem);
1346
+ return (res ?? []).filter(keep).map(batchToItem);
1335
1347
  }
1336
1348
  });
1337
1349
  const refetch = () => queryClient.invalidateQueries({
@@ -8204,7 +8216,9 @@ function CreateRecordChooser({
8204
8216
  secondaryLabel,
8205
8217
  onSecondary,
8206
8218
  tertiaryLabel,
8207
- onTertiary
8219
+ onTertiary,
8220
+ cancelLabel,
8221
+ onCancel
8208
8222
  }) {
8209
8223
  return /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center px-6 py-10", children: /* @__PURE__ */ jsxs("div", { className: "max-w-xl w-full text-center space-y-4", children: [
8210
8224
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
@@ -8265,7 +8279,20 @@ function CreateRecordChooser({
8265
8279
  ]
8266
8280
  }
8267
8281
  )
8268
- ] })
8282
+ ] }),
8283
+ cancelLabel && onCancel && /* @__PURE__ */ jsx("div", { className: "pt-1", children: /* @__PURE__ */ jsxs(
8284
+ "button",
8285
+ {
8286
+ type: "button",
8287
+ onClick: onCancel,
8288
+ className: "ra-btn",
8289
+ "data-variant": "ghost",
8290
+ children: [
8291
+ /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "w-4 h-4" }),
8292
+ /* @__PURE__ */ jsx("span", { children: cancelLabel })
8293
+ ]
8294
+ }
8295
+ ) })
8269
8296
  ] }) });
8270
8297
  }
8271
8298
  var RuleGroupEditDialog = ({
@@ -11752,9 +11779,22 @@ function RecordsAdminShellInner(props) {
11752
11779
  ),
11753
11780
  ruleWizardStep === null && !isCollection && !editingScope && activeScope === "product" && !selectedProductId && /* @__PURE__ */ jsx(EmptyState, { title: i18n.emptyTitle, body: i18n.emptyBody }),
11754
11781
  ruleWizardStep === null && isProductTab && selectedProductId && (!isCollection || selectedItemId) && (() => {
11755
- const productName = productLookupItems.find((p) => p.id === selectedProductId)?.name ?? productBrowse.items.find((p) => p.id === selectedProductId)?.name ?? selectedProductId;
11756
- const variantName = drillTab === "variant" && selectedVariantId ? variantChildren.items.find((v) => v.id === selectedVariantId)?.name ?? selectedVariantId : void 0;
11757
- const batchName = drillTab === "batch" && selectedBatchId ? batchChildren.items.find((b) => b.id === selectedBatchId)?.name ?? selectedBatchId : void 0;
11782
+ const pickName = (n, fallback) => {
11783
+ const t = typeof n === "string" ? n.trim() : "";
11784
+ return t.length > 0 ? t : fallback;
11785
+ };
11786
+ const productName = pickName(
11787
+ productLookupItems.find((p) => p.id === selectedProductId)?.name ?? productBrowse.items.find((p) => p.id === selectedProductId)?.name,
11788
+ selectedProductId
11789
+ );
11790
+ const variantName = drillTab === "variant" && selectedVariantId ? pickName(
11791
+ variantChildren.items.find((v) => v.id === selectedVariantId)?.name,
11792
+ selectedVariantId
11793
+ ) : void 0;
11794
+ const batchName = drillTab === "batch" && selectedBatchId ? pickName(
11795
+ batchChildren.items.find((b) => b.id === selectedBatchId)?.name,
11796
+ selectedBatchId
11797
+ ) : void 0;
11758
11798
  const targetKind = variantName ? "variant" : batchName ? "batch" : "product";
11759
11799
  const targetName = variantName ?? batchName ?? productName;
11760
11800
  const pasteEntry = wizardClipboard.entry;
@@ -11803,7 +11843,13 @@ function RecordsAdminShellInner(props) {
11803
11843
  secondaryLabel: singletonGlobalSeedAvailable ? "Copy from global" : void 0,
11804
11844
  onSecondary: singletonGlobalSeedAvailable ? () => onCreateProductRecord("global") : void 0,
11805
11845
  tertiaryLabel: pasteEntry ? pasteSourceLabel ? `Paste from ${pasteSourceLabel}` : "Paste from clipboard" : void 0,
11806
- onTertiary: pasteEntry ? () => onCreateProductRecord("paste") : void 0
11846
+ onTertiary: pasteEntry ? () => onCreateProductRecord("paste") : void 0,
11847
+ cancelLabel: "Cancel",
11848
+ onCancel: () => {
11849
+ if (drillTab === "variant") setSelectedVariantId(void 0);
11850
+ else if (drillTab === "batch") setSelectedBatchId(void 0);
11851
+ else setSelectedProductId(void 0);
11852
+ }
11807
11853
  }
11808
11854
  ) : editingTargetScope ? renderEditorWithPreview() : /* @__PURE__ */ jsx(
11809
11855
  EmptyState,