@nanahoshi/mona-ui 0.27.2 → 0.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/docs/api/chart.md +2 -2
  2. package/docs/api/popup.md +1 -1
  3. package/docs/api/theme.md +2 -2
  4. package/docs/chart.md +14 -0
  5. package/docs/editor.md +2 -0
  6. package/docs/installation.md +147 -15
  7. package/docs/introduction.md +37 -15
  8. package/docs/theming-built-in-themes.md +67 -0
  9. package/docs/theming-custom-colors.md +274 -0
  10. package/docs/theming-custom-themes.md +168 -0
  11. package/docs/theming.md +164 -248
  12. package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +1089 -603
  13. package/fesm2022/nanahoshi-mona-ui-avatar.mjs +369 -184
  14. package/fesm2022/nanahoshi-mona-ui-breadcrumb.mjs +658 -371
  15. package/fesm2022/nanahoshi-mona-ui-button-group.mjs +513 -359
  16. package/fesm2022/nanahoshi-mona-ui-button.mjs +622 -517
  17. package/fesm2022/nanahoshi-mona-ui-calendar.mjs +2070 -1573
  18. package/fesm2022/nanahoshi-mona-ui-card.mjs +620 -316
  19. package/fesm2022/nanahoshi-mona-ui-chart.mjs +61151 -64921
  20. package/fesm2022/nanahoshi-mona-ui-check-box.mjs +646 -317
  21. package/fesm2022/nanahoshi-mona-ui-chip.mjs +737 -516
  22. package/fesm2022/nanahoshi-mona-ui-circular-progress-bar.mjs +441 -242
  23. package/fesm2022/nanahoshi-mona-ui-collapsible.mjs +443 -390
  24. package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +1138 -814
  25. package/fesm2022/nanahoshi-mona-ui-color-palette.mjs +1114 -959
  26. package/fesm2022/nanahoshi-mona-ui-color-picker.mjs +858 -504
  27. package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +1181 -742
  28. package/fesm2022/nanahoshi-mona-ui-command.mjs +1454 -853
  29. package/fesm2022/nanahoshi-mona-ui-common.mjs +569 -743
  30. package/fesm2022/nanahoshi-mona-ui-contextmenu.mjs +978 -532
  31. package/fesm2022/nanahoshi-mona-ui-date-input.mjs +283 -266
  32. package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +973 -451
  33. package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1203 -658
  34. package/fesm2022/nanahoshi-mona-ui-dialog.mjs +1415 -936
  35. package/fesm2022/nanahoshi-mona-ui-dropdown-button.mjs +1165 -568
  36. package/fesm2022/nanahoshi-mona-ui-dropdown-list.mjs +1142 -677
  37. package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +1018 -734
  38. package/fesm2022/nanahoshi-mona-ui-editor.mjs +3589 -2122
  39. package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +577 -359
  40. package/fesm2022/nanahoshi-mona-ui-fieldset.mjs +311 -151
  41. package/fesm2022/nanahoshi-mona-ui-filter.mjs +1086 -718
  42. package/fesm2022/nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs +77 -0
  43. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs +480 -0
  44. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-WbXAzGCa.mjs +470 -0
  45. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-DkWTD3pN.mjs +2115 -0
  46. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-DAHqTwBJ.mjs +330 -0
  47. package/fesm2022/nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs +3766 -0
  48. package/fesm2022/nanahoshi-mona-ui-grid.mjs +5418 -2
  49. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1379 -1079
  50. package/fesm2022/nanahoshi-mona-ui-i18n.mjs +4451 -5077
  51. package/fesm2022/nanahoshi-mona-ui-internal-filter-input.mjs +344 -143
  52. package/fesm2022/nanahoshi-mona-ui-internal-indicator-icon.mjs +257 -127
  53. package/fesm2022/nanahoshi-mona-ui-internal-list.mjs +2080 -1829
  54. package/fesm2022/nanahoshi-mona-ui-internal-popup-menu.mjs +103 -141
  55. package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +2498 -2706
  56. package/fesm2022/nanahoshi-mona-ui-internal.mjs +722 -1007
  57. package/fesm2022/nanahoshi-mona-ui-label.mjs +313 -202
  58. package/fesm2022/nanahoshi-mona-ui-list-box.mjs +1308 -1009
  59. package/fesm2022/nanahoshi-mona-ui-list-view.mjs +1411 -677
  60. package/fesm2022/nanahoshi-mona-ui-list.mjs +1 -6
  61. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +556 -577
  62. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +530 -573
  63. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +530 -573
  64. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +533 -576
  65. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +520 -555
  66. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +530 -571
  67. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +520 -555
  68. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +520 -555
  69. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +530 -571
  70. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +576 -591
  71. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +530 -565
  72. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +520 -555
  73. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +520 -555
  74. package/fesm2022/nanahoshi-mona-ui-locales.mjs +59 -77
  75. package/fesm2022/nanahoshi-mona-ui-menubar.mjs +1411 -829
  76. package/fesm2022/nanahoshi-mona-ui-multi-select.mjs +1326 -702
  77. package/fesm2022/nanahoshi-mona-ui-notification.mjs +763 -675
  78. package/fesm2022/nanahoshi-mona-ui-numeric-text-box.mjs +1306 -826
  79. package/fesm2022/nanahoshi-mona-ui-otp-input.mjs +1122 -897
  80. package/fesm2022/nanahoshi-mona-ui-pager.mjs +1110 -651
  81. package/fesm2022/nanahoshi-mona-ui-placeholder.mjs +95 -53
  82. package/fesm2022/nanahoshi-mona-ui-popover.mjs +559 -397
  83. package/fesm2022/nanahoshi-mona-ui-popup-menu.mjs +2323 -1694
  84. package/fesm2022/nanahoshi-mona-ui-popup.mjs +1657 -1455
  85. package/fesm2022/nanahoshi-mona-ui-progress-bar.mjs +441 -267
  86. package/fesm2022/nanahoshi-mona-ui-query.mjs +211 -340
  87. package/fesm2022/nanahoshi-mona-ui-radio-button.mjs +1017 -548
  88. package/fesm2022/nanahoshi-mona-ui-rating.mjs +874 -624
  89. package/fesm2022/nanahoshi-mona-ui-scroll-view.mjs +1130 -917
  90. package/fesm2022/nanahoshi-mona-ui-segmented.mjs +705 -455
  91. package/fesm2022/nanahoshi-mona-ui-sheet.mjs +461 -283
  92. package/fesm2022/nanahoshi-mona-ui-sidebar.mjs +2791 -2449
  93. package/fesm2022/nanahoshi-mona-ui-skeleton.mjs +145 -90
  94. package/fesm2022/nanahoshi-mona-ui-slider.mjs +1563 -1103
  95. package/fesm2022/nanahoshi-mona-ui-spinner.mjs +738 -673
  96. package/fesm2022/nanahoshi-mona-ui-split-button.mjs +1287 -647
  97. package/fesm2022/nanahoshi-mona-ui-splitter.mjs +1313 -909
  98. package/fesm2022/nanahoshi-mona-ui-stepper.mjs +761 -540
  99. package/fesm2022/nanahoshi-mona-ui-switch.mjs +611 -280
  100. package/fesm2022/nanahoshi-mona-ui-tabs.mjs +1393 -841
  101. package/fesm2022/nanahoshi-mona-ui-text-area.mjs +142 -73
  102. package/fesm2022/nanahoshi-mona-ui-text-box.mjs +876 -374
  103. package/fesm2022/nanahoshi-mona-ui-theme.mjs +1465 -1449
  104. package/fesm2022/nanahoshi-mona-ui-time-picker.mjs +897 -443
  105. package/fesm2022/nanahoshi-mona-ui-time-selector.mjs +1100 -703
  106. package/fesm2022/nanahoshi-mona-ui-tooltip.mjs +789 -538
  107. package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +1361 -805
  108. package/fesm2022/nanahoshi-mona-ui-window.mjs +2145 -1531
  109. package/fesm2022/nanahoshi-mona-ui.mjs +1 -8
  110. package/llms.txt +6 -2
  111. package/package.json +62 -23
  112. package/types/nanahoshi-mona-ui-auto-complete.d.ts +367 -233
  113. package/types/nanahoshi-mona-ui-avatar.d.ts +722 -649
  114. package/types/nanahoshi-mona-ui-breadcrumb.d.ts +134 -103
  115. package/types/nanahoshi-mona-ui-button-group.d.ts +213 -152
  116. package/types/nanahoshi-mona-ui-button.d.ts +227 -166
  117. package/types/nanahoshi-mona-ui-calendar.d.ts +324 -259
  118. package/types/nanahoshi-mona-ui-card.d.ts +125 -111
  119. package/types/nanahoshi-mona-ui-chart.d.ts +10483 -7326
  120. package/types/nanahoshi-mona-ui-check-box.d.ts +293 -180
  121. package/types/nanahoshi-mona-ui-chip.d.ts +208 -141
  122. package/types/nanahoshi-mona-ui-circular-progress-bar.d.ts +194 -133
  123. package/types/nanahoshi-mona-ui-collapsible.d.ts +103 -87
  124. package/types/nanahoshi-mona-ui-color-gradient.d.ts +281 -213
  125. package/types/nanahoshi-mona-ui-color-palette.d.ts +201 -138
  126. package/types/nanahoshi-mona-ui-color-picker.d.ts +283 -194
  127. package/types/nanahoshi-mona-ui-combo-box.d.ts +401 -262
  128. package/types/nanahoshi-mona-ui-command.d.ts +279 -191
  129. package/types/nanahoshi-mona-ui-common.d.ts +354 -385
  130. package/types/nanahoshi-mona-ui-contextmenu.d.ts +142 -117
  131. package/types/nanahoshi-mona-ui-date-input.d.ts +79 -96
  132. package/types/nanahoshi-mona-ui-date-picker.d.ts +338 -208
  133. package/types/nanahoshi-mona-ui-datetime-picker.d.ts +413 -259
  134. package/types/nanahoshi-mona-ui-dialog.d.ts +470 -381
  135. package/types/nanahoshi-mona-ui-dropdown-button.d.ts +216 -168
  136. package/types/nanahoshi-mona-ui-dropdown-list.d.ts +369 -243
  137. package/types/nanahoshi-mona-ui-dropdowns.d.ts +231 -217
  138. package/types/nanahoshi-mona-ui-editor.d.ts +302 -235
  139. package/types/nanahoshi-mona-ui-expansion-panel.d.ts +140 -109
  140. package/types/nanahoshi-mona-ui-fieldset.d.ts +98 -68
  141. package/types/nanahoshi-mona-ui-filter.d.ts +150 -124
  142. package/types/nanahoshi-mona-ui-grid.d.ts +1956 -1678
  143. package/types/nanahoshi-mona-ui-i18n-icu.d.ts +25 -34
  144. package/types/nanahoshi-mona-ui-i18n.d.ts +987 -1052
  145. package/types/nanahoshi-mona-ui-internal-filter-input.d.ts +118 -71
  146. package/types/nanahoshi-mona-ui-internal-indicator-icon.d.ts +56 -27
  147. package/types/nanahoshi-mona-ui-internal-list.d.ts +474 -408
  148. package/types/nanahoshi-mona-ui-internal-popup-menu.d.ts +143 -150
  149. package/types/nanahoshi-mona-ui-internal-tree.d.ts +493 -506
  150. package/types/nanahoshi-mona-ui-internal.d.ts +195 -213
  151. package/types/nanahoshi-mona-ui-label.d.ts +108 -78
  152. package/types/nanahoshi-mona-ui-list-box.d.ts +392 -322
  153. package/types/nanahoshi-mona-ui-list-view.d.ts +423 -282
  154. package/types/nanahoshi-mona-ui-list.d.ts +2 -1
  155. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +540 -542
  156. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +540 -542
  157. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +540 -542
  158. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +540 -542
  159. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +540 -542
  160. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +540 -542
  161. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +540 -542
  162. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +540 -542
  163. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +540 -542
  164. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +540 -542
  165. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +540 -542
  166. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +540 -542
  167. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +540 -542
  168. package/types/nanahoshi-mona-ui-locales.d.ts +17 -19
  169. package/types/nanahoshi-mona-ui-menubar.d.ts +210 -181
  170. package/types/nanahoshi-mona-ui-multi-select.d.ts +416 -276
  171. package/types/nanahoshi-mona-ui-notification.d.ts +140 -151
  172. package/types/nanahoshi-mona-ui-numeric-text-box.d.ts +407 -270
  173. package/types/nanahoshi-mona-ui-otp-input.d.ts +364 -241
  174. package/types/nanahoshi-mona-ui-pager.d.ts +379 -301
  175. package/types/nanahoshi-mona-ui-placeholder.d.ts +35 -28
  176. package/types/nanahoshi-mona-ui-popover.d.ts +176 -134
  177. package/types/nanahoshi-mona-ui-popup-menu.d.ts +488 -344
  178. package/types/nanahoshi-mona-ui-popup.d.ts +698 -560
  179. package/types/nanahoshi-mona-ui-progress-bar.d.ts +197 -137
  180. package/types/nanahoshi-mona-ui-query.d.ts +82 -88
  181. package/types/nanahoshi-mona-ui-radio-button.d.ts +434 -269
  182. package/types/nanahoshi-mona-ui-rating.d.ts +348 -254
  183. package/types/nanahoshi-mona-ui-scroll-view.d.ts +244 -172
  184. package/types/nanahoshi-mona-ui-segmented.d.ts +250 -175
  185. package/types/nanahoshi-mona-ui-sheet.d.ts +115 -63
  186. package/types/nanahoshi-mona-ui-sidebar.d.ts +653 -493
  187. package/types/nanahoshi-mona-ui-skeleton.d.ts +55 -39
  188. package/types/nanahoshi-mona-ui-slider.d.ts +503 -354
  189. package/types/nanahoshi-mona-ui-spinner.d.ts +125 -112
  190. package/types/nanahoshi-mona-ui-split-button.d.ts +241 -196
  191. package/types/nanahoshi-mona-ui-splitter.d.ts +124 -78
  192. package/types/nanahoshi-mona-ui-stepper.d.ts +206 -181
  193. package/types/nanahoshi-mona-ui-switch.d.ts +197 -131
  194. package/types/nanahoshi-mona-ui-tabs.d.ts +349 -248
  195. package/types/nanahoshi-mona-ui-text-area.d.ts +52 -36
  196. package/types/nanahoshi-mona-ui-text-box.d.ts +349 -218
  197. package/types/nanahoshi-mona-ui-theme.d.ts +415 -408
  198. package/types/nanahoshi-mona-ui-time-picker.d.ts +357 -217
  199. package/types/nanahoshi-mona-ui-time-selector.d.ts +255 -170
  200. package/types/nanahoshi-mona-ui-tooltip.d.ts +222 -144
  201. package/types/nanahoshi-mona-ui-tree-view.d.ts +466 -308
  202. package/types/nanahoshi-mona-ui-window.d.ts +494 -399
  203. package/types/nanahoshi-mona-ui.d.ts +1 -2
  204. package/fesm2022/nanahoshi-mona-ui-grid-grid-footer-row.component-DjNnVxHE.mjs +0 -181
  205. package/fesm2022/nanahoshi-mona-ui-grid-grid-list.component-ihQIKeP-.mjs +0 -208
  206. package/fesm2022/nanahoshi-mona-ui-grid-grid-row.component-BpnybNcs.mjs +0 -1082
  207. package/fesm2022/nanahoshi-mona-ui-grid-grid-virtual-list.component-CYlgfc7c.mjs +0 -186
  208. package/fesm2022/nanahoshi-mona-ui-grid-nanahoshi-mona-ui-grid-LCzfCYd3.mjs +0 -7568
