@nanahoshi/mona-ui 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/popup.md +1 -1
  3. package/docs/api/theme.md +2 -2
  4. package/docs/chart.md +14 -0
  5. package/docs/editor.md +2 -0
  6. package/docs/installation.md +147 -15
  7. package/docs/introduction.md +37 -15
  8. package/docs/theming-built-in-themes.md +67 -0
  9. package/docs/theming-custom-colors.md +274 -0
  10. package/docs/theming-custom-themes.md +168 -0
  11. package/docs/theming.md +164 -248
  12. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  13. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  14. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  15. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  16. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  17. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  18. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  19. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  20. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  21. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  22. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  23. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  24. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  25. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  26. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  27. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  28. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  29. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  30. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  31. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  32. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  33. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  34. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  35. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  37. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  38. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  39. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  40. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  41. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  42. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  49. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  50. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  51. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  52. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  53. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  54. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  55. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  56. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  57. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  58. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  59. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  60. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  61. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  62. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  63. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  65. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  66. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  67. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  68. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  70. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  71. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  72. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  73. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  74. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  75. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  76. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  77. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  78. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  79. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  80. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  81. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  82. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  83. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  84. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  85. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  86. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  87. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  88. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  89. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  90. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  91. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  92. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  93. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  94. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  95. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  96. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  97. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  98. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  99. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  100. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  101. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  102. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  103. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  104. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  105. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  106. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  107. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  108. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  109. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  110. package/llms.txt +6 -2
  111. package/package.json +62 -23
  112. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  113. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  114. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  115. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  116. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  117. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  118. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  119. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  120. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  121. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  122. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  123. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  124. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  125. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  126. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  127. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  128. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  129. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  130. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  131. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  132. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  133. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  134. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  135. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  136. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  137. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  138. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  139. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  140. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  141. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  142. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  143. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  144. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  145. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  146. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  147. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  148. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  149. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  150. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  151. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  152. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  153. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  154. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  155. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  156. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  157. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  158. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  159. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  168. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  169. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  170. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  171. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  172. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  173. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  174. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  175. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  176. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  177. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  178. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  179. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  180. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  181. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  182. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  183. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  184. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  185. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  186. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  187. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  188. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  189. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  190. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  191. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  192. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  193. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  194. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  195. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  196. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  197. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  198. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  199. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  200. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  201. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  202. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  203. package/types/nanahoshi-mona-ui.d.ts +1 -2
  204. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  205. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  206. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  207. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  208. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,686 +1,751 @@
1
- import * as i0 from '@angular/core';
2
- import { inject, computed, input, booleanAttribute, Component, ElementRef, output, ApplicationRef, DOCUMENT, Injector, RendererFactory2, isDevMode, createComponent, Injectable } from '@angular/core';
3
- import { LucideLoader, LucideDynamicIcon } from '@lucide/angular';
4
- import { classInputToClass } from '@nanahoshi/mona-ui/common';
5
- import { MonaI18nService } from '@nanahoshi/mona-ui/i18n';
6
- import { twMerge } from 'tailwind-merge';
7
- import { cva } from 'class-variance-authority';
8
- import { LiveAnnouncer } from '@angular/cdk/a11y';
9
- import { Subject, defer, takeUntil, finalize } from 'rxjs';
10
- import { v4 } from 'uuid';
11
-
12
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
13
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import * as i0 from "@angular/core";
2
+ import { ApplicationRef, Component, DOCUMENT, ElementRef, Injectable, Injector, RendererFactory2, booleanAttribute, computed, createComponent, inject, input, isDevMode, output } from "@angular/core";
3
+ import { LucideDynamicIcon, LucideLoader } from "@lucide/angular";
4
+ import { classInputToClass } from "@nanahoshi/mona-ui/common";
5
+ import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
6
+ import { twMerge } from "tailwind-merge";
7
+ import { cva } from "class-variance-authority";
8
+ import { LiveAnnouncer } from "@angular/cdk/a11y";
9
+ import { Subject, defer, finalize, takeUntil } from "rxjs";
10
+ import { v4 } from "uuid";
14
11
  const SPINNER_DEFAULT_MESSAGES = {
15
- cancel: "Cancel",
16
- loading: "Loading"
12
+ cancel: "Cancel",
13
+ loading: "Loading"
17
14
  };
