@nanahoshi/mona-ui 0.27.2 → 0.29.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 (213) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/locales.md +8 -0
  3. package/docs/api/popup.md +1 -1
  4. package/docs/api/theme.md +2 -2
  5. package/docs/chart.md +14 -0
  6. package/docs/editor.md +2 -0
  7. package/docs/installation.md +147 -15
  8. package/docs/introduction.md +37 -15
  9. package/docs/theming-built-in-themes.md +67 -0
  10. package/docs/theming-custom-colors.md +274 -0
  11. package/docs/theming-custom-themes.md +168 -0
  12. package/docs/theming.md +164 -248
  13. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  14. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  15. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  16. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  17. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  18. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2071 -1573
  19. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  20. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  21. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  22. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  23. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  24. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  25. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  26. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  27. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  28. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  29. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  30. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  31. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  32. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  33. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  34. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  35. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  37. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  38. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  39. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  40. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  41. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  42. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  49. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  50. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  51. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  52. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  53. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  54. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  55. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  56. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  57. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  58. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  59. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  60. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  61. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  62. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  63. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  65. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  66. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  67. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  68. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  70. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +599 -0
  71. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  72. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  73. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  74. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  75. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  76. package/fesm2022/nanahoshi-mona-ui-locales.mjs +61 -77
  77. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  78. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  79. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  80. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  81. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  82. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  83. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  84. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  85. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  86. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  87. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  88. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  89. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  90. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  91. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  92. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  93. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  94. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  95. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  96. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  97. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  98. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  99. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  100. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  101. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  102. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  103. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  104. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  105. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  106. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  107. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  108. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  109. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  110. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  111. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  112. package/llms.txt +7 -3
  113. package/locales/pl-pl/package.json +4 -0
  114. package/locales/pl-pl/pl-pl.messages.json +536 -0
  115. package/package.json +66 -23
  116. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  117. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  118. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  119. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  120. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  121. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  122. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  123. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  124. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  125. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  126. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  127. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  128. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  129. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  130. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  131. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  132. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  133. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  134. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  135. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  136. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  137. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  138. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  139. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  140. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  141. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  142. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  143. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  144. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  145. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  146. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  147. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  148. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  149. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  150. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  151. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  152. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  153. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  154. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  155. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  156. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  157. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  158. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  159. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +540 -0
  168. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  169. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  170. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  171. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  172. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  173. package/types/nanahoshi-mona-ui-locales.d.ts +18 -19
  174. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  175. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  176. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  177. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  178. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  179. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  180. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  181. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  182. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  183. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  184. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  185. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  186. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  187. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  188. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  189. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  190. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  191. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  192. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  193. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  194. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  195. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  196. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  197. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  198. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  199. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  200. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  201. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  202. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  203. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  204. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  205. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  206. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  207. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  208. package/types/nanahoshi-mona-ui.d.ts +1 -2
  209. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  210. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  211. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  212. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  213. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,1481 +1,1683 @@
1
- import * as i0 from '@angular/core';
2
- import { InjectionToken, inject, DestroyRef, DOCUMENT, viewChild, ViewContainerRef, computed, signal, TemplateRef, Component, Injector, ElementRef, Injectable, input, output, booleanAttribute, effect } from '@angular/core';
3
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import { take, asapScheduler, Subject, ReplaySubject, asyncScheduler, fromEvent, Subscription, merge, takeUntil } from 'rxjs';
5
- import { PreventableEvent } from '@nanahoshi/mona-ui/common';
6
- import { Directionality } from '@angular/cdk/bidi';
7
- import { Overlay, OverlayConfig } from '@angular/cdk/overlay';
8
- import { ComponentPortal } from '@angular/cdk/portal';
9
- import { ScrollDispatcher } from '@angular/cdk/scrolling';
10
- import { MonaI18nService, resolveComponentDirection, observeComponentDirection } from '@nanahoshi/mona-ui/i18n';
11
- import { focusCanReturn } from '@nanahoshi/mona-ui/internal';
12
- import { NgTemplateOutlet } from '@angular/common';
13
-
14
- class PopupCloseEvent extends PreventableEvent {
15
- #options;
16
- constructor(options) {
17
- super(options?.type ?? "popupClose", options?.originalEvent);
18
- this.#options = options;
19
- }
20
- /** The result value passed to `close()`, if any. */
21
- get result() {
22
- return this.#options?.result;
23
- }
24
- /** The source of the close. */
25
- get via() {
26
- return this.#options?.via;
27
- }
28
- }
1
+ import * as i0 from "@angular/core";
2
+ import { Component, DOCUMENT, DestroyRef, ElementRef, Injectable, InjectionToken, Injector, TemplateRef, ViewContainerRef, booleanAttribute, computed, effect, inject, input, output, signal, viewChild } from "@angular/core";
3
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import { ReplaySubject, Subject, Subscription, asapScheduler, asyncScheduler, fromEvent, merge, take, takeUntil } from "rxjs";
5
+ import { PreventableEvent } from "@nanahoshi/mona-ui/common";
6
+ import { Directionality } from "@angular/cdk/bidi";
7
+ import { Overlay, OverlayConfig } from "@angular/cdk/overlay";
8
+ import { ComponentPortal } from "@angular/cdk/portal";
9
+ import { ScrollDispatcher } from "@angular/cdk/scrolling";
10
+ import { MonaI18nService, observeComponentDirection, resolveComponentDirection } from "@nanahoshi/mona-ui/i18n";
11
+ import { createPageScrollBlockStrategy, focusCanReturn } from "@nanahoshi/mona-ui/internal";
12
+ import { NgTemplateOutlet } from "@angular/common";
13
+ var PopupCloseEvent = class extends PreventableEvent {
14
+ #options;
15
+ constructor(options) {
16
+ super(options?.type ?? "popupClose", options?.originalEvent);
17
+ this.#options = options;
18
+ }
19
+ get result() {
20
+ return this.#options?.result;
21
+ }
22
+ get via() {
23
+ return this.#options?.via;
24
+ }
25
+ };
29
26
  var PopupCloseSource;