@@ -1,111 +1,204 @@
1
- import * as i0 from '@angular/core';
2
- import { Directive, inject, ElementRef, Injector, viewChild, ViewContainerRef, computed, TemplateRef, effect, untracked, afterNextRender, isDevMode, Component, InjectionToken, signal, DOCUMENT, forwardRef, Injectable, DestroyRef, contentChild, output, input } from '@angular/core';
3
- import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
4
- import { MonaI18nService, mergeMessages } from '@nanahoshi/mona-ui/i18n';
5
- import { themeOverlaySurfaceClasses, createElementControlId, focusElement, positionGlobalOverlay, inertOutside } from '@nanahoshi/mona-ui/internal';
6
- import { PopupDataInjectionToken, PopupCloseEvent, PopupCloseSource, PopupService } from '@nanahoshi/mona-ui/popup';
7
- import { Subject, ReplaySubject, take, takeUntil, merge, map } from 'rxjs';
8
- import * as i1 from '@angular/cdk/a11y';
9
- import { CdkTrapFocus } from '@angular/cdk/a11y';
10
- import { NgTemplateOutlet } from '@angular/common';
11
- import { LucideOctagonAlert, LucideCircleCheckBig, LucideBadgeInfo, LucideOctagonX, LucideBadgeQuestionMark, LucideX, LucideDynamicIcon } from '@lucide/angular';
12
- import { ButtonDirective } from '@nanahoshi/mona-ui/button';
13
- import { AnyPipe, PreventableEvent } from '@nanahoshi/mona-ui/common';
14
- import { cva } from 'class-variance-authority';
15
-
16
- class DialogContentTemplateDirective {
17
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogContentTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
18
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DialogContentTemplateDirective, isStandalone: true, selector: "ng-template[monaDialogContentTemplate]", ngImport: i0 }); }
19
- }
20
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogContentTemplateDirective, decorators: [{
21
- type: Directive,
22
- args: [{
23
- selector: "ng-template[monaDialogContentTemplate]"
24
- }]
25
- }] });
26
-
27
- class DialogDescriptionTemplateDirective {
28
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogDescriptionTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
29
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DialogDescriptionTemplateDirective, isStandalone: true, selector: "ng-template[monaDialogDescriptionTemplate]", ngImport: i0 }); }
30
- }
31
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogDescriptionTemplateDirective, decorators: [{
32
- type: Directive,
33
- args: [{
34
- selector: "ng-template[monaDialogDescriptionTemplate]"
35
- }]
36
- }] });
37
-
38
- class DialogFooterTemplateDirective {
39
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogFooterTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
40
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DialogFooterTemplateDirective, isStandalone: true, selector: "ng-template[monaDialogFooterTemplate]", ngImport: i0 }); }
41
- }
42
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogFooterTemplateDirective, decorators: [{
43
- type: Directive,
44
- args: [{
45
- selector: "ng-template[monaDialogFooterTemplate]"
46
- }]
47
- }] });
48
-
49
- class DialogIconTemplateDirective {
50
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogIconTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
51
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DialogIconTemplateDirective, isStandalone: true, selector: "ng-template[monaDialogIconTemplate]", ngImport: i0 }); }
52
- }
53
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogIconTemplateDirective, decorators: [{
54
- type: Directive,
55
- args: [{
56
- selector: "ng-template[monaDialogIconTemplate]"
57
- }]
58
- }] });
59
-
60
- class DialogTitleTemplateDirective {
61
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogTitleTemplateDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
62
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.6", type: DialogTitleTemplateDirective, isStandalone: true, selector: "ng-template[monaDialogTitleTemplate]", ngImport: i0 }); }
63
- }
64
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogTitleTemplateDirective, decorators: [{
65
- type: Directive,
66
- args: [{
67
- selector: "ng-template[monaDialogTitleTemplate]"
68
- }]
69
- }] });
70
-
71
- // Generated from i18n/catalogs/en-US.messages.json by scripts/generate-locale-catalogs.ts. Do not edit.
72
- // Edit the JSON file and run `npm run generate:locale-catalogs`.
1
+ import * as i0 from "@angular/core";
2
+ import { Component, DOCUMENT, DestroyRef, Directive, ElementRef, Injectable, InjectionToken, Injector, TemplateRef, ViewContainerRef, afterNextRender, computed, contentChild, effect, forwardRef, inject, input, isDevMode, output, signal, untracked, viewChild } from "@angular/core";
3
+ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
4
+ import { MonaI18nService, mergeMessages } from "@nanahoshi/mona-ui/i18n";
5
+ import { createElementControlId, focusElement, inertOutside, positionGlobalOverlay, themeOverlaySurfaceClasses } from "@nanahoshi/mona-ui/internal";
6
+ import { PopupCloseEvent, PopupCloseSource, PopupDataInjectionToken, PopupService } from "@nanahoshi/mona-ui/popup";
7
+ import { ReplaySubject, Subject, map, merge, take, takeUntil } from "rxjs";
8
+ import * as i1 from "@angular/cdk/a11y";
9
+ import { CdkTrapFocus } from "@angular/cdk/a11y";
10
+ import { NgTemplateOutlet } from "@angular/common";
11
+ import { LucideBadgeInfo, LucideBadgeQuestionMark, LucideCircleCheckBig, LucideDynamicIcon, LucideOctagonAlert, LucideOctagonX, LucideX } from "@lucide/angular";
12
+ import { ButtonDirective } from "@nanahoshi/mona-ui/button";
13
+ import { AnyPipe, PreventableEvent } from "@nanahoshi/mona-ui/common";
14
+ import { cva } from "class-variance-authority";
15
+ var DialogContentTemplateDirective = class DialogContentTemplateDirective {
16
+ static {
17
+ this.ɵfac = i0.ɵɵngDeclareFactory({
18
+ minVersion: "12.0.0",
19
+ version: "22.2.6",
20
+ ngImport: i0,
21
+ type: DialogContentTemplateDirective,
22
+ deps: [],
23
+ target: i0.ɵɵFactoryTarget.Directive
24
+ });
25
+ }
26
+ static {
27
+ this.ɵdir = i0.ɵɵngDeclareDirective({
28
+ minVersion: "14.0.0",
29
+ version: "22.2.6",
30
+ type: DialogContentTemplateDirective,
31
+ isStandalone: true,
32
+ selector: "ng-template[monaDialogContentTemplate]",
33
+ ngImport: i0
34
+ });
35
+ }
36
+ };
37
+ i0.ɵɵngDeclareClassMetadata({
38
+ minVersion: "12.0.0",
39
+ version: "22.2.6",
40
+ ngImport: i0,
41
+ type: DialogContentTemplateDirective,
42
+ decorators: [{
43
+ type: Directive,
44
+ args: [{ selector: "ng-template[monaDialogContentTemplate]" }]
45
+ }]
46
+ });
47
+ var DialogDescriptionTemplateDirective = class DialogDescriptionTemplateDirective {
48
+ static {
49
+ this.ɵfac = i0.ɵɵngDeclareFactory({
50
+ minVersion: "12.0.0",
51
+ version: "22.2.6",
52
+ ngImport: i0,
53
+ type: DialogDescriptionTemplateDirective,
54
+ deps: [],
55
+ target: i0.ɵɵFactoryTarget.Directive
56
+ });
57
+ }
58
+ static {
59
+ this.ɵdir = i0.ɵɵngDeclareDirective({
60
+ minVersion: "14.0.0",
61
+ version: "22.2.6",
62
+ type: DialogDescriptionTemplateDirective,
63
+ isStandalone: true,
64
+ selector: "ng-template[monaDialogDescriptionTemplate]",
65
+ ngImport: i0
66
+ });
67
+ }
68
+ };
69
+ i0.ɵɵngDeclareClassMetadata({
70
+ minVersion: "12.0.0",
71
+ version: "22.2.6",
72
+ ngImport: i0,
73
+ type: DialogDescriptionTemplateDirective,
74
+ decorators: [{
75
+ type: Directive,
76
+ args: [{ selector: "ng-template[monaDialogDescriptionTemplate]" }]
77
+ }]
78
+ });
79
+ var DialogFooterTemplateDirective = class DialogFooterTemplateDirective {
80
+ static {
81
+ this.ɵfac = i0.ɵɵngDeclareFactory({
82
+ minVersion: "12.0.0",
83
+ version: "22.2.6",
84
+ ngImport: i0,
85
+ type: DialogFooterTemplateDirective,
86
+ deps: [],
87
+ target: i0.ɵɵFactoryTarget.Directive
88
+ });
89
+ }
90
+ static {
91
+ this.ɵdir = i0.ɵɵngDeclareDirective({
92
+ minVersion: "14.0.0",
93
+ version: "22.2.6",
94
+ type: DialogFooterTemplateDirective,
95
+ isStandalone: true,
96
+ selector: "ng-template[monaDialogFooterTemplate]",
97
+ ngImport: i0
98
+ });
99
+ }
100
+ };
101
+ i0.ɵɵngDeclareClassMetadata({
102
+ minVersion: "12.0.0",
103
+ version: "22.2.6",
104
+ ngImport: i0,
105
+ type: DialogFooterTemplateDirective,
106
+ decorators: [{
107
+ type: Directive,
108
+ args: [{ selector: "ng-template[monaDialogFooterTemplate]" }]
109
+ }]
110
+ });
111
+ var DialogIconTemplateDirective = class DialogIconTemplateDirective {
112
+ static {
113
+ this.ɵfac = i0.ɵɵngDeclareFactory({
114
+ minVersion: "12.0.0",
115
+ version: "22.2.6",
116
+ ngImport: i0,
117
+ type: DialogIconTemplateDirective,
118
+ deps: [],
119
+ target: i0.ɵɵFactoryTarget.Directive
120
+ });
121
+ }
122
+ static {
123
+ this.ɵdir = i0.ɵɵngDeclareDirective({
124
+ minVersion: "14.0.0",
125
+ version: "22.2.6",
126
+ type: DialogIconTemplateDirective,
127
+ isStandalone: true,
128
+ selector: "ng-template[monaDialogIconTemplate]",
129
+ ngImport: i0
130
+ });
131
+ }
132
+ };
133
+ i0.ɵɵngDeclareClassMetadata({
134
+ minVersion: "12.0.0",
135
+ version: "22.2.6",
136
+ ngImport: i0,
137
+ type: DialogIconTemplateDirective,
138
+ decorators: [{
139
+ type: Directive,
140
+ args: [{ selector: "ng-template[monaDialogIconTemplate]" }]
141
+ }]
142
+ });
143
+ var DialogTitleTemplateDirective = class DialogTitleTemplateDirective {
144
+ static {
145
+ this.ɵfac = i0.ɵɵngDeclareFactory({
146
+ minVersion: "12.0.0",
147
+ version: "22.2.6",
148
+ ngImport: i0,
149
+ type: DialogTitleTemplateDirective,
150
+ deps: [],
151
+ target: i0.ɵɵFactoryTarget.Directive
152
+ });
153
+ }
154
+ static {
155
+ this.ɵdir = i0.ɵɵngDeclareDirective({
156
+ minVersion: "14.0.0",
157
+ version: "22.2.6",
158
+ type: DialogTitleTemplateDirective,
159
+ isStandalone: true,
160
+ selector: "ng-template[monaDialogTitleTemplate]",
161
+ ngImport: i0
162
+ });
163
+ }
164
+ };
165
+ i0.ɵɵngDeclareClassMetadata({
166
+ minVersion: "12.0.0",
167
+ version: "22.2.6",
168
+ ngImport: i0,
169
+ type: DialogTitleTemplateDirective,
170
+ decorators: [{
171
+ type: Directive,
172
+ args: [{ selector: "ng-template[monaDialogTitleTemplate]" }]
173
+ }]
174
+ });
73
175
  const DIALOG_DEFAULT_MESSAGES = {
74
- cancel: "Cancel",
75
- closeDialog: "Close dialog",
76
- ok: "OK"
176
+ cancel: "Cancel",
177
+ closeDialog: "Close dialog",
178
+ ok: "OK"
77
179
  };
78
-
79
180
  const dialogBaseThemeVariants = cva(`
80
181
  flex h-full max-h-[inherit] min-h-0 w-full flex-col gap-0.5 overflow-hidden
81
182
  ${themeOverlaySurfaceClasses} text-foreground
82
183
  border border-border shadow-(--shadow-overlay) outline-none focus-visible:outline-hidden
83
184
  `, {
84
- variants: {
85
- rounded: {
86
- none: "rounded-none",
87
- small: "rounded-sm",
88
- medium: "rounded-md",
89
- large: "rounded-lg"
90
- }
91
- },
92
- defaultVariants: {
93
- rounded: "medium"
94
- }
185
+ variants: { rounded: {
186
+ none: "rounded-none",
187
+ small: "rounded-sm",
188
+ medium: "rounded-md",
189
+ large: "rounded-lg"
190
+ } },
191
+ defaultVariants: { rounded: "medium" }
95
192
  });
96
193
  const dialogContentContainerThemeVariants = cva(`
97
194
  flex min-h-0 flex-1 flex-row gap-1
98
195
  `);
99
196
  const dialogBodyThemeVariants = cva(`
100
197
  flex h-full min-h-0 w-full flex-col gap-0 pe-2 pb-2
101
- `, {
102
- variants: {
103
- hasIcon: {
104
- true: "",
105
- false: "ps-5"
106
- }
107
- }
108
- });
198
+ `, { variants: { hasIcon: {
199
+ true: "",
200
+ false: "ps-5"
201
+ } } });
109
202
  const dialogHeaderThemeVariants = cva(`
110
203
  flex shrink-0 flex-row gap-2 pt-4
111
204
  `);
@@ -118,18 +211,14 @@ const dialogIconThemeVariants = cva(`
118
211
  [&>span]:-inset-3
119
212
  [&>span]:min-h-full [&>span]:min-w-full [&>span]:border
120
213
  `, {
121
- variants: {
122
- type: {
123
- confirm: "border-success/10 bg-success/10 [&>span]:border-success/5 [&>span]:bg-success/5",
124
- error: "border-error/10 bg-error/10 [&>span]:border-error/5 [&>span]:bg-error/5",
125
- warning: "border-warning/10 bg-warning/10 [&>span]:border-warning/5 [&>span]:bg-warning/5",
126
- info: "border-info/10 bg-info/10 [&>span]:border-info/5 [&>span]:bg-info/5",
127
- success: "border-success/10 bg-success/10 [&>span]:border-success/5 [&>span]:bg-success/5"
128
- }
129
- },
130
- defaultVariants: {
131
- type: "info"
132
- }
214
+ variants: { type: {
215
+ confirm: "border-success/10 bg-success/10 [&>span]:border-success/5 [&>span]:bg-success/5",
216
+ error: "border-error/10 bg-error/10 [&>span]:border-error/5 [&>span]:bg-error/5",
217
+ warning: "border-warning/10 bg-warning/10 [&>span]:border-warning/5 [&>span]:bg-warning/5",
218
+ info: "border-info/10 bg-info/10 [&>span]:border-info/5 [&>span]:bg-info/5",
219
+ success: "border-success/10 bg-success/10 [&>span]:border-success/5 [&>span]:bg-success/5"
220
+ } },
221
+ defaultVariants: { type: "info" }
133
222
  });
134
223
  const dialogTitleContainerThemeVariants = cva(`
135
224
  flex flex-1 items-center justify-start p-1
@@ -152,842 +241,1232 @@ const dialogFooterThemeVariants = cva(`
152
241
  bg-surface-muted
153
242
  border-t border-border-subtle
154
243
  `, {
155
- variants: {
156
- layout: {
157
- center: "justify-center",
158
- end: "justify-end",
159
- start: "justify-start",
160
- stretched: "[&>*]:flex-1"
161
- },
162
- rounded: {
163
- none: "rounded-none",
164
- small: "rounded-es-sm rounded-ee-sm",
165
- medium: "rounded-es-md rounded-ee-md",
166
- large: "rounded-es-lg rounded-ee-lg"
167
- }
168
- },
169
- defaultVariants: {
170
- rounded: "medium"
171
- }
244
+ variants: {
245
+ layout: {
246
+ center: "justify-center",
247
+ end: "justify-end",
248
+ start: "justify-start",
249
+ stretched: "[&>*]:flex-1"
250
+ },
251
+ rounded: {
252
+ none: "rounded-none",
253
+ small: "rounded-es-sm rounded-ee-sm",
254
+ medium: "rounded-es-md rounded-ee-md",
255
+ large: "rounded-es-lg rounded-ee-lg"
256
+ }
257
+ },
258
+ defaultVariants: { rounded: "medium" }
172
259
  });
