@ngx-formly/material 6.0.4 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/esm2020/checkbox/checkbox.module.mjs +4 -4
  3. package/esm2020/checkbox/checkbox.type.mjs +3 -3
  4. package/esm2020/datepicker/datepicker.module.mjs +4 -4
  5. package/esm2020/datepicker/datepicker.type.mjs +3 -3
  6. package/esm2020/form-field/field.type.mjs +3 -3
  7. package/esm2020/form-field/form-field.module.mjs +4 -4
  8. package/esm2020/form-field/form-field.wrapper.mjs +16 -16
  9. package/esm2020/input/input.module.mjs +4 -4
  10. package/esm2020/input/input.type.mjs +3 -3
  11. package/esm2020/lib/ui-material.module.mjs +4 -4
  12. package/esm2020/multicheckbox/multicheckbox.module.mjs +4 -4
  13. package/esm2020/multicheckbox/multicheckbox.type.mjs +6 -6
  14. package/esm2020/native-select/native-select.module.mjs +4 -4
  15. package/esm2020/native-select/native-select.type.mjs +6 -6
  16. package/esm2020/radio/radio.module.mjs +4 -4
  17. package/esm2020/radio/radio.type.mjs +6 -6
  18. package/esm2020/select/select.module.mjs +4 -4
  19. package/esm2020/select/select.type.mjs +6 -6
  20. package/esm2020/slider/public_api.mjs +7 -3
  21. package/esm2020/slider/slider-input.mjs +443 -0
  22. package/esm2020/slider/slider-interface.mjs +15 -0
  23. package/esm2020/slider/slider-mdc.type.mjs +80 -0
  24. package/esm2020/slider/slider.module.mjs +18 -7
  25. package/esm2020/slider/slider.type.mjs +15 -7
  26. package/esm2020/textarea/textarea.module.mjs +4 -4
  27. package/esm2020/textarea/textarea.type.mjs +3 -3
  28. package/esm2020/toggle/toggle.module.mjs +4 -4
  29. package/esm2020/toggle/toggle.type.mjs +3 -3
  30. package/fesm2015/ngx-formly-material-checkbox.mjs +7 -7
  31. package/fesm2015/ngx-formly-material-datepicker.mjs +7 -7
  32. package/fesm2015/ngx-formly-material-form-field.mjs +22 -22
  33. package/fesm2015/ngx-formly-material-form-field.mjs.map +1 -1
  34. package/fesm2015/ngx-formly-material-input.mjs +7 -7
  35. package/fesm2015/ngx-formly-material-multicheckbox.mjs +9 -9
  36. package/fesm2015/ngx-formly-material-multicheckbox.mjs.map +1 -1
  37. package/fesm2015/ngx-formly-material-native-select.mjs +9 -9
  38. package/fesm2015/ngx-formly-material-native-select.mjs.map +1 -1
  39. package/fesm2015/ngx-formly-material-radio.mjs +9 -9
  40. package/fesm2015/ngx-formly-material-radio.mjs.map +1 -1
  41. package/fesm2015/ngx-formly-material-select.mjs +9 -9
  42. package/fesm2015/ngx-formly-material-select.mjs.map +1 -1
  43. package/fesm2015/ngx-formly-material-slider.mjs +565 -18
  44. package/fesm2015/ngx-formly-material-slider.mjs.map +1 -1
  45. package/fesm2015/ngx-formly-material-textarea.mjs +7 -7
  46. package/fesm2015/ngx-formly-material-toggle.mjs +7 -7
  47. package/fesm2015/ngx-formly-material.mjs +4 -4
  48. package/fesm2020/ngx-formly-material-checkbox.mjs +7 -7
  49. package/fesm2020/ngx-formly-material-datepicker.mjs +7 -7
  50. package/fesm2020/ngx-formly-material-form-field.mjs +22 -22
  51. package/fesm2020/ngx-formly-material-form-field.mjs.map +1 -1
  52. package/fesm2020/ngx-formly-material-input.mjs +7 -7
  53. package/fesm2020/ngx-formly-material-multicheckbox.mjs +9 -9
  54. package/fesm2020/ngx-formly-material-multicheckbox.mjs.map +1 -1
  55. package/fesm2020/ngx-formly-material-native-select.mjs +9 -9
  56. package/fesm2020/ngx-formly-material-native-select.mjs.map +1 -1
  57. package/fesm2020/ngx-formly-material-radio.mjs +9 -9
  58. package/fesm2020/ngx-formly-material-radio.mjs.map +1 -1
  59. package/fesm2020/ngx-formly-material-select.mjs +9 -9
  60. package/fesm2020/ngx-formly-material-select.mjs.map +1 -1
  61. package/fesm2020/ngx-formly-material-slider.mjs +560 -18
  62. package/fesm2020/ngx-formly-material-slider.mjs.map +1 -1
  63. package/fesm2020/ngx-formly-material-textarea.mjs +7 -7
  64. package/fesm2020/ngx-formly-material-toggle.mjs +7 -7
  65. package/fesm2020/ngx-formly-material.mjs +4 -4
  66. package/package.json +2 -2
  67. package/slider/public_api.d.ts +4 -2
  68. package/slider/slider-input.d.ts +178 -0
  69. package/slider/slider-interface.d.ts +133 -0
  70. package/slider/slider-mdc.type.d.ts +10 -0
  71. package/slider/slider.module.d.ts +9 -6
  72. package/slider/slider.type.d.ts +1 -0
