pxengine 0.1.149 → 0.1.151

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/index.cjs CHANGED
@@ -11565,6 +11565,37 @@ ChatSkeleton.displayName = "ChatSkeleton";
11565
11565
  // src/molecules/generic/EditableField/EditableField.tsx
11566
11566
  var import_react59 = __toESM(require("react"), 1);
11567
11567
 
11568
+ // src/lib/format-utils.ts
11569
+ function isPlainRecord(value) {
11570
+ return typeof value === "object" && value !== null && !Array.isArray(value);
11571
+ }
11572
+ function devWarnUnexpectedObject(context, value) {
11573
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
11574
+ console.warn(
11575
+ `[PXEngine-UI] formatCellValue received an object/array where a primitive value was expected (context: "${context}"). This usually means the rendered schema and the data feeding it don't match \u2014 worth flagging to whatever generated this data.`,
11576
+ value
11577
+ );
11578
+ }
11579
+ function formatCellValue(value, context = "cell") {
11580
+ if (value === null || value === void 0 || value === "") return "";
11581
+ if (typeof value !== "object") return String(value);
11582
+ devWarnUnexpectedObject(context, value);
11583
+ if (Array.isArray(value)) {
11584
+ if (value.length === 0) return "";
11585
+ if (value.every((item) => item === null || item === void 0 || typeof item !== "object")) {
11586
+ return value.map((item) => String(item ?? "")).join(", ");
11587
+ }
11588
+ return `${value.length} item${value.length === 1 ? "" : "s"}`;
11589
+ }
11590
+ if (isPlainRecord(value)) {
11591
+ const meaningful = value.label ?? value.name ?? value.title ?? value.id ?? value.value;
11592
+ if (typeof meaningful === "string" || typeof meaningful === "number") {
11593
+ return String(meaningful);
11594
+ }
11595
+ }
11596
+ return "Complex value";
11597
+ }
11598
+
11568
11599
  // src/components/ui/hover-card.tsx
11569
11600
  var React85 = __toESM(require("react"), 1);
11570
11601
  var HoverCardPrimitive = __toESM(require("@radix-ui/react-hover-card"), 1);
@@ -12016,7 +12047,7 @@ var EditableField = import_react59.default.memo(
12016
12047
  if (!value) {
12017
12048
  return /* @__PURE__ */ (0, import_jsx_runtime97.jsx)("span", { className: "opacity-0", children: "-" });
12018
12049
  }
12019
- return typeof value === "object" ? JSON.stringify(value) : String(value ?? "");
12050
+ return formatCellValue(value, "label");
12020
12051
  };
