@luminix/mui-cms 1.0.0 → 1.1.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/bundle/mui-cms.bundle.iife.js +33 -33
- package/dist/mui-cms.js +1162 -1122
- package/docs/componentes.md +19 -0
- package/docs/extensibilidade.md +45 -0
- package/docs/facades.md +12 -0
- package/docs/tipos.md +10 -0
- package/package.json +5 -3
- package/types/components/Layout/Drawer/LogoutButton.d.ts +4 -0
- package/types/dist.d.ts +3 -1
- package/types/services/CmsService.d.ts +3 -0
- package/types/types/PropTypes.d.ts +3 -0
package/docs/componentes.md
CHANGED
|
@@ -33,6 +33,24 @@ import { Link } from '@luminix/mui-cms';
|
|
|
33
33
|
|
|
34
34
|
---
|
|
35
35
|
|
|
36
|
+
## LogoutButton
|
|
37
|
+
|
|
38
|
+
Botão de logout exibido no rodapé do menu lateral. Pode ser importado diretamente quando precisar ser usado fora do contexto do Drawer padrão.
|
|
39
|
+
|
|
40
|
+
```tsx
|
|
41
|
+
import { LogoutButton } from '@luminix/mui-cms';
|
|
42
|
+
|
|
43
|
+
<LogoutButton collapsed={false} />
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
| Prop | Tipo | Padrão | Descrição |
|
|
47
|
+
|---|---|---|---|
|
|
48
|
+
| `collapsed` | `boolean` | `false` | Quando `true`, exibe apenas o ícone (modo recolhido do drawer) com um Tooltip |
|
|
49
|
+
|
|
50
|
+
O comportamento padrão ao clicar é chamar `auth().logout()` do `@luminix/core`. Veja [Extensibilidade](extensibilidade.md#logoutbutton) para formas de customização.
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
36
54
|
## Providers de contexto
|
|
37
55
|
|
|
38
56
|
Os providers a seguir são usados internamente pelas views e componentes da biblioteca. Em cenários avançados, você pode usá-los para acessar os contextos em componentes customizados.
|
|
@@ -116,6 +134,7 @@ O `CmsServiceProvider` registra um mapa de componentes acessível via `Cms.getCo
|
|
|
116
134
|
| `Layout.AppBar` | Barra superior |
|
|
117
135
|
| `Layout.AppLogo` | Logo no drawer |
|
|
118
136
|
| `Layout.Drawer` | Menu lateral |
|
|
137
|
+
| `Layout.Drawer.LogoutButton` | Botão de logout no rodapé do drawer |
|
|
119
138
|
| `Layout.SearchBar` | Campo de busca |
|
|
120
139
|
| `Layout.BackButton` | Botão voltar |
|
|
121
140
|
| `ModelIndex.Filter` | Painel de filtros avançados |
|
package/docs/extensibilidade.md
CHANGED
|
@@ -116,6 +116,51 @@ Cms.reducer('cmsRoutes', (routes, components) => {
|
|
|
116
116
|
|
|
117
117
|
> Adicionar a rota fora de `routes[0].children` (ex.: `[...routes, { path: '...' }]`) faz a página renderizar sem o Layout do painel.
|
|
118
118
|
|
|
119
|
+
### LogoutButton
|
|
120
|
+
|
|
121
|
+
O botão de logout no rodapé do drawer pode ser personalizado de duas formas:
|
|
122
|
+
|
|
123
|
+
**1. Apenas o comportamento ao clicar** — via `Cms.logoutUsing()` no `boot()` do seu `ServiceProvider`:
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
class AppServiceProvider extends ServiceProvider {
|
|
127
|
+
boot() {
|
|
128
|
+
Cms.logoutUsing(() => {
|
|
129
|
+
// lógica de logout customizada
|
|
130
|
+
window.location.href = '/login';
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**2. Aparência e comportamento completos** — substituindo o componente `'Layout.Drawer.LogoutButton'`:
|
|
137
|
+
|
|
138
|
+
```tsx
|
|
139
|
+
import React from 'react';
|
|
140
|
+
import { ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material';
|
|
141
|
+
import { ExitToApp } from '@mui/icons-material';
|
|
142
|
+
import type { LogoutButtonProps } from '@luminix/mui-cms';
|
|
143
|
+
|
|
144
|
+
const MeuLogout: React.FC<LogoutButtonProps> = ({ collapsed }) => (
|
|
145
|
+
<ListItem disablePadding>
|
|
146
|
+
<ListItemButton onClick={() => { /* minha lógica */ }}>
|
|
147
|
+
<ListItemIcon><ExitToApp /></ListItemIcon>
|
|
148
|
+
{!collapsed && <ListItemText primary="Sair do sistema" />}
|
|
149
|
+
</ListItemButton>
|
|
150
|
+
</ListItem>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
// No boot() do seu ServiceProvider:
|
|
154
|
+
Cms.reducer('componentMap', (map) => ({
|
|
155
|
+
...map,
|
|
156
|
+
'Layout.Drawer.LogoutButton': MeuLogout,
|
|
157
|
+
}));
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
O componente recebe a prop `collapsed: boolean` — `true` quando o drawer está recolhido no modo desktop.
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
119
164
|
### wireModelFormProps
|
|
120
165
|
|
|
121
166
|
Personaliza o formulário de modelo:
|
package/docs/facades.md
CHANGED
|
@@ -44,6 +44,18 @@ Retorna as ações de instância (por linha) disponíveis.
|
|
|
44
44
|
|
|
45
45
|
Retorna as ações estáticas (nível de listagem, ex.: "Criar novo").
|
|
46
46
|
|
|
47
|
+
#### `Cms.logoutUsing(callback: () => void): void`
|
|
48
|
+
|
|
49
|
+
Registra um callback customizado para o botão de logout do menu lateral. Substitui o comportamento padrão de `auth().logout()`.
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
Cms.logoutUsing(() => {
|
|
53
|
+
window.location.href = '/login';
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Deve ser chamado no `boot()` de um `ServiceProvider`. Veja mais em [Extensibilidade — LogoutButton](extensibilidade.md#logoutbutton).
|
|
58
|
+
|
|
47
59
|
### Redutores disponíveis
|
|
48
60
|
|
|
49
61
|
| Redutor | Assinatura | Uso |
|
package/docs/tipos.md
CHANGED
|
@@ -115,6 +115,16 @@ type CmsConfig = {
|
|
|
115
115
|
};
|
|
116
116
|
```
|
|
117
117
|
|
|
118
|
+
### LogoutButtonProps
|
|
119
|
+
|
|
120
|
+
Props recebidas pelo componente `Layout.Drawer.LogoutButton`. Relevante ao substituir o componente via redutor `componentMap`.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
type LogoutButtonProps = {
|
|
124
|
+
collapsed?: boolean; // true quando o drawer está recolhido no desktop
|
|
125
|
+
};
|
|
126
|
+
```
|
|
127
|
+
|
|
118
128
|
---
|
|
119
129
|
|
|
120
130
|
## Componente LuminixCms
|
package/package.json
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luminix/mui-cms",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "bundle/mui-cms.js",
|
|
6
6
|
"module": "dist/mui-cms.js",
|
|
7
7
|
"types": "types/index.d.ts",
|
|
8
|
+
"repository": {
|
|
9
|
+
"url": "git+https://github.com/luminix-cms/js-mui-cms"
|
|
10
|
+
},
|
|
8
11
|
"scripts": {
|
|
9
12
|
"dev": "vite --port=3333 --config=vite.config.dev.ts",
|
|
10
13
|
"build": "npm run build:bundle && npm run build:dist",
|
|
@@ -14,8 +17,7 @@
|
|
|
14
17
|
"preview": "vite preview",
|
|
15
18
|
"test": "vitest run",
|
|
16
19
|
"test:coverage": "vitest run --coverage",
|
|
17
|
-
"test:watch": "vitest"
|
|
18
|
-
"publish:beta": "npm run build && npm publish --tag beta"
|
|
20
|
+
"test:watch": "vitest"
|
|
19
21
|
},
|
|
20
22
|
"peerDependencies": {
|
|
21
23
|
"@emotion/react": "^11.13.0",
|
package/types/dist.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { default as CmsServiceProvider } from './providers/CmsServiceProvider';
|
|
|
2
2
|
import { default as i18NextServiceProvider } from './providers/i18NextServiceProvider';
|
|
3
3
|
import { default as LuminixCms } from './components/LuminixCms';
|
|
4
4
|
import { default as Link } from './components/Link';
|
|
5
|
+
import { default as LogoutButton } from './components/Layout/Drawer/LogoutButton';
|
|
5
6
|
import { default as DialogProvider } from './components/providers/DialogProvider';
|
|
6
7
|
import { default as LayoutProvider } from './components/providers/LayoutProvider';
|
|
7
8
|
import { default as ModelProvider } from './components/providers/ModelProvider';
|
|
@@ -26,6 +27,7 @@ import { default as useTable } from './hooks/useTable';
|
|
|
26
27
|
import { default as Cms } from './facades/Cms';
|
|
27
28
|
import { default as Icon } from './facades/Icon';
|
|
28
29
|
import { default as Filter } from './facades/Filter';
|
|
29
|
-
export { CmsServiceProvider, i18NextServiceProvider, LuminixCms, Link, Cms, Filter, Icon, useActionEvent, useBackButton, useCurrentModel, useDialog, useDisplaceNotifications, useHandleError, useHasSearch, useIsDesktopMode, useLayoutConfig, useMenu, useNotify, usePageTitle, useSearch, useSelection, useSetPageTitle, useTable, DialogProvider, LayoutProvider, ModelProvider, NotificationProvider, TableProvider, };
|
|
30
|
+
export { CmsServiceProvider, i18NextServiceProvider, LuminixCms, Link, LogoutButton, Cms, Filter, Icon, useActionEvent, useBackButton, useCurrentModel, useDialog, useDisplaceNotifications, useHandleError, useHasSearch, useIsDesktopMode, useLayoutConfig, useMenu, useNotify, usePageTitle, useSearch, useSelection, useSetPageTitle, useTable, DialogProvider, LayoutProvider, ModelProvider, NotificationProvider, TableProvider, };
|
|
30
31
|
export type { RouteObject, } from './types/Reducers';
|
|
32
|
+
export type { LogoutButtonProps, } from './types/PropTypes';
|
|
31
33
|
export type { InstanceAction, StaticAction, MassAction, ActionCallbackEvent, InstanceActionCallbackEvent, MassActionCallbackEvent, Column, } from './types/Table';
|
|
@@ -7,11 +7,14 @@ import { StaticAction, MassAction } from '../types/Table';
|
|
|
7
7
|
export declare class CmsService {
|
|
8
8
|
[key: string]: any;
|
|
9
9
|
private components;
|
|
10
|
+
private logoutCallback;
|
|
10
11
|
booted(): void;
|
|
11
12
|
getComponents(): Record<string, React.ComponentType<any>>;
|
|
12
13
|
getComponent(name: string): React.ComponentType<any>;
|
|
13
14
|
getRoutes(): RouteObject[];
|
|
14
15
|
getMenuItems(): MenuItem[];
|
|
16
|
+
logoutUsing(callback: () => void): void;
|
|
17
|
+
getLogoutCallback(): () => void;
|
|
15
18
|
getModelFormProps(item: ModelType): ModelFormProps;
|
|
16
19
|
getMassActions(ModelClass: typeof ModelType, currentTab: string): MassAction[];
|
|
17
20
|
getInstanceActions(ModelClass: typeof ModelType, currentTab: string): StaticAction[];
|