@angular/material 20.0.0-next.0 → 20.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/autocomplete/_autocomplete-theme.scss +4 -4
- package/autocomplete/index.d.ts +96 -126
- package/autocomplete/testing/index.d.ts +6 -11
- package/badge/_badge-theme.scss +5 -5
- package/badge/index.d.ts +8 -112
- package/badge/testing/index.d.ts +7 -8
- package/badge.d-49a8a74b.d.ts +98 -0
- package/bottom-sheet/_bottom-sheet-theme.scss +3 -3
- package/bottom-sheet/index.d.ts +88 -103
- package/bottom-sheet/testing/index.d.ts +4 -6
- package/button/_button-theme.scss +84 -32
- package/button/_fab-theme.scss +13 -13
- package/button/_icon-button-theme.scss +5 -5
- package/button/index.d.ts +10 -245
- package/button/testing/index.d.ts +13 -10
- package/button-toggle/_button-toggle-theme.scss +8 -8
- package/button-toggle/index.d.ts +12 -285
- package/button-toggle/testing/index.d.ts +38 -37
- package/button-toggle.d-edc8acff.d.ts +257 -0
- package/card/_card-theme.scss +12 -12
- package/card/index.d.ts +80 -117
- package/card/testing/index.d.ts +11 -15
- package/checkbox/_checkbox-theme.scss +10 -10
- package/checkbox/index.d.ts +43 -104
- package/checkbox/testing/index.d.ts +6 -10
- package/chips/_chips-theme.scss +14 -14
- package/chips/index.d.ts +599 -693
- package/chips/testing/index.d.ts +78 -93
- package/common-module.d-0e6515ae.d.ts +43 -0
- package/core/_core-theme.scss +2 -2
- package/core/index.d.ts +50 -979
- package/core/option/_optgroup-theme.scss +2 -2
- package/core/option/_option-theme.scss +4 -4
- package/core/ripple/_ripple-theme.scss +3 -3
- package/core/selection/pseudo-checkbox/_pseudo-checkbox-theme.scss +4 -4
- package/core/testing/index.d.ts +3 -65
- package/core/theming/_color-api-backwards-compatibility.scss +19 -8
- package/core/tokens/_density.scss +3 -0
- package/core/tokens/_token-definition.scss +1 -2
- package/core/tokens/_token-utils.scss +20 -5
- package/core/tokens/m2/_index.scss +2 -0
- package/core/tokens/m2/mat/_tonal-button.scss +110 -0
- package/core/tokens/m3/_index.scss +2 -0
- package/core/tokens/m3/definitions/_index.scss +1 -1
- package/core/tokens/m3/definitions/_md-comp-elevated-card.scss +3 -1
- package/core/tokens/m3/definitions/_md-sys-color.scss +44 -2
- package/core/tokens/m3/definitions/_md-sys-typescale.scss +20 -1
- package/core/tokens/m3/mat/_tonal-button.scss +101 -0
- package/date-adapter.d-c6835d41.d.ts +267 -0
- package/date-range-input-harness.d-549a9f7e.d.ts +278 -0
- package/datepicker/_datepicker-theme.scss +8 -7
- package/datepicker/index.d.ts +1332 -1482
- package/datepicker/testing/index.d.ts +5 -287
- package/dialog/_dialog-theme.scss +6 -6
- package/dialog/index.d.ts +59 -453
- package/dialog/testing/index.d.ts +22 -26
- package/dialog.d-57867441.d.ts +335 -0
- package/divider/_divider-theme.scss +2 -2
- package/divider/index.d.ts +6 -11
- package/divider/testing/index.d.ts +2 -16
- package/divider-harness.d-d34fede4.d.ts +14 -0
- package/error-options.d-448d9046.d.ts +17 -0
- package/expansion/_expansion-theme.scss +4 -4
- package/expansion/index.d.ts +139 -190
- package/expansion/testing/index.d.ts +25 -31
- package/fesm2022/autocomplete/testing.mjs +2 -1
- package/fesm2022/autocomplete/testing.mjs.map +1 -1
- package/fesm2022/autocomplete.mjs +56 -32
- package/fesm2022/autocomplete.mjs.map +1 -1
- package/fesm2022/badge/testing.mjs.map +1 -1
- package/fesm2022/badge.mjs +14 -17
- package/fesm2022/badge.mjs.map +1 -1
- package/fesm2022/bottom-sheet/testing.mjs.map +1 -1
- package/fesm2022/bottom-sheet.mjs +13 -15
- package/fesm2022/bottom-sheet.mjs.map +1 -1
- package/fesm2022/button/testing.mjs +34 -15
- package/fesm2022/button/testing.mjs.map +1 -1
- package/fesm2022/button-toggle/testing.mjs.map +1 -1
- package/fesm2022/button-toggle.mjs +22 -15
- package/fesm2022/button-toggle.mjs.map +1 -1
- package/fesm2022/button.mjs +14 -395
- package/fesm2022/button.mjs.map +1 -1
- package/fesm2022/card/testing.mjs.map +1 -1
- package/fesm2022/card.mjs +49 -51
- package/fesm2022/card.mjs.map +1 -1
- package/fesm2022/checkbox/testing.mjs.map +1 -1
- package/fesm2022/checkbox.mjs +32 -73
- package/fesm2022/checkbox.mjs.map +1 -1
- package/fesm2022/chips/testing.mjs.map +1 -1
- package/fesm2022/chips.mjs +51 -46
- package/fesm2022/chips.mjs.map +1 -1
- package/fesm2022/common-module-2d64df09.mjs +42 -0
- package/fesm2022/common-module-2d64df09.mjs.map +1 -0
- package/fesm2022/core/testing.mjs +3 -76
- package/fesm2022/core/testing.mjs.map +1 -1
- package/fesm2022/core.mjs +38 -1598
- package/fesm2022/core.mjs.map +1 -1
- package/fesm2022/date-formats-b618acb8.mjs +190 -0
- package/fesm2022/date-formats-b618acb8.mjs.map +1 -0
- package/fesm2022/date-range-input-harness-de70be6a.mjs +467 -0
- package/fesm2022/date-range-input-harness-de70be6a.mjs.map +1 -0
- package/fesm2022/datepicker/testing.mjs +5 -465
- package/fesm2022/datepicker/testing.mjs.map +1 -1
- package/fesm2022/datepicker.mjs +162 -131
- package/fesm2022/datepicker.mjs.map +1 -1
- package/fesm2022/dialog/testing.mjs +12 -1
- package/fesm2022/dialog/testing.mjs.map +1 -1
- package/fesm2022/dialog.mjs +14 -895
- package/fesm2022/dialog.mjs.map +1 -1
- package/fesm2022/divider/testing.mjs +2 -17
- package/fesm2022/divider/testing.mjs.map +1 -1
- package/fesm2022/divider-harness-8099453f.mjs +18 -0
- package/fesm2022/divider-harness-8099453f.mjs.map +1 -0
- package/fesm2022/divider.mjs +10 -12
- package/fesm2022/divider.mjs.map +1 -1
- package/fesm2022/error-options-4a00765e.mjs +29 -0
- package/fesm2022/error-options-4a00765e.mjs.map +1 -0
- package/fesm2022/error-state-8f4ce1af.mjs +37 -0
- package/fesm2022/error-state-8f4ce1af.mjs.map +1 -0
- package/fesm2022/expansion/testing.mjs.map +1 -1
- package/fesm2022/expansion.mjs +30 -32
- package/fesm2022/expansion.mjs.map +1 -1
- package/fesm2022/form-field/testing/control.mjs +2 -10
- package/fesm2022/form-field/testing/control.mjs.map +1 -1
- package/fesm2022/form-field/testing.mjs +7 -6
- package/fesm2022/form-field/testing.mjs.map +1 -1
- package/fesm2022/form-field-6d755764.mjs +1076 -0
- package/fesm2022/form-field-6d755764.mjs.map +1 -0
- package/fesm2022/form-field-control-harness-efefd4cf.mjs +11 -0
- package/fesm2022/form-field-control-harness-efefd4cf.mjs.map +1 -0
- package/fesm2022/form-field.mjs +14 -1110
- package/fesm2022/form-field.mjs.map +1 -1
- package/fesm2022/grid-list/testing.mjs +1 -1
- package/fesm2022/grid-list/testing.mjs.map +1 -1
- package/fesm2022/grid-list.mjs +30 -173
- package/fesm2022/grid-list.mjs.map +1 -1
- package/fesm2022/icon/testing.mjs +12 -12
- package/fesm2022/icon/testing.mjs.map +1 -1
- package/fesm2022/icon-button-0850d958.mjs +211 -0
- package/fesm2022/icon-button-0850d958.mjs.map +1 -0
- package/fesm2022/icon-module-3f77a24d.mjs +395 -0
- package/fesm2022/icon-module-3f77a24d.mjs.map +1 -0
- package/fesm2022/icon-registry-13a3b98e.mjs +639 -0
- package/fesm2022/icon-registry-13a3b98e.mjs.map +1 -0
- package/fesm2022/icon.mjs +11 -1016
- package/fesm2022/icon.mjs.map +1 -1
- package/fesm2022/index-1763d3a6.mjs +22 -0
- package/fesm2022/index-1763d3a6.mjs.map +1 -0
- package/fesm2022/index-4bc1d6d3.mjs +20 -0
- package/fesm2022/index-4bc1d6d3.mjs.map +1 -0
- package/fesm2022/input/testing.mjs +5 -113
- package/fesm2022/input/testing.mjs.map +1 -1
- package/fesm2022/input-harness-e68bb132.mjs +115 -0
- package/fesm2022/input-harness-e68bb132.mjs.map +1 -0
- package/fesm2022/input-value-accessor-8a79a24e.mjs +12 -0
- package/fesm2022/input-value-accessor-8a79a24e.mjs.map +1 -0
- package/fesm2022/input.mjs +21 -23
- package/fesm2022/input.mjs.map +1 -1
- package/fesm2022/internal-form-field-434c4039.mjs +27 -0
- package/fesm2022/internal-form-field-434c4039.mjs.map +1 -0
- package/fesm2022/line-d6afe347.mjs +59 -0
- package/fesm2022/line-d6afe347.mjs.map +1 -0
- package/fesm2022/list/testing.mjs +2 -2
- package/fesm2022/list/testing.mjs.map +1 -1
- package/fesm2022/list.mjs +59 -56
- package/fesm2022/list.mjs.map +1 -1
- package/fesm2022/menu/testing.mjs.map +1 -1
- package/fesm2022/menu.mjs +37 -25
- package/fesm2022/menu.mjs.map +1 -1
- package/fesm2022/module-1c16a0a9.mjs +1293 -0
- package/fesm2022/module-1c16a0a9.mjs.map +1 -0
- package/fesm2022/module-47e3be58.mjs +970 -0
- package/fesm2022/module-47e3be58.mjs.map +1 -0
- package/fesm2022/module-a5f9ab72.mjs +875 -0
- package/fesm2022/module-a5f9ab72.mjs.map +1 -0
- package/fesm2022/module-cf951a02.mjs +214 -0
- package/fesm2022/module-cf951a02.mjs.map +1 -0
- package/fesm2022/module-d757bba0.mjs +38 -0
- package/fesm2022/module-d757bba0.mjs.map +1 -0
- package/fesm2022/optgroup-harness-5e66b138.mjs +36 -0
- package/fesm2022/optgroup-harness-5e66b138.mjs.map +1 -0
- package/fesm2022/option-07c3c660.mjs +348 -0
- package/fesm2022/option-07c3c660.mjs.map +1 -0
- package/fesm2022/option-harness-3b7c1106.mjs +46 -0
- package/fesm2022/option-harness-3b7c1106.mjs.map +1 -0
- package/fesm2022/paginator/testing.mjs +4 -1
- package/fesm2022/paginator/testing.mjs.map +1 -1
- package/fesm2022/paginator.mjs +52 -22
- package/fesm2022/paginator.mjs.map +1 -1
- package/fesm2022/progress-bar/testing.mjs +0 -4
- package/fesm2022/progress-bar/testing.mjs.map +1 -1
- package/fesm2022/progress-bar.mjs +15 -13
- package/fesm2022/progress-bar.mjs.map +1 -1
- package/fesm2022/progress-spinner/testing.mjs +0 -4
- package/fesm2022/progress-spinner/testing.mjs.map +1 -1
- package/fesm2022/progress-spinner.mjs +15 -13
- package/fesm2022/progress-spinner.mjs.map +1 -1
- package/fesm2022/pseudo-checkbox-af5a4ea4.mjs +52 -0
- package/fesm2022/pseudo-checkbox-af5a4ea4.mjs.map +1 -0
- package/fesm2022/pseudo-checkbox-module-216fae38.mjs +20 -0
- package/fesm2022/pseudo-checkbox-module-216fae38.mjs.map +1 -0
- package/fesm2022/public-api-c5ab57f5.mjs +147 -0
- package/fesm2022/public-api-c5ab57f5.mjs.map +1 -0
- package/fesm2022/radio/testing.mjs.map +1 -1
- package/fesm2022/radio.mjs +23 -15
- package/fesm2022/radio.mjs.map +1 -1
- package/fesm2022/ripple-9939d1f5.mjs +639 -0
- package/fesm2022/ripple-9939d1f5.mjs.map +1 -0
- package/fesm2022/ripple-loader-f2078c66.mjs +165 -0
- package/fesm2022/ripple-loader-f2078c66.mjs.map +1 -0
- package/fesm2022/select/testing.mjs +5 -121
- package/fesm2022/select/testing.mjs.map +1 -1
- package/fesm2022/select-harness-69d47123.mjs +123 -0
- package/fesm2022/select-harness-69d47123.mjs.map +1 -0
- package/fesm2022/select.mjs +30 -1311
- package/fesm2022/select.mjs.map +1 -1
- package/fesm2022/sidenav/testing.mjs +1 -1
- package/fesm2022/sidenav/testing.mjs.map +1 -1
- package/fesm2022/sidenav.mjs +31 -31
- package/fesm2022/sidenav.mjs.map +1 -1
- package/fesm2022/slide-toggle/testing.mjs.map +1 -1
- package/fesm2022/slide-toggle.mjs +27 -75
- package/fesm2022/slide-toggle.mjs.map +1 -1
- package/fesm2022/slider/testing.mjs.map +1 -1
- package/fesm2022/slider.mjs +27 -23
- package/fesm2022/slider.mjs.map +1 -1
- package/fesm2022/snack-bar/testing.mjs.map +1 -1
- package/fesm2022/snack-bar.mjs +38 -30
- package/fesm2022/snack-bar.mjs.map +1 -1
- package/fesm2022/sort/testing.mjs.map +1 -1
- package/fesm2022/sort.mjs +26 -20
- package/fesm2022/sort.mjs.map +1 -1
- package/fesm2022/stepper/testing.mjs.map +1 -1
- package/fesm2022/stepper.mjs +52 -39
- package/fesm2022/stepper.mjs.map +1 -1
- package/fesm2022/structural-styles-d5ada3b3.mjs +18 -0
- package/fesm2022/structural-styles-d5ada3b3.mjs.map +1 -0
- package/fesm2022/table/testing.mjs.map +1 -1
- package/fesm2022/table.mjs +58 -60
- package/fesm2022/table.mjs.map +1 -1
- package/fesm2022/tabs/testing.mjs.map +1 -1
- package/fesm2022/tabs.mjs +54 -58
- package/fesm2022/tabs.mjs.map +1 -1
- package/fesm2022/timepicker/testing.mjs +1 -1
- package/fesm2022/timepicker/testing.mjs.map +1 -1
- package/fesm2022/timepicker.mjs +37 -26
- package/fesm2022/timepicker.mjs.map +1 -1
- package/fesm2022/toolbar/testing.mjs.map +1 -1
- package/fesm2022/toolbar.mjs +13 -15
- package/fesm2022/toolbar.mjs.map +1 -1
- package/fesm2022/tooltip/testing.mjs.map +1 -1
- package/fesm2022/tooltip.mjs +15 -960
- package/fesm2022/tooltip.mjs.map +1 -1
- package/fesm2022/tree/testing.mjs.map +1 -1
- package/fesm2022/tree.mjs +28 -30
- package/fesm2022/tree.mjs.map +1 -1
- package/form-field/_form-field-theme.scss +16 -16
- package/form-field/index.d.ts +16 -508
- package/form-field/testing/control/index.d.ts +2 -10
- package/form-field/testing/index.d.ts +19 -24
- package/form-field-control-harness.d-2d91f25a.d.ts +10 -0
- package/form-field-control.d-eb86711c.d.ts +62 -0
- package/form-field.d-2edbc094.d.ts +367 -0
- package/grid-list/_grid-list-theme.scss +1 -1
- package/grid-list/index.d.ts +128 -152
- package/grid-list/testing/index.d.ts +39 -44
- package/icon/_icon-theme.scss +2 -2
- package/icon/index.d.ts +9 -470
- package/icon/testing/index.d.ts +41 -44
- package/icon-module.d-aa3bbba0.d.ts +167 -0
- package/icon-registry.d-1dffe9de.d.ts +286 -0
- package/index.d-0536b706.d.ts +11 -0
- package/index.d-37e31cd3.d.ts +13 -0
- package/index.d.ts +2 -3
- package/input/index.d.ts +33 -62
- package/input/testing/index.d.ts +13 -71
- package/input-harness.d-4eecd1d3.d.ts +60 -0
- package/line.d-570a2537.d.ts +25 -0
- package/list/_list-theme.scss +15 -15
- package/list/index.d.ts +155 -244
- package/list/testing/index.d.ts +158 -180
- package/list-option-types.d-8739f903.d.ts +15 -0
- package/menu/_menu-theme.scss +3 -3
- package/menu/index.d.ts +183 -231
- package/menu/testing/index.d.ts +17 -23
- package/module.d-74a721b9.d.ts +326 -0
- package/module.d-792a497c.d.ts +213 -0
- package/module.d-ba05faa6.d.ts +448 -0
- package/module.d-c17c834e.d.ts +18 -0
- package/optgroup-harness.d-7f741f69.d.ts +31 -0
- package/option-harness.d-3d33fc9a.d.ts +34 -0
- package/option-parent.d-559ad5c5.d.ts +19 -0
- package/option.d-6f493d78.d.ts +146 -0
- package/package.json +2 -2
- package/paginator/_paginator-theme.scss +3 -3
- package/paginator/index.d.ts +31 -216
- package/paginator/testing/index.d.ts +14 -15
- package/paginator.d-40b1766e.d.ts +199 -0
- package/palette.d-ec4a617c.d.ts +4 -0
- package/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-bar/_progress-bar-theme.scss +2 -2
- package/progress-bar/index.d.ts +40 -59
- package/progress-bar/testing/index.d.ts +7 -10
- package/progress-spinner/_progress-spinner-theme.scss +4 -4
- package/progress-spinner/index.d.ts +8 -110
- package/progress-spinner/testing/index.d.ts +10 -11
- package/progress-spinner.d-1fc040c5.d.ts +96 -0
- package/pseudo-checkbox-module.d-3abc0461.d.ts +44 -0
- package/radio/_radio-theme.scss +12 -12
- package/radio/index.d.ts +151 -170
- package/radio/testing/index.d.ts +61 -67
- package/ripple-loader.d-8aac2988.d.ts +48 -0
- package/ripple.d-2fb57d04.d.ts +255 -0
- package/schematics/ng-add/index.js +1 -1
- package/schematics/ng-add/index.mjs +1 -1
- package/schematics/ng-generate/address-form/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +2 -2
- package/schematics/ng-generate/dashboard/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +1 -1
- package/schematics/ng-generate/navigation/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +1 -1
- package/schematics/ng-generate/theme-color/index_bundled.js +2 -2
- package/schematics/ng-generate/theme-color/schema.json +10 -0
- package/schematics/ng-generate/tree/files/__path__/__name@dasherize@if-flat__/__name@dasherize__.component.html.template +2 -2
- package/schematics/ng-update/index_bundled.js +31 -31
- package/select/_select-theme.scss +6 -6
- package/select/index.d.ts +25 -505
- package/select/testing/index.d.ts +5 -67
- package/select-harness.d-7441a7ac.d.ts +63 -0
- package/sidenav/_sidenav-theme.scss +2 -2
- package/sidenav/index.d.ts +49 -92
- package/sidenav/testing/index.d.ts +58 -63
- package/slide-toggle/_slide-toggle-theme.scss +10 -10
- package/slide-toggle/index.d.ts +39 -110
- package/slide-toggle/testing/index.d.ts +17 -21
- package/slider/_slider-theme.scss +10 -10
- package/slider/index.d.ts +281 -328
- package/slider/testing/index.d.ts +42 -47
- package/snack-bar/_snack-bar-theme.scss +4 -4
- package/snack-bar/index.d.ts +152 -185
- package/snack-bar/testing/index.d.ts +7 -9
- package/sort/_sort-theme.scss +3 -3
- package/sort/index.d.ts +61 -169
- package/sort/testing/index.d.ts +22 -25
- package/sort-direction.d-f4ce4649.d.ts +3 -0
- package/sort.d-c2b79a45.d.ts +87 -0
- package/stepper/_stepper-theme.scss +5 -5
- package/stepper/index.d.ts +115 -167
- package/stepper/testing/index.d.ts +43 -52
- package/table/_table-theme.scss +4 -4
- package/table/index.d.ts +97 -156
- package/table/testing/index.d.ts +64 -78
- package/tabs/_tabs-theme.scss +16 -16
- package/tabs/index.d.ts +309 -383
- package/tabs/testing/index.d.ts +67 -76
- package/timepicker/_timepicker-theme.scss +4 -4
- package/timepicker/index.d.ts +127 -160
- package/timepicker/testing/index.d.ts +20 -26
- package/toolbar/_toolbar-theme.scss +4 -4
- package/toolbar/index.d.ts +15 -26
- package/toolbar/testing/index.d.ts +13 -16
- package/tooltip/_tooltip-theme.scss +4 -4
- package/tooltip/index.d.ts +11 -355
- package/tooltip/testing/index.d.ts +7 -10
- package/tree/_tree-theme.scss +3 -3
- package/tree/index.d.ts +117 -163
- package/tree/testing/index.d.ts +52 -58
- /package/core/tokens/m3/definitions/{unused/_md-comp-filled-tonal-button.scss → _md-comp-filled-tonal-button.scss} +0 -0
|
@@ -0,0 +1,639 @@
|
|
|
1
|
+
import { normalizePassiveListenerOptions, _getEventTarget, Platform } from '@angular/cdk/platform';
|
|
2
|
+
import * as i0 from '@angular/core';
|
|
3
|
+
import { Component, ChangeDetectionStrategy, ViewEncapsulation, InjectionToken, inject, ElementRef, ANIMATION_MODULE_TYPE, NgZone, Injector, Directive, Input } from '@angular/core';
|
|
4
|
+
import { isFakeMousedownFromScreenReader, isFakeTouchstartFromScreenReader } from '@angular/cdk/a11y';
|
|
5
|
+
import { coerceElement } from '@angular/cdk/coercion';
|
|
6
|
+
import { _CdkPrivateStyleLoader } from '@angular/cdk/private';
|
|
7
|
+
|
|
8
|
+
/** Possible states for a ripple element. */
|
|
9
|
+
var RippleState;
|
|
10
|
+
(function (RippleState) {
|
|
11
|
+
RippleState[RippleState["FADING_IN"] = 0] = "FADING_IN";
|
|
12
|
+
RippleState[RippleState["VISIBLE"] = 1] = "VISIBLE";
|
|
13
|
+
RippleState[RippleState["FADING_OUT"] = 2] = "FADING_OUT";
|
|
14
|
+
RippleState[RippleState["HIDDEN"] = 3] = "HIDDEN";
|
|
15
|
+
})(RippleState || (RippleState = {}));
|
|
16
|
+
/**
|
|
17
|
+
* Reference to a previously launched ripple element.
|
|
18
|
+
*/
|
|
19
|
+
class RippleRef {
|
|
20
|
+
_renderer;
|
|
21
|
+
element;
|
|
22
|
+
config;
|
|
23
|
+
_animationForciblyDisabledThroughCss;
|
|
24
|
+
/** Current state of the ripple. */
|
|
25
|
+
state = RippleState.HIDDEN;
|
|
26
|
+
constructor(_renderer,
|
|
27
|
+
/** Reference to the ripple HTML element. */
|
|
28
|
+
element,
|
|
29
|
+
/** Ripple configuration used for the ripple. */
|
|
30
|
+
config,
|
|
31
|
+
/* Whether animations are forcibly disabled for ripples through CSS. */
|
|
32
|
+
_animationForciblyDisabledThroughCss = false) {
|
|
33
|
+
this._renderer = _renderer;
|
|
34
|
+
this.element = element;
|
|
35
|
+
this.config = config;
|
|
36
|
+
this._animationForciblyDisabledThroughCss = _animationForciblyDisabledThroughCss;
|
|
37
|
+
}
|
|
38
|
+
/** Fades out the ripple element. */
|
|
39
|
+
fadeOut() {
|
|
40
|
+
this._renderer.fadeOutRipple(this);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Options used to bind a passive capturing event. */
|
|
45
|
+
const passiveCapturingEventOptions$1 = normalizePassiveListenerOptions({
|
|
46
|
+
passive: true,
|
|
47
|
+
capture: true,
|
|
48
|
+
});
|
|
49
|
+
/** Manages events through delegation so that as few event handlers as possible are bound. */
|
|
50
|
+
class RippleEventManager {
|
|
51
|
+
_events = new Map();
|
|
52
|
+
/** Adds an event handler. */
|
|
53
|
+
addHandler(ngZone, name, element, handler) {
|
|
54
|
+
const handlersForEvent = this._events.get(name);
|
|
55
|
+
if (handlersForEvent) {
|
|
56
|
+
const handlersForElement = handlersForEvent.get(element);
|
|
57
|
+
if (handlersForElement) {
|
|
58
|
+
handlersForElement.add(handler);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
handlersForEvent.set(element, new Set([handler]));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this._events.set(name, new Map([[element, new Set([handler])]]));
|
|
66
|
+
ngZone.runOutsideAngular(() => {
|
|
67
|
+
document.addEventListener(name, this._delegateEventHandler, passiveCapturingEventOptions$1);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Removes an event handler. */
|
|
72
|
+
removeHandler(name, element, handler) {
|
|
73
|
+
const handlersForEvent = this._events.get(name);
|
|
74
|
+
if (!handlersForEvent) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const handlersForElement = handlersForEvent.get(element);
|
|
78
|
+
if (!handlersForElement) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
handlersForElement.delete(handler);
|
|
82
|
+
if (handlersForElement.size === 0) {
|
|
83
|
+
handlersForEvent.delete(element);
|
|
84
|
+
}
|
|
85
|
+
if (handlersForEvent.size === 0) {
|
|
86
|
+
this._events.delete(name);
|
|
87
|
+
document.removeEventListener(name, this._delegateEventHandler, passiveCapturingEventOptions$1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/** Event handler that is bound and which dispatches the events to the different targets. */
|
|
91
|
+
_delegateEventHandler = (event) => {
|
|
92
|
+
const target = _getEventTarget(event);
|
|
93
|
+
if (target) {
|
|
94
|
+
this._events.get(event.type)?.forEach((handlers, element) => {
|
|
95
|
+
if (element === target || element.contains(target)) {
|
|
96
|
+
handlers.forEach(handler => handler.handleEvent(event));
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Default ripple animation configuration for ripples without an explicit
|
|
105
|
+
* animation config specified.
|
|
106
|
+
*/
|
|
107
|
+
const defaultRippleAnimationConfig = {
|
|
108
|
+
enterDuration: 225,
|
|
109
|
+
exitDuration: 150,
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Timeout for ignoring mouse events. Mouse events will be temporary ignored after touch
|
|
113
|
+
* events to avoid synthetic mouse events.
|
|
114
|
+
*/
|
|
115
|
+
const ignoreMouseEventsTimeout = 800;
|
|
116
|
+
/** Options used to bind a passive capturing event. */
|
|
117
|
+
const passiveCapturingEventOptions = normalizePassiveListenerOptions({
|
|
118
|
+
passive: true,
|
|
119
|
+
capture: true,
|
|
120
|
+
});
|
|
121
|
+
/** Events that signal that the pointer is down. */
|
|
122
|
+
const pointerDownEvents = ['mousedown', 'touchstart'];
|
|
123
|
+
/** Events that signal that the pointer is up. */
|
|
124
|
+
const pointerUpEvents = ['mouseup', 'mouseleave', 'touchend', 'touchcancel'];
|
|
125
|
+
class _MatRippleStylesLoader {
|
|
126
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: _MatRippleStylesLoader, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
127
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.0.0-next.1", type: _MatRippleStylesLoader, isStandalone: true, selector: "ng-component", host: { attributes: { "mat-ripple-style-loader": "" } }, ngImport: i0, template: '', isInline: true, styles: [".mat-ripple{overflow:hidden;position:relative}.mat-ripple:not(:empty){transform:translateZ(0)}.mat-ripple.mat-ripple-unbounded{overflow:visible}.mat-ripple-element{position:absolute;border-radius:50%;pointer-events:none;transition:opacity,transform 0ms cubic-bezier(0, 0, 0.2, 1);transform:scale3d(0, 0, 0);background-color:var(--mat-ripple-color, color-mix(in srgb, var(--mat-sys-on-surface) 10%, transparent))}@media(forced-colors: active){.mat-ripple-element{display:none}}.cdk-drag-preview .mat-ripple-element,.cdk-drag-placeholder .mat-ripple-element{display:none}"], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
|
|
128
|
+
}
|
|
129
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: _MatRippleStylesLoader, decorators: [{
|
|
130
|
+
type: Component,
|
|
131
|
+
args: [{ template: '', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: { 'mat-ripple-style-loader': '' }, styles: [".mat-ripple{overflow:hidden;position:relative}.mat-ripple:not(:empty){transform:translateZ(0)}.mat-ripple.mat-ripple-unbounded{overflow:visible}.mat-ripple-element{position:absolute;border-radius:50%;pointer-events:none;transition:opacity,transform 0ms cubic-bezier(0, 0, 0.2, 1);transform:scale3d(0, 0, 0);background-color:var(--mat-ripple-color, color-mix(in srgb, var(--mat-sys-on-surface) 10%, transparent))}@media(forced-colors: active){.mat-ripple-element{display:none}}.cdk-drag-preview .mat-ripple-element,.cdk-drag-placeholder .mat-ripple-element{display:none}"] }]
|
|
132
|
+
}] });
|
|
133
|
+
/**
|
|
134
|
+
* Helper service that performs DOM manipulations. Not intended to be used outside this module.
|
|
135
|
+
* The constructor takes a reference to the ripple directive's host element and a map of DOM
|
|
136
|
+
* event handlers to be installed on the element that triggers ripple animations.
|
|
137
|
+
* This will eventually become a custom renderer once Angular support exists.
|
|
138
|
+
* @docs-private
|
|
139
|
+
*/
|
|
140
|
+
class RippleRenderer {
|
|
141
|
+
_target;
|
|
142
|
+
_ngZone;
|
|
143
|
+
_platform;
|
|
144
|
+
/** Element where the ripples are being added to. */
|
|
145
|
+
_containerElement;
|
|
146
|
+
/** Element which triggers the ripple elements on mouse events. */
|
|
147
|
+
_triggerElement;
|
|
148
|
+
/** Whether the pointer is currently down or not. */
|
|
149
|
+
_isPointerDown = false;
|
|
150
|
+
/**
|
|
151
|
+
* Map of currently active ripple references.
|
|
152
|
+
* The ripple reference is mapped to its element event listeners.
|
|
153
|
+
* The reason why `| null` is used is that event listeners are added only
|
|
154
|
+
* when the condition is truthy (see the `_startFadeOutTransition` method).
|
|
155
|
+
*/
|
|
156
|
+
_activeRipples = new Map();
|
|
157
|
+
/** Latest non-persistent ripple that was triggered. */
|
|
158
|
+
_mostRecentTransientRipple;
|
|
159
|
+
/** Time in milliseconds when the last touchstart event happened. */
|
|
160
|
+
_lastTouchStartEvent;
|
|
161
|
+
/** Whether pointer-up event listeners have been registered. */
|
|
162
|
+
_pointerUpEventsRegistered = false;
|
|
163
|
+
/**
|
|
164
|
+
* Cached dimensions of the ripple container. Set when the first
|
|
165
|
+
* ripple is shown and cleared once no more ripples are visible.
|
|
166
|
+
*/
|
|
167
|
+
_containerRect;
|
|
168
|
+
static _eventManager = new RippleEventManager();
|
|
169
|
+
constructor(_target, _ngZone, elementOrElementRef, _platform, injector) {
|
|
170
|
+
this._target = _target;
|
|
171
|
+
this._ngZone = _ngZone;
|
|
172
|
+
this._platform = _platform;
|
|
173
|
+
// Only do anything if we're on the browser.
|
|
174
|
+
if (_platform.isBrowser) {
|
|
175
|
+
this._containerElement = coerceElement(elementOrElementRef);
|
|
176
|
+
}
|
|
177
|
+
if (injector) {
|
|
178
|
+
injector.get(_CdkPrivateStyleLoader).load(_MatRippleStylesLoader);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Fades in a ripple at the given coordinates.
|
|
183
|
+
* @param x Coordinate within the element, along the X axis at which to start the ripple.
|
|
184
|
+
* @param y Coordinate within the element, along the Y axis at which to start the ripple.
|
|
185
|
+
* @param config Extra ripple options.
|
|
186
|
+
*/
|
|
187
|
+
fadeInRipple(x, y, config = {}) {
|
|
188
|
+
const containerRect = (this._containerRect =
|
|
189
|
+
this._containerRect || this._containerElement.getBoundingClientRect());
|
|
190
|
+
const animationConfig = { ...defaultRippleAnimationConfig, ...config.animation };
|
|
191
|
+
if (config.centered) {
|
|
192
|
+
x = containerRect.left + containerRect.width / 2;
|
|
193
|
+
y = containerRect.top + containerRect.height / 2;
|
|
194
|
+
}
|
|
195
|
+
const radius = config.radius || distanceToFurthestCorner(x, y, containerRect);
|
|
196
|
+
const offsetX = x - containerRect.left;
|
|
197
|
+
const offsetY = y - containerRect.top;
|
|
198
|
+
const enterDuration = animationConfig.enterDuration;
|
|
199
|
+
const ripple = document.createElement('div');
|
|
200
|
+
ripple.classList.add('mat-ripple-element');
|
|
201
|
+
ripple.style.left = `${offsetX - radius}px`;
|
|
202
|
+
ripple.style.top = `${offsetY - radius}px`;
|
|
203
|
+
ripple.style.height = `${radius * 2}px`;
|
|
204
|
+
ripple.style.width = `${radius * 2}px`;
|
|
205
|
+
// If a custom color has been specified, set it as inline style. If no color is
|
|
206
|
+
// set, the default color will be applied through the ripple theme styles.
|
|
207
|
+
if (config.color != null) {
|
|
208
|
+
ripple.style.backgroundColor = config.color;
|
|
209
|
+
}
|
|
210
|
+
ripple.style.transitionDuration = `${enterDuration}ms`;
|
|
211
|
+
this._containerElement.appendChild(ripple);
|
|
212
|
+
// By default the browser does not recalculate the styles of dynamically created
|
|
213
|
+
// ripple elements. This is critical to ensure that the `scale` animates properly.
|
|
214
|
+
// We enforce a style recalculation by calling `getComputedStyle` and *accessing* a property.
|
|
215
|
+
// See: https://gist.github.com/paulirish/5d52fb081b3570c81e3a
|
|
216
|
+
const computedStyles = window.getComputedStyle(ripple);
|
|
217
|
+
const userTransitionProperty = computedStyles.transitionProperty;
|
|
218
|
+
const userTransitionDuration = computedStyles.transitionDuration;
|
|
219
|
+
// Note: We detect whether animation is forcibly disabled through CSS (e.g. through
|
|
220
|
+
// `transition: none` or `display: none`). This is technically unexpected since animations are
|
|
221
|
+
// controlled through the animation config, but this exists for backwards compatibility. This
|
|
222
|
+
// logic does not need to be super accurate since it covers some edge cases which can be easily
|
|
223
|
+
// avoided by users.
|
|
224
|
+
const animationForciblyDisabledThroughCss = userTransitionProperty === 'none' ||
|
|
225
|
+
// Note: The canonical unit for serialized CSS `<time>` properties is seconds. Additionally
|
|
226
|
+
// some browsers expand the duration for every property (in our case `opacity` and `transform`).
|
|
227
|
+
userTransitionDuration === '0s' ||
|
|
228
|
+
userTransitionDuration === '0s, 0s' ||
|
|
229
|
+
// If the container is 0x0, it's likely `display: none`.
|
|
230
|
+
(containerRect.width === 0 && containerRect.height === 0);
|
|
231
|
+
// Exposed reference to the ripple that will be returned.
|
|
232
|
+
const rippleRef = new RippleRef(this, ripple, config, animationForciblyDisabledThroughCss);
|
|
233
|
+
// Start the enter animation by setting the transform/scale to 100%. The animation will
|
|
234
|
+
// execute as part of this statement because we forced a style recalculation before.
|
|
235
|
+
// Note: We use a 3d transform here in order to avoid an issue in Safari where
|
|
236
|
+
// the ripples aren't clipped when inside the shadow DOM (see #24028).
|
|
237
|
+
ripple.style.transform = 'scale3d(1, 1, 1)';
|
|
238
|
+
rippleRef.state = RippleState.FADING_IN;
|
|
239
|
+
if (!config.persistent) {
|
|
240
|
+
this._mostRecentTransientRipple = rippleRef;
|
|
241
|
+
}
|
|
242
|
+
let eventListeners = null;
|
|
243
|
+
// Do not register the `transition` event listener if fade-in and fade-out duration
|
|
244
|
+
// are set to zero. The events won't fire anyway and we can save resources here.
|
|
245
|
+
if (!animationForciblyDisabledThroughCss && (enterDuration || animationConfig.exitDuration)) {
|
|
246
|
+
this._ngZone.runOutsideAngular(() => {
|
|
247
|
+
const onTransitionEnd = () => {
|
|
248
|
+
// Clear the fallback timer since the transition fired correctly.
|
|
249
|
+
if (eventListeners) {
|
|
250
|
+
eventListeners.fallbackTimer = null;
|
|
251
|
+
}
|
|
252
|
+
clearTimeout(fallbackTimer);
|
|
253
|
+
this._finishRippleTransition(rippleRef);
|
|
254
|
+
};
|
|
255
|
+
const onTransitionCancel = () => this._destroyRipple(rippleRef);
|
|
256
|
+
// In some cases where there's a higher load on the browser, it can choose not to dispatch
|
|
257
|
+
// neither `transitionend` nor `transitioncancel` (see b/227356674). This timer serves as a
|
|
258
|
+
// fallback for such cases so that the ripple doesn't become stuck. We add a 100ms buffer
|
|
259
|
+
// because timers aren't precise. Note that another approach can be to transition the ripple
|
|
260
|
+
// to the `VISIBLE` state immediately above and to `FADING_IN` afterwards inside
|
|
261
|
+
// `transitionstart`. We go with the timer because it's one less event listener and
|
|
262
|
+
// it's less likely to break existing tests.
|
|
263
|
+
const fallbackTimer = setTimeout(onTransitionCancel, enterDuration + 100);
|
|
264
|
+
ripple.addEventListener('transitionend', onTransitionEnd);
|
|
265
|
+
// If the transition is cancelled (e.g. due to DOM removal), we destroy the ripple
|
|
266
|
+
// directly as otherwise we would keep it part of the ripple container forever.
|
|
267
|
+
// https://www.w3.org/TR/css-transitions-1/#:~:text=no%20longer%20in%20the%20document.
|
|
268
|
+
ripple.addEventListener('transitioncancel', onTransitionCancel);
|
|
269
|
+
eventListeners = { onTransitionEnd, onTransitionCancel, fallbackTimer };
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
// Add the ripple reference to the list of all active ripples.
|
|
273
|
+
this._activeRipples.set(rippleRef, eventListeners);
|
|
274
|
+
// In case there is no fade-in transition duration, we need to manually call the transition
|
|
275
|
+
// end listener because `transitionend` doesn't fire if there is no transition.
|
|
276
|
+
if (animationForciblyDisabledThroughCss || !enterDuration) {
|
|
277
|
+
this._finishRippleTransition(rippleRef);
|
|
278
|
+
}
|
|
279
|
+
return rippleRef;
|
|
280
|
+
}
|
|
281
|
+
/** Fades out a ripple reference. */
|
|
282
|
+
fadeOutRipple(rippleRef) {
|
|
283
|
+
// For ripples already fading out or hidden, this should be a noop.
|
|
284
|
+
if (rippleRef.state === RippleState.FADING_OUT || rippleRef.state === RippleState.HIDDEN) {
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
const rippleEl = rippleRef.element;
|
|
288
|
+
const animationConfig = { ...defaultRippleAnimationConfig, ...rippleRef.config.animation };
|
|
289
|
+
// This starts the fade-out transition and will fire the transition end listener that
|
|
290
|
+
// removes the ripple element from the DOM.
|
|
291
|
+
rippleEl.style.transitionDuration = `${animationConfig.exitDuration}ms`;
|
|
292
|
+
rippleEl.style.opacity = '0';
|
|
293
|
+
rippleRef.state = RippleState.FADING_OUT;
|
|
294
|
+
// In case there is no fade-out transition duration, we need to manually call the
|
|
295
|
+
// transition end listener because `transitionend` doesn't fire if there is no transition.
|
|
296
|
+
if (rippleRef._animationForciblyDisabledThroughCss || !animationConfig.exitDuration) {
|
|
297
|
+
this._finishRippleTransition(rippleRef);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
/** Fades out all currently active ripples. */
|
|
301
|
+
fadeOutAll() {
|
|
302
|
+
this._getActiveRipples().forEach(ripple => ripple.fadeOut());
|
|
303
|
+
}
|
|
304
|
+
/** Fades out all currently active non-persistent ripples. */
|
|
305
|
+
fadeOutAllNonPersistent() {
|
|
306
|
+
this._getActiveRipples().forEach(ripple => {
|
|
307
|
+
if (!ripple.config.persistent) {
|
|
308
|
+
ripple.fadeOut();
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
/** Sets up the trigger event listeners */
|
|
313
|
+
setupTriggerEvents(elementOrElementRef) {
|
|
314
|
+
const element = coerceElement(elementOrElementRef);
|
|
315
|
+
if (!this._platform.isBrowser || !element || element === this._triggerElement) {
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
// Remove all previously registered event listeners from the trigger element.
|
|
319
|
+
this._removeTriggerEvents();
|
|
320
|
+
this._triggerElement = element;
|
|
321
|
+
// Use event delegation for the trigger events since they're
|
|
322
|
+
// set up during creation and are performance-sensitive.
|
|
323
|
+
pointerDownEvents.forEach(type => {
|
|
324
|
+
RippleRenderer._eventManager.addHandler(this._ngZone, type, element, this);
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Handles all registered events.
|
|
329
|
+
* @docs-private
|
|
330
|
+
*/
|
|
331
|
+
handleEvent(event) {
|
|
332
|
+
if (event.type === 'mousedown') {
|
|
333
|
+
this._onMousedown(event);
|
|
334
|
+
}
|
|
335
|
+
else if (event.type === 'touchstart') {
|
|
336
|
+
this._onTouchStart(event);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
this._onPointerUp();
|
|
340
|
+
}
|
|
341
|
+
// If pointer-up events haven't been registered yet, do so now.
|
|
342
|
+
// We do this on-demand in order to reduce the total number of event listeners
|
|
343
|
+
// registered by the ripples, which speeds up the rendering time for large UIs.
|
|
344
|
+
if (!this._pointerUpEventsRegistered) {
|
|
345
|
+
// The events for hiding the ripple are bound directly on the trigger, because:
|
|
346
|
+
// 1. Some of them occur frequently (e.g. `mouseleave`) and any advantage we get from
|
|
347
|
+
// delegation will be diminished by having to look through all the data structures often.
|
|
348
|
+
// 2. They aren't as performance-sensitive, because they're bound only after the user
|
|
349
|
+
// has interacted with an element.
|
|
350
|
+
this._ngZone.runOutsideAngular(() => {
|
|
351
|
+
pointerUpEvents.forEach(type => {
|
|
352
|
+
this._triggerElement.addEventListener(type, this, passiveCapturingEventOptions);
|
|
353
|
+
});
|
|
354
|
+
});
|
|
355
|
+
this._pointerUpEventsRegistered = true;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/** Method that will be called if the fade-in or fade-in transition completed. */
|
|
359
|
+
_finishRippleTransition(rippleRef) {
|
|
360
|
+
if (rippleRef.state === RippleState.FADING_IN) {
|
|
361
|
+
this._startFadeOutTransition(rippleRef);
|
|
362
|
+
}
|
|
363
|
+
else if (rippleRef.state === RippleState.FADING_OUT) {
|
|
364
|
+
this._destroyRipple(rippleRef);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Starts the fade-out transition of the given ripple if it's not persistent and the pointer
|
|
369
|
+
* is not held down anymore.
|
|
370
|
+
*/
|
|
371
|
+
_startFadeOutTransition(rippleRef) {
|
|
372
|
+
const isMostRecentTransientRipple = rippleRef === this._mostRecentTransientRipple;
|
|
373
|
+
const { persistent } = rippleRef.config;
|
|
374
|
+
rippleRef.state = RippleState.VISIBLE;
|
|
375
|
+
// When the timer runs out while the user has kept their pointer down, we want to
|
|
376
|
+
// keep only the persistent ripples and the latest transient ripple. We do this,
|
|
377
|
+
// because we don't want stacked transient ripples to appear after their enter
|
|
378
|
+
// animation has finished.
|
|
379
|
+
if (!persistent && (!isMostRecentTransientRipple || !this._isPointerDown)) {
|
|
380
|
+
rippleRef.fadeOut();
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/** Destroys the given ripple by removing it from the DOM and updating its state. */
|
|
384
|
+
_destroyRipple(rippleRef) {
|
|
385
|
+
const eventListeners = this._activeRipples.get(rippleRef) ?? null;
|
|
386
|
+
this._activeRipples.delete(rippleRef);
|
|
387
|
+
// Clear out the cached bounding rect if we have no more ripples.
|
|
388
|
+
if (!this._activeRipples.size) {
|
|
389
|
+
this._containerRect = null;
|
|
390
|
+
}
|
|
391
|
+
// If the current ref is the most recent transient ripple, unset it
|
|
392
|
+
// avoid memory leaks.
|
|
393
|
+
if (rippleRef === this._mostRecentTransientRipple) {
|
|
394
|
+
this._mostRecentTransientRipple = null;
|
|
395
|
+
}
|
|
396
|
+
rippleRef.state = RippleState.HIDDEN;
|
|
397
|
+
if (eventListeners !== null) {
|
|
398
|
+
rippleRef.element.removeEventListener('transitionend', eventListeners.onTransitionEnd);
|
|
399
|
+
rippleRef.element.removeEventListener('transitioncancel', eventListeners.onTransitionCancel);
|
|
400
|
+
if (eventListeners.fallbackTimer !== null) {
|
|
401
|
+
clearTimeout(eventListeners.fallbackTimer);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
rippleRef.element.remove();
|
|
405
|
+
}
|
|
406
|
+
/** Function being called whenever the trigger is being pressed using mouse. */
|
|
407
|
+
_onMousedown(event) {
|
|
408
|
+
// Screen readers will fire fake mouse events for space/enter. Skip launching a
|
|
409
|
+
// ripple in this case for consistency with the non-screen-reader experience.
|
|
410
|
+
const isFakeMousedown = isFakeMousedownFromScreenReader(event);
|
|
411
|
+
const isSyntheticEvent = this._lastTouchStartEvent &&
|
|
412
|
+
Date.now() < this._lastTouchStartEvent + ignoreMouseEventsTimeout;
|
|
413
|
+
if (!this._target.rippleDisabled && !isFakeMousedown && !isSyntheticEvent) {
|
|
414
|
+
this._isPointerDown = true;
|
|
415
|
+
this.fadeInRipple(event.clientX, event.clientY, this._target.rippleConfig);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
/** Function being called whenever the trigger is being pressed using touch. */
|
|
419
|
+
_onTouchStart(event) {
|
|
420
|
+
if (!this._target.rippleDisabled && !isFakeTouchstartFromScreenReader(event)) {
|
|
421
|
+
// Some browsers fire mouse events after a `touchstart` event. Those synthetic mouse
|
|
422
|
+
// events will launch a second ripple if we don't ignore mouse events for a specific
|
|
423
|
+
// time after a touchstart event.
|
|
424
|
+
this._lastTouchStartEvent = Date.now();
|
|
425
|
+
this._isPointerDown = true;
|
|
426
|
+
// Use `changedTouches` so we skip any touches where the user put
|
|
427
|
+
// their finger down, but used another finger to tap the element again.
|
|
428
|
+
const touches = event.changedTouches;
|
|
429
|
+
// According to the typings the touches should always be defined, but in some cases
|
|
430
|
+
// the browser appears to not assign them in tests which leads to flakes.
|
|
431
|
+
if (touches) {
|
|
432
|
+
for (let i = 0; i < touches.length; i++) {
|
|
433
|
+
this.fadeInRipple(touches[i].clientX, touches[i].clientY, this._target.rippleConfig);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/** Function being called whenever the trigger is being released. */
|
|
439
|
+
_onPointerUp() {
|
|
440
|
+
if (!this._isPointerDown) {
|
|
441
|
+
return;
|
|
442
|
+
}
|
|
443
|
+
this._isPointerDown = false;
|
|
444
|
+
// Fade-out all ripples that are visible and not persistent.
|
|
445
|
+
this._getActiveRipples().forEach(ripple => {
|
|
446
|
+
// By default, only ripples that are completely visible will fade out on pointer release.
|
|
447
|
+
// If the `terminateOnPointerUp` option is set, ripples that still fade in will also fade out.
|
|
448
|
+
const isVisible = ripple.state === RippleState.VISIBLE ||
|
|
449
|
+
(ripple.config.terminateOnPointerUp && ripple.state === RippleState.FADING_IN);
|
|
450
|
+
if (!ripple.config.persistent && isVisible) {
|
|
451
|
+
ripple.fadeOut();
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
}
|
|
455
|
+
_getActiveRipples() {
|
|
456
|
+
return Array.from(this._activeRipples.keys());
|
|
457
|
+
}
|
|
458
|
+
/** Removes previously registered event listeners from the trigger element. */
|
|
459
|
+
_removeTriggerEvents() {
|
|
460
|
+
const trigger = this._triggerElement;
|
|
461
|
+
if (trigger) {
|
|
462
|
+
pointerDownEvents.forEach(type => RippleRenderer._eventManager.removeHandler(type, trigger, this));
|
|
463
|
+
if (this._pointerUpEventsRegistered) {
|
|
464
|
+
pointerUpEvents.forEach(type => trigger.removeEventListener(type, this, passiveCapturingEventOptions));
|
|
465
|
+
this._pointerUpEventsRegistered = false;
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
/**
|
|
471
|
+
* Returns the distance from the point (x, y) to the furthest corner of a rectangle.
|
|
472
|
+
*/
|
|
473
|
+
function distanceToFurthestCorner(x, y, rect) {
|
|
474
|
+
const distX = Math.max(Math.abs(x - rect.left), Math.abs(x - rect.right));
|
|
475
|
+
const distY = Math.max(Math.abs(y - rect.top), Math.abs(y - rect.bottom));
|
|
476
|
+
return Math.sqrt(distX * distX + distY * distY);
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/** Injection token that can be used to specify the global ripple options. */
|
|
480
|
+
const MAT_RIPPLE_GLOBAL_OPTIONS = new InjectionToken('mat-ripple-global-options');
|
|
481
|
+
class MatRipple {
|
|
482
|
+
_elementRef = inject(ElementRef);
|
|
483
|
+
_animationMode = inject(ANIMATION_MODULE_TYPE, { optional: true });
|
|
484
|
+
/** Custom color for all ripples. */
|
|
485
|
+
color;
|
|
486
|
+
/** Whether the ripples should be visible outside the component's bounds. */
|
|
487
|
+
unbounded;
|
|
488
|
+
/**
|
|
489
|
+
* Whether the ripple always originates from the center of the host element's bounds, rather
|
|
490
|
+
* than originating from the location of the click event.
|
|
491
|
+
*/
|
|
492
|
+
centered;
|
|
493
|
+
/**
|
|
494
|
+
* If set, the radius in pixels of foreground ripples when fully expanded. If unset, the radius
|
|
495
|
+
* will be the distance from the center of the ripple to the furthest corner of the host element's
|
|
496
|
+
* bounding rectangle.
|
|
497
|
+
*/
|
|
498
|
+
radius = 0;
|
|
499
|
+
/**
|
|
500
|
+
* Configuration for the ripple animation. Allows modifying the enter and exit animation
|
|
501
|
+
* duration of the ripples. The animation durations will be overwritten if the
|
|
502
|
+
* `NoopAnimationsModule` is being used.
|
|
503
|
+
*/
|
|
504
|
+
animation;
|
|
505
|
+
/**
|
|
506
|
+
* Whether click events will not trigger the ripple. Ripples can be still launched manually
|
|
507
|
+
* by using the `launch()` method.
|
|
508
|
+
*/
|
|
509
|
+
get disabled() {
|
|
510
|
+
return this._disabled;
|
|
511
|
+
}
|
|
512
|
+
set disabled(value) {
|
|
513
|
+
if (value) {
|
|
514
|
+
this.fadeOutAllNonPersistent();
|
|
515
|
+
}
|
|
516
|
+
this._disabled = value;
|
|
517
|
+
this._setupTriggerEventsIfEnabled();
|
|
518
|
+
}
|
|
519
|
+
_disabled = false;
|
|
520
|
+
/**
|
|
521
|
+
* The element that triggers the ripple when click events are received.
|
|
522
|
+
* Defaults to the directive's host element.
|
|
523
|
+
*/
|
|
524
|
+
get trigger() {
|
|
525
|
+
return this._trigger || this._elementRef.nativeElement;
|
|
526
|
+
}
|
|
527
|
+
set trigger(trigger) {
|
|
528
|
+
this._trigger = trigger;
|
|
529
|
+
this._setupTriggerEventsIfEnabled();
|
|
530
|
+
}
|
|
531
|
+
_trigger;
|
|
532
|
+
/** Renderer for the ripple DOM manipulations. */
|
|
533
|
+
_rippleRenderer;
|
|
534
|
+
/** Options that are set globally for all ripples. */
|
|
535
|
+
_globalOptions;
|
|
536
|
+
/** @docs-private Whether ripple directive is initialized and the input bindings are set. */
|
|
537
|
+
_isInitialized = false;
|
|
538
|
+
constructor() {
|
|
539
|
+
const ngZone = inject(NgZone);
|
|
540
|
+
const platform = inject(Platform);
|
|
541
|
+
const globalOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, { optional: true });
|
|
542
|
+
const injector = inject(Injector);
|
|
543
|
+
// Note: cannot use `inject()` here, because this class
|
|
544
|
+
// gets instantiated manually in the ripple loader.
|
|
545
|
+
this._globalOptions = globalOptions || {};
|
|
546
|
+
this._rippleRenderer = new RippleRenderer(this, ngZone, this._elementRef, platform, injector);
|
|
547
|
+
}
|
|
548
|
+
ngOnInit() {
|
|
549
|
+
this._isInitialized = true;
|
|
550
|
+
this._setupTriggerEventsIfEnabled();
|
|
551
|
+
}
|
|
552
|
+
ngOnDestroy() {
|
|
553
|
+
this._rippleRenderer._removeTriggerEvents();
|
|
554
|
+
}
|
|
555
|
+
/** Fades out all currently showing ripple elements. */
|
|
556
|
+
fadeOutAll() {
|
|
557
|
+
this._rippleRenderer.fadeOutAll();
|
|
558
|
+
}
|
|
559
|
+
/** Fades out all currently showing non-persistent ripple elements. */
|
|
560
|
+
fadeOutAllNonPersistent() {
|
|
561
|
+
this._rippleRenderer.fadeOutAllNonPersistent();
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Ripple configuration from the directive's input values.
|
|
565
|
+
* @docs-private Implemented as part of RippleTarget
|
|
566
|
+
*/
|
|
567
|
+
get rippleConfig() {
|
|
568
|
+
return {
|
|
569
|
+
centered: this.centered,
|
|
570
|
+
radius: this.radius,
|
|
571
|
+
color: this.color,
|
|
572
|
+
animation: {
|
|
573
|
+
...this._globalOptions.animation,
|
|
574
|
+
...(this._animationMode === 'NoopAnimations' ? { enterDuration: 0, exitDuration: 0 } : {}),
|
|
575
|
+
...this.animation,
|
|
576
|
+
},
|
|
577
|
+
terminateOnPointerUp: this._globalOptions.terminateOnPointerUp,
|
|
578
|
+
};
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Whether ripples on pointer-down are disabled or not.
|
|
582
|
+
* @docs-private Implemented as part of RippleTarget
|
|
583
|
+
*/
|
|
584
|
+
get rippleDisabled() {
|
|
585
|
+
return this.disabled || !!this._globalOptions.disabled;
|
|
586
|
+
}
|
|
587
|
+
/** Sets up the trigger event listeners if ripples are enabled. */
|
|
588
|
+
_setupTriggerEventsIfEnabled() {
|
|
589
|
+
if (!this.disabled && this._isInitialized) {
|
|
590
|
+
this._rippleRenderer.setupTriggerEvents(this.trigger);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/** Launches a manual ripple at the specified coordinated or just by the ripple config. */
|
|
594
|
+
launch(configOrX, y = 0, config) {
|
|
595
|
+
if (typeof configOrX === 'number') {
|
|
596
|
+
return this._rippleRenderer.fadeInRipple(configOrX, y, { ...this.rippleConfig, ...config });
|
|
597
|
+
}
|
|
598
|
+
else {
|
|
599
|
+
return this._rippleRenderer.fadeInRipple(0, 0, { ...this.rippleConfig, ...configOrX });
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: MatRipple, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
603
|
+
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.0.0-next.1", type: MatRipple, isStandalone: true, selector: "[mat-ripple], [matRipple]", inputs: { color: ["matRippleColor", "color"], unbounded: ["matRippleUnbounded", "unbounded"], centered: ["matRippleCentered", "centered"], radius: ["matRippleRadius", "radius"], animation: ["matRippleAnimation", "animation"], disabled: ["matRippleDisabled", "disabled"], trigger: ["matRippleTrigger", "trigger"] }, host: { properties: { "class.mat-ripple-unbounded": "unbounded" }, classAttribute: "mat-ripple" }, exportAs: ["matRipple"], ngImport: i0 });
|
|
604
|
+
}
|
|
605
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.0.0-next.1", ngImport: i0, type: MatRipple, decorators: [{
|
|
606
|
+
type: Directive,
|
|
607
|
+
args: [{
|
|
608
|
+
selector: '[mat-ripple], [matRipple]',
|
|
609
|
+
exportAs: 'matRipple',
|
|
610
|
+
host: {
|
|
611
|
+
'class': 'mat-ripple',
|
|
612
|
+
'[class.mat-ripple-unbounded]': 'unbounded',
|
|
613
|
+
},
|
|
614
|
+
}]
|
|
615
|
+
}], ctorParameters: () => [], propDecorators: { color: [{
|
|
616
|
+
type: Input,
|
|
617
|
+
args: ['matRippleColor']
|
|
618
|
+
}], unbounded: [{
|
|
619
|
+
type: Input,
|
|
620
|
+
args: ['matRippleUnbounded']
|
|
621
|
+
}], centered: [{
|
|
622
|
+
type: Input,
|
|
623
|
+
args: ['matRippleCentered']
|
|
624
|
+
}], radius: [{
|
|
625
|
+
type: Input,
|
|
626
|
+
args: ['matRippleRadius']
|
|
627
|
+
}], animation: [{
|
|
628
|
+
type: Input,
|
|
629
|
+
args: ['matRippleAnimation']
|
|
630
|
+
}], disabled: [{
|
|
631
|
+
type: Input,
|
|
632
|
+
args: ['matRippleDisabled']
|
|
633
|
+
}], trigger: [{
|
|
634
|
+
type: Input,
|
|
635
|
+
args: ['matRippleTrigger']
|
|
636
|
+
}] } });
|
|
637
|
+
|
|
638
|
+
export { MatRipple as M, RippleRenderer as R, MAT_RIPPLE_GLOBAL_OPTIONS as a, RippleState as b, RippleRef as c, defaultRippleAnimationConfig as d };
|
|
639
|
+
//# sourceMappingURL=ripple-9939d1f5.mjs.map
|