@egose/shadcn-theme-ng 0.0.28 → 0.2.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 +130 -13
- package/accordion/README.md +376 -34
- package/accordion/fesm2022/accordion.mjs +27 -39
- package/alert/README.md +343 -34
- package/alert/fesm2022/alert.mjs +47 -47
- package/alert-dialog/README.md +471 -5
- package/alert-dialog/fesm2022/alert-dialog.mjs +47 -47
- package/aspect-ratio/README.md +272 -5
- package/aspect-ratio/fesm2022/aspect-ratio.mjs +9 -9
- package/autocomplete/README.md +473 -34
- package/autocomplete/fesm2022/autocomplete.mjs +53 -71
- package/avatar/README.md +357 -5
- package/avatar/fesm2022/avatar.mjs +32 -32
- package/badge/README.md +289 -34
- package/badge/fesm2022/badge.mjs +57 -57
- package/basic-alert/README.md +324 -34
- package/basic-alert/fesm2022/basic-alert.mjs +6 -18
- package/breadcrumb/README.md +406 -5
- package/breadcrumb/fesm2022/breadcrumb.mjs +33 -39
- package/button/README.md +453 -34
- package/button/fesm2022/button.mjs +147 -219
- package/button/types/button.d.ts +7 -10
- package/button-group/README.md +318 -5
- package/button-group/fesm2022/button-group.mjs +20 -20
- package/calendar/README.md +328 -34
- package/calendar/fesm2022/calendar.mjs +29 -743
- package/card/README.md +331 -5
- package/card/fesm2022/card.mjs +33 -33
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +39 -78
- package/checkbox/README.md +291 -34
- package/checkbox/fesm2022/checkbox.mjs +20 -58
- package/checkbox/types/checkbox.d.ts +5 -4
- package/collapsible/README.md +332 -5
- package/collapsible/fesm2022/collapsible.mjs +15 -15
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +91 -224
- package/command/README.md +435 -5
- package/command/fesm2022/command.mjs +49 -109
- package/confirmation-dialog/README.md +272 -34
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs +15 -40
- package/confirmation-dialog/types/confirmation-dialog.d.ts +8 -4
- package/context-menu/README.md +366 -5
- package/context-menu/fesm2022/context-menu.mjs +9 -9
- package/date-picker/README.md +436 -34
- package/date-picker/fesm2022/date-picker.mjs +64 -267
- package/date-picker/types/date-picker.d.ts +7 -3
- package/dialog/README.md +419 -34
- package/dialog/fesm2022/dialog.mjs +45 -71
- package/drawer/README.md +395 -5
- package/drawer/fesm2022/drawer.mjs +44 -54
- package/dropdown-menu/README.md +417 -5
- package/dropdown-menu/fesm2022/dropdown-menu.mjs +82 -70
- package/dropdown-menu/types/dropdown-menu.d.ts +4 -0
- package/empty/README.md +329 -5
- package/empty/fesm2022/empty.mjs +30 -30
- package/field/README.md +385 -5
- package/field/fesm2022/field.mjs +56 -72
- package/form-checkbox/README.md +283 -34
- package/form-checkbox/fesm2022/form-checkbox.mjs +25 -85
- package/form-checkbox/types/form-checkbox.d.ts +7 -1
- package/form-date-picker/README.md +293 -34
- package/form-date-picker/fesm2022/form-date-picker.mjs +31 -84
- package/form-date-picker/types/form-date-picker.d.ts +7 -1
- package/form-field/README.md +327 -34
- package/form-field/fesm2022/form-field.mjs +33 -19
- package/form-field/types/form-field.d.ts +28 -20
- package/form-field-simple/README.md +311 -34
- package/form-field-simple/fesm2022/form-field-simple.mjs +4 -4
- package/form-searchable-multiselect/README.md +332 -34
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs +31 -91
- package/form-searchable-multiselect/types/form-searchable-multiselect.d.ts +7 -1
- package/form-select/README.md +321 -34
- package/form-select/fesm2022/form-select.mjs +32 -149
- package/form-select/types/form-select.d.ts +7 -1
- package/form-text-input/README.md +342 -34
- package/form-text-input/fesm2022/form-text-input.mjs +35 -149
- package/form-text-input/types/form-text-input.d.ts +9 -12
- package/form-textarea/README.md +318 -34
- package/form-textarea/fesm2022/form-textarea.mjs +34 -109
- package/form-textarea/types/form-textarea.d.ts +8 -1
- package/hover-card/README.md +256 -5
- package/hover-card/fesm2022/hover-card.mjs +19 -19
- package/icon/README.md +210 -34
- package/icon/fesm2022/icon.mjs +8 -8
- package/input/README.md +240 -34
- package/input/fesm2022/input.mjs +17 -12
- package/input/types/input.d.ts +2 -1
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +34 -34
- package/input-otp/README.md +375 -5
- package/input-otp/fesm2022/input-otp.mjs +26 -26
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +53 -53
- package/kbd/README.md +291 -5
- package/kbd/fesm2022/kbd.mjs +12 -12
- package/label/README.md +243 -34
- package/label/fesm2022/label.mjs +10 -10
- package/label/types/label.d.ts +1 -1
- package/layout-simple/README.md +174 -44
- package/layout-simple/fesm2022/layout-simple.mjs +508 -603
- package/layout-simple/types/layout-simple.d.ts +179 -128
- package/menu/README.md +418 -0
- package/menu/fesm2022/menu.mjs +455 -0
- package/menu/package.json +24 -0
- package/menu/types/menu.d.ts +137 -0
- package/menubar/README.md +343 -5
- package/menubar/fesm2022/menubar.mjs +13 -13
- package/native-select/README.md +323 -5
- package/native-select/fesm2022/native-select.mjs +19 -19
- package/navigation-menu/README.md +369 -5
- package/navigation-menu/fesm2022/navigation-menu.mjs +35 -47
- package/package.json +183 -154
- package/pagination/README.md +388 -5
- package/pagination/fesm2022/pagination.mjs +45 -331
- package/popover/README.md +302 -34
- package/popover/fesm2022/popover.mjs +30 -30
- package/progress/README.md +311 -5
- package/progress/fesm2022/progress.mjs +13 -13
- package/radio-group/README.md +335 -34
- package/radio-group/fesm2022/radio-group.mjs +26 -19
- package/radio-group/types/radio-group.d.ts +1 -1
- package/resizable/README.md +269 -5
- package/resizable/fesm2022/resizable.mjs +18 -26
- package/scroll-area/README.md +233 -5
- package/scroll-area/fesm2022/scroll-area.mjs +9 -9
- package/searchable-multiselect/README.md +294 -34
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs +28 -117
- package/searchable-multiselect/types/searchable-multiselect.d.ts +8 -2
- package/select/README.md +408 -34
- package/select/fesm2022/select.mjs +71 -111
- package/select/types/select.d.ts +3 -1
- package/separator/README.md +193 -34
- package/separator/fesm2022/separator.mjs +9 -9
- package/separator/types/separator.d.ts +1 -1
- package/sheet/README.md +282 -34
- package/sheet/fesm2022/sheet.mjs +41 -53
- package/sidebar/README.md +457 -5
- package/sidebar/fesm2022/sidebar.mjs +125 -227
- package/skeleton/README.md +217 -5
- package/skeleton/fesm2022/skeleton.mjs +9 -9
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +10 -80
- package/sonner/README.md +317 -34
- package/sonner/fesm2022/sonner.mjs +13 -13
- package/spinner/README.md +255 -34
- package/spinner/fesm2022/spinner.mjs +11 -11
- package/switch/README.md +281 -34
- package/switch/fesm2022/switch.mjs +13 -15
- package/table/README.md +423 -5
- package/table/fesm2022/table.mjs +41 -41
- package/tabs/README.md +382 -34
- package/tabs/fesm2022/tabs.mjs +35 -111
- package/textarea/README.md +282 -5
- package/textarea/fesm2022/textarea.mjs +9 -9
- package/toggle/README.md +270 -5
- package/toggle/fesm2022/toggle.mjs +13 -13
- package/toggle-group/README.md +340 -5
- package/toggle-group/fesm2022/toggle-group.mjs +13 -13
- package/toggle-group/types/toggle-group.d.ts +13 -7
- package/tooltip/README.md +240 -34
- package/tooltip/fesm2022/tooltip.mjs +14 -14
- package/typography/README.md +271 -5
- package/typography/fesm2022/typography.mjs +53 -53
- package/typography/types/typography.d.ts +19 -19
- package/utils/README.md +274 -34
- package/utils/fesm2022/utils.mjs +68 -44
- package/accordion/fesm2022/accordion.mjs.map +0 -1
- package/alert/fesm2022/alert.mjs.map +0 -1
- package/alert-dialog/fesm2022/alert-dialog.mjs.map +0 -1
- package/aspect-ratio/fesm2022/aspect-ratio.mjs.map +0 -1
- package/autocomplete/fesm2022/autocomplete.mjs.map +0 -1
- package/avatar/fesm2022/avatar.mjs.map +0 -1
- package/badge/fesm2022/badge.mjs.map +0 -1
- package/basic-alert/fesm2022/basic-alert.mjs.map +0 -1
- package/breadcrumb/fesm2022/breadcrumb.mjs.map +0 -1
- package/button/fesm2022/button.mjs.map +0 -1
- package/button-group/fesm2022/button-group.mjs.map +0 -1
- package/calendar/fesm2022/calendar.mjs.map +0 -1
- package/card/fesm2022/card.mjs.map +0 -1
- package/carousel/fesm2022/carousel.mjs.map +0 -1
- package/checkbox/fesm2022/checkbox.mjs.map +0 -1
- package/collapsible/fesm2022/collapsible.mjs.map +0 -1
- package/combobox/fesm2022/combobox.mjs.map +0 -1
- package/command/fesm2022/command.mjs.map +0 -1
- package/confirmation-dialog/fesm2022/confirmation-dialog.mjs.map +0 -1
- package/context-menu/fesm2022/context-menu.mjs.map +0 -1
- package/date-picker/fesm2022/date-picker.mjs.map +0 -1
- package/dialog/fesm2022/dialog.mjs.map +0 -1
- package/drawer/fesm2022/drawer.mjs.map +0 -1
- package/dropdown-menu/fesm2022/dropdown-menu.mjs.map +0 -1
- package/empty/fesm2022/empty.mjs.map +0 -1
- package/field/fesm2022/field.mjs.map +0 -1
- package/form-checkbox/fesm2022/form-checkbox.mjs.map +0 -1
- package/form-date-picker/fesm2022/form-date-picker.mjs.map +0 -1
- package/form-field/fesm2022/form-field.mjs.map +0 -1
- package/form-field-simple/fesm2022/form-field-simple.mjs.map +0 -1
- package/form-searchable-multiselect/fesm2022/form-searchable-multiselect.mjs.map +0 -1
- package/form-select/fesm2022/form-select.mjs.map +0 -1
- package/form-text-input/fesm2022/form-text-input.mjs.map +0 -1
- package/form-textarea/fesm2022/form-textarea.mjs.map +0 -1
- package/hover-card/fesm2022/hover-card.mjs.map +0 -1
- package/icon/fesm2022/icon.mjs.map +0 -1
- package/input/fesm2022/input.mjs.map +0 -1
- package/input-group/fesm2022/input-group.mjs.map +0 -1
- package/input-otp/fesm2022/input-otp.mjs.map +0 -1
- package/item/fesm2022/item.mjs.map +0 -1
- package/kbd/fesm2022/kbd.mjs.map +0 -1
- package/label/fesm2022/label.mjs.map +0 -1
- package/layout-simple/fesm2022/layout-simple.mjs.map +0 -1
- package/menubar/fesm2022/menubar.mjs.map +0 -1
- package/native-select/fesm2022/native-select.mjs.map +0 -1
- package/navigation-menu/fesm2022/navigation-menu.mjs.map +0 -1
- package/pagination/fesm2022/pagination.mjs.map +0 -1
- package/popover/fesm2022/popover.mjs.map +0 -1
- package/progress/fesm2022/progress.mjs.map +0 -1
- package/radio-group/fesm2022/radio-group.mjs.map +0 -1
- package/resizable/fesm2022/resizable.mjs.map +0 -1
- package/scroll-area/fesm2022/scroll-area.mjs.map +0 -1
- package/searchable-multiselect/fesm2022/searchable-multiselect.mjs.map +0 -1
- package/select/fesm2022/select.mjs.map +0 -1
- package/separator/fesm2022/separator.mjs.map +0 -1
- package/sheet/fesm2022/sheet.mjs.map +0 -1
- package/sidebar/fesm2022/sidebar.mjs.map +0 -1
- package/skeleton/fesm2022/skeleton.mjs.map +0 -1
- package/slider/fesm2022/slider.mjs.map +0 -1
- package/sonner/fesm2022/sonner.mjs.map +0 -1
- package/spinner/fesm2022/spinner.mjs.map +0 -1
- package/switch/fesm2022/switch.mjs.map +0 -1
- package/table/fesm2022/table.mjs.map +0 -1
- package/tabs/fesm2022/tabs.mjs.map +0 -1
- package/textarea/fesm2022/textarea.mjs.map +0 -1
- package/toggle/fesm2022/toggle.mjs.map +0 -1
- package/toggle-group/fesm2022/toggle-group.mjs.map +0 -1
- package/tooltip/fesm2022/tooltip.mjs.map +0 -1
- package/typography/fesm2022/typography.mjs.map +0 -1
- package/utils/fesm2022/utils.mjs.map +0 -1
|
@@ -1,64 +1,302 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Confirmation Dialog (`@egose/shadcn-theme-ng/confirmation-dialog`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A promise-based "Are you sure?" modal — the Angular equivalent of a shadcn/ui `AlertDialog` confirmation shortcut. Instead of composing dialog primitives by hand, you call `EgConfirmationDialogService.showConfirmationDialog({ title, description })` and `await` a `Promise<boolean>` (`true` = Confirm, `false` = Cancel/dismiss). The rendered `EgConfirmationDialog` component itself (warning icon + title + description + Cancel/Confirm footer) is opened through `HlmDialogService` from `@egose/shadcn-theme-ng/dialog` with a `BrnDialogRef<boolean>` result. There is no `*Imports` array and no `*Module` — the public surface is the component, the service, and a deprecated misspelled alias.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Ships as `@egose/shadcn-theme-ng/confirmation-dialog` and `@egose/shadcn-theme-ng-tw/confirmation-dialog` (the `tw:`-prefixed variant). See the [package README](../../README.md) for install, peer dependencies, and Tailwind setup. Do not publish this project directory independently — it is consumed via the published subpath only.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
|
|
10
|
+
# Plain Tailwind (no prefix):
|
|
11
|
+
npm install @egose/shadcn-theme-ng
|
|
12
|
+
|
|
13
|
+
# Or the tw:-prefixed variant:
|
|
14
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
11
15
|
```
|
|
12
16
|
|
|
13
|
-
|
|
17
|
+
Peers are listed in the [package README](../../README.md). This subpath declares `@angular/common` and `@angular/core` as peers (see `projects/confirmation-dialog/package.json`); at runtime it uses `@egose/shadcn-theme-ng/dialog`, `button`, `alert`, and `icon`, so install the whole package.
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
## Imports
|
|
20
|
+
|
|
21
|
+
The public API (`projects/confirmation-dialog/src/public-api.ts`) exports exactly:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import {
|
|
25
|
+
EgConfirmationDialog,
|
|
26
|
+
EgConfirmationDialogService,
|
|
27
|
+
// Deprecated misspelled alias (type + const) — do not use in new code:
|
|
28
|
+
EgConfirmationDiaglog,
|
|
29
|
+
} from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
30
|
+
// tw variant:
|
|
31
|
+
// import { ... } from '@egose/shadcn-theme-ng-tw/confirmation-dialog';
|
|
17
32
|
```
|
|
18
33
|
|
|
19
|
-
|
|
34
|
+
There is no `EgConfirmationDialogImports` and no `EgConfirmationDialogModule`. The service is `@Injectable({ providedIn: 'root' })` — just inject it:
|
|
20
35
|
|
|
21
|
-
|
|
36
|
+
```ts
|
|
37
|
+
import { Component, inject } from '@angular/core';
|
|
38
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
22
39
|
|
|
23
|
-
|
|
24
|
-
|
|
40
|
+
@Component({ selector: 'app-demo', standalone: true, template: `...` })
|
|
41
|
+
export class DemoComponent {
|
|
42
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> `EgConfirmationDiaglog` (missing the second `a`) is a deprecated type+const alias for `EgConfirmationDialog` kept for back-compat. It will be removed in the next major release — use the correctly spelled name.
|
|
47
|
+
|
|
48
|
+
## Anatomy / Structure
|
|
49
|
+
|
|
50
|
+
You never write the dialog markup yourself — the service opens this fixed template:
|
|
51
|
+
|
|
52
|
+
```html
|
|
53
|
+
<!-- Rendered by EgConfirmationDialog (fixed internal template) -->
|
|
54
|
+
<hlm-dialog-header>
|
|
55
|
+
<div class="tw:flex tw:items-center tw:gap-1">
|
|
56
|
+
<ng-icon hlm hlmAlertIcon name="lucideTriangleAlert" size="base" />
|
|
57
|
+
<h3 hlmDialogTitle>{{ title }}</h3>
|
|
58
|
+
</div>
|
|
59
|
+
<p hlmDialogDescription>{{ description }}</p>
|
|
60
|
+
</hlm-dialog-header>
|
|
61
|
+
|
|
62
|
+
<hlm-dialog-footer>
|
|
63
|
+
<button hlmButton variant="secondary" appearance="outline">Cancel</button>
|
|
64
|
+
<button hlmButton variant="danger">Confirm</button>
|
|
65
|
+
</hlm-dialog-footer>
|
|
25
66
|
```
|
|
26
67
|
|
|
27
|
-
|
|
68
|
+
- `EgConfirmationDialog` has **no selector** — it is instantiated by `HlmDialogService.open<boolean>(EgConfirmationDialog, { context: { title, description } })`.
|
|
69
|
+
- Title/description fall back to `'Are you absolutely sure?'` / `'This action cannot be undone.'` when the context omits them.
|
|
70
|
+
- `close(confirm: boolean)` closes the `BrnDialogRef<boolean>` with the result; Cancel resolves `false`, Confirm resolves `true`, and dismissing (X / backdrop / Escape) resolves `false` via `closed$ ?? false`.
|
|
28
71
|
|
|
29
|
-
|
|
72
|
+
## API reference
|
|
30
73
|
|
|
31
|
-
|
|
74
|
+
### `EgConfirmationDialogService`
|
|
32
75
|
|
|
33
|
-
|
|
76
|
+
`@Injectable({ providedIn: 'root' })`, constructor-injects `HlmDialogService`.
|
|
34
77
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
78
|
+
| Method | Signature | Description |
|
|
79
|
+
| ------------------------ | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
|
|
80
|
+
| `showConfirmationDialog` | `({ title, description }: { title: string; description: string }) => Promise<boolean>` | Opens the modal with the given copy; resolves `true` on Confirm, `false` on Cancel or any dismiss. |
|
|
38
81
|
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
npm publish
|
|
42
|
-
```
|
|
82
|
+
Implementation detail: subscribes to `dialogRef.closed$` once per call and resolves `confirm ?? false`.
|
|
43
83
|
|
|
44
|
-
|
|
84
|
+
### `EgConfirmationDialog`
|
|
45
85
|
|
|
46
|
-
|
|
86
|
+
Standalone component (no selector), opened via the dialog service.
|
|
47
87
|
|
|
48
|
-
|
|
49
|
-
|
|
88
|
+
| Member | Type | Description |
|
|
89
|
+
| ------- | ---------------------------- | ------------------------------------------------------------------------------------------- |
|
|
90
|
+
| `close` | `(confirm: boolean) => void` | Closes the dialog with the boolean result. Wired to the two footer buttons in the template. |
|
|
91
|
+
|
|
92
|
+
Reads `{ title, description }` from `injectBrnDialogContext()`.
|
|
93
|
+
|
|
94
|
+
## Examples
|
|
95
|
+
|
|
96
|
+
### 1. Basic delete confirmation (`async/await`)
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { Component, inject } from '@angular/core';
|
|
100
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
101
|
+
|
|
102
|
+
@Component({
|
|
103
|
+
selector: 'app-delete-button',
|
|
104
|
+
standalone: true,
|
|
105
|
+
template: `<button type="button" (click)="onDelete()">Delete project</button>`,
|
|
106
|
+
})
|
|
107
|
+
export class DeleteButtonComponent {
|
|
108
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
109
|
+
|
|
110
|
+
async onDelete() {
|
|
111
|
+
const ok = await this.confirm.showConfirmationDialog({
|
|
112
|
+
title: 'Delete project?',
|
|
113
|
+
description: 'This will permanently delete the project and all of its data.',
|
|
114
|
+
});
|
|
115
|
+
if (ok) {
|
|
116
|
+
console.log('deleting…');
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
50
120
|
```
|
|
51
121
|
|
|
52
|
-
|
|
122
|
+
### 2. Promise-chain style (no `async`)
|
|
53
123
|
|
|
54
|
-
|
|
124
|
+
```ts
|
|
125
|
+
import { Component, inject } from '@angular/core';
|
|
126
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
55
127
|
|
|
56
|
-
|
|
57
|
-
|
|
128
|
+
@Component({
|
|
129
|
+
selector: 'app-leave-page',
|
|
130
|
+
standalone: true,
|
|
131
|
+
template: `<button type="button" (click)="leave()">Discard changes</button>`,
|
|
132
|
+
})
|
|
133
|
+
export class LeavePageComponent {
|
|
134
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
135
|
+
|
|
136
|
+
leave() {
|
|
137
|
+
this.confirm
|
|
138
|
+
.showConfirmationDialog({
|
|
139
|
+
title: 'Discard unsaved changes?',
|
|
140
|
+
description: 'Your edits will be lost if you leave this page.',
|
|
141
|
+
})
|
|
142
|
+
.then((ok) => {
|
|
143
|
+
if (ok) console.log('navigating away…');
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### 3. Destructive row action in a table
|
|
150
|
+
|
|
151
|
+
Each row awaits its own confirmation before mutating the list.
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { Component, inject, signal } from '@angular/core';
|
|
155
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
156
|
+
|
|
157
|
+
interface Member {
|
|
158
|
+
id: number;
|
|
159
|
+
name: string;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
@Component({
|
|
163
|
+
selector: 'app-members-table',
|
|
164
|
+
standalone: true,
|
|
165
|
+
template: `
|
|
166
|
+
<ul>
|
|
167
|
+
@for (m of members(); track m.id) {
|
|
168
|
+
<li class="flex items-center justify-between py-1">
|
|
169
|
+
<span>{{ m.name }}</span>
|
|
170
|
+
<button type="button" (click)="remove(m)">Remove</button>
|
|
171
|
+
</li>
|
|
172
|
+
}
|
|
173
|
+
</ul>
|
|
174
|
+
`,
|
|
175
|
+
})
|
|
176
|
+
export class MembersTableComponent {
|
|
177
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
178
|
+
readonly members = signal<Member[]>([
|
|
179
|
+
{ id: 1, name: 'Ada' },
|
|
180
|
+
{ id: 2, name: 'Grace' },
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
async remove(m: Member) {
|
|
184
|
+
const ok = await this.confirm.showConfirmationDialog({
|
|
185
|
+
title: `Remove ${m.name}?`,
|
|
186
|
+
description: `${m.name} will lose access immediately. You can re-invite them later.`,
|
|
187
|
+
});
|
|
188
|
+
if (ok) this.members.update((ms) => ms.filter((x) => x.id !== m.id));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### 4. Guarding a reactive form reset
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
import { Component, inject } from '@angular/core';
|
|
197
|
+
import { FormControl, FormGroup, ReactiveFormsModule } from '@angular/forms';
|
|
198
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
199
|
+
|
|
200
|
+
@Component({
|
|
201
|
+
selector: 'app-settings-form',
|
|
202
|
+
standalone: true,
|
|
203
|
+
imports: [ReactiveFormsModule],
|
|
204
|
+
template: `
|
|
205
|
+
<form [formGroup]="form">
|
|
206
|
+
<input formControlName="name" placeholder="Workspace name" />
|
|
207
|
+
<button type="button" (click)="reset()">Reset to defaults</button>
|
|
208
|
+
</form>
|
|
209
|
+
`,
|
|
210
|
+
})
|
|
211
|
+
export class SettingsFormComponent {
|
|
212
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
213
|
+
readonly form = new FormGroup({ name: new FormControl('acme') });
|
|
214
|
+
|
|
215
|
+
async reset() {
|
|
216
|
+
if (this.form.pristine) return;
|
|
217
|
+
const ok = await this.confirm.showConfirmationDialog({
|
|
218
|
+
title: 'Reset settings?',
|
|
219
|
+
description: 'All fields return to their default values.',
|
|
220
|
+
});
|
|
221
|
+
if (ok) this.form.reset({ name: 'acme' });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 5. Sequential confirmations (two-step destructive flow)
|
|
227
|
+
|
|
228
|
+
Await twice — e.g. confirm scope, then confirm irreversibility.
|
|
229
|
+
|
|
230
|
+
```ts
|
|
231
|
+
import { Component, inject } from '@angular/core';
|
|
232
|
+
import { EgConfirmationDialogService } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
233
|
+
|
|
234
|
+
@Component({
|
|
235
|
+
selector: 'app-purge-flow',
|
|
236
|
+
standalone: true,
|
|
237
|
+
template: `<button type="button" (click)="purge()">Purge organization</button>`,
|
|
238
|
+
})
|
|
239
|
+
export class PurgeFlowComponent {
|
|
240
|
+
private readonly confirm = inject(EgConfirmationDialogService);
|
|
241
|
+
|
|
242
|
+
async purge() {
|
|
243
|
+
const step1 = await this.confirm.showConfirmationDialog({
|
|
244
|
+
title: 'Purge all data?',
|
|
245
|
+
description: 'This affects every project in the organization.',
|
|
246
|
+
});
|
|
247
|
+
if (!step1) return;
|
|
248
|
+
|
|
249
|
+
const step2 = await this.confirm.showConfirmationDialog({
|
|
250
|
+
title: 'Are you absolutely sure?',
|
|
251
|
+
description: 'This action cannot be undone. Backups are deleted too.',
|
|
252
|
+
});
|
|
253
|
+
if (step2) console.log('purging…');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### 6. Opening the component directly (custom dialog options)
|
|
259
|
+
|
|
260
|
+
If you need non-default dialog chrome (different `contentClass`, close behavior), bypass the service and use `HlmDialogService` with `EgConfirmationDialog` directly.
|
|
261
|
+
|
|
262
|
+
```ts
|
|
263
|
+
import { Component, inject } from '@angular/core';
|
|
264
|
+
import { EgConfirmationDialog } from '@egose/shadcn-theme-ng/confirmation-dialog';
|
|
265
|
+
import { HlmDialogService } from '@egose/shadcn-theme-ng/dialog';
|
|
266
|
+
|
|
267
|
+
@Component({
|
|
268
|
+
selector: 'app-custom-open',
|
|
269
|
+
standalone: true,
|
|
270
|
+
template: `<button type="button" (click)="open()">Review defaults</button>`,
|
|
271
|
+
})
|
|
272
|
+
export class CustomOpenComponent {
|
|
273
|
+
private readonly dialogs = inject(HlmDialogService);
|
|
274
|
+
|
|
275
|
+
open() {
|
|
276
|
+
// No title/description → component falls back to its default copy.
|
|
277
|
+
const ref = this.dialogs.open<boolean>(EgConfirmationDialog, {
|
|
278
|
+
context: { title: '', description: '' },
|
|
279
|
+
contentClass: 'sm:max-w-md',
|
|
280
|
+
});
|
|
281
|
+
ref.closed$.subscribe((ok) => console.log('result:', ok ?? false));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
58
284
|
```
|
|
59
285
|
|
|
60
|
-
|
|
286
|
+
## Accessibility notes
|
|
287
|
+
|
|
288
|
+
- The dialog uses the standard `hlm-dialog` primitives (`hlmDialogTitle` + `hlmDialogDescription`), so screen readers announce title/description on open and focus is trapped/moved per the dialog service.
|
|
289
|
+
- Confirm is styled `variant="danger"` and Cancel `variant="secondary" appearance="outline"` — the safe action is visually distinct; keyboard order is Cancel → Confirm.
|
|
290
|
+
- Dismiss (Escape/backdrop/X) resolves `false` — the destructive path always requires an explicit Confirm click.
|
|
291
|
+
- Keep `title`/`description` specific ("Delete 'Q3 report'?") rather than generic so SR users hear the consequence without surrounding context.
|
|
292
|
+
|
|
293
|
+
## Theming / CSS variables
|
|
294
|
+
|
|
295
|
+
No component-specific CSS variables. The icon uses `hlmAlertIcon` (warning treatment), the title is `text-xl`, the description `text-base text-gray-700`, and the footer is `mt-4`. Buttons follow the shared `hlmButton` `secondary`/`danger` variants in both themes.
|
|
61
296
|
|
|
62
|
-
##
|
|
297
|
+
## Related subpaths
|
|
63
298
|
|
|
64
|
-
|
|
299
|
+
- `@egose/shadcn-theme-ng/dialog` — `HlmDialogService.open`, title/description/footer primitives behind this shortcut.
|
|
300
|
+
- `@egose/shadcn-theme-ng/alert-dialog` — fully custom alert dialogs when you need your own buttons/copy/layout.
|
|
301
|
+
- `@egose/shadcn-theme-ng/button` — `secondary`/`danger` variants used by the footer.
|
|
302
|
+
- `@egose/shadcn-theme-ng/alert` — `HlmAlertIcon` warning treatment for the header icon.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { inject, Component, Injectable } from '@angular/core';
|
|
3
3
|
import { HlmButton } from '@egose/shadcn-theme-ng/button';
|
|
4
|
-
import { HlmAlertIcon
|
|
4
|
+
import { HlmAlertIcon } from '@egose/shadcn-theme-ng/alert';
|
|
5
5
|
import * as i1 from '@egose/shadcn-theme-ng/dialog';
|
|
6
6
|
import { HlmDialogDescription, HlmDialogHeader, HlmDialogFooter, HlmDialogTitle } from '@egose/shadcn-theme-ng/dialog';
|
|
7
7
|
import { BrnDialogRef, injectBrnDialogContext } from '@spartan-ng/brain/dialog';
|
|
@@ -9,7 +9,7 @@ import { HlmIcon } from '@egose/shadcn-theme-ng/icon';
|
|
|
9
9
|
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
10
10
|
import { lucideTriangleAlert } from '@ng-icons/lucide';
|
|
11
11
|
|
|
12
|
-
class
|
|
12
|
+
class EgConfirmationDialog {
|
|
13
13
|
_dialogRef = inject(BrnDialogRef);
|
|
14
14
|
_dialogContext = injectBrnDialogContext();
|
|
15
15
|
_title = this._dialogContext.title || 'Are you absolutely sure?';
|
|
@@ -17,28 +17,14 @@ class EgConfirmationDiaglog {
|
|
|
17
17
|
close(confirm) {
|
|
18
18
|
this._dialogRef.close(confirm);
|
|
19
19
|
}
|
|
20
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
21
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.
|
|
22
|
-
<hlm-dialog-header>
|
|
23
|
-
<div class="flex items-center gap-1">
|
|
24
|
-
<ng-icon hlm hlmAlertIcon name="lucideTriangleAlert" size="base" />
|
|
25
|
-
<h3 hlmDialogTitle class="text-xl">{{ _title }}</h3>
|
|
26
|
-
</div>
|
|
27
|
-
<p hlmDialogDescription class="text-base text-gray-700">{{ _description }}</p>
|
|
28
|
-
</hlm-dialog-header>
|
|
29
|
-
|
|
30
|
-
<hlm-dialog-footer class="mt-4">
|
|
31
|
-
<button hlmButton variant="secondary" appearance="outline" (click)="close(false)">Cancel</button>
|
|
32
|
-
<button hlmButton variant="danger" (click)="close(true)">Confirm</button>
|
|
33
|
-
</hlm-dialog-footer>
|
|
34
|
-
`, isInline: true, dependencies: [{ kind: "component", type: HlmButton, selector: "button[hlmButton], a[hlmButton]", inputs: ["variant", "size", "appearance", "loading", "icon", "iconPosition", "class", "spinnerUserClass", "disabled", "type"] }, { kind: "directive", type: HlmAlertIcon, selector: "[hlmAlertIcon]" }, { kind: "directive", type: HlmDialogDescription, selector: "[hlmDialogDescription]" }, { kind: "directive", type: HlmDialogHeader, selector: "[hlmDialogHeader],hlm-dialog-header" }, { kind: "directive", type: HlmDialogFooter, selector: "[hlmDialogFooter],hlm-dialog-footer" }, { kind: "directive", type: HlmDialogTitle, selector: "[hlmDialogTitle]" }, { kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: HlmIcon, selector: "ng-icon[hlm]", inputs: ["size"] }] });
|
|
20
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgConfirmationDialog, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
21
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.3", type: EgConfirmationDialog, isStandalone: true, selector: "ng-component", host: { classAttribute: "w-full p-1" }, providers: [provideIcons({ lucideTriangleAlert })], ngImport: i0, template: "\n <hlm-dialog-header>\n <div class=\"flex items-center gap-1\">\n <ng-icon hlm hlmAlertIcon name=\"lucideTriangleAlert\" size=\"base\" />\n <h3 hlmDialogTitle class=\"text-xl\">{{ _title }}</h3>\n </div>\n <p hlmDialogDescription class=\"text-base text-gray-700\">{{ _description }}</p>\n </hlm-dialog-header>\n\n <hlm-dialog-footer class=\"mt-4\">\n <button hlmButton variant=\"secondary\" appearance=\"outline\" (click)=\"close(false)\">Cancel</button>\n <button hlmButton variant=\"danger\" (click)=\"close(true)\">Confirm</button>\n </hlm-dialog-footer>\n ", isInline: true, dependencies: [{ kind: "component", type: HlmButton, selector: "button[hlmButton], a[hlmButton]", inputs: ["variant", "size", "appearance", "loading", "icon", "iconPosition", "class", "spinnerUserClass", "disabled", "type"] }, { kind: "directive", type: HlmAlertIcon, selector: "[hlmAlertIcon]" }, { kind: "directive", type: HlmDialogDescription, selector: "[hlmDialogDescription]" }, { kind: "directive", type: HlmDialogHeader, selector: "[hlmDialogHeader],hlm-dialog-header" }, { kind: "directive", type: HlmDialogFooter, selector: "[hlmDialogFooter],hlm-dialog-footer" }, { kind: "directive", type: HlmDialogTitle, selector: "[hlmDialogTitle]" }, { kind: "component", type: NgIcon, selector: "ng-icon", inputs: ["name", "svg", "size", "strokeWidth", "color"] }, { kind: "directive", type: HlmIcon, selector: "ng-icon[hlm]", inputs: ["size"] }] });
|
|
35
22
|
}
|
|
36
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
23
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgConfirmationDialog, decorators: [{
|
|
37
24
|
type: Component,
|
|
38
25
|
args: [{
|
|
39
26
|
imports: [
|
|
40
27
|
HlmButton,
|
|
41
|
-
HlmAlert,
|
|
42
28
|
HlmAlertIcon,
|
|
43
29
|
HlmDialogDescription,
|
|
44
30
|
HlmDialogHeader,
|
|
@@ -49,25 +35,14 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
49
35
|
],
|
|
50
36
|
standalone: true,
|
|
51
37
|
providers: [provideIcons({ lucideTriangleAlert })],
|
|
52
|
-
template:
|
|
53
|
-
<hlm-dialog-header>
|
|
54
|
-
<div class="flex items-center gap-1">
|
|
55
|
-
<ng-icon hlm hlmAlertIcon name="lucideTriangleAlert" size="base" />
|
|
56
|
-
<h3 hlmDialogTitle class="text-xl">{{ _title }}</h3>
|
|
57
|
-
</div>
|
|
58
|
-
<p hlmDialogDescription class="text-base text-gray-700">{{ _description }}</p>
|
|
59
|
-
</hlm-dialog-header>
|
|
60
|
-
|
|
61
|
-
<hlm-dialog-footer class="mt-4">
|
|
62
|
-
<button hlmButton variant="secondary" appearance="outline" (click)="close(false)">Cancel</button>
|
|
63
|
-
<button hlmButton variant="danger" (click)="close(true)">Confirm</button>
|
|
64
|
-
</hlm-dialog-footer>
|
|
65
|
-
`,
|
|
38
|
+
template: "\n <hlm-dialog-header>\n <div class=\"flex items-center gap-1\">\n <ng-icon hlm hlmAlertIcon name=\"lucideTriangleAlert\" size=\"base\" />\n <h3 hlmDialogTitle class=\"text-xl\">{{ _title }}</h3>\n </div>\n <p hlmDialogDescription class=\"text-base text-gray-700\">{{ _description }}</p>\n </hlm-dialog-header>\n\n <hlm-dialog-footer class=\"mt-4\">\n <button hlmButton variant=\"secondary\" appearance=\"outline\" (click)=\"close(false)\">Cancel</button>\n <button hlmButton variant=\"danger\" (click)=\"close(true)\">Confirm</button>\n </hlm-dialog-footer>\n ",
|
|
66
39
|
host: {
|
|
67
|
-
class:
|
|
40
|
+
class: "w-full p-1",
|
|
68
41
|
},
|
|
69
42
|
}]
|
|
70
43
|
}] });
|
|
44
|
+
/** @deprecated Use `EgConfirmationDialog`. The misspelled name will be removed in the next major release. */
|
|
45
|
+
const EgConfirmationDiaglog = EgConfirmationDialog;
|
|
71
46
|
class EgConfirmationDialogService {
|
|
72
47
|
hlmDialogService;
|
|
73
48
|
constructor(hlmDialogService) {
|
|
@@ -75,7 +50,7 @@ class EgConfirmationDialogService {
|
|
|
75
50
|
}
|
|
76
51
|
showConfirmationDialog({ title, description }) {
|
|
77
52
|
return new Promise((resolve) => {
|
|
78
|
-
const dialogRef = this.hlmDialogService.open(
|
|
53
|
+
const dialogRef = this.hlmDialogService.open(EgConfirmationDialog, {
|
|
79
54
|
context: { title, description },
|
|
80
55
|
contentClass: '',
|
|
81
56
|
});
|
|
@@ -84,10 +59,10 @@ class EgConfirmationDialogService {
|
|
|
84
59
|
});
|
|
85
60
|
});
|
|
86
61
|
}
|
|
87
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.
|
|
88
|
-
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.
|
|
62
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgConfirmationDialogService, deps: [{ token: i1.HlmDialogService }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
63
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgConfirmationDialogService, providedIn: 'root' });
|
|
89
64
|
}
|
|
90
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.
|
|
65
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.3", ngImport: i0, type: EgConfirmationDialogService, decorators: [{
|
|
91
66
|
type: Injectable,
|
|
92
67
|
args: [{ providedIn: 'root' }]
|
|
93
68
|
}], ctorParameters: () => [{ type: i1.HlmDialogService }] });
|
|
@@ -100,5 +75,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.7", ngImpor
|
|
|
100
75
|
* Generated bundle index. Do not edit.
|
|
101
76
|
*/
|
|
102
77
|
|
|
103
|
-
export { EgConfirmationDiaglog, EgConfirmationDialogService };
|
|
104
|
-
|
|
78
|
+
export { EgConfirmationDiaglog, EgConfirmationDialog, EgConfirmationDialogService };
|
|
79
|
+
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { HlmDialogService } from '@egose/shadcn-theme-ng/dialog';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
|
|
4
|
-
declare class
|
|
4
|
+
declare class EgConfirmationDialog {
|
|
5
5
|
private readonly _dialogRef;
|
|
6
6
|
private readonly _dialogContext;
|
|
7
7
|
protected readonly _title: string;
|
|
8
8
|
protected readonly _description: string;
|
|
9
9
|
close(confirm: boolean): void;
|
|
10
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<
|
|
11
|
-
static ɵcmp: i0.ɵɵComponentDeclaration<
|
|
10
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<EgConfirmationDialog, never>;
|
|
11
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<EgConfirmationDialog, "ng-component", never, {}, {}, never, never, true, never>;
|
|
12
12
|
}
|
|
13
|
+
/** @deprecated Use `EgConfirmationDialog`. The misspelled name will be removed in the next major release. */
|
|
14
|
+
type EgConfirmationDiaglog = EgConfirmationDialog;
|
|
15
|
+
/** @deprecated Use `EgConfirmationDialog`. The misspelled name will be removed in the next major release. */
|
|
16
|
+
declare const EgConfirmationDiaglog: typeof EgConfirmationDialog;
|
|
13
17
|
declare class EgConfirmationDialogService {
|
|
14
18
|
private hlmDialogService;
|
|
15
19
|
constructor(hlmDialogService: HlmDialogService);
|
|
@@ -21,4 +25,4 @@ declare class EgConfirmationDialogService {
|
|
|
21
25
|
static ɵprov: i0.ɵɵInjectableDeclaration<EgConfirmationDialogService>;
|
|
22
26
|
}
|
|
23
27
|
|
|
24
|
-
export { EgConfirmationDiaglog, EgConfirmationDialogService };
|
|
28
|
+
export { EgConfirmationDiaglog, EgConfirmationDialog, EgConfirmationDialogService };
|