18
-
19
15
  const spinnerThemeVariants = cva("inline-flex items-center justify-center flex-none aspect-square relative text-current select-none", {
20
- variants: {
21
- size: {
22
- small: "w-3 h-3",
23
- medium: "w-4 h-4",
24
- large: "w-6 h-6"
25
- }
26
- },
27
- defaultVariants: {
28
- size: "medium"
29
- }
16
+ variants: { size: {
17
+ small: "w-3 h-3",
18
+ medium: "w-4 h-4",
19
+ large: "w-6 h-6"
20
+ } },
21
+ defaultVariants: { size: "medium" }
22
+ });
23
+ var SpinnerComponent = class SpinnerComponent {
24
+ constructor() {
25
+ this.#i18n = inject(MonaI18nService);
26
+ this.baseClass = computed(() => {
27
+ const variantClass = spinnerThemeVariants({ size: this.size() });
28
+ return twMerge(variantClass, this.userClass());
29
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
30
+ this.loaderIcon = LucideLoader;
31
+ this.messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
32
+ this.pixelSize = computed(() => {
33
+ switch (this.size()) {
34
+ case "small": return 12;
35
+ case "large": return 24;
36
+ default: return 16;
37
+ }
38
+ }, ...ngDevMode ? [{ debugName: "pixelSize" }] : /* istanbul ignore next */ []);
39
+ this.appearance = input("default", ...ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []);
40
+ this.ariaLabel = input(void 0, {
41
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
42
+ alias: "aria-label"
43
+ });
44
+ this.decorative = input(false, {
45
+ ...ngDevMode ? { debugName: "decorative" } : /* istanbul ignore next */ {},
46
+ transform: booleanAttribute
47
+ });
48
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
49
+ this.userClass = input("", {
50
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
51
+ alias: "class",
52
+ transform: (value) => classInputToClass(value)
53
+ });
54
+ }
55
+ #i18n;
56
+ static {
57
+ this.ɵfac = i0.ɵɵngDeclareFactory({
58
+ minVersion: "12.0.0",
59
+ version: "22.2.6",
60
+ ngImport: i0,
61
+ type: SpinnerComponent,
62
+ deps: [],
63
+ target: i0.ɵɵFactoryTarget.Component
64
+ });
65
+ }
66
+ static {
67
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
68
+ minVersion: "17.0.0",
69
+ version: "22.2.6",
70
+ type: SpinnerComponent,
71
+ isStandalone: true,
72
+ selector: "mona-spinner",
73
+ inputs: {
74
+ appearance: {
75
+ classPropertyName: "appearance",
76
+ publicName: "appearance",
77
+ isSignal: true,
78
+ isRequired: false,
79
+ transformFunction: null
80
+ },
81
+ ariaLabel: {
82
+ classPropertyName: "ariaLabel",
83
+ publicName: "aria-label",
84
+ isSignal: true,
85
+ isRequired: false,
86
+ transformFunction: null
87
+ },
88
+ decorative: {
89
+ classPropertyName: "decorative",
90
+ publicName: "decorative",
91
+ isSignal: true,
92
+ isRequired: false,
93
+ transformFunction: null
94
+ },
95
+ size: {
96
+ classPropertyName: "size",
97
+ publicName: "size",
98
+ isSignal: true,
99
+ isRequired: false,
100
+ transformFunction: null
101
+ },
102
+ userClass: {
103
+ classPropertyName: "userClass",
104
+ publicName: "class",
105
+ isSignal: true,
106
+ isRequired: false,
107
+ transformFunction: null
108
+ }
109
+ },
110
+ host: { properties: {
111
+ "attr.aria-hidden": "decorative() ? 'true' : null",
112
+ "attr.aria-label": "decorative() ? null : (ariaLabel() || messages().loading)",
113
+ "attr.role": "decorative() ? null : 'img'",
114
+ "class": "baseClass()"
115
+ } },
116
+ ngImport: i0,
117
+ 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",
118
+ 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"],
119
+ dependencies: [{
120
+ kind: "component",
121
+ type: LucideDynamicIcon,
122
+ selector: "svg[lucideIcon]",
123
+ inputs: ["lucideIcon"]
124
+ }]
125
+ });
126
+ }
127
+ };
128
+ i0.ɵɵngDeclareClassMetadata({
129
+ minVersion: "12.0.0",
130
+ version: "22.2.6",
131
+ ngImport: i0,
132
+ type: SpinnerComponent,
133
+ decorators: [{
134
+ type: Component,
135
+ args: [{
136
+ selector: "mona-spinner",
137
+ imports: [LucideDynamicIcon],
138
+ host: {
139
+ "[attr.aria-hidden]": "decorative() ? 'true' : null",
140
+ "[attr.aria-label]": "decorative() ? null : (ariaLabel() || messages().loading)",
141
+ "[attr.role]": "decorative() ? null : 'img'",
142
+ "[class]": "baseClass()"
143
+ },
144
+ 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",
145
+ 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"]
146
+ }]
147
+ }],
148
+ propDecorators: {
149
+ appearance: [{
150
+ type: i0.Input,
151
+ args: [{
152
+ isSignal: true,
153
+ alias: "appearance",
154
+ required: false
155
+ }]
156
+ }],
157
+ ariaLabel: [{
158
+ type: i0.Input,
159
+ args: [{
160
+ isSignal: true,
161
+ alias: "aria-label",
162
+ required: false
163
+ }]
164
+ }],
165
+ decorative: [{
166
+ type: i0.Input,
167
+ args: [{
168
+ isSignal: true,
169
+ alias: "decorative",
170
+ required: false
171
+ }]
172
+ }],
173
+ size: [{
174
+ type: i0.Input,
175
+ args: [{
176
+ isSignal: true,
177
+ alias: "size",
178
+ required: false
179
+ }]
180
+ }],
181
+ userClass: [{
182
+ type: i0.Input,
183
+ args: [{
184
+ isSignal: true,
185
+ alias: "class",
186
+ required: false
187
+ }]
188
+ }]
189
+ }
30
190
  });
