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