@ids-group-ltd/ids-design-system 0.11.4 → 0.12.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 (239) hide show
  1. package/CHANGELOG.md +53 -3
  2. package/components/README.md +86 -0
  3. package/fesm2022/ids-group-ltd-ids-design-system-components-accordion.mjs +85 -0
  4. package/fesm2022/ids-group-ltd-ids-design-system-components-accordion.mjs.map +1 -0
  5. package/fesm2022/ids-group-ltd-ids-design-system-components-alert.mjs +70 -0
  6. package/fesm2022/ids-group-ltd-ids-design-system-components-alert.mjs.map +1 -0
  7. package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs +573 -0
  8. package/fesm2022/ids-group-ltd-ids-design-system-components-app-layout.mjs.map +1 -0
  9. package/fesm2022/ids-group-ltd-ids-design-system-components-auth-layout.mjs +86 -0
  10. package/fesm2022/ids-group-ltd-ids-design-system-components-auth-layout.mjs.map +1 -0
  11. package/fesm2022/ids-group-ltd-ids-design-system-components-autocomplete.mjs +615 -0
  12. package/fesm2022/ids-group-ltd-ids-design-system-components-autocomplete.mjs.map +1 -0
  13. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar-group.mjs +30 -0
  14. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar-group.mjs.map +1 -0
  15. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs +188 -0
  16. package/fesm2022/ids-group-ltd-ids-design-system-components-avatar.mjs.map +1 -0
  17. package/fesm2022/ids-group-ltd-ids-design-system-components-badge.mjs +59 -0
  18. package/fesm2022/ids-group-ltd-ids-design-system-components-badge.mjs.map +1 -0
  19. package/fesm2022/ids-group-ltd-ids-design-system-components-banner.mjs +92 -0
  20. package/fesm2022/ids-group-ltd-ids-design-system-components-banner.mjs.map +1 -0
  21. package/fesm2022/ids-group-ltd-ids-design-system-components-bottom-sheet.mjs +204 -0
  22. package/fesm2022/ids-group-ltd-ids-design-system-components-bottom-sheet.mjs.map +1 -0
  23. package/fesm2022/ids-group-ltd-ids-design-system-components-breadcrumbs.mjs +100 -0
  24. package/fesm2022/ids-group-ltd-ids-design-system-components-breadcrumbs.mjs.map +1 -0
  25. package/fesm2022/ids-group-ltd-ids-design-system-components-button-group.mjs +23 -0
  26. package/fesm2022/ids-group-ltd-ids-design-system-components-button-group.mjs.map +1 -0
  27. package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs +180 -0
  28. package/fesm2022/ids-group-ltd-ids-design-system-components-button.mjs.map +1 -0
  29. package/fesm2022/ids-group-ltd-ids-design-system-components-calendar-day.mjs +78 -0
  30. package/fesm2022/ids-group-ltd-ids-design-system-components-calendar-day.mjs.map +1 -0
  31. package/fesm2022/ids-group-ltd-ids-design-system-components-card.mjs +49 -0
  32. package/fesm2022/ids-group-ltd-ids-design-system-components-card.mjs.map +1 -0
  33. package/fesm2022/ids-group-ltd-ids-design-system-components-checkbox.mjs +73 -0
  34. package/fesm2022/ids-group-ltd-ids-design-system-components-checkbox.mjs.map +1 -0
  35. package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs +397 -0
  36. package/fesm2022/ids-group-ltd-ids-design-system-components-color-picker.mjs.map +1 -0
  37. package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs +1231 -0
  38. package/fesm2022/ids-group-ltd-ids-design-system-components-date-picker.mjs.map +1 -0
  39. package/fesm2022/ids-group-ltd-ids-design-system-components-description-list.mjs +51 -0
  40. package/fesm2022/ids-group-ltd-ids-design-system-components-description-list.mjs.map +1 -0
  41. package/fesm2022/ids-group-ltd-ids-design-system-components-divider.mjs +35 -0
  42. package/fesm2022/ids-group-ltd-ids-design-system-components-divider.mjs.map +1 -0
  43. package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs +109 -0
  44. package/fesm2022/ids-group-ltd-ids-design-system-components-drawer.mjs.map +1 -0
  45. package/fesm2022/ids-group-ltd-ids-design-system-components-dropzone.mjs +111 -0
  46. package/fesm2022/ids-group-ltd-ids-design-system-components-dropzone.mjs.map +1 -0
  47. package/fesm2022/ids-group-ltd-ids-design-system-components-empty-state.mjs +52 -0
  48. package/fesm2022/ids-group-ltd-ids-design-system-components-empty-state.mjs.map +1 -0
  49. package/fesm2022/ids-group-ltd-ids-design-system-components-field-group.mjs +92 -0
  50. package/fesm2022/ids-group-ltd-ids-design-system-components-field-group.mjs.map +1 -0
  51. package/fesm2022/ids-group-ltd-ids-design-system-components-field-message.mjs +62 -0
  52. package/fesm2022/ids-group-ltd-ids-design-system-components-field-message.mjs.map +1 -0
  53. package/fesm2022/ids-group-ltd-ids-design-system-components-filter-bar.mjs +164 -0
  54. package/fesm2022/ids-group-ltd-ids-design-system-components-filter-bar.mjs.map +1 -0
  55. package/fesm2022/ids-group-ltd-ids-design-system-components-icon-button.mjs +85 -0
  56. package/fesm2022/ids-group-ltd-ids-design-system-components-icon-button.mjs.map +1 -0
  57. package/fesm2022/ids-group-ltd-ids-design-system-components-input.mjs +223 -0
  58. package/fesm2022/ids-group-ltd-ids-design-system-components-input.mjs.map +1 -0
  59. package/fesm2022/ids-group-ltd-ids-design-system-components-layout.mjs +63 -0
  60. package/fesm2022/ids-group-ltd-ids-design-system-components-layout.mjs.map +1 -0
  61. package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs +53 -0
  62. package/fesm2022/ids-group-ltd-ids-design-system-components-list.mjs.map +1 -0
  63. package/fesm2022/ids-group-ltd-ids-design-system-components-loading-overlay.mjs +43 -0
  64. package/fesm2022/ids-group-ltd-ids-design-system-components-loading-overlay.mjs.map +1 -0
  65. package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs +286 -0
  66. package/fesm2022/ids-group-ltd-ids-design-system-components-menu.mjs.map +1 -0
  67. package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs +329 -0
  68. package/fesm2022/ids-group-ltd-ids-design-system-components-modal.mjs.map +1 -0
  69. package/fesm2022/ids-group-ltd-ids-design-system-components-multi-select.mjs +612 -0
  70. package/fesm2022/ids-group-ltd-ids-design-system-components-multi-select.mjs.map +1 -0
  71. package/fesm2022/ids-group-ltd-ids-design-system-components-number-stepper.mjs +69 -0
  72. package/fesm2022/ids-group-ltd-ids-design-system-components-number-stepper.mjs.map +1 -0
  73. package/fesm2022/ids-group-ltd-ids-design-system-components-otp-input.mjs +191 -0
  74. package/fesm2022/ids-group-ltd-ids-design-system-components-otp-input.mjs.map +1 -0
  75. package/fesm2022/ids-group-ltd-ids-design-system-components-page-footer.mjs +23 -0
  76. package/fesm2022/ids-group-ltd-ids-design-system-components-page-footer.mjs.map +1 -0
  77. package/fesm2022/ids-group-ltd-ids-design-system-components-page-header.mjs +43 -0
  78. package/fesm2022/ids-group-ltd-ids-design-system-components-page-header.mjs.map +1 -0
  79. package/fesm2022/ids-group-ltd-ids-design-system-components-pagination.mjs +85 -0
  80. package/fesm2022/ids-group-ltd-ids-design-system-components-pagination.mjs.map +1 -0
  81. package/fesm2022/ids-group-ltd-ids-design-system-components-password-rules.mjs +95 -0
  82. package/fesm2022/ids-group-ltd-ids-design-system-components-password-rules.mjs.map +1 -0
  83. package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs +240 -0
  84. package/fesm2022/ids-group-ltd-ids-design-system-components-popover.mjs.map +1 -0
  85. package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs +41 -0
  86. package/fesm2022/ids-group-ltd-ids-design-system-components-progress.mjs.map +1 -0
  87. package/fesm2022/ids-group-ltd-ids-design-system-components-radio-group.mjs +235 -0
  88. package/fesm2022/ids-group-ltd-ids-design-system-components-radio-group.mjs.map +1 -0
  89. package/fesm2022/ids-group-ltd-ids-design-system-components-reserve-messages.mjs +62 -0
  90. package/fesm2022/ids-group-ltd-ids-design-system-components-reserve-messages.mjs.map +1 -0
  91. package/fesm2022/ids-group-ltd-ids-design-system-components-search.mjs +173 -0
  92. package/fesm2022/ids-group-ltd-ids-design-system-components-search.mjs.map +1 -0
  93. package/fesm2022/ids-group-ltd-ids-design-system-components-segmented.mjs +123 -0
  94. package/fesm2022/ids-group-ltd-ids-design-system-components-segmented.mjs.map +1 -0
  95. package/fesm2022/ids-group-ltd-ids-design-system-components-select.mjs +461 -0
  96. package/fesm2022/ids-group-ltd-ids-design-system-components-select.mjs.map +1 -0
  97. package/fesm2022/ids-group-ltd-ids-design-system-components-sidenav-footer.mjs +107 -0
  98. package/fesm2022/ids-group-ltd-ids-design-system-components-sidenav-footer.mjs.map +1 -0
  99. package/fesm2022/ids-group-ltd-ids-design-system-components-sidenav.mjs +185 -0
  100. package/fesm2022/ids-group-ltd-ids-design-system-components-sidenav.mjs.map +1 -0
  101. package/fesm2022/ids-group-ltd-ids-design-system-components-skeleton.mjs +32 -0
  102. package/fesm2022/ids-group-ltd-ids-design-system-components-skeleton.mjs.map +1 -0
  103. package/fesm2022/ids-group-ltd-ids-design-system-components-slider.mjs +204 -0
  104. package/fesm2022/ids-group-ltd-ids-design-system-components-slider.mjs.map +1 -0
  105. package/fesm2022/ids-group-ltd-ids-design-system-components-spinner.mjs +25 -0
  106. package/fesm2022/ids-group-ltd-ids-design-system-components-spinner.mjs.map +1 -0
  107. package/fesm2022/ids-group-ltd-ids-design-system-components-split-button.mjs +53 -0
  108. package/fesm2022/ids-group-ltd-ids-design-system-components-split-button.mjs.map +1 -0
  109. package/fesm2022/ids-group-ltd-ids-design-system-components-stat.mjs +99 -0
  110. package/fesm2022/ids-group-ltd-ids-design-system-components-stat.mjs.map +1 -0
  111. package/fesm2022/ids-group-ltd-ids-design-system-components-status-dot.mjs +26 -0
  112. package/fesm2022/ids-group-ltd-ids-design-system-components-status-dot.mjs.map +1 -0
  113. package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs +74 -0
  114. package/fesm2022/ids-group-ltd-ids-design-system-components-stepper.mjs.map +1 -0
  115. package/fesm2022/ids-group-ltd-ids-design-system-components-switch.mjs +76 -0
  116. package/fesm2022/ids-group-ltd-ids-design-system-components-switch.mjs.map +1 -0
  117. package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs +1802 -0
  118. package/fesm2022/ids-group-ltd-ids-design-system-components-table.mjs.map +1 -0
  119. package/fesm2022/ids-group-ltd-ids-design-system-components-tabs.mjs +381 -0
  120. package/fesm2022/ids-group-ltd-ids-design-system-components-tabs.mjs.map +1 -0
  121. package/fesm2022/ids-group-ltd-ids-design-system-components-tag.mjs +44 -0
  122. package/fesm2022/ids-group-ltd-ids-design-system-components-tag.mjs.map +1 -0
  123. package/fesm2022/ids-group-ltd-ids-design-system-components-textarea.mjs +158 -0
  124. package/fesm2022/ids-group-ltd-ids-design-system-components-textarea.mjs.map +1 -0
  125. package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs +671 -0
  126. package/fesm2022/ids-group-ltd-ids-design-system-components-time-picker.mjs.map +1 -0
  127. package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs +41 -0
  128. package/fesm2022/ids-group-ltd-ids-design-system-components-timeline.mjs.map +1 -0
  129. package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs +547 -0
  130. package/fesm2022/ids-group-ltd-ids-design-system-components-toast.mjs.map +1 -0
  131. package/fesm2022/ids-group-ltd-ids-design-system-components-toggle-button.mjs +34 -0
  132. package/fesm2022/ids-group-ltd-ids-design-system-components-toggle-button.mjs.map +1 -0
  133. package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs +218 -0
  134. package/fesm2022/ids-group-ltd-ids-design-system-components-tooltip.mjs.map +1 -0
  135. package/fesm2022/ids-group-ltd-ids-design-system-components-topbar.mjs +18 -0
  136. package/fesm2022/ids-group-ltd-ids-design-system-components-topbar.mjs.map +1 -0
  137. package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs +153 -0
  138. package/fesm2022/ids-group-ltd-ids-design-system-components-tree.mjs.map +1 -0
  139. package/fesm2022/ids-group-ltd-ids-design-system-components-w3w.mjs +48 -0
  140. package/fesm2022/ids-group-ltd-ids-design-system-components-w3w.mjs.map +1 -0
  141. package/fesm2022/ids-group-ltd-ids-design-system-components.mjs +1338 -0
  142. package/fesm2022/ids-group-ltd-ids-design-system-components.mjs.map +1 -0
  143. package/fesm2022/ids-group-ltd-ids-design-system-core.mjs +325 -0
  144. package/fesm2022/ids-group-ltd-ids-design-system-core.mjs.map +1 -0
  145. package/fesm2022/ids-group-ltd-ids-design-system-icons.mjs +101 -0
  146. package/fesm2022/ids-group-ltd-ids-design-system-icons.mjs.map +1 -0
  147. package/fesm2022/ids-group-ltd-ids-design-system-overlay.mjs +56 -0
  148. package/fesm2022/ids-group-ltd-ids-design-system-overlay.mjs.map +1 -0
  149. package/fesm2022/ids-group-ltd-ids-design-system-theme.mjs +37 -0
  150. package/fesm2022/ids-group-ltd-ids-design-system-theme.mjs.map +1 -0
  151. package/fesm2022/ids-group-ltd-ids-design-system.mjs +72 -14267
  152. package/fesm2022/ids-group-ltd-ids-design-system.mjs.map +1 -1
  153. package/migrations/0.11.0.json +0 -2
  154. package/migrations/0.11.1.json +2 -1
  155. package/migrations/0.11.2.json +2 -1
  156. package/migrations/0.11.3.json +3 -2
  157. package/migrations/0.11.4.json +7 -1
  158. package/migrations/0.12.0.json +22 -0
  159. package/migrations/0.4.0.json +2 -1
  160. package/migrations/0.7.1.json +2 -1
  161. package/package.json +573 -1
  162. package/themes/README.md +4 -4
  163. package/types/ids-group-ltd-ids-design-system-components-accordion.d.ts +48 -0
  164. package/types/ids-group-ltd-ids-design-system-components-alert.d.ts +32 -0
  165. package/types/ids-group-ltd-ids-design-system-components-app-layout.d.ts +260 -0
  166. package/types/ids-group-ltd-ids-design-system-components-auth-layout.d.ts +75 -0
  167. package/types/ids-group-ltd-ids-design-system-components-autocomplete.d.ts +226 -0
  168. package/types/ids-group-ltd-ids-design-system-components-avatar-group.d.ts +13 -0
  169. package/types/ids-group-ltd-ids-design-system-components-avatar.d.ts +99 -0
  170. package/types/ids-group-ltd-ids-design-system-components-badge.d.ts +25 -0
  171. package/types/ids-group-ltd-ids-design-system-components-banner.d.ts +41 -0
  172. package/types/ids-group-ltd-ids-design-system-components-bottom-sheet.d.ts +61 -0
  173. package/types/ids-group-ltd-ids-design-system-components-breadcrumbs.d.ts +66 -0
  174. package/types/ids-group-ltd-ids-design-system-components-button-group.d.ts +10 -0
  175. package/types/ids-group-ltd-ids-design-system-components-button.d.ts +90 -0
  176. package/types/ids-group-ltd-ids-design-system-components-calendar-day.d.ts +41 -0
  177. package/types/ids-group-ltd-ids-design-system-components-card.d.ts +24 -0
  178. package/types/ids-group-ltd-ids-design-system-components-checkbox.d.ts +41 -0
  179. package/types/ids-group-ltd-ids-design-system-components-color-picker.d.ts +79 -0
  180. package/types/ids-group-ltd-ids-design-system-components-date-picker.d.ts +251 -0
  181. package/types/ids-group-ltd-ids-design-system-components-description-list.d.ts +25 -0
  182. package/types/ids-group-ltd-ids-design-system-components-divider.d.ts +22 -0
  183. package/types/ids-group-ltd-ids-design-system-components-drawer.d.ts +38 -0
  184. package/types/ids-group-ltd-ids-design-system-components-dropzone.d.ts +45 -0
  185. package/types/ids-group-ltd-ids-design-system-components-empty-state.d.ts +22 -0
  186. package/types/ids-group-ltd-ids-design-system-components-field-group.d.ts +73 -0
  187. package/types/ids-group-ltd-ids-design-system-components-field-message.d.ts +36 -0
  188. package/types/ids-group-ltd-ids-design-system-components-filter-bar.d.ts +83 -0
  189. package/types/ids-group-ltd-ids-design-system-components-icon-button.d.ts +56 -0
  190. package/types/ids-group-ltd-ids-design-system-components-input.d.ts +121 -0
  191. package/types/ids-group-ltd-ids-design-system-components-layout.d.ts +39 -0
  192. package/types/ids-group-ltd-ids-design-system-components-list.d.ts +29 -0
  193. package/types/ids-group-ltd-ids-design-system-components-loading-overlay.d.ts +31 -0
  194. package/types/ids-group-ltd-ids-design-system-components-menu.d.ts +82 -0
  195. package/types/ids-group-ltd-ids-design-system-components-modal.d.ts +124 -0
  196. package/types/ids-group-ltd-ids-design-system-components-multi-select.d.ts +213 -0
  197. package/types/ids-group-ltd-ids-design-system-components-number-stepper.d.ts +31 -0
  198. package/types/ids-group-ltd-ids-design-system-components-otp-input.d.ts +52 -0
  199. package/types/ids-group-ltd-ids-design-system-components-page-footer.d.ts +13 -0
  200. package/types/ids-group-ltd-ids-design-system-components-page-header.d.ts +21 -0
  201. package/types/ids-group-ltd-ids-design-system-components-pagination.d.ts +32 -0
  202. package/types/ids-group-ltd-ids-design-system-components-password-rules.d.ts +80 -0
  203. package/types/ids-group-ltd-ids-design-system-components-popover.d.ts +48 -0
  204. package/types/ids-group-ltd-ids-design-system-components-progress.d.ts +22 -0
  205. package/types/ids-group-ltd-ids-design-system-components-radio-group.d.ts +106 -0
  206. package/types/ids-group-ltd-ids-design-system-components-reserve-messages.d.ts +33 -0
  207. package/types/ids-group-ltd-ids-design-system-components-search.d.ts +82 -0
  208. package/types/ids-group-ltd-ids-design-system-components-segmented.d.ts +40 -0
  209. package/types/ids-group-ltd-ids-design-system-components-select.d.ts +152 -0
  210. package/types/ids-group-ltd-ids-design-system-components-sidenav-footer.d.ts +92 -0
  211. package/types/ids-group-ltd-ids-design-system-components-sidenav.d.ts +131 -0
  212. package/types/ids-group-ltd-ids-design-system-components-skeleton.d.ts +16 -0
  213. package/types/ids-group-ltd-ids-design-system-components-slider.d.ts +51 -0
  214. package/types/ids-group-ltd-ids-design-system-components-spinner.d.ts +11 -0
  215. package/types/ids-group-ltd-ids-design-system-components-split-button.d.ts +38 -0
  216. package/types/ids-group-ltd-ids-design-system-components-stat.d.ts +44 -0
  217. package/types/ids-group-ltd-ids-design-system-components-status-dot.d.ts +12 -0
  218. package/types/ids-group-ltd-ids-design-system-components-stepper.d.ts +32 -0
  219. package/types/ids-group-ltd-ids-design-system-components-switch.d.ts +40 -0
  220. package/types/ids-group-ltd-ids-design-system-components-table.d.ts +791 -0
  221. package/types/ids-group-ltd-ids-design-system-components-tabs.d.ts +118 -0
  222. package/types/ids-group-ltd-ids-design-system-components-tag.d.ts +26 -0
  223. package/types/ids-group-ltd-ids-design-system-components-textarea.d.ts +85 -0
  224. package/types/ids-group-ltd-ids-design-system-components-time-picker.d.ts +188 -0
  225. package/types/ids-group-ltd-ids-design-system-components-timeline.d.ts +24 -0
  226. package/types/ids-group-ltd-ids-design-system-components-toast.d.ts +167 -0
  227. package/types/ids-group-ltd-ids-design-system-components-toggle-button.d.ts +18 -0
  228. package/types/ids-group-ltd-ids-design-system-components-tooltip.d.ts +66 -0
  229. package/types/ids-group-ltd-ids-design-system-components-topbar.d.ts +8 -0
  230. package/types/ids-group-ltd-ids-design-system-components-tree.d.ts +46 -0
  231. package/types/ids-group-ltd-ids-design-system-components-w3w.d.ts +18 -0
  232. package/types/ids-group-ltd-ids-design-system-components.d.ts +604 -0
  233. package/types/ids-group-ltd-ids-design-system-core.d.ts +428 -0
  234. package/types/ids-group-ltd-ids-design-system-icons.d.ts +52 -0
  235. package/types/ids-group-ltd-ids-design-system-overlay.d.ts +32 -0
  236. package/types/ids-group-ltd-ids-design-system-theme.d.ts +29 -0
  237. package/types/ids-group-ltd-ids-design-system.d.ts +72 -5594
  238. package/LICENSE +0 -21
  239. package/README.md +0 -73
