@asteby/metacore-runtime-react 37.4.0 → 37.5.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 +6 -0
- package/dist/dynamic-columns.d.ts.map +1 -1
- package/dist/dynamic-columns.js +26 -0
- package/package.json +3 -3
- package/src/dynamic-columns.tsx +34 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 37.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 453b82b: Contraparte de lectura de `DynamicMultiSelectField`: una columna `ref` cuyo valor es un array jsonb de ids (campo declarado con `multiple: true` al escribir) ahora se renderiza como una lista de badges resueltos por id (`RelationIdListCell`) en vez de intentar leer el sibling `{value,label}` de una FK simple — antes ese caso caía sin manejar en `RelationCell` y mostraba vacío/roto.
|
|
8
|
+
|
|
3
9
|
## 37.4.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-columns.d.ts","sourceRoot":"","sources":["../src/dynamic-columns.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"dynamic-columns.d.ts","sourceRoot":"","sources":["../src/dynamic-columns.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,UAAU,CAAA;AA2C9C,OAAO,KAAK,EAAiB,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE9D,OAAO,KAAK,EAER,iBAAiB,EACpB,MAAM,wBAAwB,CAAA;AAE/B,qEAAqE;AACrE,MAAM,WAAW,qBAAqB;IACl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}
|
package/dist/dynamic-columns.js
CHANGED
|
@@ -29,6 +29,7 @@ import { OptionsContext } from './options-context';
|
|
|
29
29
|
import { DynamicIcon, isLucideIconName } from './dynamic-icon';
|
|
30
30
|
import { CollectionCell } from './collection-cell';
|
|
31
31
|
import { isNilUuid, normalizeNilUuid } from './nil-uuid';
|
|
32
|
+
import { useOptionsResolver } from './use-options-resolver';
|
|
32
33
|
import { isColumnVisibleInTable } from './column-visibility';
|
|
33
34
|
const defaultGetImageUrl = (path) => path;
|
|
34
35
|
const getNestedValue = (obj, path) => path.split('.').reduce((acc, part) => acc && acc[part], obj);
|
|
@@ -265,6 +266,24 @@ const renderRelationBadges = (items, col) => {
|
|
|
265
266
|
return (_jsxs(Badge, { variant: "outline", className: "flex items-center gap-1", children: [iconValue && (_jsx(DynamicIcon, { name: iconValue, className: "h-3 w-3" })), _jsx("span", { children: label })] }, `${col.key}-${idx}`));
|
|
266
267
|
}) }));
|
|
267
268
|
};
|
|
269
|
+
/**
|
|
270
|
+
* Read-side counterpart of `DynamicMultiSelectField` (dynamic-multi-select-
|
|
271
|
+
* field.tsx): a `ref` column whose value is a plain jsonb array of target ids
|
|
272
|
+
* (field.multiple:true at write time) rather than the single-FK sibling
|
|
273
|
+
* `{value,label}` object `RelationCell` expects. There is no per-row backend
|
|
274
|
+
* resolution for this shape, so this cell resolves labels itself — one
|
|
275
|
+
* `useOptionsResolver` page (id → label) shared across every row of the
|
|
276
|
+
* column via `OptionsContext` — and renders each id as a badge.
|
|
277
|
+
*/
|
|
278
|
+
const RelationIdListCell = ({ ids, ref: relTarget }) => {
|
|
279
|
+
const { options } = useOptionsResolver({ modelKey: '', fieldKey: 'id', ref: relTarget, limit: 200 });
|
|
280
|
+
if (ids.length === 0)
|
|
281
|
+
return _jsx(EmptyCell, {});
|
|
282
|
+
return (_jsx("div", { className: "flex flex-wrap gap-1", children: ids.map((id) => {
|
|
283
|
+
const opt = options.find((o) => String(o.id) === String(id));
|
|
284
|
+
return (_jsx(Badge, { variant: "outline", children: opt ? opt.label : id.slice(0, 8) }, id));
|
|
285
|
+
}) }));
|
|
286
|
+
};
|
|
268
287
|
const BadgeWithEndpointOptions = ({ endpoint, value, getImageUrl }) => {
|
|
269
288
|
const { optionsMap } = React.useContext(OptionsContext);
|
|
270
289
|
const options = optionsMap.get(endpoint) || [];
|
|
@@ -711,6 +730,13 @@ export function makeDefaultGetDynamicColumns(helpers = {}) {
|
|
|
711
730
|
// `row[<key w/o _id>] = { value, label }` sibling.
|
|
712
731
|
if (renderAs === 'relation' ||
|
|
713
732
|
(col.ref && !col.options?.length && renderAs !== 'badge' && renderAs !== 'status')) {
|
|
733
|
+
// A `ref` column backed by a jsonb array (field.multiple:
|
|
734
|
+
// true at write time — see DynamicMultiSelectField) has no
|
|
735
|
+
// resolved sibling object; RelationCell expects one. Route
|
|
736
|
+
// it to the id-list cell instead.
|
|
737
|
+
if (Array.isArray(value)) {
|
|
738
|
+
return _jsx(RelationIdListCell, { ids: value.map(String), ref: col.ref });
|
|
739
|
+
}
|
|
714
740
|
return _jsx(RelationCell, { col: col, row: row.original, getImageUrl: getImageUrl });
|
|
715
741
|
}
|
|
716
742
|
// Option/type column: a `select`-style column ships its
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-runtime-react",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.5.0",
|
|
4
4
|
"description": "React runtime for metacore hosts — renders addon contributions dynamically",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -67,8 +67,8 @@
|
|
|
67
67
|
"typescript": "^6.0.0",
|
|
68
68
|
"vitest": "^4.0.0",
|
|
69
69
|
"zustand": "^5.0.0",
|
|
70
|
-
"@asteby/metacore-
|
|
71
|
-
"@asteby/metacore-
|
|
70
|
+
"@asteby/metacore-sdk": "3.7.0",
|
|
71
|
+
"@asteby/metacore-ui": "2.17.3"
|
|
72
72
|
},
|
|
73
73
|
"scripts": {
|
|
74
74
|
"build": "tsc -p tsconfig.json",
|
package/src/dynamic-columns.tsx
CHANGED
|
@@ -56,6 +56,7 @@ import { OptionsContext } from './options-context'
|
|
|
56
56
|
import { DynamicIcon, isLucideIconName } from './dynamic-icon'
|
|
57
57
|
import { CollectionCell } from './collection-cell'
|
|
58
58
|
import { isNilUuid, normalizeNilUuid } from './nil-uuid'
|
|
59
|
+
import { useOptionsResolver } from './use-options-resolver'
|
|
59
60
|
import type { TableMetadata, ColumnDefinition } from './types'
|
|
60
61
|
import { isColumnVisibleInTable } from './column-visibility'
|
|
61
62
|
import type {
|
|
@@ -381,6 +382,32 @@ const renderRelationBadges = (items: any, col: ColumnDefinition) => {
|
|
|
381
382
|
)
|
|
382
383
|
}
|
|
383
384
|
|
|
385
|
+
/**
|
|
386
|
+
* Read-side counterpart of `DynamicMultiSelectField` (dynamic-multi-select-
|
|
387
|
+
* field.tsx): a `ref` column whose value is a plain jsonb array of target ids
|
|
388
|
+
* (field.multiple:true at write time) rather than the single-FK sibling
|
|
389
|
+
* `{value,label}` object `RelationCell` expects. There is no per-row backend
|
|
390
|
+
* resolution for this shape, so this cell resolves labels itself — one
|
|
391
|
+
* `useOptionsResolver` page (id → label) shared across every row of the
|
|
392
|
+
* column via `OptionsContext` — and renders each id as a badge.
|
|
393
|
+
*/
|
|
394
|
+
const RelationIdListCell: React.FC<{ ids: string[]; ref: string }> = ({ ids, ref: relTarget }) => {
|
|
395
|
+
const { options } = useOptionsResolver({ modelKey: '', fieldKey: 'id', ref: relTarget, limit: 200 })
|
|
396
|
+
if (ids.length === 0) return <EmptyCell />
|
|
397
|
+
return (
|
|
398
|
+
<div className="flex flex-wrap gap-1">
|
|
399
|
+
{ids.map((id) => {
|
|
400
|
+
const opt = options.find((o) => String(o.id) === String(id))
|
|
401
|
+
return (
|
|
402
|
+
<Badge key={id} variant="outline">
|
|
403
|
+
{opt ? opt.label : id.slice(0, 8)}
|
|
404
|
+
</Badge>
|
|
405
|
+
)
|
|
406
|
+
})}
|
|
407
|
+
</div>
|
|
408
|
+
)
|
|
409
|
+
}
|
|
410
|
+
|
|
384
411
|
const BadgeWithEndpointOptions: React.FC<{
|
|
385
412
|
endpoint: string
|
|
386
413
|
value: any
|
|
@@ -1016,6 +1043,13 @@ export function makeDefaultGetDynamicColumns(
|
|
|
1016
1043
|
renderAs === 'relation' ||
|
|
1017
1044
|
(col.ref && !col.options?.length && renderAs !== 'badge' && renderAs !== 'status')
|
|
1018
1045
|
) {
|
|
1046
|
+
// A `ref` column backed by a jsonb array (field.multiple:
|
|
1047
|
+
// true at write time — see DynamicMultiSelectField) has no
|
|
1048
|
+
// resolved sibling object; RelationCell expects one. Route
|
|
1049
|
+
// it to the id-list cell instead.
|
|
1050
|
+
if (Array.isArray(value)) {
|
|
1051
|
+
return <RelationIdListCell ids={value.map(String)} ref={col.ref!} />
|
|
1052
|
+
}
|
|
1019
1053
|
return <RelationCell col={col} row={row.original} getImageUrl={getImageUrl} />
|
|
1020
1054
|
}
|
|
1021
1055
|
|