31
-
32
- /**
33
- * @description
34
- * An indeterminate loading indicator primitive for communicating ongoing activity.
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.
37
- */
38
- class SpinnerComponent {
39
- constructor() {
40
- this.#i18n = inject(MonaI18nService);
41
- this.baseClass = computed(() => {
42
- const variantClass = spinnerThemeVariants({ size: this.size() });
43
- return twMerge(variantClass, this.userClass());
44
- }, /* @ts-ignore */
45
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
46
- this.loaderIcon = LucideLoader;
47
- this.messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
48
- this.pixelSize = computed(() => {
49
- switch (this.size()) {
50
- case "small":
51
- return 12;
52
- case "large":
53
- return 24;
54
- case "medium":
55
- default:
56
- return 16;
57
- }
58
- }, /* @ts-ignore */
59
- ...(ngDevMode ? [{ debugName: "pixelSize" }] : /* istanbul ignore next */ []));
60
- /**
61
- * @description Visual appearance of the spinner animation.
62
- * @default "default"
63
- */
64
- this.appearance = input("default", /* @ts-ignore */
65
- ...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
66
- /**
67
- * @description Accessible name of the spinner when it is not decorative.
68
- * When not set, falls back to the localized loading text.
69
- * @default undefined
70
- */
71
- this.ariaLabel = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
72
- /**
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).
76
- * @default false
77
- */
78
- this.decorative = input(false, { ...(ngDevMode ? { debugName: "decorative" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
79
- /**
80
- * @description Size preset controlling the dimensions of the indicator.
81
- * @default "medium"
82
- */
83
- this.size = input("medium", /* @ts-ignore */
84
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
85
- /**
86
- * @description Additional CSS classes merged onto the host element via `tailwind-merge`.
87
- * @default ""
88
- */
89
- this.userClass = input("", { ...(ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {}), alias: "class",
90
- transform: value => classInputToClass(value) });
91
- }
92
- #i18n;
93
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
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"] }] }); }
95
- }
96
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerComponent, decorators: [{
97
- type: Component,
98
- args: [{ selector: "mona-spinner", imports: [LucideDynamicIcon], host: {
99
- "[attr.aria-hidden]": "decorative() ? 'true' : null",
100
- "[attr.aria-label]": "decorative() ? null : (ariaLabel() || messages().loading)",
101
- "[attr.role]": "decorative() ? null : 'img'",
102
- "[class]": "baseClass()"
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"] }]
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 }] }] } });
105
-
106
191
  const spinnerOverlayThemeVariants = cva(`
107
192
  isolate flex items-center justify-center
108
193
  pointer-events-auto select-none
109
194
  bg-background/60 backdrop-blur-xs
110
195
  text-foreground
111
196
  `, {
112
- variants: {
113
- fullPage: {
114
- true: "fixed inset-0",
115
- false: "absolute inset-0"
116
- }
117
- },
118
- defaultVariants: {
119
- fullPage: false
120
- }
197
+ variants: { fullPage: {
198
+ true: "fixed inset-0",
199
+ false: "absolute inset-0"
200
+ } },
201
+ defaultVariants: { fullPage: false }
121
202
  });
122
-
123
- /** Sits above `.cdk-overlay-container`, so a spinner started from a dialog isn't under that dialog. */
124
203
  const FULL_PAGE_Z_INDEX = 1001;
125
- /**
126
- * @description
127
- * Internal overlay component managed exclusively by `SpinnerService`.
128
- * Hosts a decorative `SpinnerComponent`, status message, and optional cancellation control.
129
- */
130
- class SpinnerOverlayComponent {
131
- constructor() {
132
- this.#hostElementRef = inject(ElementRef);
133
- this.#i18n = inject(MonaI18nService);
134
- this.#focusOrigin = null;
135
- this.baseClass = computed(() => {
136
- return spinnerOverlayThemeVariants({ fullPage: this.fullPage() });
137
- }, /* @ts-ignore */
138
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
139
- this.effectiveCancelText = computed(() => {
140
- return this.cancelText() ?? this.messages().cancel;
141
- }, /* @ts-ignore */
142
- ...(ngDevMode ? [{ debugName: "effectiveCancelText" }] : /* istanbul ignore next */ []));
143
- this.effectiveZIndex = computed(() => {
144
- const customZIndex = this.zIndex();
145
- if (customZIndex !== undefined) {
146
- return customZIndex;
147
- }
148
- return this.fullPage() ? FULL_PAGE_Z_INDEX : 1;
149
- }, /* @ts-ignore */
150
- ...(ngDevMode ? [{ debugName: "effectiveZIndex" }] : /* istanbul ignore next */ []));
151
- this.messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
152
- /**
153
- * @description Visual appearance of the nested spinner animation.
154
- * @default "default"
155
- */
156
- this.appearance = input("default", /* @ts-ignore */
157
- ...(ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []));
158
- /**
159
- * @description Emits when the consumer clicks the cancellation action button.
160
- */
161
- // eslint-disable-next-line @angular-eslint/no-output-native
162
- this.cancel = output();
163
- /**
164
- * @description Label text displayed inside the cancellation button.
165
- * When not set, falls back to the localized cancel text.
166
- * @default undefined
167
- */
168
- this.cancelText = input(undefined, /* @ts-ignore */
169
- ...(ngDevMode ? [{ debugName: "cancelText" }] : /* istanbul ignore next */ []));
170
- /**
171
- * @description Whether the cancellation button is displayed in the overlay.
172
- * @default false
173
- */
174
- this.cancellable = input(false, /* @ts-ignore */
175
- ...(ngDevMode ? [{ debugName: "cancellable" }] : /* istanbul ignore next */ []));
176
- /**
177
- * @description Whether the overlay is fixed across the viewport or absolute within a target container.
178
- * @default false
179
- */
180
- this.fullPage = input(false, /* @ts-ignore */
181
- ...(ngDevMode ? [{ debugName: "fullPage" }] : /* istanbul ignore next */ []));
182
- /**
183
- * @description Size preset passed to the nested spinner.
184
- * @default "medium"
185
- */
186
- this.size = input("medium", /* @ts-ignore */
187
- ...(ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []));
188
- /**
189
- * @description Status text displayed below the spinner indicator.
190
- * @default undefined
191
- */
192
- this.text = input(undefined, /* @ts-ignore */
193
- ...(ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []));
194
- /**
195
- * @description Custom z-index value for unusual stacking contexts.
196
- * @default undefined
197
- */
198
- this.zIndex = input(undefined, /* @ts-ignore */
199
- ...(ngDevMode ? [{ debugName: "zIndex" }] : /* istanbul ignore next */ []));
200
- }
201
- #hostElementRef;
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
- }
214
- onCancel() {
215
- this.cancel.emit();
216
- }
217
- onFocusIn(event) {
218
- const origin = event.relatedTarget;
219
- if (origin && !this.#hostElementRef.nativeElement.contains(origin)) {
220
- this.#focusOrigin = origin;
221
- }
222
- }
223
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerOverlayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
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"] }] }); }
225
- }
226
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerOverlayComponent, decorators: [{
227
- type: Component,
228
- args: [{ selector: "mona-spinner-overlay", imports: [SpinnerComponent], host: {
229
- "[class]": "baseClass()",
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" }]
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 }] }] } });
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;
237
- class SpinnerService {
238
- #appRef = inject(ApplicationRef);
239
- #document = inject(DOCUMENT);
240
- #i18n = inject(MonaI18nService);
241
- #injector = inject(Injector);
242
- #liveAnnouncer = inject(LiveAnnouncer);
243
- #messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
244
- #renderer = inject(RendererFactory2).createRenderer(null, null);
245
- #requests = new Map();
246
- #targetStates = new Set();
247
- #targets = new WeakMap();
248
- /**
249
- * Hides and destroys the spinner associated with the given `SpinnerRef` or string `id`.
250
- */
251
- hide(refOrId) {
252
- const id = typeof refOrId === "string" ? refOrId : refOrId.id;
253
- this.#closeRequest(id);
254
- }
255
- /**
256
- * Tears down every active/pending spinner request and physical overlay so
257
- * nothing is left behind if the service outlives its consumers.
258
- */
259
- ngOnDestroy() {
260
- for (const request of this.#requests.values()) {
261
- this.#clearRequestTimers(request);
262
- if (!request.cancellationHandled) {
263
- request.cancelledSubject.complete();
264
- }
265
- }
266
- this.#requests.clear();
267
- for (const targetState of [...this.#targetStates]) {
268
- this.#teardownTarget(targetState);
269
- }
270
- }
271
- /**
272
- * Displays a spinner loading overlay according to the provided options.
273
- * Returns a `SpinnerRef` handle for lifecycle management and updates.
274
- */
275
- show(options) {
276
- const id = options?.id ?? `spinner-${v4()}`;
277
- // If an existing request with the same ID exists, close it cleanly first
278
- if (this.#requests.has(id)) {
279
- this.#closeRequest(id);
280
- }
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];
284
- const cancellableOpt = options?.cancellable;
285
- const isCancellable = !!cancellableOpt;
286
- const cancelText = typeof cancellableOpt === "object" && cancellableOpt.text ? cancellableOpt.text : undefined;
287
- const onCancel = typeof cancellableOpt === "object" ? cancellableOpt.onCancel : undefined;
288
- const cancelledSubject = new Subject();
289
- const request = {
290
- activatedAt: Date.now(),
291
- announceTimer: null,
292
- announcedAt: null,
293
- announcedText: null,
294
- appearance: options?.appearance ?? "default",
295
- cancellationHandled: false,
296
- cancellable: isCancellable,
297
- cancelText,
298
- delayTimer: null,
299
- id,
300
- onCancel,
301
- options: options ?? {},
302
- registeredAt: Date.now(),
303
- size: options?.size ?? "medium",
304
- status: "PENDING",
305
- cancelledSubject,
306
- targets: resolvedTargets,
307
- text: options?.text
308
- };
309
- this.#requests.set(id, request);
310
- // Register request against all targets and set aria-busy. Targets that already
311
- // have a visible overlay activate immediately; idle targets respect `delay`.
312
- const immediateTargets = [];
313
- const delayedTargets = [];
314
- for (const target of resolvedTargets) {
315
- const targetState = this.#getOrCreateTargetState(target);
316
- targetState.pendingRequestIds.add(id);
317
- if (targetState.componentRef != null) {
318
- immediateTargets.push(target);
319
- }
320
- else {
321
- delayedTargets.push(target);
322
- }
323
- }
324
- if (immediateTargets.length > 0) {
325
- this.#activateRequestOnTargets(request, immediateTargets);
326
- }
327
- const delay = options?.delay ?? 0;
328
- if (delayedTargets.length > 0) {
329
- if (delay > 0) {
330
- request.delayTimer = setTimeout(() => {
331
- request.delayTimer = null;
332
- if (request.status !== "CLOSED") {
333
- this.#activateRequestOnTargets(request, delayedTargets);
334
- }
335
- }, delay);
336
- }
337
- else {
338
- this.#activateRequestOnTargets(request, delayedTargets);
339
- }
340
- }
341
- return {
342
- id,
343
- cancelled$: cancelledSubject.asObservable(),
344
- close: () => this.#closeRequest(id),
345
- update: update => this.#updateRequest(id, update)
346
- };
347
- }
348
- /**
349
- * Wraps an Observable operation with a Spinner lifecycle.
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.
353
- */
354
- track(source, options) {
355
- return defer(() => {
356
- const ref = this.show(options);
357
- return source.pipe(takeUntil(ref.cancelled$), finalize(() => ref.close()));
358
- });
359
- }
360
- #activateRequestOnTargets(request, targets) {
361
- if (request.status === "CLOSED") {
362
- return;
363
- }
364
- request.status = "VISIBLE";
365
- request.activatedAt = Date.now();
366
- for (const target of targets) {
367
- const targetState = this.#getOrCreateTargetState(target);
368
- targetState.activeRequestIds.add(request.id);
369
- targetState.minimumVisibleDuration = Math.max(targetState.minimumVisibleDuration, request.options.minimumVisibleDuration ?? 0);
370
- this.#updateTargetOverlay(targetState);
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
- }
398
- }
399
- #cancelRequest(requestId) {
400
- const request = this.#requests.get(requestId);
401
- if (!request || request.cancellationHandled || request.status === "CLOSED") {
402
- return;
403
- }
404
- request.cancellationHandled = true;
405
- request.cancelledSubject.next();
406
- request.cancelledSubject.complete();
407
- try {
408
- if (request.onCancel) {
409
- request.onCancel();
410
- }
411
- }
412
- finally {
413
- this.#closeRequest(requestId);
414
- }
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
- }
426
- #closeRequest(requestId) {
427
- const request = this.#requests.get(requestId);
428
- if (!request || request.status === "CLOSED") {
429
- return;
430
- }
431
- request.status = "CLOSED";
432
- this.#clearRequestTimers(request);
433
- if (!request.cancellationHandled) {
434
- request.cancelledSubject.complete();
435
- }
436
- this.#requests.delete(requestId);
437
- for (const target of request.targets) {
438
- const targetState = this.#targets.get(target);
439
- if (!targetState) {
440
- continue;
441
- }
442
- targetState.pendingRequestIds.delete(requestId);
443
- targetState.activeRequestIds.delete(requestId);
444
- if (targetState.activeRequestIds.size > 0) {
445
- // Other active requests remain; recompute winning presentation
446
- this.#updateTargetOverlay(targetState);
447
- }
448
- else if (targetState.pendingRequestIds.size === 0) {
449
- // No active or pending requests remain on this target
450
- const minDuration = targetState.minimumVisibleDuration;
451
- if (minDuration > 0 && targetState.visibleSince != null && targetState.componentRef != null) {
452
- const elapsed = Date.now() - targetState.visibleSince;
453
- const remaining = minDuration - elapsed;
454
- if (remaining > 0) {
455
- if (targetState.minDurationTimer != null) {
456
- clearTimeout(targetState.minDurationTimer);
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();
462
- targetState.minDurationTimer = setTimeout(() => {
463
- targetState.minDurationTimer = null;
464
- if (targetState.activeRequestIds.size === 0 && targetState.pendingRequestIds.size === 0) {
465
- this.#teardownTarget(targetState);
466
- }
467
- }, remaining);
468
- }
469
- else {
470
- this.#teardownTarget(targetState);
471
- }
472
- }
473
- else {
474
- this.#teardownTarget(targetState);
475
- }
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
- }
487
- }
488
- }
489
- #getOrCreateTargetState(target) {
490
- const isFullPage = target === this.#document.body;
491
- let state = this.#targets.get(target);
492
- if (!state) {
493
- const originalAriaBusy = target.getAttribute("aria-busy");
494
- const originalInlinePosition = target.style.position;
495
- state = {
496
- activeRequestIds: new Set(),
497
- cancelSubscription: null,
498
- changedPosition: false,
499
- componentRef: null,
500
- isFullPage,
501
- minDurationTimer: null,
502
- minimumVisibleDuration: 0,
503
- originalAriaBusy,
504
- originalInlinePosition,
505
- pendingRequestIds: new Set(),
506
- target
507
- };
508
- this.#targets.set(target, state);
509
- this.#targetStates.add(state);
510
- }
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
- }
516
- // If a delayed teardown was pending, cancel it since new activity arrived
517
- if (state.minDurationTimer != null) {
518
- clearTimeout(state.minDurationTimer);
519
- state.minDurationTimer = null;
520
- }
521
- return state;
522
- }
523
- #getWinningRequestForTarget(targetState) {
524
- let winningRequest = null;
525
- for (const requestId of targetState.activeRequestIds) {
526
- const req = this.#requests.get(requestId);
527
- if (req && req.status === "VISIBLE") {
528
- if (!winningRequest || req.activatedAt >= winningRequest.activatedAt) {
529
- winningRequest = req;
530
- }
531
- }
532
- }
533
- return winningRequest;
534
- }
535
- #normalizeTargets(target) {
536
- const rawList = Array.isArray(target) ? target : [target];
537
- const result = [];
538
- for (const item of rawList) {
539
- const element = this.#toElement(item);
540
- if (element) {
541
- result.push(element);
542
- }
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
- }
548
- return result;
549
- }
550
- #teardownTarget(targetState) {
551
- if (targetState.minDurationTimer != null) {
552
- clearTimeout(targetState.minDurationTimer);
553
- targetState.minDurationTimer = null;
554
- }
555
- targetState.cancelSubscription?.unsubscribe();
556
- targetState.cancelSubscription = null;
557
- if (targetState.componentRef != null) {
558
- targetState.componentRef.instance.returnFocus();
559
- this.#appRef.detachView(targetState.componentRef.hostView);
560
- targetState.componentRef.destroy();
561
- targetState.componentRef = null;
562
- }
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
- }
574
- }
575
- // Restore target positioning safely
576
- if (targetState.changedPosition) {
577
- if (targetState.target.style.position === "relative") {
578
- this.#renderer.setStyle(targetState.target, "position", targetState.originalInlinePosition || null);
579
- }
580
- targetState.changedPosition = false;
581
- }
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
- }
591
- #updateRequest(requestId, update) {
592
- const request = this.#requests.get(requestId);
593
- if (!request || request.status === "CLOSED") {
594
- return;
595
- }
596
- if (update.appearance !== undefined) {
597
- request.appearance = update.appearance;
598
- }
599
- if (update.size !== undefined) {
600
- request.size = update.size;
601
- }
602
- if (update.text !== undefined) {
603
- request.text = update.text;
604
- }
605
- for (const target of request.targets) {
606
- const targetState = this.#targets.get(target);
607
- if (targetState) {
608
- this.#updateTargetOverlay(targetState);
609
- }
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);
623
- }
624
- #updateTargetOverlay(targetState) {
625
- const winner = this.#getWinningRequestForTarget(targetState);
626
- if (!winner) {
627
- return;
628
- }
629
- if (!targetState.componentRef) {
630
- // Need containing block for absolute local positioning
631
- if (!targetState.isFullPage) {
632
- const defaultView = this.#document.defaultView;
633
- const computedPosition = defaultView ? defaultView.getComputedStyle(targetState.target).position : "static";
634
- if (computedPosition === "static") {
635
- this.#renderer.setStyle(targetState.target, "position", "relative");
636
- targetState.changedPosition = true;
637
- }
638
- }
639
- const compRef = createComponent(SpinnerOverlayComponent, {
640
- environmentInjector: this.#appRef.injector,
641
- elementInjector: this.#injector
642
- });
643
- this.#updateOverlayInputs(compRef, winner, targetState);
644
- targetState.cancelSubscription = compRef.instance.cancel.subscribe(() => {
645
- const currentWinner = this.#getWinningRequestForTarget(targetState);
646
- if (currentWinner) {
647
- this.#cancelRequest(currentWinner.id);
648
- }
649
- });
650
- this.#appRef.attachView(compRef.hostView);
651
- this.#renderer.appendChild(targetState.target, compRef.location.nativeElement);
652
- compRef.changeDetectorRef.detectChanges();
653
- targetState.componentRef = compRef;
654
- targetState.visibleSince = Date.now();
655
- }
656
- else {
657
- // Physical overlay already exists: update its inputs dynamically
658
- const compRef = targetState.componentRef;
659
- if (!winner.cancellable) {
660
- // The Cancel button goes away with this update, and focus mustn't go with it.
661
- compRef.instance.returnFocus();
662
- }
663
- this.#updateOverlayInputs(compRef, winner, targetState);
664
- compRef.changeDetectorRef.detectChanges();
665
- }
666
- }
667
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
668
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerService, providedIn: "root" }); }
669
- }
670
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: SpinnerService, decorators: [{
671
- type: Injectable,
672
- args: [{
673
- providedIn: "root"
674
- }]
675
- }] });
676
-
677
- /*
678
- * Public API Surface of @nanahoshi/mona-ui/spinner
679
- */
680
-
681
- /**
682
- * Generated bundle index. Do not edit.
683
- */
684
-
204
+ var SpinnerOverlayComponent = class SpinnerOverlayComponent {
205
+ constructor() {
206
+ this.#hostElementRef = inject(ElementRef);
207
+ this.#i18n = inject(MonaI18nService);
208
+ this.#focusOrigin = null;
209
+ this.baseClass = computed(() => {
210
+ return spinnerOverlayThemeVariants({ fullPage: this.fullPage() });
211
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
212
+ this.effectiveCancelText = computed(() => {
213
+ return this.cancelText() ?? this.messages().cancel;
214
+ }, ...ngDevMode ? [{ debugName: "effectiveCancelText" }] : /* istanbul ignore next */ []);
215
+ this.effectiveZIndex = computed(() => {
216
+ const customZIndex = this.zIndex();
217
+ if (customZIndex !== void 0) return customZIndex;
218
+ return this.fullPage() ? FULL_PAGE_Z_INDEX : 1;
219
+ }, ...ngDevMode ? [{ debugName: "effectiveZIndex" }] : /* istanbul ignore next */ []);
220
+ this.messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
221
+ this.appearance = input("default", ...ngDevMode ? [{ debugName: "appearance" }] : /* istanbul ignore next */ []);
222
+ this.cancel = output();
223
+ this.cancelText = input(void 0, ...ngDevMode ? [{ debugName: "cancelText" }] : /* istanbul ignore next */ []);
224
+ this.cancellable = input(false, ...ngDevMode ? [{ debugName: "cancellable" }] : /* istanbul ignore next */ []);
225
+ this.fullPage = input(false, ...ngDevMode ? [{ debugName: "fullPage" }] : /* istanbul ignore next */ []);
226
+ this.size = input("medium", ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
227
+ this.text = input(void 0, ...ngDevMode ? [{ debugName: "text" }] : /* istanbul ignore next */ []);
228
+ this.zIndex = input(void 0, ...ngDevMode ? [{ debugName: "zIndex" }] : /* istanbul ignore next */ []);
229
+ }
230
+ #hostElementRef;
231
+ #i18n;
232
+ #focusOrigin;
233
+ returnFocus() {
234
+ const host = this.#hostElementRef.nativeElement;
235
+ if (host.contains(host.ownerDocument.activeElement)) this.#focusOrigin?.focus({ preventScroll: true });
236
+ }
237
+ onCancel() {
238
+ this.cancel.emit();
239
+ }
240
+ onFocusIn(event) {
241
+ const origin = event.relatedTarget;
242
+ if (origin && !this.#hostElementRef.nativeElement.contains(origin)) this.#focusOrigin = origin;
243
+ }
244
+ static {
245
+ this.ɵfac = i0.ɵɵngDeclareFactory({
246
+ minVersion: "12.0.0",
247
+ version: "22.2.6",
248
+ ngImport: i0,
249
+ type: SpinnerOverlayComponent,
250
+ deps: [],
251
+ target: i0.ɵɵFactoryTarget.Component
252
+ });
253
+ }
254
+ static {
255
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
256
+ minVersion: "17.0.0",
257
+ version: "22.2.6",
258
+ type: SpinnerOverlayComponent,
259
+ isStandalone: true,
260
+ selector: "mona-spinner-overlay",
261
+ inputs: {
262
+ appearance: {
263
+ classPropertyName: "appearance",
264
+ publicName: "appearance",
265
+ isSignal: true,
266
+ isRequired: false,
267
+ transformFunction: null
268
+ },
269
+ cancelText: {
270
+ classPropertyName: "cancelText",
271
+ publicName: "cancelText",
272
+ isSignal: true,
273
+ isRequired: false,
274
+ transformFunction: null
275
+ },
276
+ cancellable: {
277
+ classPropertyName: "cancellable",
278
+ publicName: "cancellable",
279
+ isSignal: true,
280
+ isRequired: false,
281
+ transformFunction: null
282
+ },
283
+ fullPage: {
284
+ classPropertyName: "fullPage",
285
+ publicName: "fullPage",
286
+ isSignal: true,
287
+ isRequired: false,
288
+ transformFunction: null
289
+ },
290
+ size: {
291
+ classPropertyName: "size",
292
+ publicName: "size",
293
+ isSignal: true,
294
+ isRequired: false,
295
+ transformFunction: null
296
+ },
297
+ text: {
298
+ classPropertyName: "text",
299
+ publicName: "text",
300
+ isSignal: true,
301
+ isRequired: false,
302
+ transformFunction: null
303
+ },
304
+ zIndex: {
305
+ classPropertyName: "zIndex",
306
+ publicName: "zIndex",
307
+ isSignal: true,
308
+ isRequired: false,
309
+ transformFunction: null
310
+ }
311
+ },
312
+ outputs: { cancel: "cancel" },
313
+ host: {
314
+ listeners: { "focusin": "onFocusIn($event)" },
315
+ properties: {
316
+ "class": "baseClass()",
317
+ "style.z-index": "effectiveZIndex()"
318
+ }
319
+ },
320
+ ngImport: i0,
321
+ 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",
322
+ dependencies: [{
323
+ kind: "component",
324
+ type: SpinnerComponent,
325
+ selector: "mona-spinner",
326
+ inputs: [
327
+ "appearance",
328
+ "aria-label",
329
+ "decorative",
330
+ "size",
331
+ "class"
332
+ ]
333
+ }]
334
+ });
335
+ }
336
+ };
337
+ i0.ɵɵngDeclareClassMetadata({
338
+ minVersion: "12.0.0",
339
+ version: "22.2.6",
340
+ ngImport: i0,
341
+ type: SpinnerOverlayComponent,
342
+ decorators: [{
343
+ type: Component,
344
+ args: [{
345
+ selector: "mona-spinner-overlay",
346
+ imports: [SpinnerComponent],
347
+ host: {
348
+ "[class]": "baseClass()",
349
+ "[style.z-index]": "effectiveZIndex()",
350
+ "(focusin)": "onFocusIn($event)"
351
+ },
352
+ 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"
353
+ }]
354
+ }],
355
+ propDecorators: {
356
+ appearance: [{
357
+ type: i0.Input,
358
+ args: [{
359
+ isSignal: true,
360
+ alias: "appearance",
361
+ required: false
362
+ }]
363
+ }],
364
+ cancel: [{
365
+ type: i0.Output,
366
+ args: ["cancel"]
367
+ }],
368
+ cancelText: [{
369
+ type: i0.Input,
370
+ args: [{
371
+ isSignal: true,
372
+ alias: "cancelText",
373
+ required: false
374
+ }]
375
+ }],
376
+ cancellable: [{
377
+ type: i0.Input,
378
+ args: [{
379
+ isSignal: true,
380
+ alias: "cancellable",
381
+ required: false
382
+ }]
383
+ }],
384
+ fullPage: [{
385
+ type: i0.Input,
386
+ args: [{
387
+ isSignal: true,
388
+ alias: "fullPage",
389
+ required: false
390
+ }]
391
+ }],
392
+ size: [{
393
+ type: i0.Input,
394
+ args: [{
395
+ isSignal: true,
396
+ alias: "size",
397
+ required: false
398
+ }]
399
+ }],
400
+ text: [{
401
+ type: i0.Input,
402
+ args: [{
403
+ isSignal: true,
404
+ alias: "text",
405
+ required: false
406
+ }]
407
+ }],
408
+ zIndex: [{
409
+ type: i0.Input,
410
+ args: [{
411
+ isSignal: true,
412
+ alias: "zIndex",
413
+ required: false
414
+ }]
415
+ }]
416
+ }
417
+ });
418
+ const ANNOUNCE_INTERVAL = 5e3;
419
+ var SpinnerService = class SpinnerService {
420
+ #appRef = inject(ApplicationRef);
421
+ #document = inject(DOCUMENT);
422
+ #i18n = inject(MonaI18nService);
423
+ #injector = inject(Injector);
424
+ #liveAnnouncer = inject(LiveAnnouncer);
425
+ #messages = this.#i18n.componentMessages("spinner", SPINNER_DEFAULT_MESSAGES);
426
+ #renderer = inject(RendererFactory2).createRenderer(null, null);
427
+ #requests = /* @__PURE__ */ new Map();
428
+ #targetStates = /* @__PURE__ */ new Set();
429
+ #targets = /* @__PURE__ */ new WeakMap();
430
+ hide(refOrId) {
431
+ const id = typeof refOrId === "string" ? refOrId : refOrId.id;
432
+ this.#closeRequest(id);
433
+ }
434
+ ngOnDestroy() {
435
+ for (const request of this.#requests.values()) {
436
+ this.#clearRequestTimers(request);
437
+ if (!request.cancellationHandled) request.cancelledSubject.complete();
438
+ }
439
+ this.#requests.clear();
440
+ for (const targetState of [...this.#targetStates]) this.#teardownTarget(targetState);
441
+ }
442
+ show(options) {
443
+ const id = options?.id ?? `spinner-${v4()}`;
444
+ if (this.#requests.has(id)) this.#closeRequest(id);
445
+ const resolvedTargets = options && "target" in options ? this.#normalizeTargets(options.target) : [this.#document.body];
446
+ const cancellableOpt = options?.cancellable;
447
+ const isCancellable = !!cancellableOpt;
448
+ const cancelText = typeof cancellableOpt === "object" && cancellableOpt.text ? cancellableOpt.text : void 0;
449
+ const onCancel = typeof cancellableOpt === "object" ? cancellableOpt.onCancel : void 0;
450
+ const cancelledSubject = new Subject();
451
+ const request = {
452
+ activatedAt: Date.now(),
453
+ announceTimer: null,
454
+ announcedAt: null,
455
+ announcedText: null,
456
+ appearance: options?.appearance ?? "default",
457
+ cancellationHandled: false,
458
+ cancellable: isCancellable,
459
+ cancelText,
460
+ delayTimer: null,
461
+ id,
462
+ onCancel,
463
+ options: options ?? {},
464
+ registeredAt: Date.now(),
465
+ size: options?.size ?? "medium",
466
+ status: "PENDING",
467
+ cancelledSubject,
468
+ targets: resolvedTargets,
469
+ text: options?.text
470
+ };
471
+ this.#requests.set(id, request);
472
+ const immediateTargets = [];
473
+ const delayedTargets = [];
474
+ for (const target of resolvedTargets) {
475
+ const targetState = this.#getOrCreateTargetState(target);
476
+ targetState.pendingRequestIds.add(id);
477
+ if (targetState.componentRef != null) immediateTargets.push(target);
478
+ else delayedTargets.push(target);
479
+ }
480
+ if (immediateTargets.length > 0) this.#activateRequestOnTargets(request, immediateTargets);
481
+ const delay = options?.delay ?? 0;
482
+ if (delayedTargets.length > 0) {
483
+ if (delay > 0) request.delayTimer = setTimeout(() => {
484
+ request.delayTimer = null;
485
+ if (request.status !== "CLOSED") this.#activateRequestOnTargets(request, delayedTargets);
486
+ }, delay);
487
+ else this.#activateRequestOnTargets(request, delayedTargets);
488
+ }
489
+ return {
490
+ id,
491
+ cancelled$: cancelledSubject.asObservable(),
492
+ close: () => this.#closeRequest(id),
493
+ update: (update) => this.#updateRequest(id, update)
494
+ };
495
+ }
496
+ track(source, options) {
497
+ return defer(() => {
498
+ const ref = this.show(options);
499
+ return source.pipe(takeUntil(ref.cancelled$), finalize(() => ref.close()));
500
+ });
501
+ }
502
+ #activateRequestOnTargets(request, targets) {
503
+ if (request.status === "CLOSED") return;
504
+ request.status = "VISIBLE";
505
+ request.activatedAt = Date.now();
506
+ for (const target of targets) {
507
+ const targetState = this.#getOrCreateTargetState(target);
508
+ targetState.activeRequestIds.add(request.id);
509
+ targetState.minimumVisibleDuration = Math.max(targetState.minimumVisibleDuration, request.options.minimumVisibleDuration ?? 0);
510
+ this.#updateTargetOverlay(targetState);
511
+ }
512
+ if (request.announcedAt === null) this.#announce(request);
513
+ }
514
+ #announce(request) {
515
+ const text = request.text || this.#messages().loading;
516
+ if (text !== request.announcedText) {
517
+ request.announcedAt = Date.now();
518
+ request.announcedText = text;
519
+ this.#liveAnnouncer.announce(text, "polite");
520
+ }
521
+ }
522
+ #announceUpdate(request) {
523
+ if (request.announcedAt === null || request.announceTimer != null) return;
524
+ const wait = request.announcedAt + ANNOUNCE_INTERVAL - Date.now();
525
+ if (wait <= 0) this.#announce(request);
526
+ else request.announceTimer = setTimeout(() => {
527
+ request.announceTimer = null;
528
+ this.#announce(request);
529
+ }, wait);
530
+ }
531
+ #cancelRequest(requestId) {
532
+ const request = this.#requests.get(requestId);
533
+ if (!request || request.cancellationHandled || request.status === "CLOSED") return;
534
+ request.cancellationHandled = true;
535
+ request.cancelledSubject.next();
536
+ request.cancelledSubject.complete();
537
+ try {
538
+ if (request.onCancel) request.onCancel();
539
+ } finally {
540
+ this.#closeRequest(requestId);
541
+ }
542
+ }
543
+ #clearRequestTimers(request) {
544
+ if (request.delayTimer != null) {
545
+ clearTimeout(request.delayTimer);
546
+ request.delayTimer = null;
547
+ }
548
+ if (request.announceTimer != null) {
549
+ clearTimeout(request.announceTimer);
550
+ request.announceTimer = null;
551
+ }
552
+ }
553
+ #closeRequest(requestId) {
554
+ const request = this.#requests.get(requestId);
555
+ if (!request || request.status === "CLOSED") return;
556
+ request.status = "CLOSED";
557
+ this.#clearRequestTimers(request);
558
+ if (!request.cancellationHandled) request.cancelledSubject.complete();
559
+ this.#requests.delete(requestId);
560
+ for (const target of request.targets) {
561
+ const targetState = this.#targets.get(target);
562
+ if (!targetState) continue;
563
+ targetState.pendingRequestIds.delete(requestId);
564
+ targetState.activeRequestIds.delete(requestId);
565
+ if (targetState.activeRequestIds.size > 0) this.#updateTargetOverlay(targetState);
566
+ else if (targetState.pendingRequestIds.size === 0) {
567
+ const minDuration = targetState.minimumVisibleDuration;
568
+ if (minDuration > 0 && targetState.visibleSince != null && targetState.componentRef != null) {
569
+ const remaining = minDuration - (Date.now() - targetState.visibleSince);
570
+ if (remaining > 0) {
571
+ if (targetState.minDurationTimer != null) clearTimeout(targetState.minDurationTimer);
572
+ targetState.componentRef.instance.returnFocus();
573
+ targetState.componentRef.setInput("cancellable", false);
574
+ targetState.componentRef.changeDetectorRef.detectChanges();
575
+ targetState.minDurationTimer = setTimeout(() => {
576
+ targetState.minDurationTimer = null;
577
+ if (targetState.activeRequestIds.size === 0 && targetState.pendingRequestIds.size === 0) this.#teardownTarget(targetState);
578
+ }, remaining);
579
+ } else this.#teardownTarget(targetState);
580
+ } else this.#teardownTarget(targetState);
581
+ } else if (targetState.componentRef != null) for (const pendingId of targetState.pendingRequestIds) {
582
+ const pending = this.#requests.get(pendingId);
583
+ if (pending) this.#activateRequestOnTargets(pending, [target]);
584
+ }
585
+ }
586
+ }
587
+ #getOrCreateTargetState(target) {
588
+ const isFullPage = target === this.#document.body;
589
+ let state = this.#targets.get(target);
590
+ if (!state) {
591
+ const originalAriaBusy = target.getAttribute("aria-busy");
592
+ const originalInlinePosition = target.style.position;
593
+ state = {
594
+ activeRequestIds: /* @__PURE__ */ new Set(),
595
+ cancelSubscription: null,
596
+ changedPosition: false,
597
+ componentRef: null,
598
+ isFullPage,
599
+ minDurationTimer: null,
600
+ minimumVisibleDuration: 0,
601
+ originalAriaBusy,
602
+ originalInlinePosition,
603
+ pendingRequestIds: /* @__PURE__ */ new Set(),
604
+ target
605
+ };
606
+ this.#targets.set(target, state);
607
+ this.#targetStates.add(state);
608
+ }
609
+ if (!isFullPage) this.#renderer.setAttribute(target, "aria-busy", "true");
610
+ if (state.minDurationTimer != null) {
611
+ clearTimeout(state.minDurationTimer);
612
+ state.minDurationTimer = null;
613
+ }
614
+ return state;
615
+ }
616
+ #getWinningRequestForTarget(targetState) {
617
+ let winningRequest = null;
618
+ for (const requestId of targetState.activeRequestIds) {
619
+ const req = this.#requests.get(requestId);
620
+ if (req && req.status === "VISIBLE") {
621
+ if (!winningRequest || req.activatedAt >= winningRequest.activatedAt) winningRequest = req;
622
+ }
623
+ }
624
+ return winningRequest;
625
+ }
626
+ #normalizeTargets(target) {
627
+ const rawList = Array.isArray(target) ? target : [target];
628
+ const result = [];
629
+ for (const item of rawList) {
630
+ const element = this.#toElement(item);
631
+ if (element) result.push(element);
632
+ }
633
+ if (isDevMode() && (result.length === 0 || result.length !== rawList.length)) console.error("SpinnerService: a target didn't resolve to an element, so no overlay shows on it. Leave target out for a full-page spinner.");
634
+ return result;
635
+ }
636
+ #teardownTarget(targetState) {
637
+ if (targetState.minDurationTimer != null) {
638
+ clearTimeout(targetState.minDurationTimer);
639
+ targetState.minDurationTimer = null;
640
+ }
641
+ targetState.cancelSubscription?.unsubscribe();
642
+ targetState.cancelSubscription = null;
643
+ if (targetState.componentRef != null) {
644
+ targetState.componentRef.instance.returnFocus();
645
+ this.#appRef.detachView(targetState.componentRef.hostView);
646
+ targetState.componentRef.destroy();
647
+ targetState.componentRef = null;
648
+ }
649
+ this.#targets.delete(targetState.target);
650
+ this.#targetStates.delete(targetState);
651
+ if (!targetState.isFullPage) {
652
+ if (targetState.originalAriaBusy === null) this.#renderer.removeAttribute(targetState.target, "aria-busy");
653
+ else this.#renderer.setAttribute(targetState.target, "aria-busy", targetState.originalAriaBusy);
654
+ }
655
+ if (targetState.changedPosition) {
656
+ if (targetState.target.style.position === "relative") this.#renderer.setStyle(targetState.target, "position", targetState.originalInlinePosition || null);
657
+ targetState.changedPosition = false;
658
+ }
659
+ }
660
+ #toElement(item) {
661
+ const isElement = (value) => value?.nodeType === 1;
662
+ if (isElement(item)) return item;
663
+ const nativeElement = item?.nativeElement;
664
+ return isElement(nativeElement) ? nativeElement : null;
665
+ }
666
+ #updateRequest(requestId, update) {
667
+ const request = this.#requests.get(requestId);
668
+ if (!request || request.status === "CLOSED") return;
669
+ if (update.appearance !== void 0) request.appearance = update.appearance;
670
+ if (update.size !== void 0) request.size = update.size;
671
+ if (update.text !== void 0) request.text = update.text;
672
+ for (const target of request.targets) {
673
+ const targetState = this.#targets.get(target);
674
+ if (targetState) this.#updateTargetOverlay(targetState);
675
+ }
676
+ if (update.text !== void 0) this.#announceUpdate(request);
677
+ }
678
+ #updateOverlayInputs(componentRef, winner, targetState) {
679
+ componentRef.setInput("appearance", winner.appearance);
680
+ componentRef.setInput("size", winner.size);
681
+ componentRef.setInput("text", winner.text);
682
+ componentRef.setInput("cancellable", winner.cancellable);
683
+ componentRef.setInput("cancelText", winner.cancelText);
684
+ componentRef.setInput("fullPage", targetState.isFullPage);
685
+ componentRef.setInput("zIndex", winner.options.zIndex);
686
+ }
687
+ #updateTargetOverlay(targetState) {
688
+ const winner = this.#getWinningRequestForTarget(targetState);
689
+ if (!winner) return;
690
+ if (!targetState.componentRef) {
691
+ if (!targetState.isFullPage) {
692
+ const defaultView = this.#document.defaultView;
693
+ if ((defaultView ? defaultView.getComputedStyle(targetState.target).position : "static") === "static") {
694
+ this.#renderer.setStyle(targetState.target, "position", "relative");
695
+ targetState.changedPosition = true;
696
+ }
697
+ }
698
+ const compRef = createComponent(SpinnerOverlayComponent, {
699
+ environmentInjector: this.#appRef.injector,
700
+ elementInjector: this.#injector
701
+ });
702
+ this.#updateOverlayInputs(compRef, winner, targetState);
703
+ targetState.cancelSubscription = compRef.instance.cancel.subscribe(() => {
704
+ const currentWinner = this.#getWinningRequestForTarget(targetState);
705
+ if (currentWinner) this.#cancelRequest(currentWinner.id);
706
+ });
707
+ this.#appRef.attachView(compRef.hostView);
708
+ this.#renderer.appendChild(targetState.target, compRef.location.nativeElement);
709
+ compRef.changeDetectorRef.detectChanges();
710
+ targetState.componentRef = compRef;
711
+ targetState.visibleSince = Date.now();
712
+ } else {
713
+ const compRef = targetState.componentRef;
714
+ if (!winner.cancellable) compRef.instance.returnFocus();
715
+ this.#updateOverlayInputs(compRef, winner, targetState);
716
+ compRef.changeDetectorRef.detectChanges();
717
+ }
718
+ }
719
+ static {
720
+ this.ɵfac = i0.ɵɵngDeclareFactory({
721
+ minVersion: "12.0.0",
722
+ version: "22.2.6",
723
+ ngImport: i0,
724
+ type: SpinnerService,
725
+ deps: [],
726
+ target: i0.ɵɵFactoryTarget.Injectable
727
+ });
728
+ }
729
+ static {
730
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
731
+ minVersion: "12.0.0",
732
+ version: "22.2.6",
733
+ ngImport: i0,
734
+ type: SpinnerService,
735
+ providedIn: "root"
736
+ });
737
+ }
738
+ };
739
+ i0.ɵɵngDeclareClassMetadata({
740
+ minVersion: "12.0.0",
741
+ version: "22.2.6",
742
+ ngImport: i0,
743
+ type: SpinnerService,
744
+ decorators: [{
745
+ type: Injectable,
746
+ args: [{ providedIn: "root" }]
747
+ }]
748
+ });
685
749
  export { SPINNER_DEFAULT_MESSAGES, SpinnerComponent, SpinnerService };
686
- //# sourceMappingURL=nanahoshi-mona-ui-spinner.mjs.map
750
+
751
+ //# sourceMappingURL=nanahoshi-mona-ui-spinner.mjs.map