@praxisui/core 1.0.0-beta.7 → 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 CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  > Biblioteca central com interfaces e serviços fundamentais para o Praxis UI Workspace
4
4
 
5
+ ## Documentation
6
+
7
+ - Official documentation: https://praxisui.dev
8
+ - Quickstart reference app: https://github.com/codexrodrigues/praxis-ui-quickstart
9
+ - Recommended for: hosts that need the shared contracts, tokens, icons and base services used across `@praxisui/*`
10
+
11
+ ## When to use
12
+
13
+ - Centralize shared contracts, tokens and utilities across Praxis UI packages
14
+ - Keep icon, config and dynamic widget infrastructure aligned in the host app
15
+ - Avoid duplicating low-level primitives across multiple business libraries
16
+
5
17
  ## 🌟 Visão Geral
6
18
 
7
19
  A biblioteca `@praxisui/core` é o núcleo do Praxis UI Workspace, fornecendo interfaces robustas, serviços base e utilitários essenciais para todas as outras bibliotecas do ecossistema. Com a arquitetura unificada, oferece uma experiência de desenvolvimento consistente e type-safe.
@@ -35,6 +47,9 @@ A biblioteca `@praxisui/core` é o núcleo do Praxis UI Workspace, fornecendo in
35
47
  npm install @praxisui/core
