@angular/material 21.0.0-next.8 → 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 (204) 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 -350
  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 +125 -186
  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/sort.d.ts +1 -1
  203. package/types/table-testing.d.ts +27 -1
  204. package/types/timepicker.d.ts +148 -128
@@ -13,1047 +13,1038 @@ import '@angular/cdk/a11y';
13
13
  import '@angular/cdk/coercion';
14
14
  import '@angular/cdk/layout';
15
15
 
16
- /**
17
- * Thumb types: range slider has two thumbs (START, END) whereas single point
18
- * slider only has one thumb (END).
19
- */
20
16
  var _MatThumb;
21
17
  (function (_MatThumb) {
22
- _MatThumb[_MatThumb["START"] = 1] = "START";
23
- _MatThumb[_MatThumb["END"] = 2] = "END";
18
+ _MatThumb[_MatThumb["START"] = 1] = "START";
19
+ _MatThumb[_MatThumb["END"] = 2] = "END";
24
20
  })(_MatThumb || (_MatThumb = {}));
25
- /** Tick mark enum, for discrete sliders. */
26
21
  var _MatTickMark;
27
22
  (function (_MatTickMark) {
28
- _MatTickMark[_MatTickMark["ACTIVE"] = 0] = "ACTIVE";
29
- _MatTickMark[_MatTickMark["INACTIVE"] = 1] = "INACTIVE";
23
+ _MatTickMark[_MatTickMark["ACTIVE"] = 0] = "ACTIVE";
24
+ _MatTickMark[_MatTickMark["INACTIVE"] = 1] = "INACTIVE";
30
25
  })(_MatTickMark || (_MatTickMark = {}));
31
- /**
32
- * Injection token that can be used for a `MatSlider` to provide itself as a
33
- * parent to the `MatSliderThumb` and `MatSliderRangeThumb`.
34
- * Used primarily to avoid circular imports.
35
- * @docs-private
36
- */
37
26
  const MAT_SLIDER = new InjectionToken('_MatSlider');
38
- /**
39
- * Injection token that can be used to query for a `MatSliderThumb`.
40
- * Used primarily to avoid circular imports.
41
- * @docs-private
42
- */
43
27
  const MAT_SLIDER_THUMB = new InjectionToken('_MatSliderThumb');
44
- /**
45
- * Injection token that can be used to query for a `MatSliderRangeThumb`.
46
- * Used primarily to avoid circular imports.
47
- * @docs-private
48
- */
49
28
  const MAT_SLIDER_RANGE_THUMB = new InjectionToken('_MatSliderRangeThumb');
50
- /**
51
- * Injection token that can be used to query for a `MatSliderVisualThumb`.
52
- * Used primarily to avoid circular imports.
53
- * @docs-private
54
- */
55
29
  const MAT_SLIDER_VISUAL_THUMB = new InjectionToken('_MatSliderVisualThumb');
56
- /**
57
- * A simple change event emitted by the MatSlider component.
58
- * @deprecated Use event bindings directly on the MatSliderThumbs for `change` and `input` events. See https://v17.material.angular.dev/guide/mdc-migration for information about migrating.
59
- * @breaking-change 17.0.0
60
- */
61
30
  class MatSliderChange {
62
- /** The MatSliderThumb that was interacted with. */
63
- source;
64
- /** The MatSlider that was interacted with. */
65
- parent;
66
- /** The new value of the source slider. */
67
- value;
31
+ source;
32
+ parent;
33
+ value;
68
34
  }
69
35
 
70
- /**
71
- * The visual slider thumb.
72
- *
73
- * Handles the slider thumb ripple states (hover, focus, and active),
74
- * and displaying the value tooltip on discrete sliders.
75
- * @docs-private
76
- */
77
36
  class MatSliderVisualThumb {
78
- _cdr = inject(ChangeDetectorRef);
79
- _ngZone = inject(NgZone);
80
- _slider = inject(MAT_SLIDER);
81
- _renderer = inject(Renderer2);
82
- _listenerCleanups;
83
- /** Whether the slider displays a numeric value label upon pressing the thumb. */
84
- discrete;
85
- /** Indicates which slider thumb this input corresponds to. */
86
- thumbPosition;
87
- /** The display value of the slider thumb. */
88
- valueIndicatorText;
89
- /** The MatRipple for this slider thumb. */
90
- _ripple;
91
- /** The slider thumb knob. */
92
- _knob;
93
- /** The slider thumb value indicator container. */
94
- _valueIndicatorContainer;
95
- /** The slider input corresponding to this slider thumb. */
96
- _sliderInput;
97
- /** The native html element of the slider input corresponding to this thumb. */
98
- _sliderInputEl;
99
- /** The RippleRef for the slider thumbs hover state. */
100
- _hoverRippleRef;
101
- /** The RippleRef for the slider thumbs focus state. */
102
- _focusRippleRef;
103
- /** The RippleRef for the slider thumbs active state. */
104
- _activeRippleRef;
105
- /** Whether the slider thumb is currently being hovered. */
106
- _isHovered = false;
107
- /** Whether the slider thumb is currently being pressed. */
108
- _isActive = false;
109
- /** Whether the value indicator tooltip is visible. */
110
- _isValueIndicatorVisible = false;
111
- /** The host native HTML input element. */
112
- _hostElement = inject(ElementRef).nativeElement;
113
- _platform = inject(Platform);
114
- constructor() { }
115
- ngAfterViewInit() {
116
- const sliderInput = this._slider._getInput(this.thumbPosition);
117
- // No-op if the slider isn't configured properly. `MatSlider` will
118
- // throw an error instructing the user how to set up the slider.
119
- if (!sliderInput) {
120
- return;
121
- }
122
- this._ripple.radius = 24;
123
- this._sliderInput = sliderInput;
124
- this._sliderInputEl = this._sliderInput._hostElement;
125
- // These listeners don't update any data bindings so we bind them outside
126
- // of the NgZone to prevent Angular from needlessly running change detection.
127
- this._ngZone.runOutsideAngular(() => {
128
- const input = this._sliderInputEl;
129
- const renderer = this._renderer;
130
- this._listenerCleanups = [
131
- renderer.listen(input, 'pointermove', this._onPointerMove),
132
- renderer.listen(input, 'pointerdown', this._onDragStart),
133
- renderer.listen(input, 'pointerup', this._onDragEnd),
134
- renderer.listen(input, 'pointerleave', this._onMouseLeave),
135
- renderer.listen(input, 'focus', this._onFocus),
136
- renderer.listen(input, 'blur', this._onBlur),
137
- ];
138
- });
139
- }
140
- ngOnDestroy() {
141
- this._listenerCleanups?.forEach(cleanup => cleanup());
142
- }
143
- _onPointerMove = (event) => {
144
- if (this._sliderInput._isFocused) {
145
- return;
146
- }
147
- const rect = this._hostElement.getBoundingClientRect();
148
- const isHovered = this._slider._isCursorOnSliderThumb(event, rect);
149
- this._isHovered = isHovered;
150
- if (isHovered) {
151
- this._showHoverRipple();
152
- }
153
- else {
154
- this._hideRipple(this._hoverRippleRef);
155
- }
156
- };
157
- _onMouseLeave = () => {
158
- this._isHovered = false;
159
- this._hideRipple(this._hoverRippleRef);
160
- };
161
- _onFocus = () => {
162
- // We don't want to show the hover ripple on top of the focus ripple.
163
- // Happen when the users cursor is over a thumb and then the user tabs to it.
164
- this._hideRipple(this._hoverRippleRef);
165
- this._showFocusRipple();
166
- this._hostElement.classList.add('mdc-slider__thumb--focused');
167
- };
168
- _onBlur = () => {
169
- // Happens when the user tabs away while still dragging a thumb.
170
- if (!this._isActive) {
171
- this._hideRipple(this._focusRippleRef);
172
- }
173
- // Happens when the user tabs away from a thumb but their cursor is still over it.
174
- if (this._isHovered) {
175
- this._showHoverRipple();
176
- }
177
- this._hostElement.classList.remove('mdc-slider__thumb--focused');
178
- };
179
- _onDragStart = (event) => {
180
- if (event.button !== 0) {
181
- return;
182
- }
183
- this._isActive = true;
184
- this._showActiveRipple();
185
- };
186
- _onDragEnd = () => {
187
- this._isActive = false;
188
- this._hideRipple(this._activeRippleRef);
189
- // Happens when the user starts dragging a thumb, tabs away, and then stops dragging.
190
- if (!this._sliderInput._isFocused) {
191
- this._hideRipple(this._focusRippleRef);
192
- }
193
- // On Safari we need to immediately re-show the hover ripple because
194
- // sliders do not retain focus from pointer events on that platform.
195
- if (this._platform.SAFARI) {
196
- this._showHoverRipple();
197
- }
198
- };
199
- /** Handles displaying the hover ripple. */
200
- _showHoverRipple() {
201
- if (!this._isShowingRipple(this._hoverRippleRef)) {
202
- this._hoverRippleRef = this._showRipple({ enterDuration: 0, exitDuration: 0 });
203
- this._hoverRippleRef?.element.classList.add('mat-mdc-slider-hover-ripple');
204
- }
205
- }
206
- /** Handles displaying the focus ripple. */
207
- _showFocusRipple() {
208
- // Show the focus ripple event if noop animations are enabled.
209
- if (!this._isShowingRipple(this._focusRippleRef)) {
210
- this._focusRippleRef = this._showRipple({ enterDuration: 0, exitDuration: 0 }, true);
211
- this._focusRippleRef?.element.classList.add('mat-mdc-slider-focus-ripple');
212
- }
213
- }
214
- /** Handles displaying the active ripple. */
215
- _showActiveRipple() {
216
- if (!this._isShowingRipple(this._activeRippleRef)) {
217
- this._activeRippleRef = this._showRipple({ enterDuration: 225, exitDuration: 400 });
218
- this._activeRippleRef?.element.classList.add('mat-mdc-slider-active-ripple');
219
- }
220
- }
221
- /** Whether the given rippleRef is currently fading in or visible. */
222
- _isShowingRipple(rippleRef) {
223
- return rippleRef?.state === RippleState.FADING_IN || rippleRef?.state === RippleState.VISIBLE;
224
- }
225
- /** Manually launches the slider thumb ripple using the specified ripple animation config. */
226
- _showRipple(animation, ignoreGlobalRippleConfig) {
227
- if (this._slider.disabled) {
228
- return;
229
- }
230
- this._showValueIndicator();
231
- if (this._slider._isRange) {
232
- const sibling = this._slider._getThumb(this.thumbPosition === _MatThumb.START ? _MatThumb.END : _MatThumb.START);
233
- sibling._showValueIndicator();
234
- }
235
- if (this._slider._globalRippleOptions?.disabled && !ignoreGlobalRippleConfig) {
236
- return;
237
- }
238
- return this._ripple.launch({
239
- animation: this._slider._noopAnimations ? { enterDuration: 0, exitDuration: 0 } : animation,
240
- centered: true,
241
- persistent: true,
242
- });
243
- }
244
- /**
245
- * Fades out the given ripple.
246
- * Also hides the value indicator if no ripple is showing.
247
- */
248
- _hideRipple(rippleRef) {
249
- rippleRef?.fadeOut();
250
- if (this._isShowingAnyRipple()) {
251
- return;
252
- }
253
- if (!this._slider._isRange) {
254
- this._hideValueIndicator();
255
- }
256
- const sibling = this._getSibling();
257
- if (!sibling._isShowingAnyRipple()) {
258
- this._hideValueIndicator();
259
- sibling._hideValueIndicator();
260
- }
261
- }
262
- /** Shows the value indicator ui. */
263
- _showValueIndicator() {
264
- this._hostElement.classList.add('mdc-slider__thumb--with-indicator');
265
- }
266
- /** Hides the value indicator ui. */
267
- _hideValueIndicator() {
268
- this._hostElement.classList.remove('mdc-slider__thumb--with-indicator');
269
- }
270
- _getSibling() {
271
- return this._slider._getThumb(this.thumbPosition === _MatThumb.START ? _MatThumb.END : _MatThumb.START);
272
- }
273
- /** Gets the value indicator container's native HTML element. */
274
- _getValueIndicatorContainer() {
275
- return this._valueIndicatorContainer?.nativeElement;
276
- }
277
- /** Gets the native HTML element of the slider thumb knob. */
278
- _getKnob() {
279
- return this._knob.nativeElement;
280
- }
281
- _isShowingAnyRipple() {
282
- return (this._isShowingRipple(this._hoverRippleRef) ||
283
- this._isShowingRipple(this._focusRippleRef) ||
284
- this._isShowingRipple(this._activeRippleRef));
285
- }
286
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderVisualThumb, deps: [], target: i0.ɵɵFactoryTarget.Component });
287
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0-next.2", type: MatSliderVisualThumb, isStandalone: true, selector: "mat-slider-visual-thumb", inputs: { discrete: "discrete", thumbPosition: "thumbPosition", valueIndicatorText: "valueIndicatorText" }, host: { classAttribute: "mdc-slider__thumb mat-mdc-slider-visual-thumb" }, providers: [{ provide: MAT_SLIDER_VISUAL_THUMB, useExisting: MatSliderVisualThumb }], viewQueries: [{ propertyName: "_ripple", first: true, predicate: MatRipple, descendants: true }, { propertyName: "_knob", first: true, predicate: ["knob"], descendants: true }, { propertyName: "_valueIndicatorContainer", first: true, predicate: ["valueIndicatorContainer"], descendants: true }], ngImport: i0, template: "@if (discrete) {\n <div class=\"mdc-slider__value-indicator-container\" #valueIndicatorContainer>\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">{{valueIndicatorText}}</span>\n </div>\n </div>\n}\n<div class=\"mdc-slider__thumb-knob\" #knob></div>\n<div matRipple class=\"mat-focus-indicator\" [matRippleDisabled]=\"true\"></div>\n", styles: [".mat-mdc-slider-visual-thumb .mat-ripple{height:100%;width:100%}.mat-mdc-slider .mdc-slider__tick-marks{justify-content:start}.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--active,.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--inactive{position:absolute;left:2px}\n"], dependencies: [{ kind: "directive", type: MatRipple, selector: "[mat-ripple], [matRipple]", inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"], exportAs: ["matRipple"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
37
+ _cdr = inject(ChangeDetectorRef);
38
+ _ngZone = inject(NgZone);
39
+ _slider = inject(MAT_SLIDER);
40
+ _renderer = inject(Renderer2);
41
+ _listenerCleanups;
42
+ discrete;
43
+ thumbPosition;
44
+ valueIndicatorText;
45
+ _ripple;
46
+ _knob;
47
+ _valueIndicatorContainer;
48
+ _sliderInput;
49
+ _sliderInputEl;
50
+ _hoverRippleRef;
51
+ _focusRippleRef;
52
+ _activeRippleRef;
53
+ _isHovered = false;
54
+ _isActive = false;
55
+ _isValueIndicatorVisible = false;
56
+ _hostElement = inject(ElementRef).nativeElement;
57
+ _platform = inject(Platform);
58
+ constructor() {}
59
+ ngAfterViewInit() {
60
+ const sliderInput = this._slider._getInput(this.thumbPosition);
61
+ if (!sliderInput) {
62
+ return;
63
+ }
64
+ this._ripple.radius = 24;
65
+ this._sliderInput = sliderInput;
66
+ this._sliderInputEl = this._sliderInput._hostElement;
67
+ this._ngZone.runOutsideAngular(() => {
68
+ const input = this._sliderInputEl;
69
+ const renderer = this._renderer;
70
+ this._listenerCleanups = [renderer.listen(input, 'pointermove', this._onPointerMove), renderer.listen(input, 'pointerdown', this._onDragStart), renderer.listen(input, 'pointerup', this._onDragEnd), renderer.listen(input, 'pointerleave', this._onMouseLeave), renderer.listen(input, 'focus', this._onFocus), renderer.listen(input, 'blur', this._onBlur)];
71
+ });
72
+ }
73
+ ngOnDestroy() {
74
+ this._listenerCleanups?.forEach(cleanup => cleanup());
75
+ }
76
+ _onPointerMove = event => {
77
+ if (this._sliderInput._isFocused) {
78
+ return;
79
+ }
80
+ const rect = this._hostElement.getBoundingClientRect();
81
+ const isHovered = this._slider._isCursorOnSliderThumb(event, rect);
82
+ this._isHovered = isHovered;
83
+ if (isHovered) {
84
+ this._showHoverRipple();
85
+ } else {
86
+ this._hideRipple(this._hoverRippleRef);
87
+ }
88
+ };
89
+ _onMouseLeave = () => {
90
+ this._isHovered = false;
91
+ this._hideRipple(this._hoverRippleRef);
92
+ };
93
+ _onFocus = () => {
94
+ this._hideRipple(this._hoverRippleRef);
95
+ this._showFocusRipple();
96
+ this._hostElement.classList.add('mdc-slider__thumb--focused');
97
+ };
98
+ _onBlur = () => {
99
+ if (!this._isActive) {
100
+ this._hideRipple(this._focusRippleRef);
101
+ }
102
+ if (this._isHovered) {
103
+ this._showHoverRipple();
104
+ }
105
+ this._hostElement.classList.remove('mdc-slider__thumb--focused');
106
+ };
107
+ _onDragStart = event => {
108
+ if (event.button !== 0) {
109
+ return;
110
+ }
111
+ this._isActive = true;
112
+ this._showActiveRipple();
113
+ };
114
+ _onDragEnd = () => {
115
+ this._isActive = false;
116
+ this._hideRipple(this._activeRippleRef);
117
+ if (!this._sliderInput._isFocused) {
118
+ this._hideRipple(this._focusRippleRef);
119
+ }
120
+ if (this._platform.SAFARI) {
121
+ this._showHoverRipple();
122
+ }
123
+ };
124
+ _showHoverRipple() {
125
+ if (!this._isShowingRipple(this._hoverRippleRef)) {
126
+ this._hoverRippleRef = this._showRipple({
127
+ enterDuration: 0,
128
+ exitDuration: 0
129
+ });
130
+ this._hoverRippleRef?.element.classList.add('mat-mdc-slider-hover-ripple');
131
+ }
132
+ }
133
+ _showFocusRipple() {
134
+ if (!this._isShowingRipple(this._focusRippleRef)) {
135
+ this._focusRippleRef = this._showRipple({
136
+ enterDuration: 0,
137
+ exitDuration: 0
138
+ }, true);
139
+ this._focusRippleRef?.element.classList.add('mat-mdc-slider-focus-ripple');
140
+ }
141
+ }
142
+ _showActiveRipple() {
143
+ if (!this._isShowingRipple(this._activeRippleRef)) {
144
+ this._activeRippleRef = this._showRipple({
145
+ enterDuration: 225,
146
+ exitDuration: 400
147
+ });
148
+ this._activeRippleRef?.element.classList.add('mat-mdc-slider-active-ripple');
149
+ }
150
+ }
151
+ _isShowingRipple(rippleRef) {
152
+ return rippleRef?.state === RippleState.FADING_IN || rippleRef?.state === RippleState.VISIBLE;
153
+ }
154
+ _showRipple(animation, ignoreGlobalRippleConfig) {
155
+ if (this._slider.disabled) {
156
+ return;
157
+ }
158
+ this._showValueIndicator();
159
+ if (this._slider._isRange) {
160
+ const sibling = this._slider._getThumb(this.thumbPosition === _MatThumb.START ? _MatThumb.END : _MatThumb.START);
161
+ sibling._showValueIndicator();
162
+ }
163
+ if (this._slider._globalRippleOptions?.disabled && !ignoreGlobalRippleConfig) {
164
+ return;
165
+ }
166
+ return this._ripple.launch({
167
+ animation: this._slider._noopAnimations ? {
168
+ enterDuration: 0,
169
+ exitDuration: 0
170
+ } : animation,
171
+ centered: true,
172
+ persistent: true
173
+ });
174
+ }
175
+ _hideRipple(rippleRef) {
176
+ rippleRef?.fadeOut();
177
+ if (this._isShowingAnyRipple()) {
178
+ return;
179
+ }
180
+ if (!this._slider._isRange) {
181
+ this._hideValueIndicator();
182
+ }
183
+ const sibling = this._getSibling();
184
+ if (!sibling._isShowingAnyRipple()) {
185
+ this._hideValueIndicator();
186
+ sibling._hideValueIndicator();
187
+ }
188
+ }
189
+ _showValueIndicator() {
190
+ this._hostElement.classList.add('mdc-slider__thumb--with-indicator');
191
+ }
192
+ _hideValueIndicator() {
193
+ this._hostElement.classList.remove('mdc-slider__thumb--with-indicator');
194
+ }
195
+ _getSibling() {
196
+ return this._slider._getThumb(this.thumbPosition === _MatThumb.START ? _MatThumb.END : _MatThumb.START);
197
+ }
198
+ _getValueIndicatorContainer() {
199
+ return this._valueIndicatorContainer?.nativeElement;
200
+ }
201
+ _getKnob() {
202
+ return this._knob.nativeElement;
203
+ }
204
+ _isShowingAnyRipple() {
205
+ return this._isShowingRipple(this._hoverRippleRef) || this._isShowingRipple(this._focusRippleRef) || this._isShowingRipple(this._activeRippleRef);
206
+ }
207
+ static ɵfac = i0.ɵɵngDeclareFactory({
208
+ minVersion: "12.0.0",
209
+ version: "20.2.0-next.2",
210
+ ngImport: i0,
211
+ type: MatSliderVisualThumb,
212
+ deps: [],
213
+ target: i0.ɵɵFactoryTarget.Component
214
+ });
215
+ static ɵcmp = i0.ɵɵngDeclareComponent({
216
+ minVersion: "17.0.0",
217
+ version: "20.2.0-next.2",
218
+ type: MatSliderVisualThumb,
219
+ isStandalone: true,
220
+ selector: "mat-slider-visual-thumb",
221
+ inputs: {
222
+ discrete: "discrete",
223
+ thumbPosition: "thumbPosition",
224
+ valueIndicatorText: "valueIndicatorText"
225
+ },
226
+ host: {
227
+ classAttribute: "mdc-slider__thumb mat-mdc-slider-visual-thumb"
228
+ },
229
+ providers: [{
230
+ provide: MAT_SLIDER_VISUAL_THUMB,
231
+ useExisting: MatSliderVisualThumb
232
+ }],
233
+ viewQueries: [{
234
+ propertyName: "_ripple",
235
+ first: true,
236
+ predicate: MatRipple,
237
+ descendants: true
238
+ }, {
239
+ propertyName: "_knob",
240
+ first: true,
241
+ predicate: ["knob"],
242
+ descendants: true
243
+ }, {
244
+ propertyName: "_valueIndicatorContainer",
245
+ first: true,
246
+ predicate: ["valueIndicatorContainer"],
247
+ descendants: true
248
+ }],
249
+ ngImport: i0,
250
+ template: "@if (discrete) {\n <div class=\"mdc-slider__value-indicator-container\" #valueIndicatorContainer>\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">{{valueIndicatorText}}</span>\n </div>\n </div>\n}\n<div class=\"mdc-slider__thumb-knob\" #knob></div>\n<div matRipple class=\"mat-focus-indicator\" [matRippleDisabled]=\"true\"></div>\n",
251
+ styles: [".mat-mdc-slider-visual-thumb .mat-ripple{height:100%;width:100%}.mat-mdc-slider .mdc-slider__tick-marks{justify-content:start}.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--active,.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--inactive{position:absolute;left:2px}\n"],
252
+ dependencies: [{
253
+ kind: "directive",
254
+ type: MatRipple,
255
+ selector: "[mat-ripple], [matRipple]",
256
+ inputs: ["matRippleColor", "matRippleUnbounded", "matRippleCentered", "matRippleRadius", "matRippleAnimation", "matRippleDisabled", "matRippleTrigger"],
257
+ exportAs: ["matRipple"]
258
+ }],
259
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
260
+ encapsulation: i0.ViewEncapsulation.None
261
+ });
288
262
  }
