@su-labs/dialog 0.0.0-stage → 22.1.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/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +153 -2
- package/fesm2022/su-labs-dialog.mjs +122 -0
- package/fesm2022/su-labs-dialog.mjs.map +1 -0
- package/package.json +52 -3
- package/types/su-labs-dialog.d.ts +49 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
## [22.1.0] - 2026-11-09
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- `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`
|
|
14
|
+
- `--su-dialog-danger-border`
|
|
15
|
+
|
|
16
|
+
### Changed
|
|
17
|
+
- The danger button is a soft red (a light tint with red text and border) instead of solid red
|
|
18
|
+
- The buttons sit at the bottom of a tall dialog
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
- A page's CSS reset (`margin: 0`) no longer stretches the dialog to the full height of the screen
|
|
22
|
+
- Focus opens on a button, never on the dialog itself (no focus ring around the whole dialog)
|
|
23
|
+
- Depends on exactly `@su-labs/core` 1.5.0
|
|
24
|
+
|
|
25
|
+
## [22.0.0] - 2026-11-09
|
|
26
|
+
|
|
27
|
+
### Added
|
|
28
|
+
- `SuDialogService` (`confirm`, `alert`, `open`, `configure`, `current` as a signal) and the `<su-lib-dialog />` component, on the native `<dialog>`: focus stays inside, Escape and a click outside cancel when `dismissible`
|
|
29
|
+
- One button (`ok`) or accept and cancel (`confirm`), with your own labels; `danger` styles the accept button and starts focus on Cancel
|
|
30
|
+
- HTML body (sanitized by Angular), an optional picture, width and height
|
|
31
|
+
- A dimmed or clear backdrop, with its colour and opacity
|
|
32
|
+
- Every part themeable with `--su-dialog-*` CSS variables, and `cssClass` for one dialog
|
|
33
|
+
- Depends on exactly `@su-labs/core` 1.4.0 (version 22 follows Angular 22)
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Yevheniy Alekseyev <yev.alekseyev@gmail.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,154 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Dialog
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@su-labs/dialog`
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
Confirm and message dialogs for Angular, built on the native `<dialog>` element: accessible out of the box, answered
|
|
11
|
+
with a promise, and styled entirely through CSS variables so they follow your theme.
|
|
12
|
+
|
|
13
|
+
> **Not using Angular?** The same dialog logic is in [`@su-labs/core/dialog`](https://www.npmjs.com/package/@su-labs/core).
|
|
14
|
+
|
|
15
|
+
## Features
|
|
16
|
+
|
|
17
|
+
- **Two kinds**: one button (`alert`), or accept and cancel (`confirm`), with your own labels
|
|
18
|
+
- **A promise for the answer**: `if (await dialog.confirm({ … }))`
|
|
19
|
+
- **Rich text**: the body can be HTML (lists, `<small>`, links, images), sanitized by Angular; plus an optional picture
|
|
20
|
+
- **Backdrop**: dimmed (any colour and opacity) or clear
|
|
21
|
+
- **Sizes**: small, medium or large, growing with the content
|
|
22
|
+
- **Accessible**: native `<dialog>`, focus kept inside, Escape to cancel, title and text announced to screen readers;
|
|
23
|
+
a `danger` dialog starts on Cancel so Enter never confirms it by accident
|
|
24
|
+
- **One at a time**: dialogs opened meanwhile wait their turn
|
|
25
|
+
- **Themeable**: every colour, size and spacing is a `--su-dialog-*` CSS variable
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @su-labs/dialog
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Peer dependencies: `@angular/core` and `@angular/common` 22.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Add the component once, e.g. at the end of your app's shell:
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { SuDialogComponent } from '@su-labs/dialog';
|
|
41
|
+
|
|
42
|
+
@Component({
|
|
43
|
+
selector: 'app-root',
|
|
44
|
+
imports: [SuDialogComponent],
|
|
45
|
+
template: `<router-outlet /> <su-lib-dialog />`,
|
|
46
|
+
})
|
|
47
|
+
export class App {}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Then ask from anywhere:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { SuDialogService } from '@su-labs/dialog';
|
|
54
|
+
|
|
55
|
+
export class AccountPage {
|
|
56
|
+
private readonly dialog = inject(SuDialogService);
|
|
57
|
+
|
|
58
|
+
async deleteResults(): Promise<void> {
|
|
59
|
+
const accepted = await this.dialog.confirm({
|
|
60
|
+
title: 'Delete all your results?',
|
|
61
|
+
body: '<p>This removes:</p><ul><li>your plays</li><li>your best results</li></ul><small>It can’t be undone.</small>',
|
|
62
|
+
acceptLabel: 'Delete',
|
|
63
|
+
cancelLabel: 'Keep them',
|
|
64
|
+
danger: true,
|
|
65
|
+
});
|
|
66
|
+
if (accepted) {
|
|
67
|
+
// …
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Set defaults once, e.g. the labels in the page's language:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
dialog.configure({ acceptLabel: 'Aceptar', cancelLabel: 'Cancelar', backdropOpacity: 0.6 });
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## API
|
|
80
|
+
|
|
81
|
+
### SuDialogService
|
|
82
|
+
|
|
83
|
+
| Member | Description |
|
|
84
|
+
|--------|-------------|
|
|
85
|
+
| `confirm(options)` | Accept and cancel; resolves with `true` when accepted, `false` for cancel, Escape or a click outside |
|
|
86
|
+
| `alert(options)` | One button; resolves when closed |
|
|
87
|
+
| `open(options)` | Either, by `kind` (`'confirm'` or `'ok'`) |
|
|
88
|
+
| `configure(config)` | Defaults for every dialog from now on |
|
|
89
|
+
| `current` | Signal of the dialog on screen, or `null` |
|
|
90
|
+
| `close(accepted)` | Closes the dialog on screen (the component calls it) |
|
|
91
|
+
|
|
92
|
+
### Options
|
|
93
|
+
|
|
94
|
+
| Option | Default | Description |
|
|
95
|
+
|--------|---------|-------------|
|
|
96
|
+
| `title` | — | The heading |
|
|
97
|
+
| `body` | — | Text under it; may be HTML |
|
|
98
|
+
| `image` | — | `{ src, alt }`, a picture above the text |
|
|
99
|
+
| `acceptLabel` / `cancelLabel` | `'OK'` / `'Cancel'` | Button labels |
|
|
100
|
+
| `danger` | `false` | Red accept button, focus starts on Cancel |
|
|
101
|
+
| `size` | `'small'` | How tall it is at least, growing with its content: `'small'` (20% of the screen), `'medium'` (50%) or `'large'` (80%) |
|
|
102
|
+
| `width` / `height` | `28rem` / from `size` | Any CSS length; always kept inside the screen |
|
|
103
|
+
| `backdrop` | `'dim'` | `'dim'` tints the page behind, `'none'` leaves it clear |
|
|
104
|
+
| `backdropColor` | black | Any CSS colour for the tint |
|
|
105
|
+
| `backdropOpacity` | `0.5` | How much the tint covers, from 0 to 1 |
|
|
106
|
+
| `dismissible` | `true` | Whether Escape and a click outside close it as cancel |
|
|
107
|
+
| `cssClass` | — | Extra class on the `<dialog>`, to style one dialog its own way |
|
|
108
|
+
|
|
109
|
+
## Styling
|
|
110
|
+
|
|
111
|
+
Every part reads a CSS variable. Set them on `:root` (your theme), on `su-lib-dialog`, or on `.su-dialog.your-class`:
|
|
112
|
+
|
|
113
|
+
```css
|
|
114
|
+
:root {
|
|
115
|
+
--su-dialog-background: var(--surface);
|
|
116
|
+
--su-dialog-text-color: var(--text);
|
|
117
|
+
--su-dialog-radius: 16px;
|
|
118
|
+
--su-dialog-accept-background: var(--accent);
|
|
119
|
+
}
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
| Variable | Default |
|
|
123
|
+
|----------|---------|
|
|
124
|
+
| `--su-dialog-width` / `--su-dialog-height` | `28rem` / `fit-content` |
|
|
125
|
+
| `--su-dialog-small-height` / `--su-dialog-medium-height` / `--su-dialog-large-height` | `20dvh` / `50dvh` / `80dvh` |
|
|
126
|
+
| `--su-dialog-max-width` / `--su-dialog-max-height` | `calc(100vw - 2rem)` / `calc(100dvh - 2rem)` |
|
|
127
|
+
| `--su-dialog-background` | `#fff` |
|
|
128
|
+
| `--su-dialog-text-color` | `#333` |
|
|
129
|
+
| `--su-dialog-border` | `1px solid rgb(0 0 0 / 0.08)` |
|
|
130
|
+
| `--su-dialog-radius` | `12px` |
|
|
131
|
+
| `--su-dialog-shadow` | `0 20px 50px rgb(0 0 0 / 0.25)` |
|
|
132
|
+
| `--su-dialog-padding` / `--su-dialog-gap` | `1.5rem` / `1rem` |
|
|
133
|
+
| `--su-dialog-font-family` | `inherit` |
|
|
134
|
+
| `--su-dialog-title-color` / `--su-dialog-title-font-family` / `--su-dialog-title-size` | `inherit` / `inherit` / `1.25rem` |
|
|
135
|
+
| `--su-dialog-body-size` | `1rem` |
|
|
136
|
+
| `--su-dialog-image-max-height` / `--su-dialog-image-radius` | `12rem` / `8px` |
|
|
137
|
+
| `--su-dialog-backdrop` | `rgb(0 0 0 / 0.5)` |
|
|
138
|
+
| `--su-dialog-actions-gap` / `--su-dialog-actions-align` | `0.5rem` / `flex-end` |
|
|
139
|
+
| `--su-dialog-button-radius` / `--su-dialog-button-padding` / `--su-dialog-button-weight` | `8px` / `0.5rem 1.25rem` / `600` |
|
|
140
|
+
| `--su-dialog-accept-background` / `--su-dialog-accept-color` / `--su-dialog-accept-border` | `#111` / `#fff` / `1px solid transparent` |
|
|
141
|
+
| `--su-dialog-cancel-background` / `--su-dialog-cancel-color` / `--su-dialog-cancel-border` | `transparent` / `inherit` / `1px solid rgb(0 0 0 / 0.2)` |
|
|
142
|
+
| `--su-dialog-danger-background` / `--su-dialog-danger-color` / `--su-dialog-danger-border` | a light red tint / `#b42318` / a soft red line |
|
|
143
|
+
| `--su-dialog-focus-outline` | `2px solid currentColor` |
|
|
144
|
+
| `--su-dialog-duration` | `180ms` (no animation with reduced motion) |
|
|
145
|
+
|
|
146
|
+
The options `width`, `height`, `backdropColor` and `backdropOpacity` win over these for that dialog.
|
|
147
|
+
|
|
148
|
+
## Browser Compatibility
|
|
149
|
+
|
|
150
|
+
Uses the native `<dialog>` element and `color-mix()`: Chrome, Edge, Firefox and Safari from 2023 on.
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import { ChangeDetectionStrategy, Component, Injectable, afterRenderEffect, inject, signal, viewChild } from "@angular/core";
|
|
3
|
+
import { SuDialogController } from "@su-labs/core/dialog";
|
|
4
|
+
var SuDialogService = class SuDialogService {
|
|
5
|
+
controller = new SuDialogController();
|
|
6
|
+
currentDialog = signal(this.controller.current.get(), ...ngDevMode ? [{ debugName: "currentDialog" }] : /* istanbul ignore next */ []);
|
|
7
|
+
unsubscribe = this.controller.current.subscribe((dialog) => this.currentDialog.set(dialog));
|
|
8
|
+
current = this.currentDialog.asReadonly();
|
|
9
|
+
configure(config) {
|
|
10
|
+
this.controller.configure(config);
|
|
11
|
+
}
|
|
12
|
+
open(options) {
|
|
13
|
+
return this.controller.open(options);
|
|
14
|
+
}
|
|
15
|
+
confirm(options) {
|
|
16
|
+
return this.controller.confirm(options);
|
|
17
|
+
}
|
|
18
|
+
alert(options) {
|
|
19
|
+
return this.controller.alert(options);
|
|
20
|
+
}
|
|
21
|
+
close(accepted) {
|
|
22
|
+
this.controller.close(accepted);
|
|
23
|
+
}
|
|
24
|
+
ngOnDestroy() {
|
|
25
|
+
this.unsubscribe();
|
|
26
|
+
this.controller.destroy();
|
|
27
|
+
}
|
|
28
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
29
|
+
minVersion: "12.0.0",
|
|
30
|
+
version: "22.2.4",
|
|
31
|
+
ngImport: i0,
|
|
32
|
+
type: SuDialogService,
|
|
33
|
+
deps: [],
|
|
34
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
35
|
+
});
|
|
36
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({
|
|
37
|
+
minVersion: "12.0.0",
|
|
38
|
+
version: "22.2.4",
|
|
39
|
+
ngImport: i0,
|
|
40
|
+
type: SuDialogService,
|
|
41
|
+
providedIn: "root"
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
45
|
+
minVersion: "12.0.0",
|
|
46
|
+
version: "22.2.4",
|
|
47
|
+
ngImport: i0,
|
|
48
|
+
type: SuDialogService,
|
|
49
|
+
decorators: [{
|
|
50
|
+
type: Injectable,
|
|
51
|
+
args: [{ providedIn: "root" }]
|
|
52
|
+
}]
|
|
53
|
+
});
|
|
54
|
+
var SuDialogComponent = class SuDialogComponent {
|
|
55
|
+
service = inject(SuDialogService);
|
|
56
|
+
dialog = this.service.current;
|
|
57
|
+
element = viewChild.required("element", ...ngDevMode ? [{ debugName: "element" }] : /* istanbul ignore next */ []);
|
|
58
|
+
constructor() {
|
|
59
|
+
afterRenderEffect(() => {
|
|
60
|
+
const element = this.element().nativeElement;
|
|
61
|
+
const dialog = this.dialog();
|
|
62
|
+
if (dialog && !element.open) element.showModal();
|
|
63
|
+
else if (!dialog && element.open) element.close();
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
onCancel(event) {
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
if (this.dialog()?.dismissible) this.service.close(false);
|
|
69
|
+
}
|
|
70
|
+
onClick(event) {
|
|
71
|
+
if (event.target === this.element().nativeElement && this.dialog()?.dismissible) this.service.close(false);
|
|
72
|
+
}
|
|
73
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
74
|
+
minVersion: "12.0.0",
|
|
75
|
+
version: "22.2.4",
|
|
76
|
+
ngImport: i0,
|
|
77
|
+
type: SuDialogComponent,
|
|
78
|
+
deps: [],
|
|
79
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
80
|
+
});
|
|
81
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
82
|
+
minVersion: "17.0.0",
|
|
83
|
+
version: "22.2.4",
|
|
84
|
+
type: SuDialogComponent,
|
|
85
|
+
isStandalone: true,
|
|
86
|
+
selector: "su-lib-dialog",
|
|
87
|
+
viewQueries: [{
|
|
88
|
+
propertyName: "element",
|
|
89
|
+
first: true,
|
|
90
|
+
predicate: ["element"],
|
|
91
|
+
descendants: true,
|
|
92
|
+
isSignal: true
|
|
93
|
+
}],
|
|
94
|
+
ngImport: i0,
|
|
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 <!-- A dangerous action starts on Cancel, so Enter never confirms it by accident -->\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
|
+
changeDetection: i0.ChangeDetectionStrategy.OnPush
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
101
|
+
minVersion: "12.0.0",
|
|
102
|
+
version: "22.2.4",
|
|
103
|
+
ngImport: i0,
|
|
104
|
+
type: SuDialogComponent,
|
|
105
|
+
decorators: [{
|
|
106
|
+
type: Component,
|
|
107
|
+
args: [{
|
|
108
|
+
selector: "su-lib-dialog",
|
|
109
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
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 <!-- A dangerous action starts on Cancel, so Enter never confirms it by accident -->\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
|
+
}]
|
|
113
|
+
}],
|
|
114
|
+
ctorParameters: () => [],
|
|
115
|
+
propDecorators: { element: [{
|
|
116
|
+
type: i0.ViewChild,
|
|
117
|
+
args: ["element", { isSignal: true }]
|
|
118
|
+
}] }
|
|
119
|
+
});
|
|
120
|
+
export { SuDialogComponent, SuDialogService };
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=su-labs-dialog.mjs.map
|
|
@@ -0,0 +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 { 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 // Opens the native dialog when there's one to show (after its buttons are drawn, so focus lands on one of them),\n // and closes it when there isn't\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 <!-- A dangerous action starts on Cancel, so Enter never confirms it by accident -->\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":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,55 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@su-labs/dialog",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "22.1.0",
|
|
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
|
+
"keywords": [
|
|
6
|
+
"angular",
|
|
7
|
+
"dialog",
|
|
8
|
+
"modal",
|
|
9
|
+
"confirm",
|
|
10
|
+
"alert",
|
|
11
|
+
"popup",
|
|
12
|
+
"accessible",
|
|
13
|
+
"signals",
|
|
14
|
+
"themeable",
|
|
15
|
+
"css-variables",
|
|
16
|
+
"ui",
|
|
17
|
+
"library"
|
|
18
|
+
],
|
|
19
|
+
"homepage": "https://su-labs.dev/",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Yevheniy Alekseyev",
|
|
22
|
+
"email": "yev.alekseyev@gmail.com",
|
|
23
|
+
"url": "https://github.com/Greezaaa"
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/Greezaaa/settings-utils-lib.git",
|
|
28
|
+
"directory": "projects/su-labs/dialog"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/Greezaaa/settings-utils-lib/issues"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"@angular/common": "^22.0.0",
|
|
35
|
+
"@angular/core": "^22.0.0"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@su-labs/core": "1.5.0",
|
|
39
|
+
"tslib": "^2.3.0"
|
|
40
|
+
},
|
|
41
|
+
"sideEffects": false,
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"module": "fesm2022/su-labs-dialog.mjs",
|
|
44
|
+
"typings": "types/su-labs-dialog.d.ts",
|
|
45
|
+
"exports": {
|
|
46
|
+
"./package.json": {
|
|
47
|
+
"default": "./package.json"
|
|
48
|
+
},
|
|
49
|
+
".": {
|
|
50
|
+
"types": "./types/su-labs-dialog.d.ts",
|
|
51
|
+
"default": "./fesm2022/su-labs-dialog.mjs"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"type": "module"
|
|
6
55
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
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, SuDialogSize } from "@su-labs/core/dialog";
|
|
4
|
+
/**
|
|
5
|
+
* Angular service for dialogs: a thin wrapper around the framework-agnostic `SuDialogController` from
|
|
6
|
+
* `@su-labs/core/dialog` that exposes the dialog on screen as a signal. Put `<su-lib-dialog />` once in the app's
|
|
7
|
+
* shell to show them.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SuDialogService implements OnDestroy {
|
|
10
|
+
private readonly controller;
|
|
11
|
+
private readonly currentDialog;
|
|
12
|
+
private readonly unsubscribe;
|
|
13
|
+
/** The dialog on screen, or null */
|
|
14
|
+
readonly current: import("@angular/core").Signal<SuDialog$1 | null>;
|
|
15
|
+
/** Defaults for every dialog from now on, e.g. the button labels in the page's language */
|
|
16
|
+
configure(config: SuDialogConfig$1): void;
|
|
17
|
+
/**
|
|
18
|
+
* Opens a dialog (or queues it behind the one on screen).
|
|
19
|
+
* @returns Whether it was accepted
|
|
20
|
+
*/
|
|
21
|
+
open(options: SuDialogOptions$1): Promise<boolean>;
|
|
22
|
+
/** A question with accept and cancel buttons; resolves with whether it was accepted */
|
|
23
|
+
confirm(options: Omit<SuDialogOptions$1, 'kind'>): Promise<boolean>;
|
|
24
|
+
/** A message with one button; resolves once it's closed */
|
|
25
|
+
alert(options: Omit<SuDialogOptions$1, 'kind'>): Promise<void>;
|
|
26
|
+
/** Closes the dialog on screen with its answer; the component calls it for the buttons, Escape and the backdrop */
|
|
27
|
+
close(accepted: boolean): void;
|
|
28
|
+
ngOnDestroy(): void;
|
|
29
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuDialogService, never>;
|
|
30
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Shows the dialogs of `SuDialogService`, on the native `<dialog>` element: it sits above the page, keeps keyboard
|
|
34
|
+
* focus inside, and closes with Escape (and a click outside, when the dialog is dismissible) as cancel. The body may
|
|
35
|
+
* be HTML; Angular removes anything unsafe from it. Place it once, e.g. at the end of the app's shell.
|
|
36
|
+
*/
|
|
37
|
+
export declare class SuDialogComponent {
|
|
38
|
+
protected readonly service: SuDialogService;
|
|
39
|
+
protected readonly dialog: import("@angular/core").Signal<import("@su-labs/dialog").SuDialog | null>;
|
|
40
|
+
private readonly element;
|
|
41
|
+
constructor();
|
|
42
|
+
/** Escape: the browser would close the dialog by itself; it closes as cancel only when dismissible */
|
|
43
|
+
protected onCancel(event: Event): void;
|
|
44
|
+
/** A click on the dialog element itself (not its content) is a click on the backdrop around it */
|
|
45
|
+
protected onClick(event: MouseEvent): void;
|
|
46
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SuDialogComponent, never>;
|
|
47
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SuDialogComponent, "su-lib-dialog", never, {}, {}, never, never, true, never>;
|
|
48
|
+
}
|
|
49
|
+
export type { SuDialog, SuDialogBackdrop, SuDialogConfig, SuDialogImage, SuDialogKind, SuDialogOptions, SuDialogSize };
|