@luminix/mui-cms 0.2.13 → 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/docs/tipos.md ADDED
@@ -0,0 +1,248 @@
1
+ # Referência de tipos
2
+
3
+ Todos os tipos abaixo são exportados de `@luminix/mui-cms`.
4
+
5
+ ---
6
+
7
+ ## Ações
8
+
9
+ ### StaticAction
10
+
11
+ ```ts
12
+ type StaticAction = {
13
+ key?: string;
14
+ label: string;
15
+ icon?: React.ReactNode;
16
+ callback: (e: ActionCallbackEvent) => void;
17
+ };
18
+ ```
19
+
20
+ ### InstanceAction
21
+
22
+ ```ts
23
+ type InstanceAction = {
24
+ key?: string;
25
+ label: string;
26
+ icon?: React.ReactNode;
27
+ callback: (e: InstanceActionCallbackEvent) => void;
28
+ };
29
+ ```
30
+
31
+ ### MassAction
32
+
33
+ ```ts
34
+ type MassAction = {
35
+ key: string; // obrigatório
36
+ label: string;
37
+ callback: (e: MassActionCallbackEvent) => void;
38
+ };
39
+ ```
40
+
41
+ ### ActionCallbackEvent
42
+
43
+ ```ts
44
+ type ActionCallbackEvent = {
45
+ navigate: (path: string) => void;
46
+ refresh: () => void;
47
+ notify: NotifyFunction;
48
+ dialog: DialogFunction;
49
+ t: TFunction; // i18next
50
+ };
51
+ ```
52
+
53
+ ### InstanceActionCallbackEvent
54
+
55
+ ```ts
56
+ type InstanceActionCallbackEvent = ActionCallbackEvent & {
57
+ item: ModelType;
58
+ };
59
+ ```
60
+
61
+ ### MassActionCallbackEvent
62
+
63
+ ```ts
64
+ type MassActionCallbackEvent = ActionCallbackEvent & {
65
+ selected: Collection<ModelType>;
66
+ };
67
+ ```
68
+
69
+ ---
70
+
71
+ ## Tabela
72
+
73
+ ### Column
74
+
75
+ Estende `TableCellProps` do MUI:
76
+
77
+ ```ts
78
+ type Column = TableCellProps & {
79
+ key: string;
80
+ label: string;
81
+ sortable?: boolean;
82
+ };
83
+ ```
84
+
85
+ ---
86
+
87
+ ## Rotas
88
+
89
+ ### RouteObject
90
+
91
+ Re-exportado de `react-router-dom`. Use para tipar rotas adicionadas via redutor `cmsRoutes`:
92
+
93
+ ```ts
94
+ import type { RouteObject } from '@luminix/mui-cms';
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Configuração
100
+
101
+ ### CmsConfig
102
+
103
+ ```ts
104
+ type CmsConfig = {
105
+ layout?: {
106
+ breakpoint?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
107
+ drawer?: {
108
+ width?: number;
109
+ };
110
+ appBar?: {
111
+ height?: number;
112
+ color?: string;
113
+ };
114
+ };
115
+ };
116
+ ```
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
+
128
+ ---
129
+
130
+ ## Componente LuminixCms
131
+
132
+ ### LuminixCmsProps
133
+
134
+ ```ts
135
+ type LuminixCmsProps = Partial<LuminixProviderProps> & {
136
+ theme?: ThemeOptions; // MUI ThemeOptions
137
+ themeArgs?: object[]; // argumentos adicionais para createTheme()
138
+ };
139
+ ```
140
+
141
+ `LuminixProviderProps` vem de `@luminix/react`. Consulte a documentação desse pacote para ver as props herdadas.
142
+
143
+ ---
144
+
145
+ ## Filtros
146
+
147
+ ### FilterColumn
148
+
149
+ Representa uma coluna disponível para filtragem:
150
+
151
+ ```ts
152
+ type FilterColumn = {
153
+ key: string;
154
+ label: string;
155
+ type: string; // tipo do atributo (int, date, text, autocomplete, ...)
156
+ nullable: boolean;
157
+ is_relation: boolean;
158
+ };
159
+ ```
160
+
161
+ ### FilteredColumn
162
+
163
+ Estado de uma linha ativa no painel de filtros:
164
+
165
+ ```ts
166
+ type FilteredColumn = {
167
+ key: string;
168
+ type: string;
169
+ operator: string;
170
+ value: unknown;
171
+ };
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Notificações
177
+
178
+ ### NotifyFunction
179
+
180
+ ```ts
181
+ type NotifyFunction = (notification: string | Notification) => void;
182
+ ```
183
+
184
+ ### Notification
185
+
186
+ ```ts
187
+ type Notification = {
188
+ message: React.ReactNode;
189
+ severity?: 'success' | 'error' | 'warning' | 'info';
190
+ title?: React.ReactNode;
191
+ actions?: NotificationAction[];
192
+ };
193
+
194
+ type NotificationAction = {
195
+ label: React.ReactNode;
196
+ callback: () => void;
197
+ };
198
+ ```
199
+
200
+ ---
201
+
202
+ ## Diálogos
203
+
204
+ ### DialogFunction
205
+
206
+ ```ts
207
+ type DialogFunction = (message: string | DialogMessage) => Promise<boolean | string>;
208
+ ```
209
+
210
+ ### DialogMessage
211
+
212
+ ```ts
213
+ type DialogMessage = {
214
+ title?: React.ReactNode;
215
+ message: React.ReactNode;
216
+ type?: 'alert' | 'confirm' | 'prompt';
217
+ dismissable?: boolean;
218
+ confirmText?: string;
219
+ cancelText?: string;
220
+ defaultValue?: string;
221
+ dialogProps?: Partial<DialogProps>;
222
+ textFieldProps?: Partial<TextFieldProps>;
223
+ };
224
+ ```
225
+
226
+ ---
227
+
228
+ ## Menu
229
+
230
+ ### MenuItem
231
+
232
+ ```ts
233
+ type MenuItem = {
234
+ key: string;
235
+ text: string;
236
+ to?: string;
237
+ icon?: React.ReactNode;
238
+ children?: MenuItem[];
239
+ };
240
+ ```
241
+
242
+ ---
243
+
244
+ ## Próximos passos
245
+
246
+ - [Ações](acoes.md) — como usar esses tipos na prática
247
+ - [Extensibilidade](extensibilidade.md) — redutores e customizações
248
+ - [Volta ao índice](index.md)
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@luminix/mui-cms",
3
- "version": "0.2.13",
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",
@@ -12,15 +15,17 @@
12
15
  "build:dist": "tsc && vite build",