289
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderVisualThumb, decorators: [{
290
- type: Component,
291
- args: [{ selector: 'mat-slider-visual-thumb', host: {
292
- 'class': 'mdc-slider__thumb mat-mdc-slider-visual-thumb',
293
- }, changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: MAT_SLIDER_VISUAL_THUMB, useExisting: MatSliderVisualThumb }], imports: [MatRipple], template: "@if (discrete) {\n <div class=\"mdc-slider__value-indicator-container\" #valueIndicatorContainer>\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">{{valueIndicatorText}}</span>\n </div>\n </div>\n}\n<div class=\"mdc-slider__thumb-knob\" #knob></div>\n<div matRipple class=\"mat-focus-indicator\" [matRippleDisabled]=\"true\"></div>\n", styles: [".mat-mdc-slider-visual-thumb .mat-ripple{height:100%;width:100%}.mat-mdc-slider .mdc-slider__tick-marks{justify-content:start}.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--active,.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--inactive{position:absolute;left:2px}\n"] }]
294
- }], ctorParameters: () => [], propDecorators: { discrete: [{
295
- type: Input
296
- }], thumbPosition: [{
297
- type: Input
298
- }], valueIndicatorText: [{
299
- type: Input
300
- }], _ripple: [{
301
- type: ViewChild,
302
- args: [MatRipple]
303
- }], _knob: [{
304
- type: ViewChild,
305
- args: ['knob']
306
- }], _valueIndicatorContainer: [{
307
- type: ViewChild,
308
- args: ['valueIndicatorContainer']
309
- }] } });
263
+ i0.ɵɵngDeclareClassMetadata({
264
+ minVersion: "12.0.0",
265
+ version: "20.2.0-next.2",
266
+ ngImport: i0,
267
+ type: MatSliderVisualThumb,
268
+ decorators: [{
269
+ type: Component,
270
+ args: [{
271
+ selector: 'mat-slider-visual-thumb',
272
+ host: {
273
+ 'class': 'mdc-slider__thumb mat-mdc-slider-visual-thumb'
274
+ },
275
+ changeDetection: ChangeDetectionStrategy.OnPush,
276
+ encapsulation: ViewEncapsulation.None,
277
+ providers: [{
278
+ provide: MAT_SLIDER_VISUAL_THUMB,
279
+ useExisting: MatSliderVisualThumb
280
+ }],
281
+ imports: [MatRipple],
282
+ template: "@if (discrete) {\n <div class=\"mdc-slider__value-indicator-container\" #valueIndicatorContainer>\n <div class=\"mdc-slider__value-indicator\">\n <span class=\"mdc-slider__value-indicator-text\">{{valueIndicatorText}}</span>\n </div>\n </div>\n}\n<div class=\"mdc-slider__thumb-knob\" #knob></div>\n<div matRipple class=\"mat-focus-indicator\" [matRippleDisabled]=\"true\"></div>\n",
283
+ styles: [".mat-mdc-slider-visual-thumb .mat-ripple{height:100%;width:100%}.mat-mdc-slider .mdc-slider__tick-marks{justify-content:start}.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--active,.mat-mdc-slider .mdc-slider__tick-marks .mdc-slider__tick-mark--inactive{position:absolute;left:2px}\n"]
284
+ }]
285
+ }],
286
+ ctorParameters: () => [],
287
+ propDecorators: {
288
+ discrete: [{
289
+ type: Input
290
+ }],
291
+ thumbPosition: [{
292
+ type: Input
293
+ }],
294
+ valueIndicatorText: [{
295
+ type: Input
296
+ }],
297
+ _ripple: [{
298
+ type: ViewChild,
299
+ args: [MatRipple]
300
+ }],
301
+ _knob: [{
302
+ type: ViewChild,
303
+ args: ['knob']
304
+ }],
305
+ _valueIndicatorContainer: [{
306
+ type: ViewChild,
307
+ args: ['valueIndicatorContainer']
308
+ }]
309
+ }
310
+ });
310
311
 