173
-
174
- /** Targets that handle Enter themselves, so it doesn't trigger the dialog's default action. */
175
260
  const HANDLES_ENTER = [
176
- "a[href]",
177
- "button",
178
- "form",
179
- "select",
180
- "textarea",
181
- "[contenteditable]:not([contenteditable='false'])",
182
- "[role='button']",
183
- "[role='checkbox']",
184
- "[role='combobox']",
185
- "[role='link']",
186
- "[role='listbox']",
187
- "[role='menu']",
188
- "[role='menuitem']",
189
- "[role='option']",
190
- "[role='radio']",
191
- "[role='switch']",
192
- "[role='tab']",
193
- "input:is([type='button'], [type='checkbox'], [type='color'], [type='file'], [type='image'], [type='radio'], [type='reset'], [type='submit'])"
261
+ "a[href]",
262
+ "button",
263
+ "form",
264
+ "select",
265
+ "textarea",
266
+ "[contenteditable]:not([contenteditable='false'])",
267
+ "[role='button']",
268
+ "[role='checkbox']",
269
+ "[role='combobox']",
270
+ "[role='link']",
271
+ "[role='listbox']",
272
+ "[role='menu']",
273
+ "[role='menuitem']",
274
+ "[role='option']",
275
+ "[role='radio']",
276
+ "[role='switch']",
277
+ "[role='tab']",
278
+ "input:is([type='button'], [type='checkbox'], [type='color'], [type='file'], [type='image'], [type='radio'], [type='reset'], [type='submit'])"
194
279
  ].join(", ");
