@praxisui/crud 1.0.0-beta.8 → 2.0.0-beta.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/README.md +106 -42
- package/drawer-adapter/index.d.ts +81 -0
- package/drawer-adapter/package.json +3 -0
- package/fesm2022/praxisui-crud-drawer-adapter.mjs +18 -0
- package/fesm2022/praxisui-crud-drawer-adapter.mjs.map +1 -0
- package/fesm2022/praxisui-crud.mjs +579 -153
- package/fesm2022/praxisui-crud.mjs.map +1 -1
- package/index.d.ts +80 -20
- package/package.json +16 -11
package/README.md
CHANGED
|
@@ -1,63 +1,127 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
---
|
|
2
|
+
title: "CRUD"
|
|
3
|
+
slug: "crud-overview"
|
|
4
|
+
description: "Visao geral do @praxisui/crud com fluxo table+form, open modes governados, estabilidade de contexto e orientacoes de integracao."
|
|
5
|
+
doc_type: "reference"
|
|
6
|
+
document_kind: "component-overview"
|
|
7
|
+
component: "crud"
|
|
8
|
+
category: "data-crud"
|
|
9
|
+
audience:
|
|
10
|
+
- "frontend"
|
|
11
|
+
- "host"
|
|
12
|
+
- "architect"
|
|
13
|
+
level: "intermediate"
|
|
14
|
+
status: "active"
|
|
15
|
+
owner: "praxis-ui"
|
|
16
|
+
tags:
|
|
17
|
+
- "crud"
|
|
18
|
+
- "table"
|
|
19
|
+
- "form"
|
|
20
|
+
- "open-mode"
|
|
21
|
+
- "integration"
|
|
22
|
+
order: 20
|
|
23
|
+
icon: "database"
|
|
24
|
+
toc: true
|
|
25
|
+
sidebar: true
|
|
26
|
+
search_boost: 1.0
|
|
27
|
+
reading_time: 12
|
|
28
|
+
estimated_setup_time: 20
|
|
29
|
+
version: "1.0"
|
|
30
|
+
related_docs:
|
|
31
|
+
- "host-crud-integration"
|
|
32
|
+
- "host-integration-guide"
|
|
33
|
+
keywords:
|
|
34
|
+
- "crud context"
|
|
35
|
+
- "open mode"
|
|
36
|
+
- "drawer"
|
|
37
|
+
- "modal"
|
|
38
|
+
last_updated: "2026-03-07"
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# @praxisui/crud
|
|
42
|
+
|
|
43
|
+
> Componentes e utilitários para telas CRUD no Praxis UI.
|
|
44
|
+
|
|
45
|
+
## Documentation
|
|
46
|
+
|
|
47
|
+
- Documentação oficial: https://praxisui.dev
|
|
48
|
+
- Aplicação de referência: https://github.com/codexrodrigues/praxis-ui-quickstart
|
|
49
|
+
- Indicado para: fluxos corporativos que combinam tabela, formulário e modos de abertura governados
|
|
50
|
+
|
|
51
|
+
## When to use
|
|
52
|
+
|
|
53
|
+
- Unificar listagem, formulario e acoes de CRUD no mesmo fluxo
|
|
54
|
+
- Governar modais, drawers e comportamento por metadados e configuracao
|
|
55
|
+
- Reduzir codigo repetido em telas administrativas e backoffice
|
|
56
|
+
|
|
57
|
+
## Install
|
|
14
58
|
|
|
15
59
|
```bash
|
|
16
|
-
|
|
60
|
+
npm i @praxisui/crud
|
|
17
61
|
```
|
|
18
62
|
|
|
19
|
-
|
|
63
|
+
Peer dependencies principais:
|
|
64
|
+
- `@angular/core`
|
|
65
|
+
- `@angular/common`
|
|
66
|
+
- `@praxisui/core`
|
|
67
|
+
- `@praxisui/dynamic-form`
|
|
68
|
+
- `@praxisui/table`
|
|
69
|
+
- `@praxisui/dynamic-fields`
|
|
70
|
+
- `@praxisui/settings-panel`
|
|
20
71
|
|
|
21
|
-
|
|
72
|
+
## 🎨 Tema M3 (tokens mínimos)
|
|
22
73
|
|
|
23
|
-
|
|
24
|
-
ng build praxis-crud
|
|
25
|
-
```
|
|
74
|
+
Para garantir que cabeçalhos e ações reflitam o tema do app host:
|
|
26
75
|
|
|
27
|
-
|
|
76
|
+
- Superfícies: `--md-sys-color-surface`, `--md-sys-color-surface-container`
|
|
77
|
+
- Texto/contorno: `--md-sys-color-on-surface`, `--md-sys-color-on-surface-variant`, `--md-sys-color-outline-variant`
|
|
78
|
+
- Semânticos: `--md-sys-color-primary`, `--md-sys-color-error`
|
|
79
|
+
- Elevação: `--md-sys-elevation-level1`–`--md-sys-elevation-level2`
|
|
80
|
+
Nota: a classe de tema é decisão do host (`.dark-theme` ou `.theme-dark`/`.theme-light`); mantenha tokens e componentes no mesmo escopo.
|
|
28
81
|
|
|
29
|
-
|
|
82
|
+
## Estabilidade de Change Detection
|
|
30
83
|
|
|
31
|
-
|
|
84
|
+
Para evitar regressoes de performance no fluxo CRUD, o `PraxisCrudComponent` mantem `crudContext` estavel em memoria.
|
|
32
85
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
```
|
|
86
|
+
Problema evitado:
|
|
87
|
+
- getters que retornam objetos novos a cada ciclo de CD provocam re-render constante no `PraxisTable`
|
|
88
|
+
- sintoma tipico: warnings de frame lento e UI \"pesada\" em rotas CRUD
|
|
37
89
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
```
|
|
90
|
+
Padrao recomendado:
|
|
91
|
+
- calcular o contexto uma vez por mudanca relevante (`ngOnChanges`)
|
|
92
|
+
- reutilizar a mesma referencia no template
|
|
42
93
|
|
|
43
|
-
|
|
94
|
+
Anti-pattern:
|
|
95
|
+
```ts
|
|
96
|
+
get tableCrudContext() {
|
|
97
|
+
return { tableId: 'x', actions: [] };
|
|
98
|
+
}
|
|
99
|
+
```
|
|
44
100
|
|
|
45
|
-
|
|
101
|
+
Padrao aplicado:
|
|
102
|
+
```ts
|
|
103
|
+
tableCrudContext?: CrudContext;
|
|
46
104
|
|
|
47
|
-
|
|
48
|
-
|
|
105
|
+
ngOnChanges(changes: SimpleChanges): void {
|
|
106
|
+
if (changes['metadata']) {
|
|
107
|
+
this.tableCrudContext = this.buildTableCrudContext(this.resolvedMetadata);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
49
110
|
```
|
|
50
111
|
|
|
51
|
-
|
|
112
|
+
Checklist rapido para PR:
|
|
113
|
+
- evitar metodos/getters no template que criem objeto/array
|
|
114
|
+
- preferir memoizacao por ciclo de vida/signal
|
|
115
|
+
- manter `trackBy` em listas dinamicas
|
|
116
|
+
|
|
117
|
+
## Documentacao Tecnica da Lib
|
|
52
118
|
|
|
53
|
-
|
|
119
|
+
- `projects/praxis-crud/docs/host-crud-runtime-and-openmode.md`
|
|
120
|
+
- `projects/praxis-crud/docs/adr/2026-03-drawer-adapter-light-entrypoint.md`
|
|
121
|
+
To build the library, run:
|
|
54
122
|
|
|
55
123
|
```bash
|
|
56
|
-
ng
|
|
124
|
+
ng build praxis-crud
|
|
57
125
|
```
|
|
58
126
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## Additional Resources
|
|
62
|
-
|
|
63
|
-
For more information on using the Angular CLI, including detailed command references, visit the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
|
|
127
|
+
This command will compile your project, and the build artifacts will be placed in the `dist/` directory.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { MatDialogConfig } from '@angular/material/dialog';
|
|
3
|
+
import { RowAction, ToolbarAction, BackConfig, ApiEndpoint, TableConfig, FormConfig } from '@praxisui/core';
|
|
4
|
+
|
|
5
|
+
type FormOpenMode = 'route' | 'modal' | 'drawer';
|
|
6
|
+
interface CrudParamMapping {
|
|
7
|
+
from: string;
|
|
8
|
+
to: 'routeParam' | 'query' | 'input';
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
type CrudAction = (RowAction | ToolbarAction) & {
|
|
12
|
+
openMode?: FormOpenMode;
|
|
13
|
+
route?: string;
|
|
14
|
+
formId?: string;
|
|
15
|
+
params?: CrudParamMapping[];
|
|
16
|
+
back?: BackConfig;
|
|
17
|
+
};
|
|
18
|
+
interface CrudHeaderConfig {
|
|
19
|
+
showBack?: boolean;
|
|
20
|
+
backLabel?: string;
|
|
21
|
+
variant?: 'ghost' | 'tonal' | 'outlined';
|
|
22
|
+
sticky?: boolean;
|
|
23
|
+
breadcrumbs?: boolean;
|
|
24
|
+
divider?: boolean;
|
|
25
|
+
}
|
|
26
|
+
interface CrudDefaults {
|
|
27
|
+
openMode?: FormOpenMode;
|
|
28
|
+
modal?: DialogConfig;
|
|
29
|
+
back?: BackConfig;
|
|
30
|
+
header?: CrudHeaderConfig;
|
|
31
|
+
}
|
|
32
|
+
interface CrudResource {
|
|
33
|
+
path: string;
|
|
34
|
+
idField?: string | number;
|
|
35
|
+
endpointKey?: ApiEndpoint;
|
|
36
|
+
}
|
|
37
|
+
interface CrudMetadata {
|
|
38
|
+
component: 'praxis-crud';
|
|
39
|
+
resource?: CrudResource;
|
|
40
|
+
data?: any[] | null;
|
|
41
|
+
table: TableConfig;
|
|
42
|
+
form?: FormConfig;
|
|
43
|
+
defaults?: CrudDefaults;
|
|
44
|
+
actions?: CrudAction[];
|
|
45
|
+
i18n?: {
|
|
46
|
+
crudDialog?: Record<string, string>;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
type CrudDrawerResultType = 'save' | 'delete' | 'close';
|
|
50
|
+
interface CrudDrawerResult {
|
|
51
|
+
type: CrudDrawerResultType;
|
|
52
|
+
data?: Record<string, unknown>;
|
|
53
|
+
}
|
|
54
|
+
interface CrudDrawerOpenConfig {
|
|
55
|
+
action: CrudAction;
|
|
56
|
+
metadata: CrudMetadata;
|
|
57
|
+
inputs: Record<string, unknown>;
|
|
58
|
+
/**
|
|
59
|
+
* Notifica fechamento do drawer (cancelamento/fechamento externo/resultado finalizado).
|
|
60
|
+
*/
|
|
61
|
+
onClose?: () => void;
|
|
62
|
+
/**
|
|
63
|
+
* Notifica resultado semântico do fluxo em drawer.
|
|
64
|
+
* Hosts podem propagar `save/delete/close` para sincronizar telemetria/eventos.
|
|
65
|
+
*/
|
|
66
|
+
onResult?: (result: CrudDrawerResult) => void;
|
|
67
|
+
}
|
|
68
|
+
interface CrudDrawerAdapter {
|
|
69
|
+
open(config: CrudDrawerOpenConfig): Promise<void> | void;
|
|
70
|
+
}
|
|
71
|
+
interface DialogConfig<D = any> extends MatDialogConfig<D> {
|
|
72
|
+
disableCloseOnBackdrop?: boolean;
|
|
73
|
+
disableCloseOnEsc?: boolean;
|
|
74
|
+
canMaximize?: boolean;
|
|
75
|
+
startMaximized?: boolean;
|
|
76
|
+
fullscreenBreakpoint?: number;
|
|
77
|
+
}
|
|
78
|
+
declare const CRUD_DRAWER_ADAPTER: InjectionToken<CrudDrawerAdapter>;
|
|
79
|
+
|
|
80
|
+
export { CRUD_DRAWER_ADAPTER };
|
|
81
|
+
export type { CrudAction, CrudDefaults, CrudDrawerAdapter, CrudDrawerOpenConfig, CrudDrawerResult, CrudDrawerResultType, CrudHeaderConfig, CrudMetadata, CrudParamMapping, CrudResource, DialogConfig, FormOpenMode };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
function getCrudDrawerAdapterToken() {
|
|
4
|
+
const registryKey = '__PAX_CRUD_DRAWER_ADAPTER_TOKEN__';
|
|
5
|
+
const globalRegistry = globalThis;
|
|
6
|
+
if (!globalRegistry[registryKey]) {
|
|
7
|
+
globalRegistry[registryKey] = new InjectionToken('CRUD_DRAWER_ADAPTER');
|
|
8
|
+
}
|
|
9
|
+
return globalRegistry[registryKey];
|
|
10
|
+
}
|
|
11
|
+
const CRUD_DRAWER_ADAPTER = getCrudDrawerAdapterToken();
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Generated bundle index. Do not edit.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export { CRUD_DRAWER_ADAPTER };
|
|
18
|
+
//# sourceMappingURL=praxisui-crud-drawer-adapter.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"praxisui-crud-drawer-adapter.mjs","sources":["../../../projects/praxis-crud/drawer-adapter/src/drawer-adapter.ts","../../../projects/praxis-crud/drawer-adapter/praxisui-crud-drawer-adapter.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\nimport type { MatDialogConfig } from '@angular/material/dialog';\nimport type {\n ApiEndpoint,\n BackConfig,\n FormConfig,\n RowAction,\n TableConfig,\n ToolbarAction,\n} from '@praxisui/core';\n\nexport type FormOpenMode = 'route' | 'modal' | 'drawer';\n\nexport interface CrudParamMapping {\n from: string;\n to: 'routeParam' | 'query' | 'input';\n name: string;\n}\n\nexport type CrudAction = (RowAction | ToolbarAction) & {\n openMode?: FormOpenMode;\n route?: string;\n formId?: string;\n params?: CrudParamMapping[];\n back?: BackConfig;\n};\n\nexport interface CrudHeaderConfig {\n showBack?: boolean;\n backLabel?: string;\n variant?: 'ghost' | 'tonal' | 'outlined';\n sticky?: boolean;\n breadcrumbs?: boolean;\n divider?: boolean;\n}\n\nexport interface CrudDefaults {\n openMode?: FormOpenMode;\n modal?: DialogConfig;\n back?: BackConfig;\n header?: CrudHeaderConfig;\n}\n\nexport interface CrudResource {\n path: string;\n idField?: string | number;\n endpointKey?: ApiEndpoint;\n}\n\nexport interface CrudMetadata {\n component: 'praxis-crud';\n resource?: CrudResource;\n data?: any[] | null;\n table: TableConfig;\n form?: FormConfig;\n defaults?: CrudDefaults;\n actions?: CrudAction[];\n i18n?: { crudDialog?: Record<string, string> };\n}\n\nexport type CrudDrawerResultType = 'save' | 'delete' | 'close';\n\nexport interface CrudDrawerResult {\n type: CrudDrawerResultType;\n data?: Record<string, unknown>;\n}\n\nexport interface CrudDrawerOpenConfig {\n action: CrudAction;\n metadata: CrudMetadata;\n inputs: Record<string, unknown>;\n /**\n * Notifica fechamento do drawer (cancelamento/fechamento externo/resultado finalizado).\n */\n onClose?: () => void;\n /**\n * Notifica resultado semântico do fluxo em drawer.\n * Hosts podem propagar `save/delete/close` para sincronizar telemetria/eventos.\n */\n onResult?: (result: CrudDrawerResult) => void;\n}\n\nexport interface CrudDrawerAdapter {\n open(config: CrudDrawerOpenConfig): Promise<void> | void;\n}\n\nexport interface DialogConfig<D = any> extends MatDialogConfig<D> {\n disableCloseOnBackdrop?: boolean;\n disableCloseOnEsc?: boolean;\n canMaximize?: boolean;\n startMaximized?: boolean;\n fullscreenBreakpoint?: number;\n}\n\nfunction getCrudDrawerAdapterToken(): InjectionToken<CrudDrawerAdapter> {\n const registryKey = '__PAX_CRUD_DRAWER_ADAPTER_TOKEN__';\n const globalRegistry = globalThis as typeof globalThis & {\n [registryKey]?: InjectionToken<CrudDrawerAdapter>;\n };\n if (!globalRegistry[registryKey]) {\n globalRegistry[registryKey] = new InjectionToken<CrudDrawerAdapter>('CRUD_DRAWER_ADAPTER');\n }\n return globalRegistry[registryKey];\n}\n\nexport const CRUD_DRAWER_ADAPTER = getCrudDrawerAdapterToken();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AA8FA,SAAS,yBAAyB,GAAA;IAChC,MAAM,WAAW,GAAG,mCAAmC;IACvD,MAAM,cAAc,GAAG,UAEtB;AACD,IAAA,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE;QAChC,cAAc,CAAC,WAAW,CAAC,GAAG,IAAI,cAAc,CAAoB,qBAAqB,CAAC;IAC5F;AACA,IAAA,OAAO,cAAc,CAAC,WAAW,CAAC;AACpC;AAEO,MAAM,mBAAmB,GAAG,yBAAyB;;ACzG5D;;AAEG;;;;"}
|