311
- // TODO(wagnermaciel): maybe handle the following edge case:
312
- // 1. start dragging discrete slider
313
- // 2. tab to disable checkbox
314
- // 3. without ending drag, disable the slider
315
- /**
316
- * Allows users to select from a range of values by moving the slider thumb. It is similar in
317
- * behavior to the native `<input type="range">` element.
318
- */
319
312
  class MatSlider {
320
- _ngZone = inject(NgZone);
321
- _cdr = inject(ChangeDetectorRef);
322
- _elementRef = inject(ElementRef);
323
- _dir = inject(Directionality, { optional: true });
324
- _globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, {
325
- optional: true,
313
+ _ngZone = inject(NgZone);
314
+ _cdr = inject(ChangeDetectorRef);
315
+ _elementRef = inject(ElementRef);
316
+ _dir = inject(Directionality, {
317
+ optional: true
318
+ });
319
+ _globalRippleOptions = inject(MAT_RIPPLE_GLOBAL_OPTIONS, {
320
+ optional: true
321
+ });
322
+ _trackActive;
323
+ _thumbs;
324
+ _input;
325
+ _inputs;
326
+ get disabled() {
327
+ return this._disabled;
328
+ }
329
+ set disabled(v) {
330
+ this._disabled = v;
331
+ const endInput = this._getInput(_MatThumb.END);
332
+ const startInput = this._getInput(_MatThumb.START);
333
+ if (endInput) {
334
+ endInput.disabled = this._disabled;
335
+ }
336
+ if (startInput) {
337
+ startInput.disabled = this._disabled;
338
+ }
339
+ }
340
+ _disabled = false;
341
+ get discrete() {
342
+ return this._discrete;
343
+ }
344
+ set discrete(v) {
345
+ this._discrete = v;
346
+ this._updateValueIndicatorUIs();
347
+ }
348
+ _discrete = false;
349
+ get showTickMarks() {
350
+ return this._showTickMarks;
351
+ }
352
+ set showTickMarks(value) {
353
+ this._showTickMarks = value;
354
+ if (this._hasViewInitialized) {
355
+ this._updateTickMarkUI();
356
+ this._updateTickMarkTrackUI();
357
+ }
358
+ }
359
+ _showTickMarks = false;
360
+ get min() {
361
+ return this._min;
362
+ }
363
+ set min(v) {
364
+ const min = v === undefined || v === null || isNaN(v) ? this._min : v;
365
+ if (this._min !== min) {
366
+ this._updateMin(min);
367
+ }
368
+ }
369
+ _min = 0;
370
+ color;
371
+ disableRipple = false;
372
+ _updateMin(min) {
373
+ const prevMin = this._min;
374
+ this._min = min;
375
+ this._isRange ? this._updateMinRange({
376
+ old: prevMin,
377
+ new: min
378
+ }) : this._updateMinNonRange(min);
379
+ this._onMinMaxOrStepChange();
380
+ }
381
+ _updateMinRange(min) {
382
+ const endInput = this._getInput(_MatThumb.END);
383
+ const startInput = this._getInput(_MatThumb.START);
384
+ const oldEndValue = endInput.value;
385
+ const oldStartValue = startInput.value;
386
+ startInput.min = min.new;
387
+ endInput.min = Math.max(min.new, startInput.value);
388
+ startInput.max = Math.min(endInput.max, endInput.value);
389
+ startInput._updateWidthInactive();
390
+ endInput._updateWidthInactive();
391
+ min.new < min.old ? this._onTranslateXChangeBySideEffect(endInput, startInput) : this._onTranslateXChangeBySideEffect(startInput, endInput);
392
+ if (oldEndValue !== endInput.value) {
393
+ this._onValueChange(endInput);
394
+ }
395
+ if (oldStartValue !== startInput.value) {
396
+ this._onValueChange(startInput);
397
+ }
398
+ }
399
+ _updateMinNonRange(min) {
400
+ const input = this._getInput(_MatThumb.END);
401
+ if (input) {
402
+ const oldValue = input.value;
403
+ input.min = min;
404
+ input._updateThumbUIByValue();
405
+ this._updateTrackUI(input);
406
+ if (oldValue !== input.value) {
407
+ this._onValueChange(input);
408
+ }
409
+ }
410
+ }
411
+ get max() {
412
+ return this._max;
413
+ }
414
+ set max(v) {
415
+ const max = v === undefined || v === null || isNaN(v) ? this._max : v;
416
+ if (this._max !== max) {
417
+ this._updateMax(max);
418
+ }
419
+ }
420
+ _max = 100;
421
+ _updateMax(max) {
422
+ const prevMax = this._max;
423
+ this._max = max;
424
+ this._isRange ? this._updateMaxRange({
425
+ old: prevMax,
426
+ new: max
427
+ }) : this._updateMaxNonRange(max);
428
+ this._onMinMaxOrStepChange();
429
+ }
430
+ _updateMaxRange(max) {
431
+ const endInput = this._getInput(_MatThumb.END);
432
+ const startInput = this._getInput(_MatThumb.START);
433
+ const oldEndValue = endInput.value;
434
+ const oldStartValue = startInput.value;
435
+ endInput.max = max.new;
436
+ startInput.max = Math.min(max.new, endInput.value);
437
+ endInput.min = startInput.value;
438
+ endInput._updateWidthInactive();
439
+ startInput._updateWidthInactive();
440
+ max.new > max.old ? this._onTranslateXChangeBySideEffect(startInput, endInput) : this._onTranslateXChangeBySideEffect(endInput, startInput);
441
+ if (oldEndValue !== endInput.value) {
442
+ this._onValueChange(endInput);
443
+ }
444
+ if (oldStartValue !== startInput.value) {
445
+ this._onValueChange(startInput);
446
+ }
447
+ }
448
+ _updateMaxNonRange(max) {
449
+ const input = this._getInput(_MatThumb.END);
450
+ if (input) {
451
+ const oldValue = input.value;
452
+ input.max = max;
453
+ input._updateThumbUIByValue();
454
+ this._updateTrackUI(input);
455
+ if (oldValue !== input.value) {
456
+ this._onValueChange(input);
457
+ }
458
+ }
459
+ }
460
+ get step() {
461
+ return this._step;
462
+ }
463
+ set step(v) {
464
+ const step = isNaN(v) ? this._step : v;
465
+ if (this._step !== step) {
466
+ this._updateStep(step);
467
+ }
468
+ }
469
+ _step = 1;
470
+ _updateStep(step) {
471
+ this._step = step;
472
+ this._isRange ? this._updateStepRange() : this._updateStepNonRange();
473
+ this._onMinMaxOrStepChange();
474
+ }
475
+ _updateStepRange() {
476
+ const endInput = this._getInput(_MatThumb.END);
477
+ const startInput = this._getInput(_MatThumb.START);
478
+ const oldEndValue = endInput.value;
479
+ const oldStartValue = startInput.value;
480
+ const prevStartValue = startInput.value;
481
+ endInput.min = this._min;
482
+ startInput.max = this._max;
483
+ endInput.step = this._step;
484
+ startInput.step = this._step;
485
+ if (this._platform.SAFARI) {
486
+ endInput.value = endInput.value;
487
+ startInput.value = startInput.value;
488
+ }
489
+ endInput.min = Math.max(this._min, startInput.value);
490
+ startInput.max = Math.min(this._max, endInput.value);
491
+ startInput._updateWidthInactive();
492
+ endInput._updateWidthInactive();
493
+ endInput.value < prevStartValue ? this._onTranslateXChangeBySideEffect(startInput, endInput) : this._onTranslateXChangeBySideEffect(endInput, startInput);
494
+ if (oldEndValue !== endInput.value) {
495
+ this._onValueChange(endInput);
496
+ }
497
+ if (oldStartValue !== startInput.value) {
498
+ this._onValueChange(startInput);
499
+ }
500
+ }
501
+ _updateStepNonRange() {
502
+ const input = this._getInput(_MatThumb.END);
503
+ if (input) {
504
+ const oldValue = input.value;
505
+ input.step = this._step;
506
+ if (this._platform.SAFARI) {
507
+ input.value = input.value;
508
+ }
509
+ input._updateThumbUIByValue();
510
+ if (oldValue !== input.value) {
511
+ this._onValueChange(input);
512
+ }
513
+ }
514
+ }
515
+ displayWith = value => `${value}`;
516
+ _tickMarks;
517
+ _noopAnimations = _animationsDisabled();
518
+ _dirChangeSubscription;
519
+ _resizeObserver;
520
+ _cachedWidth;
521
+ _cachedLeft;
522
+ _rippleRadius = 24;
523
+ startValueIndicatorText = '';
524
+ endValueIndicatorText = '';
525
+ _endThumbTransform;
526
+ _startThumbTransform;
527
+ _isRange = false;
528
+ _isRtl = false;
529
+ _hasViewInitialized = false;
530
+ _tickMarkTrackWidth = 0;
531
+ _hasAnimation = false;
532
+ _resizeTimer = null;
533
+ _platform = inject(Platform);
534
+ constructor() {
535
+ inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
536
+ if (this._dir) {
537
+ this._dirChangeSubscription = this._dir.change.subscribe(() => this._onDirChange());
538
+ this._isRtl = this._dir.value === 'rtl';
539
+ }
540
+ }
541
+ _knobRadius = 8;
542
+ _inputPadding;
543
+ ngAfterViewInit() {
544
+ if (this._platform.isBrowser) {
545
+ this._updateDimensions();
546
+ }
547
+ const eInput = this._getInput(_MatThumb.END);
548
+ const sInput = this._getInput(_MatThumb.START);
549
+ this._isRange = !!eInput && !!sInput;
550
+ this._cdr.detectChanges();
551
+ if (typeof ngDevMode === 'undefined' || ngDevMode) {
552
+ _validateInputs(this._isRange, this._getInput(_MatThumb.END), this._getInput(_MatThumb.START));
553
+ }
554
+ const thumb = this._getThumb(_MatThumb.END);
555
+ this._rippleRadius = thumb._ripple.radius;
556
+ this._inputPadding = this._rippleRadius - this._knobRadius;
557
+ this._isRange ? this._initUIRange(eInput, sInput) : this._initUINonRange(eInput);
558
+ this._updateTrackUI(eInput);
559
+ this._updateTickMarkUI();
560
+ this._updateTickMarkTrackUI();
561
+ this._observeHostResize();
562
+ this._cdr.detectChanges();
563
+ }
564
+ _initUINonRange(eInput) {
565
+ eInput.initProps();
566
+ eInput.initUI();
567
+ this._updateValueIndicatorUI(eInput);
568
+ this._hasViewInitialized = true;
569
+ eInput._updateThumbUIByValue();
570
+ }
571
+ _initUIRange(eInput, sInput) {
572
+ eInput.initProps();
573
+ eInput.initUI();
574
+ sInput.initProps();
575
+ sInput.initUI();
576
+ eInput._updateMinMax();
577
+ sInput._updateMinMax();
578
+ eInput._updateStaticStyles();
579
+ sInput._updateStaticStyles();
580
+ this._updateValueIndicatorUIs();
581
+ this._hasViewInitialized = true;
582
+ eInput._updateThumbUIByValue();
583
+ sInput._updateThumbUIByValue();
584
+ }
585
+ ngOnDestroy() {
586
+ this._dirChangeSubscription.unsubscribe();
587
+ this._resizeObserver?.disconnect();
588
+ this._resizeObserver = null;
589
+ }
590
+ _onDirChange() {
591
+ this._isRtl = this._dir?.value === 'rtl';
592
+ this._isRange ? this._onDirChangeRange() : this._onDirChangeNonRange();
593
+ this._updateTickMarkUI();
594
+ }
595
+ _onDirChangeRange() {
596
+ const endInput = this._getInput(_MatThumb.END);
597
+ const startInput = this._getInput(_MatThumb.START);
598
+ endInput._setIsLeftThumb();
599
+ startInput._setIsLeftThumb();
600
+ endInput.translateX = endInput._calcTranslateXByValue();
601
+ startInput.translateX = startInput._calcTranslateXByValue();
602
+ endInput._updateStaticStyles();
603
+ startInput._updateStaticStyles();
604
+ endInput._updateWidthInactive();
605
+ startInput._updateWidthInactive();
606
+ endInput._updateThumbUIByValue();
607
+ startInput._updateThumbUIByValue();
608
+ }
609
+ _onDirChangeNonRange() {
610
+ const input = this._getInput(_MatThumb.END);
611
+ input._updateThumbUIByValue();
612
+ }
613
+ _observeHostResize() {
614
+ if (typeof ResizeObserver === 'undefined' || !ResizeObserver) {
615
+ return;
616
+ }
617
+ this._ngZone.runOutsideAngular(() => {
618
+ this._resizeObserver = new ResizeObserver(() => {
619
+ if (this._isActive()) {
620
+ return;
621
+ }
622
+ if (this._resizeTimer) {
623
+ clearTimeout(this._resizeTimer);
624
+ }
625
+ this._onResize();
626
+ });
627
+ this._resizeObserver.observe(this._elementRef.nativeElement);
326
628
  });
327
- /** The active portion of the slider track. */
328
- _trackActive;
329
- /** The slider thumb(s). */
330
- _thumbs;
331
- /** The sliders hidden range input(s). */
332
- _input;
333
- /** The sliders hidden range input(s). */
334
- _inputs;
335
- /** Whether the slider is disabled. */
336
- get disabled() {
337
- return this._disabled;
338
- }
339
- set disabled(v) {
340
- this._disabled = v;
341
- const endInput = this._getInput(_MatThumb.END);
342
- const startInput = this._getInput(_MatThumb.START);
343
- if (endInput) {
344
- endInput.disabled = this._disabled;
345
- }
346
- if (startInput) {
347
- startInput.disabled = this._disabled;
348
- }
349
- }
350
- _disabled = false;
351
- /** Whether the slider displays a numeric value label upon pressing the thumb. */
352
- get discrete() {
353
- return this._discrete;
354
- }
355
- set discrete(v) {
356
- this._discrete = v;
357
- this._updateValueIndicatorUIs();
358
- }
359
- _discrete = false;
360
- /** Whether the slider displays tick marks along the slider track. */
361
- get showTickMarks() {
362
- return this._showTickMarks;
363
- }
364
- set showTickMarks(value) {
365
- this._showTickMarks = value;
366
- if (this._hasViewInitialized) {
367
- this._updateTickMarkUI();
368
- this._updateTickMarkTrackUI();
369
- }
370
- }
371
- _showTickMarks = false;
372
- /** The minimum value that the slider can have. */
373
- get min() {
374
- return this._min;
375
- }
376
- set min(v) {
377
- const min = v === undefined || v === null || isNaN(v) ? this._min : v;
378
- if (this._min !== min) {
379
- this._updateMin(min);
380
- }
381
- }
382
- _min = 0;
383
- /**
384
- * Theme color of the slider. This API is supported in M2 themes only, it
385
- * has no effect in M3 themes. For color customization in M3, see https://material.angular.dev/components/slider/styling.
386
- *
387
- * For information on applying color variants in M3, see
388
- * https://material.angular.dev/guide/material-2-theming#optional-add-backwards-compatibility-styles-for-color-variants
389
- */
390
- color;
391
- /** Whether ripples are disabled in the slider. */
392
- disableRipple = false;
393
- _updateMin(min) {
394
- const prevMin = this._min;
395
- this._min = min;
396
- this._isRange ? this._updateMinRange({ old: prevMin, new: min }) : this._updateMinNonRange(min);
397
- this._onMinMaxOrStepChange();
398
- }
399
- _updateMinRange(min) {
400
- const endInput = this._getInput(_MatThumb.END);
401
- const startInput = this._getInput(_MatThumb.START);
402
- const oldEndValue = endInput.value;
403
- const oldStartValue = startInput.value;
404
- startInput.min = min.new;
405
- endInput.min = Math.max(min.new, startInput.value);
406
- startInput.max = Math.min(endInput.max, endInput.value);
407
- startInput._updateWidthInactive();
408
- endInput._updateWidthInactive();
409
- min.new < min.old
410
- ? this._onTranslateXChangeBySideEffect(endInput, startInput)
411
- : this._onTranslateXChangeBySideEffect(startInput, endInput);
412
- if (oldEndValue !== endInput.value) {
413
- this._onValueChange(endInput);
414
- }
415
- if (oldStartValue !== startInput.value) {
416
- this._onValueChange(startInput);
417
- }
418
- }
419
- _updateMinNonRange(min) {
420
- const input = this._getInput(_MatThumb.END);
421
- if (input) {
422
- const oldValue = input.value;
423
- input.min = min;
424
- input._updateThumbUIByValue();
425
- this._updateTrackUI(input);
426
- if (oldValue !== input.value) {
427
- this._onValueChange(input);
428
- }
429
- }
430
- }
431
- /** The maximum value that the slider can have. */
432
- get max() {
433
- return this._max;
434
- }
435
- set max(v) {
436
- const max = v === undefined || v === null || isNaN(v) ? this._max : v;
437
- if (this._max !== max) {
438
- this._updateMax(max);
439
- }
440
- }
441
- _max = 100;
442
- _updateMax(max) {
443
- const prevMax = this._max;
444
- this._max = max;
445
- this._isRange ? this._updateMaxRange({ old: prevMax, new: max }) : this._updateMaxNonRange(max);
446
- this._onMinMaxOrStepChange();
447
- }
448
- _updateMaxRange(max) {
449
- const endInput = this._getInput(_MatThumb.END);
450
- const startInput = this._getInput(_MatThumb.START);
451
- const oldEndValue = endInput.value;
452
- const oldStartValue = startInput.value;
453
- endInput.max = max.new;
454
- startInput.max = Math.min(max.new, endInput.value);
455
- endInput.min = startInput.value;
456
- endInput._updateWidthInactive();
457
- startInput._updateWidthInactive();
458
- max.new > max.old
459
- ? this._onTranslateXChangeBySideEffect(startInput, endInput)
460
- : this._onTranslateXChangeBySideEffect(endInput, startInput);
461
- if (oldEndValue !== endInput.value) {
462
- this._onValueChange(endInput);
463
- }
464
- if (oldStartValue !== startInput.value) {
465
- this._onValueChange(startInput);
466
- }
467
- }
468
- _updateMaxNonRange(max) {
469
- const input = this._getInput(_MatThumb.END);
470
- if (input) {
471
- const oldValue = input.value;
472
- input.max = max;
473
- input._updateThumbUIByValue();
474
- this._updateTrackUI(input);
475
- if (oldValue !== input.value) {
476
- this._onValueChange(input);
477
- }
478
- }
479
- }
480
- /** The values at which the thumb will snap. */
481
- get step() {
482
- return this._step;
483
- }
484
- set step(v) {
485
- const step = isNaN(v) ? this._step : v;
486
- if (this._step !== step) {
487
- this._updateStep(step);
488
- }
489
- }
490
- _step = 1;
491
- _updateStep(step) {
492
- this._step = step;
493
- this._isRange ? this._updateStepRange() : this._updateStepNonRange();
494
- this._onMinMaxOrStepChange();
495
- }
496
- _updateStepRange() {
497
- const endInput = this._getInput(_MatThumb.END);
498
- const startInput = this._getInput(_MatThumb.START);
499
- const oldEndValue = endInput.value;
500
- const oldStartValue = startInput.value;
501
- const prevStartValue = startInput.value;
502
- endInput.min = this._min;
503
- startInput.max = this._max;
504
- endInput.step = this._step;
505
- startInput.step = this._step;
506
- if (this._platform.SAFARI) {
507
- endInput.value = endInput.value;
508
- startInput.value = startInput.value;
509
- }
510
- endInput.min = Math.max(this._min, startInput.value);
511
- startInput.max = Math.min(this._max, endInput.value);
512
- startInput._updateWidthInactive();
513
- endInput._updateWidthInactive();
514
- endInput.value < prevStartValue
515
- ? this._onTranslateXChangeBySideEffect(startInput, endInput)
516
- : this._onTranslateXChangeBySideEffect(endInput, startInput);
517
- if (oldEndValue !== endInput.value) {
518
- this._onValueChange(endInput);
519
- }
520
- if (oldStartValue !== startInput.value) {
521
- this._onValueChange(startInput);
522
- }
523
- }
524
- _updateStepNonRange() {
525
- const input = this._getInput(_MatThumb.END);
526
- if (input) {
527
- const oldValue = input.value;
528
- input.step = this._step;
529
- if (this._platform.SAFARI) {
530
- input.value = input.value;
531
- }
532
- input._updateThumbUIByValue();
533
- if (oldValue !== input.value) {
534
- this._onValueChange(input);
535
- }
536
- }
537
- }
538
- /**
539
- * Function that will be used to format the value before it is displayed
540
- * in the thumb label. Can be used to format very large number in order
541
- * for them to fit into the slider thumb.
542
- */
543
- displayWith = (value) => `${value}`;
544
- /** Used to keep track of & render the active & inactive tick marks on the slider track. */
545
- _tickMarks;
546
- /** Whether animations have been disabled. */
547
- _noopAnimations = _animationsDisabled();
548
- /** Subscription to changes to the directionality (LTR / RTL) context for the application. */
549
- _dirChangeSubscription;
550
- /** Observer used to monitor size changes in the slider. */
551
- _resizeObserver;
552
- // Stored dimensions to avoid calling getBoundingClientRect redundantly.
553
- _cachedWidth;
554
- _cachedLeft;
555
- _rippleRadius = 24;
556
- // The value indicator tooltip text for the visual slider thumb(s).
557
- /** @docs-private */
558
- startValueIndicatorText = '';
559
- /** @docs-private */
560
- endValueIndicatorText = '';
561
- // Used to control the translateX of the visual slider thumb(s).
562
- _endThumbTransform;
563
- _startThumbTransform;
564
- _isRange = false;
565
- /** Whether the slider is rtl. */
566
- _isRtl = false;
567
- _hasViewInitialized = false;
568
- /**
569
- * The width of the tick mark track.
570
- * The tick mark track width is different from full track width
571
- */
572
- _tickMarkTrackWidth = 0;
573
- _hasAnimation = false;
574
- _resizeTimer = null;
575
- _platform = inject(Platform);
576
- constructor() {
577
- inject(_CdkPrivateStyleLoader).load(_StructuralStylesLoader);
578
- if (this._dir) {
579
- this._dirChangeSubscription = this._dir.change.subscribe(() => this._onDirChange());
580
- this._isRtl = this._dir.value === 'rtl';
581
- }
582
- }
583
- /** The radius of the native slider's knob. AFAIK there is no way to avoid hardcoding this. */
584
- _knobRadius = 8;
585
- _inputPadding;
586
- ngAfterViewInit() {
587
- if (this._platform.isBrowser) {
588
- this._updateDimensions();
589
- }
590
- const eInput = this._getInput(_MatThumb.END);
591
- const sInput = this._getInput(_MatThumb.START);
592
- this._isRange = !!eInput && !!sInput;
593
- this._cdr.detectChanges();
594
- if (typeof ngDevMode === 'undefined' || ngDevMode) {
595
- _validateInputs(this._isRange, this._getInput(_MatThumb.END), this._getInput(_MatThumb.START));
596
- }
597
- const thumb = this._getThumb(_MatThumb.END);
598
- this._rippleRadius = thumb._ripple.radius;
599
- this._inputPadding = this._rippleRadius - this._knobRadius;
600
- this._isRange
601
- ? this._initUIRange(eInput, sInput)
602
- : this._initUINonRange(eInput);
603
- this._updateTrackUI(eInput);
604
- this._updateTickMarkUI();
605
- this._updateTickMarkTrackUI();
606
- this._observeHostResize();
607
- this._cdr.detectChanges();
608
- }
609
- _initUINonRange(eInput) {
610
- eInput.initProps();
611
- eInput.initUI();
612
- this._updateValueIndicatorUI(eInput);
613
- this._hasViewInitialized = true;
629
+ }
630
+ _isActive() {
631
+ return this._getThumb(_MatThumb.START)._isActive || this._getThumb(_MatThumb.END)._isActive;
632
+ }
633
+ _getValue(thumbPosition = _MatThumb.END) {
634
+ const input = this._getInput(thumbPosition);
635
+ if (!input) {
636
+ return this.min;
637
+ }
638
+ return input.value;
639
+ }
640
+ _skipUpdate() {
641
+ return !!(this._getInput(_MatThumb.START)?._skipUIUpdate || this._getInput(_MatThumb.END)?._skipUIUpdate);
642
+ }
643
+ _updateDimensions() {
644
+ this._cachedWidth = this._elementRef.nativeElement.offsetWidth;
645
+ this._cachedLeft = this._elementRef.nativeElement.getBoundingClientRect().left;
646
+ }
647
+ _setTrackActiveStyles(styles) {
648
+ const trackStyle = this._trackActive.nativeElement.style;
649
+ trackStyle.left = styles.left;
650
+ trackStyle.right = styles.right;
651
+ trackStyle.transformOrigin = styles.transformOrigin;
652
+ trackStyle.transform = styles.transform;
653
+ }
654
+ _calcTickMarkTransform(index) {
655
+ const offset = index * (this._tickMarkTrackWidth / (this._tickMarks.length - 1));
656
+ const translateX = this._isRtl ? this._cachedWidth - 6 - offset : offset;
657
+ return `translateX(${translateX}px`;
658
+ }
659
+ _onTranslateXChange(source) {
660
+ if (!this._hasViewInitialized) {
661
+ return;
662
+ }
663
+ this._updateThumbUI(source);
664
+ this._updateTrackUI(source);
665
+ this._updateOverlappingThumbUI(source);
666
+ }
667
+ _onTranslateXChangeBySideEffect(input1, input2) {
668
+ if (!this._hasViewInitialized) {
669
+ return;
670
+ }
671
+ input1._updateThumbUIByValue();
672
+ input2._updateThumbUIByValue();
673
+ }
674
+ _onValueChange(source) {
675
+ if (!this._hasViewInitialized) {
676
+ return;
677
+ }
678
+ this._updateValueIndicatorUI(source);
679
+ this._updateTickMarkUI();
680
+ this._cdr.detectChanges();
681
+ }
682
+ _onMinMaxOrStepChange() {
683
+ if (!this._hasViewInitialized) {
684
+ return;
685
+ }
686
+ this._updateTickMarkUI();
687
+ this._updateTickMarkTrackUI();
688
+ this._cdr.markForCheck();
689
+ }
690
+ _onResize() {
691
+ if (!this._hasViewInitialized) {
692
+ return;
693
+ }
694
+ this._updateDimensions();
695
+ if (this._isRange) {
696
+ const eInput = this._getInput(_MatThumb.END);
697
+ const sInput = this._getInput(_MatThumb.START);
698
+ eInput._updateThumbUIByValue();
699
+ sInput._updateThumbUIByValue();
700
+ eInput._updateStaticStyles();
701
+ sInput._updateStaticStyles();
702
+ eInput._updateMinMax();
703
+ sInput._updateMinMax();
704
+ eInput._updateWidthInactive();
705
+ sInput._updateWidthInactive();
706
+ } else {
707
+ const eInput = this._getInput(_MatThumb.END);
708
+ if (eInput) {
614
709
  eInput._updateThumbUIByValue();
615
- }
616
- _initUIRange(eInput, sInput) {
617
- eInput.initProps();
618
- eInput.initUI();
619
- sInput.initProps();
620
- sInput.initUI();
621
- eInput._updateMinMax();
622
- sInput._updateMinMax();
623
- eInput._updateStaticStyles();
624
- sInput._updateStaticStyles();
625
- this._updateValueIndicatorUIs();
626
- this._hasViewInitialized = true;
627
- eInput._updateThumbUIByValue();
628
- sInput._updateThumbUIByValue();
629
- }
630
- ngOnDestroy() {
631
- this._dirChangeSubscription.unsubscribe();
632
- this._resizeObserver?.disconnect();
633
- this._resizeObserver = null;
634
- }
635
- /** Handles updating the slider ui after a dir change. */
636
- _onDirChange() {
637
- this._isRtl = this._dir?.value === 'rtl';
638
- this._isRange ? this._onDirChangeRange() : this._onDirChangeNonRange();
639
- this._updateTickMarkUI();
640
- }
641
- _onDirChangeRange() {
642
- const endInput = this._getInput(_MatThumb.END);
643
- const startInput = this._getInput(_MatThumb.START);
644
- endInput._setIsLeftThumb();
645
- startInput._setIsLeftThumb();
646
- endInput.translateX = endInput._calcTranslateXByValue();
647
- startInput.translateX = startInput._calcTranslateXByValue();
648
- endInput._updateStaticStyles();
649
- startInput._updateStaticStyles();
650
- endInput._updateWidthInactive();
651
- startInput._updateWidthInactive();
652
- endInput._updateThumbUIByValue();
653
- startInput._updateThumbUIByValue();
654
- }
655
- _onDirChangeNonRange() {
656
- const input = this._getInput(_MatThumb.END);
657
- input._updateThumbUIByValue();
658
- }
659
- /** Starts observing and updating the slider if the host changes its size. */
660
- _observeHostResize() {
661
- if (typeof ResizeObserver === 'undefined' || !ResizeObserver) {
662
- return;
663
- }
664
- this._ngZone.runOutsideAngular(() => {
665
- this._resizeObserver = new ResizeObserver(() => {
666
- if (this._isActive()) {
667
- return;
668
- }
669
- if (this._resizeTimer) {
670
- clearTimeout(this._resizeTimer);
671
- }
672
- this._onResize();
673
- });
674
- this._resizeObserver.observe(this._elementRef.nativeElement);
675
- });
676
- }
677
- /** Whether any of the thumbs are currently active. */
678
- _isActive() {
679
- return this._getThumb(_MatThumb.START)._isActive || this._getThumb(_MatThumb.END)._isActive;
680
- }
681
- _getValue(thumbPosition = _MatThumb.END) {
682
- const input = this._getInput(thumbPosition);
683
- if (!input) {
684
- return this.min;
685
- }
686
- return input.value;
687
- }
688
- _skipUpdate() {
689
- return !!(this._getInput(_MatThumb.START)?._skipUIUpdate || this._getInput(_MatThumb.END)?._skipUIUpdate);
690
- }
691
- /** Stores the slider dimensions. */
692
- _updateDimensions() {
693
- this._cachedWidth = this._elementRef.nativeElement.offsetWidth;
694
- this._cachedLeft = this._elementRef.nativeElement.getBoundingClientRect().left;
695
- }
696
- /** Sets the styles for the active portion of the track. */
697
- _setTrackActiveStyles(styles) {
698
- const trackStyle = this._trackActive.nativeElement.style;
699
- trackStyle.left = styles.left;
700
- trackStyle.right = styles.right;
701
- trackStyle.transformOrigin = styles.transformOrigin;
702
- trackStyle.transform = styles.transform;
703
- }
704
- /** Returns the translateX positioning for a tick mark based on it's index. */
705
- _calcTickMarkTransform(index) {
706
- // TODO(wagnermaciel): See if we can avoid doing this and just using flex to position these.
707
- const offset = index * (this._tickMarkTrackWidth / (this._tickMarks.length - 1));
708
- const translateX = this._isRtl ? this._cachedWidth - 6 - offset : offset;
709
- return `translateX(${translateX}px`;
710
- }
711
- // Handlers for updating the slider ui.
712
- _onTranslateXChange(source) {
713
- if (!this._hasViewInitialized) {
714
- return;
715
- }
716
- this._updateThumbUI(source);
717
- this._updateTrackUI(source);
718
- this._updateOverlappingThumbUI(source);
719
- }
720
- _onTranslateXChangeBySideEffect(input1, input2) {
721
- if (!this._hasViewInitialized) {
722
- return;
723
- }
724
- input1._updateThumbUIByValue();
725
- input2._updateThumbUIByValue();
726
- }
727
- _onValueChange(source) {
728
- if (!this._hasViewInitialized) {
729
- return;
730
- }
731
- this._updateValueIndicatorUI(source);
732
- this._updateTickMarkUI();
733
- this._cdr.detectChanges();
734
- }
735
- _onMinMaxOrStepChange() {
736
- if (!this._hasViewInitialized) {
737
- return;
738
- }
739
- this._updateTickMarkUI();
740
- this._updateTickMarkTrackUI();
741
- this._cdr.markForCheck();
742
- }
743
- _onResize() {
744
- if (!this._hasViewInitialized) {
745
- return;
746
- }
747
- this._updateDimensions();
748
- if (this._isRange) {
749
- const eInput = this._getInput(_MatThumb.END);
750
- const sInput = this._getInput(_MatThumb.START);
751
- eInput._updateThumbUIByValue();
752
- sInput._updateThumbUIByValue();
753
- eInput._updateStaticStyles();
754
- sInput._updateStaticStyles();
755
- eInput._updateMinMax();
756
- sInput._updateMinMax();
757
- eInput._updateWidthInactive();
758
- sInput._updateWidthInactive();
759
- }
760
- else {
761
- const eInput = this._getInput(_MatThumb.END);
762
- if (eInput) {
763
- eInput._updateThumbUIByValue();
764
- }
765
- }
766
- this._updateTickMarkUI();
767
- this._updateTickMarkTrackUI();
768
- this._cdr.detectChanges();
769
- }
770
- /** Whether or not the slider thumbs overlap. */
771
- _thumbsOverlap = false;
772
- /** Returns true if the slider knobs are overlapping one another. */
773
- _areThumbsOverlapping() {
774
- const startInput = this._getInput(_MatThumb.START);
775
- const endInput = this._getInput(_MatThumb.END);
776
- if (!startInput || !endInput) {
777
- return false;
778
- }
779
- return endInput.translateX - startInput.translateX < 20;
780
- }
781
- /**
782
- * Updates the class names of overlapping slider thumbs so
783
- * that the current active thumb is styled to be on "top".
784
- */
785
- _updateOverlappingThumbClassNames(source) {
786
- const sibling = source.getSibling();
787
- const sourceThumb = this._getThumb(source.thumbPosition);
788
- const siblingThumb = this._getThumb(sibling.thumbPosition);
789
- siblingThumb._hostElement.classList.remove('mdc-slider__thumb--top');
790
- sourceThumb._hostElement.classList.toggle('mdc-slider__thumb--top', this._thumbsOverlap);
791
- }
792
- /** Updates the UI of slider thumbs when they begin or stop overlapping. */
793
- _updateOverlappingThumbUI(source) {
794
- if (!this._isRange || this._skipUpdate()) {
795
- return;
796
- }
797
- if (this._thumbsOverlap !== this._areThumbsOverlapping()) {
798
- this._thumbsOverlap = !this._thumbsOverlap;
799
- this._updateOverlappingThumbClassNames(source);
800
- }
801
- }
802
- // _MatThumb styles update conditions
803
- //
804
- // 1. TranslateX, resize, or dir change
805
- // - Reason: The thumb styles need to be updated according to the new translateX.
806
- // 2. Min, max, or step
807
- // - Reason: The value may have silently changed.
808
- /** Updates the translateX of the given thumb. */
809
- _updateThumbUI(source) {
810
- if (this._skipUpdate()) {
811
- return;
812
- }
813
- const thumb = this._getThumb(source.thumbPosition === _MatThumb.END ? _MatThumb.END : _MatThumb.START);
814
- thumb._hostElement.style.transform = `translateX(${source.translateX}px)`;
815
- }
816
- // Value indicator text update conditions
817
- //
818
- // 1. Value
819
- // - Reason: The value displayed needs to be updated.
820
- // 2. Min, max, or step
821
- // - Reason: The value may have silently changed.
822
- /** Updates the value indicator tooltip ui for the given thumb. */
823
- _updateValueIndicatorUI(source) {
824
- if (this._skipUpdate()) {
825
- return;
826
- }
827
- const valuetext = this.displayWith(source.value);
828
- this._hasViewInitialized
829
- ? source._valuetext.set(valuetext)
830
- : source._hostElement.setAttribute('aria-valuetext', valuetext);
831
- if (this.discrete) {
832
- source.thumbPosition === _MatThumb.START
833
- ? (this.startValueIndicatorText = valuetext)
834
- : (this.endValueIndicatorText = valuetext);
835
- const visualThumb = this._getThumb(source.thumbPosition);
836
- valuetext.length < 3
837
- ? visualThumb._hostElement.classList.add('mdc-slider__thumb--short-value')
838
- : visualThumb._hostElement.classList.remove('mdc-slider__thumb--short-value');
839
- }
840
- }
841
- /** Updates all value indicator UIs in the slider. */
842
- _updateValueIndicatorUIs() {
843
- const eInput = this._getInput(_MatThumb.END);
844
- const sInput = this._getInput(_MatThumb.START);
845
- if (eInput) {
846
- this._updateValueIndicatorUI(eInput);
847
- }
848
- if (sInput) {
849
- this._updateValueIndicatorUI(sInput);
850
- }
851
- }
852
- // Update Tick Mark Track Width
853
- //
854
- // 1. Min, max, or step
855
- // - Reason: The maximum reachable value may have changed.
856
- // - Side note: The maximum reachable value is different from the maximum value set by the
857
- // user. For example, a slider with [min: 5, max: 100, step: 10] would have a maximum
858
- // reachable value of 95.
859
- // 2. Resize
860
- // - Reason: The position for the maximum reachable value needs to be recalculated.
861
- /** Updates the width of the tick mark track. */
862
- _updateTickMarkTrackUI() {
863
- if (!this.showTickMarks || this._skipUpdate()) {
864
- return;
865
- }
866
- const step = this._step && this._step > 0 ? this._step : 1;
867
- const maxValue = Math.floor(this.max / step) * step;
868
- const percentage = (maxValue - this.min) / (this.max - this.min);
869
- this._tickMarkTrackWidth = (this._cachedWidth - 6) * percentage;
870
- }
871
- // Track active update conditions
872
- //
873
- // 1. TranslateX
874
- // - Reason: The track active should line up with the new thumb position.
875
- // 2. Min or max
876
- // - Reason #1: The 'active' percentage needs to be recalculated.
877
- // - Reason #2: The value may have silently changed.
878
- // 3. Step
879
- // - Reason: The value may have silently changed causing the thumb(s) to shift.
880
- // 4. Dir change
881
- // - Reason: The track active will need to be updated according to the new thumb position(s).
882
- // 5. Resize
883
- // - Reason: The total width the 'active' tracks translateX is based on has changed.
884
- /** Updates the scale on the active portion of the track. */
885
- _updateTrackUI(source) {
886
- if (this._skipUpdate()) {
887
- return;
888
- }
889
- this._isRange
890
- ? this._updateTrackUIRange(source)
891
- : this._updateTrackUINonRange(source);
892
- }
893
- _updateTrackUIRange(source) {
894
- const sibling = source.getSibling();
895
- if (!sibling || !this._cachedWidth) {
896
- return;
897
- }
898
- const activePercentage = Math.abs(sibling.translateX - source.translateX) / this._cachedWidth;
899
- if (source._isLeftThumb && this._cachedWidth) {
900
- this._setTrackActiveStyles({
901
- left: 'auto',
902
- right: `${this._cachedWidth - sibling.translateX}px`,
903
- transformOrigin: 'right',
904
- transform: `scaleX(${activePercentage})`,
905
- });
906
- }
907
- else {
908
- this._setTrackActiveStyles({
909
- left: `${sibling.translateX}px`,
910
- right: 'auto',
911
- transformOrigin: 'left',
912
- transform: `scaleX(${activePercentage})`,
913
- });
914
- }
915
- }
916
- _updateTrackUINonRange(source) {
917
- this._isRtl
918
- ? this._setTrackActiveStyles({
919
- left: 'auto',
920
- right: '0px',
921
- transformOrigin: 'right',
922
- transform: `scaleX(${1 - source.fillPercentage})`,
923
- })
924
- : this._setTrackActiveStyles({
925
- left: '0px',
926
- right: 'auto',
927
- transformOrigin: 'left',
928
- transform: `scaleX(${source.fillPercentage})`,
929
- });
930
- }
931
- // Tick mark update conditions
932
- //
933
- // 1. Value
934
- // - Reason: a tick mark which was once active might now be inactive or vice versa.
935
- // 2. Min, max, or step
936
- // - Reason #1: the number of tick marks may have changed.
937
- // - Reason #2: The value may have silently changed.
938
- /** Updates the dots along the slider track. */
939
- _updateTickMarkUI() {
940
- if (!this.showTickMarks ||
941
- this.step === undefined ||
942
- this.min === undefined ||
943
- this.max === undefined) {
944
- return;
945
- }
946
- const step = this.step > 0 ? this.step : 1;
947
- this._isRange ? this._updateTickMarkUIRange(step) : this._updateTickMarkUINonRange(step);
948
- }
949
- _updateTickMarkUINonRange(step) {
950
- const value = this._getValue();
951
- let numActive = Math.max(Math.round((value - this.min) / step), 0) + 1;
952
- let numInactive = Math.max(Math.round((this.max - value) / step), 0) - 1;
953
- this._isRtl ? numActive++ : numInactive++;
954
- this._tickMarks = Array(numActive)
955
- .fill(_MatTickMark.ACTIVE)
956
- .concat(Array(numInactive).fill(_MatTickMark.INACTIVE));
957
- }
958
- _updateTickMarkUIRange(step) {
959
- const endValue = this._getValue();
960
- const startValue = this._getValue(_MatThumb.START);
961
- const numInactiveBeforeStartThumb = Math.max(Math.round((startValue - this.min) / step), 0);
962
- const numActive = Math.max(Math.round((endValue - startValue) / step) + 1, 0);
963
- const numInactiveAfterEndThumb = Math.max(Math.round((this.max - endValue) / step), 0);
964
- this._tickMarks = Array(numInactiveBeforeStartThumb)
965
- .fill(_MatTickMark.INACTIVE)
966
- .concat(Array(numActive).fill(_MatTickMark.ACTIVE), Array(numInactiveAfterEndThumb).fill(_MatTickMark.INACTIVE));
967
- }
968
- /** Gets the slider thumb input of the given thumb position. */
969
- _getInput(thumbPosition) {
970
- if (thumbPosition === _MatThumb.END && this._input) {
971
- return this._input;
972
- }
973
- if (this._inputs?.length) {
974
- return thumbPosition === _MatThumb.START ? this._inputs.first : this._inputs.last;
975
- }
976
- return;
977
- }
978
- /** Gets the slider thumb HTML input element of the given thumb position. */
979
- _getThumb(thumbPosition) {
980
- return thumbPosition === _MatThumb.END ? this._thumbs?.last : this._thumbs?.first;
981
- }
982
- _setTransition(withAnimation) {
983
- this._hasAnimation = !this._platform.IOS && withAnimation && !this._noopAnimations;
984
- this._elementRef.nativeElement.classList.toggle('mat-mdc-slider-with-animation', this._hasAnimation);
985
- }
986
- /** Whether the given pointer event occurred within the bounds of the slider pointer's DOM Rect. */
987
- _isCursorOnSliderThumb(event, rect) {
988
- const radius = rect.width / 2;
989
- const centerX = rect.x + radius;
990
- const centerY = rect.y + radius;
991
- const dx = event.clientX - centerX;
992
- const dy = event.clientY - centerY;
993
- return Math.pow(dx, 2) + Math.pow(dy, 2) < Math.pow(radius, 2);
994
- }
995
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSlider, deps: [], target: i0.ɵɵFactoryTarget.Component });
996
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.2.0-next.2", type: MatSlider, isStandalone: true, selector: "mat-slider", inputs: { disabled: ["disabled", "disabled", booleanAttribute], discrete: ["discrete", "discrete", booleanAttribute], showTickMarks: ["showTickMarks", "showTickMarks", booleanAttribute], min: ["min", "min", numberAttribute], color: "color", disableRipple: ["disableRipple", "disableRipple", booleanAttribute], max: ["max", "max", numberAttribute], step: ["step", "step", numberAttribute], displayWith: "displayWith" }, host: { properties: { "class": "\"mat-\" + (color || \"primary\")", "class.mdc-slider--range": "_isRange", "class.mdc-slider--disabled": "disabled", "class.mdc-slider--discrete": "discrete", "class.mdc-slider--tick-marks": "showTickMarks", "class._mat-animation-noopable": "_noopAnimations" }, classAttribute: "mat-mdc-slider mdc-slider" }, providers: [{ provide: MAT_SLIDER, useExisting: MatSlider }], queries: [{ propertyName: "_input", first: true, predicate: MAT_SLIDER_THUMB, descendants: true }, { propertyName: "_inputs", predicate: MAT_SLIDER_RANGE_THUMB }], viewQueries: [{ propertyName: "_trackActive", first: true, predicate: ["trackActive"], descendants: true }, { propertyName: "_thumbs", predicate: MAT_SLIDER_VISUAL_THUMB, descendants: true }], exportAs: ["matSlider"], ngImport: i0, template: "<!-- Inputs -->\n<ng-content></ng-content>\n\n<!-- Track -->\n<div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\"></div>\n <div class=\"mdc-slider__track--active\">\n <div #trackActive class=\"mdc-slider__track--active_fill\"></div>\n </div>\n @if (showTickMarks) {\n <div class=\"mdc-slider__tick-marks\" #tickMarkContainer>\n @if (_cachedWidth) {\n @for (tickMark of _tickMarks; track i; let i = $index) {\n <div\n [class]=\"tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'\"\n [style.transform]=\"_calcTickMarkTransform(i)\"></div>\n }\n }\n </div>\n }\n</div>\n\n<!-- Thumbs -->\n@if (_isRange) {\n <mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"1\"\n [valueIndicatorText]=\"startValueIndicatorText\">\n </mat-slider-visual-thumb>\n}\n\n<mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"2\"\n [valueIndicatorText]=\"endValueIndicatorText\">\n</mat-slider-visual-thumb>\n", styles: [".mdc-slider__track{position:absolute;top:50%;transform:translateY(-50%);width:100%;pointer-events:none;height:var(--mat-slider-inactive-track-height, 4px)}.mdc-slider__track--active,.mdc-slider__track--inactive{display:flex;height:100%;position:absolute;width:100%}.mdc-slider__track--active{overflow:hidden;border-radius:var(--mat-slider-active-track-shape, var(--mat-sys-corner-full));height:var(--mat-slider-active-track-height, 4px);top:calc((var(--mat-slider-inactive-track-height, 4px) - var(--mat-slider-active-track-height, 4px))/2)}.mdc-slider__track--active_fill{border-top-style:solid;box-sizing:border-box;height:100%;width:100%;position:relative;transform-origin:left;transition:transform 80ms ease;border-color:var(--mat-slider-active-track-color, var(--mat-sys-primary));border-top-width:var(--mat-slider-active-track-height, 4px)}.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:var(--mat-slider-disabled-active-track-color, var(--mat-sys-on-surface))}[dir=rtl] .mdc-slider__track--active_fill{-webkit-transform-origin:right;transform-origin:right}.mdc-slider__track--inactive{left:0;top:0;opacity:.24;background-color:var(--mat-slider-inactive-track-color, var(--mat-sys-surface-variant));height:var(--mat-slider-inactive-track-height, 4px);border-radius:var(--mat-slider-inactive-track-shape, var(--mat-sys-corner-full))}.mdc-slider--disabled .mdc-slider__track--inactive{background-color:var(--mat-slider-disabled-inactive-track-color, var(--mat-sys-on-surface));opacity:.24}.mdc-slider__track--inactive::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__track--inactive::before{border-color:CanvasText}}.mdc-slider__value-indicator-container{bottom:44px;left:50%;pointer-events:none;position:absolute;transform:var(--mat-slider-value-indicator-container-transform, translateX(-50%) rotate(-45deg))}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator-container{pointer-events:auto}.mdc-slider__value-indicator{display:flex;align-items:center;transform:scale(0);transform-origin:var(--mat-slider-value-indicator-transform-origin, 0 28px);transition:transform 100ms cubic-bezier(0.4, 0, 1, 1);word-break:normal;background-color:var(--mat-slider-label-container-color, var(--mat-sys-primary));color:var(--mat-slider-label-label-text-color, var(--mat-sys-on-primary));width:var(--mat-slider-value-indicator-width, 28px);height:var(--mat-slider-value-indicator-height, 28px);padding:var(--mat-slider-value-indicator-padding, 0);opacity:var(--mat-slider-value-indicator-opacity, 1);border-radius:var(--mat-slider-value-indicator-border-radius, 50% 50% 50% 0)}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:transform 100ms cubic-bezier(0, 0, 0.2, 1);transform:scale(1)}.mdc-slider__value-indicator::before{border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);border-top:6px solid;bottom:-5px;content:\"\";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0;display:var(--mat-slider-value-indicator-caret-display, none);border-top-color:var(--mat-slider-label-container-color, var(--mat-sys-primary))}.mdc-slider__value-indicator::after{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__value-indicator::after{border-color:CanvasText}}.mdc-slider__value-indicator-text{text-align:center;width:var(--mat-slider-value-indicator-width, 28px);transform:var(--mat-slider-value-indicator-text-transform, rotate(45deg));font-family:var(--mat-slider-label-label-text-font, var(--mat-sys-label-medium-font));font-size:var(--mat-slider-label-label-text-size, var(--mat-sys-label-medium-size));font-weight:var(--mat-slider-label-label-text-weight, var(--mat-sys-label-medium-weight));line-height:var(--mat-slider-label-label-text-line-height, var(--mat-sys-label-medium-line-height));letter-spacing:var(--mat-slider-label-label-text-tracking, var(--mat-sys-label-medium-tracking))}.mdc-slider__thumb{-webkit-user-select:none;user-select:none;display:flex;left:-24px;outline:none;position:absolute;height:48px;width:48px;pointer-events:none}.mdc-slider--discrete .mdc-slider__thumb{transition:transform 80ms ease}.mdc-slider--disabled .mdc-slider__thumb{pointer-events:none}.mdc-slider__thumb--top{z-index:1}.mdc-slider__thumb-knob{position:absolute;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%, -50%);border-style:solid;width:var(--mat-slider-handle-width, 20px);height:var(--mat-slider-handle-height, 20px);border-width:calc(var(--mat-slider-handle-height, 20px)/2) calc(var(--mat-slider-handle-width, 20px)/2);box-shadow:var(--mat-slider-handle-elevation, var(--mat-sys-level1));background-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-radius:var(--mat-slider-handle-shape, var(--mat-sys-corner-full))}.mdc-slider__thumb:hover .mdc-slider__thumb-knob{background-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary))}.mdc-slider__thumb--focused .mdc-slider__thumb-knob{background-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary))}.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface));border-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface))}.mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border:solid 1px #fff;box-sizing:content-box;border-color:var(--mat-slider-with-overlap-handle-outline-color, var(--mat-sys-on-primary));border-width:var(--mat-slider-with-overlap-handle-outline-width, 1px)}.mdc-slider__tick-marks{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:space-between;padding:0 1px;position:absolute;width:100%}.mdc-slider__tick-mark--active,.mdc-slider__tick-mark--inactive{width:var(--mat-slider-with-tick-marks-container-size, 2px);height:var(--mat-slider-with-tick-marks-container-size, 2px);border-radius:var(--mat-slider-with-tick-marks-container-shape, var(--mat-sys-corner-full))}.mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-inactive-container-color, var(--mat-sys-on-surface-variant))}.mdc-slider--disabled .mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-disabled-container-color, var(--mat-sys-on-surface))}.mdc-slider__tick-mark--active{opacity:var(--mat-slider-with-tick-marks-active-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-active-container-color, var(--mat-sys-on-primary))}.mdc-slider__input{cursor:pointer;left:2px;margin:0;height:44px;opacity:0;position:absolute;top:2px;width:44px;box-sizing:content-box}.mdc-slider__input.mat-mdc-slider-input-no-pointer-events{pointer-events:none}.mdc-slider__input.mat-slider__right-input{left:auto;right:0}.mat-mdc-slider{display:inline-block;box-sizing:border-box;outline:none;vertical-align:middle;cursor:pointer;height:48px;margin:0 8px;position:relative;touch-action:pan-y;width:auto;min-width:112px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-mdc-slider.mdc-slider--disabled{cursor:auto;opacity:.38}.mat-mdc-slider.mdc-slider--disabled .mdc-slider__input{cursor:auto}.mat-mdc-slider .mdc-slider__thumb,.mat-mdc-slider .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider.mdc-slider--discrete .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider .mat-ripple .mat-ripple-element{background-color:var(--mat-slider-ripple-color, var(--mat-sys-primary))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-hover-ripple{background-color:var(--mat-slider-hover-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 5%, transparent))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-focus-ripple,.mat-mdc-slider .mat-ripple .mat-mdc-slider-active-ripple{background-color:var(--mat-slider-focus-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 20%, transparent))}.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__track--active_fill,.mat-mdc-slider._mat-animation-noopable .mdc-slider__value-indicator{transition:none}.mat-mdc-slider .mat-focus-indicator::before{border-radius:50%}.mdc-slider__thumb--focused .mat-focus-indicator::before{content:\"\"}\n"], dependencies: [{ kind: "component", type: MatSliderVisualThumb, selector: "mat-slider-visual-thumb", inputs: ["discrete", "thumbPosition", "valueIndicatorText"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
710
+ }
711
+ }
712
+ this._updateTickMarkUI();
713
+ this._updateTickMarkTrackUI();
714
+ this._cdr.detectChanges();
715
+ }
716
+ _thumbsOverlap = false;
717
+ _areThumbsOverlapping() {
718
+ const startInput = this._getInput(_MatThumb.START);
719
+ const endInput = this._getInput(_MatThumb.END);
720
+ if (!startInput || !endInput) {
721
+ return false;
722
+ }
723
+ return endInput.translateX - startInput.translateX < 20;
724
+ }
725
+ _updateOverlappingThumbClassNames(source) {
726
+ const sibling = source.getSibling();
727
+ const sourceThumb = this._getThumb(source.thumbPosition);
728
+ const siblingThumb = this._getThumb(sibling.thumbPosition);
729
+ siblingThumb._hostElement.classList.remove('mdc-slider__thumb--top');
730
+ sourceThumb._hostElement.classList.toggle('mdc-slider__thumb--top', this._thumbsOverlap);
731
+ }
732
+ _updateOverlappingThumbUI(source) {
733
+ if (!this._isRange || this._skipUpdate()) {
734
+ return;
735
+ }
736
+ if (this._thumbsOverlap !== this._areThumbsOverlapping()) {
737
+ this._thumbsOverlap = !this._thumbsOverlap;
738
+ this._updateOverlappingThumbClassNames(source);
739
+ }
740
+ }
741
+ _updateThumbUI(source) {
742
+ if (this._skipUpdate()) {
743
+ return;
744
+ }
745
+ const thumb = this._getThumb(source.thumbPosition === _MatThumb.END ? _MatThumb.END : _MatThumb.START);
746
+ thumb._hostElement.style.transform = `translateX(${source.translateX}px)`;
747
+ }
748
+ _updateValueIndicatorUI(source) {
749
+ if (this._skipUpdate()) {
750
+ return;
751
+ }
752
+ const valuetext = this.displayWith(source.value);
753
+ this._hasViewInitialized ? source._valuetext.set(valuetext) : source._hostElement.setAttribute('aria-valuetext', valuetext);
754
+ if (this.discrete) {
755
+ source.thumbPosition === _MatThumb.START ? this.startValueIndicatorText = valuetext : this.endValueIndicatorText = valuetext;
756
+ const visualThumb = this._getThumb(source.thumbPosition);
757
+ valuetext.length < 3 ? visualThumb._hostElement.classList.add('mdc-slider__thumb--short-value') : visualThumb._hostElement.classList.remove('mdc-slider__thumb--short-value');
758
+ }
759
+ }
760
+ _updateValueIndicatorUIs() {
761
+ const eInput = this._getInput(_MatThumb.END);
762
+ const sInput = this._getInput(_MatThumb.START);
763
+ if (eInput) {
764
+ this._updateValueIndicatorUI(eInput);
765
+ }
766
+ if (sInput) {
767
+ this._updateValueIndicatorUI(sInput);
768
+ }
769
+ }
770
+ _updateTickMarkTrackUI() {
771
+ if (!this.showTickMarks || this._skipUpdate()) {
772
+ return;
773
+ }
774
+ const step = this._step && this._step > 0 ? this._step : 1;
775
+ const maxValue = Math.floor(this.max / step) * step;
776
+ const percentage = (maxValue - this.min) / (this.max - this.min);
777
+ this._tickMarkTrackWidth = (this._cachedWidth - 6) * percentage;
778
+ }
779
+ _updateTrackUI(source) {
780
+ if (this._skipUpdate()) {
781
+ return;
782
+ }
783
+ this._isRange ? this._updateTrackUIRange(source) : this._updateTrackUINonRange(source);
784
+ }
785
+ _updateTrackUIRange(source) {
786
+ const sibling = source.getSibling();
787
+ if (!sibling || !this._cachedWidth) {
788
+ return;
789
+ }
790
+ const activePercentage = Math.abs(sibling.translateX - source.translateX) / this._cachedWidth;
791
+ if (source._isLeftThumb && this._cachedWidth) {
792
+ this._setTrackActiveStyles({
793
+ left: 'auto',
794
+ right: `${this._cachedWidth - sibling.translateX}px`,
795
+ transformOrigin: 'right',
796
+ transform: `scaleX(${activePercentage})`
797
+ });
798
+ } else {
799
+ this._setTrackActiveStyles({
800
+ left: `${sibling.translateX}px`,
801
+ right: 'auto',
802
+ transformOrigin: 'left',
803
+ transform: `scaleX(${activePercentage})`
804
+ });
805
+ }
806
+ }
807
+ _updateTrackUINonRange(source) {
808
+ this._isRtl ? this._setTrackActiveStyles({
809
+ left: 'auto',
810
+ right: '0px',
811
+ transformOrigin: 'right',
812
+ transform: `scaleX(${1 - source.fillPercentage})`
813
+ }) : this._setTrackActiveStyles({
814
+ left: '0px',
815
+ right: 'auto',
816
+ transformOrigin: 'left',
817
+ transform: `scaleX(${source.fillPercentage})`
818
+ });
819
+ }
820
+ _updateTickMarkUI() {
821
+ if (!this.showTickMarks || this.step === undefined || this.min === undefined || this.max === undefined) {
822
+ return;
823
+ }
824
+ const step = this.step > 0 ? this.step : 1;
825
+ this._isRange ? this._updateTickMarkUIRange(step) : this._updateTickMarkUINonRange(step);
826
+ }
827
+ _updateTickMarkUINonRange(step) {
828
+ const value = this._getValue();
829
+ let numActive = Math.max(Math.round((value - this.min) / step), 0) + 1;
830
+ let numInactive = Math.max(Math.round((this.max - value) / step), 0) - 1;
831
+ this._isRtl ? numActive++ : numInactive++;
832
+ this._tickMarks = Array(numActive).fill(_MatTickMark.ACTIVE).concat(Array(numInactive).fill(_MatTickMark.INACTIVE));
833
+ }
834
+ _updateTickMarkUIRange(step) {
835
+ const endValue = this._getValue();
836
+ const startValue = this._getValue(_MatThumb.START);
837
+ const numInactiveBeforeStartThumb = Math.max(Math.round((startValue - this.min) / step), 0);
838
+ const numActive = Math.max(Math.round((endValue - startValue) / step) + 1, 0);
839
+ const numInactiveAfterEndThumb = Math.max(Math.round((this.max - endValue) / step), 0);
840
+ this._tickMarks = Array(numInactiveBeforeStartThumb).fill(_MatTickMark.INACTIVE).concat(Array(numActive).fill(_MatTickMark.ACTIVE), Array(numInactiveAfterEndThumb).fill(_MatTickMark.INACTIVE));
841
+ }
842
+ _getInput(thumbPosition) {
843
+ if (thumbPosition === _MatThumb.END && this._input) {
844
+ return this._input;
845
+ }
846
+ if (this._inputs?.length) {
847
+ return thumbPosition === _MatThumb.START ? this._inputs.first : this._inputs.last;
848
+ }
849
+ return;
850
+ }
851
+ _getThumb(thumbPosition) {
852
+ return thumbPosition === _MatThumb.END ? this._thumbs?.last : this._thumbs?.first;
853
+ }
854
+ _setTransition(withAnimation) {
855
+ this._hasAnimation = !this._platform.IOS && withAnimation && !this._noopAnimations;
856
+ this._elementRef.nativeElement.classList.toggle('mat-mdc-slider-with-animation', this._hasAnimation);
857
+ }
858
+ _isCursorOnSliderThumb(event, rect) {
859
+ const radius = rect.width / 2;
860
+ const centerX = rect.x + radius;
861
+ const centerY = rect.y + radius;
862
+ const dx = event.clientX - centerX;
863
+ const dy = event.clientY - centerY;
864
+ return Math.pow(dx, 2) + Math.pow(dy, 2) < Math.pow(radius, 2);
865
+ }
866
+ static ɵfac = i0.ɵɵngDeclareFactory({
867
+ minVersion: "12.0.0",
868
+ version: "20.2.0-next.2",
869
+ ngImport: i0,
870
+ type: MatSlider,
871
+ deps: [],
872
+ target: i0.ɵɵFactoryTarget.Component
873
+ });
874
+ static ɵcmp = i0.ɵɵngDeclareComponent({
875
+ minVersion: "17.0.0",
876
+ version: "20.2.0-next.2",
877
+ type: MatSlider,
878
+ isStandalone: true,
879
+ selector: "mat-slider",
880
+ inputs: {
881
+ disabled: ["disabled", "disabled", booleanAttribute],
882
+ discrete: ["discrete", "discrete", booleanAttribute],
883
+ showTickMarks: ["showTickMarks", "showTickMarks", booleanAttribute],
884
+ min: ["min", "min", numberAttribute],
885
+ color: "color",
886
+ disableRipple: ["disableRipple", "disableRipple", booleanAttribute],
887
+ max: ["max", "max", numberAttribute],
888
+ step: ["step", "step", numberAttribute],
889
+ displayWith: "displayWith"
890
+ },
891
+ host: {
892
+ properties: {
893
+ "class": "\"mat-\" + (color || \"primary\")",
894
+ "class.mdc-slider--range": "_isRange",
895
+ "class.mdc-slider--disabled": "disabled",
896
+ "class.mdc-slider--discrete": "discrete",
897
+ "class.mdc-slider--tick-marks": "showTickMarks",
898
+ "class._mat-animation-noopable": "_noopAnimations"
899
+ },
900
+ classAttribute: "mat-mdc-slider mdc-slider"
901
+ },
902
+ providers: [{
903
+ provide: MAT_SLIDER,
904
+ useExisting: MatSlider
905
+ }],
906
+ queries: [{
907
+ propertyName: "_input",
908
+ first: true,
909
+ predicate: MAT_SLIDER_THUMB,
910
+ descendants: true
911
+ }, {
912
+ propertyName: "_inputs",
913
+ predicate: MAT_SLIDER_RANGE_THUMB
914
+ }],
915
+ viewQueries: [{
916
+ propertyName: "_trackActive",
917
+ first: true,
918
+ predicate: ["trackActive"],
919
+ descendants: true
920
+ }, {
921
+ propertyName: "_thumbs",
922
+ predicate: MAT_SLIDER_VISUAL_THUMB,
923
+ descendants: true
924
+ }],
925
+ exportAs: ["matSlider"],
926
+ ngImport: i0,
927
+ template: "<!-- Inputs -->\n<ng-content></ng-content>\n\n<!-- Track -->\n<div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\"></div>\n <div class=\"mdc-slider__track--active\">\n <div #trackActive class=\"mdc-slider__track--active_fill\"></div>\n </div>\n @if (showTickMarks) {\n <div class=\"mdc-slider__tick-marks\" #tickMarkContainer>\n @if (_cachedWidth) {\n @for (tickMark of _tickMarks; track i; let i = $index) {\n <div\n [class]=\"tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'\"\n [style.transform]=\"_calcTickMarkTransform(i)\"></div>\n }\n }\n </div>\n }\n</div>\n\n<!-- Thumbs -->\n@if (_isRange) {\n <mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"1\"\n [valueIndicatorText]=\"startValueIndicatorText\">\n </mat-slider-visual-thumb>\n}\n\n<mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"2\"\n [valueIndicatorText]=\"endValueIndicatorText\">\n</mat-slider-visual-thumb>\n",
928
+ styles: [".mdc-slider__track{position:absolute;top:50%;transform:translateY(-50%);width:100%;pointer-events:none;height:var(--mat-slider-inactive-track-height, 4px)}.mdc-slider__track--active,.mdc-slider__track--inactive{display:flex;height:100%;position:absolute;width:100%}.mdc-slider__track--active{overflow:hidden;border-radius:var(--mat-slider-active-track-shape, var(--mat-sys-corner-full));height:var(--mat-slider-active-track-height, 4px);top:calc((var(--mat-slider-inactive-track-height, 4px) - var(--mat-slider-active-track-height, 4px))/2)}.mdc-slider__track--active_fill{border-top-style:solid;box-sizing:border-box;height:100%;width:100%;position:relative;transform-origin:left;transition:transform 80ms ease;border-color:var(--mat-slider-active-track-color, var(--mat-sys-primary));border-top-width:var(--mat-slider-active-track-height, 4px)}.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:var(--mat-slider-disabled-active-track-color, var(--mat-sys-on-surface))}[dir=rtl] .mdc-slider__track--active_fill{-webkit-transform-origin:right;transform-origin:right}.mdc-slider__track--inactive{left:0;top:0;opacity:.24;background-color:var(--mat-slider-inactive-track-color, var(--mat-sys-surface-variant));height:var(--mat-slider-inactive-track-height, 4px);border-radius:var(--mat-slider-inactive-track-shape, var(--mat-sys-corner-full))}.mdc-slider--disabled .mdc-slider__track--inactive{background-color:var(--mat-slider-disabled-inactive-track-color, var(--mat-sys-on-surface));opacity:.24}.mdc-slider__track--inactive::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__track--inactive::before{border-color:CanvasText}}.mdc-slider__value-indicator-container{bottom:44px;left:50%;pointer-events:none;position:absolute;transform:var(--mat-slider-value-indicator-container-transform, translateX(-50%) rotate(-45deg))}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator-container{pointer-events:auto}.mdc-slider__value-indicator{display:flex;align-items:center;transform:scale(0);transform-origin:var(--mat-slider-value-indicator-transform-origin, 0 28px);transition:transform 100ms cubic-bezier(0.4, 0, 1, 1);word-break:normal;background-color:var(--mat-slider-label-container-color, var(--mat-sys-primary));color:var(--mat-slider-label-label-text-color, var(--mat-sys-on-primary));width:var(--mat-slider-value-indicator-width, 28px);height:var(--mat-slider-value-indicator-height, 28px);padding:var(--mat-slider-value-indicator-padding, 0);opacity:var(--mat-slider-value-indicator-opacity, 1);border-radius:var(--mat-slider-value-indicator-border-radius, 50% 50% 50% 0)}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:transform 100ms cubic-bezier(0, 0, 0.2, 1);transform:scale(1)}.mdc-slider__value-indicator::before{border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);border-top:6px solid;bottom:-5px;content:\"\";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0;display:var(--mat-slider-value-indicator-caret-display, none);border-top-color:var(--mat-slider-label-container-color, var(--mat-sys-primary))}.mdc-slider__value-indicator::after{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__value-indicator::after{border-color:CanvasText}}.mdc-slider__value-indicator-text{text-align:center;width:var(--mat-slider-value-indicator-width, 28px);transform:var(--mat-slider-value-indicator-text-transform, rotate(45deg));font-family:var(--mat-slider-label-label-text-font, var(--mat-sys-label-medium-font));font-size:var(--mat-slider-label-label-text-size, var(--mat-sys-label-medium-size));font-weight:var(--mat-slider-label-label-text-weight, var(--mat-sys-label-medium-weight));line-height:var(--mat-slider-label-label-text-line-height, var(--mat-sys-label-medium-line-height));letter-spacing:var(--mat-slider-label-label-text-tracking, var(--mat-sys-label-medium-tracking))}.mdc-slider__thumb{-webkit-user-select:none;user-select:none;display:flex;left:-24px;outline:none;position:absolute;height:48px;width:48px;pointer-events:none}.mdc-slider--discrete .mdc-slider__thumb{transition:transform 80ms ease}.mdc-slider--disabled .mdc-slider__thumb{pointer-events:none}.mdc-slider__thumb--top{z-index:1}.mdc-slider__thumb-knob{position:absolute;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%, -50%);border-style:solid;width:var(--mat-slider-handle-width, 20px);height:var(--mat-slider-handle-height, 20px);border-width:calc(var(--mat-slider-handle-height, 20px)/2) calc(var(--mat-slider-handle-width, 20px)/2);box-shadow:var(--mat-slider-handle-elevation, var(--mat-sys-level1));background-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-radius:var(--mat-slider-handle-shape, var(--mat-sys-corner-full))}.mdc-slider__thumb:hover .mdc-slider__thumb-knob{background-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary))}.mdc-slider__thumb--focused .mdc-slider__thumb-knob{background-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary))}.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface));border-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface))}.mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border:solid 1px #fff;box-sizing:content-box;border-color:var(--mat-slider-with-overlap-handle-outline-color, var(--mat-sys-on-primary));border-width:var(--mat-slider-with-overlap-handle-outline-width, 1px)}.mdc-slider__tick-marks{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:space-between;padding:0 1px;position:absolute;width:100%}.mdc-slider__tick-mark--active,.mdc-slider__tick-mark--inactive{width:var(--mat-slider-with-tick-marks-container-size, 2px);height:var(--mat-slider-with-tick-marks-container-size, 2px);border-radius:var(--mat-slider-with-tick-marks-container-shape, var(--mat-sys-corner-full))}.mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-inactive-container-color, var(--mat-sys-on-surface-variant))}.mdc-slider--disabled .mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-disabled-container-color, var(--mat-sys-on-surface))}.mdc-slider__tick-mark--active{opacity:var(--mat-slider-with-tick-marks-active-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-active-container-color, var(--mat-sys-on-primary))}.mdc-slider__input{cursor:pointer;left:2px;margin:0;height:44px;opacity:0;position:absolute;top:2px;width:44px;box-sizing:content-box}.mdc-slider__input.mat-mdc-slider-input-no-pointer-events{pointer-events:none}.mdc-slider__input.mat-slider__right-input{left:auto;right:0}.mat-mdc-slider{display:inline-block;box-sizing:border-box;outline:none;vertical-align:middle;cursor:pointer;height:48px;margin:0 8px;position:relative;touch-action:pan-y;width:auto;min-width:112px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-mdc-slider.mdc-slider--disabled{cursor:auto;opacity:.38}.mat-mdc-slider.mdc-slider--disabled .mdc-slider__input{cursor:auto}.mat-mdc-slider .mdc-slider__thumb,.mat-mdc-slider .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider.mdc-slider--discrete .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider .mat-ripple .mat-ripple-element{background-color:var(--mat-slider-ripple-color, var(--mat-sys-primary))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-hover-ripple{background-color:var(--mat-slider-hover-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 5%, transparent))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-focus-ripple,.mat-mdc-slider .mat-ripple .mat-mdc-slider-active-ripple{background-color:var(--mat-slider-focus-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 20%, transparent))}.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__track--active_fill,.mat-mdc-slider._mat-animation-noopable .mdc-slider__value-indicator{transition:none}.mat-mdc-slider .mat-focus-indicator::before{border-radius:50%}.mdc-slider__thumb--focused .mat-focus-indicator::before{content:\"\"}\n"],
929
+ dependencies: [{
930
+ kind: "component",
931
+ type: MatSliderVisualThumb,
932
+ selector: "mat-slider-visual-thumb",
933
+ inputs: ["discrete", "thumbPosition", "valueIndicatorText"]
934
+ }],
935
+ changeDetection: i0.ChangeDetectionStrategy.OnPush,
936
+ encapsulation: i0.ViewEncapsulation.None
937
+ });
997
938
  }
