@egose/shadcn-theme-ng 0.1.0 → 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 +1 -1
- package/accordion/README.md +405 -2
- package/alert/README.md +372 -2
- package/alert-dialog/README.md +471 -5
- package/aspect-ratio/README.md +272 -5
- package/autocomplete/README.md +502 -2
- package/avatar/README.md +357 -5
- package/badge/README.md +318 -2
- package/basic-alert/README.md +353 -2
- package/breadcrumb/README.md +406 -5
- package/button/README.md +482 -2
- package/button/fesm2022/button.mjs +85 -107
- package/button/types/button.d.ts +5 -8
- package/button-group/README.md +318 -5
- package/calendar/README.md +357 -2
- package/card/README.md +331 -5
- package/carousel/README.md +333 -5
- package/carousel/fesm2022/carousel.mjs +4 -1
- package/checkbox/README.md +320 -2
- package/collapsible/README.md +332 -5
- package/combobox/README.md +507 -5
- package/combobox/fesm2022/combobox.mjs +4 -1
- package/command/README.md +435 -5
- package/confirmation-dialog/README.md +301 -2
- package/context-menu/README.md +366 -5
- package/date-picker/README.md +465 -2
- package/date-picker/fesm2022/date-picker.mjs +2 -2
- package/dialog/README.md +448 -2
- package/drawer/README.md +395 -5
- package/dropdown-menu/README.md +417 -5
- package/empty/README.md +329 -5
- package/field/README.md +385 -5
- package/form-checkbox/README.md +312 -2
- package/form-date-picker/README.md +322 -2
- package/form-field/README.md +356 -2
- package/form-field-simple/README.md +340 -2
- package/form-searchable-multiselect/README.md +361 -2
- package/form-select/README.md +350 -2
- package/form-text-input/README.md +371 -2
- package/form-textarea/README.md +347 -2
- package/hover-card/README.md +256 -5
- package/icon/README.md +239 -2
- package/input/README.md +269 -2
- package/input-group/README.md +335 -5
- package/input-group/fesm2022/input-group.mjs +3 -3
- package/input-otp/README.md +375 -5
- package/item/README.md +385 -5
- package/item/fesm2022/item.mjs +3 -3
- package/kbd/README.md +291 -5
- package/label/README.md +272 -2
- package/layout-simple/README.md +193 -2
- package/layout-simple/fesm2022/layout-simple.mjs +472 -236
- package/layout-simple/types/layout-simple.d.ts +174 -137
- package/menu/README.md +417 -2
- package/menubar/README.md +343 -5
- package/native-select/README.md +323 -5
- package/navigation-menu/README.md +369 -5
- package/package.json +1 -1
- package/pagination/README.md +388 -5
- package/popover/README.md +331 -2
- package/progress/README.md +311 -5
- package/radio-group/README.md +364 -2
- package/radio-group/fesm2022/radio-group.mjs +5 -1
- package/radio-group/types/radio-group.d.ts +1 -1
- package/resizable/README.md +269 -5
- package/scroll-area/README.md +233 -5
- package/searchable-multiselect/README.md +323 -2
- package/select/README.md +437 -2
- package/separator/README.md +222 -2
- package/sheet/README.md +311 -2
- package/sidebar/README.md +457 -5
- package/skeleton/README.md +217 -5
- package/slider/README.md +273 -5
- package/slider/fesm2022/slider.mjs +3 -3
- package/sonner/README.md +346 -2
- package/spinner/README.md +284 -2
- package/switch/README.md +310 -2
- package/table/README.md +423 -5
- package/tabs/README.md +411 -2
- package/tabs/fesm2022/tabs.mjs +2 -2
- package/textarea/README.md +282 -5
- package/toggle/README.md +270 -5
- package/toggle-group/README.md +340 -5
- package/tooltip/README.md +269 -2
- package/typography/README.md +271 -5
- package/typography/types/typography.d.ts +8 -8
- package/utils/README.md +303 -2
package/alert-dialog/README.md
CHANGED
|
@@ -1,11 +1,477 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Alert Dialog (`@egose/shadcn-theme-ng/alert-dialog`)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A modal confirmation dialog in the shadcn/ui Alert Dialog style: an overlay plus a centered panel
|
|
4
|
+
with a title, description, optional media illustration, and an action/cancel footer. Use it for
|
|
5
|
+
destructive or consequential confirmations ("Delete project?") that require an explicit choice.
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
The implementation styles the headless
|
|
8
|
+
[`BrnAlertDialog*` primitives from `@spartan-ng/brain/alert-dialog`](https://www.spartan-ng.com/)
|
|
9
|
+
(plus `BrnDialogClose` and the shared `BrnDialog` plumbing from `@spartan-ng/brain/dialog`).
|
|
10
|
+
`HlmAlertDialog` is a component extending `BrnAlertDialog` that renders the overlay and projects
|
|
11
|
+
the rest; every other piece is a thin directive adding `data-slot` attributes and shadcn classes
|
|
12
|
+
via `classes()` / `hlm()`. The action/cancel buttons reuse `HlmBtn` from
|
|
13
|
+
`@egose/shadcn-theme-ng/button` through `hostDirectives`, so `variant`/`size` inputs work on them
|
|
14
|
+
directly.
|
|
6
15
|
|
|
7
|
-
|
|
16
|
+
> **Ships as:** `@egose/shadcn-theme-ng/alert-dialog` and `@egose/shadcn-theme-ng-tw/alert-dialog`
|
|
17
|
+
> (the `tw:`-prefixed Tailwind variant). Both expose the identical TypeScript surface; only the
|
|
18
|
+
> emitted Tailwind class strings differ. See the [package README](../../README.md) for install
|
|
19
|
+
> steps, peer dependencies, and Tailwind setup. Do not publish this project directory independently.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
8
22
|
|
|
9
23
|
```bash
|
|
10
|
-
|
|
24
|
+
# Plain Tailwind (no prefix)
|
|
25
|
+
npm install @egose/shadcn-theme-ng
|
|
26
|
+
|
|
27
|
+
# tw:-prefixed Tailwind variant
|
|
28
|
+
npm install @egose/shadcn-theme-ng-tw
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Peer dependencies (Angular, `@spartan-ng/brain`, `@ng-icons/*`, `rxjs`, …) are documented in the
|
|
32
|
+
[package README](../../README.md#peer-dependencies). This subpath additionally relies at runtime on
|
|
33
|
+
`@egose/shadcn-theme-ng/utils` (`classes()`/`hlm()`) and
|
|
34
|
+
`@egose/shadcn-theme-ng/button` (`HlmBtn`, `provideBrnButtonConfig`).
|
|
35
|
+
|
|
36
|
+
## Imports
|
|
37
|
+
|
|
38
|
+
All symbols are exported from the subpath root (`projects/alert-dialog/src/public-api.ts`):
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import {
|
|
42
|
+
HlmAlertDialog,
|
|
43
|
+
HlmAlertDialogTrigger,
|
|
44
|
+
HlmAlertDialogPortal,
|
|
45
|
+
HlmAlertDialogOverlay,
|
|
46
|
+
HlmAlertDialogContent,
|
|
47
|
+
HlmAlertDialogHeader,
|
|
48
|
+
HlmAlertDialogMedia,
|
|
49
|
+
HlmAlertDialogTitle,
|
|
50
|
+
HlmAlertDialogDescription,
|
|
51
|
+
HlmAlertDialogFooter,
|
|
52
|
+
HlmAlertDialogAction,
|
|
53
|
+
HlmAlertDialogCancel,
|
|
54
|
+
HlmAlertDialogImports,
|
|
55
|
+
HlmAlertDialogModule,
|
|
56
|
+
} from '@egose/shadcn-theme-ng/alert-dialog';
|
|
57
|
+
// tw variant: replace with '@egose/shadcn-theme-ng-tw/alert-dialog'
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
Standalone component — spread the `*Imports` array:
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
import { Component } from '@angular/core';
|
|
64
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
65
|
+
|
|
66
|
+
@Component({
|
|
67
|
+
selector: 'app-demo',
|
|
68
|
+
standalone: true,
|
|
69
|
+
imports: [...HlmAlertDialogImports],
|
|
70
|
+
template: `...`,
|
|
71
|
+
})
|
|
72
|
+
export class DemoComponent {}
|
|
11
73
|
```
|
|
74
|
+
|
|
75
|
+
NgModule-based consumer — import the module:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { NgModule } from '@angular/core';
|
|
79
|
+
import { HlmAlertDialogModule } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
80
|
+
|
|
81
|
+
@NgModule({ imports: [HlmAlertDialogModule] })
|
|
82
|
+
export class DemoModule {}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Anatomy / Structure
|
|
86
|
+
|
|
87
|
+
```html
|
|
88
|
+
<hlm-alert-dialog>
|
|
89
|
+
<button hlmAlertDialogTrigger>Delete project</button>
|
|
90
|
+
|
|
91
|
+
<div hlmAlertDialogPortal>
|
|
92
|
+
<div hlmAlertDialogContent size="default">
|
|
93
|
+
<div hlmAlertDialogHeader>
|
|
94
|
+
<div hlmAlertDialogMedia>
|
|
95
|
+
<ng-icon name="lucideTrash" />
|
|
96
|
+
</div>
|
|
97
|
+
<h2 hlmAlertDialogTitle>Delete project?</h2>
|
|
98
|
+
<p hlmAlertDialogDescription>This cannot be undone.</p>
|
|
99
|
+
</div>
|
|
100
|
+
<div hlmAlertDialogFooter>
|
|
101
|
+
<button hlmAlertDialogCancel>Cancel</button>
|
|
102
|
+
<button hlmAlertDialogAction>Delete</button>
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
</hlm-alert-dialog>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Real selectors (from source):
|
|
110
|
+
|
|
111
|
+
| Class | Selector(s) | Kind |
|
|
112
|
+
| --------------------------- | ----------------------------------------------------------------- | --------- |
|
|
113
|
+
| `HlmAlertDialog` | `hlm-alert-dialog` (`exportAs: hlmAlertDialog`) | Component |
|
|
114
|
+
| `HlmAlertDialogTrigger` | `button[hlmAlertDialogTrigger], button[hlmAlertDialogTriggerFor]` | Directive |
|
|
115
|
+
| `HlmAlertDialogPortal` | `[hlmAlertDialogPortal]` | Directive |
|
|
116
|
+
| `HlmAlertDialogOverlay` | `[hlmAlertDialogOverlay], hlm-alert-dialog-overlay` | Directive |
|
|
117
|
+
| `HlmAlertDialogContent` | `[hlmAlertDialogContent], hlm-alert-dialog-content` | Directive |
|
|
118
|
+
| `HlmAlertDialogHeader` | `[hlmAlertDialogHeader], hlm-alert-dialog-header` | Directive |
|
|
119
|
+
| `HlmAlertDialogMedia` | `[hlmAlertDialogMedia], hlm-alert-dialog-media` | Directive |
|
|
120
|
+
| `HlmAlertDialogTitle` | `[hlmAlertDialogTitle]` | Directive |
|
|
121
|
+
| `HlmAlertDialogDescription` | `[hlmAlertDialogDescription]` | Directive |
|
|
122
|
+
| `HlmAlertDialogFooter` | `[hlmAlertDialogFooter], hlm-alert-dialog-footer` | Directive |
|
|
123
|
+
| `HlmAlertDialogAction` | `button[hlmAlertDialogAction]` | Directive |
|
|
124
|
+
| `HlmAlertDialogCancel` | `button[hlmAlertDialogCancel]` | Directive |
|
|
125
|
+
|
|
126
|
+
`HlmAlertDialog` itself renders `<hlm-alert-dialog-overlay />` plus `<ng-content />`, and provides
|
|
127
|
+
`BrnDialog` (aliased to itself) with `BRN_ALERT_DIALOG_DEFAULT_OPTIONS`, so open/close state,
|
|
128
|
+
focus trapping, and outside-pointer handling come from the brain dialog.
|
|
129
|
+
|
|
130
|
+
## API reference
|
|
131
|
+
|
|
132
|
+
### `HlmAlertDialog` — `hlm-alert-dialog`
|
|
133
|
+
|
|
134
|
+
Root component extending `BrnAlertDialog`. No own inputs — the full `BrnAlertDialog` surface
|
|
135
|
+
(open state, context) is inherited. Exposed as template ref `hlmAlertDialog`.
|
|
136
|
+
|
|
137
|
+
### `HlmAlertDialogTrigger` — `button[hlmAlertDialogTrigger], button[hlmAlertDialogTriggerFor]`
|
|
138
|
+
|
|
139
|
+
Wraps `BrnAlertDialogTrigger`.
|
|
140
|
+
|
|
141
|
+
| Input (via `BrnAlertDialogTrigger`) | Description |
|
|
142
|
+
| ---------------------------------------------------------------- | ---------------------------------- |
|
|
143
|
+
| `id` | Dialog id to toggle. |
|
|
144
|
+
| `hlmAlertDialogTriggerFor` (alias of `brnAlertDialogTriggerFor`) | Template/dialog reference to open. |
|
|
145
|
+
| `type` | Button type passthrough. |
|
|
146
|
+
|
|
147
|
+
### `HlmAlertDialogPortal` — `[hlmAlertDialogPortal]`
|
|
148
|
+
|
|
149
|
+
Wraps `BrnAlertDialogContent` (the CDK-portal outlet).
|
|
150
|
+
|
|
151
|
+
| Input (via brain) | Description |
|
|
152
|
+
| ----------------- | --------------------------------------- |
|
|
153
|
+
| `context` | Template context for the portal. |
|
|
154
|
+
| `class` | Classes forwarded to the portal outlet. |
|
|
155
|
+
|
|
156
|
+
### `HlmAlertDialogContent` — `[hlmAlertDialogContent], hlm-alert-dialog-content`
|
|
157
|
+
|
|
158
|
+
The visible panel. Reads live open/closed state from the injected `ExposesStateProvider`
|
|
159
|
+
(`state()` signal, defaulting to `'closed'`) and reflects it as `data-state`; `size()` is
|
|
160
|
+
reflected as `data-size`, which the footer/header/media styles key off.
|
|
161
|
+
|
|
162
|
+
| Input | Type | Default | Description |
|
|
163
|
+
| ------- | ------------------- | ----------- | ------------------------------------------------------------ |
|
|
164
|
+
| `size` | `'sm' \| 'default'` | `'default'` | Panel width (`sm` renders a compact two-column footer grid). |
|
|
165
|
+
| `state` | `Signal<string>` | inherited | Read-only live dialog state (`'open' \| 'closed'`). |
|
|
166
|
+
|
|
167
|
+
### `HlmAlertDialogOverlay` — `[hlmAlertDialogOverlay], hlm-alert-dialog-overlay`
|
|
168
|
+
|
|
169
|
+
Wraps `BrnAlertDialogOverlay` and forwards the computed dim/backdrop-blur classes to the
|
|
170
|
+
custom element via `injectCustomClassSettable`.
|
|
171
|
+
|
|
172
|
+
| Input | Type | Default | Description |
|
|
173
|
+
| ------- | ------------ | ------- | --------------------------------- |
|
|
174
|
+
| `class` | `ClassValue` | `''` | Extra classes merged via `hlm()`. |
|
|
175
|
+
|
|
176
|
+
### `HlmAlertDialogTitle` / `HlmAlertDialogDescription`
|
|
177
|
+
|
|
178
|
+
Thin wrappers around `BrnAlertDialogTitle` / `BrnAlertDialogDescription`. No own inputs; they add
|
|
179
|
+
`data-slot` and shadcn type styles.
|
|
180
|
+
|
|
181
|
+
### `HlmAlertDialogHeader` / `HlmAlertDialogFooter` / `HlmAlertDialogMedia`
|
|
182
|
+
|
|
183
|
+
Layout-only directives, no inputs. Header centers content (switching to start-aligned on `sm`
|
|
184
|
+
screens for `size="default"`); footer stacks buttons in a column on mobile and a right-aligned row
|
|
185
|
+
on `sm+` (a 2-column grid for `size="sm"`); media renders the `size-16` muted illustration box.
|
|
186
|
+
|
|
187
|
+
### `HlmAlertDialogAction` — `button[hlmAlertDialogAction]`
|
|
188
|
+
|
|
189
|
+
Confirm button. Composes `HlmBtn` (`variant`/`size` inputs forwarded), **not** `BrnDialogClose` —
|
|
190
|
+
closing on confirm is your handler's job.
|
|
191
|
+
|
|
192
|
+
| Input | Type | Default | Description |
|
|
193
|
+
| --------- | --------------------------------- | ------------- | ------------------- |
|
|
194
|
+
| `variant` | via `HlmBtn` | (btn default) | Button tone. |
|
|
195
|
+
| `size` | via `HlmBtn` | (btn default) | Button size. |
|
|
196
|
+
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Native button type. |
|
|
197
|
+
|
|
198
|
+
### `HlmAlertDialogCancel` — `button[hlmAlertDialogCancel]`
|
|
199
|
+
|
|
200
|
+
Cancel button. Composes `BrnDialogClose` (closes automatically) + `HlmBtn`, with
|
|
201
|
+
`provideBrnButtonConfig({ variant: 'outline' })` so it renders outlined by default.
|
|
202
|
+
|
|
203
|
+
| Input | Type | Default | Description |
|
|
204
|
+
| --------- | --------------------------------- | ------------- | -------------------------- |
|
|
205
|
+
| `variant` | via `HlmBtn` | `'outline'` | Button tone (overridable). |
|
|
206
|
+
| `size` | via `HlmBtn` | (btn default) | Button size. |
|
|
207
|
+
| `type` | `'button' \| 'submit' \| 'reset'` | `'button'` | Native button type. |
|
|
208
|
+
|
|
209
|
+
## Examples
|
|
210
|
+
|
|
211
|
+
### 1. Basic delete confirmation
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
import { Component } from '@angular/core';
|
|
215
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
216
|
+
|
|
217
|
+
@Component({
|
|
218
|
+
selector: 'app-alert-dialog-basic',
|
|
219
|
+
standalone: true,
|
|
220
|
+
imports: [...HlmAlertDialogImports],
|
|
221
|
+
template: `
|
|
222
|
+
<hlm-alert-dialog>
|
|
223
|
+
<button hlmAlertDialogTrigger>Delete project</button>
|
|
224
|
+
<div hlmAlertDialogPortal>
|
|
225
|
+
<div hlmAlertDialogContent>
|
|
226
|
+
<div hlmAlertDialogHeader>
|
|
227
|
+
<h2 hlmAlertDialogTitle>Delete project?</h2>
|
|
228
|
+
<p hlmAlertDialogDescription>This permanently removes the project and its data. This cannot be undone.</p>
|
|
229
|
+
</div>
|
|
230
|
+
<div hlmAlertDialogFooter>
|
|
231
|
+
<button hlmAlertDialogCancel>Cancel</button>
|
|
232
|
+
<button hlmAlertDialogAction (click)="remove()">Delete</button>
|
|
233
|
+
</div>
|
|
234
|
+
</div>
|
|
235
|
+
</div>
|
|
236
|
+
</hlm-alert-dialog>
|
|
237
|
+
`,
|
|
238
|
+
})
|
|
239
|
+
export class AlertDialogBasicComponent {
|
|
240
|
+
remove() {
|
|
241
|
+
/* call the delete API, then the dialog stays until Cancel/close */
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
```html
|
|
247
|
+
<app-alert-dialog-basic />
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### 2. Compact (`size="sm"`) dialog with media illustration
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
import { Component } from '@angular/core';
|
|
254
|
+
import { NgIcon, provideIcons } from '@ng-icons/core';
|
|
255
|
+
import { lucideTriangleAlert } from '@ng-icons/lucide';
|
|
256
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
257
|
+
|
|
258
|
+
@Component({
|
|
259
|
+
selector: 'app-alert-dialog-media',
|
|
260
|
+
standalone: true,
|
|
261
|
+
imports: [...HlmAlertDialogImports, NgIcon],
|
|
262
|
+
providers: [provideIcons({ lucideTriangleAlert })],
|
|
263
|
+
template: `
|
|
264
|
+
<hlm-alert-dialog>
|
|
265
|
+
<button hlmAlertDialogTrigger>Leave page</button>
|
|
266
|
+
<div hlmAlertDialogPortal>
|
|
267
|
+
<div hlmAlertDialogContent size="sm">
|
|
268
|
+
<div hlmAlertDialogHeader>
|
|
269
|
+
<div hlmAlertDialogMedia>
|
|
270
|
+
<ng-icon name="lucideTriangleAlert" />
|
|
271
|
+
</div>
|
|
272
|
+
<h2 hlmAlertDialogTitle>Discard changes?</h2>
|
|
273
|
+
<p hlmAlertDialogDescription>You have unsaved edits that will be lost.</p>
|
|
274
|
+
</div>
|
|
275
|
+
<div hlmAlertDialogFooter>
|
|
276
|
+
<button hlmAlertDialogCancel>Keep editing</button>
|
|
277
|
+
<button hlmAlertDialogAction (click)="discard()">Discard</button>
|
|
278
|
+
</div>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
</hlm-alert-dialog>
|
|
282
|
+
`,
|
|
283
|
+
})
|
|
284
|
+
export class AlertDialogMediaComponent {
|
|
285
|
+
discard() {}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 3. Custom button tones via `HlmBtn` inputs
|
|
290
|
+
|
|
291
|
+
`hlmAlertDialogAction` / `hlmAlertDialogCancel` forward `variant` and `size` to `HlmBtn`:
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
import { Component } from '@angular/core';
|
|
295
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
296
|
+
|
|
297
|
+
@Component({
|
|
298
|
+
selector: 'app-alert-dialog-tones',
|
|
299
|
+
standalone: true,
|
|
300
|
+
imports: [...HlmAlertDialogImports],
|
|
301
|
+
template: `
|
|
302
|
+
<hlm-alert-dialog>
|
|
303
|
+
<button hlmAlertDialogTrigger>Archive workspace</button>
|
|
304
|
+
<div hlmAlertDialogPortal>
|
|
305
|
+
<div hlmAlertDialogContent>
|
|
306
|
+
<div hlmAlertDialogHeader>
|
|
307
|
+
<h2 hlmAlertDialogTitle>Archive workspace?</h2>
|
|
308
|
+
<p hlmAlertDialogDescription>Members lose access until you restore it.</p>
|
|
309
|
+
</div>
|
|
310
|
+
<div hlmAlertDialogFooter>
|
|
311
|
+
<button hlmAlertDialogCancel variant="ghost" size="sm">Back</button>
|
|
312
|
+
<button hlmAlertDialogAction variant="destructive" size="sm" (click)="archive()">Archive</button>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
</div>
|
|
316
|
+
</hlm-alert-dialog>
|
|
317
|
+
`,
|
|
318
|
+
})
|
|
319
|
+
export class AlertDialogTonesComponent {
|
|
320
|
+
archive() {}
|
|
321
|
+
}
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
### 4. Programmatic control with a template reference
|
|
325
|
+
|
|
326
|
+
`HlmAlertDialog` has `exportAs: hlmAlertDialog` and extends `BrnAlertDialog`, so the brain's
|
|
327
|
+
open/close API is available from the template or a `@ViewChild`:
|
|
328
|
+
|
|
329
|
+
```ts
|
|
330
|
+
import { Component, viewChild } from '@angular/core';
|
|
331
|
+
import { HlmAlertDialog, HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
332
|
+
|
|
333
|
+
@Component({
|
|
334
|
+
selector: 'app-alert-dialog-programmatic',
|
|
335
|
+
standalone: true,
|
|
336
|
+
imports: [...HlmAlertDialogImports],
|
|
337
|
+
template: `
|
|
338
|
+
<hlm-alert-dialog #dialog="hlmAlertDialog">
|
|
339
|
+
<div hlmAlertDialogPortal>
|
|
340
|
+
<div hlmAlertDialogContent>
|
|
341
|
+
<div hlmAlertDialogHeader>
|
|
342
|
+
<h2 hlmAlertDialogTitle>Session expired</h2>
|
|
343
|
+
<p hlmAlertDialogDescription>Sign in again to continue.</p>
|
|
344
|
+
</div>
|
|
345
|
+
<div hlmAlertDialogFooter>
|
|
346
|
+
<button hlmAlertDialogCancel>Later</button>
|
|
347
|
+
<button hlmAlertDialogAction (click)="reauth()">Sign in</button>
|
|
348
|
+
</div>
|
|
349
|
+
</div>
|
|
350
|
+
</div>
|
|
351
|
+
</hlm-alert-dialog>
|
|
352
|
+
<button (click)="open()">Check session</button>
|
|
353
|
+
`,
|
|
354
|
+
})
|
|
355
|
+
export class AlertDialogProgrammaticComponent {
|
|
356
|
+
private readonly dialog = viewChild<HlmAlertDialog>('dialog');
|
|
357
|
+
|
|
358
|
+
open() {
|
|
359
|
+
this.dialog()?.open?.();
|
|
360
|
+
}
|
|
361
|
+
reauth() {
|
|
362
|
+
/* ... */ this.dialog()?.close?.();
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
> The exact open/close method names live on `BrnAlertDialog` from `@spartan-ng/brain/alert-dialog`;
|
|
368
|
+
> consult that class for the current API — this package adds no methods of its own.
|
|
369
|
+
|
|
370
|
+
### 5. Element-form variants (element selectors)
|
|
371
|
+
|
|
372
|
+
Header, footer, media, and content also match element selectors, which reads better in long
|
|
373
|
+
templates:
|
|
374
|
+
|
|
375
|
+
```html
|
|
376
|
+
<hlm-alert-dialog>
|
|
377
|
+
<button hlmAlertDialogTrigger>Reset settings</button>
|
|
378
|
+
<div hlmAlertDialogPortal>
|
|
379
|
+
<hlm-alert-dialog-content>
|
|
380
|
+
<hlm-alert-dialog-header>
|
|
381
|
+
<h2 hlmAlertDialogTitle>Reset to defaults?</h2>
|
|
382
|
+
<p hlmAlertDialogDescription>Custom themes and shortcuts will be removed.</p>
|
|
383
|
+
</hlm-alert-dialog-header>
|
|
384
|
+
<hlm-alert-dialog-footer>
|
|
385
|
+
<button hlmAlertDialogCancel>Cancel</button>
|
|
386
|
+
<button hlmAlertDialogAction (click)="reset()">Reset</button>
|
|
387
|
+
</hlm-alert-dialog-footer>
|
|
388
|
+
</hlm-alert-dialog-content>
|
|
389
|
+
</div>
|
|
390
|
+
</hlm-alert-dialog>
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
```ts
|
|
394
|
+
import { Component } from '@angular/core';
|
|
395
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
396
|
+
|
|
397
|
+
@Component({
|
|
398
|
+
selector: 'app-alert-dialog-elements',
|
|
399
|
+
standalone: true,
|
|
400
|
+
imports: [...HlmAlertDialogImports],
|
|
401
|
+
templateUrl: './alert-dialog-elements.html',
|
|
402
|
+
})
|
|
403
|
+
export class AlertDialogElementsComponent {
|
|
404
|
+
reset() {}
|
|
405
|
+
}
|
|
406
|
+
```
|
|
407
|
+
|
|
408
|
+
### 6. Async confirm with a loading button
|
|
409
|
+
|
|
410
|
+
Combine the footer action with the loading state of `HlmButton` for server round-trips:
|
|
411
|
+
|
|
412
|
+
```ts
|
|
413
|
+
import { Component, signal } from '@angular/core';
|
|
414
|
+
import { HlmAlertDialogImports } from '@egose/shadcn-theme-ng/alert-dialog';
|
|
415
|
+
import { HlmButtonImports } from '@egose/shadcn-theme-ng/button';
|
|
416
|
+
|
|
417
|
+
@Component({
|
|
418
|
+
selector: 'app-alert-dialog-async',
|
|
419
|
+
standalone: true,
|
|
420
|
+
imports: [...HlmAlertDialogImports, ...HlmButtonImports],
|
|
421
|
+
template: `
|
|
422
|
+
<hlm-alert-dialog>
|
|
423
|
+
<button hlmAlertDialogTrigger>Transfer ownership</button>
|
|
424
|
+
<div hlmAlertDialogPortal>
|
|
425
|
+
<div hlmAlertDialogContent>
|
|
426
|
+
<div hlmAlertDialogHeader>
|
|
427
|
+
<h2 hlmAlertDialogTitle>Transfer ownership?</h2>
|
|
428
|
+
<p hlmAlertDialogDescription>You will become a regular member.</p>
|
|
429
|
+
</div>
|
|
430
|
+
<div hlmAlertDialogFooter>
|
|
431
|
+
<button hlmAlertDialogCancel [disabled]="saving()">Cancel</button>
|
|
432
|
+
<button hlmButton variant="primary" [loading]="saving()" (click)="transfer()">Transfer</button>
|
|
433
|
+
</div>
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
</hlm-alert-dialog>
|
|
437
|
+
`,
|
|
438
|
+
})
|
|
439
|
+
export class AlertDialogAsyncComponent {
|
|
440
|
+
readonly saving = signal(false);
|
|
441
|
+
|
|
442
|
+
async transfer() {
|
|
443
|
+
this.saving.set(true);
|
|
444
|
+
try {
|
|
445
|
+
await fetch('/api/transfer', { method: 'POST' });
|
|
446
|
+
} finally {
|
|
447
|
+
this.saving.set(false);
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
## Accessibility notes
|
|
454
|
+
|
|
455
|
+
- The dialog is modal: the brain traps focus inside, restores focus to the trigger on close, and
|
|
456
|
+
exposes the panel as an `alertdialog` to assistive technology. Titles and descriptions are wired
|
|
457
|
+
to the panel via `BrnAlertDialogTitle` / `BrnAlertDialogDescription` — always include both so
|
|
458
|
+
screen readers announce purpose and consequence.
|
|
459
|
+
- `HlmAlertDialogCancel` closes via `BrnDialogClose` (Escape and overlay dismissal behave per
|
|
460
|
+
`BRN_ALERT_DIALOG_DEFAULT_OPTIONS`). `HlmAlertDialogAction` deliberately does **not** auto-close:
|
|
461
|
+
keep it that way for destructive flows so a failed request cannot silently dismiss the prompt.
|
|
462
|
+
- The action/cancel buttons are native `<button>` elements — keep their labels verb-led
|
|
463
|
+
("Delete project", not "OK") and distinct from each other.
|
|
464
|
+
|
|
465
|
+
## Theming / CSS variables
|
|
466
|
+
|
|
467
|
+
Class-based styling (popover tokens, `ring-foreground/10`, `animate-in/out` utilities); no
|
|
468
|
+
component-specific CSS variables. The overlay uses `bg-black/10` with a subtle backdrop blur, and
|
|
469
|
+
the panel animates on `data-state` (`fade` + `zoom`). Override via `class` on the overlay
|
|
470
|
+
(forwarded through the custom-element class settable) or any other piece.
|
|
471
|
+
|
|
472
|
+
## Related subpaths
|
|
473
|
+
|
|
474
|
+
- `@egose/shadcn-theme-ng/dialog` — general (non-alert) modal dialogs
|
|
475
|
+
- `@egose/shadcn-theme-ng/confirmation-dialog` — higher-level confirm helper
|
|
476
|
+
- `@egose/shadcn-theme-ng/button` — `HlmBtn` / `HlmButton` used by the footer actions
|
|
477
|
+
- `@egose/shadcn-theme-ng/sonner` — non-blocking toast feedback after confirm
|