195
- class DialogContentComponent {
196
- #hostElementRef;
197
- #i18n;
198
- #iconMap;
199
- #injectedData;
200
- #injector;
201
- #localeMessages;
202
- #trapFocus;
203
- #componentRef;
204
- constructor() {
205
- this.#hostElementRef = inject(ElementRef);
206
- this.#i18n = inject(MonaI18nService);
207
- this.#iconMap = {
208
- confirm: { color: "var(--color-success)", icon: LucideBadgeQuestionMark },
209
- error: { color: "var(--color-error)", icon: LucideOctagonX },
210
- info: { color: "var(--color-info)", icon: LucideBadgeInfo },
211
- success: { color: "var(--color-success)", icon: LucideCircleCheckBig },
212
- warning: { color: "var(--color-warning)", icon: LucideOctagonAlert }
213
- };
214
- this.#injectedData = inject(PopupDataInjectionToken);
215
- this.#injector = inject(Injector);
216
- this.#localeMessages = this.#i18n.componentMessages("dialog", DIALOG_DEFAULT_MESSAGES);
217
- this.#trapFocus = inject(CdkTrapFocus);
218
- this.#componentRef = null;
219
- this.componentHost = viewChild("componentHost", { ...(ngDevMode ? { debugName: "componentHost" } : /* istanbul ignore next */ {}), read: ViewContainerRef });
220
- this.actions = computed(() => {
221
- const data = this.dialogData();
222
- if (data.actions != null) {
223
- return data.actions;
224
- }
225
- return this.getDefaultActions(data.type);
226
- }, /* @ts-ignore */
227
- ...(ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []));
228
- this.baseClass = computed(() => {
229
- const rounded = this.dialogData().rounded;
230
- return dialogBaseThemeVariants({ rounded });
231
- }, /* @ts-ignore */
232
- ...(ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []));
233
- this.bodyClass = computed(() => {
234
- const hasIcon = this.dialogData().type != null;
235
- return dialogBodyThemeVariants({ hasIcon });
236
- }, /* @ts-ignore */
237
- ...(ngDevMode ? [{ debugName: "bodyClass" }] : /* istanbul ignore next */ []));
238
- this.closeButtonContainerClass = computed(() => {
239
- return dialogCloseButtonContainerThemeVariants();
240
- }, /* @ts-ignore */
241
- ...(ngDevMode ? [{ debugName: "closeButtonContainerClass" }] : /* istanbul ignore next */ []));
242
- this.contentClass = computed(() => {
243
- return dialogContentThemeVariants();
244
- }, /* @ts-ignore */
245
- ...(ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []));
246
- this.contentComponent = computed(() => {
247
- const content = this.dialogData().content;
248
- return content && !(content instanceof TemplateRef) ? content : null;
249
- }, /* @ts-ignore */
250
- ...(ngDevMode ? [{ debugName: "contentComponent" }] : /* istanbul ignore next */ []));
251
- this.contentContainerClass = computed(() => {
252
- return dialogContentContainerThemeVariants();
253
- }, /* @ts-ignore */
254
- ...(ngDevMode ? [{ debugName: "contentContainerClass" }] : /* istanbul ignore next */ []));
255
- this.contentTemplate = computed(() => {
256
- const content = this.dialogData().content;
257
- return content instanceof TemplateRef ? content : null;
258
- }, /* @ts-ignore */
259
- ...(ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []));
260
- this.describedById = computed(() => {
261
- const data = this.dialogData();
262
- return data.descriptionTemplate || data.description ? this.descriptionId : null;
263
- }, /* @ts-ignore */
264
- ...(ngDevMode ? [{ debugName: "describedById" }] : /* istanbul ignore next */ []));
265
- this.descriptionClass = computed(() => {
266
- return dialogDescriptionThemeVariants();
267
- }, /* @ts-ignore */
268
- ...(ngDevMode ? [{ debugName: "descriptionClass" }] : /* istanbul ignore next */ []));
269
- this.descriptionId = createElementControlId();
270
- this.dialogData = computed(() => this.dialogReference.data(), /* @ts-ignore */
271
- ...(ngDevMode ? [{ debugName: "dialogData" }] : /* istanbul ignore next */ []));
272
- this.dialogRef = this.#injectedData.dialogReference.dialogRef;
273
- this.dialogReference = this.#injectedData.dialogReference;
274
- this.footerClass = computed(() => {
275
- const layout = this.dialogData().actionsLayout;
276
- const rounded = this.dialogData().rounded;
277
- return dialogFooterThemeVariants({ layout, rounded });
278
- }, /* @ts-ignore */
279
- ...(ngDevMode ? [{ debugName: "footerClass" }] : /* istanbul ignore next */ []));
280
- this.hasTitle = computed(() => {
281
- const data = this.dialogData();
282
- return !!data.titleTemplate || !!data.title;
283
- }, /* @ts-ignore */
284
- ...(ngDevMode ? [{ debugName: "hasTitle" }] : /* istanbul ignore next */ []));
285
- this.headerClass = computed(() => {
286
- return dialogHeaderThemeVariants();
287
- }, /* @ts-ignore */
288
- ...(ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []));
289
- this.headerId = createElementControlId();
290
- this.icon = computed(() => {
291
- const { type } = this.dialogData();
292
- return type ? this.#iconMap[type] : undefined;
293
- }, /* @ts-ignore */
294
- ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
295
- this.iconClass = computed(() => {
296
- const type = this.dialogData().type;
297
- return dialogIconThemeVariants({ type });
298
- }, /* @ts-ignore */
299
- ...(ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []));
300
- this.iconContainerClass = computed(() => {
301
- return dialogIconContainerThemeVariants();
302
- }, /* @ts-ignore */
303
- ...(ngDevMode ? [{ debugName: "iconContainerClass" }] : /* istanbul ignore next */ []));
304
- this.messages = computed(() => {
305
- return mergeMessages(this.#localeMessages(), this.dialogData().messages);
306
- }, /* @ts-ignore */
307
- ...(ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []));
308
- this.role = computed(() => {
309
- const type = this.dialogData().type;
310
- return type === "confirm" || type === "error" || type === "warning" ? "alertdialog" : "dialog";
311
- }, /* @ts-ignore */
312
- ...(ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []));
313
- this.titleClass = computed(() => {
314
- return dialogTitleThemeVariants();
315
- }, /* @ts-ignore */
316
- ...(ngDevMode ? [{ debugName: "titleClass" }] : /* istanbul ignore next */ []));
317
- this.titleContainerClass = computed(() => {
318
- return dialogTitleContainerThemeVariants();
319
- }, /* @ts-ignore */
320
- ...(ngDevMode ? [{ debugName: "titleContainerClass" }] : /* istanbul ignore next */ []));
321
- this.#trapFocus.autoCapture = true;
322
- // A non-modal dialog leaves the page usable, so Tab can leave it too.
323
- this.#trapFocus.enabled = this.dialogData().modal ?? true;
324
- effect(() => {
325
- const host = this.componentHost();
326
- const type = this.contentComponent();
327
- untracked(() => this.#renderComponent(host, type));
328
- });
329
- afterNextRender({
330
- write: () => {
331
- this.focusElement();
332
- if (isDevMode()) {
333
- this.#warnIfUnnamed();
334
- }
335
- }
336
- });
337
- }
338
- onActionClick(action) {
339
- this.dialogReference.requestAction(action);
340
- }
341
- onCloseClick() {
342
- this.dialogReference.requestClose();
343
- }
344
- /** Enter outside a control that handles it triggers the default action, as in a form. */
345
- onKeydown(event) {
346
- if (event.key !== "Enter" || event.defaultPrevented || event.isComposing) {
347
- return;
348
- }
349
- if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || this.dialogData().footerTemplate) {
350
- return;
351
- }
352
- const target = event.target instanceof Element ? event.target : null;
353
- if (target?.closest(HANDLES_ENTER)) {
354
- return;
355
- }
356
- const action = Array.from(this.actions()).find(candidate => candidate.default);
357
- if (action) {
358
- event.preventDefault();
359
- this.onActionClick(action);
360
- }
361
- }
362
- #renderComponent(host, type) {
363
- if (this.#componentRef && (!host || this.#componentRef.componentType !== type)) {
364
- this.#componentRef.destroy();
365
- this.#componentRef = null;
366
- this.dialogReference.setComponentRef(undefined);
367
- }
368
- if (host && type && !this.#componentRef) {
369
- host.clear();
370
- this.#componentRef = host.createComponent(type, { injector: this.#injector });
371
- this.dialogReference.setComponentRef(this.#componentRef);
372
- }
373
- }
374
- #warnIfUnnamed() {
375
- if (this.hasTitle() || this.dialogData().ariaLabel) {
376
- return;
377
- }
378
- console.warn("[Mona Dialog] A dialog needs an accessible name. Set a title, a title template or aria-label (ariaLabel in the service settings).", this.#hostElementRef.nativeElement);
379
- }
380
- focusElement() {
381
- const element = this.dialogData().focusedElement;
382
- if (!element) {
383
- return;
384
- }
385
- const dialogElement = this.#hostElementRef.nativeElement;
386
- // The focus trap moves focus to its first tabbable element after this runs; marking the target makes it
387
- // land here instead.
388
- focusElement(dialogElement, element)?.setAttribute("cdkFocusInitial", "");
389
- }
390
- getDefaultActions(type) {
391
- const messages = this.messages();
392
- const ok = { data: "ok", default: true, look: "primary", text: messages.ok };
393
- if (type === "confirm") {
394
- return [ok, { data: "cancel", look: "default", text: messages.cancel }];
395
- }
396
- return [ok];
397
- }
398
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogContentComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
399
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.6", type: DialogContentComponent, isStandalone: true, selector: "ng-component", host: { listeners: { "keydown": "onKeydown($event)" }, properties: { "class": "baseClass()", "attr.aria-describedby": "describedById()", "attr.aria-label": "hasTitle() ? null : dialogData().ariaLabel || null", "attr.aria-labelledby": "hasTitle() ? headerId : null", "attr.aria-modal": "dialogData().modal ? 'true' : null", "attr.role": "role()" } }, viewQueries: [{ propertyName: "componentHost", first: true, predicate: ["componentHost"], descendants: true, read: ViewContainerRef, isSignal: true }], hostDirectives: [{ directive: i1.CdkTrapFocus }], ngImport: i0, template: "@let dialogIcon = icon();\n@let data = dialogData();\n\n<div [class]=\"contentContainerClass()\">\n @if (dialogIcon) {\n <div [class]=\"iconContainerClass()\">\n @if (data.iconTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.iconTemplate\"></ng-container>\n } @else {\n <div [class]=\"iconClass()\">\n <span aria-hidden=\"true\"></span>\n <svg [lucideIcon]=\"dialogIcon.icon\" [size]=\"24\" [style.color]=\"dialogIcon.color\"></svg>\n </div>\n }\n </div>\n }\n <div [class]=\"bodyClass()\">\n <div [class]=\"headerClass()\">\n @if (hasTitle()) {\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\n @if (data.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.titleTemplate\"></ng-container>\n } @else {\n <h2 [class]=\"titleClass()\">{{ data.title }}</h2>\n }\n </div>\n } @else {\n <div class=\"flex-1\"></div>\n }\n @if (data.closable) {\n <div [class]=\"closeButtonContainerClass()\">\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"messages().closeDialog\"\n (click)=\"onCloseClick()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n\n @let descriptionTemplateId = data.descriptionTemplate ? descriptionId : undefined;\n <div class=\"p-1\" [attr.id]=\"descriptionTemplateId\">\n @if (data.descriptionTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.descriptionTemplate\"></ng-container>\n } @else if (data.description) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ data.description }}</p>\n }\n </div>\n\n <div [class]=\"contentClass()\">\n @if (contentTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: data.data, dialogRef: dialogRef }\"></ng-container>\n } @else if (contentComponent()) {\n <ng-container #componentHost></ng-container>\n } @else if (data.text) {\n <p>{{ data.text }}</p>\n }\n </div>\n </div>\n</div>\n\n@if (data.footerTemplate || (actions() | monaAny)) {\n @if (data.footerTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.footerTemplate\"></ng-container>\n } @else {\n <div [class]=\"footerClass()\">\n @for (action of actions(); track $index) {\n <button\n monaButton\n type=\"button\"\n [class]=\"action.cssClass || ''\"\n [iconOnly]=\"action.iconOnly || false\"\n [look]=\"action.look\"\n [rounded]=\"action.rounded || data.rounded\"\n (click)=\"onActionClick(action)\">\n {{ action.text }}\n </button>\n }\n </div>\n }\n}\n", dependencies: [{ kind: "directive", type: ButtonDirective, selector: "button[monaButton]", inputs: ["aria-haspopup", "disabled", "iconOnly", "loading", "look", "rounded", "selected", "size", "tabindex", "toggleable", "type", "class", "value"], outputs: ["lookChange", "selectedChange"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: LucideX, selector: "svg[lucideX]" }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { kind: "pipe", type: AnyPipe, name: "monaAny" }] }); }
400
- }
401
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogContentComponent, decorators: [{
402
- type: Component,
403
- args: [{ imports: [ButtonDirective, NgTemplateOutlet, AnyPipe, LucideX, LucideDynamicIcon], host: {
404
- "[class]": "baseClass()",
405
- "[attr.aria-describedby]": "describedById()",
406
- "[attr.aria-label]": "hasTitle() ? null : dialogData().ariaLabel || null",
407
- "[attr.aria-labelledby]": "hasTitle() ? headerId : null",
408
- "[attr.aria-modal]": "dialogData().modal ? 'true' : null",
409
- "[attr.role]": "role()",
410
- "(keydown)": "onKeydown($event)"
411
- }, hostDirectives: [CdkTrapFocus], template: "@let dialogIcon = icon();\n@let data = dialogData();\n\n<div [class]=\"contentContainerClass()\">\n @if (dialogIcon) {\n <div [class]=\"iconContainerClass()\">\n @if (data.iconTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.iconTemplate\"></ng-container>\n } @else {\n <div [class]=\"iconClass()\">\n <span aria-hidden=\"true\"></span>\n <svg [lucideIcon]=\"dialogIcon.icon\" [size]=\"24\" [style.color]=\"dialogIcon.color\"></svg>\n </div>\n }\n </div>\n }\n <div [class]=\"bodyClass()\">\n <div [class]=\"headerClass()\">\n @if (hasTitle()) {\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\n @if (data.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.titleTemplate\"></ng-container>\n } @else {\n <h2 [class]=\"titleClass()\">{{ data.title }}</h2>\n }\n </div>\n } @else {\n <div class=\"flex-1\"></div>\n }\n @if (data.closable) {\n <div [class]=\"closeButtonContainerClass()\">\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"messages().closeDialog\"\n (click)=\"onCloseClick()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n\n @let descriptionTemplateId = data.descriptionTemplate ? descriptionId : undefined;\n <div class=\"p-1\" [attr.id]=\"descriptionTemplateId\">\n @if (data.descriptionTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.descriptionTemplate\"></ng-container>\n } @else if (data.description) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ data.description }}</p>\n }\n </div>\n\n <div [class]=\"contentClass()\">\n @if (contentTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: data.data, dialogRef: dialogRef }\"></ng-container>\n } @else if (contentComponent()) {\n <ng-container #componentHost></ng-container>\n } @else if (data.text) {\n <p>{{ data.text }}</p>\n }\n </div>\n </div>\n</div>\n\n@if (data.footerTemplate || (actions() | monaAny)) {\n @if (data.footerTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.footerTemplate\"></ng-container>\n } @else {\n <div [class]=\"footerClass()\">\n @for (action of actions(); track $index) {\n <button\n monaButton\n type=\"button\"\n [class]=\"action.cssClass || ''\"\n [iconOnly]=\"action.iconOnly || false\"\n [look]=\"action.look\"\n [rounded]=\"action.rounded || data.rounded\"\n (click)=\"onActionClick(action)\">\n {{ action.text }}\n </button>\n }\n </div>\n }\n}\n" }]
412
- }], ctorParameters: () => [], propDecorators: { componentHost: [{ type: i0.ViewChild, args: ["componentHost", { ...{ read: ViewContainerRef }, isSignal: true }] }] } });
413
-
414
- /**
415
- * The `data` a dialog was opened with, for a component given as its `content`.
416
- * @example
417
- * ```ts
418
- * readonly #data = inject<{ name: string }>(DIALOG_DATA);
419
- * ```
420
- */
280
+ var DialogContentComponent = class DialogContentComponent {
281
+ #hostElementRef;
282
+ #i18n;
283
+ #iconMap;
284
+ #injectedData;
285
+ #injector;
286
+ #localeMessages;
287
+ #trapFocus;
288
+ #componentRef;
289
+ constructor() {
290
+ this.#hostElementRef = inject(ElementRef);
291
+ this.#i18n = inject(MonaI18nService);
292
+ this.#iconMap = {
293
+ confirm: {
294
+ color: "var(--color-success)",
295
+ icon: LucideBadgeQuestionMark
296
+ },
297
+ error: {
298
+ color: "var(--color-error)",
299
+ icon: LucideOctagonX
300
+ },
301
+ info: {
302
+ color: "var(--color-info)",
303
+ icon: LucideBadgeInfo
304
+ },
305
+ success: {
306
+ color: "var(--color-success)",
307
+ icon: LucideCircleCheckBig
308
+ },
309
+ warning: {
310
+ color: "var(--color-warning)",
311
+ icon: LucideOctagonAlert
312
+ }
313
+ };
314
+ this.#injectedData = inject(PopupDataInjectionToken);
315
+ this.#injector = inject(Injector);
316
+ this.#localeMessages = this.#i18n.componentMessages("dialog", DIALOG_DEFAULT_MESSAGES);
317
+ this.#trapFocus = inject(CdkTrapFocus);
318
+ this.#componentRef = null;
319
+ this.componentHost = viewChild("componentHost", {
320
+ ...ngDevMode ? { debugName: "componentHost" } : /* istanbul ignore next */ {},
321
+ read: ViewContainerRef
322
+ });
323
+ this.actions = computed(() => {
324
+ const data = this.dialogData();
325
+ if (data.actions != null) return data.actions;
326
+ return this.getDefaultActions(data.type);
327
+ }, ...ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []);
328
+ this.baseClass = computed(() => {
329
+ const rounded = this.dialogData().rounded;
330
+ return dialogBaseThemeVariants({ rounded });
331
+ }, ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
332
+ this.bodyClass = computed(() => {
333
+ const hasIcon = this.dialogData().type != null;
334
+ return dialogBodyThemeVariants({ hasIcon });
335
+ }, ...ngDevMode ? [{ debugName: "bodyClass" }] : /* istanbul ignore next */ []);
336
+ this.closeButtonContainerClass = computed(() => {
337
+ return dialogCloseButtonContainerThemeVariants();
338
+ }, ...ngDevMode ? [{ debugName: "closeButtonContainerClass" }] : /* istanbul ignore next */ []);
339
+ this.contentClass = computed(() => {
340
+ return dialogContentThemeVariants();
341
+ }, ...ngDevMode ? [{ debugName: "contentClass" }] : /* istanbul ignore next */ []);
342
+ this.contentComponent = computed(() => {
343
+ const content = this.dialogData().content;
344
+ return content && !(content instanceof TemplateRef) ? content : null;
345
+ }, ...ngDevMode ? [{ debugName: "contentComponent" }] : /* istanbul ignore next */ []);
346
+ this.contentContainerClass = computed(() => {
347
+ return dialogContentContainerThemeVariants();
348
+ }, ...ngDevMode ? [{ debugName: "contentContainerClass" }] : /* istanbul ignore next */ []);
349
+ this.contentTemplate = computed(() => {
350
+ const content = this.dialogData().content;
351
+ return content instanceof TemplateRef ? content : null;
352
+ }, ...ngDevMode ? [{ debugName: "contentTemplate" }] : /* istanbul ignore next */ []);
353
+ this.describedById = computed(() => {
354
+ const data = this.dialogData();
355
+ return data.descriptionTemplate || data.description ? this.descriptionId : null;
356
+ }, ...ngDevMode ? [{ debugName: "describedById" }] : /* istanbul ignore next */ []);
357
+ this.descriptionClass = computed(() => {
358
+ return dialogDescriptionThemeVariants();
359
+ }, ...ngDevMode ? [{ debugName: "descriptionClass" }] : /* istanbul ignore next */ []);
360
+ this.descriptionId = createElementControlId();
361
+ this.dialogData = computed(() => this.dialogReference.data(), ...ngDevMode ? [{ debugName: "dialogData" }] : /* istanbul ignore next */ []);
362
+ this.dialogRef = this.#injectedData.dialogReference.dialogRef;
363
+ this.dialogReference = this.#injectedData.dialogReference;
364
+ this.footerClass = computed(() => {
365
+ const layout = this.dialogData().actionsLayout;
366
+ const rounded = this.dialogData().rounded;
367
+ return dialogFooterThemeVariants({
368
+ layout,
369
+ rounded
370
+ });
371
+ }, ...ngDevMode ? [{ debugName: "footerClass" }] : /* istanbul ignore next */ []);
372
+ this.hasTitle = computed(() => {
373
+ const data = this.dialogData();
374
+ return !!data.titleTemplate || !!data.title;
375
+ }, ...ngDevMode ? [{ debugName: "hasTitle" }] : /* istanbul ignore next */ []);
376
+ this.headerClass = computed(() => {
377
+ return dialogHeaderThemeVariants();
378
+ }, ...ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []);
379
+ this.headerId = createElementControlId();
380
+ this.icon = computed(() => {
381
+ const { type } = this.dialogData();
382
+ return type ? this.#iconMap[type] : void 0;
383
+ }, ...ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []);
384
+ this.iconClass = computed(() => {
385
+ const type = this.dialogData().type;
386
+ return dialogIconThemeVariants({ type });
387
+ }, ...ngDevMode ? [{ debugName: "iconClass" }] : /* istanbul ignore next */ []);
388
+ this.iconContainerClass = computed(() => {
389
+ return dialogIconContainerThemeVariants();
390
+ }, ...ngDevMode ? [{ debugName: "iconContainerClass" }] : /* istanbul ignore next */ []);
391
+ this.messages = computed(() => {
392
+ return mergeMessages(this.#localeMessages(), this.dialogData().messages);
393
+ }, ...ngDevMode ? [{ debugName: "messages" }] : /* istanbul ignore next */ []);
394
+ this.role = computed(() => {
395
+ const type = this.dialogData().type;
396
+ return type === "confirm" || type === "error" || type === "warning" ? "alertdialog" : "dialog";
397
+ }, ...ngDevMode ? [{ debugName: "role" }] : /* istanbul ignore next */ []);
398
+ this.titleClass = computed(() => {
399
+ return dialogTitleThemeVariants();
400
+ }, ...ngDevMode ? [{ debugName: "titleClass" }] : /* istanbul ignore next */ []);
401
+ this.titleContainerClass = computed(() => {
402
+ return dialogTitleContainerThemeVariants();
403
+ }, ...ngDevMode ? [{ debugName: "titleContainerClass" }] : /* istanbul ignore next */ []);
404
+ this.#trapFocus.autoCapture = true;
405
+ this.#trapFocus.enabled = this.dialogData().modal ?? true;
406
+ effect(() => {
407
+ const host = this.componentHost();
408
+ const type = this.contentComponent();
409
+ untracked(() => this.#renderComponent(host, type));
410
+ });
411
+ afterNextRender({ write: () => {
412
+ this.focusElement();
413
+ if (isDevMode()) this.#warnIfUnnamed();
414
+ } });
415
+ }
416
+ onActionClick(action) {
417
+ this.dialogReference.requestAction(action);
418
+ }
419
+ onCloseClick() {
420
+ this.dialogReference.requestClose();
421
+ }
422
+ onKeydown(event) {
423
+ if (event.key !== "Enter" || event.defaultPrevented || event.isComposing) return;
424
+ if (event.altKey || event.ctrlKey || event.metaKey || event.shiftKey || this.dialogData().footerTemplate) return;
425
+ if ((event.target instanceof Element ? event.target : null)?.closest(HANDLES_ENTER)) return;
426
+ const action = Array.from(this.actions()).find((candidate) => candidate.default);
427
+ if (action) {
428
+ event.preventDefault();
429
+ this.onActionClick(action);
430
+ }
431
+ }
432
+ #renderComponent(host, type) {
433
+ if (this.#componentRef && (!host || this.#componentRef.componentType !== type)) {
434
+ this.#componentRef.destroy();
435
+ this.#componentRef = null;
436
+ this.dialogReference.setComponentRef(void 0);
437
+ }
438
+ if (host && type && !this.#componentRef) {
439
+ host.clear();
440
+ this.#componentRef = host.createComponent(type, { injector: this.#injector });
441
+ this.dialogReference.setComponentRef(this.#componentRef);
442
+ }
443
+ }
444
+ #warnIfUnnamed() {
445
+ if (this.hasTitle() || this.dialogData().ariaLabel) return;
446
+ console.warn("[Mona Dialog] A dialog needs an accessible name. Set a title, a title template or aria-label (ariaLabel in the service settings).", this.#hostElementRef.nativeElement);
447
+ }
448
+ focusElement() {
449
+ const element = this.dialogData().focusedElement;
450
+ if (!element) return;
451
+ const dialogElement = this.#hostElementRef.nativeElement;
452
+ focusElement(dialogElement, element)?.setAttribute("cdkFocusInitial", "");
453
+ }
454
+ getDefaultActions(type) {
455
+ const messages = this.messages();
456
+ const ok = {
457
+ data: "ok",
458
+ default: true,
459
+ look: "primary",
460
+ text: messages.ok
461
+ };
462
+ if (type === "confirm") return [ok, {
463
+ data: "cancel",
464
+ look: "default",
465
+ text: messages.cancel
466
+ }];
467
+ return [ok];
468
+ }
469
+ static {
470
+ this.ɵfac = i0.ɵɵngDeclareFactory({
471
+ minVersion: "12.0.0",
472
+ version: "22.2.6",
473
+ ngImport: i0,
474
+ type: DialogContentComponent,
475
+ deps: [],
476
+ target: i0.ɵɵFactoryTarget.Component
477
+ });
478
+ }
479
+ static {
480
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
481
+ minVersion: "17.0.0",
482
+ version: "22.2.6",
483
+ type: DialogContentComponent,
484
+ isStandalone: true,
485
+ selector: "ng-component",
486
+ host: {
487
+ listeners: { "keydown": "onKeydown($event)" },
488
+ properties: {
489
+ "class": "baseClass()",
490
+ "attr.aria-describedby": "describedById()",
491
+ "attr.aria-label": "hasTitle() ? null : dialogData().ariaLabel || null",
492
+ "attr.aria-labelledby": "hasTitle() ? headerId : null",
493
+ "attr.aria-modal": "dialogData().modal ? 'true' : null",
494
+ "attr.role": "role()"
495
+ }
496
+ },
497
+ viewQueries: [{
498
+ propertyName: "componentHost",
499
+ first: true,
500
+ predicate: ["componentHost"],
501
+ descendants: true,
502
+ read: ViewContainerRef,
503
+ isSignal: true
504
+ }],
505
+ hostDirectives: [{ directive: i1.CdkTrapFocus }],
506
+ ngImport: i0,
507
+ template: "@let dialogIcon = icon();\n@let data = dialogData();\n\n<div [class]=\"contentContainerClass()\">\n @if (dialogIcon) {\n <div [class]=\"iconContainerClass()\">\n @if (data.iconTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.iconTemplate\"></ng-container>\n } @else {\n <div [class]=\"iconClass()\">\n <span aria-hidden=\"true\"></span>\n <svg [lucideIcon]=\"dialogIcon.icon\" [size]=\"24\" [style.color]=\"dialogIcon.color\"></svg>\n </div>\n }\n </div>\n }\n <div [class]=\"bodyClass()\">\n <div [class]=\"headerClass()\">\n @if (hasTitle()) {\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\n @if (data.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.titleTemplate\"></ng-container>\n } @else {\n <h2 [class]=\"titleClass()\">{{ data.title }}</h2>\n }\n </div>\n } @else {\n <div class=\"flex-1\"></div>\n }\n @if (data.closable) {\n <div [class]=\"closeButtonContainerClass()\">\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"messages().closeDialog\"\n (click)=\"onCloseClick()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n\n @let descriptionTemplateId = data.descriptionTemplate ? descriptionId : undefined;\n <div class=\"p-1\" [attr.id]=\"descriptionTemplateId\">\n @if (data.descriptionTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.descriptionTemplate\"></ng-container>\n } @else if (data.description) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ data.description }}</p>\n }\n </div>\n\n <div [class]=\"contentClass()\">\n @if (contentTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: data.data, dialogRef: dialogRef }\"></ng-container>\n } @else if (contentComponent()) {\n <ng-container #componentHost></ng-container>\n } @else if (data.text) {\n <p>{{ data.text }}</p>\n }\n </div>\n </div>\n</div>\n\n@if (data.footerTemplate || (actions() | monaAny)) {\n @if (data.footerTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.footerTemplate\"></ng-container>\n } @else {\n <div [class]=\"footerClass()\">\n @for (action of actions(); track $index) {\n <button\n monaButton\n type=\"button\"\n [class]=\"action.cssClass || ''\"\n [iconOnly]=\"action.iconOnly || false\"\n [look]=\"action.look\"\n [rounded]=\"action.rounded || data.rounded\"\n (click)=\"onActionClick(action)\">\n {{ action.text }}\n </button>\n }\n </div>\n }\n}\n",
508
+ dependencies: [
509
+ {
510
+ kind: "directive",
511
+ type: ButtonDirective,
512
+ selector: "button[monaButton]",
513
+ inputs: [
514
+ "aria-haspopup",
515
+ "disabled",
516
+ "iconOnly",
517
+ "loading",
518
+ "look",
519
+ "rounded",
520
+ "selected",
521
+ "size",
522
+ "tabindex",
523
+ "toggleable",
524
+ "type",
525
+ "class",
526
+ "value"
527
+ ],
528
+ outputs: ["lookChange", "selectedChange"]
529
+ },
530
+ {
531
+ kind: "directive",
532
+ type: NgTemplateOutlet,
533
+ selector: "[ngTemplateOutlet]",
534
+ inputs: [
535
+ "ngTemplateOutletContext",
536
+ "ngTemplateOutlet",
537
+ "ngTemplateOutletInjector"
538
+ ]
539
+ },
540
+ {
541
+ kind: "component",
542
+ type: LucideX,
543
+ selector: "svg[lucideX]"
544
+ },
545
+ {
546
+ kind: "component",
547
+ type: LucideDynamicIcon,
548
+ selector: "svg[lucideIcon]",
549
+ inputs: ["lucideIcon"]
550
+ },
551
+ {
552
+ kind: "pipe",
553
+ type: AnyPipe,
554
+ name: "monaAny"
555
+ }
556
+ ]
557
+ });
558
+ }
559
+ };
560
+ i0.ɵɵngDeclareClassMetadata({
561
+ minVersion: "12.0.0",
562
+ version: "22.2.6",
563
+ ngImport: i0,
564
+ type: DialogContentComponent,
565
+ decorators: [{
566
+ type: Component,
567
+ args: [{
568
+ imports: [
569
+ ButtonDirective,
570
+ NgTemplateOutlet,
571
+ AnyPipe,
572
+ LucideX,
573
+ LucideDynamicIcon
574
+ ],
575
+ host: {
576
+ "[class]": "baseClass()",
577
+ "[attr.aria-describedby]": "describedById()",
578
+ "[attr.aria-label]": "hasTitle() ? null : dialogData().ariaLabel || null",
579
+ "[attr.aria-labelledby]": "hasTitle() ? headerId : null",
580
+ "[attr.aria-modal]": "dialogData().modal ? 'true' : null",
581
+ "[attr.role]": "role()",
582
+ "(keydown)": "onKeydown($event)"
583
+ },
584
+ hostDirectives: [CdkTrapFocus],
585
+ template: "@let dialogIcon = icon();\n@let data = dialogData();\n\n<div [class]=\"contentContainerClass()\">\n @if (dialogIcon) {\n <div [class]=\"iconContainerClass()\">\n @if (data.iconTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.iconTemplate\"></ng-container>\n } @else {\n <div [class]=\"iconClass()\">\n <span aria-hidden=\"true\"></span>\n <svg [lucideIcon]=\"dialogIcon.icon\" [size]=\"24\" [style.color]=\"dialogIcon.color\"></svg>\n </div>\n }\n </div>\n }\n <div [class]=\"bodyClass()\">\n <div [class]=\"headerClass()\">\n @if (hasTitle()) {\n <div [id]=\"headerId\" [class]=\"titleContainerClass()\">\n @if (data.titleTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.titleTemplate\"></ng-container>\n } @else {\n <h2 [class]=\"titleClass()\">{{ data.title }}</h2>\n }\n </div>\n } @else {\n <div class=\"flex-1\"></div>\n }\n @if (data.closable) {\n <div [class]=\"closeButtonContainerClass()\">\n <button\n monaButton\n look=\"ghost\"\n size=\"small\"\n [iconOnly]=\"true\"\n [attr.aria-label]=\"messages().closeDialog\"\n (click)=\"onCloseClick()\">\n <svg lucideX [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n\n @let descriptionTemplateId = data.descriptionTemplate ? descriptionId : undefined;\n <div class=\"p-1\" [attr.id]=\"descriptionTemplateId\">\n @if (data.descriptionTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.descriptionTemplate\"></ng-container>\n } @else if (data.description) {\n <p [id]=\"descriptionId\" [class]=\"descriptionClass()\">{{ data.description }}</p>\n }\n </div>\n\n <div [class]=\"contentClass()\">\n @if (contentTemplate(); as template) {\n <ng-container\n [ngTemplateOutlet]=\"template\"\n [ngTemplateOutletContext]=\"{ $implicit: data.data, dialogRef: dialogRef }\"></ng-container>\n } @else if (contentComponent()) {\n <ng-container #componentHost></ng-container>\n } @else if (data.text) {\n <p>{{ data.text }}</p>\n }\n </div>\n </div>\n</div>\n\n@if (data.footerTemplate || (actions() | monaAny)) {\n @if (data.footerTemplate) {\n <ng-container [ngTemplateOutlet]=\"data.footerTemplate\"></ng-container>\n } @else {\n <div [class]=\"footerClass()\">\n @for (action of actions(); track $index) {\n <button\n monaButton\n type=\"button\"\n [class]=\"action.cssClass || ''\"\n [iconOnly]=\"action.iconOnly || false\"\n [look]=\"action.look\"\n [rounded]=\"action.rounded || data.rounded\"\n (click)=\"onActionClick(action)\">\n {{ action.text }}\n </button>\n }\n </div>\n }\n}\n"
586
+ }]
587
+ }],
588
+ ctorParameters: () => [],
589
+ propDecorators: { componentHost: [{
590
+ type: i0.ViewChild,
591
+ args: ["componentHost", {
592
+ read: ViewContainerRef,
593
+ isSignal: true
594
+ }]
595
+ }] }
596
+ });
421
597
  const DIALOG_DATA = new InjectionToken("DIALOG_DATA");