998
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSlider, decorators: [{
999
- type: Component,
1000
- args: [{ selector: 'mat-slider', host: {
1001
- 'class': 'mat-mdc-slider mdc-slider',
1002
- '[class]': '"mat-" + (color || "primary")',
1003
- '[class.mdc-slider--range]': '_isRange',
1004
- '[class.mdc-slider--disabled]': 'disabled',
1005
- '[class.mdc-slider--discrete]': 'discrete',
1006
- '[class.mdc-slider--tick-marks]': 'showTickMarks',
1007
- '[class._mat-animation-noopable]': '_noopAnimations',
1008
- }, exportAs: 'matSlider', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, providers: [{ provide: MAT_SLIDER, useExisting: MatSlider }], imports: [MatSliderVisualThumb], template: "<!-- Inputs -->\n<ng-content></ng-content>\n\n<!-- Track -->\n<div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\"></div>\n <div class=\"mdc-slider__track--active\">\n <div #trackActive class=\"mdc-slider__track--active_fill\"></div>\n </div>\n @if (showTickMarks) {\n <div class=\"mdc-slider__tick-marks\" #tickMarkContainer>\n @if (_cachedWidth) {\n @for (tickMark of _tickMarks; track i; let i = $index) {\n <div\n [class]=\"tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'\"\n [style.transform]=\"_calcTickMarkTransform(i)\"></div>\n }\n }\n </div>\n }\n</div>\n\n<!-- Thumbs -->\n@if (_isRange) {\n <mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"1\"\n [valueIndicatorText]=\"startValueIndicatorText\">\n </mat-slider-visual-thumb>\n}\n\n<mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"2\"\n [valueIndicatorText]=\"endValueIndicatorText\">\n</mat-slider-visual-thumb>\n", styles: [".mdc-slider__track{position:absolute;top:50%;transform:translateY(-50%);width:100%;pointer-events:none;height:var(--mat-slider-inactive-track-height, 4px)}.mdc-slider__track--active,.mdc-slider__track--inactive{display:flex;height:100%;position:absolute;width:100%}.mdc-slider__track--active{overflow:hidden;border-radius:var(--mat-slider-active-track-shape, var(--mat-sys-corner-full));height:var(--mat-slider-active-track-height, 4px);top:calc((var(--mat-slider-inactive-track-height, 4px) - var(--mat-slider-active-track-height, 4px))/2)}.mdc-slider__track--active_fill{border-top-style:solid;box-sizing:border-box;height:100%;width:100%;position:relative;transform-origin:left;transition:transform 80ms ease;border-color:var(--mat-slider-active-track-color, var(--mat-sys-primary));border-top-width:var(--mat-slider-active-track-height, 4px)}.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:var(--mat-slider-disabled-active-track-color, var(--mat-sys-on-surface))}[dir=rtl] .mdc-slider__track--active_fill{-webkit-transform-origin:right;transform-origin:right}.mdc-slider__track--inactive{left:0;top:0;opacity:.24;background-color:var(--mat-slider-inactive-track-color, var(--mat-sys-surface-variant));height:var(--mat-slider-inactive-track-height, 4px);border-radius:var(--mat-slider-inactive-track-shape, var(--mat-sys-corner-full))}.mdc-slider--disabled .mdc-slider__track--inactive{background-color:var(--mat-slider-disabled-inactive-track-color, var(--mat-sys-on-surface));opacity:.24}.mdc-slider__track--inactive::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__track--inactive::before{border-color:CanvasText}}.mdc-slider__value-indicator-container{bottom:44px;left:50%;pointer-events:none;position:absolute;transform:var(--mat-slider-value-indicator-container-transform, translateX(-50%) rotate(-45deg))}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator-container{pointer-events:auto}.mdc-slider__value-indicator{display:flex;align-items:center;transform:scale(0);transform-origin:var(--mat-slider-value-indicator-transform-origin, 0 28px);transition:transform 100ms cubic-bezier(0.4, 0, 1, 1);word-break:normal;background-color:var(--mat-slider-label-container-color, var(--mat-sys-primary));color:var(--mat-slider-label-label-text-color, var(--mat-sys-on-primary));width:var(--mat-slider-value-indicator-width, 28px);height:var(--mat-slider-value-indicator-height, 28px);padding:var(--mat-slider-value-indicator-padding, 0);opacity:var(--mat-slider-value-indicator-opacity, 1);border-radius:var(--mat-slider-value-indicator-border-radius, 50% 50% 50% 0)}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:transform 100ms cubic-bezier(0, 0, 0.2, 1);transform:scale(1)}.mdc-slider__value-indicator::before{border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);border-top:6px solid;bottom:-5px;content:\"\";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0;display:var(--mat-slider-value-indicator-caret-display, none);border-top-color:var(--mat-slider-label-container-color, var(--mat-sys-primary))}.mdc-slider__value-indicator::after{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__value-indicator::after{border-color:CanvasText}}.mdc-slider__value-indicator-text{text-align:center;width:var(--mat-slider-value-indicator-width, 28px);transform:var(--mat-slider-value-indicator-text-transform, rotate(45deg));font-family:var(--mat-slider-label-label-text-font, var(--mat-sys-label-medium-font));font-size:var(--mat-slider-label-label-text-size, var(--mat-sys-label-medium-size));font-weight:var(--mat-slider-label-label-text-weight, var(--mat-sys-label-medium-weight));line-height:var(--mat-slider-label-label-text-line-height, var(--mat-sys-label-medium-line-height));letter-spacing:var(--mat-slider-label-label-text-tracking, var(--mat-sys-label-medium-tracking))}.mdc-slider__thumb{-webkit-user-select:none;user-select:none;display:flex;left:-24px;outline:none;position:absolute;height:48px;width:48px;pointer-events:none}.mdc-slider--discrete .mdc-slider__thumb{transition:transform 80ms ease}.mdc-slider--disabled .mdc-slider__thumb{pointer-events:none}.mdc-slider__thumb--top{z-index:1}.mdc-slider__thumb-knob{position:absolute;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%, -50%);border-style:solid;width:var(--mat-slider-handle-width, 20px);height:var(--mat-slider-handle-height, 20px);border-width:calc(var(--mat-slider-handle-height, 20px)/2) calc(var(--mat-slider-handle-width, 20px)/2);box-shadow:var(--mat-slider-handle-elevation, var(--mat-sys-level1));background-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-radius:var(--mat-slider-handle-shape, var(--mat-sys-corner-full))}.mdc-slider__thumb:hover .mdc-slider__thumb-knob{background-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary))}.mdc-slider__thumb--focused .mdc-slider__thumb-knob{background-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary))}.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface));border-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface))}.mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border:solid 1px #fff;box-sizing:content-box;border-color:var(--mat-slider-with-overlap-handle-outline-color, var(--mat-sys-on-primary));border-width:var(--mat-slider-with-overlap-handle-outline-width, 1px)}.mdc-slider__tick-marks{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:space-between;padding:0 1px;position:absolute;width:100%}.mdc-slider__tick-mark--active,.mdc-slider__tick-mark--inactive{width:var(--mat-slider-with-tick-marks-container-size, 2px);height:var(--mat-slider-with-tick-marks-container-size, 2px);border-radius:var(--mat-slider-with-tick-marks-container-shape, var(--mat-sys-corner-full))}.mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-inactive-container-color, var(--mat-sys-on-surface-variant))}.mdc-slider--disabled .mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-disabled-container-color, var(--mat-sys-on-surface))}.mdc-slider__tick-mark--active{opacity:var(--mat-slider-with-tick-marks-active-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-active-container-color, var(--mat-sys-on-primary))}.mdc-slider__input{cursor:pointer;left:2px;margin:0;height:44px;opacity:0;position:absolute;top:2px;width:44px;box-sizing:content-box}.mdc-slider__input.mat-mdc-slider-input-no-pointer-events{pointer-events:none}.mdc-slider__input.mat-slider__right-input{left:auto;right:0}.mat-mdc-slider{display:inline-block;box-sizing:border-box;outline:none;vertical-align:middle;cursor:pointer;height:48px;margin:0 8px;position:relative;touch-action:pan-y;width:auto;min-width:112px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-mdc-slider.mdc-slider--disabled{cursor:auto;opacity:.38}.mat-mdc-slider.mdc-slider--disabled .mdc-slider__input{cursor:auto}.mat-mdc-slider .mdc-slider__thumb,.mat-mdc-slider .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider.mdc-slider--discrete .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider .mat-ripple .mat-ripple-element{background-color:var(--mat-slider-ripple-color, var(--mat-sys-primary))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-hover-ripple{background-color:var(--mat-slider-hover-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 5%, transparent))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-focus-ripple,.mat-mdc-slider .mat-ripple .mat-mdc-slider-active-ripple{background-color:var(--mat-slider-focus-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 20%, transparent))}.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__track--active_fill,.mat-mdc-slider._mat-animation-noopable .mdc-slider__value-indicator{transition:none}.mat-mdc-slider .mat-focus-indicator::before{border-radius:50%}.mdc-slider__thumb--focused .mat-focus-indicator::before{content:\"\"}\n"] }]
1009
- }], ctorParameters: () => [], propDecorators: { _trackActive: [{
1010
- type: ViewChild,
1011
- args: ['trackActive']
1012
- }], _thumbs: [{
1013
- type: ViewChildren,
1014
- args: [MAT_SLIDER_VISUAL_THUMB]
1015
- }], _input: [{
1016
- type: ContentChild,
1017
- args: [MAT_SLIDER_THUMB]
1018
- }], _inputs: [{
1019
- type: ContentChildren,
1020
- args: [MAT_SLIDER_RANGE_THUMB, { descendants: false }]
1021
- }], disabled: [{
1022
- type: Input,
1023
- args: [{ transform: booleanAttribute }]
1024
- }], discrete: [{
1025
- type: Input,
1026
- args: [{ transform: booleanAttribute }]
1027
- }], showTickMarks: [{
1028
- type: Input,
1029
- args: [{ transform: booleanAttribute }]
1030
- }], min: [{
1031
- type: Input,
1032
- args: [{ transform: numberAttribute }]
1033
- }], color: [{
1034
- type: Input
1035
- }], disableRipple: [{
1036
- type: Input,
1037
- args: [{ transform: booleanAttribute }]
1038
- }], max: [{
1039
- type: Input,
1040
- args: [{ transform: numberAttribute }]
1041
- }], step: [{
1042
- type: Input,
1043
- args: [{ transform: numberAttribute }]
1044
- }], displayWith: [{
1045
- type: Input
1046
- }] } });
1047
- /** Ensures that there is not an invalid configuration for the slider thumb inputs. */
939
+ i0.ɵɵngDeclareClassMetadata({
940
+ minVersion: "12.0.0",
941
+ version: "20.2.0-next.2",
942
+ ngImport: i0,
943
+ type: MatSlider,
944
+ decorators: [{
945
+ type: Component,
946
+ args: [{
947
+ selector: 'mat-slider',
948
+ host: {
949
+ 'class': 'mat-mdc-slider mdc-slider',
950
+ '[class]': '"mat-" + (color || "primary")',
951
+ '[class.mdc-slider--range]': '_isRange',
952
+ '[class.mdc-slider--disabled]': 'disabled',
953
+ '[class.mdc-slider--discrete]': 'discrete',
954
+ '[class.mdc-slider--tick-marks]': 'showTickMarks',
955
+ '[class._mat-animation-noopable]': '_noopAnimations'
956
+ },
957
+ exportAs: 'matSlider',
958
+ changeDetection: ChangeDetectionStrategy.OnPush,
959
+ encapsulation: ViewEncapsulation.None,
960
+ providers: [{
961
+ provide: MAT_SLIDER,
962
+ useExisting: MatSlider
963
+ }],
964
+ imports: [MatSliderVisualThumb],
965
+ template: "<!-- Inputs -->\n<ng-content></ng-content>\n\n<!-- Track -->\n<div class=\"mdc-slider__track\">\n <div class=\"mdc-slider__track--inactive\"></div>\n <div class=\"mdc-slider__track--active\">\n <div #trackActive class=\"mdc-slider__track--active_fill\"></div>\n </div>\n @if (showTickMarks) {\n <div class=\"mdc-slider__tick-marks\" #tickMarkContainer>\n @if (_cachedWidth) {\n @for (tickMark of _tickMarks; track i; let i = $index) {\n <div\n [class]=\"tickMark === 0 ? 'mdc-slider__tick-mark--active' : 'mdc-slider__tick-mark--inactive'\"\n [style.transform]=\"_calcTickMarkTransform(i)\"></div>\n }\n }\n </div>\n }\n</div>\n\n<!-- Thumbs -->\n@if (_isRange) {\n <mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"1\"\n [valueIndicatorText]=\"startValueIndicatorText\">\n </mat-slider-visual-thumb>\n}\n\n<mat-slider-visual-thumb\n [discrete]=\"discrete\"\n [thumbPosition]=\"2\"\n [valueIndicatorText]=\"endValueIndicatorText\">\n</mat-slider-visual-thumb>\n",
966
+ styles: [".mdc-slider__track{position:absolute;top:50%;transform:translateY(-50%);width:100%;pointer-events:none;height:var(--mat-slider-inactive-track-height, 4px)}.mdc-slider__track--active,.mdc-slider__track--inactive{display:flex;height:100%;position:absolute;width:100%}.mdc-slider__track--active{overflow:hidden;border-radius:var(--mat-slider-active-track-shape, var(--mat-sys-corner-full));height:var(--mat-slider-active-track-height, 4px);top:calc((var(--mat-slider-inactive-track-height, 4px) - var(--mat-slider-active-track-height, 4px))/2)}.mdc-slider__track--active_fill{border-top-style:solid;box-sizing:border-box;height:100%;width:100%;position:relative;transform-origin:left;transition:transform 80ms ease;border-color:var(--mat-slider-active-track-color, var(--mat-sys-primary));border-top-width:var(--mat-slider-active-track-height, 4px)}.mdc-slider--disabled .mdc-slider__track--active_fill{border-color:var(--mat-slider-disabled-active-track-color, var(--mat-sys-on-surface))}[dir=rtl] .mdc-slider__track--active_fill{-webkit-transform-origin:right;transform-origin:right}.mdc-slider__track--inactive{left:0;top:0;opacity:.24;background-color:var(--mat-slider-inactive-track-color, var(--mat-sys-surface-variant));height:var(--mat-slider-inactive-track-height, 4px);border-radius:var(--mat-slider-inactive-track-shape, var(--mat-sys-corner-full))}.mdc-slider--disabled .mdc-slider__track--inactive{background-color:var(--mat-slider-disabled-inactive-track-color, var(--mat-sys-on-surface));opacity:.24}.mdc-slider__track--inactive::before{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__track--inactive::before{border-color:CanvasText}}.mdc-slider__value-indicator-container{bottom:44px;left:50%;pointer-events:none;position:absolute;transform:var(--mat-slider-value-indicator-container-transform, translateX(-50%) rotate(-45deg))}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator-container{pointer-events:auto}.mdc-slider__value-indicator{display:flex;align-items:center;transform:scale(0);transform-origin:var(--mat-slider-value-indicator-transform-origin, 0 28px);transition:transform 100ms cubic-bezier(0.4, 0, 1, 1);word-break:normal;background-color:var(--mat-slider-label-container-color, var(--mat-sys-primary));color:var(--mat-slider-label-label-text-color, var(--mat-sys-on-primary));width:var(--mat-slider-value-indicator-width, 28px);height:var(--mat-slider-value-indicator-height, 28px);padding:var(--mat-slider-value-indicator-padding, 0);opacity:var(--mat-slider-value-indicator-opacity, 1);border-radius:var(--mat-slider-value-indicator-border-radius, 50% 50% 50% 0)}.mdc-slider__thumb--with-indicator .mdc-slider__value-indicator{transition:transform 100ms cubic-bezier(0, 0, 0.2, 1);transform:scale(1)}.mdc-slider__value-indicator::before{border-left:6px solid rgba(0,0,0,0);border-right:6px solid rgba(0,0,0,0);border-top:6px solid;bottom:-5px;content:\"\";height:0;left:50%;position:absolute;transform:translateX(-50%);width:0;display:var(--mat-slider-value-indicator-caret-display, none);border-top-color:var(--mat-slider-label-container-color, var(--mat-sys-primary))}.mdc-slider__value-indicator::after{position:absolute;box-sizing:border-box;width:100%;height:100%;top:0;left:0;border:1px solid rgba(0,0,0,0);border-radius:inherit;content:\"\";pointer-events:none}@media(forced-colors: active){.mdc-slider__value-indicator::after{border-color:CanvasText}}.mdc-slider__value-indicator-text{text-align:center;width:var(--mat-slider-value-indicator-width, 28px);transform:var(--mat-slider-value-indicator-text-transform, rotate(45deg));font-family:var(--mat-slider-label-label-text-font, var(--mat-sys-label-medium-font));font-size:var(--mat-slider-label-label-text-size, var(--mat-sys-label-medium-size));font-weight:var(--mat-slider-label-label-text-weight, var(--mat-sys-label-medium-weight));line-height:var(--mat-slider-label-label-text-line-height, var(--mat-sys-label-medium-line-height));letter-spacing:var(--mat-slider-label-label-text-tracking, var(--mat-sys-label-medium-tracking))}.mdc-slider__thumb{-webkit-user-select:none;user-select:none;display:flex;left:-24px;outline:none;position:absolute;height:48px;width:48px;pointer-events:none}.mdc-slider--discrete .mdc-slider__thumb{transition:transform 80ms ease}.mdc-slider--disabled .mdc-slider__thumb{pointer-events:none}.mdc-slider__thumb--top{z-index:1}.mdc-slider__thumb-knob{position:absolute;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%, -50%);border-style:solid;width:var(--mat-slider-handle-width, 20px);height:var(--mat-slider-handle-height, 20px);border-width:calc(var(--mat-slider-handle-height, 20px)/2) calc(var(--mat-slider-handle-width, 20px)/2);box-shadow:var(--mat-slider-handle-elevation, var(--mat-sys-level1));background-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-handle-color, var(--mat-sys-primary));border-radius:var(--mat-slider-handle-shape, var(--mat-sys-corner-full))}.mdc-slider__thumb:hover .mdc-slider__thumb-knob{background-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-hover-handle-color, var(--mat-sys-primary))}.mdc-slider__thumb--focused .mdc-slider__thumb-knob{background-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary));border-color:var(--mat-slider-focus-handle-color, var(--mat-sys-primary))}.mdc-slider--disabled .mdc-slider__thumb-knob{background-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface));border-color:var(--mat-slider-disabled-handle-color, var(--mat-sys-on-surface))}.mdc-slider__thumb--top .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb:hover .mdc-slider__thumb-knob,.mdc-slider__thumb--top.mdc-slider__thumb--focused .mdc-slider__thumb-knob{border:solid 1px #fff;box-sizing:content-box;border-color:var(--mat-slider-with-overlap-handle-outline-color, var(--mat-sys-on-primary));border-width:var(--mat-slider-with-overlap-handle-outline-width, 1px)}.mdc-slider__tick-marks{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:space-between;padding:0 1px;position:absolute;width:100%}.mdc-slider__tick-mark--active,.mdc-slider__tick-mark--inactive{width:var(--mat-slider-with-tick-marks-container-size, 2px);height:var(--mat-slider-with-tick-marks-container-size, 2px);border-radius:var(--mat-slider-with-tick-marks-container-shape, var(--mat-sys-corner-full))}.mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-inactive-container-color, var(--mat-sys-on-surface-variant))}.mdc-slider--disabled .mdc-slider__tick-mark--inactive{opacity:var(--mat-slider-with-tick-marks-inactive-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-disabled-container-color, var(--mat-sys-on-surface))}.mdc-slider__tick-mark--active{opacity:var(--mat-slider-with-tick-marks-active-container-opacity, 0.38);background-color:var(--mat-slider-with-tick-marks-active-container-color, var(--mat-sys-on-primary))}.mdc-slider__input{cursor:pointer;left:2px;margin:0;height:44px;opacity:0;position:absolute;top:2px;width:44px;box-sizing:content-box}.mdc-slider__input.mat-mdc-slider-input-no-pointer-events{pointer-events:none}.mdc-slider__input.mat-slider__right-input{left:auto;right:0}.mat-mdc-slider{display:inline-block;box-sizing:border-box;outline:none;vertical-align:middle;cursor:pointer;height:48px;margin:0 8px;position:relative;touch-action:pan-y;width:auto;min-width:112px;-webkit-tap-highlight-color:rgba(0,0,0,0)}.mat-mdc-slider.mdc-slider--disabled{cursor:auto;opacity:.38}.mat-mdc-slider.mdc-slider--disabled .mdc-slider__input{cursor:auto}.mat-mdc-slider .mdc-slider__thumb,.mat-mdc-slider .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider.mdc-slider--discrete .mdc-slider__track--active_fill{transition-duration:0ms}.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__thumb,.mat-mdc-slider.mat-mdc-slider-with-animation .mdc-slider__track--active_fill{transition-duration:80ms}.mat-mdc-slider .mat-ripple .mat-ripple-element{background-color:var(--mat-slider-ripple-color, var(--mat-sys-primary))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-hover-ripple{background-color:var(--mat-slider-hover-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 5%, transparent))}.mat-mdc-slider .mat-ripple .mat-mdc-slider-focus-ripple,.mat-mdc-slider .mat-ripple .mat-mdc-slider-active-ripple{background-color:var(--mat-slider-focus-state-layer-color, color-mix(in srgb, var(--mat-sys-primary) 20%, transparent))}.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__thumb,.mat-mdc-slider._mat-animation-noopable.mdc-slider--discrete .mdc-slider__track--active_fill,.mat-mdc-slider._mat-animation-noopable .mdc-slider__value-indicator{transition:none}.mat-mdc-slider .mat-focus-indicator::before{border-radius:50%}.mdc-slider__thumb--focused .mat-focus-indicator::before{content:\"\"}\n"]
967
+ }]
968
+ }],
969
+ ctorParameters: () => [],
970
+ propDecorators: {
971
+ _trackActive: [{
972
+ type: ViewChild,
973
+ args: ['trackActive']
974
+ }],
975
+ _thumbs: [{
976
+ type: ViewChildren,
977
+ args: [MAT_SLIDER_VISUAL_THUMB]
978
+ }],
979
+ _input: [{
980
+ type: ContentChild,
981
+ args: [MAT_SLIDER_THUMB]
982
+ }],
983
+ _inputs: [{
984
+ type: ContentChildren,
985
+ args: [MAT_SLIDER_RANGE_THUMB, {
986
+ descendants: false
987
+ }]
988
+ }],
989
+ disabled: [{
990
+ type: Input,
991
+ args: [{
992
+ transform: booleanAttribute
993
+ }]
994
+ }],
995
+ discrete: [{
996
+ type: Input,
997
+ args: [{
998
+ transform: booleanAttribute
999
+ }]
1000
+ }],
1001
+ showTickMarks: [{
1002
+ type: Input,
1003
+ args: [{
1004
+ transform: booleanAttribute
1005
+ }]
1006
+ }],
1007
+ min: [{
1008
+ type: Input,
1009
+ args: [{
1010
+ transform: numberAttribute
1011
+ }]
1012
+ }],
1013
+ color: [{
1014
+ type: Input
1015
+ }],
1016
+ disableRipple: [{
1017
+ type: Input,
1018
+ args: [{
1019
+ transform: booleanAttribute
1020
+ }]
1021
+ }],
1022
+ max: [{
1023
+ type: Input,
1024
+ args: [{
1025
+ transform: numberAttribute
1026
+ }]
1027
+ }],
1028
+ step: [{
1029
+ type: Input,
1030
+ args: [{
1031
+ transform: numberAttribute
1032
+ }]
1033
+ }],
1034
+ displayWith: [{
1035
+ type: Input
1036
+ }]
1037
+ }
1038
+ });
1048
1039
  function _validateInputs(isRange, endInputElement, startInputElement) {
1049
- const startValid = !isRange || startInputElement?._hostElement.hasAttribute('matSliderStartThumb');
1050
- const endValid = endInputElement?._hostElement.hasAttribute(isRange ? 'matSliderEndThumb' : 'matSliderThumb');
1051
- if (!startValid || !endValid) {
1052
- _throwInvalidInputConfigurationError();
1053
- }
1040
+ const startValid = !isRange || startInputElement?._hostElement.hasAttribute('matSliderStartThumb');
1041
+ const endValid = endInputElement?._hostElement.hasAttribute(isRange ? 'matSliderEndThumb' : 'matSliderThumb');
1042
+ if (!startValid || !endValid) {
1043
+ _throwInvalidInputConfigurationError();
1044
+ }
1054
1045
  }