12021
12052
  return /* @__PURE__ */ (0, import_jsx_runtime97.jsxs)(
12022
12053
  "div",
@@ -12270,7 +12301,7 @@ var FormCard = import_react61.default.memo(
12270
12301
  if (Array.isArray(val)) {
12271
12302
  return val.map((item) => {
12272
12303
  if (typeof item === "object" && item !== null) {
12273
- return item.label || item.value || item.name || JSON.stringify(item);
12304
+ return item.label || item.value || item.name || formatCellValue(item, "label");
12274
12305
  }
12275
12306
  return String(item);
12276
12307
  }).join(", ");
@@ -12539,7 +12570,7 @@ var StatsGrid = ({
12539
12570
  {
12540
12571
  id: `stat-label-${index}`,
12541
12572
  type: "text",
12542
- content: typeof item.label === "object" ? JSON.stringify(item.label) : String(item.label ?? ""),
12573
+ content: formatCellValue(item.label, "label"),
12543
12574
  variant: "small",
12544
12575
  className: cn(!hasPxVars && "text-muted-foreground", "font-medium tracking-wide uppercase text-[10px]"),
12545
12576
  style: textColor ? { color: textColor } : void 0
@@ -12579,7 +12610,7 @@ var StatsGrid = ({
12579
12610
  ),
12580
12611
  children: [
12581
12612
  TrendIcon && /* @__PURE__ */ (0, import_jsx_runtime101.jsx)(TrendIcon, { className: "w-3 h-3 mr-0.5" }),
12582
- typeof item.trend === "object" ? JSON.stringify(item.trend) : String(item.trend ?? "")
12613
+ formatCellValue(item.trend, "label")
12583
12614
  ]
12584
12615
  }
12585
12616
  )
@@ -12865,7 +12896,7 @@ var DataGrid = ({
12865
12896
  variant: "secondary",
12866
12897
  className: "border-gold/20 bg-gold/10 text-gold",
12867
12898
  style: s.accent,
12868
- children: typeof value === "object" ? JSON.stringify(value) : String(value ?? "")
12899
+ children: formatCellValue(value, "badge")
12869
12900
  }
12870
12901
  );
12871
12902
  case "avatar":
@@ -12881,7 +12912,7 @@ var DataGrid = ({
12881
12912
  case "number":
12882
12913
  return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { className: "font-mono font-medium text-cardText", style: s.text, children: Number(value ?? 0).toLocaleString() });
12883
12914
  default:
12884
- return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { className: "text-cardText", style: s.text, children: typeof value === "object" ? JSON.stringify(value) : String(value ?? "") });
12915
+ return /* @__PURE__ */ (0, import_jsx_runtime107.jsx)("span", { className: "text-cardText", style: s.text, children: formatCellValue(value, "cell") });
12885
12916
  }
12886
12917
  };
12887
12918
  return /* @__PURE__ */ (0, import_jsx_runtime107.jsxs)(
@@ -15023,11 +15054,7 @@ function stringifyValue(value, atomName, props) {
15023
15054
  }
15024
15055
  if (Array.isArray(value)) return value.join(", ");
15025
15056
  if (typeof value === "object") {
15026
- try {
15027
- return JSON.stringify(value);
15028
- } catch {
15029
- return String(value);
15030
- }
15057
+ return formatCellValue(value, "label");
15031
15058
  }
15032
15059
  return String(value);
15033
15060
  }
@@ -15183,7 +15210,7 @@ var ApprovalCard = import_react71.default.memo(
15183
15210
  style: i < details.length - 1 ? { borderBottomColor: theme?.border } : {},
15184
15211
  children: [
15185
15212
  /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "text-cardText/50", style: s.muted, children: d.label }),
15186
- /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "font-medium text-cardText", style: s.text, children: typeof d.value === "object" ? JSON.stringify(d.value) : String(d.value ?? "") })
15213
+ /* @__PURE__ */ (0, import_jsx_runtime128.jsx)("span", { className: "font-medium text-cardText", style: s.text, children: formatCellValue(d.value, "label") })
15187
15214
  ]
15188
15215
  },
15189
15216
  i
@@ -15470,7 +15497,7 @@ var DataTableCard = import_react74.default.memo(
15470
15497
  isHighlight ? "font-semibold text-gold" : colIdx === 0 ? "font-medium text-cardText" : "text-cardText/60"
15471
15498
  ),
15472
15499
  style: isHighlight ? s.accent : colIdx === 0 ? s.text : s.muted,
15473
- children: typeof cell === "object" ? JSON.stringify(cell) : String(cell)
15500
+ children: typeof cell === "object" ? formatCellValue(cell, "cell") : String(cell)
15474
15501
  },
15475
15502
  colIdx
15476
15503
  );
@@ -16465,7 +16492,7 @@ var ResearchBriefCard = ({
16465
16492
  item.label,
16466
16493
  ": "
16467
16494
  ] }),
16468
- /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("span", { className: "text-muted-foreground", children: typeof item.value === "object" ? JSON.stringify(item.value) : String(item.value ?? "") })
16495
+ /* @__PURE__ */ (0, import_jsx_runtime138.jsx)("span", { className: "text-muted-foreground", children: formatCellValue(item.value, "label") })
16469
16496
  ] }, `${item.label}-${idx}`)) })
16470
16497
  ] })
16471
16498
  ]
@@ -16560,8 +16587,8 @@ var CampaignBriefCard = ({
16560
16587
  ] }),
16561
16588
  constraints.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime140.jsx)("ul", { className: "mt-4 space-y-1.5 text-sm text-foreground/90", children: constraints.map((item, i) => /* @__PURE__ */ (0, import_jsx_runtime140.jsxs)("li", { children: [
16562
16589
  "- ",
16563
- typeof item === "object" ? JSON.stringify(item) : String(item ?? "")
16564
- ] }, `${item}-${i}`)) }) : null
16590
+ formatCellValue(item, "label")
16591
+ ] }, `${typeof item === "object" ? i : item}-${i}`)) }) : null
16565
16592
  ] });
16566
16593
  };
16567
16594
 
@@ -21359,7 +21386,7 @@ var MCQCard = import_react88.default.memo(
21359
21386
  };
