@angular/material 20.0.0-next.0 → 20.0.0-next.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 (305) hide show
  1. package/autocomplete/index.d.ts +92 -126
  2. package/autocomplete/testing/index.d.ts +6 -11
  3. package/badge/index.d.ts +8 -112
  4. package/badge/testing/index.d.ts +7 -8
  5. package/badge.d-49a8a74b.d.ts +98 -0
  6. package/bottom-sheet/index.d.ts +88 -103
  7. package/bottom-sheet/testing/index.d.ts +4 -6
  8. package/button/index.d.ts +10 -245
  9. package/button/testing/index.d.ts +6 -10
  10. package/button-toggle/index.d.ts +12 -285
  11. package/button-toggle/testing/index.d.ts +38 -37
  12. package/button-toggle.d-edc8acff.d.ts +257 -0
  13. package/card/index.d.ts +80 -117
  14. package/card/testing/index.d.ts +11 -15
  15. package/checkbox/index.d.ts +43 -104
  16. package/checkbox/testing/index.d.ts +6 -10
  17. package/chips/index.d.ts +599 -693
  18. package/chips/testing/index.d.ts +78 -93
  19. package/common-module.d-0e6515ae.d.ts +43 -0
  20. package/core/index.d.ts +50 -979
  21. package/core/testing/index.d.ts +3 -65
  22. package/date-adapter.d-c6835d41.d.ts +267 -0
  23. package/date-range-input-harness.d-549a9f7e.d.ts +278 -0
  24. package/datepicker/index.d.ts +1332 -1482
  25. package/datepicker/testing/index.d.ts +5 -287
  26. package/dialog/index.d.ts +59 -453
  27. package/dialog/testing/index.d.ts +22 -26
  28. package/dialog.d-57867441.d.ts +335 -0
  29. package/divider/index.d.ts +6 -11
  30. package/divider/testing/index.d.ts +2 -16
  31. package/divider-harness.d-d34fede4.d.ts +14 -0
  32. package/error-options.d-448d9046.d.ts +17 -0
  33. package/expansion/index.d.ts +139 -190
  34. package/expansion/testing/index.d.ts +25 -31
  35. package/fesm2022/autocomplete/testing.mjs +2 -1
  36. package/fesm2022/autocomplete/testing.mjs.map +1 -1
  37. package/fesm2022/autocomplete.mjs +53 -32
  38. package/fesm2022/autocomplete.mjs.map +1 -1
  39. package/fesm2022/badge/testing.mjs.map +1 -1
  40. package/fesm2022/badge.mjs +14 -17
  41. package/fesm2022/badge.mjs.map +1 -1
  42. package/fesm2022/bottom-sheet/testing.mjs.map +1 -1
  43. package/fesm2022/bottom-sheet.mjs +13 -15
  44. package/fesm2022/bottom-sheet.mjs.map +1 -1
  45. package/fesm2022/button/testing.mjs.map +1 -1
  46. package/fesm2022/button-toggle/testing.mjs.map +1 -1
  47. package/fesm2022/button-toggle.mjs +22 -15
  48. package/fesm2022/button-toggle.mjs.map +1 -1
  49. package/fesm2022/button.mjs +14 -395
  50. package/fesm2022/button.mjs.map +1 -1
  51. package/fesm2022/card/testing.mjs.map +1 -1
  52. package/fesm2022/card.mjs +49 -51
  53. package/fesm2022/card.mjs.map +1 -1
  54. package/fesm2022/checkbox/testing.mjs.map +1 -1
  55. package/fesm2022/checkbox.mjs +32 -73
  56. package/fesm2022/checkbox.mjs.map +1 -1
  57. package/fesm2022/chips/testing.mjs.map +1 -1
  58. package/fesm2022/chips.mjs +51 -46
  59. package/fesm2022/chips.mjs.map +1 -1
  60. package/fesm2022/common-module-2d64df09.mjs +42 -0
  61. package/fesm2022/common-module-2d64df09.mjs.map +1 -0
  62. package/fesm2022/core/testing.mjs +3 -76
  63. package/fesm2022/core/testing.mjs.map +1 -1
  64. package/fesm2022/core.mjs +38 -1598
  65. package/fesm2022/core.mjs.map +1 -1
  66. package/fesm2022/date-formats-b618acb8.mjs +190 -0
  67. package/fesm2022/date-formats-b618acb8.mjs.map +1 -0
  68. package/fesm2022/date-range-input-harness-ee47cdb0.mjs +467 -0
  69. package/fesm2022/date-range-input-harness-ee47cdb0.mjs.map +1 -0
  70. package/fesm2022/datepicker/testing.mjs +5 -465
  71. package/fesm2022/datepicker/testing.mjs.map +1 -1
  72. package/fesm2022/datepicker.mjs +159 -128
  73. package/fesm2022/datepicker.mjs.map +1 -1
  74. package/fesm2022/dialog/testing.mjs +12 -1
  75. package/fesm2022/dialog/testing.mjs.map +1 -1
  76. package/fesm2022/dialog.mjs +14 -895
  77. package/fesm2022/dialog.mjs.map +1 -1
  78. package/fesm2022/divider/testing.mjs +2 -17
  79. package/fesm2022/divider/testing.mjs.map +1 -1
  80. package/fesm2022/divider-harness-3394f29a.mjs +18 -0
  81. package/fesm2022/divider-harness-3394f29a.mjs.map +1 -0
  82. package/fesm2022/divider.mjs +10 -12
  83. package/fesm2022/divider.mjs.map +1 -1
  84. package/fesm2022/error-options-4a00765e.mjs +29 -0
  85. package/fesm2022/error-options-4a00765e.mjs.map +1 -0
  86. package/fesm2022/error-state-8f4ce1af.mjs +37 -0
  87. package/fesm2022/error-state-8f4ce1af.mjs.map +1 -0
  88. package/fesm2022/expansion/testing.mjs.map +1 -1
  89. package/fesm2022/expansion.mjs +30 -32
  90. package/fesm2022/expansion.mjs.map +1 -1
  91. package/fesm2022/form-field/testing/control.mjs +2 -10
  92. package/fesm2022/form-field/testing/control.mjs.map +1 -1
  93. package/fesm2022/form-field/testing.mjs +7 -6
  94. package/fesm2022/form-field/testing.mjs.map +1 -1
  95. package/fesm2022/form-field-6d755764.mjs +1076 -0
  96. package/fesm2022/form-field-6d755764.mjs.map +1 -0
  97. package/fesm2022/form-field-control-harness-af6fd278.mjs +11 -0
  98. package/fesm2022/form-field-control-harness-af6fd278.mjs.map +1 -0
  99. package/fesm2022/form-field.mjs +14 -1110
  100. package/fesm2022/form-field.mjs.map +1 -1
  101. package/fesm2022/grid-list/testing.mjs +1 -1
  102. package/fesm2022/grid-list/testing.mjs.map +1 -1
  103. package/fesm2022/grid-list.mjs +30 -173
  104. package/fesm2022/grid-list.mjs.map +1 -1
  105. package/fesm2022/icon/testing.mjs +12 -12
  106. package/fesm2022/icon/testing.mjs.map +1 -1
  107. package/fesm2022/icon-button-47f1b5d9.mjs +248 -0
  108. package/fesm2022/icon-button-47f1b5d9.mjs.map +1 -0
  109. package/fesm2022/icon-module-3f77a24d.mjs +395 -0
  110. package/fesm2022/icon-module-3f77a24d.mjs.map +1 -0
  111. package/fesm2022/icon-registry-13a3b98e.mjs +639 -0
  112. package/fesm2022/icon-registry-13a3b98e.mjs.map +1 -0
  113. package/fesm2022/icon.mjs +11 -1016
  114. package/fesm2022/icon.mjs.map +1 -1
  115. package/fesm2022/index-1763d3a6.mjs +22 -0
  116. package/fesm2022/index-1763d3a6.mjs.map +1 -0
  117. package/fesm2022/index-4bc1d6d3.mjs +20 -0
  118. package/fesm2022/index-4bc1d6d3.mjs.map +1 -0
  119. package/fesm2022/input/testing.mjs +5 -113
  120. package/fesm2022/input/testing.mjs.map +1 -1
  121. package/fesm2022/input-harness-ed59decc.mjs +115 -0
  122. package/fesm2022/input-harness-ed59decc.mjs.map +1 -0
  123. package/fesm2022/input-value-accessor-8a79a24e.mjs +12 -0
  124. package/fesm2022/input-value-accessor-8a79a24e.mjs.map +1 -0
  125. package/fesm2022/input.mjs +21 -23
  126. package/fesm2022/input.mjs.map +1 -1
  127. package/fesm2022/internal-form-field-434c4039.mjs +27 -0
  128. package/fesm2022/internal-form-field-434c4039.mjs.map +1 -0
  129. package/fesm2022/line-d6afe347.mjs +59 -0
  130. package/fesm2022/line-d6afe347.mjs.map +1 -0
  131. package/fesm2022/list/testing.mjs +2 -2
  132. package/fesm2022/list/testing.mjs.map +1 -1
  133. package/fesm2022/list.mjs +59 -56
  134. package/fesm2022/list.mjs.map +1 -1
  135. package/fesm2022/menu/testing.mjs.map +1 -1
  136. package/fesm2022/menu.mjs +37 -25
  137. package/fesm2022/menu.mjs.map +1 -1
  138. package/fesm2022/module-3bf2775f.mjs +1293 -0
  139. package/fesm2022/module-3bf2775f.mjs.map +1 -0
  140. package/fesm2022/module-47e3be58.mjs +970 -0
  141. package/fesm2022/module-47e3be58.mjs.map +1 -0
  142. package/fesm2022/module-a5f9ab72.mjs +875 -0
  143. package/fesm2022/module-a5f9ab72.mjs.map +1 -0
  144. package/fesm2022/module-d757bba0.mjs +38 -0
  145. package/fesm2022/module-d757bba0.mjs.map +1 -0
  146. package/fesm2022/module-df9f7af3.mjs +152 -0
  147. package/fesm2022/module-df9f7af3.mjs.map +1 -0
  148. package/fesm2022/optgroup-harness-5e66b138.mjs +36 -0
  149. package/fesm2022/optgroup-harness-5e66b138.mjs.map +1 -0
  150. package/fesm2022/option-07c3c660.mjs +348 -0
  151. package/fesm2022/option-07c3c660.mjs.map +1 -0
  152. package/fesm2022/option-harness-3b7c1106.mjs +46 -0
  153. package/fesm2022/option-harness-3b7c1106.mjs.map +1 -0
  154. package/fesm2022/paginator/testing.mjs +4 -1
  155. package/fesm2022/paginator/testing.mjs.map +1 -1
  156. package/fesm2022/paginator.mjs +51 -21
  157. package/fesm2022/paginator.mjs.map +1 -1
  158. package/fesm2022/progress-bar/testing.mjs +0 -4
  159. package/fesm2022/progress-bar/testing.mjs.map +1 -1
  160. package/fesm2022/progress-bar.mjs +15 -13
  161. package/fesm2022/progress-bar.mjs.map +1 -1
  162. package/fesm2022/progress-spinner/testing.mjs +0 -4
  163. package/fesm2022/progress-spinner/testing.mjs.map +1 -1
  164. package/fesm2022/progress-spinner.mjs +15 -13
  165. package/fesm2022/progress-spinner.mjs.map +1 -1
  166. package/fesm2022/pseudo-checkbox-af5a4ea4.mjs +52 -0
  167. package/fesm2022/pseudo-checkbox-af5a4ea4.mjs.map +1 -0
  168. package/fesm2022/pseudo-checkbox-module-216fae38.mjs +20 -0
  169. package/fesm2022/pseudo-checkbox-module-216fae38.mjs.map +1 -0
  170. package/fesm2022/public-api-c5ab57f5.mjs +147 -0
  171. package/fesm2022/public-api-c5ab57f5.mjs.map +1 -0
  172. package/fesm2022/radio/testing.mjs.map +1 -1
  173. package/fesm2022/radio.mjs +23 -15
  174. package/fesm2022/radio.mjs.map +1 -1
  175. package/fesm2022/ripple-9939d1f5.mjs +639 -0
  176. package/fesm2022/ripple-9939d1f5.mjs.map +1 -0
  177. package/fesm2022/ripple-loader-f2078c66.mjs +165 -0
  178. package/fesm2022/ripple-loader-f2078c66.mjs.map +1 -0
  179. package/fesm2022/select/testing.mjs +5 -121
  180. package/fesm2022/select/testing.mjs.map +1 -1
  181. package/fesm2022/select-harness-8c55824d.mjs +123 -0
  182. package/fesm2022/select-harness-8c55824d.mjs.map +1 -0
  183. package/fesm2022/select.mjs +30 -1311
  184. package/fesm2022/select.mjs.map +1 -1
  185. package/fesm2022/sidenav/testing.mjs +1 -1
  186. package/fesm2022/sidenav/testing.mjs.map +1 -1
  187. package/fesm2022/sidenav.mjs +31 -31
  188. package/fesm2022/sidenav.mjs.map +1 -1
  189. package/fesm2022/slide-toggle/testing.mjs.map +1 -1
  190. package/fesm2022/slide-toggle.mjs +27 -75
  191. package/fesm2022/slide-toggle.mjs.map +1 -1
  192. package/fesm2022/slider/testing.mjs.map +1 -1
  193. package/fesm2022/slider.mjs +22 -21
  194. package/fesm2022/slider.mjs.map +1 -1
  195. package/fesm2022/snack-bar/testing.mjs.map +1 -1
  196. package/fesm2022/snack-bar.mjs +37 -29
  197. package/fesm2022/snack-bar.mjs.map +1 -1
  198. package/fesm2022/sort/testing.mjs.map +1 -1
  199. package/fesm2022/sort.mjs +26 -20
  200. package/fesm2022/sort.mjs.map +1 -1
  201. package/fesm2022/stepper/testing.mjs.map +1 -1
  202. package/fesm2022/stepper.mjs +52 -39
  203. package/fesm2022/stepper.mjs.map +1 -1
  204. package/fesm2022/structural-styles-d5ada3b3.mjs +18 -0
  205. package/fesm2022/structural-styles-d5ada3b3.mjs.map +1 -0
  206. package/fesm2022/table/testing.mjs.map +1 -1
  207. package/fesm2022/table.mjs +58 -60
  208. package/fesm2022/table.mjs.map +1 -1
  209. package/fesm2022/tabs/testing.mjs.map +1 -1
  210. package/fesm2022/tabs.mjs +54 -58
  211. package/fesm2022/tabs.mjs.map +1 -1
  212. package/fesm2022/timepicker/testing.mjs +1 -1
  213. package/fesm2022/timepicker/testing.mjs.map +1 -1
  214. package/fesm2022/timepicker.mjs +31 -24
  215. package/fesm2022/timepicker.mjs.map +1 -1
  216. package/fesm2022/toolbar/testing.mjs.map +1 -1
  217. package/fesm2022/toolbar.mjs +13 -15
  218. package/fesm2022/toolbar.mjs.map +1 -1
  219. package/fesm2022/tooltip/testing.mjs.map +1 -1
  220. package/fesm2022/tooltip.mjs +15 -960
  221. package/fesm2022/tooltip.mjs.map +1 -1
  222. package/fesm2022/tree/testing.mjs.map +1 -1
  223. package/fesm2022/tree.mjs +28 -30
  224. package/fesm2022/tree.mjs.map +1 -1
  225. package/form-field/index.d.ts +16 -508
  226. package/form-field/testing/control/index.d.ts +2 -10
  227. package/form-field/testing/index.d.ts +19 -24
  228. package/form-field-control-harness.d-2d91f25a.d.ts +10 -0
  229. package/form-field-control.d-eb86711c.d.ts +62 -0
  230. package/form-field.d-2edbc094.d.ts +367 -0
  231. package/grid-list/index.d.ts +128 -152
  232. package/grid-list/testing/index.d.ts +39 -44
  233. package/icon/index.d.ts +9 -470
  234. package/icon/testing/index.d.ts +41 -44
  235. package/icon-module.d-aa3bbba0.d.ts +167 -0
  236. package/icon-registry.d-1dffe9de.d.ts +286 -0
  237. package/index.d-0536b706.d.ts +11 -0
  238. package/index.d-37e31cd3.d.ts +13 -0
  239. package/index.d.ts +2 -3
  240. package/input/index.d.ts +33 -62
  241. package/input/testing/index.d.ts +13 -71
  242. package/input-harness.d-4eecd1d3.d.ts +60 -0
  243. package/line.d-570a2537.d.ts +25 -0
  244. package/list/index.d.ts +155 -244
  245. package/list/testing/index.d.ts +158 -180
  246. package/list-option-types.d-8739f903.d.ts +15 -0
  247. package/menu/index.d.ts +183 -231
  248. package/menu/testing/index.d.ts +17 -23
  249. package/module.d-18a67f56.d.ts +206 -0
  250. package/module.d-74a721b9.d.ts +326 -0
  251. package/module.d-ba05faa6.d.ts +448 -0
  252. package/module.d-c17c834e.d.ts +18 -0
  253. package/optgroup-harness.d-7f741f69.d.ts +31 -0
  254. package/option-harness.d-3d33fc9a.d.ts +34 -0
  255. package/option-parent.d-559ad5c5.d.ts +19 -0
  256. package/option.d-6f493d78.d.ts +146 -0
  257. package/package.json +2 -2
  258. package/paginator/index.d.ts +31 -216
  259. package/paginator/testing/index.d.ts +14 -15
  260. package/paginator.d-40b1766e.d.ts +199 -0
  261. package/palette.d-ec4a617c.d.ts +4 -0
  262. package/progress-bar/index.d.ts +40 -59
  263. package/progress-bar/testing/index.d.ts +7 -10
  264. package/progress-spinner/index.d.ts +8 -110
  265. package/progress-spinner/testing/index.d.ts +10 -11
  266. package/progress-spinner.d-1fc040c5.d.ts +96 -0
  267. package/pseudo-checkbox-module.d-3abc0461.d.ts +44 -0
  268. package/radio/index.d.ts +151 -170
  269. package/radio/testing/index.d.ts +61 -67
  270. package/ripple-loader.d-8aac2988.d.ts +48 -0
  271. package/ripple.d-2fb57d04.d.ts +255 -0
  272. package/schematics/ng-add/index.js +1 -1
  273. package/schematics/ng-add/index.mjs +1 -1
  274. package/schematics/ng-generate/theme-color/index_bundled.js +2 -2
  275. package/schematics/ng-generate/theme-color/schema.json +10 -0
  276. package/schematics/ng-update/index_bundled.js +31 -31
  277. package/select/index.d.ts +25 -505
  278. package/select/testing/index.d.ts +5 -67
  279. package/select-harness.d-7441a7ac.d.ts +63 -0
  280. package/sidenav/index.d.ts +49 -92
  281. package/sidenav/testing/index.d.ts +58 -63
  282. package/slide-toggle/index.d.ts +39 -110
  283. package/slide-toggle/testing/index.d.ts +17 -21
  284. package/slider/index.d.ts +281 -328
  285. package/slider/testing/index.d.ts +42 -47
  286. package/snack-bar/index.d.ts +152 -185
  287. package/snack-bar/testing/index.d.ts +7 -9
  288. package/sort/index.d.ts +61 -169
  289. package/sort/testing/index.d.ts +22 -25
  290. package/sort-direction.d-f4ce4649.d.ts +3 -0
  291. package/sort.d-c2b79a45.d.ts +87 -0
  292. package/stepper/index.d.ts +115 -167
  293. package/stepper/testing/index.d.ts +43 -52
  294. package/table/index.d.ts +97 -156
  295. package/table/testing/index.d.ts +64 -78
  296. package/tabs/index.d.ts +309 -383
  297. package/tabs/testing/index.d.ts +67 -76
  298. package/timepicker/index.d.ts +127 -160
  299. package/timepicker/testing/index.d.ts +20 -26
  300. package/toolbar/index.d.ts +15 -26
  301. package/toolbar/testing/index.d.ts +13 -16
  302. package/tooltip/index.d.ts +11 -355
  303. package/tooltip/testing/index.d.ts +7 -10
  304. package/tree/index.d.ts +117 -163
  305. package/tree/testing/index.d.ts +52 -58