422
-
423
- /**
424
- * A handle on an open dialog. The close contract:
425
- * - `action$` emits when an action button is clicked, before the dialog closes; `preventDefault()` keeps it open.
426
- * - `close$` emits before any close, and `preventDefault()` keeps the dialog open.
427
- * - `result` emits how the dialog closed as soon as the close goes ahead, and `closed$` emits the same result once
428
- * the dialog is gone. All of them complete when it closes.
429
- */
430
- class DialogRef {
431
- #options;
432
- constructor(options) {
433
- this.#options = options;
434
- }
435
- /**
436
- * @description Closes the dialog. The value is the `value` of the result, which reports the close as
437
- * programmatic.
438
- */
439
- close(result) {
440
- this.#options.close(result);
441
- }
442
- /**
443
- * @description Updates the dialog's content and appearance in place without closing and reopening it.
444
- * Only the fields provided are changed; anything omitted keeps its current value.
445
- */
446
- update(data) {
447
- this.#options.update(data);
448
- }
449
- /**
450
- * @description Emits when an action button is clicked, before the dialog closes. Call `preventDefault()` on
451
- * the event to keep the dialog open. Completes when the dialog closes.
452
- */
453
- get action$() {
454
- return this.#options.action$;
455
- }
456
- /**
457
- * @description Emits before the dialog closes, whatever closes it. Call `preventDefault()` to keep it open.
458
- * Completes when the dialog closes.
459
- */
460
- get close$() {
461
- return this.#options.close$;
462
- }
463
- /**
464
- * @description Emits the dialog's result once it has closed and its leave animation has finished, then
465
- * completes.
466
- */
467
- get closed$() {
468
- return this.#options.closed$;
469
- }
470
- /**
471
- * @description The component given as `content`, or `null` for template and text content.
472
- */
473
- get component() {
474
- return this.#options.component;
475
- }
476
- /** The dialog's overlay element. */
477
- get element() {
478
- return this.#options.element;
479
- }
480
- /** The dialog's current rendered height, in pixels. */
481
- get height() {
482
- return this.#options.height;
483
- }
484
- /** The underlying `PopupRef`, for advanced overlay access. */
485
- get popupRef() {
486
- return this.#options.popupRef;
487
- }
488
- /**
489
- * @description Emits how the dialog closed (an action, the close button, Escape, a backdrop click or
490
- * `close()`) as soon as the close goes ahead, then completes when the dialog is gone. Late subscribers get the
491
- * result too.
492
- */
493
- get result() {
494
- return this.#options.result;
495
- }
496
- /** The dialog's current rendered width, in pixels. */
497
- get width() {
498
- return this.#options.width;
499
- }
500
- }
501
-
502
- /**
503
- * @description Emitted when the user clicks a dialog action button. Call `preventDefault()` to keep the dialog open.
504
- */
505
- class DialogActionEvent extends PreventableEvent {
506
- #action;
507
- constructor(action) {
508
- super("dialogAction");
509
- this.#action = action;
510
- }
511
- /**
512
- * @description The action that was clicked.
513
- */
514
- get action() {
515
- return this.#action;
516
- }
517
- }
518
-
519
- /**
520
- * @internal The dialog's own side of `DialogRef`: action buttons and the close button report here, so a dialog
521
- * opened through `DialogService` and one declared with `<mona-dialog>` close the same way.
522
- */
523
- class DialogReference {
524
- #action$ = new Subject();
525
- #closed$ = new ReplaySubject(1);
526
- #dialogRef;
527
- #options;
528
- #result$ = new ReplaySubject(1);
529
- #pendingAction = null;
530
- #resultValue = null;
531
- constructor(options, initialData) {
532
- this.#options = options;
533
- this.#dialogRef = new DialogRef(this);
534
- this.data = signal(initialData, /* @ts-ignore */
535
- ...(ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []));
536
- }
537
- close(result) {
538
- const event = result instanceof PopupCloseEvent
539
- ? result
540
- : new PopupCloseEvent({ result, via: PopupCloseSource.Programmatic });
541
- this.#popupRefOrThrow.close(event);
542
- }
543
- initializePopupRef(popupRef) {
544
- this.#options.popupRef = popupRef;
545
- popupRef.closeStart.pipe(take(1)).subscribe(event => this.#settle(event));
546
- popupRef.closed.pipe(take(1)).subscribe(event => {
547
- const result = this.#settle(event);
548
- this.#result$.complete();
549
- this.#action$.complete();
550
- this.#closed$.next(result);
551
- this.#closed$.complete();
552
- });
553
- }
554
- /**
555
- * Reports a click on an action button: `action$` first, where it can be prevented, then the close.
556
- */
557
- requestAction(action) {
558
- const event = new DialogActionEvent(action);
559
- this.#action$.next(event);
560
- if (event.isDefaultPrevented()) {
561
- return;
562
- }
563
- this.#pendingAction = action;
564
- if (!this.#popupRefOrThrow.close(new PopupCloseEvent({ via: PopupCloseSource.Action }))) {
565
- this.#pendingAction = null;
566
- }
567
- }
568
- /**
569
- * Reports a click on the close button.
570
- */
571
- requestClose() {
572
- this.#popupRefOrThrow.close(new PopupCloseEvent({ via: PopupCloseSource.CloseButton }));
573
- }
574
- setComponentRef(componentRef) {
575
- this.#options.componentRef = componentRef;
576
- }
577
- update(data) {
578
- this.data.update(current => ({ ...current, ...data }));
579
- }
580
- /** Works out the result once, when the close goes ahead, and publishes it on `result`. */
581
- #settle(event) {
582
- if (this.#resultValue) {
583
- return this.#resultValue;
584
- }
585
- const action = this.#pendingAction;
586
- const result = action && event.via === PopupCloseSource.Action
587
- ? { action, via: PopupCloseSource.Action, viaClose: false }
588
- : {
589
- value: event.result,
590
- via: event.via == null || event.via === PopupCloseSource.Action
591
- ? PopupCloseSource.Programmatic
592
- : event.via,
593
- viaClose: true
594
- };
595
- this.#resultValue = result;
596
- this.#result$.next(result);
597
- return result;
598
- }
599
- get action$() {
600
- return this.#action$.asObservable();
601
- }
602
- get close$() {
603
- const popupRef = this.#popupRefOrThrow;
604
- return popupRef.beforeClose.pipe(takeUntil(merge(popupRef.closed, this.#closed$).pipe(take(1))), map(event => event));
605
- }
606
- get closed$() {
607
- return this.#closed$.asObservable();
608
- }
609
- get component() {
610
- return this.#options.componentRef ?? null;
611
- }
612
- get dialogRef() {
613
- return this.#dialogRef;
614
- }
615
- get element() {
616
- return this.#popupRefOrThrow.overlayRef.overlayElement;
617
- }
618
- get height() {
619
- return this.element.offsetHeight;
620
- }
621
- get popupRef() {
622
- return this.#popupRefOrThrow;
623
- }
624
- get #popupRefOrThrow() {
625
- if (!this.#options.popupRef) {
626
- throw new Error("DialogReference: popupRef has not been initialized.");
627
- }
628
- return this.#options.popupRef;
629
- }
630
- get result() {
631
- return this.#result$.asObservable();
632
- }
633
- get width() {
634
- return this.element.offsetWidth;
635
- }
636
- }
637
-
598
+ var DialogRef = class {
599
+ #options;
600
+ constructor(options) {
601
+ this.#options = options;
602
+ }
603
+ close(result) {
604
+ this.#options.close(result);
605
+ }
606
+ update(data) {
607
+ this.#options.update(data);
608
+ }
609
+ get action$() {
610
+ return this.#options.action$;
611
+ }
612
+ get close$() {
613
+ return this.#options.close$;
614
+ }
615
+ get closed$() {
616
+ return this.#options.closed$;
617
+ }
618
+ get component() {
619
+ return this.#options.component;
620
+ }
621
+ get element() {
622
+ return this.#options.element;
623
+ }
624
+ get height() {
625
+ return this.#options.height;
626
+ }
627
+ get popupRef() {
628
+ return this.#options.popupRef;
629
+ }
630
+ get result() {
631
+ return this.#options.result;
632
+ }
633
+ get width() {
634
+ return this.#options.width;
635
+ }
636
+ };
637
+ var DialogActionEvent = class extends PreventableEvent {
638
+ #action;
639
+ constructor(action) {
640
+ super("dialogAction");
641
+ this.#action = action;
642
+ }
643
+ get action() {
644
+ return this.#action;
645
+ }
646
+ };
647
+ var DialogReference = class {
648
+ #action$ = new Subject();
649
+ #closed$ = new ReplaySubject(1);
650
+ #dialogRef;
651
+ #options;
652
+ #result$ = new ReplaySubject(1);
653
+ #pendingAction = null;
654
+ #resultValue = null;
655
+ constructor(options, initialData) {
656
+ this.#options = options;
657
+ this.#dialogRef = new DialogRef(this);
658
+ this.data = signal(initialData, ...ngDevMode ? [{ debugName: "data" }] : /* istanbul ignore next */ []);
659
+ }
660
+ close(result) {
661
+ const event = result instanceof PopupCloseEvent ? result : new PopupCloseEvent({
662
+ result,
663
+ via: PopupCloseSource.Programmatic
664
+ });
665
+ this.#popupRefOrThrow.close(event);
666
+ }
667
+ initializePopupRef(popupRef) {
668
+ this.#options.popupRef = popupRef;
669
+ popupRef.closeStart.pipe(take(1)).subscribe((event) => this.#settle(event));
670
+ popupRef.closed.pipe(take(1)).subscribe((event) => {
671
+ const result = this.#settle(event);
672
+ this.#result$.complete();
673
+ this.#action$.complete();
674
+ this.#closed$.next(result);
675
+ this.#closed$.complete();
676
+ });
677
+ }
678
+ requestAction(action) {
679
+ const event = new DialogActionEvent(action);
680
+ this.#action$.next(event);
681
+ if (event.isDefaultPrevented()) return;
682
+ this.#pendingAction = action;
683
+ if (!this.#popupRefOrThrow.close(new PopupCloseEvent({ via: PopupCloseSource.Action }))) this.#pendingAction = null;
684
+ }
685
+ requestClose() {
686
+ this.#popupRefOrThrow.close(new PopupCloseEvent({ via: PopupCloseSource.CloseButton }));
687
+ }
688
+ setComponentRef(componentRef) {
689
+ this.#options.componentRef = componentRef;
690
+ }
691
+ update(data) {
692
+ this.data.update((current) => ({
693
+ ...current,
694
+ ...data
695
+ }));
696
+ }
697
+ #settle(event) {
698
+ if (this.#resultValue) return this.#resultValue;
699
+ const action = this.#pendingAction;
700
+ const result = action && event.via === PopupCloseSource.Action ? {
701
+ action,
702
+ via: PopupCloseSource.Action,
703
+ viaClose: false
704
+ } : {
705
+ value: event.result,
706
+ via: event.via == null || event.via === PopupCloseSource.Action ? PopupCloseSource.Programmatic : event.via,
707
+ viaClose: true
708
+ };
709
+ this.#resultValue = result;
710
+ this.#result$.next(result);
711
+ return result;
712
+ }
713
+ get action$() {
714
+ return this.#action$.asObservable();
715
+ }
716
+ get close$() {
717
+ const popupRef = this.#popupRefOrThrow;
718
+ return popupRef.beforeClose.pipe(takeUntil(merge(popupRef.closed, this.#closed$).pipe(take(1))), map((event) => event));
719
+ }
720
+ get closed$() {
721
+ return this.#closed$.asObservable();
722
+ }
723
+ get component() {
724
+ return this.#options.componentRef ?? null;
725
+ }
726
+ get dialogRef() {
727
+ return this.#dialogRef;
728
+ }
729
+ get element() {
730
+ return this.#popupRefOrThrow.overlayRef.overlayElement;
731
+ }
732
+ get height() {
733
+ return this.element.offsetHeight;
734
+ }
735
+ get popupRef() {
736
+ return this.#popupRefOrThrow;
737
+ }
738
+ get #popupRefOrThrow() {
739
+ if (!this.#options.popupRef) throw new Error("DialogReference: popupRef has not been initialized.");
740
+ return this.#options.popupRef;
741
+ }
742
+ get result() {
743
+ return this.#result$.asObservable();
744
+ }
745
+ get width() {
746
+ return this.element.offsetWidth;
747
+ }
748
+ };
638
749
  const createDialogInjectorData = (settings) => {
639
- return {
640
- actions: settings.actions,
641
- actionsLayout: settings.actionsLayout ?? "end",
642
- ariaLabel: settings.ariaLabel,
643
- closable: settings.closable ?? true,
644
- closeOnEscape: settings.closeOnEscape ?? true,
645
- content: settings.content,
646
- data: settings.data,
647
- description: settings.description,
648
- descriptionTemplate: settings.descriptionTemplate,
649
- dialogReference: null,
650
- focusedElement: settings.focusedElement ?? null,
651
- footerTemplate: settings.footerTemplate,
652
- iconTemplate: settings.iconTemplate,
653
- messages: settings.messages,
654
- modal: settings.modal ?? true,
655
- rounded: settings.rounded ?? "medium",
656
- text: settings.text ?? "",
657
- title: settings.title,
658
- titleTemplate: settings.titleTemplate,
659
- type: settings.type
660
- };
750
+ return {
751
+ actions: settings.actions,
752
+ actionsLayout: settings.actionsLayout ?? "end",
753
+ ariaLabel: settings.ariaLabel,
754
+ closable: settings.closable ?? true,
755
+ closeOnEscape: settings.closeOnEscape ?? true,
756
+ content: settings.content,
757
+ data: settings.data,
758
+ description: settings.description,
759
+ descriptionTemplate: settings.descriptionTemplate,
760
+ dialogReference: null,
761
+ focusedElement: settings.focusedElement ?? null,
762
+ footerTemplate: settings.footerTemplate,
763
+ iconTemplate: settings.iconTemplate,
764
+ messages: settings.messages,
765
+ modal: settings.modal ?? true,
766
+ rounded: settings.rounded ?? "medium",
767
+ text: settings.text ?? "",
768
+ title: settings.title,
769
+ titleTemplate: settings.titleTemplate,
770
+ type: settings.type
771
+ };
661
772
  };
662
-
663
- /** Marks the buttons `confirm()` and `alert()` add, so their result can be read without comparing text. */
664
773
  const DIALOG_OK = "ok";
665
774
  const DIALOG_CANCEL = "cancel";
666
- /** Keeps a dialog 1rem inside the viewport unless the settings give their own limits. */
667
775
  const VIEWPORT_MARGIN = "2rem";
668
- class DialogService {
669
- #document = inject(DOCUMENT);
670
- #i18n = inject(MonaI18nService);
671
- #injector = inject(Injector);
672
- #localeMessages = this.#i18n.componentMessages("dialog", DIALOG_DEFAULT_MESSAGES);
673
- #popupService = inject(PopupService);
674
- /**
675
- * Opens a dialog with an OK button. Emits once it closes, however it closes, then completes.
676
- * The dialog opens when `alert()` is called, whether or not the result is subscribed to.
677
- */
678
- alert(settings) {
679
- const actions = this.#promptActions(settings, false);
680
- return this.show({ type: "info", ...settings, actions }).result.pipe(map(() => undefined));
681
- }
682
- /**
683
- * Opens a confirmation dialog with OK and Cancel buttons. Emits `true` for OK and `false` for anything else
684
- * (Cancel, the close button, Escape), then completes. The dialog opens when `confirm()` is called, whether or
685
- * not the result is subscribed to.
686
- */
687
- confirm(settings) {
688
- const actions = this.#promptActions(settings, true);
689
- return this.show({ type: "confirm", ...settings, actions }).result.pipe(map(result => !result.viaClose && result.action.data === DIALOG_OK));
690
- }
691
- /**
692
- * Opens a dialog.
693
- * @typeParam R the type of the value passed to `DialogRef.close(value)`
694
- * @typeParam D the type of `data`
695
- */
696
- show(settings) {
697
- const modal = settings.modal ?? true;
698
- const injectorData = createDialogInjectorData(settings);
699
- const dialogReference = new DialogReference({}, injectorData);
700
- injectorData.dialogReference = dialogReference;
701
- const popupRef = this.#popupService.create({
702
- anchor: this.#document.body,
703
- backdropClass: modal
704
- ? ["fixed", "inset-0", "bg-background/50", "transition-opacity", "z-40", "backdrop-blur-xs"]
705
- : "transparent",
706
- blockScroll: modal,
707
- closeOnBackdropClick: false,
708
- closeOnEscape: injectorData.closeOnEscape,
709
- closeOnOutsideClick: false,
710
- content: DialogContentComponent,
711
- data: injectorData,
712
- hasBackdrop: modal,
713
- height: settings.height ?? "fit-content",
714
- injector: settings.injector,
715
- maxHeight: settings.maxHeight ?? `calc(100dvh - ${VIEWPORT_MARGIN})`,
716
- maxWidth: settings.maxWidth ?? `calc(100dvw - ${VIEWPORT_MARGIN})`,
717
- minHeight: settings.minHeight,
718
- minWidth: settings.minWidth,
719
- popupWrapperClass: "mona-popup-constrain-height",
720
- positionStrategy: "global",
721
- providers: [
722
- { provide: DialogRef, useFactory: forwardRef(() => dialogReference.dialogRef) },
723
- { provide: DIALOG_DATA, useValue: settings.data }
724
- ],
725
- restoreFocus: (settings.restoreFocus ?? true) ? "auto" : false,
726
- width: settings.width
727
- });
728
- dialogReference.initializePopupRef(popupRef);
729
- positionGlobalOverlay(popupRef.overlayRef, { left: settings.left, top: settings.top });
730
- if (modal) {
731
- const release = inertOutside(popupRef.overlayRef.hostElement);
732
- merge(popupRef.closeStart, popupRef.closed)
733
- .pipe(take(1))
734
- .subscribe(() => release());
735
- }
736
- // Once rendered, center again from the real size, in case the content changed it.
737
- afterNextRender({ write: () => popupRef.overlayRef.updatePosition() }, { injector: this.#injector });
738
- return dialogReference.dialogRef;
739
- }
740
- #promptActions(settings, withCancel) {
741
- const messages = mergeMessages(this.#localeMessages(), settings.messages);
742
- const ok = { data: DIALOG_OK, default: true, look: "primary", text: messages.ok };
743
- const cancel = { data: DIALOG_CANCEL, look: "default", text: messages.cancel };
744
- return withCancel ? [ok, cancel] : [ok];
745
- }
746
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
747
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogService, providedIn: "root" }); }
748
- }
749
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogService, decorators: [{
750
- type: Injectable,
751
- args: [{
752
- providedIn: "root"
753
- }]
754
- }] });
755
-
756
- class DialogComponent {
757
- #destroyRef;
758
- #dialogService;
759
- #destroyed;
760
- #dialogRef;
761
- constructor() {
762
- this.#destroyRef = inject(DestroyRef);
763
- this.#dialogService = inject(DialogService);
764
- this.#destroyed = false;
765
- this.contentTemplate = contentChild(DialogContentTemplateDirective, { ...(ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
766
- this.descriptionTemplate = contentChild(DialogDescriptionTemplateDirective, { ...(ngDevMode ? { debugName: "descriptionTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
767
- this.footerTemplate = contentChild(DialogFooterTemplateDirective, { ...(ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
768
- this.iconTemplate = contentChild(DialogIconTemplateDirective, { ...(ngDevMode ? { debugName: "iconTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
769
- this.titleTemplate = contentChild(DialogTitleTemplateDirective, { ...(ngDevMode ? { debugName: "titleTemplate" } : /* istanbul ignore next */ {}), read: TemplateRef });
770
- /**
771
- * @description Emitted when the user clicks an action button. Call `event.preventDefault()` on the emitted
772
- * `DialogActionEvent` to keep the dialog open.
773
- */
774
- this.action = output();
775
- /**
776
- * @description Sets the actions of the dialog.
777
- * @default []
778
- */
779
- this.actions = input([], /* @ts-ignore */
780
- ...(ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []));
781
- /**
782
- * @description Sets the layout of the actions in the dialog footer.
783
- * @default "end"
784
- */
785
- this.actionsLayout = input("end", /* @ts-ignore */
786
- ...(ngDevMode ? [{ debugName: "actionsLayout" }] : /* istanbul ignore next */ []));
787
- /**
788
- * @description Accessible name for the dialog when it has no `title` or title template.
789
- */
790
- this.ariaLabel = input(undefined, { ...(ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {}), alias: "aria-label" });
791
- /**
792
- * @description Sets the visibility of the close button in the dialog header.
793
- * @default true
794
- */
795
- this.closable = input(true, /* @ts-ignore */
796
- ...(ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []));
797
- /**
798
- * @description Emits before the dialog closes, whatever closes it: an action, the close button, Escape, or the
799
- * component being destroyed. Call `preventDefault()` to keep it open (a close caused by destruction can't be
800
- * kept).
801
- */
802
- // eslint-disable-next-line @angular-eslint/no-output-native
803
- this.close = output();
804
- /**
805
- * @description Sets whether the dialog should close when the escape key is pressed.
806
- * @default true
807
- */
808
- this.closeOnEscape = input(true, /* @ts-ignore */
809
- ...(ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []));
810
- /**
811
- * @description Emits when the dialog has closed and its leave animation has finished.
812
- */
813
- this.closed = output();
814
- /**
815
- * @description Sets the description of the dialog.
816
- */
817
- this.description = input(/* @ts-ignore */
818
- ...(ngDevMode ? [undefined, { debugName: "description" }] : /* istanbul ignore next */ []));
819
- /**
820
- * @description Sets the element that should receive focus when the dialog is opened. When omitted, focus
821
- * moves to the first focusable element automatically.
822
- */
823
- this.focusedElement = input(/* @ts-ignore */
824
- ...(ngDevMode ? [undefined, { debugName: "focusedElement" }] : /* istanbul ignore next */ []));
825
- /**
826
- * @description Sets the height of the dialog.
827
- */
828
- this.height = input(/* @ts-ignore */
829
- ...(ngDevMode ? [undefined, { debugName: "height" }] : /* istanbul ignore next */ []));
830
- /**
831
- * @description Sets the left position of the dialog.
832
- */
833
- this.left = input(/* @ts-ignore */
834
- ...(ngDevMode ? [undefined, { debugName: "left" }] : /* istanbul ignore next */ []));
835
- /**
836
- * @description Sets the maximum height of the dialog.
837
- */
838
- this.maxHeight = input(/* @ts-ignore */
839
- ...(ngDevMode ? [undefined, { debugName: "maxHeight" }] : /* istanbul ignore next */ []));
840
- /**
841
- * @description Sets the maximum width of the dialog.
842
- */
843
- this.maxWidth = input(/* @ts-ignore */
844
- ...(ngDevMode ? [undefined, { debugName: "maxWidth" }] : /* istanbul ignore next */ []));
845
- /**
846
- * @description Sets the custom messages for the dialog.
847
- */
848
- this.messages = input(/* @ts-ignore */
849
- ...(ngDevMode ? [undefined, { debugName: "messages" }] : /* istanbul ignore next */ []));
850
- /**
851
- * @description Sets the minimum height of the dialog.
852
- */
853
- this.minHeight = input(/* @ts-ignore */
854
- ...(ngDevMode ? [undefined, { debugName: "minHeight" }] : /* istanbul ignore next */ []));
855
- /**
856
- * @description Sets the minimum width of the dialog.
857
- */
858
- this.minWidth = input(/* @ts-ignore */
859
- ...(ngDevMode ? [undefined, { debugName: "minWidth" }] : /* istanbul ignore next */ []));
860
- /**
861
- * @description Whether the dialog is modal: a backdrop, `aria-modal="true"`, focus kept inside, page scroll
862
- * locked, and the rest of the page inert.
863
- * @default true
864
- */
865
- this.modal = input(true, /* @ts-ignore */
866
- ...(ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []));
867
- /**
868
- * @description Border-radius preset applied to the component.
869
- * @default "medium"
870
- */
871
- this.rounded = input("medium", /* @ts-ignore */
872
- ...(ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []));
873
- /**
874
- * @description Primary text content displayed by the component.
875
- */
876
- this.text = input(/* @ts-ignore */
877
- ...(ngDevMode ? [undefined, { debugName: "text" }] : /* istanbul ignore next */ []));
878
- /**
879
- * @description Title text displayed in the component header or trigger.
880
- */
881
- this.title = input(/* @ts-ignore */
882
- ...(ngDevMode ? [undefined, { debugName: "title" }] : /* istanbul ignore next */ []));
883
- /**
884
- * @description Sets the top position of the dialog.
885
- */
886
- this.top = input(/* @ts-ignore */
887
- ...(ngDevMode ? [undefined, { debugName: "top" }] : /* istanbul ignore next */ []));
888
- /**
889
- * @description Visual severity type of the dialog, controlling its icon and semantic role. Set to `null` to
890
- * render the dialog without an icon.
891
- * @default "info"
892
- */
893
- this.type = input("info", /* @ts-ignore */
894
- ...(ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []));
895
- /**
896
- * @description Sets the width of the dialog.
897
- */
898
- this.width = input(/* @ts-ignore */
899
- ...(ngDevMode ? [undefined, { debugName: "width" }] : /* istanbul ignore next */ []));
900
- afterNextRender({
901
- write: () => this.#openDialog()
902
- });
903
- effect(() => {
904
- const actions = this.actions() ? [...this.actions()] : undefined;
905
- const update = {
906
- actions,
907
- actionsLayout: this.actionsLayout(),
908
- ariaLabel: this.ariaLabel(),
909
- closable: this.closable(),
910
- description: this.description(),
911
- messages: this.messages(),
912
- rounded: this.rounded(),
913
- text: this.text(),
914
- title: this.title(),
915
- type: this.type()
916
- };
917
- this.#dialogRef?.update(update);
918
- });
919
- this.#destroyRef.onDestroy(() => {
920
- // Outputs can't emit once the component is destroyed, so this close is silent.
921
- this.#destroyed = true;
922
- this.#dialogRef?.close();
923
- });
924
- }
925
- #openDialog() {
926
- const actions = this.actions() ? [...this.actions()] : undefined;
927
- this.#dialogRef = this.#dialogService.show({
928
- actions,
929
- actionsLayout: this.actionsLayout(),
930
- ariaLabel: this.ariaLabel(),
931
- closable: this.closable(),
932
- closeOnEscape: this.closeOnEscape(),
933
- content: this.contentTemplate(),
934
- description: this.description(),
935
- descriptionTemplate: this.descriptionTemplate(),
936
- focusedElement: this.focusedElement(),
937
- footerTemplate: this.footerTemplate(),
938
- height: this.height(),
939
- iconTemplate: this.iconTemplate(),
940
- left: this.left(),
941
- maxHeight: this.maxHeight(),
942
- maxWidth: this.maxWidth(),
943
- messages: this.messages(),
944
- minHeight: this.minHeight(),
945
- minWidth: this.minWidth(),
946
- modal: this.modal(),
947
- rounded: this.rounded(),
948
- text: this.text(),
949
- title: this.title(),
950
- titleTemplate: this.titleTemplate(),
951
- top: this.top(),
952
- type: this.type(),
953
- width: this.width()
954
- });
955
- this.#dialogRef.action$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
956
- this.action.emit(event);
957
- });
958
- this.#dialogRef.close$.subscribe((event) => {
959
- if (!this.#destroyed) {
960
- this.close.emit(event);
961
- }
962
- });
963
- this.#dialogRef.closed$.subscribe(() => {
964
- if (!this.#destroyed) {
965
- this.closed.emit();
966
- }
967
- });
968
- }
969
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
970
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.6", type: DialogComponent, isStandalone: true, selector: "mona-dialog", inputs: { actions: { classPropertyName: "actions", publicName: "actions", isSignal: true, isRequired: false, transformFunction: null }, actionsLayout: { classPropertyName: "actionsLayout", publicName: "actionsLayout", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "aria-label", isSignal: true, isRequired: false, transformFunction: null }, closable: { classPropertyName: "closable", publicName: "closable", isSignal: true, isRequired: false, transformFunction: null }, closeOnEscape: { classPropertyName: "closeOnEscape", publicName: "closeOnEscape", isSignal: true, isRequired: false, transformFunction: null }, description: { classPropertyName: "description", publicName: "description", isSignal: true, isRequired: false, transformFunction: null }, focusedElement: { classPropertyName: "focusedElement", publicName: "focusedElement", isSignal: true, isRequired: false, transformFunction: null }, height: { classPropertyName: "height", publicName: "height", isSignal: true, isRequired: false, transformFunction: null }, left: { classPropertyName: "left", publicName: "left", 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 }, messages: { classPropertyName: "messages", publicName: "messages", 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 }, modal: { classPropertyName: "modal", publicName: "modal", isSignal: true, isRequired: false, transformFunction: null }, rounded: { classPropertyName: "rounded", publicName: "rounded", isSignal: true, isRequired: false, transformFunction: null }, text: { classPropertyName: "text", publicName: "text", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, top: { classPropertyName: "top", publicName: "top", isSignal: true, isRequired: false, transformFunction: null }, type: { classPropertyName: "type", publicName: "type", isSignal: true, isRequired: false, transformFunction: null }, width: { classPropertyName: "width", publicName: "width", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { action: "action", close: "close", closed: "closed" }, host: { properties: { "attr.aria-label": "null" }, classAttribute: "hidden" }, queries: [{ propertyName: "contentTemplate", first: true, predicate: DialogContentTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "descriptionTemplate", first: true, predicate: DialogDescriptionTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "footerTemplate", first: true, predicate: DialogFooterTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "iconTemplate", first: true, predicate: DialogIconTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }, { propertyName: "titleTemplate", first: true, predicate: DialogTitleTemplateDirective, descendants: true, read: TemplateRef, isSignal: true }], ngImport: i0, template: ``, isInline: true }); }
971
- }
972
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.6", ngImport: i0, type: DialogComponent, decorators: [{
973
- type: Component,
974
- args: [{
975
- selector: "mona-dialog",
976
- template: ``,
977
- host: {
978
- "[attr.aria-label]": "null",
979
- class: "hidden"
980
- }
981
- }]
982
- }], ctorParameters: () => [], propDecorators: { contentTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DialogContentTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], descriptionTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DialogDescriptionTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], footerTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DialogFooterTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], iconTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DialogIconTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], titleTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => DialogTitleTemplateDirective), { ...{ read: TemplateRef }, isSignal: true }] }], action: [{ type: i0.Output, args: ["action"] }], actions: [{ type: i0.Input, args: [{ isSignal: true, alias: "actions", required: false }] }], actionsLayout: [{ type: i0.Input, args: [{ isSignal: true, alias: "actionsLayout", required: false }] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "aria-label", required: false }] }], closable: [{ type: i0.Input, args: [{ isSignal: true, alias: "closable", required: false }] }], close: [{ type: i0.Output, args: ["close"] }], closeOnEscape: [{ type: i0.Input, args: [{ isSignal: true, alias: "closeOnEscape", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }], description: [{ type: i0.Input, args: [{ isSignal: true, alias: "description", required: false }] }], focusedElement: [{ type: i0.Input, args: [{ isSignal: true, alias: "focusedElement", required: false }] }], height: [{ type: i0.Input, args: [{ isSignal: true, alias: "height", required: false }] }], left: [{ type: i0.Input, args: [{ isSignal: true, alias: "left", required: false }] }], maxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxHeight", required: false }] }], maxWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxWidth", required: false }] }], messages: [{ type: i0.Input, args: [{ isSignal: true, alias: "messages", required: false }] }], minHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "minHeight", required: false }] }], minWidth: [{ type: i0.Input, args: [{ isSignal: true, alias: "minWidth", required: false }] }], modal: [{ type: i0.Input, args: [{ isSignal: true, alias: "modal", required: false }] }], rounded: [{ type: i0.Input, args: [{ isSignal: true, alias: "rounded", required: false }] }], text: [{ type: i0.Input, args: [{ isSignal: true, alias: "text", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], top: [{ type: i0.Input, args: [{ isSignal: true, alias: "top", required: false }] }], type: [{ type: i0.Input, args: [{ isSignal: true, alias: "type", required: false }] }], width: [{ type: i0.Input, args: [{ isSignal: true, alias: "width", required: false }] }] } });
983
-
984
- /*
985
- * Public API Surface of @nanahoshi/mona-ui/dialog
986
- */
987
-
988
- /**
989
- * Generated bundle index. Do not edit.
990
- */
991
-
776
+ var DialogService = class DialogService {
777
+ #document = inject(DOCUMENT);
778
+ #i18n = inject(MonaI18nService);
779
+ #injector = inject(Injector);
780
+ #localeMessages = this.#i18n.componentMessages("dialog", DIALOG_DEFAULT_MESSAGES);
781
+ #popupService = inject(PopupService);
782
+ alert(settings) {
783
+ const actions = this.#promptActions(settings, false);
784
+ return this.show({
785
+ type: "info",
786
+ ...settings,
787
+ actions
788
+ }).result.pipe(map(() => void 0));
789
+ }
790
+ confirm(settings) {
791
+ const actions = this.#promptActions(settings, true);
792
+ return this.show({
793
+ type: "confirm",
794
+ ...settings,
795
+ actions
796
+ }).result.pipe(map((result) => !result.viaClose && result.action.data === "ok"));
797
+ }
798
+ show(settings) {
799
+ const modal = settings.modal ?? true;
800
+ const injectorData = createDialogInjectorData(settings);
801
+ const dialogReference = new DialogReference({}, injectorData);
802
+ injectorData.dialogReference = dialogReference;
803
+ const popupRef = this.#popupService.create({
804
+ anchor: this.#document.body,
805
+ backdropClass: modal ? [
806
+ "fixed",
807
+ "inset-0",
808
+ "bg-background/50",
809
+ "transition-opacity",
810
+ "z-40",
811
+ "backdrop-blur-xs"
812
+ ] : "transparent",
813
+ blockScroll: modal,
814
+ closeOnBackdropClick: false,
815
+ closeOnEscape: injectorData.closeOnEscape,
816
+ closeOnOutsideClick: false,
817
+ content: DialogContentComponent,
818
+ data: injectorData,
819
+ hasBackdrop: modal,
820
+ height: settings.height ?? "fit-content",
821
+ injector: settings.injector,
822
+ maxHeight: settings.maxHeight ?? `calc(100dvh - ${VIEWPORT_MARGIN})`,
823
+ maxWidth: settings.maxWidth ?? `calc(100dvw - ${VIEWPORT_MARGIN})`,
824
+ minHeight: settings.minHeight,
825
+ minWidth: settings.minWidth,
826
+ popupWrapperClass: "mona-popup-constrain-height",
827
+ positionStrategy: "global",
828
+ providers: [{
829
+ provide: DialogRef,
830
+ useFactory: forwardRef(() => dialogReference.dialogRef)
831
+ }, {
832
+ provide: DIALOG_DATA,
833
+ useValue: settings.data
834
+ }],
835
+ restoreFocus: settings.restoreFocus ?? true ? "auto" : false,
836
+ width: settings.width
837
+ });
838
+ dialogReference.initializePopupRef(popupRef);
839
+ positionGlobalOverlay(popupRef.overlayRef, {
840
+ left: settings.left,
841
+ top: settings.top
842
+ });
843
+ if (modal) {
844
+ const release = inertOutside(popupRef.overlayRef.hostElement);
845
+ merge(popupRef.closeStart, popupRef.closed).pipe(take(1)).subscribe(() => release());
846
+ }
847
+ afterNextRender({ write: () => popupRef.overlayRef.updatePosition() }, { injector: this.#injector });
848
+ return dialogReference.dialogRef;
849
+ }
850
+ #promptActions(settings, withCancel) {
851
+ const messages = mergeMessages(this.#localeMessages(), settings.messages);
852
+ const ok = {
853
+ data: "ok",
854
+ default: true,
855
+ look: "primary",
856
+ text: messages.ok
857
+ };
858
+ const cancel = {
859
+ data: DIALOG_CANCEL,
860
+ look: "default",
861
+ text: messages.cancel
862
+ };
863
+ return withCancel ? [ok, cancel] : [ok];
864
+ }
865
+ static {
866
+ this.ɵfac = i0.ɵɵngDeclareFactory({
867
+ minVersion: "12.0.0",
868
+ version: "22.2.6",
869
+ ngImport: i0,
870
+ type: DialogService,
871
+ deps: [],
872
+ target: i0.ɵɵFactoryTarget.Injectable
873
+ });
874
+ }
875
+ static {
876
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
877
+ minVersion: "12.0.0",
878
+ version: "22.2.6",
879
+ ngImport: i0,
880
+ type: DialogService,
881
+ providedIn: "root"
882
+ });
883
+ }
884
+ };
885
+ i0.ɵɵngDeclareClassMetadata({
886
+ minVersion: "12.0.0",
887
+ version: "22.2.6",
888
+ ngImport: i0,
889
+ type: DialogService,
890
+ decorators: [{
891
+ type: Injectable,
892
+ args: [{ providedIn: "root" }]
893
+ }]
894
+ });
895
+ var DialogComponent = class DialogComponent {
896
+ #destroyRef;
897
+ #dialogService;
898
+ #destroyed;
899
+ #dialogRef;
900
+ constructor() {
901
+ this.#destroyRef = inject(DestroyRef);
902
+ this.#dialogService = inject(DialogService);
903
+ this.#destroyed = false;
904
+ this.contentTemplate = contentChild(DialogContentTemplateDirective, {
905
+ ...ngDevMode ? { debugName: "contentTemplate" } : /* istanbul ignore next */ {},
906
+ read: TemplateRef
907
+ });
908
+ this.descriptionTemplate = contentChild(DialogDescriptionTemplateDirective, {
909
+ ...ngDevMode ? { debugName: "descriptionTemplate" } : /* istanbul ignore next */ {},
910
+ read: TemplateRef
911
+ });
912
+ this.footerTemplate = contentChild(DialogFooterTemplateDirective, {
913
+ ...ngDevMode ? { debugName: "footerTemplate" } : /* istanbul ignore next */ {},
914
+ read: TemplateRef
915
+ });
916
+ this.iconTemplate = contentChild(DialogIconTemplateDirective, {
917
+ ...ngDevMode ? { debugName: "iconTemplate" } : /* istanbul ignore next */ {},
918
+ read: TemplateRef
919
+ });
920
+ this.titleTemplate = contentChild(DialogTitleTemplateDirective, {
921
+ ...ngDevMode ? { debugName: "titleTemplate" } : /* istanbul ignore next */ {},
922
+ read: TemplateRef
923
+ });
924
+ this.action = output();
925
+ this.actions = input([], ...ngDevMode ? [{ debugName: "actions" }] : /* istanbul ignore next */ []);
926
+ this.actionsLayout = input("end", ...ngDevMode ? [{ debugName: "actionsLayout" }] : /* istanbul ignore next */ []);
927
+ this.ariaLabel = input(void 0, {
928
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
929
+ alias: "aria-label"
930
+ });
931
+ this.closable = input(true, ...ngDevMode ? [{ debugName: "closable" }] : /* istanbul ignore next */ []);
932
+ this.close = output();
933
+ this.closeOnEscape = input(true, ...ngDevMode ? [{ debugName: "closeOnEscape" }] : /* istanbul ignore next */ []);
934
+ this.closed = output();
935
+ this.description = input(...ngDevMode ? [void 0, { debugName: "description" }] : /* istanbul ignore next */ []);
936
+ this.focusedElement = input(...ngDevMode ? [void 0, { debugName: "focusedElement" }] : /* istanbul ignore next */ []);
937
+ this.height = input(...ngDevMode ? [void 0, { debugName: "height" }] : /* istanbul ignore next */ []);
938
+ this.left = input(...ngDevMode ? [void 0, { debugName: "left" }] : /* istanbul ignore next */ []);
939
+ this.maxHeight = input(...ngDevMode ? [void 0, { debugName: "maxHeight" }] : /* istanbul ignore next */ []);
940
+ this.maxWidth = input(...ngDevMode ? [void 0, { debugName: "maxWidth" }] : /* istanbul ignore next */ []);
941
+ this.messages = input(...ngDevMode ? [void 0, { debugName: "messages" }] : /* istanbul ignore next */ []);
942
+ this.minHeight = input(...ngDevMode ? [void 0, { debugName: "minHeight" }] : /* istanbul ignore next */ []);
943
+ this.minWidth = input(...ngDevMode ? [void 0, { debugName: "minWidth" }] : /* istanbul ignore next */ []);
944
+ this.modal = input(true, ...ngDevMode ? [{ debugName: "modal" }] : /* istanbul ignore next */ []);
945
+ this.rounded = input("medium", ...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
946
+ this.text = input(...ngDevMode ? [void 0, { debugName: "text" }] : /* istanbul ignore next */ []);
947
+ this.title = input(...ngDevMode ? [void 0, { debugName: "title" }] : /* istanbul ignore next */ []);
948
+ this.top = input(...ngDevMode ? [void 0, { debugName: "top" }] : /* istanbul ignore next */ []);
949
+ this.type = input("info", ...ngDevMode ? [{ debugName: "type" }] : /* istanbul ignore next */ []);
950
+ this.width = input(...ngDevMode ? [void 0, { debugName: "width" }] : /* istanbul ignore next */ []);
951
+ afterNextRender({ write: () => this.#openDialog() });
952
+ effect(() => {
953
+ const update = {
954
+ actions: this.actions() ? [...this.actions()] : void 0,
955
+ actionsLayout: this.actionsLayout(),
956
+ ariaLabel: this.ariaLabel(),
957
+ closable: this.closable(),
958
+ description: this.description(),
959
+ messages: this.messages(),
960
+ rounded: this.rounded(),
961
+ text: this.text(),
962
+ title: this.title(),
963
+ type: this.type()
964
+ };
965
+ this.#dialogRef?.update(update);
966
+ });
967
+ this.#destroyRef.onDestroy(() => {
968
+ this.#destroyed = true;
969
+ this.#dialogRef?.close();
970
+ });
971
+ }
972
+ #openDialog() {
973
+ const actions = this.actions() ? [...this.actions()] : void 0;
974
+ this.#dialogRef = this.#dialogService.show({
975
+ actions,
976
+ actionsLayout: this.actionsLayout(),
977
+ ariaLabel: this.ariaLabel(),
978
+ closable: this.closable(),
979
+ closeOnEscape: this.closeOnEscape(),
980
+ content: this.contentTemplate(),
981
+ description: this.description(),
982
+ descriptionTemplate: this.descriptionTemplate(),
983
+ focusedElement: this.focusedElement(),
984
+ footerTemplate: this.footerTemplate(),
985
+ height: this.height(),
986
+ iconTemplate: this.iconTemplate(),
987
+ left: this.left(),
988
+ maxHeight: this.maxHeight(),
989
+ maxWidth: this.maxWidth(),
990
+ messages: this.messages(),
991
+ minHeight: this.minHeight(),
992
+ minWidth: this.minWidth(),
993
+ modal: this.modal(),
994
+ rounded: this.rounded(),
995
+ text: this.text(),
996
+ title: this.title(),
997
+ titleTemplate: this.titleTemplate(),
998
+ top: this.top(),
999
+ type: this.type(),
1000
+ width: this.width()
1001
+ });
1002
+ this.#dialogRef.action$.pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => {
1003
+ this.action.emit(event);
1004
+ });
1005
+ this.#dialogRef.close$.subscribe((event) => {
1006
+ if (!this.#destroyed) this.close.emit(event);
1007
+ });
1008
+ this.#dialogRef.closed$.subscribe(() => {
1009
+ if (!this.#destroyed) this.closed.emit();
1010
+ });
1011
+ }
1012
+ static {
1013
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1014
+ minVersion: "12.0.0",
1015
+ version: "22.2.6",
1016
+ ngImport: i0,
1017
+ type: DialogComponent,
1018
+ deps: [],
1019
+ target: i0.ɵɵFactoryTarget.Component
1020
+ });
1021
+ }
1022
+ static {
1023
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1024
+ minVersion: "17.2.0",
1025
+ version: "22.2.6",
1026
+ type: DialogComponent,
1027
+ isStandalone: true,
1028
+ selector: "mona-dialog",
1029
+ inputs: {
1030
+ actions: {
1031
+ classPropertyName: "actions",
1032
+ publicName: "actions",
1033
+ isSignal: true,
1034
+ isRequired: false,
1035
+ transformFunction: null
1036
+ },
1037
+ actionsLayout: {
1038
+ classPropertyName: "actionsLayout",
1039
+ publicName: "actionsLayout",
1040
+ isSignal: true,
1041
+ isRequired: false,
1042
+ transformFunction: null
1043
+ },
1044
+ ariaLabel: {
1045
+ classPropertyName: "ariaLabel",
1046
+ publicName: "aria-label",
1047
+ isSignal: true,
1048
+ isRequired: false,
1049
+ transformFunction: null
1050
+ },
1051
+ closable: {
1052
+ classPropertyName: "closable",
1053
+ publicName: "closable",
1054
+ isSignal: true,
1055
+ isRequired: false,
1056
+ transformFunction: null
1057
+ },
1058
+ closeOnEscape: {
1059
+ classPropertyName: "closeOnEscape",
1060
+ publicName: "closeOnEscape",
1061
+ isSignal: true,
1062
+ isRequired: false,
1063
+ transformFunction: null
1064
+ },
1065
+ description: {
1066
+ classPropertyName: "description",
1067
+ publicName: "description",
1068
+ isSignal: true,
1069
+ isRequired: false,
1070
+ transformFunction: null
1071
+ },
1072
+ focusedElement: {
1073
+ classPropertyName: "focusedElement",
1074
+ publicName: "focusedElement",
1075
+ isSignal: true,
1076
+ isRequired: false,
1077
+ transformFunction: null
1078
+ },
1079
+ height: {
1080
+ classPropertyName: "height",
1081
+ publicName: "height",
1082
+ isSignal: true,
1083
+ isRequired: false,
1084
+ transformFunction: null
1085
+ },
1086
+ left: {
1087
+ classPropertyName: "left",
1088
+ publicName: "left",
1089
+ isSignal: true,
1090
+ isRequired: false,
1091
+ transformFunction: null
1092
+ },
1093
+ maxHeight: {
1094
+ classPropertyName: "maxHeight",
1095
+ publicName: "maxHeight",
1096
+ isSignal: true,
1097
+ isRequired: false,
1098
+ transformFunction: null
1099
+ },
1100
+ maxWidth: {
1101
+ classPropertyName: "maxWidth",
1102
+ publicName: "maxWidth",
1103
+ isSignal: true,
1104
+ isRequired: false,
1105
+ transformFunction: null
1106
+ },
1107
+ messages: {
1108
+ classPropertyName: "messages",
1109
+ publicName: "messages",
1110
+ isSignal: true,
1111
+ isRequired: false,
1112
+ transformFunction: null
1113
+ },
1114
+ minHeight: {
1115
+ classPropertyName: "minHeight",
1116
+ publicName: "minHeight",
1117
+ isSignal: true,
1118
+ isRequired: false,
1119
+ transformFunction: null
1120
+ },
1121
+ minWidth: {
1122
+ classPropertyName: "minWidth",
1123
+ publicName: "minWidth",
1124
+ isSignal: true,
1125
+ isRequired: false,
1126
+ transformFunction: null
1127
+ },
1128
+ modal: {
1129
+ classPropertyName: "modal",
1130
+ publicName: "modal",
1131
+ isSignal: true,
1132
+ isRequired: false,
1133
+ transformFunction: null
1134
+ },
1135
+ rounded: {
1136
+ classPropertyName: "rounded",
1137
+ publicName: "rounded",
1138
+ isSignal: true,
1139
+ isRequired: false,
1140
+ transformFunction: null
1141
+ },
1142
+ text: {
1143
+ classPropertyName: "text",
1144
+ publicName: "text",
1145
+ isSignal: true,
1146
+ isRequired: false,
1147
+ transformFunction: null
1148
+ },
1149
+ title: {
1150
+ classPropertyName: "title",
1151
+ publicName: "title",
1152
+ isSignal: true,
1153
+ isRequired: false,
1154
+ transformFunction: null
1155
+ },
1156
+ top: {
1157
+ classPropertyName: "top",
1158
+ publicName: "top",
1159
+ isSignal: true,
1160
+ isRequired: false,
1161
+ transformFunction: null
1162
+ },
1163
+ type: {
1164
+ classPropertyName: "type",
1165
+ publicName: "type",
1166
+ isSignal: true,
1167
+ isRequired: false,
1168
+ transformFunction: null
1169
+ },
1170
+ width: {
1171
+ classPropertyName: "width",
1172
+ publicName: "width",
1173
+ isSignal: true,
1174
+ isRequired: false,
1175
+ transformFunction: null
1176
+ }
1177
+ },
1178
+ outputs: {
1179
+ action: "action",
1180
+ close: "close",
1181
+ closed: "closed"
1182
+ },
1183
+ host: {
1184
+ properties: { "attr.aria-label": "null" },
1185
+ classAttribute: "hidden"
1186
+ },
1187
+ queries: [
1188
+ {
1189
+ propertyName: "contentTemplate",
1190
+ first: true,
1191
+ predicate: DialogContentTemplateDirective,
1192
+ descendants: true,
1193
+ read: TemplateRef,
1194
+ isSignal: true
1195
+ },
1196
+ {
1197
+ propertyName: "descriptionTemplate",
1198
+ first: true,
1199
+ predicate: DialogDescriptionTemplateDirective,
1200
+ descendants: true,
1201
+ read: TemplateRef,
1202
+ isSignal: true
1203
+ },
1204
+ {
1205
+ propertyName: "footerTemplate",
1206
+ first: true,
1207
+ predicate: DialogFooterTemplateDirective,
1208
+ descendants: true,
1209
+ read: TemplateRef,
1210
+ isSignal: true
1211
+ },
1212
+ {
1213
+ propertyName: "iconTemplate",
1214
+ first: true,
1215
+ predicate: DialogIconTemplateDirective,
1216
+ descendants: true,
1217
+ read: TemplateRef,
1218
+ isSignal: true
1219
+ },
1220
+ {
1221
+ propertyName: "titleTemplate",
1222
+ first: true,
1223
+ predicate: DialogTitleTemplateDirective,
1224
+ descendants: true,
1225
+ read: TemplateRef,
1226
+ isSignal: true
1227
+ }
1228
+ ],
1229
+ ngImport: i0,
1230
+ template: ``,
1231
+ isInline: true
1232
+ });
1233
+ }
1234
+ };
1235
+ i0.ɵɵngDeclareClassMetadata({
1236
+ minVersion: "12.0.0",
1237
+ version: "22.2.6",
1238
+ ngImport: i0,
1239
+ type: DialogComponent,
1240
+ decorators: [{
1241
+ type: Component,
1242
+ args: [{
1243
+ selector: "mona-dialog",
1244
+ template: ``,
1245
+ host: {
1246
+ "[attr.aria-label]": "null",
1247
+ class: "hidden"
1248
+ }
1249
+ }]
1250
+ }],
1251
+ ctorParameters: () => [],
1252
+ propDecorators: {
1253
+ contentTemplate: [{
1254
+ type: i0.ContentChild,
1255
+ args: [i0.forwardRef(() => DialogContentTemplateDirective), {
1256
+ read: TemplateRef,
1257
+ isSignal: true
1258
+ }]
1259
+ }],
1260
+ descriptionTemplate: [{
1261
+ type: i0.ContentChild,
1262
+ args: [i0.forwardRef(() => DialogDescriptionTemplateDirective), {
1263
+ read: TemplateRef,
1264
+ isSignal: true
1265
+ }]
1266
+ }],
1267
+ footerTemplate: [{
1268
+ type: i0.ContentChild,
1269
+ args: [i0.forwardRef(() => DialogFooterTemplateDirective), {
1270
+ read: TemplateRef,
1271
+ isSignal: true
1272
+ }]
1273
+ }],
1274
+ iconTemplate: [{
1275
+ type: i0.ContentChild,
1276
+ args: [i0.forwardRef(() => DialogIconTemplateDirective), {
1277
+ read: TemplateRef,
1278
+ isSignal: true
1279
+ }]
1280
+ }],
1281
+ titleTemplate: [{
1282
+ type: i0.ContentChild,
1283
+ args: [i0.forwardRef(() => DialogTitleTemplateDirective), {
1284
+ read: TemplateRef,
1285
+ isSignal: true
1286
+ }]
1287
+ }],
1288
+ action: [{
1289
+ type: i0.Output,
1290
+ args: ["action"]
1291
+ }],
1292
+ actions: [{
1293
+ type: i0.Input,
1294
+ args: [{
1295
+ isSignal: true,
1296
+ alias: "actions",
1297
+ required: false
1298
+ }]
1299
+ }],
1300
+ actionsLayout: [{
1301
+ type: i0.Input,
1302
+ args: [{
1303
+ isSignal: true,
1304
+ alias: "actionsLayout",
1305
+ required: false
1306
+ }]
1307
+ }],
1308
+ ariaLabel: [{
1309
+ type: i0.Input,
1310
+ args: [{
1311
+ isSignal: true,
1312
+ alias: "aria-label",
1313
+ required: false
1314
+ }]
1315
+ }],
1316
+ closable: [{
1317
+ type: i0.Input,
1318
+ args: [{
1319
+ isSignal: true,
1320
+ alias: "closable",
1321
+ required: false
1322
+ }]
1323
+ }],
1324
+ close: [{
1325
+ type: i0.Output,
1326
+ args: ["close"]
1327
+ }],
1328
+ closeOnEscape: [{
1329
+ type: i0.Input,
1330
+ args: [{
1331
+ isSignal: true,
1332
+ alias: "closeOnEscape",
1333
+ required: false
1334
+ }]
1335
+ }],
1336
+ closed: [{
1337
+ type: i0.Output,
1338
+ args: ["closed"]
1339
+ }],
1340
+ description: [{
1341
+ type: i0.Input,
1342
+ args: [{
1343
+ isSignal: true,
1344
+ alias: "description",
1345
+ required: false
1346
+ }]
1347
+ }],
1348
+ focusedElement: [{
1349
+ type: i0.Input,
1350
+ args: [{
1351
+ isSignal: true,
1352
+ alias: "focusedElement",
1353
+ required: false
1354
+ }]
1355
+ }],
1356
+ height: [{
1357
+ type: i0.Input,
1358
+ args: [{
1359
+ isSignal: true,
1360
+ alias: "height",
1361
+ required: false
1362
+ }]
1363
+ }],
1364
+ left: [{
1365
+ type: i0.Input,
1366
+ args: [{
1367
+ isSignal: true,
1368
+ alias: "left",
1369
+ required: false
1370
+ }]
1371
+ }],
1372
+ maxHeight: [{
1373
+ type: i0.Input,
1374
+ args: [{
1375
+ isSignal: true,
1376
+ alias: "maxHeight",
1377
+ required: false
1378
+ }]
1379
+ }],
1380
+ maxWidth: [{
1381
+ type: i0.Input,
1382
+ args: [{
1383
+ isSignal: true,
1384
+ alias: "maxWidth",
1385
+ required: false
1386
+ }]
1387
+ }],
1388
+ messages: [{
1389
+ type: i0.Input,
1390
+ args: [{
1391
+ isSignal: true,
1392
+ alias: "messages",
1393
+ required: false
1394
+ }]
1395
+ }],
1396
+ minHeight: [{
1397
+ type: i0.Input,
1398
+ args: [{
1399
+ isSignal: true,
1400
+ alias: "minHeight",
1401
+ required: false
1402
+ }]
1403
+ }],
1404
+ minWidth: [{
1405
+ type: i0.Input,
1406
+ args: [{
1407
+ isSignal: true,
1408
+ alias: "minWidth",
1409
+ required: false
1410
+ }]
1411
+ }],
1412
+ modal: [{
1413
+ type: i0.Input,
1414
+ args: [{
1415
+ isSignal: true,
1416
+ alias: "modal",
1417
+ required: false
1418
+ }]
1419
+ }],
1420
+ rounded: [{
1421
+ type: i0.Input,
1422
+ args: [{
1423
+ isSignal: true,
1424
+ alias: "rounded",
1425
+ required: false
1426
+ }]
1427
+ }],
1428
+ text: [{
1429
+ type: i0.Input,
1430
+ args: [{
1431
+ isSignal: true,
1432
+ alias: "text",
1433
+ required: false
1434
+ }]
1435
+ }],
1436
+ title: [{
1437
+ type: i0.Input,
1438
+ args: [{
1439
+ isSignal: true,
1440
+ alias: "title",
1441
+ required: false
1442
+ }]
1443
+ }],
1444
+ top: [{
1445
+ type: i0.Input,
1446
+ args: [{
1447
+ isSignal: true,
1448
+ alias: "top",
1449
+ required: false
1450
+ }]
1451
+ }],
1452
+ type: [{
1453
+ type: i0.Input,
1454
+ args: [{
1455
+ isSignal: true,
1456
+ alias: "type",
1457
+ required: false
1458
+ }]
1459
+ }],
1460
+ width: [{
1461
+ type: i0.Input,
1462
+ args: [{
1463
+ isSignal: true,
1464
+ alias: "width",
1465
+ required: false
1466
+ }]
1467
+ }]
1468
+ }
1469
+ });
992
1470
  export { DIALOG_CANCEL, DIALOG_DATA, DIALOG_DEFAULT_MESSAGES, DIALOG_OK, DialogActionEvent, DialogComponent, DialogContentTemplateDirective, DialogDescriptionTemplateDirective, DialogFooterTemplateDirective, DialogIconTemplateDirective, DialogRef, DialogService, DialogTitleTemplateDirective };
993
- //# sourceMappingURL=nanahoshi-mona-ui-dialog.mjs.map
1471
+
1472
+ //# sourceMappingURL=nanahoshi-mona-ui-dialog.mjs.map