36
48
  ```
37
49
 
50
+ Exemplo completo (app de referência)
51
+ - Quickstart: https://github.com/codexrodrigues/praxis-ui-quickstart
52
+
38
53
  ### Peer dependencies (Angular v20)
39
54
 
40
55
  - `@angular/core` `^20.0.0`
@@ -105,6 +120,153 @@ Observação: os IDs de widgets usados na página devem estar registrados via `C
105
120
  [`public-api.ts`](https://github.com/codexrodrigues/praxis/blob/main/frontend-libs/praxis-ui-workspace/projects/praxis-core/src/public-api.ts)
106
121
  para a lista consolidada de serviços, tokens, modelos e utilitários disponíveis para importação.
107
122
 
123
+ ## 📄 Documentacao Tecnica da Lib
124
+
125
+ - `projects/praxis-core/docs/connection-editor.md`
126
+ - `projects/praxis-core/docs/dynamic-gridster-page.md`
127
+ - `projects/praxis-core/docs/schema-flow.md`
128
+
129
+ ## ⚙️ Global Config (bootstrap)
130
+
131
+ - Use `provideGlobalConfigTenant(...)` para definir o tenant e bloquear o bootstrap até a config remota ser carregada.
132
+ - Se não houver tenant, use `provideGlobalConfigReady()` para apenas aguardar o carregamento remoto.
133
+
134
+ ## 🌐 Global Actions (shell + widgets)
135
+
136
+ O core agora suporta **ações globais** executadas por widgets e pelo Widget Shell, permitindo integrar navegação, dialog, toast, analytics, API e rotas dinâmicas de forma padronizada.
137
+
138
+ ### 1) Providers (plug-and-play no host)
139
+
140
+ ```ts
141
+ import {
142
+ providePraxisGlobalActions,
143
+ providePraxisToastGlobalActions,
144
+ providePraxisAnalyticsGlobalActions,
145
+ } from '@praxisui/core';
146
+ import { providePraxisDialogGlobalActions } from '@praxisui/dialog';
147
+
148
+ providers: [
149
+ ...providePraxisGlobalActions({ dialog: false, toast: false, analytics: false }),
150
+ providePraxisDialogGlobalActions(),
151
+ providePraxisToastGlobalActions(),
152
+ providePraxisAnalyticsGlobalActions({ prefix: 'app' }),
153
+ ]
154
+ ```
155
+
156
+ ### 2) Mapeando outputs para ações globais
157
+
158
+ `WidgetDefinition.outputs` pode apontar para ações globais:
159
+
160
+ ```ts
161
+ definition: {
162
+ id: 'praxis-dynamic-form',
163
+ outputs: {
164
+ formSubmit: {
165
+ type: 'api.post',
166
+ params: { url: '/api/clientes', body: '${payload.formData}' }
167
+ }
168
+ }
169
+ }
170
+ ```
171
+
172
+ ### 3) Ação global no Widget Shell
173
+
174
+ ```ts
175
+ shell: {
176
+ actions: [
177
+ { id: 'back', icon: 'arrow_back', command: 'global:navigation.back' }
178
+ ]
179
+ }
180
+ ```
181
+
182
+ ### 4) Catálogo básico de ações globais
183
+
184
+ - `navigation.back`
185
+ - `navigation.openExternal` → `{ url }`
186
+ - `dialog.alert` → `{ title, message, variant }`
187
+ - `dialog.prompt` → `{ title, message, placeholder, defaultValue }`
188
+ - `dialog.open` → `{ componentId, inputs, size, data }`
189
+ - `toast.success` / `toast.error` → `{ message }`
190
+ - `clipboard.copy` → `{ text }`
191
+ - `trackEvent` → `{ eventName, payload }`
192
+ - `log` → `{ level, message, payload }`
193
+ - `api.get` / `api.post` / `api.patch` → `{ url, params|body }`
194
+ - `route.register` → `{ path, componentId|loadChildren, data?, resolve?, guards?, canMatch?, canActivateChild?, replace?, position? }`
195
+
196
+ ### 5) Rotas dinâmicas (route.register)
197
+
198
+ Requer `componentId` **ou** `loadChildren`. Guards são resolvidos pelo host via `GLOBAL_ROUTE_GUARD_RESOLVER`.
199
+
200
+ ```ts
201
+ // payload
202
+ {
203
+ path: '/clientes/novo',
204
+ componentId: 'praxis-dynamic-page',
205
+ data: { pageId: 'clientes-novo' },
206
+ guards: ['auth', 'permission:clientes.create'],
207
+ position: 'before-wildcard'
208
+ }
209
+ ```
210
+
211
+ As rotas registradas são persistidas em `GlobalConfig.routes.dynamic`. O host deve re‑hidratar isso no bootstrap (ex.: ler `GlobalConfigService` e re‑aplicar com `route.register`).
212
+
213
+ ### 7) Output mapeado para ação global x conexões
214
+
215
+ Quando `WidgetDefinition.outputs[output]` aponta para uma ação global (não `'emit'`), o evento **não** é repassado para conexões locais — a ação global tem prioridade.
216
+
217
+ ### 6) Estilo de toast
218
+
219
+ O estilo padrão usa as classes `.pdx-toast-success` / `.pdx-toast-error`.
220
+ Inclua estilos equivalentes no app host (ou sobrescreva com `providePraxisToastGlobalActions`).
221
+
222
+ ## 🔎 Schema Viewer (para Showcases)
223
+
224
+ Para exibir os metadados e schemas usados por um exemplo (ex.: na aba “Schema” de um showcase), use o componente `SchemaViewerComponent` e (opcionalmente) injete o contexto via `SCHEMA_VIEWER_CONTEXT`.
225
+
226
+ ```ts
227
+ import { Component, Provider } from '@angular/core';
228
+ import { PraxisTabs, TabsMetadata } from '@praxisui/tabs';
229
+ import { SchemaViewerComponent, SCHEMA_VIEWER_CONTEXT } from '@praxisui/core';
230
+
231
+ @Component({
232
+ standalone: true,
233
+ selector: 'app-tabs-showcase',
234
+ imports: [PraxisTabs, SchemaViewerComponent],
235
+ template: `
236
+ <!-- Aba Preview -->
237
+ <praxis-tabs [config]="tabs" tabsId="tabs-preview"></praxis-tabs>
238
+
239
+ <!-- Aba Schema -->
240
+ <praxis-schema-viewer [context]="schemaCtx"></praxis-schema-viewer>
241
+ `,
242
+ providers: [
243
+ {
244
+ provide: SCHEMA_VIEWER_CONTEXT,
245
+ useFactory: () => ({
246
+ componentId: 'praxis-tabs',
247
+ title: 'Tabs — Schema & Metadata',
248
+ rawConfig: {
249
+ group: { alignTabs: 'center', dynamicHeight: true },
250
+ tabs: [ { id: 't1', textLabel: 'Dados', content: [] } ],
251
+ } satisfies TabsMetadata,
252
+ }),
253
+ } as Provider,
254
+ ],
255
+ })
256
+ export class TabsShowcaseComponent {
257
+ tabs: TabsMetadata = { group: { dynamicHeight: true }, tabs: [] };
258
+ schemaCtx = {
259
+ componentId: 'praxis-tabs',
260
+ rawConfig: this.tabs,
261
+ };
262
+ }
263
+ ```
264
+
265
+ Campos opcionais do contexto (`SchemaViewerContext`):
266
+ - `rawConfig` (JSON usado pelo exemplo), `effectiveConfig` (se houver merge de defaults);
267
+ - `backendSchema` (OpenAPI/JSON Schema) e `schemaMeta` (path/operation/schemaType/schemaHash);
268
+ - `normalizedFields` (se já normalizado; caso contrário, o componente aplica `SchemaNormalizerService`).
269
+
108
270
  ## 🧩 Compatibilidade
109
271
 
110
272
  - `@praxisui/core` `1.0.0-beta.x` → Angular `20.x`
@@ -322,7 +484,7 @@ interface SortingConfig {
322
484
  /** Habilitar ordenação */
323
485
  enabled: boolean;
324
486
 
325
- /** Permitir ordenação múltipla */
487
+ /** Permitir ordenação múltipla (schema-only no runtime atual) */
326
488
  multiSort: boolean;
327
489
 
328
490
  /** Estratégia de ordenação */
@@ -339,6 +501,8 @@ interface SortingConfig {
339
501
  }
340
502
  ```
341
503
 
504
+ Observação enterprise: `multiSort` está disponível no contrato de schema, porém no runtime atual deve ser tratado como `schema-only` (apenas 1 critério de ordenação efetivo).
505
+
342
506
  ## 🎨 Configurações de Aparência
343
507
 
344
508
  ### TableAppearanceConfig
@@ -508,7 +672,8 @@ export class MyComponent {
508
672
  this.configService.setConfig(this.tableConfig);
509
673
 
510
674
  // Verificar recursos
511
- const hasMultiSort = this.configService.isFeatureEnabled('multiSort');
675
+ // No runtime atual, multiSort permanece schema-only.
676
+ const hasMultiSort = false;
512
677
  const hasBulkActions = this.configService.isFeatureEnabled('bulkActions');
513
678
  const hasExport = this.configService.isFeatureEnabled('export');
514
679