ngwr 16.0.0 → 16.2.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/badge/styles/_tag.scss +8 -4
- package/button/styles/_index.scss +13 -7
- package/cascader/styles/_rules.scss +4 -2
- package/checkbox/styles/_index.scss +4 -2
- package/date-picker/styles/_index.scss +95 -3
- package/date-stamp/styles/_index.scss +38 -0
- package/dialog/styles/_index.scss +38 -0
- package/dropdown/styles/_index.scss +37 -1
- package/fesm2022/internal-CVLvP9b_.mjs +33 -0
- package/fesm2022/internal-CVLvP9b_.mjs.map +1 -0
- package/fesm2022/ngwr-alert.mjs +11 -7
- package/fesm2022/ngwr-alert.mjs.map +1 -1
- package/fesm2022/ngwr-avatar.mjs +11 -7
- package/fesm2022/ngwr-avatar.mjs.map +1 -1
- package/fesm2022/ngwr-back-top.mjs +10 -6
- package/fesm2022/ngwr-back-top.mjs.map +1 -1
- package/fesm2022/ngwr-badge.mjs +18 -6
- package/fesm2022/ngwr-badge.mjs.map +1 -1
- package/fesm2022/ngwr-burger.mjs +9 -6
- package/fesm2022/ngwr-burger.mjs.map +1 -1
- package/fesm2022/ngwr-button.mjs +8 -4
- package/fesm2022/ngwr-button.mjs.map +1 -1
- package/fesm2022/ngwr-calendar.mjs +19 -8
- package/fesm2022/ngwr-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-card.mjs +9 -5
- package/fesm2022/ngwr-card.mjs.map +1 -1
- package/fesm2022/ngwr-cascader.mjs +11 -5
- package/fesm2022/ngwr-cascader.mjs.map +1 -1
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs +5 -2
- package/fesm2022/ngwr-charts-calendar-heatmap.mjs.map +1 -1
- package/fesm2022/ngwr-checkbox.mjs +10 -6
- package/fesm2022/ngwr-checkbox.mjs.map +1 -1
- package/fesm2022/ngwr-clipboard.mjs +2 -1
- package/fesm2022/ngwr-clipboard.mjs.map +1 -1
- package/fesm2022/ngwr-collapse.mjs +9 -5
- package/fesm2022/ngwr-collapse.mjs.map +1 -1
- package/fesm2022/ngwr-color-picker.mjs +4 -2
- package/fesm2022/ngwr-color-picker.mjs.map +1 -1
- package/fesm2022/ngwr-comment.mjs +13 -7
- package/fesm2022/ngwr-comment.mjs.map +1 -1
- package/fesm2022/ngwr-compare.mjs +9 -3
- package/fesm2022/ngwr-compare.mjs.map +1 -1
- package/fesm2022/ngwr-context-menu.mjs +4 -2
- package/fesm2022/ngwr-context-menu.mjs.map +1 -1
- package/fesm2022/ngwr-copy-value.mjs +11 -6
- package/fesm2022/ngwr-copy-value.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker-testing.mjs +18 -0
- package/fesm2022/ngwr-date-picker-testing.mjs.map +1 -1
- package/fesm2022/ngwr-date-picker.mjs +238 -38
- package/fesm2022/ngwr-date-picker.mjs.map +1 -1
- package/fesm2022/ngwr-date-stamp-testing.mjs +34 -0
- package/fesm2022/ngwr-date-stamp-testing.mjs.map +1 -0
- package/fesm2022/ngwr-date-stamp.mjs +213 -0
- package/fesm2022/ngwr-date-stamp.mjs.map +1 -0
- package/fesm2022/ngwr-date.mjs +364 -54
- package/fesm2022/ngwr-date.mjs.map +1 -1
- package/fesm2022/ngwr-descriptions.mjs +9 -5
- package/fesm2022/ngwr-descriptions.mjs.map +1 -1
- package/fesm2022/ngwr-dialog-testing.mjs +23 -2
- package/fesm2022/ngwr-dialog-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dialog.mjs +45 -16
- package/fesm2022/ngwr-dialog.mjs.map +1 -1
- package/fesm2022/ngwr-directives.mjs +102 -11
- package/fesm2022/ngwr-directives.mjs.map +1 -1
- package/fesm2022/ngwr-divider.mjs +4 -2
- package/fesm2022/ngwr-divider.mjs.map +1 -1
- package/fesm2022/ngwr-drawer.mjs +29 -3
- package/fesm2022/ngwr-drawer.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown-testing.mjs +38 -3
- package/fesm2022/ngwr-dropdown-testing.mjs.map +1 -1
- package/fesm2022/ngwr-dropdown.mjs +362 -26
- package/fesm2022/ngwr-dropdown.mjs.map +1 -1
- package/fesm2022/ngwr-editor.mjs +5 -2
- package/fesm2022/ngwr-editor.mjs.map +1 -1
- package/fesm2022/ngwr-event-calendar.mjs +4 -2
- package/fesm2022/ngwr-event-calendar.mjs.map +1 -1
- package/fesm2022/ngwr-file-upload.mjs +9 -3
- package/fesm2022/ngwr-file-upload.mjs.map +1 -1
- package/fesm2022/ngwr-form.mjs +18 -6
- package/fesm2022/ngwr-form.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ar.mjs +9 -2
- package/fesm2022/ngwr-i18n-ar.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-cs.mjs +9 -2
- package/fesm2022/ngwr-i18n-cs.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-de.mjs +9 -2
- package/fesm2022/ngwr-i18n-de.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-en.mjs +9 -2
- package/fesm2022/ngwr-i18n-en.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-es.mjs +9 -2
- package/fesm2022/ngwr-i18n-es.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-fr.mjs +9 -2
- package/fesm2022/ngwr-i18n-fr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-he.mjs +9 -2
- package/fesm2022/ngwr-i18n-he.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-hi.mjs +9 -2
- package/fesm2022/ngwr-i18n-hi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-id.mjs +9 -2
- package/fesm2022/ngwr-i18n-id.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-it.mjs +9 -2
- package/fesm2022/ngwr-i18n-it.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ja.mjs +9 -2
- package/fesm2022/ngwr-i18n-ja.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ko.mjs +9 -2
- package/fesm2022/ngwr-i18n-ko.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-nl.mjs +9 -2
- package/fesm2022/ngwr-i18n-nl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pl.mjs +9 -2
- package/fesm2022/ngwr-i18n-pl.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-pt.mjs +9 -2
- package/fesm2022/ngwr-i18n-pt.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-ru.mjs +9 -2
- package/fesm2022/ngwr-i18n-ru.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-sv.mjs +9 -2
- package/fesm2022/ngwr-i18n-sv.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-tr.mjs +9 -2
- package/fesm2022/ngwr-i18n-tr.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-uk.mjs +9 -2
- package/fesm2022/ngwr-i18n-uk.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-vi.mjs +9 -2
- package/fesm2022/ngwr-i18n-vi.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh-tw.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh-tw.mjs.map +1 -1
- package/fesm2022/ngwr-i18n-zh.mjs +9 -2
- package/fesm2022/ngwr-i18n-zh.mjs.map +1 -1
- package/fesm2022/ngwr-i18n.mjs +34 -8
- package/fesm2022/ngwr-i18n.mjs.map +1 -1
- package/fesm2022/ngwr-input-number.mjs +9 -3
- package/fesm2022/ngwr-input-number.mjs.map +1 -1
- package/fesm2022/ngwr-input-otp.mjs +4 -2
- package/fesm2022/ngwr-input-otp.mjs.map +1 -1
- package/fesm2022/ngwr-input.mjs +20 -10
- package/fesm2022/ngwr-input.mjs.map +1 -1
- package/fesm2022/ngwr-keyboard.mjs +9 -3
- package/fesm2022/ngwr-keyboard.mjs.map +1 -1
- package/fesm2022/ngwr-knob.mjs +9 -3
- package/fesm2022/ngwr-knob.mjs.map +1 -1
- package/fesm2022/ngwr-layout.mjs +13 -5
- package/fesm2022/ngwr-layout.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox-testing.mjs +26 -0
- package/fesm2022/ngwr-lightbox-testing.mjs.map +1 -1
- package/fesm2022/ngwr-lightbox.mjs +255 -15
- package/fesm2022/ngwr-lightbox.mjs.map +1 -1
- package/fesm2022/ngwr-list.mjs +13 -5
- package/fesm2022/ngwr-list.mjs.map +1 -1
- package/fesm2022/ngwr-load-state.mjs +9 -5
- package/fesm2022/ngwr-load-state.mjs.map +1 -1
- package/fesm2022/ngwr-overlay.mjs +84 -1
- package/fesm2022/ngwr-overlay.mjs.map +1 -1
- package/fesm2022/ngwr-pagination.mjs +3 -2
- package/fesm2022/ngwr-pagination.mjs.map +1 -1
- package/fesm2022/ngwr-pipes.mjs +47 -9
- package/fesm2022/ngwr-pipes.mjs.map +1 -1
- package/fesm2022/ngwr-popover.mjs +93 -4
- package/fesm2022/ngwr-popover.mjs.map +1 -1
- package/fesm2022/ngwr-progress.mjs +4 -2
- package/fesm2022/ngwr-progress.mjs.map +1 -1
- package/fesm2022/ngwr-radio.mjs +9 -5
- package/fesm2022/ngwr-radio.mjs.map +1 -1
- package/fesm2022/ngwr-rating.mjs +9 -3
- package/fesm2022/ngwr-rating.mjs.map +1 -1
- package/fesm2022/ngwr-resizable.mjs +503 -0
- package/fesm2022/ngwr-resizable.mjs.map +1 -0
- package/fesm2022/ngwr-result.mjs +9 -5
- package/fesm2022/ngwr-result.mjs.map +1 -1
- package/fesm2022/ngwr-schema-form.mjs +3 -0
- package/fesm2022/ngwr-schema-form.mjs.map +1 -1
- package/fesm2022/ngwr-segmented.mjs +4 -2
- package/fesm2022/ngwr-segmented.mjs.map +1 -1
- package/fesm2022/ngwr-select.mjs +13 -5
- package/fesm2022/ngwr-select.mjs.map +1 -1
- package/fesm2022/ngwr-skeleton.mjs +4 -2
- package/fesm2022/ngwr-skeleton.mjs.map +1 -1
- package/fesm2022/ngwr-slider-testing.mjs +17 -0
- package/fesm2022/ngwr-slider-testing.mjs.map +1 -1
- package/fesm2022/ngwr-slider.mjs +91 -13
- package/fesm2022/ngwr-slider.mjs.map +1 -1
- package/fesm2022/ngwr-sortable-list-testing.mjs +103 -0
- package/fesm2022/ngwr-sortable-list-testing.mjs.map +1 -0
- package/fesm2022/ngwr-sortable-list.mjs +257 -53
- package/fesm2022/ngwr-sortable-list.mjs.map +1 -1
- package/fesm2022/ngwr-speed-dial.mjs +4 -2
- package/fesm2022/ngwr-speed-dial.mjs.map +1 -1
- package/fesm2022/ngwr-spinner.mjs +4 -2
- package/fesm2022/ngwr-spinner.mjs.map +1 -1
- package/fesm2022/ngwr-splitter.mjs +17 -21
- package/fesm2022/ngwr-splitter.mjs.map +1 -1
- package/fesm2022/ngwr-stepper.mjs +9 -3
- package/fesm2022/ngwr-stepper.mjs.map +1 -1
- package/fesm2022/ngwr-switch.mjs +9 -5
- package/fesm2022/ngwr-switch.mjs.map +1 -1
- package/fesm2022/ngwr-table-testing.mjs +5 -1
- package/fesm2022/ngwr-table-testing.mjs.map +1 -1
- package/fesm2022/ngwr-table.mjs +167 -10
- package/fesm2022/ngwr-table.mjs.map +1 -1
- package/fesm2022/ngwr-textarea.mjs +9 -3
- package/fesm2022/ngwr-textarea.mjs.map +1 -1
- package/fesm2022/ngwr-timeline.mjs +18 -8
- package/fesm2022/ngwr-timeline.mjs.map +1 -1
- package/fesm2022/ngwr-toast-testing.mjs +6 -1
- package/fesm2022/ngwr-toast-testing.mjs.map +1 -1
- package/fesm2022/ngwr-toast.mjs +529 -104
- package/fesm2022/ngwr-toast.mjs.map +1 -1
- package/fesm2022/ngwr-transfer.mjs +4 -2
- package/fesm2022/ngwr-transfer.mjs.map +1 -1
- package/fesm2022/ngwr-tree.mjs +4 -2
- package/fesm2022/ngwr-tree.mjs.map +1 -1
- package/fesm2022/ngwr-typography.mjs +9 -3
- package/fesm2022/ngwr-typography.mjs.map +1 -1
- package/fesm2022/ngwr-utils-router.mjs +18 -2
- package/fesm2022/ngwr-utils-router.mjs.map +1 -1
- package/fesm2022/ngwr-utils.mjs +9 -2
- package/fesm2022/ngwr-utils.mjs.map +1 -1
- package/fesm2022/ngwr-version.mjs +1 -1
- package/fesm2022/ngwr-version.mjs.map +1 -1
- package/fesm2022/ngwr-window.mjs +7 -4
- package/fesm2022/ngwr-window.mjs.map +1 -1
- package/fesm2022/ngwr.mjs.map +1 -1
- package/i18n/ar.json +13 -2
- package/i18n/cs.json +13 -2
- package/i18n/de.json +13 -2
- package/i18n/en.json +13 -2
- package/i18n/es.json +13 -2
- package/i18n/fr.json +13 -2
- package/i18n/he.json +13 -2
- package/i18n/hi.json +13 -2
- package/i18n/id.json +13 -2
- package/i18n/it.json +13 -2
- package/i18n/ja.json +13 -2
- package/i18n/ko.json +13 -2
- package/i18n/nl.json +13 -2
- package/i18n/pl.json +13 -2
- package/i18n/pt.json +13 -2
- package/i18n/ru.json +13 -2
- package/i18n/sv.json +13 -2
- package/i18n/tr.json +13 -2
- package/i18n/uk.json +13 -2
- package/i18n/vi.json +13 -2
- package/i18n/zh-TW.json +13 -2
- package/i18n/zh.json +13 -2
- package/input/styles/_index.scss +10 -5
- package/input-number/styles/_index.scss +6 -3
- package/input-otp/styles/_index.scss +4 -2
- package/lightbox/styles/_rules.scss +96 -0
- package/llms-full.txt +40 -17
- package/llms.txt +20 -4
- package/package.json +19 -1
- package/radio/styles/_index.scss +4 -2
- package/resizable/styles/_index.scss +154 -0
- package/schematics/use/rule.js +1 -0
- package/schematics/use/symbol-map.json +5 -0
- package/select/styles/_index.scss +6 -3
- package/skills/ngwr/SKILL.md +1 -1
- package/skills/ngwr/references/catalog.md +6 -2
- package/skills/ngwr/references/setup.md +3 -0
- package/slider/styles/_index.scss +106 -0
- package/sortable-list/styles/_rules.scss +23 -1
- package/switch/styles/_index.scss +4 -2
- package/table/styles/_index.scss +53 -0
- package/textarea/styles/_index.scss +4 -2
- package/theme/styles/_motion.scss +6 -0
- package/toast/styles/_index.scss +19 -0
- package/types/ngwr-burger.d.ts +0 -1
- package/types/ngwr-calendar.d.ts +7 -0
- package/types/ngwr-charts-calendar-heatmap.d.ts +2 -1
- package/types/ngwr-clipboard.d.ts +7 -0
- package/types/ngwr-date-picker-testing.d.ts +17 -0
- package/types/ngwr-date-picker.d.ts +88 -4
- package/types/ngwr-date-stamp-testing.d.ts +47 -0
- package/types/ngwr-date-stamp.d.ts +127 -0
- package/types/ngwr-date.d.ts +251 -37
- package/types/ngwr-dialog-testing.d.ts +10 -0
- package/types/ngwr-dialog.d.ts +72 -4
- package/types/ngwr-directives.d.ts +36 -1
- package/types/ngwr-drawer.d.ts +21 -0
- package/types/ngwr-dropdown-testing.d.ts +53 -5
- package/types/ngwr-dropdown.d.ts +100 -0
- package/types/ngwr-i18n.d.ts +44 -14
- package/types/ngwr-lightbox-testing.d.ts +27 -0
- package/types/ngwr-lightbox.d.ts +71 -6
- package/types/ngwr-overlay.d.ts +36 -0
- package/types/ngwr-pipes.d.ts +48 -13
- package/types/ngwr-popover.d.ts +39 -1
- package/types/ngwr-resizable.d.ts +228 -0
- package/types/ngwr-slider-testing.d.ts +8 -1
- package/types/ngwr-slider.d.ts +89 -3
- package/types/ngwr-sortable-list-testing.d.ts +79 -0
- package/types/ngwr-sortable-list.d.ts +113 -10
- package/types/ngwr-table-testing.d.ts +3 -1
- package/types/ngwr-table.d.ts +120 -4
- package/types/ngwr-toast-testing.d.ts +12 -1
- package/types/ngwr-toast.d.ts +215 -18
- package/types/ngwr-utils-router.d.ts +22 -0
- package/types/ngwr-utils.d.ts +8 -1
- package/types/ngwr-version.d.ts +1 -1
- package/types/ngwr.d.ts +1 -0
package/fesm2022/ngwr-toast.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as i0 from "@angular/core";
|
|
2
|
-
import { ApplicationRef, Component, DestroyRef, ENVIRONMENT_INITIALIZER, ElementRef, EnvironmentInjector, InjectionToken, Injector, Service, ViewEncapsulation, afterNextRender, computed, effect, inject, input, isDevMode, output, signal, viewChildren } from "@angular/core";
|
|
2
|
+
import { ApplicationRef, Component, DestroyRef, ENVIRONMENT_INITIALIZER, ElementRef, EnvironmentInjector, InjectionToken, Injector, Service, ViewEncapsulation, afterNextRender, computed, effect, inject, input, isDevMode, output, signal, untracked, viewChild, viewChildren } from "@angular/core";
|
|
3
3
|
import { wrCheckStyles, wrFeature, wrRestoreFocus, wrToClassList } from "ngwr/utils";
|
|
4
4
|
import { useI18nText } from "ngwr/i18n";
|
|
5
5
|
import { Directionality } from "@angular/cdk/bidi";
|
|
6
6
|
import { ComponentPortal } from "@angular/cdk/portal";
|
|
7
|
-
import { WR_OVERLAY, wrFollowDirection } from "ngwr/overlay";
|
|
7
|
+
import { WR_OVERLAY, WrOverlayOrder, wrFollowDirection } from "ngwr/overlay";
|
|
8
8
|
import { FocusMonitor } from "@angular/cdk/a11y";
|
|
9
9
|
/**
|
|
10
10
|
* @license
|
|
@@ -12,6 +12,218 @@ import { FocusMonitor } from "@angular/cdk/a11y";
|
|
|
12
12
|
* Use of this source code is governed by an MIT-style license that can be
|
|
13
13
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
14
14
|
*/
|
|
15
|
+
const DEFAULT_WR_TOAST_CONFIG = {
|
|
16
|
+
position: "top-end",
|
|
17
|
+
mode: "stack",
|
|
18
|
+
duration: 4e3,
|
|
19
|
+
showProgress: true,
|
|
20
|
+
showCopy: false,
|
|
21
|
+
showCloseAll: true,
|
|
22
|
+
closeAllThreshold: 2,
|
|
23
|
+
maxStack: 5,
|
|
24
|
+
labels: {
|
|
25
|
+
close: null,
|
|
26
|
+
copy: null,
|
|
27
|
+
copied: null,
|
|
28
|
+
closeAll: null
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* @license
|
|
33
|
+
*
|
|
34
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
35
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
36
|
+
*/
|
|
37
|
+
const WR_TOAST_CONFIG = new InjectionToken("WR_TOAST_CONFIG", {
|
|
38
|
+
providedIn: "root",
|
|
39
|
+
factory: () => DEFAULT_WR_TOAST_CONFIG
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* @license
|
|
43
|
+
*
|
|
44
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
45
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
46
|
+
*/
|
|
47
|
+
var WrToastChannel = class {
|
|
48
|
+
expire;
|
|
49
|
+
drops;
|
|
50
|
+
live;
|
|
51
|
+
maxStack;
|
|
52
|
+
duration;
|
|
53
|
+
toasts = signal([], ...ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []);
|
|
54
|
+
queued = signal(0, ...ngDevMode ? [{ debugName: "queued" }] : /* istanbul ignore next */ []);
|
|
55
|
+
queue = [];
|
|
56
|
+
held = false;
|
|
57
|
+
mounts = 0;
|
|
58
|
+
constructor(expire, drops, live, maxStack, duration) {
|
|
59
|
+
this.expire = expire;
|
|
60
|
+
this.drops = drops;
|
|
61
|
+
this.live = live;
|
|
62
|
+
this.maxStack = maxStack;
|
|
63
|
+
this.duration = duration;
|
|
64
|
+
}
|
|
65
|
+
get empty() {
|
|
66
|
+
return this.toasts().length === 0 && this.queue.length === 0;
|
|
67
|
+
}
|
|
68
|
+
find(id) {
|
|
69
|
+
return this.toasts().find((t) => t.id === id);
|
|
70
|
+
}
|
|
71
|
+
add(entry) {
|
|
72
|
+
const max = this.maxStack;
|
|
73
|
+
const active = this.toasts();
|
|
74
|
+
if (max <= 0 || active.length < max) this.toasts.set([...active, entry]);
|
|
75
|
+
else if (this.drops && this.held) {
|
|
76
|
+
if (this.queue.length >= max) this.queue.shift();
|
|
77
|
+
this.queue.push(entry);
|
|
78
|
+
this.queued.set(this.queue.length);
|
|
79
|
+
return;
|
|
80
|
+
} else if (this.drops) {
|
|
81
|
+
const kept = active.length - max + 1;
|
|
82
|
+
for (let i = 0; i < kept; i++) this.stopTimer(active[i]);
|
|
83
|
+
this.toasts.set([...active.slice(kept), entry]);
|
|
84
|
+
} else {
|
|
85
|
+
this.queue.push(entry);
|
|
86
|
+
this.queued.set(this.queue.length);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.startTimer(entry);
|
|
90
|
+
}
|
|
91
|
+
remove(id) {
|
|
92
|
+
const active = this.toasts();
|
|
93
|
+
const entry = active.find((t) => t.id === id);
|
|
94
|
+
const queuedAt = entry ? -1 : this.queue.findIndex((t) => t.id === id);
|
|
95
|
+
if (!entry && queuedAt < 0) return false;
|
|
96
|
+
if (entry) {
|
|
97
|
+
this.stopTimer(entry);
|
|
98
|
+
this.toasts.set(active.filter((t) => t !== entry));
|
|
99
|
+
} else this.queue.splice(queuedAt, 1);
|
|
100
|
+
this.promote();
|
|
101
|
+
if (this.empty) this.held = false;
|
|
102
|
+
return true;
|
|
103
|
+
}
|
|
104
|
+
clear() {
|
|
105
|
+
for (const entry of this.toasts()) this.stopTimer(entry);
|
|
106
|
+
this.toasts.set([]);
|
|
107
|
+
this.queue = [];
|
|
108
|
+
this.queued.set(0);
|
|
109
|
+
this.held = false;
|
|
110
|
+
}
|
|
111
|
+
pause(id) {
|
|
112
|
+
const entry = this.find(id);
|
|
113
|
+
if (entry) this.pauseTimer(entry);
|
|
114
|
+
}
|
|
115
|
+
resume(id) {
|
|
116
|
+
const entry = this.find(id);
|
|
117
|
+
if (entry) this.startTimer(entry);
|
|
118
|
+
}
|
|
119
|
+
setHeld(held) {
|
|
120
|
+
this.held = held;
|
|
121
|
+
if (!held) this.release();
|
|
122
|
+
this.syncTimers();
|
|
123
|
+
}
|
|
124
|
+
configure(maxStack, duration) {
|
|
125
|
+
this.maxStack = maxStack;
|
|
126
|
+
this.duration = duration;
|
|
127
|
+
const active = this.toasts();
|
|
128
|
+
if (!this.drops || maxStack <= 0 || active.length <= maxStack) return;
|
|
129
|
+
const over = active.length - maxStack;
|
|
130
|
+
for (let i = 0; i < over; i++) this.stopTimer(active[i]);
|
|
131
|
+
this.toasts.set(active.slice(over));
|
|
132
|
+
}
|
|
133
|
+
mount() {
|
|
134
|
+
this.mounts++;
|
|
135
|
+
this.live = true;
|
|
136
|
+
this.syncTimers();
|
|
137
|
+
return this.mounts;
|
|
138
|
+
}
|
|
139
|
+
unmount() {
|
|
140
|
+
if (--this.mounts > 0) return;
|
|
141
|
+
this.live = false;
|
|
142
|
+
this.held = false;
|
|
143
|
+
this.release();
|
|
144
|
+
this.syncTimers();
|
|
145
|
+
}
|
|
146
|
+
release() {
|
|
147
|
+
if (!this.drops || this.queue.length === 0) return;
|
|
148
|
+
const all = [...this.toasts(), ...this.queue];
|
|
149
|
+
const over = this.maxStack > 0 ? Math.max(0, all.length - this.maxStack) : 0;
|
|
150
|
+
for (let i = 0; i < over; i++) this.stopTimer(all[i]);
|
|
151
|
+
this.queue = [];
|
|
152
|
+
this.queued.set(0);
|
|
153
|
+
this.toasts.set(all.slice(over));
|
|
154
|
+
}
|
|
155
|
+
syncTimers() {
|
|
156
|
+
const running = this.live && !this.held;
|
|
157
|
+
for (const entry of this.toasts()) if (running) this.startTimer(entry);
|
|
158
|
+
else this.pauseTimer(entry);
|
|
159
|
+
}
|
|
160
|
+
promote() {
|
|
161
|
+
const max = this.maxStack;
|
|
162
|
+
const promoted = [];
|
|
163
|
+
while (this.queue.length > 0 && (max <= 0 || this.toasts().length + promoted.length < max)) promoted.push(this.queue.shift());
|
|
164
|
+
if (promoted.length === 0) return;
|
|
165
|
+
this.toasts.update((active) => [...active, ...promoted]);
|
|
166
|
+
this.queued.set(this.queue.length);
|
|
167
|
+
for (const entry of promoted) this.startTimer(entry);
|
|
168
|
+
}
|
|
169
|
+
startTimer(entry) {
|
|
170
|
+
if (entry.remaining <= 0 || entry.timer || this.held || !this.live) return;
|
|
171
|
+
entry.startedAt = Date.now();
|
|
172
|
+
entry.timer = setTimeout(() => this.expire(entry.id), entry.remaining);
|
|
173
|
+
}
|
|
174
|
+
pauseTimer(entry) {
|
|
175
|
+
if (!entry.timer) return;
|
|
176
|
+
this.stopTimer(entry);
|
|
177
|
+
if (entry.startedAt) entry.remaining = Math.max(0, entry.remaining - (Date.now() - entry.startedAt));
|
|
178
|
+
}
|
|
179
|
+
stopTimer(entry) {
|
|
180
|
+
if (!entry.timer) return;
|
|
181
|
+
clearTimeout(entry.timer);
|
|
182
|
+
entry.timer = void 0;
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
var WrToastChannels = class WrToastChannels {
|
|
186
|
+
config = inject(WR_TOAST_CONFIG);
|
|
187
|
+
channels = /* @__PURE__ */ new Map();
|
|
188
|
+
get(name) {
|
|
189
|
+
let channel = this.channels.get(name);
|
|
190
|
+
if (!channel) {
|
|
191
|
+
channel = new WrToastChannel((id) => channel?.remove(id), true, false, this.config.maxStack, this.config.duration);
|
|
192
|
+
this.channels.set(name, channel);
|
|
193
|
+
}
|
|
194
|
+
return channel;
|
|
195
|
+
}
|
|
196
|
+
remove(id) {
|
|
197
|
+
for (const channel of this.channels.values()) if (channel.remove(id)) return;
|
|
198
|
+
}
|
|
199
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
200
|
+
minVersion: "12.0.0",
|
|
201
|
+
version: "22.2.5",
|
|
202
|
+
ngImport: i0,
|
|
203
|
+
type: WrToastChannels,
|
|
204
|
+
deps: [],
|
|
205
|
+
target: i0.ɵɵFactoryTarget.Service
|
|
206
|
+
});
|
|
207
|
+
static ɵprov = i0.ɵɵngDeclareService({
|
|
208
|
+
minVersion: "22.0.0",
|
|
209
|
+
version: "22.2.5",
|
|
210
|
+
ngImport: i0,
|
|
211
|
+
type: WrToastChannels
|
|
212
|
+
});
|
|
213
|
+
};
|
|
214
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
215
|
+
minVersion: "12.0.0",
|
|
216
|
+
version: "22.2.5",
|
|
217
|
+
ngImport: i0,
|
|
218
|
+
type: WrToastChannels,
|
|
219
|
+
decorators: [{ type: Service }]
|
|
220
|
+
});
|
|
221
|
+
/**
|
|
222
|
+
* @license
|
|
223
|
+
*
|
|
224
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
225
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
226
|
+
*/
|
|
15
227
|
var WrToastItem = class WrToastItem {
|
|
16
228
|
constructor() {
|
|
17
229
|
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("toast");
|
|
@@ -209,7 +421,8 @@ var WrToastItem = class WrToastItem {
|
|
|
209
421
|
"style.transition": "swiping() ? \"none\" : null",
|
|
210
422
|
"attr.role": "liveRole()",
|
|
211
423
|
"attr.aria-live": "liveLevel()"
|
|
212
|
-
}
|
|
424
|
+
},
|
|
425
|
+
classAttribute: "wr-toast"
|
|
213
426
|
},
|
|
214
427
|
ngImport: i0,
|
|
215
428
|
template: "<!-- A glyph per type, and this is the one channel the toast had none of. Its\n four types differed by `--wr-toast-accent` alone — a 3px inline-start\n border, in four colours that sit within 1.06:1 of each other in relative\n luminance, so `success` and `danger` were the same 3px line to a reader\n who cannot separate hue. The shapes are the ones `wr-alert` and\n `wr-result` already use for the same four meanings: a check in a broken\n circle, a triangle, an octagon, an `i`. Three components agreeing is worth\n more than three components each being locally reasonable.\n\n `aria-hidden`, because the type is already announced: the host takes\n `role=\"alert\"` for danger and `role=\"status\"` otherwise. -->\n<svg\n class=\"wr-toast__icon wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n>\n @switch (type()) {\n @case ('success') {\n <path d=\"M21.801 10A10 10 0 1 1 17 3.335\" />\n <path d=\"m9 11 3 3L22 4\" />\n }\n @case ('warning') {\n <path d=\"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3\" />\n <path d=\"M12 9v4\" />\n <path d=\"M12 17h.01\" />\n }\n @case ('danger') {\n <path\n d=\"M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z\"\n />\n <path d=\"M12 8v4\" />\n <path d=\"M12 16h.01\" />\n }\n @default {\n <circle cx=\"12\" cy=\"12\" r=\"10\" />\n <path d=\"M12 16v-4\" />\n <path d=\"M12 8h.01\" />\n }\n }\n</svg>\n\n<!-- Each part renders only when it has text. A title-only toast is shown with\n `message: ''`, and the empty `<p>` it used to leave behind kept the title's\n bottom margin under it: 4px of dead space that made the card taller below\n its one line than above it. -->\n<div class=\"wr-toast__body\">\n @if (title(); as text) {\n <p class=\"wr-toast__title\">{{ text }}</p>\n }\n @if (message(); as text) {\n <p class=\"wr-toast__message\">{{ text }}</p>\n }\n</div>\n\n<div class=\"wr-toast__actions\">\n @if (actionLabel(); as label) {\n <button type=\"button\" class=\"wr-toast__action wr-toast__action--run\" (click)=\"actionRequested.emit()\">\n {{ label }}\n </button>\n }\n\n @if (showCopy()) {\n <button\n type=\"button\"\n class=\"wr-toast__action wr-toast__action--copy\"\n [attr.aria-label]=\"justCopied() ? labels().copied : labels().copy\"\n [title]=\"justCopied() ? labels().copied : labels().copy\"\n (click)=\"onCopy()\"\n >\n @if (justCopied()) {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M20 6 9 17l-5-5\" />\n </svg>\n } @else {\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <rect width=\"14\" height=\"14\" x=\"8\" y=\"8\" rx=\"2\" ry=\"2\" />\n <path d=\"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2\" />\n </svg>\n }\n </button>\n }\n\n @if (closable()) {\n <button\n type=\"button\"\n class=\"wr-toast__action wr-toast__action--close\"\n [attr.aria-label]=\"labels().close\"\n [title]=\"labels().close\"\n (click)=\"dismissed.emit()\"\n >\n <svg\n class=\"wr-icon__svg\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n aria-hidden=\"true\"\n >\n <path d=\"M18 6 6 18\" />\n <path d=\"m6 6 12 12\" />\n </svg>\n </button>\n }\n</div>\n\n@if (progressVisible()) {\n <span class=\"wr-toast__progress\" aria-hidden=\"true\"></span>\n}\n",
|
|
@@ -228,6 +441,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
228
441
|
encapsulation: ViewEncapsulation.None,
|
|
229
442
|
host: {
|
|
230
443
|
"[attr.title]": "null",
|
|
444
|
+
class: "wr-toast",
|
|
231
445
|
"[class]": "classes()",
|
|
232
446
|
"[style.--wr-toast-duration]": "durationMs()",
|
|
233
447
|
"[style.transform]": "swipeTransform()",
|
|
@@ -592,7 +806,8 @@ var WrToastHost = class WrToastHost {
|
|
|
592
806
|
"class": "classes()",
|
|
593
807
|
"style.--wr-toast-front-height": "frontHeight()",
|
|
594
808
|
"attr.aria-label": "regionLabel()"
|
|
595
|
-
}
|
|
809
|
+
},
|
|
810
|
+
classAttribute: "wr-toast-host"
|
|
596
811
|
},
|
|
597
812
|
viewQueries: [{
|
|
598
813
|
propertyName: "items",
|
|
@@ -640,6 +855,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
640
855
|
selector: "wr-toast-host",
|
|
641
856
|
encapsulation: ViewEncapsulation.None,
|
|
642
857
|
host: {
|
|
858
|
+
class: "wr-toast-host",
|
|
643
859
|
"[class]": "classes()",
|
|
644
860
|
"[style.--wr-toast-front-height]": "frontHeight()",
|
|
645
861
|
role: "region",
|
|
@@ -737,40 +953,9 @@ var WrToastRef = class {
|
|
|
737
953
|
* Use of this source code is governed by an MIT-style license that can be
|
|
738
954
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
739
955
|
*/
|
|
740
|
-
const DEFAULT_WR_TOAST_CONFIG = {
|
|
741
|
-
position: "top-end",
|
|
742
|
-
mode: "stack",
|
|
743
|
-
duration: 4e3,
|
|
744
|
-
showProgress: true,
|
|
745
|
-
showCopy: false,
|
|
746
|
-
showCloseAll: true,
|
|
747
|
-
closeAllThreshold: 2,
|
|
748
|
-
maxStack: 5,
|
|
749
|
-
labels: {
|
|
750
|
-
close: null,
|
|
751
|
-
copy: null,
|
|
752
|
-
copied: null,
|
|
753
|
-
closeAll: null
|
|
754
|
-
}
|
|
755
|
-
};
|
|
756
|
-
/**
|
|
757
|
-
* @license
|
|
758
|
-
*
|
|
759
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
760
|
-
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
761
|
-
*/
|
|
762
|
-
const WR_TOAST_CONFIG = new InjectionToken("WR_TOAST_CONFIG", {
|
|
763
|
-
providedIn: "root",
|
|
764
|
-
factory: () => DEFAULT_WR_TOAST_CONFIG
|
|
765
|
-
});
|
|
766
|
-
/**
|
|
767
|
-
* @license
|
|
768
|
-
*
|
|
769
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
770
|
-
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
771
|
-
*/
|
|
772
956
|
var WrToast = class WrToast {
|
|
773
957
|
overlay = inject(WR_OVERLAY);
|
|
958
|
+
order = inject(WrOverlayOrder);
|
|
774
959
|
config = inject(WR_TOAST_CONFIG);
|
|
775
960
|
injector = inject(Injector);
|
|
776
961
|
dir = inject(Directionality, { optional: true });
|
|
@@ -780,51 +965,53 @@ var WrToast = class WrToast {
|
|
|
780
965
|
currentPosition = this.config.position;
|
|
781
966
|
currentMode = this.config.mode;
|
|
782
967
|
nextId = 1;
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
held = false;
|
|
968
|
+
global = new WrToastChannel((id) => this.dismiss(id), false, true, this.config.maxStack, this.config.duration);
|
|
969
|
+
outlets = inject(WrToastChannels);
|
|
786
970
|
show(options) {
|
|
971
|
+
const id = this.nextId++;
|
|
972
|
+
const ref = new WrToastRef(id, options, (toastId) => this.dismiss(toastId));
|
|
973
|
+
if (options.outlet != null) {
|
|
974
|
+
const channel = this.outlets.get(options.outlet);
|
|
975
|
+
const resolvedDuration = options.duration ?? channel.duration;
|
|
976
|
+
channel.add({
|
|
977
|
+
...options,
|
|
978
|
+
id,
|
|
979
|
+
resolvedDuration,
|
|
980
|
+
remaining: resolvedDuration
|
|
981
|
+
});
|
|
982
|
+
return ref;
|
|
983
|
+
}
|
|
787
984
|
const resolvedPosition = options.position ?? this.currentPosition;
|
|
788
985
|
const resolvedDuration = options.duration ?? this.config.duration;
|
|
789
986
|
this.ensureHost(resolvedPosition);
|
|
790
987
|
this.raiseHost();
|
|
791
988
|
const entry = {
|
|
792
989
|
...options,
|
|
793
|
-
id
|
|
990
|
+
id,
|
|
794
991
|
resolvedDuration,
|
|
795
|
-
resolvedPosition,
|
|
796
992
|
remaining: resolvedDuration
|
|
797
993
|
};
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
this.pushToHost();
|
|
802
|
-
} else {
|
|
803
|
-
this.active = [...this.active, entry];
|
|
804
|
-
this.pushToHost();
|
|
805
|
-
this.startTimer(entry);
|
|
806
|
-
}
|
|
807
|
-
return new WrToastRef(entry.id, options, (id) => this.dismiss(id));
|
|
994
|
+
this.global.add(entry);
|
|
995
|
+
this.pushToHost();
|
|
996
|
+
return ref;
|
|
808
997
|
}
|
|
809
998
|
dismiss(id) {
|
|
810
|
-
|
|
811
|
-
if (entry?.timer) clearTimeout(entry.timer);
|
|
812
|
-
this.active = this.active.filter((t) => t.id !== id);
|
|
813
|
-
this.queue = this.queue.filter((t) => t.id !== id);
|
|
814
|
-
this.promoteFromQueue();
|
|
999
|
+
if (!this.global.remove(id)) this.outlets.remove(id);
|
|
815
1000
|
this.pushToHost();
|
|
816
|
-
if (this.
|
|
1001
|
+
if (this.global.empty) this.disposeHost();
|
|
817
1002
|
}
|
|
818
1003
|
runAction(id) {
|
|
819
|
-
const action = this.
|
|
1004
|
+
const action = this.global.find(id)?.action;
|
|
820
1005
|
if (!action) return;
|
|
821
1006
|
this.dismiss(id);
|
|
822
1007
|
action.run();
|
|
823
1008
|
}
|
|
824
|
-
dismissAll() {
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
1009
|
+
dismissAll(outlet) {
|
|
1010
|
+
if (outlet != null) {
|
|
1011
|
+
this.outlets.get(outlet).clear();
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
this.global.clear();
|
|
828
1015
|
this.disposeHost();
|
|
829
1016
|
}
|
|
830
1017
|
setPosition(position) {
|
|
@@ -835,22 +1022,6 @@ var WrToast = class WrToast {
|
|
|
835
1022
|
this.currentMode = mode;
|
|
836
1023
|
if (this.hostRef) this.hostRef.setInput("mode", mode);
|
|
837
1024
|
}
|
|
838
|
-
startTimer(entry) {
|
|
839
|
-
if (entry.remaining <= 0 || entry.timer || this.held) return;
|
|
840
|
-
entry.startedAt = Date.now();
|
|
841
|
-
entry.timer = setTimeout(() => this.dismiss(entry.id), entry.remaining);
|
|
842
|
-
}
|
|
843
|
-
pauseTimer(entry) {
|
|
844
|
-
if (!entry.timer) return;
|
|
845
|
-
clearTimeout(entry.timer);
|
|
846
|
-
entry.timer = void 0;
|
|
847
|
-
if (entry.startedAt) entry.remaining = Math.max(0, entry.remaining - (Date.now() - entry.startedAt));
|
|
848
|
-
}
|
|
849
|
-
setHeld(held) {
|
|
850
|
-
this.held = held;
|
|
851
|
-
for (const entry of this.active) if (held) this.pauseTimer(entry);
|
|
852
|
-
else this.startTimer(entry);
|
|
853
|
-
}
|
|
854
1025
|
ensureHost(position) {
|
|
855
1026
|
if (this.overlayRef) {
|
|
856
1027
|
if (position !== this.currentPosition) this.setPosition(position);
|
|
@@ -873,25 +1044,16 @@ var WrToast = class WrToast {
|
|
|
873
1044
|
inst.dismissed.subscribe((id) => this.dismiss(id));
|
|
874
1045
|
inst.actionRequested.subscribe((id) => this.runAction(id));
|
|
875
1046
|
inst.dismissAllRequested.subscribe(() => this.dismissAll());
|
|
876
|
-
inst.pauseRequested.subscribe((id) =>
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
});
|
|
880
|
-
inst.resumeRequested.subscribe((id) => {
|
|
881
|
-
const entry = this.active.find((t) => t.id === id);
|
|
882
|
-
if (entry) this.startTimer(entry);
|
|
883
|
-
});
|
|
884
|
-
inst.holdChange.subscribe((held) => this.setHeld(held));
|
|
1047
|
+
inst.pauseRequested.subscribe((id) => this.global.pause(id));
|
|
1048
|
+
inst.resumeRequested.subscribe((id) => this.global.resume(id));
|
|
1049
|
+
inst.holdChange.subscribe((held) => this.global.setHeld(held));
|
|
885
1050
|
this.watchForNewerOverlays();
|
|
886
1051
|
}
|
|
887
1052
|
raiseHost() {
|
|
888
1053
|
const host = this.overlayRef?.hostElement;
|
|
889
1054
|
if (!host?.isConnected || !host.hasAttribute("popover")) return;
|
|
890
1055
|
if (host.contains(host.ownerDocument.activeElement)) return;
|
|
891
|
-
|
|
892
|
-
host.hidePopover();
|
|
893
|
-
host.showPopover();
|
|
894
|
-
} catch {}
|
|
1056
|
+
this.order.raiseToasts(host);
|
|
895
1057
|
}
|
|
896
1058
|
watchForNewerOverlays() {
|
|
897
1059
|
const parent = this.overlayRef?.hostElement.parentElement;
|
|
@@ -899,23 +1061,15 @@ var WrToast = class WrToast {
|
|
|
899
1061
|
this.containerObserver = new MutationObserver(() => this.raiseHost());
|
|
900
1062
|
this.containerObserver.observe(parent, { childList: true });
|
|
901
1063
|
}
|
|
902
|
-
promoteFromQueue() {
|
|
903
|
-
const max = this.config.maxStack;
|
|
904
|
-
while ((max <= 0 || this.active.length < max) && this.queue.length > 0) {
|
|
905
|
-
const [next, ...rest] = this.queue;
|
|
906
|
-
this.queue = rest;
|
|
907
|
-
this.active = [...this.active, next];
|
|
908
|
-
this.startTimer(next);
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
1064
|
pushToHost() {
|
|
912
|
-
this.hostRef?.instance.toasts.set(
|
|
913
|
-
this.hostRef?.instance.queued.set(this.
|
|
1065
|
+
this.hostRef?.instance.toasts.set(this.global.toasts());
|
|
1066
|
+
this.hostRef?.instance.queued.set(this.global.queued());
|
|
914
1067
|
}
|
|
915
1068
|
disposeHost() {
|
|
916
|
-
this.
|
|
1069
|
+
this.global.setHeld(false);
|
|
917
1070
|
this.containerObserver?.disconnect();
|
|
918
1071
|
this.containerObserver = null;
|
|
1072
|
+
this.order.dropToasts();
|
|
919
1073
|
if (this.overlayRef) {
|
|
920
1074
|
this.overlayRef.dispose();
|
|
921
1075
|
this.overlayRef = null;
|
|
@@ -950,6 +1104,277 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
950
1104
|
* Use of this source code is governed by an MIT-style license that can be
|
|
951
1105
|
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
952
1106
|
*/
|
|
1107
|
+
var WrToastOutlet = class WrToastOutlet {
|
|
1108
|
+
config = inject(WR_TOAST_CONFIG);
|
|
1109
|
+
channels = inject(WrToastChannels);
|
|
1110
|
+
name = input.required(...ngDevMode ? [{ debugName: "name" }] : /* istanbul ignore next */ []);
|
|
1111
|
+
position = input(this.config.position, ...ngDevMode ? [{ debugName: "position" }] : /* istanbul ignore next */ []);
|
|
1112
|
+
mode = input(this.config.mode, ...ngDevMode ? [{ debugName: "mode" }] : /* istanbul ignore next */ []);
|
|
1113
|
+
duration = input(this.config.duration, ...ngDevMode ? [{ debugName: "duration" }] : /* istanbul ignore next */ []);
|
|
1114
|
+
showProgress = input(this.config.showProgress, ...ngDevMode ? [{ debugName: "showProgress" }] : /* istanbul ignore next */ []);
|
|
1115
|
+
showCopy = input(this.config.showCopy, ...ngDevMode ? [{ debugName: "showCopy" }] : /* istanbul ignore next */ []);
|
|
1116
|
+
showCloseAll = input(this.config.showCloseAll, ...ngDevMode ? [{ debugName: "showCloseAll" }] : /* istanbul ignore next */ []);
|
|
1117
|
+
closeAllThreshold = input(this.config.closeAllThreshold, ...ngDevMode ? [{ debugName: "closeAllThreshold" }] : /* istanbul ignore next */ []);
|
|
1118
|
+
maxStack = input(this.config.maxStack, ...ngDevMode ? [{ debugName: "maxStack" }] : /* istanbul ignore next */ []);
|
|
1119
|
+
channel = computed(() => this.channels.get(this.name()), ...ngDevMode ? [{ debugName: "channel" }] : /* istanbul ignore next */ []);
|
|
1120
|
+
resolved = computed(() => ({
|
|
1121
|
+
...this.config,
|
|
1122
|
+
position: this.position(),
|
|
1123
|
+
mode: this.mode(),
|
|
1124
|
+
duration: this.duration(),
|
|
1125
|
+
showProgress: this.showProgress(),
|
|
1126
|
+
showCopy: this.showCopy(),
|
|
1127
|
+
showCloseAll: this.showCloseAll(),
|
|
1128
|
+
closeAllThreshold: this.closeAllThreshold(),
|
|
1129
|
+
maxStack: this.maxStack()
|
|
1130
|
+
}), ...ngDevMode ? [{ debugName: "resolved" }] : /* istanbul ignore next */ []);
|
|
1131
|
+
host = viewChild(WrToastHost, ...ngDevMode ? [{ debugName: "host" }] : /* istanbul ignore next */ []);
|
|
1132
|
+
constructor() {
|
|
1133
|
+
if (typeof ngDevMode === "undefined" || ngDevMode) wrCheckStyles("toast");
|
|
1134
|
+
effect(() => this.channel().configure(this.maxStack(), this.duration()));
|
|
1135
|
+
effect((onCleanup) => {
|
|
1136
|
+
const channel = this.channel();
|
|
1137
|
+
if (untracked(() => channel.mount()) > 1 && (typeof ngDevMode === "undefined" || ngDevMode)) console.warn(`[NGWR] Two <wr-toast-outlet> share the name "${this.name()}", so both render the same toasts. Give each outlet its own name.`);
|
|
1138
|
+
onCleanup(() => channel.unmount());
|
|
1139
|
+
});
|
|
1140
|
+
effect(() => this.push());
|
|
1141
|
+
}
|
|
1142
|
+
onDismissed(id) {
|
|
1143
|
+
this.channel().remove(id);
|
|
1144
|
+
this.push();
|
|
1145
|
+
}
|
|
1146
|
+
onAction(id) {
|
|
1147
|
+
const channel = this.channel();
|
|
1148
|
+
const action = channel.find(id)?.action;
|
|
1149
|
+
if (!action) return;
|
|
1150
|
+
channel.remove(id);
|
|
1151
|
+
this.push();
|
|
1152
|
+
action.run();
|
|
1153
|
+
}
|
|
1154
|
+
onDismissAll() {
|
|
1155
|
+
this.channel().clear();
|
|
1156
|
+
this.push();
|
|
1157
|
+
}
|
|
1158
|
+
push() {
|
|
1159
|
+
this.host()?.toasts.set(this.channel().toasts());
|
|
1160
|
+
}
|
|
1161
|
+
static ɵfac = i0.ɵɵngDeclareFactory({
|
|
1162
|
+
minVersion: "12.0.0",
|
|
1163
|
+
version: "22.2.5",
|
|
1164
|
+
ngImport: i0,
|
|
1165
|
+
type: WrToastOutlet,
|
|
1166
|
+
deps: [],
|
|
1167
|
+
target: i0.ɵɵFactoryTarget.Component
|
|
1168
|
+
});
|
|
1169
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({
|
|
1170
|
+
minVersion: "17.0.0",
|
|
1171
|
+
version: "22.2.5",
|
|
1172
|
+
type: WrToastOutlet,
|
|
1173
|
+
isStandalone: true,
|
|
1174
|
+
selector: "wr-toast-outlet",
|
|
1175
|
+
inputs: {
|
|
1176
|
+
name: {
|
|
1177
|
+
classPropertyName: "name",
|
|
1178
|
+
publicName: "name",
|
|
1179
|
+
isSignal: true,
|
|
1180
|
+
isRequired: true,
|
|
1181
|
+
transformFunction: null
|
|
1182
|
+
},
|
|
1183
|
+
position: {
|
|
1184
|
+
classPropertyName: "position",
|
|
1185
|
+
publicName: "position",
|
|
1186
|
+
isSignal: true,
|
|
1187
|
+
isRequired: false,
|
|
1188
|
+
transformFunction: null
|
|
1189
|
+
},
|
|
1190
|
+
mode: {
|
|
1191
|
+
classPropertyName: "mode",
|
|
1192
|
+
publicName: "mode",
|
|
1193
|
+
isSignal: true,
|
|
1194
|
+
isRequired: false,
|
|
1195
|
+
transformFunction: null
|
|
1196
|
+
},
|
|
1197
|
+
duration: {
|
|
1198
|
+
classPropertyName: "duration",
|
|
1199
|
+
publicName: "duration",
|
|
1200
|
+
isSignal: true,
|
|
1201
|
+
isRequired: false,
|
|
1202
|
+
transformFunction: null
|
|
1203
|
+
},
|
|
1204
|
+
showProgress: {
|
|
1205
|
+
classPropertyName: "showProgress",
|
|
1206
|
+
publicName: "showProgress",
|
|
1207
|
+
isSignal: true,
|
|
1208
|
+
isRequired: false,
|
|
1209
|
+
transformFunction: null
|
|
1210
|
+
},
|
|
1211
|
+
showCopy: {
|
|
1212
|
+
classPropertyName: "showCopy",
|
|
1213
|
+
publicName: "showCopy",
|
|
1214
|
+
isSignal: true,
|
|
1215
|
+
isRequired: false,
|
|
1216
|
+
transformFunction: null
|
|
1217
|
+
},
|
|
1218
|
+
showCloseAll: {
|
|
1219
|
+
classPropertyName: "showCloseAll",
|
|
1220
|
+
publicName: "showCloseAll",
|
|
1221
|
+
isSignal: true,
|
|
1222
|
+
isRequired: false,
|
|
1223
|
+
transformFunction: null
|
|
1224
|
+
},
|
|
1225
|
+
closeAllThreshold: {
|
|
1226
|
+
classPropertyName: "closeAllThreshold",
|
|
1227
|
+
publicName: "closeAllThreshold",
|
|
1228
|
+
isSignal: true,
|
|
1229
|
+
isRequired: false,
|
|
1230
|
+
transformFunction: null
|
|
1231
|
+
},
|
|
1232
|
+
maxStack: {
|
|
1233
|
+
classPropertyName: "maxStack",
|
|
1234
|
+
publicName: "maxStack",
|
|
1235
|
+
isSignal: true,
|
|
1236
|
+
isRequired: false,
|
|
1237
|
+
transformFunction: null
|
|
1238
|
+
}
|
|
1239
|
+
},
|
|
1240
|
+
host: {
|
|
1241
|
+
properties: { "attr.name": "name()" },
|
|
1242
|
+
classAttribute: "wr-toast-outlet"
|
|
1243
|
+
},
|
|
1244
|
+
viewQueries: [{
|
|
1245
|
+
propertyName: "host",
|
|
1246
|
+
first: true,
|
|
1247
|
+
predicate: WrToastHost,
|
|
1248
|
+
descendants: true,
|
|
1249
|
+
isSignal: true
|
|
1250
|
+
}],
|
|
1251
|
+
ngImport: i0,
|
|
1252
|
+
template: "@if (channel().toasts().length > 0) {\n <wr-toast-host\n [position]=\"position()\"\n [mode]=\"mode()\"\n [config]=\"resolved()\"\n (dismissed)=\"onDismissed($event)\"\n (actionRequested)=\"onAction($event)\"\n (dismissAllRequested)=\"onDismissAll()\"\n (pauseRequested)=\"channel().pause($event)\"\n (resumeRequested)=\"channel().resume($event)\"\n (holdChange)=\"channel().setHeld($event)\"\n />\n}\n",
|
|
1253
|
+
dependencies: [{
|
|
1254
|
+
kind: "component",
|
|
1255
|
+
type: WrToastHost,
|
|
1256
|
+
selector: "wr-toast-host",
|
|
1257
|
+
inputs: [
|
|
1258
|
+
"position",
|
|
1259
|
+
"config",
|
|
1260
|
+
"mode"
|
|
1261
|
+
],
|
|
1262
|
+
outputs: [
|
|
1263
|
+
"dismissed",
|
|
1264
|
+
"actionRequested",
|
|
1265
|
+
"pauseRequested",
|
|
1266
|
+
"resumeRequested",
|
|
1267
|
+
"holdChange",
|
|
1268
|
+
"dismissAllRequested"
|
|
1269
|
+
]
|
|
1270
|
+
}],
|
|
1271
|
+
encapsulation: i0.ViewEncapsulation.None
|
|
1272
|
+
});
|
|
1273
|
+
};
|
|
1274
|
+
i0.ɵɵngDeclareClassMetadata({
|
|
1275
|
+
minVersion: "12.0.0",
|
|
1276
|
+
version: "22.2.5",
|
|
1277
|
+
ngImport: i0,
|
|
1278
|
+
type: WrToastOutlet,
|
|
1279
|
+
decorators: [{
|
|
1280
|
+
type: Component,
|
|
1281
|
+
args: [{
|
|
1282
|
+
selector: "wr-toast-outlet",
|
|
1283
|
+
encapsulation: ViewEncapsulation.None,
|
|
1284
|
+
host: {
|
|
1285
|
+
class: "wr-toast-outlet",
|
|
1286
|
+
"[attr.name]": "name()"
|
|
1287
|
+
},
|
|
1288
|
+
imports: [WrToastHost],
|
|
1289
|
+
template: "@if (channel().toasts().length > 0) {\n <wr-toast-host\n [position]=\"position()\"\n [mode]=\"mode()\"\n [config]=\"resolved()\"\n (dismissed)=\"onDismissed($event)\"\n (actionRequested)=\"onAction($event)\"\n (dismissAllRequested)=\"onDismissAll()\"\n (pauseRequested)=\"channel().pause($event)\"\n (resumeRequested)=\"channel().resume($event)\"\n (holdChange)=\"channel().setHeld($event)\"\n />\n}\n"
|
|
1290
|
+
}]
|
|
1291
|
+
}],
|
|
1292
|
+
ctorParameters: () => [],
|
|
1293
|
+
propDecorators: {
|
|
1294
|
+
name: [{
|
|
1295
|
+
type: i0.Input,
|
|
1296
|
+
args: [{
|
|
1297
|
+
isSignal: true,
|
|
1298
|
+
alias: "name",
|
|
1299
|
+
required: true
|
|
1300
|
+
}]
|
|
1301
|
+
}],
|
|
1302
|
+
position: [{
|
|
1303
|
+
type: i0.Input,
|
|
1304
|
+
args: [{
|
|
1305
|
+
isSignal: true,
|
|
1306
|
+
alias: "position",
|
|
1307
|
+
required: false
|
|
1308
|
+
}]
|
|
1309
|
+
}],
|
|
1310
|
+
mode: [{
|
|
1311
|
+
type: i0.Input,
|
|
1312
|
+
args: [{
|
|
1313
|
+
isSignal: true,
|
|
1314
|
+
alias: "mode",
|
|
1315
|
+
required: false
|
|
1316
|
+
}]
|
|
1317
|
+
}],
|
|
1318
|
+
duration: [{
|
|
1319
|
+
type: i0.Input,
|
|
1320
|
+
args: [{
|
|
1321
|
+
isSignal: true,
|
|
1322
|
+
alias: "duration",
|
|
1323
|
+
required: false
|
|
1324
|
+
}]
|
|
1325
|
+
}],
|
|
1326
|
+
showProgress: [{
|
|
1327
|
+
type: i0.Input,
|
|
1328
|
+
args: [{
|
|
1329
|
+
isSignal: true,
|
|
1330
|
+
alias: "showProgress",
|
|
1331
|
+
required: false
|
|
1332
|
+
}]
|
|
1333
|
+
}],
|
|
1334
|
+
showCopy: [{
|
|
1335
|
+
type: i0.Input,
|
|
1336
|
+
args: [{
|
|
1337
|
+
isSignal: true,
|
|
1338
|
+
alias: "showCopy",
|
|
1339
|
+
required: false
|
|
1340
|
+
}]
|
|
1341
|
+
}],
|
|
1342
|
+
showCloseAll: [{
|
|
1343
|
+
type: i0.Input,
|
|
1344
|
+
args: [{
|
|
1345
|
+
isSignal: true,
|
|
1346
|
+
alias: "showCloseAll",
|
|
1347
|
+
required: false
|
|
1348
|
+
}]
|
|
1349
|
+
}],
|
|
1350
|
+
closeAllThreshold: [{
|
|
1351
|
+
type: i0.Input,
|
|
1352
|
+
args: [{
|
|
1353
|
+
isSignal: true,
|
|
1354
|
+
alias: "closeAllThreshold",
|
|
1355
|
+
required: false
|
|
1356
|
+
}]
|
|
1357
|
+
}],
|
|
1358
|
+
maxStack: [{
|
|
1359
|
+
type: i0.Input,
|
|
1360
|
+
args: [{
|
|
1361
|
+
isSignal: true,
|
|
1362
|
+
alias: "maxStack",
|
|
1363
|
+
required: false
|
|
1364
|
+
}]
|
|
1365
|
+
}],
|
|
1366
|
+
host: [{
|
|
1367
|
+
type: i0.ViewChild,
|
|
1368
|
+
args: [i0.forwardRef(() => WrToastHost), { isSignal: true }]
|
|
1369
|
+
}]
|
|
1370
|
+
}
|
|
1371
|
+
});
|
|
1372
|
+
/**
|
|
1373
|
+
* @license
|
|
1374
|
+
*
|
|
1375
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
1376
|
+
* found in the LICENSE file at https://github.com/thekhegay/ngwr/blob/main/LICENSE
|
|
1377
|
+
*/
|
|
953
1378
|
function withToast(config) {
|
|
954
1379
|
const merged = {
|
|
955
1380
|
...DEFAULT_WR_TOAST_CONFIG,
|
|
@@ -970,6 +1395,6 @@ function withToast(config) {
|
|
|
970
1395
|
}
|
|
971
1396
|
}] : []]);
|
|
972
1397
|
}
|
|
973
|
-
export { DEFAULT_WR_TOAST_CONFIG, WR_TOAST_CONFIG, WrToast, WrToastRef, withToast };
|
|
1398
|
+
export { DEFAULT_WR_TOAST_CONFIG, WR_TOAST_CONFIG, WrToast, WrToastOutlet, WrToastRef, withToast };
|
|
974
1399
|
|
|
975
1400
|
//# sourceMappingURL=ngwr-toast.mjs.map
|