@asteby/metacore-runtime-react 18.25.0 → 18.26.0

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,23 @@
1
1
  # @asteby/metacore-runtime-react
2
2
 
3
+ ## 18.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d0056f1: Activity log (record history) renders jsonb line items as a table and localizes
8
+ relation field labels.
9
+ - **Line-items render as the shared `CollectionCell` mini-table** instead of raw
10
+ `JSON.stringify`. A jsonb array-of-objects value (e.g. a transfer's `items`,
11
+ directly or JSON-string-encoded) now shows a localized mini-table with
12
+ resolved relation chips (when the backend injects the `{value,label,image}`
13
+ siblings into the snapshot) — matching the detail view. Uses the column's
14
+ declared `item_fields` when present.
15
+ - **Relation field labels localize.** `resolveColumn` now matches the `*_id`
16
+ twin of a resolved relation key (`destination_warehouse` →
17
+ `destination_warehouse_id`), so the diff "Campo" uses the localized column
18
+ label ("Almacén destino") instead of humanizing the key in English
19
+ ("Destination Warehouse").
20
+
3
21
  ## 18.25.0
4
22
 
5
23
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"activity-diff.d.ts","sourceRoot":"","sources":["../src/activity-diff.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAO/C;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,EAAE,EAAE,MAAM,CAAA;IACV,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,+EAA+E;IAC/E,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,SAAS,EAAE,MAAM,C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14 @@ function resolveColumn(key, columns) {
81
81
  const exact = columns.find((c) => c.key === key);
82
82
  if (exact)
83
83
  return exact;
84
+ // A resolved relation key is the FK column minus `_id` (the backend injects a
85
+ // `destination_warehouse` sibling next to `destination_warehouse_id`). The
86
+ // served metadata carries the LOCALIZED label on the `*_id` column, so match
87
+ // it — else the label falls back to humanizing the key in English
88
+ // ("Destination Warehouse" instead of "Almacén destino").
89
+ const fk = columns.find((c) => c.key === `${key}_id`);
90
+ if (fk)
91
+ return fk;
84
92
  // A diff key is the physical column (created_by); the served metadata may
85
93
  // only carry the dotted display column for it (created_by.avatar). Match on
86
94
  // the base segment so the diff cell inherits its label and rich renderer.
@@ -1 +1 @@
1
- {"version":3,"file":"activity-value-renderer.d.ts","sourceRoot":"","sources":["../src/activity-value-renderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AA0E/C,MAAM,WAAW,0BAA0B;IACvC,4DAA4D;IAC5D,KAAK,EAAE,OAAO,CAAA;IACd,+EAA+E;IAC/E,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAiRtE,CAAA"}
1
+ {"version":3,"file":"activity-value-renderer.d.ts","sourceRoot":"","sources":["../src/activity-value-renderer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAU9B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAqG/C,MAAM,WAAW,0BAA0B;IACvC,4DAA4D;IAC5D,KAAK,EAAE,OAAO,CAAA;IACd,+EAA+E;IAC/E,GAAG,CAAC,EAAE,gBAAgB,CAAA;IACtB,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAA;CAClB;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,KAAK,CAAC,EAAE,CAAC,0BAA0B,CAqStE,CAAA"}
@@ -17,6 +17,32 @@ import { Badge, Avatar, AvatarImage, AvatarFallback, } from '@asteby/metacore-ui
17
17
  import { generateBadgeStyles, getInitials, optionColor, relationChipStyles } from '@asteby/metacore-ui/lib';
18
18
  import { formatDateCell } from './dynamic-columns';
19
19
  import { humanizeToken } from './dynamic-columns-helpers';
20
+ import { CollectionCell } from './collection-cell';
21
+ /**
22
+ * Parses a value into a jsonb line-items array (array of plain objects) when it
23
+ * is one — directly, or from a JSON-encoded string. Returns null otherwise, so
24
+ * scalars / resolved-entity objects keep their existing renderers.
25
+ */
26
+ function asLineItemsArray(value) {
27
+ let arr = value;
28
+ if (typeof value === 'string') {
29
+ const t = value.trim();
30
+ if (!t.startsWith('['))
31
+ return null;
32
+ try {
33
+ arr = JSON.parse(t);
34
+ }
35
+ catch {
36
+ return null;
37
+ }
38
+ }
39
+ if (Array.isArray(arr) &&
40
+ arr.length > 0 &&
41
+ arr.every((v) => v !== null && typeof v === 'object' && !Array.isArray(v))) {
42
+ return arr;
43
+ }
44
+ return null;
45
+ }
20
46
  // ---------------------------------------------------------------------------
21
47
  // Internal helpers (mirror dynamic-columns.tsx private helpers)
22
48
  // ---------------------------------------------------------------------------
@@ -81,6 +107,16 @@ export const ActivityValueRenderer = ({ value, col, timeZone, currency, locale =
81
107
  if (value === null || value === undefined || value === '') {
82
108
  return _jsx("span", { className: "text-muted-foreground", children: "\u2014" });
83
109
  }
110
+ // jsonb line-items (array of objects, e.g. a transfer's `items`) → the shared
111
+ // CollectionCell mini-table (localized headers + resolved ref chips) instead
112
+ // of raw JSON. Uses the column's declared item_fields when present.
113
+ const lineItems = asLineItemsArray(value);
114
+ if (lineItems) {
115
+ return (_jsx(CollectionCell, { value: lineItems, variant: "inline", itemFields: col
116
+ ?.itemFields ??
117
+ col
118
+ ?.item_fields, locale: locale }));
119
+ }
84
120
  // No column metadata → entity chip when the value is a resolved object,
85
121
  // plain string otherwise.
86
122
  if (!col) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asteby/metacore-runtime-react",
3
- "version": "18.25.0",
3
+ "version": "18.26.0",
4
4
  "description": "React runtime for metacore hosts — renders addon contributions dynamically",
5
5
  "repository": {
6
6
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "react-i18next": ">=13",
35
35
  "sonner": ">=1.7",
36
36
  "zustand": ">=5",
37
- "@asteby/metacore-ui": "^2.5.2",
38
- "@asteby/metacore-sdk": "^3.2.0"
37
+ "@asteby/metacore-sdk": "^3.2.0",
38
+ "@asteby/metacore-ui": "^2.5.2"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@tanstack/react-router": {
@@ -132,6 +132,13 @@ function resolveColumn(key: string, columns?: ColumnDefinition[]): ColumnDefinit
132
132
  if (!columns?.length) return undefined
133
133
  const exact = columns.find((c) => c.key === key)
134
134
  if (exact) return exact
135
+ // A resolved relation key is the FK column minus `_id` (the backend injects a
136
+ // `destination_warehouse` sibling next to `destination_warehouse_id`). The
137
+ // served metadata carries the LOCALIZED label on the `*_id` column, so match
138
+ // it — else the label falls back to humanizing the key in English
139
+ // ("Destination Warehouse" instead of "Almacén destino").
140
+ const fk = columns.find((c) => c.key === `${key}_id`)
141
+ if (fk) return fk
135
142
  // A diff key is the physical column (created_by); the served metadata may
136
143
  // only carry the dotted display column for it (created_by.avatar). Match on
137
144
  // the base segment so the diff cell inherits its label and rich renderer.
@@ -23,6 +23,33 @@ import { generateBadgeStyles, getInitials, optionColor, relationChipStyles } fro
23
23
  import type { ColumnDefinition } from './types'
24
24
  import { formatDateCell } from './dynamic-columns'
25
25
  import { humanizeToken } from './dynamic-columns-helpers'
26
+ import { CollectionCell, type ItemField } from './collection-cell'
27
+
28
+ /**
29
+ * Parses a value into a jsonb line-items array (array of plain objects) when it
30
+ * is one — directly, or from a JSON-encoded string. Returns null otherwise, so
31
+ * scalars / resolved-entity objects keep their existing renderers.
32
+ */
33
+ function asLineItemsArray(value: unknown): Record<string, unknown>[] | null {
34
+ let arr: unknown = value
35
+ if (typeof value === 'string') {
36
+ const t = value.trim()
37
+ if (!t.startsWith('[')) return null
38
+ try {
39
+ arr = JSON.parse(t)
40
+ } catch {
41
+ return null
42
+ }
43
+ }
44
+ if (
45
+ Array.isArray(arr) &&
46
+ arr.length > 0 &&
47
+ arr.every((v) => v !== null && typeof v === 'object' && !Array.isArray(v))
48
+ ) {
49
+ return arr as Record<string, unknown>[]
50
+ }
51
+ return null
52
+ }
26
53
 
27
54
  // ---------------------------------------------------------------------------
28
55
  // Internal helpers (mirror dynamic-columns.tsx private helpers)
@@ -128,6 +155,26 @@ export const ActivityValueRenderer: React.FC<ActivityValueRendererProps> = ({
128
155
  return <span className="text-muted-foreground">—</span>
129
156
  }
130
157
 
158
+ // jsonb line-items (array of objects, e.g. a transfer's `items`) → the shared
159
+ // CollectionCell mini-table (localized headers + resolved ref chips) instead
160
+ // of raw JSON. Uses the column's declared item_fields when present.
161
+ const lineItems = asLineItemsArray(value)
162
+ if (lineItems) {
163
+ return (
164
+ <CollectionCell
165
+ value={lineItems}
166
+ variant="inline"
167
+ itemFields={
168
+ (col as { itemFields?: ItemField[]; item_fields?: ItemField[] })
169
+ ?.itemFields ??
170
+ (col as { itemFields?: ItemField[]; item_fields?: ItemField[] })
171
+ ?.item_fields
172
+ }
173
+ locale={locale}
174
+ />
175
+ )
176
+ }
177
+
131
178
  // No column metadata → entity chip when the value is a resolved object,
132
179
  // plain string otherwise.
133
180
  if (!col) {