@praxisui/dialog 0.0.1
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/LICENSE +7 -0
- package/README.md +128 -0
- package/fesm2022/praxisui-dialog.mjs +981 -0
- package/fesm2022/praxisui-dialog.mjs.map +1 -0
- package/index.d.ts +310 -0
- package/package.json +37 -0
package/LICENSE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# @praxis/dialog
|
|
2
|
+
|
|
3
|
+
> Unified dialog for Praxis built on Angular CDK. Provides a service API (MatDialog-like) and a tag mode (`<praxis-dialog>`) with theming, CSS-only animations, accessibility and metadata integration.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @praxis/dialog
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Peer dependencies (Angular v20):
|
|
12
|
+
- `@angular/core` `^20.0.0`
|
|
13
|
+
- `@angular/common` `^20.0.0`
|
|
14
|
+
- `@angular/cdk` `^20.0.0`
|
|
15
|
+
- `@angular/forms` `^20.0.0`
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### Service (recommended)
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { Component } from '@angular/core';
|
|
23
|
+
import { PraxisDialog } from '@praxis/dialog';
|
|
24
|
+
|
|
25
|
+
@Component({ selector: 'app-users', standalone: true })
|
|
26
|
+
export class UsersComponent {
|
|
27
|
+
constructor(private dialog: PraxisDialog) {}
|
|
28
|
+
|
|
29
|
+
deleteUser() {
|
|
30
|
+
const ref = this.dialog.confirm({
|
|
31
|
+
title: 'Confirmar Exclusão',
|
|
32
|
+
message: 'Deseja excluir este item?',
|
|
33
|
+
disableClose: true,
|
|
34
|
+
}, 'question'); // variant: question
|
|
35
|
+
|
|
36
|
+
ref.afterClosed().subscribe((ok) => { if (ok) this.doDelete(); });
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
private doDelete() {/* ... */}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Open custom component or template:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
this.dialog.open(CustomerFormComponent, { width: 720, data: customer });
|
|
47
|
+
// or template:
|
|
48
|
+
this.dialog.open(this.templateRef, { ariaRole: 'alertdialog' });
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Tag (embedded)
|
|
52
|
+
|
|
53
|
+
```html
|
|
54
|
+
<praxis-dialog [open]="open" (close)="open=false" [themeColor]="'light'">
|
|
55
|
+
<ng-template praxisDialogTitle>Diálogo</ng-template>
|
|
56
|
+
<ng-template praxisDialogContent>Conteúdo</ng-template>
|
|
57
|
+
<ng-template praxisDialogActions>
|
|
58
|
+
<button class="pdx-dialog__action-btn" (click)="open=false">Fechar</button>
|
|
59
|
+
</ng-template>
|
|
60
|
+
</praxis-dialog>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Global Presets
|
|
64
|
+
|
|
65
|
+
Provide presets app‑wide:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
import { PRAXIS_DIALOG_GLOBAL_PRESETS } from '@praxis/dialog';
|
|
69
|
+
|
|
70
|
+
providers: [{
|
|
71
|
+
provide: PRAXIS_DIALOG_GLOBAL_PRESETS,
|
|
72
|
+
useValue: {
|
|
73
|
+
confirm: { themeColor: 'light', animation: { type: 'translate', duration: 200 } },
|
|
74
|
+
variants: { question: { themeColor: 'dark', animation: { type: 'fade', duration: 150 } } },
|
|
75
|
+
},
|
|
76
|
+
}]
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Merge order: type → variant (optional) → local config.
|
|
80
|
+
|
|
81
|
+
## Template/Component Registry
|
|
82
|
+
|
|
83
|
+
- Component registry: `PRAXIS_DIALOG_CONTENT_REGISTRY` (string → ComponentType)
|
|
84
|
+
- Template registry: `PRAXIS_DIALOG_TEMPLATE_REGISTRY` (string → TemplateRef)
|
|
85
|
+
|
|
86
|
+
Register via `ENVIRONMENT_INITIALIZER` and open by id:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
providers: [{
|
|
90
|
+
provide: ENVIRONMENT_INITIALIZER,
|
|
91
|
+
multi: true,
|
|
92
|
+
useFactory: (reg: Record<string, any>) => () => reg['CustomerForm'] = CustomerFormComponent,
|
|
93
|
+
deps: [PRAXIS_DIALOG_CONTENT_REGISTRY],
|
|
94
|
+
}]
|
|
95
|
+
|
|
96
|
+
this.dialog.openByRegistry('CustomerForm', { width: 720 });
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Accessibility
|
|
100
|
+
|
|
101
|
+
- `role="dialog|alertdialog"`, `aria-modal`, `aria-*` inputs
|
|
102
|
+
- Focus trap + ESC (respects `disableClose`)
|
|
103
|
+
- In `alertdialog`, focuses the primary action when present
|
|
104
|
+
- Restores focus on close (service and tag)
|
|
105
|
+
|
|
106
|
+
## Theming & Styles
|
|
107
|
+
|
|
108
|
+
- `themeColor: 'light' | 'dark' | 'primary'`
|
|
109
|
+
- Style tokens via `styles` map to CSS vars (e.g. `containerShape`, `contentPadding`, `typography` fields)
|
|
110
|
+
- Size props (`width/height/min/max`) are top‑level inputs
|
|
111
|
+
|
|
112
|
+
## API (quick reference)
|
|
113
|
+
|
|
114
|
+
Exports:
|
|
115
|
+
- Service: `PraxisDialog`
|
|
116
|
+
- Component + directives: `PraxisDialogComponent`, `PraxisDialogTitleDirective`, `PraxisDialogContentDirective`, `PraxisDialogActionsDirective`
|
|
117
|
+
- Ref: `PraxisDialogRef`
|
|
118
|
+
- Tokens: `PRAXIS_DIALOG_DATA`, `PRAXIS_DIALOG_DEFAULTS`, `PRAXIS_DIALOG_GLOBAL_PRESETS`, `PRAXIS_DIALOG_I18N`, registries
|
|
119
|
+
- Types: `PraxisDialogConfig`, `PraxisConfirmConfig`, `PraxisAlertConfig`, `PraxisPromptConfig`
|
|
120
|
+
|
|
121
|
+
Highlights:
|
|
122
|
+
- `afterAllClosed`, `afterOpened`, `openDialogs`, `closeAll()`, `getDialogById(id)`
|
|
123
|
+
- `PraxisDialogRef`: `afterOpened/beforeClosed/afterClosed`, `backdropClick`, `keydownEvents`, `close()`, `updateSize/Position()`
|
|
124
|
+
|
|
125
|
+
## Links
|
|
126
|
+
- Repo: https://github.com/codexrodrigues/praxis
|
|
127
|
+
- Issues: https://github.com/codexrodrigues/praxis/issues
|
|
128
|
+
|