21360
21387
  const optionsEntries = resolvedOptions && Object.keys(resolvedOptions).length > 0 ? Object.entries(resolvedOptions).map(([key, val]) => [
21361
21388
  key,
21362
- typeof val === "string" ? val : typeof val === "object" && val !== null ? val.label || val.description || val.id || JSON.stringify(val) : String(val ?? "")
21389
+ typeof val === "string" ? val : typeof val === "object" && val !== null ? val.label || val.description || val.id || formatCellValue(val, "label") : String(val ?? "")
21363
21390
  ]) : [];
21364
21391
  const labelFor = (key) => {
21365
21392
  const found = optionsEntries.find(([k]) => k === key);
@@ -22299,7 +22326,7 @@ var CampaignConceptCard = import_react90.default.memo(
22299
22326
  if (val.length === 0)
22300
22327
  return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("span", { className: "text-muted-foreground text-sm", children: "-" });
22301
22328
  return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("div", { className: "flex flex-wrap gap-2 pt-1", children: val.map((item, idx) => {
22302
- const label = typeof item === "object" && item !== null ? item.label || item.value || item.name || JSON.stringify(item) : String(item);
22329
+ const label = typeof item === "object" && item !== null ? item.label || item.value || item.name || formatCellValue(item, "badge") : String(item);
22303
22330
  return /* @__PURE__ */ (0, import_jsx_runtime172.jsx)(
22304
22331
  "span",
22305
22332
  {
@@ -22339,7 +22366,7 @@ var CampaignConceptCard = import_react90.default.memo(
22339
22366
  index !== void 0 ? index : "",
22340
22367
  " :",
22341
22368
  " ",
22342
- typeof cardTitle === "object" ? JSON.stringify(cardTitle) : String(cardTitle)
22369
+ typeof cardTitle === "object" ? formatCellValue(cardTitle, "title") : String(cardTitle)
22343
22370
  ] }),
22344
22371
  /* @__PURE__ */ (0, import_jsx_runtime172.jsxs)("div", { className: "flex flex-wrap gap-2", children: [
22345
22372
  isRecommended && /* @__PURE__ */ (0, import_jsx_runtime172.jsx)("span", { className: "text-[10px] font-semibold uppercase tracking-widest text-gold", children: "Recommended" }),
@@ -22397,7 +22424,7 @@ var CampaignConceptCard = import_react90.default.memo(
22397
22424
  FormCard,
22398
22425
  {
22399
22426
  ...formCardProps,
22400
- title: typeof cardTitle === "object" ? JSON.stringify(cardTitle) : String(cardTitle),
22427
+ title: typeof cardTitle === "object" ? formatCellValue(cardTitle, "title") : String(cardTitle),
22401
22428
  data,
22402
22429
  fields,
22403
22430
  showTimeline: true,
@@ -27038,6 +27065,22 @@ var CONTEXT_DEPENDENT_COMPONENTS = /* @__PURE__ */ new Set([
27038
27065
  "NavigationMenuContent",
27039
27066
  "NavigationMenuItem"
27040
27067
  ]);
27068
+ var renderComponentNotFoundError = (componentName, key) => {
27069
+ return /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)(
27070
+ "div",
27071
+ {
27072
+ className: "p-4 border-2 border-dashed border-gray-300 rounded-lg bg-gray-50/80 my-2",
27073
+ children: [
27074
+ /* @__PURE__ */ (0, import_jsx_runtime195.jsx)("p", { className: "text-sm font-semibold text-gray-600", children: "This content couldn't be displayed." }),
27075
+ /* @__PURE__ */ (0, import_jsx_runtime195.jsxs)("p", { className: "text-xs text-gray-400 mt-1", children: [
27076
+ "Unknown component: ",
27077
+ componentName
27078
+ ] })
27079
+ ]
27080
+ },
27081
+ key
27082
+ );
27083
+ };
27041
27084
  var COMPONENT_SUGGESTIONS = {
27042
27085
  FormLabel: "FormInputAtom (with label prop)",
27043
27086
  FormControl: "FormInputAtom",
@@ -27292,7 +27335,7 @@ var PXEngineRenderer = import_react101.default.memo(function PXEngineRenderer2({
27292
27335
  console.warn(
27293
27336
  `[PXEngineRenderer] Component not found: ${componentName}`
27294
27337
  );
27295
- return null;
27338
+ return renderComponentNotFoundError(componentName, uniqueKey);
27296
27339
  }
27297
27340
  }
27298
27341
  const resolvedNormalized = resolvedIdentifier.charAt(0).toUpperCase() + resolvedIdentifier.slice(1);