@asteby/metacore-runtime-react 18.12.0 → 18.12.1
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 18.12.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e568344: ViewValue: render structured jsonb values (objects/arrays without a label/name/title) as readable key→value pairs instead of "[object Object]" — e.g. a `fiscal_data` jsonb column on the record detail page. Plain objects become a humanized key/value list, primitive arrays a comma-joined line, nested structures a pretty-printed JSON block; empty structures render the "—" empty marker.
|
|
8
|
+
|
|
3
9
|
## 18.12.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-record.d.ts","sourceRoot":"","sources":["../../src/dialogs/dynamic-record.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAA;AA6C1C,OAAO,EAAqC,KAAK,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAK1F,YAAY,EAAE,WAAW,EAAE,CAAA;AAE3B,MAAM,WAAW,WAAW;IACxB,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb;;;;;OAKG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,QAAQ;IACrB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,CAAA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Q,EACR,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACR,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,MAAM,EACN,cAAc,EACd,aAAa,EACb,WAA8B,EAC9B,QAAQ,EACR,QAAQ,EACR,QAAQ,GACX,EAAE,wBAAwB,+BAuY1B;AAgGD,wBAAgB,SAAS,CAAC,EACtB,KAAK,EACL,KAAK,EAAE,QAAQ,EACf,MAAM,EACN,WAAW,EAAE,eAAe,EAC5B,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,YAAY,GACzB,EAAE;IACC,KAAK,EAAE,QAAQ,CAAA;IACf,KAAK,EAAE,GAAG,CAAA;IACV,MAAM,EAAE,GAAG,CAAA;IACX,mFAAmF;IACnF,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,0EAA0E;IAC1E,QAAQ,CAAC,EAAE,MAAM,CAAA;CACpB,+BAiKA"}
|
|
@@ -123,6 +123,9 @@ function formatDisplayValue(rawValue, field) {
|
|
|
123
123
|
// when no declared option matches the value.
|
|
124
124
|
return match?.label ?? humanizeToken(value);
|
|
125
125
|
}
|
|
126
|
+
// Structured value with no label — JSON beats "[object Object]".
|
|
127
|
+
if (typeof value === 'object')
|
|
128
|
+
return JSON.stringify(value);
|
|
126
129
|
return String(value);
|
|
127
130
|
}
|
|
128
131
|
const MODE_CONFIG = {
|
|
@@ -574,12 +577,38 @@ export function ViewValue({ field, value: rawValue, record, getImageUrl: getImag
|
|
|
574
577
|
};
|
|
575
578
|
return (_jsxs(Badge, { variant: "secondary", className: "w-fit flex items-center gap-1", style: opt.color && !opt.icon ? { backgroundColor: opt.color, color: '#fff', borderColor: 'transparent' } : undefined, children: [_jsx(OptionLead, { option: lead, size: 16 }), opt.label] }));
|
|
576
579
|
}
|
|
580
|
+
// Structured value (jsonb column, e.g. fiscal_data) with no label/name/title
|
|
581
|
+
// to surface — render readable key/value pairs instead of falling through to
|
|
582
|
+
// String(value) ("[object Object]").
|
|
583
|
+
if (value !== null && typeof value === 'object') {
|
|
584
|
+
return _jsx(StructuredViewValue, { value: value });
|
|
585
|
+
}
|
|
577
586
|
const display = formatDisplayValue(value, field);
|
|
578
587
|
if (field.type === 'textarea') {
|
|
579
588
|
return (_jsx("p", { className: "text-sm whitespace-pre-wrap rounded-md bg-muted/40 p-3 min-h-[60px]", children: display }));
|
|
580
589
|
}
|
|
581
590
|
return _jsx("p", { className: "text-sm py-1", children: display });
|
|
582
591
|
}
|
|
592
|
+
// StructuredViewValue renders a jsonb object/array that has no resolvable label:
|
|
593
|
+
// plain objects become a key→value list (keys humanized), primitive arrays a
|
|
594
|
+
// comma-joined line, and anything deeper a pretty-printed JSON block. Empty
|
|
595
|
+
// structures render the same "—" marker as null scalars.
|
|
596
|
+
function StructuredViewValue({ value }) {
|
|
597
|
+
if (Array.isArray(value)) {
|
|
598
|
+
if (value.length === 0) {
|
|
599
|
+
return _jsx("p", { className: "text-sm py-1 text-muted-foreground", children: "\u2014" });
|
|
600
|
+
}
|
|
601
|
+
if (value.every(v => v === null || typeof v !== 'object')) {
|
|
602
|
+
return _jsx("p", { className: "text-sm py-1", children: value.map(v => String(v ?? '—')).join(', ') });
|
|
603
|
+
}
|
|
604
|
+
return (_jsx("pre", { className: "text-xs whitespace-pre-wrap rounded-md bg-muted/40 p-3 overflow-x-auto", children: JSON.stringify(value, null, 2) }));
|
|
605
|
+
}
|
|
606
|
+
const entries = Object.entries(value).filter(([, v]) => v !== null && v !== undefined && v !== '');
|
|
607
|
+
if (entries.length === 0) {
|
|
608
|
+
return _jsx("p", { className: "text-sm py-1 text-muted-foreground", children: "\u2014" });
|
|
609
|
+
}
|
|
610
|
+
return (_jsx("dl", { className: "text-sm py-1 space-y-0.5", children: entries.map(([k, v]) => (_jsxs("div", { className: "flex gap-2", children: [_jsxs("dt", { className: "text-muted-foreground shrink-0", children: [humanizeToken(k), ":"] }), _jsx("dd", { className: "break-words", children: typeof v === 'object' ? JSON.stringify(v) : String(v) })] }, k))) }));
|
|
611
|
+
}
|
|
583
612
|
function EditField({ field, value, onChange }) {
|
|
584
613
|
if (field.type === 'boolean') {
|
|
585
614
|
return (_jsxs("div", { className: "flex items-center gap-2 py-1", children: [_jsx(Switch, { checked: !!value, onCheckedChange: onChange }), _jsx("span", { className: "text-sm text-muted-foreground", children: value ? 'Sí' : 'No' })] }));
|
package/package.json
CHANGED
|
@@ -323,6 +323,9 @@ function formatDisplayValue(rawValue: any, field: FieldDef): string {
|
|
|
323
323
|
return match?.label ?? humanizeToken(value)
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
// Structured value with no label — JSON beats "[object Object]".
|
|
327
|
+
if (typeof value === 'object') return JSON.stringify(value)
|
|
328
|
+
|
|
326
329
|
return String(value)
|
|
327
330
|
}
|
|
328
331
|
|
|
@@ -1048,6 +1051,13 @@ export function ViewValue({
|
|
|
1048
1051
|
)
|
|
1049
1052
|
}
|
|
1050
1053
|
|
|
1054
|
+
// Structured value (jsonb column, e.g. fiscal_data) with no label/name/title
|
|
1055
|
+
// to surface — render readable key/value pairs instead of falling through to
|
|
1056
|
+
// String(value) ("[object Object]").
|
|
1057
|
+
if (value !== null && typeof value === 'object') {
|
|
1058
|
+
return <StructuredViewValue value={value} />
|
|
1059
|
+
}
|
|
1060
|
+
|
|
1051
1061
|
const display = formatDisplayValue(value, field)
|
|
1052
1062
|
|
|
1053
1063
|
if (field.type === 'textarea') {
|
|
@@ -1061,6 +1071,44 @@ export function ViewValue({
|
|
|
1061
1071
|
return <p className="text-sm py-1">{display}</p>
|
|
1062
1072
|
}
|
|
1063
1073
|
|
|
1074
|
+
// StructuredViewValue renders a jsonb object/array that has no resolvable label:
|
|
1075
|
+
// plain objects become a key→value list (keys humanized), primitive arrays a
|
|
1076
|
+
// comma-joined line, and anything deeper a pretty-printed JSON block. Empty
|
|
1077
|
+
// structures render the same "—" marker as null scalars.
|
|
1078
|
+
function StructuredViewValue({ value }: { value: any }) {
|
|
1079
|
+
if (Array.isArray(value)) {
|
|
1080
|
+
if (value.length === 0) {
|
|
1081
|
+
return <p className="text-sm py-1 text-muted-foreground">—</p>
|
|
1082
|
+
}
|
|
1083
|
+
if (value.every(v => v === null || typeof v !== 'object')) {
|
|
1084
|
+
return <p className="text-sm py-1">{value.map(v => String(v ?? '—')).join(', ')}</p>
|
|
1085
|
+
}
|
|
1086
|
+
return (
|
|
1087
|
+
<pre className="text-xs whitespace-pre-wrap rounded-md bg-muted/40 p-3 overflow-x-auto">
|
|
1088
|
+
{JSON.stringify(value, null, 2)}
|
|
1089
|
+
</pre>
|
|
1090
|
+
)
|
|
1091
|
+
}
|
|
1092
|
+
const entries = Object.entries(value).filter(
|
|
1093
|
+
([, v]) => v !== null && v !== undefined && v !== '',
|
|
1094
|
+
)
|
|
1095
|
+
if (entries.length === 0) {
|
|
1096
|
+
return <p className="text-sm py-1 text-muted-foreground">—</p>
|
|
1097
|
+
}
|
|
1098
|
+
return (
|
|
1099
|
+
<dl className="text-sm py-1 space-y-0.5">
|
|
1100
|
+
{entries.map(([k, v]) => (
|
|
1101
|
+
<div key={k} className="flex gap-2">
|
|
1102
|
+
<dt className="text-muted-foreground shrink-0">{humanizeToken(k)}:</dt>
|
|
1103
|
+
<dd className="break-words">
|
|
1104
|
+
{typeof v === 'object' ? JSON.stringify(v) : String(v)}
|
|
1105
|
+
</dd>
|
|
1106
|
+
</div>
|
|
1107
|
+
))}
|
|
1108
|
+
</dl>
|
|
1109
|
+
)
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1064
1112
|
function EditField({ field, value, onChange }: {
|
|
1065
1113
|
field: FieldDef
|
|
1066
1114
|
value: any
|