@nanahoshi/mona-ui 0.24.11 → 0.25.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/README.md +9 -0
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +11 -10
- package/fesm2022/nanahoshi-mona-ui-avatar.mjs +37 -20
- package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +239 -47
- package/fesm2022/nanahoshi-mona-ui-button-group.mjs +184 -31
- package/fesm2022/nanahoshi-mona-ui-button.mjs +47 -11
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +17 -13
- package/fesm2022/nanahoshi-mona-ui-card.mjs +54 -30
- package/fesm2022/nanahoshi-mona-ui-chart.mjs +27 -22
- package/fesm2022/nanahoshi-mona-ui-check-box.mjs +112 -31
- package/fesm2022/nanahoshi-mona-ui-chip.mjs +131 -89
- package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +59 -19
- package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +118 -41
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +243 -212
- package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +155 -86
- package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +161 -131
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +12 -11
- package/fesm2022/nanahoshi-mona-ui-common.mjs +18 -1
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-dialog.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-editor.mjs +25 -24
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +202 -33
- package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +31 -10
- package/fesm2022/nanahoshi-mona-ui-filter.mjs +1 -1
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-DhKLnW06.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-2tVhD2hK.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-voGbKOiB.mjs → nanahoshi-mona-ui-grid-grid-list.component-BAN70Wcn.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-HQ1Kv6R9.mjs → nanahoshi-mona-ui-grid-grid-row.component-C_kCaA5b.mjs} +7 -7
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-PNLJFcuH.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-BsNfrAHz.mjs} +4 -4
- package/fesm2022/{nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-BO19AVwC.mjs → nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-CEfVa7eo.mjs} +27 -29
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +39 -4
- package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +5 -5
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +7 -7
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +183 -47
- package/fesm2022/nanahoshi-mona-ui-label.mjs +111 -15
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +33 -4
- package/fesm2022/nanahoshi-mona-ui-menubar.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +14 -13
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +13 -12
- package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +192 -56
- package/fesm2022/nanahoshi-mona-ui-pager.mjs +1 -1
- package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +3 -1
- package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +60 -29
- package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +334 -37
- package/fesm2022/nanahoshi-mona-ui-rating.mjs +84 -30
- package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +274 -108
- package/fesm2022/nanahoshi-mona-ui-segmented.mjs +127 -37
- package/fesm2022/nanahoshi-mona-ui-sheet.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +595 -170
- package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-slider.mjs +323 -166
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +167 -82
- package/fesm2022/nanahoshi-mona-ui-split-button.mjs +3 -3
- package/fesm2022/nanahoshi-mona-ui-splitter.mjs +273 -165
- package/fesm2022/nanahoshi-mona-ui-stepper.mjs +219 -132
- package/fesm2022/nanahoshi-mona-ui-switch.mjs +84 -32
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +337 -116
- package/fesm2022/nanahoshi-mona-ui-text-area.mjs +10 -12
- package/fesm2022/nanahoshi-mona-ui-text-box.mjs +21 -8
- package/fesm2022/nanahoshi-mona-ui-theme.mjs +444 -88
- package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +10 -9
- package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +15 -14
- package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +17 -3
- package/fesm2022/nanahoshi-mona-ui-window.mjs +1 -1
- package/i18n/catalogs/en-US.messages.json +33 -4
- package/locales/ar-sa/ar-sa.messages.json +33 -4
- package/locales/de-de/de-de.messages.json +33 -4
- package/locales/es-es/es-es.messages.json +33 -4
- package/locales/fr-fr/fr-fr.messages.json +33 -4
- package/locales/id-id/id-id.messages.json +33 -4
- package/locales/it-it/it-it.messages.json +33 -4
- package/locales/ja-jp/ja-jp.messages.json +33 -4
- package/locales/ko-kr/ko-kr.messages.json +33 -4
- package/locales/pt-br/pt-br.messages.json +33 -4
- package/locales/ru-ru/ru-ru.messages.json +33 -4
- package/locales/tr-tr/tr-tr.messages.json +33 -4
- package/locales/zh-cn/zh-cn.messages.json +33 -4
- package/locales/zh-tw/zh-tw.messages.json +33 -4
- package/package.json +2 -1
- package/styles.css +156 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +1 -0
- package/types/nanahoshi-mona-ui-avatar.d.ts +18 -11
- package/types/nanahoshi-mona-ui-breadcrumb.d.ts +62 -14
- package/types/nanahoshi-mona-ui-button-group.d.ts +86 -16
- package/types/nanahoshi-mona-ui-button.d.ts +26 -3
- package/types/nanahoshi-mona-ui-calendar.d.ts +1 -0
- package/types/nanahoshi-mona-ui-card.d.ts +22 -6
- package/types/nanahoshi-mona-ui-check-box.d.ts +54 -13
- package/types/nanahoshi-mona-ui-chip.d.ts +31 -18
- package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +21 -5
- package/types/nanahoshi-mona-ui-collapsible.d.ts +20 -11
- package/types/nanahoshi-mona-ui-color-gradient.d.ts +62 -36
- package/types/nanahoshi-mona-ui-color-palette.d.ts +65 -27
- package/types/nanahoshi-mona-ui-color-picker.d.ts +64 -23
- package/types/nanahoshi-mona-ui-combo-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-common.d.ts +28 -2
- package/types/nanahoshi-mona-ui-date-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-datetime-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-dropdown-list.d.ts +1 -0
- package/types/nanahoshi-mona-ui-editor.d.ts +1 -0
- package/types/nanahoshi-mona-ui-expansion-panel.d.ts +51 -7
- package/types/nanahoshi-mona-ui-fieldset.d.ts +18 -4
- package/types/nanahoshi-mona-ui-grid.d.ts +0 -1
- package/types/nanahoshi-mona-ui-i18n.d.ts +38 -3
- package/types/nanahoshi-mona-ui-internal.d.ts +95 -14
- package/types/nanahoshi-mona-ui-label.d.ts +17 -2
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -0
- package/types/nanahoshi-mona-ui-multi-select.d.ts +1 -0
- package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +1 -0
- package/types/nanahoshi-mona-ui-otp-input.d.ts +49 -12
- package/types/nanahoshi-mona-ui-placeholder.d.ts +2 -1
- package/types/nanahoshi-mona-ui-progress-bar.d.ts +21 -9
- package/types/nanahoshi-mona-ui-radio-button.d.ts +165 -20
- package/types/nanahoshi-mona-ui-rating.d.ts +21 -6
- package/types/nanahoshi-mona-ui-scroll-view.d.ts +59 -27
- package/types/nanahoshi-mona-ui-segmented.d.ts +52 -24
- package/types/nanahoshi-mona-ui-sidebar.d.ts +104 -41
- package/types/nanahoshi-mona-ui-skeleton.d.ts +1 -1
- package/types/nanahoshi-mona-ui-slider.d.ts +99 -35
- package/types/nanahoshi-mona-ui-spinner.d.ts +9 -5
- package/types/nanahoshi-mona-ui-splitter.d.ts +31 -10
- package/types/nanahoshi-mona-ui-stepper.d.ts +58 -12
- package/types/nanahoshi-mona-ui-switch.d.ts +32 -10
- package/types/nanahoshi-mona-ui-tabs.d.ts +75 -20
- package/types/nanahoshi-mona-ui-text-area.d.ts +7 -7
- package/types/nanahoshi-mona-ui-text-box.d.ts +2 -0
- package/types/nanahoshi-mona-ui-theme.d.ts +392 -15
- package/types/nanahoshi-mona-ui-time-picker.d.ts +1 -0
- package/types/nanahoshi-mona-ui-time-selector.d.ts +1 -0
- package/types/nanahoshi-mona-ui-tooltip.d.ts +7 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, computed, input, Component, output, ApplicationRef, DOCUMENT, Injector, RendererFactory2, createComponent, Injectable } from '@angular/core';
|
|
2
|
+
import { inject, computed, input, booleanAttribute, Component, ElementRef, output, ApplicationRef, DOCUMENT, Injector, RendererFactory2, isDevMode, createComponent, Injectable } from '@angular/core';
|
|
3
3
|
import { LucideLoader, LucideDynamicIcon } from '@lucide/angular';
|
|
4
4
|
import { classInputToClass } from '@nanahoshi/mona-ui/common';
|
|
5
5
|
import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
|
|
6
6
|
import { twMerge } from 'tailwind-merge';
|
|
7
7
|
import { cva } from 'class-variance-authority';
|
|
8
|
-
import {
|
|
8
|
+
import { LiveAnnouncer } from '@angular/cdk/a11y';
|
|
9
|
+
import { Subject, defer, takeUntil, finalize } from 'rxjs';
|
|
9
10
|
import { v4 } from 'uuid';
|
|
10
11
|
|
|
11
12
|
// Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
|
|
@@ -31,7 +32,8 @@ const spinnerThemeVariants = cva("inline-flex items-center justify-center flex-n
|
|
|
31
32
|
/**
|
|
32
33
|
* @description
|
|
33
34
|
* An indeterminate loading indicator primitive for communicating ongoing activity.
|
|
34
|
-
* Supports multiple appearances
|
|
35
|
+
* Supports multiple appearances and standard sizes. It's a named image, so it's found when a screen reader reaches it,
|
|
36
|
+
* not announced. To announce loading, use `SpinnerService` or a live region that's already on the page.
|
|
35
37
|
*/
|
|
36
38
|
class SpinnerComponent {
|
|
37
39
|
constructor() {
|
|
@@ -62,18 +64,18 @@ class SpinnerComponent {
|
|
|
62
64
|
this.appearance = input("default", /* @ts-ignore */
|
|
63
65
|
...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
|
|
64
66
|
/**
|
|
65
|
-
* @description Accessible
|
|
67
|
+
* @description Accessible name of the spinner when it is not decorative.
|
|
66
68
|
* When not set, falls back to the localized loading text.
|
|
67
69
|
* @default undefined
|
|
68
70
|
*/
|
|
69
71
|
this.ariaLabel = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
|
|
70
72
|
/**
|
|
71
|
-
* @description When `true`, removes the `
|
|
72
|
-
* Useful when a parent element already manages loading semantics (such as
|
|
73
|
+
* @description When `true`, removes the `img` role and hides the spinner from assistive technology with `aria-hidden="true"`.
|
|
74
|
+
* Useful when visible text says the same thing, or a parent element already manages loading semantics (such as
|
|
75
|
+
* `aria-busy="true"` on a button).
|
|
73
76
|
* @default false
|
|
74
77
|
*/
|
|
75
|
-
this.decorative = input(false, /*
|
|
76
|
-
...(ngDevMode ? [{ debugName: "decorative" }] : /* istanbul ignore next */ []));
|
|
78
|
+
this.decorative = input(false, { ...(ngDevMode ? { debugName: "decorative" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
|
|
77
79
|
/**
|
|
78
80
|
* @description Size preset controlling the dimensions of the indicator.
|
|
79
81
|
* @default "medium"
|
|
@@ -89,16 +91,16 @@ class SpinnerComponent {
|
|
|
89
91
|
}
|
|
90
92
|
#i18n;
|
|
91
93
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
92
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SpinnerComponent, isStandalone: true, selector: "mona-spinner", inputs: { appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, decorative: { classPropertyName: "decorative", publicName: "decorative", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-hidden": "decorative() ? 'true' : null", "attr.aria-label": "decorative() ? null : (ariaLabel() || messages().loading)", "attr.role": "decorative() ? null : '
|
|
94
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SpinnerComponent, isStandalone: true, selector: "mona-spinner", inputs: { appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, decorative: { classPropertyName: "decorative", publicName: "decorative", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, userClass: { classPropertyName: "userClass", publicName: "class", isSignal: true, isRequired: false, transformFunction: null } }, host: { properties: { "attr.aria-hidden": "decorative() ? 'true' : null", "attr.aria-label": "decorative() ? null : (ariaLabel() || messages().loading)", "attr.role": "decorative() ? null : 'img'", "class": "baseClass()" } }, ngImport: i0, template: "@switch (appearance()) {\n @case (\"default\") {\n <svg [lucideIcon]=\"loaderIcon\" [size]=\"pixelSize()\" class=\"size-full animate-[spin_1.5s_linear_infinite] motion-reduce:animate-none\"></svg>\n }\n @case (\"pulsing\") {\n <span class=\"mona-spinner-pulsing-container\">\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-2\"></span>\n </span>\n }\n @case (\"pulsing-triad\") {\n <span class=\"mona-spinner-pulsing-triad-container\">\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-3\"></span>\n </span>\n }\n @case (\"pulsing-ring\") {\n <span class=\"mona-spinner-pulsing-ring-container\">\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-3\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-4\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-5\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-6\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-7\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-8\"></span>\n </span>\n }\n @case (\"converging-spinner\") {\n <span class=\"mona-spinner-converge-container\">\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-1\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-2\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-3\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-4\"></span>\n </span>\n }\n}\n", styles: [":host{display:inline-flex;vertical-align:middle}.mona-spinner-pulsing-container{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.mona-spinner-pulsing-segment{position:absolute;inset:0;border-radius:9999px;background-color:currentColor;opacity:.6;animation:mona-spinner-pulse 1.2s cubic-bezier(0,.2,.8,1) infinite}.mona-spinner-pulsing-2{animation-delay:-.6s}@keyframes mona-spinner-pulse{0%{transform:scale(.1);opacity:.9}50%{transform:scale(.6);opacity:.5}to{transform:scale(1);opacity:0}}.mona-spinner-pulsing-triad-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-triad-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.4s ease-in-out infinite}.mona-spinner-pulsing-triad-1{top:0;left:34%;animation-delay:-.933s}.mona-spinner-pulsing-triad-2{bottom:0;left:0;animation-delay:-.467s}.mona-spinner-pulsing-triad-3{bottom:0;right:0;animation-delay:0s}@keyframes mona-spinner-dot-pulse{0%,to{transform:scale(.4);opacity:.4}50%{transform:scale(1);opacity:1}}.mona-spinner-pulsing-ring-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-ring-segment{position:absolute;width:22%;height:22%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.6s ease-in-out infinite}.mona-spinner-pulsing-ring-1{top:5%;left:39%;animation-delay:0s}.mona-spinner-pulsing-ring-2{top:14.96%;left:63.04%;animation-delay:-.2s}.mona-spinner-pulsing-ring-3{top:39%;left:73%;animation-delay:-.4s}.mona-spinner-pulsing-ring-4{top:63.04%;left:63.04%;animation-delay:-.6s}.mona-spinner-pulsing-ring-5{top:73%;left:39%;animation-delay:-.8s}.mona-spinner-pulsing-ring-6{top:63.04%;left:14.96%;animation-delay:-1s}.mona-spinner-pulsing-ring-7{top:39%;left:5%;animation-delay:-1.2s}.mona-spinner-pulsing-ring-8{top:14.96%;left:14.96%;animation-delay:-1.4s}.mona-spinner-converge-container{position:relative;width:100%;height:100%;animation:mona-spinner-rotate 1.5s linear infinite}.mona-spinner-converge-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-converge 1.5s ease-in-out infinite}.mona-spinner-converge-1{top:0;left:0}.mona-spinner-converge-2{top:0;right:0}.mona-spinner-converge-3{bottom:0;right:0}.mona-spinner-converge-4{bottom:0;left:0}@keyframes mona-spinner-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes mona-spinner-converge{0%,to{transform:scale(1)}50%{transform:scale(.4)}}@media(prefers-reduced-motion:reduce){.mona-spinner-pulsing-segment,.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment,.mona-spinner-converge-container,.mona-spinner-converge-segment{animation:none!important}.mona-spinner-pulsing-segment{opacity:.6;transform:scale(.85)}.mona-spinner-pulsing-2{opacity:.3;transform:scale(.5)}.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment{opacity:.7;transform:scale(.8)}}@media(forced-colors:active){[data-segment]{background-color:CanvasText}}\n"], dependencies: [{ kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] }); }
|
|
93
95
|
}
|
|
94
96
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerComponent, decorators: [{
|
|
95
97
|
type: Component,
|
|
96
98
|
args: [{ selector: "mona-spinner", imports: [LucideDynamicIcon], host: {
|
|
97
99
|
"[attr.aria-hidden]": "decorative() ? 'true' : null",
|
|
98
100
|
"[attr.aria-label]": "decorative() ? null : (ariaLabel() || messages().loading)",
|
|
99
|
-
"[attr.role]": "decorative() ? null : '
|
|
101
|
+
"[attr.role]": "decorative() ? null : 'img'",
|
|
100
102
|
"[class]": "baseClass()"
|
|
101
|
-
}, template: "@switch (appearance()) {\n @case (\"default\") {\n <svg [lucideIcon]=\"loaderIcon\" [size]=\"pixelSize()\" class=\"animate-[spin_1.5s_linear_infinite] motion-reduce:animate-none\"></svg>\n }\n @case (\"pulsing\") {\n <span class=\"mona-spinner-pulsing-container\">\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-2\"></span>\n </span>\n }\n @case (\"pulsing-triad\") {\n <span class=\"mona-spinner-pulsing-triad-container\">\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-3\"></span>\n </span>\n }\n @case (\"pulsing-ring\") {\n <span class=\"mona-spinner-pulsing-ring-container\">\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-3\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-4\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-5\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-6\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-7\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-8\"></span>\n </span>\n }\n @case (\"converging-spinner\") {\n <span class=\"mona-spinner-converge-container\">\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-1\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-2\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-3\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-4\"></span>\n </span>\n }\n}\n", styles: [":host{display:inline-flex;vertical-align:middle}.mona-spinner-pulsing-container{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.mona-spinner-pulsing-segment{position:absolute;inset:0;border-radius:9999px;background-color:currentColor;opacity:.6;animation:mona-spinner-pulse 1.2s cubic-bezier(0,.2,.8,1) infinite}.mona-spinner-pulsing-2{animation-delay:-.6s}@keyframes mona-spinner-pulse{0%{transform:scale(.1);opacity:.9}50%{transform:scale(.6);opacity:.5}to{transform:scale(1);opacity:0}}.mona-spinner-pulsing-triad-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-triad-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.4s ease-in-out infinite}.mona-spinner-pulsing-triad-1{top:0;left:34%;animation-delay:-.933s}.mona-spinner-pulsing-triad-2{bottom:0;left:0;animation-delay:-.467s}.mona-spinner-pulsing-triad-3{bottom:0;right:0;animation-delay:0s}@keyframes mona-spinner-dot-pulse{0%,to{transform:scale(.4);opacity:.4}50%{transform:scale(1);opacity:1}}.mona-spinner-pulsing-ring-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-ring-segment{position:absolute;width:22%;height:22%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.6s ease-in-out infinite}.mona-spinner-pulsing-ring-1{top:5%;left:39%;animation-delay:0s}.mona-spinner-pulsing-ring-2{top:14.96%;left:63.04%;animation-delay:-.2s}.mona-spinner-pulsing-ring-3{top:39%;left:73%;animation-delay:-.4s}.mona-spinner-pulsing-ring-4{top:63.04%;left:63.04%;animation-delay:-.6s}.mona-spinner-pulsing-ring-5{top:73%;left:39%;animation-delay:-.8s}.mona-spinner-pulsing-ring-6{top:63.04%;left:14.96%;animation-delay:-1s}.mona-spinner-pulsing-ring-7{top:39%;left:5%;animation-delay:-1.2s}.mona-spinner-pulsing-ring-8{top:14.96%;left:14.96%;animation-delay:-1.4s}.mona-spinner-converge-container{position:relative;width:100%;height:100%;animation:mona-spinner-rotate 1.5s linear infinite}.mona-spinner-converge-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-converge 1.5s ease-in-out infinite}.mona-spinner-converge-1{top:0;left:0}.mona-spinner-converge-2{top:0;right:0}.mona-spinner-converge-3{bottom:0;right:0}.mona-spinner-converge-4{bottom:0;left:0}@keyframes mona-spinner-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes mona-spinner-converge{0%,to{transform:scale(1)}50%{transform:scale(.4)}}@media(prefers-reduced-motion:reduce){.mona-spinner-pulsing-segment,.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment,.mona-spinner-converge-container,.mona-spinner-converge-segment{animation:none!important}.mona-spinner-pulsing-segment{opacity:.6;transform:scale(.85)}.mona-spinner-pulsing-2{opacity:.3;transform:scale(.5)}.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment{opacity:.7;transform:scale(.8)}}\n"] }]
|
|
103
|
+
}, template: "@switch (appearance()) {\n @case (\"default\") {\n <svg [lucideIcon]=\"loaderIcon\" [size]=\"pixelSize()\" class=\"size-full animate-[spin_1.5s_linear_infinite] motion-reduce:animate-none\"></svg>\n }\n @case (\"pulsing\") {\n <span class=\"mona-spinner-pulsing-container\">\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-segment mona-spinner-pulsing-2\"></span>\n </span>\n }\n @case (\"pulsing-triad\") {\n <span class=\"mona-spinner-pulsing-triad-container\">\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-triad-segment mona-spinner-pulsing-triad-3\"></span>\n </span>\n }\n @case (\"pulsing-ring\") {\n <span class=\"mona-spinner-pulsing-ring-container\">\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-1\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-2\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-3\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-4\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-5\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-6\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-7\"></span>\n <span data-segment class=\"mona-spinner-pulsing-ring-segment mona-spinner-pulsing-ring-8\"></span>\n </span>\n }\n @case (\"converging-spinner\") {\n <span class=\"mona-spinner-converge-container\">\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-1\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-2\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-3\"></span>\n <span data-segment class=\"mona-spinner-converge-segment mona-spinner-converge-4\"></span>\n </span>\n }\n}\n", styles: [":host{display:inline-flex;vertical-align:middle}.mona-spinner-pulsing-container{position:relative;width:100%;height:100%;display:flex;align-items:center;justify-content:center}.mona-spinner-pulsing-segment{position:absolute;inset:0;border-radius:9999px;background-color:currentColor;opacity:.6;animation:mona-spinner-pulse 1.2s cubic-bezier(0,.2,.8,1) infinite}.mona-spinner-pulsing-2{animation-delay:-.6s}@keyframes mona-spinner-pulse{0%{transform:scale(.1);opacity:.9}50%{transform:scale(.6);opacity:.5}to{transform:scale(1);opacity:0}}.mona-spinner-pulsing-triad-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-triad-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.4s ease-in-out infinite}.mona-spinner-pulsing-triad-1{top:0;left:34%;animation-delay:-.933s}.mona-spinner-pulsing-triad-2{bottom:0;left:0;animation-delay:-.467s}.mona-spinner-pulsing-triad-3{bottom:0;right:0;animation-delay:0s}@keyframes mona-spinner-dot-pulse{0%,to{transform:scale(.4);opacity:.4}50%{transform:scale(1);opacity:1}}.mona-spinner-pulsing-ring-container{position:relative;width:100%;height:100%}.mona-spinner-pulsing-ring-segment{position:absolute;width:22%;height:22%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-dot-pulse 1.6s ease-in-out infinite}.mona-spinner-pulsing-ring-1{top:5%;left:39%;animation-delay:0s}.mona-spinner-pulsing-ring-2{top:14.96%;left:63.04%;animation-delay:-.2s}.mona-spinner-pulsing-ring-3{top:39%;left:73%;animation-delay:-.4s}.mona-spinner-pulsing-ring-4{top:63.04%;left:63.04%;animation-delay:-.6s}.mona-spinner-pulsing-ring-5{top:73%;left:39%;animation-delay:-.8s}.mona-spinner-pulsing-ring-6{top:63.04%;left:14.96%;animation-delay:-1s}.mona-spinner-pulsing-ring-7{top:39%;left:5%;animation-delay:-1.2s}.mona-spinner-pulsing-ring-8{top:14.96%;left:14.96%;animation-delay:-1.4s}.mona-spinner-converge-container{position:relative;width:100%;height:100%;animation:mona-spinner-rotate 1.5s linear infinite}.mona-spinner-converge-segment{position:absolute;width:32%;height:32%;border-radius:9999px;background-color:currentColor;animation:mona-spinner-converge 1.5s ease-in-out infinite}.mona-spinner-converge-1{top:0;left:0}.mona-spinner-converge-2{top:0;right:0}.mona-spinner-converge-3{bottom:0;right:0}.mona-spinner-converge-4{bottom:0;left:0}@keyframes mona-spinner-rotate{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes mona-spinner-converge{0%,to{transform:scale(1)}50%{transform:scale(.4)}}@media(prefers-reduced-motion:reduce){.mona-spinner-pulsing-segment,.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment,.mona-spinner-converge-container,.mona-spinner-converge-segment{animation:none!important}.mona-spinner-pulsing-segment{opacity:.6;transform:scale(.85)}.mona-spinner-pulsing-2{opacity:.3;transform:scale(.5)}.mona-spinner-pulsing-triad-segment,.mona-spinner-pulsing-ring-segment{opacity:.7;transform:scale(.8)}}@media(forced-colors:active){[data-segment]{background-color:CanvasText}}\n"] }]
|
|
102
104
|
}], propDecorators: { appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], decorative: [{ type: i0.Input, args: [{ isSignal: true, alias: "decorative", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], userClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "class", required: false }] }] } });
|
|
103
105
|
|
|
104
106
|
const spinnerOverlayThemeVariants = cva(`
|
|
@@ -109,8 +111,8 @@ const spinnerOverlayThemeVariants = cva(`
|
|
|
109
111
|
`, {
|
|
110
112
|
variants: {
|
|
111
113
|
fullPage: {
|
|
112
|
-
true: "fixed inset-0
|
|
113
|
-
false: "absolute inset-0
|
|
114
|
+
true: "fixed inset-0",
|
|
115
|
+
false: "absolute inset-0"
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
118
|
defaultVariants: {
|
|
@@ -118,6 +120,8 @@ const spinnerOverlayThemeVariants = cva(`
|
|
|
118
120
|
}
|
|
119
121
|
});
|
|
120
122
|
|
|
123
|
+
/** Sits above `.cdk-overlay-container`, so a spinner started from a dialog isn't under that dialog. */
|
|
124
|
+
const FULL_PAGE_Z_INDEX = 1001;
|
|
121
125
|
/**
|
|
122
126
|
* @description
|
|
123
127
|
* Internal overlay component managed exclusively by `SpinnerService`.
|
|
@@ -125,7 +129,9 @@ const spinnerOverlayThemeVariants = cva(`
|
|
|
125
129
|
*/
|
|
126
130
|
class SpinnerOverlayComponent {
|
|
127
131
|
constructor() {
|
|
132
|
+
this.#hostElementRef = inject(ElementRef);
|
|
128
133
|
this.#i18n = inject(MonaI18nService);
|
|
134
|
+
this.#focusOrigin = null;
|
|
129
135
|
this.baseClass = computed(() => {
|
|
130
136
|
return spinnerOverlayThemeVariants({ fullPage: this.fullPage() });
|
|
131
137
|
}, /* @ts-ignore */
|
|
@@ -139,7 +145,7 @@ class SpinnerOverlayComponent {
|
|
|
139
145
|
if (customZIndex !== undefined) {
|
|
140
146
|
return customZIndex;
|
|
141
147
|
}
|
|
142
|
-
return this.fullPage() ?
|
|
148
|
+
return this.fullPage() ? FULL_PAGE_Z_INDEX : 1;
|
|
143
149
|
}, /* @ts-ignore */
|
|
144
150
|
...(ngDevMode ? [{ debugName: "effectiveZIndex" }] : /* istanbul ignore next */ []));
|
|
145
151
|
this.messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
|
|
@@ -192,25 +198,49 @@ class SpinnerOverlayComponent {
|
|
|
192
198
|
this.zIndex = input(undefined, /* @ts-ignore */
|
|
193
199
|
...(ngDevMode ? [{ debugName: "zIndex" }] : /* istanbul ignore next */ []));
|
|
194
200
|
}
|
|
201
|
+
#hostElementRef;
|
|
195
202
|
#i18n;
|
|
203
|
+
#focusOrigin;
|
|
204
|
+
/**
|
|
205
|
+
* Gives focus back to where it came from, if it's inside the overlay. Call before the overlay's controls go, or
|
|
206
|
+
* focus falls to the body.
|
|
207
|
+
*/
|
|
208
|
+
returnFocus() {
|
|
209
|
+
const host = this.#hostElementRef.nativeElement;
|
|
210
|
+
if (host.contains(host.ownerDocument.activeElement)) {
|
|
211
|
+
this.#focusOrigin?.focus({ preventScroll: true });
|
|
212
|
+
}
|
|
213
|
+
}
|
|
196
214
|
onCancel() {
|
|
197
215
|
this.cancel.emit();
|
|
198
216
|
}
|
|
217
|
+
onFocusIn(event) {
|
|
218
|
+
const origin = event.relatedTarget;
|
|
219
|
+
if (origin && !this.#hostElementRef.nativeElement.contains(origin)) {
|
|
220
|
+
this.#focusOrigin = origin;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
199
223
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerOverlayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
200
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SpinnerOverlayComponent, isStandalone: true, selector: "mona-spinner-overlay", inputs: { appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, cancelText: { classPropertyName: "cancelText", publicName: "cancelText", isSignal: true, isRequired: false, transformFunction: null }, cancellable: { classPropertyName: "cancellable", publicName: "cancellable", isSignal: true, isRequired: false, transformFunction: null }, fullPage: { classPropertyName: "fullPage", publicName: "fullPage", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cancel: "cancel" }, host: { properties: { "class": "baseClass()", "style.z-index": "effectiveZIndex()" } }, ngImport: i0, template: "<div class=\"flex flex-col items-center justify-center gap-2.5 p-4 text-sm font-medium text-foreground text-center\"
|
|
224
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: SpinnerOverlayComponent, isStandalone: true, selector: "mona-spinner-overlay", inputs: { appearance: { classPropertyName: "appearance", publicName: "appearance", isSignal: true, isRequired: false, transformFunction: null }, cancelText: { classPropertyName: "cancelText", publicName: "cancelText", isSignal: true, isRequired: false, transformFunction: null }, cancellable: { classPropertyName: "cancellable", publicName: "cancellable", isSignal: true, isRequired: false, transformFunction: null }, fullPage: { classPropertyName: "fullPage", publicName: "fullPage", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, zIndex: { classPropertyName: "zIndex", publicName: "zIndex", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { cancel: "cancel" }, host: { listeners: { "focusin": "onFocusIn($event)" }, properties: { "class": "baseClass()", "style.z-index": "effectiveZIndex()" } }, ngImport: i0, template: "<div class=\"flex flex-col items-center justify-center gap-2.5 p-4 text-sm font-medium text-foreground text-center\">\n <mona-spinner [appearance]=\"appearance()\" [size]=\"size()\" [decorative]=\"true\"></mona-spinner>\n\n @if (text()) {\n <span class=\"max-w-xs wrap-anywhere\">{{ text() }}</span>\n } @else {\n <span class=\"sr-only\">{{ messages().loading }}</span>\n }\n\n @if (cancellable()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n class=\"mt-1 inline-flex items-center justify-center rounded-md border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator cursor-pointer transition-colors\"\n >\n {{ effectiveCancelText() }}\n </button>\n }\n</div>\n", dependencies: [{ kind: "component", type: SpinnerComponent, selector: "mona-spinner", inputs: ["appearance", "aria-label", "decorative", "size", "class"] }] }); }
|
|
201
225
|
}
|
|
202
226
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerOverlayComponent, decorators: [{
|
|
203
227
|
type: Component,
|
|
204
228
|
args: [{ selector: "mona-spinner-overlay", imports: [SpinnerComponent], host: {
|
|
205
229
|
"[class]": "baseClass()",
|
|
206
|
-
"[style.z-index]": "effectiveZIndex()"
|
|
207
|
-
|
|
230
|
+
"[style.z-index]": "effectiveZIndex()",
|
|
231
|
+
"(focusin)": "onFocusIn($event)"
|
|
232
|
+
}, template: "<div class=\"flex flex-col items-center justify-center gap-2.5 p-4 text-sm font-medium text-foreground text-center\">\n <mona-spinner [appearance]=\"appearance()\" [size]=\"size()\" [decorative]=\"true\"></mona-spinner>\n\n @if (text()) {\n <span class=\"max-w-xs wrap-anywhere\">{{ text() }}</span>\n } @else {\n <span class=\"sr-only\">{{ messages().loading }}</span>\n }\n\n @if (cancellable()) {\n <button\n type=\"button\"\n (click)=\"onCancel()\"\n class=\"mt-1 inline-flex items-center justify-center rounded-md border border-border bg-background px-2.5 py-1 text-xs font-medium text-foreground shadow-xs hover:bg-accent hover:text-accent-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator cursor-pointer transition-colors\"\n >\n {{ effectiveCancelText() }}\n </button>\n }\n</div>\n" }]
|
|
208
233
|
}], propDecorators: { appearance: [{ type: i0.Input, args: [{ isSignal: true, alias: "appearance", required: false }] }], cancel: [{ type: i0.Output, args: ["cancel"] }], cancelText: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancelText", required: false }] }], cancellable: [{ type: i0.Input, args: [{ isSignal: true, alias: "cancellable", required: false }] }], fullPage: [{ type: i0.Input, args: [{ isSignal: true, alias: "fullPage", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], zIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "zIndex", required: false }] }] } });
|
|
209
234
|
|
|
235
|
+
/** The most often a request's changing text is read out, so a progress loop doesn't queue up behind itself. */
|
|
236
|
+
const ANNOUNCE_INTERVAL = 5000;
|
|
210
237
|
class SpinnerService {
|
|
211
238
|
#appRef = inject(ApplicationRef);
|
|
212
239
|
#document = inject(DOCUMENT);
|
|
240
|
+
#i18n = inject(MonaI18nService);
|
|
213
241
|
#injector = inject(Injector);
|
|
242
|
+
#liveAnnouncer = inject(LiveAnnouncer);
|
|
243
|
+
#messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
|
|
214
244
|
#renderer = inject(RendererFactory2).createRenderer(null, null);
|
|
215
245
|
#requests = new Map();
|
|
216
246
|
#targetStates = new Set();
|
|
@@ -228,29 +258,15 @@ class SpinnerService {
|
|
|
228
258
|
*/
|
|
229
259
|
ngOnDestroy() {
|
|
230
260
|
for (const request of this.#requests.values()) {
|
|
231
|
-
|
|
232
|
-
clearTimeout(request.delayTimer);
|
|
233
|
-
request.delayTimer = null;
|
|
234
|
-
}
|
|
261
|
+
this.#clearRequestTimers(request);
|
|
235
262
|
if (!request.cancellationHandled) {
|
|
236
263
|
request.cancelledSubject.complete();
|
|
237
264
|
}
|
|
238
265
|
}
|
|
239
266
|
this.#requests.clear();
|
|
240
|
-
for (const targetState of this.#targetStates) {
|
|
241
|
-
|
|
242
|
-
clearTimeout(targetState.minDurationTimer);
|
|
243
|
-
targetState.minDurationTimer = null;
|
|
244
|
-
}
|
|
245
|
-
targetState.cancelSubscription?.unsubscribe();
|
|
246
|
-
targetState.cancelSubscription = null;
|
|
247
|
-
if (targetState.componentRef != null) {
|
|
248
|
-
this.#appRef.detachView(targetState.componentRef.hostView);
|
|
249
|
-
targetState.componentRef.destroy();
|
|
250
|
-
targetState.componentRef = null;
|
|
251
|
-
}
|
|
267
|
+
for (const targetState of [...this.#targetStates]) {
|
|
268
|
+
this.#teardownTarget(targetState);
|
|
252
269
|
}
|
|
253
|
-
this.#targetStates.clear();
|
|
254
270
|
}
|
|
255
271
|
/**
|
|
256
272
|
* Displays a spinner loading overlay according to the provided options.
|
|
@@ -262,23 +278,25 @@ class SpinnerService {
|
|
|
262
278
|
if (this.#requests.has(id)) {
|
|
263
279
|
this.#closeRequest(id);
|
|
264
280
|
}
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
const resolvedTargets =
|
|
281
|
+
// Only leaving the key out means the whole page. A target that hasn't resolved yet, such as a viewChild before
|
|
282
|
+
// its first render, must not cover the page instead of the panel it was meant for.
|
|
283
|
+
const resolvedTargets = options && "target" in options ? this.#normalizeTargets(options.target) : [this.#document.body];
|
|
268
284
|
const cancellableOpt = options?.cancellable;
|
|
269
285
|
const isCancellable = !!cancellableOpt;
|
|
270
|
-
const cancelText = typeof cancellableOpt === "object" && cancellableOpt.text ? cancellableOpt.text :
|
|
286
|
+
const cancelText = typeof cancellableOpt === "object" && cancellableOpt.text ? cancellableOpt.text : undefined;
|
|
271
287
|
const onCancel = typeof cancellableOpt === "object" ? cancellableOpt.onCancel : undefined;
|
|
272
288
|
const cancelledSubject = new Subject();
|
|
273
289
|
const request = {
|
|
274
290
|
activatedAt: Date.now(),
|
|
291
|
+
announceTimer: null,
|
|
292
|
+
announcedAt: null,
|
|
293
|
+
announcedText: null,
|
|
275
294
|
appearance: options?.appearance ?? "default",
|
|
276
295
|
cancellationHandled: false,
|
|
277
296
|
cancellable: isCancellable,
|
|
278
297
|
cancelText,
|
|
279
298
|
delayTimer: null,
|
|
280
299
|
id,
|
|
281
|
-
isFullPage,
|
|
282
300
|
onCancel,
|
|
283
301
|
options: options ?? {},
|
|
284
302
|
registeredAt: Date.now(),
|
|
@@ -294,7 +312,7 @@ class SpinnerService {
|
|
|
294
312
|
const immediateTargets = [];
|
|
295
313
|
const delayedTargets = [];
|
|
296
314
|
for (const target of resolvedTargets) {
|
|
297
|
-
const targetState = this.#getOrCreateTargetState(target
|
|
315
|
+
const targetState = this.#getOrCreateTargetState(target);
|
|
298
316
|
targetState.pendingRequestIds.add(id);
|
|
299
317
|
if (targetState.componentRef != null) {
|
|
300
318
|
immediateTargets.push(target);
|
|
@@ -330,11 +348,13 @@ class SpinnerService {
|
|
|
330
348
|
/**
|
|
331
349
|
* Wraps an Observable operation with a Spinner lifecycle.
|
|
332
350
|
* Shows the spinner on subscription and closes it when the observable completes, errors, or is unsubscribed.
|
|
351
|
+
* Cancelling a `cancellable` spinner completes the returned observable and unsubscribes from the source, which also
|
|
352
|
+
* aborts an HTTP request.
|
|
333
353
|
*/
|
|
334
354
|
track(source, options) {
|
|
335
355
|
return defer(() => {
|
|
336
356
|
const ref = this.show(options);
|
|
337
|
-
return source.pipe(finalize(() => ref.close()));
|
|
357
|
+
return source.pipe(takeUntil(ref.cancelled$), finalize(() => ref.close()));
|
|
338
358
|
});
|
|
339
359
|
}
|
|
340
360
|
#activateRequestOnTargets(request, targets) {
|
|
@@ -344,10 +364,37 @@ class SpinnerService {
|
|
|
344
364
|
request.status = "VISIBLE";
|
|
345
365
|
request.activatedAt = Date.now();
|
|
346
366
|
for (const target of targets) {
|
|
347
|
-
const targetState = this.#getOrCreateTargetState(target
|
|
367
|
+
const targetState = this.#getOrCreateTargetState(target);
|
|
348
368
|
targetState.activeRequestIds.add(request.id);
|
|
369
|
+
targetState.minimumVisibleDuration = Math.max(targetState.minimumVisibleDuration, request.options.minimumVisibleDuration ?? 0);
|
|
349
370
|
this.#updateTargetOverlay(targetState);
|
|
350
371
|
}
|
|
372
|
+
if (request.announcedAt === null) {
|
|
373
|
+
this.#announce(request);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
#announce(request) {
|
|
377
|
+
const text = request.text || this.#messages().loading;
|
|
378
|
+
if (text !== request.announcedText) {
|
|
379
|
+
request.announcedAt = Date.now();
|
|
380
|
+
request.announcedText = text;
|
|
381
|
+
void this.#liveAnnouncer.announce(text, "polite");
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
#announceUpdate(request) {
|
|
385
|
+
if (request.announcedAt === null || request.announceTimer != null) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
const wait = request.announcedAt + ANNOUNCE_INTERVAL - Date.now();
|
|
389
|
+
if (wait <= 0) {
|
|
390
|
+
this.#announce(request);
|
|
391
|
+
}
|
|
392
|
+
else {
|
|
393
|
+
request.announceTimer = setTimeout(() => {
|
|
394
|
+
request.announceTimer = null;
|
|
395
|
+
this.#announce(request);
|
|
396
|
+
}, wait);
|
|
397
|
+
}
|
|
351
398
|
}
|
|
352
399
|
#cancelRequest(requestId) {
|
|
353
400
|
const request = this.#requests.get(requestId);
|
|
@@ -366,16 +413,23 @@ class SpinnerService {
|
|
|
366
413
|
this.#closeRequest(requestId);
|
|
367
414
|
}
|
|
368
415
|
}
|
|
416
|
+
#clearRequestTimers(request) {
|
|
417
|
+
if (request.delayTimer != null) {
|
|
418
|
+
clearTimeout(request.delayTimer);
|
|
419
|
+
request.delayTimer = null;
|
|
420
|
+
}
|
|
421
|
+
if (request.announceTimer != null) {
|
|
422
|
+
clearTimeout(request.announceTimer);
|
|
423
|
+
request.announceTimer = null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
369
426
|
#closeRequest(requestId) {
|
|
370
427
|
const request = this.#requests.get(requestId);
|
|
371
428
|
if (!request || request.status === "CLOSED") {
|
|
372
429
|
return;
|
|
373
430
|
}
|
|
374
431
|
request.status = "CLOSED";
|
|
375
|
-
|
|
376
|
-
clearTimeout(request.delayTimer);
|
|
377
|
-
request.delayTimer = null;
|
|
378
|
-
}
|
|
432
|
+
this.#clearRequestTimers(request);
|
|
379
433
|
if (!request.cancellationHandled) {
|
|
380
434
|
request.cancelledSubject.complete();
|
|
381
435
|
}
|
|
@@ -393,7 +447,7 @@ class SpinnerService {
|
|
|
393
447
|
}
|
|
394
448
|
else if (targetState.pendingRequestIds.size === 0) {
|
|
395
449
|
// No active or pending requests remain on this target
|
|
396
|
-
const minDuration =
|
|
450
|
+
const minDuration = targetState.minimumVisibleDuration;
|
|
397
451
|
if (minDuration > 0 && targetState.visibleSince != null && targetState.componentRef != null) {
|
|
398
452
|
const elapsed = Date.now() - targetState.visibleSince;
|
|
399
453
|
const remaining = minDuration - elapsed;
|
|
@@ -401,6 +455,10 @@ class SpinnerService {
|
|
|
401
455
|
if (targetState.minDurationTimer != null) {
|
|
402
456
|
clearTimeout(targetState.minDurationTimer);
|
|
403
457
|
}
|
|
458
|
+
// Nothing is left to cancel while the overlay is only being held.
|
|
459
|
+
targetState.componentRef.instance.returnFocus();
|
|
460
|
+
targetState.componentRef.setInput("cancellable", false);
|
|
461
|
+
targetState.componentRef.changeDetectorRef.detectChanges();
|
|
404
462
|
targetState.minDurationTimer = setTimeout(() => {
|
|
405
463
|
targetState.minDurationTimer = null;
|
|
406
464
|
if (targetState.activeRequestIds.size === 0 && targetState.pendingRequestIds.size === 0) {
|
|
@@ -416,9 +474,20 @@ class SpinnerService {
|
|
|
416
474
|
this.#teardownTarget(targetState);
|
|
417
475
|
}
|
|
418
476
|
}
|
|
477
|
+
else if (targetState.componentRef != null) {
|
|
478
|
+
// Only requests still in their delay remain. A new request on a visible overlay shows at once, and
|
|
479
|
+
// these get the same, rather than leaving the closed request's text and a dead Cancel on screen.
|
|
480
|
+
for (const pendingId of targetState.pendingRequestIds) {
|
|
481
|
+
const pending = this.#requests.get(pendingId);
|
|
482
|
+
if (pending) {
|
|
483
|
+
this.#activateRequestOnTargets(pending, [target]);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
419
487
|
}
|
|
420
488
|
}
|
|
421
|
-
#getOrCreateTargetState(target
|
|
489
|
+
#getOrCreateTargetState(target) {
|
|
490
|
+
const isFullPage = target === this.#document.body;
|
|
422
491
|
let state = this.#targets.get(target);
|
|
423
492
|
if (!state) {
|
|
424
493
|
const originalAriaBusy = target.getAttribute("aria-busy");
|
|
@@ -430,6 +499,7 @@ class SpinnerService {
|
|
|
430
499
|
componentRef: null,
|
|
431
500
|
isFullPage,
|
|
432
501
|
minDurationTimer: null,
|
|
502
|
+
minimumVisibleDuration: 0,
|
|
433
503
|
originalAriaBusy,
|
|
434
504
|
originalInlinePosition,
|
|
435
505
|
pendingRequestIds: new Set(),
|
|
@@ -438,8 +508,11 @@ class SpinnerService {
|
|
|
438
508
|
this.#targets.set(target, state);
|
|
439
509
|
this.#targetStates.add(state);
|
|
440
510
|
}
|
|
441
|
-
// Apply aria-busy immediately while logically busy
|
|
442
|
-
|
|
511
|
+
// Apply aria-busy immediately while logically busy. Not on the body: it would mark the whole page, this
|
|
512
|
+
// overlay's own text and Cancel button included, as something assistive technology can skip until it clears.
|
|
513
|
+
if (!isFullPage) {
|
|
514
|
+
this.#renderer.setAttribute(target, "aria-busy", "true");
|
|
515
|
+
}
|
|
443
516
|
// If a delayed teardown was pending, cancel it since new activity arrived
|
|
444
517
|
if (state.minDurationTimer != null) {
|
|
445
518
|
clearTimeout(state.minDurationTimer);
|
|
@@ -460,19 +533,18 @@ class SpinnerService {
|
|
|
460
533
|
return winningRequest;
|
|
461
534
|
}
|
|
462
535
|
#normalizeTargets(target) {
|
|
463
|
-
if (!target) {
|
|
464
|
-
return [];
|
|
465
|
-
}
|
|
466
536
|
const rawList = Array.isArray(target) ? target : [target];
|
|
467
537
|
const result = [];
|
|
468
538
|
for (const item of rawList) {
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
else if (item && typeof item === "object" && "nativeElement" in item && item.nativeElement instanceof HTMLElement) {
|
|
473
|
-
result.push(item.nativeElement);
|
|
539
|
+
const element = this.#toElement(item);
|
|
540
|
+
if (element) {
|
|
541
|
+
result.push(element);
|
|
474
542
|
}
|
|
475
543
|
}
|
|
544
|
+
if (isDevMode() && (result.length === 0 || result.length !== rawList.length)) {
|
|
545
|
+
console.error("SpinnerService: a target didn't resolve to an element, so no overlay shows on it. " +
|
|
546
|
+
"Leave target out for a full-page spinner.");
|
|
547
|
+
}
|
|
476
548
|
return result;
|
|
477
549
|
}
|
|
478
550
|
#teardownTarget(targetState) {
|
|
@@ -483,17 +555,22 @@ class SpinnerService {
|
|
|
483
555
|
targetState.cancelSubscription?.unsubscribe();
|
|
484
556
|
targetState.cancelSubscription = null;
|
|
485
557
|
if (targetState.componentRef != null) {
|
|
558
|
+
targetState.componentRef.instance.returnFocus();
|
|
486
559
|
this.#appRef.detachView(targetState.componentRef.hostView);
|
|
487
560
|
targetState.componentRef.destroy();
|
|
488
561
|
targetState.componentRef = null;
|
|
489
562
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
563
|
+
// Forget the target, so it isn't kept alive and the next request reads its attributes afresh.
|
|
564
|
+
this.#targets.delete(targetState.target);
|
|
565
|
+
this.#targetStates.delete(targetState);
|
|
566
|
+
if (!targetState.isFullPage) {
|
|
567
|
+
// Restore aria-busy attribute exactly
|
|
568
|
+
if (targetState.originalAriaBusy === null) {
|
|
569
|
+
this.#renderer.removeAttribute(targetState.target, "aria-busy");
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
this.#renderer.setAttribute(targetState.target, "aria-busy", targetState.originalAriaBusy);
|
|
573
|
+
}
|
|
497
574
|
}
|
|
498
575
|
// Restore target positioning safely
|
|
499
576
|
if (targetState.changedPosition) {
|
|
@@ -503,6 +580,14 @@ class SpinnerService {
|
|
|
503
580
|
targetState.changedPosition = false;
|
|
504
581
|
}
|
|
505
582
|
}
|
|
583
|
+
#toElement(item) {
|
|
584
|
+
const isElement = (value) => value?.nodeType === 1;
|
|
585
|
+
if (isElement(item)) {
|
|
586
|
+
return item;
|
|
587
|
+
}
|
|
588
|
+
const nativeElement = item?.nativeElement;
|
|
589
|
+
return isElement(nativeElement) ? nativeElement : null;
|
|
590
|
+
}
|
|
506
591
|
#updateRequest(requestId, update) {
|
|
507
592
|
const request = this.#requests.get(requestId);
|
|
508
593
|
if (!request || request.status === "CLOSED") {
|
|
@@ -523,6 +608,18 @@ class SpinnerService {
|
|
|
523
608
|
this.#updateTargetOverlay(targetState);
|
|
524
609
|
}
|
|
525
610
|
}
|
|
611
|
+
if (update.text !== undefined) {
|
|
612
|
+
this.#announceUpdate(request);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
#updateOverlayInputs(componentRef, winner, targetState) {
|
|
616
|
+
componentRef.setInput("appearance", winner.appearance);
|
|
617
|
+
componentRef.setInput("size", winner.size);
|
|
618
|
+
componentRef.setInput("text", winner.text);
|
|
619
|
+
componentRef.setInput("cancellable", winner.cancellable);
|
|
620
|
+
componentRef.setInput("cancelText", winner.cancelText);
|
|
621
|
+
componentRef.setInput("fullPage", targetState.isFullPage);
|
|
622
|
+
componentRef.setInput("zIndex", winner.options.zIndex);
|
|
526
623
|
}
|
|
527
624
|
#updateTargetOverlay(targetState) {
|
|
528
625
|
const winner = this.#getWinningRequestForTarget(targetState);
|
|
@@ -543,15 +640,7 @@ class SpinnerService {
|
|
|
543
640
|
environmentInjector: this.#appRef.injector,
|
|
544
641
|
elementInjector: this.#injector
|
|
545
642
|
});
|
|
546
|
-
compRef
|
|
547
|
-
compRef.setInput("size", winner.size);
|
|
548
|
-
compRef.setInput("text", winner.text);
|
|
549
|
-
compRef.setInput("cancellable", winner.cancellable);
|
|
550
|
-
compRef.setInput("cancelText", winner.cancelText);
|
|
551
|
-
compRef.setInput("fullPage", targetState.isFullPage);
|
|
552
|
-
if (winner.options.zIndex !== undefined) {
|
|
553
|
-
compRef.setInput("zIndex", winner.options.zIndex);
|
|
554
|
-
}
|
|
643
|
+
this.#updateOverlayInputs(compRef, winner, targetState);
|
|
555
644
|
targetState.cancelSubscription = compRef.instance.cancel.subscribe(() => {
|
|
556
645
|
const currentWinner = this.#getWinningRequestForTarget(targetState);
|
|
557
646
|
if (currentWinner) {
|
|
@@ -567,15 +656,11 @@ class SpinnerService {
|
|
|
567
656
|
else {
|
|
568
657
|
// Physical overlay already exists: update its inputs dynamically
|
|
569
658
|
const compRef = targetState.componentRef;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
compRef.setInput("cancellable", winner.cancellable);
|
|
574
|
-
compRef.setInput("cancelText", winner.cancelText);
|
|
575
|
-
compRef.setInput("fullPage", targetState.isFullPage);
|
|
576
|
-
if (winner.options.zIndex !== undefined) {
|
|
577
|
-
compRef.setInput("zIndex", winner.options.zIndex);
|
|
659
|
+
if (!winner.cancellable) {
|
|
660
|
+
// The Cancel button goes away with this update, and focus mustn't go with it.
|
|
661
|
+
compRef.instance.returnFocus();
|
|
578
662
|
}
|
|
663
|
+
this.#updateOverlayInputs(compRef, winner, targetState);
|
|
579
664
|
compRef.changeDetectorRef.detectChanges();
|
|
580
665
|
}
|
|
581
666
|
}
|