@molecule/app-ui-angular 1.0.6 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11710 -1117
- package/dist/components/accordion.component.d.ts +114 -0
- package/dist/components/accordion.component.d.ts.map +1 -0
- package/dist/components/accordion.component.js +286 -0
- package/dist/components/accordion.component.js.map +1 -0
- package/dist/components/alert.component.d.ts +81 -37
- package/dist/components/alert.component.d.ts.map +1 -1
- package/dist/components/alert.component.js +232 -146
- package/dist/components/alert.component.js.map +1 -1
- package/dist/components/auth-guard.component.d.ts +94 -0
- package/dist/components/auth-guard.component.d.ts.map +1 -0
- package/dist/components/auth-guard.component.js +212 -0
- package/dist/components/auth-guard.component.js.map +1 -0
- package/dist/components/avatar.component.d.ts +97 -0
- package/dist/components/avatar.component.d.ts.map +1 -0
- package/dist/components/avatar.component.js +216 -0
- package/dist/components/avatar.component.js.map +1 -0
- package/dist/components/badge.component.d.ts +27 -12
- package/dist/components/badge.component.d.ts.map +1 -1
- package/dist/components/badge.component.js +47 -47
- package/dist/components/badge.component.js.map +1 -1
- package/dist/components/button.component.d.ts +96 -14
- package/dist/components/button.component.d.ts.map +1 -1
- package/dist/components/button.component.js +232 -87
- package/dist/components/button.component.js.map +1 -1
- package/dist/components/card.component.d.ts +135 -0
- package/dist/components/card.component.d.ts.map +1 -0
- package/dist/components/card.component.js +291 -0
- package/dist/components/card.component.js.map +1 -0
- package/dist/components/checkbox.component.d.ts +97 -29
- package/dist/components/checkbox.component.d.ts.map +1 -1
- package/dist/components/checkbox.component.js +222 -117
- package/dist/components/checkbox.component.js.map +1 -1
- package/dist/components/confirm-button.component.d.ts +130 -0
- package/dist/components/confirm-button.component.d.ts.map +1 -0
- package/dist/components/confirm-button.component.js +322 -0
- package/dist/components/confirm-button.component.js.map +1 -0
- package/dist/components/confirm-dialog.component.d.ts +60 -0
- package/dist/components/confirm-dialog.component.d.ts.map +1 -0
- package/dist/components/confirm-dialog.component.js +152 -0
- package/dist/components/confirm-dialog.component.js.map +1 -0
- package/dist/components/controlled-checked.directive.d.ts +45 -0
- package/dist/components/controlled-checked.directive.d.ts.map +1 -0
- package/dist/components/controlled-checked.directive.js +74 -0
- package/dist/components/controlled-checked.directive.js.map +1 -0
- package/dist/components/dropdown.component.d.ts +313 -0
- package/dist/components/dropdown.component.d.ts.map +1 -0
- package/dist/components/dropdown.component.js +919 -0
- package/dist/components/dropdown.component.js.map +1 -0
- package/dist/components/empty-state.component.d.ts +73 -0
- package/dist/components/empty-state.component.d.ts.map +1 -0
- package/dist/components/empty-state.component.js +180 -0
- package/dist/components/empty-state.component.js.map +1 -0
- package/dist/components/floating-input.component.d.ts +86 -0
- package/dist/components/floating-input.component.d.ts.map +1 -0
- package/dist/components/floating-input.component.js +167 -0
- package/dist/components/floating-input.component.js.map +1 -0
- package/dist/components/form-field.component.d.ts +111 -0
- package/dist/components/form-field.component.d.ts.map +1 -0
- package/dist/components/form-field.component.js +300 -0
- package/dist/components/form-field.component.js.map +1 -0
- package/dist/components/form.component.d.ts +77 -0
- package/dist/components/form.component.d.ts.map +1 -0
- package/dist/components/form.component.js +222 -0
- package/dist/components/form.component.js.map +1 -0
- package/dist/components/icon.component.d.ts +85 -0
- package/dist/components/icon.component.d.ts.map +1 -0
- package/dist/components/icon.component.js +187 -0
- package/dist/components/icon.component.js.map +1 -0
- package/dist/components/index.d.ts +49 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +49 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/input.component.d.ts +157 -54
- package/dist/components/input.component.d.ts.map +1 -1
- package/dist/components/input.component.js +437 -222
- package/dist/components/input.component.js.map +1 -1
- package/dist/components/label.component.d.ts +29 -0
- package/dist/components/label.component.d.ts.map +1 -0
- package/dist/components/label.component.js +60 -0
- package/dist/components/label.component.js.map +1 -0
- package/dist/components/language-picker.component.d.ts +124 -0
- package/dist/components/language-picker.component.d.ts.map +1 -0
- package/dist/components/language-picker.component.js +305 -0
- package/dist/components/language-picker.component.js.map +1 -0
- package/dist/components/layout.component.d.ts +167 -0
- package/dist/components/layout.component.d.ts.map +1 -0
- package/dist/components/layout.component.js +364 -0
- package/dist/components/layout.component.js.map +1 -0
- package/dist/components/load-error-banner.component.d.ts +103 -0
- package/dist/components/load-error-banner.component.d.ts.map +1 -0
- package/dist/components/load-error-banner.component.js +263 -0
- package/dist/components/load-error-banner.component.js.map +1 -0
- package/dist/components/modal.component.d.ts +125 -95
- package/dist/components/modal.component.d.ts.map +1 -1
- package/dist/components/modal.component.js +458 -271
- package/dist/components/modal.component.js.map +1 -1
- package/dist/components/molecule/alert.component.d.ts +77 -0
- package/dist/components/molecule/alert.component.d.ts.map +1 -0
- package/dist/components/molecule/alert.component.js +229 -0
- package/dist/components/molecule/alert.component.js.map +1 -0
- package/dist/components/molecule/badge.component.d.ts +27 -0
- package/dist/components/molecule/badge.component.d.ts.map +1 -0
- package/dist/components/molecule/badge.component.js +79 -0
- package/dist/components/molecule/badge.component.js.map +1 -0
- package/dist/components/molecule/button.component.d.ts +38 -0
- package/dist/components/molecule/button.component.d.ts.map +1 -0
- package/dist/components/molecule/button.component.js +137 -0
- package/dist/components/molecule/button.component.js.map +1 -0
- package/dist/components/molecule/checkbox.component.d.ts +53 -0
- package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
- package/dist/components/molecule/checkbox.component.js +166 -0
- package/dist/components/molecule/checkbox.component.js.map +1 -0
- package/dist/components/molecule/index.d.ts +18 -0
- package/dist/components/molecule/index.d.ts.map +1 -0
- package/dist/components/molecule/index.js +18 -0
- package/dist/components/molecule/index.js.map +1 -0
- package/dist/components/molecule/input.component.d.ts +93 -0
- package/dist/components/molecule/input.component.d.ts.map +1 -0
- package/dist/components/molecule/input.component.js +314 -0
- package/dist/components/molecule/input.component.js.map +1 -0
- package/dist/components/molecule/modal.component.d.ts +148 -0
- package/dist/components/molecule/modal.component.d.ts.map +1 -0
- package/dist/components/molecule/modal.component.js +382 -0
- package/dist/components/molecule/modal.component.js.map +1 -0
- package/dist/components/molecule/radio-group.component.d.ts +63 -0
- package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
- package/dist/components/molecule/radio-group.component.js +208 -0
- package/dist/components/molecule/radio-group.component.js.map +1 -0
- package/dist/components/molecule/select.component.d.ts +72 -0
- package/dist/components/molecule/select.component.d.ts.map +1 -0
- package/dist/components/molecule/select.component.js +274 -0
- package/dist/components/molecule/select.component.js.map +1 -0
- package/dist/components/molecule/spinner.component.d.ts +42 -0
- package/dist/components/molecule/spinner.component.d.ts.map +1 -0
- package/dist/components/molecule/spinner.component.js +122 -0
- package/dist/components/molecule/spinner.component.js.map +1 -0
- package/dist/components/molecule/switch.component.d.ts +54 -0
- package/dist/components/molecule/switch.component.d.ts.map +1 -0
- package/dist/components/molecule/switch.component.js +148 -0
- package/dist/components/molecule/switch.component.js.map +1 -0
- package/dist/components/molecule/toast.component.d.ts +98 -0
- package/dist/components/molecule/toast.component.d.ts.map +1 -0
- package/dist/components/molecule/toast.component.js +305 -0
- package/dist/components/molecule/toast.component.js.map +1 -0
- package/dist/components/molecule/tooltip.component.d.ts +77 -0
- package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
- package/dist/components/molecule/tooltip.component.js +316 -0
- package/dist/components/molecule/tooltip.component.js.map +1 -0
- package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
- package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
- package/dist/components/optimistic-toggle-button.component.js +296 -0
- package/dist/components/optimistic-toggle-button.component.js.map +1 -0
- package/dist/components/page-header.component.d.ts +77 -0
- package/dist/components/page-header.component.d.ts.map +1 -0
- package/dist/components/page-header.component.js +225 -0
- package/dist/components/page-header.component.js.map +1 -0
- package/dist/components/page-shell.component.d.ts +101 -0
- package/dist/components/page-shell.component.d.ts.map +1 -0
- package/dist/components/page-shell.component.js +221 -0
- package/dist/components/page-shell.component.js.map +1 -0
- package/dist/components/pagination.component.d.ts +137 -0
- package/dist/components/pagination.component.d.ts.map +1 -0
- package/dist/components/pagination.component.js +419 -0
- package/dist/components/pagination.component.js.map +1 -0
- package/dist/components/panel-close.component.d.ts +43 -0
- package/dist/components/panel-close.component.d.ts.map +1 -0
- package/dist/components/panel-close.component.js +75 -0
- package/dist/components/panel-close.component.js.map +1 -0
- package/dist/components/progress.component.d.ts +84 -0
- package/dist/components/progress.component.d.ts.map +1 -0
- package/dist/components/progress.component.js +219 -0
- package/dist/components/progress.component.js.map +1 -0
- package/dist/components/prompt-dialog.component.d.ts +121 -0
- package/dist/components/prompt-dialog.component.d.ts.map +1 -0
- package/dist/components/prompt-dialog.component.js +332 -0
- package/dist/components/prompt-dialog.component.js.map +1 -0
- package/dist/components/radio-group.component.d.ts +66 -34
- package/dist/components/radio-group.component.d.ts.map +1 -1
- package/dist/components/radio-group.component.js +157 -134
- package/dist/components/radio-group.component.js.map +1 -1
- package/dist/components/responsive-app-shell.component.d.ts +408 -0
- package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
- package/dist/components/responsive-app-shell.component.js +1144 -0
- package/dist/components/responsive-app-shell.component.js.map +1 -0
- package/dist/components/select.component.d.ts +135 -38
- package/dist/components/select.component.d.ts.map +1 -1
- package/dist/components/select.component.js +373 -181
- package/dist/components/select.component.js.map +1 -1
- package/dist/components/separator.component.d.ts +39 -0
- package/dist/components/separator.component.d.ts.map +1 -0
- package/dist/components/separator.component.js +73 -0
- package/dist/components/separator.component.js.map +1 -0
- package/dist/components/sidebar-user-card.component.d.ts +106 -0
- package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
- package/dist/components/sidebar-user-card.component.js +277 -0
- package/dist/components/sidebar-user-card.component.js.map +1 -0
- package/dist/components/skeleton.component.d.ts +100 -0
- package/dist/components/skeleton.component.d.ts.map +1 -0
- package/dist/components/skeleton.component.js +214 -0
- package/dist/components/skeleton.component.js.map +1 -0
- package/dist/components/spinner.component.d.ts +36 -19
- package/dist/components/spinner.component.d.ts.map +1 -1
- package/dist/components/spinner.component.js +69 -71
- package/dist/components/spinner.component.js.map +1 -1
- package/dist/components/switch.component.d.ts +72 -29
- package/dist/components/switch.component.d.ts.map +1 -1
- package/dist/components/switch.component.js +168 -95
- package/dist/components/switch.component.js.map +1 -1
- package/dist/components/table.component.d.ts +193 -0
- package/dist/components/table.component.d.ts.map +1 -0
- package/dist/components/table.component.js +550 -0
- package/dist/components/table.component.js.map +1 -0
- package/dist/components/tabs.component.d.ts +140 -0
- package/dist/components/tabs.component.d.ts.map +1 -0
- package/dist/components/tabs.component.js +390 -0
- package/dist/components/tabs.component.js.map +1 -0
- package/dist/components/template-outlet.directive.d.ts +50 -0
- package/dist/components/template-outlet.directive.d.ts.map +1 -0
- package/dist/components/template-outlet.directive.js +81 -0
- package/dist/components/template-outlet.directive.js.map +1 -0
- package/dist/components/textarea.component.d.ts +151 -0
- package/dist/components/textarea.component.d.ts.map +1 -0
- package/dist/components/textarea.component.js +340 -0
- package/dist/components/textarea.component.js.map +1 -0
- package/dist/components/theme-toggle.component.d.ts +58 -0
- package/dist/components/theme-toggle.component.d.ts.map +1 -0
- package/dist/components/theme-toggle.component.js +124 -0
- package/dist/components/theme-toggle.component.js.map +1 -0
- package/dist/components/toast.component.d.ts +237 -49
- package/dist/components/toast.component.d.ts.map +1 -1
- package/dist/components/toast.component.js +636 -201
- package/dist/components/toast.component.js.map +1 -1
- package/dist/components/tooltip.component.d.ts +95 -45
- package/dist/components/tooltip.component.d.ts.map +1 -1
- package/dist/components/tooltip.component.js +372 -221
- package/dist/components/tooltip.component.js.map +1 -1
- package/dist/components/user-menu-popover.component.d.ts +283 -0
- package/dist/components/user-menu-popover.component.d.ts.map +1 -0
- package/dist/components/user-menu-popover.component.js +646 -0
- package/dist/components/user-menu-popover.component.js.map +1 -0
- package/dist/components/user-menu.component.d.ts +95 -0
- package/dist/components/user-menu.component.d.ts.map +1 -0
- package/dist/components/user-menu.component.js +218 -0
- package/dist/components/user-menu.component.js.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +7 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-is-desktop.d.ts +22 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/hooks/use-is-desktop.js +37 -0
- package/dist/hooks/use-is-desktop.js.map +1 -0
- package/dist/index.d.ts +32 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/utilities/dom-context.d.ts +42 -0
- package/dist/utilities/dom-context.d.ts.map +1 -0
- package/dist/utilities/dom-context.js +66 -0
- package/dist/utilities/dom-context.js.map +1 -0
- package/dist/utilities/focus.d.ts +32 -0
- package/dist/utilities/focus.d.ts.map +1 -0
- package/dist/utilities/focus.js +47 -0
- package/dist/utilities/focus.js.map +1 -0
- package/dist/utilities/form-field-context.d.ts +34 -0
- package/dist/utilities/form-field-context.d.ts.map +1 -0
- package/dist/utilities/form-field-context.js +28 -0
- package/dist/utilities/form-field-context.js.map +1 -0
- package/dist/utilities/form-submit-error.d.ts +17 -0
- package/dist/utilities/form-submit-error.d.ts.map +1 -0
- package/dist/utilities/form-submit-error.js +42 -0
- package/dist/utilities/form-submit-error.js.map +1 -0
- package/dist/utilities/icon-markup.d.ts +17 -0
- package/dist/utilities/icon-markup.d.ts.map +1 -0
- package/dist/utilities/icon-markup.js +46 -0
- package/dist/utilities/icon-markup.js.map +1 -0
- package/dist/utilities/ids.d.ts +15 -0
- package/dist/utilities/ids.d.ts.map +1 -0
- package/dist/utilities/ids.js +19 -0
- package/dist/utilities/ids.js.map +1 -0
- package/dist/utilities/index.d.ts +11 -0
- package/dist/utilities/index.d.ts.map +1 -1
- package/dist/utilities/index.js +11 -0
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/initials.d.ts +13 -0
- package/dist/utilities/initials.d.ts.map +1 -0
- package/dist/utilities/initials.js +23 -0
- package/dist/utilities/initials.js.map +1 -0
- package/dist/utilities/node-value.d.ts +31 -0
- package/dist/utilities/node-value.d.ts.map +1 -0
- package/dist/utilities/node-value.js +37 -0
- package/dist/utilities/node-value.js.map +1 -0
- package/dist/utilities/optimistic-value.d.ts +81 -0
- package/dist/utilities/optimistic-value.d.ts.map +1 -0
- package/dist/utilities/optimistic-value.js +154 -0
- package/dist/utilities/optimistic-value.js.map +1 -0
- package/dist/utilities/render-icon.d.ts +77 -7
- package/dist/utilities/render-icon.d.ts.map +1 -1
- package/dist/utilities/render-icon.js +123 -33
- package/dist/utilities/render-icon.js.map +1 -1
- package/dist/utilities/rest-attrs.d.ts +21 -0
- package/dist/utilities/rest-attrs.d.ts.map +1 -0
- package/dist/utilities/rest-attrs.js +37 -0
- package/dist/utilities/rest-attrs.js.map +1 -0
- package/dist/utilities/style.d.ts +23 -0
- package/dist/utilities/style.d.ts.map +1 -0
- package/dist/utilities/style.js +86 -0
- package/dist/utilities/style.js.map +1 -0
- package/package.json +6 -4
|
@@ -1,91 +1,77 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Toast family (React parity): Toast, ToastContainer, ToastProvider and the
|
|
3
|
+
* `useToast` hook.
|
|
3
4
|
*
|
|
4
5
|
* @module
|
|
5
6
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
7
|
+
import { Component, ElementRef, EventEmitter, inject, Output, Renderer2, signal, TemplateRef, ViewChild, } from '@angular/core';
|
|
8
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
9
|
+
import { I18nError } from '@molecule/app-i18n';
|
|
8
10
|
import { getClassMap } from '@molecule/app-ui';
|
|
9
|
-
import {
|
|
11
|
+
import { findDomContext, provideDomContext, removeDomContext } from '../utilities/dom-context.js';
|
|
12
|
+
import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
|
|
13
|
+
import { styleText } from '../utilities/style.js';
|
|
14
|
+
import { hasNodes, SlotWrapper } from './button.component.js';
|
|
15
|
+
import { MolTemplateOutlet } from './template-outlet.directive.js';
|
|
10
16
|
import * as i0 from "@angular/core";
|
|
11
|
-
const _c0 = ["
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
i0.ɵɵ
|
|
17
|
+
const _c0 = ["descriptionSlot"];
|
|
18
|
+
const _c1 = ["childrenSlot"];
|
|
19
|
+
const _c2 = ["*"];
|
|
20
|
+
function Toast_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
21
|
+
i0.ɵɵelementStart(0, "span");
|
|
22
|
+
i0.ɵɵnamespaceSVG();
|
|
23
|
+
i0.ɵɵelement(1, "svg", 5);
|
|
24
|
+
i0.ɵɵelementEnd();
|
|
16
25
|
} if (rf & 2) {
|
|
17
|
-
const ctx_r0 = i0.ɵɵnextContext(
|
|
18
|
-
i0.ɵɵclassMap(ctx_r0.cm.toastIconWrapper);
|
|
26
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
27
|
+
i0.ɵɵclassMap(ctx_r0.cm().toastIconWrapper);
|
|
19
28
|
i0.ɵɵadvance();
|
|
20
|
-
i0.ɵɵ
|
|
29
|
+
i0.ɵɵproperty("data", ctx);
|
|
21
30
|
} }
|
|
22
|
-
function
|
|
23
|
-
i0.ɵɵ
|
|
31
|
+
function Toast_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
32
|
+
i0.ɵɵelementStart(0, "div");
|
|
24
33
|
i0.ɵɵtext(1);
|
|
25
|
-
i0.ɵɵ
|
|
34
|
+
i0.ɵɵelementEnd();
|
|
26
35
|
} if (rf & 2) {
|
|
27
|
-
const ctx_r0 = i0.ɵɵnextContext(
|
|
28
|
-
i0.ɵɵclassMap(ctx_r0.
|
|
36
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
37
|
+
i0.ɵɵclassMap(ctx_r0.cm().toastTitle);
|
|
29
38
|
i0.ɵɵadvance();
|
|
30
39
|
i0.ɵɵtextInterpolate(ctx_r0.title);
|
|
31
40
|
} }
|
|
32
|
-
function
|
|
33
|
-
i0.ɵɵ
|
|
34
|
-
i0.ɵɵtext(1);
|
|
35
|
-
i0.ɵɵdomElementEnd();
|
|
36
|
-
} if (rf & 2) {
|
|
37
|
-
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
38
|
-
i0.ɵɵclassMap(ctx_r0.descriptionClass);
|
|
39
|
-
i0.ɵɵadvance();
|
|
40
|
-
i0.ɵɵtextInterpolate(ctx_r0.description);
|
|
41
|
-
} }
|
|
42
|
-
function MoleculeToast_Conditional_0_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
43
|
-
i0.ɵɵdomElementStart(0, "div");
|
|
44
|
-
i0.ɵɵprojection(1);
|
|
45
|
-
i0.ɵɵdomElementEnd();
|
|
41
|
+
function Toast_Conditional_5_Template(rf, ctx) { if (rf & 1) {
|
|
42
|
+
i0.ɵɵtext(0);
|
|
46
43
|
} if (rf & 2) {
|
|
47
|
-
|
|
48
|
-
i0.ɵɵclassMap(ctx_r0.descriptionClass);
|
|
44
|
+
i0.ɵɵtextInterpolate1(" ", ctx, " ");
|
|
49
45
|
} }
|
|
50
|
-
function
|
|
46
|
+
function Toast_Conditional_10_Template(rf, ctx) { if (rf & 1) {
|
|
51
47
|
const _r2 = i0.ɵɵgetCurrentView();
|
|
52
|
-
i0.ɵɵ
|
|
53
|
-
i0.ɵɵ
|
|
54
|
-
i0.ɵɵ
|
|
55
|
-
i0.ɵɵ
|
|
48
|
+
i0.ɵɵelementStart(0, "button", 6);
|
|
49
|
+
i0.ɵɵlistener("click", function Toast_Conditional_10_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.handleDismiss()); });
|
|
50
|
+
i0.ɵɵnamespaceSVG();
|
|
51
|
+
i0.ɵɵelement(1, "svg", 5);
|
|
52
|
+
i0.ɵɵelementEnd();
|
|
56
53
|
} if (rf & 2) {
|
|
57
|
-
const ctx_r0 = i0.ɵɵnextContext(
|
|
58
|
-
i0.ɵɵclassMap(ctx_r0.
|
|
59
|
-
i0.ɵɵattribute("aria-label", ctx_r0.
|
|
54
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
55
|
+
i0.ɵɵclassMap(ctx_r0.cm().toastClose);
|
|
56
|
+
i0.ɵɵattribute("aria-label", ctx_r0.closeText());
|
|
60
57
|
i0.ɵɵadvance();
|
|
61
|
-
i0.ɵɵ
|
|
58
|
+
i0.ɵɵproperty("data", ctx_r0.closeIcon());
|
|
62
59
|
} }
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
i0.ɵɵ
|
|
68
|
-
i0.ɵɵ
|
|
69
|
-
i0.ɵɵ
|
|
70
|
-
i0.ɵɵ
|
|
71
|
-
i0.ɵɵdomElementEnd();
|
|
60
|
+
const _c3 = ["container"];
|
|
61
|
+
const _c4 = ["childrenCapture"];
|
|
62
|
+
const _forTrack0 = ($index, $item) => $item.id;
|
|
63
|
+
function ToastProvider_For_6_Template(rf, ctx) { if (rf & 1) {
|
|
64
|
+
const _r1 = i0.ɵɵgetCurrentView();
|
|
65
|
+
i0.ɵɵelementStart(0, "div", 3);
|
|
66
|
+
i0.ɵɵlistener("dismiss", function ToastProvider_For_6_Template_div_dismiss_0_listener() { const toast_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.removeToast(toast_r2.id)); });
|
|
67
|
+
i0.ɵɵelementEnd();
|
|
72
68
|
} if (rf & 2) {
|
|
73
|
-
const
|
|
74
|
-
i0.ɵɵstyleMap(
|
|
75
|
-
i0.ɵɵ
|
|
76
|
-
i0.ɵɵattribute("data-testid", ctx_r0.testId);
|
|
77
|
-
i0.ɵɵadvance();
|
|
78
|
-
i0.ɵɵconditional(ctx_r0.showIcon ? 1 : -1);
|
|
79
|
-
i0.ɵɵadvance();
|
|
80
|
-
i0.ɵɵclassMap(ctx_r0.cm.toastContentWrapper);
|
|
81
|
-
i0.ɵɵadvance();
|
|
82
|
-
i0.ɵɵconditional(ctx_r0.title ? 3 : -1);
|
|
83
|
-
i0.ɵɵadvance();
|
|
84
|
-
i0.ɵɵconditional(ctx_r0.description ? 4 : 5);
|
|
85
|
-
i0.ɵɵadvance(2);
|
|
86
|
-
i0.ɵɵconditional(ctx_r0.dismissible ? 6 : -1);
|
|
69
|
+
const toast_r2 = ctx.$implicit;
|
|
70
|
+
i0.ɵɵstyleMap(toast_r2.style);
|
|
71
|
+
i0.ɵɵproperty("title", toast_r2.title)("description", toast_r2.description)("status", toast_r2.status ?? "info")("duration", toast_r2.duration ?? 5000)("dismissible", toast_r2.dismissible ?? true)("closeLabel", toast_r2.closeLabel)("className", toast_r2.className)("testId", toast_r2.testId);
|
|
87
72
|
} }
|
|
88
|
-
|
|
73
|
+
/** Toast status → class-map variant. */
|
|
74
|
+
const STATUS_VARIANT = {
|
|
89
75
|
primary: 'default',
|
|
90
76
|
secondary: 'default',
|
|
91
77
|
success: 'success',
|
|
@@ -93,206 +79,655 @@ const statusVariantMap = {
|
|
|
93
79
|
error: 'error',
|
|
94
80
|
info: 'info',
|
|
95
81
|
};
|
|
82
|
+
/** Toast status variant → default glyph name. */
|
|
83
|
+
const STATUS_ICON = {
|
|
84
|
+
info: 'info-circle',
|
|
85
|
+
success: 'check-circle',
|
|
86
|
+
warning: 'exclamation-triangle',
|
|
87
|
+
error: 'x-circle',
|
|
88
|
+
};
|
|
89
|
+
/** Module-global toast id counter (React's `toastCounter`). */
|
|
90
|
+
let toastCounter = 0;
|
|
96
91
|
/**
|
|
97
|
-
*
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
*
|
|
92
|
+
* Toast component.
|
|
93
|
+
*
|
|
94
|
+
* The host is the toast `<div>` (`div[mol-toast]`), exactly React's root. The
|
|
95
|
+
* auto-dismiss countdown pauses on hover AND focus (WCAG 2.2.1) and resumes
|
|
96
|
+
* with the remaining time; the announced role follows `status`
|
|
97
|
+
* (`warning`/`error` assertive, everything else polite).
|
|
101
98
|
*/
|
|
102
|
-
export class
|
|
99
|
+
export class Toast {
|
|
100
|
+
/** The toast title. */
|
|
103
101
|
title;
|
|
102
|
+
/** The toast description (a string or a node value rendered as a template). */
|
|
104
103
|
description;
|
|
104
|
+
/** The toast status. */
|
|
105
105
|
status = 'info';
|
|
106
|
+
/** Auto-dismiss delay in ms (`0` keeps it until dismissed). */
|
|
106
107
|
duration = 5000;
|
|
108
|
+
/** Whether the close button renders. */
|
|
107
109
|
dismissible = true;
|
|
110
|
+
/** The close button's accessible label. */
|
|
108
111
|
closeLabel;
|
|
109
|
-
|
|
112
|
+
/** Extra classes. */
|
|
110
113
|
className;
|
|
114
|
+
/** Inline style object (React camelCase). */
|
|
111
115
|
style;
|
|
116
|
+
/** `data-testid`. */
|
|
112
117
|
testId;
|
|
118
|
+
/** Accepted for prop parity; positioning is the container's job. */
|
|
119
|
+
position;
|
|
120
|
+
/** Fires when the toast dismisses itself or its close button is pressed. */
|
|
113
121
|
dismiss = new EventEmitter();
|
|
114
|
-
|
|
122
|
+
/** The description wrapper (always in the template; detached when empty). */
|
|
123
|
+
descriptionSlot;
|
|
124
|
+
/** The children capture point. */
|
|
125
|
+
childrenSlot;
|
|
126
|
+
/** Whether the toast is still rendered (React's `isVisible`). */
|
|
127
|
+
visible = signal(true, /* @ts-ignore */
|
|
128
|
+
...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
|
|
129
|
+
el = inject(ElementRef);
|
|
130
|
+
/**
|
|
131
|
+
* Reactive translation, read in the injection context. Its `t` reads the
|
|
132
|
+
* locale, so the view re-renders the text on a locale switch (the static `t`
|
|
133
|
+
* does not).
|
|
134
|
+
*/
|
|
135
|
+
i18n = useTranslation();
|
|
136
|
+
renderer = inject(Renderer2);
|
|
137
|
+
host = this.el.nativeElement;
|
|
138
|
+
sync = new SlotWrapper(this.el, this.renderer);
|
|
139
|
+
remaining;
|
|
140
|
+
startedAt = null;
|
|
115
141
|
timer;
|
|
142
|
+
lastDuration;
|
|
143
|
+
descriptionParent = null;
|
|
144
|
+
childrenParent = null;
|
|
145
|
+
hasChildren = false;
|
|
146
|
+
adoptedChildren = [];
|
|
147
|
+
detachedParent = null;
|
|
148
|
+
detachedAnchor = null;
|
|
149
|
+
/** Prepares the countdown state (the timer starts at view init). */
|
|
150
|
+
constructor() {
|
|
151
|
+
this.remaining = this.duration;
|
|
152
|
+
this.lastDuration = this.duration;
|
|
153
|
+
}
|
|
116
154
|
/**
|
|
117
|
-
*
|
|
118
|
-
* @returns The UIClassMap
|
|
155
|
+
* The current class map.
|
|
156
|
+
* @returns The UIClassMap.
|
|
119
157
|
*/
|
|
120
|
-
|
|
158
|
+
cm() {
|
|
121
159
|
return getClassMap();
|
|
122
160
|
}
|
|
123
161
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @returns The
|
|
162
|
+
* The mapped class-map variant.
|
|
163
|
+
* @returns The variant.
|
|
126
164
|
*/
|
|
127
|
-
|
|
128
|
-
return this.
|
|
165
|
+
variant() {
|
|
166
|
+
return STATUS_VARIANT[this.status] || 'default';
|
|
129
167
|
}
|
|
130
168
|
/**
|
|
131
|
-
*
|
|
132
|
-
* @returns The
|
|
169
|
+
* The toast class list.
|
|
170
|
+
* @returns The class string.
|
|
133
171
|
*/
|
|
134
|
-
|
|
135
|
-
return this.cm.
|
|
172
|
+
classes() {
|
|
173
|
+
return this.cm().cn(this.cm().toast({ variant: this.variant() }), this.className);
|
|
136
174
|
}
|
|
137
175
|
/**
|
|
138
|
-
*
|
|
139
|
-
* @returns The
|
|
176
|
+
* Serializes the inline style.
|
|
177
|
+
* @returns The style attribute text.
|
|
140
178
|
*/
|
|
141
|
-
|
|
142
|
-
return this.
|
|
179
|
+
hostStyle() {
|
|
180
|
+
return styleText(this.style);
|
|
143
181
|
}
|
|
144
182
|
/**
|
|
145
|
-
*
|
|
146
|
-
* @returns The
|
|
183
|
+
* The announced role: assertive for warnings/errors, polite otherwise.
|
|
184
|
+
* @returns The role attribute value.
|
|
147
185
|
*/
|
|
148
|
-
|
|
149
|
-
return this.
|
|
186
|
+
role() {
|
|
187
|
+
return this.variant() === 'warning' || this.variant() === 'error' ? 'alert' : 'status';
|
|
150
188
|
}
|
|
151
189
|
/**
|
|
152
|
-
*
|
|
153
|
-
* @returns The
|
|
190
|
+
* The status glyph, when the variant has one.
|
|
191
|
+
* @returns The resolved icon, or null.
|
|
154
192
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
193
|
+
statusIcon() {
|
|
194
|
+
const name = STATUS_ICON[this.variant()];
|
|
195
|
+
return name ? resolveIcon(name, this.cm().iconMd) : null;
|
|
157
196
|
}
|
|
158
197
|
/**
|
|
159
|
-
*
|
|
160
|
-
* @returns
|
|
198
|
+
* The close button's X glyph.
|
|
199
|
+
* @returns The resolved icon.
|
|
161
200
|
*/
|
|
162
|
-
|
|
163
|
-
return this.
|
|
164
|
-
}
|
|
165
|
-
statusIconMap = {
|
|
166
|
-
info: 'info-circle',
|
|
167
|
-
success: 'check-circle',
|
|
168
|
-
warning: 'exclamation-triangle',
|
|
169
|
-
error: 'x-circle',
|
|
170
|
-
};
|
|
201
|
+
closeIcon() {
|
|
202
|
+
return resolveIcon('x-mark', this.cm().iconSm);
|
|
203
|
+
}
|
|
171
204
|
/**
|
|
172
|
-
*
|
|
173
|
-
* @returns The
|
|
205
|
+
* The string description, when the description is a string.
|
|
206
|
+
* @returns The text, or null.
|
|
174
207
|
*/
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
return name ? getIconSvg(name, this.cm.iconMd) : '';
|
|
208
|
+
descriptionText() {
|
|
209
|
+
return typeof this.description === 'string' ? this.description : null;
|
|
178
210
|
}
|
|
179
211
|
/**
|
|
180
|
-
*
|
|
181
|
-
* @returns The
|
|
212
|
+
* The description as a template, when it is a node value.
|
|
213
|
+
* @returns The template, or null.
|
|
182
214
|
*/
|
|
183
|
-
|
|
184
|
-
return
|
|
215
|
+
descriptionTemplate() {
|
|
216
|
+
return this.description instanceof TemplateRef ? this.description : null;
|
|
185
217
|
}
|
|
186
218
|
/**
|
|
187
|
-
*
|
|
188
|
-
* @returns The
|
|
219
|
+
* The close button's accessible label.
|
|
220
|
+
* @returns The label text.
|
|
189
221
|
*/
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
222
|
+
closeText() {
|
|
223
|
+
return this.closeLabel ?? this.i18n.t('ui.toast.close', undefined, { defaultValue: 'Close' });
|
|
224
|
+
}
|
|
225
|
+
/** Dismisses the toast and calls the callback (React's `handleDismiss`). */
|
|
226
|
+
handleDismiss() {
|
|
227
|
+
this.visible.set(false);
|
|
228
|
+
this.dismiss.emit();
|
|
229
|
+
}
|
|
230
|
+
/** Pauses the countdown, keeping the time left (React's `pauseTimer`). */
|
|
231
|
+
pauseTimer() {
|
|
232
|
+
if (this.startedAt === null)
|
|
233
|
+
return;
|
|
234
|
+
const elapsed = Date.now() - this.startedAt;
|
|
235
|
+
this.remaining = Math.max(0, this.remaining - elapsed);
|
|
236
|
+
this.clearTimer();
|
|
237
|
+
}
|
|
238
|
+
/** Resumes the countdown with the remaining time (React's `resumeTimer`). */
|
|
239
|
+
resumeTimer() {
|
|
240
|
+
if (this.remaining > 0)
|
|
241
|
+
this.startTimer(this.remaining);
|
|
193
242
|
}
|
|
194
243
|
/**
|
|
195
|
-
*
|
|
244
|
+
* Detects the first view and the `duration` input changes, and starts the
|
|
245
|
+
* countdown (React's mount effect, with `[duration]` deps).
|
|
196
246
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
}
|
|
247
|
+
ngAfterViewInit() {
|
|
248
|
+
this.descriptionParent = this.descriptionSlot?.nativeElement.parentElement ?? null;
|
|
249
|
+
this.childrenParent = this.childrenSlot?.nativeElement.parentElement ?? null;
|
|
250
|
+
this.hasChildren = hasNodes(this.childrenSlot?.nativeElement);
|
|
251
|
+
this.adoptChildren();
|
|
252
|
+
this.restart();
|
|
204
253
|
}
|
|
205
254
|
/**
|
|
206
|
-
*
|
|
255
|
+
* Re-reconciles children visibility on later passes.
|
|
207
256
|
*/
|
|
257
|
+
ngDoCheck() {
|
|
258
|
+
if (this.duration !== this.lastDuration) {
|
|
259
|
+
this.lastDuration = this.duration;
|
|
260
|
+
this.restart();
|
|
261
|
+
}
|
|
262
|
+
this.syncDescription();
|
|
263
|
+
this.syncHostVisibility();
|
|
264
|
+
}
|
|
265
|
+
/** Stops the countdown (React's unmount cleanup). */
|
|
208
266
|
ngOnDestroy() {
|
|
267
|
+
this.clearTimer();
|
|
268
|
+
this.adoptedChildren = [];
|
|
269
|
+
// The host must be inside its parent for Angular's own removal to succeed.
|
|
270
|
+
if (!this.host.isConnected && this.detachedParent) {
|
|
271
|
+
this.detachedParent.insertBefore(this.host, this.detachedAnchor);
|
|
272
|
+
this.detachedParent = null;
|
|
273
|
+
this.detachedAnchor = null;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** React's effect body: reset the remaining time and start counting. */
|
|
277
|
+
restart() {
|
|
278
|
+
this.remaining = this.duration;
|
|
279
|
+
this.startTimer(this.duration);
|
|
280
|
+
}
|
|
281
|
+
/** Clears the running timer (React's `clearTimer`). */
|
|
282
|
+
clearTimer() {
|
|
209
283
|
if (this.timer) {
|
|
210
284
|
clearTimeout(this.timer);
|
|
285
|
+
this.timer = undefined;
|
|
211
286
|
}
|
|
287
|
+
this.startedAt = null;
|
|
212
288
|
}
|
|
213
289
|
/**
|
|
214
|
-
*
|
|
290
|
+
* Starts the countdown (React's `startTimer`).
|
|
291
|
+
* @param ms - Milliseconds until dismissal.
|
|
215
292
|
*/
|
|
216
|
-
|
|
217
|
-
this.
|
|
218
|
-
|
|
293
|
+
startTimer(ms) {
|
|
294
|
+
this.clearTimer();
|
|
295
|
+
if (ms <= 0)
|
|
296
|
+
return;
|
|
297
|
+
this.startedAt = Date.now();
|
|
298
|
+
this.timer = setTimeout(() => {
|
|
299
|
+
this.visible.set(false);
|
|
300
|
+
this.dismiss.emit();
|
|
301
|
+
}, ms);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Moves the projected children into the description wrapper (React renders
|
|
305
|
+
* them there) unless the description prop wins.
|
|
306
|
+
*/
|
|
307
|
+
adoptChildren() {
|
|
308
|
+
const span = this.childrenSlot?.nativeElement;
|
|
309
|
+
if (!span)
|
|
310
|
+
return;
|
|
311
|
+
const wrapper = this.descriptionSlot?.nativeElement;
|
|
312
|
+
const descWins = this.descriptionText() !== null || this.descriptionTemplate() !== null;
|
|
313
|
+
if (wrapper && !descWins && this.hasChildren) {
|
|
314
|
+
this.adoptedChildren = Array.from(span.childNodes);
|
|
315
|
+
for (const node of this.adoptedChildren)
|
|
316
|
+
wrapper.appendChild(node);
|
|
317
|
+
}
|
|
318
|
+
this.sync.sync(span, false, this.childrenParent ?? undefined);
|
|
319
|
+
this.syncDescription();
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Removes the host element from the DOM when React renders null (the toast
|
|
323
|
+
* dismissed itself), and restores it before Angular removes it on destroy.
|
|
324
|
+
*/
|
|
325
|
+
syncHostVisibility() {
|
|
326
|
+
const host = this.host;
|
|
327
|
+
if (!this.visible()) {
|
|
328
|
+
if (host.isConnected) {
|
|
329
|
+
this.detachedParent = host.parentNode;
|
|
330
|
+
this.detachedAnchor = host.nextSibling;
|
|
331
|
+
host.parentNode?.removeChild(host);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
else if (this.detachedParent && !host.isConnected) {
|
|
335
|
+
this.detachedParent.insertBefore(host, this.detachedAnchor);
|
|
336
|
+
this.detachedParent = null;
|
|
337
|
+
this.detachedAnchor = null;
|
|
338
|
+
}
|
|
219
339
|
}
|
|
220
|
-
|
|
221
|
-
|
|
340
|
+
/** Applies React's `{!!(description || children) && <div>…</div>}`. */
|
|
341
|
+
syncDescription() {
|
|
342
|
+
const wrapper = this.descriptionSlot?.nativeElement;
|
|
343
|
+
if (!wrapper)
|
|
344
|
+
return;
|
|
345
|
+
const hasDescription = this.descriptionText() !== null || this.descriptionTemplate() !== null;
|
|
346
|
+
this.sync.sync(wrapper, hasDescription || this.hasChildren, this.descriptionParent ?? undefined);
|
|
347
|
+
}
|
|
348
|
+
static ɵfac = function Toast_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Toast)(); };
|
|
349
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Toast, selectors: [["div", "mol-toast", ""]], viewQuery: function Toast_Query(rf, ctx) { if (rf & 1) {
|
|
350
|
+
i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
|
|
351
|
+
} if (rf & 2) {
|
|
352
|
+
let _t;
|
|
353
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.descriptionSlot = _t.first);
|
|
354
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenSlot = _t.first);
|
|
355
|
+
} }, hostVars: 7, hostBindings: function Toast_HostBindings(rf, ctx) { if (rf & 1) {
|
|
356
|
+
i0.ɵɵlistener("mouseenter", function Toast_mouseenter_HostBindingHandler() { return ctx.pauseTimer(); })("mouseleave", function Toast_mouseleave_HostBindingHandler() { return ctx.resumeTimer(); })("focusin", function Toast_focusin_HostBindingHandler() { return ctx.pauseTimer(); })("focusout", function Toast_focusout_HostBindingHandler() { return ctx.resumeTimer(); });
|
|
357
|
+
} if (rf & 2) {
|
|
358
|
+
i0.ɵɵattribute("data-testid", ctx.testId)("role", ctx.role())("data-state", ctx.visible() ? "open" : null);
|
|
359
|
+
i0.ɵɵstyleMap(ctx.hostStyle());
|
|
360
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
361
|
+
} }, inputs: { title: "title", description: "description", status: "status", duration: "duration", dismissible: "dismissible", closeLabel: "closeLabel", className: "className", style: "style", testId: "testId", position: "position" }, outputs: { dismiss: "dismiss" }, ngContentSelectors: _c2, decls: 11, vars: 9, consts: [["descriptionSlot", ""], ["childrenSlot", ""], [3, "class"], [3, "molTemplateOutlet"], ["type", "button", 3, "class"], ["mol-icon", "", 3, "data"], ["type", "button", 3, "click"]], template: function Toast_Template(rf, ctx) { if (rf & 1) {
|
|
222
362
|
i0.ɵɵprojectionDef();
|
|
223
|
-
i0.ɵɵconditionalCreate(0,
|
|
363
|
+
i0.ɵɵconditionalCreate(0, Toast_Conditional_0_Template, 2, 3, "span", 2);
|
|
364
|
+
i0.ɵɵelementStart(1, "div");
|
|
365
|
+
i0.ɵɵconditionalCreate(2, Toast_Conditional_2_Template, 2, 3, "div", 2);
|
|
366
|
+
i0.ɵɵelementStart(3, "div", null, 0);
|
|
367
|
+
i0.ɵɵconditionalCreate(5, Toast_Conditional_5_Template, 1, 1);
|
|
368
|
+
i0.ɵɵelementContainer(6, 3);
|
|
369
|
+
i0.ɵɵelementStart(7, "span", null, 1);
|
|
370
|
+
i0.ɵɵprojection(9);
|
|
371
|
+
i0.ɵɵelementEnd()()();
|
|
372
|
+
i0.ɵɵconditionalCreate(10, Toast_Conditional_10_Template, 2, 4, "button", 4);
|
|
224
373
|
} if (rf & 2) {
|
|
225
|
-
|
|
226
|
-
|
|
374
|
+
let tmp_2_0;
|
|
375
|
+
let tmp_6_0;
|
|
376
|
+
i0.ɵɵconditional((tmp_2_0 = ctx.statusIcon()) ? 0 : -1, tmp_2_0);
|
|
377
|
+
i0.ɵɵadvance();
|
|
378
|
+
i0.ɵɵclassMap(ctx.cm().toastContentWrapper);
|
|
379
|
+
i0.ɵɵadvance();
|
|
380
|
+
i0.ɵɵconditional(ctx.title ? 2 : -1);
|
|
381
|
+
i0.ɵɵadvance();
|
|
382
|
+
i0.ɵɵclassMap(ctx.cm().toastDescription);
|
|
383
|
+
i0.ɵɵadvance(2);
|
|
384
|
+
i0.ɵɵconditional((tmp_6_0 = ctx.descriptionText()) ? 5 : -1, tmp_6_0);
|
|
385
|
+
i0.ɵɵadvance();
|
|
386
|
+
i0.ɵɵproperty("molTemplateOutlet", ctx.descriptionTemplate());
|
|
387
|
+
i0.ɵɵadvance(4);
|
|
388
|
+
i0.ɵɵconditional(ctx.dismissible ? 10 : -1);
|
|
389
|
+
} }, dependencies: [MolIconSvg, MolTemplateOutlet], encapsulation: 2 });
|
|
227
390
|
}
|
|
228
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(
|
|
391
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Toast, [{
|
|
229
392
|
type: Component,
|
|
230
393
|
args: [{
|
|
231
|
-
selector: 'mol-toast',
|
|
394
|
+
selector: 'div[mol-toast]',
|
|
232
395
|
standalone: true,
|
|
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
|
-
</button>
|
|
396
|
+
imports: [MolIconSvg, MolTemplateOutlet],
|
|
397
|
+
inputs: [
|
|
398
|
+
'title',
|
|
399
|
+
'description',
|
|
400
|
+
'status',
|
|
401
|
+
'duration',
|
|
402
|
+
'dismissible',
|
|
403
|
+
'closeLabel',
|
|
404
|
+
'className',
|
|
405
|
+
'style',
|
|
406
|
+
'testId',
|
|
407
|
+
'position',
|
|
408
|
+
],
|
|
409
|
+
outputs: ['dismiss'],
|
|
410
|
+
host: {
|
|
411
|
+
'[class]': 'classes()',
|
|
412
|
+
'[style]': 'hostStyle()',
|
|
413
|
+
'[attr.data-testid]': 'testId',
|
|
414
|
+
'[attr.role]': 'role()',
|
|
415
|
+
'[attr.data-state]': 'visible() ? "open" : null',
|
|
416
|
+
'(mouseenter)': 'pauseTimer()',
|
|
417
|
+
'(mouseleave)': 'resumeTimer()',
|
|
418
|
+
'(focusin)': 'pauseTimer()',
|
|
419
|
+
'(focusout)': 'resumeTimer()',
|
|
420
|
+
},
|
|
421
|
+
template: `@if (statusIcon(); as icon) {
|
|
422
|
+
<span [class]="cm().toastIconWrapper"><svg mol-icon [data]="icon" /></span>
|
|
423
|
+
}
|
|
424
|
+
<div [class]="cm().toastContentWrapper">
|
|
425
|
+
@if (title) {
|
|
426
|
+
<div [class]="cm().toastTitle">{{ title }}</div>
|
|
427
|
+
}
|
|
428
|
+
<div #descriptionSlot [class]="cm().toastDescription">
|
|
429
|
+
@if (descriptionText(); as descriptionTextValue) {
|
|
430
|
+
{{ descriptionTextValue }}
|
|
269
431
|
}
|
|
432
|
+
<ng-container [molTemplateOutlet]="descriptionTemplate()"></ng-container
|
|
433
|
+
><span #childrenSlot><ng-content></ng-content></span>
|
|
270
434
|
</div>
|
|
271
|
-
|
|
272
|
-
|
|
435
|
+
</div>
|
|
436
|
+
@if (dismissible) {
|
|
437
|
+
<button
|
|
438
|
+
type="button"
|
|
439
|
+
[class]="cm().toastClose"
|
|
440
|
+
[attr.aria-label]="closeText()"
|
|
441
|
+
(click)="handleDismiss()"
|
|
442
|
+
>
|
|
443
|
+
<svg mol-icon [data]="closeIcon()" />
|
|
444
|
+
</button>
|
|
445
|
+
}`,
|
|
273
446
|
}]
|
|
274
|
-
}],
|
|
275
|
-
type: Input
|
|
276
|
-
}], description: [{
|
|
277
|
-
type: Input
|
|
278
|
-
}], status: [{
|
|
279
|
-
type: Input
|
|
280
|
-
}], duration: [{
|
|
281
|
-
type: Input
|
|
282
|
-
}], dismissible: [{
|
|
283
|
-
type: Input
|
|
284
|
-
}], closeLabel: [{
|
|
285
|
-
type: Input
|
|
286
|
-
}], position: [{
|
|
287
|
-
type: Input
|
|
288
|
-
}], className: [{
|
|
289
|
-
type: Input
|
|
290
|
-
}], style: [{
|
|
291
|
-
type: Input
|
|
292
|
-
}], testId: [{
|
|
293
|
-
type: Input
|
|
294
|
-
}], dismiss: [{
|
|
447
|
+
}], () => [], { dismiss: [{
|
|
295
448
|
type: Output
|
|
449
|
+
}], descriptionSlot: [{
|
|
450
|
+
type: ViewChild,
|
|
451
|
+
args: ['descriptionSlot']
|
|
452
|
+
}], childrenSlot: [{
|
|
453
|
+
type: ViewChild,
|
|
454
|
+
args: ['childrenSlot']
|
|
455
|
+
}] }); })();
|
|
456
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Toast, { className: "Toast", filePath: "components/toast.component.ts", lineNumber: 139 }); })();
|
|
457
|
+
/**
|
|
458
|
+
* Toast container: positions toasts on screen via a body portal.
|
|
459
|
+
*
|
|
460
|
+
* React's root is a portal, so the host is unwrapped
|
|
461
|
+
* (`data-parity-unwrap`, `display: contents`) and the container `<div>` is
|
|
462
|
+
* moved into `document.body`.
|
|
463
|
+
*/
|
|
464
|
+
export class ToastContainer {
|
|
465
|
+
/** The container position (default `bottom-right`). */
|
|
466
|
+
position = 'bottom-right';
|
|
467
|
+
/** Extra classes. */
|
|
468
|
+
className;
|
|
469
|
+
/** The container element (moved to `document.body`). */
|
|
470
|
+
container;
|
|
471
|
+
host = inject(ElementRef);
|
|
472
|
+
/**
|
|
473
|
+
* The current class map.
|
|
474
|
+
* @returns The UIClassMap.
|
|
475
|
+
*/
|
|
476
|
+
cm() {
|
|
477
|
+
return getClassMap();
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* The container class list.
|
|
481
|
+
* @returns The class string.
|
|
482
|
+
*/
|
|
483
|
+
classes() {
|
|
484
|
+
return this.cm().cn(this.cm().toastContainer({ position: this.position }), this.className);
|
|
485
|
+
}
|
|
486
|
+
/** Moves the container to `document.body` (React's portal). */
|
|
487
|
+
ngAfterViewInit() {
|
|
488
|
+
const el = this.container?.nativeElement;
|
|
489
|
+
if (el && typeof document !== 'undefined')
|
|
490
|
+
document.body.appendChild(el);
|
|
491
|
+
}
|
|
492
|
+
/** Moves the container back under the host so Angular can remove it. */
|
|
493
|
+
ngOnDestroy() {
|
|
494
|
+
const el = this.container?.nativeElement;
|
|
495
|
+
if (el && this.host.nativeElement.parentNode)
|
|
496
|
+
this.host.nativeElement.appendChild(el);
|
|
497
|
+
}
|
|
498
|
+
static ɵfac = function ToastContainer_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToastContainer)(); };
|
|
499
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ToastContainer, selectors: [["mol-toast-container"]], viewQuery: function ToastContainer_Query(rf, ctx) { if (rf & 1) {
|
|
500
|
+
i0.ɵɵviewQuery(_c3, 5);
|
|
501
|
+
} if (rf & 2) {
|
|
502
|
+
let _t;
|
|
503
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
|
|
504
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { position: "position", className: "className" }, ngContentSelectors: _c2, decls: 3, vars: 2, consts: [["container", ""]], template: function ToastContainer_Template(rf, ctx) { if (rf & 1) {
|
|
505
|
+
i0.ɵɵprojectionDef();
|
|
506
|
+
i0.ɵɵdomElementStart(0, "div", null, 0);
|
|
507
|
+
i0.ɵɵprojection(2);
|
|
508
|
+
i0.ɵɵdomElementEnd();
|
|
509
|
+
} if (rf & 2) {
|
|
510
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
511
|
+
} }, encapsulation: 2 });
|
|
512
|
+
}
|
|
513
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastContainer, [{
|
|
514
|
+
type: Component,
|
|
515
|
+
args: [{
|
|
516
|
+
selector: 'mol-toast-container',
|
|
517
|
+
standalone: true,
|
|
518
|
+
inputs: ['position', 'className'],
|
|
519
|
+
host: {
|
|
520
|
+
'data-parity-unwrap': '',
|
|
521
|
+
style: 'display: contents',
|
|
522
|
+
},
|
|
523
|
+
template: `<div #container [class]="classes()"><ng-content></ng-content></div>`,
|
|
524
|
+
}]
|
|
525
|
+
}], null, { container: [{
|
|
526
|
+
type: ViewChild,
|
|
527
|
+
args: ['container']
|
|
528
|
+
}] }); })();
|
|
529
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ToastContainer, { className: "ToastContainer", filePath: "components/toast.component.ts", lineNumber: 428 }); })();
|
|
530
|
+
/**
|
|
531
|
+
* ToastProvider: manages global toast state and renders children plus a
|
|
532
|
+
* positioned toast container (React's context provider + portal).
|
|
533
|
+
*
|
|
534
|
+
* The context value is registered on the host element (React context flows
|
|
535
|
+
* through the rendered tree, which Angular DI cannot reach for projected
|
|
536
|
+
* content); `useToast()` reads it through the DOM ancestors.
|
|
537
|
+
*/
|
|
538
|
+
export class ToastProvider {
|
|
539
|
+
/** The default position for toasts (default `bottom-right`). */
|
|
540
|
+
position = 'bottom-right';
|
|
541
|
+
/** The children capture point (removed once children are adopted). */
|
|
542
|
+
childrenCapture;
|
|
543
|
+
/** The toast container (moved to `document.body`). */
|
|
544
|
+
container;
|
|
545
|
+
/** The current toasts. */
|
|
546
|
+
toasts = signal([], /* @ts-ignore */
|
|
547
|
+
...(ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []));
|
|
548
|
+
host = inject(ElementRef);
|
|
549
|
+
renderer = inject(Renderer2);
|
|
550
|
+
sync = new SlotWrapper(this.host, this.renderer);
|
|
551
|
+
adopted = [];
|
|
552
|
+
/** Registers the toast context on the host (before any projected child resolves it). */
|
|
553
|
+
constructor() {
|
|
554
|
+
provideDomContext(this.host.nativeElement, new ToastContextImplementation(this));
|
|
555
|
+
}
|
|
556
|
+
/**
|
|
557
|
+
* The current class map.
|
|
558
|
+
* @returns The UIClassMap.
|
|
559
|
+
*/
|
|
560
|
+
cm() {
|
|
561
|
+
return getClassMap();
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* The container class list.
|
|
565
|
+
* @returns The class string.
|
|
566
|
+
*/
|
|
567
|
+
containerClasses() {
|
|
568
|
+
return this.cm().toastContainer({ position: this.position });
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* Adds a toast and returns its generated id (React's `addToast`).
|
|
572
|
+
* @param toast - The toast to add.
|
|
573
|
+
* @returns The id.
|
|
574
|
+
*/
|
|
575
|
+
addToast(toast) {
|
|
576
|
+
const id = `toast-${++toastCounter}`;
|
|
577
|
+
this.toasts.update((prev) => [...prev, { ...toast, id }]);
|
|
578
|
+
return id;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Removes a toast by id (React's `removeToast`).
|
|
582
|
+
* @param id - The toast's id.
|
|
583
|
+
*/
|
|
584
|
+
removeToast(id) {
|
|
585
|
+
this.toasts.update((prev) => prev.filter((toast) => toast.id !== id));
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Adopts the children bare into the host and moves the container to
|
|
589
|
+
* `document.body` (React's portal).
|
|
590
|
+
*/
|
|
591
|
+
ngAfterViewInit() {
|
|
592
|
+
const capture = this.childrenCapture?.nativeElement;
|
|
593
|
+
const host = this.host.nativeElement;
|
|
594
|
+
if (capture) {
|
|
595
|
+
this.adopted = Array.from(capture.childNodes);
|
|
596
|
+
for (const node of this.adopted)
|
|
597
|
+
host.appendChild(node);
|
|
598
|
+
this.sync.sync(capture, false, host);
|
|
599
|
+
}
|
|
600
|
+
const container = this.container?.nativeElement;
|
|
601
|
+
if (container && typeof document !== 'undefined')
|
|
602
|
+
document.body.appendChild(container);
|
|
603
|
+
}
|
|
604
|
+
/** Removes the context registration and restores the container (unmount). */
|
|
605
|
+
ngOnDestroy() {
|
|
606
|
+
removeDomContext(this.host.nativeElement);
|
|
607
|
+
const container = this.container?.nativeElement;
|
|
608
|
+
if (container && this.host.nativeElement.parentNode)
|
|
609
|
+
this.host.nativeElement.appendChild(container);
|
|
610
|
+
this.adopted = [];
|
|
611
|
+
}
|
|
612
|
+
static ɵfac = function ToastProvider_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToastProvider)(); };
|
|
613
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ToastProvider, selectors: [["mol-toast-provider"]], viewQuery: function ToastProvider_Query(rf, ctx) { if (rf & 1) {
|
|
614
|
+
i0.ɵɵviewQuery(_c4, 5)(_c3, 5);
|
|
615
|
+
} if (rf & 2) {
|
|
616
|
+
let _t;
|
|
617
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenCapture = _t.first);
|
|
618
|
+
i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
|
|
619
|
+
} }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { position: "position" }, ngContentSelectors: _c2, decls: 7, vars: 2, consts: [["childrenCapture", ""], ["container", ""], ["mol-toast", "", 3, "title", "description", "status", "duration", "dismissible", "closeLabel", "className", "style", "testId"], ["mol-toast", "", 3, "dismiss", "title", "description", "status", "duration", "dismissible", "closeLabel", "className", "testId"]], template: function ToastProvider_Template(rf, ctx) { if (rf & 1) {
|
|
620
|
+
i0.ɵɵprojectionDef();
|
|
621
|
+
i0.ɵɵelementStart(0, "span", null, 0);
|
|
622
|
+
i0.ɵɵprojection(2);
|
|
623
|
+
i0.ɵɵelementEnd();
|
|
624
|
+
i0.ɵɵelementStart(3, "div", null, 1);
|
|
625
|
+
i0.ɵɵrepeaterCreate(5, ToastProvider_For_6_Template, 1, 10, "div", 2, _forTrack0);
|
|
626
|
+
i0.ɵɵelementEnd();
|
|
627
|
+
} if (rf & 2) {
|
|
628
|
+
i0.ɵɵadvance(3);
|
|
629
|
+
i0.ɵɵclassMap(ctx.containerClasses());
|
|
630
|
+
i0.ɵɵadvance(2);
|
|
631
|
+
i0.ɵɵrepeater(ctx.toasts());
|
|
632
|
+
} }, dependencies: [Toast], encapsulation: 2 });
|
|
633
|
+
}
|
|
634
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastProvider, [{
|
|
635
|
+
type: Component,
|
|
636
|
+
args: [{
|
|
637
|
+
selector: 'mol-toast-provider',
|
|
638
|
+
standalone: true,
|
|
639
|
+
imports: [Toast],
|
|
640
|
+
inputs: ['position'],
|
|
641
|
+
host: {
|
|
642
|
+
'data-parity-unwrap': '',
|
|
643
|
+
style: 'display: contents',
|
|
644
|
+
},
|
|
645
|
+
template: `<span #childrenCapture><ng-content></ng-content></span>
|
|
646
|
+
<div #container [class]="containerClasses()">
|
|
647
|
+
@for (toast of toasts(); track toast.id) {
|
|
648
|
+
<div
|
|
649
|
+
mol-toast
|
|
650
|
+
[title]="toast.title"
|
|
651
|
+
[description]="toast.description"
|
|
652
|
+
[status]="toast.status ?? 'info'"
|
|
653
|
+
[duration]="toast.duration ?? 5000"
|
|
654
|
+
[dismissible]="toast.dismissible ?? true"
|
|
655
|
+
[closeLabel]="toast.closeLabel"
|
|
656
|
+
[className]="toast.className"
|
|
657
|
+
[style]="toast.style"
|
|
658
|
+
[testId]="toast.testId"
|
|
659
|
+
(dismiss)="removeToast(toast.id)"
|
|
660
|
+
></div>
|
|
661
|
+
}
|
|
662
|
+
</div>`,
|
|
663
|
+
}]
|
|
664
|
+
}], () => [], { childrenCapture: [{
|
|
665
|
+
type: ViewChild,
|
|
666
|
+
args: ['childrenCapture']
|
|
667
|
+
}], container: [{
|
|
668
|
+
type: ViewChild,
|
|
669
|
+
args: ['container']
|
|
296
670
|
}] }); })();
|
|
297
|
-
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(
|
|
671
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ToastProvider, { className: "ToastProvider", filePath: "components/toast.component.ts", lineNumber: 504 }); })();
|
|
672
|
+
/** The toast context a `ToastProvider` registers. */
|
|
673
|
+
class ToastContextImplementation {
|
|
674
|
+
provider;
|
|
675
|
+
/**
|
|
676
|
+
* Creates the context for a provider.
|
|
677
|
+
*
|
|
678
|
+
* @param provider - The owning provider.
|
|
679
|
+
*/
|
|
680
|
+
constructor(provider) {
|
|
681
|
+
this.provider = provider;
|
|
682
|
+
}
|
|
683
|
+
/** The current toasts. */
|
|
684
|
+
get toasts() {
|
|
685
|
+
return this.provider.toasts();
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Adds a toast.
|
|
689
|
+
* @param toast - The toast to add.
|
|
690
|
+
* @returns The generated id.
|
|
691
|
+
*/
|
|
692
|
+
addToast(toast) {
|
|
693
|
+
return this.provider.addToast(toast);
|
|
694
|
+
}
|
|
695
|
+
/**
|
|
696
|
+
* Removes a toast by id.
|
|
697
|
+
* @param id - The toast's id.
|
|
698
|
+
*/
|
|
699
|
+
removeToast(id) {
|
|
700
|
+
this.provider.removeToast(id);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
/**
|
|
704
|
+
* Accesses the toast context for adding and removing toasts.
|
|
705
|
+
*
|
|
706
|
+
* Must be called in an injection context (a component field initializer or
|
|
707
|
+
* constructor).
|
|
708
|
+
*
|
|
709
|
+
* @returns The toast context value.
|
|
710
|
+
* @throws {Error} When there is no enclosing `ToastProvider` (React throws too).
|
|
711
|
+
*/
|
|
712
|
+
export function useToast() {
|
|
713
|
+
const el = inject(ElementRef, { optional: true });
|
|
714
|
+
const resolve = () => {
|
|
715
|
+
const found = findDomContext(el?.nativeElement ?? null);
|
|
716
|
+
if (!found) {
|
|
717
|
+
// Thrown outside rendering (a hook used outside its provider), so the
|
|
718
|
+
// English fallback travels with the error instead of the static `t`.
|
|
719
|
+
throw new I18nError('react.error.useToastOutsideProvider', undefined, 'useToast must be used within a ToastProvider');
|
|
720
|
+
}
|
|
721
|
+
return found;
|
|
722
|
+
};
|
|
723
|
+
// Resolved at CALL time (a probe resolves the context in its constructor,
|
|
724
|
+
// before Angular has inserted its host into the DOM).
|
|
725
|
+
return {
|
|
726
|
+
get toasts() {
|
|
727
|
+
return resolve().toasts;
|
|
728
|
+
},
|
|
729
|
+
addToast: (toast) => resolve().addToast(toast),
|
|
730
|
+
removeToast: (id) => resolve().removeToast(id),
|
|
731
|
+
};
|
|
732
|
+
}
|
|
298
733
|
//# sourceMappingURL=toast.component.js.map
|