@ngx-formly/material 6.0.4 → 6.1.1

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 (75) 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 +24 -5
  7. package/esm2020/form-field/form-field.module.mjs +7 -6
  8. package/esm2020/form-field/form-field.wrapper.mjs +34 -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 +20 -8
  20. package/esm2020/slider/public_api.mjs +7 -3
  21. package/esm2020/slider/slider-input.mjs +442 -0
  22. package/esm2020/slider/slider-interface.mjs +15 -0
  23. package/esm2020/slider/slider-mdc.type.mjs +94 -0
  24. package/esm2020/slider/slider.module.mjs +20 -8
  25. package/esm2020/slider/slider.type.mjs +17 -9
  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 +63 -25
  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 +23 -13
  42. package/fesm2015/ngx-formly-material-select.mjs.map +1 -1
  43. package/fesm2015/ngx-formly-material-slider.mjs +581 -20
  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 +62 -24
  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 +23 -13
  60. package/fesm2020/ngx-formly-material-select.mjs.map +1 -1
  61. package/fesm2020/ngx-formly-material-slider.mjs +576 -20
  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/form-field/field.type.d.ts +2 -0
  67. package/form-field/form-field.wrapper.d.ts +3 -0
  68. package/package.json +2 -2
  69. package/select/select.type.d.ts +1 -0
  70. package/slider/public_api.d.ts +4 -2
  71. package/slider/slider-input.d.ts +178 -0
  72. package/slider/slider-interface.d.ts +133 -0
  73. package/slider/slider-mdc.type.d.ts +10 -0
  74. package/slider/slider.module.d.ts +9 -6
  75. package/slider/slider.type.d.ts +5 -1
@@ -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, NO_ERRORS_SCHEMA } 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,12 +46,12 @@ 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"
41
53
  [step]="props.step"
42
- [thumbLabel]="props.thumbLabel"
54
+ [thumbLabel]="props.thumbLabel || props.discrete"
43
55
  [tickInterval]="props.tickInterval"
44
56
  [valueText]="props.valueText"
45
57
  [vertical]="props.vertical"
@@ -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,12 +72,12 @@ 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"
67
79
  [step]="props.step"
68
- [thumbLabel]="props.thumbLabel"
80
+ [thumbLabel]="props.thumbLabel || props.discrete"
69
81
  [tickInterval]="props.tickInterval"
70
82
  [valueText]="props.valueText"
71
83
  [vertical]="props.vertical"
