@ids-group-ltd/ids-design-system 1.0.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +261 -3
- package/agent/INDEX.md +12 -2
- package/agent/feedback/ds-attachment.md +12 -0
- package/agent/feedback/ds-chat-attachment.md +10 -0
- package/agent/feedback/ds-chat-message.md +11 -0
- package/agent/feedback/ds-chat-step.md +10 -0
- package/agent/feedback/ds-chat-steps.md +10 -0
- package/agent/feedback/ds-chat-thread.md +11 -0
- package/agent/feedback/ds-timeline-item.md +3 -1
- package/agent/feedback/ds-timeline.md +9 -0
- package/agent/feedback/ds-toast.md +1 -1
- package/agent/feedback/ds-tree.md +3 -1
- package/agent/forms/ds-chat-input.md +16 -0
- package/agent/forms/ds-inline-edit.md +14 -0
- package/agent/foundations/tokens.md +3 -3
- package/agent/navigation/ds-splitter.md +14 -0
- package/agent/platform/toast-service.md +3 -2
- package/agent/tables/ds-table.md +1 -1
- package/components.md +107 -9
- package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs +7 -4
- package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs +858 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-chat.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-inline-edit.mjs +107 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-inline-edit.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs +4 -4
- package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-splitter.mjs +359 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-splitter.mjs.map +1 -0
- package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs +74 -17
- package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs +163 -20
- package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs +2 -2
- package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs +146 -24
- package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +54 -0
- package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs +4 -1
- package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
- package/migrations/1.0.2.json +28 -0
- package/migrations/1.0.3.json +15 -0
- package/migrations/1.1.0.json +183 -0
- package/package.json +25 -1
- package/schematics/check-overrides/surface.json +181 -5
- package/styles/_dropdown-overlay.scss +6 -4
- package/styles/_step-marker.scss +51 -0
- package/styles/_tokens.scss +5 -3
- package/themes/README.md +2 -1
- package/themes/_semantic.scss +10 -0
- package/themes/dark/_palette.scss +1 -2
- package/themes/dark/_theme.scss +24 -3
- package/types/ids-group-ltd-ids-design-system-components-avatar.d.ts +3 -1
- package/types/ids-group-ltd-ids-design-system-components-button.d.ts +2 -2
- package/types/ids-group-ltd-ids-design-system-components-chart.d.ts +1 -1
- package/types/ids-group-ltd-ids-design-system-components-chat.d.ts +340 -0
- package/types/ids-group-ltd-ids-design-system-components-inline-edit.d.ts +43 -0
- package/types/ids-group-ltd-ids-design-system-components-pie-chart.d.ts +1 -1
- package/types/ids-group-ltd-ids-design-system-components-splitter.d.ts +83 -0
- package/types/ids-group-ltd-ids-design-system-components-timeline.d.ts +34 -5
- package/types/ids-group-ltd-ids-design-system-components-toast.d.ts +53 -4
- package/types/ids-group-ltd-ids-design-system-components-tree.d.ts +51 -7
- package/types/ids-group-ltd-ids-design-system-core.d.ts +104 -0
- package/types/ids-group-ltd-ids-design-system.d.ts +6 -3
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, input, booleanAttribute, output, computed, ViewEncapsulation, Component,
|
|
2
|
+
import { inject, input, booleanAttribute, output, computed, signal, ViewEncapsulation, Component, ElementRef, effect, DestroyRef, Injectable } from '@angular/core';
|
|
3
3
|
import { Overlay } from '@angular/cdk/overlay';
|
|
4
4
|
import { ComponentPortal } from '@angular/cdk/portal';
|
|
5
5
|
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
|
6
|
-
import { DS_INTL, retainStyles, DS_CONFIG, devWarn, addDevWarningSink } from '@ids-group-ltd/ids-design-system/core';
|
|
6
|
+
import { DS_INTL, DS_INTL_DEFAULTS, injectDsLocale, retainStyles, DS_CONFIG, devWarn, addDevWarningSink } from '@ids-group-ltd/ids-design-system/core';
|
|
7
7
|
import { moveFocusOutOf } from '@ids-group-ltd/ids-design-system/components';
|
|
8
8
|
import { IconComponent } from '@ids-group-ltd/ids-design-system/icons';
|
|
9
9
|
import { SpinnerComponent } from '@ids-group-ltd/ids-design-system/components/spinner';
|
|
@@ -31,8 +31,24 @@ class ToastComponent {
|
|
|
31
31
|
icon = input(null, ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
|
|
32
32
|
/** Optional action button rendered before the dismiss control. */
|
|
33
33
|
action = input(null, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
|
|
34
|
+
/** Every call folded into this toast; two or more draw a `×N` stack that lists them. */
|
|
35
|
+
occurrences = input([], ...(ngDevMode ? [{ debugName: "occurrences" }] : /* istanbul ignore next */ []));
|
|
34
36
|
/** Fires when the toast is dismissed or its action is invoked. */
|
|
35
37
|
closed = output();
|
|
38
|
+
/** Fires with an occurrence's `id` when its own close button in the list is pressed. */
|
|
39
|
+
occurrenceClosed = output();
|
|
40
|
+
count = computed(() => this.occurrences().length, ...(ngDevMode ? [{ debugName: "count" }] : /* istanbul ignore next */ []));
|
|
41
|
+
stacked = computed(() => this.count() > 1, ...(ngDevMode ? [{ debugName: "stacked" }] : /* istanbul ignore next */ []));
|
|
42
|
+
expanded = signal(false, ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
|
|
43
|
+
toastIntl = computed(() => ({
|
|
44
|
+
...DS_INTL_DEFAULTS.toast,
|
|
45
|
+
...this.intl().toast,
|
|
46
|
+
}), ...(ngDevMode ? [{ debugName: "toastIntl" }] : /* istanbul ignore next */ []));
|
|
47
|
+
timeFormat = new Intl.DateTimeFormat(injectDsLocale(), {
|
|
48
|
+
hour: '2-digit',
|
|
49
|
+
minute: '2-digit',
|
|
50
|
+
second: '2-digit',
|
|
51
|
+
});
|
|
36
52
|
isLoading = computed(() => this.variant() === 'loading', ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
|
|
37
53
|
constructor() {
|
|
38
54
|
retainStyles(ToastComponent);
|
|
@@ -54,16 +70,89 @@ class ToastComponent {
|
|
|
54
70
|
return 'info';
|
|
55
71
|
}
|
|
56
72
|
}, ...(ngDevMode ? [{ debugName: "defaultIcon" }] : /* istanbul ignore next */ []));
|
|
73
|
+
formatTime(at) {
|
|
74
|
+
return this.timeFormat.format(at);
|
|
75
|
+
}
|
|
57
76
|
onDismiss() {
|
|
58
77
|
this.closed.emit();
|
|
59
78
|
}
|
|
60
79
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
61
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastComponent, isStandalone: true, selector: "ds-toast", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, body: { classPropertyName: "body", publicName: "body", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, host: { properties: { "attr.title": "null" } }, ngImport: i0, template: "<!-- No role or aria-live: a region created with its text already in it announces nothing;\n ToastService speaks through the CDK LiveAnnouncer. A hand-placed <ds-toast> is silent. -->\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\" />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n </div>\n }\n {{ body() }}\n <ng-content></ng-content>\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\">\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"intl().dialog.dismiss\"\n (click)=\"onDismiss()\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;pointer-events:none}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}.toast{--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay));--_toast-border: var(--ds-toast-border-color, var(--border-default));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-fade-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .close{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toast .close:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .close{position:relative}.toast .close:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toast .close:focus-visible{outline-style:none}.toast .close:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{color:var(--icon-default)}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:active{background:var(--surface-muted)}.toast .action:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }, { kind: "component", type: SpinnerComponent, selector: "ds-spinner", inputs: ["size"] }] });
|
|
80
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastComponent, isStandalone: true, selector: "ds-toast", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, body: { classPropertyName: "body", publicName: "body", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null }, occurrences: { classPropertyName: "occurrences", publicName: "occurrences", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed", occurrenceClosed: "occurrenceClosed" }, host: { properties: { "attr.title": "null", "class.piled": "stacked() && !expanded()" } }, ngImport: i0, template: "<!-- No role or aria-live: a region created with its text already in it announces nothing;\n ToastService speaks through the CDK LiveAnnouncer. A hand-placed <ds-toast> is silent. -->\n@if (stacked() && !expanded()) {\n <div\n class=\"ghost ghost-far\"\n aria-hidden=\"true\">\n </div>\n\n <div\n class=\"ghost ghost-near\"\n aria-hidden=\"true\">\n </div>\n}\n\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\" />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n @if (stacked()) {\n <span class=\"count\">\n \u00D7{{ count() }}\n </span>\n }\n </div>\n }\n {{ body() }}\n @if (stacked() && !title()) {\n <span class=\"count\">\n \u00D7{{ count() }}\n </span>\n }\n\n <ng-content></ng-content>\n\n @if (stacked()) {\n <button\n type=\"button\"\n class=\"more\"\n [attr.aria-expanded]=\"expanded()\"\n (click)=\"expanded.set(!expanded())\">\n {{ expanded() ? toastIntl().hide : toastIntl().showAll }}\n </button>\n }\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\">\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"\n stacked() ? toastIntl().dismissAll : intl().dialog.dismiss\n \"\n (click)=\"onDismiss()\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n</div>\n\n@if (stacked() && expanded()) {\n <div class=\"occurrences\">\n @for (occurrence of occurrences(); track occurrence.id) {\n <div [class]=\"classes()\">\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n\n <div class=\"body\">\n {{ occurrence.body }}\n <span class=\"time\">\n {{ formatTime(occurrence.at) }}\n </span>\n </div>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"intl().dialog.dismiss\"\n (click)=\"occurrenceClosed.emit(occurrence.id)\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n </div>\n }\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;pointer-events:none}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}:host(.piled){position:relative;margin-block-end:var(--space-3)}:host(.piled) .toast{position:relative}.ghost{position:absolute;inset-inline:0;height:100%;background-color:var(--surface-overlay-raised);border:var(--border-width-default) solid var(--border-overlay);border-radius:var(--radius-lg);box-shadow:var(--shadow-2)}.ghost-near{top:var(--space-1-5);transform:scale(.96)}.ghost-far{top:var(--space-3);transform:scale(.92)}.occurrences{display:flex;flex-direction:column;gap:var(--space-1-5);margin-block-start:var(--space-1-5)}.toast{--_toast-count-bg-color: var(--accent-muted);--_toast-count-text-color: var(--accent-strong);--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay-raised));--_toast-border: var(--ds-toast-border-color, var(--border-overlay));--surface-secondary: var(--surface-overlay-raised-secondary);--surface-muted: var(--surface-overlay-raised-muted);--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-fade-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .count{display:inline-block;margin-inline-start:var(--space-1-5);padding:0 var(--space-1-5);border-radius:var(--radius-pill);background-color:var(--_toast-count-bg-color);color:var(--_toast-count-text-color);font:var(--font-weight-semibold) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}.toast .time{margin-inline-start:var(--space-1);color:var(--text-tertiary-overlay);font-size:var(--font-size-xs)}.toast .more{display:block;margin-block-start:var(--space-1);padding:0;border:0;border-radius:var(--ds-radius-inner);background:transparent;color:var(--text-link);font:var(--font-weight-semibold) var(--font-size-xs)/var(--line-height-base) var(--font-sans);cursor:pointer}.toast .more:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toast .close:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .close{position:relative}.toast .close:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toast .close:focus-visible{outline-style:none}.toast .close:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{color:var(--icon-default)}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:active{background:var(--surface-muted)}.toast .action:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));--_toast-count-bg-color: var(--success-muted);--_toast-count-text-color: var(--success-text);border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));--_toast-count-bg-color: var(--warning-muted);--_toast-count-text-color: var(--warning-text);border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));--_toast-count-bg-color: var(--error-muted);--_toast-count-text-color: var(--error-text);border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }, { kind: "component", type: SpinnerComponent, selector: "ds-spinner", inputs: ["size"] }] });
|
|
62
81
|
}
|
|
63
82
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastComponent, decorators: [{
|
|
64
83
|
type: Component,
|
|
65
|
-
args: [{ selector: 'ds-toast', standalone: true, imports: [IconComponent, SpinnerComponent], host: { '[attr.title]': 'null' }, encapsulation: ViewEncapsulation.Emulated, template: "<!-- No role or aria-live: a region created with its text already in it announces nothing;\n ToastService speaks through the CDK LiveAnnouncer. A hand-placed <ds-toast> is silent. -->\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\" />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n </div>\n }\n {{ body() }}\n <ng-content></ng-content>\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\">\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"intl().dialog.dismiss\"\n (click)=\"onDismiss()\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n</div>\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;pointer-events:none}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}.toast{--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay));--_toast-border: var(--ds-toast-border-color, var(--border-default));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-fade-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .close{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toast .close:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .close{position:relative}.toast .close:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toast .close:focus-visible{outline-style:none}.toast .close:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{color:var(--icon-default)}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:active{background:var(--surface-muted)}.toast .action:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"] }]
|
|
66
|
-
}], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], body: [{ type: i0.Input, args: [{ isSignal: true, alias: "body", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
|
|
84
|
+
args: [{ selector: 'ds-toast', standalone: true, imports: [IconComponent, SpinnerComponent], host: { '[attr.title]': 'null', '[class.piled]': 'stacked() && !expanded()' }, encapsulation: ViewEncapsulation.Emulated, template: "<!-- No role or aria-live: a region created with its text already in it announces nothing;\n ToastService speaks through the CDK LiveAnnouncer. A hand-placed <ds-toast> is silent. -->\n@if (stacked() && !expanded()) {\n <div\n class=\"ghost ghost-far\"\n aria-hidden=\"true\">\n </div>\n\n <div\n class=\"ghost ghost-near\"\n aria-hidden=\"true\">\n </div>\n}\n\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\" />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n @if (stacked()) {\n <span class=\"count\">\n \u00D7{{ count() }}\n </span>\n }\n </div>\n }\n {{ body() }}\n @if (stacked() && !title()) {\n <span class=\"count\">\n \u00D7{{ count() }}\n </span>\n }\n\n <ng-content></ng-content>\n\n @if (stacked()) {\n <button\n type=\"button\"\n class=\"more\"\n [attr.aria-expanded]=\"expanded()\"\n (click)=\"expanded.set(!expanded())\">\n {{ expanded() ? toastIntl().hide : toastIntl().showAll }}\n </button>\n }\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\">\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"\n stacked() ? toastIntl().dismissAll : intl().dialog.dismiss\n \"\n (click)=\"onDismiss()\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n</div>\n\n@if (stacked() && expanded()) {\n <div class=\"occurrences\">\n @for (occurrence of occurrences(); track occurrence.id) {\n <div [class]=\"classes()\">\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\" />\n\n <div class=\"body\">\n {{ occurrence.body }}\n <span class=\"time\">\n {{ formatTime(occurrence.at) }}\n </span>\n </div>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n [attr.aria-label]=\"intl().dialog.dismiss\"\n (click)=\"occurrenceClosed.emit(occurrence.id)\">\n <ds-icon\n name=\"x\"\n [size]=\"14\" />\n </button>\n }\n </div>\n }\n </div>\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;pointer-events:none}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}:host(.piled){position:relative;margin-block-end:var(--space-3)}:host(.piled) .toast{position:relative}.ghost{position:absolute;inset-inline:0;height:100%;background-color:var(--surface-overlay-raised);border:var(--border-width-default) solid var(--border-overlay);border-radius:var(--radius-lg);box-shadow:var(--shadow-2)}.ghost-near{top:var(--space-1-5);transform:scale(.96)}.ghost-far{top:var(--space-3);transform:scale(.92)}.occurrences{display:flex;flex-direction:column;gap:var(--space-1-5);margin-block-start:var(--space-1-5)}.toast{--_toast-count-bg-color: var(--accent-muted);--_toast-count-text-color: var(--accent-strong);--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay-raised));--_toast-border: var(--ds-toast-border-color, var(--border-overlay));--surface-secondary: var(--surface-overlay-raised-secondary);--surface-muted: var(--surface-overlay-raised-muted);--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-fade-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .count{display:inline-block;margin-inline-start:var(--space-1-5);padding:0 var(--space-1-5);border-radius:var(--radius-pill);background-color:var(--_toast-count-bg-color);color:var(--_toast-count-text-color);font:var(--font-weight-semibold) var(--font-size-xs)/var(--line-height-base) var(--font-sans)}.toast .time{margin-inline-start:var(--space-1);color:var(--text-tertiary-overlay);font-size:var(--font-size-xs)}.toast .more{display:block;margin-block-start:var(--space-1);padding:0;border:0;border-radius:var(--ds-radius-inner);background:transparent;color:var(--text-link);font:var(--font-weight-semibold) var(--font-size-xs)/var(--line-height-base) var(--font-sans);cursor:pointer}.toast .more:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{display:inline-flex;align-items:center;justify-content:center;padding:var(--space-0-5);border:0;background:none;cursor:pointer}.toast .close:active:not(:disabled,[disabled],.is-disabled,.disabled,[aria-disabled=true]){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .close{position:relative}.toast .close:before{content:\"\";position:absolute;top:50%;left:50%;width:max(100%,var(--hit-xs));height:max(100%,var(--hit-xs));translate:-50% -50%;border-radius:inherit}.toast .close:focus-visible{outline-style:none}.toast .close:focus-visible:before{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:calc(var(--focus-ring-offset) - 2 * var(--focus-ring-width));animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .close{color:var(--icon-default)}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:active{background:var(--surface-muted)}.toast .action:focus-visible{outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));--_toast-count-bg-color: var(--success-muted);--_toast-count-text-color: var(--success-text);border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));--_toast-count-bg-color: var(--warning-muted);--_toast-count-text-color: var(--warning-text);border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay-raised)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-overlay)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));--_toast-count-bg-color: var(--error-muted);--_toast-count-text-color: var(--error-text);border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"] }]
|
|
85
|
+
}], ctorParameters: () => [], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], body: [{ type: i0.Input, args: [{ isSignal: true, alias: "body", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], occurrences: [{ type: i0.Input, args: [{ isSignal: true, alias: "occurrences", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], occurrenceClosed: [{ type: i0.Output, args: ["occurrenceClosed"] }] } });
|
|
86
|
+
|
|
87
|
+
/** @internal */
|
|
88
|
+
const TOAST_DEFAULT_DURATION_MS = 5000;
|
|
89
|
+
function toastTextKey(variant, title, body) {
|
|
90
|
+
return JSON.stringify([variant, title ?? '', body]);
|
|
91
|
+
}
|
|
92
|
+
/** @internal */
|
|
93
|
+
function toastGroupKey(config, options, variant) {
|
|
94
|
+
if (!config?.groupDuplicates || variant === 'loading') {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
return options.groupKey ?? toastTextKey(variant, options.title, options.body);
|
|
98
|
+
}
|
|
99
|
+
/** `null` when the region no longer holds the toast. @internal */
|
|
100
|
+
function toastUpdatePatch(current, update) {
|
|
101
|
+
if (!current) {
|
|
102
|
+
return null;
|
|
103
|
+
}
|
|
104
|
+
const variant = update.variant ?? current.variant;
|
|
105
|
+
const title = update.title ?? current.title;
|
|
106
|
+
const body = update.body ?? current.body;
|
|
107
|
+
const neverExpires = variant === 'loading' || current.action !== undefined;
|
|
108
|
+
const leavesLoading = current.variant === 'loading' && variant !== 'loading';
|
|
109
|
+
const durationMs = neverExpires
|
|
110
|
+
? 0
|
|
111
|
+
: (update.durationMs ??
|
|
112
|
+
(leavesLoading ? TOAST_DEFAULT_DURATION_MS : current.durationMs));
|
|
113
|
+
// Re-sending `durationMs` restarts the countdown, so a text-only change leaves it out.
|
|
114
|
+
const restartsCountdown = update.durationMs !== undefined || durationMs !== current.durationMs;
|
|
115
|
+
// A key derived from the old text would fold a later repeat of that text into this toast.
|
|
116
|
+
const keyFollowsText = current.groupKey !== undefined &&
|
|
117
|
+
current.groupKey ===
|
|
118
|
+
toastTextKey(current.variant, current.title, current.body);
|
|
119
|
+
const patch = {
|
|
120
|
+
title,
|
|
121
|
+
body,
|
|
122
|
+
variant,
|
|
123
|
+
dismissible: durationMs > 0 ? (update.dismissible ?? current.dismissible) : true,
|
|
124
|
+
...(restartsCountdown ? { durationMs } : {}),
|
|
125
|
+
...(keyFollowsText
|
|
126
|
+
? {
|
|
127
|
+
groupKey: variant === 'loading'
|
|
128
|
+
? undefined
|
|
129
|
+
: toastTextKey(variant, title, body),
|
|
130
|
+
}
|
|
131
|
+
: {}),
|
|
132
|
+
};
|
|
133
|
+
return {
|
|
134
|
+
patch,
|
|
135
|
+
announce: variant !== current.variant &&
|
|
136
|
+
(variant === 'success' || variant === 'error'),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/** @internal */
|
|
140
|
+
function findToastStack(entries, key) {
|
|
141
|
+
return entries.find((entry) => entry.groupKey === key);
|
|
142
|
+
}
|
|
143
|
+
// Re-sending `durationMs` is what restarts the countdown in `ToastRegionComponent.update`.
|
|
144
|
+
/** @internal */
|
|
145
|
+
function toastRepeatPatch(stack, occurrence) {
|
|
146
|
+
return {
|
|
147
|
+
occurrences: [...(stack.occurrences ?? []), occurrence],
|
|
148
|
+
durationMs: stack.durationMs,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/** `null` when the closed occurrence was the last: the whole toast goes. @internal */
|
|
152
|
+
function withoutToastOccurrence(entry, occurrenceId) {
|
|
153
|
+
const left = (entry.occurrences ?? []).filter((occurrence) => occurrence.id !== occurrenceId);
|
|
154
|
+
return left.length ? left : null;
|
|
155
|
+
}
|
|
67
156
|
|
|
68
157
|
// Fallback floor; leaveDuration() reads the real length off the node.
|
|
69
158
|
const LEAVE_FALLBACK_MS = 180;
|
|
@@ -269,6 +358,27 @@ class ToastRegionComponent {
|
|
|
269
358
|
}
|
|
270
359
|
this.pendingQueue.update((queue) => queue.map((entry) => (entry.id === id ? { ...entry, ...patch } : entry)));
|
|
271
360
|
}
|
|
361
|
+
/** The visible or queued toast with this id; one already leaving is gone. */
|
|
362
|
+
entryFor(id) {
|
|
363
|
+
return [...this.visibleEntries(), ...this.pendingQueue()].find((entry) => entry.id === id && !this.isLeaving(id));
|
|
364
|
+
}
|
|
365
|
+
/** The visible or queued toast a repeat with this `groupKey` folds into; one already leaving
|
|
366
|
+
* takes no more. */
|
|
367
|
+
stackFor(key) {
|
|
368
|
+
return findToastStack([
|
|
369
|
+
...this.visibleEntries().filter((entry) => !this.isLeaving(entry.id)),
|
|
370
|
+
...this.pendingQueue(),
|
|
371
|
+
], key);
|
|
372
|
+
}
|
|
373
|
+
closeOccurrence(entry, occurrenceId) {
|
|
374
|
+
const occurrences = withoutToastOccurrence(entry, occurrenceId);
|
|
375
|
+
if (occurrences) {
|
|
376
|
+
this.update(entry.id, { occurrences });
|
|
377
|
+
}
|
|
378
|
+
else {
|
|
379
|
+
this.remove(entry.id);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
272
382
|
remove(id) {
|
|
273
383
|
// A `ToastRef` outlives its toast, so dismiss() can arrive for an id nothing holds.
|
|
274
384
|
const isVisible = this.visibleEntries().some((entry) => entry.id === id);
|
|
@@ -340,7 +450,7 @@ class ToastRegionComponent {
|
|
|
340
450
|
}
|
|
341
451
|
}
|
|
342
452
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastRegionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
343
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastRegionComponent, isStandalone: true, selector: "ds-toast-region", inputs: { maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null }, showQueueCount: { classPropertyName: "showQueueCount", publicName: "showQueueCount", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region" }, listeners: { "mouseenter": "onHover(true)", "mouseleave": "onHover(false)", "focusin": "onFocusIn($event)", "focusout": "onFocusWithin($event)" }, properties: { "attr.aria-label": "intl().toast.region", "class.stack-newest-last": "!newestFirst" } }, ngImport: i0, template: "@if (queuedLabel(); as label) {\n <!-- aria-hidden: ToastService already announced every toast, queued ones included. -->\n <div\n class=\"queue-count\"\n aria-hidden=\"true\">\n {{ label }}\n </div>\n}\n\n@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\" />\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column;gap:var(--space-2)}.queue-count{--_toast-queue-bg-color: var(--ds-toast-queue-bg-color, var(--surface-overlay));--_toast-queue-text-color: var(--ds-toast-queue-text-color, var(--text-secondary));align-self:center;padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-
|
|
453
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastRegionComponent, isStandalone: true, selector: "ds-toast-region", inputs: { maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null }, showQueueCount: { classPropertyName: "showQueueCount", publicName: "showQueueCount", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region" }, listeners: { "mouseenter": "onHover(true)", "mouseleave": "onHover(false)", "focusin": "onFocusIn($event)", "focusout": "onFocusWithin($event)" }, properties: { "attr.aria-label": "intl().toast.region", "class.stack-newest-last": "!newestFirst" } }, ngImport: i0, template: "@if (queuedLabel(); as label) {\n <!-- aria-hidden: ToastService already announced every toast, queued ones included. -->\n <div\n class=\"queue-count\"\n aria-hidden=\"true\">\n {{ label }}\n </div>\n}\n\n@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [occurrences]=\"entry.occurrences ?? []\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\"\n (occurrenceClosed)=\"closeOccurrence(entry, $event)\" />\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column;gap:var(--space-2)}.queue-count{--_toast-queue-bg-color: var(--ds-toast-queue-bg-color, var(--surface-overlay-raised));--_toast-queue-text-color: var(--ds-toast-queue-text-color, var(--text-secondary));align-self:center;padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-overlay);border-radius:var(--radius-pill);background-color:var(--_toast-queue-bg-color);box-shadow:var(--shadow-toast);color:var(--_toast-queue-text-color);font:var(--font-weight-semibold) var(--font-size-xs)/1 var(--font-sans)}:host(.stack-newest-last) .queue-count{order:1}\n"], dependencies: [{ kind: "component", type: ToastComponent, selector: "ds-toast", inputs: ["variant", "title", "body", "dismissible", "icon", "action", "occurrences"], outputs: ["closed", "occurrenceClosed"] }] });
|
|
344
454
|
}
|
|
345
455
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastRegionComponent, decorators: [{
|
|
346
456
|
type: Component,
|
|
@@ -352,7 +462,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImpo
|
|
|
352
462
|
'(focusin)': 'onFocusIn($event)',
|
|
353
463
|
'(focusout)': 'onFocusWithin($event)',
|
|
354
464
|
'[class.stack-newest-last]': '!newestFirst',
|
|
355
|
-
}, template: "@if (queuedLabel(); as label) {\n <!-- aria-hidden: ToastService already announced every toast, queued ones included. -->\n <div\n class=\"queue-count\"\n aria-hidden=\"true\">\n {{ label }}\n </div>\n}\n\n@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\" />\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column;gap:var(--space-2)}.queue-count{--_toast-queue-bg-color: var(--ds-toast-queue-bg-color, var(--surface-overlay));--_toast-queue-text-color: var(--ds-toast-queue-text-color, var(--text-secondary));align-self:center;padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-
|
|
465
|
+
}, template: "@if (queuedLabel(); as label) {\n <!-- aria-hidden: ToastService already announced every toast, queued ones included. -->\n <div\n class=\"queue-count\"\n aria-hidden=\"true\">\n {{ label }}\n </div>\n}\n\n@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [occurrences]=\"entry.occurrences ?? []\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\"\n (occurrenceClosed)=\"closeOccurrence(entry, $event)\" />\n}\n", styles: [":where(:host){box-sizing:border-box;interpolate-size:allow-keywords}:where(*){box-sizing:border-box}:where(button,input,select,textarea){font-family:inherit}:where(h1,h2,h3,h4,h5,h6){margin:0}:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid var(--focus-ring-color);outline-offset:var(--focus-ring-offset);animation:ds-focus-ring-in var(--duration-fast) var(--ease-standard);border-radius:var(--focus-ring-radius)}@media(forced-colors:active){:where(:host(:focus-visible),:focus-visible){outline:var(--focus-ring-width) solid CanvasText;outline-offset:var(--focus-ring-offset)}}:host{display:flex;flex-direction:column;gap:var(--space-2)}.queue-count{--_toast-queue-bg-color: var(--ds-toast-queue-bg-color, var(--surface-overlay-raised));--_toast-queue-text-color: var(--ds-toast-queue-text-color, var(--text-secondary));align-self:center;padding:var(--space-0-5) var(--space-2);border:var(--border-width-default) solid var(--border-overlay);border-radius:var(--radius-pill);background-color:var(--_toast-queue-bg-color);box-shadow:var(--shadow-toast);color:var(--_toast-queue-text-color);font:var(--font-weight-semibold) var(--font-size-xs)/1 var(--font-sans)}:host(.stack-newest-last) .queue-count{order:1}\n"] }]
|
|
356
466
|
}], ctorParameters: () => [], propDecorators: { maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }], showQueueCount: [{ type: i0.Input, args: [{ isSignal: true, alias: "showQueueCount", required: false }] }] } });
|
|
357
467
|
|
|
358
468
|
const SETTLED_SUCCESS_MS = 4000;
|
|
@@ -364,10 +474,12 @@ class ToastService {
|
|
|
364
474
|
overlay = inject(Overlay);
|
|
365
475
|
toastConfig = inject(DS_CONFIG).toast;
|
|
366
476
|
announcer = inject(LiveAnnouncer);
|
|
477
|
+
intl = inject(DS_INTL);
|
|
367
478
|
overlayRef = null;
|
|
368
479
|
regionRef = null;
|
|
369
480
|
nextId = 1;
|
|
370
|
-
|
|
481
|
+
// Keyed so a burst of repeats of one stack leaves only its latest count to speak.
|
|
482
|
+
pendingAnnouncements = new Map();
|
|
371
483
|
pendingAssertive = false;
|
|
372
484
|
announceTimer;
|
|
373
485
|
scrimWatcher = null;
|
|
@@ -396,9 +508,24 @@ class ToastService {
|
|
|
396
508
|
this.ensureRegion();
|
|
397
509
|
const id = this.nextId++;
|
|
398
510
|
const variant = opts.variant ?? 'info';
|
|
511
|
+
const groupKey = toastGroupKey(this.toastConfig, opts, variant);
|
|
512
|
+
const occurrence = { id, body: opts.body, at: Date.now() };
|
|
513
|
+
const stack = groupKey === undefined
|
|
514
|
+
? undefined
|
|
515
|
+
: this.regionRef.instance.stackFor(groupKey);
|
|
516
|
+
if (stack) {
|
|
517
|
+
const patch = toastRepeatPatch(stack, occurrence);
|
|
518
|
+
this.regionRef.instance.update(stack.id, patch);
|
|
519
|
+
const repeated = this.intl().toast.repeated ?? DS_INTL_DEFAULTS.toast.repeated;
|
|
520
|
+
const message = [stack.title, stack.body].filter(Boolean).join('. ');
|
|
521
|
+
this.announce(variant, repeated(message, patch.occurrences.length), undefined, groupKey);
|
|
522
|
+
return this.refFor(stack.id);
|
|
523
|
+
}
|
|
399
524
|
// An `action` toast cannot expire: the region is the last child of `body`, so a
|
|
400
525
|
// keyboard user cannot reach the button in time.
|
|
401
|
-
const durationMs = variant === 'loading' || opts.action
|
|
526
|
+
const durationMs = variant === 'loading' || opts.action
|
|
527
|
+
? 0
|
|
528
|
+
: (opts.durationMs ?? TOAST_DEFAULT_DURATION_MS);
|
|
402
529
|
const entry = {
|
|
403
530
|
id,
|
|
404
531
|
title: opts.title,
|
|
@@ -408,15 +535,35 @@ class ToastService {
|
|
|
408
535
|
dismissible: durationMs > 0 ? (opts.dismissible ?? true) : true,
|
|
409
536
|
action: opts.action,
|
|
410
537
|
durationMs,
|
|
538
|
+
...(groupKey === undefined
|
|
539
|
+
? {}
|
|
540
|
+
: { groupKey, occurrences: [occurrence] }),
|
|
411
541
|
};
|
|
412
542
|
// The region runs the countdown: a toast queued behind `maxVisible` would expire unseen if started here.
|
|
413
543
|
this.regionRef.instance.add(entry);
|
|
414
|
-
this.announce(variant, entry.body, entry.title);
|
|
544
|
+
this.announce(variant, entry.body, entry.title, groupKey);
|
|
545
|
+
return this.refFor(id);
|
|
546
|
+
}
|
|
547
|
+
refFor(id) {
|
|
415
548
|
return {
|
|
416
549
|
id,
|
|
417
550
|
dismiss: () => this.regionRef?.instance.remove(id),
|
|
551
|
+
update: (patch) => this.updateToast(id, patch),
|
|
418
552
|
};
|
|
419
553
|
}
|
|
554
|
+
updateToast(id, update) {
|
|
555
|
+
const region = this.regionRef?.instance;
|
|
556
|
+
const current = region?.entryFor(id);
|
|
557
|
+
const planned = toastUpdatePatch(current, update);
|
|
558
|
+
if (!region || !current || !planned) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
region.update(id, planned.patch);
|
|
562
|
+
if (planned.announce) {
|
|
563
|
+
const next = { ...current, ...planned.patch };
|
|
564
|
+
this.announce(next.variant, next.body, next.title);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
420
567
|
/** Shows a loading toast for the duration of `source`; resolution and rejection turn the
|
|
421
568
|
* same toast into a success/error variant with its own auto-dismiss delay.
|
|
422
569
|
*
|
|
@@ -431,24 +578,20 @@ class ToastService {
|
|
|
431
578
|
const successBody = typeof messages.success === 'function'
|
|
432
579
|
? messages.success(value)
|
|
433
580
|
: messages.success;
|
|
434
|
-
|
|
581
|
+
ref.update({
|
|
435
582
|
body: successBody,
|
|
436
583
|
variant: 'success',
|
|
437
|
-
dismissible: true,
|
|
438
584
|
durationMs: SETTLED_SUCCESS_MS,
|
|
439
585
|
});
|
|
440
|
-
this.announce('success', successBody);
|
|
441
586
|
}, (reason) => {
|
|
442
587
|
const errorBody = typeof messages.error === 'function'
|
|
443
588
|
? messages.error(reason)
|
|
444
589
|
: messages.error;
|
|
445
|
-
|
|
590
|
+
ref.update({
|
|
446
591
|
body: errorBody,
|
|
447
592
|
variant: 'error',
|
|
448
|
-
dismissible: true,
|
|
449
593
|
durationMs: SETTLED_ERROR_MS,
|
|
450
594
|
});
|
|
451
|
-
this.announce('error', errorBody);
|
|
452
595
|
});
|
|
453
596
|
return source;
|
|
454
597
|
}
|
|
@@ -458,20 +601,20 @@ class ToastService {
|
|
|
458
601
|
* Serialising a burst does not work either: `announce()` clears the region and writes
|
|
459
602
|
* on a timeout, so the next message wipes the previous one. One region change carrying
|
|
460
603
|
* every message is the only shape that survives. */
|
|
461
|
-
announce(variant, body, title) {
|
|
604
|
+
announce(variant, body, title, key = Symbol()) {
|
|
462
605
|
const spoken = [title, body].filter(Boolean).join('. ');
|
|
463
606
|
if (!spoken) {
|
|
464
607
|
return;
|
|
465
608
|
}
|
|
466
|
-
this.pendingAnnouncements.
|
|
609
|
+
this.pendingAnnouncements.set(key, spoken);
|
|
467
610
|
if (variant === 'error' || variant === 'warning') {
|
|
468
611
|
this.pendingAssertive = true;
|
|
469
612
|
}
|
|
470
613
|
clearTimeout(this.announceTimer);
|
|
471
614
|
this.announceTimer = window.setTimeout(() => {
|
|
472
|
-
const message = this.pendingAnnouncements.join('. ');
|
|
615
|
+
const message = [...this.pendingAnnouncements.values()].join('. ');
|
|
473
616
|
const politeness = this.pendingAssertive ? 'assertive' : 'polite';
|
|
474
|
-
this.pendingAnnouncements
|
|
617
|
+
this.pendingAnnouncements.clear();
|
|
475
618
|
this.pendingAssertive = false;
|
|
476
619
|
this.announcer.announce(message, politeness);
|
|
477
620
|
}, ANNOUNCE_COALESCE_MS);
|