@asteby/metacore-runtime-react 50.0.0 → 50.2.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 +12 -0
- package/dist/addon-loader.d.ts.map +1 -1
- package/dist/addon-loader.js +11 -3
- package/dist/row-actions-menu.d.ts +7 -1
- package/dist/row-actions-menu.d.ts.map +1 -1
- package/dist/row-actions-menu.js +3 -3
- package/package.json +8 -4
- package/src/__tests__/secondary-actions.test.tsx +19 -0
- package/src/addon-loader.tsx +20 -3
- package/src/row-actions-menu.tsx +14 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 50.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b285f48: RowActionsMenu: nueva prop `groupSecondary` (por defecto `true`, sin cambios). Con `false` todas las acciones de la fila salen en el primer nivel del menú, sin el submenú «Más…».
|
|
8
|
+
|
|
9
|
+
## 50.1.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 3ee45fd: `@module-federation/vite` (starter-config) y `@module-federation/runtime` (runtime-react) pasan de `dependencies` a `peerDependencies` opcionales. Las apps sin microfrontends ya no los instalan; `runtime-react` carga `@module-federation/runtime` de forma diferida sólo al cargar un addon federado. Migración para apps con federación: agregar explícitamente `@module-federation/vite` (devDependency) y `@module-federation/runtime` (dependency) a su `package.json`. La API no cambia.
|
|
14
|
+
|
|
3
15
|
## 50.0.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addon-loader.d.ts","sourceRoot":"","sources":["../src/addon-loader.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"addon-loader.d.ts","sourceRoot":"","sources":["../src/addon-loader.tsx"],"names":[],"mappings":"AAyBA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAc3E,MAAM,WAAW,gBAAgB;IAC7B,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAA;IACb,+EAA+E;IAC/E,GAAG,EAAE,MAAM,CAAA;IACX,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,+DAA+D;IAC/D,GAAG,EAAE,QAAQ,CAAA;IACb;;;;OAIG;IACH,YAAY,CAAC,EAAE,QAAQ,CAAA;IACvB;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,wCAAwC;IACxC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC1B,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,+BAA+B;IAC/B,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAA;IAC9B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AA4ED,wBAAgB,WAAW,CAAC,EACxB,KAAK,EACL,GAAG,EACH,MAAqB,EACrB,GAAG,EACH,YAAY,EACZ,QAAQ,EACR,SAAS,EACT,QAAe,EACf,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,GACX,EAAE,gBAAgB,sCAmElB"}
|
package/dist/addon-loader.js
CHANGED
|
@@ -10,7 +10,15 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
10
10
|
// purged, and register() runs again against the new remote. The host shell
|
|
11
11
|
// (auth, QueryClient, WebSocket, service worker controller) is not touched.
|
|
12
12
|
import { useEffect, useRef, useState } from 'react';
|
|
13
|
-
|
|
13
|
+
let mfRuntime = null;
|
|
14
|
+
function getMfRuntime() {
|
|
15
|
+
mfRuntime ??= import('@module-federation/runtime').catch((e) => {
|
|
16
|
+
mfRuntime = null;
|
|
17
|
+
throw new Error('Loading federated addons requires the optional peer dependency "@module-federation/runtime" (pnpm add @module-federation/runtime). ' +
|
|
18
|
+
(e instanceof Error ? e.message : String(e)));
|
|
19
|
+
});
|
|
20
|
+
return mfRuntime;
|
|
21
|
+
}
|
|
14
22
|
import { useDeclareAddonLayout } from './addon-layout-context';
|
|
15
23
|
import { composeDisposables, disposableFromRegisterResult, markRemoteRegistered, purgeAddonFrontendCache, resolvePluginExports, runDispose, shouldReregisterRemote, } from './addon-fiber';
|
|
16
24
|
// Derive the `loadRemote` id from the scope + exposed module name. MF resolves
|
|
@@ -63,10 +71,10 @@ async function loadAddon(scope, url, module) {
|
|
|
63
71
|
// fetches the new remoteEntry. `force: true` wipes that remote's module
|
|
64
72
|
// cache — without it, loadRemote would keep serving the previous bundle.
|
|
65
73
|
if (shouldReregisterRemote(scope, url)) {
|
|
66
|
-
await withRemoteLoadRetry(() => registerRemotes([{ name: scope, entry: url, type: 'module' }], { force: true }));
|
|
74
|
+
await withRemoteLoadRetry(() => getMfRuntime().then((mf) => mf.registerRemotes([{ name: scope, entry: url, type: 'module' }], { force: true })));
|
|
67
75
|
markRemoteRegistered(scope, url);
|
|
68
76
|
}
|
|
69
|
-
return withRemoteLoadRetry(() => loadRemote(remoteId(scope, module)));
|
|
77
|
+
return withRemoteLoadRetry(() => getMfRuntime().then((mf) => mf.loadRemote(remoteId(scope, module))));
|
|
70
78
|
}
|
|
71
79
|
export function AddonLoader({ scope, url, module = './register', api, hostRegistry, addonKey, unbindKey, fallback = null, onReady, onError, layout, children, }) {
|
|
72
80
|
const [status, setStatus] = useState('loading');
|
|
@@ -21,6 +21,12 @@ export interface RowActionsMenuProps {
|
|
|
21
21
|
/** Sustituye el ícono del disparador (p. ej. un spinner mientras imprime). */
|
|
22
22
|
triggerIcon?: React.ReactNode;
|
|
23
23
|
disabled?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Agrupa las acciones secundarias en un submenú «Más…» (por defecto). Con
|
|
26
|
+
* `false` todas se listan en el primer nivel: las secundarias van después
|
|
27
|
+
* de un separador, sin submenú.
|
|
28
|
+
*/
|
|
29
|
+
groupSecondary?: boolean;
|
|
24
30
|
}
|
|
25
31
|
/**
|
|
26
32
|
* Modelo de las filas que pinta la tabla. DynamicTable lo provee: la factoría
|
|
@@ -28,5 +34,5 @@ export interface RowActionsMenuProps {
|
|
|
28
34
|
* para resolver las acciones aportadas por addons.
|
|
29
35
|
*/
|
|
30
36
|
export declare const RowActionsModelContext: React.Context<string | undefined>;
|
|
31
|
-
export declare function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled }: RowActionsMenuProps): React.JSX.Element | null;
|
|
37
|
+
export declare function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled, groupSecondary }: RowActionsMenuProps): React.JSX.Element | null;
|
|
32
38
|
//# sourceMappingURL=row-actions-menu.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row-actions-menu.d.ts","sourceRoot":"","sources":["../src/row-actions-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAqB9B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAC9B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,GACZ,EAAE;IACC,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,qBAgBA;AAED,MAAM,WAAW,mBAAmB;IAChC,yEAAyE;IACzE,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAChD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"row-actions-menu.d.ts","sourceRoot":"","sources":["../src/row-actions-menu.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAqB9B;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAC9B,MAAM,EACN,KAAK,EACL,QAAQ,EACR,SAAS,GACZ,EAAE;IACC,MAAM,EAAE,GAAG,CAAA;IACX,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,qBAgBA;AAED,MAAM,WAAW,mBAAmB;IAChC,yEAAyE;IACzE,OAAO,EAAE,GAAG,EAAE,CAAA;IACd,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACxB,qEAAqE;IACrE,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,IAAI,CAAA;IAChD,8EAA8E;IAC9E,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,mCAAqD,CAAA;AAMxF,wBAAgB,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,cAAqB,EAAE,EAAE,mBAAmB,4BA6ElI"}
|
package/dist/row-actions-menu.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
// RowActionsMenu — el «…» de una fila: la acción primaria (si hay) arriba y
|
|
3
3
|
// destacada, las principales debajo y las secundarias (compartir, imprimir,
|
|
4
4
|
// correo, chat, PDF/XML y lo que aporten addons vía registerRecordAction)
|
|
5
|
-
// agrupadas en un «Más…» discreto. Una acción por capacidad sin proveedor
|
|
5
|
+
// agrupadas en un «Más…» discreto (o en el primer nivel con groupSecondary={false}). Una acción por capacidad sin proveedor
|
|
6
6
|
// activo, o una contribución cuyo addon no está instalado, no aparece.
|
|
7
7
|
//
|
|
8
8
|
// DynamicTable lo usa por defecto (getDynamicColumns) y los hosts que arman su
|
|
@@ -34,7 +34,7 @@ export function RowActionMenuItem({ action, label, onSelect, className, }) {
|
|
|
34
34
|
* para resolver las acciones aportadas por addons.
|
|
35
35
|
*/
|
|
36
36
|
export const RowActionsModelContext = React.createContext(undefined);
|
|
37
|
-
export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled }) {
|
|
37
|
+
export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled, groupSecondary = true }) {
|
|
38
38
|
const { t } = useTranslation();
|
|
39
39
|
const installed = useInstalledAddons();
|
|
40
40
|
const ctxModel = React.useContext(RowActionsModelContext);
|
|
@@ -53,7 +53,7 @@ export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, dis
|
|
|
53
53
|
const renderEntry = (e) => e.kind === 'action' ? (_jsx(RowActionMenuItem, { action: e.action, label: translateMetadataLabel(e.action.label, t), onSelect: () => onAction?.(e.action.key, row) }, e.action.key)) : (_jsxs(DropdownMenuItem, { "data-action": e.item.key, onClick: () => void e.item.run?.(), children: [_jsx(DynamicIcon, { name: e.item.icon || 'Share2', className: "mr-2 h-4 w-4" }), t(e.item.label, { defaultValue: e.item.label })] }, e.item.key));
|
|
54
54
|
const hasMain = !!primary || mainEntries.length > 0;
|
|
55
55
|
const moreLabel = t('datatable.more_actions', { defaultValue: 'Más…' });
|
|
56
|
-
return (_jsx("div", { className: "flex items-center justify-end", children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: "h-8 w-8 p-0", disabled: disabled, onClick: (e) => e.stopPropagation(), children: [_jsx("span", { className: "sr-only", children: t('datatable.open_menu', { defaultValue: 'Abrir menú' }) }), triggerIcon ?? _jsx(MoreHorizontal, { className: "h-4 w-4" })] }) }), _jsxs(DropdownMenuContent, { align: "end", onClick: (e) => e.stopPropagation(), children: [primary ? (_jsx(RowActionMenuItem, { action: primary, label: translateMetadataLabel(primary.label, t), onSelect: () => onAction?.(primary.key, row), className: "font-semibold" })) : null, mainEntries.map(renderEntry), secondaryEntries.length > 0 && hasMain ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuSub, { children: [_jsx(DropdownMenuSubTrigger, { "data-row-more": "", className: "text-muted-foreground", children: moreLabel }), _jsx(DropdownMenuSubContent, { "data-row-secondary": "", children: secondaryEntries.map(renderEntry) })] })] })) : (
|
|
56
|
+
return (_jsx("div", { className: "flex items-center justify-end", children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", className: "h-8 w-8 p-0", disabled: disabled, onClick: (e) => e.stopPropagation(), children: [_jsx("span", { className: "sr-only", children: t('datatable.open_menu', { defaultValue: 'Abrir menú' }) }), triggerIcon ?? _jsx(MoreHorizontal, { className: "h-4 w-4" })] }) }), _jsxs(DropdownMenuContent, { align: "end", onClick: (e) => e.stopPropagation(), children: [primary ? (_jsx(RowActionMenuItem, { action: primary, label: translateMetadataLabel(primary.label, t), onSelect: () => onAction?.(primary.key, row), className: "font-semibold" })) : null, mainEntries.map(renderEntry), secondaryEntries.length > 0 && hasMain && !groupSecondary ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), secondaryEntries.map(renderEntry)] })) : secondaryEntries.length > 0 && hasMain ? (_jsxs(_Fragment, { children: [_jsx(DropdownMenuSeparator, {}), _jsxs(DropdownMenuSub, { children: [_jsx(DropdownMenuSubTrigger, { "data-row-more": "", className: "text-muted-foreground", children: moreLabel }), _jsx(DropdownMenuSubContent, { "data-row-secondary": "", children: secondaryEntries.map(renderEntry) })] })] })) : (
|
|
57
57
|
// Sin principales no hay con qué competir: lista plana.
|
|
58
58
|
secondaryEntries.map(renderEntry))] })] }) }));
|
|
59
59
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-runtime-react",
|
|
3
|
-
"version": "50.
|
|
3
|
+
"version": "50.2.0",
|
|
4
4
|
"description": "React runtime for metacore hosts — renders addon contributions dynamically",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"@dnd-kit/core": "^6.3.0",
|
|
21
21
|
"@dnd-kit/sortable": "^10.0.0",
|
|
22
22
|
"@dnd-kit/utilities": "^3.2.2",
|
|
23
|
-
"@module-federation/runtime": "^2.5.0",
|
|
24
23
|
"@tanstack/react-virtual": "^3.14.13",
|
|
25
24
|
"recharts": "^2.15.0",
|
|
26
25
|
"zod": "^4.3.0"
|
|
@@ -39,7 +38,8 @@
|
|
|
39
38
|
"react-dom": ">=18",
|
|
40
39
|
"react-i18next": ">=13",
|
|
41
40
|
"sonner": ">=1.7",
|
|
42
|
-
"zustand": ">=5"
|
|
41
|
+
"zustand": ">=5",
|
|
42
|
+
"@module-federation/runtime": ">=2.5"
|
|
43
43
|
},
|
|
44
44
|
"peerDependenciesMeta": {
|
|
45
45
|
"@tanstack/react-router": {
|
|
@@ -47,6 +47,9 @@
|
|
|
47
47
|
},
|
|
48
48
|
"react-day-picker": {
|
|
49
49
|
"optional": true
|
|
50
|
+
},
|
|
51
|
+
"@module-federation/runtime": {
|
|
52
|
+
"optional": true
|
|
50
53
|
}
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
|
@@ -70,7 +73,8 @@
|
|
|
70
73
|
"tsx": "^4.21.0",
|
|
71
74
|
"typescript": "^6.0.0",
|
|
72
75
|
"vitest": "^4.0.0",
|
|
73
|
-
"zustand": "^5.0.0"
|
|
76
|
+
"zustand": "^5.0.0",
|
|
77
|
+
"@module-federation/runtime": "^2.5.0"
|
|
74
78
|
},
|
|
75
79
|
"scripts": {
|
|
76
80
|
"build": "tsc -p tsconfig.json",
|
|
@@ -129,6 +129,25 @@ describe('RowActionsMenu', () => {
|
|
|
129
129
|
expect(screen.getByText('Enviar al chat')).toBeTruthy()
|
|
130
130
|
})
|
|
131
131
|
|
|
132
|
+
it('con groupSecondary={false} todas las acciones salen en el primer nivel, sin «Más…»', async () => {
|
|
133
|
+
const run = shareToChat()
|
|
134
|
+
render(
|
|
135
|
+
<InstalledAddonsProvider addons={['link']}>
|
|
136
|
+
<RowActionsMenu actions={ACTIONS} row={ROW} model="Invoice" groupSecondary={false} />
|
|
137
|
+
</InstalledAddonsProvider>,
|
|
138
|
+
)
|
|
139
|
+
await openMenu()
|
|
140
|
+
const top = [...document.querySelectorAll('[role="menu"] > [role="menuitem"]')].map(
|
|
141
|
+
(el) => el.getAttribute('data-action') ?? el.textContent,
|
|
142
|
+
)
|
|
143
|
+
expect(top).toEqual(['stamp', 'cancel', 'approve', 'send_cfdi_email', 'reprint_cfdi', 'team_chat.share'])
|
|
144
|
+
expect(screen.queryByText('Más…')).toBeNull()
|
|
145
|
+
await act(async () => {
|
|
146
|
+
fireEvent.click(screen.getByText('Enviar al chat'))
|
|
147
|
+
})
|
|
148
|
+
expect(run).toHaveBeenCalledWith({ model: 'Invoice', record: ROW })
|
|
149
|
+
})
|
|
150
|
+
|
|
132
151
|
it('primaria única destacada; las secundarias van bajo «Más…», no en el primer nivel', async () => {
|
|
133
152
|
const run = shareToChat()
|
|
134
153
|
render(
|
package/src/addon-loader.tsx
CHANGED
|
@@ -9,7 +9,20 @@
|
|
|
9
9
|
// purged, and register() runs again against the new remote. The host shell
|
|
10
10
|
// (auth, QueryClient, WebSocket, service worker controller) is not touched.
|
|
11
11
|
import { useEffect, useRef, useState } from 'react'
|
|
12
|
-
|
|
12
|
+
// `@module-federation/runtime` is an OPTIONAL peer: apps without federated
|
|
13
|
+
// addons never install it. It is loaded lazily, only when an addon is loaded.
|
|
14
|
+
type MfRuntime = typeof import('@module-federation/runtime')
|
|
15
|
+
let mfRuntime: Promise<MfRuntime> | null = null
|
|
16
|
+
function getMfRuntime(): Promise<MfRuntime> {
|
|
17
|
+
mfRuntime ??= import('@module-federation/runtime').catch((e) => {
|
|
18
|
+
mfRuntime = null
|
|
19
|
+
throw new Error(
|
|
20
|
+
'Loading federated addons requires the optional peer dependency "@module-federation/runtime" (pnpm add @module-federation/runtime). ' +
|
|
21
|
+
(e instanceof Error ? e.message : String(e)),
|
|
22
|
+
)
|
|
23
|
+
})
|
|
24
|
+
return mfRuntime
|
|
25
|
+
}
|
|
13
26
|
import type { AddonAPI, AddonLayout, Registry } from '@asteby/metacore-sdk'
|
|
14
27
|
import { useDeclareAddonLayout } from './addon-layout-context'
|
|
15
28
|
import {
|
|
@@ -131,12 +144,16 @@ async function loadAddon(
|
|
|
131
144
|
// cache — without it, loadRemote would keep serving the previous bundle.
|
|
132
145
|
if (shouldReregisterRemote(scope, url)) {
|
|
133
146
|
await withRemoteLoadRetry(() =>
|
|
134
|
-
|
|
147
|
+
getMfRuntime().then((mf) =>
|
|
148
|
+
mf.registerRemotes([{ name: scope, entry: url, type: 'module' }], { force: true }),
|
|
149
|
+
),
|
|
135
150
|
)
|
|
136
151
|
markRemoteRegistered(scope, url)
|
|
137
152
|
}
|
|
138
153
|
return withRemoteLoadRetry(() =>
|
|
139
|
-
|
|
154
|
+
getMfRuntime().then((mf) =>
|
|
155
|
+
mf.loadRemote<AddonRegisterModule>(remoteId(scope, module)),
|
|
156
|
+
),
|
|
140
157
|
)
|
|
141
158
|
}
|
|
142
159
|
|
package/src/row-actions-menu.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// RowActionsMenu — el «…» de una fila: la acción primaria (si hay) arriba y
|
|
2
2
|
// destacada, las principales debajo y las secundarias (compartir, imprimir,
|
|
3
3
|
// correo, chat, PDF/XML y lo que aporten addons vía registerRecordAction)
|
|
4
|
-
// agrupadas en un «Más…» discreto. Una acción por capacidad sin proveedor
|
|
4
|
+
// agrupadas en un «Más…» discreto (o en el primer nivel con groupSecondary={false}). Una acción por capacidad sin proveedor
|
|
5
5
|
// activo, o una contribución cuyo addon no está instalado, no aparece.
|
|
6
6
|
//
|
|
7
7
|
// DynamicTable lo usa por defecto (getDynamicColumns) y los hosts que arman su
|
|
@@ -71,6 +71,12 @@ export interface RowActionsMenuProps {
|
|
|
71
71
|
/** Sustituye el ícono del disparador (p. ej. un spinner mientras imprime). */
|
|
72
72
|
triggerIcon?: React.ReactNode
|
|
73
73
|
disabled?: boolean
|
|
74
|
+
/**
|
|
75
|
+
* Agrupa las acciones secundarias en un submenú «Más…» (por defecto). Con
|
|
76
|
+
* `false` todas se listan en el primer nivel: las secundarias van después
|
|
77
|
+
* de un separador, sin submenú.
|
|
78
|
+
*/
|
|
79
|
+
groupSecondary?: boolean
|
|
74
80
|
}
|
|
75
81
|
|
|
76
82
|
/**
|
|
@@ -84,7 +90,7 @@ type MenuEntry =
|
|
|
84
90
|
| { kind: 'action'; action: any }
|
|
85
91
|
| { kind: 'contribution'; item: ResolvedRecordAction }
|
|
86
92
|
|
|
87
|
-
export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled }: RowActionsMenuProps) {
|
|
93
|
+
export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, disabled, groupSecondary = true }: RowActionsMenuProps) {
|
|
88
94
|
const { t } = useTranslation()
|
|
89
95
|
const installed = useInstalledAddons()
|
|
90
96
|
const ctxModel = React.useContext(RowActionsModelContext)
|
|
@@ -138,7 +144,12 @@ export function RowActionsMenu({ actions, row, model, onAction, triggerIcon, dis
|
|
|
138
144
|
/>
|
|
139
145
|
) : null}
|
|
140
146
|
{mainEntries.map(renderEntry)}
|
|
141
|
-
{secondaryEntries.length > 0 && hasMain ? (
|
|
147
|
+
{secondaryEntries.length > 0 && hasMain && !groupSecondary ? (
|
|
148
|
+
<>
|
|
149
|
+
<DropdownMenuSeparator />
|
|
150
|
+
{secondaryEntries.map(renderEntry)}
|
|
151
|
+
</>
|
|
152
|
+
) : secondaryEntries.length > 0 && hasMain ? (
|
|
142
153
|
<>
|
|
143
154
|
<DropdownMenuSeparator />
|
|
144
155
|
<DropdownMenuSub>
|