@@ -81,15 +93,554 @@ 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
+ this.dragStart.emit({ source: this, parent: this._slider, value: this.value });
363
+ }
364
+ }
365
+ /**
366
+ * Corrects the value of the slider on pointer up/down.
367
+ *
368
+ * Called on pointer down and up because the value is set based
369
+ * on the inactive width instead of the active width.
370
+ */
371
+ _handleValueCorrection(event) {
372
+ // Don't update the UI with the current value! The value on pointerdown
373
+ // and pointerup is calculated in the split second before the input(s)
374
+ // resize. See _updateWidthInactive() and _updateWidthActive() for more
375
+ // details.
376
+ this._skipUIUpdate = true;
377
+ // Note that this function gets triggered before the actual value of the
378
+ // slider is updated. This means if we were to set the value here, it
379
+ // would immediately be overwritten. Using setTimeout ensures the setting
380
+ // of the value happens after the value has been updated by the
381
+ // pointerdown event.
382
+ setTimeout(() => {
383
+ this._skipUIUpdate = false;
384
+ this._fixValue(event);
385
+ }, 0);
386
+ }
387
+ /** Corrects the value of the slider based on the pointer event's position. */
388
+ _fixValue(event) {
389
+ const xPos = event.clientX - this._slider._cachedLeft;
390
+ const width = this._slider._cachedWidth;
391
+ const step = this._slider.step === 0 ? 1 : this._slider.step;
392
+ const numSteps = Math.floor((this._slider.max - this._slider.min) / step);
393
+ const percentage = this._slider._isRtl ? 1 - xPos / width : xPos / width;
394
+ // To ensure the percentage is rounded to the necessary number of decimals.
395
+ const fixedPercentage = Math.round(percentage * numSteps) / numSteps;
396
+ const impreciseValue = fixedPercentage * (this._slider.max - this._slider.min) + this._slider.min;
397
+ const value = Math.round(impreciseValue / step) * step;
398
+ const prevValue = this.value;
399
+ if (value === prevValue) {
400
+ // Because we prevented UI updates, if it turns out that the race
401
+ // condition didn't happen and the value is already correct, we
402
+ // have to apply the ui updates now.
403
+ this._slider._onValueChange(this);
404
+ this._slider.step > 0
405
+ ? this._updateThumbUIByValue()
406
+ : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
407
+ return;
408
+ }
409
+ this.value = value;
410
+ this.valueChange.emit(this.value);
411
+ this._onChangeFn(this.value);
412
+ this._slider._onValueChange(this);
413
+ this._slider.step > 0
414
+ ? this._updateThumbUIByValue()
415
+ : this._updateThumbUIByPointerEvent(event, { withAnimation: this._slider._hasAnimation });
416
+ }
417
+ _onPointerMove(event) {
418
+ // Again, does nothing if a step is defined because
419
+ // we want the value to snap to the values on input.
420
+ if (!this._slider.step && this._isActive) {
421
+ this._updateThumbUIByPointerEvent(event);
422
+ }
423
+ }
424
+ _onPointerUp() {
425
+ if (this._isActive) {
426
+ this._isActive = false;
427
+ this.dragEnd.emit({ source: this, parent: this._slider, value: this.value });
428
+ setTimeout(() => this._updateWidthInactive());
429
+ }
430
+ }
431
+ _clamp(v) {
432
+ return Math.max(Math.min(v, this._slider._cachedWidth), 0);
433
+ }
434
+ _calcTranslateXByValue() {
435
+ if (this._slider._isRtl) {
436
+ return (1 - this.percentage) * this._slider._cachedWidth;
437
+ }
438
+ return this.percentage * this._slider._cachedWidth;
439
+ }
440
+ _calcTranslateXByPointerEvent(event) {
441
+ return event.clientX - this._slider._cachedLeft;
442
+ }
443
+ /**
444
+ * Used to set the slider width to the correct
445
+ * dimensions while the user is dragging.
446
+ */
447
+ _updateWidthActive() {
448
+ this._hostElement.style.padding = `0 ${this._slider._inputPadding}px`;
449
+ this._hostElement.style.width = `calc(100% + ${this._slider._inputPadding}px)`;
450
+ }
451
+ /**
452
+ * Sets the slider input to disproportionate dimensions to allow for touch
453
+ * events to be captured on touch devices.
454
+ */
455
+ _updateWidthInactive() {
456
+ this._hostElement.style.padding = '0px';
457
+ this._hostElement.style.width = 'calc(100% + 48px)';
458
+ this._hostElement.style.left = '-24px';
459
+ }
460
+ _updateThumbUIByValue(options) {
461
+ this.translateX = this._clamp(this._calcTranslateXByValue());
462
+ this._updateThumbUI(options);
463
+ }
464
+ _updateThumbUIByPointerEvent(event, options) {
465
+ this.translateX = this._clamp(this._calcTranslateXByPointerEvent(event));
466
+ this._updateThumbUI(options);
467
+ }
468
+ _updateThumbUI(options) {
469
+ this._slider._setTransition(!!options?.withAnimation);
470
+ this._slider._onTranslateXChange(this);
471
+ }
472
+ /**
473
+ * Sets the input's value.
474
+ * @param value The new value of the input
475
+ * @docs-private
476
+ */
477
+ writeValue(value) {
478
+ this.value = value;
479
+ }
480
+ /**
481
+ * Registers a callback to be invoked when the input's value changes from user input.
482
+ * @param fn The callback to register
483
+ * @docs-private
484
+ */
485
+ registerOnChange(fn) {
486
+ this._onChangeFn = fn;
487
+ }
488
+ /**
489
+ * Registers a callback to be invoked when the input is blurred by the user.
490
+ * @param fn The callback to register
491
+ * @docs-private
492
+ */
493
+ registerOnTouched(fn) {
494
+ this._onTouchedFn = fn;
495
+ }
496
+ /**
497
+ * Sets the disabled state of the slider.
498
+ * @param isDisabled The new disabled state
499
+ * @docs-private
500
+ */
501
+ setDisabledState(isDisabled) {
502
+ this.disabled = isDisabled;
503
+ }
504
+ focus() {
505
+ this._hostElement.focus();
506
+ }
507
+ blur() {
508
+ this._hostElement.blur();
509
+ }
510
+ }
511
+ 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 });
512
+ 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 });
513
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: MatSliderThumb, decorators: [{
514
+ type: Directive,
515
+ args: [{
516
+ // eslint-disable-next-line
517
+ selector: 'input[matSliderThumb]',
518
+ exportAs: 'matSliderThumb',
519
+ host: {
520
+ class: 'mdc-slider__input',
521
+ type: 'range',
522
+ '[attr.aria-valuetext]': '_valuetext',
523
+ '(change)': '_onChange()',
524
+ '(input)': '_onInput()',
525
+ // TODO(wagnermaciel): Consider using a global event listener instead.
526
+ // Reason: I have found a semi-consistent way to mouse up without triggering this event.
527
+ '(blur)': '_onBlur()',
528
+ '(focus)': '_onFocus()',
529
+ },
530
+ providers: [MAT_SLIDER_THUMB_VALUE_ACCESSOR, { provide: MAT_SLIDER_THUMB, useExisting: MatSliderThumb }],
531
+ }]
532
+ }], ctorParameters: function () { return [{ type: i0.NgZone }, { type: i0.ElementRef }, { type: i0.ChangeDetectorRef }, { type: undefined, decorators: [{
533
+ type: Inject,
534
+ args: [MatSlider]
535
+ }] }]; }, propDecorators: { value: [{
536
+ type: Input
537
+ }], valueChange: [{
538
+ type: Output
539
+ }], dragStart: [{
540
+ type: Output
541
+ }], dragEnd: [{
542
+ type: Output
543
+ }] } });
544
+
545
+ class FormlyFieldMDCSlider extends FormlyFieldSlider$2 {
546
+ set mdcSlider(slider) {
547
+ Object.defineProperty(slider, '_input', {
548
+ set: () => { },
549
+ get: () => this.sliderThumb,
550
+ });
551
+ const visualThumb = {
552
+ _hostElement: {
553
+ classList: {
554
+ add: () => { },
555
+ remove: () => { },
556
+ },
557
+ },
558
+ };
559
+ // workarround for "ERROR TypeError: visualThumb is undefined" when `discrete` is set to `true`
560
+ slider._thumbs = { first: visualThumb, last: visualThumb };
561
+ }
562
+ onContainerClick(event) {
563
+ this.sliderThumb?._hostElement.focus();
564
+ super.onContainerClick(event);
565
+ }
566
+ }
567
+ FormlyFieldMDCSlider.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldMDCSlider, deps: null, target: i0.ɵɵFactoryTarget.Component });
568
+ 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: `
569
+ <mat-slider
570
+ [id]="id"
571
+ [style.width]="'100%'"
572
+ [formlyAttributes]="field"
573
+ [tabIndex]="props.tabindex"
574
+ [color]="props.color"
575
+ [displayWith]="displayWith"
576
+ [invert]="props.invert"
577
+ [max]="props.max"
578
+ [min]="props.min"
579
+ [step]="props.step"
580
+ [discrete]="props.thumbLabel || props.discrete"
581
+ [showTickMarks]="props.showTickMarks"
582
+ [step]="props.step"
583
+ [tickInterval]="props.tickInterval"
584
+ [valueText]="props.valueText"
585
+ [vertical]="props.vertical"
586
+ (input)="props.input && props.input(field, $event)"
587
+ (change)="props.change && props.change(field, $event)"
588
+ >
589
+ <input matSliderThumb [formControl]="formControl" [formlyAttributes]="field" />
590
+ </mat-slider>
591
+ `, 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 });
592
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyFieldMDCSlider, decorators: [{
593
+ type: Component,
594
+ args: [{
595
+ selector: 'formly-field-mat-slider',
596
+ template: `
597
+ <mat-slider
598
+ [id]="id"
599
+ [style.width]="'100%'"
600
+ [formlyAttributes]="field"
601
+ [tabIndex]="props.tabindex"
602
+ [color]="props.color"
603
+ [displayWith]="displayWith"
604
+ [invert]="props.invert"
605
+ [max]="props.max"
606
+ [min]="props.min"
607
+ [step]="props.step"
608
+ [discrete]="props.thumbLabel || props.discrete"
609
+ [showTickMarks]="props.showTickMarks"
610
+ [step]="props.step"
611
+ [tickInterval]="props.tickInterval"
612
+ [valueText]="props.valueText"
613
+ [vertical]="props.vertical"
614
+ (input)="props.input && props.input(field, $event)"
615
+ (change)="props.change && props.change(field, $event)"
616
+ >
617
+ <input matSliderThumb [formControl]="formControl" [formlyAttributes]="field" />
618
+ </mat-slider>
619
+ `,
620
+ changeDetection: ChangeDetectionStrategy.OnPush,
621
+ }]
622
+ }], propDecorators: { sliderThumb: [{
623
+ type: ViewChild,
624
+ args: [MAT_SLIDER_THUMB, { static: true }]
625
+ }], mdcSlider: [{
626
+ type: ViewChild,
627
+ args: [MatSlider, { static: true }]
628
+ }] } });
629
+
630
+ const FormlyFieldSlider$1 = Number(VERSION.major) >= 15 ? FormlyFieldMDCSlider : FormlyFieldSlider$2;
84
631
  class FormlyMatSliderModule {
85
632
  }
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,
633
+ FormlyMatSliderModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
634
+ FormlyMatSliderModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, declarations: [FormlyFieldSlider$2, FormlyFieldMDCSlider, MatSliderThumb], imports: [CommonModule,
635
+ MatCommonModule,
636
+ MatRippleModule,
88
637
  ReactiveFormsModule,
89
638
  MatSliderModule,
90
639
  FormlyMatFormFieldModule, i3.FormlyModule] });
