ngwr 16.4.0 → 16.5.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/charts/bar-chart/styles/_index.scss +494 -305
- package/charts/boxplot-chart/styles/_index.scss +114 -48
- package/charts/bullet-chart/styles/_index.scss +113 -42
- package/charts/calendar-heatmap/styles/_index.scss +111 -20
- package/charts/candlestick-chart/styles/_index.scss +61 -26
- package/charts/chart-legend/styles/_index.scss +119 -1
- package/charts/core/styles/_index.scss +201 -5
- package/charts/donut-chart/styles/_index.scss +76 -21
- package/charts/funnel-chart/styles/_index.scss +66 -38
- package/charts/gauge/styles/_index.scss +12 -1
- package/charts/heatmap-chart/styles/_index.scss +90 -53
- package/charts/line-chart/styles/_index.scss +143 -139
- package/charts/meter-group/styles/_index.scss +87 -25
- package/charts/radar-chart/styles/_index.scss +82 -40
- package/charts/scatter-chart/styles/_index.scss +117 -44
- package/charts/sparkline/styles/_index.scss +7 -1
- package/charts/treemap-chart/styles/_index.scss +94 -42
- package/charts/waterfall-chart/styles/_index.scss +150 -87
- package/color-picker/styles/_index.scss +7 -3
- package/copy-value/styles/_index.scss +21 -2
- package/date-stamp/styles/_index.scss +2 -1
- package/dialog/styles/_index.scss +6 -0
- package/drawer/styles/_index.scss +5 -1
- package/fesm2022/ngwr-carousel-testing.mjs +4 -1
- package/fesm2022/ngwr-carousel-testing.mjs.map +1 -1
- package/fesm2022/ngwr-carousel.mjs +21 -2
- package/fesm2022/ngwr-carousel.mjs.map +1 -1
- package/fesm2022/ngwr-cascader-testing.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +48 -4
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs +16 -14
- package/fesm2022/ngwr-charts-bar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bar-chart.mjs +399 -141
- package/fesm2022/ngwr-charts-bar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs +19 -5
- package/fesm2022/ngwr-charts-boxplot-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-boxplot-chart.mjs +250 -56
- package/fesm2022/ngwr-charts-boxplot-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-bullet-chart.mjs +118 -18
- package/fesm2022/ngwr-charts-bullet-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +266 -46
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs +21 -10
- package/fesm2022/ngwr-charts-candlestick-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-candlestick-chart.mjs +319 -72
- package/fesm2022/ngwr-charts-candlestick-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-chart-legend.mjs +211 -9
- package/fesm2022/ngwr-charts-chart-legend.mjs.map +1 -1
- package/fesm2022/ngwr-charts-core.mjs +299 -18
- package/fesm2022/ngwr-charts-core.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-donut-chart.mjs +206 -27
- package/fesm2022/ngwr-charts-donut-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-funnel-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-funnel-chart.mjs +113 -10
- package/fesm2022/ngwr-charts-funnel-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-gauge.mjs +98 -12
- package/fesm2022/ngwr-charts-gauge.mjs.map +1 -1
- package/fesm2022/ngwr-charts-heatmap-chart.mjs +226 -31
- package/fesm2022/ngwr-charts-heatmap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart-testing.mjs +16 -4
- package/fesm2022/ngwr-charts-line-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-line-chart.mjs +407 -172
- package/fesm2022/ngwr-charts-line-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group-testing.mjs +4 -4
- package/fesm2022/ngwr-charts-meter-group-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-meter-group.mjs +223 -31
- package/fesm2022/ngwr-charts-meter-group.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs +2 -1
- package/fesm2022/ngwr-charts-radar-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-radar-chart.mjs +255 -66
- package/fesm2022/ngwr-charts-radar-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs +39 -18
- package/fesm2022/ngwr-charts-scatter-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-scatter-chart.mjs +431 -53
- package/fesm2022/ngwr-charts-scatter-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-sparkline.mjs +19 -8
- package/fesm2022/ngwr-charts-sparkline.mjs.map +1 -1
- package/fesm2022/ngwr-charts-treemap-chart.mjs +253 -44
- package/fesm2022/ngwr-charts-treemap-chart.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs +15 -7
- package/fesm2022/ngwr-charts-waterfall-chart-testing.mjs.map +1 -1
- package/fesm2022/ngwr-charts-waterfall-chart.mjs +151 -23
- package/fesm2022/ngwr-charts-waterfall-chart.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +44 -4
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu-testing.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +47 -19
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value-testing.mjs +5 -1
- package/fesm2022/ngwr-copy-value-testing.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +38 -2
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +56 -8
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +13 -5
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +19 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +35 -6
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +1 -0
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-graph.mjs +81 -13
- package/fesm2022/ngwr-graph.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +5 -0
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +5 -0
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +5 -0
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +5 -0
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +5 -0
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +5 -0
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +5 -0
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +5 -0
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +5 -0
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +5 -0
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +5 -0
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +5 -0
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +5 -0
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +5 -0
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +5 -0
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +5 -0
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +5 -0
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +5 -0
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +5 -0
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +5 -0
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +5 -0
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +20 -3
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +21 -2
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs +4 -1
- package/fesm2022/ngwr-popconfirm-testing.mjs.map +1 -1
- package/fesm2022/ngwr-popconfirm.mjs +41 -5
- package/fesm2022/ngwr-popconfirm.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +67 -12
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +2 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +2 -0
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-tour.mjs +14 -9
- package/fesm2022/ngwr-tour.mjs.map +1 -1
- package/fesm2022/ngwr-tree-testing.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +49 -16
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +16 -9
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/i18n/ar.json +5 -0
- package/i18n/cs.json +5 -0
- package/i18n/de.json +5 -0
- package/i18n/en.json +5 -0
- package/i18n/es.json +5 -0
- package/i18n/fr.json +5 -0
- package/i18n/he.json +5 -0
- package/i18n/hi.json +5 -0
- package/i18n/id.json +5 -0
- package/i18n/it.json +5 -0
- package/i18n/ja.json +5 -0
- package/i18n/ko.json +5 -0
- package/i18n/nl.json +5 -0
- package/i18n/pl.json +5 -0
- package/i18n/pt.json +5 -0
- package/i18n/ru.json +5 -0
- package/i18n/sv.json +5 -0
- package/i18n/tr.json +5 -0
- package/i18n/uk.json +5 -0
- package/i18n/vi.json +5 -0
- package/i18n/zh-TW.json +5 -0
- package/i18n/zh.json +5 -0
- package/llms-full.txt +8 -8
- package/llms.txt +7 -3
- package/package.json +1 -1
- package/popconfirm/styles/_index.scss +6 -0
- package/popover/styles/_index.scss +24 -13
- package/schematics/use/symbol-map.json +1 -0
- package/skills/ngwr/references/catalog.md +1 -1
- package/tour/styles/_index.scss +6 -0
- package/types/ngwr-carousel-testing.d.ts +6 -4
- package/types/ngwr-carousel.d.ts +14 -3
- package/types/ngwr-cascader-testing.d.ts +4 -3
- package/types/ngwr-cascader.d.ts +27 -3
- package/types/ngwr-charts-bar-chart-testing.d.ts +15 -13
- package/types/ngwr-charts-bar-chart.d.ts +220 -48
- package/types/ngwr-charts-boxplot-chart-testing.d.ts +9 -2
- package/types/ngwr-charts-boxplot-chart.d.ts +110 -19
- package/types/ngwr-charts-bullet-chart.d.ts +72 -12
- package/types/ngwr-charts-calendar-heatmap.d.ts +119 -15
- package/types/ngwr-charts-candlestick-chart-testing.d.ts +19 -9
- package/types/ngwr-charts-candlestick-chart.d.ts +195 -62
- package/types/ngwr-charts-chart-legend.d.ts +142 -5
- package/types/ngwr-charts-core.d.ts +259 -21
- package/types/ngwr-charts-donut-chart-testing.d.ts +11 -5
- package/types/ngwr-charts-donut-chart.d.ts +124 -16
- package/types/ngwr-charts-funnel-chart.d.ts +62 -6
- package/types/ngwr-charts-gauge-testing.d.ts +5 -1
- package/types/ngwr-charts-gauge.d.ts +72 -10
- package/types/ngwr-charts-heatmap-chart.d.ts +103 -20
- package/types/ngwr-charts-line-chart-testing.d.ts +16 -2
- package/types/ngwr-charts-line-chart.d.ts +215 -86
- package/types/ngwr-charts-meter-group.d.ts +96 -7
- package/types/ngwr-charts-radar-chart-testing.d.ts +14 -3
- package/types/ngwr-charts-radar-chart.d.ts +148 -28
- package/types/ngwr-charts-scatter-chart-testing.d.ts +22 -10
- package/types/ngwr-charts-scatter-chart.d.ts +188 -18
- package/types/ngwr-charts-sparkline.d.ts +26 -4
- package/types/ngwr-charts-treemap-chart.d.ts +121 -23
- package/types/ngwr-charts-waterfall-chart-testing.d.ts +8 -1
- package/types/ngwr-charts-waterfall-chart.d.ts +108 -21
- package/types/ngwr-color-picker.d.ts +27 -0
- package/types/ngwr-context-menu-testing.d.ts +10 -9
- package/types/ngwr-context-menu.d.ts +17 -0
- package/types/ngwr-copy-value.d.ts +8 -0
- package/types/ngwr-date-picker.d.ts +34 -2
- package/types/ngwr-dialog.d.ts +30 -10
- package/types/ngwr-drawer.d.ts +32 -1
- package/types/ngwr-dropdown-testing.d.ts +8 -5
- package/types/ngwr-dropdown.d.ts +29 -6
- package/types/ngwr-graph.d.ts +22 -6
- package/types/ngwr-lightbox.d.ts +15 -0
- package/types/ngwr-overlay.d.ts +16 -1
- package/types/ngwr-popconfirm-testing.d.ts +11 -2
- package/types/ngwr-popconfirm.d.ts +28 -1
- package/types/ngwr-popover.d.ts +59 -9
- package/types/ngwr-table.d.ts +1 -1
- package/types/ngwr-tour.d.ts +21 -2
- package/types/ngwr-tree-testing.d.ts +1 -2
- package/types/ngwr-tree.d.ts +33 -2
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr-window.d.ts +14 -11
- package/window/styles/_index.scss +5 -10
package/fesm2022/ngwr-dialog.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { Directionality } from "@angular/cdk/bidi";
|
|
|
7
7
|
import { WrButton } from "ngwr/button";
|
|
8
8
|
import { ScrollStrategyOptions } from "@angular/cdk/overlay";
|
|
9
9
|
import { ComponentPortal } from "@angular/cdk/portal";
|
|
10
|
-
import { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFollowDirection } from "ngwr/overlay";
|
|
10
|
+
import { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFocusOverlay, wrFollowDirection } from "ngwr/overlay";
|
|
11
11
|
import { ConfigurableFocusTrapFactory, FocusMonitor } from "@angular/cdk/a11y";
|
|
12
12
|
import { ReplaySubject } from "rxjs";
|
|
13
13
|
import { WrMeta } from "ngwr/meta";
|
|
@@ -370,6 +370,7 @@ var WrDialogConfirm = class WrDialogConfirm {
|
|
|
370
370
|
intent = this.data.intent ?? null;
|
|
371
371
|
color = this.data.confirmColor ?? (this.alert || !this.intent ? "primary" : INTENT_COLORS[this.intent] ?? "primary");
|
|
372
372
|
danger = this.color === "danger";
|
|
373
|
+
focusInitial = this.data.focusInitial === true;
|
|
373
374
|
confirmLabel = useI18nText(signal(this.data.confirmLabel ?? null), "common.ok", "OK");
|
|
374
375
|
cancelLabel = useI18nText(signal(this.data.cancelLabel ?? null), "common.cancel", "Cancel");
|
|
375
376
|
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
@@ -391,7 +392,7 @@ var WrDialogConfirm = class WrDialogConfirm {
|
|
|
391
392
|
classAttribute: "wr-dialog-confirm"
|
|
392
393
|
},
|
|
393
394
|
ngImport: i0,
|
|
394
|
-
template: "<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n
|
|
395
|
+
template: "<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n Under `autoFocus: 'first-tabbable'` initial focus sits on the safe answer of a\n danger question and on the confirm button otherwise, through the\n `cdkFocusInitial` the focus trap already reads. An alert has one button, and\n it takes the focus. In the other modes none of them is marked.\n-->\n<div wrDialogFooter>\n @if (alert) {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--ok\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial ? '' : null\"\n (click)=\"ref.close()\"\n >\n {{ confirmLabel() }}\n </button>\n } @else {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--cancel\"\n [attr.cdkFocusInitial]=\"focusInitial && danger ? '' : null\"\n (click)=\"ref.close(false)\"\n >\n {{ cancelLabel() }}\n </button>\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--confirm\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial && !danger ? '' : null\"\n (click)=\"ref.close(true)\"\n >\n {{ confirmLabel() }}\n </button>\n }\n</div>\n",
|
|
395
396
|
dependencies: [
|
|
396
397
|
{
|
|
397
398
|
kind: "component",
|
|
@@ -452,7 +453,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
452
453
|
class: "wr-dialog-confirm",
|
|
453
454
|
"[class.wr-dialog-confirm--danger]": "danger"
|
|
454
455
|
},
|
|
455
|
-
template: "<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n
|
|
456
|
+
template: "<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n Under `autoFocus: 'first-tabbable'` initial focus sits on the safe answer of a\n danger question and on the confirm button otherwise, through the\n `cdkFocusInitial` the focus trap already reads. An alert has one button, and\n it takes the focus. In the other modes none of them is marked.\n-->\n<div wrDialogFooter>\n @if (alert) {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--ok\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial ? '' : null\"\n (click)=\"ref.close()\"\n >\n {{ confirmLabel() }}\n </button>\n } @else {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--cancel\"\n [attr.cdkFocusInitial]=\"focusInitial && danger ? '' : null\"\n (click)=\"ref.close(false)\"\n >\n {{ cancelLabel() }}\n </button>\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--confirm\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial && !danger ? '' : null\"\n (click)=\"ref.close(true)\"\n >\n {{ confirmLabel() }}\n </button>\n }\n</div>\n"
|
|
456
457
|
}]
|
|
457
458
|
}],
|
|
458
459
|
ctorParameters: () => []
|
|
@@ -545,7 +546,7 @@ var WrDialog = class WrDialog {
|
|
|
545
546
|
overlayRef.detachments().subscribe(() => labelSync.destroy());
|
|
546
547
|
const trap = this.focusTrapFactory.create(host);
|
|
547
548
|
dialogRef.focusTrap = trap;
|
|
548
|
-
trap.
|
|
549
|
+
wrFocusOverlay(host, trap, this.autoFocusOf(options), this.parentInjector);
|
|
549
550
|
}
|
|
550
551
|
return dialogRef;
|
|
551
552
|
}
|
|
@@ -572,12 +573,19 @@ var WrDialog = class WrDialog {
|
|
|
572
573
|
alert: true
|
|
573
574
|
});
|
|
574
575
|
}
|
|
576
|
+
autoFocusOf(options) {
|
|
577
|
+
return options.autoFocus ?? this.defaults.autoFocus ?? "dialog";
|
|
578
|
+
}
|
|
575
579
|
ask(options, data) {
|
|
580
|
+
const focusInitial = this.autoFocusOf(options) === "first-tabbable";
|
|
576
581
|
const ref = this.open(WrDialogConfirm, {
|
|
577
582
|
...options,
|
|
578
583
|
role: "alertdialog",
|
|
579
584
|
closable: false,
|
|
580
|
-
data
|
|
585
|
+
data: {
|
|
586
|
+
...data,
|
|
587
|
+
focusInitial
|
|
588
|
+
}
|
|
581
589
|
});
|
|
582
590
|
const unhook = this.destroyRef.onDestroy(() => ref.close());
|
|
583
591
|
ref.closed.subscribe({ complete: unhook });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ngwr-dialog.mjs","names":["uid"],"sources":["../../../projects/lib/dialog/dialog-ref.ts","../../../projects/lib/dialog/directives/dialog-title.ts","../../../projects/lib/dialog/directives/dialog-content.ts","../../../projects/lib/dialog/directives/dialog-footer.ts","../../../projects/lib/dialog/tokens/dialog-defaults.token.ts","../../../projects/lib/dialog/tokens/dialog-data.token.ts","../../../projects/lib/dialog/tokens/dialog-ref.token.ts","../../../projects/lib/dialog/directives/dialog-close.ts","../../../projects/lib/dialog/confirm/dialog-confirm.ts","../../../projects/lib/dialog/confirm/dialog-confirm.html","../../../projects/lib/dialog/dialog.ts","../../../projects/lib/dialog/with-dialog.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, FocusMonitor } from '@angular/cdk/a11y';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { type ComponentRef, type EffectRef, type Injector, type Signal, effect, untracked } from '@angular/core';\n\nimport { ReplaySubject } from 'rxjs';\n\nimport { wrRestoreFocus } from 'ngwr/utils';\n\n/**\n * Handle returned by `WrDialog.open()`.\n *\n * Wraps the underlying `OverlayRef` and tracks the close result. It is also\n * provided inside the dialog's own injector, so the projected content can\n * inject it and close itself — the counterpart to `[wrDialogClose]` when the\n * close is programmatic (after a save succeeds, say) rather than a click.\n *\n * @example\n * ```ts\n * // Caller side.\n * const ref = dialog.open<ConfirmComponent, boolean>(ConfirmComponent);\n * const result = await ref.awaitClose(); // boolean | undefined\n * ```\n *\n * @example\n * ```ts\n * // Content side — the dialog closes itself.\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject(WrDialogRef);\n *\n * save(): void {\n * this.store.save();\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport class WrDialogRef<C, R = unknown> {\n /**\n * Emits the close result once and completes.\n *\n * A `ReplaySubject`, not a plain `Subject`, so the result survives a late\n * subscriber: content can close itself before `open()` has even returned, and\n * `awaitClose()` may be called long after the dismissal — both would otherwise\n * see only `complete` and resolve `undefined`.\n */\n readonly closed = new ReplaySubject<R | undefined>(1);\n\n /** @internal */\n componentRef: ComponentRef<C> | null = null;\n\n /** @internal */\n focusTrap: ConfigurableFocusTrap | null = null;\n\n /** @internal */\n previouslyFocused: HTMLElement | null = null;\n\n private readonly watchers: EffectRef[] = [];\n\n private readonly focusMonitor: FocusMonitor | null;\n\n /**\n * @param _overlayRef the overlay the dialog is mounted in.\n * @param injector what `closeWhen()` runs its watcher in. `WrDialog.open()`\n * passes the root injector; a ref built without one cannot watch.\n */\n constructor(\n private readonly _overlayRef: OverlayRef,\n private readonly injector?: Injector\n ) {\n // Resolved now: the injector may be gone by the time the dialog closes.\n this.focusMonitor = injector?.get(FocusMonitor, null) ?? null;\n }\n\n /** The instantiated dialog component. */\n get componentInstance(): C {\n if (!this.componentRef) {\n throw new Error('WrDialogRef: component not yet attached');\n }\n return this.componentRef.instance;\n }\n\n private isClosed = false;\n\n /** Close the dialog, optionally returning a result. */\n close(result?: R): void {\n if (this.isClosed) return;\n this.isClosed = true;\n for (const watcher of this.watchers.splice(0)) watcher.destroy();\n this.closed.next(result);\n this.closed.complete();\n // Content that closes itself while constructing gets here with\n // `OverlayRef.attach()` still on the stack — `componentRef` is assigned\n // only once attach returns. Disposing mid-attach leaves the CDK writing to\n // a detached host, so let the current task finish first.\n if (!this.componentRef) {\n queueMicrotask(() => this.teardown());\n return;\n }\n this.teardown();\n }\n\n private teardown(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this._overlayRef.dispose();\n // Drop the destroyed component so a retained ref doesn't pin its instance,\n // host element and view in memory.\n this.componentRef = null;\n // Restore focus after disposal so the trigger is reachable again.\n if (restore && typeof restore.focus === 'function') {\n wrRestoreFocus(restore, this.focusMonitor);\n }\n }\n\n /**\n * Close the dialog once `source` reads `true`, with `result` - `undefined`\n * when omitted, which is what every dismissal closes with. A source that is\n * already `true` closes it on the next change detection, after the attach\n * has finished.\n *\n * The watcher belongs to the dialog: it runs in the root injector, so the\n * caller needs no injection context, and it is destroyed when the dialog\n * closes by any path, so a source that turns `true` later does nothing. Each\n * call adds a watcher; the first to fire closes. A closed dialog ignores the\n * call.\n *\n * @example\n * ```ts\n * const saved = computed(() => this.save.status() === 'resolved');\n * this.dialog.open(SavingComponent).closeWhen(saved, 'saved');\n * ```\n */\n closeWhen(source: Signal<boolean>, result?: R): void {\n if (this.isClosed) return;\n if (!this.injector) {\n throw new Error('WrDialogRef: closeWhen() needs a ref opened by WrDialog, which carries the injector');\n }\n this.watchers.push(\n effect(\n () => {\n if (source()) untracked(() => this.close(result));\n },\n { injector: this.injector }\n )\n );\n }\n\n /** Resolves with the close result when the dialog is dismissed. */\n awaitClose(): Promise<R | undefined> {\n return new Promise(resolve => {\n this.closed.subscribe({\n next: value => resolve(value),\n complete: () => resolve(undefined),\n });\n });\n }\n\n /** Underlying overlay ref — escape hatch for advanced cases. */\n get overlayRef(): OverlayRef {\n return this._overlayRef;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, inject } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nlet uid = 0;\n\n/**\n * Styles a dialog title row. Use on a heading inside an opened dialog.\n * Auto-assigns an `id` so the dialog panel can reference it via\n * `aria-labelledby`.\n *\n * @example\n * ```html\n * <h2 wrDialogTitle>Confirm delete</h2>\n * ```\n */\n@Directive({\n selector: '[wrDialogTitle]',\n exportAs: 'wrDialogTitle',\n host: { class: 'wr-dialog__title', '[attr.id]': 'id' },\n})\nexport class WrDialogTitle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /** Generated id used for `aria-labelledby` wiring. */\n readonly id = `wr-dialog-title-${++uid}`;\n\n /** @internal */\n readonly elementRef = inject(ElementRef<HTMLElement>);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { CdkScrollable } from '@angular/cdk/scrolling';\nimport { Directive, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nlet uid = 0;\n\n/**\n * Styles the scrollable body section of a dialog. Auto-assigns an `id` so an\n * `alertdialog` panel can reference it via `aria-describedby`.\n *\n * `CdkScrollable` is a host directive because this element is a real scroll\n * container (`overflow: auto`) and an anchored overlay opened from inside it has\n * to follow its trigger. CDK's `reposition()` strategy listens to\n * `ScrollDispatcher`, which is fed by registered scrollables plus ONE\n * non-capturing `document` listener — and element `scroll` does not bubble, so\n * without the registration a `<wr-select>` halfway down a long dialog form kept\n * its panel pinned to the viewport while the trigger scrolled away. Angular\n * Material carries the same host directive on `MatDialogContent` for the same\n * reason.\n *\n * @example\n * ```html\n * <div wrDialogContent>…body…</div>\n * ```\n */\n@Directive({\n selector: '[wrDialogContent]',\n host: { class: 'wr-dialog__content', '[attr.id]': 'id()' },\n hostDirectives: [CdkScrollable],\n})\nexport class WrDialogContent {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /** The element's id, generated unless given. An `alertdialog` names it in `aria-describedby`. */\n readonly id = input(`wr-dialog-content-${++uid}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Footer row, typically holding action buttons.\n *\n * @example\n * ```html\n * <div wrDialogFooter align=\"end\">\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"danger\" (click)=\"confirm()\">Delete</wr-btn>\n * </div>\n * ```\n */\n@Directive({\n selector: '[wrDialogFooter]',\n host: { class: 'wr-dialog__footer', '[class]': 'classes()' },\n})\nexport class WrDialogFooter {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /**\n * Horizontal alignment of the children.\n *\n * @default 'end'\n */\n readonly align = input<'start' | 'center' | 'end'>('end');\n\n protected readonly classes = computed(() => `wr-dialog__footer wr-dialog__footer--${this.align()}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrDialogDefaults } from '../types';\n\n/** What `withDialog()` provides. @internal */\nexport const WR_DIALOG_DEFAULTS = new InjectionToken<WrDialogDefaults>('WR_DIALOG_DEFAULTS', {\n factory: (): WrDialogDefaults => ({}),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/**\n * Token that exposes the `data` payload passed to `WrDialog.open()`.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * readonly data = inject<ConfirmData>(WR_DIALOG_DATA);\n * }\n * ```\n */\nexport const WR_DIALOG_DATA = new InjectionToken<unknown>('WR_DIALOG_DATA');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrDialogRef } from '../dialog-ref';\n\n/**\n * Token exposing the open dialog's `WrDialogRef` to components and\n * directives rendered inside it (e.g. `[wrDialogClose]`).\n *\n * **Prefer `inject(WrDialogRef)`** — the ref is provided under the class token\n * too, and the class path is the documented one. It already covers both cases\n * you might reach for a token for: `inject(WrDialogRef, { optional: true })`\n * works for content that also renders outside a dialog, and\n * `inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef)` types the\n * generics without a cast.\n *\n * This token is the same object under a second key. It exists for the library's\n * own directives (`[wrDialogClose]`) and for swapping the provider out — a test\n * stub, say — without touching the class.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef);\n *\n * confirm(): void {\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport const WR_DIALOG_REF = new InjectionToken<WrDialogRef<unknown, unknown>>('WR_DIALOG_REF');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrDialogRef } from '../dialog-ref';\nimport { WR_DIALOG_REF } from '../tokens';\n\n/**\n * Closes the dialog when the host element is clicked.\n *\n * Optionally passes a `[wrDialogClose]` value as the close result.\n *\n * @example\n * ```html\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"primary\" [wrDialogClose]=\"true\">Confirm</wr-btn>\n * ```\n */\n@Directive({\n selector: '[wrDialogClose]',\n host: { '(click)': 'onClick()' },\n})\nexport class WrDialogClose<R = unknown> {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /**\n * Value to pass to `close()`. When unset — or used as a bare attribute — the\n * dialog closes with `undefined`.\n */\n readonly result = input<R | undefined, R | undefined | ''>(undefined, {\n alias: 'wrDialogClose',\n // A bare `wrDialogClose` attribute arrives as the empty string; that means\n // \"no result\", not a result of `''`. Matches `wrDrawerClose`.\n transform: value => (value === '' ? undefined : value),\n });\n\n private readonly ref = inject<WrDialogRef<unknown, R>>(WR_DIALOG_REF, { optional: true });\n\n protected onClick(): void {\n this.ref?.close(this.result());\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, inject, signal } from '@angular/core';\n\nimport { WrButton } from 'ngwr/button';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrDialogRef } from '../dialog-ref';\nimport { WrDialogContent, WrDialogFooter, WrDialogTitle } from '../directives';\nimport { WR_DIALOG_DATA } from '../tokens';\nimport type { WrDialogIntent } from '../types';\n\nimport type { WrDialogConfirmData } from './dialog-confirm-data';\n\nconst INTENT_COLORS: Partial<Record<WrDialogIntent, 'danger' | 'warning'>> = { danger: 'danger', warning: 'warning' };\n\n/**\n * The content `WrDialog.confirm()` and `WrDialog.alert()` mount: the dialog's\n * own title, content and footer around two `wr-btn`, or one for an alert. Not\n * exported; the service is the API.\n */\n@Component({\n selector: 'wr-dialog-confirm',\n templateUrl: './dialog-confirm.html',\n imports: [WrButton, WrDialogTitle, WrDialogContent, WrDialogFooter],\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-dialog-confirm',\n '[class.wr-dialog-confirm--danger]': 'danger',\n },\n})\nexport class WrDialogConfirm {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n protected readonly data = inject<WrDialogConfirmData>(WR_DIALOG_DATA);\n protected readonly ref = inject<WrDialogRef<WrDialogConfirm, boolean>>(WrDialogRef);\n\n protected readonly alert = this.data.alert === true;\n protected readonly intent = this.data.intent ?? null;\n // An alert's button dismisses a message, so it never takes the intent's color.\n protected readonly color =\n this.data.confirmColor ?? (this.alert || !this.intent ? 'primary' : (INTENT_COLORS[this.intent] ?? 'primary'));\n protected readonly danger = this.color === 'danger';\n\n protected readonly confirmLabel = useI18nText(signal(this.data.confirmLabel ?? null), 'common.ok', 'OK');\n protected readonly cancelLabel = useI18nText(signal(this.data.cancelLabel ?? null), 'common.cancel', 'Cancel');\n}\n","<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n Initial focus sits on the safe answer of a danger question and on the confirm\n button otherwise, through the `cdkFocusInitial` the focus trap already reads.\n An alert has one button, and it takes the focus.\n-->\n<div wrDialogFooter>\n @if (alert) {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--ok\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"''\"\n (click)=\"ref.close()\"\n >\n {{ confirmLabel() }}\n </button>\n } @else {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--cancel\"\n [attr.cdkFocusInitial]=\"danger ? '' : null\"\n (click)=\"ref.close(false)\"\n >\n {{ cancelLabel() }}\n </button>\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--confirm\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"danger ? null : ''\"\n (click)=\"ref.close(true)\"\n >\n {{ confirmLabel() }}\n </button>\n }\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal, type ComponentType } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n EnvironmentInjector,\n Service,\n Injector,\n PLATFORM_ID,\n type WritableSignal,\n afterEveryRender,\n inject,\n signal,\n} from '@angular/core';\n\nimport { WrI18n } from 'ngwr/i18n';\nimport { WrMeta } from 'ngwr/meta';\nimport { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFollowDirection } from 'ngwr/overlay';\nimport { wrToClassList } from 'ngwr/utils';\n\nimport { WrDialogConfirm } from './confirm/dialog-confirm';\nimport type { WrDialogConfirmData } from './confirm/dialog-confirm-data';\nimport { WrDialogRef } from './dialog-ref';\nimport { WR_DIALOG_DATA, WR_DIALOG_DEFAULTS, WR_DIALOG_REF } from './tokens';\nimport type { WrDialogAlertOptions, WrDialogConfirmOptions, WrDialogOptions } from './types';\n\nconst DEFAULT_PANEL_CLASS = 'wr-dialog-panel';\nconst DEFAULT_BACKDROP_CLASS = 'wr-dialog-backdrop';\n\n/**\n * Opens dialog components in an isolated NGWR overlay.\n *\n * Uses `WR_OVERLAY`, so dialogs render into NGWR's own overlay container\n * and never collide with other CDK consumers (Material, NG-ZORRO, etc.).\n *\n * @example\n * ```ts\n * const dialog = inject(WrDialog);\n *\n * const ref = dialog.open(ConfirmComponent, {\n * data: { message: 'Delete this item?' },\n * width: '24rem',\n * });\n *\n * const ok = await ref.awaitClose();\n * if (ok) remove();\n * ```\n *\n * @see https://ngwr.dev/reference/components/dialog\n */\n@Service()\nexport class WrDialog {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly parentInjector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly i18n = inject(WrI18n, { optional: true });\n private readonly dir = inject(Directionality, { optional: true });\n // Resolvable wherever the CDK's own `Overlay` is — it injects the same thing\n // to implement `disposeOnNavigation`.\n private readonly location = inject(Location);\n private readonly destroyRef = inject(DestroyRef);\n private readonly defaults = inject(WR_DIALOG_DEFAULTS);\n private readonly order = inject(WrOverlayOrder);\n\n open<C, R = unknown, D = unknown>(component: ComponentType<C>, options: WrDialogOptions<D> = {}): WrDialogRef<C, R> {\n const overlayRef: OverlayRef = this.overlay.create({\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.scrollStrategies.block(),\n hasBackdrop: true,\n backdropClass: DEFAULT_BACKDROP_CLASS,\n panelClass: wrToClassList(DEFAULT_PANEL_CLASS, options.panelClass),\n width: options.width,\n maxWidth: options.maxWidth,\n });\n\n // The CDK captures the direction as a string at create and never looks\n // again, so an app that flips while a dialog is up leaves the panel behind.\n // Nothing here derives from it — the box is centred and its x offset is\n // empty, so `apply()`'s RTL branch moves nothing — but the `dir` attribute\n // is what the dialog's own logical CSS and every ngwr control inside it\n // resolve `start` and `end` against, so it has to follow. No teardown kept:\n // the follower ends on the ref's own `detachments()`, which every dismissal\n // path goes through, and each `open()` creates a fresh ref of its own.\n wrFollowDirection(overlayRef, this.dir, this.parentInjector);\n\n const dialogRef = new WrDialogRef<C, R>(overlayRef, this.parentInjector);\n\n if (this.isBrowser) {\n const active = document.activeElement;\n dialogRef.previouslyFocused = active instanceof HTMLElement ? active : null;\n }\n\n const injector = Injector.create({\n parent: this.parentInjector,\n providers: [\n { provide: WR_DIALOG_DATA, useValue: options.data },\n { provide: WR_DIALOG_REF, useValue: dialogRef },\n // Provided as its own token as well, so dialog content can reach for\n // the familiar `inject(WrDialogRef)` and close itself.\n { provide: WrDialogRef, useValue: dialogRef },\n ],\n });\n\n const portal = new ComponentPortal(component, null, injector);\n dialogRef.componentRef = overlayRef.attach(portal);\n overlayRef.detachments().subscribe(this.order.add(overlayRef.hostElement, options.toasts));\n\n // Wired BEFORE the panel is decorated, and the order is the fix: everything\n // below attaches attributes, a ✕ and a focus trap to an overlay that is\n // already on screen, so anything that throws in there used to leave an\n // `aria-modal` panel with no dismissal path at all — no ✕, no backdrop\n // handler, no Escape — over the whole application, and no ref for the caller\n // to close it with. A dialog that fails to finish opening must still be one\n // the user can get rid of. Overlay subscriptions complete when the overlay is\n // disposed, so no explicit teardown is required.\n if (options.closeOnBackdropClick !== false) {\n overlayRef.backdropClick().subscribe(() => dialogRef.close());\n }\n if (options.closeOnEscape !== false) {\n overlayRef.keydownEvents().subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n dialogRef.close();\n }\n });\n }\n if (options.closeOnNavigation !== false) {\n this.watchNavigation(overlayRef, dialogRef);\n }\n\n if (this.isBrowser) {\n const host = overlayRef.overlayElement;\n const role = options.role ?? 'dialog';\n host.setAttribute('role', role);\n host.setAttribute('aria-modal', 'true');\n // Built-in dismiss. Appended after the content portal so it paints above\n // it, and marked on the panel so the title reserves the corner gutter.\n if (options.closable !== false) {\n host.classList.add('wr-dialog-panel--closable');\n const label = options.closeLabel ?? this.closeLabel();\n wrAppendOverlayClose(host, 'wr-dialog__close', label, () => dialogRef.close());\n }\n // Wire aria-labelledby to wrDialogTitle's auto-id once content is in DOM.\n // Has to wait for a render, not a microtask: attaching the portal only\n // schedules change detection, so under zoneless CD a microtask runs while\n // the content is still an empty view and the title id doesn't exist yet.\n //\n // And after EVERY render, not just the next one: the title belongs to the\n // caller's component, so an `@if` or a late-arriving heading can replace\n // or remove the element the attribute names. A reference to a node that is\n // no longer there is not a name — the dialog announces as unnamed — so a\n // missing title clears the attribute rather than leaving it dangling.\n //\n // An `alertdialog` is described by its content the same way: the message\n // is the dialog, and it can be conditional too.\n const tabTitle = (options.tabTitle ?? this.defaults.tabTitle) ? this.nameTab(overlayRef) : null;\n const labelSync = afterEveryRender(\n () => {\n const titleEl = host.querySelector<HTMLElement>('[wrDialogTitle], [wr-dialog-title]');\n if (titleEl?.id) host.setAttribute('aria-labelledby', titleEl.id);\n else host.removeAttribute('aria-labelledby');\n tabTitle?.set((titleEl?.textContent ?? '').replace(/\\s+/g, ' ').trim());\n if (role !== 'alertdialog') return;\n const contentEl = host.querySelector<HTMLElement>('[wrDialogContent], [wr-dialog-content]');\n if (contentEl?.id) host.setAttribute('aria-describedby', contentEl.id);\n else host.removeAttribute('aria-describedby');\n },\n { injector: this.parentInjector }\n );\n // The hook is bound to the root injector, so it outlives the dialog unless\n // it is torn down with it. `detachments()` fires on dispose, which is the\n // one path every dismissal goes through.\n overlayRef.detachments().subscribe(() => labelSync.destroy());\n // Trap focus inside the dialog and move initial focus in.\n const trap = this.focusTrapFactory.create(host);\n dialogRef.focusTrap = trap;\n void trap.focusInitialElementWhenReady();\n }\n\n return dialogRef;\n }\n\n /**\n * Ask a yes-or-no question and get the answer: `true` only when the user\n * pressed the confirm button. Escape, the backdrop, the cancel button, a\n * navigation and the application being torn down all resolve `false`. The\n * promise settles exactly once and never rejects, so the caller needs no\n * `catch` and no cleanup.\n *\n * The dialog is `role=\"alertdialog\"`, named by `title` and described by\n * `message`, with no corner dismiss: the two buttons are the answers. Labels\n * fall back to the `common.ok` and `common.cancel` catalog keys. With\n * `confirmColor: 'danger'` initial focus is on the cancel button; otherwise it\n * is on the confirm button. Focus returns to the opener on close, as it does\n * for `open()`.\n *\n * `intent` puts an icon before the title, and `danger` or `warning` color the\n * confirm button unless `confirmColor` is set, so a `danger` question also\n * starts on the cancel button.\n *\n * On the server nothing can answer, so it resolves `false` at once and opens\n * nothing.\n *\n * @example\n * ```ts\n * const ok = await dialog.confirm({\n * title: 'Delete this item?',\n * message: 'This cannot be undone.',\n * confirmLabel: 'Delete',\n * intent: 'danger',\n * });\n * if (ok) remove();\n * ```\n */\n async confirm(options: WrDialogConfirmOptions): Promise<boolean> {\n if (!this.isBrowser) return false;\n const { title, message, confirmLabel, cancelLabel, confirmColor, intent, ...rest } = options;\n return (await this.ask(rest, { title, message, confirmLabel, cancelLabel, confirmColor, intent })) === true;\n }\n\n /**\n * Show a message with one button and wait until the user has dismissed it.\n * The button, Escape, the backdrop, a navigation and the application being\n * torn down all resolve the promise, which settles exactly once with no\n * value and never rejects.\n *\n * The dialog is `confirm()`'s with one button: `role=\"alertdialog\"` for every\n * intent, named by `title` and described by `message`, with no corner\n * dismiss. The button takes the initial focus and its label falls back to the\n * `common.ok` catalog key. `intent` puts an icon before the title.\n *\n * On the server it resolves at once and opens nothing.\n *\n * @example\n * ```ts\n * await dialog.alert({\n * title: 'Range too large',\n * message: 'Pick at most 31 days to export.',\n * okLabel: 'Close',\n * intent: 'danger',\n * });\n * ```\n */\n async alert(options: WrDialogAlertOptions): Promise<void> {\n if (!this.isBrowser) return;\n const { title, message, okLabel, intent, ...rest } = options;\n await this.ask(rest, { title, message, confirmLabel: okLabel, intent, alert: true });\n }\n\n private ask(options: WrDialogOptions, data: WrDialogConfirmData): Promise<boolean | undefined> {\n const ref = this.open<WrDialogConfirm, boolean, WrDialogConfirmData>(WrDialogConfirm, {\n ...options,\n role: 'alertdialog',\n closable: false,\n data,\n });\n // The root injector going away takes the overlay container with it and\n // completes nothing, which would leave this promise pending for good.\n const unhook = this.destroyRef.onDestroy(() => ref.close());\n ref.closed.subscribe({ complete: unhook });\n return ref.awaitClose();\n }\n\n /**\n * Tie the dialog's lifetime to the URL it was opened on.\n *\n * Nothing else does. The overlay belongs to a root service and is dismissed\n * only by the backdrop, Escape or an explicit `close()`, so pressing Back\n * swapped the routed view underneath and left the modal pane, its backdrop and\n * its focus trap sitting over a page the user never opened them on.\n *\n * `onUrlChange`, not `Location.subscribe()` — which is what CDK's own\n * `disposeOnNavigation` uses: `subscribe` fires on popstate alone, so an\n * in-app `router.navigate()` left the dialog standing. And `dialogRef.close()`\n * rather than disposing the overlay behind the ref's back, which would never\n * emit `closed`, never destroy the focus trap, and leave `awaitClose()`\n * pending forever.\n */\n private watchNavigation<C, R>(overlayRef: OverlayRef, dialogRef: WrDialogRef<C, R>): void {\n const stopWatching = this.location.onUrlChange(() => dialogRef.close());\n // Unhooked a microtask late, because `Location` notifies its listeners with\n // a `forEach` and unregistering splices the array it is iterating: removing\n // ours synchronously from inside the notification would shift the next entry\n // into the slot forEach has already passed, and a SECOND stacked dialog\n // would be skipped and left behind.\n overlayRef.detachments().subscribe(() => queueMicrotask(stopWatching));\n }\n\n /**\n * Put the dialog's title in front of the page title for as long as the\n * overlay is attached, and hand back where to write that title.\n *\n * A `titlePrefix` layer rather than a composed `title`: the page title stays\n * whatever the layers under it resolve to, so a page that retitles itself\n * under an open dialog is followed, and closing restores nothing, it only\n * removes the layer. Stacked dialogs each hold a layer and the top one wins.\n *\n * `WrMeta` is resolved here and not injected with the service: constructing\n * it applies its defaults to `<head>`, which an app that never asked for\n * `tabTitle` must not pay for.\n */\n private nameTab(overlayRef: OverlayRef): WritableSignal<string> {\n const heading = signal('');\n const layer = this.parentInjector.get(WrMeta).bind(() => (heading() ? { titlePrefix: heading() } : {}));\n overlayRef.detachments().subscribe(() => layer.pop());\n return heading;\n }\n\n /**\n * The dismiss button's accessible name.\n *\n * Two failure modes, and resolving PER OPEN is what covers both. `t()` hands\n * back the KEY on a miss, and `WrI18n` is root-provided with an empty catalog\n * by default, so an app that never configured i18n named its dismiss button\n * \"dialog.close\" — a name axe cannot fault, because a name is present, and a\n * screen reader reads out verbatim. Resolving once at injection time fixed\n * that but froze the answer: this is a root service, constructed before an\n * async catalog has loaded, so a localized app got the English fallback on\n * every dialog it ever opened.\n */\n private closeLabel(): string {\n const resolved = this.i18n?.t('dialog.close');\n return !resolved || resolved === 'dialog.close' ? 'Close dialog' : resolved;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { WR_DIALOG_DEFAULTS } from './tokens';\nimport type { WrDialogDefaults } from './types';\n\n/**\n * App-wide dialog defaults, as a feature of `provideWr()`: today `tabTitle`,\n * so every dialog names the browser tab while it is open. The same option on\n * `open()` or `confirm()` still wins.\n *\n * Bootstrap only: `WrDialog` is root-provided and reads it once, from the root\n * injector, so in a route's `providers` it changes nothing.\n *\n * @example\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withDialog } from 'ngwr/dialog';\n *\n * bootstrapApplication(App, {\n * providers: [provideWr(withDialog({ tabTitle: true }))],\n * });\n * ```\n */\nexport function withDialog(defaults: WrDialogDefaults): WrFeature<'dialog'> {\n return wrFeature('dialog', [{ provide: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,OAAO,IAAI,WAAU;CACvB;CAiBQ,gBAAsB,YAAwB,WAA4B;EAChF,MAAM,eAAe,KAAK,SAAS,kBAAkB,UAAU,MAAK,CAAE;EAMtE,WAAW,YAAW,CAAE,CAAC,gBAAgB,eAAe,YAAY,CAAC;CACvE;CAeQ,QAAQ,YAAsB;EACpC,MAAM,UAAU,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAC1B,MAAM,QAAQ,KAAK,eAAe,IAAI,MAAM,CAAC,CAAC,WAAY,QAAO,IAAK,EAAE,aAAa,QAAO,EAAE,IAAK,CAAA,CAAG;EACtG,WAAW,YAAW,CAAE,CAAC,gBAAgB,MAAM,IAAG,CAAE;EACpD,OAAO;CACT;CAcQ,aAAU;EAChB,MAAM,WAAW,KAAK,MAAM,EAAE,cAAc;EAC5C,OAAO,CAAC,YAAY,aAAa,iBAAiB,iBAAiB;CACrE;CAlRW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAQ,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA,EADpB,MAAA,Q;;;;;;;;AC7BD,SAAgB,WAAW,UAA0B;CACnD,OAAO,UAAU,UAAU,CAAC;EAAE,SAAS;EAAoB,UAAU;CAAQ,CAAE,CAAC;AAClF"}
|
|
1
|
+
{"version":3,"file":"ngwr-dialog.mjs","names":["uid"],"sources":["../../../projects/lib/dialog/dialog-ref.ts","../../../projects/lib/dialog/directives/dialog-title.ts","../../../projects/lib/dialog/directives/dialog-content.ts","../../../projects/lib/dialog/directives/dialog-footer.ts","../../../projects/lib/dialog/tokens/dialog-defaults.token.ts","../../../projects/lib/dialog/tokens/dialog-data.token.ts","../../../projects/lib/dialog/tokens/dialog-ref.token.ts","../../../projects/lib/dialog/directives/dialog-close.ts","../../../projects/lib/dialog/confirm/dialog-confirm.ts","../../../projects/lib/dialog/confirm/dialog-confirm.html","../../../projects/lib/dialog/dialog.ts","../../../projects/lib/dialog/with-dialog.ts"],"sourcesContent":["/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type ConfigurableFocusTrap, FocusMonitor } from '@angular/cdk/a11y';\nimport type { OverlayRef } from '@angular/cdk/overlay';\nimport { type ComponentRef, type EffectRef, type Injector, type Signal, effect, untracked } from '@angular/core';\n\nimport { ReplaySubject } from 'rxjs';\n\nimport { wrRestoreFocus } from 'ngwr/utils';\n\n/**\n * Handle returned by `WrDialog.open()`.\n *\n * Wraps the underlying `OverlayRef` and tracks the close result. It is also\n * provided inside the dialog's own injector, so the projected content can\n * inject it and close itself — the counterpart to `[wrDialogClose]` when the\n * close is programmatic (after a save succeeds, say) rather than a click.\n *\n * @example\n * ```ts\n * // Caller side.\n * const ref = dialog.open<ConfirmComponent, boolean>(ConfirmComponent);\n * const result = await ref.awaitClose(); // boolean | undefined\n * ```\n *\n * @example\n * ```ts\n * // Content side — the dialog closes itself.\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject(WrDialogRef);\n *\n * save(): void {\n * this.store.save();\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport class WrDialogRef<C, R = unknown> {\n /**\n * Emits the close result once and completes.\n *\n * A `ReplaySubject`, not a plain `Subject`, so the result survives a late\n * subscriber: content can close itself before `open()` has even returned, and\n * `awaitClose()` may be called long after the dismissal — both would otherwise\n * see only `complete` and resolve `undefined`.\n */\n readonly closed = new ReplaySubject<R | undefined>(1);\n\n /** @internal */\n componentRef: ComponentRef<C> | null = null;\n\n /** @internal */\n focusTrap: ConfigurableFocusTrap | null = null;\n\n /** @internal */\n previouslyFocused: HTMLElement | null = null;\n\n private readonly watchers: EffectRef[] = [];\n\n private readonly focusMonitor: FocusMonitor | null;\n\n /**\n * @param _overlayRef the overlay the dialog is mounted in.\n * @param injector what `closeWhen()` runs its watcher in. `WrDialog.open()`\n * passes the root injector; a ref built without one cannot watch.\n */\n constructor(\n private readonly _overlayRef: OverlayRef,\n private readonly injector?: Injector\n ) {\n // Resolved now: the injector may be gone by the time the dialog closes.\n this.focusMonitor = injector?.get(FocusMonitor, null) ?? null;\n }\n\n /** The instantiated dialog component. */\n get componentInstance(): C {\n if (!this.componentRef) {\n throw new Error('WrDialogRef: component not yet attached');\n }\n return this.componentRef.instance;\n }\n\n private isClosed = false;\n\n /** Close the dialog, optionally returning a result. */\n close(result?: R): void {\n if (this.isClosed) return;\n this.isClosed = true;\n for (const watcher of this.watchers.splice(0)) watcher.destroy();\n this.closed.next(result);\n this.closed.complete();\n // Content that closes itself while constructing gets here with\n // `OverlayRef.attach()` still on the stack — `componentRef` is assigned\n // only once attach returns. Disposing mid-attach leaves the CDK writing to\n // a detached host, so let the current task finish first.\n if (!this.componentRef) {\n queueMicrotask(() => this.teardown());\n return;\n }\n this.teardown();\n }\n\n private teardown(): void {\n this.focusTrap?.destroy();\n this.focusTrap = null;\n const restore = this.previouslyFocused;\n this.previouslyFocused = null;\n this._overlayRef.dispose();\n // Drop the destroyed component so a retained ref doesn't pin its instance,\n // host element and view in memory.\n this.componentRef = null;\n // Restore focus after disposal so the trigger is reachable again.\n if (restore && typeof restore.focus === 'function') {\n wrRestoreFocus(restore, this.focusMonitor);\n }\n }\n\n /**\n * Close the dialog once `source` reads `true`, with `result` - `undefined`\n * when omitted, which is what every dismissal closes with. A source that is\n * already `true` closes it on the next change detection, after the attach\n * has finished.\n *\n * The watcher belongs to the dialog: it runs in the root injector, so the\n * caller needs no injection context, and it is destroyed when the dialog\n * closes by any path, so a source that turns `true` later does nothing. Each\n * call adds a watcher; the first to fire closes. A closed dialog ignores the\n * call.\n *\n * @example\n * ```ts\n * const saved = computed(() => this.save.status() === 'resolved');\n * this.dialog.open(SavingComponent).closeWhen(saved, 'saved');\n * ```\n */\n closeWhen(source: Signal<boolean>, result?: R): void {\n if (this.isClosed) return;\n if (!this.injector) {\n throw new Error('WrDialogRef: closeWhen() needs a ref opened by WrDialog, which carries the injector');\n }\n this.watchers.push(\n effect(\n () => {\n if (source()) untracked(() => this.close(result));\n },\n { injector: this.injector }\n )\n );\n }\n\n /** Resolves with the close result when the dialog is dismissed. */\n awaitClose(): Promise<R | undefined> {\n return new Promise(resolve => {\n this.closed.subscribe({\n next: value => resolve(value),\n complete: () => resolve(undefined),\n });\n });\n }\n\n /** Underlying overlay ref — escape hatch for advanced cases. */\n get overlayRef(): OverlayRef {\n return this._overlayRef;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, ElementRef, inject } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nlet uid = 0;\n\n/**\n * Styles a dialog title row. Use on a heading inside an opened dialog.\n * Auto-assigns an `id` so the dialog panel can reference it via\n * `aria-labelledby`.\n *\n * @example\n * ```html\n * <h2 wrDialogTitle>Confirm delete</h2>\n * ```\n */\n@Directive({\n selector: '[wrDialogTitle]',\n exportAs: 'wrDialogTitle',\n host: { class: 'wr-dialog__title', '[attr.id]': 'id' },\n})\nexport class WrDialogTitle {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /** Generated id used for `aria-labelledby` wiring. */\n readonly id = `wr-dialog-title-${++uid}`;\n\n /** @internal */\n readonly elementRef = inject(ElementRef<HTMLElement>);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { CdkScrollable } from '@angular/cdk/scrolling';\nimport { Directive, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nlet uid = 0;\n\n/**\n * Styles the scrollable body section of a dialog. Auto-assigns an `id` so an\n * `alertdialog` panel can reference it via `aria-describedby`.\n *\n * `CdkScrollable` is a host directive because this element is a real scroll\n * container (`overflow: auto`) and an anchored overlay opened from inside it has\n * to follow its trigger. CDK's `reposition()` strategy listens to\n * `ScrollDispatcher`, which is fed by registered scrollables plus ONE\n * non-capturing `document` listener — and element `scroll` does not bubble, so\n * without the registration a `<wr-select>` halfway down a long dialog form kept\n * its panel pinned to the viewport while the trigger scrolled away. Angular\n * Material carries the same host directive on `MatDialogContent` for the same\n * reason.\n *\n * @example\n * ```html\n * <div wrDialogContent>…body…</div>\n * ```\n */\n@Directive({\n selector: '[wrDialogContent]',\n host: { class: 'wr-dialog__content', '[attr.id]': 'id()' },\n hostDirectives: [CdkScrollable],\n})\nexport class WrDialogContent {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /** The element's id, generated unless given. An `alertdialog` names it in `aria-describedby`. */\n readonly id = input(`wr-dialog-content-${++uid}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, computed, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\n/**\n * Footer row, typically holding action buttons.\n *\n * @example\n * ```html\n * <div wrDialogFooter align=\"end\">\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"danger\" (click)=\"confirm()\">Delete</wr-btn>\n * </div>\n * ```\n */\n@Directive({\n selector: '[wrDialogFooter]',\n host: { class: 'wr-dialog__footer', '[class]': 'classes()' },\n})\nexport class WrDialogFooter {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /**\n * Horizontal alignment of the children.\n *\n * @default 'end'\n */\n readonly align = input<'start' | 'center' | 'end'>('end');\n\n protected readonly classes = computed(() => `wr-dialog__footer wr-dialog__footer--${this.align()}`);\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrDialogDefaults } from '../types';\n\n/** What `withDialog()` provides. @internal */\nexport const WR_DIALOG_DEFAULTS = new InjectionToken<WrDialogDefaults>('WR_DIALOG_DEFAULTS', {\n factory: (): WrDialogDefaults => ({}),\n});\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\n/**\n * Token that exposes the `data` payload passed to `WrDialog.open()`.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * readonly data = inject<ConfirmData>(WR_DIALOG_DATA);\n * }\n * ```\n */\nexport const WR_DIALOG_DATA = new InjectionToken<unknown>('WR_DIALOG_DATA');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { InjectionToken } from '@angular/core';\n\nimport type { WrDialogRef } from '../dialog-ref';\n\n/**\n * Token exposing the open dialog's `WrDialogRef` to components and\n * directives rendered inside it (e.g. `[wrDialogClose]`).\n *\n * **Prefer `inject(WrDialogRef)`** — the ref is provided under the class token\n * too, and the class path is the documented one. It already covers both cases\n * you might reach for a token for: `inject(WrDialogRef, { optional: true })`\n * works for content that also renders outside a dialog, and\n * `inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef)` types the\n * generics without a cast.\n *\n * This token is the same object under a second key. It exists for the library's\n * own directives (`[wrDialogClose]`) and for swapping the provider out — a test\n * stub, say — without touching the class.\n *\n * @example\n * ```ts\n * @Component({...})\n * export class ConfirmComponent {\n * private readonly ref = inject<WrDialogRef<ConfirmComponent, boolean>>(WrDialogRef);\n *\n * confirm(): void {\n * this.ref.close(true);\n * }\n * }\n * ```\n */\nexport const WR_DIALOG_REF = new InjectionToken<WrDialogRef<unknown, unknown>>('WR_DIALOG_REF');\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Directive, inject, input } from '@angular/core';\n\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport type { WrDialogRef } from '../dialog-ref';\nimport { WR_DIALOG_REF } from '../tokens';\n\n/**\n * Closes the dialog when the host element is clicked.\n *\n * Optionally passes a `[wrDialogClose]` value as the close result.\n *\n * @example\n * ```html\n * <wr-btn wrDialogClose>Cancel</wr-btn>\n * <wr-btn color=\"primary\" [wrDialogClose]=\"true\">Confirm</wr-btn>\n * ```\n */\n@Directive({\n selector: '[wrDialogClose]',\n host: { '(click)': 'onClick()' },\n})\nexport class WrDialogClose<R = unknown> {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n /**\n * Value to pass to `close()`. When unset — or used as a bare attribute — the\n * dialog closes with `undefined`.\n */\n readonly result = input<R | undefined, R | undefined | ''>(undefined, {\n alias: 'wrDialogClose',\n // A bare `wrDialogClose` attribute arrives as the empty string; that means\n // \"no result\", not a result of `''`. Matches `wrDrawerClose`.\n transform: value => (value === '' ? undefined : value),\n });\n\n private readonly ref = inject<WrDialogRef<unknown, R>>(WR_DIALOG_REF, { optional: true });\n\n protected onClick(): void {\n this.ref?.close(this.result());\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { Component, ViewEncapsulation, inject, signal } from '@angular/core';\n\nimport { WrButton } from 'ngwr/button';\nimport { useI18nText } from 'ngwr/i18n';\nimport { wrCheckStyles } from 'ngwr/utils';\n\nimport { WrDialogRef } from '../dialog-ref';\nimport { WrDialogContent, WrDialogFooter, WrDialogTitle } from '../directives';\nimport { WR_DIALOG_DATA } from '../tokens';\nimport type { WrDialogIntent } from '../types';\n\nimport type { WrDialogConfirmData } from './dialog-confirm-data';\n\nconst INTENT_COLORS: Partial<Record<WrDialogIntent, 'danger' | 'warning'>> = { danger: 'danger', warning: 'warning' };\n\n/**\n * The content `WrDialog.confirm()` and `WrDialog.alert()` mount: the dialog's\n * own title, content and footer around two `wr-btn`, or one for an alert. Not\n * exported; the service is the API.\n */\n@Component({\n selector: 'wr-dialog-confirm',\n templateUrl: './dialog-confirm.html',\n imports: [WrButton, WrDialogTitle, WrDialogContent, WrDialogFooter],\n encapsulation: ViewEncapsulation.None,\n host: {\n class: 'wr-dialog-confirm',\n '[class.wr-dialog-confirm--danger]': 'danger',\n },\n})\nexport class WrDialogConfirm {\n constructor() {\n if (typeof ngDevMode === 'undefined' || ngDevMode) wrCheckStyles('dialog');\n }\n\n protected readonly data = inject<WrDialogConfirmData>(WR_DIALOG_DATA);\n protected readonly ref = inject<WrDialogRef<WrDialogConfirm, boolean>>(WrDialogRef);\n\n protected readonly alert = this.data.alert === true;\n protected readonly intent = this.data.intent ?? null;\n // An alert's button dismisses a message, so it never takes the intent's color.\n protected readonly color =\n this.data.confirmColor ?? (this.alert || !this.intent ? 'primary' : (INTENT_COLORS[this.intent] ?? 'primary'));\n protected readonly danger = this.color === 'danger';\n protected readonly focusInitial = this.data.focusInitial === true;\n\n protected readonly confirmLabel = useI18nText(signal(this.data.confirmLabel ?? null), 'common.ok', 'OK');\n protected readonly cancelLabel = useI18nText(signal(this.data.cancelLabel ?? null), 'common.cancel', 'Cancel');\n}\n","<h2 wrDialogTitle>\n @if (intent) {\n <svg\n [class]=\"`wr-dialog-confirm__icon wr-dialog-confirm__icon--${intent}`\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <!-- The glyphs `wr-alert` and `wr-toast` draw for the same four meanings. -->\n @switch (intent) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n </svg>\n }\n {{ data.title }}\n</h2>\n@if (data.message) {\n <div wrDialogContent>{{ data.message }}</div>\n}\n<!--\n Under `autoFocus: 'first-tabbable'` initial focus sits on the safe answer of a\n danger question and on the confirm button otherwise, through the\n `cdkFocusInitial` the focus trap already reads. An alert has one button, and\n it takes the focus. In the other modes none of them is marked.\n-->\n<div wrDialogFooter>\n @if (alert) {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--ok\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial ? '' : null\"\n (click)=\"ref.close()\"\n >\n {{ confirmLabel() }}\n </button>\n } @else {\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--cancel\"\n [attr.cdkFocusInitial]=\"focusInitial && danger ? '' : null\"\n (click)=\"ref.close(false)\"\n >\n {{ cancelLabel() }}\n </button>\n <button\n wr-btn\n type=\"button\"\n class=\"wr-dialog-confirm__action wr-dialog-confirm__action--confirm\"\n [color]=\"color\"\n [attr.cdkFocusInitial]=\"focusInitial && !danger ? '' : null\"\n (click)=\"ref.close(true)\"\n >\n {{ confirmLabel() }}\n </button>\n }\n</div>\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { ConfigurableFocusTrapFactory } from '@angular/cdk/a11y';\nimport { Directionality } from '@angular/cdk/bidi';\nimport { type OverlayRef, ScrollStrategyOptions } from '@angular/cdk/overlay';\nimport { ComponentPortal, type ComponentType } from '@angular/cdk/portal';\nimport { Location, isPlatformBrowser } from '@angular/common';\nimport {\n DestroyRef,\n EnvironmentInjector,\n Service,\n Injector,\n PLATFORM_ID,\n type WritableSignal,\n afterEveryRender,\n inject,\n signal,\n} from '@angular/core';\n\nimport { WrI18n } from 'ngwr/i18n';\nimport { WrMeta } from 'ngwr/meta';\nimport { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFocusOverlay, wrFollowDirection } from 'ngwr/overlay';\nimport { wrToClassList } from 'ngwr/utils';\n\nimport { WrDialogConfirm } from './confirm/dialog-confirm';\nimport type { WrDialogConfirmData } from './confirm/dialog-confirm-data';\nimport { WrDialogRef } from './dialog-ref';\nimport { WR_DIALOG_DATA, WR_DIALOG_DEFAULTS, WR_DIALOG_REF } from './tokens';\nimport type { WrDialogAlertOptions, WrDialogAutoFocus, WrDialogConfirmOptions, WrDialogOptions } from './types';\n\nconst DEFAULT_PANEL_CLASS = 'wr-dialog-panel';\nconst DEFAULT_BACKDROP_CLASS = 'wr-dialog-backdrop';\n\n/**\n * Opens dialog components in an isolated NGWR overlay.\n *\n * Uses `WR_OVERLAY`, so dialogs render into NGWR's own overlay container\n * and never collide with other CDK consumers (Material, NG-ZORRO, etc.).\n *\n * @example\n * ```ts\n * const dialog = inject(WrDialog);\n *\n * const ref = dialog.open(ConfirmComponent, {\n * data: { message: 'Delete this item?' },\n * width: '24rem',\n * });\n *\n * const ok = await ref.awaitClose();\n * if (ok) remove();\n * ```\n *\n * @see https://ngwr.dev/reference/components/dialog\n */\n@Service()\nexport class WrDialog {\n private readonly overlay = inject(WR_OVERLAY);\n private readonly scrollStrategies = inject(ScrollStrategyOptions);\n private readonly parentInjector = inject(EnvironmentInjector);\n private readonly focusTrapFactory = inject(ConfigurableFocusTrapFactory);\n private readonly isBrowser = isPlatformBrowser(inject(PLATFORM_ID));\n private readonly i18n = inject(WrI18n, { optional: true });\n private readonly dir = inject(Directionality, { optional: true });\n // Resolvable wherever the CDK's own `Overlay` is — it injects the same thing\n // to implement `disposeOnNavigation`.\n private readonly location = inject(Location);\n private readonly destroyRef = inject(DestroyRef);\n private readonly defaults = inject(WR_DIALOG_DEFAULTS);\n private readonly order = inject(WrOverlayOrder);\n\n open<C, R = unknown, D = unknown>(component: ComponentType<C>, options: WrDialogOptions<D> = {}): WrDialogRef<C, R> {\n const overlayRef: OverlayRef = this.overlay.create({\n positionStrategy: this.overlay.position().global().centerHorizontally().centerVertically(),\n scrollStrategy: this.scrollStrategies.block(),\n hasBackdrop: true,\n backdropClass: DEFAULT_BACKDROP_CLASS,\n panelClass: wrToClassList(DEFAULT_PANEL_CLASS, options.panelClass),\n width: options.width,\n maxWidth: options.maxWidth,\n });\n\n // The CDK captures the direction as a string at create and never looks\n // again, so an app that flips while a dialog is up leaves the panel behind.\n // Nothing here derives from it — the box is centred and its x offset is\n // empty, so `apply()`'s RTL branch moves nothing — but the `dir` attribute\n // is what the dialog's own logical CSS and every ngwr control inside it\n // resolve `start` and `end` against, so it has to follow. No teardown kept:\n // the follower ends on the ref's own `detachments()`, which every dismissal\n // path goes through, and each `open()` creates a fresh ref of its own.\n wrFollowDirection(overlayRef, this.dir, this.parentInjector);\n\n const dialogRef = new WrDialogRef<C, R>(overlayRef, this.parentInjector);\n\n if (this.isBrowser) {\n const active = document.activeElement;\n dialogRef.previouslyFocused = active instanceof HTMLElement ? active : null;\n }\n\n const injector = Injector.create({\n parent: this.parentInjector,\n providers: [\n { provide: WR_DIALOG_DATA, useValue: options.data },\n { provide: WR_DIALOG_REF, useValue: dialogRef },\n // Provided as its own token as well, so dialog content can reach for\n // the familiar `inject(WrDialogRef)` and close itself.\n { provide: WrDialogRef, useValue: dialogRef },\n ],\n });\n\n const portal = new ComponentPortal(component, null, injector);\n dialogRef.componentRef = overlayRef.attach(portal);\n overlayRef.detachments().subscribe(this.order.add(overlayRef.hostElement, options.toasts));\n\n // Wired BEFORE the panel is decorated, and the order is the fix: everything\n // below attaches attributes, a ✕ and a focus trap to an overlay that is\n // already on screen, so anything that throws in there used to leave an\n // `aria-modal` panel with no dismissal path at all — no ✕, no backdrop\n // handler, no Escape — over the whole application, and no ref for the caller\n // to close it with. A dialog that fails to finish opening must still be one\n // the user can get rid of. Overlay subscriptions complete when the overlay is\n // disposed, so no explicit teardown is required.\n if (options.closeOnBackdropClick !== false) {\n overlayRef.backdropClick().subscribe(() => dialogRef.close());\n }\n if (options.closeOnEscape !== false) {\n overlayRef.keydownEvents().subscribe(event => {\n if (event.key === 'Escape') {\n event.preventDefault();\n dialogRef.close();\n }\n });\n }\n if (options.closeOnNavigation !== false) {\n this.watchNavigation(overlayRef, dialogRef);\n }\n\n if (this.isBrowser) {\n const host = overlayRef.overlayElement;\n const role = options.role ?? 'dialog';\n host.setAttribute('role', role);\n host.setAttribute('aria-modal', 'true');\n // Built-in dismiss. Appended after the content portal so it paints above\n // it, and marked on the panel so the title reserves the corner gutter.\n if (options.closable !== false) {\n host.classList.add('wr-dialog-panel--closable');\n const label = options.closeLabel ?? this.closeLabel();\n wrAppendOverlayClose(host, 'wr-dialog__close', label, () => dialogRef.close());\n }\n // Wire aria-labelledby to wrDialogTitle's auto-id once content is in DOM.\n // Has to wait for a render, not a microtask: attaching the portal only\n // schedules change detection, so under zoneless CD a microtask runs while\n // the content is still an empty view and the title id doesn't exist yet.\n //\n // And after EVERY render, not just the next one: the title belongs to the\n // caller's component, so an `@if` or a late-arriving heading can replace\n // or remove the element the attribute names. A reference to a node that is\n // no longer there is not a name — the dialog announces as unnamed — so a\n // missing title clears the attribute rather than leaving it dangling.\n //\n // An `alertdialog` is described by its content the same way: the message\n // is the dialog, and it can be conditional too.\n const tabTitle = (options.tabTitle ?? this.defaults.tabTitle) ? this.nameTab(overlayRef) : null;\n const labelSync = afterEveryRender(\n () => {\n const titleEl = host.querySelector<HTMLElement>('[wrDialogTitle], [wr-dialog-title]');\n if (titleEl?.id) host.setAttribute('aria-labelledby', titleEl.id);\n else host.removeAttribute('aria-labelledby');\n tabTitle?.set((titleEl?.textContent ?? '').replace(/\\s+/g, ' ').trim());\n if (role !== 'alertdialog') return;\n const contentEl = host.querySelector<HTMLElement>('[wrDialogContent], [wr-dialog-content]');\n if (contentEl?.id) host.setAttribute('aria-describedby', contentEl.id);\n else host.removeAttribute('aria-describedby');\n },\n { injector: this.parentInjector }\n );\n // The hook is bound to the root injector, so it outlives the dialog unless\n // it is torn down with it. `detachments()` fires on dispose, which is the\n // one path every dismissal goes through.\n overlayRef.detachments().subscribe(() => labelSync.destroy());\n // Trap focus inside the dialog and move initial focus in.\n const trap = this.focusTrapFactory.create(host);\n dialogRef.focusTrap = trap;\n wrFocusOverlay(host, trap, this.autoFocusOf(options), this.parentInjector);\n }\n\n return dialogRef;\n }\n\n /**\n * Ask a yes-or-no question and get the answer: `true` only when the user\n * pressed the confirm button. Escape, the backdrop, the cancel button, a\n * navigation and the application being torn down all resolve `false`. The\n * promise settles exactly once and never rejects, so the caller needs no\n * `catch` and no cleanup.\n *\n * The dialog is `role=\"alertdialog\"`, named by `title` and described by\n * `message`, with no corner dismiss: the two buttons are the answers. Labels\n * fall back to the `common.ok` and `common.cancel` catalog keys. With\n * `autoFocus: 'first-tabbable'` and `confirmColor: 'danger'` initial focus is on\n * the cancel button, and on the confirm button otherwise; by default the panel\n * takes it. Focus returns to the opener on close, as it does\n * for `open()`.\n *\n * `intent` puts an icon before the title, and `danger` or `warning` color the\n * confirm button unless `confirmColor` is set, so a `danger` question also\n * starts on the cancel button.\n *\n * On the server nothing can answer, so it resolves `false` at once and opens\n * nothing.\n *\n * @example\n * ```ts\n * const ok = await dialog.confirm({\n * title: 'Delete this item?',\n * message: 'This cannot be undone.',\n * confirmLabel: 'Delete',\n * intent: 'danger',\n * });\n * if (ok) remove();\n * ```\n */\n async confirm(options: WrDialogConfirmOptions): Promise<boolean> {\n if (!this.isBrowser) return false;\n const { title, message, confirmLabel, cancelLabel, confirmColor, intent, ...rest } = options;\n return (await this.ask(rest, { title, message, confirmLabel, cancelLabel, confirmColor, intent })) === true;\n }\n\n /**\n * Show a message with one button and wait until the user has dismissed it.\n * The button, Escape, the backdrop, a navigation and the application being\n * torn down all resolve the promise, which settles exactly once with no\n * value and never rejects.\n *\n * The dialog is `confirm()`'s with one button: `role=\"alertdialog\"` for every\n * intent, named by `title` and described by `message`, with no corner\n * dismiss. Under `autoFocus: 'first-tabbable'` the button takes the initial focus; its label falls back to the\n * `common.ok` catalog key. `intent` puts an icon before the title.\n *\n * On the server it resolves at once and opens nothing.\n *\n * @example\n * ```ts\n * await dialog.alert({\n * title: 'Range too large',\n * message: 'Pick at most 31 days to export.',\n * okLabel: 'Close',\n * intent: 'danger',\n * });\n * ```\n */\n async alert(options: WrDialogAlertOptions): Promise<void> {\n if (!this.isBrowser) return;\n const { title, message, okLabel, intent, ...rest } = options;\n await this.ask(rest, { title, message, confirmLabel: okLabel, intent, alert: true });\n }\n\n private autoFocusOf(options: WrDialogOptions): WrDialogAutoFocus {\n return options.autoFocus ?? this.defaults.autoFocus ?? 'dialog';\n }\n\n private ask(options: WrDialogOptions, data: WrDialogConfirmData): Promise<boolean | undefined> {\n const focusInitial = this.autoFocusOf(options) === 'first-tabbable';\n const ref = this.open<WrDialogConfirm, boolean, WrDialogConfirmData>(WrDialogConfirm, {\n ...options,\n role: 'alertdialog',\n closable: false,\n data: { ...data, focusInitial },\n });\n // The root injector going away takes the overlay container with it and\n // completes nothing, which would leave this promise pending for good.\n const unhook = this.destroyRef.onDestroy(() => ref.close());\n ref.closed.subscribe({ complete: unhook });\n return ref.awaitClose();\n }\n\n /**\n * Tie the dialog's lifetime to the URL it was opened on.\n *\n * Nothing else does. The overlay belongs to a root service and is dismissed\n * only by the backdrop, Escape or an explicit `close()`, so pressing Back\n * swapped the routed view underneath and left the modal pane, its backdrop and\n * its focus trap sitting over a page the user never opened them on.\n *\n * `onUrlChange`, not `Location.subscribe()` — which is what CDK's own\n * `disposeOnNavigation` uses: `subscribe` fires on popstate alone, so an\n * in-app `router.navigate()` left the dialog standing. And `dialogRef.close()`\n * rather than disposing the overlay behind the ref's back, which would never\n * emit `closed`, never destroy the focus trap, and leave `awaitClose()`\n * pending forever.\n */\n private watchNavigation<C, R>(overlayRef: OverlayRef, dialogRef: WrDialogRef<C, R>): void {\n const stopWatching = this.location.onUrlChange(() => dialogRef.close());\n // Unhooked a microtask late, because `Location` notifies its listeners with\n // a `forEach` and unregistering splices the array it is iterating: removing\n // ours synchronously from inside the notification would shift the next entry\n // into the slot forEach has already passed, and a SECOND stacked dialog\n // would be skipped and left behind.\n overlayRef.detachments().subscribe(() => queueMicrotask(stopWatching));\n }\n\n /**\n * Put the dialog's title in front of the page title for as long as the\n * overlay is attached, and hand back where to write that title.\n *\n * A `titlePrefix` layer rather than a composed `title`: the page title stays\n * whatever the layers under it resolve to, so a page that retitles itself\n * under an open dialog is followed, and closing restores nothing, it only\n * removes the layer. Stacked dialogs each hold a layer and the top one wins.\n *\n * `WrMeta` is resolved here and not injected with the service: constructing\n * it applies its defaults to `<head>`, which an app that never asked for\n * `tabTitle` must not pay for.\n */\n private nameTab(overlayRef: OverlayRef): WritableSignal<string> {\n const heading = signal('');\n const layer = this.parentInjector.get(WrMeta).bind(() => (heading() ? { titlePrefix: heading() } : {}));\n overlayRef.detachments().subscribe(() => layer.pop());\n return heading;\n }\n\n /**\n * The dismiss button's accessible name.\n *\n * Two failure modes, and resolving PER OPEN is what covers both. `t()` hands\n * back the KEY on a miss, and `WrI18n` is root-provided with an empty catalog\n * by default, so an app that never configured i18n named its dismiss button\n * \"dialog.close\" — a name axe cannot fault, because a name is present, and a\n * screen reader reads out verbatim. Resolving once at injection time fixed\n * that but froze the answer: this is a root service, constructed before an\n * async catalog has loaded, so a localized app got the English fallback on\n * every dialog it ever opened.\n */\n private closeLabel(): string {\n const resolved = this.i18n?.t('dialog.close');\n return !resolved || resolved === 'dialog.close' ? 'Close dialog' : resolved;\n }\n}\n","/**\n * @license\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE\n */\n\nimport { type WrFeature, wrFeature } from 'ngwr/utils';\n\nimport { WR_DIALOG_DEFAULTS } from './tokens';\nimport type { WrDialogDefaults } from './types';\n\n/**\n * App-wide dialog defaults, as a feature of `provideWr()`: `tabTitle`, so\n * every dialog names the browser tab while it is open, and `autoFocus`, where\n * focus goes on open. The same option on `open()` or `confirm()` still wins.\n *\n * Bootstrap only: `WrDialog` is root-provided and reads it once, from the root\n * injector, so in a route's `providers` it changes nothing.\n *\n * @example\n * ```ts\n * import { provideWr } from 'ngwr';\n * import { withDialog } from 'ngwr/dialog';\n *\n * bootstrapApplication(App, {\n * providers: [provideWr(withDialog({ tabTitle: true, autoFocus: 'first-tabbable' }))],\n * });\n * ```\n */\nexport function withDialog(defaults: WrDialogDefaults): WrFeature<'dialog'> {\n return wrFeature('dialog', [{ provide: WR_DIALOG_DEFAULTS, useValue: defaults }]);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,cAAb,MAAwB;CA8BH;CACA;CAtBV,SAAS,IAAI,cAA6B,CAAC;CAGpD,eAAuC;CAGvC,YAA0C;CAG1C,oBAAwC;CAEvB,WAAwB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M,CAAE;EACzC,OAAO,IAAI,WAAU;CACvB;CAiBQ,gBAAsB,YAAwB,WAA4B;EAChF,MAAM,eAAe,KAAK,SAAS,kBAAkB,UAAU,MAAK,CAAE;EAMtE,WAAW,YAAW,CAAE,CAAC,gBAAgB,eAAe,YAAY,CAAC;CACvE;CAeQ,QAAQ,YAAsB;EACpC,MAAM,UAAU,OAAO,IAAG,GAAA,YAAA,CAAA,EAAA,WAAA,UAAA,CAAA,+BAAA,CAAA,CAAA;EAC1B,MAAM,QAAQ,KAAK,eAAe,IAAI,MAAM,CAAC,CAAC,WAAY,QAAO,IAAK,EAAE,aAAa,QAAO,EAAE,IAAK,CAAA,CAAG;EACtG,WAAW,YAAW,CAAE,CAAC,gBAAgB,MAAM,IAAG,CAAE;EACpD,OAAO;CACT;CAcQ,aAAU;EAChB,MAAM,WAAW,KAAK,MAAM,EAAE,cAAc;EAC5C,OAAO,CAAC,YAAY,aAAa,iBAAiB,iBAAiB;CACrE;CAxRW,OAAA,OAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;EAAQ,MAAA,CAAA;EAAA,QAAA,GAAA,gBAAA;CAAA,CAAA;CAAR,OAAA,QAAA,GAAA,mBAAA;EAAA,YAAA;EAAA,SAAA;EAAA,UAAA;EAAA,MAAA;CAAQ,CAAA;;AAAR,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAAQ,YAAA,CAAA,EADpB,MAAA,Q;;;;;;;;AC7BD,SAAgB,WAAW,UAA0B;CACnD,OAAO,UAAU,UAAU,CAAC;EAAE,SAAS;EAAoB,UAAU;CAAQ,CAAE,CAAC;AAClF"}
|
package/fesm2022/ngwr-drawer.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { Directionality } from "@angular/cdk/bidi";
|
|
|
8
8
|
import { ScrollStrategyOptions } from "@angular/cdk/overlay";
|
|
9
9
|
import { ComponentPortal, TemplatePortal } from "@angular/cdk/portal";
|
|
10
10
|
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
11
|
-
import { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFollowDirection } from "ngwr/overlay";
|
|
11
|
+
import { WR_OVERLAY, WrOverlayOrder, wrAppendOverlayClose, wrFocusOverlay, wrFollowDirection } from "ngwr/overlay";
|
|
12
12
|
import { ConfigurableFocusTrapFactory, FocusMonitor, FocusTrapFactory } from "@angular/cdk/a11y";
|
|
13
13
|
import { ReplaySubject } from "rxjs";
|
|
14
14
|
/**
|
|
@@ -117,6 +117,7 @@ var WrDrawer = class WrDrawer {
|
|
|
117
117
|
closeLabel = input(null, ...ngDevMode ? [{ debugName: "closeLabel" }] : /* istanbul ignore next */ []);
|
|
118
118
|
panelClass = input(null, ...ngDevMode ? [{ debugName: "panelClass" }] : /* istanbul ignore next */ []);
|
|
119
119
|
toasts = input("above", ...ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []);
|
|
120
|
+
autoFocus = input("dialog", ...ngDevMode ? [{ debugName: "autoFocus" }] : /* istanbul ignore next */ []);
|
|
120
121
|
resolvedCloseLabel = useI18nText(this.closeLabel, "drawer.close", "Close drawer");
|
|
121
122
|
panelTpl = viewChild.required(TemplateRef, ...ngDevMode ? [{ debugName: "panelTpl" }] : /* istanbul ignore next */ []);
|
|
122
123
|
projectedTitle = contentChild(WrDrawerTitle, ...ngDevMode ? [{ debugName: "projectedTitle" }] : /* istanbul ignore next */ []);
|
|
@@ -213,7 +214,7 @@ var WrDrawer = class WrDrawer {
|
|
|
213
214
|
host.setAttribute("role", "dialog");
|
|
214
215
|
if (modal) host.setAttribute("aria-modal", "true");
|
|
215
216
|
this.focusTrap = modal ? this.focusTrapFactory.create(host) : this.plainFocusTrapFactory.create(host, true);
|
|
216
|
-
this.focusTrap.
|
|
217
|
+
wrFocusOverlay(host, this.focusTrap, this.autoFocus(), this.injector);
|
|
217
218
|
}
|
|
218
219
|
if (this.closeOnBackdropClick()) this.overlayRef.backdropClick().pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => this.open.set(false));
|
|
219
220
|
if (this.closeOnEscape()) this.overlayRef.keydownEvents().pipe(takeUntilDestroyed(this.destroyRef)).subscribe((event) => {
|
|
@@ -346,6 +347,13 @@ var WrDrawer = class WrDrawer {
|
|
|
346
347
|
isSignal: true,
|
|
347
348
|
isRequired: false,
|
|
348
349
|
transformFunction: null
|
|
350
|
+
},
|
|
351
|
+
autoFocus: {
|
|
352
|
+
classPropertyName: "autoFocus",
|
|
353
|
+
publicName: "autoFocus",
|
|
354
|
+
isSignal: true,
|
|
355
|
+
isRequired: false,
|
|
356
|
+
transformFunction: null
|
|
349
357
|
}
|
|
350
358
|
},
|
|
351
359
|
outputs: { open: "openChange" },
|
|
@@ -500,6 +508,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
500
508
|
required: false
|
|
501
509
|
}]
|
|
502
510
|
}],
|
|
511
|
+
autoFocus: [{
|
|
512
|
+
type: i0.Input,
|
|
513
|
+
args: [{
|
|
514
|
+
isSignal: true,
|
|
515
|
+
alias: "autoFocus",
|
|
516
|
+
required: false
|
|
517
|
+
}]
|
|
518
|
+
}],
|
|
503
519
|
panelTpl: [{
|
|
504
520
|
type: i0.ViewChild,
|
|
505
521
|
args: [i0.forwardRef(() => TemplateRef), { isSignal: true }]
|
|
@@ -676,7 +692,7 @@ var WrDrawerManager = class WrDrawerManager {
|
|
|
676
692
|
overlayRef.detachments().subscribe(() => labelSync.destroy());
|
|
677
693
|
const trap = modal ? this.focusTrapFactory.create(host) : this.plainFocusTrapFactory.create(host, true);
|
|
678
694
|
drawerRef.focusTrap = trap;
|
|
679
|
-
trap.
|
|
695
|
+
wrFocusOverlay(host, trap, options.autoFocus ?? "dialog", this.parentInjector);
|
|
680
696
|
}
|
|
681
697
|
return drawerRef;
|
|
682
698
|
}
|