@molecule/app-ui-angular 1.0.5 → 1.1.1

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 (308) hide show
  1. package/README.md +11742 -1145
  2. package/dist/components/accordion.component.d.ts +114 -0
  3. package/dist/components/accordion.component.d.ts.map +1 -0
  4. package/dist/components/accordion.component.js +286 -0
  5. package/dist/components/accordion.component.js.map +1 -0
  6. package/dist/components/alert.component.d.ts +81 -37
  7. package/dist/components/alert.component.d.ts.map +1 -1
  8. package/dist/components/alert.component.js +232 -146
  9. package/dist/components/alert.component.js.map +1 -1
  10. package/dist/components/auth-guard.component.d.ts +94 -0
  11. package/dist/components/auth-guard.component.d.ts.map +1 -0
  12. package/dist/components/auth-guard.component.js +212 -0
  13. package/dist/components/auth-guard.component.js.map +1 -0
  14. package/dist/components/avatar.component.d.ts +97 -0
  15. package/dist/components/avatar.component.d.ts.map +1 -0
  16. package/dist/components/avatar.component.js +216 -0
  17. package/dist/components/avatar.component.js.map +1 -0
  18. package/dist/components/badge.component.d.ts +27 -12
  19. package/dist/components/badge.component.d.ts.map +1 -1
  20. package/dist/components/badge.component.js +47 -47
  21. package/dist/components/badge.component.js.map +1 -1
  22. package/dist/components/button.component.d.ts +96 -14
  23. package/dist/components/button.component.d.ts.map +1 -1
  24. package/dist/components/button.component.js +232 -87
  25. package/dist/components/button.component.js.map +1 -1
  26. package/dist/components/card.component.d.ts +135 -0
  27. package/dist/components/card.component.d.ts.map +1 -0
  28. package/dist/components/card.component.js +291 -0
  29. package/dist/components/card.component.js.map +1 -0
  30. package/dist/components/checkbox.component.d.ts +102 -29
  31. package/dist/components/checkbox.component.d.ts.map +1 -1
  32. package/dist/components/checkbox.component.js +222 -113
  33. package/dist/components/checkbox.component.js.map +1 -1
  34. package/dist/components/confirm-button.component.d.ts +130 -0
  35. package/dist/components/confirm-button.component.d.ts.map +1 -0
  36. package/dist/components/confirm-button.component.js +322 -0
  37. package/dist/components/confirm-button.component.js.map +1 -0
  38. package/dist/components/confirm-dialog.component.d.ts +60 -0
  39. package/dist/components/confirm-dialog.component.d.ts.map +1 -0
  40. package/dist/components/confirm-dialog.component.js +152 -0
  41. package/dist/components/confirm-dialog.component.js.map +1 -0
  42. package/dist/components/dropdown.component.d.ts +313 -0
  43. package/dist/components/dropdown.component.d.ts.map +1 -0
  44. package/dist/components/dropdown.component.js +919 -0
  45. package/dist/components/dropdown.component.js.map +1 -0
  46. package/dist/components/empty-state.component.d.ts +73 -0
  47. package/dist/components/empty-state.component.d.ts.map +1 -0
  48. package/dist/components/empty-state.component.js +180 -0
  49. package/dist/components/empty-state.component.js.map +1 -0
  50. package/dist/components/floating-input.component.d.ts +86 -0
  51. package/dist/components/floating-input.component.d.ts.map +1 -0
  52. package/dist/components/floating-input.component.js +167 -0
  53. package/dist/components/floating-input.component.js.map +1 -0
  54. package/dist/components/form-field.component.d.ts +111 -0
  55. package/dist/components/form-field.component.d.ts.map +1 -0
  56. package/dist/components/form-field.component.js +300 -0
  57. package/dist/components/form-field.component.js.map +1 -0
  58. package/dist/components/form.component.d.ts +77 -0
  59. package/dist/components/form.component.d.ts.map +1 -0
  60. package/dist/components/form.component.js +222 -0
  61. package/dist/components/form.component.js.map +1 -0
  62. package/dist/components/icon.component.d.ts +85 -0
  63. package/dist/components/icon.component.d.ts.map +1 -0
  64. package/dist/components/icon.component.js +187 -0
  65. package/dist/components/icon.component.js.map +1 -0
  66. package/dist/components/index.d.ts +49 -0
  67. package/dist/components/index.d.ts.map +1 -1
  68. package/dist/components/index.js +49 -0
  69. package/dist/components/index.js.map +1 -1
  70. package/dist/components/input.component.d.ts +157 -54
  71. package/dist/components/input.component.d.ts.map +1 -1
  72. package/dist/components/input.component.js +437 -222
  73. package/dist/components/input.component.js.map +1 -1
  74. package/dist/components/label.component.d.ts +29 -0
  75. package/dist/components/label.component.d.ts.map +1 -0
  76. package/dist/components/label.component.js +60 -0
  77. package/dist/components/label.component.js.map +1 -0
  78. package/dist/components/language-picker.component.d.ts +124 -0
  79. package/dist/components/language-picker.component.d.ts.map +1 -0
  80. package/dist/components/language-picker.component.js +305 -0
  81. package/dist/components/language-picker.component.js.map +1 -0
  82. package/dist/components/layout.component.d.ts +167 -0
  83. package/dist/components/layout.component.d.ts.map +1 -0
  84. package/dist/components/layout.component.js +364 -0
  85. package/dist/components/layout.component.js.map +1 -0
  86. package/dist/components/load-error-banner.component.d.ts +103 -0
  87. package/dist/components/load-error-banner.component.d.ts.map +1 -0
  88. package/dist/components/load-error-banner.component.js +263 -0
  89. package/dist/components/load-error-banner.component.js.map +1 -0
  90. package/dist/components/modal.component.d.ts +125 -95
  91. package/dist/components/modal.component.d.ts.map +1 -1
  92. package/dist/components/modal.component.js +458 -271
  93. package/dist/components/modal.component.js.map +1 -1
  94. package/dist/components/molecule/alert.component.d.ts +77 -0
  95. package/dist/components/molecule/alert.component.d.ts.map +1 -0
  96. package/dist/components/molecule/alert.component.js +229 -0
  97. package/dist/components/molecule/alert.component.js.map +1 -0
  98. package/dist/components/molecule/badge.component.d.ts +27 -0
  99. package/dist/components/molecule/badge.component.d.ts.map +1 -0
  100. package/dist/components/molecule/badge.component.js +79 -0
  101. package/dist/components/molecule/badge.component.js.map +1 -0
  102. package/dist/components/molecule/button.component.d.ts +38 -0
  103. package/dist/components/molecule/button.component.d.ts.map +1 -0
  104. package/dist/components/molecule/button.component.js +137 -0
  105. package/dist/components/molecule/button.component.js.map +1 -0
  106. package/dist/components/molecule/checkbox.component.d.ts +53 -0
  107. package/dist/components/molecule/checkbox.component.d.ts.map +1 -0
  108. package/dist/components/molecule/checkbox.component.js +166 -0
  109. package/dist/components/molecule/checkbox.component.js.map +1 -0
  110. package/dist/components/molecule/index.d.ts +18 -0
  111. package/dist/components/molecule/index.d.ts.map +1 -0
  112. package/dist/components/molecule/index.js +18 -0
  113. package/dist/components/molecule/index.js.map +1 -0
  114. package/dist/components/molecule/input.component.d.ts +93 -0
  115. package/dist/components/molecule/input.component.d.ts.map +1 -0
  116. package/dist/components/molecule/input.component.js +314 -0
  117. package/dist/components/molecule/input.component.js.map +1 -0
  118. package/dist/components/molecule/modal.component.d.ts +148 -0
  119. package/dist/components/molecule/modal.component.d.ts.map +1 -0
  120. package/dist/components/molecule/modal.component.js +382 -0
  121. package/dist/components/molecule/modal.component.js.map +1 -0
  122. package/dist/components/molecule/radio-group.component.d.ts +63 -0
  123. package/dist/components/molecule/radio-group.component.d.ts.map +1 -0
  124. package/dist/components/molecule/radio-group.component.js +208 -0
  125. package/dist/components/molecule/radio-group.component.js.map +1 -0
  126. package/dist/components/molecule/select.component.d.ts +72 -0
  127. package/dist/components/molecule/select.component.d.ts.map +1 -0
  128. package/dist/components/molecule/select.component.js +274 -0
  129. package/dist/components/molecule/select.component.js.map +1 -0
  130. package/dist/components/molecule/spinner.component.d.ts +42 -0
  131. package/dist/components/molecule/spinner.component.d.ts.map +1 -0
  132. package/dist/components/molecule/spinner.component.js +122 -0
  133. package/dist/components/molecule/spinner.component.js.map +1 -0
  134. package/dist/components/molecule/switch.component.d.ts +54 -0
  135. package/dist/components/molecule/switch.component.d.ts.map +1 -0
  136. package/dist/components/molecule/switch.component.js +148 -0
  137. package/dist/components/molecule/switch.component.js.map +1 -0
  138. package/dist/components/molecule/toast.component.d.ts +98 -0
  139. package/dist/components/molecule/toast.component.d.ts.map +1 -0
  140. package/dist/components/molecule/toast.component.js +305 -0
  141. package/dist/components/molecule/toast.component.js.map +1 -0
  142. package/dist/components/molecule/tooltip.component.d.ts +77 -0
  143. package/dist/components/molecule/tooltip.component.d.ts.map +1 -0
  144. package/dist/components/molecule/tooltip.component.js +316 -0
  145. package/dist/components/molecule/tooltip.component.js.map +1 -0
  146. package/dist/components/optimistic-toggle-button.component.d.ts +125 -0
  147. package/dist/components/optimistic-toggle-button.component.d.ts.map +1 -0
  148. package/dist/components/optimistic-toggle-button.component.js +296 -0
  149. package/dist/components/optimistic-toggle-button.component.js.map +1 -0
  150. package/dist/components/page-header.component.d.ts +77 -0
  151. package/dist/components/page-header.component.d.ts.map +1 -0
  152. package/dist/components/page-header.component.js +225 -0
  153. package/dist/components/page-header.component.js.map +1 -0
  154. package/dist/components/page-shell.component.d.ts +101 -0
  155. package/dist/components/page-shell.component.d.ts.map +1 -0
  156. package/dist/components/page-shell.component.js +221 -0
  157. package/dist/components/page-shell.component.js.map +1 -0
  158. package/dist/components/pagination.component.d.ts +137 -0
  159. package/dist/components/pagination.component.d.ts.map +1 -0
  160. package/dist/components/pagination.component.js +419 -0
  161. package/dist/components/pagination.component.js.map +1 -0
  162. package/dist/components/panel-close.component.d.ts +43 -0
  163. package/dist/components/panel-close.component.d.ts.map +1 -0
  164. package/dist/components/panel-close.component.js +75 -0
  165. package/dist/components/panel-close.component.js.map +1 -0
  166. package/dist/components/progress.component.d.ts +84 -0
  167. package/dist/components/progress.component.d.ts.map +1 -0
  168. package/dist/components/progress.component.js +219 -0
  169. package/dist/components/progress.component.js.map +1 -0
  170. package/dist/components/prompt-dialog.component.d.ts +121 -0
  171. package/dist/components/prompt-dialog.component.d.ts.map +1 -0
  172. package/dist/components/prompt-dialog.component.js +332 -0
  173. package/dist/components/prompt-dialog.component.js.map +1 -0
  174. package/dist/components/radio-group.component.d.ts +66 -34
  175. package/dist/components/radio-group.component.d.ts.map +1 -1
  176. package/dist/components/radio-group.component.js +146 -125
  177. package/dist/components/radio-group.component.js.map +1 -1
  178. package/dist/components/responsive-app-shell.component.d.ts +408 -0
  179. package/dist/components/responsive-app-shell.component.d.ts.map +1 -0
  180. package/dist/components/responsive-app-shell.component.js +1144 -0
  181. package/dist/components/responsive-app-shell.component.js.map +1 -0
  182. package/dist/components/select.component.d.ts +135 -38
  183. package/dist/components/select.component.d.ts.map +1 -1
  184. package/dist/components/select.component.js +373 -181
  185. package/dist/components/select.component.js.map +1 -1
  186. package/dist/components/separator.component.d.ts +39 -0
  187. package/dist/components/separator.component.d.ts.map +1 -0
  188. package/dist/components/separator.component.js +73 -0
  189. package/dist/components/separator.component.js.map +1 -0
  190. package/dist/components/sidebar-user-card.component.d.ts +106 -0
  191. package/dist/components/sidebar-user-card.component.d.ts.map +1 -0
  192. package/dist/components/sidebar-user-card.component.js +277 -0
  193. package/dist/components/sidebar-user-card.component.js.map +1 -0
  194. package/dist/components/skeleton.component.d.ts +100 -0
  195. package/dist/components/skeleton.component.d.ts.map +1 -0
  196. package/dist/components/skeleton.component.js +214 -0
  197. package/dist/components/skeleton.component.js.map +1 -0
  198. package/dist/components/spinner.component.d.ts +36 -19
  199. package/dist/components/spinner.component.d.ts.map +1 -1
  200. package/dist/components/spinner.component.js +69 -71
  201. package/dist/components/spinner.component.js.map +1 -1
  202. package/dist/components/switch.component.d.ts +72 -29
  203. package/dist/components/switch.component.d.ts.map +1 -1
  204. package/dist/components/switch.component.js +163 -91
  205. package/dist/components/switch.component.js.map +1 -1
  206. package/dist/components/table.component.d.ts +193 -0
  207. package/dist/components/table.component.d.ts.map +1 -0
  208. package/dist/components/table.component.js +550 -0
  209. package/dist/components/table.component.js.map +1 -0
  210. package/dist/components/tabs.component.d.ts +140 -0
  211. package/dist/components/tabs.component.d.ts.map +1 -0
  212. package/dist/components/tabs.component.js +390 -0
  213. package/dist/components/tabs.component.js.map +1 -0
  214. package/dist/components/template-outlet.directive.d.ts +50 -0
  215. package/dist/components/template-outlet.directive.d.ts.map +1 -0
  216. package/dist/components/template-outlet.directive.js +81 -0
  217. package/dist/components/template-outlet.directive.js.map +1 -0
  218. package/dist/components/textarea.component.d.ts +151 -0
  219. package/dist/components/textarea.component.d.ts.map +1 -0
  220. package/dist/components/textarea.component.js +340 -0
  221. package/dist/components/textarea.component.js.map +1 -0
  222. package/dist/components/theme-toggle.component.d.ts +58 -0
  223. package/dist/components/theme-toggle.component.d.ts.map +1 -0
  224. package/dist/components/theme-toggle.component.js +124 -0
  225. package/dist/components/theme-toggle.component.js.map +1 -0
  226. package/dist/components/toast.component.d.ts +237 -49
  227. package/dist/components/toast.component.d.ts.map +1 -1
  228. package/dist/components/toast.component.js +636 -201
  229. package/dist/components/toast.component.js.map +1 -1
  230. package/dist/components/tooltip.component.d.ts +95 -45
  231. package/dist/components/tooltip.component.d.ts.map +1 -1
  232. package/dist/components/tooltip.component.js +372 -221
  233. package/dist/components/tooltip.component.js.map +1 -1
  234. package/dist/components/user-menu-popover.component.d.ts +283 -0
  235. package/dist/components/user-menu-popover.component.d.ts.map +1 -0
  236. package/dist/components/user-menu-popover.component.js +646 -0
  237. package/dist/components/user-menu-popover.component.js.map +1 -0
  238. package/dist/components/user-menu.component.d.ts +95 -0
  239. package/dist/components/user-menu.component.d.ts.map +1 -0
  240. package/dist/components/user-menu.component.js +218 -0
  241. package/dist/components/user-menu.component.js.map +1 -0
  242. package/dist/hooks/index.d.ts +7 -0
  243. package/dist/hooks/index.d.ts.map +1 -0
  244. package/dist/hooks/index.js +7 -0
  245. package/dist/hooks/index.js.map +1 -0
  246. package/dist/hooks/use-is-desktop.d.ts +22 -0
  247. package/dist/hooks/use-is-desktop.d.ts.map +1 -0
  248. package/dist/hooks/use-is-desktop.js +37 -0
  249. package/dist/hooks/use-is-desktop.js.map +1 -0
  250. package/dist/index.d.ts +32 -17
  251. package/dist/index.d.ts.map +1 -1
  252. package/dist/index.js +32 -17
  253. package/dist/index.js.map +1 -1
  254. package/dist/types.d.ts +1 -1
  255. package/dist/types.d.ts.map +1 -1
  256. package/dist/utilities/dom-context.d.ts +42 -0
  257. package/dist/utilities/dom-context.d.ts.map +1 -0
  258. package/dist/utilities/dom-context.js +66 -0
  259. package/dist/utilities/dom-context.js.map +1 -0
  260. package/dist/utilities/focus.d.ts +32 -0
  261. package/dist/utilities/focus.d.ts.map +1 -0
  262. package/dist/utilities/focus.js +47 -0
  263. package/dist/utilities/focus.js.map +1 -0
  264. package/dist/utilities/form-field-context.d.ts +34 -0
  265. package/dist/utilities/form-field-context.d.ts.map +1 -0
  266. package/dist/utilities/form-field-context.js +28 -0
  267. package/dist/utilities/form-field-context.js.map +1 -0
  268. package/dist/utilities/form-submit-error.d.ts +17 -0
  269. package/dist/utilities/form-submit-error.d.ts.map +1 -0
  270. package/dist/utilities/form-submit-error.js +42 -0
  271. package/dist/utilities/form-submit-error.js.map +1 -0
  272. package/dist/utilities/icon-markup.d.ts +17 -0
  273. package/dist/utilities/icon-markup.d.ts.map +1 -0
  274. package/dist/utilities/icon-markup.js +46 -0
  275. package/dist/utilities/icon-markup.js.map +1 -0
  276. package/dist/utilities/ids.d.ts +15 -0
  277. package/dist/utilities/ids.d.ts.map +1 -0
  278. package/dist/utilities/ids.js +19 -0
  279. package/dist/utilities/ids.js.map +1 -0
  280. package/dist/utilities/index.d.ts +11 -0
  281. package/dist/utilities/index.d.ts.map +1 -1
  282. package/dist/utilities/index.js +11 -0
  283. package/dist/utilities/index.js.map +1 -1
  284. package/dist/utilities/initials.d.ts +13 -0
  285. package/dist/utilities/initials.d.ts.map +1 -0
  286. package/dist/utilities/initials.js +23 -0
  287. package/dist/utilities/initials.js.map +1 -0
  288. package/dist/utilities/node-value.d.ts +31 -0
  289. package/dist/utilities/node-value.d.ts.map +1 -0
  290. package/dist/utilities/node-value.js +37 -0
  291. package/dist/utilities/node-value.js.map +1 -0
  292. package/dist/utilities/optimistic-value.d.ts +81 -0
  293. package/dist/utilities/optimistic-value.d.ts.map +1 -0
  294. package/dist/utilities/optimistic-value.js +154 -0
  295. package/dist/utilities/optimistic-value.js.map +1 -0
  296. package/dist/utilities/render-icon.d.ts +77 -7
  297. package/dist/utilities/render-icon.d.ts.map +1 -1
  298. package/dist/utilities/render-icon.js +123 -33
  299. package/dist/utilities/render-icon.js.map +1 -1
  300. package/dist/utilities/rest-attrs.d.ts +21 -0
  301. package/dist/utilities/rest-attrs.d.ts.map +1 -0
  302. package/dist/utilities/rest-attrs.js +37 -0
  303. package/dist/utilities/rest-attrs.js.map +1 -0
  304. package/dist/utilities/style.d.ts +23 -0
  305. package/dist/utilities/style.d.ts.map +1 -0
  306. package/dist/utilities/style.js +86 -0
  307. package/dist/utilities/style.js.map +1 -0
  308. package/package.json +10 -5