@@ -0,0 +1,547 @@
1
+ import * as i0 from '@angular/core';
2
+ import { input, booleanAttribute, output, computed, ViewEncapsulation, Component, signal, inject, ElementRef, effect, DestroyRef, Injectable } from '@angular/core';
3
+ import { Overlay } from '@angular/cdk/overlay';
4
+ import { ComponentPortal } from '@angular/cdk/portal';
5
+ import { LiveAnnouncer } from '@angular/cdk/a11y';
6
+ import { DS_CONFIG, devWarn } from '@ids-group-ltd/ids-design-system/core';
7
+ import { IconComponent } from '@ids-group-ltd/ids-design-system/icons';
8
+ import { SpinnerComponent } from '@ids-group-ltd/ids-design-system/components/spinner';
9
+
10
+ const DS_TOAST_POSITION_DEFAULT = {
11
+ horizontalPosition: 'right',
12
+ verticalPosition: 'top',
13
+ offset: 'var(--space-6)',
14
+ };
15
+
16
+ /**
17
+ * Single toast pill. Consumed by ToastRegion for service-driven runtime toasts
18
+ * AND by static showcases that need to display a toast specimen inline.
19
+ */
20
+ class ToastComponent {
21
+ /** Severity — drives colour and the default icon or spinner. */
22
+ variant = input('info', ...(ngDevMode ? [{ debugName: "variant" }] : /* istanbul ignore next */ []));
23
+ /** Optional bold heading above the message. */
24
+ title = input('', ...(ngDevMode ? [{ debugName: "title" }] : /* istanbul ignore next */ []));
25
+ /** The same field `ToastOptions.body` carries, so a specimen and a raised toast agree. */
26
+ body = input('', ...(ngDevMode ? [{ debugName: "body" }] : /* istanbul ignore next */ []));
27
+ /** Show a close button that emits `closed`. */
28
+ dismissible = input(false, { ...(ngDevMode ? { debugName: "dismissible" } : /* istanbul ignore next */ {}), transform: booleanAttribute });
29
+ /** Override the variant's default icon. */
30
+ icon = input(null, ...(ngDevMode ? [{ debugName: "icon" }] : /* istanbul ignore next */ []));
31
+ /** Optional action button rendered before the dismiss control. */
32
+ action = input(null, ...(ngDevMode ? [{ debugName: "action" }] : /* istanbul ignore next */ []));
33
+ /** Fires when the toast is dismissed or its action is invoked. */
34
+ closed = output();
35
+ isLoading = computed(() => this.variant() === 'loading', ...(ngDevMode ? [{ debugName: "isLoading" }] : /* istanbul ignore next */ []));
36
+ onAction(action) {
37
+ action.handler();
38
+ this.closed.emit();
39
+ }
40
+ classes = computed(() => `toast ${this.variant()}`, ...(ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []));
41
+ defaultIcon = computed(() => {
42
+ switch (this.variant()) {
43
+ case 'success':
44
+ return 'success';
45
+ case 'warning':
46
+ return 'warn';
47
+ case 'error':
48
+ return 'error';
49
+ default:
50
+ return 'info';
51
+ }
52
+ }, ...(ngDevMode ? [{ debugName: "defaultIcon" }] : /* istanbul ignore next */ []));
53
+ onDismiss() {
54
+ this.closed.emit();
55
+ }
56
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
57
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastComponent, isStandalone: true, selector: "ds-toast", inputs: { variant: { classPropertyName: "variant", publicName: "variant", isSignal: true, isRequired: false, transformFunction: null }, title: { classPropertyName: "title", publicName: "title", isSignal: true, isRequired: false, transformFunction: null }, body: { classPropertyName: "body", publicName: "body", isSignal: true, isRequired: false, transformFunction: null }, dismissible: { classPropertyName: "dismissible", publicName: "dismissible", isSignal: true, isRequired: false, transformFunction: null }, icon: { classPropertyName: "icon", publicName: "icon", isSignal: true, isRequired: false, transformFunction: null }, action: { classPropertyName: "action", publicName: "action", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { closed: "closed" }, ngImport: i0, template: "<!-- No role or aria-live: a region created with its text already in it announces\n nothing, so ToastService speaks through the CDK LiveAnnouncer. A hand-placed\n <ds-toast> is therefore silent to a reader \u2014 it is a specimen, not an event. -->\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\"\n />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\"\n />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n </div>\n }\n {{ body() }}\n <ng-content></ng-content>\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\"\n >\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n aria-label=\"Dismiss\"\n (click)=\"onDismiss()\"\n >\n <ds-icon\n name=\"x\"\n [size]=\"14\"\n />\n </button>\n }\n</div>\n", styles: ["@charset \"UTF-8\";:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;transform:translateY(calc(var(--space-2) * -1));pointer-events:none;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-leave-duration) var(--_toast-leave-easing)}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}.toast{--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay));--_toast-border: var(--ds-toast-border-color, var(--border-default));--_toast-focus-shadow: var(--ds-toast-focus-shadow, var(--ds-control-focus-shadow));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-slide-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .close{border:0;background:transparent;color:var(--icon-default);cursor:pointer;padding:var(--space-0-5)}.toast .close:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:focus-visible{outline:none;box-shadow:var(--_toast-focus-shadow)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"], dependencies: [{ kind: "component", type: IconComponent, selector: "ds-icon", inputs: ["name", "size", "stroke", "ariaLabel"] }, { kind: "component", type: SpinnerComponent, selector: "ds-spinner", inputs: ["size"] }] });
58
+ }
59
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastComponent, decorators: [{
60
+ type: Component,
61
+ args: [{ selector: 'ds-toast', standalone: true, imports: [IconComponent, SpinnerComponent], encapsulation: ViewEncapsulation.Emulated, template: "<!-- No role or aria-live: a region created with its text already in it announces\n nothing, so ToastService speaks through the CDK LiveAnnouncer. A hand-placed\n <ds-toast> is therefore silent to a reader \u2014 it is a specimen, not an event. -->\n<div [class]=\"classes()\">\n @if (isLoading()) {\n <!-- aria-hidden because ds-spinner is a role=\"status\" of its own: the message is\n announced by ToastService, and a nested live region would speak twice. -->\n <ds-spinner\n class=\"icon\"\n size=\"sm\"\n aria-hidden=\"true\"\n />\n } @else {\n <ds-icon\n class=\"icon\"\n [name]=\"icon() ?? defaultIcon()\"\n [size]=\"16\"\n />\n }\n\n <div class=\"body\">\n @if (title()) {\n <div class=\"title\">\n {{ title() }}\n </div>\n }\n {{ body() }}\n <ng-content></ng-content>\n </div>\n\n @if (action(); as act) {\n <button\n type=\"button\"\n class=\"action\"\n (click)=\"onAction(act)\"\n >\n {{ act.label }}\n </button>\n }\n\n <span class=\"actions\">\n <ng-content select=\"[actions]\"></ng-content>\n </span>\n\n @if (dismissible()) {\n <button\n type=\"button\"\n class=\"close\"\n aria-label=\"Dismiss\"\n (click)=\"onDismiss()\"\n >\n <ds-icon\n name=\"x\"\n [size]=\"14\"\n />\n </button>\n }\n</div>\n", styles: ["@charset \"UTF-8\";:host{--_toast-leave-duration: var(--ds-toast-leave-duration, var(--duration-base));--_toast-leave-easing: var(--ds-toast-leave-easing, var(--ease-standard));--_toast-shift-duration: var(--ds-toast-shift-duration, var(--duration-fast));--_toast-shift-easing: var(--ds-toast-shift-easing, var(--ease-standard));display:block;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-shift-duration) var(--_toast-shift-easing)}:host(.leaving){opacity:0;transform:translateY(calc(var(--space-2) * -1));pointer-events:none;transition:opacity var(--_toast-leave-duration) var(--_toast-leave-easing),transform var(--_toast-leave-duration) var(--_toast-leave-easing)}:host(.shifting){transform:translateY(var(--_toast-shift, 0));transition:none}.toast{--_toast-bg-color: var(--ds-toast-bg-color, var(--surface-overlay));--_toast-border: var(--ds-toast-border-color, var(--border-default));--_toast-focus-shadow: var(--ds-toast-focus-shadow, var(--ds-control-focus-shadow));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));--_toast-enter-keyframes: var(--ds-toast-enter-keyframes, ds-slide-in);--_toast-enter-duration: var(--ds-toast-enter-duration, var(--ds-motion-enter-large-duration));--_toast-enter-easing: var(--ds-toast-enter-easing, var(--ds-motion-enter-large-easing));--_toast-enter-offset: var(--ds-toast-enter-offset, var(--space-2));--_toast-min-width: var(--ds-toast-min-width, var(--toast-minw));--_toast-max-width: var(--ds-toast-max-width, var(--toast-maxw));--_ds-enter-y: var(--_toast-enter-offset);--_ds-enter-scale: var(--ds-toast-enter-scale, .96);display:flex;align-items:flex-start;gap:var(--space-3);background-color:var(--_toast-bg-color);border:var(--border-width-default) solid var(--_toast-border);border-left:var(--toast-bar-w) solid var(--_toast-bar-color);border-radius:var(--radius-lg);padding:var(--space-3) var(--space-4);box-shadow:var(--shadow-toast);min-width:var(--_toast-min-width);max-width:var(--_toast-max-width);animation-name:var(--_toast-enter-keyframes);animation-duration:var(--_toast-enter-duration);animation-timing-function:var(--_toast-enter-easing)}@media(prefers-reduced-motion:reduce){.toast{--_toast-enter-duration: 0ms}}.toast .icon{color:var(--_toast-icon-color);flex-shrink:0;align-self:center}.toast .body{flex:1;min-width:0;overflow-wrap:anywhere;font:var(--font-weight-regular) var(--font-size-s)/var(--line-height-base) var(--font-sans);color:var(--text-secondary)}.toast .title{font-weight:var(--font-weight-bold);color:var(--text-primary);margin-bottom:var(--space-0-5)}.toast .close{border:0;background:transparent;color:var(--icon-default);cursor:pointer;padding:var(--space-0-5)}.toast .close:active:not(:disabled,[disabled],.is-disabled){filter:brightness(var(--ds-press-brightness, .9));transform:scale(var(--ds-press-scale, .97))}.toast .action{flex-shrink:0;align-self:center;border:0;background:transparent;color:var(--accent-strong);font:var(--font-weight-bold) var(--font-size-s)/var(--line-height-flat) var(--font-sans);cursor:pointer;padding:var(--space-1) var(--space-2);border-radius:var(--ds-radius-inner)}.toast .action:hover{background:var(--surface-secondary)}.toast .action:focus-visible{outline:none;box-shadow:var(--_toast-focus-shadow)}.toast .actions{display:inline-flex;align-items:center;gap:var(--space-2);flex-shrink:0}.toast .actions:empty{display:none}.toast.info{--_toast-bg-color: var(--ds-toast-bg-color-info, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-info, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--accent));--_toast-icon-color: var(--ds-toast-icon-color, var(--accent));border-left-color:var(--_toast-bar-color)}.toast.success{--_toast-bg-color: var(--ds-toast-bg-color-success, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-success, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--success));--_toast-icon-color: var(--ds-toast-icon-color, var(--success));border-left-color:var(--_toast-bar-color)}.toast.success .icon{color:var(--_toast-icon-color)}.toast.warning{--_toast-bg-color: var(--ds-toast-bg-color-warning, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-warning, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--warning-hover));--_toast-icon-color: var(--ds-toast-icon-color, var(--warning-hover));border-left-color:var(--_toast-bar-color)}.toast.warning .icon{color:var(--_toast-icon-color)}.toast.error{--_toast-bg-color: var(--ds-toast-bg-color-error, var(--ds-toast-bg-color, var(--surface-overlay)));--_toast-border: var(--ds-toast-border-color-error, var(--ds-toast-border-color, var(--border-default)));--_toast-bar-color: var(--ds-toast-bar-color, var(--error));--_toast-icon-color: var(--ds-toast-icon-color, var(--error));border-left-color:var(--_toast-bar-color)}.toast.error .icon{color:var(--_toast-icon-color)}.toast.loading{border-left-color:var(--accent)}.toast.loading .icon{color:var(--accent)}\n"] }]
62
+ }], propDecorators: { variant: [{ type: i0.Input, args: [{ isSignal: true, alias: "variant", required: false }] }], title: [{ type: i0.Input, args: [{ isSignal: true, alias: "title", required: false }] }], body: [{ type: i0.Input, args: [{ isSignal: true, alias: "body", required: false }] }], dismissible: [{ type: i0.Input, args: [{ isSignal: true, alias: "dismissible", required: false }] }], icon: [{ type: i0.Input, args: [{ isSignal: true, alias: "icon", required: false }] }], action: [{ type: i0.Input, args: [{ isSignal: true, alias: "action", required: false }] }], closed: [{ type: i0.Output, args: ["closed"] }] } });
63
+
64
+ // Only the floor: see leaveDuration(), which reads the real length off the node.
65
+ const LEAVE_FALLBACK_MS = 180;
66
+ // A toast whose clock ran out while the pointer was over it should not vanish the
67
+ // instant the pointer leaves — the reader gets this much to see it go.
68
+ const MIN_RESUME_MS = 600;
69
+ const DEFAULT_MAX_VISIBLE = 5;
70
+ class ToastRegionComponent {
71
+ /** Cap on concurrently visible toasts. Extras are queued and shown as
72
+ * earlier ones dismiss. `0` = unlimited. */
73
+ maxVisible = input(DEFAULT_MAX_VISIBLE, ...(ngDevMode ? [{ debugName: "maxVisible" }] : /* istanbul ignore next */ []));
74
+ visibleEntries = signal([], ...(ngDevMode ? [{ debugName: "visibleEntries" }] : /* istanbul ignore next */ []));
75
+ leaving = signal(new Set(), ...(ngDevMode ? [{ debugName: "leaving" }] : /* istanbul ignore next */ []));
76
+ pendingQueue = [];
77
+ timers = new Map();
78
+ leaveTimers = new Map();
79
+ remaining = new Map();
80
+ startedAt = new Map();
81
+ hovered = false;
82
+ focusWithin = false;
83
+ host = inject(ElementRef);
84
+ position = inject(DS_CONFIG).toast?.position;
85
+ constructor() {
86
+ devWarn(() => this.maxVisible() < 0
87
+ ? `<ds-toast-region> maxVisible is ${this.maxVisible()}; a negative cap means unlimited, which is what 0 says. Pass 0 if that is the intent.`
88
+ : null);
89
+ effect(() => {
90
+ this.maxVisible();
91
+ this.drainQueue();
92
+ });
93
+ // An uncancelled timer fires into a destroyed component: invisible in an app that
94
+ // never tears the root down, a stream of "N timers still in the queue" under fakeAsync.
95
+ inject(DestroyRef).onDestroy(() => {
96
+ this.timers.forEach((timer) => window.clearTimeout(timer));
97
+ this.leaveTimers.forEach((timer) => window.clearTimeout(timer));
98
+ this.timers.clear();
99
+ this.leaveTimers.clear();
100
+ });
101
+ }
102
+ /** Newest goes NEAREST the anchor, so the toast that just fired appears where the
103
+ * stack is pinned rather than at the far end of a list the reader has to hunt
104
+ * down. DOM order is the visual order, so this also keeps the reading order. */
105
+ newestFirst = (this.position?.verticalPosition ??
106
+ DS_TOAST_POSITION_DEFAULT.verticalPosition) === 'top';
107
+ add(entry) {
108
+ const limit = this.maxVisible();
109
+ if (limit > 0 && this.visibleEntries().length >= limit) {
110
+ this.pendingQueue.push(entry);
111
+ return;
112
+ }
113
+ this.show(entry);
114
+ }
115
+ show(entry) {
116
+ const before = this.measureTops();
117
+ this.visibleEntries.update((existing) => this.newestFirst ? [entry, ...existing] : [...existing, entry]);
118
+ this.arm(entry.id, entry.durationMs);
119
+ this.slideNeighbours(before);
120
+ }
121
+ /** FLIP, rather than the usual absolute stack: absolute positioning collapses the region
122
+ * to zero height, and it lives in a CDK pane sized to its content, so the hit area goes
123
+ * with it. */
124
+ slideNeighbours(before) {
125
+ if (!before.size) {
126
+ return;
127
+ }
128
+ requestAnimationFrame(() => {
129
+ const nodes = this.toastNodes();
130
+ const deltas = [];
131
+ for (const [id, node] of nodes) {
132
+ const previousTop = before.get(id);
133
+ if (previousTop === undefined) {
134
+ continue;
135
+ }
136
+ const delta = previousTop - node.getBoundingClientRect().top;
137
+ if (delta) {
138
+ deltas.push([node, delta]);
139
+ }
140
+ }
141
+ for (const [node, delta] of deltas) {
142
+ node.style.setProperty('--_toast-shift', `${delta}px`);
143
+ node.classList.add('shifting');
144
+ }
145
+ requestAnimationFrame(() => {
146
+ for (const [node] of deltas) {
147
+ node.classList.remove('shifting');
148
+ node.style.removeProperty('--_toast-shift');
149
+ }
150
+ });
151
+ });
152
+ }
153
+ toastNodes() {
154
+ const nodes = new Map();
155
+ const elements = this.host.nativeElement.querySelectorAll('ds-toast');
156
+ this.visibleEntries().forEach((entry, index) => {
157
+ const node = elements[index];
158
+ if (node) {
159
+ nodes.set(entry.id, node);
160
+ }
161
+ });
162
+ return nodes;
163
+ }
164
+ measureTops() {
165
+ const tops = new Map();
166
+ for (const [id, node] of this.toastNodes()) {
167
+ tops.set(id, node.getBoundingClientRect().top);
168
+ }
169
+ return tops;
170
+ }
171
+ arm(id, remaining) {
172
+ if (remaining <= 0) {
173
+ return;
174
+ }
175
+ this.remaining.set(id, remaining);
176
+ // A toast can be armed with no user event anywhere near it — drainQueue runs from a
177
+ // timeout — so this has to bank rather than trust that a pause event will follow.
178
+ if (this.hovered || this.focusWithin) {
179
+ this.startedAt.delete(id);
180
+ return;
181
+ }
182
+ this.startedAt.set(id, Date.now());
183
+ const existing = this.timers.get(id);
184
+ if (existing !== undefined) {
185
+ window.clearTimeout(existing);
186
+ }
187
+ this.timers.set(id, window.setTimeout(() => this.remove(id), remaining));
188
+ }
189
+ clearCountdown(id) {
190
+ const timer = this.timers.get(id);
191
+ if (timer !== undefined) {
192
+ window.clearTimeout(timer);
193
+ this.timers.delete(id);
194
+ }
195
+ this.remaining.delete(id);
196
+ this.startedAt.delete(id);
197
+ }
198
+ onHover(entered) {
199
+ this.hovered = entered;
200
+ this.syncPause();
201
+ }
202
+ // `focusout` bubbles, so it also fires when focus moves BETWEEN elements inside the region —
203
+ // tabbing from the action to the close button. Without the containment check that reads as
204
+ // leaving, and every round trip re-floors the remainder at MIN_RESUME_MS.
205
+ onFocusWithin(event) {
206
+ this.focusWithin =
207
+ event === true ||
208
+ (event.relatedTarget instanceof Node &&
209
+ this.host.nativeElement.contains(event.relatedTarget));
210
+ this.syncPause();
211
+ }
212
+ syncPause() {
213
+ const shouldPause = this.hovered || this.focusWithin;
214
+ if (shouldPause === this.paused) {
215
+ return;
216
+ }
217
+ if (shouldPause) {
218
+ this.pauseAll();
219
+ }
220
+ else {
221
+ this.resumeAll();
222
+ }
223
+ }
224
+ get paused() {
225
+ return this.timers.size === 0 && this.remaining.size > 0;
226
+ }
227
+ pauseAll() {
228
+ const now = Date.now();
229
+ for (const [id, timer] of this.timers) {
230
+ window.clearTimeout(timer);
231
+ const left = (this.remaining.get(id) ?? 0) - (now - (this.startedAt.get(id) ?? now));
232
+ this.remaining.set(id, Math.max(left, MIN_RESUME_MS));
233
+ }
234
+ this.timers.clear();
235
+ }
236
+ resumeAll() {
237
+ for (const [id, left] of [...this.remaining]) {
238
+ this.arm(id, left);
239
+ }
240
+ }
241
+ /** Replace fields of an already-visible or queued toast in place. Patching
242
+ * `durationMs` restarts the clock, and on a QUEUED toast it takes effect only on
243
+ * promotion — otherwise a duration would burn down while the toast is invisible. */
244
+ update(id, patch) {
245
+ const inVisible = this.visibleEntries().some((entry) => entry.id === id);
246
+ if (inVisible) {
247
+ this.visibleEntries.update((entries) => entries.map((entry) => entry.id === id ? { ...entry, ...patch } : entry));
248
+ if (patch.durationMs !== undefined) {
249
+ this.clearCountdown(id);
250
+ this.arm(id, patch.durationMs);
251
+ }
252
+ return;
253
+ }
254
+ const queueIndex = this.pendingQueue.findIndex((entry) => entry.id === id);
255
+ if (queueIndex !== -1) {
256
+ this.pendingQueue[queueIndex] = {
257
+ ...this.pendingQueue[queueIndex],
258
+ ...patch,
259
+ };
260
+ }
261
+ }
262
+ remove(id) {
263
+ // A `ToastRef` outlives its toast, so dismiss() can arrive for an id nothing holds.
264
+ const isVisible = this.visibleEntries().some((entry) => entry.id === id);
265
+ const queueIndex = this.pendingQueue.findIndex((entry) => entry.id === id);
266
+ if (!isVisible && queueIndex === -1) {
267
+ return;
268
+ }
269
+ this.clearCountdown(id);
270
+ if (queueIndex !== -1) {
271
+ this.pendingQueue.splice(queueIndex, 1);
272
+ return;
273
+ }
274
+ if (this.leaving().has(id)) {
275
+ return;
276
+ }
277
+ this.leaving.update((set) => new Set(set).add(id));
278
+ this.leaveTimers.set(id, window.setTimeout(() => {
279
+ this.leaveTimers.delete(id);
280
+ this.visibleEntries.update((existing) => existing.filter((entry) => entry.id !== id));
281
+ this.leaving.update((set) => {
282
+ const next = new Set(set);
283
+ next.delete(id);
284
+ return next;
285
+ });
286
+ this.drainQueue();
287
+ }, this.leaveDuration(id)));
288
+ }
289
+ /** The leave transition is a public token, so its length is whatever the consumer
290
+ * set — read it off the node rather than assuming. Reduced motion zeroes it, which
291
+ * is why the floor applies only when there is nothing to measure. */
292
+ leaveDuration(id) {
293
+ const node = this.toastNodes().get(id);
294
+ if (!node) {
295
+ return LEAVE_FALLBACK_MS;
296
+ }
297
+ const declared = getComputedStyle(node)
298
+ .transitionDuration.split(',')
299
+ .map((part) => parseFloat(part) * 1000)
300
+ .filter((ms) => !Number.isNaN(ms));
301
+ return declared.length ? Math.max(...declared) : LEAVE_FALLBACK_MS;
302
+ }
303
+ isLeaving(id) {
304
+ return this.leaving().has(id);
305
+ }
306
+ clear() {
307
+ this.timers.forEach((timer) => window.clearTimeout(timer));
308
+ this.leaveTimers.forEach((timer) => window.clearTimeout(timer));
309
+ this.timers.clear();
310
+ this.leaveTimers.clear();
311
+ this.remaining.clear();
312
+ this.startedAt.clear();
313
+ this.visibleEntries.set([]);
314
+ this.leaving.set(new Set());
315
+ this.pendingQueue.length = 0;
316
+ }
317
+ drainQueue() {
318
+ while (this.pendingQueue.length) {
319
+ const limit = this.maxVisible();
320
+ if (limit > 0 && this.visibleEntries().length >= limit) {
321
+ return;
322
+ }
323
+ this.show(this.pendingQueue.shift());
324
+ }
325
+ }
326
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastRegionComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
327
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.22", type: ToastRegionComponent, isStandalone: true, selector: "ds-toast-region", inputs: { maxVisible: { classPropertyName: "maxVisible", publicName: "maxVisible", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "role": "region", "aria-label": "Notifications" }, listeners: { "mouseenter": "onHover(true)", "mouseleave": "onHover(false)", "focusin": "onFocusWithin(true)", "focusout": "onFocusWithin($event)" } }, ngImport: i0, template: "@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\"\n />\n}\n", styles: ["@charset \"UTF-8\";:host{display:flex;flex-direction:column;gap:var(--space-2)}\n"], dependencies: [{ kind: "component", type: ToastComponent, selector: "ds-toast", inputs: ["variant", "title", "body", "dismissible", "icon", "action"], outputs: ["closed"] }] });
328
+ }
329
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastRegionComponent, decorators: [{
330
+ type: Component,
331
+ args: [{ selector: 'ds-toast-region', standalone: true, imports: [ToastComponent], encapsulation: ViewEncapsulation.Emulated, host: {
332
+ role: 'region',
333
+ 'aria-label': 'Notifications',
334
+ '(mouseenter)': 'onHover(true)',
335
+ '(mouseleave)': 'onHover(false)',
336
+ '(focusin)': 'onFocusWithin(true)',
337
+ '(focusout)': 'onFocusWithin($event)',
338
+ }, template: "@for (entry of visibleEntries(); track entry.id) {\n <ds-toast\n [variant]=\"entry.variant\"\n [title]=\"entry.title ?? ''\"\n [body]=\"entry.body\"\n [dismissible]=\"entry.dismissible\"\n [action]=\"entry.action ?? null\"\n [class.leaving]=\"isLeaving(entry.id)\"\n (closed)=\"remove(entry.id)\"\n />\n}\n", styles: ["@charset \"UTF-8\";:host{display:flex;flex-direction:column;gap:var(--space-2)}\n"] }]
339
+ }], ctorParameters: () => [], propDecorators: { maxVisible: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxVisible", required: false }] }] } });
340
+
341
+ // An error stays longer than a success: it usually needs reading, and often acting on.
342
+ const SETTLED_SUCCESS_MS = 4000;
343
+ const SETTLED_ERROR_MS = 6000;
344
+ // Has to outlast the loop that fires a burst, not any human interval.
345
+ const ANNOUNCE_COALESCE_MS = 120;
346
+ class ToastService {
347
+ overlay = inject(Overlay);
348
+ toastConfig = inject(DS_CONFIG).toast;
349
+ announcer = inject(LiveAnnouncer);
350
+ overlayRef = null;
351
+ regionRef = null;
352
+ nextId = 1;
353
+ pendingAnnouncements = [];
354
+ pendingAssertive = false;
355
+ announceTimer;
356
+ scrimWatcher = null;
357
+ constructor() {
358
+ inject(DestroyRef).onDestroy(() => {
359
+ clearTimeout(this.announceTimer);
360
+ this.scrimWatcher?.disconnect();
361
+ this.overlayRef?.dispose();
362
+ this.overlayRef = null;
363
+ this.regionRef = null;
364
+ });
365
+ }
366
+ show(opts) {
367
+ this.ensureRegion();
368
+ const id = this.nextId++;
369
+ const variant = opts.variant ?? 'info';
370
+ // An `action` toast cannot expire: that button is the only way to take the action,
371
+ // the region is the last child of `body`, and a keyboard user cannot cross a page
372
+ // to reach it inside five seconds.
373
+ const durationMs = variant === 'loading' || opts.action ? 0 : (opts.durationMs ?? 5000);
374
+ const entry = {
375
+ id,
376
+ title: opts.title,
377
+ body: opts.body,
378
+ variant,
379
+ // Nothing that cannot expire may also be unclosable, or it holds a slot for the
380
+ // life of the page — which is how a hung promise blocked the whole region.
381
+ dismissible: durationMs > 0 ? (opts.dismissible ?? true) : true,
382
+ action: opts.action,
383
+ durationMs,
384
+ };
385
+ // The region runs the countdown, because only it knows when the toast became
386
+ // visible — started here, one queued behind `maxVisible` expires unseen.
387
+ this.regionRef.instance.add(entry);
388
+ this.announce(variant, entry.body, entry.title);
389
+ return {
390
+ id,
391
+ dismiss: () => this.regionRef?.instance.remove(id),
392
+ };
393
+ }
394
+ /** Show a loading toast for the duration of `source`. Resolution and rejection are
395
+ * reflected in-place (same toast, no stack-up) as success/error variants, each with
396
+ * its own auto-dismiss delay.
397
+ *
398
+ * Returns `source` itself, so the caller still owns rejection handling — an
399
+ * un-`catch`ed call produces an unhandled rejection exactly as it would without a
400
+ * toast. */
401
+ promise(source, messages) {
402
+ const ref = this.show({
403
+ body: messages.loading,
404
+ variant: 'loading',
405
+ durationMs: 0,
406
+ });
407
+ // The duration goes to the region, for the reason given on `add()` above.
408
+ source.then((value) => {
409
+ const successBody = typeof messages.success === 'function'
410
+ ? messages.success(value)
411
+ : messages.success;
412
+ this.regionRef?.instance.update(ref.id, {
413
+ body: successBody,
414
+ variant: 'success',
415
+ dismissible: true,
416
+ durationMs: SETTLED_SUCCESS_MS,
417
+ });
418
+ this.announce('success', successBody);
419
+ }, (reason) => {
420
+ const errorBody = typeof messages.error === 'function'
421
+ ? messages.error(reason)
422
+ : messages.error;
423
+ this.regionRef?.instance.update(ref.id, {
424
+ body: errorBody,
425
+ variant: 'error',
426
+ dismissible: true,
427
+ durationMs: SETTLED_ERROR_MS,
428
+ });
429
+ this.announce('error', errorBody);
430
+ });
431
+ return source;
432
+ }
433
+ /** The announcement must NOT ride the visual toast: `aria-live` on an element created
434
+ * together with its text announces nothing in NVDA or JAWS. The CDK announcer's region
435
+ * exists from construction and only its text changes.
436
+ *
437
+ * Serialising a burst does not work either — `announce()` clears the region and writes
438
+ * on a timeout, resolving its promise inside that callback, so the next message wipes
439
+ * the previous one before anything can read it. One region change carrying every
440
+ * message is the only shape that survives. */
441
+ announce(variant, body, title) {
442
+ const spoken = [title, body].filter(Boolean).join('. ');
443
+ if (!spoken) {
444
+ return;
445
+ }
446
+ this.pendingAnnouncements.push(spoken);
447
+ if (variant === 'error' || variant === 'warning') {
448
+ this.pendingAssertive = true;
449
+ }
450
+ clearTimeout(this.announceTimer);
451
+ this.announceTimer = window.setTimeout(() => {
452
+ const message = this.pendingAnnouncements.join('. ');
453
+ const politeness = this.pendingAssertive ? 'assertive' : 'polite';
454
+ this.pendingAnnouncements = [];
455
+ this.pendingAssertive = false;
456
+ this.announcer.announce(message, politeness);
457
+ }, ANNOUNCE_COALESCE_MS);
458
+ }
459
+ dismissAll() {
460
+ this.regionRef?.instance.clear();
461
+ }
462
+ ensureRegion() {
463
+ if (this.overlayRef) {
464
+ return;
465
+ }
466
+ this.overlayRef = this.overlay.create({
467
+ hasBackdrop: false,
468
+ panelClass: 'ds-toast-panel',
469
+ positionStrategy: this.buildPositionStrategy(),
470
+ });
471
+ this.regionRef = this.overlayRef.attach(new ComponentPortal(ToastRegionComponent));
472
+ // `>= 0`, not truthiness: 0 is the only way to ask for an uncapped stack, so it has
473
+ // to reach the region rather than read as "unset".
474
+ const maxVisible = this.toastConfig?.maxVisible;
475
+ if (typeof maxVisible === 'number' && maxVisible >= 0) {
476
+ this.regionRef.setInput('maxVisible', maxVisible);
477
+ }
478
+ this.keepAboveScrims();
479
+ }
480
+ /** Keeps the toast above a scrim opened AFTER it. `--layer-toast` cannot: CDK gives
481
+ * every overlay host `popover="manual"`, and the browser's top layer paints in the
482
+ * order things were shown, ignoring z-index. Re-showing the host is the only lever.
483
+ *
484
+ * Scrimmed overlays only: the published layer scale puts `--layer-tooltip` above the
485
+ * toast. */
486
+ keepAboveScrims() {
487
+ const host = this.overlayRef?.hostElement;
488
+ const container = host?.parentElement;
489
+ if (!host || !container || typeof host.showPopover !== 'function') {
490
+ return;
491
+ }
492
+ this.scrimWatcher = new MutationObserver((records) => {
493
+ const scrimAppeared = records.some((record) => [...record.addedNodes].some((node) => node instanceof HTMLElement &&
494
+ node !== host &&
495
+ (node.classList.contains('cdk-overlay-backdrop') ||
496
+ node.querySelector?.('.cdk-overlay-backdrop'))));
497
+ if (!scrimAppeared || !host.isConnected) {
498
+ return;
499
+ }
500
+ // The top layer has no "raise"; nothing paints between these two calls.
501
+ try {
502
+ host.hidePopover();
503
+ host.showPopover();
504
+ }
505
+ catch {
506
+ // The host may not be showing, and hidePopover() throws when it is not.
507
+ }
508
+ });
509
+ this.scrimWatcher.observe(container, { childList: true, subtree: true });
510
+ }
511
+ buildPositionStrategy() {
512
+ const config = {
513
+ ...DS_TOAST_POSITION_DEFAULT,
514
+ ...this.toastConfig?.position,
515
+ };
516
+ const strategy = this.overlay.position().global();
517
+ if (config.verticalPosition === 'top') {
518
+ strategy.top(config.offset);
519
+ }
520
+ else {
521
+ strategy.bottom(config.offset);
522
+ }
523
+ if (config.horizontalPosition === 'left') {
524
+ strategy.left(config.offset);
525
+ }
526
+ else if (config.horizontalPosition === 'right') {
527
+ strategy.right(config.offset);
528
+ }
529
+ else {
530
+ strategy.centerHorizontally();
531
+ }
532
+ return strategy;
533
+ }
534
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
535
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastService, providedIn: 'root' });
536
+ }
537
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.22", ngImport: i0, type: ToastService, decorators: [{
538
+ type: Injectable,
539
+ args: [{ providedIn: 'root' }]
540
+ }], ctorParameters: () => [] });
541
+
542
+ /**
543
+ * Generated bundle index. Do not edit.
544
+ */
545
+
546
+ export { DS_TOAST_POSITION_DEFAULT, ToastComponent, ToastRegionComponent, ToastService };
547
+ //# sourceMappingURL=ids-group-ltd-ids-design-system-components-toast.mjs.map