@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.
- package/autocomplete/index.d.ts +92 -126
- package/autocomplete/testing/index.d.ts +6 -11
- package/badge/index.d.ts +8 -112
- package/badge/testing/index.d.ts +7 -8
- package/badge.d-49a8a74b.d.ts +98 -0
- package/bottom-sheet/index.d.ts +88 -103
- package/bottom-sheet/testing/index.d.ts +4 -6
- package/button/index.d.ts +10 -245
- package/button/testing/index.d.ts +6 -10
- package/button-toggle/index.d.ts +12 -285
- package/button-toggle/testing/index.d.ts +38 -37
- package/button-toggle.d-edc8acff.d.ts +257 -0
- package/card/index.d.ts +80 -117
- package/card/testing/index.d.ts +11 -15
- package/checkbox/index.d.ts +43 -104
- package/checkbox/testing/index.d.ts +6 -10
- package/chips/index.d.ts +599 -693
- package/chips/testing/index.d.ts +78 -93
- package/common-module.d-0e6515ae.d.ts +43 -0
- package/core/index.d.ts +50 -979
- package/core/testing/index.d.ts +3 -65
- package/date-adapter.d-c6835d41.d.ts +267 -0
- package/date-range-input-harness.d-549a9f7e.d.ts +278 -0
- package/datepicker/index.d.ts +1332 -1482
- package/datepicker/testing/index.d.ts +5 -287
- package/dialog/index.d.ts +59 -453
- package/dialog/testing/index.d.ts +22 -26
- package/dialog.d-57867441.d.ts +335 -0
- package/divider/index.d.ts +6 -11
- package/divider/testing/index.d.ts +2 -16
- package/divider-harness.d-d34fede4.d.ts +14 -0
- package/error-options.d-448d9046.d.ts +17 -0
- package/expansion/index.d.ts +139 -190
- package/expansion/testing/index.d.ts +25 -31
- package/fesm2022/autocomplete/testing.mjs +2 -1
- package/fesm2022/autocomplete/testing.mjs.map +1 -1
- package/fesm2022/autocomplete.mjs +53 -32
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge/testing.mjs.map +1 -1
- package/fesm2022/badge.mjs +14 -17
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet/testing.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs +13 -15
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button/testing.mjs.map +1 -1
- package/fesm2022/button-toggle/testing.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs +22 -15
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs +14 -395
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card/testing.mjs.map +1 -1
- package/fesm2022/card.mjs +49 -51
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox/testing.mjs.map +1 -1
- package/fesm2022/checkbox.mjs +32 -73
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips/testing.mjs.map +1 -1
- package/fesm2022/chips.mjs +51 -46
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/common-module-2d64df09.mjs +42 -0
- package/fesm2022/common-module-2d64df09.mjs.map +1 -0
- package/fesm2022/core/testing.mjs +3 -76
- package/fesm2022/core/testing.mjs.map +1 -1
- package/fesm2022/core.mjs +38 -1598
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/date-formats-b618acb8.mjs +190 -0
- package/fesm2022/date-formats-b618acb8.mjs.map +1 -0
- package/fesm2022/date-range-input-harness-ee47cdb0.mjs +467 -0
- package/fesm2022/date-range-input-harness-ee47cdb0.mjs.map +1 -0
- package/fesm2022/datepicker/testing.mjs +5 -465
- package/fesm2022/datepicker/testing.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +159 -128
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog/testing.mjs +12 -1
- package/fesm2022/dialog/testing.mjs.map +1 -1
- package/fesm2022/dialog.mjs +14 -895
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider/testing.mjs +2 -17
- package/fesm2022/divider/testing.mjs.map +1 -1
- package/fesm2022/divider-harness-3394f29a.mjs +18 -0
- package/fesm2022/divider-harness-3394f29a.mjs.map +1 -0
- package/fesm2022/divider.mjs +10 -12
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/error-options-4a00765e.mjs +29 -0
- package/fesm2022/error-options-4a00765e.mjs.map +1 -0
- package/fesm2022/error-state-8f4ce1af.mjs +37 -0
- package/fesm2022/error-state-8f4ce1af.mjs.map +1 -0
- package/fesm2022/expansion/testing.mjs.map +1 -1
- package/fesm2022/expansion.mjs +30 -32
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field/testing/control.mjs +2 -10
- package/fesm2022/form-field/testing/control.mjs.map +1 -1
- package/fesm2022/form-field/testing.mjs +7 -6
- package/fesm2022/form-field/testing.mjs.map +1 -1
- package/fesm2022/form-field-6d755764.mjs +1076 -0
- package/fesm2022/form-field-6d755764.mjs.map +1 -0
- package/fesm2022/form-field-control-harness-af6fd278.mjs +11 -0
- package/fesm2022/form-field-control-harness-af6fd278.mjs.map +1 -0
- package/fesm2022/form-field.mjs +14 -1110
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list/testing.mjs +1 -1
- package/fesm2022/grid-list/testing.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +30 -173
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon/testing.mjs +12 -12
- package/fesm2022/icon/testing.mjs.map +1 -1
- package/fesm2022/icon-button-47f1b5d9.mjs +248 -0
- package/fesm2022/icon-button-47f1b5d9.mjs.map +1 -0
- package/fesm2022/icon-module-3f77a24d.mjs +395 -0
- package/fesm2022/icon-module-3f77a24d.mjs.map +1 -0
- package/fesm2022/icon-registry-13a3b98e.mjs +639 -0
- package/fesm2022/icon-registry-13a3b98e.mjs.map +1 -0
- package/fesm2022/icon.mjs +11 -1016
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/index-1763d3a6.mjs +22 -0
- package/fesm2022/index-1763d3a6.mjs.map +1 -0
- package/fesm2022/index-4bc1d6d3.mjs +20 -0
- package/fesm2022/index-4bc1d6d3.mjs.map +1 -0
- package/fesm2022/input/testing.mjs +5 -113
- package/fesm2022/input/testing.mjs.map +1 -1
- package/fesm2022/input-harness-ed59decc.mjs +115 -0
- package/fesm2022/input-harness-ed59decc.mjs.map +1 -0
- package/fesm2022/input-value-accessor-8a79a24e.mjs +12 -0
- package/fesm2022/input-value-accessor-8a79a24e.mjs.map +1 -0
- package/fesm2022/input.mjs +21 -23
- package/fesm2022/input.mjs.map +1 -1
- package/fesm2022/internal-form-field-434c4039.mjs +27 -0
- package/fesm2022/internal-form-field-434c4039.mjs.map +1 -0
- package/fesm2022/line-d6afe347.mjs +59 -0
- package/fesm2022/line-d6afe347.mjs.map +1 -0
- package/fesm2022/list/testing.mjs +2 -2
- package/fesm2022/list/testing.mjs.map +1 -1
- package/fesm2022/list.mjs +59 -56
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/menu/testing.mjs.map +1 -1
- package/fesm2022/menu.mjs +37 -25
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/module-3bf2775f.mjs +1293 -0
- package/fesm2022/module-3bf2775f.mjs.map +1 -0
- package/fesm2022/module-47e3be58.mjs +970 -0
- package/fesm2022/module-47e3be58.mjs.map +1 -0
- package/fesm2022/module-a5f9ab72.mjs +875 -0
- package/fesm2022/module-a5f9ab72.mjs.map +1 -0
- package/fesm2022/module-d757bba0.mjs +38 -0
- package/fesm2022/module-d757bba0.mjs.map +1 -0
- package/fesm2022/module-df9f7af3.mjs +152 -0
- package/fesm2022/module-df9f7af3.mjs.map +1 -0
- package/fesm2022/optgroup-harness-5e66b138.mjs +36 -0
- package/fesm2022/optgroup-harness-5e66b138.mjs.map +1 -0
- package/fesm2022/option-07c3c660.mjs +348 -0
- package/fesm2022/option-07c3c660.mjs.map +1 -0
- package/fesm2022/option-harness-3b7c1106.mjs +46 -0
- package/fesm2022/option-harness-3b7c1106.mjs.map +1 -0
- package/fesm2022/paginator/testing.mjs +4 -1
- package/fesm2022/paginator/testing.mjs.map +1 -1
- package/fesm2022/paginator.mjs +51 -21
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar/testing.mjs +0 -4
- package/fesm2022/progress-bar/testing.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs +15 -13
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner/testing.mjs +0 -4
- package/fesm2022/progress-spinner/testing.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +15 -13
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/pseudo-checkbox-af5a4ea4.mjs +52 -0
- package/fesm2022/pseudo-checkbox-af5a4ea4.mjs.map +1 -0
- package/fesm2022/pseudo-checkbox-module-216fae38.mjs +20 -0
- package/fesm2022/pseudo-checkbox-module-216fae38.mjs.map +1 -0
- package/fesm2022/public-api-c5ab57f5.mjs +147 -0
- package/fesm2022/public-api-c5ab57f5.mjs.map +1 -0
- package/fesm2022/radio/testing.mjs.map +1 -1
- package/fesm2022/radio.mjs +23 -15
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/ripple-9939d1f5.mjs +639 -0
- package/fesm2022/ripple-9939d1f5.mjs.map +1 -0
- package/fesm2022/ripple-loader-f2078c66.mjs +165 -0
- package/fesm2022/ripple-loader-f2078c66.mjs.map +1 -0
- package/fesm2022/select/testing.mjs +5 -121
- package/fesm2022/select/testing.mjs.map +1 -1
- package/fesm2022/select-harness-8c55824d.mjs +123 -0
- package/fesm2022/select-harness-8c55824d.mjs.map +1 -0
- package/fesm2022/select.mjs +30 -1311
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav/testing.mjs +1 -1
- package/fesm2022/sidenav/testing.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +31 -31
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle/testing.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +27 -75
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider/testing.mjs.map +1 -1
- package/fesm2022/slider.mjs +22 -21
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar/testing.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs +37 -29
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort/testing.mjs.map +1 -1
- package/fesm2022/sort.mjs +26 -20
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper/testing.mjs.map +1 -1
- package/fesm2022/stepper.mjs +52 -39
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/structural-styles-d5ada3b3.mjs +18 -0
- package/fesm2022/structural-styles-d5ada3b3.mjs.map +1 -0
- package/fesm2022/table/testing.mjs.map +1 -1
- package/fesm2022/table.mjs +58 -60
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs/testing.mjs.map +1 -1
- package/fesm2022/tabs.mjs +54 -58
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/timepicker/testing.mjs +1 -1
- package/fesm2022/timepicker/testing.mjs.map +1 -1
- package/fesm2022/timepicker.mjs +31 -24
- package/fesm2022/timepicker.mjs.map +1 -1
- package/fesm2022/toolbar/testing.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +13 -15
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip/testing.mjs.map +1 -1
- package/fesm2022/tooltip.mjs +15 -960
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree/testing.mjs.map +1 -1
- package/fesm2022/tree.mjs +28 -30
- package/fesm2022/tree.mjs.map +1 -1
- package/form-field/index.d.ts +16 -508
- package/form-field/testing/control/index.d.ts +2 -10
- package/form-field/testing/index.d.ts +19 -24
- package/form-field-control-harness.d-2d91f25a.d.ts +10 -0
- package/form-field-control.d-eb86711c.d.ts +62 -0
- package/form-field.d-2edbc094.d.ts +367 -0
- package/grid-list/index.d.ts +128 -152
- package/grid-list/testing/index.d.ts +39 -44
- package/icon/index.d.ts +9 -470
- package/icon/testing/index.d.ts +41 -44
- package/icon-module.d-aa3bbba0.d.ts +167 -0
- package/icon-registry.d-1dffe9de.d.ts +286 -0
- package/index.d-0536b706.d.ts +11 -0
- package/index.d-37e31cd3.d.ts +13 -0
- package/index.d.ts +2 -3
- package/input/index.d.ts +33 -62
- package/input/testing/index.d.ts +13 -71
- package/input-harness.d-4eecd1d3.d.ts +60 -0
- package/line.d-570a2537.d.ts +25 -0
- package/list/index.d.ts +155 -244
- package/list/testing/index.d.ts +158 -180
- package/list-option-types.d-8739f903.d.ts +15 -0
- package/menu/index.d.ts +183 -231
- package/menu/testing/index.d.ts +17 -23
- package/module.d-18a67f56.d.ts +206 -0
- package/module.d-74a721b9.d.ts +326 -0
- package/module.d-ba05faa6.d.ts +448 -0
- package/module.d-c17c834e.d.ts +18 -0
- package/optgroup-harness.d-7f741f69.d.ts +31 -0
- package/option-harness.d-3d33fc9a.d.ts +34 -0
- package/option-parent.d-559ad5c5.d.ts +19 -0
- package/option.d-6f493d78.d.ts +146 -0
- package/package.json +2 -2
- package/paginator/index.d.ts +31 -216
- package/paginator/testing/index.d.ts +14 -15
- package/paginator.d-40b1766e.d.ts +199 -0
- package/palette.d-ec4a617c.d.ts +4 -0
- package/progress-bar/index.d.ts +40 -59
- package/progress-bar/testing/index.d.ts +7 -10
- package/progress-spinner/index.d.ts +8 -110
- package/progress-spinner/testing/index.d.ts +10 -11
- package/progress-spinner.d-1fc040c5.d.ts +96 -0
- package/pseudo-checkbox-module.d-3abc0461.d.ts +44 -0
- package/radio/index.d.ts +151 -170
- package/radio/testing/index.d.ts +61 -67
- package/ripple-loader.d-8aac2988.d.ts +48 -0
- package/ripple.d-2fb57d04.d.ts +255 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/schematics/ng-generate/theme-color/index_bundled.js +2 -2
- package/schematics/ng-generate/theme-color/schema.json +10 -0
- package/schematics/ng-update/index_bundled.js +31 -31
- package/select/index.d.ts +25 -505
- package/select/testing/index.d.ts +5 -67
- package/select-harness.d-7441a7ac.d.ts +63 -0
- package/sidenav/index.d.ts +49 -92
- package/sidenav/testing/index.d.ts +58 -63
- package/slide-toggle/index.d.ts +39 -110
- package/slide-toggle/testing/index.d.ts +17 -21
- package/slider/index.d.ts +281 -328
- package/slider/testing/index.d.ts +42 -47
- package/snack-bar/index.d.ts +152 -185
- package/snack-bar/testing/index.d.ts +7 -9
- package/sort/index.d.ts +61 -169
- package/sort/testing/index.d.ts +22 -25
- package/sort-direction.d-f4ce4649.d.ts +3 -0
- package/sort.d-c2b79a45.d.ts +87 -0
- package/stepper/index.d.ts +115 -167
- package/stepper/testing/index.d.ts +43 -52
- package/table/index.d.ts +97 -156
- package/table/testing/index.d.ts +64 -78
- package/tabs/index.d.ts +309 -383
- package/tabs/testing/index.d.ts +67 -76
- package/timepicker/index.d.ts +127 -160
- package/timepicker/testing/index.d.ts +20 -26
- package/toolbar/index.d.ts +15 -26
- package/toolbar/testing/index.d.ts +13 -16
- package/tooltip/index.d.ts +11 -355
- package/tooltip/testing/index.d.ts +7 -10
- package/tree/index.d.ts +117 -163
- package/tree/testing/index.d.ts +52 -58
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { DOCUMENT } from '@angular/common';
|
|
2
|
+
import * as i1 from '@angular/common/http';
|
|
3
|
+
import { HttpClient } from '@angular/common/http';
|
|
4
|
+
import * as i0 from '@angular/core';
|
|
5
|
+
import { SecurityContext, Injectable, Optional, Inject, SkipSelf, ErrorHandler } from '@angular/core';
|
|
6
|
+
import * as i2 from '@angular/platform-browser';
|
|
7
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
8
|
+
import { of, throwError, forkJoin } from 'rxjs';
|
|
9
|
+
import { tap, map, catchError, finalize, share } from 'rxjs/operators';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The Trusted Types policy, or null if Trusted Types are not
|
|
13
|
+
* enabled/supported, or undefined if the policy has not been created yet.
|
|
14
|
+
*/
|
|
15
|
+
let policy;
|
|
16
|
+
/**
|
|
17
|
+
* Returns the Trusted Types policy, or null if Trusted Types are not
|
|
18
|
+
* enabled/supported. The first call to this function will create the policy.
|
|
19
|
+
*/
|
|
20
|
+
function getPolicy() {
|
|
21
|
+
if (policy === undefined) {
|
|
22
|
+
policy = null;
|
|
23
|
+
if (typeof window !== 'undefined') {
|
|
24
|
+
const ttWindow = window;
|
|
25
|
+
if (ttWindow.trustedTypes !== undefined) {
|
|
26
|
+
policy = ttWindow.trustedTypes.createPolicy('angular#components', {
|
|
27
|
+
createHTML: (s) => s,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return policy;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Unsafely promote a string to a TrustedHTML, falling back to strings when
|
|
36
|
+
* Trusted Types are not available.
|
|
37
|
+
* @security This is a security-sensitive function; any use of this function
|
|
38
|
+
* must go through security review. In particular, it must be assured that the
|
|
39
|
+
* provided string will never cause an XSS vulnerability if used in a context
|
|
40
|
+
* that will be interpreted as HTML by a browser, e.g. when assigning to
|
|
41
|
+
* element.innerHTML.
|
|
42
|
+
*/
|
|
43
|
+
function trustedHTMLFromString(html) {
|
|
44
|
+
return getPolicy()?.createHTML(html) || html;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Returns an exception to be thrown in the case when attempting to
|
|
49
|
+
* load an icon with a name that cannot be found.
|
|
50
|
+
* @docs-private
|
|
51
|
+
*/
|
|
52
|
+
function getMatIconNameNotFoundError(iconName) {
|
|
53
|
+
return Error(`Unable to find icon with the name "${iconName}"`);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns an exception to be thrown when the consumer attempts to use
|
|
57
|
+
* `<mat-icon>` without including @angular/common/http.
|
|
58
|
+
* @docs-private
|
|
59
|
+
*/
|
|
60
|
+
function getMatIconNoHttpProviderError() {
|
|
61
|
+
return Error('Could not find HttpClient for use with Angular Material icons. ' +
|
|
62
|
+
'Please add provideHttpClient() to your providers.');
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Returns an exception to be thrown when a URL couldn't be sanitized.
|
|
66
|
+
* @param url URL that was attempted to be sanitized.
|
|
67
|
+
* @docs-private
|
|
68
|
+
*/
|
|
69
|
+
function getMatIconFailedToSanitizeUrlError(url) {
|
|
70
|
+
return Error(`The URL provided to MatIconRegistry was not trusted as a resource URL ` +
|
|
71
|
+
`via Angular's DomSanitizer. Attempted URL was "${url}".`);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Returns an exception to be thrown when a HTML string couldn't be sanitized.
|
|
75
|
+
* @param literal HTML that was attempted to be sanitized.
|
|
76
|
+
* @docs-private
|
|
77
|
+
*/
|
|
78
|
+
function getMatIconFailedToSanitizeLiteralError(literal) {
|
|
79
|
+
return Error(`The literal provided to MatIconRegistry was not trusted as safe HTML by ` +
|
|
80
|
+
`Angular's DomSanitizer. Attempted literal was "${literal}".`);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Configuration for an icon, including the URL and possibly the cached SVG element.
|
|
84
|
+
* @docs-private
|
|
85
|
+
*/
|
|
86
|
+
class SvgIconConfig {
|
|
87
|
+
url;
|
|
88
|
+
svgText;
|
|
89
|
+
options;
|
|
90
|
+
svgElement;
|
|
91
|
+
constructor(url, svgText, options) {
|
|
92
|
+
this.url = url;
|
|
93
|
+
this.svgText = svgText;
|
|
94
|
+
this.options = options;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Service to register and display icons used by the `<mat-icon>` component.
|
|
99
|
+
* - Registers icon URLs by namespace and name.
|
|
100
|
+
* - Registers icon set URLs by namespace.
|
|
101
|
+
* - Registers aliases for CSS classes, for use with icon fonts.
|
|
102
|
+
* - Loads icons from URLs and extracts individual icons from icon sets.
|
|
103
|
+
*/
|
|
104
|
+
class MatIconRegistry {
|
|
105
|
+
_httpClient;
|
|
106
|
+
_sanitizer;
|
|
107
|
+
_errorHandler;
|
|
108
|
+
_document;
|
|
109
|
+
/**
|
|
110
|
+
* URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
|
|
111
|
+
*/
|
|
112
|
+
_svgIconConfigs = new Map();
|
|
113
|
+
/**
|
|
114
|
+
* SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
|
|
115
|
+
* Multiple icon sets can be registered under the same namespace.
|
|
116
|
+
*/
|
|
117
|
+
_iconSetConfigs = new Map();
|
|
118
|
+
/** Cache for icons loaded by direct URLs. */
|
|
119
|
+
_cachedIconsByUrl = new Map();
|
|
120
|
+
/** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
|
|
121
|
+
_inProgressUrlFetches = new Map();
|
|
122
|
+
/** Map from font identifiers to their CSS class names. Used for icon fonts. */
|
|
123
|
+
_fontCssClassesByAlias = new Map();
|
|
124
|
+
/** Registered icon resolver functions. */
|
|
125
|
+
_resolvers = [];
|
|
126
|
+
/**
|
|
127
|
+
* The CSS classes to apply when an `<mat-icon>` component has no icon name, url, or font
|
|
128
|
+
* specified. The default 'material-icons' value assumes that the material icon font has been
|
|
129
|
+
* loaded as described at https://google.github.io/material-design-icons/#icon-font-for-the-web
|
|
130
|
+
*/
|
|
131
|
+
_defaultFontSetClass = ['material-icons', 'mat-ligature-font'];
|
|
132
|
+
constructor(_httpClient, _sanitizer, document, _errorHandler) {
|
|
133
|
+
this._httpClient = _httpClient;
|
|
134
|
+
this._sanitizer = _sanitizer;
|
|
135
|
+
this._errorHandler = _errorHandler;
|
|
136
|
+
this._document = document;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Registers an icon by URL in the default namespace.
|
|
140
|
+
* @param iconName Name under which the icon should be registered.
|
|
141
|
+
* @param url
|
|
142
|
+
*/
|
|
143
|
+
addSvgIcon(iconName, url, options) {
|
|
144
|
+
return this.addSvgIconInNamespace('', iconName, url, options);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Registers an icon using an HTML string in the default namespace.
|
|
148
|
+
* @param iconName Name under which the icon should be registered.
|
|
149
|
+
* @param literal SVG source of the icon.
|
|
150
|
+
*/
|
|
151
|
+
addSvgIconLiteral(iconName, literal, options) {
|
|
152
|
+
return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Registers an icon by URL in the specified namespace.
|
|
156
|
+
* @param namespace Namespace in which the icon should be registered.
|
|
157
|
+
* @param iconName Name under which the icon should be registered.
|
|
158
|
+
* @param url
|
|
159
|
+
*/
|
|
160
|
+
addSvgIconInNamespace(namespace, iconName, url, options) {
|
|
161
|
+
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, null, options));
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Registers an icon resolver function with the registry. The function will be invoked with the
|
|
165
|
+
* name and namespace of an icon when the registry tries to resolve the URL from which to fetch
|
|
166
|
+
* the icon. The resolver is expected to return a `SafeResourceUrl` that points to the icon,
|
|
167
|
+
* an object with the icon URL and icon options, or `null` if the icon is not supported. Resolvers
|
|
168
|
+
* will be invoked in the order in which they have been registered.
|
|
169
|
+
* @param resolver Resolver function to be registered.
|
|
170
|
+
*/
|
|
171
|
+
addSvgIconResolver(resolver) {
|
|
172
|
+
this._resolvers.push(resolver);
|
|
173
|
+
return this;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Registers an icon using an HTML string in the specified namespace.
|
|
177
|
+
* @param namespace Namespace in which the icon should be registered.
|
|
178
|
+
* @param iconName Name under which the icon should be registered.
|
|
179
|
+
* @param literal SVG source of the icon.
|
|
180
|
+
*/
|
|
181
|
+
addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
|
|
182
|
+
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
183
|
+
// TODO: add an ngDevMode check
|
|
184
|
+
if (!cleanLiteral) {
|
|
185
|
+
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
186
|
+
}
|
|
187
|
+
// Security: The literal is passed in as SafeHtml, and is thus trusted.
|
|
188
|
+
const trustedLiteral = trustedHTMLFromString(cleanLiteral);
|
|
189
|
+
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig('', trustedLiteral, options));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Registers an icon set by URL in the default namespace.
|
|
193
|
+
* @param url
|
|
194
|
+
*/
|
|
195
|
+
addSvgIconSet(url, options) {
|
|
196
|
+
return this.addSvgIconSetInNamespace('', url, options);
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Registers an icon set using an HTML string in the default namespace.
|
|
200
|
+
* @param literal SVG source of the icon set.
|
|
201
|
+
*/
|
|
202
|
+
addSvgIconSetLiteral(literal, options) {
|
|
203
|
+
return this.addSvgIconSetLiteralInNamespace('', literal, options);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Registers an icon set by URL in the specified namespace.
|
|
207
|
+
* @param namespace Namespace in which to register the icon set.
|
|
208
|
+
* @param url
|
|
209
|
+
*/
|
|
210
|
+
addSvgIconSetInNamespace(namespace, url, options) {
|
|
211
|
+
return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, null, options));
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Registers an icon set using an HTML string in the specified namespace.
|
|
215
|
+
* @param namespace Namespace in which to register the icon set.
|
|
216
|
+
* @param literal SVG source of the icon set.
|
|
217
|
+
*/
|
|
218
|
+
addSvgIconSetLiteralInNamespace(namespace, literal, options) {
|
|
219
|
+
const cleanLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
220
|
+
if (!cleanLiteral) {
|
|
221
|
+
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
222
|
+
}
|
|
223
|
+
// Security: The literal is passed in as SafeHtml, and is thus trusted.
|
|
224
|
+
const trustedLiteral = trustedHTMLFromString(cleanLiteral);
|
|
225
|
+
return this._addSvgIconSetConfig(namespace, new SvgIconConfig('', trustedLiteral, options));
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Defines an alias for CSS class names to be used for icon fonts. Creating an matIcon
|
|
229
|
+
* component with the alias as the fontSet input will cause the class name to be applied
|
|
230
|
+
* to the `<mat-icon>` element.
|
|
231
|
+
*
|
|
232
|
+
* If the registered font is a ligature font, then don't forget to also include the special
|
|
233
|
+
* class `mat-ligature-font` to allow the usage via attribute. So register like this:
|
|
234
|
+
*
|
|
235
|
+
* ```ts
|
|
236
|
+
* iconRegistry.registerFontClassAlias('f1', 'font1 mat-ligature-font');
|
|
237
|
+
* ```
|
|
238
|
+
*
|
|
239
|
+
* And use like this:
|
|
240
|
+
*
|
|
241
|
+
* ```html
|
|
242
|
+
* <mat-icon fontSet="f1" fontIcon="home"></mat-icon>
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @param alias Alias for the font.
|
|
246
|
+
* @param classNames Class names override to be used instead of the alias.
|
|
247
|
+
*/
|
|
248
|
+
registerFontClassAlias(alias, classNames = alias) {
|
|
249
|
+
this._fontCssClassesByAlias.set(alias, classNames);
|
|
250
|
+
return this;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Returns the CSS class name associated with the alias by a previous call to
|
|
254
|
+
* registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
|
|
255
|
+
*/
|
|
256
|
+
classNameForFontAlias(alias) {
|
|
257
|
+
return this._fontCssClassesByAlias.get(alias) || alias;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sets the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
|
|
261
|
+
* have a fontSet input value, and is not loading an icon by name or URL.
|
|
262
|
+
*/
|
|
263
|
+
setDefaultFontSetClass(...classNames) {
|
|
264
|
+
this._defaultFontSetClass = classNames;
|
|
265
|
+
return this;
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Returns the CSS classes to be used for icon fonts when an `<mat-icon>` component does not
|
|
269
|
+
* have a fontSet input value, and is not loading an icon by name or URL.
|
|
270
|
+
*/
|
|
271
|
+
getDefaultFontSetClass() {
|
|
272
|
+
return this._defaultFontSetClass;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
|
|
276
|
+
* The response from the URL may be cached so this will not always cause an HTTP request, but
|
|
277
|
+
* the produced element will always be a new copy of the originally fetched icon. (That is,
|
|
278
|
+
* it will not contain any modifications made to elements previously returned).
|
|
279
|
+
*
|
|
280
|
+
* @param safeUrl URL from which to fetch the SVG icon.
|
|
281
|
+
*/
|
|
282
|
+
getSvgIconFromUrl(safeUrl) {
|
|
283
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
|
284
|
+
if (!url) {
|
|
285
|
+
throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
|
286
|
+
}
|
|
287
|
+
const cachedIcon = this._cachedIconsByUrl.get(url);
|
|
288
|
+
if (cachedIcon) {
|
|
289
|
+
return of(cloneSvg(cachedIcon));
|
|
290
|
+
}
|
|
291
|
+
return this._loadSvgIconFromConfig(new SvgIconConfig(safeUrl, null)).pipe(tap(svg => this._cachedIconsByUrl.set(url, svg)), map(svg => cloneSvg(svg)));
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
|
|
295
|
+
* and namespace. The icon must have been previously registered with addIcon or addIconSet;
|
|
296
|
+
* if not, the Observable will throw an error.
|
|
297
|
+
*
|
|
298
|
+
* @param name Name of the icon to be retrieved.
|
|
299
|
+
* @param namespace Namespace in which to look for the icon.
|
|
300
|
+
*/
|
|
301
|
+
getNamedSvgIcon(name, namespace = '') {
|
|
302
|
+
const key = iconKey(namespace, name);
|
|
303
|
+
let config = this._svgIconConfigs.get(key);
|
|
304
|
+
// Return (copy of) cached icon if possible.
|
|
305
|
+
if (config) {
|
|
306
|
+
return this._getSvgFromConfig(config);
|
|
307
|
+
}
|
|
308
|
+
// Otherwise try to resolve the config from one of the resolver functions.
|
|
309
|
+
config = this._getIconConfigFromResolvers(namespace, name);
|
|
310
|
+
if (config) {
|
|
311
|
+
this._svgIconConfigs.set(key, config);
|
|
312
|
+
return this._getSvgFromConfig(config);
|
|
313
|
+
}
|
|
314
|
+
// See if we have any icon sets registered for the namespace.
|
|
315
|
+
const iconSetConfigs = this._iconSetConfigs.get(namespace);
|
|
316
|
+
if (iconSetConfigs) {
|
|
317
|
+
return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
|
|
318
|
+
}
|
|
319
|
+
return throwError(getMatIconNameNotFoundError(key));
|
|
320
|
+
}
|
|
321
|
+
ngOnDestroy() {
|
|
322
|
+
this._resolvers = [];
|
|
323
|
+
this._svgIconConfigs.clear();
|
|
324
|
+
this._iconSetConfigs.clear();
|
|
325
|
+
this._cachedIconsByUrl.clear();
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
|
|
329
|
+
*/
|
|
330
|
+
_getSvgFromConfig(config) {
|
|
331
|
+
if (config.svgText) {
|
|
332
|
+
// We already have the SVG element for this icon, return a copy.
|
|
333
|
+
return of(cloneSvg(this._svgElementFromConfig(config)));
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
// Fetch the icon from the config's URL, cache it, and return a copy.
|
|
337
|
+
return this._loadSvgIconFromConfig(config).pipe(map(svg => cloneSvg(svg)));
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Attempts to find an icon with the specified name in any of the SVG icon sets.
|
|
342
|
+
* First searches the available cached icons for a nested element with a matching name, and
|
|
343
|
+
* if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
|
|
344
|
+
* that have not been cached, and searches again after all fetches are completed.
|
|
345
|
+
* The returned Observable produces the SVG element if possible, and throws
|
|
346
|
+
* an error if no icon with the specified name can be found.
|
|
347
|
+
*/
|
|
348
|
+
_getSvgFromIconSetConfigs(name, iconSetConfigs) {
|
|
349
|
+
// For all the icon set SVG elements we've fetched, see if any contain an icon with the
|
|
350
|
+
// requested name.
|
|
351
|
+
const namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
|
352
|
+
if (namedIcon) {
|
|
353
|
+
// We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
|
|
354
|
+
// time anyway, there's probably not much advantage compared to just always extracting
|
|
355
|
+
// it from the icon set.
|
|
356
|
+
return of(namedIcon);
|
|
357
|
+
}
|
|
358
|
+
// Not found in any cached icon sets. If there are icon sets with URLs that we haven't
|
|
359
|
+
// fetched, fetch them now and look for iconName in the results.
|
|
360
|
+
const iconSetFetchRequests = iconSetConfigs
|
|
361
|
+
.filter(iconSetConfig => !iconSetConfig.svgText)
|
|
362
|
+
.map(iconSetConfig => {
|
|
363
|
+
return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(catchError((err) => {
|
|
364
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
|
|
365
|
+
// Swallow errors fetching individual URLs so the
|
|
366
|
+
// combined Observable won't necessarily fail.
|
|
367
|
+
const errorMessage = `Loading icon set URL: ${url} failed: ${err.message}`;
|
|
368
|
+
this._errorHandler.handleError(new Error(errorMessage));
|
|
369
|
+
return of(null);
|
|
370
|
+
}));
|
|
371
|
+
});
|
|
372
|
+
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
|
|
373
|
+
// cached SVG element (unless the request failed), and we can check again for the icon.
|
|
374
|
+
return forkJoin(iconSetFetchRequests).pipe(map(() => {
|
|
375
|
+
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
|
376
|
+
// TODO: add an ngDevMode check
|
|
377
|
+
if (!foundIcon) {
|
|
378
|
+
throw getMatIconNameNotFoundError(name);
|
|
379
|
+
}
|
|
380
|
+
return foundIcon;
|
|
381
|
+
}));
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
|
|
385
|
+
* tag matches the specified name. If found, copies the nested element to a new SVG element and
|
|
386
|
+
* returns it. Returns null if no matching element is found.
|
|
387
|
+
*/
|
|
388
|
+
_extractIconWithNameFromAnySet(iconName, iconSetConfigs) {
|
|
389
|
+
// Iterate backwards, so icon sets added later have precedence.
|
|
390
|
+
for (let i = iconSetConfigs.length - 1; i >= 0; i--) {
|
|
391
|
+
const config = iconSetConfigs[i];
|
|
392
|
+
// Parsing the icon set's text into an SVG element can be expensive. We can avoid some of
|
|
393
|
+
// the parsing by doing a quick check using `indexOf` to see if there's any chance for the
|
|
394
|
+
// icon to be in the set. This won't be 100% accurate, but it should help us avoid at least
|
|
395
|
+
// some of the parsing.
|
|
396
|
+
if (config.svgText && config.svgText.toString().indexOf(iconName) > -1) {
|
|
397
|
+
const svg = this._svgElementFromConfig(config);
|
|
398
|
+
const foundIcon = this._extractSvgIconFromSet(svg, iconName, config.options);
|
|
399
|
+
if (foundIcon) {
|
|
400
|
+
return foundIcon;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
return null;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
|
|
408
|
+
* from it.
|
|
409
|
+
*/
|
|
410
|
+
_loadSvgIconFromConfig(config) {
|
|
411
|
+
return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)), map(() => this._svgElementFromConfig(config)));
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Loads the content of the icon set URL specified in the
|
|
415
|
+
* SvgIconConfig and attaches it to the config.
|
|
416
|
+
*/
|
|
417
|
+
_loadSvgIconSetFromConfig(config) {
|
|
418
|
+
if (config.svgText) {
|
|
419
|
+
return of(null);
|
|
420
|
+
}
|
|
421
|
+
return this._fetchIcon(config).pipe(tap(svgText => (config.svgText = svgText)));
|
|
422
|
+
}
|
|
423
|
+
/**
|
|
424
|
+
* Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
|
|
425
|
+
* tag matches the specified name. If found, copies the nested element to a new SVG element and
|
|
426
|
+
* returns it. Returns null if no matching element is found.
|
|
427
|
+
*/
|
|
428
|
+
_extractSvgIconFromSet(iconSet, iconName, options) {
|
|
429
|
+
// Use the `id="iconName"` syntax in order to escape special
|
|
430
|
+
// characters in the ID (versus using the #iconName syntax).
|
|
431
|
+
const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
|
|
432
|
+
if (!iconSource) {
|
|
433
|
+
return null;
|
|
434
|
+
}
|
|
435
|
+
// Clone the element and remove the ID to prevent multiple elements from being added
|
|
436
|
+
// to the page with the same ID.
|
|
437
|
+
const iconElement = iconSource.cloneNode(true);
|
|
438
|
+
iconElement.removeAttribute('id');
|
|
439
|
+
// If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
|
|
440
|
+
// the content of a new <svg> node.
|
|
441
|
+
if (iconElement.nodeName.toLowerCase() === 'svg') {
|
|
442
|
+
return this._setSvgAttributes(iconElement, options);
|
|
443
|
+
}
|
|
444
|
+
// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
|
|
445
|
+
// that the same could be achieved by referring to it via <use href="#id">, however the <use>
|
|
446
|
+
// tag is problematic on Firefox, because it needs to include the current page path.
|
|
447
|
+
if (iconElement.nodeName.toLowerCase() === 'symbol') {
|
|
448
|
+
return this._setSvgAttributes(this._toSvgElement(iconElement), options);
|
|
449
|
+
}
|
|
450
|
+
// createElement('SVG') doesn't work as expected; the DOM ends up with
|
|
451
|
+
// the correct nodes, but the SVG content doesn't render. Instead we
|
|
452
|
+
// have to create an empty SVG node using innerHTML and append its content.
|
|
453
|
+
// Elements created using DOMParser.parseFromString have the same problem.
|
|
454
|
+
// http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
|
|
455
|
+
const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
|
|
456
|
+
// Clone the node so we don't remove it from the parent icon set element.
|
|
457
|
+
svg.appendChild(iconElement);
|
|
458
|
+
return this._setSvgAttributes(svg, options);
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Creates a DOM element from the given SVG string.
|
|
462
|
+
*/
|
|
463
|
+
_svgElementFromString(str) {
|
|
464
|
+
const div = this._document.createElement('DIV');
|
|
465
|
+
div.innerHTML = str;
|
|
466
|
+
const svg = div.querySelector('svg');
|
|
467
|
+
// TODO: add an ngDevMode check
|
|
468
|
+
if (!svg) {
|
|
469
|
+
throw Error('<svg> tag not found');
|
|
470
|
+
}
|
|
471
|
+
return svg;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* Converts an element into an SVG node by cloning all of its children.
|
|
475
|
+
*/
|
|
476
|
+
_toSvgElement(element) {
|
|
477
|
+
const svg = this._svgElementFromString(trustedHTMLFromString('<svg></svg>'));
|
|
478
|
+
const attributes = element.attributes;
|
|
479
|
+
// Copy over all the attributes from the `symbol` to the new SVG, except the id.
|
|
480
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
481
|
+
const { name, value } = attributes[i];
|
|
482
|
+
if (name !== 'id') {
|
|
483
|
+
svg.setAttribute(name, value);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
487
|
+
if (element.childNodes[i].nodeType === this._document.ELEMENT_NODE) {
|
|
488
|
+
svg.appendChild(element.childNodes[i].cloneNode(true));
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return svg;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Sets the default attributes for an SVG element to be used as an icon.
|
|
495
|
+
*/
|
|
496
|
+
_setSvgAttributes(svg, options) {
|
|
497
|
+
svg.setAttribute('fit', '');
|
|
498
|
+
svg.setAttribute('height', '100%');
|
|
499
|
+
svg.setAttribute('width', '100%');
|
|
500
|
+
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
|
501
|
+
svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
|
|
502
|
+
if (options && options.viewBox) {
|
|
503
|
+
svg.setAttribute('viewBox', options.viewBox);
|
|
504
|
+
}
|
|
505
|
+
return svg;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Returns an Observable which produces the string contents of the given icon. Results may be
|
|
509
|
+
* cached, so future calls with the same URL may not cause another HTTP request.
|
|
510
|
+
*/
|
|
511
|
+
_fetchIcon(iconConfig) {
|
|
512
|
+
const { url: safeUrl, options } = iconConfig;
|
|
513
|
+
const withCredentials = options?.withCredentials ?? false;
|
|
514
|
+
if (!this._httpClient) {
|
|
515
|
+
throw getMatIconNoHttpProviderError();
|
|
516
|
+
}
|
|
517
|
+
// TODO: add an ngDevMode check
|
|
518
|
+
if (safeUrl == null) {
|
|
519
|
+
throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
|
|
520
|
+
}
|
|
521
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
|
522
|
+
// TODO: add an ngDevMode check
|
|
523
|
+
if (!url) {
|
|
524
|
+
throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
|
525
|
+
}
|
|
526
|
+
// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
|
|
527
|
+
// already a request in progress for that URL. It's necessary to call share() on the
|
|
528
|
+
// Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
|
|
529
|
+
const inProgressFetch = this._inProgressUrlFetches.get(url);
|
|
530
|
+
if (inProgressFetch) {
|
|
531
|
+
return inProgressFetch;
|
|
532
|
+
}
|
|
533
|
+
const req = this._httpClient.get(url, { responseType: 'text', withCredentials }).pipe(map(svg => {
|
|
534
|
+
// Security: This SVG is fetched from a SafeResourceUrl, and is thus
|
|
535
|
+
// trusted HTML.
|
|
536
|
+
return trustedHTMLFromString(svg);
|
|
537
|
+
}), finalize(() => this._inProgressUrlFetches.delete(url)), share());
|
|
538
|
+
this._inProgressUrlFetches.set(url, req);
|
|
539
|
+
return req;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* Registers an icon config by name in the specified namespace.
|
|
543
|
+
* @param namespace Namespace in which to register the icon config.
|
|
544
|
+
* @param iconName Name under which to register the config.
|
|
545
|
+
* @param config Config to be registered.
|
|
546
|
+
*/
|
|
547
|
+
_addSvgIconConfig(namespace, iconName, config) {
|
|
548
|
+
this._svgIconConfigs.set(iconKey(namespace, iconName), config);
|
|
549
|
+
return this;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* Registers an icon set config in the specified namespace.
|
|
553
|
+
* @param namespace Namespace in which to register the icon config.
|
|
554
|
+
* @param config Config to be registered.
|
|
555
|
+
*/
|
|
556
|
+
_addSvgIconSetConfig(namespace, config) {
|
|
557
|
+
const configNamespace = this._iconSetConfigs.get(namespace);
|
|
558
|
+
if (configNamespace) {
|
|
559
|
+
configNamespace.push(config);
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
this._iconSetConfigs.set(namespace, [config]);
|
|
563
|
+
}
|
|
564
|
+
return this;
|
|
565
|
+
}
|
|
566
|
+
/** Parses a config's text into an SVG element. */
|
|
567
|
+
_svgElementFromConfig(config) {
|
|
568
|
+
if (!config.svgElement) {
|
|
569
|
+
const svg = this._svgElementFromString(config.svgText);
|
|
570
|
+
this._setSvgAttributes(svg, config.options);
|
|
571
|
+
config.svgElement = svg;
|
|
572
|
+
}
|
|
573
|
+
return config.svgElement;
|
|
574
|
+
}
|
|
575
|
+
/** Tries to create an icon config through the registered resolver functions. */
|
|
576
|
+
_getIconConfigFromResolvers(namespace, name) {
|
|
577
|
+
for (let i = 0; i < this._resolvers.length; i++) {
|
|
578
|
+
const result = this._resolvers[i](name, namespace);
|
|
579
|
+
if (result) {
|
|
580
|
+
return isSafeUrlWithOptions(result)
|
|
581
|
+
? new SvgIconConfig(result.url, null, result.options)
|
|
582
|
+
: new SvgIconConfig(result, null);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
return undefined;
|
|
586
|
+
}
|
|
587
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: MatIconRegistry, deps: [{ token: i1.HttpClient, optional: true }, { token: i2.DomSanitizer }, { token: DOCUMENT, optional: true }, { token: i0.ErrorHandler }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
588
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: MatIconRegistry, providedIn: 'root' });
|
|
589
|
+
}
|
|
590
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: MatIconRegistry, decorators: [{
|
|
591
|
+
type: Injectable,
|
|
592
|
+
args: [{ providedIn: 'root' }]
|
|
593
|
+
}], ctorParameters: () => [{ type: i1.HttpClient, decorators: [{
|
|
594
|
+
type: Optional
|
|
595
|
+
}] }, { type: i2.DomSanitizer }, { type: undefined, decorators: [{
|
|
596
|
+
type: Optional
|
|
597
|
+
}, {
|
|
598
|
+
type: Inject,
|
|
599
|
+
args: [DOCUMENT]
|
|
600
|
+
}] }, { type: i0.ErrorHandler }] });
|
|
601
|
+
/**
|
|
602
|
+
* @docs-private
|
|
603
|
+
* @deprecated No longer used, will be removed.
|
|
604
|
+
* @breaking-change 21.0.0
|
|
605
|
+
*/
|
|
606
|
+
function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry, httpClient, sanitizer, errorHandler, document) {
|
|
607
|
+
return parentRegistry || new MatIconRegistry(httpClient, sanitizer, document, errorHandler);
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* @docs-private
|
|
611
|
+
* @deprecated No longer used, will be removed.
|
|
612
|
+
* @breaking-change 21.0.0
|
|
613
|
+
*/
|
|
614
|
+
const ICON_REGISTRY_PROVIDER = {
|
|
615
|
+
// If there is already an MatIconRegistry available, use that. Otherwise, provide a new one.
|
|
616
|
+
provide: MatIconRegistry,
|
|
617
|
+
deps: [
|
|
618
|
+
[new Optional(), new SkipSelf(), MatIconRegistry],
|
|
619
|
+
[new Optional(), HttpClient],
|
|
620
|
+
DomSanitizer,
|
|
621
|
+
ErrorHandler,
|
|
622
|
+
[new Optional(), DOCUMENT],
|
|
623
|
+
],
|
|
624
|
+
useFactory: ICON_REGISTRY_PROVIDER_FACTORY,
|
|
625
|
+
};
|
|
626
|
+
/** Clones an SVGElement while preserving type information. */
|
|
627
|
+
function cloneSvg(svg) {
|
|
628
|
+
return svg.cloneNode(true);
|
|
629
|
+
}
|
|
630
|
+
/** Returns the cache key to use for an icon namespace and name. */
|
|
631
|
+
function iconKey(namespace, name) {
|
|
632
|
+
return namespace + ':' + name;
|
|
633
|
+
}
|
|
634
|
+
function isSafeUrlWithOptions(value) {
|
|
635
|
+
return !!(value.url && value.options);
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
export { ICON_REGISTRY_PROVIDER_FACTORY as I, MatIconRegistry as M, getMatIconNoHttpProviderError as a, getMatIconFailedToSanitizeUrlError as b, getMatIconFailedToSanitizeLiteralError as c, ICON_REGISTRY_PROVIDER as d, getMatIconNameNotFoundError as g };
|
|
639
|
+
//# sourceMappingURL=icon-registry-13a3b98e.mjs.map
|