@su-labs/dialog 22.0.0 → 22.1.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/CHANGELOG.md +20 -0
- package/README.md +8 -3
- package/fesm2022/su-labs-dialog.mjs +6 -6
- package/fesm2022/su-labs-dialog.mjs.map +1 -1
- package/package.json +2 -2
- package/types/su-labs-dialog.d.ts +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [22.1.1] - 2026-11-16
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
- Uses `@su-labs/core` 1.9.0 (was 1.5.0), the same version as every other `@su-labs` package, so apps using several of them install core once
|
|
14
|
+
|
|
15
|
+
## [22.1.0] - 2026-11-09
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- `size`: `'small'`, `'medium'` or `'large'` (at least 20%, 50% or 80% of the screen's height, growing with the content; default `'small'`), each adjustable with `--su-dialog-small-height`, `--su-dialog-medium-height` and `--su-dialog-large-height`
|
|
19
|
+
- `--su-dialog-danger-border`
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- The danger button is a soft red (a light tint with red text and border) instead of solid red
|
|
23
|
+
- The buttons sit at the bottom of a tall dialog
|
|
24
|
+
|
|
25
|
+
### Fixed
|
|
26
|
+
- A page's CSS reset (`margin: 0`) no longer stretches the dialog to the full height of the screen
|
|
27
|
+
- Focus opens on a button, never on the dialog itself (no focus ring around the whole dialog)
|
|
28
|
+
- Depends on exactly `@su-labs/core` 1.5.0
|
|
29
|
+
|
|
10
30
|
## [22.0.0] - 2026-11-09
|
|
11
31
|
|
|
12
32
|
### Added
|
package/README.md
CHANGED
|
@@ -18,6 +18,7 @@ with a promise, and styled entirely through CSS variables so they follow your th
|
|
|
18
18
|
- **A promise for the answer**: `if (await dialog.confirm({ … }))`
|
|
19
19
|
- **Rich text**: the body can be HTML (lists, `<small>`, links, images), sanitized by Angular; plus an optional picture
|
|
20
20
|
- **Backdrop**: dimmed (any colour and opacity) or clear
|
|
21
|
+
- **Sizes**: small, medium or large, growing with the content
|
|
21
22
|
- **Accessible**: native `<dialog>`, focus kept inside, Escape to cancel, title and text announced to screen readers;
|
|
22
23
|
a `danger` dialog starts on Cancel so Enter never confirms it by accident
|
|
23
24
|
- **One at a time**: dialogs opened meanwhile wait their turn
|
|
@@ -29,6 +30,8 @@ with a promise, and styled entirely through CSS variables so they follow your th
|
|
|
29
30
|
npm install @su-labs/dialog
|
|
30
31
|
```
|
|
31
32
|
|
|
33
|
+
On Angular 19 or 20, install the matching version: `npm install @su-labs/dialog@ng19` or `npm install @su-labs/dialog@ng20`.
|
|
34
|
+
|
|
32
35
|
Peer dependencies: `@angular/core` and `@angular/common` 22.
|
|
33
36
|
|
|
34
37
|
## Quick Start
|
|
@@ -97,7 +100,8 @@ dialog.configure({ acceptLabel: 'Aceptar', cancelLabel: 'Cancelar', backdropOpac
|
|
|
97
100
|
| `image` | — | `{ src, alt }`, a picture above the text |
|
|
98
101
|
| `acceptLabel` / `cancelLabel` | `'OK'` / `'Cancel'` | Button labels |
|
|
99
102
|
| `danger` | `false` | Red accept button, focus starts on Cancel |
|
|
100
|
-
| `
|
|
103
|
+
| `size` | `'small'` | How tall it is at least, growing with its content: `'small'` (20% of the screen), `'medium'` (50%) or `'large'` (80%) |
|
|
104
|
+
| `width` / `height` | `28rem` / from `size` | Any CSS length; always kept inside the screen |
|
|
101
105
|
| `backdrop` | `'dim'` | `'dim'` tints the page behind, `'none'` leaves it clear |
|
|
102
106
|
| `backdropColor` | black | Any CSS colour for the tint |
|
|
103
107
|
| `backdropOpacity` | `0.5` | How much the tint covers, from 0 to 1 |
|
|
@@ -119,7 +123,8 @@ Every part reads a CSS variable. Set them on `:root` (your theme), on `su-lib-di
|
|
|
119
123
|
|
|
120
124
|
| Variable | Default |
|
|
121
125
|
|----------|---------|
|
|
122
|
-
| `--su-dialog-width` / `--su-dialog-height` | `28rem` / `
|
|
126
|
+
| `--su-dialog-width` / `--su-dialog-height` | `28rem` / `fit-content` |
|
|
127
|
+
| `--su-dialog-small-height` / `--su-dialog-medium-height` / `--su-dialog-large-height` | `20dvh` / `50dvh` / `80dvh` |
|
|
123
128
|
| `--su-dialog-max-width` / `--su-dialog-max-height` | `calc(100vw - 2rem)` / `calc(100dvh - 2rem)` |
|
|
124
129
|
| `--su-dialog-background` | `#fff` |
|
|
125
130
|
| `--su-dialog-text-color` | `#333` |
|
|
@@ -136,7 +141,7 @@ Every part reads a CSS variable. Set them on `:root` (your theme), on `su-lib-di
|
|
|
136
141
|
| `--su-dialog-button-radius` / `--su-dialog-button-padding` / `--su-dialog-button-weight` | `8px` / `0.5rem 1.25rem` / `600` |
|
|
137
142
|
| `--su-dialog-accept-background` / `--su-dialog-accept-color` / `--su-dialog-accept-border` | `#111` / `#fff` / `1px solid transparent` |
|
|
138
143
|
| `--su-dialog-cancel-background` / `--su-dialog-cancel-color` / `--su-dialog-cancel-border` | `transparent` / `inherit` / `1px solid rgb(0 0 0 / 0.2)` |
|
|
139
|
-
| `--su-dialog-danger-background` / `--su-dialog-danger-color` | `#b42318` /
|
|
144
|
+
| `--su-dialog-danger-background` / `--su-dialog-danger-color` / `--su-dialog-danger-border` | a light red tint / `#b42318` / a soft red line |
|
|
140
145
|
| `--su-dialog-focus-outline` | `2px solid currentColor` |
|
|
141
146
|
| `--su-dialog-duration` | `180ms` (no animation with reduced motion) |
|
|
142
147
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ChangeDetectionStrategy, Component, Injectable,
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Injectable, afterRenderEffect, inject, signal, viewChild } from "@angular/core";
|
|
3
3
|
import { SuDialogController } from "@su-labs/core/dialog";
|
|
4
4
|
var SuDialogService = class SuDialogService {
|
|
5
5
|
controller = new SuDialogController();
|
|
@@ -56,7 +56,7 @@ var SuDialogComponent = class SuDialogComponent {
|
|
|
56
56
|
dialog = this.service.current;
|
|
57
57
|
element = viewChild.required("element", ...ngDevMode ? [{ debugName: "element" }] : /* istanbul ignore next */ []);
|
|
58
58
|
constructor() {
|
|
59
|
-
|
|
59
|
+
afterRenderEffect(() => {
|
|
60
60
|
const element = this.element().nativeElement;
|
|
61
61
|
const dialog = this.dialog();
|
|
62
62
|
if (dialog && !element.open) element.showModal();
|
|
@@ -92,8 +92,8 @@ var SuDialogComponent = class SuDialogComponent {
|
|
|
92
92
|
isSignal: true
|
|
93
93
|
}],
|
|
94
94
|
ngImport: i0,
|
|
95
|
-
template: "<dialog\n #element\n class=\"su-dialog {{ dialog()?.cssClass ?? '' }}\"\n [class.is-danger]=\"dialog()?.danger\"\n [style.--su-dialog-width]=\"dialog()?.width\"\n [style.--su-dialog-height]=\"dialog()?.height\"\n [style.--su-dialog-backdrop]=\"dialog()?.backdropColor\"\n [attr.aria-labelledby]=\"dialog() ? 'su-dialog-title' : null\"\n [attr.aria-describedby]=\"dialog()?.body ? 'su-dialog-body' : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onClick($event)\"\n>\n @if (dialog(); as dialog) {\n <div class=\"su-dialog-content\">\n @if (dialog.image; as image) {\n <img class=\"su-dialog-image\" [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n <h2 class=\"su-dialog-title\" id=\"su-dialog-title\">{{ dialog.title }}</h2>\n @if (dialog.body) {\n <div class=\"su-dialog-body\" id=\"su-dialog-body\" [innerHTML]=\"dialog.body\"></div>\n }\n <div class=\"su-dialog-actions\">\n @if (dialog.kind === 'confirm') {\n
|
|
96
|
-
styles: [".su-dialog{background:var(--su-dialog-background, #fff);border:var(--su-dialog-border, 1px solid rgba(0, 0, 0, .08));border-radius:var(--su-dialog-radius, 12px);box-shadow:var(--su-dialog-shadow, 0 20px 50px rgba(0, 0, 0, .25));box-sizing:border-box;color:var(--su-dialog-text-color, #333);font-family:var(--su-dialog-font-family, inherit);height:var(--su-dialog-height,
|
|
95
|
+
template: "<dialog\n #element\n class=\"su-dialog su-dialog-{{ dialog()?.size ?? 'small' }} {{ dialog()?.cssClass ?? '' }}\"\n [class.is-danger]=\"dialog()?.danger\"\n [style.--su-dialog-width]=\"dialog()?.width\"\n [style.--su-dialog-height]=\"dialog()?.height\"\n [style.--su-dialog-backdrop]=\"dialog()?.backdropColor\"\n [attr.aria-labelledby]=\"dialog() ? 'su-dialog-title' : null\"\n [attr.aria-describedby]=\"dialog()?.body ? 'su-dialog-body' : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onClick($event)\"\n>\n @if (dialog(); as dialog) {\n <div class=\"su-dialog-content\">\n @if (dialog.image; as image) {\n <img class=\"su-dialog-image\" [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n <h2 class=\"su-dialog-title\" id=\"su-dialog-title\">{{ dialog.title }}</h2>\n @if (dialog.body) {\n <div class=\"su-dialog-body\" id=\"su-dialog-body\" [innerHTML]=\"dialog.body\"></div>\n }\n <div class=\"su-dialog-actions\">\n @if (dialog.kind === 'confirm') {\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-cancel\"\n [attr.autofocus]=\"dialog.danger ? '' : null\"\n (click)=\"service.close(false)\"\n >\n {{ dialog.cancelLabel }}\n </button>\n }\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-accept\"\n [attr.autofocus]=\"dialog.danger && dialog.kind === 'confirm' ? null : ''\"\n (click)=\"service.close(true)\"\n >\n {{ dialog.acceptLabel }}\n </button>\n </div>\n </div>\n }\n</dialog>\n",
|
|
96
|
+
styles: [".su-dialog{background:var(--su-dialog-background, #fff);border:var(--su-dialog-border, 1px solid rgba(0, 0, 0, .08));border-radius:var(--su-dialog-radius, 12px);box-shadow:var(--su-dialog-shadow, 0 20px 50px rgba(0, 0, 0, .25));box-sizing:border-box;color:var(--su-dialog-text-color, #333);font-family:var(--su-dialog-font-family, inherit);height:var(--su-dialog-height, fit-content);margin:auto;max-height:var(--su-dialog-max-height, calc(100dvh - 2rem) );max-width:var(--su-dialog-max-width, calc(100vw - 2rem) );overflow:auto;padding:0;width:var(--su-dialog-width, 28rem)}.su-dialog:focus,.su-dialog:focus-visible{outline:none}.su-dialog[open]{animation:su-dialog-in var(--su-dialog-duration, .18s) ease-out;display:flex;flex-direction:column}.su-dialog::backdrop{background:var(--su-dialog-backdrop, rgba(0, 0, 0, .5))}.su-dialog[open]::backdrop{animation:su-dialog-fade var(--su-dialog-duration, .18s) ease-out}.su-dialog-small{min-height:var(--su-dialog-small-height, 20dvh)}.su-dialog-medium{min-height:var(--su-dialog-medium-height, 50dvh)}.su-dialog-large{min-height:var(--su-dialog-large-height, 80dvh)}.su-dialog-content{display:flex;flex:1;flex-direction:column;gap:var(--su-dialog-gap, 1rem);padding:var(--su-dialog-padding, 1.5rem)}.su-dialog-image{border-radius:var(--su-dialog-image-radius, 8px);align-self:center;max-height:var(--su-dialog-image-max-height, 12rem);max-width:100%;object-fit:contain}.su-dialog-title{color:var(--su-dialog-title-color, inherit);font-family:var(--su-dialog-title-font-family, inherit);font-size:var(--su-dialog-title-size, 1.25rem);line-height:1.3;margin:0}.su-dialog-body{font-size:var(--su-dialog-body-size, 1rem);line-height:1.5}.su-dialog-body :where(p,ul,ol){margin:0 0 .5rem}.su-dialog-body :where(ul,ol){padding-left:1.25rem}.su-dialog-body :where(img){max-width:100%}.su-dialog-body :where(small){opacity:.75}.su-dialog-actions{display:flex;margin-top:auto;flex-wrap:wrap;gap:var(--su-dialog-actions-gap, .5rem);justify-content:var(--su-dialog-actions-align, flex-end)}.su-dialog-button{border-radius:var(--su-dialog-button-radius, 8px);cursor:pointer;font:inherit;font-weight:var(--su-dialog-button-weight, 600);min-height:2.5rem;padding:var(--su-dialog-button-padding, .5rem 1.25rem)}.su-dialog-button:focus-visible{outline:var(--su-dialog-focus-outline, 2px solid currentColor);outline-offset:2px}.su-dialog-accept{background:var(--su-dialog-accept-background, #111);border:var(--su-dialog-accept-border, 1px solid transparent);color:var(--su-dialog-accept-color, #fff)}.su-dialog-cancel{background:var(--su-dialog-cancel-background, transparent);border:var(--su-dialog-cancel-border, 1px solid rgba(0, 0, 0, .2));color:var(--su-dialog-cancel-color, inherit)}.is-danger .su-dialog-accept{background:var(--su-dialog-danger-background, color-mix(in srgb, #b42318 12%, transparent));border:var(--su-dialog-danger-border, 1px solid color-mix(in srgb, #b42318 35%, transparent));color:var(--su-dialog-danger-color, #b42318)}@keyframes su-dialog-in{0%{opacity:0;transform:translateY(.5rem) scale(.98)}}@keyframes su-dialog-fade{0%{opacity:0}}@media(prefers-reduced-motion:reduce){.su-dialog[open],.su-dialog[open]::backdrop{animation:none}}\n"],
|
|
97
97
|
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
98
98
|
});
|
|
99
99
|
};
|
|
@@ -107,8 +107,8 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
107
107
|
args: [{
|
|
108
108
|
selector: "su-lib-dialog",
|
|
109
109
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
110
|
-
template: "<dialog\n #element\n class=\"su-dialog {{ dialog()?.cssClass ?? '' }}\"\n [class.is-danger]=\"dialog()?.danger\"\n [style.--su-dialog-width]=\"dialog()?.width\"\n [style.--su-dialog-height]=\"dialog()?.height\"\n [style.--su-dialog-backdrop]=\"dialog()?.backdropColor\"\n [attr.aria-labelledby]=\"dialog() ? 'su-dialog-title' : null\"\n [attr.aria-describedby]=\"dialog()?.body ? 'su-dialog-body' : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onClick($event)\"\n>\n @if (dialog(); as dialog) {\n <div class=\"su-dialog-content\">\n @if (dialog.image; as image) {\n <img class=\"su-dialog-image\" [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n <h2 class=\"su-dialog-title\" id=\"su-dialog-title\">{{ dialog.title }}</h2>\n @if (dialog.body) {\n <div class=\"su-dialog-body\" id=\"su-dialog-body\" [innerHTML]=\"dialog.body\"></div>\n }\n <div class=\"su-dialog-actions\">\n @if (dialog.kind === 'confirm') {\n
|
|
111
|
-
styles: [".su-dialog{background:var(--su-dialog-background, #fff);border:var(--su-dialog-border, 1px solid rgba(0, 0, 0, .08));border-radius:var(--su-dialog-radius, 12px);box-shadow:var(--su-dialog-shadow, 0 20px 50px rgba(0, 0, 0, .25));box-sizing:border-box;color:var(--su-dialog-text-color, #333);font-family:var(--su-dialog-font-family, inherit);height:var(--su-dialog-height,
|
|
110
|
+
template: "<dialog\n #element\n class=\"su-dialog su-dialog-{{ dialog()?.size ?? 'small' }} {{ dialog()?.cssClass ?? '' }}\"\n [class.is-danger]=\"dialog()?.danger\"\n [style.--su-dialog-width]=\"dialog()?.width\"\n [style.--su-dialog-height]=\"dialog()?.height\"\n [style.--su-dialog-backdrop]=\"dialog()?.backdropColor\"\n [attr.aria-labelledby]=\"dialog() ? 'su-dialog-title' : null\"\n [attr.aria-describedby]=\"dialog()?.body ? 'su-dialog-body' : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onClick($event)\"\n>\n @if (dialog(); as dialog) {\n <div class=\"su-dialog-content\">\n @if (dialog.image; as image) {\n <img class=\"su-dialog-image\" [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n <h2 class=\"su-dialog-title\" id=\"su-dialog-title\">{{ dialog.title }}</h2>\n @if (dialog.body) {\n <div class=\"su-dialog-body\" id=\"su-dialog-body\" [innerHTML]=\"dialog.body\"></div>\n }\n <div class=\"su-dialog-actions\">\n @if (dialog.kind === 'confirm') {\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-cancel\"\n [attr.autofocus]=\"dialog.danger ? '' : null\"\n (click)=\"service.close(false)\"\n >\n {{ dialog.cancelLabel }}\n </button>\n }\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-accept\"\n [attr.autofocus]=\"dialog.danger && dialog.kind === 'confirm' ? null : ''\"\n (click)=\"service.close(true)\"\n >\n {{ dialog.acceptLabel }}\n </button>\n </div>\n </div>\n }\n</dialog>\n",
|
|
111
|
+
styles: [".su-dialog{background:var(--su-dialog-background, #fff);border:var(--su-dialog-border, 1px solid rgba(0, 0, 0, .08));border-radius:var(--su-dialog-radius, 12px);box-shadow:var(--su-dialog-shadow, 0 20px 50px rgba(0, 0, 0, .25));box-sizing:border-box;color:var(--su-dialog-text-color, #333);font-family:var(--su-dialog-font-family, inherit);height:var(--su-dialog-height, fit-content);margin:auto;max-height:var(--su-dialog-max-height, calc(100dvh - 2rem) );max-width:var(--su-dialog-max-width, calc(100vw - 2rem) );overflow:auto;padding:0;width:var(--su-dialog-width, 28rem)}.su-dialog:focus,.su-dialog:focus-visible{outline:none}.su-dialog[open]{animation:su-dialog-in var(--su-dialog-duration, .18s) ease-out;display:flex;flex-direction:column}.su-dialog::backdrop{background:var(--su-dialog-backdrop, rgba(0, 0, 0, .5))}.su-dialog[open]::backdrop{animation:su-dialog-fade var(--su-dialog-duration, .18s) ease-out}.su-dialog-small{min-height:var(--su-dialog-small-height, 20dvh)}.su-dialog-medium{min-height:var(--su-dialog-medium-height, 50dvh)}.su-dialog-large{min-height:var(--su-dialog-large-height, 80dvh)}.su-dialog-content{display:flex;flex:1;flex-direction:column;gap:var(--su-dialog-gap, 1rem);padding:var(--su-dialog-padding, 1.5rem)}.su-dialog-image{border-radius:var(--su-dialog-image-radius, 8px);align-self:center;max-height:var(--su-dialog-image-max-height, 12rem);max-width:100%;object-fit:contain}.su-dialog-title{color:var(--su-dialog-title-color, inherit);font-family:var(--su-dialog-title-font-family, inherit);font-size:var(--su-dialog-title-size, 1.25rem);line-height:1.3;margin:0}.su-dialog-body{font-size:var(--su-dialog-body-size, 1rem);line-height:1.5}.su-dialog-body :where(p,ul,ol){margin:0 0 .5rem}.su-dialog-body :where(ul,ol){padding-left:1.25rem}.su-dialog-body :where(img){max-width:100%}.su-dialog-body :where(small){opacity:.75}.su-dialog-actions{display:flex;margin-top:auto;flex-wrap:wrap;gap:var(--su-dialog-actions-gap, .5rem);justify-content:var(--su-dialog-actions-align, flex-end)}.su-dialog-button{border-radius:var(--su-dialog-button-radius, 8px);cursor:pointer;font:inherit;font-weight:var(--su-dialog-button-weight, 600);min-height:2.5rem;padding:var(--su-dialog-button-padding, .5rem 1.25rem)}.su-dialog-button:focus-visible{outline:var(--su-dialog-focus-outline, 2px solid currentColor);outline-offset:2px}.su-dialog-accept{background:var(--su-dialog-accept-background, #111);border:var(--su-dialog-accept-border, 1px solid transparent);color:var(--su-dialog-accept-color, #fff)}.su-dialog-cancel{background:var(--su-dialog-cancel-background, transparent);border:var(--su-dialog-cancel-border, 1px solid rgba(0, 0, 0, .2));color:var(--su-dialog-cancel-color, inherit)}.is-danger .su-dialog-accept{background:var(--su-dialog-danger-background, color-mix(in srgb, #b42318 12%, transparent));border:var(--su-dialog-danger-border, 1px solid color-mix(in srgb, #b42318 35%, transparent));color:var(--su-dialog-danger-color, #b42318)}@keyframes su-dialog-in{0%{opacity:0;transform:translateY(.5rem) scale(.98)}}@keyframes su-dialog-fade{0%{opacity:0}}@media(prefers-reduced-motion:reduce){.su-dialog[open],.su-dialog[open]::backdrop{animation:none}}\n"]
|
|
112
112
|
}]
|
|
113
113
|
}],
|
|
114
114
|
ctorParameters: () => [],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"su-labs-dialog.mjs","names":[],"sources":["../../../../projects/su-labs/dialog/src/lib/dialog.service.ts","../../../../projects/su-labs/dialog/src/lib/dialog.component.ts","../../../../projects/su-labs/dialog/src/lib/dialog.component.html"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport { SuDialog, SuDialogConfig, SuDialogController, SuDialogOptions } from '@su-labs/core/dialog';\n\n/**\n * Angular service for dialogs: a thin wrapper around the framework-agnostic `SuDialogController` from\n * `@su-labs/core/dialog` that exposes the dialog on screen as a signal. Put `<su-lib-dialog />` once in the app's\n * shell to show them.\n */\n@Injectable({ providedIn: 'root' })\nexport class SuDialogService implements OnDestroy {\n private readonly controller = new SuDialogController();\n private readonly currentDialog = signal<SuDialog | null>(this.controller.current.get());\n private readonly unsubscribe = this.controller.current.subscribe((dialog) => this.currentDialog.set(dialog));\n\n /** The dialog on screen, or null */\n readonly current = this.currentDialog.asReadonly();\n\n /** Defaults for every dialog from now on, e.g. the button labels in the page's language */\n configure(config: SuDialogConfig): void {\n this.controller.configure(config);\n }\n\n /**\n * Opens a dialog (or queues it behind the one on screen).\n * @returns Whether it was accepted\n */\n open(options: SuDialogOptions): Promise<boolean> {\n return this.controller.open(options);\n }\n\n /** A question with accept and cancel buttons; resolves with whether it was accepted */\n confirm(options: Omit<SuDialogOptions, 'kind'>): Promise<boolean> {\n return this.controller.confirm(options);\n }\n\n /** A message with one button; resolves once it's closed */\n alert(options: Omit<SuDialogOptions, 'kind'>): Promise<void> {\n return this.controller.alert(options);\n }\n\n /** Closes the dialog on screen with its answer; the component calls it for the buttons, Escape and the backdrop */\n close(accepted: boolean): void {\n this.controller.close(accepted);\n }\n\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","import { ChangeDetectionStrategy, Component,
|
|
1
|
+
{"version":3,"file":"su-labs-dialog.mjs","names":[],"sources":["../../../../projects/su-labs/dialog/src/lib/dialog.service.ts","../../../../projects/su-labs/dialog/src/lib/dialog.component.ts","../../../../projects/su-labs/dialog/src/lib/dialog.component.html"],"sourcesContent":["import { Injectable, OnDestroy, signal } from '@angular/core';\nimport { SuDialog, SuDialogConfig, SuDialogController, SuDialogOptions } from '@su-labs/core/dialog';\n\n/**\n * Angular service for dialogs: a thin wrapper around the framework-agnostic `SuDialogController` from\n * `@su-labs/core/dialog` that exposes the dialog on screen as a signal. Put `<su-lib-dialog />` once in the app's\n * shell to show them.\n */\n@Injectable({ providedIn: 'root' })\nexport class SuDialogService implements OnDestroy {\n private readonly controller = new SuDialogController();\n private readonly currentDialog = signal<SuDialog | null>(this.controller.current.get());\n private readonly unsubscribe = this.controller.current.subscribe((dialog) => this.currentDialog.set(dialog));\n\n /** The dialog on screen, or null */\n readonly current = this.currentDialog.asReadonly();\n\n /** Defaults for every dialog from now on, e.g. the button labels in the page's language */\n configure(config: SuDialogConfig): void {\n this.controller.configure(config);\n }\n\n /**\n * Opens a dialog (or queues it behind the one on screen).\n * @returns Whether it was accepted\n */\n open(options: SuDialogOptions): Promise<boolean> {\n return this.controller.open(options);\n }\n\n /** A question with accept and cancel buttons; resolves with whether it was accepted */\n confirm(options: Omit<SuDialogOptions, 'kind'>): Promise<boolean> {\n return this.controller.confirm(options);\n }\n\n /** A message with one button; resolves once it's closed */\n alert(options: Omit<SuDialogOptions, 'kind'>): Promise<void> {\n return this.controller.alert(options);\n }\n\n /** Closes the dialog on screen with its answer; the component calls it for the buttons, Escape and the backdrop */\n close(accepted: boolean): void {\n this.controller.close(accepted);\n }\n\n ngOnDestroy(): void {\n this.unsubscribe();\n this.controller.destroy();\n }\n}\n","import { afterRenderEffect, ChangeDetectionStrategy, Component, ElementRef, inject, viewChild } from '@angular/core';\nimport { SuDialogService } from './dialog.service';\n\n/**\n * Shows the dialogs of `SuDialogService`, on the native `<dialog>` element: it sits above the page, keeps keyboard\n * focus inside, and closes with Escape (and a click outside, when the dialog is dismissible) as cancel. The body may\n * be HTML; Angular removes anything unsafe from it. Place it once, e.g. at the end of the app's shell.\n */\n@Component({\n selector: 'su-lib-dialog',\n changeDetection: ChangeDetectionStrategy.OnPush,\n templateUrl: './dialog.component.html',\n styleUrl: './dialog.component.scss',\n})\nexport class SuDialogComponent {\n protected readonly service = inject(SuDialogService);\n protected readonly dialog = this.service.current;\n private readonly element = viewChild.required<ElementRef<HTMLDialogElement>>('element');\n\n constructor() {\n afterRenderEffect(() => {\n const element = this.element().nativeElement;\n const dialog = this.dialog();\n if (dialog && !element.open) {\n element.showModal();\n } else if (!dialog && element.open) {\n element.close();\n }\n });\n }\n\n /** Escape: the browser would close the dialog by itself; it closes as cancel only when dismissible */\n protected onCancel(event: Event): void {\n event.preventDefault();\n if (this.dialog()?.dismissible) {\n this.service.close(false);\n }\n }\n\n /** A click on the dialog element itself (not its content) is a click on the backdrop around it */\n protected onClick(event: MouseEvent): void {\n if (event.target === this.element().nativeElement && this.dialog()?.dismissible) {\n this.service.close(false);\n }\n }\n}\n","<dialog\n #element\n class=\"su-dialog su-dialog-{{ dialog()?.size ?? 'small' }} {{ dialog()?.cssClass ?? '' }}\"\n [class.is-danger]=\"dialog()?.danger\"\n [style.--su-dialog-width]=\"dialog()?.width\"\n [style.--su-dialog-height]=\"dialog()?.height\"\n [style.--su-dialog-backdrop]=\"dialog()?.backdropColor\"\n [attr.aria-labelledby]=\"dialog() ? 'su-dialog-title' : null\"\n [attr.aria-describedby]=\"dialog()?.body ? 'su-dialog-body' : null\"\n (cancel)=\"onCancel($event)\"\n (click)=\"onClick($event)\"\n>\n @if (dialog(); as dialog) {\n <div class=\"su-dialog-content\">\n @if (dialog.image; as image) {\n <img class=\"su-dialog-image\" [src]=\"image.src\" [alt]=\"image.alt\" />\n }\n <h2 class=\"su-dialog-title\" id=\"su-dialog-title\">{{ dialog.title }}</h2>\n @if (dialog.body) {\n <div class=\"su-dialog-body\" id=\"su-dialog-body\" [innerHTML]=\"dialog.body\"></div>\n }\n <div class=\"su-dialog-actions\">\n @if (dialog.kind === 'confirm') {\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-cancel\"\n [attr.autofocus]=\"dialog.danger ? '' : null\"\n (click)=\"service.close(false)\"\n >\n {{ dialog.cancelLabel }}\n </button>\n }\n <button\n type=\"button\"\n class=\"su-dialog-button su-dialog-accept\"\n [attr.autofocus]=\"dialog.danger && dialog.kind === 'confirm' ? null : ''\"\n (click)=\"service.close(true)\"\n >\n {{ dialog.acceptLabel }}\n </button>\n </div>\n </div>\n }\n</dialog>\n"],"mappings":";;;AASA,IAAa,kBAAb,MAAa,gBAAe;CACT,aAAa,IAAI,mBAAkB;CACnC,gBAAgB,OAAwB,KAAK,WAAW,QAAQ,IAAG,GAAG,GAA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+
"version": "22.1.1",
|
|
4
4
|
"description": "Accessible confirm and message dialogs for Angular, on the native <dialog>: one or two buttons, HTML text, an optional picture, a dimmed or clear backdrop, and every part themeable with CSS variables.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"angular",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@angular/core": "^22.0.0"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@su-labs/core": "1.
|
|
38
|
+
"@su-labs/core": "1.9.0",
|
|
39
39
|
"tslib": "^2.3.0"
|
|
40
40
|
},
|
|
41
41
|
"sideEffects": false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
2
|
import { OnDestroy } from "@angular/core";
|
|
3
|
-
import { SuDialog, SuDialog as SuDialog$1, SuDialogBackdrop, SuDialogConfig, SuDialogConfig as SuDialogConfig$1, SuDialogImage, SuDialogKind, SuDialogOptions, SuDialogOptions as SuDialogOptions$1 } from "@su-labs/core/dialog";
|
|
3
|
+
import { SuDialog, SuDialog as SuDialog$1, SuDialogBackdrop, SuDialogConfig, SuDialogConfig as SuDialogConfig$1, SuDialogImage, SuDialogKind, SuDialogOptions, SuDialogOptions as SuDialogOptions$1, SuDialogSize } from "@su-labs/core/dialog";
|
|
4
4
|
/**
|
|
5
5
|
* Angular service for dialogs: a thin wrapper around the framework-agnostic `SuDialogController` from
|
|
6
6
|
* `@su-labs/core/dialog` that exposes the dialog on screen as a signal. Put `<su-lib-dialog />` once in the app's
|
|
@@ -46,4 +46,4 @@ export declare class SuDialogComponent {
|
|
|
46
46
|
static ɵfac: i0.ɵɵFactoryDeclaration<SuDialogComponent, never>;
|
|
47
47
|
static ɵcmp: i0.ɵɵComponentDeclaration<SuDialogComponent, "su-lib-dialog", never, {}, {}, never, never, true, never>;
|
|
48
48
|
}
|
|
49
|
-
export type { SuDialog, SuDialogBackdrop, SuDialogConfig, SuDialogImage, SuDialogKind, SuDialogOptions };
|
|
49
|
+
export type { SuDialog, SuDialogBackdrop, SuDialogConfig, SuDialogImage, SuDialogKind, SuDialogOptions, SuDialogSize };
|