13
16
  "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
14
17
  "preview": "vite preview",
15
- "publish:beta": "npm run build && npm publish --tag beta"
18
+ "test": "vitest run",
19
+ "test:coverage": "vitest run --coverage",
20
+ "test:watch": "vitest"
16
21
  },
17
22
  "peerDependencies": {
18
23
  "@emotion/react": "^11.13.0",
19
24
  "@emotion/styled": "^11.13.0",
20
25
  "@fontsource/roboto": "^5.0.12",
21
- "@luminix/core": "^0.4.0",
22
- "@luminix/react": "^0.4.0",
23
- "@luminix/support": "^0.4.9",
26
+ "@luminix/core": "^1.0.0",
27
+ "@luminix/react": "^1.0.0",
28
+ "@luminix/support": "^1.0.1",
24
29
  "@mui/icons-material": "^5.16.5",
25
30
  "@mui/material": "^5.16.5",
26
31
  "i18next": "^23.12.2",
@@ -30,17 +35,24 @@
30
35
  "react-router-dom": "6.25.1"
31
36
  },
32
37
  "devDependencies": {
38
+ "@testing-library/jest-dom": "^6.9.1",
39
+ "@testing-library/react": "^16.3.2",
40
+ "@testing-library/user-event": "^14.6.1",
41
+ "@types/node": "^25.8.0",
33
42
  "@types/react": "^18.3.3",
34
43
  "@types/react-dom": "^18.3.0",
35
44
  "@typescript-eslint/eslint-plugin": "^7.2.0",
36
45
  "@typescript-eslint/parser": "^7.2.0",
37
46
  "@vitejs/plugin-react": "^4.2.1",
47
+ "@vitest/coverage-v8": "^4.1.6",
38
48
  "eslint": "^8.57.0",
39
49
  "eslint-plugin-react-hooks": "^4.6.0",
40
50
  "eslint-plugin-react-refresh": "^0.4.6",
51
+ "jsdom": "^29.1.1",
41
52
  "terser": "^5.31.6",
42
53
  "typescript": "^5.2.2",
43
54
  "vite": "^5.2.0",
44
- "vite-plugin-dts": "^4.0.3"
55
+ "vite-plugin-dts": "^4.0.3",
56
+ "vitest": "^4.1.6"
45
57
  }
46
58
  }
package/tsconfig.json CHANGED
@@ -21,5 +21,6 @@
21
21
  "noFallthroughCasesInSwitch": true
22
22
  },
23
23
  "include": ["src"],
24
+ "exclude": ["src/__tests__"],
24
25
  "references": [{ "path": "./tsconfig.node.json" }]
25
26
  }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "skipLibCheck": true,
5
+ "moduleResolution": "bundler",
6
+ "noUnusedLocals": false,
7
+ "noUnusedParameters": false,
8
+ "types": [
9
+ "vite/client",
10
+ "vitest/globals",
11
+ "@testing-library/jest-dom"
12
+ ]
13
+ },
14
+ "include": ["src"],
15
+ "exclude": []
16
+ }
@@ -0,0 +1,4 @@
1
+ import { default as React } from 'react';
2
+ import { LogoutButtonProps } from '../../../types/PropTypes';
3
+ declare const LogoutButton: React.FunctionComponent<LogoutButtonProps>;
4
+ export default LogoutButton;
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[];
@@ -91,6 +91,9 @@ export type BreadcrumbsProps = BreadcrumbsOwnProps & {
91
91
  href?: string;
92
92
  }[];
93
93
  };
94
+ export type LogoutButtonProps = {
95
+ collapsed?: boolean;
96
+ };
94
97
  export type InputOption = {
95
98
  key: string;
96
99
  label: string;
@@ -0,0 +1,22 @@
1
+ import { defineConfig } from 'vitest/config';
2
+ import { resolve } from 'path';
3
+
4
+ export default defineConfig({
5
+ resolve: {
6
+ alias: {
7
+ '@luminix/react': resolve(__dirname, 'node_modules/@luminix/react/dist/react.js'),
8
+ '@luminix/core': resolve(__dirname, 'node_modules/@luminix/core/dist/core.js'),
9
+ '@luminix/support': resolve(__dirname, 'node_modules/@luminix/support/dist/support.js'),
10
+ },
11
+ },
12
+ test: {
13
+ environment: 'jsdom',
14
+ globals: true,
15
+ setupFiles: ['./src/__tests__/setup.ts'],
16
+ coverage: {
17
+ provider: 'v8',
18
+ include: ['src/**/*.{ts,tsx}'],
19
+ exclude: ['src/__tests__/**', 'src/**/*.d.ts', 'src/main.tsx'],
20
+ },
21
+ },
22
+ });
File without changes