@proveanything/smartlinks-utils-ui 1.14.2 → 1.14.3

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.
@@ -1303,16 +1303,27 @@ 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
1328
  const { SL, collectionId, productId, kind, enabled = true } = args;
1318
1329
  const queryClient = useQueryClient();
@@ -8204,7 +8215,9 @@ function CreateRecordChooser({
8204
8215
  secondaryLabel,
8205
8216
  onSecondary,
8206
8217
  tertiaryLabel,
8207
- onTertiary
8218
+ onTertiary,
8219
+ cancelLabel,
8220
+ onCancel
8208
8221
  }) {
8209
8222
  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
8223
  /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
@@ -8265,7 +8278,20 @@ function CreateRecordChooser({
8265
8278
  ]
8266
8279
  }
8267
8280
  )
8268
- ] })
8281
+ ] }),
8282
+ cancelLabel && onCancel && /* @__PURE__ */ jsx("div", { className: "pt-1", children: /* @__PURE__ */ jsxs(
8283
+ "button",
8284
+ {
8285
+ type: "button",
8286
+ onClick: onCancel,
8287
+ className: "ra-btn",
8288
+ "data-variant": "ghost",
8289
+ children: [
8290
+ /* @__PURE__ */ jsx(X, { "aria-hidden": "true", className: "w-4 h-4" }),
8291
+ /* @__PURE__ */ jsx("span", { children: cancelLabel })
8292
+ ]
8293
+ }
8294
+ ) })
8269
8295
  ] }) });
8270
8296
  }
8271
8297
  var RuleGroupEditDialog = ({
@@ -11752,9 +11778,22 @@ function RecordsAdminShellInner(props) {
11752
11778
  ),
11753
11779
  ruleWizardStep === null && !isCollection && !editingScope && activeScope === "product" && !selectedProductId && /* @__PURE__ */ jsx(EmptyState, { title: i18n.emptyTitle, body: i18n.emptyBody }),
11754
11780
  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;
11781
+ const pickName = (n, fallback) => {
11782
+ const t = typeof n === "string" ? n.trim() : "";
11783
+ return t.length > 0 ? t : fallback;
11784
+ };
11785
+ const productName = pickName(
11786
+ productLookupItems.find((p) => p.id === selectedProductId)?.name ?? productBrowse.items.find((p) => p.id === selectedProductId)?.name,
11787
+ selectedProductId
11788
+ );
11789
+ const variantName = drillTab === "variant" && selectedVariantId ? pickName(
11790
+ variantChildren.items.find((v) => v.id === selectedVariantId)?.name,
11791
+ selectedVariantId
11792
+ ) : void 0;
11793
+ const batchName = drillTab === "batch" && selectedBatchId ? pickName(
11794
+ batchChildren.items.find((b) => b.id === selectedBatchId)?.name,
11795
+ selectedBatchId
11796
+ ) : void 0;
11758
11797
  const targetKind = variantName ? "variant" : batchName ? "batch" : "product";
11759
11798
  const targetName = variantName ?? batchName ?? productName;
11760
11799
  const pasteEntry = wizardClipboard.entry;
@@ -11803,7 +11842,13 @@ function RecordsAdminShellInner(props) {
11803
11842
  secondaryLabel: singletonGlobalSeedAvailable ? "Copy from global" : void 0,
11804
11843
  onSecondary: singletonGlobalSeedAvailable ? () => onCreateProductRecord("global") : void 0,
11805
11844
  tertiaryLabel: pasteEntry ? pasteSourceLabel ? `Paste from ${pasteSourceLabel}` : "Paste from clipboard" : void 0,
11806
- onTertiary: pasteEntry ? () => onCreateProductRecord("paste") : void 0
11845
+ onTertiary: pasteEntry ? () => onCreateProductRecord("paste") : void 0,
11846
+ cancelLabel: "Cancel",
11847
+ onCancel: () => {
11848
+ if (drillTab === "variant") setSelectedVariantId(void 0);
11849
+ else if (drillTab === "batch") setSelectedBatchId(void 0);
11850
+ else setSelectedProductId(void 0);
11851
+ }
11807
11852
  }
11808
11853
  ) : editingTargetScope ? renderEditorWithPreview() : /* @__PURE__ */ jsx(
11809
11854
  EmptyState,