package/fesm2022/icon.mjs CHANGED
@@ -1,1017 +1,12 @@
1
- import * as i0 from '@angular/core';
2
- import { SecurityContext, Injectable, Optional, Inject, SkipSelf, ErrorHandler, InjectionToken, inject, ElementRef, HostAttributeToken, booleanAttribute, Component, ViewEncapsulation, ChangeDetectionStrategy, Input, NgModule } from '@angular/core';
3
- import { MatCommonModule } from '@angular/material/core';
4
- import { DOCUMENT } from '@angular/common';
5
- import { of, throwError, forkJoin, Subscription } from 'rxjs';
6
- import { tap, map, catchError, finalize, share, take } from 'rxjs/operators';
7
- import * as i1 from '@angular/common/http';
8
- import { HttpClient } from '@angular/common/http';
9
- import * as i2 from '@angular/platform-browser';
10
- import { DomSanitizer } from '@angular/platform-browser';
11
-
12
- /**
13
- * The Trusted Types policy, or null if Trusted Types are not
14
- * enabled/supported, or undefined if the policy has not been created yet.
15
- */
16
- let policy;
17
- /**
18
- * Returns the Trusted Types policy, or null if Trusted Types are not
19
- * enabled/supported. The first call to this function will create the policy.
20
- */
21
- function getPolicy() {
22
- if (policy === undefined) {
23
- policy = null;
24
- if (typeof window !== 'undefined') {
25
- const ttWindow = window;
26
- if (ttWindow.trustedTypes !== undefined) {
27
- policy = ttWindow.trustedTypes.createPolicy('angular#components', {
28
- createHTML: (s) => s,
29
- });
30
- }
31
- }
32
- }
33
- return policy;
34
- }
35
- /**
36
- * Unsafely promote a string to a TrustedHTML, falling back to strings when
37
- * Trusted Types are not available.
38
- * @security This is a security-sensitive function; any use of this function
39
- * must go through security review. In particular, it must be assured that the
40
- * provided string will never cause an XSS vulnerability if used in a context
41
- * that will be interpreted as HTML by a browser, e.g. when assigning to
42
- * element.innerHTML.
43
- */
44
- function trustedHTMLFromString(html) {
45
- return getPolicy()?.createHTML(html) || html;
46
- }
47
-
48
- /**
49
- * Returns an exception to be thrown in the case when attempting to
50
- * load an icon with a name that cannot be found.
51
- * @docs-private
52
- */
53
- function getMatIconNameNotFoundError(iconName) {
54
- return Error(`Unable to find icon with the name "${iconName}"`);
55
- }
56
- /**
57
- * Returns an exception to be thrown when the consumer attempts to use
58
- * `<mat-icon>` without including @angular/common/http.
59
- * @docs-private
60
- */
61
- function getMatIconNoHttpProviderError() {
62
- return Error('Could not find HttpClient for use with Angular Material icons. ' +
63
- 'Please add provideHttpClient() to your providers.');
64
- }
65
- /**
66
- * Returns an exception to be thrown when a URL couldn't be sanitized.
67
- * @param url URL that was attempted to be sanitized.
68
- * @docs-private
69
- */
70
- function getMatIconFailedToSanitizeUrlError(url) {
71
- return Error(`The URL provided to MatIconRegistry was not trusted as a resource URL ` +
72
- `via Angular's DomSanitizer. Attempted URL was "${url}".`);
73
- }
74
- /**
75
- * Returns an exception to be thrown when a HTML string couldn't be sanitized.
76
- * @param literal HTML that was attempted to be sanitized.
77
- * @docs-private
78
- */
79
- function getMatIconFailedToSanitizeLiteralError(literal) {
80
- return Error(`The literal provided to MatIconRegistry was not trusted as safe HTML by ` +
81
- `Angular's DomSanitizer. Attempted literal was "${literal}".`);
82
- }
83
- /**
84
- * Configuration for an icon, including the URL and possibly the cached SVG element.
85
- * @docs-private
86
- */
87
- class SvgIconConfig {
88
- url;
89
- svgText;
90
- options;
91
- svgElement;
92
- constructor(url, svgText, options) {
93
- this.url = url;
94
- this.svgText = svgText;
95
- this.options = options;
96
- }
97
- }
98
- /**
99
- * Service to register and display icons used by the `<mat-icon>` component.
100
- * - Registers icon URLs by namespace and name.
101
- * - Registers icon set URLs by namespace.
102
- * - Registers aliases for CSS classes, for use with icon fonts.
103
- * - Loads icons from URLs and extracts individual icons from icon sets.
104
- */
105
- class MatIconRegistry {
106
- _httpClient;
107
- _sanitizer;
108
- _errorHandler;
109
- _document;
110
- /**
111
- * URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
112
- */
113
- _svgIconConfigs = new Map();
114
- /**
115
- * SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
116
- * Multiple icon sets can be registered under the same namespace.
117
- */
118
- _iconSetConfigs = new Map();
119
- /** Cache for icons loaded by direct URLs. */
120
- _cachedIconsByUrl = new Map();
121
- /** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
122
- _inProgressUrlFetches = new Map();
123
- /** Map from font identifiers to their CSS class names. Used for icon fonts. */
124
- _fontCssClassesByAlias = new Map();
125
- /** Registered icon resolver functions. */
126
- _resolvers = [];
127
- /**
128
- * The CSS classes to apply when an `<mat-icon>` component has no icon name, url, or font
129
- * specified. The default 'material-icons' value assumes that the material icon font has been
130
- * loaded as described at https://google.github.io/material-design-icons/#icon-font-for-the-web
131
- */
132
- _defaultFontSetClass = ['material-icons', 'mat-ligature-font'];
133
- constructor(_httpClient, _sanitizer, document, _errorHandler) {
134
- this._httpClient = _httpClient;
135
- this._sanitizer = _sanitizer;
136
- this._errorHandler = _errorHandler;
137
- this._document = document;
138
- }
139
- /**
140
- * Registers an icon by URL in the default namespace.
141
- * @param iconName Name under which the icon should be registered.
142
- * @param url
143
- */
144
- addSvgIcon(iconName, url, options) {
145
- return this.addSvgIconInNamespace('', iconName, url, options);
146
- }
147
- /**
148
- * Registers an icon using an HTML string in the default namespace.
149
- * @param iconName Name under which the icon should be registered.
150
- * @param literal SVG source of the icon.
151
- */
152
- addSvgIconLiteral(iconName, literal, options) {
153
- return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
154
- }
155
- /**
156
- * Registers an icon by URL in the specified namespace.
157
- * @param namespace Namespace in which the icon should be registered.
158
- * @param iconName Name under which the icon should be registered.
159
- * @param url
160
- */
161
- addSvgIconInNamespace(namespace, iconName, url, options) {
162
- return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, null, options));
163
- }
164
- /**
165
- * Registers an icon resolver function with the registry. The function will be invoked with the
166
- * name and namespace of an icon when the registry tries to resolve the URL from which to fetch
167
- * the icon. The resolver is expected to return a `SafeResourceUrl` that points to the icon,
168
- * an object with the icon URL and icon options, or `null` if the icon is not supported. Resolvers
169
- * will be invoked in the order in which they have been registered.
170
- * @param resolver Resolver function to be registered.
171
- */
172
- addSvgIconResolver(resolver) {
173
- this._resolvers.push(resolver);
174
- return this;
175
- }
176
- /**
177
- * Registers an icon using an HTML string in the specified namespace.
178
- * @param namespace Namespace in which the icon should be registered.
179
- * @param iconName Name under which the icon should be registered.
180
- * @param literal SVG source of the icon.
181
- */
182
- addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
183
- const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
184
- // TODO: add an ngDevMode check
185
- if (!cleanLiteral) {
186
- throw getMatIconFailedToSanitizeLiteralError(literal);
187
- }
188
- // Security: The literal is passed in as SafeHtml, and is thus trusted.
189
- const trustedLiteral = trustedHTMLFromString(cleanLiteral);
190
- return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig('', trustedLiteral, options));
191
- }
192
- /**
193
- * Registers an icon set by URL in the default namespace.
194
- * @param url
195
- */
196
- addSvgIconSet(url, options) {
197
- return this.addSvgIconSetInNamespace('', url, options);
198
- }
199
- /**
200
- * Registers an icon set using an HTML string in the default namespace.
201
- * @param literal SVG source of the icon set.
202
- */
203
- addSvgIconSetLiteral(literal, options) {
204
- return this.addSvgIconSetLiteralInNamespace('', literal, options);
205
- }
206
- /**
207
- * Registers an icon set by URL in the specified namespace.
208
- * @param namespace Namespace in which to register the icon set.
209
- * @param url
210
- */
211
- addSvgIconSetInNamespace(namespace, url, options) {
212
- return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, null, options));
213
- }
214
- /**
215
- * Registers an icon set using an HTML string in the specified namespace.
216
- * @param namespace Namespace in which to register the icon set.
217
- * @param literal SVG source of the icon set.
218
- */
219
- addSvgIconSetLiteralInNamespace(namespace, literal, options) {
220
- const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
221
- if (!cleanLiteral) {
222
- throw getMatIconFailedToSanitizeLiteralError(literal);
223
- }
224
- // Security: The literal is passed in as SafeHtml, and is thus trusted.
225
- const trustedLiteral = trustedHTMLFromString(cleanLiteral);
226
- return this._addSvgIconSetConfig(namespace, new SvgIconConfig('', trustedLiteral, options));
227
- }
228
- /**
229
- * Defines an alias for CSS class names to be used for icon fonts. Creating an matIcon
230
- * component with the alias as the fontSet input will cause the class name to be applied
231
- * to the `<mat-icon>` element.
232
- *
233
- * If the registered font is a ligature font, then don't forget to also include the special
234
- * class `mat-ligature-font` to allow the usage via attribute. So register like this:
235
- *
236
- * ```ts
237
- * iconRegistry.registerFontClassAlias('f1', 'font1 mat-ligature-font');
238
- * ```
239
- *
240
- * And use like this:
241
- *
242
- * ```html
243
- * <mat-icon fontSet="f1" fontIcon="home"></mat-icon>
244
- * ```
245
- *
246
- * @param alias Alias for the font.
247
- * @param classNames Class names override to be used instead of the alias.
248
- */
249
- registerFontClassAlias(alias, classNames = alias) {
250
- this._fontCssClassesByAlias.set(alias, classNames);
251
- return this;
252
- }
253
- /**
254
- * Returns the CSS class name associated with the alias by a previous call to
255
- * registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
256
- */
257
- classNameForFontAlias(alias) {
258
- return this._fontCssClassesByAlias.get(alias) || alias;
259
- }
260
- /**
261
- * Sets the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
262
- * have a fontSet input value, and is not loading an icon by name or URL.
263
- */
264
- setDefaultFontSetClass(...classNames) {
265
- this._defaultFontSetClass = classNames;
266
- return this;
267
- }
268
- /**
269
- * Returns the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
270
- * have a fontSet input value, and is not loading an icon by name or URL.
271
- */
272
- getDefaultFontSetClass() {
273
- return this._defaultFontSetClass;
274
- }
275
- /**
276
- * Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
277
- * The response from the URL may be cached so this will not always cause an HTTP request, but
278
- * the produced element will always be a new copy of the originally fetched icon. (That is,
279
- * it will not contain any modifications made to elements previously returned).
280
- *
281
- * @param safeUrl URL from which to fetch the SVG icon.
282
- */
283
- getSvgIconFromUrl(safeUrl) {
284
- const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
285
- if (!url) {
286
- throw getMatIconFailedToSanitizeUrlError(safeUrl);
287
- }
288
- const cachedIcon = this._cachedIconsByUrl.get(url);
289
- if (cachedIcon) {
290
- return of(cloneSvg(cachedIcon));
291
- }
292
- return this._loadSvgIconFromConfig(new SvgIconConfig(safeUrl, null)).pipe(tap(svg => this._cachedIconsByUrl.set(url, svg)), map(svg => cloneSvg(svg)));
293
- }
294
- /**
295
- * Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
296
- * and namespace. The icon must have been previously registered with addIcon or addIconSet;
297
- * if not, the Observable will throw an error.
298
- *
299
- * @param name Name of the icon to be retrieved.
300
- * @param namespace Namespace in which to look for the icon.
301
- */
302
- getNamedSvgIcon(name, namespace = '') {
303
- const key = iconKey(namespace, name);
304
- let config = this._svgIconConfigs.get(key);
305
- // Return (copy of) cached icon if possible.
306
- if (config) {
307
- return this._getSvgFromConfig(config);
308
- }
309
- // Otherwise try to resolve the config from one of the resolver functions.
310
- config = this._getIconConfigFromResolvers(namespace, name);
311
- if (config) {
312
- this._svgIconConfigs.set(key, config);
313
- return this._getSvgFromConfig(config);
314
- }
315
- // See if we have any icon sets registered for the namespace.
316
- const iconSetConfigs = this._iconSetConfigs.get(namespace);
317
- if (iconSetConfigs) {
318
- return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
319
- }
320
- return throwError(getMatIconNameNotFoundError(key));
321
- }
322
- ngOnDestroy() {
323
- this._resolvers = [];
324
- this._svgIconConfigs.clear();
325
- this._iconSetConfigs.clear();
326
- this._cachedIconsByUrl.clear();
327
- }
328
- /**
329
- * Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
330
- */
331
- _getSvgFromConfig(config) {
332
- if (config.svgText) {
333
- // We already have the SVG element for this icon, return a copy.
334
- return of(cloneSvg(this._svgElementFromConfig(config)));
335
- }
336
- else {
337
- // Fetch the icon from the config's URL, cache it, and return a copy.
338
- return this._loadSvgIconFromConfig(config).pipe(map(svg => cloneSvg(svg)));
339
- }
340
- }
341
- /**
342
- * Attempts to find an icon with the specified name in any of the SVG icon sets.
343
- * First searches the available cached icons for a nested element with a matching name, and
344
- * if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
345
- * that have not been cached, and searches again after all fetches are completed.
346
- * The returned Observable produces the SVG element if possible, and throws
347
- * an error if no icon with the specified name can be found.
348
- */
349
- _getSvgFromIconSetConfigs(name, iconSetConfigs) {
350
- // For all the icon set SVG elements we've fetched, see if any contain an icon with the
351
- // requested name.
352
- const namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
353
- if (namedIcon) {
354
- // We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
355
- // time anyway, there's probably not much advantage compared to just always extracting
356
- // it from the icon set.
357
- return of(namedIcon);
358
- }
359
- // Not found in any cached icon sets. If there are icon sets with URLs that we haven't
360
- // fetched, fetch them now and look for iconName in the results.
361
- const iconSetFetchRequests = iconSetConfigs
362
- .filter(iconSetConfig => !iconSetConfig.svgText)
363
- .map(iconSetConfig => {
364
- return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(catchError((err) => {
365
- const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
366
- // Swallow errors fetching individual URLs so the
367
- // combined Observable won't necessarily fail.
368
- const errorMessage = `Loading icon set URL: ${url} failed: ${err.message}`;
369
- this._errorHandler.handleError(new Error(errorMessage));
370
- return of(null);
371
- }));
372
- });
373
- // Fetch all the icon set URLs. When the requests complete, every IconSet should have a
374
- // cached SVG element (unless the request failed), and we can check again for the icon.
375
- return forkJoin(iconSetFetchRequests).pipe(map(() => {
376
- const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
377
- // TODO: add an ngDevMode check
378
- if (!foundIcon) {
379
- throw getMatIconNameNotFoundError(name);
380
- }
381
- return foundIcon;
382
- }));
383
- }
384
- /**
385
- * Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
386
- * tag matches the specified name. If found, copies the nested element to a new SVG element and
387
- * returns it. Returns null if no matching element is found.
388
- */
389
- _extractIconWithNameFromAnySet(iconName, iconSetConfigs) {
390
- // Iterate backwards, so icon sets added later have precedence.
391
- for (let i = iconSetConfigs.length - 1; i >= 0; i--) {
392
- const config = iconSetConfigs[i];
393
- // Parsing the icon set's text into an SVG element can be expensive. We can avoid some of
394
- // the parsing by doing a quick check using `indexOf` to see if there's any chance for the
395
- // icon to be in the set. This won't be 100% accurate, but it should help us avoid at least
396
- // some of the parsing.
397
- if (config.svgText && config.svgText.toString().indexOf(iconName) > -1) {
398
- const svg = this._svgElementFromConfig(config);
399
- const foundIcon = this._extractSvgIconFromSet(svg, iconName, config.options);
400
- if (foundIcon) {
401
- return foundIcon;
402
- }
403
- }
404
- }
405
- return null;
406
- }
407
- /**
408
- * Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
409
- * from it.
410
- */
411
- _loadSvgIconFromConfig(config) {
412
- return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)), map(() => this._svgElementFromConfig(config)));
413
- }
414
- /**
415
- * Loads the content of the icon set URL specified in the
416
- * SvgIconConfig and attaches it to the config.
417
- */
418
- _loadSvgIconSetFromConfig(config) {
419
- if (config.svgText) {
420
- return of(null);
421
- }
422
- return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)));
423
- }
424
- /**
425
- * Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
426
- * tag matches the specified name. If found, copies the nested element to a new SVG element and
427
- * returns it. Returns null if no matching element is found.
428
- */
429
- _extractSvgIconFromSet(iconSet, iconName, options) {
430
- // Use the `id="iconName"` syntax in order to escape special
431
- // characters in the ID (versus using the #iconName syntax).
432
- const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
433
- if (!iconSource) {
434
- return null;
435
- }
436
- // Clone the element and remove the ID to prevent multiple elements from being added
437
- // to the page with the same ID.
438
- const iconElement = iconSource.cloneNode(true);
439
- iconElement.removeAttribute('id');
440
- // If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
441
- // the content of a new <svg> node.
442
- if (iconElement.nodeName.toLowerCase() === 'svg') {
443
- return this._setSvgAttributes(iconElement, options);
444
- }
445
- // If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
446
- // that the same could be achieved by referring to it via <use href="#id">, however the <use>
447
- // tag is problematic on Firefox, because it needs to include the current page path.
448
- if (iconElement.nodeName.toLowerCase() === 'symbol') {
449
- return this._setSvgAttributes(this._toSvgElement(iconElement), options);
450
- }
451
- // createElement('SVG') doesn't work as expected; the DOM ends up with
452
- // the correct nodes, but the SVG content doesn't render. Instead we
453
- // have to create an empty SVG node using innerHTML and append its content.
454
- // Elements created using DOMParser.parseFromString have the same problem.
455
- // http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
456
- const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
457
- // Clone the node so we don't remove it from the parent icon set element.
458
- svg.appendChild(iconElement);
459
- return this._setSvgAttributes(svg, options);
460
- }
461
- /**
462
- * Creates a DOM element from the given SVG string.
463
- */
464
- _svgElementFromString(str) {
465
- const div = this._document.createElement('DIV');
466
- div.innerHTML = str;
467
- const svg = div.querySelector('svg');
468
- // TODO: add an ngDevMode check
469
- if (!svg) {
470
- throw Error('<svg> tag not found');
471
- }
472
- return svg;
473
- }
474
- /**
475
- * Converts an element into an SVG node by cloning all of its children.
476
- */
477
- _toSvgElement(element) {
478
- const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
479
- const attributes = element.attributes;
480
- // Copy over all the attributes from the `symbol` to the new SVG, except the id.
481
- for (let i = 0; i < attributes.length; i++) {
482
- const { name, value } = attributes[i];
483
- if (name !== 'id') {
484
- svg.setAttribute(name, value);
485
- }
486
- }
487
- for (let i = 0; i < element.childNodes.length; i++) {
488
- if (element.childNodes[i].nodeType === this._document.ELEMENT_NODE) {
489
- svg.appendChild(element.childNodes[i].cloneNode(true));
490
- }
491
- }
492
- return svg;
493
- }
494
- /**
495
- * Sets the default attributes for an SVG element to be used as an icon.
496
- */
497
- _setSvgAttributes(svg, options) {
498
- svg.setAttribute('fit', '');
499
- svg.setAttribute('height', '100%');
500
- svg.setAttribute('width', '100%');
501
- svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
502
- svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
503
- if (options && options.viewBox) {
504
- svg.setAttribute('viewBox', options.viewBox);
505
- }
506
- return svg;
507
- }
508
- /**
509
- * Returns an Observable which produces the string contents of the given icon. Results may be
510
- * cached, so future calls with the same URL may not cause another HTTP request.
511
- */
512
- _fetchIcon(iconConfig) {
513
- const { url: safeUrl, options } = iconConfig;
514
- const withCredentials = options?.withCredentials ?? false;
515
- if (!this._httpClient) {
516
- throw getMatIconNoHttpProviderError();
517
- }
518
- // TODO: add an ngDevMode check
519
- if (safeUrl == null) {
520
- throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
521
- }
522
- const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
523
- // TODO: add an ngDevMode check
524
- if (!url) {
525
- throw getMatIconFailedToSanitizeUrlError(safeUrl);
526
- }
527
- // Store in-progress fetches to avoid sending a duplicate request for a URL when there is
528
- // already a request in progress for that URL. It's necessary to call share() on the
529
- // Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
530
- const inProgressFetch = this._inProgressUrlFetches.get(url);
531
- if (inProgressFetch) {
532
- return inProgressFetch;
533
- }
534
- const req = this._httpClient.get(url, { responseType: 'text', withCredentials }).pipe(map(svg => {
535
- // Security: This SVG is fetched from a SafeResourceUrl, and is thus
536
- // trusted HTML.
537
- return trustedHTMLFromString(svg);
538
- }), finalize(() => this._inProgressUrlFetches.delete(url)), share());
539
- this._inProgressUrlFetches.set(url, req);
540
- return req;
541
- }
542
- /**
543
- * Registers an icon config by name in the specified namespace.
544
- * @param namespace Namespace in which to register the icon config.
545
- * @param iconName Name under which to register the config.
546
- * @param config Config to be registered.
547
- */
548
- _addSvgIconConfig(namespace, iconName, config) {
549
- this._svgIconConfigs.set(iconKey(namespace, iconName), config);
550
- return this;
551
- }
552
- /**
553
- * Registers an icon set config in the specified namespace.
554
- * @param namespace Namespace in which to register the icon config.
555
- * @param config Config to be registered.
556
- */
557
- _addSvgIconSetConfig(namespace, config) {
558
- const configNamespace = this._iconSetConfigs.get(namespace);
559
- if (configNamespace) {
560
- configNamespace.push(config);
561
- }
562
- else {
563
- this._iconSetConfigs.set(namespace, [config]);
564
- }
565
- return this;
566
- }
567
- /** Parses a config's text into an SVG element. */
568
- _svgElementFromConfig(config) {
569
- if (!config.svgElement) {
570
- const svg = this._svgElementFromString(config.svgText);
571
- this._setSvgAttributes(svg, config.options);
572
- config.svgElement = svg;
573
- }
574
- return config.svgElement;
575
- }
576
- /** Tries to create an icon config through the registered resolver functions. */
577
- _getIconConfigFromResolvers(namespace, name) {
578
- for (let i = 0; i < this._resolvers.length; i++) {
579
- const result = this._resolvers[i](name, namespace);
580
- if (result) {
581
- return isSafeUrlWithOptions(result)
582
- ? new SvgIconConfig(result.url, null, result.options)
583
- : new SvgIconConfig(result, null);
584
- }
585
- }
586
- return undefined;
587
- }
588
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconRegistry, deps: [{ token: i1.HttpClient, optional: true }, { token: i2.DomSanitizer }, { token: DOCUMENT, optional: true }, { token: i0.ErrorHandler }], target: i0.ɵɵFactoryTarget.Injectable });
589
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconRegistry, providedIn: 'root' });
590
- }
591
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconRegistry, decorators: [{
592
- type: Injectable,
593
- args: [{ providedIn: 'root' }]
594
- }], ctorParameters: () => [{ type: i1.HttpClient, decorators: [{
595
- type: Optional
596
- }] }, { type: i2.DomSanitizer }, { type: undefined, decorators: [{
597
- type: Optional
598
- }, {
599
- type: Inject,
600
- args: [DOCUMENT]
601
- }] }, { type: i0.ErrorHandler }] });
602
- /** @docs-private */
603
- function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry, httpClient, sanitizer, errorHandler, document) {
604
- return parentRegistry || new MatIconRegistry(httpClient, sanitizer, document, errorHandler);
605
- }
606
- /** @docs-private */
607
- const ICON_REGISTRY_PROVIDER = {
608
- // If there is already an MatIconRegistry available, use that. Otherwise, provide a new one.
609
- provide: MatIconRegistry,
610
- deps: [
611
- [new Optional(), new SkipSelf(), MatIconRegistry],
612
- [new Optional(), HttpClient],
613
- DomSanitizer,
614
- ErrorHandler,
615
- [new Optional(), DOCUMENT],
616
- ],
617
- useFactory: ICON_REGISTRY_PROVIDER_FACTORY,
618
- };
619
- /** Clones an SVGElement while preserving type information. */
620
- function cloneSvg(svg) {
621
- return svg.cloneNode(true);
622
- }
623
- /** Returns the cache key to use for an icon namespace and name. */
624
- function iconKey(namespace, name) {
625
- return namespace + ':' + name;
626
- }
627
- function isSafeUrlWithOptions(value) {
628
- return !!(value.url && value.options);
629
- }
630
-
631
- /** Injection token to be used to override the default options for `mat-icon`. */
632
- const MAT_ICON_DEFAULT_OPTIONS = new InjectionToken('MAT_ICON_DEFAULT_OPTIONS');
633
- /**
634
- * Injection token used to provide the current location to `MatIcon`.
635
- * Used to handle server-side rendering and to stub out during unit tests.
636
- * @docs-private
637
- */
638
- const MAT_ICON_LOCATION = new InjectionToken('mat-icon-location', {
639
- providedIn: 'root',
640
- factory: MAT_ICON_LOCATION_FACTORY,
641
- });
642
- /** @docs-private */
643
- function MAT_ICON_LOCATION_FACTORY() {
644
- const _document = inject(DOCUMENT);
645
- const _location = _document ? _document.location : null;
646
- return {
647
- // Note that this needs to be a function, rather than a property, because Angular
648
- // will only resolve it once, but we want the current path on each call.
649
- getPathname: () => (_location ? _location.pathname + _location.search : ''),
650
- };
651
- }
652
- /** SVG attributes that accept a FuncIRI (e.g. `url(<something>)`). */
653
- const funcIriAttributes = [
654
- 'clip-path',
655
- 'color-profile',
656
- 'src',
657
- 'cursor',
658
- 'fill',
659
- 'filter',
660
- 'marker',
661
- 'marker-start',
662
- 'marker-mid',
663
- 'marker-end',
664
- 'mask',
665
- 'stroke',
666
- ];
667
- /** Selector that can be used to find all elements that are using a `FuncIRI`. */
668
- const funcIriAttributeSelector = funcIriAttributes.map(attr => `[${attr}]`).join(', ');
669
- /** Regex that can be used to extract the id out of a FuncIRI. */
670
- const funcIriPattern = /^url\(['"]?#(.*?)['"]?\)$/;
671
- /**
672
- * Component to display an icon. It can be used in the following ways:
673
- *
674
- * - Specify the svgIcon input to load an SVG icon from a URL previously registered with the
675
- * addSvgIcon, addSvgIconInNamespace, addSvgIconSet, or addSvgIconSetInNamespace methods of
676
- * MatIconRegistry. If the svgIcon value contains a colon it is assumed to be in the format
677
- * "[namespace]:[name]", if not the value will be the name of an icon in the default namespace.
678
- * Examples:
679
- * `<mat-icon svgIcon="left-arrow"></mat-icon>
680
- * <mat-icon svgIcon="animals:cat"></mat-icon>`
681
- *
682
- * - Use a font ligature as an icon by putting the ligature text in the `fontIcon` attribute or the
683
- * content of the `<mat-icon>` component. If you register a custom font class, don't forget to also
684
- * include the special class `mat-ligature-font`. It is recommended to use the attribute alternative
685
- * to prevent the ligature text to be selectable and to appear in search engine results.
686
- * By default, the Material icons font is used as described at
687
- * http://google.github.io/material-design-icons/#icon-font-for-the-web. You can specify an
688
- * alternate font by setting the fontSet input to either the CSS class to apply to use the
689
- * desired font, or to an alias previously registered with MatIconRegistry.registerFontClassAlias.
690
- * Examples:
691
- * `<mat-icon fontIcon="home"></mat-icon>
692
- * <mat-icon>home</mat-icon>
693
- * <mat-icon fontSet="myfont" fontIcon="sun"></mat-icon>
694
- * <mat-icon fontSet="myfont">sun</mat-icon>`
695
- *
696
- * - Specify a font glyph to be included via CSS rules by setting the fontSet input to specify the
697
- * font, and the fontIcon input to specify the icon. Typically the fontIcon will specify a
698
- * CSS class which causes the glyph to be displayed via a :before selector, as in
699
- * https://fontawesome-v4.github.io/examples/
700
- * Example:
701
- * `<mat-icon fontSet="fa" fontIcon="alarm"></mat-icon>`
702
- */
703
- class MatIcon {
704
- _elementRef = inject(ElementRef);
705
- _iconRegistry = inject(MatIconRegistry);
706
- _location = inject(MAT_ICON_LOCATION);
707
- _errorHandler = inject(ErrorHandler);
708
- _defaultColor;
709
- /**
710
- * Theme color of the icon. This API is supported in M2 themes only, it
711
- * has no effect in M3 themes. For color customization in M3, see https://material.angular.io/components/icon/styling.
712
- *
713
- * For information on applying color variants in M3, see
714
- * https://material.angular.io/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants
715
- */
716
- get color() {
717
- return this._color || this._defaultColor;
718
- }
719
- set color(value) {
720
- this._color = value;
721
- }
722
- _color;
723
- /**
724
- * Whether the icon should be inlined, automatically sizing the icon to match the font size of
725
- * the element the icon is contained in.
726
- */
727
- inline = false;
728
- /** Name of the icon in the SVG icon set. */
729
- get svgIcon() {
730
- return this._svgIcon;
731
- }
732
- set svgIcon(value) {
733
- if (value !== this._svgIcon) {
734
- if (value) {
735
- this._updateSvgIcon(value);
736
- }
737
- else if (this._svgIcon) {
738
- this._clearSvgElement();
739
- }
740
- this._svgIcon = value;
741
- }
742
- }
743
- _svgIcon;
744
- /** Font set that the icon is a part of. */
745
- get fontSet() {
746
- return this._fontSet;
747
- }
748
- set fontSet(value) {
749
- const newValue = this._cleanupFontValue(value);
750
- if (newValue !== this._fontSet) {
751
- this._fontSet = newValue;
752
- this._updateFontIconClasses();
753
- }
754
- }
755
- _fontSet;
756
- /** Name of an icon within a font set. */
757
- get fontIcon() {
758
- return this._fontIcon;
759
- }
760
- set fontIcon(value) {
761
- const newValue = this._cleanupFontValue(value);
762
- if (newValue !== this._fontIcon) {
763
- this._fontIcon = newValue;
764
- this._updateFontIconClasses();
765
- }
766
- }
767
- _fontIcon;
768
- _previousFontSetClass = [];
769
- _previousFontIconClass;
770
- _svgName;
771
- _svgNamespace;
772
- /** Keeps track of the current page path. */
773
- _previousPath;
774
- /** Keeps track of the elements and attributes that we've prefixed with the current path. */
775
- _elementsWithExternalReferences;
776
- /** Subscription to the current in-progress SVG icon request. */
777
- _currentIconFetch = Subscription.EMPTY;
778
- constructor() {
779
- const ariaHidden = inject(new HostAttributeToken('aria-hidden'), { optional: true });
780
- const defaults = inject(MAT_ICON_DEFAULT_OPTIONS, { optional: true });
781
- if (defaults) {
782
- if (defaults.color) {
783
- this.color = this._defaultColor = defaults.color;
784
- }
785
- if (defaults.fontSet) {
786
- this.fontSet = defaults.fontSet;
787
- }
788
- }
789
- // If the user has not explicitly set aria-hidden, mark the icon as hidden, as this is
790
- // the right thing to do for the majority of icon use-cases.
791
- if (!ariaHidden) {
792
- this._elementRef.nativeElement.setAttribute('aria-hidden', 'true');
793
- }
794
- }
795
- /**
796
- * Splits an svgIcon binding value into its icon set and icon name components.
797
- * Returns a 2-element array of [(icon set), (icon name)].
798
- * The separator for the two fields is ':'. If there is no separator, an empty
799
- * string is returned for the icon set and the entire value is returned for
800
- * the icon name. If the argument is falsy, returns an array of two empty strings.
801
- * Throws an error if the name contains two or more ':' separators.
802
- * Examples:
803
- * `'social:cake' -> ['social', 'cake']
804
- * 'penguin' -> ['', 'penguin']
805
- * null -> ['', '']
806
- * 'a:b:c' -> (throws Error)`
807
- */
808
- _splitIconName(iconName) {
809
- if (!iconName) {
810
- return ['', ''];
811
- }
812
- const parts = iconName.split(':');
813
- switch (parts.length) {
814
- case 1:
815
- return ['', parts[0]]; // Use default namespace.
816
- case 2:
817
- return parts;
818
- default:
819
- throw Error(`Invalid icon name: "${iconName}"`); // TODO: add an ngDevMode check
820
- }
821
- }
822
- ngOnInit() {
823
- // Update font classes because ngOnChanges won't be called if none of the inputs are present,
824
- // e.g. <mat-icon>arrow</mat-icon> In this case we need to add a CSS class for the default font.
825
- this._updateFontIconClasses();
826
- }
827
- ngAfterViewChecked() {
828
- const cachedElements = this._elementsWithExternalReferences;
829
- if (cachedElements && cachedElements.size) {
830
- const newPath = this._location.getPathname();
831
- // We need to check whether the URL has changed on each change detection since
832
- // the browser doesn't have an API that will let us react on link clicks and
833
- // we can't depend on the Angular router. The references need to be updated,
834
- // because while most browsers don't care whether the URL is correct after
835
- // the first render, Safari will break if the user navigates to a different
836
- // page and the SVG isn't re-rendered.
837
- if (newPath !== this._previousPath) {
838
- this._previousPath = newPath;
839
- this._prependPathToReferences(newPath);
840
- }
841
- }
842
- }
843
- ngOnDestroy() {
844
- this._currentIconFetch.unsubscribe();
845
- if (this._elementsWithExternalReferences) {
846
- this._elementsWithExternalReferences.clear();
847
- }
848
- }
849
- _usingFontIcon() {
850
- return !this.svgIcon;
851
- }
852
- _setSvgElement(svg) {
853
- this._clearSvgElement();
854
- // Note: we do this fix here, rather than the icon registry, because the
855
- // references have to point to the URL at the time that the icon was created.
856
- const path = this._location.getPathname();
857
- this._previousPath = path;
858
- this._cacheChildrenWithExternalReferences(svg);
859
- this._prependPathToReferences(path);
860
- this._elementRef.nativeElement.appendChild(svg);
861
- }
862
- _clearSvgElement() {
863
- const layoutElement = this._elementRef.nativeElement;
864
- let childCount = layoutElement.childNodes.length;
865
- if (this._elementsWithExternalReferences) {
866
- this._elementsWithExternalReferences.clear();
867
- }
868
- // Remove existing non-element child nodes and SVGs, and add the new SVG element. Note that
869
- // we can't use innerHTML, because IE will throw if the element has a data binding.
870
- while (childCount--) {
871
- const child = layoutElement.childNodes[childCount];
872
- // 1 corresponds to Node.ELEMENT_NODE. We remove all non-element nodes in order to get rid
873
- // of any loose text nodes, as well as any SVG elements in order to remove any old icons.
874
- if (child.nodeType !== 1 || child.nodeName.toLowerCase() === 'svg') {
875
- child.remove();
876
- }
877
- }
878
- }
879
- _updateFontIconClasses() {
880
- if (!this._usingFontIcon()) {
881
- return;
882
- }
883
- const elem = this._elementRef.nativeElement;
884
- const fontSetClasses = (this.fontSet
885
- ? this._iconRegistry.classNameForFontAlias(this.fontSet).split(/ +/)
886
- : this._iconRegistry.getDefaultFontSetClass()).filter(className => className.length > 0);
887
- this._previousFontSetClass.forEach(className => elem.classList.remove(className));
888
- fontSetClasses.forEach(className => elem.classList.add(className));
889
- this._previousFontSetClass = fontSetClasses;
890
- if (this.fontIcon !== this._previousFontIconClass &&
891
- !fontSetClasses.includes('mat-ligature-font')) {
892
- if (this._previousFontIconClass) {
893
- elem.classList.remove(this._previousFontIconClass);
894
- }
895
- if (this.fontIcon) {
896
- elem.classList.add(this.fontIcon);
897
- }
898
- this._previousFontIconClass = this.fontIcon;
899
- }
900
- }
901
- /**
902
- * Cleans up a value to be used as a fontIcon or fontSet.
903
- * Since the value ends up being assigned as a CSS class, we
904
- * have to trim the value and omit space-separated values.
905
- */
906
- _cleanupFontValue(value) {
907
- return typeof value === 'string' ? value.trim().split(' ')[0] : value;
908
- }
909
- /**
910
- * Prepends the current path to all elements that have an attribute pointing to a `FuncIRI`
911
- * reference. This is required because WebKit browsers require references to be prefixed with
912
- * the current path, if the page has a `base` tag.
913
- */
914
- _prependPathToReferences(path) {
915
- const elements = this._elementsWithExternalReferences;
916
- if (elements) {
917
- elements.forEach((attrs, element) => {
918
- attrs.forEach(attr => {
919
- element.setAttribute(attr.name, `url('${path}#${attr.value}')`);
920
- });
921
- });
922
- }
923
- }
924
- /**
925
- * Caches the children of an SVG element that have `url()`
926
- * references that we need to prefix with the current path.
927
- */
928
- _cacheChildrenWithExternalReferences(element) {
929
- const elementsWithFuncIri = element.querySelectorAll(funcIriAttributeSelector);
930
- const elements = (this._elementsWithExternalReferences =
931
- this._elementsWithExternalReferences || new Map());
932
- for (let i = 0; i < elementsWithFuncIri.length; i++) {
933
- funcIriAttributes.forEach(attr => {
934
- const elementWithReference = elementsWithFuncIri[i];
935
- const value = elementWithReference.getAttribute(attr);
936
- const match = value ? value.match(funcIriPattern) : null;
937
- if (match) {
938
- let attributes = elements.get(elementWithReference);
939
- if (!attributes) {
940
- attributes = [];
941
- elements.set(elementWithReference, attributes);
942
- }
943
- attributes.push({ name: attr, value: match[1] });
944
- }
945
- });
946
- }
947
- }
948
- /** Sets a new SVG icon with a particular name. */
949
- _updateSvgIcon(rawName) {
950
- this._svgNamespace = null;
951
- this._svgName = null;
952
- this._currentIconFetch.unsubscribe();
953
- if (rawName) {
954
- const [namespace, iconName] = this._splitIconName(rawName);
955
- if (namespace) {
956
- this._svgNamespace = namespace;
957
- }
958
- if (iconName) {
959
- this._svgName = iconName;
960
- }
961
- this._currentIconFetch = this._iconRegistry
962
- .getNamedSvgIcon(iconName, namespace)
963
- .pipe(take(1))
964
- .subscribe(svg => this._setSvgElement(svg), (err) => {
965
- const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`;
966
- this._errorHandler.handleError(new Error(errorMessage));
967
- });
968
- }
969
- }
970
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIcon, deps: [], target: i0.ɵɵFactoryTarget.Component });
971
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "16.1.0", version: "19.2.0", type: MatIcon, isStandalone: true, selector: "mat-icon", inputs: { color: "color", inline: ["inline", "inline", booleanAttribute], svgIcon: "svgIcon", fontSet: "fontSet", fontIcon: "fontIcon" }, host: { attributes: { "role": "img" }, properties: { "class": "color ? \"mat-\" + color : \"\"", "attr.data-mat-icon-type": "_usingFontIcon() ? \"font\" : \"svg\"", "attr.data-mat-icon-name": "_svgName || fontIcon", "attr.data-mat-icon-namespace": "_svgNamespace || fontSet", "attr.fontIcon": "_usingFontIcon() ? fontIcon : null", "class.mat-icon-inline": "inline", "class.mat-icon-no-color": "color !== \"primary\" && color !== \"accent\" && color !== \"warn\"" }, classAttribute: "mat-icon notranslate" }, exportAs: ["matIcon"], ngImport: i0, template: '<ng-content></ng-content>', isInline: true, styles: ["mat-icon,mat-icon.mat-primary,mat-icon.mat-accent,mat-icon.mat-warn{color:var(--mat-icon-color, inherit)}.mat-icon{-webkit-user-select:none;user-select:none;background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px;overflow:hidden}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}.mat-icon.mat-ligature-font[fontIcon]::before{content:attr(fontIcon)}[dir=rtl] .mat-icon-rtl-mirror{transform:scale(-1, 1)}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon{display:block}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon-button .mat-icon{margin:auto}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
972
- }
973
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIcon, decorators: [{
974
- type: Component,
975
- args: [{ template: '<ng-content></ng-content>', selector: 'mat-icon', exportAs: 'matIcon', host: {
976
- 'role': 'img',
977
- 'class': 'mat-icon notranslate',
978
- '[class]': 'color ? "mat-" + color : ""',
979
- '[attr.data-mat-icon-type]': '_usingFontIcon() ? "font" : "svg"',
980
- '[attr.data-mat-icon-name]': '_svgName || fontIcon',
981
- '[attr.data-mat-icon-namespace]': '_svgNamespace || fontSet',
982
- '[attr.fontIcon]': '_usingFontIcon() ? fontIcon : null',
983
- '[class.mat-icon-inline]': 'inline',
984
- '[class.mat-icon-no-color]': 'color !== "primary" && color !== "accent" && color !== "warn"',
985
- }, encapsulation: ViewEncapsulation.None, changeDetection: ChangeDetectionStrategy.OnPush, styles: ["mat-icon,mat-icon.mat-primary,mat-icon.mat-accent,mat-icon.mat-warn{color:var(--mat-icon-color, inherit)}.mat-icon{-webkit-user-select:none;user-select:none;background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px;overflow:hidden}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}.mat-icon.mat-ligature-font[fontIcon]::before{content:attr(fontIcon)}[dir=rtl] .mat-icon-rtl-mirror{transform:scale(-1, 1)}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon{display:block}.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-prefix .mat-icon-button .mat-icon,.mat-form-field:not(.mat-form-field-appearance-legacy) .mat-form-field-suffix .mat-icon-button .mat-icon{margin:auto}"] }]
986
- }], ctorParameters: () => [], propDecorators: { color: [{
987
- type: Input
988
- }], inline: [{
989
- type: Input,
990
- args: [{ transform: booleanAttribute }]
991
- }], svgIcon: [{
992
- type: Input
993
- }], fontSet: [{
994
- type: Input
995
- }], fontIcon: [{
996
- type: Input
997
- }] } });
998
-
999
- class MatIconModule {
1000
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1001
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "19.2.0", ngImport: i0, type: MatIconModule, imports: [MatCommonModule, MatIcon], exports: [MatIcon, MatCommonModule] });
1002
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconModule, imports: [MatCommonModule, MatCommonModule] });
1003
- }
1004
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.0", ngImport: i0, type: MatIconModule, decorators: [{
1005
- type: NgModule,
1006
- args: [{
1007
- imports: [MatCommonModule, MatIcon],
1008
- exports: [MatIcon, MatCommonModule],
1009
- }]
1010
- }] });
1011
-
1012
- /**
1013
- * Generated bundle index. Do not edit.
1014
- */
1015
-
1016
- export { ICON_REGISTRY_PROVIDER, ICON_REGISTRY_PROVIDER_FACTORY, MAT_ICON_DEFAULT_OPTIONS, MAT_ICON_LOCATION, MAT_ICON_LOCATION_FACTORY, MatIcon, MatIconModule, MatIconRegistry, getMatIconFailedToSanitizeLiteralError, getMatIconFailedToSanitizeUrlError, getMatIconNameNotFoundError, getMatIconNoHttpProviderError };
1
+ export { a as MAT_ICON_DEFAULT_OPTIONS, b as MAT_ICON_LOCATION, c as MAT_ICON_LOCATION_FACTORY, d as MatIcon, M as MatIconModule } from './icon-module-3f77a24d.mjs';
2
+ export { d as ICON_REGISTRY_PROVIDER, I as ICON_REGISTRY_PROVIDER_FACTORY, M as MatIconRegistry, c as getMatIconFailedToSanitizeLiteralError, b as getMatIconFailedToSanitizeUrlError, g as getMatIconNameNotFoundError, a as getMatIconNoHttpProviderError } from './icon-registry-13a3b98e.mjs';
3
+ import '@angular/core';
4
+ import '@angular/common';
5
+ import 'rxjs';
6
+ import 'rxjs/operators';
7
+ import './common-module-2d64df09.mjs';
8
+ import '@angular/cdk/a11y';
9
+ import '@angular/cdk/bidi';
10
+ import '@angular/common/http';
11
+ import '@angular/platform-browser';
1017
12
  //# sourceMappingURL=icon.mjs.map