@praxisui/core 1.0.0-beta.4 → 1.0.0-beta.40
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 +151 -0
- package/fesm2022/praxisui-core.mjs +12238 -4538
- package/fesm2022/praxisui-core.mjs.map +1 -1
- package/index.d.ts +2914 -808
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
> Biblioteca central com interfaces e serviços fundamentais para o Praxis UI Workspace
|
|
4
4
|
|
|
5
|
+
## 🔰 Exemplos / Quickstart
|
|
6
|
+
|
|
7
|
+
Para ver esta biblioteca em funcionamento em uma aplicação completa, utilize o projeto de exemplo (Quickstart):
|
|
8
|
+
|
|
9
|
+
- Repositório: https://github.com/codexrodrigues/praxis-ui-quickstart
|
|
10
|
+
- O Quickstart demonstra a integração das bibliotecas `@praxisui/*` em um app Angular, incluindo instalação, configuração e uso em telas reais.
|
|
11
|
+
|
|
5
12
|
## 🌟 Visão Geral
|
|
6
13
|
|
|
7
14
|
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 +42,9 @@ A biblioteca `@praxisui/core` é o núcleo do Praxis UI Workspace, fornecendo in
|
|
|
35
42
|
npm install @praxisui/core
|
|
36
43
|
```
|
|
37
44
|
|
|
45
|
+
Exemplo completo (app de referência)
|
|
46
|
+
- Quickstart: https://github.com/codexrodrigues/praxis-ui-quickstart
|
|
47
|
+
|
|
38
48
|
### Peer dependencies (Angular v20)
|
|
39
49
|
|
|
40
50
|
- `@angular/core` `^20.0.0`
|
|
@@ -105,6 +115,147 @@ Observação: os IDs de widgets usados na página devem estar registrados via `C
|
|
|
105
115
|
[`public-api.ts`](https://github.com/codexrodrigues/praxis/blob/main/frontend-libs/praxis-ui-workspace/projects/praxis-core/src/public-api.ts)
|
|
106
116
|
para a lista consolidada de serviços, tokens, modelos e utilitários disponíveis para importação.
|
|
107
117
|
|
|
118
|
+
## ⚙️ Global Config (bootstrap)
|
|
119
|
+
|
|
120
|
+
- Use `provideGlobalConfigTenant(...)` para definir o tenant e bloquear o bootstrap até a config remota ser carregada.
|
|
121
|
+
- Se não houver tenant, use `provideGlobalConfigReady()` para apenas aguardar o carregamento remoto.
|
|
122
|
+
|
|
123
|
+
## 🌐 Global Actions (shell + widgets)
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
### 1) Providers (plug-and-play no host)
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
import {
|
|
131
|
+
providePraxisGlobalActions,
|
|
132
|
+
providePraxisToastGlobalActions,
|
|
133
|
+
providePraxisAnalyticsGlobalActions,
|
|
134
|
+
} from '@praxisui/core';
|
|
135
|
+
import { providePraxisDialogGlobalActions } from '@praxisui/dialog';
|
|
136
|
+
|
|
137
|
+
providers: [
|
|
138
|
+
...providePraxisGlobalActions({ dialog: false, toast: false, analytics: false }),
|
|
139
|
+
providePraxisDialogGlobalActions(),
|
|
140
|
+
providePraxisToastGlobalActions(),
|
|
141
|
+
providePraxisAnalyticsGlobalActions({ prefix: 'app' }),
|
|
142
|
+
]
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### 2) Mapeando outputs para ações globais
|
|
146
|
+
|
|
147
|
+
`WidgetDefinition.outputs` pode apontar para ações globais:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
definition: {
|
|
151
|
+
id: 'praxis-dynamic-form',
|
|
152
|
+
outputs: {
|
|
153
|
+
formSubmit: {
|
|
154
|
+
type: 'api.post',
|
|
155
|
+
params: { url: '/api/clientes', body: '${payload.formData}' }
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### 3) Ação global no Widget Shell
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
shell: {
|
|
165
|
+
actions: [
|
|
166
|
+
{ id: 'back', icon: 'arrow_back', command: 'global:navigation.back' }
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### 4) Catálogo básico de ações globais
|
|
172
|
+
|
|
173
|
+
- `navigation.back`
|
|
174
|
+
- `navigation.openExternal` → `{ url }`
|
|
175
|
+
- `dialog.alert` → `{ title, message, variant }`
|
|
176
|
+
- `dialog.prompt` → `{ title, message, placeholder, defaultValue }`
|
|
177
|
+
- `dialog.open` → `{ componentId, inputs, size, data }`
|
|
178
|
+
- `toast.success` / `toast.error` → `{ message }`
|
|
179
|
+
- `clipboard.copy` → `{ text }`
|
|
180
|
+
- `trackEvent` → `{ eventName, payload }`
|
|
181
|
+
- `log` → `{ level, message, payload }`
|
|
182
|
+
- `api.get` / `api.post` / `api.patch` → `{ url, params|body }`
|
|
183
|
+
- `route.register` → `{ path, componentId|loadChildren, data?, resolve?, guards?, canMatch?, canActivateChild?, replace?, position? }`
|
|
184
|
+
|
|
185
|
+
### 5) Rotas dinâmicas (route.register)
|
|
186
|
+
|
|
187
|
+
Requer `componentId` **ou** `loadChildren`. Guards são resolvidos pelo host via `GLOBAL_ROUTE_GUARD_RESOLVER`.
|
|
188
|
+
|
|
189
|
+
```ts
|
|
190
|
+
// payload
|
|
191
|
+
{
|
|
192
|
+
path: '/clientes/novo',
|
|
193
|
+
componentId: 'praxis-dynamic-page',
|
|
194
|
+
data: { pageId: 'clientes-novo' },
|
|
195
|
+
guards: ['auth', 'permission:clientes.create'],
|
|
196
|
+
position: 'before-wildcard'
|
|
197
|
+
}
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
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`).
|
|
201
|
+
|
|
202
|
+
### 7) Output mapeado para ação global x conexões
|
|
203
|
+
|
|
204
|
+
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.
|
|
205
|
+
|
|
206
|
+
### 6) Estilo de toast
|
|
207
|
+
|
|
208
|
+
O estilo padrão usa as classes `.pdx-toast-success` / `.pdx-toast-error`.
|
|
209
|
+
Inclua estilos equivalentes no app host (ou sobrescreva com `providePraxisToastGlobalActions`).
|
|
210
|
+
|
|
211
|
+
## 🔎 Schema Viewer (para Showcases)
|
|
212
|
+
|
|
213
|
+
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`.
|
|
214
|
+
|
|
215
|
+
```ts
|
|
216
|
+
import { Component, Provider } from '@angular/core';
|
|
217
|
+
import { PraxisTabs, TabsMetadata } from '@praxisui/tabs';
|
|
218
|
+
import { SchemaViewerComponent, SCHEMA_VIEWER_CONTEXT } from '@praxisui/core';
|
|
219
|
+
|
|
220
|
+
@Component({
|
|
221
|
+
standalone: true,
|
|
222
|
+
selector: 'app-tabs-showcase',
|
|
223
|
+
imports: [PraxisTabs, SchemaViewerComponent],
|
|
224
|
+
template: `
|
|
225
|
+
<!-- Aba Preview -->
|
|
226
|
+
<praxis-tabs [config]="tabs" tabsId="tabs-preview"></praxis-tabs>
|
|
227
|
+
|
|
228
|
+
<!-- Aba Schema -->
|
|
229
|
+
<praxis-schema-viewer [context]="schemaCtx"></praxis-schema-viewer>
|
|
230
|
+
`,
|
|
231
|
+
providers: [
|
|
232
|
+
{
|
|
233
|
+
provide: SCHEMA_VIEWER_CONTEXT,
|
|
234
|
+
useFactory: () => ({
|
|
235
|
+
componentId: 'praxis-tabs',
|
|
236
|
+
title: 'Tabs — Schema & Metadata',
|
|
237
|
+
rawConfig: {
|
|
238
|
+
group: { alignTabs: 'center', dynamicHeight: true },
|
|
239
|
+
tabs: [ { id: 't1', textLabel: 'Dados', content: [] } ],
|
|
240
|
+
} satisfies TabsMetadata,
|
|
241
|
+
}),
|
|
242
|
+
} as Provider,
|
|
243
|
+
],
|
|
244
|
+
})
|
|
245
|
+
export class TabsShowcaseComponent {
|
|
246
|
+
tabs: TabsMetadata = { group: { dynamicHeight: true }, tabs: [] };
|
|
247
|
+
schemaCtx = {
|
|
248
|
+
componentId: 'praxis-tabs',
|
|
249
|
+
rawConfig: this.tabs,
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
Campos opcionais do contexto (`SchemaViewerContext`):
|
|
255
|
+
- `rawConfig` (JSON usado pelo exemplo), `effectiveConfig` (se houver merge de defaults);
|
|
256
|
+
- `backendSchema` (OpenAPI/JSON Schema) e `schemaMeta` (path/operation/schemaType/schemaHash);
|
|
257
|
+
- `normalizedFields` (se já normalizado; caso contrário, o componente aplica `SchemaNormalizerService`).
|
|
258
|
+
|
|
108
259
|
## 🧩 Compatibilidade
|
|
109
260
|
|
|
110
261
|
- `@praxisui/core` `1.0.0-beta.x` → Angular `20.x`
|