91
- FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, imports: [[
640
+ FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, imports: [[
92
641
  CommonModule,
642
+ MatCommonModule,
643
+ MatRippleModule,
93
644
  ReactiveFormsModule,
94
645
  MatSliderModule,
95
646
  FormlyMatFormFieldModule,
@@ -97,18 +648,20 @@ FormlyMatSliderModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", v
97
648
  types: [
98
649
  {
99
650
  name: 'slider',
100
- component: FormlyFieldSlider,
651
+ component: FormlyFieldSlider$1,
101
652
  wrappers: ['form-field'],
102
653
  },
103
654
  ],
104
655
  }),
105
656
  ]] });
106
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImport: i0, type: FormlyMatSliderModule, decorators: [{
657
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.12", ngImport: i0, type: FormlyMatSliderModule, decorators: [{
107
658
  type: NgModule,
108
659
  args: [{
109
- declarations: [FormlyFieldSlider],
660
+ declarations: [FormlyFieldSlider$2, FormlyFieldMDCSlider, MatSliderThumb],
110
661
  imports: [
111
662
  CommonModule,
663
+ MatCommonModule,
664
+ MatRippleModule,
112
665
  ReactiveFormsModule,
113
666
  MatSliderModule,
114
667
  FormlyMatFormFieldModule,
@@ -116,15 +669,18 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.11", ngImpo
116
669
  types: [
117
670
  {
118
671
  name: 'slider',
119
- component: FormlyFieldSlider,
672
+ component: FormlyFieldSlider$1,
120
673
  wrappers: ['form-field'],
121
674
  },
122
675
  ],
123
676
  }),
124
677
  ],
678
+ schemas: [NO_ERRORS_SCHEMA],
125
679
  }]
126
680
  }] });
127
681
 
682
+ const FormlyFieldSlider = Number(VERSION.major) >= 15 ? FormlyFieldMDCSlider : FormlyFieldSlider$2;
683
+
128
684
  /**
129
685
  * Generated bundle index. Do not edit.
130
686
  */