@@ -1,15 +1,19 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Component, ChangeDetectionStrategy, ViewChild, NgModule } from '@angular/core';
2
+ import { Component, ChangeDetectionStrategy, ViewChild, InjectionToken, forwardRef, EventEmitter, Directive, Inject, Input, Output, NgModule } from '@angular/core';
3
3
  import { CommonModule } from '@angular/common';
4
4
  import * as i3 from '@ngx-formly/core';
5
5
  import { FormlyModule } from '@ngx-formly/core';
6
- import * as i2 from '@angular/forms';
7
- import { ReactiveFormsModule } from '@angular/forms';
6
+ import * as i4 from '@angular/forms';
7
+ import { NG_VALUE_ACCESSOR, ReactiveFormsModule } from '@angular/forms';
8
8
  import * as i1 from '@angular/material/slider';
9
9
  import { MatSlider, MatSliderModule } from '@angular/material/slider';
10
10
  import { FieldType, FormlyMatFormFieldModule } from '@ngx-formly/material/form-field';
11
+ import { VERSION } from '@angular/cdk';
12
+ import { MatCommonModule, MatRippleModule } from '@angular/material/core';
13
+ import { coerceNumberProperty, coerceBooleanProperty } from '@angular/cdk/coercion';
14
+ import { Subject } from 'rxjs';
11
15
 