1055
1046
  function _throwInvalidInputConfigurationError() {
1056
- throw Error(`Invalid slider thumb input configuration!
1047
+ throw Error(`Invalid slider thumb input configuration!
1057
1048
 
1058
1049
  Valid configurations are as follows:
1059
1050
 
@@ -1070,716 +1061,660 @@ function _throwInvalidInputConfigurationError() {
1070
1061
  `);
1071
1062
  }
1072
1063
 
1073
- /**
1074
- * Provider that allows the slider thumb to register as a ControlValueAccessor.
1075
- * @docs-private
1076
- */
1077
1064
  const MAT_SLIDER_THUMB_VALUE_ACCESSOR = {
1078
- provide: NG_VALUE_ACCESSOR,
1079
- useExisting: forwardRef(() => MatSliderThumb),
1080
- multi: true,
1065
+ provide: NG_VALUE_ACCESSOR,
1066
+ useExisting: forwardRef(() => MatSliderThumb),
1067
+ multi: true
1081
1068
  };
1082
- /**
1083
- * Provider that allows the range slider thumb to register as a ControlValueAccessor.
1084
- * @docs-private
1085
- */
1086
1069
  const MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR = {
1087
- provide: NG_VALUE_ACCESSOR,
1088
- useExisting: forwardRef(() => MatSliderRangeThumb),
1089
- multi: true,
1070
+ provide: NG_VALUE_ACCESSOR,
1071
+ useExisting: forwardRef(() => MatSliderRangeThumb),
1072
+ multi: true
1090
1073
  };
1091
- /**
1092
- * Directive that adds slider-specific behaviors to an input element inside `<mat-slider>`.
1093
- * Up to two may be placed inside of a `<mat-slider>`.
1094
- *
1095
- * If one is used, the selector `matSliderThumb` must be used, and the outcome will be a normal
1096
- * slider. If two are used, the selectors `matSliderStartThumb` and `matSliderEndThumb` must be
1097
- * used, and the outcome will be a range slider with two slider thumbs.
1098
- */
1099
1074
  class MatSliderThumb {
1100
- _ngZone = inject(NgZone);
1101
- _elementRef = inject(ElementRef);
1102
- _cdr = inject(ChangeDetectorRef);
1103
- _slider = inject(MAT_SLIDER);
1104
- _platform = inject(Platform);
1105
- _listenerCleanups;
1106
- get value() {
1107
- return numberAttribute(this._hostElement.value, 0);
1108
- }
1109
- set value(value) {
1110
- if (value === null) {
1111
- value = this._getDefaultValue();
1112
- }
1113
- value = isNaN(value) ? 0 : value;
1114
- const stringValue = value + '';
1115
- if (!this._hasSetInitialValue) {
1116
- this._initialValue = stringValue;
1117
- return;
1118
- }
1119
- if (this._isActive) {
1120
- return;
1121
- }
1122
- this._setValue(stringValue);
1123
- }
1124
- /**
1125
- * Handles programmatic value setting. This has been split out to
1126
- * allow the range thumb to override it and add additional necessary logic.
1127
- */
1128
- _setValue(value) {
1129
- this._hostElement.value = value;
1130
- this._updateThumbUIByValue();
1131
- this._slider._onValueChange(this);
1132
- this._cdr.detectChanges();
1133
- this._slider._cdr.markForCheck();
1134
- }
1135
- /** Event emitted when the `value` is changed. */
1136
- valueChange = new EventEmitter();
1137
- /** Event emitted when the slider thumb starts being dragged. */
1138
- dragStart = new EventEmitter();
1139
- /** Event emitted when the slider thumb stops being dragged. */
1140
- dragEnd = new EventEmitter();
1141
- /**
1142
- * The current translateX in px of the slider visual thumb.
1143
- * @docs-private
1144
- */
1145
- get translateX() {
1146
- if (this._slider.min >= this._slider.max) {
1147
- this._translateX = this._tickMarkOffset;
1148
- return this._translateX;
1149
- }
1150
- if (this._translateX === undefined) {
1151
- this._translateX = this._calcTranslateXByValue();
1152
- }
1153
- return this._translateX;
1154
- }
1155
- set translateX(v) {
1156
- this._translateX = v;
1157
- }
1158
- _translateX;
1159
- /**
1160
- * Indicates whether this thumb is the start or end thumb.
1161
- * @docs-private
1162
- */
1163
- thumbPosition = _MatThumb.END;
1164
- /** @docs-private */
1165
- get min() {
1166
- return numberAttribute(this._hostElement.min, 0);
1167
- }
1168
- set min(v) {
1169
- this._hostElement.min = v + '';
1170
- this._cdr.detectChanges();
1171
- }
1172
- /** @docs-private */
1173
- get max() {
1174
- return numberAttribute(this._hostElement.max, 0);
1175
- }
1176
- set max(v) {
1177
- this._hostElement.max = v + '';
1178
- this._cdr.detectChanges();
1179
- }
1180
- get step() {
1181
- return numberAttribute(this._hostElement.step, 0);
1182
- }
1183
- set step(v) {
1184
- this._hostElement.step = v + '';
1185
- this._cdr.detectChanges();
1186
- }
1187
- /** @docs-private */
1188
- get disabled() {
1189
- return booleanAttribute(this._hostElement.disabled);
1190
- }
1191
- set disabled(v) {
1192
- this._hostElement.disabled = v;
1193
- this._cdr.detectChanges();
1194
- if (this._slider.disabled !== this.disabled) {
1195
- this._slider.disabled = this.disabled;
1196
- }
1197
- }
1198
- /** The percentage of the slider that coincides with the value. */
1199
- get percentage() {
1200
- if (this._slider.min >= this._slider.max) {
1201
- return this._slider._isRtl ? 1 : 0;
1202
- }
1203
- return (this.value - this._slider.min) / (this._slider.max - this._slider.min);
1204
- }
1205
- /** @docs-private */
1206
- get fillPercentage() {
1207
- if (!this._slider._cachedWidth) {
1208
- return this._slider._isRtl ? 1 : 0;
1209
- }
1210
- if (this._translateX === 0) {
1211
- return 0;
1212
- }
1213
- return this.translateX / this._slider._cachedWidth;
1214
- }
1215
- /** The host native HTML input element. */
1216
- _hostElement = this._elementRef.nativeElement;
1217
- /** The aria-valuetext string representation of the input's value. */
1218
- _valuetext = signal('', ...(ngDevMode ? [{ debugName: "_valuetext" }] : []));
1219
- /** The radius of a native html slider's knob. */
1220
- _knobRadius = 8;
1221
- /** The distance in px from the start of the slider track to the first tick mark. */
1222
- _tickMarkOffset = 3;
1223
- /** Whether user's cursor is currently in a mouse down state on the input. */
1224
- _isActive = false;
1225
- /** Whether the input is currently focused (either by tab or after clicking). */
1226
- _isFocused = false;
1227
- /** Used to relay updates to _isFocused to the slider visual thumbs. */
1228
- _setIsFocused(v) {
1229
- this._isFocused = v;
1230
- }
1231
- /**
1232
- * Whether the initial value has been set.
1233
- * This exists because the initial value cannot be immediately set because the min and max
1234
- * must first be relayed from the parent MatSlider component, which can only happen later
1235
- * in the component lifecycle.
1236
- */
1237
- _hasSetInitialValue = false;
1238
- /** The stored initial value. */
1239
- _initialValue;
1240
- /** Defined when a user is using a form control to manage slider value & validation. */
1241
- _formControl;
1242
- /** Emits when the component is destroyed. */
1243
- _destroyed = new Subject();
1244
- /**
1245
- * Indicates whether UI updates should be skipped.
1246
- *
1247
- * This flag is used to avoid flickering
1248
- * when correcting values on pointer up/down.
1249
- */
1250
- _skipUIUpdate = false;
1251
- /** Callback called when the slider input value changes. */
1252
- _onChangeFn;
1253
- /** Callback called when the slider input has been touched. */
1254
- _onTouchedFn = () => { };
1255
- /**
1256
- * Whether the NgModel has been initialized.
1257
- *
1258
- * This flag is used to ignore ghost null calls to
1259
- * writeValue which can break slider initialization.
1260
- *
1261
- * See https://github.com/angular/angular/issues/14988.
1262
- */
1263
- _isControlInitialized = false;
1264
- constructor() {
1265
- const renderer = inject(Renderer2);
1266
- this._ngZone.runOutsideAngular(() => {
1267
- this._listenerCleanups = [
1268
- renderer.listen(this._hostElement, 'pointerdown', this._onPointerDown.bind(this)),
1269
- renderer.listen(this._hostElement, 'pointermove', this._onPointerMove.bind(this)),
1270
- renderer.listen(this._hostElement, 'pointerup', this._onPointerUp.bind(this)),
1271
- ];
1272
- });
1273
- }
1274
- ngOnDestroy() {
1275
- this._listenerCleanups.forEach(cleanup => cleanup());
1276
- this._destroyed.next();
1277
- this._destroyed.complete();
1278
- this.dragStart.complete();
1279
- this.dragEnd.complete();
1280
- }
1281
- /** @docs-private */
1282
- initProps() {
1283
- this._updateWidthInactive();
1284
- // If this or the parent slider is disabled, just make everything disabled.
1285
- if (this.disabled !== this._slider.disabled) {
1286
- // The MatSlider setter for disabled will relay this and disable both inputs.
1287
- this._slider.disabled = true;
1288
- }
1289
- this.step = this._slider.step;
1290
- this.min = this._slider.min;
1291
- this.max = this._slider.max;
1292
- this._initValue();
1293
- }
1294
- /** @docs-private */
1295
- initUI() {
1296
- this._updateThumbUIByValue();
1297
- }
1298
- _initValue() {
1299
- this._hasSetInitialValue = true;
1300
- if (this._initialValue === undefined) {
1301
- this.value = this._getDefaultValue();
1302
- }
1303
- else {
1304
- this._hostElement.value = this._initialValue;
1305
- this._updateThumbUIByValue();
1306
- this._slider._onValueChange(this);
1307
- this._cdr.detectChanges();
1308
- }
1309
- }
1310
- _getDefaultValue() {
1311
- return this.min;
1312
- }
1313
- _onBlur() {
1075
+ _ngZone = inject(NgZone);
1076
+ _elementRef = inject(ElementRef);
1077
+ _cdr = inject(ChangeDetectorRef);
1078
+ _slider = inject(MAT_SLIDER);
1079
+ _platform = inject(Platform);
1080
+ _listenerCleanups;
1081
+ get value() {
1082
+ return numberAttribute(this._hostElement.value, 0);
1083
+ }
1084
+ set value(value) {
1085
+ if (value === null) {
1086
+ value = this._getDefaultValue();
1087
+ }
1088
+ value = isNaN(value) ? 0 : value;
1089
+ const stringValue = value + '';
1090
+ if (!this._hasSetInitialValue) {
1091
+ this._initialValue = stringValue;
1092
+ return;
1093
+ }
1094
+ if (this._isActive) {
1095
+ return;
1096
+ }
1097
+ this._setValue(stringValue);
1098
+ }
1099
+ _setValue(value) {
1100
+ this._hostElement.value = value;
1101
+ this._updateThumbUIByValue();
1102
+ this._slider._onValueChange(this);
1103
+ this._cdr.detectChanges();
1104
+ this._slider._cdr.markForCheck();
1105
+ }
1106
+ valueChange = new EventEmitter();
1107
+ dragStart = new EventEmitter();
1108
+ dragEnd = new EventEmitter();
1109
+ get translateX() {
1110
+ if (this._slider.min >= this._slider.max) {
1111
+ this._translateX = this._tickMarkOffset;
1112
+ return this._translateX;
1113
+ }
1114
+ if (this._translateX === undefined) {
1115
+ this._translateX = this._calcTranslateXByValue();
1116
+ }
1117
+ return this._translateX;
1118
+ }
1119
+ set translateX(v) {
1120
+ this._translateX = v;
1121
+ }
1122
+ _translateX;
1123
+ thumbPosition = _MatThumb.END;
1124
+ get min() {
1125
+ return numberAttribute(this._hostElement.min, 0);
1126
+ }
1127
+ set min(v) {
1128
+ this._hostElement.min = v + '';
1129
+ this._cdr.detectChanges();
1130
+ }
1131
+ get max() {
1132
+ return numberAttribute(this._hostElement.max, 0);
1133
+ }
1134
+ set max(v) {
1135
+ this._hostElement.max = v + '';
1136
+ this._cdr.detectChanges();
1137
+ }
1138
+ get step() {
1139
+ return numberAttribute(this._hostElement.step, 0);
1140
+ }
1141
+ set step(v) {
1142
+ this._hostElement.step = v + '';
1143
+ this._cdr.detectChanges();
1144
+ }
1145
+ get disabled() {
1146
+ return booleanAttribute(this._hostElement.disabled);
1147
+ }
1148
+ set disabled(v) {
1149
+ this._hostElement.disabled = v;
1150
+ this._cdr.detectChanges();
1151
+ if (this._slider.disabled !== this.disabled) {
1152
+ this._slider.disabled = this.disabled;
1153
+ }
1154
+ }
1155
+ get percentage() {
1156
+ if (this._slider.min >= this._slider.max) {
1157
+ return this._slider._isRtl ? 1 : 0;
1158
+ }
1159
+ return (this.value - this._slider.min) / (this._slider.max - this._slider.min);
1160
+ }
1161
+ get fillPercentage() {
1162
+ if (!this._slider._cachedWidth) {
1163
+ return this._slider._isRtl ? 1 : 0;
1164
+ }
1165
+ if (this._translateX === 0) {
1166
+ return 0;
1167
+ }
1168
+ return this.translateX / this._slider._cachedWidth;
1169
+ }
1170
+ _hostElement = this._elementRef.nativeElement;
1171
+ _valuetext = signal('', ...(ngDevMode ? [{
1172
+ debugName: "_valuetext"
1173
+ }] : []));
1174
+ _knobRadius = 8;
1175
+ _tickMarkOffset = 3;
1176
+ _isActive = false;
1177
+ _isFocused = false;
1178
+ _setIsFocused(v) {
1179
+ this._isFocused = v;
1180
+ }
1181
+ _hasSetInitialValue = false;
1182
+ _initialValue;
1183
+ _formControl;
1184
+ _destroyed = new Subject();
1185
+ _skipUIUpdate = false;
1186
+ _onChangeFn;
1187
+ _onTouchedFn = () => {};
1188
+ _isControlInitialized = false;
1189
+ constructor() {
1190
+ const renderer = inject(Renderer2);
1191
+ this._ngZone.runOutsideAngular(() => {
1192
+ this._listenerCleanups = [renderer.listen(this._hostElement, 'pointerdown', this._onPointerDown.bind(this)), renderer.listen(this._hostElement, 'pointermove', this._onPointerMove.bind(this)), renderer.listen(this._hostElement, 'pointerup', this._onPointerUp.bind(this))];
1193
+ });
1194
+ }
1195
+ ngOnDestroy() {
1196
+ this._listenerCleanups.forEach(cleanup => cleanup());
1197
+ this._destroyed.next();
1198
+ this._destroyed.complete();
1199
+ this.dragStart.complete();
1200
+ this.dragEnd.complete();
1201
+ }
1202
+ initProps() {
1203
+ this._updateWidthInactive();
1204
+ if (this.disabled !== this._slider.disabled) {
1205
+ this._slider.disabled = true;
1206
+ }
1207
+ this.step = this._slider.step;
1208
+ this.min = this._slider.min;
1209
+ this.max = this._slider.max;
1210
+ this._initValue();
1211
+ }
1212
+ initUI() {
1213
+ this._updateThumbUIByValue();
1214
+ }
1215
+ _initValue() {
1216
+ this._hasSetInitialValue = true;
1217
+ if (this._initialValue === undefined) {
1218
+ this.value = this._getDefaultValue();
1219
+ } else {
1220
+ this._hostElement.value = this._initialValue;
1221
+ this._updateThumbUIByValue();
1222
+ this._slider._onValueChange(this);
1223
+ this._cdr.detectChanges();
1224
+ }
1225
+ }
1226
+ _getDefaultValue() {
1227
+ return this.min;
1228
+ }
1229
+ _onBlur() {
1230
+ this._setIsFocused(false);
1231
+ this._onTouchedFn();
1232
+ }
1233
+ _onFocus() {
1234
+ this._slider._setTransition(false);
1235
+ this._slider._updateTrackUI(this);
1236
+ this._setIsFocused(true);
1237
+ }
1238
+ _onChange() {
1239
+ this.valueChange.emit(this.value);
1240
+ if (this._isActive) {
1241
+ this._updateThumbUIByValue({
1242
+ withAnimation: true
1243
+ });
1244
+ }
1245
+ }
1246
+ _onInput() {
1247
+ this._onChangeFn?.(this.value);
1248
+ if (this._slider.step || !this._isActive) {
1249
+ this._updateThumbUIByValue({
1250
+ withAnimation: true
1251
+ });
1252
+ }
1253
+ this._slider._onValueChange(this);
1254
+ }
1255
+ _onNgControlValueChange() {
1256
+ if (!this._isActive || !this._isFocused) {
1257
+ this._slider._onValueChange(this);
1258
+ this._updateThumbUIByValue();
1259
+ }
1260
+ this._slider.disabled = this._formControl.disabled;
1261
+ }
1262
+ _onPointerDown(event) {
1263
+ if (this.disabled || event.button !== 0) {
1264
+ return;
1265
+ }
1266
+ if (this._platform.IOS) {
1267
+ const isCursorOnSliderThumb = this._slider._isCursorOnSliderThumb(event, this._slider._getThumb(this.thumbPosition)._hostElement.getBoundingClientRect());
1268
+ this._isActive = isCursorOnSliderThumb;
1269
+ this._updateWidthActive();
1270
+ this._slider._updateDimensions();
1271
+ return;
1272
+ }
1273
+ this._isActive = true;
1274
+ this._setIsFocused(true);
1275
+ this._updateWidthActive();
1276
+ this._slider._updateDimensions();
1277
+ if (!this._slider.step) {
1278
+ this._updateThumbUIByPointerEvent(event, {
1279
+ withAnimation: true
1280
+ });
1281
+ }
1282
+ if (!this.disabled) {
1283
+ this._handleValueCorrection(event);
1284
+ this.dragStart.emit({
1285
+ source: this,
1286
+ parent: this._slider,
1287
+ value: this.value
1288
+ });
1289
+ }
1290
+ }
1291
+ _handleValueCorrection(event) {
1292
+ this._skipUIUpdate = true;
1293
+ setTimeout(() => {
1294
+ this._skipUIUpdate = false;
1295
+ this._fixValue(event);
1296
+ }, 0);
1297
+ }
1298
+ _fixValue(event) {
1299
+ const xPos = event.clientX - this._slider._cachedLeft;
1300
+ const width = this._slider._cachedWidth;
1301
+ const step = this._slider.step === 0 ? 1 : this._slider.step;
1302
+ const numSteps = Math.floor((this._slider.max - this._slider.min) / step);
1303
+ const percentage = this._slider._isRtl ? 1 - xPos / width : xPos / width;
1304
+ const fixedPercentage = Math.round(percentage * numSteps) / numSteps;
1305
+ const impreciseValue = fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min;
1306
+ const value = Math.round(impreciseValue / step) * step;
1307
+ const prevValue = this.value;
1308
+ if (value === prevValue) {
1309
+ this._slider._onValueChange(this);
1310
+ this._slider.step > 0 ? this._updateThumbUIByValue() : this._updateThumbUIByPointerEvent(event, {
1311
+ withAnimation: this._slider._hasAnimation
1312
+ });
1313
+ return;
1314
+ }
1315
+ this.value = value;
1316
+ this.valueChange.emit(this.value);
1317
+ this._onChangeFn?.(this.value);
1318
+ this._slider._onValueChange(this);
1319
+ this._slider.step > 0 ? this._updateThumbUIByValue() : this._updateThumbUIByPointerEvent(event, {
1320
+ withAnimation: this._slider._hasAnimation
1321
+ });
1322
+ }
1323
+ _onPointerMove(event) {
1324
+ if (!this._slider.step && this._isActive) {
1325
+ this._updateThumbUIByPointerEvent(event);
1326
+ }
1327
+ }
1328
+ _onPointerUp() {
1329
+ if (this._isActive) {
1330
+ this._isActive = false;
1331
+ if (this._platform.SAFARI) {
1314
1332
  this._setIsFocused(false);
1315
- this._onTouchedFn();
1316
- }
1317
- _onFocus() {
1318
- this._slider._setTransition(false);
1319
- this._slider._updateTrackUI(this);
1320
- this._setIsFocused(true);
1321
- }
1322
- _onChange() {
1323
- this.valueChange.emit(this.value);
1324
- // only used to handle the edge case where user
1325
- // mousedown on the slider then uses arrow keys.
1326
- if (this._isActive) {
1327
- this._updateThumbUIByValue({ withAnimation: true });
1328
- }
1329
- }
1330
- _onInput() {
1331
- this._onChangeFn?.(this.value);
1332
- // handles arrowing and updating the value when
1333
- // a step is defined.
1334
- if (this._slider.step || !this._isActive) {
1335
- this._updateThumbUIByValue({ withAnimation: true });
1336
- }
1337
- this._slider._onValueChange(this);
1338
- }
1339
- _onNgControlValueChange() {
1340
- // only used to handle when the value change
1341
- // originates outside of the slider.
1342
- if (!this._isActive || !this._isFocused) {
1343
- this._slider._onValueChange(this);
1344
- this._updateThumbUIByValue();
1345
- }
1346
- this._slider.disabled = this._formControl.disabled;
1347
- }
1348
- _onPointerDown(event) {
1349
- if (this.disabled || event.button !== 0) {
1350
- return;
1351
- }
1352
- // On IOS, dragging only works if the pointer down happens on the
1353
- // slider thumb and the slider does not receive focus from pointer events.
1354
- if (this._platform.IOS) {
1355
- const isCursorOnSliderThumb = this._slider._isCursorOnSliderThumb(event, this._slider._getThumb(this.thumbPosition)._hostElement.getBoundingClientRect());
1356
- this._isActive = isCursorOnSliderThumb;
1357
- this._updateWidthActive();
1358
- this._slider._updateDimensions();
1359
- return;
1360
- }
1361
- this._isActive = true;
1362
- this._setIsFocused(true);
1363
- this._updateWidthActive();
1364
- this._slider._updateDimensions();
1365
- // Does nothing if a step is defined because we
1366
- // want the value to snap to the values on input.
1367
- if (!this._slider.step) {
1368
- this._updateThumbUIByPointerEvent(event, { withAnimation: true });
1369
- }
1370
- if (!this.disabled) {
1371
- this._handleValueCorrection(event);
1372
- this.dragStart.emit({ source: this, parent: this._slider, value: this.value });
1373
- }
1374
- }
1375
- /**
1376
- * Corrects the value of the slider on pointer up/down.
1377
- *
1378
- * Called on pointer down and up because the value is set based
1379
- * on the inactive width instead of the active width.
1380
- */
1381
- _handleValueCorrection(event) {
1382
- // Don't update the UI with the current value! The value on pointerdown
1383
- // and pointerup is calculated in the split second before the input(s)
1384
- // resize. See _updateWidthInactive() and _updateWidthActive() for more
1385
- // details.
1386
- this._skipUIUpdate = true;
1387
- // Note that this function gets triggered before the actual value of the
1388
- // slider is updated. This means if we were to set the value here, it
1389
- // would immediately be overwritten. Using setTimeout ensures the setting
1390
- // of the value happens after the value has been updated by the
1391
- // pointerdown event.
1392
- setTimeout(() => {
1393
- this._skipUIUpdate = false;
1394
- this._fixValue(event);
1395
- }, 0);
1396
- }
1397
- /** Corrects the value of the slider based on the pointer event's position. */
1398
- _fixValue(event) {
1399
- const xPos = event.clientX - this._slider._cachedLeft;
1400
- const width = this._slider._cachedWidth;
1401
- const step = this._slider.step === 0 ? 1 : this._slider.step;
1402
- const numSteps = Math.floor((this._slider.max - this._slider.min) / step);
1403
- const percentage = this._slider._isRtl ? 1 - xPos / width : xPos / width;
1404
- // To ensure the percentage is rounded to the necessary number of decimals.
1405
- const fixedPercentage = Math.round(percentage * numSteps) / numSteps;
1406
- const impreciseValue = fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min;
1407
- const value = Math.round(impreciseValue / step) * step;
1408
- const prevValue = this.value;
1409
- if (value === prevValue) {
1410
- // Because we prevented UI updates, if it turns out that the race
1411
- // condition didn't happen and the value is already correct, we
1412
- // have to apply the ui updates now.
1413
- this._slider._onValueChange(this);
1414
- this._slider.step > 0
1415
- ? this._updateThumbUIByValue()
1416
- : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
1417
- return;
1418
- }
1419
- this.value = value;
1420
- this.valueChange.emit(this.value);
1421
- this._onChangeFn?.(this.value);
1422
- this._slider._onValueChange(this);
1423
- this._slider.step > 0
1424
- ? this._updateThumbUIByValue()
1425
- : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
1426
- }
1427
- _onPointerMove(event) {
1428
- // Again, does nothing if a step is defined because
1429
- // we want the value to snap to the values on input.
1430
- if (!this._slider.step && this._isActive) {
1431
- this._updateThumbUIByPointerEvent(event);
1432
- }
1433
- }
1434
- _onPointerUp() {
1435
- if (this._isActive) {
1436
- this._isActive = false;
1437
- if (this._platform.SAFARI) {
1438
- this._setIsFocused(false);
1439
- }
1440
- this.dragEnd.emit({ source: this, parent: this._slider, value: this.value });
1441
- // This setTimeout is to prevent the pointerup from triggering a value
1442
- // change on the input based on the inactive width. It's not clear why
1443
- // but for some reason on IOS this race condition is even more common so
1444
- // the timeout needs to be increased.
1445
- setTimeout(() => this._updateWidthInactive(), this._platform.IOS ? 10 : 0);
1446
- }
1447
- }
1448
- _clamp(v) {
1449
- const min = this._tickMarkOffset;
1450
- const max = this._slider._cachedWidth - this._tickMarkOffset;
1451
- return Math.max(Math.min(v, max), min);
1452
- }
1453
- _calcTranslateXByValue() {
1454
- if (this._slider._isRtl) {
1455
- return ((1 - this.percentage) * (this._slider._cachedWidth - this._tickMarkOffset * 2) +
1456
- this._tickMarkOffset);
1457
- }
1458
- return (this.percentage * (this._slider._cachedWidth - this._tickMarkOffset * 2) +
1459
- this._tickMarkOffset);
1460
- }
1461
- _calcTranslateXByPointerEvent(event) {
1462
- return event.clientX - this._slider._cachedLeft;
1463
- }
1464
- /**
1465
- * Used to set the slider width to the correct
1466
- * dimensions while the user is dragging.
1467
- */
1468
- _updateWidthActive() { }
1469
- /**
1470
- * Sets the slider input to disproportionate dimensions to allow for touch
1471
- * events to be captured on touch devices.
1472
- */
1473
- _updateWidthInactive() {
1474
- this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
1475
- this._hostElement.style.width = `calc(100% + ${this._slider._inputPadding - this._tickMarkOffset * 2}px)`;
1476
- this._hostElement.style.left = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1477
- }
1478
- _updateThumbUIByValue(options) {
1479
- this.translateX = this._clamp(this._calcTranslateXByValue());
1480
- this._updateThumbUI(options);
1481
- }
1482
- _updateThumbUIByPointerEvent(event, options) {
1483
- this.translateX = this._clamp(this._calcTranslateXByPointerEvent(event));
1484
- this._updateThumbUI(options);
1485
- }
1486
- _updateThumbUI(options) {
1487
- this._slider._setTransition(!!options?.withAnimation);
1488
- this._slider._onTranslateXChange(this);
1489
- }
1490
- /**
1491
- * Sets the input's value.
1492
- * @param value The new value of the input
1493
- * @docs-private
1494
- */
1495
- writeValue(value) {
1496
- if (this._isControlInitialized || value !== null) {
1497
- this.value = value;
1498
- }
1499
- }
1500
- /**
1501
- * Registers a callback to be invoked when the input's value changes from user input.
1502
- * @param fn The callback to register
1503
- * @docs-private
1504
- */
1505
- registerOnChange(fn) {
1506
- this._onChangeFn = fn;
1507
- this._isControlInitialized = true;
1508
- }
1509
- /**
1510
- * Registers a callback to be invoked when the input is blurred by the user.
1511
- * @param fn The callback to register
1512
- * @docs-private
1513
- */
1514
- registerOnTouched(fn) {
1515
- this._onTouchedFn = fn;
1516
- }
1517
- /**
1518
- * Sets the disabled state of the slider.
1519
- * @param isDisabled The new disabled state
1520
- * @docs-private
1521
- */
1522
- setDisabledState(isDisabled) {
1523
- this.disabled = isDisabled;
1524
- }
1525
- focus() {
1526
- this._hostElement.focus();
1527
- }
1528
- blur() {
1529
- this._hostElement.blur();
1530
- }
1531
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderThumb, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1532
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "16.1.0", version: "20.2.0-next.2", type: MatSliderThumb, isStandalone: true, selector: "input[matSliderThumb]", inputs: { value: ["value", "value", numberAttribute] }, outputs: { valueChange: "valueChange", dragStart: "dragStart", dragEnd: "dragEnd" }, host: { attributes: { "type": "range" }, listeners: { "change": "_onChange()", "input": "_onInput()", "blur": "_onBlur()", "focus": "_onFocus()" }, properties: { "attr.aria-valuetext": "_valuetext()" }, classAttribute: "mdc-slider__input" }, providers: [
1533
- MAT_SLIDER_THUMB_VALUE_ACCESSOR,
1534
- { provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb },
1535
- ], exportAs: ["matSliderThumb"], ngImport: i0 });
1333
+ }
1334
+ this.dragEnd.emit({
1335
+ source: this,
1336
+ parent: this._slider,
1337
+ value: this.value
1338
+ });
1339
+ setTimeout(() => this._updateWidthInactive(), this._platform.IOS ? 10 : 0);
1340
+ }
1341
+ }
1342
+ _clamp(v) {
1343
+ const min = this._tickMarkOffset;
1344
+ const max = this._slider._cachedWidth - this._tickMarkOffset;
1345
+ return Math.max(Math.min(v, max), min);
1346
+ }
1347
+ _calcTranslateXByValue() {
1348
+ if (this._slider._isRtl) {
1349
+ return (1 - this.percentage) * (this._slider._cachedWidth - this._tickMarkOffset * 2) + this._tickMarkOffset;
1350
+ }
1351
+ return this.percentage * (this._slider._cachedWidth - this._tickMarkOffset * 2) + this._tickMarkOffset;
1352
+ }
1353
+ _calcTranslateXByPointerEvent(event) {
1354
+ return event.clientX - this._slider._cachedLeft;
1355
+ }
1356
+ _updateWidthActive() {}
1357
+ _updateWidthInactive() {
1358
+ this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
1359
+ this._hostElement.style.width = `calc(100% + ${this._slider._inputPadding - this._tickMarkOffset * 2}px)`;
1360
+ this._hostElement.style.left = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1361
+ }
1362
+ _updateThumbUIByValue(options) {
1363
+ this.translateX = this._clamp(this._calcTranslateXByValue());
1364
+ this._updateThumbUI(options);
1365
+ }
1366
+ _updateThumbUIByPointerEvent(event, options) {
1367
+ this.translateX = this._clamp(this._calcTranslateXByPointerEvent(event));
1368
+ this._updateThumbUI(options);
1369
+ }
1370
+ _updateThumbUI(options) {
1371
+ this._slider._setTransition(!!options?.withAnimation);
1372
+ this._slider._onTranslateXChange(this);
1373
+ }
1374
+ writeValue(value) {
1375
+ if (this._isControlInitialized || value !== null) {
1376
+ this.value = value;
1377
+ }
1378
+ }
1379
+ registerOnChange(fn) {
1380
+ this._onChangeFn = fn;
1381
+ this._isControlInitialized = true;
1382
+ }
1383
+ registerOnTouched(fn) {
1384
+ this._onTouchedFn = fn;
1385
+ }
1386
+ setDisabledState(isDisabled) {
1387
+ this.disabled = isDisabled;
1388
+ }
1389
+ focus() {
1390
+ this._hostElement.focus();
1391
+ }
1392
+ blur() {
1393
+ this._hostElement.blur();
1394
+ }
1395
+ static ɵfac = i0.ɵɵngDeclareFactory({
1396
+ minVersion: "12.0.0",
1397
+ version: "20.2.0-next.2",
1398
+ ngImport: i0,
1399
+ type: MatSliderThumb,
1400
+ deps: [],
1401
+ target: i0.ɵɵFactoryTarget.Directive
1402
+ });
1403
+ static ɵdir = i0.ɵɵngDeclareDirective({
1404
+ minVersion: "16.1.0",
1405
+ version: "20.2.0-next.2",
1406
+ type: MatSliderThumb,
1407
+ isStandalone: true,
1408
+ selector: "input[matSliderThumb]",
1409
+ inputs: {
1410
+ value: ["value", "value", numberAttribute]
1411
+ },
1412
+ outputs: {
1413
+ valueChange: "valueChange",
1414
+ dragStart: "dragStart",
1415
+ dragEnd: "dragEnd"
1416
+ },
1417
+ host: {
1418
+ attributes: {
1419
+ "type": "range"
1420
+ },
1421
+ listeners: {
1422
+ "change": "_onChange()",
1423
+ "input": "_onInput()",
1424
+ "blur": "_onBlur()",
1425
+ "focus": "_onFocus()"
1426
+ },
1427
+ properties: {
1428
+ "attr.aria-valuetext": "_valuetext()"
1429
+ },
1430
+ classAttribute: "mdc-slider__input"
1431
+ },
1432
+ providers: [MAT_SLIDER_THUMB_VALUE_ACCESSOR, {
1433
+ provide: MAT_SLIDER_THUMB,
1434
+ useExisting: MatSliderThumb
1435
+ }],
1436
+ exportAs: ["matSliderThumb"],
1437
+ ngImport: i0
1438
+ });
1536
1439
  }
1537
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderThumb, decorators: [{
1538
- type: Directive,
1539
- args: [{
1540
- selector: 'input[matSliderThumb]',
1541
- exportAs: 'matSliderThumb',
1542
- host: {
1543
- 'class': 'mdc-slider__input',
1544
- 'type': 'range',
1545
- '[attr.aria-valuetext]': '_valuetext()',
1546
- '(change)': '_onChange()',
1547
- '(input)': '_onInput()',
1548
- // TODO(wagnermaciel): Consider using a global event listener instead.
1549
- // Reason: I have found a semi-consistent way to mouse up without triggering this event.
1550
- '(blur)': '_onBlur()',
1551
- '(focus)': '_onFocus()',
1552
- },
1553
- providers: [
1554
- MAT_SLIDER_THUMB_VALUE_ACCESSOR,
1555
- { provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb },
1556
- ],
1557
- }]
1558
- }], ctorParameters: () => [], propDecorators: { value: [{
1559
- type: Input,
1560
- args: [{ transform: numberAttribute }]
1561
- }], valueChange: [{
1562
- type: Output
1563
- }], dragStart: [{
1564
- type: Output
1565
- }], dragEnd: [{
1566
- type: Output
1567
- }] } });
1440
+ i0.ɵɵngDeclareClassMetadata({
1441
+ minVersion: "12.0.0",
1442
+ version: "20.2.0-next.2",
1443
+ ngImport: i0,
1444
+ type: MatSliderThumb,
1445
+ decorators: [{
1446
+ type: Directive,
1447
+ args: [{
1448
+ selector: 'input[matSliderThumb]',
1449
+ exportAs: 'matSliderThumb',
1450
+ host: {
1451
+ 'class': 'mdc-slider__input',
1452
+ 'type': 'range',
1453
+ '[attr.aria-valuetext]': '_valuetext()',
1454
+ '(change)': '_onChange()',
1455
+ '(input)': '_onInput()',
1456
+ '(blur)': '_onBlur()',
1457
+ '(focus)': '_onFocus()'
1458
+ },
1459
+ providers: [MAT_SLIDER_THUMB_VALUE_ACCESSOR, {
1460
+ provide: MAT_SLIDER_THUMB,
1461
+ useExisting: MatSliderThumb
1462
+ }]
1463
+ }]
1464
+ }],
1465
+ ctorParameters: () => [],
1466
+ propDecorators: {
1467
+ value: [{
1468
+ type: Input,
1469
+ args: [{
1470
+ transform: numberAttribute
1471
+ }]
1472
+ }],
1473
+ valueChange: [{
1474
+ type: Output
1475
+ }],
1476
+ dragStart: [{
1477
+ type: Output
1478
+ }],
1479
+ dragEnd: [{
1480
+ type: Output
1481
+ }]
1482
+ }
1483
+ });
1568
1484
  class MatSliderRangeThumb extends MatSliderThumb {
1569
- _cdr = inject(ChangeDetectorRef);
1570
- /** @docs-private */
1571
- getSibling() {
1572
- if (!this._sibling) {
1573
- this._sibling = this._slider._getInput(this._isEndThumb ? _MatThumb.START : _MatThumb.END);
1574
- }
1575
- return this._sibling;
1576
- }
1577
- _sibling;
1578
- /**
1579
- * Returns the minimum translateX position allowed for this slider input's visual thumb.
1580
- * @docs-private
1581
- */
1582
- getMinPos() {
1583
- const sibling = this.getSibling();
1584
- if (!this._isLeftThumb && sibling) {
1585
- return sibling.translateX;
1586
- }
1587
- return this._tickMarkOffset;
1588
- }
1589
- /**
1590
- * Returns the maximum translateX position allowed for this slider input's visual thumb.
1591
- * @docs-private
1592
- */
1593
- getMaxPos() {
1594
- const sibling = this.getSibling();
1595
- if (this._isLeftThumb && sibling) {
1596
- return sibling.translateX;
1597
- }
1598
- return this._slider._cachedWidth - this._tickMarkOffset;
1599
- }
1600
- _setIsLeftThumb() {
1601
- this._isLeftThumb =
1602
- (this._isEndThumb && this._slider._isRtl) || (!this._isEndThumb && !this._slider._isRtl);
1603
- }
1604
- /** Whether this slider corresponds to the input on the left hand side. */
1605
- _isLeftThumb;
1606
- /** Whether this slider corresponds to the input with greater value. */
1607
- _isEndThumb;
1608
- constructor() {
1609
- super();
1610
- this._isEndThumb = this._hostElement.hasAttribute('matSliderEndThumb');
1611
- this._setIsLeftThumb();
1612
- this.thumbPosition = this._isEndThumb ? _MatThumb.END : _MatThumb.START;
1613
- }
1614
- _getDefaultValue() {
1615
- return this._isEndThumb && this._slider._isRange ? this.max : this.min;
1616
- }
1617
- _onInput() {
1618
- super._onInput();
1619
- this._updateSibling();
1620
- if (!this._isActive) {
1621
- this._updateWidthInactive();
1622
- }
1623
- }
1624
- _onNgControlValueChange() {
1625
- super._onNgControlValueChange();
1626
- this.getSibling()?._updateMinMax();
1627
- }
1628
- _onPointerDown(event) {
1629
- if (this.disabled || event.button !== 0) {
1630
- return;
1631
- }
1632
- if (this._sibling) {
1633
- this._sibling._updateWidthActive();
1634
- this._sibling._hostElement.classList.add('mat-mdc-slider-input-no-pointer-events');
1635
- }
1636
- super._onPointerDown(event);
1637
- }
1638
- _onPointerUp() {
1639
- super._onPointerUp();
1640
- if (this._sibling) {
1641
- setTimeout(() => {
1642
- this._sibling._updateWidthInactive();
1643
- this._sibling._hostElement.classList.remove('mat-mdc-slider-input-no-pointer-events');
1644
- });
1645
- }
1646
- }
1647
- _onPointerMove(event) {
1648
- super._onPointerMove(event);
1649
- if (!this._slider.step && this._isActive) {
1650
- this._updateSibling();
1651
- }
1652
- }
1653
- _fixValue(event) {
1654
- super._fixValue(event);
1655
- this._sibling?._updateMinMax();
1656
- }
1657
- _clamp(v) {
1658
- return Math.max(Math.min(v, this.getMaxPos()), this.getMinPos());
1659
- }
1660
- _updateMinMax() {
1661
- const sibling = this.getSibling();
1662
- if (!sibling) {
1663
- return;
1664
- }
1665
- if (this._isEndThumb) {
1666
- this.min = Math.max(this._slider.min, sibling.value);
1667
- this.max = this._slider.max;
1668
- }
1669
- else {
1670
- this.min = this._slider.min;
1671
- this.max = Math.min(this._slider.max, sibling.value);
1672
- }
1673
- }
1674
- _updateWidthActive() {
1675
- const minWidth = this._slider._rippleRadius * 2 - this._slider._inputPadding * 2;
1676
- const maxWidth = this._slider._cachedWidth + this._slider._inputPadding - minWidth - this._tickMarkOffset * 2;
1677
- const percentage = this._slider.min < this._slider.max
1678
- ? (this.max - this.min) / (this._slider.max - this._slider.min)
1679
- : 1;
1680
- const width = maxWidth * percentage + minWidth;
1681
- this._hostElement.style.width = `${width}px`;
1682
- this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
1683
- }
1684
- _updateWidthInactive() {
1685
- const sibling = this.getSibling();
1686
- if (!sibling) {
1687
- return;
1688
- }
1689
- const maxWidth = this._slider._cachedWidth - this._tickMarkOffset * 2;
1690
- const midValue = this._isEndThumb
1691
- ? this.value - (this.value - sibling.value) / 2
1692
- : this.value + (sibling.value - this.value) / 2;
1693
- const _percentage = this._isEndThumb
1694
- ? (this.max - midValue) / (this._slider.max - this._slider.min)
1695
- : (midValue - this.min) / (this._slider.max - this._slider.min);
1696
- const percentage = this._slider.min < this._slider.max ? _percentage : 1;
1697
- // Extend the native input width by the radius of the ripple
1698
- let ripplePadding = this._slider._rippleRadius;
1699
- // If one of the inputs is maximally sized (the value of both thumbs is
1700
- // equal to the min or max), make that input take up all of the width and
1701
- // make the other unselectable.
1702
- if (percentage === 1) {
1703
- ripplePadding = 48;
1704
- }
1705
- else if (percentage === 0) {
1706
- ripplePadding = 0;
1707
- }
1708
- const width = maxWidth * percentage + ripplePadding;
1709
- this._hostElement.style.width = `${width}px`;
1710
- this._hostElement.style.padding = '0px';
1711
- if (this._isLeftThumb) {
1712
- this._hostElement.style.left = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1713
- this._hostElement.style.right = 'auto';
1714
- }
1715
- else {
1716
- this._hostElement.style.left = 'auto';
1717
- this._hostElement.style.right = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1718
- }
1719
- }
1720
- _updateStaticStyles() {
1721
- this._hostElement.classList.toggle('mat-slider__right-input', !this._isLeftThumb);
1722
- }
1723
- _updateSibling() {
1724
- const sibling = this.getSibling();
1725
- if (!sibling) {
1726
- return;
1727
- }
1728
- sibling._updateMinMax();
1729
- if (this._isActive) {
1730
- sibling._updateWidthActive();
1731
- }
1732
- else {
1733
- sibling._updateWidthInactive();
1734
- }
1735
- }
1736
- /**
1737
- * Sets the input's value.
1738
- * @param value The new value of the input
1739
- * @docs-private
1740
- */
1741
- writeValue(value) {
1742
- if (this._isControlInitialized || value !== null) {
1743
- this.value = value;
1744
- this._updateWidthInactive();
1745
- this._updateSibling();
1746
- }
1747
- }
1748
- _setValue(value) {
1749
- super._setValue(value);
1750
- this._updateWidthInactive();
1751
- this._updateSibling();
1752
- }
1753
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderRangeThumb, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1754
- static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "20.2.0-next.2", type: MatSliderRangeThumb, isStandalone: true, selector: "input[matSliderStartThumb], input[matSliderEndThumb]", providers: [
1755
- MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR,
1756
- { provide: MAT_SLIDER_RANGE_THUMB, useExisting: MatSliderRangeThumb },
1757
- ], exportAs: ["matSliderRangeThumb"], usesInheritance: true, ngImport: i0 });
1485
+ _cdr = inject(ChangeDetectorRef);
1486
+ getSibling() {
1487
+ if (!this._sibling) {
1488
+ this._sibling = this._slider._getInput(this._isEndThumb ? _MatThumb.START : _MatThumb.END);
1489
+ }
1490
+ return this._sibling;
1491
+ }
1492
+ _sibling;
1493
+ getMinPos() {
1494
+ const sibling = this.getSibling();
1495
+ if (!this._isLeftThumb && sibling) {
1496
+ return sibling.translateX;
1497
+ }
1498
+ return this._tickMarkOffset;
1499
+ }
1500
+ getMaxPos() {
1501
+ const sibling = this.getSibling();
1502
+ if (this._isLeftThumb && sibling) {
1503
+ return sibling.translateX;
1504
+ }
1505
+ return this._slider._cachedWidth - this._tickMarkOffset;
1506
+ }
1507
+ _setIsLeftThumb() {
1508
+ this._isLeftThumb = this._isEndThumb && this._slider._isRtl || !this._isEndThumb && !this._slider._isRtl;
1509
+ }
1510
+ _isLeftThumb;
1511
+ _isEndThumb;
1512
+ constructor() {
1513
+ super();
1514
+ this._isEndThumb = this._hostElement.hasAttribute('matSliderEndThumb');
1515
+ this._setIsLeftThumb();
1516
+ this.thumbPosition = this._isEndThumb ? _MatThumb.END : _MatThumb.START;
1517
+ }
1518
+ _getDefaultValue() {
1519
+ return this._isEndThumb && this._slider._isRange ? this.max : this.min;
1520
+ }
1521
+ _onInput() {
1522
+ super._onInput();
1523
+ this._updateSibling();
1524
+ if (!this._isActive) {
1525
+ this._updateWidthInactive();
1526
+ }
1527
+ }
1528
+ _onNgControlValueChange() {
1529
+ super._onNgControlValueChange();
1530
+ this.getSibling()?._updateMinMax();
1531
+ }
1532
+ _onPointerDown(event) {
1533
+ if (this.disabled || event.button !== 0) {
1534
+ return;
1535
+ }
1536
+ if (this._sibling) {
1537
+ this._sibling._updateWidthActive();
1538
+ this._sibling._hostElement.classList.add('mat-mdc-slider-input-no-pointer-events');
1539
+ }
1540
+ super._onPointerDown(event);
1541
+ }
1542
+ _onPointerUp() {
1543
+ super._onPointerUp();
1544
+ if (this._sibling) {
1545
+ setTimeout(() => {
1546
+ this._sibling._updateWidthInactive();
1547
+ this._sibling._hostElement.classList.remove('mat-mdc-slider-input-no-pointer-events');
1548
+ });
1549
+ }
1550
+ }
1551
+ _onPointerMove(event) {
1552
+ super._onPointerMove(event);
1553
+ if (!this._slider.step && this._isActive) {
1554
+ this._updateSibling();
1555
+ }
1556
+ }
1557
+ _fixValue(event) {
1558
+ super._fixValue(event);
1559
+ this._sibling?._updateMinMax();
1560
+ }
1561
+ _clamp(v) {
1562
+ return Math.max(Math.min(v, this.getMaxPos()), this.getMinPos());
1563
+ }
1564
+ _updateMinMax() {
1565
+ const sibling = this.getSibling();
1566
+ if (!sibling) {
1567
+ return;
1568
+ }
1569
+ if (this._isEndThumb) {
1570
+ this.min = Math.max(this._slider.min, sibling.value);
1571
+ this.max = this._slider.max;
1572
+ } else {
1573
+ this.min = this._slider.min;
1574
+ this.max = Math.min(this._slider.max, sibling.value);
1575
+ }
1576
+ }
1577
+ _updateWidthActive() {
1578
+ const minWidth = this._slider._rippleRadius * 2 - this._slider._inputPadding * 2;
1579
+ const maxWidth = this._slider._cachedWidth + this._slider._inputPadding - minWidth - this._tickMarkOffset * 2;
1580
+ const percentage = this._slider.min < this._slider.max ? (this.max - this.min) / (this._slider.max - this._slider.min) : 1;
1581
+ const width = maxWidth * percentage + minWidth;
1582
+ this._hostElement.style.width = `${width}px`;
1583
+ this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
1584
+ }
1585
+ _updateWidthInactive() {
1586
+ const sibling = this.getSibling();
1587
+ if (!sibling) {
1588
+ return;
1589
+ }
1590
+ const maxWidth = this._slider._cachedWidth - this._tickMarkOffset * 2;
1591
+ const midValue = this._isEndThumb ? this.value - (this.value - sibling.value) / 2 : this.value + (sibling.value - this.value) / 2;
1592
+ const _percentage = this._isEndThumb ? (this.max - midValue) / (this._slider.max - this._slider.min) : (midValue - this.min) / (this._slider.max - this._slider.min);
1593
+ const percentage = this._slider.min < this._slider.max ? _percentage : 1;
1594
+ let ripplePadding = this._slider._rippleRadius;
1595
+ if (percentage === 1) {
1596
+ ripplePadding = 48;
1597
+ } else if (percentage === 0) {
1598
+ ripplePadding = 0;
1599
+ }
1600
+ const width = maxWidth * percentage + ripplePadding;
1601
+ this._hostElement.style.width = `${width}px`;
1602
+ this._hostElement.style.padding = '0px';
1603
+ if (this._isLeftThumb) {
1604
+ this._hostElement.style.left = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1605
+ this._hostElement.style.right = 'auto';
1606
+ } else {
1607
+ this._hostElement.style.left = 'auto';
1608
+ this._hostElement.style.right = `-${this._slider._rippleRadius - this._tickMarkOffset}px`;
1609
+ }
1610
+ }
1611
+ _updateStaticStyles() {
1612
+ this._hostElement.classList.toggle('mat-slider__right-input', !this._isLeftThumb);
1613
+ }
1614
+ _updateSibling() {
1615
+ const sibling = this.getSibling();
1616
+ if (!sibling) {
1617
+ return;
1618
+ }
1619
+ sibling._updateMinMax();
1620
+ if (this._isActive) {
1621
+ sibling._updateWidthActive();
1622
+ } else {
1623
+ sibling._updateWidthInactive();
1624
+ }
1625
+ }
1626
+ writeValue(value) {
1627
+ if (this._isControlInitialized || value !== null) {
1628
+ this.value = value;
1629
+ this._updateWidthInactive();
1630
+ this._updateSibling();
1631
+ }
1632
+ }
1633
+ _setValue(value) {
1634
+ super._setValue(value);
1635
+ this._updateWidthInactive();
1636
+ this._updateSibling();
1637
+ }
1638
+ static ɵfac = i0.ɵɵngDeclareFactory({
1639
+ minVersion: "12.0.0",
1640
+ version: "20.2.0-next.2",
1641
+ ngImport: i0,
1642
+ type: MatSliderRangeThumb,
1643
+ deps: [],
1644
+ target: i0.ɵɵFactoryTarget.Directive
1645
+ });
1646
+ static ɵdir = i0.ɵɵngDeclareDirective({
1647
+ minVersion: "14.0.0",
1648
+ version: "20.2.0-next.2",
1649
+ type: MatSliderRangeThumb,
1650
+ isStandalone: true,
1651
+ selector: "input[matSliderStartThumb], input[matSliderEndThumb]",
1652
+ providers: [MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR, {
1653
+ provide: MAT_SLIDER_RANGE_THUMB,
1654
+ useExisting: MatSliderRangeThumb
1655
+ }],
1656
+ exportAs: ["matSliderRangeThumb"],
1657
+ usesInheritance: true,
1658
+ ngImport: i0
1659
+ });
1758
1660
  }
1759
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderRangeThumb, decorators: [{
1760
- type: Directive,
1761
- args: [{
1762
- selector: 'input[matSliderStartThumb], input[matSliderEndThumb]',
1763
- exportAs: 'matSliderRangeThumb',
1764
- providers: [
1765
- MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR,
1766
- { provide: MAT_SLIDER_RANGE_THUMB, useExisting: MatSliderRangeThumb },
1767
- ],
1768
- }]
1769
- }], ctorParameters: () => [] });
1661
+ i0.ɵɵngDeclareClassMetadata({
1662
+ minVersion: "12.0.0",
1663
+ version: "20.2.0-next.2",
1664
+ ngImport: i0,
1665
+ type: MatSliderRangeThumb,
1666
+ decorators: [{
1667
+ type: Directive,
1668
+ args: [{
1669
+ selector: 'input[matSliderStartThumb], input[matSliderEndThumb]',
1670
+ exportAs: 'matSliderRangeThumb',
1671
+ providers: [MAT_SLIDER_RANGE_THUMB_VALUE_ACCESSOR, {
1672
+ provide: MAT_SLIDER_RANGE_THUMB,
1673
+ useExisting: MatSliderRangeThumb
1674
+ }]
1675
+ }]
1676
+ }],
1677
+ ctorParameters: () => []
1678
+ });
1770
1679
 
1771
1680
  class MatSliderModule {
1772
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1773
- static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderModule, imports: [MatRippleModule, MatSlider, MatSliderThumb, MatSliderRangeThumb, MatSliderVisualThumb], exports: [MatSlider, MatSliderThumb, MatSliderRangeThumb, BidiModule] });
1774
- static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderModule, imports: [MatRippleModule, BidiModule] });
1681
+ static ɵfac = i0.ɵɵngDeclareFactory({
1682
+ minVersion: "12.0.0",
1683
+ version: "20.2.0-next.2",
1684
+ ngImport: i0,
1685
+ type: MatSliderModule,
1686
+ deps: [],
1687
+ target: i0.ɵɵFactoryTarget.NgModule
1688
+ });
1689
+ static ɵmod = i0.ɵɵngDeclareNgModule({
1690
+ minVersion: "14.0.0",
1691
+ version: "20.2.0-next.2",
1692
+ ngImport: i0,
1693
+ type: MatSliderModule,
1694
+ imports: [MatRippleModule, MatSlider, MatSliderThumb, MatSliderRangeThumb, MatSliderVisualThumb],
1695
+ exports: [MatSlider, MatSliderThumb, MatSliderRangeThumb, BidiModule]
1696
+ });
1697
+ static ɵinj = i0.ɵɵngDeclareInjector({
1698
+ minVersion: "12.0.0",
1699
+ version: "20.2.0-next.2",
1700
+ ngImport: i0,
1701
+ type: MatSliderModule,
1702
+ imports: [MatRippleModule, BidiModule]
1703
+ });
1775
1704
  }
1776
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.2.0-next.2", ngImport: i0, type: MatSliderModule, decorators: [{
1777
- type: NgModule,
1778
- args: [{
1779
- imports: [MatRippleModule, MatSlider, MatSliderThumb, MatSliderRangeThumb, MatSliderVisualThumb],
1780
- exports: [MatSlider, MatSliderThumb, MatSliderRangeThumb, BidiModule],
1781
- }]
1782
- }] });
1705
+ i0.ɵɵngDeclareClassMetadata({
1706
+ minVersion: "12.0.0",
1707
+ version: "20.2.0-next.2",
1708
+ ngImport: i0,
1709
+ type: MatSliderModule,
1710
+ decorators: [{
1711
+ type: NgModule,
1712
+ args: [{
1713
+ imports: [MatRippleModule, MatSlider, MatSliderThumb, MatSliderRangeThumb, MatSliderVisualThumb],
1714
+ exports: [MatSlider, MatSliderThumb, MatSliderRangeThumb, BidiModule]
1715
+ }]
1716
+ }]
1717
+ });
1783
1718
 
1784
1719
  export { MatSlider, MatSliderChange, MatSliderModule, MatSliderRangeThumb, MatSliderThumb, MatSliderVisualThumb };
1785
1720
  //# sourceMappingURL=slider.mjs.map