@@ -1,91 +1,77 @@
1
1
  /**
2
- * Angular Toast UI component with UIClassMap-driven styling.
2
+ * Toast family (React parity): Toast, ToastContainer, ToastProvider and the
3
+ * `useToast` hook.
3
4
  *
4
5
  * @module
5
6
  */
6
- import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, } from '@angular/core';
7
- import { t } from '@molecule/app-i18n';
7
+ import { Component, ElementRef, EventEmitter, inject, Output, Renderer2, signal, TemplateRef, ViewChild, } from '@angular/core';
8
+ import { useTranslation } from '@molecule/app-angular';
9
+ import { I18nError } from '@molecule/app-i18n';
8
10
  import { getClassMap } from '@molecule/app-ui';
9
- import { getIconSvg } from '../utilities/render-icon.js';
11
+ import { findDomContext, provideDomContext, removeDomContext } from '../utilities/dom-context.js';
12
+ import { MolIconSvg, resolveIcon } from '../utilities/render-icon.js';
13
+ import { styleText } from '../utilities/style.js';
14
+ import { hasNodes, SlotWrapper } from './button.component.js';
15
+ import { MolTemplateOutlet } from './template-outlet.directive.js';
10
16
  import * as i0 from "@angular/core";
11
- const _c0 = ["*"];
12
- function MoleculeToast_Conditional_0_Conditional_1_Template(rf, ctx) { if (rf & 1) {
13
- i0.ɵɵdomElementStart(0, "span");
14
- i0.ɵɵdomElement(1, "span", 4);
15
- i0.ɵɵdomElementEnd();
17
+ const _c0 = ["descriptionSlot"];
18
+ const _c1 = ["childrenSlot"];
19
+ const _c2 = ["*"];
20
+ function Toast_Conditional_0_Template(rf, ctx) { if (rf & 1) {
21
+ i0.ɵɵelementStart(0, "span");
22
+ i0.ɵɵnamespaceSVG();
23
+ i0.ɵɵelement(1, "svg", 5);
24
+ i0.ɵɵelementEnd();
16
25
  } if (rf & 2) {
17
- const ctx_r0 = i0.ɵɵnextContext(2);
18
- i0.ɵɵclassMap(ctx_r0.cm.toastIconWrapper);
26
+ const ctx_r0 = i0.ɵɵnextContext();
27
+ i0.ɵɵclassMap(ctx_r0.cm().toastIconWrapper);
19
28
  i0.ɵɵadvance();
20
- i0.ɵɵdomProperty("innerHTML", ctx_r0.statusIconSvg, i0.ɵɵsanitizeHtml);
29
+ i0.ɵɵproperty("data", ctx);
21
30
  } }
22
- function MoleculeToast_Conditional_0_Conditional_3_Template(rf, ctx) { if (rf & 1) {
23
- i0.ɵɵdomElementStart(0, "div");
31
+ function Toast_Conditional_2_Template(rf, ctx) { if (rf & 1) {
32
+ i0.ɵɵelementStart(0, "div");
24
33
  i0.ɵɵtext(1);
25
- i0.ɵɵdomElementEnd();
34
+ i0.ɵɵelementEnd();
26
35
  } if (rf & 2) {
27
- const ctx_r0 = i0.ɵɵnextContext(2);
28
- i0.ɵɵclassMap(ctx_r0.titleClass);
36
+ const ctx_r0 = i0.ɵɵnextContext();
37
+ i0.ɵɵclassMap(ctx_r0.cm().toastTitle);
29
38
  i0.ɵɵadvance();
30
39
  i0.ɵɵtextInterpolate(ctx_r0.title);
31
40
  } }
32
- function MoleculeToast_Conditional_0_Conditional_4_Template(rf, ctx) { if (rf & 1) {
33
- i0.ɵɵdomElementStart(0, "div");
34
- i0.ɵɵtext(1);
35
- i0.ɵɵdomElementEnd();
36
- } if (rf & 2) {
37
- const ctx_r0 = i0.ɵɵnextContext(2);
38
- i0.ɵɵclassMap(ctx_r0.descriptionClass);
39
- i0.ɵɵadvance();
40
- i0.ɵɵtextInterpolate(ctx_r0.description);
41
- } }
42
- function MoleculeToast_Conditional_0_Conditional_5_Template(rf, ctx) { if (rf & 1) {
43
- i0.ɵɵdomElementStart(0, "div");
44
- i0.ɵɵprojection(1);
45
- i0.ɵɵdomElementEnd();
41
+ function Toast_Conditional_5_Template(rf, ctx) { if (rf & 1) {
42
+ i0.ɵɵtext(0);
46
43
  } if (rf & 2) {
47
- const ctx_r0 = i0.ɵɵnextContext(2);
48
- i0.ɵɵclassMap(ctx_r0.descriptionClass);
44
+ i0.ɵɵtextInterpolate1(" ", ctx, " ");
49
45
  } }
50
- function MoleculeToast_Conditional_0_Conditional_6_Template(rf, ctx) { if (rf & 1) {
46
+ function Toast_Conditional_10_Template(rf, ctx) { if (rf & 1) {
51
47
  const _r2 = i0.ɵɵgetCurrentView();
52
- i0.ɵɵdomElementStart(0, "button", 5);
53
- i0.ɵɵdomListener("click", function MoleculeToast_Conditional_0_Conditional_6_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.onDismiss()); });
54
- i0.ɵɵdomElement(1, "span", 4);
55
- i0.ɵɵdomElementEnd();
48
+ i0.ɵɵelementStart(0, "button", 6);
49
+ i0.ɵɵlistener("click", function Toast_Conditional_10_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r2); const ctx_r0 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r0.handleDismiss()); });
50
+ i0.ɵɵnamespaceSVG();
51
+ i0.ɵɵelement(1, "svg", 5);
52
+ i0.ɵɵelementEnd();
56
53
  } if (rf & 2) {
57
- const ctx_r0 = i0.ɵɵnextContext(2);
58
- i0.ɵɵclassMap(ctx_r0.closeButtonClass);
59
- i0.ɵɵattribute("aria-label", ctx_r0.closeAriaLabel);
54
+ const ctx_r0 = i0.ɵɵnextContext();
55
+ i0.ɵɵclassMap(ctx_r0.cm().toastClose);
56
+ i0.ɵɵattribute("aria-label", ctx_r0.closeText());
60
57
  i0.ɵɵadvance();
61
- i0.ɵɵdomProperty("innerHTML", ctx_r0.dismissIconSvg, i0.ɵɵsanitizeHtml);
58
+ i0.ɵɵproperty("data", ctx_r0.closeIcon());
62
59
  } }
63
- function MoleculeToast_Conditional_0_Template(rf, ctx) { if (rf & 1) {
64
- i0.ɵɵdomElementStart(0, "div", 1);
65
- i0.ɵɵconditionalCreate(1, MoleculeToast_Conditional_0_Conditional_1_Template, 2, 3, "span", 2);
66
- i0.ɵɵdomElementStart(2, "div");
67
- i0.ɵɵconditionalCreate(3, MoleculeToast_Conditional_0_Conditional_3_Template, 2, 3, "div", 2);
68
- i0.ɵɵconditionalCreate(4, MoleculeToast_Conditional_0_Conditional_4_Template, 2, 3, "div", 2)(5, MoleculeToast_Conditional_0_Conditional_5_Template, 2, 2, "div", 2);
69
- i0.ɵɵdomElementEnd();
70
- i0.ɵɵconditionalCreate(6, MoleculeToast_Conditional_0_Conditional_6_Template, 2, 4, "button", 3);
71
- i0.ɵɵdomElementEnd();
60
+ const _c3 = ["container"];
61
+ const _c4 = ["childrenCapture"];
62
+ const _forTrack0 = ($index, $item) => $item.id;
63
+ function ToastProvider_For_6_Template(rf, ctx) { if (rf & 1) {
64
+ const _r1 = i0.ɵɵgetCurrentView();
65
+ i0.ɵɵelementStart(0, "div", 3);
66
+ i0.ɵɵlistener("dismiss", function ToastProvider_For_6_Template_div_dismiss_0_listener() { const toast_r2 = i0.ɵɵrestoreView(_r1).$implicit; const ctx_r2 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r2.removeToast(toast_r2.id)); });
67
+ i0.ɵɵelementEnd();
72
68
  } if (rf & 2) {
73
- const ctx_r0 = i0.ɵɵnextContext();
74
- i0.ɵɵstyleMap(ctx_r0.style);
75
- i0.ɵɵclassMap(ctx_r0.toastClasses);
76
- i0.ɵɵattribute("data-testid", ctx_r0.testId);
77
- i0.ɵɵadvance();
78
- i0.ɵɵconditional(ctx_r0.showIcon ? 1 : -1);
79
- i0.ɵɵadvance();
80
- i0.ɵɵclassMap(ctx_r0.cm.toastContentWrapper);
81
- i0.ɵɵadvance();
82
- i0.ɵɵconditional(ctx_r0.title ? 3 : -1);
83
- i0.ɵɵadvance();
84
- i0.ɵɵconditional(ctx_r0.description ? 4 : 5);
85
- i0.ɵɵadvance(2);
86
- i0.ɵɵconditional(ctx_r0.dismissible ? 6 : -1);
69
+ const toast_r2 = ctx.$implicit;
70
+ i0.ɵɵstyleMap(toast_r2.style);
71
+ i0.ɵɵproperty("title", toast_r2.title)("description", toast_r2.description)("status", toast_r2.status ?? "info")("duration", toast_r2.duration ?? 5000)("dismissible", toast_r2.dismissible ?? true)("closeLabel", toast_r2.closeLabel)("className", toast_r2.className)("testId", toast_r2.testId);
87
72
  } }
88
- const statusVariantMap = {
73
+ /** Toast status → class-map variant. */
74
+ const STATUS_VARIANT = {
89
75
  primary: 'default',
90
76
  secondary: 'default',
91
77
  success: 'success',
@@ -93,206 +79,655 @@ const statusVariantMap = {
93
79
  error: 'error',
94
80
  info: 'info',
95
81
  };
82
+ /** Toast status variant → default glyph name. */
83
+ const STATUS_ICON = {
84
+ info: 'info-circle',
85
+ success: 'check-circle',
86
+ warning: 'exclamation-triangle',
87
+ error: 'x-circle',
88
+ };
89
+ /** Module-global toast id counter (React's `toastCounter`). */
90
+ let toastCounter = 0;
96
91
  /**
97
- * Angular Toast UI component with UIClassMap-driven styling.
98
- */
99
- /**
100
- * Molecule Toast class.
92
+ * Toast component.
93
+ *
94
+ * The host is the toast `<div>` (`div[mol-toast]`), exactly React's root. The
95
+ * auto-dismiss countdown pauses on hover AND focus (WCAG 2.2.1) and resumes
96
+ * with the remaining time; the announced role follows `status`
97
+ * (`warning`/`error` assertive, everything else polite).
101
98
  */
102
- export class MoleculeToast {
99
+ export class Toast {
100
+ /** The toast title. */
103
101
  title;
102
+ /** The toast description (a string or a node value rendered as a template). */
104
103
  description;
104
+ /** The toast status. */
105
105
  status = 'info';
106
+ /** Auto-dismiss delay in ms (`0` keeps it until dismissed). */
106
107
  duration = 5000;
108
+ /** Whether the close button renders. */
107
109
  dismissible = true;
110
+ /** The close button's accessible label. */
108
111
  closeLabel;
109
- position = 'bottom-right';
112
+ /** Extra classes. */
110
113
  className;
114
+ /** Inline style object (React camelCase). */
111
115
  style;
116
+ /** `data-testid`. */
112
117
  testId;
118
+ /** Accepted for prop parity; positioning is the container's job. */
119
+ position;
120
+ /** Fires when the toast dismisses itself or its close button is pressed. */
113
121
  dismiss = new EventEmitter();
114
- isVisible = true;
122
+ /** The description wrapper (always in the template; detached when empty). */
123
+ descriptionSlot;
124
+ /** The children capture point. */
125
+ childrenSlot;
126
+ /** Whether the toast is still rendered (React's `isVisible`). */
127
+ visible = signal(true, /* @ts-ignore */
128
+ ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
129
+ el = inject(ElementRef);
130
+ /**
131
+ * Reactive translation, read in the injection context. Its `t` reads the
132
+ * locale, so the view re-renders the text on a locale switch (the static `t`
133
+ * does not).
134
+ */
135
+ i18n = useTranslation();
136
+ renderer = inject(Renderer2);
137
+ host = this.el.nativeElement;
138
+ sync = new SlotWrapper(this.el, this.renderer);
139
+ remaining;
140
+ startedAt = null;
115
141
  timer;
142
+ lastDuration;
143
+ descriptionParent = null;
144
+ childrenParent = null;
145
+ hasChildren = false;
146
+ adoptedChildren = [];
147
+ detachedParent = null;
148
+ detachedAnchor = null;
149
+ /** Prepares the countdown state (the timer starts at view init). */
150
+ constructor() {
151
+ this.remaining = this.duration;
152
+ this.lastDuration = this.duration;
153
+ }
116
154
  /**
117
- * Retrieves the current UI class map.
118
- * @returns The UIClassMap instance for styling.
155
+ * The current class map.
156
+ * @returns The UIClassMap.
119
157
  */
120
- get cm() {
158
+ cm() {
121
159
  return getClassMap();
122
160
  }
123
161
  /**
124
- * Computes the accessible close button label.
125
- * @returns The localized aria-label for the close button.
162
+ * The mapped class-map variant.
163
+ * @returns The variant.
126
164
  */
127
- get closeAriaLabel() {
128
- return this.closeLabel || t('ui.toast.close', undefined, { defaultValue: 'Close' });
165
+ variant() {
166
+ return STATUS_VARIANT[this.status] || 'default';
129
167
  }
130
168
  /**
131
- * Retrieves the CSS class for the toast title.
132
- * @returns The title class name string.
169
+ * The toast class list.
170
+ * @returns The class string.
133
171
  */
134
- get titleClass() {
135
- return this.cm.toastTitle;
172
+ classes() {
173
+ return this.cm().cn(this.cm().toast({ variant: this.variant() }), this.className);
136
174
  }
137
175
  /**
138
- * Retrieves the CSS class for the toast description.
139
- * @returns The description class name string.
176
+ * Serializes the inline style.
177
+ * @returns The style attribute text.
140
178
  */
141
- get descriptionClass() {
142
- return this.cm.toastDescription;
179
+ hostStyle() {
180
+ return styleText(this.style);
143
181
  }
144
182
  /**
145
- * Retrieves the CSS class for the close button.
146
- * @returns The close button class name string.
183
+ * The announced role: assertive for warnings/errors, polite otherwise.
184
+ * @returns The role attribute value.
147
185
  */
148
- get closeButtonClass() {
149
- return this.cm.toastClose;
186
+ role() {
187
+ return this.variant() === 'warning' || this.variant() === 'error' ? 'alert' : 'status';
150
188
  }
151
189
  /**
152
- * Determines the icon type based on the toast status.
153
- * @returns The mapped icon type string.
190
+ * The status glyph, when the variant has one.
191
+ * @returns The resolved icon, or null.
154
192
  */
155
- get iconType() {
156
- return statusVariantMap[this.status] || 'default';
193
+ statusIcon() {
194
+ const name = STATUS_ICON[this.variant()];
195
+ return name ? resolveIcon(name, this.cm().iconMd) : null;
157
196
  }
158
197
  /**
159
- * Determines whether the status icon should be shown.
160
- * @returns True if the icon type is not default.
198
+ * The close button's X glyph.
199
+ * @returns The resolved icon.
161
200
  */
162
- get showIcon() {
163
- return this.iconType !== 'default';
164
- }
165
- statusIconMap = {
166
- info: 'info-circle',
167
- success: 'check-circle',
168
- warning: 'exclamation-triangle',
169
- error: 'x-circle',
170
- };
201
+ closeIcon() {
202
+ return resolveIcon('x-mark', this.cm().iconSm);
203
+ }
171
204
  /**
172
- * Generates the SVG markup for the status icon.
173
- * @returns The SVG string for the current status icon.
205
+ * The string description, when the description is a string.
206
+ * @returns The text, or null.
174
207
  */
175
- get statusIconSvg() {
176
- const name = this.statusIconMap[this.iconType];
177
- return name ? getIconSvg(name, this.cm.iconMd) : '';
208
+ descriptionText() {
209
+ return typeof this.description === 'string' ? this.description : null;
178
210
  }
179
211
  /**
180
- * Generates the SVG markup for the dismiss icon.
181
- * @returns The SVG string for the dismiss button icon.
212
+ * The description as a template, when it is a node value.
213
+ * @returns The template, or null.
182
214
  */
183
- get dismissIconSvg() {
184
- return getIconSvg('x-mark', this.cm.iconSm);
215
+ descriptionTemplate() {
216
+ return this.description instanceof TemplateRef ? this.description : null;
185
217
  }
186
218
  /**
187
- * Computes the combined CSS classes for the toast container.
188
- * @returns The toast class name string.
219
+ * The close button's accessible label.
220
+ * @returns The label text.
189
221
  */
190
- get toastClasses() {
191
- const variant = statusVariantMap[this.status] || 'default';
192
- return this.cm.cn(this.cm.toast({ variant }), this.className);
222
+ closeText() {
223
+ return this.closeLabel ?? this.i18n.t('ui.toast.close', undefined, { defaultValue: 'Close' });
224
+ }
225
+ /** Dismisses the toast and calls the callback (React's `handleDismiss`). */
226
+ handleDismiss() {
227
+ this.visible.set(false);
228
+ this.dismiss.emit();
229
+ }
230
+ /** Pauses the countdown, keeping the time left (React's `pauseTimer`). */
231
+ pauseTimer() {
232
+ if (this.startedAt === null)
233
+ return;
234
+ const elapsed = Date.now() - this.startedAt;
235
+ this.remaining = Math.max(0, this.remaining - elapsed);
236
+ this.clearTimer();
237
+ }
238
+ /** Resumes the countdown with the remaining time (React's `resumeTimer`). */
239
+ resumeTimer() {
240
+ if (this.remaining > 0)
241
+ this.startTimer(this.remaining);
193
242
  }
194
243
  /**
195
- * Starts the auto-dismiss timer on component creation.
244
+ * Detects the first view and the `duration` input changes, and starts the
245
+ * countdown (React's mount effect, with `[duration]` deps).
196
246
  */
197
- ngOnInit() {
198
- if (this.duration > 0) {
199
- this.timer = setTimeout(() => {
200
- this.isVisible = false;
201
- this.dismiss.emit();
202
- }, this.duration);
203
- }
247
+ ngAfterViewInit() {
248
+ this.descriptionParent = this.descriptionSlot?.nativeElement.parentElement ?? null;
249
+ this.childrenParent = this.childrenSlot?.nativeElement.parentElement ?? null;
250
+ this.hasChildren = hasNodes(this.childrenSlot?.nativeElement);
251
+ this.adoptChildren();
252
+ this.restart();
204
253
  }
205
254
  /**
206
- * Clears the auto-dismiss timer on component destruction.
255
+ * Re-reconciles children visibility on later passes.
207
256
  */
257
+ ngDoCheck() {
258
+ if (this.duration !== this.lastDuration) {
259
+ this.lastDuration = this.duration;
260
+ this.restart();
261
+ }
262
+ this.syncDescription();
263
+ this.syncHostVisibility();
264
+ }
265
+ /** Stops the countdown (React's unmount cleanup). */
208
266
  ngOnDestroy() {
267
+ this.clearTimer();
268
+ this.adoptedChildren = [];
269
+ // The host must be inside its parent for Angular's own removal to succeed.
270
+ if (!this.host.isConnected && this.detachedParent) {
271
+ this.detachedParent.insertBefore(this.host, this.detachedAnchor);
272
+ this.detachedParent = null;
273
+ this.detachedAnchor = null;
274
+ }
275
+ }
276
+ /** React's effect body: reset the remaining time and start counting. */
277
+ restart() {
278
+ this.remaining = this.duration;
279
+ this.startTimer(this.duration);
280
+ }
281
+ /** Clears the running timer (React's `clearTimer`). */
282
+ clearTimer() {
209
283
  if (this.timer) {
210
284
  clearTimeout(this.timer);
285
+ this.timer = undefined;
211
286
  }
287
+ this.startedAt = null;
212
288
  }
213
289
  /**
214
- * Handles the dismiss action by hiding the toast.
290
+ * Starts the countdown (React's `startTimer`).
291
+ * @param ms - Milliseconds until dismissal.
215
292
  */
216
- onDismiss() {
217
- this.isVisible = false;
218
- this.dismiss.emit();
293
+ startTimer(ms) {
294
+ this.clearTimer();
295
+ if (ms <= 0)
296
+ return;
297
+ this.startedAt = Date.now();
298
+ this.timer = setTimeout(() => {
299
+ this.visible.set(false);
300
+ this.dismiss.emit();
301
+ }, ms);
302
+ }
303
+ /**
304
+ * Moves the projected children into the description wrapper (React renders
305
+ * them there) unless the description prop wins.
306
+ */
307
+ adoptChildren() {
308
+ const span = this.childrenSlot?.nativeElement;
309
+ if (!span)
310
+ return;
311
+ const wrapper = this.descriptionSlot?.nativeElement;
312
+ const descWins = this.descriptionText() !== null || this.descriptionTemplate() !== null;
313
+ if (wrapper && !descWins && this.hasChildren) {
314
+ this.adoptedChildren = Array.from(span.childNodes);
315
+ for (const node of this.adoptedChildren)
316
+ wrapper.appendChild(node);
317
+ }
318
+ this.sync.sync(span, false, this.childrenParent ?? undefined);
319
+ this.syncDescription();
320
+ }
321
+ /**
322
+ * Removes the host element from the DOM when React renders null (the toast
323
+ * dismissed itself), and restores it before Angular removes it on destroy.
324
+ */
325
+ syncHostVisibility() {
326
+ const host = this.host;
327
+ if (!this.visible()) {
328
+ if (host.isConnected) {
329
+ this.detachedParent = host.parentNode;
330
+ this.detachedAnchor = host.nextSibling;
331
+ host.parentNode?.removeChild(host);
332
+ }
333
+ }
334
+ else if (this.detachedParent && !host.isConnected) {
335
+ this.detachedParent.insertBefore(host, this.detachedAnchor);
336
+ this.detachedParent = null;
337
+ this.detachedAnchor = null;
338
+ }
219
339
  }
220
- static ɵfac = function MoleculeToast_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || MoleculeToast)(); };
221
- static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: MoleculeToast, selectors: [["mol-toast"]], inputs: { title: "title", description: "description", status: "status", duration: "duration", dismissible: "dismissible", closeLabel: "closeLabel", position: "position", className: "className", style: "style", testId: "testId" }, outputs: { dismiss: "dismiss" }, ngContentSelectors: _c0, decls: 1, vars: 1, consts: [["role", "alert", "data-state", "open", 3, "class", "style"], ["role", "alert", "data-state", "open"], [3, "class"], ["type", "button", 3, "class"], [3, "innerHTML"], ["type", "button", 3, "click"]], template: function MoleculeToast_Template(rf, ctx) { if (rf & 1) {
340
+ /** Applies React's `{!!(description || children) && <div>…</div>}`. */
341
+ syncDescription() {
342
+ const wrapper = this.descriptionSlot?.nativeElement;
343
+ if (!wrapper)
344
+ return;
345
+ const hasDescription = this.descriptionText() !== null || this.descriptionTemplate() !== null;
346
+ this.sync.sync(wrapper, hasDescription || this.hasChildren, this.descriptionParent ?? undefined);
347
+ }
348
+ static ɵfac = function Toast_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || Toast)(); };
349
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: Toast, selectors: [["div", "mol-toast", ""]], viewQuery: function Toast_Query(rf, ctx) { if (rf & 1) {
350
+ i0.ɵɵviewQuery(_c0, 5)(_c1, 5);
351
+ } if (rf & 2) {
352
+ let _t;
353
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.descriptionSlot = _t.first);
354
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenSlot = _t.first);
355
+ } }, hostVars: 7, hostBindings: function Toast_HostBindings(rf, ctx) { if (rf & 1) {
356
+ i0.ɵɵlistener("mouseenter", function Toast_mouseenter_HostBindingHandler() { return ctx.pauseTimer(); })("mouseleave", function Toast_mouseleave_HostBindingHandler() { return ctx.resumeTimer(); })("focusin", function Toast_focusin_HostBindingHandler() { return ctx.pauseTimer(); })("focusout", function Toast_focusout_HostBindingHandler() { return ctx.resumeTimer(); });
357
+ } if (rf & 2) {
358
+ i0.ɵɵattribute("data-testid", ctx.testId)("role", ctx.role())("data-state", ctx.visible() ? "open" : null);
359
+ i0.ɵɵstyleMap(ctx.hostStyle());
360
+ i0.ɵɵclassMap(ctx.classes());
361
+ } }, inputs: { title: "title", description: "description", status: "status", duration: "duration", dismissible: "dismissible", closeLabel: "closeLabel", className: "className", style: "style", testId: "testId", position: "position" }, outputs: { dismiss: "dismiss" }, ngContentSelectors: _c2, decls: 11, vars: 9, consts: [["descriptionSlot", ""], ["childrenSlot", ""], [3, "class"], [3, "molTemplateOutlet"], ["type", "button", 3, "class"], ["mol-icon", "", 3, "data"], ["type", "button", 3, "click"]], template: function Toast_Template(rf, ctx) { if (rf & 1) {
222
362
  i0.ɵɵprojectionDef();
223
- i0.ɵɵconditionalCreate(0, MoleculeToast_Conditional_0_Template, 7, 11, "div", 0);
363
+ i0.ɵɵconditionalCreate(0, Toast_Conditional_0_Template, 2, 3, "span", 2);
364
+ i0.ɵɵelementStart(1, "div");
365
+ i0.ɵɵconditionalCreate(2, Toast_Conditional_2_Template, 2, 3, "div", 2);
366
+ i0.ɵɵelementStart(3, "div", null, 0);
367
+ i0.ɵɵconditionalCreate(5, Toast_Conditional_5_Template, 1, 1);
368
+ i0.ɵɵelementContainer(6, 3);
369
+ i0.ɵɵelementStart(7, "span", null, 1);
370
+ i0.ɵɵprojection(9);
371
+ i0.ɵɵelementEnd()()();
372
+ i0.ɵɵconditionalCreate(10, Toast_Conditional_10_Template, 2, 4, "button", 4);
224
373
  } if (rf & 2) {
225
- i0.ɵɵconditional(ctx.isVisible ? 0 : -1);
226
- } }, encapsulation: 2 });
374
+ let tmp_2_0;
375
+ let tmp_6_0;
376
+ i0.ɵɵconditional((tmp_2_0 = ctx.statusIcon()) ? 0 : -1, tmp_2_0);
377
+ i0.ɵɵadvance();
378
+ i0.ɵɵclassMap(ctx.cm().toastContentWrapper);
379
+ i0.ɵɵadvance();
380
+ i0.ɵɵconditional(ctx.title ? 2 : -1);
381
+ i0.ɵɵadvance();
382
+ i0.ɵɵclassMap(ctx.cm().toastDescription);
383
+ i0.ɵɵadvance(2);
384
+ i0.ɵɵconditional((tmp_6_0 = ctx.descriptionText()) ? 5 : -1, tmp_6_0);
385
+ i0.ɵɵadvance();
386
+ i0.ɵɵproperty("molTemplateOutlet", ctx.descriptionTemplate());
387
+ i0.ɵɵadvance(4);
388
+ i0.ɵɵconditional(ctx.dismissible ? 10 : -1);
389
+ } }, dependencies: [MolIconSvg, MolTemplateOutlet], encapsulation: 2 });
227
390
  }
228
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(MoleculeToast, [{
391
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(Toast, [{
229
392
  type: Component,
230
393
  args: [{
231
- selector: 'mol-toast',
394
+ selector: 'div[mol-toast]',
232
395
  standalone: true,
233
- changeDetection: ChangeDetectionStrategy.OnPush,
234
- template: `
235
- @if (isVisible) {
236
- <div
237
- role="alert"
238
- data-state="open"
239
- [class]="toastClasses"
240
- [style]="style"
241
- [attr.data-testid]="testId"
242
- >
243
- @if (showIcon) {
244
- <span [class]="cm.toastIconWrapper">
245
- <span [innerHTML]="statusIconSvg"></span>
246
- </span>
247
- }
248
- <div [class]="cm.toastContentWrapper">
249
- @if (title) {
250
- <div [class]="titleClass">{{ title }}</div>
251
- }
252
- @if (description) {
253
- <div [class]="descriptionClass">{{ description }}</div>
254
- } @else {
255
- <div [class]="descriptionClass">
256
- <ng-content></ng-content>
257
- </div>
258
- }
259
- </div>
260
- @if (dismissible) {
261
- <button
262
- type="button"
263
- (click)="onDismiss()"
264
- [class]="closeButtonClass"
265
- [attr.aria-label]="closeAriaLabel"
266
- >
267
- <span [innerHTML]="dismissIconSvg"></span>
268
- </button>
396
+ imports: [MolIconSvg, MolTemplateOutlet],
397
+ inputs: [
398
+ 'title',
399
+ 'description',
400
+ 'status',
401
+ 'duration',
402
+ 'dismissible',
403
+ 'closeLabel',
404
+ 'className',
405
+ 'style',
406
+ 'testId',
407
+ 'position',
408
+ ],
409
+ outputs: ['dismiss'],
410
+ host: {
411
+ '[class]': 'classes()',
412
+ '[style]': 'hostStyle()',
413
+ '[attr.data-testid]': 'testId',
414
+ '[attr.role]': 'role()',
415
+ '[attr.data-state]': 'visible() ? "open" : null',
416
+ '(mouseenter)': 'pauseTimer()',
417
+ '(mouseleave)': 'resumeTimer()',
418
+ '(focusin)': 'pauseTimer()',
419
+ '(focusout)': 'resumeTimer()',
420
+ },
421
+ template: `@if (statusIcon(); as icon) {
422
+ <span [class]="cm().toastIconWrapper"><svg mol-icon [data]="icon" /></span>
423
+ }
424
+ <div [class]="cm().toastContentWrapper">
425
+ @if (title) {
426
+ <div [class]="cm().toastTitle">{{ title }}</div>
427
+ }
428
+ <div #descriptionSlot [class]="cm().toastDescription">
429
+ @if (descriptionText(); as descriptionTextValue) {
430
+ {{ descriptionTextValue }}
269
431
  }
432
+ <ng-container [molTemplateOutlet]="descriptionTemplate()"></ng-container
433
+ ><span #childrenSlot><ng-content></ng-content></span>
270
434
  </div>
271
- }
272
- `,
435
+ </div>
436
+ @if (dismissible) {
437
+ <button
438
+ type="button"
439
+ [class]="cm().toastClose"
440
+ [attr.aria-label]="closeText()"
441
+ (click)="handleDismiss()"
442
+ >
443
+ <svg mol-icon [data]="closeIcon()" />
444
+ </button>
445
+ }`,
273
446
  }]
274
- }], null, { title: [{
275
- type: Input
276
- }], description: [{
277
- type: Input
278
- }], status: [{
279
- type: Input
280
- }], duration: [{
281
- type: Input
282
- }], dismissible: [{
283
- type: Input
284
- }], closeLabel: [{
285
- type: Input
286
- }], position: [{
287
- type: Input
288
- }], className: [{
289
- type: Input
290
- }], style: [{
291
- type: Input
292
- }], testId: [{
293
- type: Input
294
- }], dismiss: [{
447
+ }], () => [], { dismiss: [{
295
448
  type: Output
449
+ }], descriptionSlot: [{
450
+ type: ViewChild,
451
+ args: ['descriptionSlot']
452
+ }], childrenSlot: [{
453
+ type: ViewChild,
454
+ args: ['childrenSlot']
455
+ }] }); })();
456
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(Toast, { className: "Toast", filePath: "components/toast.component.ts", lineNumber: 139 }); })();
457
+ /**
458
+ * Toast container: positions toasts on screen via a body portal.
459
+ *
460
+ * React's root is a portal, so the host is unwrapped
461
+ * (`data-parity-unwrap`, `display: contents`) and the container `<div>` is
462
+ * moved into `document.body`.
463
+ */
464
+ export class ToastContainer {
465
+ /** The container position (default `bottom-right`). */
466
+ position = 'bottom-right';
467
+ /** Extra classes. */
468
+ className;
469
+ /** The container element (moved to `document.body`). */
470
+ container;
471
+ host = inject(ElementRef);
472
+ /**
473
+ * The current class map.
474
+ * @returns The UIClassMap.
475
+ */
476
+ cm() {
477
+ return getClassMap();
478
+ }
479
+ /**
480
+ * The container class list.
481
+ * @returns The class string.
482
+ */
483
+ classes() {
484
+ return this.cm().cn(this.cm().toastContainer({ position: this.position }), this.className);
485
+ }
486
+ /** Moves the container to `document.body` (React's portal). */
487
+ ngAfterViewInit() {
488
+ const el = this.container?.nativeElement;
489
+ if (el && typeof document !== 'undefined')
490
+ document.body.appendChild(el);
491
+ }
492
+ /** Moves the container back under the host so Angular can remove it. */
493
+ ngOnDestroy() {
494
+ const el = this.container?.nativeElement;
495
+ if (el && this.host.nativeElement.parentNode)
496
+ this.host.nativeElement.appendChild(el);
497
+ }
498
+ static ɵfac = function ToastContainer_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToastContainer)(); };
499
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ToastContainer, selectors: [["mol-toast-container"]], viewQuery: function ToastContainer_Query(rf, ctx) { if (rf & 1) {
500
+ i0.ɵɵviewQuery(_c3, 5);
501
+ } if (rf & 2) {
502
+ let _t;
503
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
504
+ } }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { position: "position", className: "className" }, ngContentSelectors: _c2, decls: 3, vars: 2, consts: [["container", ""]], template: function ToastContainer_Template(rf, ctx) { if (rf & 1) {
505
+ i0.ɵɵprojectionDef();
506
+ i0.ɵɵdomElementStart(0, "div", null, 0);
507
+ i0.ɵɵprojection(2);
508
+ i0.ɵɵdomElementEnd();
509
+ } if (rf & 2) {
510
+ i0.ɵɵclassMap(ctx.classes());
511
+ } }, encapsulation: 2 });
512
+ }
513
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastContainer, [{
514
+ type: Component,
515
+ args: [{
516
+ selector: 'mol-toast-container',
517
+ standalone: true,
518
+ inputs: ['position', 'className'],
519
+ host: {
520
+ 'data-parity-unwrap': '',
521
+ style: 'display: contents',
522
+ },
523
+ template: `<div #container [class]="classes()"><ng-content></ng-content></div>`,
524
+ }]
525
+ }], null, { container: [{
526
+ type: ViewChild,
527
+ args: ['container']
528
+ }] }); })();
529
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ToastContainer, { className: "ToastContainer", filePath: "components/toast.component.ts", lineNumber: 428 }); })();
530
+ /**
531
+ * ToastProvider: manages global toast state and renders children plus a
532
+ * positioned toast container (React's context provider + portal).
533
+ *
534
+ * The context value is registered on the host element (React context flows
535
+ * through the rendered tree, which Angular DI cannot reach for projected
536
+ * content); `useToast()` reads it through the DOM ancestors.
537
+ */
538
+ export class ToastProvider {
539
+ /** The default position for toasts (default `bottom-right`). */
540
+ position = 'bottom-right';
541
+ /** The children capture point (removed once children are adopted). */
542
+ childrenCapture;
543
+ /** The toast container (moved to `document.body`). */
544
+ container;
545
+ /** The current toasts. */
546
+ toasts = signal([], /* @ts-ignore */
547
+ ...(ngDevMode ? [{ debugName: "toasts" }] : /* istanbul ignore next */ []));
548
+ host = inject(ElementRef);
549
+ renderer = inject(Renderer2);
550
+ sync = new SlotWrapper(this.host, this.renderer);
551
+ adopted = [];
552
+ /** Registers the toast context on the host (before any projected child resolves it). */
553
+ constructor() {
554
+ provideDomContext(this.host.nativeElement, new ToastContextImplementation(this));
555
+ }
556
+ /**
557
+ * The current class map.
558
+ * @returns The UIClassMap.
559
+ */
560
+ cm() {
561
+ return getClassMap();
562
+ }
563
+ /**
564
+ * The container class list.
565
+ * @returns The class string.
566
+ */
567
+ containerClasses() {
568
+ return this.cm().toastContainer({ position: this.position });
569
+ }
570
+ /**
571
+ * Adds a toast and returns its generated id (React's `addToast`).
572
+ * @param toast - The toast to add.
573
+ * @returns The id.
574
+ */
575
+ addToast(toast) {
576
+ const id = `toast-${++toastCounter}`;
577
+ this.toasts.update((prev) => [...prev, { ...toast, id }]);
578
+ return id;
579
+ }
580
+ /**
581
+ * Removes a toast by id (React's `removeToast`).
582
+ * @param id - The toast's id.
583
+ */
584
+ removeToast(id) {
585
+ this.toasts.update((prev) => prev.filter((toast) => toast.id !== id));
586
+ }
587
+ /**
588
+ * Adopts the children bare into the host and moves the container to
589
+ * `document.body` (React's portal).
590
+ */
591
+ ngAfterViewInit() {
592
+ const capture = this.childrenCapture?.nativeElement;
593
+ const host = this.host.nativeElement;
594
+ if (capture) {
595
+ this.adopted = Array.from(capture.childNodes);
596
+ for (const node of this.adopted)
597
+ host.appendChild(node);
598
+ this.sync.sync(capture, false, host);
599
+ }
600
+ const container = this.container?.nativeElement;
601
+ if (container && typeof document !== 'undefined')
602
+ document.body.appendChild(container);
603
+ }
604
+ /** Removes the context registration and restores the container (unmount). */
605
+ ngOnDestroy() {
606
+ removeDomContext(this.host.nativeElement);
607
+ const container = this.container?.nativeElement;
608
+ if (container && this.host.nativeElement.parentNode)
609
+ this.host.nativeElement.appendChild(container);
610
+ this.adopted = [];
611
+ }
612
+ static ɵfac = function ToastProvider_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ToastProvider)(); };
613
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ToastProvider, selectors: [["mol-toast-provider"]], viewQuery: function ToastProvider_Query(rf, ctx) { if (rf & 1) {
614
+ i0.ɵɵviewQuery(_c4, 5)(_c3, 5);
615
+ } if (rf & 2) {
616
+ let _t;
617
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.childrenCapture = _t.first);
618
+ i0.ɵɵqueryRefresh(_t = i0.ɵɵloadQuery()) && (ctx.container = _t.first);
619
+ } }, hostAttrs: ["data-parity-unwrap", "", 2, "display", "contents"], inputs: { position: "position" }, ngContentSelectors: _c2, decls: 7, vars: 2, consts: [["childrenCapture", ""], ["container", ""], ["mol-toast", "", 3, "title", "description", "status", "duration", "dismissible", "closeLabel", "className", "style", "testId"], ["mol-toast", "", 3, "dismiss", "title", "description", "status", "duration", "dismissible", "closeLabel", "className", "testId"]], template: function ToastProvider_Template(rf, ctx) { if (rf & 1) {
620
+ i0.ɵɵprojectionDef();
621
+ i0.ɵɵelementStart(0, "span", null, 0);
622
+ i0.ɵɵprojection(2);
623
+ i0.ɵɵelementEnd();
624
+ i0.ɵɵelementStart(3, "div", null, 1);
625
+ i0.ɵɵrepeaterCreate(5, ToastProvider_For_6_Template, 1, 10, "div", 2, _forTrack0);
626
+ i0.ɵɵelementEnd();
627
+ } if (rf & 2) {
628
+ i0.ɵɵadvance(3);
629
+ i0.ɵɵclassMap(ctx.containerClasses());
630
+ i0.ɵɵadvance(2);
631
+ i0.ɵɵrepeater(ctx.toasts());
632
+ } }, dependencies: [Toast], encapsulation: 2 });
633
+ }
634
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ToastProvider, [{
635
+ type: Component,
636
+ args: [{
637
+ selector: 'mol-toast-provider',
638
+ standalone: true,
639
+ imports: [Toast],
640
+ inputs: ['position'],
641
+ host: {
642
+ 'data-parity-unwrap': '',
643
+ style: 'display: contents',
644
+ },
645
+ template: `<span #childrenCapture><ng-content></ng-content></span>
646
+ <div #container [class]="containerClasses()">
647
+ @for (toast of toasts(); track toast.id) {
648
+ <div
649
+ mol-toast
650
+ [title]="toast.title"
651
+ [description]="toast.description"
652
+ [status]="toast.status ?? 'info'"
653
+ [duration]="toast.duration ?? 5000"
654
+ [dismissible]="toast.dismissible ?? true"
655
+ [closeLabel]="toast.closeLabel"
656
+ [className]="toast.className"
657
+ [style]="toast.style"
658
+ [testId]="toast.testId"
659
+ (dismiss)="removeToast(toast.id)"
660
+ ></div>
661
+ }
662
+ </div>`,
663
+ }]
664
+ }], () => [], { childrenCapture: [{
665
+ type: ViewChild,
666
+ args: ['childrenCapture']
667
+ }], container: [{
668
+ type: ViewChild,
669
+ args: ['container']
296
670
  }] }); })();
