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