30
- (function (PopupCloseSource) {
31
- /** A dialog action button, such as OK or Cancel. */
32
- PopupCloseSource["Action"] = "action";
33
- /** A click on the backdrop, when `closeOnBackdropClick` allows it. */
34
- PopupCloseSource["BackdropClick"] = "backdropClick";
35
- /** The close button of a dialog, window or sheet. */
36
- PopupCloseSource["CloseButton"] = "closeButton";
37
- /** The Escape key. */
38
- PopupCloseSource["Escape"] = "escape";
39
- /** The pointer leaving the anchor, when `closeOnMouseLeave` is set. */
40
- PopupCloseSource["MouseLeave"] = "mouseLeave";
41
- /** A `close()` call from code, with no user interaction behind it. */
42
- PopupCloseSource["Programmatic"] = "programmatic";
43
- /** A pointer press outside the popup and its anchor. */
44
- PopupCloseSource["OutsideClick"] = "outsideClick";
45
- /** The anchor scrolling away, when `closeOnScroll` is set. */
46
- PopupCloseSource["Scroll"] = "scroll";
27
+ (function(PopupCloseSource) {
28
+ PopupCloseSource["Action"] = "action";
29
+ PopupCloseSource["BackdropClick"] = "backdropClick";
30
+ PopupCloseSource["CloseButton"] = "closeButton";
31
+ PopupCloseSource["Escape"] = "escape";
32
+ PopupCloseSource["MouseLeave"] = "mouseLeave";
33
+ PopupCloseSource["Programmatic"] = "programmatic";
34
+ PopupCloseSource["OutsideClick"] = "outsideClick";
35
+ PopupCloseSource["Scroll"] = "scroll";
47
36
  })(PopupCloseSource || (PopupCloseSource = {}));
48
-
49
37
  const defaultPopupAnimation = {
50
- enter: "mona-popup-enter",
51
- leave: "mona-popup-leave"
38
+ enter: "mona-popup-enter",
39
+ leave: "mona-popup-leave"
52
40
  };
53
41
  const dropdownPopupAnimation = {
54
- enter: "mona-dropdown-popup-enter",
55
- leave: "mona-dropdown-popup-leave"
42
+ enter: "mona-dropdown-popup-enter",
43
+ leave: "mona-dropdown-popup-leave"
56
44
  };
57
45
  const fadePopupAnimation = {
58
- enter: "mona-popup-fade-enter",
59
- leave: "mona-popup-fade-leave"
46
+ enter: "mona-popup-fade-enter",
47
+ leave: "mona-popup-fade-leave"
60
48
  };
61
49
  const slideFromRightPopupAnimation = {
62
- enter: "mona-popup-slide-from-right-enter",
63
- leave: "mona-popup-slide-to-right-leave"
50
+ enter: "mona-popup-slide-from-right-enter",
51
+ leave: "mona-popup-slide-to-right-leave"
64
52
  };
65
53
  const slideFromLeftPopupAnimation = {
66
- enter: "mona-popup-slide-from-left-enter",
67
- leave: "mona-popup-slide-to-left-leave"
54
+ enter: "mona-popup-slide-from-left-enter",
55
+ leave: "mona-popup-slide-to-left-leave"
68
56
  };
69
57
  const slideFromTopPopupAnimation = {
70
- enter: "mona-popup-slide-from-top-enter",
71
- leave: "mona-popup-slide-to-top-leave"
58
+ enter: "mona-popup-slide-from-top-enter",
59
+ leave: "mona-popup-slide-to-top-leave"
72
60
  };
73
61
  const slideFromBottomPopupAnimation = {
74
- enter: "mona-popup-slide-from-bottom-enter",
75
- leave: "mona-popup-slide-to-bottom-leave"
62
+ enter: "mona-popup-slide-from-bottom-enter",
63
+ leave: "mona-popup-slide-to-bottom-leave"
76
64
  };
77
-
78
- /**
79
- * The `data` passed in `PopupSettings`, available to the popup content.
80
- */
81
- // eslint-disable-next-line @typescript-eslint/naming-convention -- public API name, kept for compatibility.
82
65
  const PopupDataInjectionToken = new InjectionToken("PopupDataInjectionToken");
83
66
  const POPUP_SETTINGS = new InjectionToken("POPUP_SETTINGS");
84
-
85
- /**
86
- * @internal - used by the popup service. Do not use directly or export.
87
- */
88
67
  const POPUP_REFERENCE = new InjectionToken("POPUP_REFERENCE");
89
-
90
- class PopupWrapperComponent {
91
- #destroyRef;
92
- #document;
93
- #popupReference;
94
- #popupSettings;
95
- #closeEvent;
96
- #fallbackTimer;
97
- #leaveCompleted;
98
- constructor() {
99
- this.#destroyRef = inject(DestroyRef);
100
- this.#document = inject(DOCUMENT);
101
- this.#popupReference = inject(POPUP_REFERENCE);
102
- this.#popupSettings = inject(POPUP_SETTINGS);
103
- this.#closeEvent = null;
104
- this.#fallbackTimer = null;
105
- this.#leaveCompleted = false;
106
- this.animationElement = viewChild.required("animationElement", /* @ts-ignore */
107
- ...(ngDevMode ? [{ debugName: "animationElement" }] : /* istanbul ignore next */ []));
108
- this.componentOutlet = viewChild.required("componentOutlet", { ...(ngDevMode ? { debugName: "componentOutlet" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
109
- this.enterAnimationClasses = computed(() => this.#getAnimationConfig()?.enter ?? "", /* @ts-ignore */
110
- ...(ngDevMode ? [{ debugName: "enterAnimationClasses" }] : /* istanbul ignore next */ []));
111
- this.hostClasses = computed(() => {
112
- const wrapperClass = this.wrapperClass();
113
- return ["mona-popup-wrapper", "w-full", "h-full", wrapperClass].filter(Boolean).join(" ");
114
- }, /* @ts-ignore */
115
- ...(ngDevMode ? [{ debugName: "hostClasses" }] : /* istanbul ignore next */ []));
116
- this.leaveAnimationClasses = computed(() => this.#getAnimationConfig()?.leave ?? "", /* @ts-ignore */
117
- ...(ngDevMode ? [{ debugName: "leaveAnimationClasses" }] : /* istanbul ignore next */ []));
118
- this.templateRef = signal(null, /* @ts-ignore */
119
- ...(ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []));
120
- this.visible = signal(true, /* @ts-ignore */
121
- ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
122
- this.wrapperClass = signal(this.#popupSettings.popupWrapperClass instanceof Array
123
- ? this.#popupSettings.popupWrapperClass.join(" ")
124
- : (this.#popupSettings.popupWrapperClass ?? ""), /* @ts-ignore */
125
- ...(ngDevMode ? [{ debugName: "wrapperClass" }] : /* istanbul ignore next */ []));
126
- this.#popupReference.closeStart$.pipe(take(1), takeUntilDestroyed(this.#destroyRef)).subscribe(event => {
127
- this.#closeEvent = event;
128
- const animationElement = this.animationElement().nativeElement;
129
- this.visible.set(false);
130
- if (!this.leaveAnimationClasses()) {
131
- this.#completeClose();
132
- return;
133
- }
134
- this.#document.defaultView?.setTimeout(() => this.#startFallbackTimer(animationElement));
135
- });
136
- this.#destroyRef.onDestroy(() => this.#clearFallbackTimer());
137
- }
138
- attachContent(content, injector) {
139
- if (content instanceof TemplateRef) {
140
- this.templateRef.set(content);
141
- return null;
142
- }
143
- return this.componentOutlet().createComponent(content, { injector });
144
- }
145
- /**
146
- * Only completion events are observed. A cancellation is also raised when the enter animation is
147
- * replaced by the leave animation, so treating it as completion would dispose the overlay before
148
- * the leave animation had a chance to play. {@link #startFallbackTimer} covers genuine cancellations.
149
- */
150
- onNativeLeaveComplete(event) {
151
- if (event.target !== event.currentTarget) {
152
- return;
153
- }
154
- this.#completeClose();
155
- }
156
- #getAnimationConfig() {
157
- const config = this.#popupSettings.animation;
158
- if (config === false) {
159
- return null;
160
- }
161
- if (config == null || config === true) {
162
- return defaultPopupAnimation;
163
- }
164
- return {
165
- enter: config.enter ?? defaultPopupAnimation.enter,
166
- leave: config.leave ?? defaultPopupAnimation.leave
167
- };
168
- }
169
- #clearFallbackTimer() {
170
- if (this.#fallbackTimer == null) {
171
- return;
172
- }
173
- this.#document.defaultView?.clearTimeout(this.#fallbackTimer);
174
- this.#fallbackTimer = null;
175
- }
176
- #completeClose() {
177
- if (this.#leaveCompleted || this.#closeEvent == null) {
178
- return;
179
- }
180
- this.#leaveCompleted = true;
181
- this.#clearFallbackTimer();
182
- this.#popupReference.completeClose(this.#closeEvent);
183
- }
184
- #getLongestCssTime(style) {
185
- return Math.max(this.#getLongestCssTimeFromProperties(style.animationDuration, style.animationDelay), this.#getLongestCssTimeFromProperties(style.transitionDuration, style.transitionDelay));
186
- }
187
- #getLongestCssTimeFromProperties(durations, delays) {
188
- const durationValues = durations.split(",").map(duration => this.#parseCssTime(duration));
189
- const delayValues = delays.split(",").map(delay => this.#parseCssTime(delay));
190
- const valueCount = Math.max(durationValues.length, delayValues.length);
191
- if (valueCount === 0) {
192
- return 0;
193
- }
194
- return Math.max(...Array.from({ length: valueCount }, (_, index) => {
195
- const duration = durationValues[index % durationValues.length] ?? 0;
196
- const delay = delayValues[index % delayValues.length] ?? 0;
197
- return duration + delay;
198
- }));
199
- }
200
- #parseCssTime(value) {
201
- const trimmedValue = value.trim();
202
- if (!trimmedValue) {
203
- return 0;
204
- }
205
- if (trimmedValue.endsWith("ms")) {
206
- return Number.parseFloat(trimmedValue);
207
- }
208
- if (trimmedValue.endsWith("s")) {
209
- return Number.parseFloat(trimmedValue) * 1000;
210
- }
211
- return 0;
212
- }
213
- #startFallbackTimer(animationElement) {
214
- if (this.#leaveCompleted) {
215
- return;
216
- }
217
- const win = this.#document.defaultView;
218
- if (!win) {
219
- this.#completeClose();
220
- return;
221
- }
222
- const duration = this.#getLongestCssTime(win.getComputedStyle(animationElement));
223
- if (duration <= 0) {
224
- this.#completeClose();
225
- return;
226
- }
227
- this.#fallbackTimer = win.setTimeout(() => this.#completeClose(), duration + 50);
228
- }
229
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupWrapperComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
230
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: PopupWrapperComponent, isStandalone: true, selector: "mona-popup-wrapper", host: { properties: { "class": "hostClasses()" } }, viewQueries: [{ propertyName: "animationElement", first: true, predicate: ["animationElement"], descendants: true, isSignal: true }, { propertyName: "componentOutlet", first: true, predicate: ["componentOutlet"], descendants: true, read: ViewContainerRef, isSignal: true }], ngImport: i0, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n", styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }] }); }
231
- }
232
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupWrapperComponent, decorators: [{
233
- type: Component,
234
- args: [{ selector: "mona-popup-wrapper", imports: [NgTemplateOutlet], host: {
235
- "[class]": "hostClasses()"
236
- }, template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n", styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"] }]
237
- }], ctorParameters: () => [], propDecorators: { animationElement: [{ type: i0.ViewChild, args: ["animationElement", { isSignal: true }] }], componentOutlet: [{ type: i0.ViewChild, args: ["componentOutlet", { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
238
-
239
- /** Returned by `PopupService.create()` and emitted via `PopupComponent`'s `open` output. */
240
- class PopupRef {
241
- #options;
242
- constructor(options) {
243
- this.#options = options;
244
- }
245
- /**
246
- * Requests the popup to close.
247
- * @param result optional result passed to `beforeClose` and `closed` as the event's `result`
248
- * @param delay optional delay in milliseconds before the popup is removed, instead of waiting for the
249
- * leave animation
250
- * @returns `false` when the close was prevented or the popup is already closing, `true` otherwise.
251
- */
252
- close(result, delay) {
253
- return this.#options.close(result, delay);
254
- }
255
- /**
256
- * Closes the popup after a delay.
257
- * When the popup is closed, the overlay element is removed from the DOM instantly.
258
- * This causes the animation of the child elements to not play, therefore,
259
- * a delay is added to allow the animation to play.
260
- *
261
- * @see {@link https://github.com/angular/angular/issues/23302} for more information.
262
- * @param delay delay in milliseconds
263
- * @param result optional result to pass to the closed observable
264
- */
265
- closeWithDelay(delay = 100, result) {
266
- asapScheduler.schedule(() => this.close(result), delay);
267
- }
268
- /**
269
- * @description Emitted when the popup is about to close.
270
- * This event can be prevented. If it is prevented, the popup will not close.
271
- */
272
- get beforeClose() {
273
- return this.#options.beforeClose$;
274
- }
275
- /**
276
- * @description Emitted when the popup begins closing, before the leave animation completes.
277
- * Subscribe to this to react at the moment the close sequence starts — for example, to begin
278
- * coordinating a transition in the consuming component. The `closed` observable fires after
279
- * the leave animation finishes.
280
- */
281
- get closeStart() {
282
- return this.#options.closeStart$;
283
- }
284
- /**
285
- * @description Emitted when the popup is closed.
286
- * This event is emitted after the animation completes.
287
- * Preventing this event has no effect.
288
- */
289
- get closed() {
290
- return this.#options.closed$;
291
- }
292
- /**
293
- * @description Reference to the component hosted in the popup.
294
- * This is `null` if the popup does not contain a component.
295
- */
296
- get component() {
297
- return this.#options.component;
298
- }
299
- /**
300
- * @description Emitted when the popup is opened.
301
- */
302
- get opened() {
303
- return this.#options.opened$;
304
- }
305
- /**
306
- * @description Reference to the underlying CDK overlay.
307
- * Use this reference to manipulate the overlay directly, such as to set its size or position.
308
- * @see {@link https://material.angular.io/cdk/overlay/overview} for more information.
309
- * @example
310
- * ```ts
311
- * const overlayRef = popupRef.overlayRef;
312
- * overlayRef.updateSize({ width: '500px', height: '300px' });
313
- * ```
314
- */
315
- get overlayRef() {
316
- return this.#options.overlayRef;
317
- }
318
- /**
319
- * @description Returns the position pair of the popup's anchor element.
320
- * @example
321
- * ```ts
322
- * const positionChanges$ = popupRef.positionChanges;
323
- * positionChanges$.subscribe(pair => {
324
- * console.log(`Popup position changed to: ${pair.originX} ${pair.originY} -> ${pair.overlayX} ${pair.overlayY}`);
325
- * });
326
- * ```
327
- */
328
- get positionChanges() {
329
- return this.#options.positionChanges$;
330
- }
331
- }
332
-
333
- /**
334
- * @internal - used by the popup service. Do not use directly or export.
335
- */
336
- class PopupReference {
337
- #closed;
338
- #closing;
339
- constructor(overlayReference, preventClose) {
340
- this.overlayReference = overlayReference;
341
- this.preventClose = preventClose;
342
- this.#closed = false;
343
- this.#closing = false;
344
- this.beforeClosed$ = new Subject();
345
- this.closeStart$ = new Subject();
346
- this.closed$ = new Subject();
347
- this.opened$ = new ReplaySubject(1);
348
- this.positionChanges$ = new Subject();
349
- this.popupRef = new PopupRef(this);
350
- }
351
- /**
352
- * Emits {@link beforeClosed$} exactly once and, unless the close is prevented (either by the
353
- * `preventClose` callback passed to the popup or by a subscriber calling `preventDefault()`
354
- * on the event), proceeds to close the popup.
355
- * @returns `true` if the close proceeded, `false` if it was prevented.
356
- */
357
- close(result, delay) {
358
- if (this.#closing) {
359
- return false;
360
- }
361
- const beforeCloseEvent = result instanceof PopupCloseEvent
362
- ? result
363
- : new PopupCloseEvent({ result, via: PopupCloseSource.Programmatic });
364
- this.beforeClosed$.next(beforeCloseEvent);
365
- const prevented = this.preventClose
366
- ? this.preventClose(beforeCloseEvent) || beforeCloseEvent.isDefaultPrevented()
367
- : beforeCloseEvent.isDefaultPrevented();
368
- if (prevented) {
369
- return false;
370
- }
371
- this.#closing = true;
372
- this.closeStart$.next(beforeCloseEvent);
373
- if (delay != null) {
374
- if (delay > 0) {
375
- asyncScheduler.schedule(() => this.completeClose(beforeCloseEvent), delay);
376
- }
377
- else {
378
- this.completeClose(beforeCloseEvent);
379
- }
380
- }
381
- else if (this.wrapperComponentRef == null) {
382
- this.completeClose(beforeCloseEvent);
383
- }
384
- return true;
385
- }
386
- /**
387
- * Finishes a close that bypassed {@link close}: the overlay was detached or disposed directly. Nothing can
388
- * prevent it any more, so `beforeClose` is skipped; `closeStart` and `closed` still fire, in that order.
389
- */
390
- closeDetached() {
391
- if (this.#closed) {
392
- return;
393
- }
394
- const event = new PopupCloseEvent({ via: PopupCloseSource.Programmatic });
395
- if (!this.#closing) {
396
- this.#closing = true;
397
- this.closeStart$.next(event);
398
- }
399
- this.completeClose(event);
400
- }
401
- completeClose(event) {
402
- if (this.#closed) {
403
- return;
404
- }
405
- this.#closed = true;
406
- this.closed$.next(event);
407
- this.closed$.complete();
408
- this.positionChanges$.complete();
409
- this.overlayRef.dispose();
410
- }
411
- notifyOpen() {
412
- this.opened$.next();
413
- }
414
- get beforeClose$() {
415
- return this.beforeClosed$.asObservable();
416
- }
417
- get closeStart() {
418
- return this.closeStart$.asObservable();
419
- }
420
- get closed() {
421
- return this.closed$.asObservable();
422
- }
423
- get component() {
424
- return this.componentRef ?? null;
425
- }
426
- get opened() {
427
- return this.opened$;
428
- }
429
- get overlayRef() {
430
- return this.overlayReference;
431
- }
432
- }
433
-
68
+ var PopupWrapperComponent = class PopupWrapperComponent {
69
+ #destroyRef;
70
+ #document;
71
+ #popupReference;
72
+ #popupSettings;
73
+ #closeEvent;
74
+ #fallbackTimer;
75
+ #leaveCompleted;
76
+ constructor() {
77
+ this.#destroyRef = inject(DestroyRef);
78
+ this.#document = inject(DOCUMENT);
79
+ this.#popupReference = inject(POPUP_REFERENCE);
80
+ this.#popupSettings = inject(POPUP_SETTINGS);
81
+ this.#closeEvent = null;
82
+ this.#fallbackTimer = null;
83
+ this.#leaveCompleted = false;
84
+ this.animationElement = viewChild.required("animationElement", ...ngDevMode ? [{ debugName: "animationElement" }] : /* istanbul ignore next */ []);
85
+ this.componentOutlet = viewChild.required("componentOutlet", {
86
+ ...ngDevMode ? { debugName: "componentOutlet" } : /* istanbul ignore next */ {},
87
+ read: ViewContainerRef
88
+ });
89
+ this.enterAnimationClasses = computed(() => this.#getAnimationConfig()?.enter ?? "", ...ngDevMode ? [{ debugName: "enterAnimationClasses" }] : /* istanbul ignore next */ []);
90
+ this.hostClasses = computed(() => {
91
+ return [
92
+ "mona-popup-wrapper",
93
+ "w-full",
94
+ "h-full",
95
+ this.wrapperClass()
96
+ ].filter(Boolean).join(" ");
97
+ }, ...ngDevMode ? [{ debugName: "hostClasses" }] : /* istanbul ignore next */ []);
98
+ this.leaveAnimationClasses = computed(() => this.#getAnimationConfig()?.leave ?? "", ...ngDevMode ? [{ debugName: "leaveAnimationClasses" }] : /* istanbul ignore next */ []);
99
+ this.templateRef = signal(null, ...ngDevMode ? [{ debugName: "templateRef" }] : /* istanbul ignore next */ []);
100
+ this.visible = signal(true, ...ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []);
101
+ this.wrapperClass = signal(this.#popupSettings.popupWrapperClass instanceof Array ? this.#popupSettings.popupWrapperClass.join(" ") : this.#popupSettings.popupWrapperClass ?? "", ...ngDevMode ? [{ debugName: "wrapperClass" }] : /* istanbul ignore next */ []);
102
+ this.#popupReference.closeStart$.pipe(take(1), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
103
+ this.#closeEvent = event;
104
+ const animationElement = this.animationElement().nativeElement;
105
+ this.visible.set(false);
106
+ if (!this.leaveAnimationClasses()) {
107
+ this.#completeClose();
108
+ return;
109
+ }
110
+ this.#document.defaultView?.setTimeout(() => this.#startFallbackTimer(animationElement));
111
+ });
112
+ this.#destroyRef.onDestroy(() => this.#clearFallbackTimer());
113
+ }
114
+ attachContent(content, injector) {
115
+ if (content instanceof TemplateRef) {
116
+ this.templateRef.set(content);
117
+ return null;
118
+ }
119
+ return this.componentOutlet().createComponent(content, { injector });
120
+ }
121
+ onNativeLeaveComplete(event) {
122
+ if (event.target !== event.currentTarget) return;
123
+ this.#completeClose();
124
+ }
125
+ #getAnimationConfig() {
126
+ const config = this.#popupSettings.animation;
127
+ if (config === false) return null;
128
+ if (config == null || config === true) return defaultPopupAnimation;
129
+ return {
130
+ enter: config.enter ?? defaultPopupAnimation.enter,
131
+ leave: config.leave ?? defaultPopupAnimation.leave
132
+ };
133
+ }
134
+ #clearFallbackTimer() {
135
+ if (this.#fallbackTimer == null) return;
136
+ this.#document.defaultView?.clearTimeout(this.#fallbackTimer);
137
+ this.#fallbackTimer = null;
138
+ }
139
+ #completeClose() {
140
+ if (this.#leaveCompleted || this.#closeEvent == null) return;
141
+ this.#leaveCompleted = true;
142
+ this.#clearFallbackTimer();
143
+ this.#popupReference.completeClose(this.#closeEvent);
144
+ }
145
+ #getLongestCssTime(style) {
146
+ return Math.max(this.#getLongestCssTimeFromProperties(style.animationDuration, style.animationDelay), this.#getLongestCssTimeFromProperties(style.transitionDuration, style.transitionDelay));
147
+ }
148
+ #getLongestCssTimeFromProperties(durations, delays) {
149
+ const durationValues = durations.split(",").map((duration) => this.#parseCssTime(duration));
150
+ const delayValues = delays.split(",").map((delay) => this.#parseCssTime(delay));
151
+ const valueCount = Math.max(durationValues.length, delayValues.length);
152
+ if (valueCount === 0) return 0;
153
+ return Math.max(...Array.from({ length: valueCount }, (_, index) => {
154
+ return (durationValues[index % durationValues.length] ?? 0) + (delayValues[index % delayValues.length] ?? 0);
155
+ }));
156
+ }
157
+ #parseCssTime(value) {
158
+ const trimmedValue = value.trim();
159
+ if (!trimmedValue) return 0;
160
+ if (trimmedValue.endsWith("ms")) return Number.parseFloat(trimmedValue);
161
+ if (trimmedValue.endsWith("s")) return Number.parseFloat(trimmedValue) * 1e3;
162
+ return 0;
163
+ }
164
+ #startFallbackTimer(animationElement) {
165
+ if (this.#leaveCompleted) return;
166
+ const win = this.#document.defaultView;
167
+ if (!win) {
168
+ this.#completeClose();
169
+ return;
170
+ }
171
+ const duration = this.#getLongestCssTime(win.getComputedStyle(animationElement));
172
+ if (duration <= 0) {
173
+ this.#completeClose();
174
+ return;
175
+ }
176
+ this.#fallbackTimer = win.setTimeout(() => this.#completeClose(), duration + 50);
177
+ }
178
+ static {
179
+ this.ɵfac = i0.ɵɵngDeclareFactory({
180
+ minVersion: "12.0.0",
181
+ version: "22.2.6",
182
+ ngImport: i0,
183
+ type: PopupWrapperComponent,
184
+ deps: [],
185
+ target: i0.ɵɵFactoryTarget.Component
186
+ });
187
+ }
188
+ static {
189
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
190
+ minVersion: "17.0.0",
191
+ version: "22.2.6",
192
+ type: PopupWrapperComponent,
193
+ isStandalone: true,
194
+ selector: "mona-popup-wrapper",
195
+ host: { properties: { "class": "hostClasses()" } },
196
+ viewQueries: [{
197
+ propertyName: "animationElement",
198
+ first: true,
199
+ predicate: ["animationElement"],
200
+ descendants: true,
201
+ isSignal: true
202
+ }, {
203
+ propertyName: "componentOutlet",
204
+ first: true,
205
+ predicate: ["componentOutlet"],
206
+ descendants: true,
207
+ read: ViewContainerRef,
208
+ isSignal: true
209
+ }],
210
+ ngImport: i0,
211
+ template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n",
212
+ styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"],
213
+ dependencies: [{
214
+ kind: "directive",
215
+ type: NgTemplateOutlet,
216
+ selector: "[ngTemplateOutlet]",
217
+ inputs: [
218
+ "ngTemplateOutletContext",
219
+ "ngTemplateOutlet",
220
+ "ngTemplateOutletInjector"
221
+ ]
222
+ }]
223
+ });
224
+ }
225
+ };
226
+ i0.ɵɵngDeclareClassMetadata({
227
+ minVersion: "12.0.0",
228
+ version: "22.2.6",
229
+ ngImport: i0,
230
+ type: PopupWrapperComponent,
231
+ decorators: [{
232
+ type: Component,
233
+ args: [{
234
+ selector: "mona-popup-wrapper",
235
+ imports: [NgTemplateOutlet],
236
+ host: { "[class]": "hostClasses()" },
237
+ template: "@if (visible()) {\n <div\n #animationElement\n class=\"w-full h-full origin-center\"\n [animate.enter]=\"enterAnimationClasses()\"\n [animate.leave]=\"leaveAnimationClasses()\"\n (animationend)=\"onNativeLeaveComplete($event)\"\n (transitionend)=\"onNativeLeaveComplete($event)\">\n @if (templateRef()) {\n <ng-container [ngTemplateOutlet]=\"templateRef()\"></ng-container>\n }\n <ng-container #componentOutlet></ng-container>\n </div>\n}\n",
238
+ styles: [":host{display:block}:host(.mona-popup-constrain-height){min-height:0;max-height:inherit;overflow:clip}:host(.mona-popup-constrain-height)>div{display:flex;min-height:0;max-height:inherit;overflow:clip}.mona-popup-enter{animation:mona-popup-scale-in .15s cubic-bezier(.4,0,.2,1)}.mona-popup-leave{animation:mona-popup-scale-out .15s cubic-bezier(.4,0,.2,1)}.mona-dropdown-popup-enter{animation:mona-dropdown-popup-scale-in .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-dropdown-popup-leave{animation:mona-dropdown-popup-scale-out .15s cubic-bezier(.4,0,.2,1);transform-origin:top center}.mona-popup-fade-enter{animation:mona-popup-fade-in 50ms ease-in}.mona-popup-fade-leave{animation:mona-popup-fade-out .15s ease-out}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-fill-mode:both;backface-visibility:hidden;will-change:transform}.mona-popup-slide-from-right-enter,.mona-popup-slide-from-left-enter,.mona-popup-slide-from-top-enter,.mona-popup-slide-from-bottom-enter{animation-duration:.32s;animation-timing-function:cubic-bezier(.25,.46,.45,.94)}.mona-popup-slide-to-right-leave,.mona-popup-slide-to-left-leave,.mona-popup-slide-to-top-leave,.mona-popup-slide-to-bottom-leave{animation-duration:.24s;animation-timing-function:cubic-bezier(.4,0,1,1)}.mona-popup-slide-from-right-enter{animation-name:mona-popup-slide-from-right}.mona-popup-slide-to-right-leave{animation-name:mona-popup-slide-to-right}.mona-popup-slide-from-left-enter{animation-name:mona-popup-slide-from-left}.mona-popup-slide-to-left-leave{animation-name:mona-popup-slide-to-left}.mona-popup-slide-from-top-enter{animation-name:mona-popup-slide-from-top}.mona-popup-slide-to-top-leave{animation-name:mona-popup-slide-to-top}.mona-popup-slide-from-bottom-enter{animation-name:mona-popup-slide-from-bottom}.mona-popup-slide-to-bottom-leave{animation-name:mona-popup-slide-to-bottom}@keyframes mona-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-dropdown-popup-scale-in{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes mona-dropdown-popup-scale-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}@keyframes mona-popup-fade-in{0%{opacity:0}to{opacity:1}}@keyframes mona-popup-fade-out{0%{opacity:1}to{opacity:0}}@keyframes mona-popup-slide-from-right{0%{transform:translate(100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-right{0%{transform:translate(0)}to{transform:translate(100%)}}@keyframes mona-popup-slide-from-left{0%{transform:translate(-100%)}to{transform:translate(0)}}@keyframes mona-popup-slide-to-left{0%{transform:translate(0)}to{transform:translate(-100%)}}@keyframes mona-popup-slide-from-top{0%{transform:translateY(-100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-top{0%{transform:translateY(0)}to{transform:translateY(-100%)}}@keyframes mona-popup-slide-from-bottom{0%{transform:translateY(100%)}to{transform:translateY(0)}}@keyframes mona-popup-slide-to-bottom{0%{transform:translateY(0)}to{transform:translateY(100%)}}@media(prefers-reduced-motion:reduce){.mona-popup-enter,.mona-popup-leave,.mona-dropdown-popup-enter,.mona-dropdown-popup-leave,.mona-popup-fade-enter,.mona-popup-fade-leave,.mona-popup-slide-from-right-enter,.mona-popup-slide-to-right-leave,.mona-popup-slide-from-left-enter,.mona-popup-slide-to-left-leave,.mona-popup-slide-from-top-enter,.mona-popup-slide-to-top-leave,.mona-popup-slide-from-bottom-enter,.mona-popup-slide-to-bottom-leave{animation-duration:1ms}}\n"]
239
+ }]
240
+ }],
241
+ ctorParameters: () => [],
242
+ propDecorators: {
243
+ animationElement: [{
244
+ type: i0.ViewChild,
245
+ args: ["animationElement", { isSignal: true }]
246
+ }],
247
+ componentOutlet: [{
248
+ type: i0.ViewChild,
249
+ args: ["componentOutlet", {
250
+ read: ViewContainerRef,
251
+ isSignal: true
252
+ }]
253
+ }]
254
+ }
255
+ });
256
+ var PopupRef = class {
257
+ #options;
258
+ constructor(options) {
259
+ this.#options = options;
260
+ }
261
+ close(result, delay) {
262
+ return this.#options.close(result, delay);
263
+ }
264
+ closeWithDelay(delay = 100, result) {
265
+ asapScheduler.schedule(() => this.close(result), delay);
266
+ }
267
+ get beforeClose() {
268
+ return this.#options.beforeClose$;
269
+ }
270
+ get closeStart() {
271
+ return this.#options.closeStart$;
272
+ }
273
+ get closed() {
274
+ return this.#options.closed$;
275
+ }
276
+ get component() {
277
+ return this.#options.component;
278
+ }
279
+ get opened() {
280
+ return this.#options.opened$;
281
+ }
282
+ get overlayRef() {
283
+ return this.#options.overlayRef;
284
+ }
285
+ get positionChanges() {
286
+ return this.#options.positionChanges$;
287
+ }
288
+ };
289
+ var PopupReference = class {
290
+ #closed;
291
+ #closing;
292
+ constructor(overlayReference, preventClose) {
293
+ this.overlayReference = overlayReference;
294
+ this.preventClose = preventClose;
295
+ this.#closed = false;
296
+ this.#closing = false;
297
+ this.beforeClosed$ = new Subject();
298
+ this.closeStart$ = new Subject();
299
+ this.closed$ = new Subject();
300
+ this.opened$ = new ReplaySubject(1);
301
+ this.positionChanges$ = new Subject();
302
+ this.popupRef = new PopupRef(this);
303
+ }
304
+ close(result, delay) {
305
+ if (this.#closing) return false;
306
+ const beforeCloseEvent = result instanceof PopupCloseEvent ? result : new PopupCloseEvent({
307
+ result,
308
+ via: PopupCloseSource.Programmatic
309
+ });
310
+ this.beforeClosed$.next(beforeCloseEvent);
311
+ if (this.preventClose ? this.preventClose(beforeCloseEvent) || beforeCloseEvent.isDefaultPrevented() : beforeCloseEvent.isDefaultPrevented()) return false;
312
+ this.#closing = true;
313
+ this.closeStart$.next(beforeCloseEvent);
314
+ if (delay != null) {
315
+ if (delay > 0) asyncScheduler.schedule(() => this.completeClose(beforeCloseEvent), delay);
316
+ else this.completeClose(beforeCloseEvent);
317
+ } else if (this.wrapperComponentRef == null) this.completeClose(beforeCloseEvent);
318
+ return true;
319
+ }
320
+ closeDetached() {
321
+ if (this.#closed) return;
322
+ const event = new PopupCloseEvent({ via: PopupCloseSource.Programmatic });
323
+ if (!this.#closing) {
324
+ this.#closing = true;
325
+ this.closeStart$.next(event);
326
+ }
327
+ this.completeClose(event);
328
+ }
329
+ completeClose(event) {
330
+ if (this.#closed) return;
331
+ this.#closed = true;
332
+ this.closed$.next(event);
333
+ this.closed$.complete();
334
+ this.positionChanges$.complete();
335
+ this.overlayRef.dispose();
336
+ }
337
+ notifyOpen() {
338
+ this.opened$.next();
339
+ }
340
+ get beforeClose$() {
341
+ return this.beforeClosed$.asObservable();
342
+ }
343
+ get closeStart() {
344
+ return this.closeStart$.asObservable();
345
+ }
346
+ get closed() {
347
+ return this.closed$.asObservable();
348
+ }
349
+ get component() {
350
+ return this.componentRef ?? null;
351
+ }
352
+ get opened() {
353
+ return this.opened$;
354
+ }
355
+ get overlayRef() {
356
+ return this.overlayReference;
357
+ }
358
+ };
434
359
  const connectionPosition = (anchorConnectionPoint, popupConnectionPoint) => {
435
- const originMap = {
436
- topleft: { originX: "start", originY: "top" },
437
- topcenter: { originX: "center", originY: "top" },
438
- topright: { originX: "end", originY: "top" },
439
- centerleft: { originX: "start", originY: "center" },
440
- center: { originX: "center", originY: "center" },
441
- centerright: { originX: "end", originY: "center" },
442
- bottomleft: { originX: "start", originY: "bottom" },
443
- bottomcenter: { originX: "center", originY: "bottom" },
444
- bottomright: { originX: "end", originY: "bottom" }
445
- };
446
- const overlayMap = {
447
- topleft: { overlayX: "start", overlayY: "top" },
448
- topcenter: { overlayX: "center", overlayY: "top" },
449
- topright: { overlayX: "end", overlayY: "top" },
450
- centerleft: { overlayX: "start", overlayY: "center" },
451
- center: { overlayX: "center", overlayY: "center" },
452
- centerright: { overlayX: "end", overlayY: "center" },
453
- bottomleft: { overlayX: "start", overlayY: "bottom" },
454
- bottomcenter: { overlayX: "center", overlayY: "bottom" },
455
- bottomright: { overlayX: "end", overlayY: "bottom" }
456
- };
457
- const primaryPosition = {
458
- ...originMap[anchorConnectionPoint],
459
- ...overlayMap[popupConnectionPoint]
460
- };
461
- const fallbackPositions = generateFallbackPositions(primaryPosition);
462
- return [primaryPosition, ...fallbackPositions];
360
+ const originMap = {
361
+ topleft: {
362
+ originX: "start",
363
+ originY: "top"
364
+ },
365
+ topcenter: {
366
+ originX: "center",
367
+ originY: "top"
368
+ },
369
+ topright: {
370
+ originX: "end",
371
+ originY: "top"
372
+ },
373
+ centerleft: {
374
+ originX: "start",
375
+ originY: "center"
376
+ },
377
+ center: {
378
+ originX: "center",
379
+ originY: "center"
380
+ },
381
+ centerright: {
382
+ originX: "end",
383
+ originY: "center"
384
+ },
385
+ bottomleft: {
386
+ originX: "start",
387
+ originY: "bottom"
388
+ },
389
+ bottomcenter: {
390
+ originX: "center",
391
+ originY: "bottom"
392
+ },
393
+ bottomright: {
394
+ originX: "end",
395
+ originY: "bottom"
396
+ }
397
+ };
398
+ const overlayMap = {
399
+ topleft: {
400
+ overlayX: "start",
401
+ overlayY: "top"
402
+ },
403
+ topcenter: {
404
+ overlayX: "center",
405
+ overlayY: "top"
406
+ },
407
+ topright: {
408
+ overlayX: "end",
409
+ overlayY: "top"
410
+ },
411
+ centerleft: {
412
+ overlayX: "start",
413
+ overlayY: "center"
414
+ },
415
+ center: {
416
+ overlayX: "center",
417
+ overlayY: "center"
418
+ },
419
+ centerright: {
420
+ overlayX: "end",
421
+ overlayY: "center"
422
+ },
423
+ bottomleft: {
424
+ overlayX: "start",
425
+ overlayY: "bottom"
426
+ },
427
+ bottomcenter: {
428
+ overlayX: "center",
429
+ overlayY: "bottom"
430
+ },
431
+ bottomright: {
432
+ overlayX: "end",
433
+ overlayY: "bottom"
434
+ }
435
+ };
436
+ const primaryPosition = {
437
+ ...originMap[anchorConnectionPoint],
438
+ ...overlayMap[popupConnectionPoint]
439
+ };
440
+ return [primaryPosition, ...generateFallbackPositions(primaryPosition)];
463
441
  };
464
- /**
465
- * Generate fallback positions for the given primary position.
466
- * This function is mostly AI-generated.
467
- * @param primaryPosition The primary position to generate fallbacks for.
468
- */
469
442
  const generateFallbackPositions = (primaryPosition) => {
470
- const { originX, originY, overlayX, overlayY } = primaryPosition;
471
- const fallbacks = [];
472
- // 1. Keep the same X, try bottom.
473
- if (originY !== "bottom" && overlayY !== "bottom") {
474
- if (originY === "top") {
475
- fallbacks.push({ originX, originY: "bottom", overlayX, overlayY: "bottom" });
476
- }
477
- else {
478
- //originY is center
479
- if (overlayY === "top") {
480
- fallbacks.push({ originX, originY: "center", overlayX, overlayY: "bottom" });
481
- }
482
- }
483
- }
484
- // 2. Keep same Y, try right
485
- if (originX !== "end" && overlayX !== "end") {
486
- if (originX === "start") {
487
- fallbacks.push({ originX: "end", originY, overlayX: "end", overlayY });
488
- }
489
- else {
490
- // originX is center
491
- if (overlayX === "start") {
492
- fallbacks.push({ originX: "center", originY, overlayX: "end", overlayY });
493
- }
494
- }
495
- }
496
- // 3. Keep X and flip Y to the opposite if possible.
497
- if (!fallbacks.find(f => f.originX === originX && f.overlayX === overlayX)) {
498
- if (originY === "top" && overlayY === "top") {
499
- fallbacks.push({ originX, originY: "bottom", overlayX, overlayY: "bottom" });
500
- }
501
- else if (originY === "bottom" && overlayY === "bottom") {
502
- fallbacks.push({ originX, originY: "top", overlayX, overlayY: "top" });
503
- }
504
- else if (originY === "top" && overlayY === "bottom") {
505
- fallbacks.push({ originX, originY: "bottom", overlayX, overlayY: "top" });
506
- }
507
- else if (originY === "bottom" && overlayY === "top") {
508
- fallbacks.push({ originX, originY: "top", overlayX, overlayY: "bottom" });
509
- }
510
- else {
511
- //originY === 'center'
512
- if (overlayY === "top") {
513
- fallbacks.push({ originX, originY: "center", overlayX, overlayY: "bottom" });
514
- }
515
- else if (overlayY === "bottom") {
516
- fallbacks.push({ originX, originY: "center", overlayX, overlayY: "top" });
517
- }
518
- }
519
- }
520
- // 4. Keep Y and flip X to the opposite if possible
521
- if (!fallbacks.find(f => f.originY === originY && f.overlayY === overlayY)) {
522
- if (originX === "start" && overlayX === "start") {
523
- fallbacks.push({ originX: "end", originY, overlayX: "end", overlayY });
524
- }
525
- else if (originX === "end" && overlayX === "end") {
526
- fallbacks.push({ originX: "start", originY, overlayX: "start", overlayY });
527
- }
528
- else if (originX === "start" && overlayX === "end") {
529
- fallbacks.push({ originX: "end", originY, overlayX: "start", overlayY });
530
- }
531
- else if (originX === "end" && overlayX === "start") {
532
- fallbacks.push({ originX: "start", originY, overlayX: "end", overlayY });
533
- }
534
- else {
535
- if (overlayX === "start") {
536
- fallbacks.push({ originX: "center", originY, overlayX: "end", overlayY });
537
- }
538
- else if (overlayX === "end") {
539
- fallbacks.push({ originX: "center", originY, overlayX: "start", overlayY });
540
- }
541
- }
542
- }
543
- // 5. Diagonal Flips
544
- if (originX === "start" && originY === "top" && overlayX === "end" && overlayY === "bottom") {
545
- fallbacks.push({ originX: "end", originY: "bottom", overlayX: "start", overlayY: "top" });
546
- }
547
- else if (originX === "end" && originY === "bottom" && overlayX === "start" && overlayY === "top") {
548
- fallbacks.push({ originX: "start", originY: "top", overlayX: "end", overlayY: "bottom" });
549
- }
550
- else if (originX === "start" && originY === "bottom" && overlayX === "end" && overlayY === "top") {
551
- fallbacks.push({ originX: "end", originY: "top", overlayX: "start", overlayY: "bottom" });
552
- }
553
- else if (originX === "end" && originY === "top" && overlayX === "start" && overlayY === "bottom") {
554
- fallbacks.push({ originX: "start", originY: "bottom", overlayX: "end", overlayY: "top" });
555
- }
556
- // 6. Complete mirroring: flip both the anchor corner and the popup corner on both axes, so the popup lands on
557
- // the opposite side and alignment of the anchor. Flipping only the anchor corner and copying it onto the popup
558
- // corner, as this used to do, placed the popup over the anchor.
559
- const mirrored = {
560
- originX: flipX(originX),
561
- originY: flipY(originY),
562
- overlayX: flipX(overlayX),
563
- overlayY: flipY(overlayY)
564
- };
565
- const isPrimary = mirrored.originX === originX &&
566
- mirrored.originY === originY &&
567
- mirrored.overlayX === overlayX &&
568
- mirrored.overlayY === overlayY;
569
- const isListed = fallbacks.some(f => f.originX === mirrored.originX &&
570
- f.originY === mirrored.originY &&
571
- f.overlayX === mirrored.overlayX &&
572
- f.overlayY === mirrored.overlayY);
573
- if (!isPrimary && !isListed) {
574
- fallbacks.push(mirrored);
575
- }
576
- return fallbacks;
443
+ const { originX, originY, overlayX, overlayY } = primaryPosition;
444
+ const fallbacks = [];
445
+ if (originY !== "bottom" && overlayY !== "bottom") {
446
+ if (originY === "top") fallbacks.push({
447
+ originX,
448
+ originY: "bottom",
449
+ overlayX,
450
+ overlayY: "bottom"
451
+ });
452
+ else if (overlayY === "top") fallbacks.push({
453
+ originX,
454
+ originY: "center",
455
+ overlayX,
456
+ overlayY: "bottom"
457
+ });
458
+ }
459
+ if (originX !== "end" && overlayX !== "end") {
460
+ if (originX === "start") fallbacks.push({
461
+ originX: "end",
462
+ originY,
463
+ overlayX: "end",
464
+ overlayY
465
+ });
466
+ else if (overlayX === "start") fallbacks.push({
467
+ originX: "center",
468
+ originY,
469
+ overlayX: "end",
470
+ overlayY
471
+ });
472
+ }
473
+ if (!fallbacks.find((f) => f.originX === originX && f.overlayX === overlayX)) {
474
+ if (originY === "top" && overlayY === "top") fallbacks.push({
475
+ originX,
476
+ originY: "bottom",
477
+ overlayX,
478
+ overlayY: "bottom"
479
+ });
480
+ else if (originY === "bottom" && overlayY === "bottom") fallbacks.push({
481
+ originX,
482
+ originY: "top",
483
+ overlayX,
484
+ overlayY: "top"
485
+ });
486
+ else if (originY === "top" && overlayY === "bottom") fallbacks.push({
487
+ originX,
488
+ originY: "bottom",
489
+ overlayX,
490
+ overlayY: "top"
491
+ });
492
+ else if (originY === "bottom" && overlayY === "top") fallbacks.push({
493
+ originX,
494
+ originY: "top",
495
+ overlayX,
496
+ overlayY: "bottom"
497
+ });
498
+ else if (overlayY === "top") fallbacks.push({
499
+ originX,
500
+ originY: "center",
501
+ overlayX,
502
+ overlayY: "bottom"
503
+ });
504
+ else if (overlayY === "bottom") fallbacks.push({
505
+ originX,
506
+ originY: "center",
507
+ overlayX,
508
+ overlayY: "top"
509
+ });
510
+ }
511
+ if (!fallbacks.find((f) => f.originY === originY && f.overlayY === overlayY)) {
512
+ if (originX === "start" && overlayX === "start") fallbacks.push({
513
+ originX: "end",
514
+ originY,
515
+ overlayX: "end",
516
+ overlayY
517
+ });
518
+ else if (originX === "end" && overlayX === "end") fallbacks.push({
519
+ originX: "start",
520
+ originY,
521
+ overlayX: "start",
522
+ overlayY
523
+ });
524
+ else if (originX === "start" && overlayX === "end") fallbacks.push({
525
+ originX: "end",
526
+ originY,
527
+ overlayX: "start",
528
+ overlayY
529
+ });
530
+ else if (originX === "end" && overlayX === "start") fallbacks.push({
531
+ originX: "start",
532
+ originY,
533
+ overlayX: "end",
534
+ overlayY
535
+ });
536
+ else if (overlayX === "start") fallbacks.push({
537
+ originX: "center",
538
+ originY,
539
+ overlayX: "end",
540
+ overlayY
541
+ });
542
+ else if (overlayX === "end") fallbacks.push({
543
+ originX: "center",
544
+ originY,
545
+ overlayX: "start",
546
+ overlayY
547
+ });
548
+ }
549
+ if (originX === "start" && originY === "top" && overlayX === "end" && overlayY === "bottom") fallbacks.push({
550
+ originX: "end",
551
+ originY: "bottom",
552
+ overlayX: "start",
553
+ overlayY: "top"
554
+ });
555
+ else if (originX === "end" && originY === "bottom" && overlayX === "start" && overlayY === "top") fallbacks.push({
556
+ originX: "start",
557
+ originY: "top",
558
+ overlayX: "end",
559
+ overlayY: "bottom"
560
+ });
561
+ else if (originX === "start" && originY === "bottom" && overlayX === "end" && overlayY === "top") fallbacks.push({
562
+ originX: "end",
563
+ originY: "top",
564
+ overlayX: "start",
565
+ overlayY: "bottom"
566
+ });
567
+ else if (originX === "end" && originY === "top" && overlayX === "start" && overlayY === "bottom") fallbacks.push({
568
+ originX: "start",
569
+ originY: "bottom",
570
+ overlayX: "end",
571
+ overlayY: "top"
572
+ });
573
+ const mirrored = {
574
+ originX: flipX(originX),
575
+ originY: flipY(originY),
576
+ overlayX: flipX(overlayX),
577
+ overlayY: flipY(overlayY)
578
+ };
579
+ const isPrimary = mirrored.originX === originX && mirrored.originY === originY && mirrored.overlayX === overlayX && mirrored.overlayY === overlayY;
580
+ const isListed = fallbacks.some((f) => f.originX === mirrored.originX && f.originY === mirrored.originY && f.overlayX === mirrored.overlayX && f.overlayY === mirrored.overlayY);
581
+ if (!isPrimary && !isListed) fallbacks.push(mirrored);
582
+ return fallbacks;
577
583
  };
578
- const flipX = (value) => (value === "start" ? "end" : value === "end" ? "start" : value);
579
- const flipY = (value) => (value === "top" ? "bottom" : value === "bottom" ? "top" : value);
580
-
581
- class PopupService {
582
- #destroyRef = inject(DestroyRef);
583
- #directionality = inject(Directionality, { optional: true });
584
- #document = inject(DOCUMENT);
585
- #i18n = inject(MonaI18nService, { optional: true });
586
- #injector = inject(Injector);
587
- /** Open popups in the order they were opened; the last one is on top. */
588
- #openPopups = [];
589
- #outsideEventsToClose = ["click", "mousedown", "dblclick", "contextmenu", "auxclick"];
590
- #overlay = inject(Overlay);
591
- #scrollDispatcher = inject(ScrollDispatcher);
592
- #escapeSubscription = null;
593
- #escapeTarget = null;
594
- /**
595
- * Opens a popup and returns its `PopupRef`. If `settings.anchor` is a CSS selector string, creates a
596
- * hover-triggered popup for every matching element (see Multi-element popups); otherwise creates a single popup
597
- * attached to the given element, `ElementRef`, or point.
598
- */
599
- create(settings) {
600
- if (typeof settings.anchor === "string") {
601
- return this.createMultiElementPopup(settings);
602
- }
603
- return this.createSingleElementPopup(settings);
604
- }
605
- attachContent(settings, popupReference, overlayRef, injector) {
606
- const portal = new ComponentPortal(PopupWrapperComponent, null, injector);
607
- const wrapperComponentRef = overlayRef.attach(portal);
608
- popupReference.wrapperComponentRef = wrapperComponentRef;
609
- wrapperComponentRef.changeDetectorRef.detectChanges();
610
- popupReference.componentRef =
611
- wrapperComponentRef.instance.attachContent(settings.content, injector) ?? undefined;
612
- wrapperComponentRef.changeDetectorRef.detectChanges();
613
- return wrapperComponentRef.location.nativeElement;
614
- }
615
- buildPanelClass(popupClass) {
616
- if (!popupClass) {
617
- return "mona-popup-content";
618
- }
619
- return ["mona-popup-content"].concat(popupClass);
620
- }
621
- /**
622
- * With `"auto"` (also the default), remembers the focused element when it is the anchor or inside it, such
623
- * as the button inside a host component or the input inside a date picker, and returns focus to that element.
624
- */
625
- captureOriginalFocus(settings) {
626
- const restoreFocus = settings.restoreFocus ?? "auto";
627
- if (typeof settings.anchor === "string" || restoreFocus === false) {
628
- return null;
629
- }
630
- const activeElement = this.#document.activeElement;
631
- if (!(activeElement instanceof HTMLElement)) {
632
- return null;
633
- }
634
- if (restoreFocus === "auto") {
635
- const anchorElement = this.getAnchorElement(settings.anchor);
636
- return anchorElement?.contains(activeElement) ? activeElement : null;
637
- }
638
- return this.getAnchorElement(settings.anchor);
639
- }
640
- createInjector(settings, popupReference) {
641
- return Injector.create({
642
- parent: settings.injector ?? this.#injector,
643
- providers: [
644
- { provide: PopupRef, useFactory: () => popupReference.popupRef },
645
- { provide: PopupDataInjectionToken, useValue: settings.data },
646
- { provide: POPUP_REFERENCE, useValue: popupReference },
647
- { provide: POPUP_SETTINGS, useValue: settings },
648
- ...(settings.providers ?? [])
649
- ]
650
- });
651
- }
652
- createMultiElementPopup(settings) {
653
- const selector = settings.anchor;
654
- // Create a virtual PopupRef that manages multi-element interactions
655
- const virtualOverlayRef = this.#overlay.create({ hasBackdrop: false });
656
- const virtualPopupReference = new PopupReference(virtualOverlayRef);
657
- // Closing the returned ref stops the delegation and closes the popup currently showing.
658
- const delegation = this.setupInternalEventDelegation(selector, settings);
659
- virtualPopupReference.popupRef.closed.pipe(take(1)).subscribe(() => delegation.unsubscribe());
660
- return virtualPopupReference.popupRef;
661
- }
662
- createOverlay(settings) {
663
- const positionStrategy = this.createPositionStrategy(settings);
664
- const panelClass = this.buildPanelClass(settings.popupClass);
665
- const anchorElement = settings.anchor instanceof ElementRef
666
- ? settings.anchor.nativeElement
667
- : settings.anchor instanceof HTMLElement
668
- ? settings.anchor
669
- : null;
670
- const direction = resolveComponentDirection(anchorElement, this.#directionality);
671
- const overlayRef = this.#overlay.create(new OverlayConfig({
672
- positionStrategy,
673
- hasBackdrop: settings.hasBackdrop ?? false,
674
- height: settings.height,
675
- maxHeight: settings.maxHeight,
676
- maxWidth: settings.maxWidth,
677
- minHeight: settings.minHeight,
678
- minWidth: settings.minWidth,
679
- width: settings.width,
680
- panelClass,
681
- backdropClass: settings.backdropClass ?? "transparent",
682
- direction,
683
- scrollStrategy: settings.blockScroll ? this.#overlay.scrollStrategies.block() : undefined
684
- }));
685
- const lang = resolvePopupLanguage(anchorElement, this.#i18n?.localeId());
686
- if (lang) {
687
- overlayRef.overlayElement.setAttribute("lang", lang);
688
- }
689
- return overlayRef;
690
- }
691
- createPositionStrategy(settings) {
692
- if (settings.positionStrategy === "global") {
693
- return this.#overlay.position().global();
694
- }
695
- const resolvedAnchor = this.resolveAnchor(settings.anchor);
696
- const position = settings.positions?.length
697
- ? settings.positions
698
- : this.getPosition(settings.anchorConnectionPoint, settings.popupConnectionPoint);
699
- const strategy = this.#overlay
700
- .position()
701
- .flexibleConnectedTo(resolvedAnchor)
702
- .withPositions(position)
703
- .withDefaultOffsetX(settings.offset?.horizontal ?? 0)
704
- .withDefaultOffsetY(settings.offset?.vertical ?? 0)
705
- .withPush(settings.withPush ?? true);
706
- if (settings.withScrollTracking ?? true) {
707
- const scrollableContainers = this.getScrollableContainers(resolvedAnchor);
708
- strategy.withScrollableContainers(scrollableContainers);
709
- }
710
- return strategy;
711
- }
712
- createScrollDispatcherTarget(element) {
713
- const elementRef = new ElementRef(element);
714
- return {
715
- elementScrolled: () => fromEvent(element, "scroll", { passive: true }),
716
- getElementRef: () => elementRef
717
- };
718
- }
719
- createSingleElementPopup(settings) {
720
- const overlayRef = this.createOverlay(settings);
721
- const popupReference = new PopupReference(overlayRef, settings.preventClose);
722
- const originallyFocusedElement = this.captureOriginalFocus(settings);
723
- const injector = this.createInjector(settings, popupReference);
724
- popupReference.notifyOpen();
725
- this.attachContent(settings, popupReference, overlayRef, injector);
726
- const subscription = this.setupCloseSubscriptions(settings, popupReference, overlayRef);
727
- this.setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement);
728
- this.setupBackdropFadeOut(settings, popupReference, overlayRef);
729
- if (settings.closeOnScroll) {
730
- this.setupScrollClosing(settings, popupReference, overlayRef);
731
- }
732
- this.setupScrollTracking(settings, overlayRef, popupReference);
733
- this.registerOpenPopup(settings, popupReference);
734
- this.setupDetachTracking(overlayRef, popupReference);
735
- this.setupPositionChangeTracking(settings, overlayRef, popupReference);
736
- this.setupDirectionTracking(settings, overlayRef, popupReference);
737
- return popupReference.popupRef;
738
- }
739
- getAnchorElement(anchor) {
740
- if (anchor instanceof HTMLElement) {
741
- return anchor;
742
- }
743
- if (typeof anchor === "object" && "nativeElement" in anchor && anchor.nativeElement instanceof HTMLElement) {
744
- return anchor.nativeElement;
745
- }
746
- return null;
747
- }
748
- getPosition(anchorConnectionPoint, popupConnectionPoint) {
749
- const anchorPoint = anchorConnectionPoint ?? "bottomleft";
750
- const popupPoint = popupConnectionPoint ?? "topleft";
751
- return connectionPosition(anchorPoint, popupPoint);
752
- }
753
- getScrollableAncestorElements(anchorElement) {
754
- const scrollables = [];
755
- let element = anchorElement.parentElement;
756
- while (element) {
757
- if (this.isScrollableElement(element)) {
758
- scrollables.push(element);
759
- }
760
- element = element.parentElement;
761
- }
762
- return scrollables;
763
- }
764
- getScrollableContainers(anchor) {
765
- const anchorElement = this.getAnchorElement(anchor);
766
- if (!anchorElement) {
767
- return [];
768
- }
769
- const scrollablesByElement = new Map();
770
- const addScrollable = (scrollable) => {
771
- scrollablesByElement.set(scrollable.getElementRef().nativeElement, scrollable);
772
- };
773
- this.#scrollDispatcher
774
- .getAncestorScrollContainers(anchorElement)
775
- .forEach(scrollable => addScrollable(scrollable));
776
- this.getScrollableAncestorElements(anchorElement)
777
- .map(element => this.createScrollDispatcherTarget(element))
778
- .forEach(scrollable => addScrollable(scrollable));
779
- return Array.from(scrollablesByElement.values());
780
- }
781
- getTopmostOpenPopup() {
782
- for (let index = this.#openPopups.length - 1; index >= 0; index--) {
783
- const popup = this.#openPopups[index];
784
- if (popup.reference.overlayRef.hasAttached()) {
785
- return popup;
786
- }
787
- }
788
- return null;
789
- }
790
- /**
791
- * Escape goes to the topmost open popup only, so closing a dropdown inside a dialog leaves the dialog
792
- * open. The topmost popup consumes the key even when it doesn't close on Escape, so a modal that can't
793
- * be dismissed doesn't let it reach the popup underneath. An Escape that ends an IME composition is left
794
- * alone. `preventDefault()` doesn't keep the popup open, because controls call it on every navigation key;
795
- * a control that handles Escape itself stops its propagation instead.
796
- */
797
- handleEscapeKey(event) {
798
- const escapeTarget = this.#escapeTarget;
799
- this.#escapeTarget = null;
800
- if (event.key !== "Escape" || event.isComposing) {
801
- return;
802
- }
803
- // The popup on top when the key was pressed, before handlers further down could close it.
804
- const popup = escapeTarget?.event === event ? escapeTarget.popup : this.getTopmostOpenPopup();
805
- if (!popup?.closeOnEscape) {
806
- return;
807
- }
808
- popup.reference.popupRef.close(new PopupCloseEvent({
809
- event,
810
- originalEvent: event,
811
- via: PopupCloseSource.Escape
812
- }));
813
- }
814
- handleFocusRestoration(settings, overlayRef, originallyFocusedElement) {
815
- const restoreFocus = settings.restoreFocus ?? "auto";
816
- if (restoreFocus === false) {
817
- return;
818
- }
819
- const target = restoreFocus === "auto" ? originallyFocusedElement : this.getAnchorElement(settings.anchor);
820
- if (target && focusCanReturn(this.#document, target, overlayRef.overlayElement)) {
821
- target.focus();
822
- }
823
- }
824
- isScrollableElement(element) {
825
- const defaultView = this.#document.defaultView;
826
- if (!defaultView) {
827
- return false;
828
- }
829
- const style = defaultView.getComputedStyle(element);
830
- const canScrollVertically = (this.isScrollableOverflow(style.overflowY) || this.isScrollableOverflow(style.overflow)) &&
831
- element.scrollHeight > element.clientHeight;
832
- const canScrollHorizontally = (this.isScrollableOverflow(style.overflowX) || this.isScrollableOverflow(style.overflow)) &&
833
- element.scrollWidth > element.clientWidth;
834
- return canScrollVertically || canScrollHorizontally;
835
- }
836
- isScrollableOverflow(value) {
837
- return value === "auto" || value === "scroll" || value === "overlay";
838
- }
839
- /**
840
- * One pair of `document` listeners serves every open popup. The capturing one notes which popup is on
841
- * top before the key reaches any control; the bubbling one closes it if nothing handled the key.
842
- */
843
- listenForEscape() {
844
- if (this.#escapeSubscription) {
845
- return;
846
- }
847
- const subscription = new Subscription();
848
- subscription.add(fromEvent(this.#document, "keydown", { capture: true }).subscribe(event => {
849
- this.#escapeTarget = event.key === "Escape" ? { event, popup: this.getTopmostOpenPopup() } : null;
850
- }));
851
- subscription.add(fromEvent(this.#document, "keydown").subscribe(event => this.handleEscapeKey(event)));
852
- this.#escapeSubscription = subscription;
853
- }
854
- /**
855
- * A popup leaves the stack as soon as it starts closing, so a second Escape during its leave animation
856
- * goes to the popup underneath.
857
- */
858
- registerOpenPopup(settings, popupReference) {
859
- const popup = { closeOnEscape: settings.closeOnEscape ?? true, reference: popupReference };
860
- this.#openPopups.push(popup);
861
- this.listenForEscape();
862
- merge(popupReference.closeStart, popupReference.closed)
863
- .pipe(take(1))
864
- .subscribe(() => this.unregisterOpenPopup(popup));
865
- }
866
- /**
867
- * Resolves a PopupAnchor to a FlexibleConnectedPositionStrategyOrigin.
868
- * This method should only receive actual elements or ElementRefs, not CSS selector strings.
869
- * CSS selectors are handled by the multi-element popup creation path.
870
- * @param anchor The anchor to resolve (should be Element or ElementRef)
871
- * @returns The resolved anchor
872
- */
873
- resolveAnchor(anchor) {
874
- if (typeof anchor === "string") {
875
- throw new Error(`CSS selector "${anchor}" should not reach resolveAnchor(). ` +
876
- `CSS selectors should be handled by createMultiElementPopup().`);
877
- }
878
- return anchor;
879
- }
880
- setupBackdropCloseSubscription(settings, popupReference, overlayRef) {
881
- if (!(settings.closeOnBackdropClick ?? true)) {
882
- return null;
883
- }
884
- const backdropSubject = new Subject();
885
- return overlayRef
886
- .backdropClick()
887
- .pipe(takeUntil(backdropSubject))
888
- .subscribe(e => {
889
- const event = new PopupCloseEvent({
890
- event: e,
891
- originalEvent: e,
892
- via: PopupCloseSource.BackdropClick
893
- });
894
- if (!popupReference.close(event)) {
895
- return;
896
- }
897
- backdropSubject.next();
898
- backdropSubject.complete();
899
- });
900
- }
901
- /**
902
- * Starts the backdrop fade-out as soon as the close begins, so it runs alongside the popup's leave
903
- * animation. Without it the backdrop stays fully opaque until `dispose()` removes it in one frame.
904
- */
905
- setupBackdropFadeOut(settings, popupReference, overlayRef) {
906
- if (!settings.hasBackdrop) {
907
- return;
908
- }
909
- popupReference.closeStart.pipe(take(1)).subscribe(() => overlayRef.detachBackdrop());
910
- }
911
- setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement) {
912
- popupReference.closed.pipe(take(1)).subscribe(() => {
913
- subscription?.unsubscribe();
914
- this.handleFocusRestoration(settings, popupReference.overlayRef, originallyFocusedElement);
915
- });
916
- }
917
- setupCloseSubscriptions(settings, popupReference, overlayRef) {
918
- const subscriptions = [];
919
- if (settings.hasBackdrop) {
920
- const backdropSub = this.setupBackdropCloseSubscription(settings, popupReference, overlayRef);
921
- if (backdropSub) {
922
- subscriptions.push(backdropSub);
923
- }
924
- }
925
- if (settings.closeOnOutsideClick ?? true) {
926
- const outsideClickSub = this.setupOutsideClickSubscription(settings, popupReference, overlayRef);
927
- if (outsideClickSub) {
928
- subscriptions.push(outsideClickSub);
929
- }
930
- }
931
- if (settings.closeOnMouseLeave) {
932
- const mouseLeaveSubscription = this.setupMouseLeaveSubscription(settings, popupReference);
933
- if (mouseLeaveSubscription) {
934
- subscriptions.push(mouseLeaveSubscription);
935
- }
936
- }
937
- if (subscriptions.length === 0) {
938
- return null;
939
- }
940
- const combinedSubscription = new Subscription();
941
- subscriptions.forEach(sub => combinedSubscription.add(sub));
942
- return combinedSubscription;
943
- }
944
- /**
945
- * `PopupRef.overlayRef` is public, so the overlay can be detached or disposed without going through
946
- * `close()`. Finish the close then too, or `closed` never fires and focus, subscriptions and consumers
947
- * waiting for it (the dropdowns won't reopen until it does) stay stuck.
948
- */
949
- setupDetachTracking(overlayRef, popupReference) {
950
- overlayRef
951
- .detachments()
952
- .pipe(take(1), takeUntil(popupReference.closed))
953
- .subscribe(() => popupReference.closeDetached());
954
- }
955
- setupDirectionTracking(settings, overlayRef, popupReference) {
956
- const resolvedAnchor = this.resolveAnchor(settings.anchor);
957
- const anchorElement = this.getAnchorElement(resolvedAnchor);
958
- const cleanup = observeComponentDirection(anchorElement, this.#directionality, nextDir => {
959
- overlayRef.setDirection(nextDir);
960
- overlayRef.updatePosition();
961
- popupReference.componentRef?.changeDetectorRef.markForCheck();
962
- });
963
- popupReference.closed.pipe(take(1)).subscribe(() => {
964
- cleanup();
965
- });
966
- }
967
- /**
968
- * Listens on the document rather than on the elements matched at creation time, so elements added later
969
- * get a popup too. One popup shows at a time; it closes when the pointer leaves its element, and the
970
- * returned subscription's teardown closes it as well.
971
- */
972
- setupInternalEventDelegation(selector, settings) {
973
- let current = null;
974
- const closeCurrent = () => {
975
- const popup = current;
976
- current = null;
977
- popup?.popupRef.close();
978
- };
979
- const subscription = new Subscription(closeCurrent);
980
- subscription.add(fromEvent(this.#document, "pointerover")
981
- .pipe(takeUntilDestroyed(this.#destroyRef))
982
- .subscribe(event => {
983
- const target = event.target instanceof Element ? event.target : null;
984
- const element = target?.closest(selector);
985
- if (!(element instanceof HTMLElement) || element === current?.element) {
986
- return;
987
- }
988
- closeCurrent();
989
- const popupRef = this.createSingleElementPopup({ ...settings, anchor: element });
990
- current = { element, popupRef };
991
- popupRef.closed.pipe(take(1)).subscribe(() => {
992
- if (current?.popupRef === popupRef) {
993
- current = null;
994
- }
995
- });
996
- }));
997
- subscription.add(fromEvent(this.#document, "pointerout")
998
- .pipe(takeUntilDestroyed(this.#destroyRef))
999
- .subscribe(event => {
1000
- const element = current?.element;
1001
- const target = event.target instanceof Node ? event.target : null;
1002
- const next = event.relatedTarget instanceof Node ? event.relatedTarget : null;
1003
- if (element && target && element.contains(target) && !(next && element.contains(next))) {
1004
- closeCurrent();
1005
- }
1006
- }));
1007
- return subscription;
1008
- }
1009
- setupMouseLeaveSubscription(settings, popupReference) {
1010
- if (typeof settings.anchor === "string") {
1011
- return null;
1012
- }
1013
- const resolvedAnchor = this.resolveAnchor(settings.anchor);
1014
- const anchorElement = this.getAnchorElement(resolvedAnchor);
1015
- if (!anchorElement) {
1016
- return null;
1017
- }
1018
- return fromEvent(anchorElement, "pointerleave")
1019
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1020
- .subscribe(event => {
1021
- const closeEvent = new PopupCloseEvent({
1022
- event,
1023
- originalEvent: event,
1024
- via: PopupCloseSource.MouseLeave
1025
- });
1026
- popupReference.close(closeEvent);
1027
- });
1028
- }
1029
- setupOutsideClickSubscription(settings, popupReference, overlayRef) {
1030
- return overlayRef
1031
- .outsidePointerEvents()
1032
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1033
- .subscribe(event => {
1034
- if (this.shouldIgnoreOutsideClick(settings, event, overlayRef)) {
1035
- return;
1036
- }
1037
- const closeEvent = new PopupCloseEvent({
1038
- event,
1039
- originalEvent: event,
1040
- via: PopupCloseSource.OutsideClick
1041
- });
1042
- popupReference.close(closeEvent);
1043
- });
1044
- }
1045
- setupPositionChangeTracking(settings, overlayRef, popupReference) {
1046
- if (settings.positionStrategy === "global") {
1047
- return;
1048
- }
1049
- const positionStrategy = overlayRef.getConfig().positionStrategy;
1050
- if (positionStrategy && positionStrategy.positionChanges) {
1051
- positionStrategy.positionChanges
1052
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1053
- .subscribe(change => popupReference.positionChanges$.next(change.connectionPair));
1054
- }
1055
- }
1056
- setupScrollClosing(settings, popupReference, overlayRef) {
1057
- if (!settings.closeOnScroll) {
1058
- return;
1059
- }
1060
- const scrollableContainers = this.getScrollableContainers(this.resolveAnchor(settings.anchor));
1061
- const subscriptions = [];
1062
- const handleScrollClose = (originalEvent) => {
1063
- if (!overlayRef.hasAttached()) {
1064
- return;
1065
- }
1066
- const closeEvent = new PopupCloseEvent({
1067
- event: originalEvent ?? new Event("scroll"),
1068
- originalEvent: originalEvent ?? new Event("scroll"),
1069
- via: PopupCloseSource.Scroll
1070
- });
1071
- popupReference.close(closeEvent, 0);
1072
- };
1073
- // The page scrolls the anchor away whether or not it also sits in a scrollable container.
1074
- const win = this.#document.defaultView;
1075
- const pageEvents = [
1076
- fromEvent(win, "scroll", { passive: true }),
1077
- fromEvent(this.#document, "scroll", { passive: true })
1078
- ];
1079
- if (scrollableContainers.length === 0) {
1080
- pageEvents.push(fromEvent(win, "resize", { passive: true }));
1081
- }
1082
- const pageScrollSubscription = merge(...pageEvents)
1083
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1084
- .subscribe(event => handleScrollClose(event));
1085
- subscriptions.push(pageScrollSubscription);
1086
- scrollableContainers.forEach(scrollable => {
1087
- const containerScrollSubscription = scrollable
1088
- .elementScrolled()
1089
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1090
- .subscribe(() => handleScrollClose());
1091
- subscriptions.push(containerScrollSubscription);
1092
- });
1093
- popupReference.closed.pipe(take(1)).subscribe(() => {
1094
- subscriptions.forEach(sub => sub.unsubscribe());
1095
- });
1096
- }
1097
- setupScrollTracking(settings, overlayRef, popupReference) {
1098
- if (!(settings.withScrollTracking ?? true) || settings.positionStrategy === "global") {
1099
- return;
1100
- }
1101
- if (typeof settings.anchor === "string") {
1102
- return;
1103
- }
1104
- const subscriptions = [];
1105
- const updatePosition = () => {
1106
- if (overlayRef.hasAttached()) {
1107
- overlayRef.updatePosition();
1108
- }
1109
- };
1110
- const win = this.#document.defaultView;
1111
- const windowScrollSubscription = fromEvent(win, "scroll", { passive: true })
1112
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1113
- .subscribe(updatePosition);
1114
- subscriptions.push(windowScrollSubscription);
1115
- const resizeSubscription = fromEvent(win, "resize", { passive: true })
1116
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1117
- .subscribe(updatePosition);
1118
- subscriptions.push(resizeSubscription);
1119
- this.getScrollableContainers(this.resolveAnchor(settings.anchor)).forEach(scrollable => {
1120
- const containerScrollSubscription = scrollable
1121
- .elementScrolled()
1122
- .pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef))
1123
- .subscribe(updatePosition);
1124
- subscriptions.push(containerScrollSubscription);
1125
- });
1126
- popupReference.closed.pipe(take(1)).subscribe(() => {
1127
- subscriptions.forEach(sub => sub.unsubscribe());
1128
- });
1129
- }
1130
- shouldIgnoreOutsideClick(settings, event, overlayRef) {
1131
- const eventTarget = event.target;
1132
- // The backdrop lies outside the pane, so its clicks also arrive here. They belong to the backdrop
1133
- // handler, which honours closeOnBackdropClick and reports them as BackdropClick.
1134
- if (overlayRef.backdropElement?.contains(eventTarget)) {
1135
- return true;
1136
- }
1137
- if (typeof settings.anchor === "string") {
1138
- return !this.#outsideEventsToClose.includes(event.type);
1139
- }
1140
- const resolvedAnchor = this.resolveAnchor(settings.anchor);
1141
- const anchorElement = this.getAnchorElement(resolvedAnchor);
1142
- const isAnchorClick = anchorElement && anchorElement.contains(eventTarget);
1143
- const isRelevantEventType = this.#outsideEventsToClose.includes(event.type);
1144
- return isAnchorClick || !isRelevantEventType;
1145
- }
1146
- unregisterOpenPopup(popup) {
1147
- const index = this.#openPopups.indexOf(popup);
1148
- if (index !== -1) {
1149
- this.#openPopups.splice(index, 1);
1150
- }
1151
- if (this.#openPopups.length === 0) {
1152
- this.#escapeSubscription?.unsubscribe();
1153
- this.#escapeSubscription = null;
1154
- this.#escapeTarget = null;
1155
- }
1156
- }
1157
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1158
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupService, providedIn: "root" }); }
1159
- }
1160
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupService, decorators: [{
1161
- type: Injectable,
1162
- args: [{
1163
- providedIn: "root"
1164
- }]
1165
- }] });
1166
- /**
1167
- * Language of the popup content. The overlay container sits outside the app root, so a `lang` set on the root
1168
- * (or near the anchor) would not reach the popup and screen readers could read it with the wrong voice
1169
- * (WCAG 3.1.2). The nearest `lang` above the anchor wins; without one, the active Mona locale is used.
1170
- */
584
+ const flipX = (value) => value === "start" ? "end" : value === "end" ? "start" : value;
585
+ const flipY = (value) => value === "top" ? "bottom" : value === "bottom" ? "top" : value;
586
+ var PopupService = class PopupService {
587
+ #destroyRef = inject(DestroyRef);
588
+ #directionality = inject(Directionality, { optional: true });
589
+ #document = inject(DOCUMENT);
590
+ #i18n = inject(MonaI18nService, { optional: true });
591
+ #injector = inject(Injector);
592
+ #openPopups = [];
593
+ #outsideEventsToClose = [
594
+ "click",
595
+ "mousedown",
596
+ "dblclick",
597
+ "contextmenu",
598
+ "auxclick"
599
+ ];
600
+ #overlay = inject(Overlay);
601
+ #scrollDispatcher = inject(ScrollDispatcher);
602
+ #escapeSubscription = null;
603
+ #escapeTarget = null;
604
+ create(settings) {
605
+ if (typeof settings.anchor === "string") return this.createMultiElementPopup(settings);
606
+ return this.createSingleElementPopup(settings);
607
+ }
608
+ attachContent(settings, popupReference, overlayRef, injector) {
609
+ const portal = new ComponentPortal(PopupWrapperComponent, null, injector);
610
+ const wrapperComponentRef = overlayRef.attach(portal);
611
+ popupReference.wrapperComponentRef = wrapperComponentRef;
612
+ wrapperComponentRef.changeDetectorRef.detectChanges();
613
+ popupReference.componentRef = wrapperComponentRef.instance.attachContent(settings.content, injector) ?? void 0;
614
+ wrapperComponentRef.changeDetectorRef.detectChanges();
615
+ return wrapperComponentRef.location.nativeElement;
616
+ }
617
+ buildPanelClass(popupClass) {
618
+ if (!popupClass) return "mona-popup-content";
619
+ return ["mona-popup-content"].concat(popupClass);
620
+ }
621
+ captureOriginalFocus(settings) {
622
+ const restoreFocus = settings.restoreFocus ?? "auto";
623
+ if (typeof settings.anchor === "string" || restoreFocus === false) return null;
624
+ const activeElement = this.#document.activeElement;
625
+ if (!(activeElement instanceof HTMLElement)) return null;
626
+ if (restoreFocus === "auto") return this.getAnchorElement(settings.anchor)?.contains(activeElement) ? activeElement : null;
627
+ return this.getAnchorElement(settings.anchor);
628
+ }
629
+ createInjector(settings, popupReference) {
630
+ return Injector.create({
631
+ parent: settings.injector ?? this.#injector,
632
+ providers: [
633
+ {
634
+ provide: PopupRef,
635
+ useFactory: () => popupReference.popupRef
636
+ },
637
+ {
638
+ provide: PopupDataInjectionToken,
639
+ useValue: settings.data
640
+ },
641
+ {
642
+ provide: POPUP_REFERENCE,
643
+ useValue: popupReference
644
+ },
645
+ {
646
+ provide: POPUP_SETTINGS,
647
+ useValue: settings
648
+ },
649
+ ...settings.providers ?? []
650
+ ]
651
+ });
652
+ }
653
+ createMultiElementPopup(settings) {
654
+ const selector = settings.anchor;
655
+ const virtualPopupReference = new PopupReference(this.#overlay.create({ hasBackdrop: false }));
656
+ const delegation = this.setupInternalEventDelegation(selector, settings);
657
+ virtualPopupReference.popupRef.closed.pipe(take(1)).subscribe(() => delegation.unsubscribe());
658
+ return virtualPopupReference.popupRef;
659
+ }
660
+ createOverlay(settings) {
661
+ const positionStrategy = this.createPositionStrategy(settings);
662
+ const panelClass = this.buildPanelClass(settings.popupClass);
663
+ const anchorElement = settings.anchor instanceof ElementRef ? settings.anchor.nativeElement : settings.anchor instanceof HTMLElement ? settings.anchor : null;
664
+ const direction = resolveComponentDirection(anchorElement, this.#directionality);
665
+ const overlayRef = this.#overlay.create(new OverlayConfig({
666
+ positionStrategy,
667
+ hasBackdrop: settings.hasBackdrop ?? false,
668
+ height: settings.height,
669
+ maxHeight: settings.maxHeight,
670
+ maxWidth: settings.maxWidth,
671
+ minHeight: settings.minHeight,
672
+ minWidth: settings.minWidth,
673
+ width: settings.width,
674
+ panelClass,
675
+ backdropClass: settings.backdropClass ?? "transparent",
676
+ direction,
677
+ scrollStrategy: settings.blockScroll ? createPageScrollBlockStrategy(this.#document, this.#overlay.scrollStrategies.block()) : void 0
678
+ }));
679
+ const lang = resolvePopupLanguage(anchorElement, this.#i18n?.localeId());
680
+ if (lang) overlayRef.overlayElement.setAttribute("lang", lang);
681
+ return overlayRef;
682
+ }
683
+ createPositionStrategy(settings) {
684
+ if (settings.positionStrategy === "global") return this.#overlay.position().global();
685
+ const resolvedAnchor = this.resolveAnchor(settings.anchor);
686
+ const position = settings.positions?.length ? settings.positions : this.getPosition(settings.anchorConnectionPoint, settings.popupConnectionPoint);
687
+ const strategy = this.#overlay.position().flexibleConnectedTo(resolvedAnchor).withPositions(position).withDefaultOffsetX(settings.offset?.horizontal ?? 0).withDefaultOffsetY(settings.offset?.vertical ?? 0).withPush(settings.withPush ?? true);
688
+ if (settings.withScrollTracking ?? true) {
689
+ const scrollableContainers = this.getScrollableContainers(resolvedAnchor);
690
+ strategy.withScrollableContainers(scrollableContainers);
691
+ }
692
+ return strategy;
693
+ }
694
+ createScrollDispatcherTarget(element) {
695
+ const elementRef = new ElementRef(element);
696
+ return {
697
+ elementScrolled: () => fromEvent(element, "scroll", { passive: true }),
698
+ getElementRef: () => elementRef
699
+ };
700
+ }
701
+ createSingleElementPopup(settings) {
702
+ const overlayRef = this.createOverlay(settings);
703
+ const popupReference = new PopupReference(overlayRef, settings.preventClose);
704
+ const originallyFocusedElement = this.captureOriginalFocus(settings);
705
+ const injector = this.createInjector(settings, popupReference);
706
+ popupReference.notifyOpen();
707
+ this.attachContent(settings, popupReference, overlayRef, injector);
708
+ const subscription = this.setupCloseSubscriptions(settings, popupReference, overlayRef);
709
+ this.setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement);
710
+ this.setupBackdropFadeOut(settings, popupReference, overlayRef);
711
+ if (settings.closeOnScroll) this.setupScrollClosing(settings, popupReference, overlayRef);
712
+ this.setupScrollTracking(settings, overlayRef, popupReference);
713
+ this.registerOpenPopup(settings, popupReference);
714
+ this.setupDetachTracking(overlayRef, popupReference);
715
+ this.setupPositionChangeTracking(settings, overlayRef, popupReference);
716
+ this.setupDirectionTracking(settings, overlayRef, popupReference);
717
+ return popupReference.popupRef;
718
+ }
719
+ getAnchorElement(anchor) {
720
+ if (anchor instanceof HTMLElement) return anchor;
721
+ if (typeof anchor === "object" && "nativeElement" in anchor && anchor.nativeElement instanceof HTMLElement) return anchor.nativeElement;
722
+ return null;
723
+ }
724
+ getPosition(anchorConnectionPoint, popupConnectionPoint) {
725
+ return connectionPosition(anchorConnectionPoint ?? "bottomleft", popupConnectionPoint ?? "topleft");
726
+ }
727
+ getScrollableAncestorElements(anchorElement) {
728
+ const scrollables = [];
729
+ let element = anchorElement.parentElement;
730
+ while (element) {
731
+ if (this.isScrollableElement(element)) scrollables.push(element);
732
+ element = element.parentElement;
733
+ }
734
+ return scrollables;
735
+ }
736
+ getScrollableContainers(anchor) {
737
+ const anchorElement = this.getAnchorElement(anchor);
738
+ if (!anchorElement) return [];
739
+ const scrollablesByElement = /* @__PURE__ */ new Map();
740
+ const addScrollable = (scrollable) => {
741
+ scrollablesByElement.set(scrollable.getElementRef().nativeElement, scrollable);
742
+ };
743
+ this.#scrollDispatcher.getAncestorScrollContainers(anchorElement).forEach((scrollable) => addScrollable(scrollable));
744
+ this.getScrollableAncestorElements(anchorElement).map((element) => this.createScrollDispatcherTarget(element)).forEach((scrollable) => addScrollable(scrollable));
745
+ return Array.from(scrollablesByElement.values());
746
+ }
747
+ getTopmostOpenPopup() {
748
+ for (let index = this.#openPopups.length - 1; index >= 0; index--) {
749
+ const popup = this.#openPopups[index];
750
+ if (popup.reference.overlayRef.hasAttached()) return popup;
751
+ }
752
+ return null;
753
+ }
754
+ handleEscapeKey(event) {
755
+ const escapeTarget = this.#escapeTarget;
756
+ this.#escapeTarget = null;
757
+ if (event.key !== "Escape" || event.isComposing) return;
758
+ const popup = escapeTarget?.event === event ? escapeTarget.popup : this.getTopmostOpenPopup();
759
+ if (!popup?.closeOnEscape) return;
760
+ popup.reference.popupRef.close(new PopupCloseEvent({
761
+ event,
762
+ originalEvent: event,
763
+ via: PopupCloseSource.Escape
764
+ }));
765
+ }
766
+ handleFocusRestoration(settings, overlayRef, originallyFocusedElement) {
767
+ const restoreFocus = settings.restoreFocus ?? "auto";
768
+ if (restoreFocus === false) return;
769
+ const target = restoreFocus === "auto" ? originallyFocusedElement : this.getAnchorElement(settings.anchor);
770
+ if (target && focusCanReturn(this.#document, target, overlayRef.overlayElement)) target.focus();
771
+ }
772
+ isScrollableElement(element) {
773
+ const defaultView = this.#document.defaultView;
774
+ if (!defaultView) return false;
775
+ const style = defaultView.getComputedStyle(element);
776
+ const canScrollVertically = (this.isScrollableOverflow(style.overflowY) || this.isScrollableOverflow(style.overflow)) && element.scrollHeight > element.clientHeight;
777
+ const canScrollHorizontally = (this.isScrollableOverflow(style.overflowX) || this.isScrollableOverflow(style.overflow)) && element.scrollWidth > element.clientWidth;
778
+ return canScrollVertically || canScrollHorizontally;
779
+ }
780
+ isScrollableOverflow(value) {
781
+ return value === "auto" || value === "scroll" || value === "overlay";
782
+ }
783
+ listenForEscape() {
784
+ if (this.#escapeSubscription) return;
785
+ const subscription = new Subscription();
786
+ subscription.add(fromEvent(this.#document, "keydown", { capture: true }).subscribe((event) => {
787
+ this.#escapeTarget = event.key === "Escape" ? {
788
+ event,
789
+ popup: this.getTopmostOpenPopup()
790
+ } : null;
791
+ }));
792
+ subscription.add(fromEvent(this.#document, "keydown").subscribe((event) => this.handleEscapeKey(event)));
793
+ this.#escapeSubscription = subscription;
794
+ }
795
+ registerOpenPopup(settings, popupReference) {
796
+ const popup = {
797
+ closeOnEscape: settings.closeOnEscape ?? true,
798
+ reference: popupReference
799
+ };
800
+ this.#openPopups.push(popup);
801
+ this.listenForEscape();
802
+ merge(popupReference.closeStart, popupReference.closed).pipe(take(1)).subscribe(() => this.unregisterOpenPopup(popup));
803
+ }
804
+ resolveAnchor(anchor) {
805
+ if (typeof anchor === "string") throw new Error(`CSS selector "${anchor}" should not reach resolveAnchor(). CSS selectors should be handled by createMultiElementPopup().`);
806
+ return anchor;
807
+ }
808
+ setupBackdropCloseSubscription(settings, popupReference, overlayRef) {
809
+ if (!(settings.closeOnBackdropClick ?? true)) return null;
810
+ const backdropSubject = new Subject();
811
+ return overlayRef.backdropClick().pipe(takeUntil(backdropSubject)).subscribe((e) => {
812
+ const event = new PopupCloseEvent({
813
+ event: e,
814
+ originalEvent: e,
815
+ via: PopupCloseSource.BackdropClick
816
+ });
817
+ if (!popupReference.close(event)) return;
818
+ backdropSubject.next();
819
+ backdropSubject.complete();
820
+ });
821
+ }
822
+ setupBackdropFadeOut(settings, popupReference, overlayRef) {
823
+ if (!settings.hasBackdrop) return;
824
+ popupReference.closeStart.pipe(take(1)).subscribe(() => overlayRef.detachBackdrop());
825
+ }
826
+ setupCleanupSubscription(popupReference, subscription, settings, originallyFocusedElement) {
827
+ popupReference.closed.pipe(take(1)).subscribe(() => {
828
+ subscription?.unsubscribe();
829
+ this.handleFocusRestoration(settings, popupReference.overlayRef, originallyFocusedElement);
830
+ });
831
+ }
832
+ setupCloseSubscriptions(settings, popupReference, overlayRef) {
833
+ const subscriptions = [];
834
+ if (settings.hasBackdrop) {
835
+ const backdropSub = this.setupBackdropCloseSubscription(settings, popupReference, overlayRef);
836
+ if (backdropSub) subscriptions.push(backdropSub);
837
+ }
838
+ if (settings.closeOnOutsideClick ?? true) {
839
+ const outsideClickSub = this.setupOutsideClickSubscription(settings, popupReference, overlayRef);
840
+ if (outsideClickSub) subscriptions.push(outsideClickSub);
841
+ }
842
+ if (settings.closeOnMouseLeave) {
843
+ const mouseLeaveSubscription = this.setupMouseLeaveSubscription(settings, popupReference);
844
+ if (mouseLeaveSubscription) subscriptions.push(mouseLeaveSubscription);
845
+ }
846
+ if (subscriptions.length === 0) return null;
847
+ const combinedSubscription = new Subscription();
848
+ subscriptions.forEach((sub) => combinedSubscription.add(sub));
849
+ return combinedSubscription;
850
+ }
851
+ setupDetachTracking(overlayRef, popupReference) {
852
+ overlayRef.detachments().pipe(take(1), takeUntil(popupReference.closed)).subscribe(() => popupReference.closeDetached());
853
+ }
854
+ setupDirectionTracking(settings, overlayRef, popupReference) {
855
+ const resolvedAnchor = this.resolveAnchor(settings.anchor);
856
+ const anchorElement = this.getAnchorElement(resolvedAnchor);
857
+ const cleanup = observeComponentDirection(anchorElement, this.#directionality, (nextDir) => {
858
+ overlayRef.setDirection(nextDir);
859
+ overlayRef.updatePosition();
860
+ popupReference.componentRef?.changeDetectorRef.markForCheck();
861
+ });
862
+ popupReference.closed.pipe(take(1)).subscribe(() => {
863
+ cleanup();
864
+ });
865
+ }
866
+ setupInternalEventDelegation(selector, settings) {
867
+ let current = null;
868
+ const closeCurrent = () => {
869
+ const popup = current;
870
+ current = null;
871
+ popup?.popupRef.close();
872
+ };
873
+ const subscription = new Subscription(closeCurrent);
874
+ subscription.add(fromEvent(this.#document, "pointerover").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
875
+ const element = (event.target instanceof Element ? event.target : null)?.closest(selector);
876
+ if (!(element instanceof HTMLElement) || element === current?.element) return;
877
+ closeCurrent();
878
+ const popupRef = this.createSingleElementPopup({
879
+ ...settings,
880
+ anchor: element
881
+ });
882
+ current = {
883
+ element,
884
+ popupRef
885
+ };
886
+ popupRef.closed.pipe(take(1)).subscribe(() => {
887
+ if (current?.popupRef === popupRef) current = null;
888
+ });
889
+ }));
890
+ subscription.add(fromEvent(this.#document, "pointerout").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
891
+ const element = current?.element;
892
+ const target = event.target instanceof Node ? event.target : null;
893
+ const next = event.relatedTarget instanceof Node ? event.relatedTarget : null;
894
+ if (element && target && element.contains(target) && !(next && element.contains(next))) closeCurrent();
895
+ }));
896
+ return subscription;
897
+ }
898
+ setupMouseLeaveSubscription(settings, popupReference) {
899
+ if (typeof settings.anchor === "string") return null;
900
+ const resolvedAnchor = this.resolveAnchor(settings.anchor);
901
+ const anchorElement = this.getAnchorElement(resolvedAnchor);
902
+ if (!anchorElement) return null;
903
+ return fromEvent(anchorElement, "pointerleave").pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
904
+ const closeEvent = new PopupCloseEvent({
905
+ event,
906
+ originalEvent: event,
907
+ via: PopupCloseSource.MouseLeave
908
+ });
909
+ popupReference.close(closeEvent);
910
+ });
911
+ }
912
+ setupOutsideClickSubscription(settings, popupReference, overlayRef) {
913
+ return overlayRef.outsidePointerEvents().pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
914
+ if (this.shouldIgnoreOutsideClick(settings, event, overlayRef)) return;
915
+ const closeEvent = new PopupCloseEvent({
916
+ event,
917
+ originalEvent: event,
918
+ via: PopupCloseSource.OutsideClick
919
+ });
920
+ popupReference.close(closeEvent);
921
+ });
922
+ }
923
+ setupPositionChangeTracking(settings, overlayRef, popupReference) {
924
+ if (settings.positionStrategy === "global") return;
925
+ const positionStrategy = overlayRef.getConfig().positionStrategy;
926
+ if (positionStrategy && positionStrategy.positionChanges) positionStrategy.positionChanges.pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe((change) => popupReference.positionChanges$.next(change.connectionPair));
927
+ }
928
+ setupScrollClosing(settings, popupReference, overlayRef) {
929
+ if (!settings.closeOnScroll) return;
930
+ const scrollableContainers = this.getScrollableContainers(this.resolveAnchor(settings.anchor));
931
+ const subscriptions = [];
932
+ const handleScrollClose = (originalEvent) => {
933
+ if (!overlayRef.hasAttached()) return;
934
+ const closeEvent = new PopupCloseEvent({
935
+ event: originalEvent ?? new Event("scroll"),
936
+ originalEvent: originalEvent ?? new Event("scroll"),
937
+ via: PopupCloseSource.Scroll
938
+ });
939
+ popupReference.close(closeEvent, 0);
940
+ };
941
+ const win = this.#document.defaultView;
942
+ const pageEvents = [fromEvent(win, "scroll", { passive: true }), fromEvent(this.#document, "scroll", { passive: true })];
943
+ if (scrollableContainers.length === 0) pageEvents.push(fromEvent(win, "resize", { passive: true }));
944
+ const pageScrollSubscription = merge(...pageEvents).pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => handleScrollClose(event));
945
+ subscriptions.push(pageScrollSubscription);
946
+ scrollableContainers.forEach((scrollable) => {
947
+ const containerScrollSubscription = scrollable.elementScrolled().pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe(() => handleScrollClose());
948
+ subscriptions.push(containerScrollSubscription);
949
+ });
950
+ popupReference.closed.pipe(take(1)).subscribe(() => {
951
+ subscriptions.forEach((sub) => sub.unsubscribe());
952
+ });
953
+ }
954
+ setupScrollTracking(settings, overlayRef, popupReference) {
955
+ if (!(settings.withScrollTracking ?? true) || settings.positionStrategy === "global") return;
956
+ if (typeof settings.anchor === "string") return;
957
+ const subscriptions = [];
958
+ const updatePosition = () => {
959
+ if (overlayRef.hasAttached()) overlayRef.updatePosition();
960
+ };
961
+ const win = this.#document.defaultView;
962
+ const windowScrollSubscription = fromEvent(win, "scroll", { passive: true }).pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe(updatePosition);
963
+ subscriptions.push(windowScrollSubscription);
964
+ const resizeSubscription = fromEvent(win, "resize", { passive: true }).pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe(updatePosition);
965
+ subscriptions.push(resizeSubscription);
966
+ this.getScrollableContainers(this.resolveAnchor(settings.anchor)).forEach((scrollable) => {
967
+ const containerScrollSubscription = scrollable.elementScrolled().pipe(takeUntil(popupReference.closed), takeUntilDestroyed(this.#destroyRef)).subscribe(updatePosition);
968
+ subscriptions.push(containerScrollSubscription);
969
+ });
970
+ popupReference.closed.pipe(take(1)).subscribe(() => {
971
+ subscriptions.forEach((sub) => sub.unsubscribe());
972
+ });
973
+ }
974
+ shouldIgnoreOutsideClick(settings, event, overlayRef) {
975
+ const eventTarget = event.target;
976
+ if (overlayRef.backdropElement?.contains(eventTarget)) return true;
977
+ if (typeof settings.anchor === "string") return !this.#outsideEventsToClose.includes(event.type);
978
+ const resolvedAnchor = this.resolveAnchor(settings.anchor);
979
+ const anchorElement = this.getAnchorElement(resolvedAnchor);
980
+ const isAnchorClick = anchorElement && anchorElement.contains(eventTarget);
981
+ const isRelevantEventType = this.#outsideEventsToClose.includes(event.type);
982
+ return isAnchorClick || !isRelevantEventType;
983
+ }
984
+ unregisterOpenPopup(popup) {
985
+ const index = this.#openPopups.indexOf(popup);
986
+ if (index !== -1) this.#openPopups.splice(index, 1);
987
+ if (this.#openPopups.length === 0) {
988
+ this.#escapeSubscription?.unsubscribe();
989
+ this.#escapeSubscription = null;
990
+ this.#escapeTarget = null;
991
+ }
992
+ }
993
+ static {
994
+ this.ɵfac = i0.ɵɵngDeclareFactory({
995
+ minVersion: "12.0.0",
996
+ version: "22.2.6",
997
+ ngImport: i0,
998
+ type: PopupService,
999
+ deps: [],
1000
+ target: i0.ɵɵFactoryTarget.Injectable
1001
+ });
1002
+ }
1003
+ static {
1004
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
1005
+ minVersion: "12.0.0",
1006
+ version: "22.2.6",
1007
+ ngImport: i0,
1008
+ type: PopupService,
1009
+ providedIn: "root"
1010
+ });
1011
+ }
1012
+ };
1013
+ i0.ɵɵngDeclareClassMetadata({
1014
+ minVersion: "12.0.0",
1015
+ version: "22.2.6",
1016
+ ngImport: i0,
1017
+ type: PopupService,
1018
+ decorators: [{
1019
+ type: Injectable,
1020
+ args: [{ providedIn: "root" }]
1021
+ }]
1022
+ });
1171
1023
  function resolvePopupLanguage(anchorElement, localeId) {
1172
- const inherited = anchorElement?.closest("[lang]")?.getAttribute("lang")?.trim();
1173
- return inherited || localeId || null;
1024
+ return anchorElement?.closest("[lang]")?.getAttribute("lang")?.trim() || localeId || null;
1174
1025
  }
1175
-
1176
- class PopupComponent {
1177
- #destroyRef;
1178
- #document;
1179
- #popupService;
1180
- #eventListenerCleanup$;
1181
- #popupOpened;
1182
- constructor() {
1183
- this.#destroyRef = inject(DestroyRef);
1184
- this.#document = inject(DOCUMENT);
1185
- this.#popupService = inject(PopupService);
1186
- this.#eventListenerCleanup$ = new Subject();
1187
- this.#popupOpened = false;
1188
- this.contentTemplate = viewChild.required(TemplateRef, /* @ts-ignore */
1189
- ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
1190
- this.popupRef = null;
1191
- /**
1192
- * @description The anchor element or point for the popup.
1193
- */
1194
- this.anchor = input.required(/* @ts-ignore */
1195
- ...(ngDevMode ? [{ debugName: "anchor" }] : /* istanbul ignore next */ []));
1196
- /**
1197
- * @description The connection point for the popup anchor.
1198
- */
1199
- this.anchorConnectionPoint = input("bottomcenter", /* @ts-ignore */
1200
- ...(ngDevMode ? [{ debugName: "anchorConnectionPoint" }] : /* istanbul ignore next */ []));
1201
- /**
1202
- * @description The animation settings for the popup.
1203
- */
1204
- this.animation = input(true, /* @ts-ignore */
1205
- ...(ngDevMode ? [{ debugName: "animation" }] : /* istanbul ignore next */ []));
1206
- /**
1207
- * @description The class or classes to apply to the backdrop of the popup.
1208
- */
1209
- this.backdropClass = input([], /* @ts-ignore */
1210
- ...(ngDevMode ? [{ debugName: "backdropClass" }] : /* istanbul ignore next */ []));
1211
- /**
1212
- * @description Emits when the popup is closed.
1213
- */
1214
- // eslint-disable-next-line @angular-eslint/no-output-native -- public API name, kept for compatibility.
1215
- this.close = output();
1216
- /**
1217
- * @description Whether to close the popup when clicking on the backdrop.
1218
- * Only applies when the popup has a backdrop.
1219
- */
1220
- this.closeOnBackdropClick = input(true, { ...(ngDevMode ? { debugName: "closeOnBackdropClick" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1221
- /**
1222
- * @description Whether to close the popup when the escape key is pressed.
1223
- * Escape only reaches the topmost open popup.
1224
- */
1225
- this.closeOnEscape = input(true, { ...(ngDevMode ? { debugName: "closeOnEscape" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1226
- /**
1227
- * @description Whether to close the popup when the mouse leaves the anchor element.
1228
- */
1229
- this.closeOnMouseLeave = input(false, { ...(ngDevMode ? { debugName: "closeOnMouseLeave" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1230
- /**
1231
- * @description Whether to close the popup when clicking outside of it.
1232
- */
1233
- this.closeOnOutsideClick = input(true, { ...(ngDevMode ? { debugName: "closeOnOutsideClick" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1234
- /**
1235
- * @description Whether to close the popup when the user scrolls the page or a scrollable container around the anchor.
1236
- */
1237
- this.closeOnScroll = input(false, { ...(ngDevMode ? { debugName: "closeOnScroll" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1238
- /**
1239
- * @description Arbitrary data to pass to the popup.
1240
- */
1241
- this.data = input(/* @ts-ignore */
1242
- ...(ngDevMode ? [undefined, { debugName: "data" }] : /* istanbul ignore next */ []));
1243
- /**
1244
- * @description Whether the popup should have a backdrop.
1245
- */
1246
- this.hasBackdrop = input(false, { ...(ngDevMode ? { debugName: "hasBackdrop" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1247
- /**
1248
- * @description The height of the popup.
1249
- */
1250
- this.height = input(/* @ts-ignore */
1251
- ...(ngDevMode ? [undefined, { debugName: "height" }] : /* istanbul ignore next */ []));
1252
- /**
1253
- * @description The maximum height of the popup.
1254
- */
1255
- this.maxHeight = input(/* @ts-ignore */
1256
- ...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : /* istanbul ignore next */ []));
1257
- /**
1258
- * @description The maximum width of the popup.
1259
- */
1260
- this.maxWidth = input(/* @ts-ignore */
1261
- ...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : /* istanbul ignore next */ []));
1262
- /**
1263
- * @description The minimum height of the popup.
1264
- */
1265
- this.minHeight = input(/* @ts-ignore */
1266
- ...(ngDevMode ? [undefined, { debugName: "minHeight" }] : /* istanbul ignore next */ []));
1267
- /**
1268
- * @description The minimum width of the popup.
1269
- */
1270
- this.minWidth = input(/* @ts-ignore */
1271
- ...(ngDevMode ? [undefined, { debugName: "minWidth" }] : /* istanbul ignore next */ []));
1272
- /**
1273
- * @description The offset of the popup from the anchor.
1274
- */
1275
- this.offset = input(/* @ts-ignore */
1276
- ...(ngDevMode ? [undefined, { debugName: "offset" }] : /* istanbul ignore next */ []));
1277
- /**
1278
- * @description Emits when the popup is opened.
1279
- */
1280
- this.open = output();
1281
- /**
1282
- * @description The class or classes to apply to the popup.
1283
- */
1284
- this.popupClass = input([], /* @ts-ignore */
1285
- ...(ngDevMode ? [{ debugName: "popupClass" }] : /* istanbul ignore next */ []));
1286
- /**
1287
- * @description The connection point for the popup.
1288
- */
1289
- this.popupConnectionPoint = input("topcenter", /* @ts-ignore */
1290
- ...(ngDevMode ? [{ debugName: "popupConnectionPoint" }] : /* istanbul ignore next */ []));
1291
- /**
1292
- * @description The class or classes to apply to the popup wrapper.
1293
- */
1294
- this.popupWrapperClass = input([], /* @ts-ignore */
1295
- ...(ngDevMode ? [{ debugName: "popupWrapperClass" }] : /* istanbul ignore next */ []));
1296
- /**
1297
- * @description The strategy for positioning the popup.
1298
- * `global` means the popup will be positioned relative to the viewport,
1299
- * `connected` means the popup will be positioned relative to the anchor element.
1300
- */
1301
- this.positionStrategy = input("connected", /* @ts-ignore */
1302
- ...(ngDevMode ? [{ debugName: "positionStrategy" }] : /* istanbul ignore next */ []));
1303
- /**
1304
- * @description The positions to use for the popup.
1305
- * The popup will try to position itself in the first position that fits.
1306
- * This is only used when the `positionStrategy` is set to `connected`.
1307
- */
1308
- this.positions = input(/* @ts-ignore */
1309
- ...(ngDevMode ? [undefined, { debugName: "positions" }] : /* istanbul ignore next */ []));
1310
- /**
1311
- * @description Called when the popup is requested to close.
1312
- * This can be used to prevent the popup from closing.
1313
- */
1314
- this.preventClose = input(/* @ts-ignore */
1315
- ...(ngDevMode ? [undefined, { debugName: "preventClose" }] : /* istanbul ignore next */ []));
1316
- /**
1317
- * @description The providers that will be injected into the popup.
1318
- */
1319
- this.providers = input([], /* @ts-ignore */
1320
- ...(ngDevMode ? [{ debugName: "providers" }] : /* istanbul ignore next */ []));
1321
- /**
1322
- * @description Controls focus restoration when the popup closes.
1323
- * - `true`: always restore focus to the anchor element.
1324
- * - `false`: never restore focus (recommended for tooltips).
1325
- * - `"auto"`: restore focus only if the anchor, or an element inside it, was focused when the popup opened.
1326
- *
1327
- * Focus is left alone if the user moved it outside the popup and the anchor before it closed.
1328
- */
1329
- this.restoreFocus = input("auto", { ...(ngDevMode ? { debugName: "restoreFocus" } : /* istanbul ignore next */ {}), transform: (value) => (value === "auto" ? "auto" : booleanAttribute(value)) });
1330
- /**
1331
- * @description The trigger event for opening the popup.
1332
- */
1333
- this.trigger = input("click", /* @ts-ignore */
1334
- ...(ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []));
1335
- /**
1336
- * @description The width of the popup.
1337
- */
1338
- this.width = input(undefined, /* @ts-ignore */
1339
- ...(ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []));
1340
- /**
1341
- * @description Whether to push the popup into the screen when it is opened.
1342
- */
1343
- this.withPush = input(true, { ...(ngDevMode ? { debugName: "withPush" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1344
- /**
1345
- * @description Whether the popup should track scroll events and reposition itself.
1346
- */
1347
- this.withScrollTracking = input(true, { ...(ngDevMode ? { debugName: "withScrollTracking" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
1348
- effect(() => this.setupEventListeners());
1349
- }
1350
- /** Closes the popup if one is currently open. */
1351
- closePopup() {
1352
- this.popupRef?.close();
1353
- }
1354
- ngOnDestroy() {
1355
- this.popupRef?.close();
1356
- this.#eventListenerCleanup$.next();
1357
- this.#eventListenerCleanup$.complete();
1358
- }
1359
- getPopupWidth() {
1360
- const width = this.width();
1361
- if (width != null) {
1362
- return width;
1363
- }
1364
- const anchor = this.anchor();
1365
- if (anchor instanceof HTMLElement) {
1366
- return anchor.getBoundingClientRect().width;
1367
- }
1368
- if (anchor instanceof ElementRef) {
1369
- return anchor.nativeElement.getBoundingClientRect().width;
1370
- }
1371
- return undefined;
1372
- }
1373
- setupEventListeners() {
1374
- // Clean up previous event listeners
1375
- this.#eventListenerCleanup$.next();
1376
- const trigger = this.trigger();
1377
- const anchor = this.anchor();
1378
- if (!trigger || !anchor) {
1379
- return;
1380
- }
1381
- let pointAnchor = false;
1382
- let target;
1383
- if (anchor instanceof ElementRef) {
1384
- target = anchor.nativeElement;
1385
- }
1386
- else if (anchor instanceof HTMLElement) {
1387
- target = anchor;
1388
- }
1389
- else {
1390
- target = this.#document.body;
1391
- pointAnchor = true;
1392
- }
1393
- fromEvent(target, trigger)
1394
- .pipe(takeUntil(this.#eventListenerCleanup$), takeUntilDestroyed(this.#destroyRef))
1395
- .subscribe(event => {
1396
- event.preventDefault();
1397
- if (this.#popupOpened) {
1398
- this.#popupOpened = false;
1399
- return;
1400
- }
1401
- if (this.popupRef !== null) {
1402
- this.popupRef.close();
1403
- return;
1404
- }
1405
- const popupSettings = {
1406
- anchor,
1407
- anchorConnectionPoint: this.anchorConnectionPoint(),
1408
- animation: this.animation(),
1409
- backdropClass: this.backdropClass(),
1410
- closeOnBackdropClick: this.closeOnBackdropClick(),
1411
- closeOnEscape: this.closeOnEscape(),
1412
- closeOnMouseLeave: this.closeOnMouseLeave(),
1413
- closeOnOutsideClick: this.closeOnOutsideClick(),
1414
- closeOnScroll: this.closeOnScroll(),
1415
- content: this.contentTemplate(),
1416
- data: this.data(),
1417
- hasBackdrop: this.hasBackdrop(),
1418
- height: this.height(),
1419
- maxHeight: this.maxHeight(),
1420
- maxWidth: this.maxWidth(),
1421
- minHeight: this.minHeight(),
1422
- minWidth: this.minWidth(),
1423
- offset: this.offset(),
1424
- popupClass: this.popupClass(),
1425
- popupConnectionPoint: this.popupConnectionPoint(),
1426
- popupWrapperClass: this.popupWrapperClass(),
1427
- positionStrategy: this.positionStrategy(),
1428
- positions: this.positions(),
1429
- preventClose: this.preventClose(),
1430
- providers: this.providers(),
1431
- restoreFocus: this.restoreFocus(),
1432
- // Measured now rather than when the listener was set up, so it follows the anchor's size.
1433
- width: this.getPopupWidth(),
1434
- withPush: this.withPush(),
1435
- withScrollTracking: this.withScrollTracking()
1436
- };
1437
- this.popupRef = this.#popupService.create(popupSettings);
1438
- this.popupRef.closed.pipe(take(1)).subscribe(result => {
1439
- this.popupRef = null;
1440
- this.close.emit();
1441
- if (result instanceof PopupCloseEvent) {
1442
- if (!result.originalEvent) {
1443
- this.#popupOpened = false;
1444
- }
1445
- else if (result.originalEvent instanceof PointerEvent &&
1446
- result.originalEvent.type === trigger) {
1447
- this.#popupOpened =
1448
- target instanceof HTMLElement &&
1449
- target.contains(result.originalEvent.target);
1450
- }
1451
- else if (result.originalEvent instanceof PointerEvent &&
1452
- pointAnchor &&
1453
- result.originalEvent.type !== trigger) {
1454
- this.#popupOpened = false;
1455
- }
1456
- }
1457
- });
1458
- if (pointAnchor) {
1459
- this.#popupOpened = true;
1460
- }
1461
- this.open.emit(this.popupRef);
1462
- });
1463
- }
1464
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
1465
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: PopupComponent, isStandalone: true, selector: "mona-popup", inputs: { anchor: { classPropertyName: "anchor", publicName: "anchor", isSignal: true, isRequired: true, transformFunction: null }, anchorConnectionPoint: { classPropertyName: "anchorConnectionPoint", publicName: "anchorConnectionPoint", isSignal: true, isRequired: false, transformFunction: null }, animation: { classPropertyName: "animation", publicName: "animation", isSignal: true, isRequired: false, transformFunction: null }, backdropClass: { classPropertyName: "backdropClass", publicName: "backdropClass", isSignal: true, isRequired: false, transformFunction: null }, closeOnBackdropClick: { classPropertyName: "closeOnBackdropClick", publicName: "closeOnBackdropClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, closeOnMouseLeave: { classPropertyName: "closeOnMouseLeave", publicName: "closeOnMouseLeave", isSignal: true, isRequired: false, transformFunction: null }, closeOnOutsideClick: { classPropertyName: "closeOnOutsideClick", publicName: "closeOnOutsideClick", isSignal: true, isRequired: false, transformFunction: null }, closeOnScroll: { classPropertyName: "closeOnScroll", publicName: "closeOnScroll", isSignal: true, isRequired: false, transformFunction: null }, data: { classPropertyName: "data", publicName: "data", isSignal: true, isRequired: false, transformFunction: null }, hasBackdrop: { classPropertyName: "hasBackdrop", publicName: "hasBackdrop", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, maxHeight: { classPropertyName: "maxHeight", publicName: "maxHeight", isSignal: true, isRequired: false, transformFunction: null }, maxWidth: { classPropertyName: "maxWidth", publicName: "maxWidth", isSignal: true, isRequired: false, transformFunction: null }, minHeight: { classPropertyName: "minHeight", publicName: "minHeight", isSignal: true, isRequired: false, transformFunction: null }, minWidth: { classPropertyName: "minWidth", publicName: "minWidth", isSignal: true, isRequired: false, transformFunction: null }, offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null }, popupClass: { classPropertyName: "popupClass", publicName: "popupClass", isSignal: true, isRequired: false, transformFunction: null }, popupConnectionPoint: { classPropertyName: "popupConnectionPoint", publicName: "popupConnectionPoint", isSignal: true, isRequired: false, transformFunction: null }, popupWrapperClass: { classPropertyName: "popupWrapperClass", publicName: "popupWrapperClass", isSignal: true, isRequired: false, transformFunction: null }, positionStrategy: { classPropertyName: "positionStrategy", publicName: "positionStrategy", isSignal: true, isRequired: false, transformFunction: null }, positions: { classPropertyName: "positions", publicName: "positions", isSignal: true, isRequired: false, transformFunction: null }, preventClose: { classPropertyName: "preventClose", publicName: "preventClose", isSignal: true, isRequired: false, transformFunction: null }, providers: { classPropertyName: "providers", publicName: "providers", isSignal: true, isRequired: false, transformFunction: null }, restoreFocus: { classPropertyName: "restoreFocus", publicName: "restoreFocus", isSignal: true, isRequired: false, transformFunction: null }, trigger: { classPropertyName: "trigger", publicName: "trigger", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null }, withPush: { classPropertyName: "withPush", publicName: "withPush", isSignal: true, isRequired: false, transformFunction: null }, withScrollTracking: { classPropertyName: "withScrollTracking", publicName: "withScrollTracking", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { close: "close", open: "open" }, viewQueries: [{ propertyName: "contentTemplate", first: true, predicate: TemplateRef, descendants: true, isSignal: true }], ngImport: i0, template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>\n" }); }
1466
- }
1467
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: PopupComponent, decorators: [{
1468
- type: Component,
1469
- args: [{ selector: "mona-popup", template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>\n" }]
1470
- }], ctorParameters: () => [], propDecorators: { contentTemplate: [{ type: i0.ViewChild, args: [i0.forwardRef(() => TemplateRef), { isSignal: true }] }], anchor: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchor", required: true }] }], anchorConnectionPoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "anchorConnectionPoint", required: false }] }], animation: [{ type: i0.Input, args: [{ isSignal: true, alias: "animation", required: false }] }], backdropClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "backdropClass", required: false }] }], close: [{ type: i0.Output, args: ["close"] }], closeOnBackdropClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnBackdropClick", required: false }] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], closeOnMouseLeave: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnMouseLeave", required: false }] }], closeOnOutsideClick: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnOutsideClick", required: false }] }], closeOnScroll: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnScroll", required: false }] }], data: [{ type: i0.Input, args: [{ isSignal: true, alias: "data", required: false }] }], hasBackdrop: [{ type: i0.Input, args: [{ isSignal: true, alias: "hasBackdrop", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], open: [{ type: i0.Output, args: ["open"] }], popupClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupClass", required: false }] }], popupConnectionPoint: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupConnectionPoint", required: false }] }], popupWrapperClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "popupWrapperClass", required: false }] }], positionStrategy: [{ type: i0.Input, args: [{ isSignal: true, alias: "positionStrategy", required: false }] }], positions: [{ type: i0.Input, args: [{ isSignal: true, alias: "positions", required: false }] }], preventClose: [{ type: i0.Input, args: [{ isSignal: true, alias: "preventClose", required: false }] }], providers: [{ type: i0.Input, args: [{ isSignal: true, alias: "providers", required: false }] }], restoreFocus: [{ type: i0.Input, args: [{ isSignal: true, alias: "restoreFocus", required: false }] }], trigger: [{ type: i0.Input, args: [{ isSignal: true, alias: "trigger", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }], withPush: [{ type: i0.Input, args: [{ isSignal: true, alias: "withPush", required: false }] }], withScrollTracking: [{ type: i0.Input, args: [{ isSignal: true, alias: "withScrollTracking", required: false }] }] } });
1471
-
1472
- /*
1473
- * Public API Surface of @nanahoshi/mona-ui/popup
1474
- */
1475
-
1476
- /**
1477
- * Generated bundle index. Do not edit.
1478
- */
1479
-
1026
+ var PopupComponent = class PopupComponent {
1027
+ #destroyRef;
1028
+ #document;
1029
+ #popupService;
1030
+ #eventListenerCleanup$;
1031
+ #popupOpened;
1032
+ constructor() {
1033
+ this.#destroyRef = inject(DestroyRef);
1034
+ this.#document = inject(DOCUMENT);
1035
+ this.#popupService = inject(PopupService);
1036
+ this.#eventListenerCleanup$ = new Subject();
1037
+ this.#popupOpened = false;
1038
+ this.contentTemplate = viewChild.required(TemplateRef, ...ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []);
1039
+ this.popupRef = null;
1040
+ this.anchor = input.required(...ngDevMode ? [{ debugName: "anchor" }] : /* istanbul ignore next */ []);
1041
+ this.anchorConnectionPoint = input("bottomcenter", ...ngDevMode ? [{ debugName: "anchorConnectionPoint" }] : /* istanbul ignore next */ []);
1042
+ this.animation = input(true, ...ngDevMode ? [{ debugName: "animation" }] : /* istanbul ignore next */ []);
1043
+ this.backdropClass = input([], ...ngDevMode ? [{ debugName: "backdropClass" }] : /* istanbul ignore next */ []);
1044
+ this.close = output();
1045
+ this.closeOnBackdropClick = input(true, {
1046
+ ...ngDevMode ? { debugName: "closeOnBackdropClick" } : /* istanbul ignore next */ {},
1047
+ transform: booleanAttribute
1048
+ });
1049
+ this.closeOnEscape = input(true, {
1050
+ ...ngDevMode ? { debugName: "closeOnEscape" } : /* istanbul ignore next */ {},
1051
+ transform: booleanAttribute
1052
+ });
1053
+ this.closeOnMouseLeave = input(false, {
1054
+ ...ngDevMode ? { debugName: "closeOnMouseLeave" } : /* istanbul ignore next */ {},
1055
+ transform: booleanAttribute
1056
+ });
1057
+ this.closeOnOutsideClick = input(true, {
1058
+ ...ngDevMode ? { debugName: "closeOnOutsideClick" } : /* istanbul ignore next */ {},
1059
+ transform: booleanAttribute
1060
+ });
1061
+ this.closeOnScroll = input(false, {
1062
+ ...ngDevMode ? { debugName: "closeOnScroll" } : /* istanbul ignore next */ {},
1063
+ transform: booleanAttribute
1064
+ });
1065
+ this.data = input(...ngDevMode ? [void 0, { debugName: "data" }] : /* istanbul ignore next */ []);
1066
+ this.hasBackdrop = input(false, {
1067
+ ...ngDevMode ? { debugName: "hasBackdrop" } : /* istanbul ignore next */ {},
1068
+ transform: booleanAttribute
1069
+ });
1070
+ this.height = input(...ngDevMode ? [void 0, { debugName: "height" }] : /* istanbul ignore next */ []);
1071
+ this.maxHeight = input(...ngDevMode ? [void 0, { debugName: "maxHeight" }] : /* istanbul ignore next */ []);
1072
+ this.maxWidth = input(...ngDevMode ? [void 0, { debugName: "maxWidth" }] : /* istanbul ignore next */ []);
1073
+ this.minHeight = input(...ngDevMode ? [void 0, { debugName: "minHeight" }] : /* istanbul ignore next */ []);
1074
+ this.minWidth = input(...ngDevMode ? [void 0, { debugName: "minWidth" }] : /* istanbul ignore next */ []);
1075
+ this.offset = input(...ngDevMode ? [void 0, { debugName: "offset" }] : /* istanbul ignore next */ []);
1076
+ this.open = output();
1077
+ this.popupClass = input([], ...ngDevMode ? [{ debugName: "popupClass" }] : /* istanbul ignore next */ []);
1078
+ this.popupConnectionPoint = input("topcenter", ...ngDevMode ? [{ debugName: "popupConnectionPoint" }] : /* istanbul ignore next */ []);
1079
+ this.popupWrapperClass = input([], ...ngDevMode ? [{ debugName: "popupWrapperClass" }] : /* istanbul ignore next */ []);
1080
+ this.positionStrategy = input("connected", ...ngDevMode ? [{ debugName: "positionStrategy" }] : /* istanbul ignore next */ []);
1081
+ this.positions = input(...ngDevMode ? [void 0, { debugName: "positions" }] : /* istanbul ignore next */ []);
1082
+ this.preventClose = input(...ngDevMode ? [void 0, { debugName: "preventClose" }] : /* istanbul ignore next */ []);
1083
+ this.providers = input([], ...ngDevMode ? [{ debugName: "providers" }] : /* istanbul ignore next */ []);
1084
+ this.restoreFocus = input("auto", {
1085
+ ...ngDevMode ? { debugName: "restoreFocus" } : /* istanbul ignore next */ {},
1086
+ transform: (value) => value === "auto" ? "auto" : booleanAttribute(value)
1087
+ });
1088
+ this.trigger = input("click", ...ngDevMode ? [{ debugName: "trigger" }] : /* istanbul ignore next */ []);
1089
+ this.width = input(void 0, ...ngDevMode ? [{ debugName: "width" }] : /* istanbul ignore next */ []);
1090
+ this.withPush = input(true, {
1091
+ ...ngDevMode ? { debugName: "withPush" } : /* istanbul ignore next */ {},
1092
+ transform: booleanAttribute
1093
+ });
1094
+ this.withScrollTracking = input(true, {
1095
+ ...ngDevMode ? { debugName: "withScrollTracking" } : /* istanbul ignore next */ {},
1096
+ transform: booleanAttribute
1097
+ });
1098
+ effect(() => this.setupEventListeners());
1099
+ }
1100
+ closePopup() {
1101
+ this.popupRef?.close();
1102
+ }
1103
+ ngOnDestroy() {
1104
+ this.popupRef?.close();
1105
+ this.#eventListenerCleanup$.next();
1106
+ this.#eventListenerCleanup$.complete();
1107
+ }
1108
+ getPopupWidth() {
1109
+ const width = this.width();
1110
+ if (width != null) return width;
1111
+ const anchor = this.anchor();
1112
+ if (anchor instanceof HTMLElement) return anchor.getBoundingClientRect().width;
1113
+ if (anchor instanceof ElementRef) return anchor.nativeElement.getBoundingClientRect().width;
1114
+ }
1115
+ setupEventListeners() {
1116
+ this.#eventListenerCleanup$.next();
1117
+ const trigger = this.trigger();
1118
+ const anchor = this.anchor();
1119
+ if (!trigger || !anchor) return;
1120
+ let pointAnchor = false;
1121
+ let target;
1122
+ if (anchor instanceof ElementRef) target = anchor.nativeElement;
1123
+ else if (anchor instanceof HTMLElement) target = anchor;
1124
+ else {
1125
+ target = this.#document.body;
1126
+ pointAnchor = true;
1127
+ }
1128
+ fromEvent(target, trigger).pipe(takeUntil(this.#eventListenerCleanup$), takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
1129
+ event.preventDefault();
1130
+ if (this.#popupOpened) {
1131
+ this.#popupOpened = false;
1132
+ return;
1133
+ }
1134
+ if (this.popupRef !== null) {
1135
+ this.popupRef.close();
1136
+ return;
1137
+ }
1138
+ const popupSettings = {
1139
+ anchor,
1140
+ anchorConnectionPoint: this.anchorConnectionPoint(),
1141
+ animation: this.animation(),
1142
+ backdropClass: this.backdropClass(),
1143
+ closeOnBackdropClick: this.closeOnBackdropClick(),
1144
+ closeOnEscape: this.closeOnEscape(),
1145
+ closeOnMouseLeave: this.closeOnMouseLeave(),
1146
+ closeOnOutsideClick: this.closeOnOutsideClick(),
1147
+ closeOnScroll: this.closeOnScroll(),
1148
+ content: this.contentTemplate(),
1149
+ data: this.data(),
1150
+ hasBackdrop: this.hasBackdrop(),
1151
+ height: this.height(),
1152
+ maxHeight: this.maxHeight(),
1153
+ maxWidth: this.maxWidth(),
1154
+ minHeight: this.minHeight(),
1155
+ minWidth: this.minWidth(),
1156
+ offset: this.offset(),
1157
+ popupClass: this.popupClass(),
1158
+ popupConnectionPoint: this.popupConnectionPoint(),
1159
+ popupWrapperClass: this.popupWrapperClass(),
1160
+ positionStrategy: this.positionStrategy(),
1161
+ positions: this.positions(),
1162
+ preventClose: this.preventClose(),
1163
+ providers: this.providers(),
1164
+ restoreFocus: this.restoreFocus(),
1165
+ width: this.getPopupWidth(),
1166
+ withPush: this.withPush(),
1167
+ withScrollTracking: this.withScrollTracking()
1168
+ };
1169
+ this.popupRef = this.#popupService.create(popupSettings);
1170
+ this.popupRef.closed.pipe(take(1)).subscribe((result) => {
1171
+ this.popupRef = null;
1172
+ this.close.emit();
1173
+ if (result instanceof PopupCloseEvent) {
1174
+ if (!result.originalEvent) this.#popupOpened = false;
1175
+ else if (result.originalEvent instanceof PointerEvent && result.originalEvent.type === trigger) this.#popupOpened = target instanceof HTMLElement && target.contains(result.originalEvent.target);
1176
+ else if (result.originalEvent instanceof PointerEvent && pointAnchor && result.originalEvent.type !== trigger) this.#popupOpened = false;
1177
+ }
1178
+ });
1179
+ if (pointAnchor) this.#popupOpened = true;
1180
+ this.open.emit(this.popupRef);
1181
+ });
1182
+ }
1183
+ static {
1184
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1185
+ minVersion: "12.0.0",
1186
+ version: "22.2.6",
1187
+ ngImport: i0,
1188
+ type: PopupComponent,
1189
+ deps: [],
1190
+ target: i0.ɵɵFactoryTarget.Component
1191
+ });
1192
+ }
1193
+ static {
1194
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1195
+ minVersion: "17.2.0",
1196
+ version: "22.2.6",
1197
+ type: PopupComponent,
1198
+ isStandalone: true,
1199
+ selector: "mona-popup",
1200
+ inputs: {
1201
+ anchor: {
1202
+ classPropertyName: "anchor",
1203
+ publicName: "anchor",
1204
+ isSignal: true,
1205
+ isRequired: true,
1206
+ transformFunction: null
1207
+ },
1208
+ anchorConnectionPoint: {
1209
+ classPropertyName: "anchorConnectionPoint",
1210
+ publicName: "anchorConnectionPoint",
1211
+ isSignal: true,
1212
+ isRequired: false,
1213
+ transformFunction: null
1214
+ },
1215
+ animation: {
1216
+ classPropertyName: "animation",
1217
+ publicName: "animation",
1218
+ isSignal: true,
1219
+ isRequired: false,
1220
+ transformFunction: null
1221
+ },
1222
+ backdropClass: {
1223
+ classPropertyName: "backdropClass",
1224
+ publicName: "backdropClass",
1225
+ isSignal: true,
1226
+ isRequired: false,
1227
+ transformFunction: null
1228
+ },
1229
+ closeOnBackdropClick: {
1230
+ classPropertyName: "closeOnBackdropClick",
1231
+ publicName: "closeOnBackdropClick",
1232
+ isSignal: true,
1233
+ isRequired: false,
1234
+ transformFunction: null
1235
+ },
1236
+ closeOnEscape: {
1237
+ classPropertyName: "closeOnEscape",
1238
+ publicName: "closeOnEscape",
1239
+ isSignal: true,
1240
+ isRequired: false,
1241
+ transformFunction: null
1242
+ },
1243
+ closeOnMouseLeave: {
1244
+ classPropertyName: "closeOnMouseLeave",
1245
+ publicName: "closeOnMouseLeave",
1246
+ isSignal: true,
1247
+ isRequired: false,
1248
+ transformFunction: null
1249
+ },
1250
+ closeOnOutsideClick: {
1251
+ classPropertyName: "closeOnOutsideClick",
1252
+ publicName: "closeOnOutsideClick",
1253
+ isSignal: true,
1254
+ isRequired: false,
1255
+ transformFunction: null
1256
+ },
1257
+ closeOnScroll: {
1258
+ classPropertyName: "closeOnScroll",
1259
+ publicName: "closeOnScroll",
1260
+ isSignal: true,
1261
+ isRequired: false,
1262
+ transformFunction: null
1263
+ },
1264
+ data: {
1265
+ classPropertyName: "data",
1266
+ publicName: "data",
1267
+ isSignal: true,
1268
+ isRequired: false,
1269
+ transformFunction: null
1270
+ },
1271
+ hasBackdrop: {
1272
+ classPropertyName: "hasBackdrop",
1273
+ publicName: "hasBackdrop",
1274
+ isSignal: true,
1275
+ isRequired: false,
1276
+ transformFunction: null
1277
+ },
1278
+ height: {
1279
+ classPropertyName: "height",
1280
+ publicName: "height",
1281
+ isSignal: true,
1282
+ isRequired: false,
1283
+ transformFunction: null
1284
+ },
1285
+ maxHeight: {
1286
+ classPropertyName: "maxHeight",
1287
+ publicName: "maxHeight",
1288
+ isSignal: true,
1289
+ isRequired: false,
1290
+ transformFunction: null
1291
+ },
1292
+ maxWidth: {
1293
+ classPropertyName: "maxWidth",
1294
+ publicName: "maxWidth",
1295
+ isSignal: true,
1296
+ isRequired: false,
1297
+ transformFunction: null
1298
+ },
1299
+ minHeight: {
1300
+ classPropertyName: "minHeight",
1301
+ publicName: "minHeight",
1302
+ isSignal: true,
1303
+ isRequired: false,
1304
+ transformFunction: null
1305
+ },
1306
+ minWidth: {
1307
+ classPropertyName: "minWidth",
1308
+ publicName: "minWidth",
1309
+ isSignal: true,
1310
+ isRequired: false,
1311
+ transformFunction: null
1312
+ },
1313
+ offset: {
1314
+ classPropertyName: "offset",
1315
+ publicName: "offset",
1316
+ isSignal: true,
1317
+ isRequired: false,
1318
+ transformFunction: null
1319
+ },
1320
+ popupClass: {
1321
+ classPropertyName: "popupClass",
1322
+ publicName: "popupClass",
1323
+ isSignal: true,
1324
+ isRequired: false,
1325
+ transformFunction: null
1326
+ },
1327
+ popupConnectionPoint: {
1328
+ classPropertyName: "popupConnectionPoint",
1329
+ publicName: "popupConnectionPoint",
1330
+ isSignal: true,
1331
+ isRequired: false,
1332
+ transformFunction: null
1333
+ },
1334
+ popupWrapperClass: {
1335
+ classPropertyName: "popupWrapperClass",
1336
+ publicName: "popupWrapperClass",
1337
+ isSignal: true,
1338
+ isRequired: false,
1339
+ transformFunction: null
1340
+ },
1341
+ positionStrategy: {
1342
+ classPropertyName: "positionStrategy",
1343
+ publicName: "positionStrategy",
1344
+ isSignal: true,
1345
+ isRequired: false,
1346
+ transformFunction: null
1347
+ },
1348
+ positions: {
1349
+ classPropertyName: "positions",
1350
+ publicName: "positions",
1351
+ isSignal: true,
1352
+ isRequired: false,
1353
+ transformFunction: null
1354
+ },
1355
+ preventClose: {
1356
+ classPropertyName: "preventClose",
1357
+ publicName: "preventClose",
1358
+ isSignal: true,
1359
+ isRequired: false,
1360
+ transformFunction: null
1361
+ },
1362
+ providers: {
1363
+ classPropertyName: "providers",
1364
+ publicName: "providers",
1365
+ isSignal: true,
1366
+ isRequired: false,
1367
+ transformFunction: null
1368
+ },
1369
+ restoreFocus: {
1370
+ classPropertyName: "restoreFocus",
1371
+ publicName: "restoreFocus",
1372
+ isSignal: true,
1373
+ isRequired: false,
1374
+ transformFunction: null
1375
+ },
1376
+ trigger: {
1377
+ classPropertyName: "trigger",
1378
+ publicName: "trigger",
1379
+ isSignal: true,
1380
+ isRequired: false,
1381
+ transformFunction: null
1382
+ },
1383
+ width: {
1384
+ classPropertyName: "width",
1385
+ publicName: "width",
1386
+ isSignal: true,
1387
+ isRequired: false,
1388
+ transformFunction: null
1389
+ },
1390
+ withPush: {
1391
+ classPropertyName: "withPush",
1392
+ publicName: "withPush",
1393
+ isSignal: true,
1394
+ isRequired: false,
1395
+ transformFunction: null
1396
+ },
1397
+ withScrollTracking: {
1398
+ classPropertyName: "withScrollTracking",
1399
+ publicName: "withScrollTracking",
1400
+ isSignal: true,
1401
+ isRequired: false,
1402
+ transformFunction: null
1403
+ }
1404
+ },
1405
+ outputs: {
1406
+ close: "close",
1407
+ open: "open"
1408
+ },
1409
+ viewQueries: [{
1410
+ propertyName: "contentTemplate",
1411
+ first: true,
1412
+ predicate: TemplateRef,
1413
+ descendants: true,
1414
+ isSignal: true
1415
+ }],
1416
+ ngImport: i0,
1417
+ template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>\n"
1418
+ });
1419
+ }
1420
+ };
1421
+ i0.ɵɵngDeclareClassMetadata({
1422
+ minVersion: "12.0.0",
1423
+ version: "22.2.6",
1424
+ ngImport: i0,
1425
+ type: PopupComponent,
1426
+ decorators: [{
1427
+ type: Component,
1428
+ args: [{
1429
+ selector: "mona-popup",
1430
+ template: "<ng-template>\n <ng-content></ng-content>\n</ng-template>\n"
1431
+ }]
1432
+ }],
1433
+ ctorParameters: () => [],
1434
+ propDecorators: {
1435
+ contentTemplate: [{
1436
+ type: i0.ViewChild,
1437
+ args: [i0.forwardRef(() => TemplateRef), { isSignal: true }]
1438
+ }],
1439
+ anchor: [{
1440
+ type: i0.Input,
1441
+ args: [{
1442
+ isSignal: true,
1443
+ alias: "anchor",
1444
+ required: true
1445
+ }]
1446
+ }],
1447
+ anchorConnectionPoint: [{
1448
+ type: i0.Input,
1449
+ args: [{
1450
+ isSignal: true,
1451
+ alias: "anchorConnectionPoint",
1452
+ required: false
1453
+ }]
1454
+ }],
1455
+ animation: [{
1456
+ type: i0.Input,
1457
+ args: [{
1458
+ isSignal: true,
1459
+ alias: "animation",
1460
+ required: false
1461
+ }]
1462
+ }],
1463
+ backdropClass: [{
1464
+ type: i0.Input,
1465
+ args: [{
1466
+ isSignal: true,
1467
+ alias: "backdropClass",
1468
+ required: false
1469
+ }]
1470
+ }],
1471
+ close: [{
1472
+ type: i0.Output,
1473
+ args: ["close"]
1474
+ }],
1475
+ closeOnBackdropClick: [{
1476
+ type: i0.Input,
1477
+ args: [{
1478
+ isSignal: true,
1479
+ alias: "closeOnBackdropClick",
1480
+ required: false
1481
+ }]
1482
+ }],
1483
+ closeOnEscape: [{
1484
+ type: i0.Input,
1485
+ args: [{
1486
+ isSignal: true,
1487
+ alias: "closeOnEscape",
1488
+ required: false
1489
+ }]
1490
+ }],
1491
+ closeOnMouseLeave: [{
1492
+ type: i0.Input,
1493
+ args: [{
1494
+ isSignal: true,
1495
+ alias: "closeOnMouseLeave",
1496
+ required: false
1497
+ }]
1498
+ }],
1499
+ closeOnOutsideClick: [{
1500
+ type: i0.Input,
1501
+ args: [{
1502
+ isSignal: true,
1503
+ alias: "closeOnOutsideClick",
1504
+ required: false
1505
+ }]
1506
+ }],
1507
+ closeOnScroll: [{
1508
+ type: i0.Input,
1509
+ args: [{
1510
+ isSignal: true,
1511
+ alias: "closeOnScroll",
1512
+ required: false
1513
+ }]
1514
+ }],
1515
+ data: [{
1516
+ type: i0.Input,
1517
+ args: [{
1518
+ isSignal: true,
1519
+ alias: "data",
1520
+ required: false
1521
+ }]
1522
+ }],
1523
+ hasBackdrop: [{
1524
+ type: i0.Input,
1525
+ args: [{
1526
+ isSignal: true,
1527
+ alias: "hasBackdrop",
1528
+ required: false
1529
+ }]
1530
+ }],
1531
+ height: [{
1532
+ type: i0.Input,
1533
+ args: [{
1534
+ isSignal: true,
1535
+ alias: "height",
1536
+ required: false
1537
+ }]
1538
+ }],
1539
+ maxHeight: [{
1540
+ type: i0.Input,
1541
+ args: [{
1542
+ isSignal: true,
1543
+ alias: "maxHeight",
1544
+ required: false
1545
+ }]
1546
+ }],
1547
+ maxWidth: [{
1548
+ type: i0.Input,
1549
+ args: [{
1550
+ isSignal: true,
1551
+ alias: "maxWidth",
1552
+ required: false
1553
+ }]
1554
+ }],
1555
+ minHeight: [{
1556
+ type: i0.Input,
1557
+ args: [{
1558
+ isSignal: true,
1559
+ alias: "minHeight",
1560
+ required: false
1561
+ }]
1562
+ }],
1563
+ minWidth: [{
1564
+ type: i0.Input,
1565
+ args: [{
1566
+ isSignal: true,
1567
+ alias: "minWidth",
1568
+ required: false
1569
+ }]
1570
+ }],
1571
+ offset: [{
1572
+ type: i0.Input,
1573
+ args: [{
1574
+ isSignal: true,
1575
+ alias: "offset",
1576
+ required: false
1577
+ }]
1578
+ }],
1579
+ open: [{
1580
+ type: i0.Output,
1581
+ args: ["open"]
1582
+ }],
1583
+ popupClass: [{
1584
+ type: i0.Input,
1585
+ args: [{
1586
+ isSignal: true,
1587
+ alias: "popupClass",
1588
+ required: false
1589
+ }]
1590
+ }],
1591
+ popupConnectionPoint: [{
1592
+ type: i0.Input,
1593
+ args: [{
1594
+ isSignal: true,
1595
+ alias: "popupConnectionPoint",
1596
+ required: false
1597
+ }]
1598
+ }],
1599
+ popupWrapperClass: [{
1600
+ type: i0.Input,
1601
+ args: [{
1602
+ isSignal: true,
1603
+ alias: "popupWrapperClass",
1604
+ required: false
1605
+ }]
1606
+ }],
1607
+ positionStrategy: [{
1608
+ type: i0.Input,
1609
+ args: [{
1610
+ isSignal: true,
1611
+ alias: "positionStrategy",
1612
+ required: false
1613
+ }]
1614
+ }],
1615
+ positions: [{
1616
+ type: i0.Input,
1617
+ args: [{
1618
+ isSignal: true,
1619
+ alias: "positions",
1620
+ required: false
1621
+ }]
1622
+ }],
1623
+ preventClose: [{
1624
+ type: i0.Input,
1625
+ args: [{
1626
+ isSignal: true,
1627
+ alias: "preventClose",
1628
+ required: false
1629
+ }]
1630
+ }],
1631
+ providers: [{
1632
+ type: i0.Input,
1633
+ args: [{
1634
+ isSignal: true,
1635
+ alias: "providers",
1636
+ required: false
1637
+ }]
1638
+ }],
1639
+ restoreFocus: [{
1640
+ type: i0.Input,
1641
+ args: [{
1642
+ isSignal: true,
1643
+ alias: "restoreFocus",
1644
+ required: false
1645
+ }]
1646
+ }],
1647
+ trigger: [{
1648
+ type: i0.Input,
1649
+ args: [{
1650
+ isSignal: true,
1651
+ alias: "trigger",
1652
+ required: false
1653
+ }]
1654
+ }],
1655
+ width: [{
1656
+ type: i0.Input,
1657
+ args: [{
1658
+ isSignal: true,
1659
+ alias: "width",
1660
+ required: false
1661
+ }]
1662
+ }],
1663
+ withPush: [{
1664
+ type: i0.Input,
1665
+ args: [{
1666
+ isSignal: true,
1667
+ alias: "withPush",
1668
+ required: false
1669
+ }]
1670
+ }],
1671
+ withScrollTracking: [{
1672
+ type: i0.Input,
1673
+ args: [{
1674
+ isSignal: true,
1675
+ alias: "withScrollTracking",
1676
+ required: false
1677
+ }]
1678
+ }]
1679
+ }
1680
+ });
1480
1681
  export { PopupCloseEvent, PopupCloseSource, PopupComponent, PopupDataInjectionToken, PopupRef, PopupService, defaultPopupAnimation, dropdownPopupAnimation, fadePopupAnimation, slideFromBottomPopupAnimation, slideFromLeftPopupAnimation, slideFromRightPopupAnimation, slideFromTopPopupAnimation };
1481
- //# sourceMappingURL=nanahoshi-mona-ui-popup.mjs.map
1682
+
1683
+ //# sourceMappingURL=nanahoshi-mona-ui-popup.mjs.map