@angular/material 10.0.0-rc.3 → 10.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_theming.scss +17 -17
- package/autocomplete/index.metadata.json +1 -1
- package/autocomplete/testing/autocomplete-harness.d.ts +2 -0
- package/bundles/material-autocomplete-testing.umd.js +11 -0
- package/bundles/material-autocomplete-testing.umd.js.map +1 -1
- package/bundles/material-autocomplete-testing.umd.min.js +2 -2
- package/bundles/material-autocomplete-testing.umd.min.js.map +1 -1
- package/bundles/material-autocomplete.umd.js +3 -1
- package/bundles/material-autocomplete.umd.js.map +1 -1
- package/bundles/material-autocomplete.umd.min.js +5 -5
- package/bundles/material-autocomplete.umd.min.js.map +1 -1
- package/bundles/material-badge-testing.umd.min.js +1 -1
- package/bundles/material-badge-testing.umd.min.js.map +1 -1
- package/bundles/material-bottom-sheet-testing.umd.min.js +1 -1
- package/bundles/material-bottom-sheet-testing.umd.min.js.map +1 -1
- package/bundles/material-button-testing.umd.js +11 -0
- package/bundles/material-button-testing.umd.js.map +1 -1
- package/bundles/material-button-testing.umd.min.js +2 -2
- package/bundles/material-button-testing.umd.min.js.map +1 -1
- package/bundles/material-button-toggle-testing.umd.js +11 -0
- package/bundles/material-button-toggle-testing.umd.js.map +1 -1
- package/bundles/material-button-toggle-testing.umd.min.js +3 -3
- package/bundles/material-button-toggle-testing.umd.min.js.map +1 -1
- package/bundles/material-button-toggle.umd.js +12 -3
- package/bundles/material-button-toggle.umd.js.map +1 -1
- package/bundles/material-button-toggle.umd.min.js +2 -2
- package/bundles/material-button-toggle.umd.min.js.map +1 -1
- package/bundles/material-button.umd.js +7 -2
- package/bundles/material-button.umd.js.map +1 -1
- package/bundles/material-button.umd.min.js +4 -4
- package/bundles/material-button.umd.min.js.map +1 -1
- package/bundles/material-card-testing.umd.js +335 -0
- package/bundles/material-card-testing.umd.js.map +1 -0
- package/bundles/material-card-testing.umd.min.js +44 -0
- package/bundles/material-card-testing.umd.min.js.map +1 -0
- package/bundles/material-checkbox-testing.umd.js +11 -0
- package/bundles/material-checkbox-testing.umd.js.map +1 -1
- package/bundles/material-checkbox-testing.umd.min.js +3 -3
- package/bundles/material-checkbox-testing.umd.min.js.map +1 -1
- package/bundles/material-checkbox.umd.js.map +1 -1
- package/bundles/material-chips.umd.js +36 -12
- package/bundles/material-chips.umd.js.map +1 -1
- package/bundles/material-chips.umd.min.js +4 -4
- package/bundles/material-chips.umd.min.js.map +1 -1
- package/bundles/material-core-testing.umd.min.js +1 -1
- package/bundles/material-core-testing.umd.min.js.map +1 -1
- package/bundles/material-core.umd.js +11 -3
- package/bundles/material-core.umd.js.map +1 -1
- package/bundles/material-core.umd.min.js +11 -11
- package/bundles/material-core.umd.min.js.map +1 -1
- package/bundles/material-datepicker.umd.js +20 -11
- package/bundles/material-datepicker.umd.js.map +1 -1
- package/bundles/material-datepicker.umd.min.js +5 -5
- package/bundles/material-datepicker.umd.min.js.map +1 -1
- package/bundles/material-dialog-testing.umd.min.js +1 -1
- package/bundles/material-dialog-testing.umd.min.js.map +1 -1
- package/bundles/material-dialog.umd.js +45 -8
- package/bundles/material-dialog.umd.js.map +1 -1
- package/bundles/material-dialog.umd.min.js +14 -7
- package/bundles/material-dialog.umd.min.js.map +1 -1
- package/bundles/material-divider-testing.umd.min.js +1 -1
- package/bundles/material-divider-testing.umd.min.js.map +1 -1
- package/bundles/material-expansion-testing.umd.js +11 -0
- package/bundles/material-expansion-testing.umd.js.map +1 -1
- package/bundles/material-expansion-testing.umd.min.js +3 -3
- package/bundles/material-expansion-testing.umd.min.js.map +1 -1
- package/bundles/material-form-field-testing.umd.js +32 -0
- package/bundles/material-form-field-testing.umd.js.map +1 -1
- package/bundles/material-form-field-testing.umd.min.js +4 -4
- package/bundles/material-form-field-testing.umd.min.js.map +1 -1
- package/bundles/material-form-field.umd.js +47 -21
- package/bundles/material-form-field.umd.js.map +1 -1
- package/bundles/material-form-field.umd.min.js +5 -5
- package/bundles/material-form-field.umd.min.js.map +1 -1
- package/bundles/material-grid-list-testing.umd.min.js +1 -1
- package/bundles/material-grid-list-testing.umd.min.js.map +1 -1
- package/bundles/material-grid-list.umd.js +2 -2
- package/bundles/material-grid-list.umd.js.map +1 -1
- package/bundles/material-grid-list.umd.min.js +2 -2
- package/bundles/material-grid-list.umd.min.js.map +1 -1
- package/bundles/material-input-testing.umd.js +23 -6
- package/bundles/material-input-testing.umd.js.map +1 -1
- package/bundles/material-input-testing.umd.min.js +3 -3
- package/bundles/material-input-testing.umd.min.js.map +1 -1
- package/bundles/material-input.umd.js +28 -3
- package/bundles/material-input.umd.js.map +1 -1
- package/bundles/material-input.umd.min.js +3 -3
- package/bundles/material-input.umd.min.js.map +1 -1
- package/bundles/material-list-testing.umd.js +33 -0
- package/bundles/material-list-testing.umd.js.map +1 -1
- package/bundles/material-list-testing.umd.min.js +2 -2
- package/bundles/material-list-testing.umd.min.js.map +1 -1
- package/bundles/material-list.umd.js +3 -3
- package/bundles/material-list.umd.min.js +1 -1
- package/bundles/material-list.umd.min.js.map +1 -1
- package/bundles/material-menu-testing.umd.js +22 -0
- package/bundles/material-menu-testing.umd.js.map +1 -1
- package/bundles/material-menu-testing.umd.min.js +2 -2
- package/bundles/material-menu-testing.umd.min.js.map +1 -1
- package/bundles/material-menu.umd.js +13 -2
- package/bundles/material-menu.umd.js.map +1 -1
- package/bundles/material-menu.umd.min.js +4 -4
- package/bundles/material-menu.umd.min.js.map +1 -1
- package/bundles/material-paginator-testing.umd.min.js +1 -1
- package/bundles/material-paginator-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-bar-testing.umd.min.js +1 -1
- package/bundles/material-progress-bar-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-spinner-testing.umd.js +1 -1
- package/bundles/material-progress-spinner-testing.umd.js.map +1 -1
- package/bundles/material-progress-spinner-testing.umd.min.js +2 -2
- package/bundles/material-progress-spinner-testing.umd.min.js.map +1 -1
- package/bundles/material-progress-spinner.umd.js +2 -2
- package/bundles/material-progress-spinner.umd.min.js +3 -3
- package/bundles/material-progress-spinner.umd.min.js.map +1 -1
- package/bundles/material-radio-testing.umd.js +11 -0
- package/bundles/material-radio-testing.umd.js.map +1 -1
- package/bundles/material-radio-testing.umd.min.js +3 -3
- package/bundles/material-radio-testing.umd.min.js.map +1 -1
- package/bundles/material-radio.umd.js +15 -5
- package/bundles/material-radio.umd.js.map +1 -1
- package/bundles/material-radio.umd.min.js +2 -2
- package/bundles/material-radio.umd.min.js.map +1 -1
- package/bundles/material-select-testing.umd.js +11 -0
- package/bundles/material-select-testing.umd.js.map +1 -1
- package/bundles/material-select-testing.umd.min.js +2 -2
- package/bundles/material-select-testing.umd.min.js.map +1 -1
- package/bundles/material-select.umd.js +11 -3
- package/bundles/material-select.umd.js.map +1 -1
- package/bundles/material-select.umd.min.js +4 -4
- package/bundles/material-select.umd.min.js.map +1 -1
- package/bundles/material-sidenav-testing.umd.min.js +1 -1
- package/bundles/material-sidenav-testing.umd.min.js.map +1 -1
- package/bundles/material-sidenav.umd.js +41 -17
- package/bundles/material-sidenav.umd.js.map +1 -1
- package/bundles/material-sidenav.umd.min.js +2 -2
- package/bundles/material-sidenav.umd.min.js.map +1 -1
- package/bundles/material-slide-toggle-testing.umd.js +11 -0
- package/bundles/material-slide-toggle-testing.umd.js.map +1 -1
- package/bundles/material-slide-toggle-testing.umd.min.js +2 -2
- package/bundles/material-slide-toggle-testing.umd.min.js.map +1 -1
- package/bundles/material-slide-toggle.umd.js.map +1 -1
- package/bundles/material-slider-testing.umd.js +11 -0
- package/bundles/material-slider-testing.umd.js.map +1 -1
- package/bundles/material-slider-testing.umd.min.js +2 -2
- package/bundles/material-slider-testing.umd.min.js.map +1 -1
- package/bundles/material-snack-bar-testing.umd.min.js +1 -1
- package/bundles/material-snack-bar-testing.umd.min.js.map +1 -1
- package/bundles/material-snack-bar.umd.js +47 -39
- package/bundles/material-snack-bar.umd.js.map +1 -1
- package/bundles/material-snack-bar.umd.min.js +2 -2
- package/bundles/material-snack-bar.umd.min.js.map +1 -1
- package/bundles/material-sort-testing.umd.js +10 -10
- package/bundles/material-sort-testing.umd.js.map +1 -1
- package/bundles/material-sort-testing.umd.min.js +3 -3
- package/bundles/material-sort-testing.umd.min.js.map +1 -1
- package/bundles/material-sort.umd.js +25 -12
- package/bundles/material-sort.umd.js.map +1 -1
- package/bundles/material-sort.umd.min.js +5 -5
- package/bundles/material-sort.umd.min.js.map +1 -1
- package/bundles/material-table-testing.umd.min.js +1 -1
- package/bundles/material-table-testing.umd.min.js.map +1 -1
- package/bundles/material-table.umd.min.js +2 -2
- package/bundles/material-table.umd.min.js.map +1 -1
- package/bundles/material-tabs-testing.umd.min.js +1 -1
- package/bundles/material-tabs-testing.umd.min.js.map +1 -1
- package/bundles/material-tabs.umd.js +23 -4
- package/bundles/material-tabs.umd.js.map +1 -1
- package/bundles/material-tabs.umd.min.js +5 -12
- package/bundles/material-tabs.umd.min.js.map +1 -1
- package/bundles/material-toolbar-testing.umd.js +330 -0
- package/bundles/material-toolbar-testing.umd.js.map +1 -0
- package/bundles/material-toolbar-testing.umd.min.js +44 -0
- package/bundles/material-toolbar-testing.umd.min.js.map +1 -0
- package/bundles/material-tooltip-testing.umd.min.js +1 -1
- package/bundles/material-tooltip-testing.umd.min.js.map +1 -1
- package/bundles/material-tooltip.umd.js +14 -1
- package/bundles/material-tooltip.umd.js.map +1 -1
- package/bundles/material-tooltip.umd.min.js +3 -3
- package/bundles/material-tooltip.umd.min.js.map +1 -1
- package/bundles/material-tree.umd.js.map +1 -1
- package/button/_button-base.scss +1 -1
- package/button/_button-theme.scss +8 -8
- package/button/index.metadata.json +1 -1
- package/button/testing/button-harness.d.ts +2 -0
- package/button-toggle/button-toggle.d.ts +10 -3
- package/button-toggle/index.metadata.json +1 -1
- package/button-toggle/testing/button-toggle-harness.d.ts +2 -0
- package/card/testing/card-harness-filters.d.ts +17 -0
- package/card/testing/card-harness.d.ts +36 -0
- package/card/testing/index.d.ts +8 -0
- package/card/testing/package.json +9 -0
- package/card/testing/public-api.d.ts +9 -0
- package/checkbox/index.metadata.json +1 -1
- package/checkbox/testing/checkbox-harness.d.ts +2 -0
- package/chips/chip.d.ts +19 -1
- package/chips/index.metadata.json +1 -1
- package/core/focus-indicators/_focus-indicators.scss +6 -6
- package/core/index.metadata.json +1 -1
- package/core/option/optgroup.d.ts +7 -0
- package/core/ripple/ripple-ref.d.ts +21 -2
- package/core/ripple/ripple-renderer.d.ts +1 -19
- package/core/ripple/ripple.d.ts +2 -2
- package/core/style/_list-common.scss +1 -1
- package/datepicker/date-range-input-parts.d.ts +2 -4
- package/datepicker/date-range-input.d.ts +4 -4
- package/datepicker/date-range-picker.d.ts +10 -3
- package/datepicker/datepicker.d.ts +2 -3
- package/datepicker/index.metadata.json +1 -1
- package/datepicker/public-api.d.ts +1 -1
- package/dialog/dialog-container.d.ts +9 -2
- package/dialog/dialog-content-directives.d.ts +1 -0
- package/dialog/dialog-ref.d.ts +7 -0
- package/dialog/index.metadata.json +1 -1
- package/esm2015/autocomplete/autocomplete-module.js +18 -22
- package/esm2015/autocomplete/autocomplete-origin.js +16 -20
- package/esm2015/autocomplete/autocomplete-trigger.js +519 -521
- package/esm2015/autocomplete/autocomplete.js +126 -130
- package/esm2015/autocomplete/testing/autocomplete-harness.js +99 -97
- package/esm2015/badge/badge-module.js +13 -17
- package/esm2015/badge/badge.js +184 -188
- package/esm2015/badge/testing/badge-harness.js +74 -78
- package/esm2015/bottom-sheet/bottom-sheet-container.js +161 -165
- package/esm2015/bottom-sheet/bottom-sheet-module.js +15 -19
- package/esm2015/bottom-sheet/bottom-sheet.js +124 -128
- package/esm2015/bottom-sheet/testing/bottom-sheet-harness.js +29 -33
- package/esm2015/button/button-module.js +20 -24
- package/esm2015/button/button.js +111 -114
- package/esm2015/button/testing/button-harness.js +60 -58
- package/esm2015/button-toggle/button-toggle-module.js +10 -14
- package/esm2015/button-toggle/button-toggle.js +368 -368
- package/esm2015/button-toggle/testing/button-toggle-group-harness.js +42 -46
- package/esm2015/button-toggle/testing/button-toggle-harness.js +113 -111
- package/esm2015/card/card-module.js +30 -34
- package/esm2015/card/card.js +147 -203
- package/esm2015/card/testing/card-harness-filters.js +8 -0
- package/esm2015/card/testing/card-harness.js +52 -0
- package/esm2015/card/testing/index.js +9 -0
- package/esm2015/card/testing/public-api.js +10 -0
- package/esm2015/card/testing/testing.externs.js +0 -0
- package/esm2015/checkbox/checkbox-module.js +21 -29
- package/esm2015/checkbox/checkbox-required-validator.js +9 -13
- package/esm2015/checkbox/checkbox.js +315 -319
- package/esm2015/checkbox/testing/checkbox-harness.js +150 -148
- package/esm2015/chips/chip-input.js +119 -123
- package/esm2015/chips/chip-list.js +572 -576
- package/esm2015/chips/chip.js +333 -328
- package/esm2015/chips/chips-module.js +16 -20
- package/esm2015/core/animation/animation.js +12 -20
- package/esm2015/core/common-behaviors/common-module.js +91 -95
- package/esm2015/core/datetime/index.js +19 -27
- package/esm2015/core/datetime/native-date-adapter.js +202 -206
- package/esm2015/core/error/error-options.js +16 -24
- package/esm2015/core/line/line.js +18 -26
- package/esm2015/core/option/index.js +10 -14
- package/esm2015/core/option/optgroup.js +36 -33
- package/esm2015/core/option/option.js +181 -185
- package/esm2015/core/ripple/index.js +10 -14
- package/esm2015/core/ripple/ripple-ref.js +1 -1
- package/esm2015/core/ripple/ripple-renderer.js +1 -1
- package/esm2015/core/ripple/ripple.js +102 -106
- package/esm2015/core/selection/index.js +9 -13
- package/esm2015/core/selection/pseudo-checkbox/pseudo-checkbox.js +32 -36
- package/esm2015/core/testing/optgroup-harness.js +39 -43
- package/esm2015/core/testing/option-harness.js +51 -55
- package/esm2015/core/version.js +1 -1
- package/esm2015/datepicker/calendar-body.js +214 -218
- package/esm2015/datepicker/calendar.js +295 -303
- package/esm2015/datepicker/date-range-input-parts.js +214 -229
- package/esm2015/datepicker/date-range-input.js +244 -242
- package/esm2015/datepicker/date-range-picker.js +19 -23
- package/esm2015/datepicker/date-range-selection-strategy.js +31 -35
- package/esm2015/datepicker/date-selection-model.js +110 -122
- package/esm2015/datepicker/datepicker-base.js +418 -426
- package/esm2015/datepicker/datepicker-input-base.js +227 -224
- package/esm2015/datepicker/datepicker-input.js +111 -115
- package/esm2015/datepicker/datepicker-intl.js +37 -41
- package/esm2015/datepicker/datepicker-module.js +62 -66
- package/esm2015/datepicker/datepicker-toggle.js +81 -89
- package/esm2015/datepicker/datepicker.js +13 -17
- package/esm2015/datepicker/month-view.js +283 -287
- package/esm2015/datepicker/multi-year-view.js +198 -202
- package/esm2015/datepicker/public-api.js +2 -2
- package/esm2015/datepicker/year-view.js +220 -224
- package/esm2015/dialog/dialog-container.js +175 -164
- package/esm2015/dialog/dialog-content-directives.js +105 -114
- package/esm2015/dialog/dialog-module.js +32 -36
- package/esm2015/dialog/dialog-ref.js +17 -3
- package/esm2015/dialog/dialog.js +236 -240
- package/esm2015/dialog/testing/dialog-harness.js +58 -62
- package/esm2015/divider/divider-module.js +10 -14
- package/esm2015/divider/divider.js +33 -37
- package/esm2015/divider/testing/divider-harness.js +16 -20
- package/esm2015/expansion/accordion.js +73 -77
- package/esm2015/expansion/expansion-module.js +26 -30
- package/esm2015/expansion/expansion-panel-content.js +13 -17
- package/esm2015/expansion/expansion-panel-header.js +168 -180
- package/esm2015/expansion/expansion-panel.js +144 -152
- package/esm2015/expansion/testing/accordion-harness.js +24 -28
- package/esm2015/expansion/testing/expansion-harness.js +136 -134
- package/esm2015/form-field/error.js +26 -23
- package/esm2015/form-field/form-field-control.js +6 -10
- package/esm2015/form-field/form-field-module.js +31 -35
- package/esm2015/form-field/form-field.js +407 -409
- package/esm2015/form-field/hint.js +35 -29
- package/esm2015/form-field/label.js +8 -12
- package/esm2015/form-field/placeholder.js +8 -12
- package/esm2015/form-field/prefix.js +16 -13
- package/esm2015/form-field/suffix.js +16 -13
- package/esm2015/form-field/testing/form-field-harness.js +220 -206
- package/esm2015/grid-list/grid-list-module.js +26 -30
- package/esm2015/grid-list/grid-list.js +108 -112
- package/esm2015/grid-list/grid-tile.js +91 -111
- package/esm2015/grid-list/testing/grid-list-harness.js +62 -66
- package/esm2015/grid-list/testing/grid-tile-harness.js +69 -73
- package/esm2015/grid-list/tile-styler.js +1 -1
- package/esm2015/icon/icon-module.js +10 -14
- package/esm2015/icon/icon-registry.js +406 -410
- package/esm2015/icon/icon.js +228 -232
- package/esm2015/icon/testing/fake-icon-registry.js +66 -74
- package/esm2015/input/autosize.js +30 -34
- package/esm2015/input/input-module.js +21 -25
- package/esm2015/input/input.js +305 -284
- package/esm2015/input/testing/input-harness.js +129 -123
- package/esm2015/list/list-module.js +32 -36
- package/esm2015/list/list.js +165 -189
- package/esm2015/list/selection-list.js +503 -511
- package/esm2015/list/testing/action-list-harness.js +55 -57
- package/esm2015/list/testing/list-harness.js +31 -39
- package/esm2015/list/testing/list-item-harness-base.js +13 -17
- package/esm2015/list/testing/nav-list-harness.js +62 -64
- package/esm2015/list/testing/selection-list-harness.js +136 -138
- package/esm2015/menu/menu-content.js +74 -71
- package/esm2015/menu/menu-item.js +119 -123
- package/esm2015/menu/menu-module.js +29 -37
- package/esm2015/menu/menu-panel.js +1 -1
- package/esm2015/menu/menu-trigger.js +402 -405
- package/esm2015/menu/menu.js +329 -339
- package/esm2015/menu/testing/menu-harness.js +193 -189
- package/esm2015/paginator/paginator-intl.js +36 -40
- package/esm2015/paginator/paginator-module.js +16 -20
- package/esm2015/paginator/paginator.js +205 -209
- package/esm2015/paginator/testing/paginator-harness.js +91 -95
- package/esm2015/progress-bar/progress-bar-module.js +10 -14
- package/esm2015/progress-bar/progress-bar.js +114 -118
- package/esm2015/progress-bar/testing/progress-bar-harness.js +27 -31
- package/esm2015/progress-spinner/progress-spinner-module.js +17 -21
- package/esm2015/progress-spinner/progress-spinner.js +181 -189
- package/esm2015/progress-spinner/testing/progress-spinner-harness.js +28 -32
- package/esm2015/radio/radio-module.js +10 -14
- package/esm2015/radio/radio.js +437 -444
- package/esm2015/radio/testing/radio-harness.js +241 -243
- package/esm2015/select/select-module.js +23 -27
- package/esm2015/select/select.js +917 -918
- package/esm2015/select/testing/select-harness.js +138 -136
- package/esm2015/sidenav/drawer.js +632 -620
- package/esm2015/sidenav/sidenav-module.js +31 -35
- package/esm2015/sidenav/sidenav.js +104 -116
- package/esm2015/sidenav/testing/drawer-harness.js +40 -44
- package/esm2015/sidenav/testing/sidenav-harness.js +20 -24
- package/esm2015/slide-toggle/slide-toggle-module.js +27 -35
- package/esm2015/slide-toggle/slide-toggle-required-validator.js +9 -13
- package/esm2015/slide-toggle/slide-toggle.js +184 -188
- package/esm2015/slide-toggle/testing/slide-toggle-harness.js +123 -121
- package/esm2015/slider/slider-module.js +10 -14
- package/esm2015/slider/slider.js +640 -644
- package/esm2015/slider/testing/slider-harness.js +129 -127
- package/esm2015/snack-bar/simple-snack-bar.js +32 -36
- package/esm2015/snack-bar/snack-bar-container.js +144 -148
- package/esm2015/snack-bar/snack-bar-module.js +17 -21
- package/esm2015/snack-bar/snack-bar-ref.js +1 -1
- package/esm2015/snack-bar/snack-bar.js +208 -205
- package/esm2015/snack-bar/testing/snack-bar-harness.js +112 -116
- package/esm2015/sort/sort-header-intl.js +21 -21
- package/esm2015/sort/sort-header.js +200 -194
- package/esm2015/sort/sort-module.js +11 -15
- package/esm2015/sort/sort.js +92 -96
- package/esm2015/sort/testing/sort-harness.js +28 -32
- package/esm2015/sort/testing/sort-header-harness.js +66 -67
- package/esm2015/stepper/step-header.js +78 -82
- package/esm2015/stepper/step-label.js +8 -12
- package/esm2015/stepper/stepper-button.js +23 -31
- package/esm2015/stepper/stepper-icon.js +16 -20
- package/esm2015/stepper/stepper-intl.js +15 -19
- package/esm2015/stepper/stepper-module.js +40 -44
- package/esm2015/stepper/stepper.js +139 -155
- package/esm2015/table/cell.js +94 -122
- package/esm2015/table/row.js +90 -118
- package/esm2015/table/table-module.js +13 -17
- package/esm2015/table/table.js +26 -30
- package/esm2015/table/testing/cell-harness.js +56 -68
- package/esm2015/table/testing/row-harness.js +90 -102
- package/esm2015/table/testing/table-harness.js +65 -69
- package/esm2015/table/text-column.js +17 -21
- package/esm2015/tabs/index.js +4 -2
- package/esm2015/tabs/ink-bar.js +55 -59
- package/esm2015/tabs/paginated-tab-header.js +415 -419
- package/esm2015/tabs/tab-body.js +179 -191
- package/esm2015/tabs/tab-content.js +21 -16
- package/esm2015/tabs/tab-group.js +263 -271
- package/esm2015/tabs/tab-header.js +69 -77
- package/esm2015/tabs/tab-label-wrapper.js +29 -33
- package/esm2015/tabs/tab-label.js +16 -13
- package/esm2015/tabs/tab-nav-bar/tab-nav-bar.js +199 -215
- package/esm2015/tabs/tab.js +80 -83
- package/esm2015/tabs/tabs-module.js +38 -42
- package/esm2015/tabs/testing/tab-group-harness.js +52 -56
- package/esm2015/tabs/testing/tab-harness.js +78 -82
- package/esm2015/toolbar/testing/index.js +9 -0
- package/esm2015/toolbar/testing/public-api.js +10 -0
- package/esm2015/toolbar/testing/testing.externs.js +0 -0
- package/esm2015/toolbar/testing/toolbar-harness-filters.js +8 -0
- package/esm2015/toolbar/testing/toolbar-harness.js +47 -0
- package/esm2015/toolbar/toolbar-module.js +10 -14
- package/esm2015/toolbar/toolbar.js +61 -69
- package/esm2015/tooltip/testing/tooltip-harness.js +43 -47
- package/esm2015/tooltip/tooltip-module.js +17 -21
- package/esm2015/tooltip/tooltip.js +502 -497
- package/esm2015/tree/data-source/flat-data-source.js +1 -1
- package/esm2015/tree/node.js +99 -111
- package/esm2015/tree/outlet.js +19 -23
- package/esm2015/tree/padding.js +13 -17
- package/esm2015/tree/toggle.js +15 -19
- package/esm2015/tree/tree-module.js +10 -14
- package/esm2015/tree/tree.js +23 -27
- package/expansion/testing/expansion-harness.d.ts +2 -0
- package/fesm2015/autocomplete/testing.js +98 -95
- package/fesm2015/autocomplete/testing.js.map +1 -1
- package/fesm2015/autocomplete.js +677 -687
- package/fesm2015/autocomplete.js.map +1 -1
- package/fesm2015/badge/testing.js +73 -76
- package/fesm2015/badge/testing.js.map +1 -1
- package/fesm2015/badge.js +195 -201
- package/fesm2015/badge.js.map +1 -1
- package/fesm2015/bottom-sheet/testing.js +28 -31
- package/fesm2015/bottom-sheet/testing.js.map +1 -1
- package/fesm2015/bottom-sheet.js +297 -306
- package/fesm2015/bottom-sheet.js.map +1 -1
- package/fesm2015/button/testing.js +59 -56
- package/fesm2015/button/testing.js.map +1 -1
- package/fesm2015/button-toggle/testing.js +155 -155
- package/fesm2015/button-toggle/testing.js.map +1 -1
- package/fesm2015/button-toggle.js +377 -378
- package/fesm2015/button-toggle.js.map +1 -1
- package/fesm2015/button.js +129 -133
- package/fesm2015/button.js.map +1 -1
- package/fesm2015/card/testing.js +79 -0
- package/fesm2015/card/testing.js.map +1 -0
- package/fesm2015/card.js +175 -220
- package/fesm2015/card.js.map +1 -1
- package/fesm2015/checkbox/testing.js +149 -146
- package/fesm2015/checkbox/testing.js.map +1 -1
- package/fesm2015/checkbox.js +342 -354
- package/fesm2015/checkbox.js.map +1 -1
- package/fesm2015/chips.js +1039 -1039
- package/fesm2015/chips.js.map +1 -1
- package/fesm2015/core/testing.js +88 -94
- package/fesm2015/core/testing.js.map +1 -1
- package/fesm2015/core.js +729 -773
- package/fesm2015/core.js.map +1 -1
- package/fesm2015/datepicker.js +2821 -2884
- package/fesm2015/datepicker.js.map +1 -1
- package/fesm2015/dialog/testing.js +57 -60
- package/fesm2015/dialog/testing.js.map +1 -1
- package/fesm2015/dialog.js +564 -549
- package/fesm2015/dialog.js.map +1 -1
- package/fesm2015/divider/testing.js +15 -18
- package/fesm2015/divider/testing.js.map +1 -1
- package/fesm2015/divider.js +41 -47
- package/fesm2015/divider.js.map +1 -1
- package/fesm2015/expansion/testing.js +159 -159
- package/fesm2015/expansion/testing.js.map +1 -1
- package/fesm2015/expansion.js +422 -446
- package/fesm2015/expansion.js.map +1 -1
- package/fesm2015/form-field/testing.js +219 -204
- package/fesm2015/form-field/testing.js.map +1 -1
- package/fesm2015/form-field.js +538 -532
- package/fesm2015/form-field.js.map +1 -1
- package/fesm2015/grid-list/testing.js +129 -135
- package/fesm2015/grid-list/testing.js.map +1 -1
- package/fesm2015/grid-list.js +221 -242
- package/fesm2015/grid-list.js.map +1 -1
- package/fesm2015/icon/testing.js +65 -71
- package/fesm2015/icon/testing.js.map +1 -1
- package/fesm2015/icon.js +660 -669
- package/fesm2015/icon.js.map +1 -1
- package/fesm2015/input/testing.js +128 -121
- package/fesm2015/input/testing.js.map +1 -1
- package/fesm2015/input.js +353 -337
- package/fesm2015/input.js.map +1 -1
- package/fesm2015/list/testing.js +298 -307
- package/fesm2015/list/testing.js.map +1 -1
- package/fesm2015/list.js +698 -725
- package/fesm2015/list.js.map +1 -1
- package/fesm2015/menu/testing.js +192 -186
- package/fesm2015/menu/testing.js.map +1 -1
- package/fesm2015/menu.js +948 -962
- package/fesm2015/menu.js.map +1 -1
- package/fesm2015/paginator/testing.js +90 -93
- package/fesm2015/paginator/testing.js.map +1 -1
- package/fesm2015/paginator.js +247 -256
- package/fesm2015/paginator.js.map +1 -1
- package/fesm2015/progress-bar/testing.js +26 -29
- package/fesm2015/progress-bar/testing.js.map +1 -1
- package/fesm2015/progress-bar.js +122 -128
- package/fesm2015/progress-bar.js.map +1 -1
- package/fesm2015/progress-spinner/testing.js +27 -30
- package/fesm2015/progress-spinner/testing.js.map +1 -1
- package/fesm2015/progress-spinner.js +196 -205
- package/fesm2015/progress-spinner.js.map +1 -1
- package/fesm2015/radio/testing.js +240 -240
- package/fesm2015/radio/testing.js.map +1 -1
- package/fesm2015/radio.js +447 -453
- package/fesm2015/radio.js.map +1 -1
- package/fesm2015/select/testing.js +137 -134
- package/fesm2015/select/testing.js.map +1 -1
- package/fesm2015/select.js +939 -941
- package/fesm2015/select.js.map +1 -1
- package/fesm2015/sidenav/testing.js +58 -64
- package/fesm2015/sidenav/testing.js.map +1 -1
- package/fesm2015/sidenav.js +765 -762
- package/fesm2015/sidenav.js.map +1 -1
- package/fesm2015/slide-toggle/testing.js +122 -119
- package/fesm2015/slide-toggle/testing.js.map +1 -1
- package/fesm2015/slide-toggle.js +217 -229
- package/fesm2015/slide-toggle.js.map +1 -1
- package/fesm2015/slider/testing.js +128 -125
- package/fesm2015/slider/testing.js.map +1 -1
- package/fesm2015/slider.js +648 -654
- package/fesm2015/slider.js.map +1 -1
- package/fesm2015/snack-bar/testing.js +111 -114
- package/fesm2015/snack-bar/testing.js.map +1 -1
- package/fesm2015/snack-bar.js +426 -431
- package/fesm2015/snack-bar.js.map +1 -1
- package/fesm2015/sort/testing.js +92 -95
- package/fesm2015/sort/testing.js.map +1 -1
- package/fesm2015/sort.js +320 -318
- package/fesm2015/sort.js.map +1 -1
- package/fesm2015/stepper.js +312 -345
- package/fesm2015/stepper.js.map +1 -1
- package/fesm2015/table/testing.js +208 -229
- package/fesm2015/table/testing.js.map +1 -1
- package/fesm2015/table.js +235 -286
- package/fesm2015/table.js.map +1 -1
- package/fesm2015/tabs/testing.js +128 -134
- package/fesm2015/tabs/testing.js.map +1 -1
- package/fesm2015/tabs.js +1362 -1399
- package/fesm2015/tabs.js.map +1 -1
- package/fesm2015/toolbar/testing.js +74 -0
- package/fesm2015/toolbar/testing.js.map +1 -0
- package/fesm2015/toolbar.js +69 -78
- package/fesm2015/toolbar.js.map +1 -1
- package/fesm2015/tooltip/testing.js +42 -45
- package/fesm2015/tooltip/testing.js.map +1 -1
- package/fesm2015/tooltip.js +517 -513
- package/fesm2015/tooltip.js.map +1 -1
- package/fesm2015/tree.js +173 -197
- package/fesm2015/tree.js.map +1 -1
- package/form-field/error.d.ts +7 -0
- package/form-field/hint.d.ts +10 -0
- package/form-field/index.metadata.json +1 -1
- package/form-field/prefix.d.ts +7 -0
- package/form-field/suffix.d.ts +7 -0
- package/form-field/testing/form-field-harness.d.ts +8 -0
- package/grid-list/grid-list.d.ts +2 -1
- package/grid-list/index.metadata.json +1 -1
- package/grid-list/tile-styler.d.ts +10 -5
- package/input/_input-theme.scss +2 -2
- package/input/index.metadata.json +1 -1
- package/input/input.d.ts +6 -2
- package/input/testing/input-harness.d.ts +2 -0
- package/list/index.metadata.json +1 -1
- package/list/testing/action-list-harness.d.ts +2 -0
- package/list/testing/nav-list-harness.d.ts +2 -0
- package/list/testing/selection-list-harness.d.ts +2 -0
- package/menu/index.metadata.json +1 -1
- package/menu/menu-content.d.ts +7 -1
- package/menu/menu-panel.d.ts +1 -0
- package/menu/menu.d.ts +4 -0
- package/menu/testing/menu-harness.d.ts +4 -0
- package/package.json +6 -6
- package/prebuilt-themes/deeppurple-amber.css +1 -1
- package/prebuilt-themes/indigo-pink.css +1 -1
- package/prebuilt-themes/pink-bluegrey.css +1 -1
- package/prebuilt-themes/purple-green.css +1 -1
- package/progress-spinner/index.metadata.json +1 -1
- package/radio/index.metadata.json +1 -1
- package/radio/radio.d.ts +6 -0
- package/radio/testing/radio-harness.d.ts +2 -0
- package/schematics/migration.json +5 -0
- package/schematics/ng-add/index.js +2 -2
- package/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +3 -3
- package/schematics/ng-generate/navigation/schema.json +5 -0
- package/schematics/ng-update/data/index.js +1 -1
- package/schematics/ng-update/index.d.ts +2 -0
- package/schematics/ng-update/index.js +7 -2
- package/schematics/ng-update/migrations/hammer-gestures-v9/hammer-gestures-migration.js +639 -639
- package/schematics/ng-update/migrations/misc-ripples-v7/ripple-speed-factor-migration.js +1 -1
- package/select/index.metadata.json +1 -1
- package/select/select.d.ts +6 -0
- package/select/testing/select-harness.d.ts +2 -0
- package/sidenav/drawer.d.ts +15 -3
- package/sidenav/index.metadata.json +1 -1
- package/slide-toggle/index.metadata.json +1 -1
- package/slide-toggle/testing/slide-toggle-harness.d.ts +2 -0
- package/slider/testing/slider-harness.d.ts +2 -0
- package/snack-bar/index.metadata.json +1 -1
- package/snack-bar/simple-snack-bar.d.ts +13 -1
- package/snack-bar/snack-bar-container.d.ts +16 -3
- package/snack-bar/snack-bar-ref.d.ts +3 -3
- package/snack-bar/snack-bar.d.ts +10 -3
- package/sort/index.metadata.json +1 -1
- package/sort/sort-header-intl.d.ts +5 -1
- package/sort/sort-header.d.ts +3 -1
- package/sort/testing/sort-header-harness.d.ts +6 -2
- package/tabs/index.d.ts +3 -1
- package/tabs/index.metadata.json +1 -1
- package/tabs/tab-content.d.ts +7 -1
- package/tabs/tab-label.d.ts +7 -0
- package/toolbar/testing/index.d.ts +8 -0
- package/toolbar/testing/package.json +9 -0
- package/toolbar/testing/public-api.d.ts +9 -0
- package/toolbar/testing/toolbar-harness-filters.d.ts +13 -0
- package/toolbar/testing/toolbar-harness.d.ts +31 -0
- package/tooltip/index.metadata.json +1 -1
- package/tooltip/tooltip.d.ts +1 -0
- package/tree/data-source/flat-data-source.d.ts +4 -4
- package/tree/index.metadata.json +1 -1
package/fesm2015/icon.js
CHANGED
|
@@ -74,450 +74,447 @@ class SvgIconConfig {
|
|
|
74
74
|
* - Registers aliases for CSS classes, for use with icon fonts.
|
|
75
75
|
* - Loads icons from URLs and extracts individual icons from icon sets.
|
|
76
76
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
this._errorHandler = _errorHandler;
|
|
83
|
-
/**
|
|
84
|
-
* URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
|
|
85
|
-
*/
|
|
86
|
-
this._svgIconConfigs = new Map();
|
|
87
|
-
/**
|
|
88
|
-
* SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
|
|
89
|
-
* Multiple icon sets can be registered under the same namespace.
|
|
90
|
-
*/
|
|
91
|
-
this._iconSetConfigs = new Map();
|
|
92
|
-
/** Cache for icons loaded by direct URLs. */
|
|
93
|
-
this._cachedIconsByUrl = new Map();
|
|
94
|
-
/** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
|
|
95
|
-
this._inProgressUrlFetches = new Map();
|
|
96
|
-
/** Map from font identifiers to their CSS class names. Used for icon fonts. */
|
|
97
|
-
this._fontCssClassesByAlias = new Map();
|
|
98
|
-
/**
|
|
99
|
-
* The CSS class to apply when an `<mat-icon>` component has no icon name, url, or font specified.
|
|
100
|
-
* The default 'material-icons' value assumes that the material icon font has been loaded as
|
|
101
|
-
* described at http://google.github.io/material-design-icons/#icon-font-for-the-web
|
|
102
|
-
*/
|
|
103
|
-
this._defaultFontSetClass = 'material-icons';
|
|
104
|
-
this._document = document;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Registers an icon by URL in the default namespace.
|
|
108
|
-
* @param iconName Name under which the icon should be registered.
|
|
109
|
-
* @param url
|
|
110
|
-
*/
|
|
111
|
-
addSvgIcon(iconName, url, options) {
|
|
112
|
-
return this.addSvgIconInNamespace('', iconName, url, options);
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Registers an icon using an HTML string in the default namespace.
|
|
116
|
-
* @param iconName Name under which the icon should be registered.
|
|
117
|
-
* @param literal SVG source of the icon.
|
|
118
|
-
*/
|
|
119
|
-
addSvgIconLiteral(iconName, literal, options) {
|
|
120
|
-
return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Registers an icon by URL in the specified namespace.
|
|
124
|
-
* @param namespace Namespace in which the icon should be registered.
|
|
125
|
-
* @param iconName Name under which the icon should be registered.
|
|
126
|
-
* @param url
|
|
127
|
-
*/
|
|
128
|
-
addSvgIconInNamespace(namespace, iconName, url, options) {
|
|
129
|
-
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, options));
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Registers an icon using an HTML string in the specified namespace.
|
|
133
|
-
* @param namespace Namespace in which the icon should be registered.
|
|
134
|
-
* @param iconName Name under which the icon should be registered.
|
|
135
|
-
* @param literal SVG source of the icon.
|
|
136
|
-
*/
|
|
137
|
-
addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
|
|
138
|
-
const sanitizedLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
139
|
-
if (!sanitizedLiteral) {
|
|
140
|
-
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
141
|
-
}
|
|
142
|
-
const svgElement = this._createSvgElementForSingleIcon(sanitizedLiteral, options);
|
|
143
|
-
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(svgElement, options));
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Registers an icon set by URL in the default namespace.
|
|
147
|
-
* @param url
|
|
148
|
-
*/
|
|
149
|
-
addSvgIconSet(url, options) {
|
|
150
|
-
return this.addSvgIconSetInNamespace('', url, options);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Registers an icon set using an HTML string in the default namespace.
|
|
154
|
-
* @param literal SVG source of the icon set.
|
|
155
|
-
*/
|
|
156
|
-
addSvgIconSetLiteral(literal, options) {
|
|
157
|
-
return this.addSvgIconSetLiteralInNamespace('', literal, options);
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Registers an icon set by URL in the specified namespace.
|
|
161
|
-
* @param namespace Namespace in which to register the icon set.
|
|
162
|
-
* @param url
|
|
163
|
-
*/
|
|
164
|
-
addSvgIconSetInNamespace(namespace, url, options) {
|
|
165
|
-
return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, options));
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Registers an icon set using an HTML string in the specified namespace.
|
|
169
|
-
* @param namespace Namespace in which to register the icon set.
|
|
170
|
-
* @param literal SVG source of the icon set.
|
|
171
|
-
*/
|
|
172
|
-
addSvgIconSetLiteralInNamespace(namespace, literal, options) {
|
|
173
|
-
const sanitizedLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
174
|
-
if (!sanitizedLiteral) {
|
|
175
|
-
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
176
|
-
}
|
|
177
|
-
const svgElement = this._svgElementFromString(sanitizedLiteral);
|
|
178
|
-
return this._addSvgIconSetConfig(namespace, new SvgIconConfig(svgElement, options));
|
|
179
|
-
}
|
|
77
|
+
class MatIconRegistry {
|
|
78
|
+
constructor(_httpClient, _sanitizer, document, _errorHandler) {
|
|
79
|
+
this._httpClient = _httpClient;
|
|
80
|
+
this._sanitizer = _sanitizer;
|
|
81
|
+
this._errorHandler = _errorHandler;
|
|
180
82
|
/**
|
|
181
|
-
*
|
|
182
|
-
* component with the alias as the fontSet input will cause the class name to be applied
|
|
183
|
-
* to the `<mat-icon>` element.
|
|
184
|
-
*
|
|
185
|
-
* @param alias Alias for the font.
|
|
186
|
-
* @param className Class name override to be used instead of the alias.
|
|
83
|
+
* URLs and cached SVG elements for individual icons. Keys are of the format "[namespace]:[icon]".
|
|
187
84
|
*/
|
|
188
|
-
|
|
189
|
-
this._fontCssClassesByAlias.set(alias, className);
|
|
190
|
-
return this;
|
|
191
|
-
}
|
|
85
|
+
this._svgIconConfigs = new Map();
|
|
192
86
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
87
|
+
* SvgIconConfig objects and cached SVG elements for icon sets, keyed by namespace.
|
|
88
|
+
* Multiple icon sets can be registered under the same namespace.
|
|
195
89
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
* @param className
|
|
204
|
-
*/
|
|
205
|
-
setDefaultFontSetClass(className) {
|
|
206
|
-
this._defaultFontSetClass = className;
|
|
207
|
-
return this;
|
|
208
|
-
}
|
|
90
|
+
this._iconSetConfigs = new Map();
|
|
91
|
+
/** Cache for icons loaded by direct URLs. */
|
|
92
|
+
this._cachedIconsByUrl = new Map();
|
|
93
|
+
/** In-progress icon fetches. Used to coalesce multiple requests to the same URL. */
|
|
94
|
+
this._inProgressUrlFetches = new Map();
|
|
95
|
+
/** Map from font identifiers to their CSS class names. Used for icon fonts. */
|
|
96
|
+
this._fontCssClassesByAlias = new Map();
|
|
209
97
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
98
|
+
* The CSS class to apply when an `<mat-icon>` component has no icon name, url, or font specified.
|
|
99
|
+
* The default 'material-icons' value assumes that the material icon font has been loaded as
|
|
100
|
+
* described at http://google.github.io/material-design-icons/#icon-font-for-the-web
|
|
212
101
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
102
|
+
this._defaultFontSetClass = 'material-icons';
|
|
103
|
+
this._document = document;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Registers an icon by URL in the default namespace.
|
|
107
|
+
* @param iconName Name under which the icon should be registered.
|
|
108
|
+
* @param url
|
|
109
|
+
*/
|
|
110
|
+
addSvgIcon(iconName, url, options) {
|
|
111
|
+
return this.addSvgIconInNamespace('', iconName, url, options);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Registers an icon using an HTML string in the default namespace.
|
|
115
|
+
* @param iconName Name under which the icon should be registered.
|
|
116
|
+
* @param literal SVG source of the icon.
|
|
117
|
+
*/
|
|
118
|
+
addSvgIconLiteral(iconName, literal, options) {
|
|
119
|
+
return this.addSvgIconLiteralInNamespace('', iconName, literal, options);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Registers an icon by URL in the specified namespace.
|
|
123
|
+
* @param namespace Namespace in which the icon should be registered.
|
|
124
|
+
* @param iconName Name under which the icon should be registered.
|
|
125
|
+
* @param url
|
|
126
|
+
*/
|
|
127
|
+
addSvgIconInNamespace(namespace, iconName, url, options) {
|
|
128
|
+
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(url, options));
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Registers an icon using an HTML string in the specified namespace.
|
|
132
|
+
* @param namespace Namespace in which the icon should be registered.
|
|
133
|
+
* @param iconName Name under which the icon should be registered.
|
|
134
|
+
* @param literal SVG source of the icon.
|
|
135
|
+
*/
|
|
136
|
+
addSvgIconLiteralInNamespace(namespace, iconName, literal, options) {
|
|
137
|
+
const sanitizedLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
138
|
+
if (!sanitizedLiteral) {
|
|
139
|
+
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
140
|
+
}
|
|
141
|
+
const svgElement = this._createSvgElementForSingleIcon(sanitizedLiteral, options);
|
|
142
|
+
return this._addSvgIconConfig(namespace, iconName, new SvgIconConfig(svgElement, options));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Registers an icon set by URL in the default namespace.
|
|
146
|
+
* @param url
|
|
147
|
+
*/
|
|
148
|
+
addSvgIconSet(url, options) {
|
|
149
|
+
return this.addSvgIconSetInNamespace('', url, options);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Registers an icon set using an HTML string in the default namespace.
|
|
153
|
+
* @param literal SVG source of the icon set.
|
|
154
|
+
*/
|
|
155
|
+
addSvgIconSetLiteral(literal, options) {
|
|
156
|
+
return this.addSvgIconSetLiteralInNamespace('', literal, options);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Registers an icon set by URL in the specified namespace.
|
|
160
|
+
* @param namespace Namespace in which to register the icon set.
|
|
161
|
+
* @param url
|
|
162
|
+
*/
|
|
163
|
+
addSvgIconSetInNamespace(namespace, url, options) {
|
|
164
|
+
return this._addSvgIconSetConfig(namespace, new SvgIconConfig(url, options));
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Registers an icon set using an HTML string in the specified namespace.
|
|
168
|
+
* @param namespace Namespace in which to register the icon set.
|
|
169
|
+
* @param literal SVG source of the icon set.
|
|
170
|
+
*/
|
|
171
|
+
addSvgIconSetLiteralInNamespace(namespace, literal, options) {
|
|
172
|
+
const sanitizedLiteral = this._sanitizer.sanitize(SecurityContext.HTML, literal);
|
|
173
|
+
if (!sanitizedLiteral) {
|
|
174
|
+
throw getMatIconFailedToSanitizeLiteralError(literal);
|
|
175
|
+
}
|
|
176
|
+
const svgElement = this._svgElementFromString(sanitizedLiteral);
|
|
177
|
+
return this._addSvgIconSetConfig(namespace, new SvgIconConfig(svgElement, options));
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Defines an alias for a CSS class name to be used for icon fonts. Creating an matIcon
|
|
181
|
+
* component with the alias as the fontSet input will cause the class name to be applied
|
|
182
|
+
* to the `<mat-icon>` element.
|
|
183
|
+
*
|
|
184
|
+
* @param alias Alias for the font.
|
|
185
|
+
* @param className Class name override to be used instead of the alias.
|
|
186
|
+
*/
|
|
187
|
+
registerFontClassAlias(alias, className = alias) {
|
|
188
|
+
this._fontCssClassesByAlias.set(alias, className);
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns the CSS class name associated with the alias by a previous call to
|
|
193
|
+
* registerFontClassAlias. If no CSS class has been associated, returns the alias unmodified.
|
|
194
|
+
*/
|
|
195
|
+
classNameForFontAlias(alias) {
|
|
196
|
+
return this._fontCssClassesByAlias.get(alias) || alias;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Sets the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
|
|
200
|
+
* have a fontSet input value, and is not loading an icon by name or URL.
|
|
201
|
+
*
|
|
202
|
+
* @param className
|
|
203
|
+
*/
|
|
204
|
+
setDefaultFontSetClass(className) {
|
|
205
|
+
this._defaultFontSetClass = className;
|
|
206
|
+
return this;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Returns the CSS class name to be used for icon fonts when an `<mat-icon>` component does not
|
|
210
|
+
* have a fontSet input value, and is not loading an icon by name or URL.
|
|
211
|
+
*/
|
|
212
|
+
getDefaultFontSetClass() {
|
|
213
|
+
return this._defaultFontSetClass;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Returns an Observable that produces the icon (as an `<svg>` DOM element) from the given URL.
|
|
217
|
+
* The response from the URL may be cached so this will not always cause an HTTP request, but
|
|
218
|
+
* the produced element will always be a new copy of the originally fetched icon. (That is,
|
|
219
|
+
* it will not contain any modifications made to elements previously returned).
|
|
220
|
+
*
|
|
221
|
+
* @param safeUrl URL from which to fetch the SVG icon.
|
|
222
|
+
*/
|
|
223
|
+
getSvgIconFromUrl(safeUrl) {
|
|
224
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
|
225
|
+
if (!url) {
|
|
226
|
+
throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
|
227
|
+
}
|
|
228
|
+
const cachedIcon = this._cachedIconsByUrl.get(url);
|
|
229
|
+
if (cachedIcon) {
|
|
230
|
+
return of(cloneSvg(cachedIcon));
|
|
231
|
+
}
|
|
232
|
+
return this._loadSvgIconFromConfig(new SvgIconConfig(safeUrl)).pipe(tap(svg => this._cachedIconsByUrl.set(url, svg)), map(svg => cloneSvg(svg)));
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Returns an Observable that produces the icon (as an `<svg>` DOM element) with the given name
|
|
236
|
+
* and namespace. The icon must have been previously registered with addIcon or addIconSet;
|
|
237
|
+
* if not, the Observable will throw an error.
|
|
238
|
+
*
|
|
239
|
+
* @param name Name of the icon to be retrieved.
|
|
240
|
+
* @param namespace Namespace in which to look for the icon.
|
|
241
|
+
*/
|
|
242
|
+
getNamedSvgIcon(name, namespace = '') {
|
|
243
|
+
// Return (copy of) cached icon if possible.
|
|
244
|
+
const key = iconKey(namespace, name);
|
|
245
|
+
const config = this._svgIconConfigs.get(key);
|
|
246
|
+
if (config) {
|
|
247
|
+
return this._getSvgFromConfig(config);
|
|
248
|
+
}
|
|
249
|
+
// See if we have any icon sets registered for the namespace.
|
|
250
|
+
const iconSetConfigs = this._iconSetConfigs.get(namespace);
|
|
251
|
+
if (iconSetConfigs) {
|
|
252
|
+
return this._getSvgFromIconSetConfigs(name, iconSetConfigs);
|
|
253
|
+
}
|
|
254
|
+
return throwError(getMatIconNameNotFoundError(key));
|
|
255
|
+
}
|
|
256
|
+
ngOnDestroy() {
|
|
257
|
+
this._svgIconConfigs.clear();
|
|
258
|
+
this._iconSetConfigs.clear();
|
|
259
|
+
this._cachedIconsByUrl.clear();
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Returns the cached icon for a SvgIconConfig if available, or fetches it from its URL if not.
|
|
263
|
+
*/
|
|
264
|
+
_getSvgFromConfig(config) {
|
|
265
|
+
if (config.svgElement) {
|
|
266
|
+
// We already have the SVG element for this icon, return a copy.
|
|
267
|
+
return of(cloneSvg(config.svgElement));
|
|
261
268
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
_getSvgFromConfig(config) {
|
|
266
|
-
if (config.svgElement) {
|
|
267
|
-
// We already have the SVG element for this icon, return a copy.
|
|
268
|
-
return of(cloneSvg(config.svgElement));
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
// Fetch the icon from the config's URL, cache it, and return a copy.
|
|
272
|
-
return this._loadSvgIconFromConfig(config).pipe(tap(svg => config.svgElement = svg), map(svg => cloneSvg(svg)));
|
|
273
|
-
}
|
|
269
|
+
else {
|
|
270
|
+
// Fetch the icon from the config's URL, cache it, and return a copy.
|
|
271
|
+
return this._loadSvgIconFromConfig(config).pipe(tap(svg => config.svgElement = svg), map(svg => cloneSvg(svg)));
|
|
274
272
|
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
});
|
|
307
|
-
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
|
|
308
|
-
// cached SVG element (unless the request failed), and we can check again for the icon.
|
|
309
|
-
return forkJoin(iconSetFetchRequests).pipe(map(() => {
|
|
310
|
-
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
|
311
|
-
if (!foundIcon) {
|
|
312
|
-
throw getMatIconNameNotFoundError(name);
|
|
313
|
-
}
|
|
314
|
-
return foundIcon;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Attempts to find an icon with the specified name in any of the SVG icon sets.
|
|
276
|
+
* First searches the available cached icons for a nested element with a matching name, and
|
|
277
|
+
* if found copies the element to a new `<svg>` element. If not found, fetches all icon sets
|
|
278
|
+
* that have not been cached, and searches again after all fetches are completed.
|
|
279
|
+
* The returned Observable produces the SVG element if possible, and throws
|
|
280
|
+
* an error if no icon with the specified name can be found.
|
|
281
|
+
*/
|
|
282
|
+
_getSvgFromIconSetConfigs(name, iconSetConfigs) {
|
|
283
|
+
// For all the icon set SVG elements we've fetched, see if any contain an icon with the
|
|
284
|
+
// requested name.
|
|
285
|
+
const namedIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
|
286
|
+
if (namedIcon) {
|
|
287
|
+
// We could cache namedIcon in _svgIconConfigs, but since we have to make a copy every
|
|
288
|
+
// time anyway, there's probably not much advantage compared to just always extracting
|
|
289
|
+
// it from the icon set.
|
|
290
|
+
return of(namedIcon);
|
|
291
|
+
}
|
|
292
|
+
// Not found in any cached icon sets. If there are icon sets with URLs that we haven't
|
|
293
|
+
// fetched, fetch them now and look for iconName in the results.
|
|
294
|
+
const iconSetFetchRequests = iconSetConfigs
|
|
295
|
+
.filter(iconSetConfig => !iconSetConfig.svgElement)
|
|
296
|
+
.map(iconSetConfig => {
|
|
297
|
+
return this._loadSvgIconSetFromConfig(iconSetConfig).pipe(catchError((err) => {
|
|
298
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, iconSetConfig.url);
|
|
299
|
+
// Swallow errors fetching individual URLs so the
|
|
300
|
+
// combined Observable won't necessarily fail.
|
|
301
|
+
const errorMessage = `Loading icon set URL: ${url} failed: ${err.message}`;
|
|
302
|
+
this._errorHandler.handleError(new Error(errorMessage));
|
|
303
|
+
return of(null);
|
|
315
304
|
}));
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
* Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
|
|
337
|
-
* from it.
|
|
338
|
-
*/
|
|
339
|
-
_loadSvgIconFromConfig(config) {
|
|
340
|
-
return this._fetchIcon(config)
|
|
341
|
-
.pipe(map(svgText => this._createSvgElementForSingleIcon(svgText, config.options)));
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Loads the content of the icon set URL specified in the SvgIconConfig and creates an SVG element
|
|
345
|
-
* from it.
|
|
346
|
-
*/
|
|
347
|
-
_loadSvgIconSetFromConfig(config) {
|
|
348
|
-
// If the SVG for this icon set has already been parsed, do nothing.
|
|
305
|
+
});
|
|
306
|
+
// Fetch all the icon set URLs. When the requests complete, every IconSet should have a
|
|
307
|
+
// cached SVG element (unless the request failed), and we can check again for the icon.
|
|
308
|
+
return forkJoin(iconSetFetchRequests).pipe(map(() => {
|
|
309
|
+
const foundIcon = this._extractIconWithNameFromAnySet(name, iconSetConfigs);
|
|
310
|
+
if (!foundIcon) {
|
|
311
|
+
throw getMatIconNameNotFoundError(name);
|
|
312
|
+
}
|
|
313
|
+
return foundIcon;
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Searches the cached SVG elements for the given icon sets for a nested icon element whose "id"
|
|
318
|
+
* tag matches the specified name. If found, copies the nested element to a new SVG element and
|
|
319
|
+
* returns it. Returns null if no matching element is found.
|
|
320
|
+
*/
|
|
321
|
+
_extractIconWithNameFromAnySet(iconName, iconSetConfigs) {
|
|
322
|
+
// Iterate backwards, so icon sets added later have precedence.
|
|
323
|
+
for (let i = iconSetConfigs.length - 1; i >= 0; i--) {
|
|
324
|
+
const config = iconSetConfigs[i];
|
|
349
325
|
if (config.svgElement) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
// It is possible that the icon set was parsed and cached by an earlier request, so parsing
|
|
354
|
-
// only needs to occur if the cache is yet unset.
|
|
355
|
-
if (!config.svgElement) {
|
|
356
|
-
config.svgElement = this._svgElementFromString(svgText);
|
|
326
|
+
const foundIcon = this._extractSvgIconFromSet(config.svgElement, iconName, config.options);
|
|
327
|
+
if (foundIcon) {
|
|
328
|
+
return foundIcon;
|
|
357
329
|
}
|
|
358
|
-
return config.svgElement;
|
|
359
|
-
}));
|
|
360
|
-
}
|
|
361
|
-
/**
|
|
362
|
-
* Creates a DOM element from the given SVG string, and adds default attributes.
|
|
363
|
-
*/
|
|
364
|
-
_createSvgElementForSingleIcon(responseText, options) {
|
|
365
|
-
const svg = this._svgElementFromString(responseText);
|
|
366
|
-
this._setSvgAttributes(svg, options);
|
|
367
|
-
return svg;
|
|
368
|
-
}
|
|
369
|
-
/**
|
|
370
|
-
* Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
|
|
371
|
-
* tag matches the specified name. If found, copies the nested element to a new SVG element and
|
|
372
|
-
* returns it. Returns null if no matching element is found.
|
|
373
|
-
*/
|
|
374
|
-
_extractSvgIconFromSet(iconSet, iconName, options) {
|
|
375
|
-
// Use the `id="iconName"` syntax in order to escape special
|
|
376
|
-
// characters in the ID (versus using the #iconName syntax).
|
|
377
|
-
const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
|
|
378
|
-
if (!iconSource) {
|
|
379
|
-
return null;
|
|
380
|
-
}
|
|
381
|
-
// Clone the element and remove the ID to prevent multiple elements from being added
|
|
382
|
-
// to the page with the same ID.
|
|
383
|
-
const iconElement = iconSource.cloneNode(true);
|
|
384
|
-
iconElement.removeAttribute('id');
|
|
385
|
-
// If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
|
|
386
|
-
// the content of a new <svg> node.
|
|
387
|
-
if (iconElement.nodeName.toLowerCase() === 'svg') {
|
|
388
|
-
return this._setSvgAttributes(iconElement, options);
|
|
389
|
-
}
|
|
390
|
-
// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
|
|
391
|
-
// that the same could be achieved by referring to it via <use href="#id">, however the <use>
|
|
392
|
-
// tag is problematic on Firefox, because it needs to include the current page path.
|
|
393
|
-
if (iconElement.nodeName.toLowerCase() === 'symbol') {
|
|
394
|
-
return this._setSvgAttributes(this._toSvgElement(iconElement), options);
|
|
395
330
|
}
|
|
396
|
-
// createElement('SVG') doesn't work as expected; the DOM ends up with
|
|
397
|
-
// the correct nodes, but the SVG content doesn't render. Instead we
|
|
398
|
-
// have to create an empty SVG node using innerHTML and append its content.
|
|
399
|
-
// Elements created using DOMParser.parseFromString have the same problem.
|
|
400
|
-
// http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
|
|
401
|
-
const svg = this._svgElementFromString('<svg></svg>');
|
|
402
|
-
// Clone the node so we don't remove it from the parent icon set element.
|
|
403
|
-
svg.appendChild(iconElement);
|
|
404
|
-
return this._setSvgAttributes(svg, options);
|
|
405
331
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Loads the content of the icon URL specified in the SvgIconConfig and creates an SVG element
|
|
336
|
+
* from it.
|
|
337
|
+
*/
|
|
338
|
+
_loadSvgIconFromConfig(config) {
|
|
339
|
+
return this._fetchIcon(config)
|
|
340
|
+
.pipe(map(svgText => this._createSvgElementForSingleIcon(svgText, config.options)));
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Loads the content of the icon set URL specified in the SvgIconConfig and creates an SVG element
|
|
344
|
+
* from it.
|
|
345
|
+
*/
|
|
346
|
+
_loadSvgIconSetFromConfig(config) {
|
|
347
|
+
// If the SVG for this icon set has already been parsed, do nothing.
|
|
348
|
+
if (config.svgElement) {
|
|
349
|
+
return of(config.svgElement);
|
|
350
|
+
}
|
|
351
|
+
return this._fetchIcon(config).pipe(map(svgText => {
|
|
352
|
+
// It is possible that the icon set was parsed and cached by an earlier request, so parsing
|
|
353
|
+
// only needs to occur if the cache is yet unset.
|
|
354
|
+
if (!config.svgElement) {
|
|
355
|
+
config.svgElement = this._svgElementFromString(svgText);
|
|
356
|
+
}
|
|
357
|
+
return config.svgElement;
|
|
358
|
+
}));
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Creates a DOM element from the given SVG string, and adds default attributes.
|
|
362
|
+
*/
|
|
363
|
+
_createSvgElementForSingleIcon(responseText, options) {
|
|
364
|
+
const svg = this._svgElementFromString(responseText);
|
|
365
|
+
this._setSvgAttributes(svg, options);
|
|
366
|
+
return svg;
|
|
367
|
+
}
|
|
368
|
+
/**
|
|
369
|
+
* Searches the cached element of the given SvgIconConfig for a nested icon element whose "id"
|
|
370
|
+
* tag matches the specified name. If found, copies the nested element to a new SVG element and
|
|
371
|
+
* returns it. Returns null if no matching element is found.
|
|
372
|
+
*/
|
|
373
|
+
_extractSvgIconFromSet(iconSet, iconName, options) {
|
|
374
|
+
// Use the `id="iconName"` syntax in order to escape special
|
|
375
|
+
// characters in the ID (versus using the #iconName syntax).
|
|
376
|
+
const iconSource = iconSet.querySelector(`[id="${iconName}"]`);
|
|
377
|
+
if (!iconSource) {
|
|
378
|
+
return null;
|
|
417
379
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
380
|
+
// Clone the element and remove the ID to prevent multiple elements from being added
|
|
381
|
+
// to the page with the same ID.
|
|
382
|
+
const iconElement = iconSource.cloneNode(true);
|
|
383
|
+
iconElement.removeAttribute('id');
|
|
384
|
+
// If the icon node is itself an <svg> node, clone and return it directly. If not, set it as
|
|
385
|
+
// the content of a new <svg> node.
|
|
386
|
+
if (iconElement.nodeName.toLowerCase() === 'svg') {
|
|
387
|
+
return this._setSvgAttributes(iconElement, options);
|
|
388
|
+
}
|
|
389
|
+
// If the node is a <symbol>, it won't be rendered so we have to convert it into <svg>. Note
|
|
390
|
+
// that the same could be achieved by referring to it via <use href="#id">, however the <use>
|
|
391
|
+
// tag is problematic on Firefox, because it needs to include the current page path.
|
|
392
|
+
if (iconElement.nodeName.toLowerCase() === 'symbol') {
|
|
393
|
+
return this._setSvgAttributes(this._toSvgElement(iconElement), options);
|
|
394
|
+
}
|
|
395
|
+
// createElement('SVG') doesn't work as expected; the DOM ends up with
|
|
396
|
+
// the correct nodes, but the SVG content doesn't render. Instead we
|
|
397
|
+
// have to create an empty SVG node using innerHTML and append its content.
|
|
398
|
+
// Elements created using DOMParser.parseFromString have the same problem.
|
|
399
|
+
// http://stackoverflow.com/questions/23003278/svg-innerhtml-in-firefox-can-not-display
|
|
400
|
+
const svg = this._svgElementFromString('<svg></svg>');
|
|
401
|
+
// Clone the node so we don't remove it from the parent icon set element.
|
|
402
|
+
svg.appendChild(iconElement);
|
|
403
|
+
return this._setSvgAttributes(svg, options);
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Creates a DOM element from the given SVG string.
|
|
407
|
+
*/
|
|
408
|
+
_svgElementFromString(str) {
|
|
409
|
+
const div = this._document.createElement('DIV');
|
|
410
|
+
div.innerHTML = str;
|
|
411
|
+
const svg = div.querySelector('svg');
|
|
412
|
+
if (!svg) {
|
|
413
|
+
throw Error('<svg> tag not found');
|
|
414
|
+
}
|
|
415
|
+
return svg;
|
|
416
|
+
}
|
|
417
|
+
/**
|
|
418
|
+
* Converts an element into an SVG node by cloning all of its children.
|
|
419
|
+
*/
|
|
420
|
+
_toSvgElement(element) {
|
|
421
|
+
const svg = this._svgElementFromString('<svg></svg>');
|
|
422
|
+
const attributes = element.attributes;
|
|
423
|
+
// Copy over all the attributes from the `symbol` to the new SVG, except the id.
|
|
424
|
+
for (let i = 0; i < attributes.length; i++) {
|
|
425
|
+
const { name, value } = attributes[i];
|
|
426
|
+
if (name !== 'id') {
|
|
427
|
+
svg.setAttribute(name, value);
|
|
435
428
|
}
|
|
436
|
-
return svg;
|
|
437
429
|
}
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
_setSvgAttributes(svg, options) {
|
|
442
|
-
svg.setAttribute('fit', '');
|
|
443
|
-
svg.setAttribute('height', '100%');
|
|
444
|
-
svg.setAttribute('width', '100%');
|
|
445
|
-
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
|
446
|
-
svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
|
|
447
|
-
if (options && options.viewBox) {
|
|
448
|
-
svg.setAttribute('viewBox', options.viewBox);
|
|
430
|
+
for (let i = 0; i < element.childNodes.length; i++) {
|
|
431
|
+
if (element.childNodes[i].nodeType === this._document.ELEMENT_NODE) {
|
|
432
|
+
svg.appendChild(element.childNodes[i].cloneNode(true));
|
|
449
433
|
}
|
|
450
|
-
return svg;
|
|
451
434
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
435
|
+
return svg;
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Sets the default attributes for an SVG element to be used as an icon.
|
|
439
|
+
*/
|
|
440
|
+
_setSvgAttributes(svg, options) {
|
|
441
|
+
svg.setAttribute('fit', '');
|
|
442
|
+
svg.setAttribute('height', '100%');
|
|
443
|
+
svg.setAttribute('width', '100%');
|
|
444
|
+
svg.setAttribute('preserveAspectRatio', 'xMidYMid meet');
|
|
445
|
+
svg.setAttribute('focusable', 'false'); // Disable IE11 default behavior to make SVGs focusable.
|
|
446
|
+
if (options && options.viewBox) {
|
|
447
|
+
svg.setAttribute('viewBox', options.viewBox);
|
|
448
|
+
}
|
|
449
|
+
return svg;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Returns an Observable which produces the string contents of the given icon. Results may be
|
|
453
|
+
* cached, so future calls with the same URL may not cause another HTTP request.
|
|
454
|
+
*/
|
|
455
|
+
_fetchIcon(iconConfig) {
|
|
456
|
+
var _a;
|
|
457
|
+
const { url: safeUrl, options } = iconConfig;
|
|
458
|
+
const withCredentials = (_a = options === null || options === void 0 ? void 0 : options.withCredentials) !== null && _a !== void 0 ? _a : false;
|
|
459
|
+
if (!this._httpClient) {
|
|
460
|
+
throw getMatIconNoHttpProviderError();
|
|
461
|
+
}
|
|
462
|
+
if (safeUrl == null) {
|
|
463
|
+
throw Error(`Cannot fetch icon from URL "${safeUrl}".`);
|
|
464
|
+
}
|
|
465
|
+
const url = this._sanitizer.sanitize(SecurityContext.RESOURCE_URL, safeUrl);
|
|
466
|
+
if (!url) {
|
|
467
|
+
throw getMatIconFailedToSanitizeUrlError(safeUrl);
|
|
468
|
+
}
|
|
469
|
+
// Store in-progress fetches to avoid sending a duplicate request for a URL when there is
|
|
470
|
+
// already a request in progress for that URL. It's necessary to call share() on the
|
|
471
|
+
// Observable returned by http.get() so that multiple subscribers don't cause multiple XHRs.
|
|
472
|
+
const inProgressFetch = this._inProgressUrlFetches.get(url);
|
|
473
|
+
if (inProgressFetch) {
|
|
474
|
+
return inProgressFetch;
|
|
475
|
+
}
|
|
476
|
+
// TODO(jelbourn): for some reason, the `finalize` operator "loses" the generic type on the
|
|
477
|
+
// Observable. Figure out why and fix it.
|
|
478
|
+
const req = this._httpClient.get(url, { responseType: 'text', withCredentials }).pipe(finalize(() => this._inProgressUrlFetches.delete(url)), share());
|
|
479
|
+
this._inProgressUrlFetches.set(url, req);
|
|
480
|
+
return req;
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Registers an icon config by name in the specified namespace.
|
|
484
|
+
* @param namespace Namespace in which to register the icon config.
|
|
485
|
+
* @param iconName Name under which to register the config.
|
|
486
|
+
* @param config Config to be registered.
|
|
487
|
+
*/
|
|
488
|
+
_addSvgIconConfig(namespace, iconName, config) {
|
|
489
|
+
this._svgIconConfigs.set(iconKey(namespace, iconName), config);
|
|
490
|
+
return this;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Registers an icon set config in the specified namespace.
|
|
494
|
+
* @param namespace Namespace in which to register the icon config.
|
|
495
|
+
* @param config Config to be registered.
|
|
496
|
+
*/
|
|
497
|
+
_addSvgIconSetConfig(namespace, config) {
|
|
498
|
+
const configNamespace = this._iconSetConfigs.get(namespace);
|
|
499
|
+
if (configNamespace) {
|
|
500
|
+
configNamespace.push(config);
|
|
482
501
|
}
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
* @param namespace Namespace in which to register the icon config.
|
|
486
|
-
* @param iconName Name under which to register the config.
|
|
487
|
-
* @param config Config to be registered.
|
|
488
|
-
*/
|
|
489
|
-
_addSvgIconConfig(namespace, iconName, config) {
|
|
490
|
-
this._svgIconConfigs.set(iconKey(namespace, iconName), config);
|
|
491
|
-
return this;
|
|
502
|
+
else {
|
|
503
|
+
this._iconSetConfigs.set(namespace, [config]);
|
|
492
504
|
}
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
return this;
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
MatIconRegistry.ɵprov = ɵɵdefineInjectable({ factory: function MatIconRegistry_Factory() { return new MatIconRegistry(ɵɵinject(HttpClient, 8), ɵɵinject(DomSanitizer), ɵɵinject(DOCUMENT, 8), ɵɵinject(ErrorHandler)); }, token: MatIconRegistry, providedIn: "root" });
|
|
510
|
-
MatIconRegistry.decorators = [
|
|
511
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
512
|
-
];
|
|
513
|
-
MatIconRegistry.ctorParameters = () => [
|
|
514
|
-
{ type: HttpClient, decorators: [{ type: Optional }] },
|
|
515
|
-
{ type: DomSanitizer },
|
|
516
|
-
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
517
|
-
{ type: ErrorHandler }
|
|
518
|
-
];
|
|
519
|
-
return MatIconRegistry;
|
|
520
|
-
})();
|
|
505
|
+
return this;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
MatIconRegistry.ɵprov = ɵɵdefineInjectable({ factory: function MatIconRegistry_Factory() { return new MatIconRegistry(ɵɵinject(HttpClient, 8), ɵɵinject(DomSanitizer), ɵɵinject(DOCUMENT, 8), ɵɵinject(ErrorHandler)); }, token: MatIconRegistry, providedIn: "root" });
|
|
509
|
+
MatIconRegistry.decorators = [
|
|
510
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
511
|
+
];
|
|
512
|
+
MatIconRegistry.ctorParameters = () => [
|
|
513
|
+
{ type: HttpClient, decorators: [{ type: Optional }] },
|
|
514
|
+
{ type: DomSanitizer },
|
|
515
|
+
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] }] },
|
|
516
|
+
{ type: ErrorHandler }
|
|
517
|
+
];
|
|
521
518
|
/** @docs-private */
|
|
522
519
|
function ICON_REGISTRY_PROVIDER_FACTORY(parentRegistry, httpClient, sanitizer, errorHandler, document) {
|
|
523
520
|
return parentRegistry || new MatIconRegistry(httpClient, sanitizer, document, errorHandler);
|
|
@@ -625,261 +622,258 @@ const funcIriPattern = /^url\(['"]?#(.*?)['"]?\)$/;
|
|
|
625
622
|
* Example:
|
|
626
623
|
* `<mat-icon fontSet="fa" fontIcon="alarm"></mat-icon>`
|
|
627
624
|
*/
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
elementRef.nativeElement.setAttribute('aria-hidden', 'true');
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
/**
|
|
645
|
-
* Whether the icon should be inlined, automatically sizing the icon to match the font size of
|
|
646
|
-
* the element the icon is contained in.
|
|
647
|
-
*/
|
|
648
|
-
get inline() {
|
|
649
|
-
return this._inline;
|
|
650
|
-
}
|
|
651
|
-
set inline(inline) {
|
|
652
|
-
this._inline = coerceBooleanProperty(inline);
|
|
625
|
+
class MatIcon extends _MatIconMixinBase {
|
|
626
|
+
constructor(elementRef, _iconRegistry, ariaHidden, _location, _errorHandler) {
|
|
627
|
+
super(elementRef);
|
|
628
|
+
this._iconRegistry = _iconRegistry;
|
|
629
|
+
this._location = _location;
|
|
630
|
+
this._errorHandler = _errorHandler;
|
|
631
|
+
this._inline = false;
|
|
632
|
+
/** Subscription to the current in-progress SVG icon request. */
|
|
633
|
+
this._currentIconFetch = Subscription.EMPTY;
|
|
634
|
+
// If the user has not explicitly set aria-hidden, mark the icon as hidden, as this is
|
|
635
|
+
// the right thing to do for the majority of icon use-cases.
|
|
636
|
+
if (!ariaHidden) {
|
|
637
|
+
elementRef.nativeElement.setAttribute('aria-hidden', 'true');
|
|
653
638
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Whether the icon should be inlined, automatically sizing the icon to match the font size of
|
|
642
|
+
* the element the icon is contained in.
|
|
643
|
+
*/
|
|
644
|
+
get inline() {
|
|
645
|
+
return this._inline;
|
|
646
|
+
}
|
|
647
|
+
set inline(inline) {
|
|
648
|
+
this._inline = coerceBooleanProperty(inline);
|
|
649
|
+
}
|
|
650
|
+
/** Font set that the icon is a part of. */
|
|
651
|
+
get fontSet() { return this._fontSet; }
|
|
652
|
+
set fontSet(value) {
|
|
653
|
+
this._fontSet = this._cleanupFontValue(value);
|
|
654
|
+
}
|
|
655
|
+
/** Name of an icon within a font set. */
|
|
656
|
+
get fontIcon() { return this._fontIcon; }
|
|
657
|
+
set fontIcon(value) {
|
|
658
|
+
this._fontIcon = this._cleanupFontValue(value);
|
|
659
|
+
}
|
|
660
|
+
/**
|
|
661
|
+
* Splits an svgIcon binding value into its icon set and icon name components.
|
|
662
|
+
* Returns a 2-element array of [(icon set), (icon name)].
|
|
663
|
+
* The separator for the two fields is ':'. If there is no separator, an empty
|
|
664
|
+
* string is returned for the icon set and the entire value is returned for
|
|
665
|
+
* the icon name. If the argument is falsy, returns an array of two empty strings.
|
|
666
|
+
* Throws an error if the name contains two or more ':' separators.
|
|
667
|
+
* Examples:
|
|
668
|
+
* `'social:cake' -> ['social', 'cake']
|
|
669
|
+
* 'penguin' -> ['', 'penguin']
|
|
670
|
+
* null -> ['', '']
|
|
671
|
+
* 'a:b:c' -> (throws Error)`
|
|
672
|
+
*/
|
|
673
|
+
_splitIconName(iconName) {
|
|
674
|
+
if (!iconName) {
|
|
675
|
+
return ['', ''];
|
|
676
|
+
}
|
|
677
|
+
const parts = iconName.split(':');
|
|
678
|
+
switch (parts.length) {
|
|
679
|
+
case 1: return ['', parts[0]]; // Use default namespace.
|
|
680
|
+
case 2: return parts;
|
|
681
|
+
default: throw Error(`Invalid icon name: "${iconName}"`);
|
|
663
682
|
}
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (!iconName) {
|
|
679
|
-
return ['', ''];
|
|
683
|
+
}
|
|
684
|
+
ngOnChanges(changes) {
|
|
685
|
+
// Only update the inline SVG icon if the inputs changed, to avoid unnecessary DOM operations.
|
|
686
|
+
const svgIconChanges = changes['svgIcon'];
|
|
687
|
+
if (svgIconChanges) {
|
|
688
|
+
this._currentIconFetch.unsubscribe();
|
|
689
|
+
if (this.svgIcon) {
|
|
690
|
+
const [namespace, iconName] = this._splitIconName(this.svgIcon);
|
|
691
|
+
this._currentIconFetch = this._iconRegistry.getNamedSvgIcon(iconName, namespace)
|
|
692
|
+
.pipe(take(1))
|
|
693
|
+
.subscribe(svg => this._setSvgElement(svg), (err) => {
|
|
694
|
+
const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`;
|
|
695
|
+
this._errorHandler.handleError(new Error(errorMessage));
|
|
696
|
+
});
|
|
680
697
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
case 1: return ['', parts[0]]; // Use default namespace.
|
|
684
|
-
case 2: return parts;
|
|
685
|
-
default: throw Error(`Invalid icon name: "${iconName}"`);
|
|
698
|
+
else if (svgIconChanges.previousValue) {
|
|
699
|
+
this._clearSvgElement();
|
|
686
700
|
}
|
|
687
701
|
}
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
const svgIconChanges = changes['svgIcon'];
|
|
691
|
-
if (svgIconChanges) {
|
|
692
|
-
this._currentIconFetch.unsubscribe();
|
|
693
|
-
if (this.svgIcon) {
|
|
694
|
-
const [namespace, iconName] = this._splitIconName(this.svgIcon);
|
|
695
|
-
this._currentIconFetch = this._iconRegistry.getNamedSvgIcon(iconName, namespace)
|
|
696
|
-
.pipe(take(1))
|
|
697
|
-
.subscribe(svg => this._setSvgElement(svg), (err) => {
|
|
698
|
-
const errorMessage = `Error retrieving icon ${namespace}:${iconName}! ${err.message}`;
|
|
699
|
-
this._errorHandler.handleError(new Error(errorMessage));
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
else if (svgIconChanges.previousValue) {
|
|
703
|
-
this._clearSvgElement();
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
if (this._usingFontIcon()) {
|
|
707
|
-
this._updateFontIconClasses();
|
|
708
|
-
}
|
|
702
|
+
if (this._usingFontIcon()) {
|
|
703
|
+
this._updateFontIconClasses();
|
|
709
704
|
}
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
705
|
+
}
|
|
706
|
+
ngOnInit() {
|
|
707
|
+
// Update font classes because ngOnChanges won't be called if none of the inputs are present,
|
|
708
|
+
// e.g. <mat-icon>arrow</mat-icon> In this case we need to add a CSS class for the default font.
|
|
709
|
+
if (this._usingFontIcon()) {
|
|
710
|
+
this._updateFontIconClasses();
|
|
716
711
|
}
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
712
|
+
}
|
|
713
|
+
ngAfterViewChecked() {
|
|
714
|
+
const cachedElements = this._elementsWithExternalReferences;
|
|
715
|
+
if (cachedElements && cachedElements.size) {
|
|
716
|
+
const newPath = this._location.getPathname();
|
|
717
|
+
// We need to check whether the URL has changed on each change detection since
|
|
718
|
+
// the browser doesn't have an API that will let us react on link clicks and
|
|
719
|
+
// we can't depend on the Angular router. The references need to be updated,
|
|
720
|
+
// because while most browsers don't care whether the URL is correct after
|
|
721
|
+
// the first render, Safari will break if the user navigates to a different
|
|
722
|
+
// page and the SVG isn't re-rendered.
|
|
723
|
+
if (newPath !== this._previousPath) {
|
|
724
|
+
this._previousPath = newPath;
|
|
725
|
+
this._prependPathToReferences(newPath);
|
|
731
726
|
}
|
|
732
727
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
728
|
+
}
|
|
729
|
+
ngOnDestroy() {
|
|
730
|
+
this._currentIconFetch.unsubscribe();
|
|
731
|
+
if (this._elementsWithExternalReferences) {
|
|
732
|
+
this._elementsWithExternalReferences.clear();
|
|
738
733
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
734
|
+
}
|
|
735
|
+
_usingFontIcon() {
|
|
736
|
+
return !this.svgIcon;
|
|
737
|
+
}
|
|
738
|
+
_setSvgElement(svg) {
|
|
739
|
+
this._clearSvgElement();
|
|
740
|
+
// Workaround for IE11 and Edge ignoring `style` tags inside dynamically-created SVGs.
|
|
741
|
+
// See: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/10898469/
|
|
742
|
+
// Do this before inserting the element into the DOM, in order to avoid a style recalculation.
|
|
743
|
+
const styleTags = svg.querySelectorAll('style');
|
|
744
|
+
for (let i = 0; i < styleTags.length; i++) {
|
|
745
|
+
styleTags[i].textContent += ' ';
|
|
746
|
+
}
|
|
747
|
+
// Note: we do this fix here, rather than the icon registry, because the
|
|
748
|
+
// references have to point to the URL at the time that the icon was created.
|
|
749
|
+
const path = this._location.getPathname();
|
|
750
|
+
this._previousPath = path;
|
|
751
|
+
this._cacheChildrenWithExternalReferences(svg);
|
|
752
|
+
this._prependPathToReferences(path);
|
|
753
|
+
this._elementRef.nativeElement.appendChild(svg);
|
|
754
|
+
}
|
|
755
|
+
_clearSvgElement() {
|
|
756
|
+
const layoutElement = this._elementRef.nativeElement;
|
|
757
|
+
let childCount = layoutElement.childNodes.length;
|
|
758
|
+
if (this._elementsWithExternalReferences) {
|
|
759
|
+
this._elementsWithExternalReferences.clear();
|
|
760
|
+
}
|
|
761
|
+
// Remove existing non-element child nodes and SVGs, and add the new SVG element. Note that
|
|
762
|
+
// we can't use innerHTML, because IE will throw if the element has a data binding.
|
|
763
|
+
while (childCount--) {
|
|
764
|
+
const child = layoutElement.childNodes[childCount];
|
|
765
|
+
// 1 corresponds to Node.ELEMENT_NODE. We remove all non-element nodes in order to get rid
|
|
766
|
+
// of any loose text nodes, as well as any SVG elements in order to remove any old icons.
|
|
767
|
+
if (child.nodeType !== 1 || child.nodeName.toLowerCase() === 'svg') {
|
|
768
|
+
layoutElement.removeChild(child);
|
|
750
769
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
if (this.
|
|
763
|
-
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
_updateFontIconClasses() {
|
|
773
|
+
if (!this._usingFontIcon()) {
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
const elem = this._elementRef.nativeElement;
|
|
777
|
+
const fontSetClass = this.fontSet ?
|
|
778
|
+
this._iconRegistry.classNameForFontAlias(this.fontSet) :
|
|
779
|
+
this._iconRegistry.getDefaultFontSetClass();
|
|
780
|
+
if (fontSetClass != this._previousFontSetClass) {
|
|
781
|
+
if (this._previousFontSetClass) {
|
|
782
|
+
elem.classList.remove(this._previousFontSetClass);
|
|
764
783
|
}
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
while (childCount--) {
|
|
768
|
-
const child = layoutElement.childNodes[childCount];
|
|
769
|
-
// 1 corresponds to Node.ELEMENT_NODE. We remove all non-element nodes in order to get rid
|
|
770
|
-
// of any loose text nodes, as well as any SVG elements in order to remove any old icons.
|
|
771
|
-
if (child.nodeType !== 1 || child.nodeName.toLowerCase() === 'svg') {
|
|
772
|
-
layoutElement.removeChild(child);
|
|
773
|
-
}
|
|
784
|
+
if (fontSetClass) {
|
|
785
|
+
elem.classList.add(fontSetClass);
|
|
774
786
|
}
|
|
787
|
+
this._previousFontSetClass = fontSetClass;
|
|
775
788
|
}
|
|
776
|
-
|
|
777
|
-
if (
|
|
778
|
-
|
|
789
|
+
if (this.fontIcon != this._previousFontIconClass) {
|
|
790
|
+
if (this._previousFontIconClass) {
|
|
791
|
+
elem.classList.remove(this._previousFontIconClass);
|
|
779
792
|
}
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
this._iconRegistry.classNameForFontAlias(this.fontSet) :
|
|
783
|
-
this._iconRegistry.getDefaultFontSetClass();
|
|
784
|
-
if (fontSetClass != this._previousFontSetClass) {
|
|
785
|
-
if (this._previousFontSetClass) {
|
|
786
|
-
elem.classList.remove(this._previousFontSetClass);
|
|
787
|
-
}
|
|
788
|
-
if (fontSetClass) {
|
|
789
|
-
elem.classList.add(fontSetClass);
|
|
790
|
-
}
|
|
791
|
-
this._previousFontSetClass = fontSetClass;
|
|
793
|
+
if (this.fontIcon) {
|
|
794
|
+
elem.classList.add(this.fontIcon);
|
|
792
795
|
}
|
|
793
|
-
|
|
794
|
-
if (this._previousFontIconClass) {
|
|
795
|
-
elem.classList.remove(this._previousFontIconClass);
|
|
796
|
-
}
|
|
797
|
-
if (this.fontIcon) {
|
|
798
|
-
elem.classList.add(this.fontIcon);
|
|
799
|
-
}
|
|
800
|
-
this._previousFontIconClass = this.fontIcon;
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
/**
|
|
804
|
-
* Cleans up a value to be used as a fontIcon or fontSet.
|
|
805
|
-
* Since the value ends up being assigned as a CSS class, we
|
|
806
|
-
* have to trim the value and omit space-separated values.
|
|
807
|
-
*/
|
|
808
|
-
_cleanupFontValue(value) {
|
|
809
|
-
return typeof value === 'string' ? value.trim().split(' ')[0] : value;
|
|
796
|
+
this._previousFontIconClass = this.fontIcon;
|
|
810
797
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
798
|
+
}
|
|
799
|
+
/**
|
|
800
|
+
* Cleans up a value to be used as a fontIcon or fontSet.
|
|
801
|
+
* Since the value ends up being assigned as a CSS class, we
|
|
802
|
+
* have to trim the value and omit space-separated values.
|
|
803
|
+
*/
|
|
804
|
+
_cleanupFontValue(value) {
|
|
805
|
+
return typeof value === 'string' ? value.trim().split(' ')[0] : value;
|
|
806
|
+
}
|
|
807
|
+
/**
|
|
808
|
+
* Prepends the current path to all elements that have an attribute pointing to a `FuncIRI`
|
|
809
|
+
* reference. This is required because WebKit browsers require references to be prefixed with
|
|
810
|
+
* the current path, if the page has a `base` tag.
|
|
811
|
+
*/
|
|
812
|
+
_prependPathToReferences(path) {
|
|
813
|
+
const elements = this._elementsWithExternalReferences;
|
|
814
|
+
if (elements) {
|
|
815
|
+
elements.forEach((attrs, element) => {
|
|
816
|
+
attrs.forEach(attr => {
|
|
817
|
+
element.setAttribute(attr.name, `url('${path}#${attr.value}')`);
|
|
823
818
|
});
|
|
824
|
-
}
|
|
819
|
+
});
|
|
825
820
|
}
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
attributes.push({ name: attr, value: match[1] });
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Caches the children of an SVG element that have `url()`
|
|
824
|
+
* references that we need to prefix with the current path.
|
|
825
|
+
*/
|
|
826
|
+
_cacheChildrenWithExternalReferences(element) {
|
|
827
|
+
const elementsWithFuncIri = element.querySelectorAll(funcIriAttributeSelector);
|
|
828
|
+
const elements = this._elementsWithExternalReferences =
|
|
829
|
+
this._elementsWithExternalReferences || new Map();
|
|
830
|
+
for (let i = 0; i < elementsWithFuncIri.length; i++) {
|
|
831
|
+
funcIriAttributes.forEach(attr => {
|
|
832
|
+
const elementWithReference = elementsWithFuncIri[i];
|
|
833
|
+
const value = elementWithReference.getAttribute(attr);
|
|
834
|
+
const match = value ? value.match(funcIriPattern) : null;
|
|
835
|
+
if (match) {
|
|
836
|
+
let attributes = elements.get(elementWithReference);
|
|
837
|
+
if (!attributes) {
|
|
838
|
+
attributes = [];
|
|
839
|
+
elements.set(elementWithReference, attributes);
|
|
846
840
|
}
|
|
847
|
-
|
|
848
|
-
|
|
841
|
+
attributes.push({ name: attr, value: match[1] });
|
|
842
|
+
}
|
|
843
|
+
});
|
|
849
844
|
}
|
|
850
845
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
})();
|
|
846
|
+
}
|
|
847
|
+
MatIcon.decorators = [
|
|
848
|
+
{ type: Component, args: [{
|
|
849
|
+
template: '<ng-content></ng-content>',
|
|
850
|
+
selector: 'mat-icon',
|
|
851
|
+
exportAs: 'matIcon',
|
|
852
|
+
inputs: ['color'],
|
|
853
|
+
host: {
|
|
854
|
+
'role': 'img',
|
|
855
|
+
'class': 'mat-icon notranslate',
|
|
856
|
+
'[class.mat-icon-inline]': 'inline',
|
|
857
|
+
'[class.mat-icon-no-color]': 'color !== "primary" && color !== "accent" && color !== "warn"',
|
|
858
|
+
},
|
|
859
|
+
encapsulation: ViewEncapsulation.None,
|
|
860
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
861
|
+
styles: [".mat-icon{background-repeat:no-repeat;display:inline-block;fill:currentColor;height:24px;width:24px}.mat-icon.mat-icon-inline{font-size:inherit;height:inherit;line-height:inherit;width:inherit}[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}\n"]
|
|
862
|
+
},] }
|
|
863
|
+
];
|
|
864
|
+
MatIcon.ctorParameters = () => [
|
|
865
|
+
{ type: ElementRef },
|
|
866
|
+
{ type: MatIconRegistry },
|
|
867
|
+
{ type: String, decorators: [{ type: Attribute, args: ['aria-hidden',] }] },
|
|
868
|
+
{ type: undefined, decorators: [{ type: Inject, args: [MAT_ICON_LOCATION,] }] },
|
|
869
|
+
{ type: ErrorHandler }
|
|
870
|
+
];
|
|
871
|
+
MatIcon.propDecorators = {
|
|
872
|
+
inline: [{ type: Input }],
|
|
873
|
+
svgIcon: [{ type: Input }],
|
|
874
|
+
fontSet: [{ type: Input }],
|
|
875
|
+
fontIcon: [{ type: Input }]
|
|
876
|
+
};
|
|
883
877
|
|
|
884
878
|
/**
|
|
885
879
|
* @license
|
|
@@ -888,18 +882,15 @@ let MatIcon = /** @class */ (() => {
|
|
|
888
882
|
* Use of this source code is governed by an MIT-style license that can be
|
|
889
883
|
* found in the LICENSE file at https://angular.io/license
|
|
890
884
|
*/
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
];
|
|
901
|
-
return MatIconModule;
|
|
902
|
-
})();
|
|
885
|
+
class MatIconModule {
|
|
886
|
+
}
|
|
887
|
+
MatIconModule.decorators = [
|
|
888
|
+
{ type: NgModule, args: [{
|
|
889
|
+
imports: [MatCommonModule],
|
|
890
|
+
exports: [MatIcon, MatCommonModule],
|
|
891
|
+
declarations: [MatIcon],
|
|
892
|
+
},] }
|
|
893
|
+
];
|
|
903
894
|
|
|
904
895
|
/**
|
|
905
896
|
* @license
|