@nanahoshi/mona-ui 0.27.2 → 0.28.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/docs/api/chart.md +2 -2
- package/docs/api/popup.md +1 -1
- package/docs/api/theme.md +2 -2
- package/docs/chart.md +14 -0
- package/docs/editor.md +2 -0
- package/docs/installation.md +147 -15
- package/docs/introduction.md +37 -15
- package/docs/theming-built-in-themes.md +67 -0
- package/docs/theming-custom-colors.md +274 -0
- package/docs/theming-custom-themes.md +168 -0
- package/docs/theming.md +164 -248
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
- package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
- package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
- package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
- package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
- package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
- package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
- package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
- package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
- package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
- package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
- package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
- package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
- package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
- package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
- package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
- package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
- package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
- package/llms.txt +6 -2
- package/package.json +62 -23
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
- package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
- package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
- package/types/nanahoshi-mona-ui-button.d.ts +227 -166
- package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
- package/types/nanahoshi-mona-ui-card.d.ts +125 -111
- package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
- package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
- package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
- package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
- package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
- package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
- package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
- package/types/nanahoshi-mona-ui-command.d.ts +279 -191
- package/types/nanahoshi-mona-ui-common.d.ts +354 -385
- package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
- package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
- package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
- package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
- package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
- package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
- package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
- package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
- package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
- package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
- package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
- package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
- package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
- package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
- package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
- package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
- package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
- package/types/nanahoshi-mona-ui-label.d.ts +108 -78
- package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
- package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
- package/types/nanahoshi-mona-ui-list.d.ts +2 -1
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
- package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
- package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
- package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
- package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
- package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
- package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
- package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
- package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
- package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
- package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
- package/types/nanahoshi-mona-ui-query.d.ts +82 -88
- package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
- package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
- package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
- package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
- package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
- package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
- package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
- package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
- package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
- package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
- package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
- package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
- package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
- package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
- package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
- package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
- package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
- package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
- package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
- package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
- package/types/nanahoshi-mona-ui-window.d.ts +494 -399
- package/types/nanahoshi-mona-ui.d.ts +1 -2
- package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
- package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
- package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
- package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
- package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
|
@@ -1,52 +1,40 @@
|
|
|
1
|
-
import { Directionality } from
|
|
2
|
-
import * as i0 from
|
|
3
|
-
import {
|
|
4
|
-
import { MonaI18nService } from
|
|
5
|
-
import {
|
|
6
|
-
import { cva } from
|
|
7
|
-
import { LiveAnnouncer } from
|
|
8
|
-
import { DOCUMENT, NgTemplateOutlet } from
|
|
9
|
-
import {
|
|
10
|
-
import { ButtonDirective } from
|
|
11
|
-
import { ProgressBarComponent } from
|
|
12
|
-
import { Subject } from
|
|
13
|
-
|
|
14
|
-
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
15
|
-
// Edit the JSON file and run `npm run generate:locale-catalogs`.
|
|
1
|
+
import { Directionality } from "@angular/cdk/bidi";
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
import { ApplicationRef, Component, DOCUMENT, DestroyRef, ElementRef, Injectable, InjectionToken, Injector, TemplateRef, ViewContainerRef, afterNextRender, afterRenderEffect, computed, createComponent, effect, inject, input, makeEnvironmentProviders, signal, untracked, viewChild } from "@angular/core";
|
|
4
|
+
import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
|
|
5
|
+
import { createElementControlId, themeOverlaySurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
6
|
+
import { cva } from "class-variance-authority";
|
|
7
|
+
import { LiveAnnouncer } from "@angular/cdk/a11y";
|
|
8
|
+
import { DOCUMENT as DOCUMENT$1, NgTemplateOutlet } from "@angular/common";
|
|
9
|
+
import { LucideBadgeInfo, LucideCircleCheckBig, LucideOctagonAlert, LucideOctagonX, LucideX } from "@lucide/angular";
|
|
10
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
11
|
+
import { ProgressBarComponent } from "@nanahoshi/mona-ui/progress-bar";
|
|
12
|
+
import { Subject } from "rxjs";
|
|
16
13
|
const NOTIFICATION_DEFAULT_MESSAGES = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
close: "Close",
|
|
15
|
+
error: "Error",
|
|
16
|
+
info: "Info",
|
|
17
|
+
region: "Notifications",
|
|
18
|
+
success: "Success",
|
|
19
|
+
warning: "Warning"
|
|
23
20
|
};
|
|
24
|
-
|
|
25
|
-
//---------------------------------
|
|
26
|
-
// Notification Container Component
|
|
27
|
-
//---------------------------------
|
|
28
21
|
const notificationContainerBaseThemeVariants = cva(`p-2 z-40000`, {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
positionType: "fixed"
|
|
45
|
-
}
|
|
22
|
+
variants: {
|
|
23
|
+
position: {
|
|
24
|
+
bottom: "bottom-0 left-1/2 -translate-x-1/2",
|
|
25
|
+
bottomleft: "bottom-0 left-0",
|
|
26
|
+
bottomright: "bottom-0 right-0",
|
|
27
|
+
top: "top-0 left-1/2 -translate-x-1/2",
|
|
28
|
+
topleft: "top-0 left-0",
|
|
29
|
+
topright: "top-0 right-0"
|
|
30
|
+
},
|
|
31
|
+
positionType: {
|
|
32
|
+
fixed: "fixed",
|
|
33
|
+
absolute: "absolute"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
defaultVariants: { positionType: "fixed" }
|
|
46
37
|
});
|
|
47
|
-
//-----------------------
|
|
48
|
-
// Notification Component
|
|
49
|
-
//-----------------------
|
|
50
38
|
const notificationActionThemeVariants = cva(`
|
|
51
39
|
absolute top-0 end-0 flex h-auto items-start
|
|
52
40
|
[&>svg.lucide]:cursor-pointer
|
|
@@ -70,647 +58,747 @@ const notificationHeaderThemeVariants = cva(`
|
|
|
70
58
|
`);
|
|
71
59
|
const notificationIconThemeVariants = cva(`
|
|
72
60
|
flex items-center justify-center px-4
|
|
73
|
-
`, {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
error: "text-error"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
});
|
|
61
|
+
`, { variants: { type: {
|
|
62
|
+
info: "text-info",
|
|
63
|
+
success: "text-success",
|
|
64
|
+
warning: "text-warning",
|
|
65
|
+
error: "text-error"
|
|
66
|
+
} } });
|
|
83
67
|
const notificationTextThemeVariants = cva(`
|
|
84
68
|
text-sm text-foreground
|
|
85
69
|
`);
|
|
86
|
-
|
|
87
|
-
/** The defaults used when nothing is provided with `provideNotificationDefaults()`. */
|
|
88
70
|
const DEFAULT_NOTIFICATION_DEFAULTS = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
71
|
+
autoHide: true,
|
|
72
|
+
durationScale: 1,
|
|
73
|
+
pauseOnWindowBlur: true
|
|
92
74
|
};
|
|
93
|
-
/**
|
|
94
|
-
* @description Application-wide notification settings. Provide them with `provideNotificationDefaults()`.
|
|
95
|
-
*/
|
|
96
75
|
const NOTIFICATION_DEFAULTS = new InjectionToken("Mona UI notification defaults", {
|
|
97
|
-
|
|
98
|
-
|
|
76
|
+
providedIn: "root",
|
|
77
|
+
factory: () => DEFAULT_NOTIFICATION_DEFAULTS
|
|
99
78
|
});
|
|
100
|
-
/**
|
|
101
|
-
* @description The `data` given in the notification's options, for a content component or template to inject.
|
|
102
|
-
*/
|
|
103
79
|
const NOTIFICATION_DATA = new InjectionToken("Mona UI notification data");
|
|
104
|
-
/**
|
|
105
|
-
* @description The reference of the notification a content component or template is shown in.
|
|
106
|
-
*/
|
|
107
80
|
const NOTIFICATION_REF = new InjectionToken("Mona UI notification reference");
|
|
108
|
-
|
|
109
|
-
/** Elements that can take focus with Tab, for moving focus to another notification. */
|
|
110
81
|
const TABBABLE = [
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
82
|
+
"a[href]",
|
|
83
|
+
"button:not([disabled])",
|
|
84
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
85
|
+
"select:not([disabled])",
|
|
86
|
+
"textarea:not([disabled])",
|
|
87
|
+
"[tabindex]:not([tabindex='-1'])"
|
|
117
88
|
].join(", ");
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
#
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
89
|
+
const LEAVE_FALLBACK = 1e3;
|
|
90
|
+
const RETURN_FOCUS = /* @__PURE__ */ new WeakMap();
|
|
91
|
+
var NotificationComponent = class NotificationComponent {
|
|
92
|
+
#announcer;
|
|
93
|
+
#defaults;
|
|
94
|
+
#destroyRef;
|
|
95
|
+
#document;
|
|
96
|
+
#focused;
|
|
97
|
+
#host;
|
|
98
|
+
#hovered;
|
|
99
|
+
#i18n;
|
|
100
|
+
#injector;
|
|
101
|
+
#isUrgent;
|
|
102
|
+
#running;
|
|
103
|
+
#windowBlurred;
|
|
104
|
+
#closeTimer;
|
|
105
|
+
#progressTimer;
|
|
106
|
+
#remaining;
|
|
107
|
+
#startedAt;
|
|
108
|
+
constructor() {
|
|
109
|
+
this.#announcer = inject(LiveAnnouncer);
|
|
110
|
+
this.#defaults = inject(NOTIFICATION_DEFAULTS);
|
|
111
|
+
this.#destroyRef = inject(DestroyRef);
|
|
112
|
+
this.#document = inject(DOCUMENT$1);
|
|
113
|
+
this.#focused = signal(false, ...ngDevMode ? [{ debugName: "#focused" }] : /* istanbul ignore next */ []);
|
|
114
|
+
this.#host = inject(ElementRef);
|
|
115
|
+
this.#hovered = signal(false, ...ngDevMode ? [{ debugName: "#hovered" }] : /* istanbul ignore next */ []);
|
|
116
|
+
this.#i18n = inject(MonaI18nService);
|
|
117
|
+
this.#injector = inject(Injector);
|
|
118
|
+
this.#isUrgent = computed(() => this.type() === "error" || this.type() === "warning", ...ngDevMode ? [{ debugName: "#isUrgent" }] : /* istanbul ignore next */ []);
|
|
119
|
+
this.#running = computed(() => this.options().duration != null && !this.data().closing() && !this.#hovered() && !this.#focused() && !this.#windowBlurred(), ...ngDevMode ? [{ debugName: "#running" }] : /* istanbul ignore next */ []);
|
|
120
|
+
this.#windowBlurred = signal(false, ...ngDevMode ? [{ debugName: "#windowBlurred" }] : /* istanbul ignore next */ []);
|
|
121
|
+
this.#closeTimer = null;
|
|
122
|
+
this.#progressTimer = null;
|
|
123
|
+
this.#remaining = null;
|
|
124
|
+
this.#startedAt = 0;
|
|
125
|
+
this.actionClass = computed(() => {
|
|
126
|
+
return notificationActionThemeVariants();
|
|
127
|
+
}, ...ngDevMode ? [{ debugName: "actionClass" }] : /* istanbul ignore next */ []);
|
|
128
|
+
this.baseClass = computed(() => {
|
|
129
|
+
return notificationBaseThemeVariants();
|
|
130
|
+
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
131
|
+
this.bodyClass = computed(() => {
|
|
132
|
+
return notificationBodyThemeVariants();
|
|
133
|
+
}, ...ngDevMode ? [{ debugName: "bodyClass" }] : /* istanbul ignore next */ []);
|
|
134
|
+
this.closeTitle = computed(() => {
|
|
135
|
+
return this.options().closeTitle ?? this.messages().close;
|
|
136
|
+
}, ...ngDevMode ? [{ debugName: "closeTitle" }] : /* istanbul ignore next */ []);
|
|
137
|
+
this.contentClass = computed(() => {
|
|
138
|
+
return notificationContentThemeVariants();
|
|
139
|
+
}, ...ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []);
|
|
140
|
+
this.contentComponent = computed(() => {
|
|
141
|
+
const content = this.options().content;
|
|
142
|
+
return typeof content !== "string" && !(content instanceof TemplateRef) ? content : null;
|
|
143
|
+
}, ...ngDevMode ? [{ debugName: "contentComponent" }] : /* istanbul ignore next */ []);
|
|
144
|
+
this.contentHost = viewChild("contentHost", {
|
|
145
|
+
...ngDevMode ? { debugName: "contentHost" } : /* istanbul ignore next */ {},
|
|
146
|
+
read: ViewContainerRef
|
|
147
|
+
});
|
|
148
|
+
this.contentInjector = computed(() => {
|
|
149
|
+
const data = this.data();
|
|
150
|
+
return Injector.create({
|
|
151
|
+
parent: this.#injector,
|
|
152
|
+
providers: [{
|
|
153
|
+
provide: NOTIFICATION_REF,
|
|
154
|
+
useValue: data.ref
|
|
155
|
+
}, {
|
|
156
|
+
provide: NOTIFICATION_DATA,
|
|
157
|
+
useValue: untracked(() => data.options().data)
|
|
158
|
+
}]
|
|
159
|
+
});
|
|
160
|
+
}, ...ngDevMode ? [{ debugName: "contentInjector" }] : /* istanbul ignore next */ []);
|
|
161
|
+
this.contentTemplate = computed(() => {
|
|
162
|
+
const content = this.options().content;
|
|
163
|
+
return content instanceof TemplateRef ? content : null;
|
|
164
|
+
}, ...ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []);
|
|
165
|
+
this.headerClass = computed(() => {
|
|
166
|
+
return notificationHeaderThemeVariants();
|
|
167
|
+
}, ...ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []);
|
|
168
|
+
this.iconClass = computed(() => {
|
|
169
|
+
const type = this.type();
|
|
170
|
+
return notificationIconThemeVariants({ type });
|
|
171
|
+
}, ...ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []);
|
|
172
|
+
this.messageElement = viewChild("message", ...ngDevMode ? [{ debugName: "messageElement" }] : /* istanbul ignore next */ []);
|
|
173
|
+
this.messages = this.#i18n.componentMessages("notification", NOTIFICATION_DEFAULT_MESSAGES);
|
|
174
|
+
this.options = computed(() => this.data().options(), ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
175
|
+
this.progressColor = computed(() => `var(--color-${this.type()})`, ...ngDevMode ? [{ debugName: "progressColor" }] : /* istanbul ignore next */ []);
|
|
176
|
+
this.progressValue = signal(100, ...ngDevMode ? [{ debugName: "progressValue" }] : /* istanbul ignore next */ []);
|
|
177
|
+
this.stringContent = computed(() => {
|
|
178
|
+
const content = this.options().content;
|
|
179
|
+
return typeof content === "string" ? content : null;
|
|
180
|
+
}, ...ngDevMode ? [{ debugName: "stringContent" }] : /* istanbul ignore next */ []);
|
|
181
|
+
this.templateContext = computed(() => ({
|
|
182
|
+
$implicit: this.data().ref,
|
|
183
|
+
data: this.options().data
|
|
184
|
+
}), ...ngDevMode ? [{ debugName: "templateContext" }] : /* istanbul ignore next */ []);
|
|
185
|
+
this.textClass = computed(() => {
|
|
186
|
+
return notificationTextThemeVariants();
|
|
187
|
+
}, ...ngDevMode ? [{ debugName: "textClass" }] : /* istanbul ignore next */ []);
|
|
188
|
+
this.title = computed(() => this.options().title ?? this.messages()[this.type()], ...ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []);
|
|
189
|
+
this.type = computed(() => this.options().type ?? "info", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
|
|
190
|
+
this.data = input.required(...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
|
|
191
|
+
this.side = input("top", ...ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []);
|
|
192
|
+
effect(() => {
|
|
193
|
+
this.data().rendered = true;
|
|
194
|
+
});
|
|
195
|
+
effect(() => {
|
|
196
|
+
const running = this.#running();
|
|
197
|
+
untracked(() => running ? this.#resume() : this.#pause());
|
|
198
|
+
});
|
|
199
|
+
effect(() => {
|
|
200
|
+
if (this.data().closing()) untracked(() => this.#leave());
|
|
201
|
+
});
|
|
202
|
+
afterRenderEffect({ write: () => {
|
|
203
|
+
const type = this.contentComponent();
|
|
204
|
+
const host = this.contentHost();
|
|
205
|
+
const injector = this.contentInjector();
|
|
206
|
+
untracked(() => {
|
|
207
|
+
host?.clear();
|
|
208
|
+
const componentRef = type && host ? host.createComponent(type, { injector }) : null;
|
|
209
|
+
componentRef?.changeDetectorRef.detectChanges();
|
|
210
|
+
this.data().contentComponentRef.set(componentRef);
|
|
211
|
+
});
|
|
212
|
+
} });
|
|
213
|
+
afterRenderEffect({ read: () => {
|
|
214
|
+
this.options();
|
|
215
|
+
untracked(() => this.#announce());
|
|
216
|
+
} });
|
|
217
|
+
this.#listenForWindowFocus();
|
|
218
|
+
this.#destroyRef.onDestroy(() => {
|
|
219
|
+
this.#stopTimers();
|
|
220
|
+
this.data().finish();
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
close() {
|
|
224
|
+
this.data().close();
|
|
225
|
+
}
|
|
226
|
+
onFocusIn(event) {
|
|
227
|
+
const host = this.#host.nativeElement;
|
|
228
|
+
const from = event.relatedTarget;
|
|
229
|
+
if (!this.#focused() && from instanceof HTMLElement && !host.contains(from)) {
|
|
230
|
+
const fromNotification = from.closest(host.tagName);
|
|
231
|
+
const target = fromNotification ? RETURN_FOCUS.get(fromNotification) : from;
|
|
232
|
+
if (target) RETURN_FOCUS.set(host, target);
|
|
233
|
+
}
|
|
234
|
+
this.#focused.set(true);
|
|
235
|
+
}
|
|
236
|
+
onFocusOut(event) {
|
|
237
|
+
const to = event.relatedTarget;
|
|
238
|
+
if (to instanceof Node && this.#host.nativeElement.contains(to)) return;
|
|
239
|
+
this.#focused.set(false);
|
|
240
|
+
}
|
|
241
|
+
onPointerChange(inside) {
|
|
242
|
+
this.#hovered.set(inside);
|
|
243
|
+
}
|
|
244
|
+
#announce() {
|
|
245
|
+
const content = this.stringContent();
|
|
246
|
+
const element = this.messageElement()?.nativeElement;
|
|
247
|
+
const message = (content != null ? `${this.title()} ${content}` : element?.innerText ?? element?.textContent)?.replace(/\s+/g, " ").trim();
|
|
248
|
+
if (message) this.#announcer.announce(message, this.#isUrgent() ? "assertive" : "polite");
|
|
249
|
+
}
|
|
250
|
+
#leave() {
|
|
251
|
+
this.#stopTimers();
|
|
252
|
+
this.#moveFocusAway();
|
|
253
|
+
afterNextRender({ read: () => {
|
|
254
|
+
const host = this.#host.nativeElement;
|
|
255
|
+
const animation = this.#document.defaultView?.getComputedStyle(host).animationName;
|
|
256
|
+
if (!animation || animation === "none") {
|
|
257
|
+
this.data().finish();
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
const done = () => {
|
|
261
|
+
clearTimeout(fallback);
|
|
262
|
+
host.removeEventListener("animationend", onEnd);
|
|
263
|
+
this.data().finish();
|
|
264
|
+
};
|
|
265
|
+
const onEnd = (event) => {
|
|
266
|
+
if (event.target === host) done();
|
|
267
|
+
};
|
|
268
|
+
const fallback = setTimeout(done, LEAVE_FALLBACK);
|
|
269
|
+
host.addEventListener("animationend", onEnd);
|
|
270
|
+
} }, { injector: this.#injector });
|
|
271
|
+
}
|
|
272
|
+
#listenForWindowFocus() {
|
|
273
|
+
const view = this.#document.defaultView;
|
|
274
|
+
if (!this.#defaults.pauseOnWindowBlur || !view) return;
|
|
275
|
+
const blur = () => this.#windowBlurred.set(true);
|
|
276
|
+
const focus = () => this.#windowBlurred.set(false);
|
|
277
|
+
view.addEventListener("blur", blur);
|
|
278
|
+
view.addEventListener("focus", focus);
|
|
279
|
+
this.#destroyRef.onDestroy(() => {
|
|
280
|
+
view.removeEventListener("blur", blur);
|
|
281
|
+
view.removeEventListener("focus", focus);
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
#moveFocusAway() {
|
|
285
|
+
const host = this.#host.nativeElement;
|
|
286
|
+
const active = this.#document.activeElement;
|
|
287
|
+
if (!(active instanceof HTMLElement) || !host.contains(active)) return;
|
|
288
|
+
const siblings = Array.from(host.parentElement?.children ?? []).filter((element) => element !== host && element.tagName === host.tagName && !element.hasAttribute("data-closing"));
|
|
289
|
+
const isAfter = (element) => !!(host.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING);
|
|
290
|
+
const ordered = [...siblings.filter(isAfter), ...siblings.filter((element) => !isAfter(element)).reverse()];
|
|
291
|
+
for (const sibling of ordered) {
|
|
292
|
+
const target = sibling.querySelector(TABBABLE);
|
|
293
|
+
if (target) {
|
|
294
|
+
target.focus();
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
const returnFocus = RETURN_FOCUS.get(host);
|
|
299
|
+
if (returnFocus?.isConnected) {
|
|
300
|
+
returnFocus.focus();
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
active.blur();
|
|
304
|
+
}
|
|
305
|
+
#pause() {
|
|
306
|
+
if (this.#closeTimer == null) return;
|
|
307
|
+
const duration = this.options().duration ?? 0;
|
|
308
|
+
this.#remaining = Math.max(0, (this.#remaining ?? duration) - (performance.now() - this.#startedAt));
|
|
309
|
+
this.#stopTimers();
|
|
310
|
+
this.progressValue.set(duration > 0 ? this.#remaining / duration * 100 : 0);
|
|
311
|
+
}
|
|
312
|
+
#resume() {
|
|
313
|
+
const duration = this.options().duration;
|
|
314
|
+
if (duration == null || this.#closeTimer != null) return;
|
|
315
|
+
const remaining = this.#remaining ??= duration;
|
|
316
|
+
this.#startedAt = performance.now();
|
|
317
|
+
this.#closeTimer = setTimeout(() => {
|
|
318
|
+
this.#closeTimer = null;
|
|
319
|
+
this.#remaining = 0;
|
|
320
|
+
this.#stopTimers();
|
|
321
|
+
this.progressValue.set(0);
|
|
322
|
+
this.data().close();
|
|
323
|
+
}, remaining);
|
|
324
|
+
if (this.options().progressBar && duration > 0) {
|
|
325
|
+
const step = Math.min(100, Math.max(16, duration / 100));
|
|
326
|
+
this.#progressTimer = setInterval(() => {
|
|
327
|
+
const left = remaining - (performance.now() - this.#startedAt);
|
|
328
|
+
this.progressValue.set(Math.max(0, left / duration * 100));
|
|
329
|
+
}, step);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
#stopTimers() {
|
|
333
|
+
if (this.#closeTimer != null) {
|
|
334
|
+
clearTimeout(this.#closeTimer);
|
|
335
|
+
this.#closeTimer = null;
|
|
336
|
+
}
|
|
337
|
+
if (this.#progressTimer != null) {
|
|
338
|
+
clearInterval(this.#progressTimer);
|
|
339
|
+
this.#progressTimer = null;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
static {
|
|
343
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
344
|
+
minVersion: "12.0.0",
|
|
345
|
+
version: "22.2.6",
|
|
346
|
+
ngImport: i0,
|
|
347
|
+
type: NotificationComponent,
|
|
348
|
+
deps: [],
|
|
349
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
static {
|
|
353
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
354
|
+
minVersion: "17.0.0",
|
|
355
|
+
version: "22.2.6",
|
|
356
|
+
type: NotificationComponent,
|
|
357
|
+
isStandalone: true,
|
|
358
|
+
selector: "mona-notification",
|
|
359
|
+
inputs: {
|
|
360
|
+
data: {
|
|
361
|
+
classPropertyName: "data",
|
|
362
|
+
publicName: "data",
|
|
363
|
+
isSignal: true,
|
|
364
|
+
isRequired: true,
|
|
365
|
+
transformFunction: null
|
|
366
|
+
},
|
|
367
|
+
side: {
|
|
368
|
+
classPropertyName: "side",
|
|
369
|
+
publicName: "side",
|
|
370
|
+
isSignal: true,
|
|
371
|
+
isRequired: false,
|
|
372
|
+
transformFunction: null
|
|
373
|
+
}
|
|
374
|
+
},
|
|
375
|
+
host: {
|
|
376
|
+
listeners: {
|
|
377
|
+
"focusin": "onFocusIn($event)",
|
|
378
|
+
"focusout": "onFocusOut($event)",
|
|
379
|
+
"pointerenter": "onPointerChange(true)",
|
|
380
|
+
"pointerleave": "onPointerChange(false)"
|
|
381
|
+
},
|
|
382
|
+
properties: {
|
|
383
|
+
"attr.data-closing": "data().closing() ? '' : null",
|
|
384
|
+
"class.notification-leave-bottom": "data().closing() && side() === 'bottom'",
|
|
385
|
+
"class.notification-leave-top": "data().closing() && side() !== 'bottom'"
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
viewQueries: [{
|
|
389
|
+
propertyName: "contentHost",
|
|
390
|
+
first: true,
|
|
391
|
+
predicate: ["contentHost"],
|
|
392
|
+
descendants: true,
|
|
393
|
+
read: ViewContainerRef,
|
|
394
|
+
isSignal: true
|
|
395
|
+
}, {
|
|
396
|
+
propertyName: "messageElement",
|
|
397
|
+
first: true,
|
|
398
|
+
predicate: ["message"],
|
|
399
|
+
descendants: true,
|
|
400
|
+
isSignal: true
|
|
401
|
+
}],
|
|
402
|
+
ngImport: i0,
|
|
403
|
+
template: "@let opts = options();\n@let width = typeof opts.width === \"string\" ? opts.width : `${opts.width}px`;\n@let height = typeof opts.height === \"string\" ? opts.height : `${opts.height}px`;\n\n<div [class]=\"baseClass()\" [style.width]=\"width\" [style.height]=\"height\">\n @if (contentTemplate(); as template) {\n <div #message class=\"contents\">\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"templateContext()\"\n [ngTemplateOutletInjector]=\"contentInjector()\"></ng-container>\n </div>\n } @else if (contentComponent()) {\n <div #message class=\"contents\">\n <ng-container #contentHost></ng-container>\n </div>\n } @else {\n <div #message [class]=\"bodyClass()\">\n <div [class]=\"iconClass()\" aria-hidden=\"true\">\n @switch (type()) {\n @case (\"error\") {\n <svg lucideOctagonX aria-hidden=\"true\"></svg>\n }\n @case (\"info\") {\n <svg lucideBadgeInfo aria-hidden=\"true\"></svg>\n }\n @case (\"success\") {\n <svg lucideCircleCheckBig aria-hidden=\"true\"></svg>\n }\n @case (\"warning\") {\n <svg lucideOctagonAlert aria-hidden=\"true\"></svg>\n }\n }\n </div>\n <div class=\"flex flex-col flex-1\">\n <div [class]=\"headerClass()\">{{ title() }}</div>\n <div [class]=\"contentClass()\">\n <span [class]=\"textClass()\">{{ stringContent() }}</span>\n </div>\n </div>\n </div>\n @if (opts.progressBar && opts.duration !== undefined) {\n <!-- Decorative: the time left isn't worth announcing. -->\n <div class=\"w-full h-1\" aria-hidden=\"true\">\n <mona-progress-bar\n [value]=\"progressValue()\"\n [color]=\"progressColor()\"\n [labelVisible]=\"false\"\n [animate]=\"false\"\n rounded=\"none\"\n class=\"h-full\"></mona-progress-bar>\n </div>\n }\n }\n @if (opts.closable) {\n <div [class]=\"actionClass()\">\n <button\n monaButton\n size=\"small\"\n look=\"link\"\n rounded=\"none\"\n [iconOnly]=\"true\"\n [title]=\"closeTitle()\"\n [attr.aria-label]=\"closeTitle()\"\n (click)=\"close()\">\n <svg lucideX [size]=\"14\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n }\n</div>\n",
|
|
404
|
+
styles: [":host{display:block}@keyframes notification-slide-in-top{0%{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-top{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}}@keyframes notification-slide-in-bottom{0%{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-bottom{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}}:host.notification-enter-top{animation:notification-slide-in-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-enter-bottom{animation:notification-slide-in-bottom .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-top{animation:notification-slide-out-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-bottom{animation:notification-slide-out-bottom .3s cubic-bezier(.4,0,.2,1) forwards}@media(prefers-reduced-motion:reduce){:host.notification-enter-top,:host.notification-enter-bottom,:host.notification-leave-top,:host.notification-leave-bottom{animation:none}}\n"],
|
|
405
|
+
dependencies: [
|
|
406
|
+
{
|
|
407
|
+
kind: "directive",
|
|
408
|
+
type: NgTemplateOutlet,
|
|
409
|
+
selector: "[ngTemplateOutlet]",
|
|
410
|
+
inputs: [
|
|
411
|
+
"ngTemplateOutletContext",
|
|
412
|
+
"ngTemplateOutlet",
|
|
413
|
+
"ngTemplateOutletInjector"
|
|
414
|
+
]
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
kind: "component",
|
|
418
|
+
type: ProgressBarComponent,
|
|
419
|
+
selector: "mona-progress-bar",
|
|
420
|
+
inputs: [
|
|
421
|
+
"animate",
|
|
422
|
+
"aria-label",
|
|
423
|
+
"aria-valuetext",
|
|
424
|
+
"color",
|
|
425
|
+
"disabled",
|
|
426
|
+
"indeterminate",
|
|
427
|
+
"labelPosition",
|
|
428
|
+
"labelStyles",
|
|
429
|
+
"labelVisible",
|
|
430
|
+
"max",
|
|
431
|
+
"min",
|
|
432
|
+
"rounded",
|
|
433
|
+
"class",
|
|
434
|
+
"value"
|
|
435
|
+
]
|
|
436
|
+
},
|
|
437
|
+
{
|
|
438
|
+
kind: "directive",
|
|
439
|
+
type: ButtonDirective,
|
|
440
|
+
selector: "button[monaButton]",
|
|
441
|
+
inputs: [
|
|
442
|
+
"aria-haspopup",
|
|
443
|
+
"disabled",
|
|
444
|
+
"iconOnly",
|
|
445
|
+
"loading",
|
|
446
|
+
"look",
|
|
447
|
+
"rounded",
|
|
448
|
+
"selected",
|
|
449
|
+
"size",
|
|
450
|
+
"tabindex",
|
|
451
|
+
"toggleable",
|
|
452
|
+
"type",
|
|
453
|
+
"class",
|
|
454
|
+
"value"
|
|
455
|
+
],
|
|
456
|
+
outputs: ["lookChange", "selectedChange"]
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
kind: "component",
|
|
460
|
+
type: LucideOctagonX,
|
|
461
|
+
selector: "svg[lucideOctagonX], svg[lucideXOctagon]"
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
kind: "component",
|
|
465
|
+
type: LucideBadgeInfo,
|
|
466
|
+
selector: "svg[lucideBadgeInfo]"
|
|
467
|
+
},
|
|
468
|
+
{
|
|
469
|
+
kind: "component",
|
|
470
|
+
type: LucideCircleCheckBig,
|
|
471
|
+
selector: "svg[lucideCircleCheckBig], svg[lucideCheckCircle]"
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
kind: "component",
|
|
475
|
+
type: LucideOctagonAlert,
|
|
476
|
+
selector: "svg[lucideOctagonExclamationPoint], svg[lucideAlertOctagon], svg[lucideOctagonAlert]"
|
|
477
|
+
},
|
|
478
|
+
{
|
|
479
|
+
kind: "component",
|
|
480
|
+
type: LucideX,
|
|
481
|
+
selector: "svg[lucideX]"
|
|
482
|
+
}
|
|
483
|
+
]
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
488
|
+
minVersion: "12.0.0",
|
|
489
|
+
version: "22.2.6",
|
|
490
|
+
ngImport: i0,
|
|
491
|
+
type: NotificationComponent,
|
|
492
|
+
decorators: [{
|
|
493
|
+
type: Component,
|
|
494
|
+
args: [{
|
|
495
|
+
selector: "mona-notification",
|
|
496
|
+
imports: [
|
|
497
|
+
NgTemplateOutlet,
|
|
498
|
+
ProgressBarComponent,
|
|
499
|
+
ButtonDirective,
|
|
500
|
+
LucideOctagonX,
|
|
501
|
+
LucideBadgeInfo,
|
|
502
|
+
LucideCircleCheckBig,
|
|
503
|
+
LucideOctagonAlert,
|
|
504
|
+
LucideX
|
|
505
|
+
],
|
|
506
|
+
host: {
|
|
507
|
+
"[attr.data-closing]": "data().closing() ? '' : null",
|
|
508
|
+
"[class.notification-leave-bottom]": "data().closing() && side() === 'bottom'",
|
|
509
|
+
"[class.notification-leave-top]": "data().closing() && side() !== 'bottom'",
|
|
510
|
+
"(focusin)": "onFocusIn($event)",
|
|
511
|
+
"(focusout)": "onFocusOut($event)",
|
|
512
|
+
"(pointerenter)": "onPointerChange(true)",
|
|
513
|
+
"(pointerleave)": "onPointerChange(false)"
|
|
514
|
+
},
|
|
515
|
+
template: "@let opts = options();\n@let width = typeof opts.width === \"string\" ? opts.width : `${opts.width}px`;\n@let height = typeof opts.height === \"string\" ? opts.height : `${opts.height}px`;\n\n<div [class]=\"baseClass()\" [style.width]=\"width\" [style.height]=\"height\">\n @if (contentTemplate(); as template) {\n <div #message class=\"contents\">\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"templateContext()\"\n [ngTemplateOutletInjector]=\"contentInjector()\"></ng-container>\n </div>\n } @else if (contentComponent()) {\n <div #message class=\"contents\">\n <ng-container #contentHost></ng-container>\n </div>\n } @else {\n <div #message [class]=\"bodyClass()\">\n <div [class]=\"iconClass()\" aria-hidden=\"true\">\n @switch (type()) {\n @case (\"error\") {\n <svg lucideOctagonX aria-hidden=\"true\"></svg>\n }\n @case (\"info\") {\n <svg lucideBadgeInfo aria-hidden=\"true\"></svg>\n }\n @case (\"success\") {\n <svg lucideCircleCheckBig aria-hidden=\"true\"></svg>\n }\n @case (\"warning\") {\n <svg lucideOctagonAlert aria-hidden=\"true\"></svg>\n }\n }\n </div>\n <div class=\"flex flex-col flex-1\">\n <div [class]=\"headerClass()\">{{ title() }}</div>\n <div [class]=\"contentClass()\">\n <span [class]=\"textClass()\">{{ stringContent() }}</span>\n </div>\n </div>\n </div>\n @if (opts.progressBar && opts.duration !== undefined) {\n <!-- Decorative: the time left isn't worth announcing. -->\n <div class=\"w-full h-1\" aria-hidden=\"true\">\n <mona-progress-bar\n [value]=\"progressValue()\"\n [color]=\"progressColor()\"\n [labelVisible]=\"false\"\n [animate]=\"false\"\n rounded=\"none\"\n class=\"h-full\"></mona-progress-bar>\n </div>\n }\n }\n @if (opts.closable) {\n <div [class]=\"actionClass()\">\n <button\n monaButton\n size=\"small\"\n look=\"link\"\n rounded=\"none\"\n [iconOnly]=\"true\"\n [title]=\"closeTitle()\"\n [attr.aria-label]=\"closeTitle()\"\n (click)=\"close()\">\n <svg lucideX [size]=\"14\" aria-hidden=\"true\"></svg>\n </button>\n </div>\n }\n</div>\n",
|
|
516
|
+
styles: [":host{display:block}@keyframes notification-slide-in-top{0%{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-top{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(0 -20px 100% -20px);transform:translateY(-12px);opacity:0}}@keyframes notification-slide-in-bottom{0%{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}to{clip-path:inset(-20px);transform:translateY(0);opacity:1}}@keyframes notification-slide-out-bottom{0%{clip-path:inset(-20px);transform:translateY(0);opacity:1}to{clip-path:inset(100% -20px 0 -20px);transform:translateY(12px);opacity:0}}:host.notification-enter-top{animation:notification-slide-in-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-enter-bottom{animation:notification-slide-in-bottom .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-top{animation:notification-slide-out-top .3s cubic-bezier(.4,0,.2,1) forwards}:host.notification-leave-bottom{animation:notification-slide-out-bottom .3s cubic-bezier(.4,0,.2,1) forwards}@media(prefers-reduced-motion:reduce){:host.notification-enter-top,:host.notification-enter-bottom,:host.notification-leave-top,:host.notification-leave-bottom{animation:none}}\n"]
|
|
517
|
+
}]
|
|
518
|
+
}],
|
|
519
|
+
ctorParameters: () => [],
|
|
520
|
+
propDecorators: {
|
|
521
|
+
contentHost: [{
|
|
522
|
+
type: i0.ViewChild,
|
|
523
|
+
args: ["contentHost", {
|
|
524
|
+
read: ViewContainerRef,
|
|
525
|
+
isSignal: true
|
|
526
|
+
}]
|
|
527
|
+
}],
|
|
528
|
+
messageElement: [{
|
|
529
|
+
type: i0.ViewChild,
|
|
530
|
+
args: ["message", { isSignal: true }]
|
|
531
|
+
}],
|
|
532
|
+
data: [{
|
|
533
|
+
type: i0.Input,
|
|
534
|
+
args: [{
|
|
535
|
+
isSignal: true,
|
|
536
|
+
alias: "data",
|
|
537
|
+
required: true
|
|
538
|
+
}]
|
|
539
|
+
}],
|
|
540
|
+
side: [{
|
|
541
|
+
type: i0.Input,
|
|
542
|
+
args: [{
|
|
543
|
+
isSignal: true,
|
|
544
|
+
alias: "side",
|
|
545
|
+
required: false
|
|
546
|
+
}]
|
|
547
|
+
}]
|
|
548
|
+
}
|
|
549
|
+
});
|
|
550
|
+
var NotificationContainerComponent = class NotificationContainerComponent {
|
|
551
|
+
constructor() {
|
|
552
|
+
this.#i18n = inject(MonaI18nService);
|
|
553
|
+
this.baseClass = computed(() => {
|
|
554
|
+
const position = this.position();
|
|
555
|
+
const positionType = this.positionType();
|
|
556
|
+
return notificationContainerBaseThemeVariants({
|
|
557
|
+
position,
|
|
558
|
+
positionType
|
|
559
|
+
});
|
|
560
|
+
}, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
561
|
+
this.enterAnimClass = computed(() => this.side() === "bottom" ? "notification-enter-bottom" : "notification-enter-top", ...ngDevMode ? [{ debugName: "enterAnimClass" }] : /* istanbul ignore next */ []);
|
|
562
|
+
this.messages = this.#i18n.componentMessages("notification", NOTIFICATION_DEFAULT_MESSAGES);
|
|
563
|
+
this.side = computed(() => this.position().startsWith("bottom") ? "bottom" : "top", ...ngDevMode ? [{ debugName: "side" }] : /* istanbul ignore next */ []);
|
|
564
|
+
this.notificationDataList = signal([], ...ngDevMode ? [{ debugName: "notificationDataList" }] : /* istanbul ignore next */ []);
|
|
565
|
+
this.position = signal("topright", ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
|
|
566
|
+
this.positionType = signal("fixed", ...ngDevMode ? [{ debugName: "positionType" }] : /* istanbul ignore next */ []);
|
|
567
|
+
}
|
|
568
|
+
#i18n;
|
|
569
|
+
static {
|
|
570
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
571
|
+
minVersion: "12.0.0",
|
|
572
|
+
version: "22.2.6",
|
|
573
|
+
ngImport: i0,
|
|
574
|
+
type: NotificationContainerComponent,
|
|
575
|
+
deps: [],
|
|
576
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
static {
|
|
580
|
+
this.ɵcmp = i0.ɵɵngDeclareComponent({
|
|
581
|
+
minVersion: "17.0.0",
|
|
582
|
+
version: "22.2.6",
|
|
583
|
+
type: NotificationContainerComponent,
|
|
584
|
+
isStandalone: true,
|
|
585
|
+
selector: "mona-notification-container",
|
|
586
|
+
host: {
|
|
587
|
+
attributes: { "role": "region" },
|
|
588
|
+
properties: {
|
|
589
|
+
"attr.aria-label": "messages().region",
|
|
590
|
+
"class": "baseClass()"
|
|
591
|
+
}
|
|
592
|
+
},
|
|
593
|
+
ngImport: i0,
|
|
594
|
+
template: "@for (notificationData of notificationDataList(); track notificationData) {\n <mona-notification [data]=\"notificationData\" [side]=\"side()\" [animate.enter]=\"enterAnimClass()\"></mona-notification>\n}\n",
|
|
595
|
+
dependencies: [{
|
|
596
|
+
kind: "component",
|
|
597
|
+
type: NotificationComponent,
|
|
598
|
+
selector: "mona-notification",
|
|
599
|
+
inputs: ["data", "side"]
|
|
600
|
+
}]
|
|
601
|
+
});
|
|
602
|
+
}
|
|
603
|
+
};
|
|
604
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
605
|
+
minVersion: "12.0.0",
|
|
606
|
+
version: "22.2.6",
|
|
607
|
+
ngImport: i0,
|
|
608
|
+
type: NotificationContainerComponent,
|
|
609
|
+
decorators: [{
|
|
610
|
+
type: Component,
|
|
611
|
+
args: [{
|
|
612
|
+
selector: "mona-notification-container",
|
|
613
|
+
imports: [NotificationComponent],
|
|
614
|
+
host: {
|
|
615
|
+
"[attr.aria-label]": "messages().region",
|
|
616
|
+
"[class]": "baseClass()",
|
|
617
|
+
role: "region"
|
|
618
|
+
},
|
|
619
|
+
template: "@for (notificationData of notificationDataList(); track notificationData) {\n <mona-notification [data]=\"notificationData\" [side]=\"side()\" [animate.enter]=\"enterAnimClass()\"></mona-notification>\n}\n"
|
|
620
|
+
}]
|
|
621
|
+
}]
|
|
622
|
+
});
|
|
623
|
+
var NotificationData = class {
|
|
624
|
+
#afterHide$;
|
|
625
|
+
#onFinish;
|
|
626
|
+
#finished;
|
|
627
|
+
constructor(options, onFinish = () => void 0) {
|
|
628
|
+
this.#afterHide$ = new Subject();
|
|
629
|
+
this.#finished = false;
|
|
630
|
+
this.closing = signal(false, ...ngDevMode ? [{ debugName: "closing" }] : /* istanbul ignore next */ []);
|
|
631
|
+
this.contentComponentRef = signal(null, ...ngDevMode ? [{ debugName: "contentComponentRef" }] : /* istanbul ignore next */ []);
|
|
632
|
+
this.rendered = false;
|
|
633
|
+
this.#onFinish = onFinish;
|
|
634
|
+
this.options = signal(options, ...ngDevMode ? [{ debugName: "options" }] : /* istanbul ignore next */ []);
|
|
635
|
+
const contentComponentRef = this.contentComponentRef;
|
|
636
|
+
this.ref = {
|
|
637
|
+
afterHide: this.#afterHide$.asObservable(),
|
|
638
|
+
get content() {
|
|
639
|
+
return contentComponentRef();
|
|
640
|
+
},
|
|
641
|
+
hide: () => this.close(),
|
|
642
|
+
id: options.id,
|
|
643
|
+
update: (changes) => {
|
|
644
|
+
if (!this.#finished) this.options.update((current) => ({
|
|
645
|
+
...current,
|
|
646
|
+
...changes
|
|
647
|
+
}));
|
|
648
|
+
}
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
get finished() {
|
|
652
|
+
return this.#finished;
|
|
653
|
+
}
|
|
654
|
+
get id() {
|
|
655
|
+
return this.options().id;
|
|
656
|
+
}
|
|
657
|
+
close() {
|
|
658
|
+
if (this.#finished || this.closing()) return;
|
|
659
|
+
if (!this.rendered) {
|
|
660
|
+
this.finish();
|
|
661
|
+
return;
|
|
662
|
+
}
|
|
663
|
+
this.closing.set(true);
|
|
664
|
+
}
|
|
665
|
+
finish() {
|
|
666
|
+
if (this.#finished) return;
|
|
667
|
+
this.#finished = true;
|
|
668
|
+
this.closing.set(true);
|
|
669
|
+
this.#onFinish(this);
|
|
670
|
+
this.#afterHide$.next();
|
|
671
|
+
this.#afterHide$.complete();
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
var NotificationService = class NotificationService {
|
|
675
|
+
#appRef = inject(ApplicationRef);
|
|
676
|
+
#containers = /* @__PURE__ */ new Map();
|
|
677
|
+
#defaults = inject(NOTIFICATION_DEFAULTS);
|
|
678
|
+
#directionality = inject(Directionality, { optional: true });
|
|
679
|
+
#document = inject(DOCUMENT);
|
|
680
|
+
#i18n = inject(MonaI18nService, { optional: true });
|
|
681
|
+
#destroyed = false;
|
|
682
|
+
constructor() {
|
|
683
|
+
inject(DestroyRef).onDestroy(() => {
|
|
684
|
+
this.#destroyed = true;
|
|
685
|
+
for (const container of this.#containers.values()) this.#destroyContainer(container);
|
|
686
|
+
this.#containers.clear();
|
|
687
|
+
});
|
|
688
|
+
}
|
|
689
|
+
hide(id) {
|
|
690
|
+
for (const container of this.#containers.values()) container.notifications.get(id)?.close();
|
|
691
|
+
}
|
|
692
|
+
hideAll() {
|
|
693
|
+
for (const container of [...this.#containers.values()]) for (const notification of [...container.notifications.values()]) notification.close();
|
|
694
|
+
}
|
|
695
|
+
show(options) {
|
|
696
|
+
const position = options.position ?? "topright";
|
|
697
|
+
const id = options.id ?? createElementControlId();
|
|
698
|
+
const existing = this.#containers.get(position)?.notifications.get(id);
|
|
699
|
+
if (existing && !existing.finished) return existing.ref;
|
|
700
|
+
const duration = options.duration != null && this.#defaults.autoHide ? options.duration * this.#defaults.durationScale : void 0;
|
|
701
|
+
const resolved = {
|
|
702
|
+
...options,
|
|
703
|
+
closable: options.closable ?? true,
|
|
704
|
+
duration,
|
|
705
|
+
id,
|
|
706
|
+
position,
|
|
707
|
+
type: options.type ?? "info"
|
|
708
|
+
};
|
|
709
|
+
const container = this.#containers.get(position) ?? this.#createContainer(position, options.appendTo);
|
|
710
|
+
const data = new NotificationData(resolved, (finished) => this.#remove(position, finished));
|
|
711
|
+
container.notifications.set(id, data);
|
|
712
|
+
this.#limit(container);
|
|
713
|
+
this.#sync(container);
|
|
714
|
+
return data.ref;
|
|
715
|
+
}
|
|
716
|
+
#createContainer(position, appendTo) {
|
|
717
|
+
const componentRef = createComponent(NotificationContainerComponent, { environmentInjector: this.#appRef.injector });
|
|
718
|
+
const element = componentRef.location.nativeElement;
|
|
719
|
+
const host = appendTo ? appendTo.element.nativeElement : this.#document.body;
|
|
720
|
+
componentRef.instance.position.set(position);
|
|
721
|
+
componentRef.instance.positionType.set(appendTo ? "absolute" : "fixed");
|
|
722
|
+
if (!appendTo) {
|
|
723
|
+
element.setAttribute("dir", this.#directionality?.value ?? "ltr");
|
|
724
|
+
const lang = this.#i18n?.localeId();
|
|
725
|
+
if (lang) element.setAttribute("lang", lang);
|
|
726
|
+
}
|
|
727
|
+
host.appendChild(element);
|
|
728
|
+
this.#appRef.attachView(componentRef.hostView);
|
|
729
|
+
componentRef.changeDetectorRef.detectChanges();
|
|
730
|
+
const container = {
|
|
731
|
+
componentRef,
|
|
732
|
+
notifications: /* @__PURE__ */ new Map()
|
|
733
|
+
};
|
|
734
|
+
this.#containers.set(position, container);
|
|
735
|
+
return container;
|
|
736
|
+
}
|
|
737
|
+
#destroyContainer(container) {
|
|
738
|
+
const { componentRef } = container;
|
|
739
|
+
if (!componentRef.hostView.destroyed) componentRef.destroy();
|
|
740
|
+
componentRef.location.nativeElement.remove();
|
|
741
|
+
}
|
|
742
|
+
#limit(container) {
|
|
743
|
+
const max = this.#defaults.maxVisible;
|
|
744
|
+
if (max == null || max < 1) return;
|
|
745
|
+
const open = [...container.notifications.values()].filter((notification) => !notification.closing());
|
|
746
|
+
for (const notification of open.slice(0, Math.max(0, open.length - max))) notification.close();
|
|
747
|
+
}
|
|
748
|
+
#remove(position, data) {
|
|
749
|
+
const container = this.#containers.get(position);
|
|
750
|
+
if (this.#destroyed || !container || container.notifications.get(data.id) !== data) return;
|
|
751
|
+
container.notifications.delete(data.id);
|
|
752
|
+
if (container.notifications.size === 0) {
|
|
753
|
+
this.#containers.delete(position);
|
|
754
|
+
this.#destroyContainer(container);
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
this.#sync(container);
|
|
758
|
+
}
|
|
759
|
+
#sync(container) {
|
|
760
|
+
container.componentRef.instance.notificationDataList.set([...container.notifications.values()]);
|
|
761
|
+
}
|
|
762
|
+
static {
|
|
763
|
+
this.ɵfac = i0.ɵɵngDeclareFactory({
|
|
764
|
+
minVersion: "12.0.0",
|
|
765
|
+
version: "22.2.6",
|
|
766
|
+
ngImport: i0,
|
|
767
|
+
type: NotificationService,
|
|
768
|
+
deps: [],
|
|
769
|
+
target: i0.ɵɵFactoryTarget.Injectable
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
static {
|
|
773
|
+
this.ɵprov = i0.ɵɵngDeclareInjectable({
|
|
774
|
+
minVersion: "12.0.0",
|
|
775
|
+
version: "22.2.6",
|
|
776
|
+
ngImport: i0,
|
|
777
|
+
type: NotificationService,
|
|
778
|
+
providedIn: "root"
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
};
|
|
782
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
783
|
+
minVersion: "12.0.0",
|
|
784
|
+
version: "22.2.6",
|
|
785
|
+
ngImport: i0,
|
|
786
|
+
type: NotificationService,
|
|
787
|
+
decorators: [{
|
|
788
|
+
type: Injectable,
|
|
789
|
+
args: [{ providedIn: "root" }]
|
|
790
|
+
}],
|
|
791
|
+
ctorParameters: () => []
|
|
792
|
+
});
|
|
701
793
|
function provideNotificationDefaults(defaults) {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
794
|
+
return makeEnvironmentProviders([{
|
|
795
|
+
provide: NOTIFICATION_DEFAULTS,
|
|
796
|
+
useValue: {
|
|
797
|
+
...DEFAULT_NOTIFICATION_DEFAULTS,
|
|
798
|
+
...defaults
|
|
799
|
+
}
|
|
800
|
+
}]);
|
|
705
801
|
}
|
|
706
|
-
|
|
707
|
-
/*
|
|
708
|
-
* Public API Surface of @nanahoshi/mona-ui/notification
|
|
709
|
-
*/
|
|
710
|
-
|
|
711
|
-
/**
|
|
712
|
-
* Generated bundle index. Do not edit.
|
|
713
|
-
*/
|
|
714
|
-
|
|
715
802
|
export { NOTIFICATION_DATA, NOTIFICATION_DEFAULTS, NOTIFICATION_DEFAULT_MESSAGES, NOTIFICATION_REF, NotificationService, provideNotificationDefaults };
|
|
716
|
-
|
|
803
|
+
|
|
804
|
+
//# sourceMappingURL=nanahoshi-mona-ui-notification.mjs.map
|