@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/slider.js
CHANGED
|
@@ -54,680 +54,677 @@ const _MatSliderMixinBase = mixinTabIndex(mixinColor(mixinDisabled(MatSliderBase
|
|
|
54
54
|
* Allows users to select from a range of values by moving the slider thumb. It is similar in
|
|
55
55
|
* behavior to the native `<input type="range">` element.
|
|
56
56
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
this.input = new EventEmitter();
|
|
78
|
-
/**
|
|
79
|
-
* Emits when the raw value of the slider changes. This is here primarily
|
|
80
|
-
* to facilitate the two-way binding for the `value` input.
|
|
81
|
-
* @docs-private
|
|
82
|
-
*/
|
|
83
|
-
this.valueChange = new EventEmitter();
|
|
84
|
-
/** onTouch function registered via registerOnTouch (ControlValueAccessor). */
|
|
85
|
-
this.onTouched = () => { };
|
|
86
|
-
this._percent = 0;
|
|
87
|
-
/**
|
|
88
|
-
* Whether or not the thumb is sliding.
|
|
89
|
-
* Used to determine if there should be a transition for the thumb and fill track.
|
|
90
|
-
*/
|
|
91
|
-
this._isSliding = false;
|
|
92
|
-
/**
|
|
93
|
-
* Whether or not the slider is active (clicked or sliding).
|
|
94
|
-
* Used to shrink and grow the thumb as according to the Material Design spec.
|
|
95
|
-
*/
|
|
96
|
-
this._isActive = false;
|
|
97
|
-
/** The size of a tick interval as a percentage of the size of the track. */
|
|
98
|
-
this._tickIntervalPercent = 0;
|
|
99
|
-
/** The dimensions of the slider. */
|
|
100
|
-
this._sliderDimensions = null;
|
|
101
|
-
this._controlValueAccessorChangeFn = () => { };
|
|
102
|
-
/** Subscription to the Directionality change EventEmitter. */
|
|
103
|
-
this._dirChangeSubscription = Subscription.EMPTY;
|
|
104
|
-
/** Called when the user has put their pointer down on the slider. */
|
|
105
|
-
this._pointerDown = (event) => {
|
|
106
|
-
// Don't do anything if the slider is disabled or the
|
|
107
|
-
// user is using anything other than the main mouse button.
|
|
108
|
-
if (this.disabled || this._isSliding || (!isTouchEvent(event) && event.button !== 0)) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
this._ngZone.run(() => {
|
|
112
|
-
const oldValue = this.value;
|
|
113
|
-
const pointerPosition = getPointerPositionOnPage(event);
|
|
114
|
-
this._isSliding = true;
|
|
115
|
-
this._lastPointerEvent = event;
|
|
116
|
-
event.preventDefault();
|
|
117
|
-
this._focusHostElement();
|
|
118
|
-
this._onMouseenter(); // Simulate mouseenter in case this is a mobile device.
|
|
119
|
-
this._bindGlobalEvents(event);
|
|
120
|
-
this._focusHostElement();
|
|
121
|
-
this._updateValueFromPosition(pointerPosition);
|
|
122
|
-
this._valueOnSlideStart = this.value;
|
|
123
|
-
this._pointerPositionOnStart = pointerPosition;
|
|
124
|
-
// Emit a change and input event if the value changed.
|
|
125
|
-
if (oldValue != this.value) {
|
|
126
|
-
this._emitInputEvent();
|
|
127
|
-
this._emitChangeEvent();
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Called when the user has moved their pointer after
|
|
133
|
-
* starting to drag. Bound on the document level.
|
|
134
|
-
*/
|
|
135
|
-
this._pointerMove = (event) => {
|
|
136
|
-
if (this._isSliding) {
|
|
137
|
-
// Prevent the slide from selecting anything else.
|
|
138
|
-
event.preventDefault();
|
|
139
|
-
const oldValue = this.value;
|
|
140
|
-
this._lastPointerEvent = event;
|
|
141
|
-
this._updateValueFromPosition(getPointerPositionOnPage(event));
|
|
142
|
-
// Native range elements always emit `input` events when the value changed while sliding.
|
|
143
|
-
if (oldValue != this.value) {
|
|
144
|
-
this._emitInputEvent();
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
};
|
|
148
|
-
/** Called when the user has lifted their pointer. Bound on the document level. */
|
|
149
|
-
this._pointerUp = (event) => {
|
|
150
|
-
if (this._isSliding) {
|
|
151
|
-
const pointerPositionOnStart = this._pointerPositionOnStart;
|
|
152
|
-
const currentPointerPosition = getPointerPositionOnPage(event);
|
|
153
|
-
event.preventDefault();
|
|
154
|
-
this._removeGlobalEvents();
|
|
155
|
-
this._valueOnSlideStart = this._pointerPositionOnStart = this._lastPointerEvent = null;
|
|
156
|
-
this._isSliding = false;
|
|
157
|
-
if (this._valueOnSlideStart != this.value && !this.disabled &&
|
|
158
|
-
pointerPositionOnStart && (pointerPositionOnStart.x !== currentPointerPosition.x ||
|
|
159
|
-
pointerPositionOnStart.y !== currentPointerPosition.y)) {
|
|
160
|
-
this._emitChangeEvent();
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
/** Called when the window has lost focus. */
|
|
165
|
-
this._windowBlur = () => {
|
|
166
|
-
// If the window is blurred while dragging we need to stop dragging because the
|
|
167
|
-
// browser won't dispatch the `mouseup` and `touchend` events anymore.
|
|
168
|
-
if (this._lastPointerEvent) {
|
|
169
|
-
this._pointerUp(this._lastPointerEvent);
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
this._document = _document;
|
|
173
|
-
this.tabIndex = parseInt(tabIndex) || 0;
|
|
174
|
-
_ngZone.runOutsideAngular(() => {
|
|
175
|
-
const element = elementRef.nativeElement;
|
|
176
|
-
element.addEventListener('mousedown', this._pointerDown, activeEventOptions);
|
|
177
|
-
element.addEventListener('touchstart', this._pointerDown, activeEventOptions);
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
/** Whether the slider is inverted. */
|
|
181
|
-
get invert() { return this._invert; }
|
|
182
|
-
set invert(value) {
|
|
183
|
-
this._invert = coerceBooleanProperty(value);
|
|
184
|
-
}
|
|
185
|
-
/** The maximum value that the slider can have. */
|
|
186
|
-
get max() { return this._max; }
|
|
187
|
-
set max(v) {
|
|
188
|
-
this._max = coerceNumberProperty(v, this._max);
|
|
189
|
-
this._percent = this._calculatePercentage(this._value);
|
|
190
|
-
// Since this also modifies the percentage, we need to let the change detection know.
|
|
191
|
-
this._changeDetectorRef.markForCheck();
|
|
192
|
-
}
|
|
193
|
-
/** The minimum value that the slider can have. */
|
|
194
|
-
get min() { return this._min; }
|
|
195
|
-
set min(v) {
|
|
196
|
-
this._min = coerceNumberProperty(v, this._min);
|
|
197
|
-
// If the value wasn't explicitly set by the user, set it to the min.
|
|
198
|
-
if (this._value === null) {
|
|
199
|
-
this.value = this._min;
|
|
200
|
-
}
|
|
201
|
-
this._percent = this._calculatePercentage(this._value);
|
|
202
|
-
// Since this also modifies the percentage, we need to let the change detection know.
|
|
203
|
-
this._changeDetectorRef.markForCheck();
|
|
204
|
-
}
|
|
205
|
-
/** The values at which the thumb will snap. */
|
|
206
|
-
get step() { return this._step; }
|
|
207
|
-
set step(v) {
|
|
208
|
-
this._step = coerceNumberProperty(v, this._step);
|
|
209
|
-
if (this._step % 1 !== 0) {
|
|
210
|
-
this._roundToDecimal = this._step.toString().split('.').pop().length;
|
|
211
|
-
}
|
|
212
|
-
// Since this could modify the label, we need to notify the change detection.
|
|
213
|
-
this._changeDetectorRef.markForCheck();
|
|
214
|
-
}
|
|
215
|
-
/** Whether or not to show the thumb label. */
|
|
216
|
-
get thumbLabel() { return this._thumbLabel; }
|
|
217
|
-
set thumbLabel(value) { this._thumbLabel = coerceBooleanProperty(value); }
|
|
57
|
+
class MatSlider extends _MatSliderMixinBase {
|
|
58
|
+
constructor(elementRef, _focusMonitor, _changeDetectorRef, _dir, tabIndex, _ngZone, _document, _animationMode) {
|
|
59
|
+
super(elementRef);
|
|
60
|
+
this._focusMonitor = _focusMonitor;
|
|
61
|
+
this._changeDetectorRef = _changeDetectorRef;
|
|
62
|
+
this._dir = _dir;
|
|
63
|
+
this._ngZone = _ngZone;
|
|
64
|
+
this._animationMode = _animationMode;
|
|
65
|
+
this._invert = false;
|
|
66
|
+
this._max = 100;
|
|
67
|
+
this._min = 0;
|
|
68
|
+
this._step = 1;
|
|
69
|
+
this._thumbLabel = false;
|
|
70
|
+
this._tickInterval = 0;
|
|
71
|
+
this._value = null;
|
|
72
|
+
this._vertical = false;
|
|
73
|
+
/** Event emitted when the slider value has changed. */
|
|
74
|
+
this.change = new EventEmitter();
|
|
75
|
+
/** Event emitted when the slider thumb moves. */
|
|
76
|
+
this.input = new EventEmitter();
|
|
218
77
|
/**
|
|
219
|
-
*
|
|
220
|
-
*
|
|
78
|
+
* Emits when the raw value of the slider changes. This is here primarily
|
|
79
|
+
* to facilitate the two-way binding for the `value` input.
|
|
80
|
+
* @docs-private
|
|
221
81
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}
|
|
227
|
-
else if (typeof value === 'number' || typeof value === 'string') {
|
|
228
|
-
this._tickInterval = coerceNumberProperty(value, this._tickInterval);
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
this._tickInterval = 0;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
/** Value of the slider. */
|
|
235
|
-
get value() {
|
|
236
|
-
// If the value needs to be read and it is still uninitialized, initialize it to the min.
|
|
237
|
-
if (this._value === null) {
|
|
238
|
-
this.value = this._min;
|
|
239
|
-
}
|
|
240
|
-
return this._value;
|
|
241
|
-
}
|
|
242
|
-
set value(v) {
|
|
243
|
-
if (v !== this._value) {
|
|
244
|
-
let value = coerceNumberProperty(v);
|
|
245
|
-
// While incrementing by a decimal we can end up with values like 33.300000000000004.
|
|
246
|
-
// Truncate it to ensure that it matches the label and to make it easier to work with.
|
|
247
|
-
if (this._roundToDecimal) {
|
|
248
|
-
value = parseFloat(value.toFixed(this._roundToDecimal));
|
|
249
|
-
}
|
|
250
|
-
this._value = value;
|
|
251
|
-
this._percent = this._calculatePercentage(this._value);
|
|
252
|
-
// Since this also modifies the percentage, we need to let the change detection know.
|
|
253
|
-
this._changeDetectorRef.markForCheck();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
/** Whether the slider is vertical. */
|
|
257
|
-
get vertical() { return this._vertical; }
|
|
258
|
-
set vertical(value) {
|
|
259
|
-
this._vertical = coerceBooleanProperty(value);
|
|
260
|
-
}
|
|
261
|
-
/** The value to be used for display purposes. */
|
|
262
|
-
get displayValue() {
|
|
263
|
-
if (this.displayWith) {
|
|
264
|
-
// Value is never null but since setters and getters cannot have
|
|
265
|
-
// different types, the value getter is also typed to return null.
|
|
266
|
-
return this.displayWith(this.value);
|
|
267
|
-
}
|
|
268
|
-
// Note that this could be improved further by rounding something like 0.999 to 1 or
|
|
269
|
-
// 0.899 to 0.9, however it is very performance sensitive, because it gets called on
|
|
270
|
-
// every change detection cycle.
|
|
271
|
-
if (this._roundToDecimal && this.value && this.value % 1 !== 0) {
|
|
272
|
-
return this.value.toFixed(this._roundToDecimal);
|
|
273
|
-
}
|
|
274
|
-
return this.value || 0;
|
|
275
|
-
}
|
|
276
|
-
/** set focus to the host element */
|
|
277
|
-
focus(options) {
|
|
278
|
-
this._focusHostElement(options);
|
|
279
|
-
}
|
|
280
|
-
/** blur the host element */
|
|
281
|
-
blur() {
|
|
282
|
-
this._blurHostElement();
|
|
283
|
-
}
|
|
284
|
-
/** The percentage of the slider that coincides with the value. */
|
|
285
|
-
get percent() { return this._clamp(this._percent); }
|
|
82
|
+
this.valueChange = new EventEmitter();
|
|
83
|
+
/** onTouch function registered via registerOnTouch (ControlValueAccessor). */
|
|
84
|
+
this.onTouched = () => { };
|
|
85
|
+
this._percent = 0;
|
|
286
86
|
/**
|
|
287
|
-
* Whether
|
|
288
|
-
*
|
|
87
|
+
* Whether or not the thumb is sliding.
|
|
88
|
+
* Used to determine if there should be a transition for the thumb and fill track.
|
|
289
89
|
*/
|
|
290
|
-
|
|
291
|
-
// Standard non-inverted mode for a vertical slider should be dragging the thumb from bottom to
|
|
292
|
-
// top. However from a y-axis standpoint this is inverted.
|
|
293
|
-
return this.vertical ? !this.invert : this.invert;
|
|
294
|
-
}
|
|
295
|
-
/** Whether the slider is at its minimum value. */
|
|
296
|
-
get _isMinValue() {
|
|
297
|
-
return this.percent === 0;
|
|
298
|
-
}
|
|
90
|
+
this._isSliding = false;
|
|
299
91
|
/**
|
|
300
|
-
*
|
|
301
|
-
*
|
|
92
|
+
* Whether or not the slider is active (clicked or sliding).
|
|
93
|
+
* Used to shrink and grow the thumb as according to the Material Design spec.
|
|
302
94
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
95
|
+
this._isActive = false;
|
|
96
|
+
/** The size of a tick interval as a percentage of the size of the track. */
|
|
97
|
+
this._tickIntervalPercent = 0;
|
|
98
|
+
/** The dimensions of the slider. */
|
|
99
|
+
this._sliderDimensions = null;
|
|
100
|
+
this._controlValueAccessorChangeFn = () => { };
|
|
101
|
+
/** Subscription to the Directionality change EventEmitter. */
|
|
102
|
+
this._dirChangeSubscription = Subscription.EMPTY;
|
|
103
|
+
/** Called when the user has put their pointer down on the slider. */
|
|
104
|
+
this._pointerDown = (event) => {
|
|
105
|
+
// Don't do anything if the slider is disabled or the
|
|
106
|
+
// user is using anything other than the main mouse button.
|
|
107
|
+
if (this.disabled || this._isSliding || (!isTouchEvent(event) && event.button !== 0)) {
|
|
108
|
+
return;
|
|
309
109
|
}
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
const sign = this._shouldInvertMouseCoords() ? '' : '-';
|
|
328
|
-
return {
|
|
329
|
-
// scale3d avoids some rendering issues in Chrome. See #12071.
|
|
330
|
-
transform: `translate${axis}(${sign}${this._thumbGap}px) scale3d(${scale})`,
|
|
331
|
-
// iOS Safari has a bug where it won't re-render elements which start of as `scale(0)` until
|
|
332
|
-
// something forces a style recalculation on it. Since we'll end up with `scale(0)` when
|
|
333
|
-
// the value of the slider is 0, we can easily get into this situation. We force a
|
|
334
|
-
// recalculation by changing the element's `display` when it goes from 0 to any other value.
|
|
335
|
-
display: percent === 0 ? 'none' : ''
|
|
336
|
-
};
|
|
337
|
-
}
|
|
338
|
-
/** CSS styles for the ticks container element. */
|
|
339
|
-
get _ticksContainerStyles() {
|
|
340
|
-
let axis = this.vertical ? 'Y' : 'X';
|
|
341
|
-
// For a horizontal slider in RTL languages we push the ticks container off the left edge
|
|
342
|
-
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
|
|
343
|
-
let sign = !this.vertical && this._getDirection() == 'rtl' ? '' : '-';
|
|
344
|
-
let offset = this._tickIntervalPercent / 2 * 100;
|
|
345
|
-
return {
|
|
346
|
-
'transform': `translate${axis}(${sign}${offset}%)`
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
/** CSS styles for the ticks element. */
|
|
350
|
-
get _ticksStyles() {
|
|
351
|
-
let tickSize = this._tickIntervalPercent * 100;
|
|
352
|
-
let backgroundSize = this.vertical ? `2px ${tickSize}%` : `${tickSize}% 2px`;
|
|
353
|
-
let axis = this.vertical ? 'Y' : 'X';
|
|
354
|
-
// Depending on the direction we pushed the ticks container, push the ticks the opposite
|
|
355
|
-
// direction to re-center them but clip off the end edge. In RTL languages we need to flip the
|
|
356
|
-
// ticks 180 degrees so we're really cutting off the end edge abd not the start.
|
|
357
|
-
let sign = !this.vertical && this._getDirection() == 'rtl' ? '-' : '';
|
|
358
|
-
let rotate = !this.vertical && this._getDirection() == 'rtl' ? ' rotate(180deg)' : '';
|
|
359
|
-
let styles = {
|
|
360
|
-
'backgroundSize': backgroundSize,
|
|
361
|
-
// Without translateZ ticks sometimes jitter as the slider moves on Chrome & Firefox.
|
|
362
|
-
'transform': `translateZ(0) translate${axis}(${sign}${tickSize / 2}%)${rotate}`
|
|
363
|
-
};
|
|
364
|
-
if (this._isMinValue && this._thumbGap) {
|
|
365
|
-
let side;
|
|
366
|
-
if (this.vertical) {
|
|
367
|
-
side = this._invertAxis ? 'Bottom' : 'Top';
|
|
368
|
-
}
|
|
369
|
-
else {
|
|
370
|
-
side = this._invertAxis ? 'Right' : 'Left';
|
|
110
|
+
this._ngZone.run(() => {
|
|
111
|
+
const oldValue = this.value;
|
|
112
|
+
const pointerPosition = getPointerPositionOnPage(event);
|
|
113
|
+
this._isSliding = true;
|
|
114
|
+
this._lastPointerEvent = event;
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
this._focusHostElement();
|
|
117
|
+
this._onMouseenter(); // Simulate mouseenter in case this is a mobile device.
|
|
118
|
+
this._bindGlobalEvents(event);
|
|
119
|
+
this._focusHostElement();
|
|
120
|
+
this._updateValueFromPosition(pointerPosition);
|
|
121
|
+
this._valueOnSlideStart = this.value;
|
|
122
|
+
this._pointerPositionOnStart = pointerPosition;
|
|
123
|
+
// Emit a change and input event if the value changed.
|
|
124
|
+
if (oldValue != this.value) {
|
|
125
|
+
this._emitInputEvent();
|
|
126
|
+
this._emitChangeEvent();
|
|
371
127
|
}
|
|
372
|
-
styles[`padding${side}`] = `${this._thumbGap}px`;
|
|
373
|
-
}
|
|
374
|
-
return styles;
|
|
375
|
-
}
|
|
376
|
-
get _thumbContainerStyles() {
|
|
377
|
-
let axis = this.vertical ? 'Y' : 'X';
|
|
378
|
-
// For a horizontal slider in RTL languages we push the thumb container off the left edge
|
|
379
|
-
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
|
|
380
|
-
let invertOffset = (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
|
|
381
|
-
let offset = (invertOffset ? this.percent : 1 - this.percent) * 100;
|
|
382
|
-
return {
|
|
383
|
-
'transform': `translate${axis}(-${offset}%)`
|
|
384
|
-
};
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Whether mouse events should be converted to a slider position by calculating their distance
|
|
388
|
-
* from the right or bottom edge of the slider as opposed to the top or left.
|
|
389
|
-
*/
|
|
390
|
-
_shouldInvertMouseCoords() {
|
|
391
|
-
return (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
|
|
392
|
-
}
|
|
393
|
-
/** The language direction for this slider element. */
|
|
394
|
-
_getDirection() {
|
|
395
|
-
return (this._dir && this._dir.value == 'rtl') ? 'rtl' : 'ltr';
|
|
396
|
-
}
|
|
397
|
-
ngAfterViewInit() {
|
|
398
|
-
this._focusMonitor
|
|
399
|
-
.monitor(this._elementRef, true)
|
|
400
|
-
.subscribe((origin) => {
|
|
401
|
-
this._isActive = !!origin && origin !== 'keyboard';
|
|
402
|
-
this._changeDetectorRef.detectChanges();
|
|
403
128
|
});
|
|
404
|
-
|
|
405
|
-
this._dirChangeSubscription = this._dir.change.subscribe(() => {
|
|
406
|
-
this._changeDetectorRef.markForCheck();
|
|
407
|
-
});
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
ngOnDestroy() {
|
|
411
|
-
const element = this._elementRef.nativeElement;
|
|
412
|
-
element.removeEventListener('mousedown', this._pointerDown, activeEventOptions);
|
|
413
|
-
element.removeEventListener('touchstart', this._pointerDown, activeEventOptions);
|
|
414
|
-
this._lastPointerEvent = null;
|
|
415
|
-
this._removeGlobalEvents();
|
|
416
|
-
this._focusMonitor.stopMonitoring(this._elementRef);
|
|
417
|
-
this._dirChangeSubscription.unsubscribe();
|
|
418
|
-
}
|
|
419
|
-
_onMouseenter() {
|
|
420
|
-
if (this.disabled) {
|
|
421
|
-
return;
|
|
422
|
-
}
|
|
423
|
-
// We save the dimensions of the slider here so we can use them to update the spacing of the
|
|
424
|
-
// ticks and determine where on the slider click and slide events happen.
|
|
425
|
-
this._sliderDimensions = this._getSliderDimensions();
|
|
426
|
-
this._updateTickIntervalPercent();
|
|
427
|
-
}
|
|
428
|
-
_onFocus() {
|
|
429
|
-
// We save the dimensions of the slider here so we can use them to update the spacing of the
|
|
430
|
-
// ticks and determine where on the slider click and slide events happen.
|
|
431
|
-
this._sliderDimensions = this._getSliderDimensions();
|
|
432
|
-
this._updateTickIntervalPercent();
|
|
433
|
-
}
|
|
434
|
-
_onBlur() {
|
|
435
|
-
this.onTouched();
|
|
436
|
-
}
|
|
437
|
-
_onKeydown(event) {
|
|
438
|
-
if (this.disabled || hasModifierKey(event)) {
|
|
439
|
-
return;
|
|
440
|
-
}
|
|
441
|
-
const oldValue = this.value;
|
|
442
|
-
switch (event.keyCode) {
|
|
443
|
-
case PAGE_UP:
|
|
444
|
-
this._increment(10);
|
|
445
|
-
break;
|
|
446
|
-
case PAGE_DOWN:
|
|
447
|
-
this._increment(-10);
|
|
448
|
-
break;
|
|
449
|
-
case END:
|
|
450
|
-
this.value = this.max;
|
|
451
|
-
break;
|
|
452
|
-
case HOME:
|
|
453
|
-
this.value = this.min;
|
|
454
|
-
break;
|
|
455
|
-
case LEFT_ARROW:
|
|
456
|
-
// NOTE: For a sighted user it would make more sense that when they press an arrow key on an
|
|
457
|
-
// inverted slider the thumb moves in that direction. However for a blind user, nothing
|
|
458
|
-
// about the slider indicates that it is inverted. They will expect left to be decrement,
|
|
459
|
-
// regardless of how it appears on the screen. For speakers ofRTL languages, they probably
|
|
460
|
-
// expect left to mean increment. Therefore we flip the meaning of the side arrow keys for
|
|
461
|
-
// RTL. For inverted sliders we prefer a good a11y experience to having it "look right" for
|
|
462
|
-
// sighted users, therefore we do not swap the meaning.
|
|
463
|
-
this._increment(this._getDirection() == 'rtl' ? 1 : -1);
|
|
464
|
-
break;
|
|
465
|
-
case UP_ARROW:
|
|
466
|
-
this._increment(1);
|
|
467
|
-
break;
|
|
468
|
-
case RIGHT_ARROW:
|
|
469
|
-
// See comment on LEFT_ARROW about the conditions under which we flip the meaning.
|
|
470
|
-
this._increment(this._getDirection() == 'rtl' ? -1 : 1);
|
|
471
|
-
break;
|
|
472
|
-
case DOWN_ARROW:
|
|
473
|
-
this._increment(-1);
|
|
474
|
-
break;
|
|
475
|
-
default:
|
|
476
|
-
// Return if the key is not one that we explicitly handle to avoid calling preventDefault on
|
|
477
|
-
// it.
|
|
478
|
-
return;
|
|
479
|
-
}
|
|
480
|
-
if (oldValue != this.value) {
|
|
481
|
-
this._emitInputEvent();
|
|
482
|
-
this._emitChangeEvent();
|
|
483
|
-
}
|
|
484
|
-
this._isSliding = true;
|
|
485
|
-
event.preventDefault();
|
|
486
|
-
}
|
|
487
|
-
_onKeyup() {
|
|
488
|
-
this._isSliding = false;
|
|
489
|
-
}
|
|
490
|
-
/** Use defaultView of injected document if available or fallback to global window reference */
|
|
491
|
-
_getWindow() {
|
|
492
|
-
return this._document.defaultView || window;
|
|
493
|
-
}
|
|
129
|
+
};
|
|
494
130
|
/**
|
|
495
|
-
*
|
|
496
|
-
*
|
|
497
|
-
* as they're swiping across the screen.
|
|
131
|
+
* Called when the user has moved their pointer after
|
|
132
|
+
* starting to drag. Bound on the document level.
|
|
498
133
|
*/
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
134
|
+
this._pointerMove = (event) => {
|
|
135
|
+
if (this._isSliding) {
|
|
136
|
+
// Prevent the slide from selecting anything else.
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
const oldValue = this.value;
|
|
139
|
+
this._lastPointerEvent = event;
|
|
140
|
+
this._updateValueFromPosition(getPointerPositionOnPage(event));
|
|
141
|
+
// Native range elements always emit `input` events when the value changed while sliding.
|
|
142
|
+
if (oldValue != this.value) {
|
|
143
|
+
this._emitInputEvent();
|
|
144
|
+
}
|
|
510
145
|
}
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
146
|
+
};
|
|
147
|
+
/** Called when the user has lifted their pointer. Bound on the document level. */
|
|
148
|
+
this._pointerUp = (event) => {
|
|
149
|
+
if (this._isSliding) {
|
|
150
|
+
const pointerPositionOnStart = this._pointerPositionOnStart;
|
|
151
|
+
const currentPointerPosition = getPointerPositionOnPage(event);
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
this._removeGlobalEvents();
|
|
154
|
+
this._valueOnSlideStart = this._pointerPositionOnStart = this._lastPointerEvent = null;
|
|
155
|
+
this._isSliding = false;
|
|
156
|
+
if (this._valueOnSlideStart != this.value && !this.disabled &&
|
|
157
|
+
pointerPositionOnStart && (pointerPositionOnStart.x !== currentPointerPosition.x ||
|
|
158
|
+
pointerPositionOnStart.y !== currentPointerPosition.y)) {
|
|
159
|
+
this._emitChangeEvent();
|
|
160
|
+
}
|
|
514
161
|
}
|
|
515
|
-
}
|
|
516
|
-
/**
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
document.removeEventListener('touchend', this._pointerUp, activeEventOptions);
|
|
523
|
-
document.removeEventListener('touchcancel', this._pointerUp, activeEventOptions);
|
|
524
|
-
const window = this._getWindow();
|
|
525
|
-
if (typeof window !== 'undefined' && window) {
|
|
526
|
-
window.removeEventListener('blur', this._windowBlur);
|
|
162
|
+
};
|
|
163
|
+
/** Called when the window has lost focus. */
|
|
164
|
+
this._windowBlur = () => {
|
|
165
|
+
// If the window is blurred while dragging we need to stop dragging because the
|
|
166
|
+
// browser won't dispatch the `mouseup` and `touchend` events anymore.
|
|
167
|
+
if (this._lastPointerEvent) {
|
|
168
|
+
this._pointerUp(this._lastPointerEvent);
|
|
527
169
|
}
|
|
170
|
+
};
|
|
171
|
+
this._document = _document;
|
|
172
|
+
this.tabIndex = parseInt(tabIndex) || 0;
|
|
173
|
+
_ngZone.runOutsideAngular(() => {
|
|
174
|
+
const element = elementRef.nativeElement;
|
|
175
|
+
element.addEventListener('mousedown', this._pointerDown, activeEventOptions);
|
|
176
|
+
element.addEventListener('touchstart', this._pointerDown, activeEventOptions);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
/** Whether the slider is inverted. */
|
|
180
|
+
get invert() { return this._invert; }
|
|
181
|
+
set invert(value) {
|
|
182
|
+
this._invert = coerceBooleanProperty(value);
|
|
183
|
+
}
|
|
184
|
+
/** The maximum value that the slider can have. */
|
|
185
|
+
get max() { return this._max; }
|
|
186
|
+
set max(v) {
|
|
187
|
+
this._max = coerceNumberProperty(v, this._max);
|
|
188
|
+
this._percent = this._calculatePercentage(this._value);
|
|
189
|
+
// Since this also modifies the percentage, we need to let the change detection know.
|
|
190
|
+
this._changeDetectorRef.markForCheck();
|
|
191
|
+
}
|
|
192
|
+
/** The minimum value that the slider can have. */
|
|
193
|
+
get min() { return this._min; }
|
|
194
|
+
set min(v) {
|
|
195
|
+
this._min = coerceNumberProperty(v, this._min);
|
|
196
|
+
// If the value wasn't explicitly set by the user, set it to the min.
|
|
197
|
+
if (this._value === null) {
|
|
198
|
+
this.value = this._min;
|
|
199
|
+
}
|
|
200
|
+
this._percent = this._calculatePercentage(this._value);
|
|
201
|
+
// Since this also modifies the percentage, we need to let the change detection know.
|
|
202
|
+
this._changeDetectorRef.markForCheck();
|
|
203
|
+
}
|
|
204
|
+
/** The values at which the thumb will snap. */
|
|
205
|
+
get step() { return this._step; }
|
|
206
|
+
set step(v) {
|
|
207
|
+
this._step = coerceNumberProperty(v, this._step);
|
|
208
|
+
if (this._step % 1 !== 0) {
|
|
209
|
+
this._roundToDecimal = this._step.toString().split('.').pop().length;
|
|
210
|
+
}
|
|
211
|
+
// Since this could modify the label, we need to notify the change detection.
|
|
212
|
+
this._changeDetectorRef.markForCheck();
|
|
213
|
+
}
|
|
214
|
+
/** Whether or not to show the thumb label. */
|
|
215
|
+
get thumbLabel() { return this._thumbLabel; }
|
|
216
|
+
set thumbLabel(value) { this._thumbLabel = coerceBooleanProperty(value); }
|
|
217
|
+
/**
|
|
218
|
+
* How often to show ticks. Relative to the step so that a tick always appears on a step.
|
|
219
|
+
* Ex: Tick interval of 4 with a step of 3 will draw a tick every 4 steps (every 12 values).
|
|
220
|
+
*/
|
|
221
|
+
get tickInterval() { return this._tickInterval; }
|
|
222
|
+
set tickInterval(value) {
|
|
223
|
+
if (value === 'auto') {
|
|
224
|
+
this._tickInterval = 'auto';
|
|
225
|
+
}
|
|
226
|
+
else if (typeof value === 'number' || typeof value === 'string') {
|
|
227
|
+
this._tickInterval = coerceNumberProperty(value, this._tickInterval);
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
this._tickInterval = 0;
|
|
528
231
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
232
|
+
}
|
|
233
|
+
/** Value of the slider. */
|
|
234
|
+
get value() {
|
|
235
|
+
// If the value needs to be read and it is still uninitialized, initialize it to the min.
|
|
236
|
+
if (this._value === null) {
|
|
237
|
+
this.value = this._min;
|
|
532
238
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
let percent = this._clamp((posComponent - offset) / size);
|
|
543
|
-
if (this._shouldInvertMouseCoords()) {
|
|
544
|
-
percent = 1 - percent;
|
|
545
|
-
}
|
|
546
|
-
// Since the steps may not divide cleanly into the max value, if the user
|
|
547
|
-
// slid to 0 or 100 percent, we jump to the min/max value. This approach
|
|
548
|
-
// is slightly more intuitive than using `Math.ceil` below, because it
|
|
549
|
-
// follows the user's pointer closer.
|
|
550
|
-
if (percent === 0) {
|
|
551
|
-
this.value = this.min;
|
|
552
|
-
}
|
|
553
|
-
else if (percent === 1) {
|
|
554
|
-
this.value = this.max;
|
|
555
|
-
}
|
|
556
|
-
else {
|
|
557
|
-
const exactValue = this._calculateValue(percent);
|
|
558
|
-
// This calculation finds the closest step by finding the closest
|
|
559
|
-
// whole number divisible by the step relative to the min.
|
|
560
|
-
const closestValue = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
|
|
561
|
-
// The value needs to snap to the min and max.
|
|
562
|
-
this.value = this._clamp(closestValue, this.min, this.max);
|
|
239
|
+
return this._value;
|
|
240
|
+
}
|
|
241
|
+
set value(v) {
|
|
242
|
+
if (v !== this._value) {
|
|
243
|
+
let value = coerceNumberProperty(v);
|
|
244
|
+
// While incrementing by a decimal we can end up with values like 33.300000000000004.
|
|
245
|
+
// Truncate it to ensure that it matches the label and to make it easier to work with.
|
|
246
|
+
if (this._roundToDecimal) {
|
|
247
|
+
value = parseFloat(value.toFixed(this._roundToDecimal));
|
|
563
248
|
}
|
|
249
|
+
this._value = value;
|
|
250
|
+
this._percent = this._calculatePercentage(this._value);
|
|
251
|
+
// Since this also modifies the percentage, we need to let the change detection know.
|
|
252
|
+
this._changeDetectorRef.markForCheck();
|
|
564
253
|
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
254
|
+
}
|
|
255
|
+
/** Whether the slider is vertical. */
|
|
256
|
+
get vertical() { return this._vertical; }
|
|
257
|
+
set vertical(value) {
|
|
258
|
+
this._vertical = coerceBooleanProperty(value);
|
|
259
|
+
}
|
|
260
|
+
/** The value to be used for display purposes. */
|
|
261
|
+
get displayValue() {
|
|
262
|
+
if (this.displayWith) {
|
|
263
|
+
// Value is never null but since setters and getters cannot have
|
|
264
|
+
// different types, the value getter is also typed to return null.
|
|
265
|
+
return this.displayWith(this.value);
|
|
266
|
+
}
|
|
267
|
+
// Note that this could be improved further by rounding something like 0.999 to 1 or
|
|
268
|
+
// 0.899 to 0.9, however it is very performance sensitive, because it gets called on
|
|
269
|
+
// every change detection cycle.
|
|
270
|
+
if (this._roundToDecimal && this.value && this.value % 1 !== 0) {
|
|
271
|
+
return this.value.toFixed(this._roundToDecimal);
|
|
272
|
+
}
|
|
273
|
+
return this.value || 0;
|
|
274
|
+
}
|
|
275
|
+
/** set focus to the host element */
|
|
276
|
+
focus(options) {
|
|
277
|
+
this._focusHostElement(options);
|
|
278
|
+
}
|
|
279
|
+
/** blur the host element */
|
|
280
|
+
blur() {
|
|
281
|
+
this._blurHostElement();
|
|
282
|
+
}
|
|
283
|
+
/** The percentage of the slider that coincides with the value. */
|
|
284
|
+
get percent() { return this._clamp(this._percent); }
|
|
285
|
+
/**
|
|
286
|
+
* Whether the axis of the slider is inverted.
|
|
287
|
+
* (i.e. whether moving the thumb in the positive x or y direction decreases the slider's value).
|
|
288
|
+
*/
|
|
289
|
+
get _invertAxis() {
|
|
290
|
+
// Standard non-inverted mode for a vertical slider should be dragging the thumb from bottom to
|
|
291
|
+
// top. However from a y-axis standpoint this is inverted.
|
|
292
|
+
return this.vertical ? !this.invert : this.invert;
|
|
293
|
+
}
|
|
294
|
+
/** Whether the slider is at its minimum value. */
|
|
295
|
+
get _isMinValue() {
|
|
296
|
+
return this.percent === 0;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* The amount of space to leave between the slider thumb and the track fill & track background
|
|
300
|
+
* elements.
|
|
301
|
+
*/
|
|
302
|
+
get _thumbGap() {
|
|
303
|
+
if (this.disabled) {
|
|
304
|
+
return DISABLED_THUMB_GAP;
|
|
305
|
+
}
|
|
306
|
+
if (this._isMinValue && !this.thumbLabel) {
|
|
307
|
+
return this._isActive ? MIN_VALUE_ACTIVE_THUMB_GAP : MIN_VALUE_NONACTIVE_THUMB_GAP;
|
|
308
|
+
}
|
|
309
|
+
return 0;
|
|
310
|
+
}
|
|
311
|
+
/** CSS styles for the track background element. */
|
|
312
|
+
get _trackBackgroundStyles() {
|
|
313
|
+
const axis = this.vertical ? 'Y' : 'X';
|
|
314
|
+
const scale = this.vertical ? `1, ${1 - this.percent}, 1` : `${1 - this.percent}, 1, 1`;
|
|
315
|
+
const sign = this._shouldInvertMouseCoords() ? '-' : '';
|
|
316
|
+
return {
|
|
317
|
+
// scale3d avoids some rendering issues in Chrome. See #12071.
|
|
318
|
+
transform: `translate${axis}(${sign}${this._thumbGap}px) scale3d(${scale})`
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/** CSS styles for the track fill element. */
|
|
322
|
+
get _trackFillStyles() {
|
|
323
|
+
const percent = this.percent;
|
|
324
|
+
const axis = this.vertical ? 'Y' : 'X';
|
|
325
|
+
const scale = this.vertical ? `1, ${percent}, 1` : `${percent}, 1, 1`;
|
|
326
|
+
const sign = this._shouldInvertMouseCoords() ? '' : '-';
|
|
327
|
+
return {
|
|
328
|
+
// scale3d avoids some rendering issues in Chrome. See #12071.
|
|
329
|
+
transform: `translate${axis}(${sign}${this._thumbGap}px) scale3d(${scale})`,
|
|
330
|
+
// iOS Safari has a bug where it won't re-render elements which start of as `scale(0)` until
|
|
331
|
+
// something forces a style recalculation on it. Since we'll end up with `scale(0)` when
|
|
332
|
+
// the value of the slider is 0, we can easily get into this situation. We force a
|
|
333
|
+
// recalculation by changing the element's `display` when it goes from 0 to any other value.
|
|
334
|
+
display: percent === 0 ? 'none' : ''
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/** CSS styles for the ticks container element. */
|
|
338
|
+
get _ticksContainerStyles() {
|
|
339
|
+
let axis = this.vertical ? 'Y' : 'X';
|
|
340
|
+
// For a horizontal slider in RTL languages we push the ticks container off the left edge
|
|
341
|
+
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
|
|
342
|
+
let sign = !this.vertical && this._getDirection() == 'rtl' ? '' : '-';
|
|
343
|
+
let offset = this._tickIntervalPercent / 2 * 100;
|
|
344
|
+
return {
|
|
345
|
+
'transform': `translate${axis}(${sign}${offset}%)`
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/** CSS styles for the ticks element. */
|
|
349
|
+
get _ticksStyles() {
|
|
350
|
+
let tickSize = this._tickIntervalPercent * 100;
|
|
351
|
+
let backgroundSize = this.vertical ? `2px ${tickSize}%` : `${tickSize}% 2px`;
|
|
352
|
+
let axis = this.vertical ? 'Y' : 'X';
|
|
353
|
+
// Depending on the direction we pushed the ticks container, push the ticks the opposite
|
|
354
|
+
// direction to re-center them but clip off the end edge. In RTL languages we need to flip the
|
|
355
|
+
// ticks 180 degrees so we're really cutting off the end edge abd not the start.
|
|
356
|
+
let sign = !this.vertical && this._getDirection() == 'rtl' ? '-' : '';
|
|
357
|
+
let rotate = !this.vertical && this._getDirection() == 'rtl' ? ' rotate(180deg)' : '';
|
|
358
|
+
let styles = {
|
|
359
|
+
'backgroundSize': backgroundSize,
|
|
360
|
+
// Without translateZ ticks sometimes jitter as the slider moves on Chrome & Firefox.
|
|
361
|
+
'transform': `translateZ(0) translate${axis}(${sign}${tickSize / 2}%)${rotate}`
|
|
362
|
+
};
|
|
363
|
+
if (this._isMinValue && this._thumbGap) {
|
|
364
|
+
let side;
|
|
365
|
+
if (this.vertical) {
|
|
366
|
+
side = this._invertAxis ? 'Bottom' : 'Top';
|
|
586
367
|
}
|
|
587
368
|
else {
|
|
588
|
-
|
|
369
|
+
side = this._invertAxis ? 'Right' : 'Left';
|
|
589
370
|
}
|
|
371
|
+
styles[`padding${side}`] = `${this._thumbGap}px`;
|
|
590
372
|
}
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
373
|
+
return styles;
|
|
374
|
+
}
|
|
375
|
+
get _thumbContainerStyles() {
|
|
376
|
+
let axis = this.vertical ? 'Y' : 'X';
|
|
377
|
+
// For a horizontal slider in RTL languages we push the thumb container off the left edge
|
|
378
|
+
// instead of the right edge to avoid causing a horizontal scrollbar to appear.
|
|
379
|
+
let invertOffset = (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
|
|
380
|
+
let offset = (invertOffset ? this.percent : 1 - this.percent) * 100;
|
|
381
|
+
return {
|
|
382
|
+
'transform': `translate${axis}(-${offset}%)`
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Whether mouse events should be converted to a slider position by calculating their distance
|
|
387
|
+
* from the right or bottom edge of the slider as opposed to the top or left.
|
|
388
|
+
*/
|
|
389
|
+
_shouldInvertMouseCoords() {
|
|
390
|
+
return (this._getDirection() == 'rtl' && !this.vertical) ? !this._invertAxis : this._invertAxis;
|
|
391
|
+
}
|
|
392
|
+
/** The language direction for this slider element. */
|
|
393
|
+
_getDirection() {
|
|
394
|
+
return (this._dir && this._dir.value == 'rtl') ? 'rtl' : 'ltr';
|
|
395
|
+
}
|
|
396
|
+
ngAfterViewInit() {
|
|
397
|
+
this._focusMonitor
|
|
398
|
+
.monitor(this._elementRef, true)
|
|
399
|
+
.subscribe((origin) => {
|
|
400
|
+
this._isActive = !!origin && origin !== 'keyboard';
|
|
401
|
+
this._changeDetectorRef.detectChanges();
|
|
402
|
+
});
|
|
403
|
+
if (this._dir) {
|
|
404
|
+
this._dirChangeSubscription = this._dir.change.subscribe(() => {
|
|
405
|
+
this._changeDetectorRef.markForCheck();
|
|
406
|
+
});
|
|
605
407
|
}
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
408
|
+
}
|
|
409
|
+
ngOnDestroy() {
|
|
410
|
+
const element = this._elementRef.nativeElement;
|
|
411
|
+
element.removeEventListener('mousedown', this._pointerDown, activeEventOptions);
|
|
412
|
+
element.removeEventListener('touchstart', this._pointerDown, activeEventOptions);
|
|
413
|
+
this._lastPointerEvent = null;
|
|
414
|
+
this._removeGlobalEvents();
|
|
415
|
+
this._focusMonitor.stopMonitoring(this._elementRef);
|
|
416
|
+
this._dirChangeSubscription.unsubscribe();
|
|
417
|
+
}
|
|
418
|
+
_onMouseenter() {
|
|
419
|
+
if (this.disabled) {
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
// We save the dimensions of the slider here so we can use them to update the spacing of the
|
|
423
|
+
// ticks and determine where on the slider click and slide events happen.
|
|
424
|
+
this._sliderDimensions = this._getSliderDimensions();
|
|
425
|
+
this._updateTickIntervalPercent();
|
|
426
|
+
}
|
|
427
|
+
_onFocus() {
|
|
428
|
+
// We save the dimensions of the slider here so we can use them to update the spacing of the
|
|
429
|
+
// ticks and determine where on the slider click and slide events happen.
|
|
430
|
+
this._sliderDimensions = this._getSliderDimensions();
|
|
431
|
+
this._updateTickIntervalPercent();
|
|
432
|
+
}
|
|
433
|
+
_onBlur() {
|
|
434
|
+
this.onTouched();
|
|
435
|
+
}
|
|
436
|
+
_onKeydown(event) {
|
|
437
|
+
if (this.disabled || hasModifierKey(event)) {
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
const oldValue = this.value;
|
|
441
|
+
switch (event.keyCode) {
|
|
442
|
+
case PAGE_UP:
|
|
443
|
+
this._increment(10);
|
|
444
|
+
break;
|
|
445
|
+
case PAGE_DOWN:
|
|
446
|
+
this._increment(-10);
|
|
447
|
+
break;
|
|
448
|
+
case END:
|
|
449
|
+
this.value = this.max;
|
|
450
|
+
break;
|
|
451
|
+
case HOME:
|
|
452
|
+
this.value = this.min;
|
|
453
|
+
break;
|
|
454
|
+
case LEFT_ARROW:
|
|
455
|
+
// NOTE: For a sighted user it would make more sense that when they press an arrow key on an
|
|
456
|
+
// inverted slider the thumb moves in that direction. However for a blind user, nothing
|
|
457
|
+
// about the slider indicates that it is inverted. They will expect left to be decrement,
|
|
458
|
+
// regardless of how it appears on the screen. For speakers ofRTL languages, they probably
|
|
459
|
+
// expect left to mean increment. Therefore we flip the meaning of the side arrow keys for
|
|
460
|
+
// RTL. For inverted sliders we prefer a good a11y experience to having it "look right" for
|
|
461
|
+
// sighted users, therefore we do not swap the meaning.
|
|
462
|
+
this._increment(this._getDirection() == 'rtl' ? 1 : -1);
|
|
463
|
+
break;
|
|
464
|
+
case UP_ARROW:
|
|
465
|
+
this._increment(1);
|
|
466
|
+
break;
|
|
467
|
+
case RIGHT_ARROW:
|
|
468
|
+
// See comment on LEFT_ARROW about the conditions under which we flip the meaning.
|
|
469
|
+
this._increment(this._getDirection() == 'rtl' ? -1 : 1);
|
|
470
|
+
break;
|
|
471
|
+
case DOWN_ARROW:
|
|
472
|
+
this._increment(-1);
|
|
473
|
+
break;
|
|
474
|
+
default:
|
|
475
|
+
// Return if the key is not one that we explicitly handle to avoid calling preventDefault on
|
|
476
|
+
// it.
|
|
477
|
+
return;
|
|
609
478
|
}
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
* take up.
|
|
614
|
-
*/
|
|
615
|
-
_getSliderDimensions() {
|
|
616
|
-
return this._sliderWrapper ? this._sliderWrapper.nativeElement.getBoundingClientRect() : null;
|
|
479
|
+
if (oldValue != this.value) {
|
|
480
|
+
this._emitInputEvent();
|
|
481
|
+
this._emitChangeEvent();
|
|
617
482
|
}
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
483
|
+
this._isSliding = true;
|
|
484
|
+
event.preventDefault();
|
|
485
|
+
}
|
|
486
|
+
_onKeyup() {
|
|
487
|
+
this._isSliding = false;
|
|
488
|
+
}
|
|
489
|
+
/** Use defaultView of injected document if available or fallback to global window reference */
|
|
490
|
+
_getWindow() {
|
|
491
|
+
return this._document.defaultView || window;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Binds our global move and end events. They're bound at the document level and only while
|
|
495
|
+
* dragging so that the user doesn't have to keep their pointer exactly over the slider
|
|
496
|
+
* as they're swiping across the screen.
|
|
497
|
+
*/
|
|
498
|
+
_bindGlobalEvents(triggerEvent) {
|
|
499
|
+
// Note that we bind the events to the `document`, because it allows us to capture
|
|
500
|
+
// drag cancel events where the user's pointer is outside the browser window.
|
|
501
|
+
const document = this._document;
|
|
502
|
+
const isTouch = isTouchEvent(triggerEvent);
|
|
503
|
+
const moveEventName = isTouch ? 'touchmove' : 'mousemove';
|
|
504
|
+
const endEventName = isTouch ? 'touchend' : 'mouseup';
|
|
505
|
+
document.addEventListener(moveEventName, this._pointerMove, activeEventOptions);
|
|
506
|
+
document.addEventListener(endEventName, this._pointerUp, activeEventOptions);
|
|
507
|
+
if (isTouch) {
|
|
508
|
+
document.addEventListener('touchcancel', this._pointerUp, activeEventOptions);
|
|
509
|
+
}
|
|
510
|
+
const window = this._getWindow();
|
|
511
|
+
if (typeof window !== 'undefined' && window) {
|
|
512
|
+
window.addEventListener('blur', this._windowBlur);
|
|
624
513
|
}
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
514
|
+
}
|
|
515
|
+
/** Removes any global event listeners that we may have added. */
|
|
516
|
+
_removeGlobalEvents() {
|
|
517
|
+
const document = this._document;
|
|
518
|
+
document.removeEventListener('mousemove', this._pointerMove, activeEventOptions);
|
|
519
|
+
document.removeEventListener('mouseup', this._pointerUp, activeEventOptions);
|
|
520
|
+
document.removeEventListener('touchmove', this._pointerMove, activeEventOptions);
|
|
521
|
+
document.removeEventListener('touchend', this._pointerUp, activeEventOptions);
|
|
522
|
+
document.removeEventListener('touchcancel', this._pointerUp, activeEventOptions);
|
|
523
|
+
const window = this._getWindow();
|
|
524
|
+
if (typeof window !== 'undefined' && window) {
|
|
525
|
+
window.removeEventListener('blur', this._windowBlur);
|
|
628
526
|
}
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
527
|
+
}
|
|
528
|
+
/** Increments the slider by the given number of steps (negative number decrements). */
|
|
529
|
+
_increment(numSteps) {
|
|
530
|
+
this.value = this._clamp((this.value || 0) + this.step * numSteps, this.min, this.max);
|
|
531
|
+
}
|
|
532
|
+
/** Calculate the new value from the new physical location. The value will always be snapped. */
|
|
533
|
+
_updateValueFromPosition(pos) {
|
|
534
|
+
if (!this._sliderDimensions) {
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
let offset = this.vertical ? this._sliderDimensions.top : this._sliderDimensions.left;
|
|
538
|
+
let size = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
|
|
539
|
+
let posComponent = this.vertical ? pos.y : pos.x;
|
|
540
|
+
// The exact value is calculated from the event and used to find the closest snap value.
|
|
541
|
+
let percent = this._clamp((posComponent - offset) / size);
|
|
542
|
+
if (this._shouldInvertMouseCoords()) {
|
|
543
|
+
percent = 1 - percent;
|
|
544
|
+
}
|
|
545
|
+
// Since the steps may not divide cleanly into the max value, if the user
|
|
546
|
+
// slid to 0 or 100 percent, we jump to the min/max value. This approach
|
|
547
|
+
// is slightly more intuitive than using `Math.ceil` below, because it
|
|
548
|
+
// follows the user's pointer closer.
|
|
549
|
+
if (percent === 0) {
|
|
550
|
+
this.value = this.min;
|
|
551
|
+
}
|
|
552
|
+
else if (percent === 1) {
|
|
553
|
+
this.value = this.max;
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
const exactValue = this._calculateValue(percent);
|
|
557
|
+
// This calculation finds the closest step by finding the closest
|
|
558
|
+
// whole number divisible by the step relative to the min.
|
|
559
|
+
const closestValue = Math.round((exactValue - this.min) / this.step) * this.step + this.min;
|
|
560
|
+
// The value needs to snap to the min and max.
|
|
561
|
+
this.value = this._clamp(closestValue, this.min, this.max);
|
|
635
562
|
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
563
|
+
}
|
|
564
|
+
/** Emits a change event if the current value is different from the last emitted value. */
|
|
565
|
+
_emitChangeEvent() {
|
|
566
|
+
this._controlValueAccessorChangeFn(this.value);
|
|
567
|
+
this.valueChange.emit(this.value);
|
|
568
|
+
this.change.emit(this._createChangeEvent());
|
|
569
|
+
}
|
|
570
|
+
/** Emits an input event when the current value is different from the last emitted value. */
|
|
571
|
+
_emitInputEvent() {
|
|
572
|
+
this.input.emit(this._createChangeEvent());
|
|
573
|
+
}
|
|
574
|
+
/** Updates the amount of space between ticks as a percentage of the width of the slider. */
|
|
575
|
+
_updateTickIntervalPercent() {
|
|
576
|
+
if (!this.tickInterval || !this._sliderDimensions) {
|
|
577
|
+
return;
|
|
643
578
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
this.onTouched = fn;
|
|
579
|
+
if (this.tickInterval == 'auto') {
|
|
580
|
+
let trackSize = this.vertical ? this._sliderDimensions.height : this._sliderDimensions.width;
|
|
581
|
+
let pixelsPerStep = trackSize * this.step / (this.max - this.min);
|
|
582
|
+
let stepsPerTick = Math.ceil(MIN_AUTO_TICK_SEPARATION / pixelsPerStep);
|
|
583
|
+
let pixelsPerTick = stepsPerTick * this.step;
|
|
584
|
+
this._tickIntervalPercent = pixelsPerTick / trackSize;
|
|
651
585
|
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
* Implemented as part of ControlValueAccessor.
|
|
655
|
-
* @param isDisabled
|
|
656
|
-
*/
|
|
657
|
-
setDisabledState(isDisabled) {
|
|
658
|
-
this.disabled = isDisabled;
|
|
586
|
+
else {
|
|
587
|
+
this._tickIntervalPercent = this.tickInterval * this.step / (this.max - this.min);
|
|
659
588
|
}
|
|
660
589
|
}
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
}
|
|
590
|
+
/** Creates a slider change object from the specified value. */
|
|
591
|
+
_createChangeEvent(value = this.value) {
|
|
592
|
+
let event = new MatSliderChange();
|
|
593
|
+
event.source = this;
|
|
594
|
+
event.value = value;
|
|
595
|
+
return event;
|
|
596
|
+
}
|
|
597
|
+
/** Calculates the percentage of the slider that a value is. */
|
|
598
|
+
_calculatePercentage(value) {
|
|
599
|
+
return ((value || 0) - this.min) / (this.max - this.min);
|
|
600
|
+
}
|
|
601
|
+
/** Calculates the value a percentage of the slider corresponds to. */
|
|
602
|
+
_calculateValue(percentage) {
|
|
603
|
+
return this.min + percentage * (this.max - this.min);
|
|
604
|
+
}
|
|
605
|
+
/** Return a number between two numbers. */
|
|
606
|
+
_clamp(value, min = 0, max = 1) {
|
|
607
|
+
return Math.max(min, Math.min(value, max));
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Get the bounding client rect of the slider track element.
|
|
611
|
+
* The track is used rather than the native element to ignore the extra space that the thumb can
|
|
612
|
+
* take up.
|
|
613
|
+
*/
|
|
614
|
+
_getSliderDimensions() {
|
|
615
|
+
return this._sliderWrapper ? this._sliderWrapper.nativeElement.getBoundingClientRect() : null;
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Focuses the native element.
|
|
619
|
+
* Currently only used to allow a blur event to fire but will be used with keyboard input later.
|
|
620
|
+
*/
|
|
621
|
+
_focusHostElement(options) {
|
|
622
|
+
this._elementRef.nativeElement.focus(options);
|
|
623
|
+
}
|
|
624
|
+
/** Blurs the native element. */
|
|
625
|
+
_blurHostElement() {
|
|
626
|
+
this._elementRef.nativeElement.blur();
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* Sets the model value. Implemented as part of ControlValueAccessor.
|
|
630
|
+
* @param value
|
|
631
|
+
*/
|
|
632
|
+
writeValue(value) {
|
|
633
|
+
this.value = value;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Registers a callback to be triggered when the value has changed.
|
|
637
|
+
* Implemented as part of ControlValueAccessor.
|
|
638
|
+
* @param fn Callback to be registered.
|
|
639
|
+
*/
|
|
640
|
+
registerOnChange(fn) {
|
|
641
|
+
this._controlValueAccessorChangeFn = fn;
|
|
642
|
+
}
|
|
643
|
+
/**
|
|
644
|
+
* Registers a callback to be triggered when the component is touched.
|
|
645
|
+
* Implemented as part of ControlValueAccessor.
|
|
646
|
+
* @param fn Callback to be registered.
|
|
647
|
+
*/
|
|
648
|
+
registerOnTouched(fn) {
|
|
649
|
+
this.onTouched = fn;
|
|
650
|
+
}
|
|
651
|
+
/**
|
|
652
|
+
* Sets whether the component should be disabled.
|
|
653
|
+
* Implemented as part of ControlValueAccessor.
|
|
654
|
+
* @param isDisabled
|
|
655
|
+
*/
|
|
656
|
+
setDisabledState(isDisabled) {
|
|
657
|
+
this.disabled = isDisabled;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
MatSlider.decorators = [
|
|
661
|
+
{ type: Component, args: [{
|
|
662
|
+
selector: 'mat-slider',
|
|
663
|
+
exportAs: 'matSlider',
|
|
664
|
+
providers: [MAT_SLIDER_VALUE_ACCESSOR],
|
|
665
|
+
host: {
|
|
666
|
+
'(focus)': '_onFocus()',
|
|
667
|
+
'(blur)': '_onBlur()',
|
|
668
|
+
'(keydown)': '_onKeydown($event)',
|
|
669
|
+
'(keyup)': '_onKeyup()',
|
|
670
|
+
'(mouseenter)': '_onMouseenter()',
|
|
671
|
+
// On Safari starting to slide temporarily triggers text selection mode which
|
|
672
|
+
// show the wrong cursor. We prevent it by stopping the `selectstart` event.
|
|
673
|
+
'(selectstart)': '$event.preventDefault()',
|
|
674
|
+
'class': 'mat-slider mat-focus-indicator',
|
|
675
|
+
'role': 'slider',
|
|
676
|
+
'[tabIndex]': 'tabIndex',
|
|
677
|
+
'[attr.aria-disabled]': 'disabled',
|
|
678
|
+
'[attr.aria-valuemax]': 'max',
|
|
679
|
+
'[attr.aria-valuemin]': 'min',
|
|
680
|
+
'[attr.aria-valuenow]': 'value',
|
|
681
|
+
'[attr.aria-orientation]': 'vertical ? "vertical" : "horizontal"',
|
|
682
|
+
'[class.mat-slider-disabled]': 'disabled',
|
|
683
|
+
'[class.mat-slider-has-ticks]': 'tickInterval',
|
|
684
|
+
'[class.mat-slider-horizontal]': '!vertical',
|
|
685
|
+
'[class.mat-slider-axis-inverted]': '_invertAxis',
|
|
686
|
+
// Class binding which is only used by the test harness as there is no other
|
|
687
|
+
// way for the harness to detect if mouse coordinates need to be inverted.
|
|
688
|
+
'[class.mat-slider-invert-mouse-coords]': '_shouldInvertMouseCoords()',
|
|
689
|
+
'[class.mat-slider-sliding]': '_isSliding',
|
|
690
|
+
'[class.mat-slider-thumb-label-showing]': 'thumbLabel',
|
|
691
|
+
'[class.mat-slider-vertical]': 'vertical',
|
|
692
|
+
'[class.mat-slider-min-value]': '_isMinValue',
|
|
693
|
+
'[class.mat-slider-hide-last-tick]': 'disabled || _isMinValue && _thumbGap && _invertAxis',
|
|
694
|
+
'[class._mat-animation-noopable]': '_animationMode === "NoopAnimations"',
|
|
695
|
+
},
|
|
696
|
+
template: "<div class=\"mat-slider-wrapper\" #sliderWrapper>\n <div class=\"mat-slider-track-wrapper\">\n <div class=\"mat-slider-track-background\" [ngStyle]=\"_trackBackgroundStyles\"></div>\n <div class=\"mat-slider-track-fill\" [ngStyle]=\"_trackFillStyles\"></div>\n </div>\n <div class=\"mat-slider-ticks-container\" [ngStyle]=\"_ticksContainerStyles\">\n <div class=\"mat-slider-ticks\" [ngStyle]=\"_ticksStyles\"></div>\n </div>\n <div class=\"mat-slider-thumb-container\" [ngStyle]=\"_thumbContainerStyles\">\n <div class=\"mat-slider-focus-ring\"></div>\n <div class=\"mat-slider-thumb\"></div>\n <div class=\"mat-slider-thumb-label\">\n <span class=\"mat-slider-thumb-label-text\">{{displayValue}}</span>\n </div>\n </div>\n</div>\n",
|
|
697
|
+
inputs: ['disabled', 'color', 'tabIndex'],
|
|
698
|
+
encapsulation: ViewEncapsulation.None,
|
|
699
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
700
|
+
styles: [".mat-slider{display:inline-block;position:relative;box-sizing:border-box;padding:8px;outline:none;vertical-align:middle}.mat-slider:not(.mat-slider-disabled):active,.mat-slider.mat-slider-sliding:not(.mat-slider-disabled){cursor:-webkit-grabbing;cursor:grabbing}.mat-slider-wrapper{position:absolute}.mat-slider-track-wrapper{position:absolute;top:0;left:0;overflow:hidden}.mat-slider-track-fill{position:absolute;transform-origin:0 0;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-track-background{position:absolute;transform-origin:100% 100%;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-ticks-container{position:absolute;left:0;top:0;overflow:hidden}.mat-slider-ticks{background-repeat:repeat;background-clip:content-box;box-sizing:border-box;opacity:0;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-thumb-container{position:absolute;z-index:1;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-focus-ring{position:absolute;width:30px;height:30px;border-radius:50%;transform:scale(0);opacity:0;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1),opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider.cdk-keyboard-focused .mat-slider-focus-ring,.mat-slider.cdk-program-focused .mat-slider-focus-ring{transform:scale(1);opacity:1}.mat-slider:not(.mat-slider-disabled):not(.mat-slider-sliding) .mat-slider-thumb-label,.mat-slider:not(.mat-slider-disabled):not(.mat-slider-sliding) .mat-slider-thumb{cursor:-webkit-grab;cursor:grab}.mat-slider-thumb{position:absolute;right:-10px;bottom:-10px;box-sizing:border-box;width:20px;height:20px;border:3px solid transparent;border-radius:50%;transform:scale(0.7);transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1),border-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-thumb-label{display:none;align-items:center;justify-content:center;position:absolute;width:28px;height:28px;border-radius:50%;transition:transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1),border-radius 400ms cubic-bezier(0.25, 0.8, 0.25, 1),background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.cdk-high-contrast-active .mat-slider-thumb-label{outline:solid 1px}.mat-slider-thumb-label-text{z-index:1;opacity:0;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-sliding .mat-slider-track-fill,.mat-slider-sliding .mat-slider-track-background,.mat-slider-sliding .mat-slider-thumb-container{transition-duration:0ms}.mat-slider-has-ticks .mat-slider-wrapper::after{content:\"\";position:absolute;border-width:0;border-style:solid;opacity:0;transition:opacity 400ms cubic-bezier(0.25, 0.8, 0.25, 1)}.mat-slider-has-ticks.cdk-focused:not(.mat-slider-hide-last-tick) .mat-slider-wrapper::after,.mat-slider-has-ticks:hover:not(.mat-slider-hide-last-tick) .mat-slider-wrapper::after{opacity:1}.mat-slider-has-ticks.cdk-focused:not(.mat-slider-disabled) .mat-slider-ticks,.mat-slider-has-ticks:hover:not(.mat-slider-disabled) .mat-slider-ticks{opacity:1}.mat-slider-thumb-label-showing .mat-slider-focus-ring{display:none}.mat-slider-thumb-label-showing .mat-slider-thumb-label{display:flex}.mat-slider-axis-inverted .mat-slider-track-fill{transform-origin:100% 100%}.mat-slider-axis-inverted .mat-slider-track-background{transform-origin:0 0}.mat-slider:not(.mat-slider-disabled).cdk-focused.mat-slider-thumb-label-showing .mat-slider-thumb{transform:scale(0)}.mat-slider:not(.mat-slider-disabled).cdk-focused .mat-slider-thumb-label{border-radius:50% 50% 0}.mat-slider:not(.mat-slider-disabled).cdk-focused .mat-slider-thumb-label-text{opacity:1}.mat-slider:not(.mat-slider-disabled).cdk-mouse-focused .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled).cdk-touch-focused .mat-slider-thumb,.mat-slider:not(.mat-slider-disabled).cdk-program-focused .mat-slider-thumb{border-width:2px;transform:scale(1)}.mat-slider-disabled .mat-slider-focus-ring{transform:scale(0);opacity:0}.mat-slider-disabled .mat-slider-thumb{border-width:4px;transform:scale(0.5)}.mat-slider-disabled .mat-slider-thumb-label{display:none}.mat-slider-horizontal{height:48px;min-width:128px}.mat-slider-horizontal .mat-slider-wrapper{height:2px;top:23px;left:8px;right:8px}.mat-slider-horizontal .mat-slider-wrapper::after{height:2px;border-left-width:2px;right:0;top:0}.mat-slider-horizontal .mat-slider-track-wrapper{height:2px;width:100%}.mat-slider-horizontal .mat-slider-track-fill{height:2px;width:100%;transform:scaleX(0)}.mat-slider-horizontal .mat-slider-track-background{height:2px;width:100%;transform:scaleX(1)}.mat-slider-horizontal .mat-slider-ticks-container{height:2px;width:100%}.cdk-high-contrast-active .mat-slider-horizontal .mat-slider-ticks-container{height:0;outline:solid 2px;top:1px}.mat-slider-horizontal .mat-slider-ticks{height:2px;width:100%}.mat-slider-horizontal .mat-slider-thumb-container{width:100%;height:0;top:50%}.mat-slider-horizontal .mat-slider-focus-ring{top:-15px;right:-15px}.mat-slider-horizontal .mat-slider-thumb-label{right:-14px;top:-40px;transform:translateY(26px) scale(0.01) rotate(45deg)}.mat-slider-horizontal .mat-slider-thumb-label-text{transform:rotate(-45deg)}.mat-slider-horizontal.cdk-focused .mat-slider-thumb-label{transform:rotate(45deg)}.cdk-high-contrast-active .mat-slider-horizontal.cdk-focused .mat-slider-thumb-label,.cdk-high-contrast-active .mat-slider-horizontal.cdk-focused .mat-slider-thumb-label-text{transform:none}.mat-slider-vertical{width:48px;min-height:128px}.mat-slider-vertical .mat-slider-wrapper{width:2px;top:8px;bottom:8px;left:23px}.mat-slider-vertical .mat-slider-wrapper::after{width:2px;border-top-width:2px;bottom:0;left:0}.mat-slider-vertical .mat-slider-track-wrapper{height:100%;width:2px}.mat-slider-vertical .mat-slider-track-fill{height:100%;width:2px;transform:scaleY(0)}.mat-slider-vertical .mat-slider-track-background{height:100%;width:2px;transform:scaleY(1)}.mat-slider-vertical .mat-slider-ticks-container{width:2px;height:100%}.cdk-high-contrast-active .mat-slider-vertical .mat-slider-ticks-container{width:0;outline:solid 2px;left:1px}.mat-slider-vertical .mat-slider-focus-ring{bottom:-15px;left:-15px}.mat-slider-vertical .mat-slider-ticks{width:2px;height:100%}.mat-slider-vertical .mat-slider-thumb-container{height:100%;width:0;left:50%}.mat-slider-vertical .mat-slider-thumb{-webkit-backface-visibility:hidden;backface-visibility:hidden}.mat-slider-vertical .mat-slider-thumb-label{bottom:-14px;left:-40px;transform:translateX(26px) scale(0.01) rotate(-45deg)}.mat-slider-vertical .mat-slider-thumb-label-text{transform:rotate(45deg)}.mat-slider-vertical.cdk-focused .mat-slider-thumb-label{transform:rotate(-45deg)}[dir=rtl] .mat-slider-wrapper::after{left:0;right:auto}[dir=rtl] .mat-slider-horizontal .mat-slider-track-fill{transform-origin:100% 100%}[dir=rtl] .mat-slider-horizontal .mat-slider-track-background{transform-origin:0 0}[dir=rtl] .mat-slider-horizontal.mat-slider-axis-inverted .mat-slider-track-fill{transform-origin:0 0}[dir=rtl] .mat-slider-horizontal.mat-slider-axis-inverted .mat-slider-track-background{transform-origin:100% 100%}.mat-slider._mat-animation-noopable .mat-slider-track-fill,.mat-slider._mat-animation-noopable .mat-slider-track-background,.mat-slider._mat-animation-noopable .mat-slider-ticks,.mat-slider._mat-animation-noopable .mat-slider-thumb-container,.mat-slider._mat-animation-noopable .mat-slider-focus-ring,.mat-slider._mat-animation-noopable .mat-slider-thumb,.mat-slider._mat-animation-noopable .mat-slider-thumb-label,.mat-slider._mat-animation-noopable .mat-slider-thumb-label-text,.mat-slider._mat-animation-noopable .mat-slider-has-ticks .mat-slider-wrapper::after{transition:none}\n"]
|
|
701
|
+
},] }
|
|
702
|
+
];
|
|
703
|
+
MatSlider.ctorParameters = () => [
|
|
704
|
+
{ type: ElementRef },
|
|
705
|
+
{ type: FocusMonitor },
|
|
706
|
+
{ type: ChangeDetectorRef },
|
|
707
|
+
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
708
|
+
{ type: String, decorators: [{ type: Attribute, args: ['tabindex',] }] },
|
|
709
|
+
{ type: NgZone },
|
|
710
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
711
|
+
{ type: String, decorators: [{ type: Optional }, { type: Inject, args: [ANIMATION_MODULE_TYPE,] }] }
|
|
712
|
+
];
|
|
713
|
+
MatSlider.propDecorators = {
|
|
714
|
+
invert: [{ type: Input }],
|
|
715
|
+
max: [{ type: Input }],
|
|
716
|
+
min: [{ type: Input }],
|
|
717
|
+
step: [{ type: Input }],
|
|
718
|
+
thumbLabel: [{ type: Input }],
|
|
719
|
+
tickInterval: [{ type: Input }],
|
|
720
|
+
value: [{ type: Input }],
|
|
721
|
+
displayWith: [{ type: Input }],
|
|
722
|
+
vertical: [{ type: Input }],
|
|
723
|
+
change: [{ type: Output }],
|
|
724
|
+
input: [{ type: Output }],
|
|
725
|
+
valueChange: [{ type: Output }],
|
|
726
|
+
_sliderWrapper: [{ type: ViewChild, args: ['sliderWrapper',] }]
|
|
727
|
+
};
|
|
731
728
|
/** Returns whether an event is a touch event. */
|
|
732
729
|
function isTouchEvent(event) {
|
|
733
730
|
// This function is called for every pixel that the user has dragged so we need it to be
|
|
@@ -749,18 +746,15 @@ function getPointerPositionOnPage(event) {
|
|
|
749
746
|
* Use of this source code is governed by an MIT-style license that can be
|
|
750
747
|
* found in the LICENSE file at https://angular.io/license
|
|
751
748
|
*/
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
];
|
|
762
|
-
return MatSliderModule;
|
|
763
|
-
})();
|
|
749
|
+
class MatSliderModule {
|
|
750
|
+
}
|
|
751
|
+
MatSliderModule.decorators = [
|
|
752
|
+
{ type: NgModule, args: [{
|
|
753
|
+
imports: [CommonModule, MatCommonModule],
|
|
754
|
+
exports: [MatSlider, MatCommonModule],
|
|
755
|
+
declarations: [MatSlider],
|
|
756
|
+
},] }
|
|
757
|
+
];
|
|
764
758
|
|
|
765
759
|
/**
|
|
766
760
|
* @license
|