@praxisui/crud 1.0.0-beta.5 → 1.0.0-beta.52

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 CHANGED
@@ -1,6 +1,107 @@
1
- # PraxisCrud
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
+ ## 🎨 Tema M3 (tokens mínimos)
46
+
47
+ Para garantir que cabeçalhos e ações reflitam o tema do app host:
48
+
49
+ - Superfícies: `--md-sys-color-surface`, `--md-sys-color-surface-container`
50
+ - Texto/contorno: `--md-sys-color-on-surface`, `--md-sys-color-on-surface-variant`, `--md-sys-color-outline-variant`
51
+ - Semânticos: `--md-sys-color-primary`, `--md-sys-color-error`
52
+ - Elevação: `--md-sys-elevation-level1`–`--md-sys-elevation-level2`
53
+ Nota: a classe de tema é decisão do host (`.dark-theme` ou `.theme-dark`/`.theme-light`); mantenha tokens e componentes no mesmo escopo.
54
+
55
+ ## 🔰 Exemplos / Quickstart
56
+
57
+ Para ver esta biblioteca em funcionamento em uma aplicação completa, utilize o projeto de exemplo (Quickstart):
58
+
59
+ - Repositório: https://github.com/codexrodrigues/praxis-ui-quickstart
60
+ - O Quickstart demonstra a integração das bibliotecas `@praxisui/*` em um app Angular, incluindo instalação, configuração e uso em telas reais.
61
+
62
+ ## Estabilidade de Change Detection
63
+
64
+ Para evitar regressoes de performance no fluxo CRUD, o `PraxisCrudComponent` mantem `crudContext` estavel em memoria.
65
+
66
+ Problema evitado:
67
+ - getters que retornam objetos novos a cada ciclo de CD provocam re-render constante no `PraxisTable`
68
+ - sintoma tipico: warnings de frame lento e UI \"pesada\" em rotas CRUD
69
+
70
+ Padrao recomendado:
71
+ - calcular o contexto uma vez por mudanca relevante (`ngOnChanges`)
72
+ - reutilizar a mesma referencia no template
73
+
74
+ Anti-pattern:
75
+ ```ts
76
+ get tableCrudContext() {
77
+ return { tableId: 'x', actions: [] };
78
+ }
79
+ ```
80
+
81
+ Padrao aplicado:
82
+ ```ts
83
+ tableCrudContext?: CrudContext;
84
+
85
+ ngOnChanges(changes: SimpleChanges): void {
86
+ if (changes['metadata']) {
87
+ this.tableCrudContext = this.buildTableCrudContext(this.resolvedMetadata);
88
+ }
89
+ }
90
+ ```
91
+
92
+ Checklist rapido para PR:
93
+ - evitar metodos/getters no template que criem objeto/array
94
+ - preferir memoizacao por ciclo de vida/signal
95
+ - manter `trackBy` em listas dinamicas
96
+
97
+ ## Documentacao Tecnica da Lib
98
+
99
+ - `projects/praxis-crud/docs/host-crud-runtime-and-openmode.md`
100
+ - `projects/praxis-crud/docs/adr/2026-03-drawer-adapter-light-entrypoint.md`
101
+
102
+ ---
2
103
 
3
- This project was generated using [Angular CLI](https://github.com/angular/angular-cli) version 20.1.0.
104
+ Este projeto foi gerado com [Angular CLI](https://github.com/angular/angular-cli) versão 20.1.0.
4
105
 
5
106
  ## Code scaffolding
6
107
 
@@ -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,3 @@
1
+ {
2
+ "module": "../fesm2022/praxisui-crud-drawer-adapter.mjs"
3
+ }
@@ -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;;;;"}