297
- (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(MoleculeToast, { className: "MoleculeToast", filePath: "components/toast.component.ts", lineNumber: 84 }); })();
671
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ToastProvider, { className: "ToastProvider", filePath: "components/toast.component.ts", lineNumber: 504 }); })();
672
+ /** The toast context a `ToastProvider` registers. */
673
+ class ToastContextImplementation {
674
+ provider;
675
+ /**
676
+ * Creates the context for a provider.
677
+ *
678
+ * @param provider - The owning provider.
679
+ */
680
+ constructor(provider) {
681
+ this.provider = provider;
682
+ }
683
+ /** The current toasts. */
684
+ get toasts() {
685
+ return this.provider.toasts();
686
+ }
687
+ /**
688
+ * Adds a toast.
689
+ * @param toast - The toast to add.
690
+ * @returns The generated id.
691
+ */
692
+ addToast(toast) {
693
+ return this.provider.addToast(toast);
694
+ }
695
+ /**
696
+ * Removes a toast by id.
697
+ * @param id - The toast's id.
698
+ */
699
+ removeToast(id) {
700
+ this.provider.removeToast(id);
701
+ }
702
+ }
703
+ /**
704
+ * Accesses the toast context for adding and removing toasts.
705
+ *
706
+ * Must be called in an injection context (a component field initializer or
707
+ * constructor).
708
+ *
709
+ * @returns The toast context value.
710
+ * @throws {Error} When there is no enclosing `ToastProvider` (React throws too).
711
+ */
712
+ export function useToast() {
713
+ const el = inject(ElementRef, { optional: true });
714
+ const resolve = () => {
715
+ const found = findDomContext(el?.nativeElement ?? null);
716
+ if (!found) {
717
+ // Thrown outside rendering (a hook used outside its provider), so the
718
+ // English fallback travels with the error instead of the static `t`.
719
+ throw new I18nError('react.error.useToastOutsideProvider', undefined, 'useToast must be used within a ToastProvider');
720
+ }
721
+ return found;
722
+ };
723
+ // Resolved at CALL time (a probe resolves the context in its constructor,
724
+ // before Angular has inserted its host into the DOM).
725
+ return {
726
+ get toasts() {
727
+ return resolve().toasts;
728
+ },
729
+ addToast: (toast) => resolve().addToast(toast),
730
+ removeToast: (id) => resolve().removeToast(id),
731
+ };
732
+ }
298
733
  //# sourceMappingURL=toast.component.js.map