@asteby/metacore-runtime-react 53.29.0 → 53.29.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
package/dist/loom/proposals.js
CHANGED
|
@@ -61,7 +61,7 @@ export function ProposalReview({ queue, labelOf, values }) {
|
|
|
61
61
|
const label = (p, k) => p.labels?.[k] ?? labelOf?.(k) ?? k;
|
|
62
62
|
if (!queue.pending.length && !queue.applied)
|
|
63
63
|
return null;
|
|
64
|
-
return (_jsxs("div", { className: "grid gap-2", "data-loom-proposals": "", children: [queue.pending.map((p) => {
|
|
64
|
+
return (_jsxs("div", { className: "mb-4 grid gap-2", "data-loom-proposals": "", children: [queue.pending.map((p) => {
|
|
65
65
|
const keys = Object.keys(p.patch);
|
|
66
66
|
return (_jsxs("section", { "aria-label": p.reason ?? t('loom.proposal.title', { defaultValue: 'Cambios propuestos' }), "data-loom-proposal": p.graft, className: "rounded-lg border bg-muted/40 p-3 text-sm", children: [_jsx("p", { className: "font-medium", children: p.reason ?? t('loom.proposal.title', { defaultValue: 'Cambios propuestos' }) }), _jsxs("table", { className: "mt-2 w-full text-xs", children: [_jsx("thead", { className: "sr-only", children: _jsxs("tr", { children: [_jsx("th", { children: t('loom.proposal.field', { defaultValue: 'Campo' }) }), _jsx("th", { children: t('loom.proposal.before', { defaultValue: 'Antes' }) }), _jsx("th", { children: t('loom.proposal.after', { defaultValue: 'Después' }) })] }) }), _jsx("tbody", { children: keys.map((k) => {
|
|
67
67
|
const same = show(values[k]) === show(p.patch[k]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-runtime-react",
|
|
3
|
-
"version": "53.29.
|
|
3
|
+
"version": "53.29.1",
|
|
4
4
|
"description": "React runtime for metacore hosts — renders addon contributions dynamically",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"zustand": ">=5",
|
|
64
64
|
"@module-federation/runtime": ">=2.5",
|
|
65
65
|
"@testing-library/react": ">=14",
|
|
66
|
-
"@asteby/metacore-genui": "^2.
|
|
66
|
+
"@asteby/metacore-genui": "^2.11.0"
|
|
67
67
|
},
|
|
68
68
|
"peerDependenciesMeta": {
|
|
69
69
|
"@tanstack/react-router": {
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"vitest": "^4.0.0",
|
|
106
106
|
"zustand": "^5.0.0",
|
|
107
107
|
"@module-federation/runtime": "^2.5.0",
|
|
108
|
-
"@asteby/metacore-genui": "2.
|
|
108
|
+
"@asteby/metacore-genui": "2.11.0"
|
|
109
109
|
},
|
|
110
110
|
"scripts": {
|
|
111
111
|
"build": "tsc -p tsconfig.json && node ../../scripts/fix-dist-esm-imports.mjs",
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Pagina como datos (genui.page-graph/v1) + overlays: el arbol de genui pasa por la fusion plana de Loom
|
|
2
|
+
// y vuelve a ser un arbol valido que `resolveGraph` compila. La funcion de fusion es la de Loom (no se duplica).
|
|
3
|
+
import { describe, expect, it } from 'vitest'
|
|
4
|
+
import { fromBlockGraph, indexGraph, parsePageGraph, resolveGraph, toBlockGraph, type PageGraph } from '@asteby/metacore-genui'
|
|
5
|
+
import { applyOverlays, type OverlayLayer } from '../loom'
|
|
6
|
+
|
|
7
|
+
const base: PageGraph = {
|
|
8
|
+
version: 'genui.page-graph/v1',
|
|
9
|
+
id: 'dashboard',
|
|
10
|
+
root: [
|
|
11
|
+
{
|
|
12
|
+
id: 'kpis',
|
|
13
|
+
type: 'grid',
|
|
14
|
+
props: { areas: ['a b'], columns: ['1fr', '1fr'] },
|
|
15
|
+
children: [
|
|
16
|
+
{ id: 'kpi.sales', type: 'kpi_card', area: 'a', props: { label: 'Ventas', value: 1 } },
|
|
17
|
+
{ id: 'kpi.margin', type: 'kpi_card', area: 'b', props: { label: 'Margen', value: 2 }, visible: { permission: 'reports.margin.read' } },
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{ id: 'recent', type: 'section', props: { mode: 'declarative', title: 'Recientes' } },
|
|
21
|
+
],
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const run = (layers: OverlayLayer[]) => {
|
|
25
|
+
const { graph: flat } = toBlockGraph(base, '1.0.0')
|
|
26
|
+
const r = applyOverlays(flat, layers)
|
|
27
|
+
const back = fromBlockGraph(r.graph, {}, Object.fromEntries(Object.entries(r.provenance).map(([k, v]) => [k, { origin: v.origin }])))
|
|
28
|
+
return { r, ...back }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe('page graph + applyOverlays', () => {
|
|
32
|
+
it('add / configure / move / remove keep a valid tree and the stable ids', () => {
|
|
33
|
+
const { r, graph, orphans } = run([
|
|
34
|
+
{
|
|
35
|
+
id: 'preset.7leguas',
|
|
36
|
+
scope: 'preset',
|
|
37
|
+
ops: [
|
|
38
|
+
{ op: 'add', block: { id: 'leguas.vehicles', type: 'kpi_card', region: 'kpis', config: { area: 'a', label: 'Vehiculos', value: 3 } }, after: 'kpi.sales' },
|
|
39
|
+
{ op: 'configure', id: 'kpi.sales', set: { label: 'Ventas netas' } },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
{ id: 'org.matriz', scope: 'org', ops: [{ op: 'remove', id: 'recent' }] },
|
|
43
|
+
])
|
|
44
|
+
expect(r.conflicts).toEqual([])
|
|
45
|
+
expect(orphans).toEqual([])
|
|
46
|
+
expect(parsePageGraph(graph).ok).toBe(true)
|
|
47
|
+
const idx = indexGraph(graph)
|
|
48
|
+
expect([...idx.keys()]).toEqual(['kpis', 'kpi.sales', 'leguas.vehicles', 'kpi.margin'])
|
|
49
|
+
expect(idx.get('kpi.sales')!.node.props).toMatchObject({ label: 'Ventas netas' })
|
|
50
|
+
expect(idx.get('leguas.vehicles')!.node.origin).toBe('preset.7leguas')
|
|
51
|
+
const blocks = resolveGraph(graph, { can: () => true }).blocks
|
|
52
|
+
expect((blocks[0]!.blocks as Array<{ id: string }>).map((b) => b.id)).toEqual(['kpi.sales', 'leguas.vehicles', 'kpi.margin'])
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('visibility survives a configure and is enforced after the merge', () => {
|
|
56
|
+
const { graph } = run([{ id: 'org.x', scope: 'org', ops: [{ op: 'configure', id: 'kpi.sales', set: { visible: { setting: { key: 'sales.kpi', equals: true } } } }] }])
|
|
57
|
+
expect(parsePageGraph(graph).ok).toBe(true)
|
|
58
|
+
expect(resolveGraph(graph, { can: () => true, settings: {} }).hidden).toContainEqual({ id: 'kpi.sales', reason: 'setting', detail: 'sales.kpi' })
|
|
59
|
+
expect(resolveGraph(graph, { can: () => true, settings: { 'sales.kpi': true } }).hidden).toEqual([])
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('replace keeps the original as fallback_node and its position', () => {
|
|
63
|
+
const { graph } = run([{ id: 'preset.p', scope: 'preset', ops: [{ op: 'replace', id: 'kpi.margin', with: { id: 'x', type: 'ext', config: { ext: 'crm.margin@1' } } }] }])
|
|
64
|
+
const n = indexGraph(graph).get('kpi.margin')!
|
|
65
|
+
expect(n.parentId).toBe('kpis')
|
|
66
|
+
expect(n.node).toMatchObject({ type: 'ext', props: { ext: 'crm.margin@1' }, fallback_node: { type: 'kpi_card', props: { label: 'Margen' } } })
|
|
67
|
+
expect(resolveGraph(graph, { can: () => true }).fallbacks['kpi.margin']).toMatchObject({ type: 'kpi_card', label: 'Margen' })
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
it('a layer that fails is discarded whole and the tree is the base', () => {
|
|
71
|
+
const { r, graph } = run([{ id: 'org.bad', scope: 'org', ops: [{ op: 'remove', id: 'recent' }, { op: 'remove', id: 'nope' }] }])
|
|
72
|
+
expect(r.conflicts).toHaveLength(1)
|
|
73
|
+
expect([...indexGraph(graph).keys()]).toEqual(['kpis', 'kpi.sales', 'kpi.margin', 'recent'])
|
|
74
|
+
})
|
|
75
|
+
})
|
package/src/loom/proposals.tsx
CHANGED
|
@@ -91,7 +91,7 @@ export function ProposalReview({ queue, labelOf, values }: ProposalReviewProps)
|
|
|
91
91
|
const label = (p: Proposal, k: string) => p.labels?.[k] ?? labelOf?.(k) ?? k
|
|
92
92
|
if (!queue.pending.length && !queue.applied) return null
|
|
93
93
|
return (
|
|
94
|
-
<div className="grid gap-2" data-loom-proposals="">
|
|
94
|
+
<div className="mb-4 grid gap-2" data-loom-proposals="">
|
|
95
95
|
{queue.pending.map((p) => {
|
|
96
96
|
const keys = Object.keys(p.patch)
|
|
97
97
|
return (
|