12
- class FormlyFieldSlider extends FieldType {
16
+ class FormlyFieldSlider$2 extends FieldType {
13
17
  constructor() {
14
18
  super(...arguments);
15
19
  this.defaultOptions = {
@@ -21,12 +25,20 @@ class FormlyFieldSlider extends FieldType {
21
25
  };
22
26
  }
23
27
  onContainerClick(event) {
24
- this.slider.focus();
28
+ this.slider.focus?.();
25
29
  super.onContainerClick(event);
26
30
  }
31
+ displayWith(value) {
32
+ if (this.props?.displayWith) {
33
+ return String(this.props.displayWith(value));
34
+ }
35
+ else {
36
+ return String(value);
37
+ }
38
+ }
27
39
  }
28
- FormlyFieldSlider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyFieldSlider, deps: null, target: i0.ɵɵFactoryTarget.Component });
29
- FormlyFieldSlider.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.11", type: FormlyFieldSlider, selector: "formly-field-mat-slider", viewQueries: [{ propertyName: "slider", first: true, predicate: MatSlider, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
40
+ FormlyFieldSlider$2.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldSlider$2, deps: null, target: i0.ɵɵFactoryTarget.Component });
41
+ FormlyFieldSlider$2.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FormlyFieldSlider$2, selector: "formly-field-mat-slider", viewQueries: [{ propertyName: "slider", first: true, predicate: MatSlider, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
30
42
  <mat-slider
31
43
  [id]="id"
32
44
  [style.width]="'100%'"
@@ -34,7 +46,7 @@ FormlyFieldSlider.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
34
46
  [formlyAttributes]="field"
35
47
  [tabIndex]="props.tabindex"
36
48
  [color]="props.color"
37
- [displayWith]="props.displayWith"
49
+ [displayWith]="displayWith"
38
50
  [invert]="props.invert"
39
51
  [max]="props.max"
40
52
  [min]="props.min"
@@ -47,8 +59,8 @@ FormlyFieldSlider.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", vers
47
59
  (change)="props.change && props.change(field, $event)"
48
60
  >
49
61
  </mat-slider>
50
- `, isInline: true, components: [{ type: i1.MatSlider, selector: "mat-slider", inputs: ["disabled", "color", "tabIndex", "invert", "max", "min", "step", "thumbLabel", "tickInterval", "value", "displayWith", "valueText", "vertical"], outputs: ["change", "input", "valueChange"], exportAs: ["matSlider"] }], directives: [{ type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.ɵFormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
51
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyFieldSlider, decorators: [{
62
+ `, isInline: true, components: [{ type: i1.MatSlider, selector: "mat-slider", inputs: ["disabled", "color", "tabIndex", "invert", "max", "min", "step", "thumbLabel", "tickInterval", "value", "displayWith", "valueText", "vertical"], outputs: ["change", "input", "valueChange"], exportAs: ["matSlider"] }], directives: [{ type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i3.ɵFormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
63
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldSlider$2, decorators: [{
52
64
  type: Component,
53
65
  args: [{
54
66
  selector: 'formly-field-mat-slider',
@@ -60,7 +72,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
60
72
  [formlyAttributes]="field"
61
73
  [tabIndex]="props.tabindex"
62
74
  [color]="props.color"
63
- [displayWith]="props.displayWith"
75
+ [displayWith]="displayWith"
64
76
  [invert]="props.invert"
65
77
  [max]="props.max"
66
78
  [min]="props.min"
@@ -81,15 +93,541 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
81
93
  args: [MatSlider, { static: true }]
82
94
  }] } });
83
95
 
96
+ /**
97
+ * @license
98
+ * Copyright Google LLC All Rights Reserved.
99
+ *
100
+ * Use of this source code is governed by an MIT-style license that can be
101
+ * found in the LICENSE file at https://angular.io/license
102
+ */
103
+ /**
104
+ * Injection token that can be used to query for a `MatSliderThumb`.
105
+ * Used primarily to avoid circular imports.
106
+ * @docs-private
107
+ */
108
+ const MAT_SLIDER_THUMB = new InjectionToken('_MatSliderThumb');
109
+
110
+ /**
111
+ * @license
112
+ * Copyright Google LLC All Rights Reserved.
113
+ *
114
+ * Use of this source code is governed by an MIT-style license that can be
115
+ * found in the LICENSE file at https://angular.io/license
116
+ */
117
+ /**
118
+ * Provider that allows the slider thumb to register as a ControlValueAccessor.
119
+ * @docs-private
120
+ */
121
+ const MAT_SLIDER_THUMB_VALUE_ACCESSOR = {
122
+ provide: NG_VALUE_ACCESSOR,
123
+ useExisting: forwardRef(() => MatSliderThumb),
124
+ multi: true,
125
+ };
126
+ /**
127
+ * Directive that adds slider-specific behaviors to an input element inside `<mat-slider>`.
128
+ * Up to two may be placed inside of a `<mat-slider>`.
129
+ *
130
+ * If one is used, the selector `matSliderThumb` must be used, and the outcome will be a normal
131
+ * slider. If two are used, the selectors `matSliderStartThumb` and `matSliderEndThumb` must be
132
+ * used, and the outcome will be a range slider with two slider thumbs.
133
+ */
134
+ class MatSliderThumb {
135
+ constructor(_ngZone, _elementRef, _cdr, _slider) {
136
+ this._ngZone = _ngZone;
137
+ this._elementRef = _elementRef;
138
+ this._cdr = _cdr;
139
+ this._slider = _slider;
140
+ /** Event emitted when the `value` is changed. */
141
+ this.valueChange = new EventEmitter();
142
+ /** Event emitted when the slider thumb starts being dragged. */
143
+ this.dragStart = new EventEmitter();
144
+ /** Event emitted when the slider thumb stops being dragged. */
145
+ this.dragEnd = new EventEmitter();
146
+ /**
147
+ * Indicates whether this thumb is the start or end thumb.
148
+ * @docs-private
149
+ */
150
+ this.thumbPosition = 2 /* END */;
151
+ /** The radius of a native html slider's knob. */
152
+ this._knobRadius = 8;
153
+ /** Whether user's cursor is currently in a mouse down state on the input. */
154
+ this._isActive = false;
155
+ /** Whether the input is currently focused (either by tab or after clicking). */
156
+ this._isFocused = false;
157
+ /**
158
+ * Whether the initial value has been set.
159
+ * This exists because the initial value cannot be immediately set because the min and max
160
+ * must first be relayed from the parent MatSlider component, which can only happen later
161
+ * in the component lifecycle.
162
+ */
163
+ this._hasSetInitialValue = false;
164
+ /** Emits when the component is destroyed. */
165
+ this._destroyed = new Subject();
166
+ /**
167
+ * Indicates whether UI updates should be skipped.
168
+ *
169
+ * This flag is used to avoid flickering
170
+ * when correcting values on pointer up/down.
171
+ */
172
+ this._skipUIUpdate = false;
173
+ /** Callback called when the slider input value changes. */
174
+ this._onChangeFn = () => { };
175
+ /** Callback called when the slider input has been touched. */
176
+ this._onTouchedFn = () => { };
177
+ this._hostElement = _elementRef.nativeElement;
178
+ this._ngZone.runOutsideAngular(() => {
179
+ this._hostElement.addEventListener('pointerdown', this._onPointerDown.bind(this));
180
+ this._hostElement.addEventListener('pointermove', this._onPointerMove.bind(this));
181
+ this._hostElement.addEventListener('pointerup', this._onPointerUp.bind(this));
182
+ });
183
+ }
184
+ get value() {
185
+ return coerceNumberProperty(this._hostElement.value);
186
+ }
187
+ set value(v) {
188
+ const val = coerceNumberProperty(v).toString();
189
+ if (!this._hasSetInitialValue) {
190
+ this._initialValue = val;
191
+ return;
192
+ }
193
+ if (this._isActive) {
194
+ return;
195
+ }
196
+ this._hostElement.value = val;
197
+ this._updateThumbUIByValue();
198
+ this._slider._onValueChange(this);
199
+ this._cdr.detectChanges();
200
+ }
201
+ /**
202
+ * The current translateX in px of the slider visual thumb.
203
+ * @docs-private
204
+ */
205
+ get translateX() {
206
+ if (this._slider.min >= this._slider.max) {
207
+ this._translateX = 0;
208
+ return this._translateX;
209
+ }
210
+ if (this._translateX === undefined) {
211
+ this._translateX = this._calcTranslateXByValue();
212
+ }
213
+ return this._translateX;
214
+ }
215
+ set translateX(v) {
216
+ this._translateX = v;
217
+ }
218
+ /** @docs-private */
219
+ get min() {
220
+ return coerceNumberProperty(this._hostElement.min);
221
+ }
222
+ set min(v) {
223
+ this._hostElement.min = coerceNumberProperty(v).toString();
224
+ this._cdr.detectChanges();
225
+ }
226
+ /** @docs-private */
227
+ get max() {
228
+ return coerceNumberProperty(this._hostElement.max);
229
+ }
230
+ set max(v) {
231
+ this._hostElement.max = coerceNumberProperty(v).toString();
232
+ this._cdr.detectChanges();
233
+ }
234
+ get step() {
235
+ return coerceNumberProperty(this._hostElement.step);
236
+ }
237
+ set step(v) {
238
+ this._hostElement.step = coerceNumberProperty(v).toString();
239
+ this._cdr.detectChanges();
240
+ }
241
+ /** @docs-private */
242
+ get disabled() {
243
+ return coerceBooleanProperty(this._hostElement.disabled);
244
+ }
245
+ set disabled(v) {
246
+ this._hostElement.disabled = coerceBooleanProperty(v);
247
+ this._cdr.detectChanges();
248
+ if (this._slider.disabled !== this.disabled) {
249
+ this._slider.disabled = this.disabled;
250
+ }
251
+ }
252
+ /** The percentage of the slider that coincides with the value. */
253
+ get percentage() {
254
+ if (this._slider.min >= this._slider.max) {
255
+ return this._slider._isRtl ? 1 : 0;
256
+ }
257
+ return (this.value - this._slider.min) / (this._slider.max - this._slider.min);
258
+ }
259
+ /** @docs-private */
260
+ get fillPercentage() {
261
+ if (!this._slider._cachedWidth) {
262
+ return this._slider._isRtl ? 1 : 0;
263
+ }
264
+ if (this._translateX === 0) {
265
+ return 0;
266
+ }
267
+ return this.translateX / this._slider._cachedWidth;
268
+ }
269
+ /** Used to relay updates to _isFocused to the slider visual thumbs. */
270
+ _setIsFocused(v) {
271
+ this._isFocused = v;
272
+ }
273
+ ngOnDestroy() {
274
+ this._hostElement.removeEventListener('pointerdown', this._onPointerDown);
275
+ this._hostElement.removeEventListener('pointermove', this._onPointerMove);
276
+ this._hostElement.removeEventListener('pointerup', this._onPointerUp);
277
+ this._destroyed.next();
278
+ this._destroyed.complete();
279
+ this.dragStart.complete();
280
+ this.dragEnd.complete();
281
+ }
282
+ /** @docs-private */
283
+ initProps() {
284
+ this._updateWidthInactive();
285
+ // If this or the parent slider is disabled, just make everything disabled.
286
+ if (this.disabled !== this._slider.disabled) {
287
+ // The MatSlider setter for disabled will relay this and disable both inputs.
288
+ this._slider.disabled = true;
289
+ }
290
+ this.step = this._slider.step;
291
+ this.min = this._slider.min;
292
+ this.max = this._slider.max;
293
+ this._initValue();
294
+ }
295
+ /** @docs-private */
296
+ initUI() {
297
+ this._updateThumbUIByValue();
298
+ }
299
+ _initValue() {
300
+ this._hasSetInitialValue = true;
301
+ if (this._initialValue === undefined) {
302
+ this.value = this._getDefaultValue();
303
+ }
304
+ else {
305
+ this._hostElement.value = this._initialValue;
306
+ this._updateThumbUIByValue();
307
+ this._slider._onValueChange(this);
308
+ this._cdr.detectChanges();
309
+ }
310
+ }
311
+ _getDefaultValue() {
312
+ return this.min;
313
+ }
314
+ _onBlur() {
315
+ this._setIsFocused(false);
316
+ this._onTouchedFn();
317
+ }
318
+ _onFocus() {
319
+ this._setIsFocused(true);
320
+ }
321
+ _onChange() {
322
+ // only used to handle the edge case where user
323
+ // mousedown on the slider then uses arrow keys.
324
+ if (this._isActive) {
325
+ this._updateThumbUIByValue({ withAnimation: true });
326
+ }
327
+ }
328
+ _onInput() {
329
+ this.valueChange.emit(this.value);
330
+ this._onChangeFn(this.value);
331
+ // handles arrowing and updating the value when
332
+ // a step is defined.
333
+ if (this._slider.step || !this._isActive) {
334
+ this._updateThumbUIByValue({ withAnimation: true });
335
+ }
336
+ this._slider._onValueChange(this);
337
+ }
338
+ _onNgControlValueChange() {
339
+ // only used to handle when the value change
340
+ // originates outside of the slider.
341
+ if (!this._isActive || !this._isFocused) {
342
+ this._slider._onValueChange(this);
343
+ this._updateThumbUIByValue();
344
+ }
345
+ this._slider.disabled = this._formControl.disabled;
346
+ }
347
+ _onPointerDown(event) {
348
+ if (this.disabled || event.button !== 0) {
349
+ return;
350
+ }
351
+ this._isActive = true;
352
+ this._setIsFocused(true);
353
+ this._updateWidthActive();
354
+ this._slider._updateDimensions();
355
+ // Does nothing if a step is defined because we
356
+ // want the value to snap to the values on input.
357
+ if (!this._slider.step) {
358
+ this._updateThumbUIByPointerEvent(event, { withAnimation: true });
359
+ }
360
+ if (!this.disabled) {
361
+ this._handleValueCorrection(event);
362
+ }
363
+ }
364
+ /**
365
+ * Corrects the value of the slider on pointer up/down.
366
+ *
367
+ * Called on pointer down and up because the value is set based
368
+ * on the inactive width instead of the active width.
369
+ */
370
+ _handleValueCorrection(event) {
371
+ // Don't update the UI with the current value! The value on pointerdown
372
+ // and pointerup is calculated in the split second before the input(s)
373
+ // resize. See _updateWidthInactive() and _updateWidthActive() for more
374
+ // details.
375
+ this._skipUIUpdate = true;
376
+ // Note that this function gets triggered before the actual value of the
377
+ // slider is updated. This means if we were to set the value here, it
378
+ // would immediately be overwritten. Using setTimeout ensures the setting
379
+ // of the value happens after the value has been updated by the
380
+ // pointerdown event.
381
+ setTimeout(() => {
382
+ this._skipUIUpdate = false;
383
+ this._fixValue(event);
384
+ }, 0);
385
+ }
386
+ /** Corrects the value of the slider based on the pointer event's position. */
387
+ _fixValue(event) {
388
+ const xPos = event.clientX - this._slider._cachedLeft;
389
+ const width = this._slider._cachedWidth;
390
+ const step = this._slider.step === 0 ? 1 : this._slider.step;
391
+ const numSteps = Math.floor((this._slider.max - this._slider.min) / step);
392
+ const percentage = this._slider._isRtl ? 1 - xPos / width : xPos / width;
393
+ // To ensure the percentage is rounded to the necessary number of decimals.
394
+ const fixedPercentage = Math.round(percentage * numSteps) / numSteps;
395
+ const impreciseValue = fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min;
396
+ const value = Math.round(impreciseValue / step) * step;
397
+ const prevValue = this.value;
398
+ const dragEvent = { source: this, parent: this._slider, value: value };
399
+ this._isActive ? this.dragStart.emit(dragEvent) : this.dragEnd.emit(dragEvent);
400
+ if (value === prevValue) {
401
+ // Because we prevented UI updates, if it turns out that the race
402
+ // condition didn't happen and the value is already correct, we
403
+ // have to apply the ui updates now.
404
+ this._slider._onValueChange(this);
405
+ this._slider.step > 0
406
+ ? this._updateThumbUIByValue()
407
+ : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
408
+ return;
409
+ }
410
+ this.value = value;
411
+ this.valueChange.emit(this.value);
412
+ this._onChangeFn(this.value);
413
+ this._slider._onValueChange(this);
414
+ this._slider.step > 0
415
+ ? this._updateThumbUIByValue()
416
+ : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
417
+ }
418
+ _onPointerMove(event) {
419
+ // Again, does nothing if a step is defined because
420
+ // we want the value to snap to the values on input.
421
+ if (!this._slider.step && this._isActive) {
422
+ this._updateThumbUIByPointerEvent(event);
423
+ }
424
+ }
425
+ _onPointerUp(event) {
426
+ this._isActive = false;
427
+ this._updateWidthInactive();
428
+ if (!this.disabled) {
429
+ this._handleValueCorrection(event);
430
+ }
431
+ }
432
+ _clamp(v) {
433
+ return Math.max(Math.min(v, this._slider._cachedWidth), 0);
434
+ }
435
+ _calcTranslateXByValue() {
436
+ if (this._slider._isRtl) {
437
+ return (1 - this.percentage) * this._slider._cachedWidth;
438
+ }
439
+ return this.percentage * this._slider._cachedWidth;
440
+ }
441
+ _calcTranslateXByPointerEvent(event) {
442
+ return event.clientX - this._slider._cachedLeft;
443
+ }
444
+ /**
445
+ * Used to set the slider width to the correct
446
+ * dimensions while the user is dragging.
447
+ */
448
+ _updateWidthActive() {
449
+ this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
450
+ this._hostElement.style.width = `calc(100% + ${this._slider._inputPadding}px)`;
451
+ }
452
+ /**
453
+ * Sets the slider input to disproportionate dimensions to allow for touch
454
+ * events to be captured on touch devices.
455
+ */
456
+ _updateWidthInactive() {
457
+ this._hostElement.style.padding = '0px';
458
+ this._hostElement.style.width = 'calc(100% + 48px)';
459
+ this._hostElement.style.left = '-24px';
460
+ }
461
+ _updateThumbUIByValue(options) {
462
+ this.translateX = this._clamp(this._calcTranslateXByValue());
463
+ this._updateThumbUI(options);
464
+ }
465
+ _updateThumbUIByPointerEvent(event, options) {
466
+ this.translateX = this._clamp(this._calcTranslateXByPointerEvent(event));
467
+ this._updateThumbUI(options);
468
+ }
469
+ _updateThumbUI(options) {
470
+ this._slider._setTransition(!!options?.withAnimation);
471
+ this._slider._onTranslateXChange(this);
472
+ }
473
+ /**
474
+ * Sets the input's value.
475
+ * @param value The new value of the input
476
+ * @docs-private
477
+ */
478
+ writeValue(value) {
479
+ this.value = value;
480
+ }
481
+ /**
482
+ * Registers a callback to be invoked when the input's value changes from user input.
483
+ * @param fn The callback to register
484
+ * @docs-private
485
+ */
486
+ registerOnChange(fn) {
487
+ this._onChangeFn = fn;
488
+ }
489
+ /**
490
+ * Registers a callback to be invoked when the input is blurred by the user.
491
+ * @param fn The callback to register
492
+ * @docs-private
493
+ */
494
+ registerOnTouched(fn) {
495
+ this._onTouchedFn = fn;
496
+ }
497
+ /**
498
+ * Sets the disabled state of the slider.
499
+ * @param isDisabled The new disabled state
500
+ * @docs-private
501
+ */
502
+ setDisabledState(isDisabled) {
503
+ this.disabled = isDisabled;
504
+ }
505
+ focus() {
506
+ this._hostElement.focus();
507
+ }
508
+ blur() {
509
+ this._hostElement.blur();
510
+ }
511
+ }
512
+ MatSliderThumb.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MatSliderThumb, deps: [{ token: i0.NgZone }, { token: i0.ElementRef }, { token: i0.ChangeDetectorRef }, { token: MatSlider }], target: i0.ɵɵFactoryTarget.Directive });
513
+ MatSliderThumb.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.3.12", type: MatSliderThumb, selector: "input[matSliderThumb]", inputs: { value: "value" }, 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: [MAT_SLIDER_THUMB_VALUE_ACCESSOR, { provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb }], exportAs: ["matSliderThumb"], ngImport: i0 });
514
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MatSliderThumb, decorators: [{
515
+ type: Directive,
516
+ args: [{
517
+ // eslint-disable-next-line
518
+ selector: 'input[matSliderThumb]',
519
+ exportAs: 'matSliderThumb',
520
+ host: {
521
+ class: 'mdc-slider__input',
522
+ type: 'range',
523
+ '[attr.aria-valuetext]': '_valuetext',
524
+ '(change)': '_onChange()',
525
+ '(input)': '_onInput()',
526
+ // TODO(wagnermaciel): Consider using a global event listener instead.
527
+ // Reason: I have found a semi-consistent way to mouse up without triggering this event.
528
+ '(blur)': '_onBlur()',
529
+ '(focus)': '_onFocus()',
530
+ },
531
+ providers: [MAT_SLIDER_THUMB_VALUE_ACCESSOR, { provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb }],
532
+ }]
533
+ }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
534
+ type: Inject,
535
+ args: [MatSlider]
536
+ }] }]; }, propDecorators: { value: [{
537
+ type: Input
538
+ }], valueChange: [{
539
+ type: Output
540
+ }], dragStart: [{
541
+ type: Output
542
+ }], dragEnd: [{
543
+ type: Output
544
+ }] } });
545
+
546
+ class FormlyFieldMDCSlider extends FormlyFieldSlider$2 {
547
+ set mdcSlider(slider) {
548
+ Object.defineProperty(slider, '_input', {
549
+ set: () => { },
550
+ get: () => this.sliderThumb,
551
+ });
552
+ }
553
+ onContainerClick(event) {
554
+ this.sliderThumb?._hostElement.focus();
555
+ super.onContainerClick(event);
556
+ }
557
+ }
558
+ FormlyFieldMDCSlider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldMDCSlider, deps: null, target: i0.ɵɵFactoryTarget.Component });
559
+ FormlyFieldMDCSlider.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.12", type: FormlyFieldMDCSlider, selector: "formly-field-mat-slider", viewQueries: [{ propertyName: "sliderThumb", first: true, predicate: MAT_SLIDER_THUMB, descendants: true, static: true }, { propertyName: "mdcSlider", first: true, predicate: MatSlider, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
560
+ <mat-slider
561
+ [id]="id"
562
+ [style.width]="'100%'"
563
+ [formlyAttributes]="field"
564
+ [tabIndex]="props.tabindex"
565
+ [color]="props.color"
566
+ [displayWith]="displayWith"
567
+ [invert]="props.invert"
568
+ [max]="props.max"
569
+ [min]="props.min"
570
+ [step]="props.step"
571
+ [thumbLabel]="props.thumbLabel"
572
+ [tickInterval]="props.tickInterval"
573
+ [valueText]="props.valueText"
574
+ [vertical]="props.vertical"
575
+ (input)="props.input && props.input(field, $event)"
576
+ (change)="props.change && props.change(field, $event)"
577
+ >
578
+ <input matSliderThumb [formControl]="formControl" [formlyAttributes]="field" />
579
+ </mat-slider>
580
+ `, isInline: true, components: [{ type: i1.MatSlider, selector: "mat-slider", inputs: ["disabled", "color", "tabIndex", "invert", "max", "min", "step", "thumbLabel", "tickInterval", "value", "displayWith", "valueText", "vertical"], outputs: ["change", "input", "valueChange"], exportAs: ["matSlider"] }], directives: [{ type: i3.ɵFormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }, { type: MatSliderThumb, selector: "input[matSliderThumb]", inputs: ["value"], outputs: ["valueChange", "dragStart", "dragEnd"], exportAs: ["matSliderThumb"] }, { type: i4.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i4.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i4.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
581
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldMDCSlider, decorators: [{
582
+ type: Component,
583
+ args: [{
584
+ selector: 'formly-field-mat-slider',
585
+ template: `
586
+ <mat-slider
587
+ [id]="id"
588
+ [style.width]="'100%'"
589
+ [formlyAttributes]="field"
590
+ [tabIndex]="props.tabindex"
591
+ [color]="props.color"
592
+ [displayWith]="displayWith"
593
+ [invert]="props.invert"
594
+ [max]="props.max"
595
+ [min]="props.min"
596
+ [step]="props.step"
597
+ [thumbLabel]="props.thumbLabel"
598
+ [tickInterval]="props.tickInterval"
599
+ [valueText]="props.valueText"
600
+ [vertical]="props.vertical"
601
+ (input)="props.input && props.input(field, $event)"
602
+ (change)="props.change && props.change(field, $event)"
603
+ >
604
+ <input matSliderThumb [formControl]="formControl" [formlyAttributes]="field" />
605
+ </mat-slider>
606
+ `,
607
+ changeDetection: ChangeDetectionStrategy.OnPush,
608
+ }]
609
+ }], propDecorators: { sliderThumb: [{
610
+ type: ViewChild,
611
+ args: [MAT_SLIDER_THUMB, { static: true }]
612
+ }], mdcSlider: [{
613
+ type: ViewChild,
614
+ args: [MatSlider, { static: true }]
615
+ }] } });
616
+
617
+ const FormlyFieldSlider$1 = Number(VERSION.major) >= 15 ? FormlyFieldMDCSlider : FormlyFieldSlider$2;
84
618
  class FormlyMatSliderModule {
85
619
  }
86
- FormlyMatSliderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
87
- FormlyMatSliderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, declarations: [FormlyFieldSlider], imports: [CommonModule,
620
+ FormlyMatSliderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
621
+ FormlyMatSliderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, declarations: [FormlyFieldSlider$2, FormlyFieldMDCSlider, MatSliderThumb], imports: [CommonModule,
622
+ MatCommonModule,
623
+ MatRippleModule,
88
624
  ReactiveFormsModule,
89
625
  MatSliderModule,
90
626
  FormlyMatFormFieldModule, i3.FormlyModule] });
91
- FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, imports: [[
627
+ FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, imports: [[
92
628
  CommonModule,
629
+ MatCommonModule,
630
+ MatRippleModule,
93
631
  ReactiveFormsModule,
94
632
  MatSliderModule,
95
633
  FormlyMatFormFieldModule,
@@ -97,18 +635,20 @@ FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", v
97
635
  types: [
98
636
  {
99
637
  name: 'slider',
100
- component: FormlyFieldSlider,
638
+ component: FormlyFieldSlider$1,
101
639
  wrappers: ['form-field'],
102
640
  },
103
641
  ],
104
642
  }),
105
643
  ]] });
106
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, decorators: [{
644
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, decorators: [{
107
645
  type: NgModule,
108
646
  args: [{
109
- declarations: [FormlyFieldSlider],
647
+ declarations: [FormlyFieldSlider$2, FormlyFieldMDCSlider, MatSliderThumb],
110
648
  imports: [
111
649
  CommonModule,
650
+ MatCommonModule,
651
+ MatRippleModule,
112
652
  ReactiveFormsModule,
113
653
  MatSliderModule,
114
654
  FormlyMatFormFieldModule,
@@ -116,7 +656,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
116
656
  types: [
117
657
  {
118
658
  name: 'slider',
119
- component: FormlyFieldSlider,
659
+ component: FormlyFieldSlider$1,
120
660
  wrappers: ['form-field'],
121
661
  },
122
662
  ],
@@ -125,6 +665,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
125
665
  }]
126
666
  }] });
127
667
 
668
+ const FormlyFieldSlider = Number(VERSION.major) >= 15 ? FormlyFieldMDCSlider : FormlyFieldSlider$2;
669
+
128
670
  /**
129
671
  * Generated bundle index. Do not edit.
130
672
  */