@ngx-formly/material 10.0.1 → 11.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +107 -177
  2. package/fesm2022/ngx-formly-material-checkbox.mjs +234 -127
  3. package/fesm2022/ngx-formly-material-checkbox.mjs.map +1 -1
  4. package/fesm2022/ngx-formly-material-datepicker.mjs +264 -118
  5. package/fesm2022/ngx-formly-material-datepicker.mjs.map +1 -1
  6. package/fesm2022/ngx-formly-material-form-field.mjs +440 -226
  7. package/fesm2022/ngx-formly-material-form-field.mjs.map +1 -1
  8. package/fesm2022/ngx-formly-material-input.mjs +199 -89
  9. package/fesm2022/ngx-formly-material-input.mjs.map +1 -1
  10. package/fesm2022/ngx-formly-material-multicheckbox.mjs +203 -106
  11. package/fesm2022/ngx-formly-material-multicheckbox.mjs.map +1 -1
  12. package/fesm2022/ngx-formly-material-native-select.mjs +204 -73
  13. package/fesm2022/ngx-formly-material-native-select.mjs.map +1 -1
  14. package/fesm2022/ngx-formly-material-radio.mjs +247 -104
  15. package/fesm2022/ngx-formly-material-radio.mjs.map +1 -1
  16. package/fesm2022/ngx-formly-material-select.mjs +318 -133
  17. package/fesm2022/ngx-formly-material-select.mjs.map +1 -1
  18. package/fesm2022/ngx-formly-material-slider.mjs +195 -85
  19. package/fesm2022/ngx-formly-material-slider.mjs.map +1 -1
  20. package/fesm2022/ngx-formly-material-textarea.mjs +203 -86
  21. package/fesm2022/ngx-formly-material-textarea.mjs.map +1 -1
  22. package/fesm2022/ngx-formly-material-toggle.mjs +208 -86
  23. package/fesm2022/ngx-formly-material-toggle.mjs.map +1 -1
  24. package/fesm2022/ngx-formly-material.mjs +84 -62
  25. package/fesm2022/ngx-formly-material.mjs.map +1 -1
  26. package/package.json +3 -3
  27. package/types/ngx-formly-material-checkbox.d.ts +41 -46
  28. package/types/ngx-formly-material-datepicker.d.ts +62 -67
  29. package/types/ngx-formly-material-form-field.d.ts +71 -77
  30. package/types/ngx-formly-material-input.d.ts +22 -28
  31. package/types/ngx-formly-material-multicheckbox.d.ts +33 -38
  32. package/types/ngx-formly-material-native-select.d.ts +23 -29
  33. package/types/ngx-formly-material-radio.d.ts +34 -39
  34. package/types/ngx-formly-material-select.d.ts +45 -48
  35. package/types/ngx-formly-material-slider.d.ts +32 -37
  36. package/types/ngx-formly-material-textarea.d.ts +28 -33
  37. package/types/ngx-formly-material-toggle.d.ts +30 -35
  38. package/types/ngx-formly-material.d.ts +16 -19
@@ -1,55 +1,84 @@
1
- import * as i0 from '@angular/core';
2
- import { ViewChild, ViewEncapsulation, Component, NO_ERRORS_SCHEMA, NgModule, Type, ViewChildren, Directive } from '@angular/core';
3
- import * as i4 from '@ngx-formly/core';
4
- import { FieldWrapper, ɵdefineHiddenProp as _defineHiddenProp, FormlyModule, FieldType as FieldType$1, ɵobserve as _observe } from '@ngx-formly/core';
5
- import * as i3 from '@angular/material/form-field';
6
- import { MatFormField, MatFormFieldModule, MatFormFieldControl } from '@angular/material/form-field';
7
- import * as i1 from '@angular/cdk/a11y';
8
- import * as i2 from '@angular/common';
9
- import { CommonModule } from '@angular/common';
10
- import { ReactiveFormsModule } from '@angular/forms';
11
- import { Subject } from 'rxjs';
12
-
13
- class FormlyWrapperFormField extends FieldWrapper {
14
- constructor(renderer, elementRef, focusMonitor) {
15
- super();
16
- this.renderer = renderer;
17
- this.elementRef = elementRef;
18
- this.focusMonitor = focusMonitor;
19
- }
20
- ngOnInit() {
21
- _defineHiddenProp(this.field, '_formField', this.formField);
22
- this.focusMonitor.monitor(this.elementRef, true).subscribe((origin) => {
23
- if (!origin && this.field.focus) {
24
- this.field.focus = false;
25
- }
26
- });
27
- }
28
- ngAfterViewInit() {
29
- // temporary fix for https://github.com/angular/material2/issues/7891
30
- if (this.formField.appearance !== 'outline' && this.props.hideFieldUnderline === true) {
31
- const underlineElement = this.formField._elementRef.nativeElement.querySelector('.mat-form-field-underline');
32
- underlineElement && this.renderer.removeChild(underlineElement.parentNode, underlineElement);
33
- }
34
- }
35
- ngOnDestroy() {
36
- delete this.field._formField;
37
- this.focusMonitor.stopMonitoring(this.elementRef);
38
- }
39
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FormlyWrapperFormField, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i1.FocusMonitor }], target: i0.ɵɵFactoryTarget.Component }); }
40
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.25", type: FormlyWrapperFormField, isStandalone: false, selector: "formly-wrapper-mat-form-field", viewQueries: [{ propertyName: "formField", first: true, predicate: MatFormField, descendants: true, static: true }], usesInheritance: true, ngImport: i0, template: `
1
+ import * as i0 from "@angular/core";
2
+ import { Component, Directive, NO_ERRORS_SCHEMA, NgModule, Type, ViewChild, ViewChildren, ViewEncapsulation } from "@angular/core";
3
+ import * as i4 from "@ngx-formly/core";
4
+ import { FieldType as FieldType$1, FieldWrapper, FormlyModule, ɵdefineHiddenProp, ɵobserve } from "@ngx-formly/core";
5
+ import * as i3 from "@angular/material/form-field";
6
+ import { MatFormField, MatFormFieldControl, MatFormFieldModule } from "@angular/material/form-field";
7
+ import * as i1 from "@angular/cdk/a11y";
8
+ import * as i2 from "@angular/common";
9
+ import { CommonModule } from "@angular/common";
10
+ import { ReactiveFormsModule } from "@angular/forms";
11
+ import { Subject } from "rxjs";
12
+ var FormlyWrapperFormField = class FormlyWrapperFormField extends FieldWrapper {
13
+ constructor(renderer, elementRef, focusMonitor) {
14
+ super();
15
+ this.renderer = renderer;
16
+ this.elementRef = elementRef;
17
+ this.focusMonitor = focusMonitor;
18
+ }
19
+ ngOnInit() {
20
+ ɵdefineHiddenProp(this.field, "_formField", this.formField);
21
+ this.focusMonitor.monitor(this.elementRef, true).subscribe((origin) => {
22
+ if (!origin && this.field.focus) this.field.focus = false;
23
+ });
24
+ }
25
+ ngAfterViewInit() {
26
+ if (this.formField.appearance !== "outline" && this.props.hideFieldUnderline === true) {
27
+ const underlineElement = this.formField._elementRef.nativeElement.querySelector(".mat-form-field-underline");
28
+ underlineElement && this.renderer.removeChild(underlineElement.parentNode, underlineElement);
29
+ }
30
+ }
31
+ ngOnDestroy() {
32
+ delete this.field._formField;
33
+ this.focusMonitor.stopMonitoring(this.elementRef);
34
+ }
35
+ static {
36
+ this.ɵfac = i0.ɵɵngDeclareFactory({
37
+ minVersion: "12.0.0",
38
+ version: "22.2.2",
39
+ ngImport: i0,
40
+ type: FormlyWrapperFormField,
41
+ deps: [
42
+ { token: i0.Renderer2 },
43
+ { token: i0.ElementRef },
44
+ { token: i1.FocusMonitor }
45
+ ],
46
+ target: i0.ɵɵFactoryTarget.Component
47
+ });
48
+ }
49
+ static {
50
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
51
+ minVersion: "17.0.0",
52
+ version: "22.2.2",
53
+ type: FormlyWrapperFormField,
54
+ isStandalone: false,
55
+ selector: "formly-wrapper-mat-form-field",
56
+ viewQueries: [{
57
+ propertyName: "formField",
58
+ first: true,
59
+ predicate: MatFormField,
60
+ descendants: true,
61
+ static: true
62
+ }],
63
+ usesInheritance: true,
64
+ ngImport: i0,
65
+ template: `
41
66
  <!-- fix https://github.com/angular/material2/pull/7083 by setting width to 100% -->
42
67
  <mat-form-field
43
68
  [hideRequiredMarker]="true"
44
69
  [floatLabel]="props.floatLabel"
45
70
  [appearance]="props.appearance"
46
- [subscriptSizing]="props.subscriptSizing"
71
+ [subscriptSizing]="props.subscriptSizing ?? (field.validation?.showAllErrors ? 'dynamic' : undefined)"
47
72
  [color]="props.color ?? 'primary'"
48
73
  >
49
74
  <ng-container #fieldComponent></ng-container>
50
75
  @if (props.label && props.hideLabel !== true) {
51
76
  <mat-label>
52
- {{ props.label }}
77
+ @if (props.allowHtml) {
78
+ <span [innerHTML]="props.label"></span>
79
+ } @else {
80
+ {{ props.label }}
81
+ }
53
82
  @if (props.required && props.hideRequiredMarker !== true) {
54
83
  <span aria-hidden="true" class="mat-form-field-required-marker mat-mdc-form-field-required-marker">*</span>
55
84
  }
@@ -94,7 +123,10 @@ class FormlyWrapperFormField extends FieldWrapper {
94
123
 
95
124
  @if (props.description || props.hintStart; as hint) {
96
125
  <mat-hint>
97
- <ng-container [ngTemplateOutlet]="stringOrTemplate" [ngTemplateOutletContext]="{ content: hint }">
126
+ <ng-container
127
+ [ngTemplateOutlet]="stringOrTemplate"
128
+ [ngTemplateOutletContext]="{ content: hint, allowHtml: props.allowHtml && !!props.description }"
129
+ >
98
130
  </ng-container>
99
131
  </mat-hint>
100
132
  }
@@ -107,30 +139,110 @@ class FormlyWrapperFormField extends FieldWrapper {
107
139
  }
108
140
  </mat-form-field>
109
141
 
110
- <ng-template #stringOrTemplate let-content="content">
142
+ <ng-template #stringOrTemplate let-content="content" let-allowHtml="allowHtml">
111
143
  @if (!content.createEmbeddedView) {
112
- <ng-container>{{ content }}</ng-container>
144
+ @if (allowHtml) {
145
+ <span [innerHTML]="content"></span>
146
+ } @else {
147
+ <ng-container>{{ content }}</ng-container>
148
+ }
113
149
  } @else {
114
150
  <ng-container [ngTemplateOutlet]="content" [ngTemplateOutletContext]="{ field: field }"></ng-container>
115
151
  }
116
152
  </ng-template>
117
- `, isInline: true, styles: ["formly-wrapper-mat-form-field .mat-mdc-form-field,formly-wrapper-mat-form-field .mat-form-field{width:100%}\n"], dependencies: [{ kind: "directive", type: i2.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: i3.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i3.MatLabel, selector: "mat-label" }, { kind: "directive", type: i3.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i3.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i3.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "directive", type: i3.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i4.LegacyFormlyValidationMessage, selector: "formly-validation-message" }], encapsulation: i0.ViewEncapsulation.None }); }
118
- }
119
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FormlyWrapperFormField, decorators: [{
120
- type: Component,
121
- args: [{ selector: 'formly-wrapper-mat-form-field', template: `
153
+ `,
154
+ isInline: true,
155
+ styles: ["formly-wrapper-mat-form-field .mat-mdc-form-field,formly-wrapper-mat-form-field .mat-form-field{width:100%}\n"],
156
+ dependencies: [
157
+ {
158
+ kind: "directive",
159
+ type: i2.NgTemplateOutlet,
160
+ selector: "[ngTemplateOutlet]",
161
+ inputs: [
162
+ "ngTemplateOutletContext",
163
+ "ngTemplateOutlet",
164
+ "ngTemplateOutletInjector"
165
+ ]
166
+ },
167
+ {
168
+ kind: "component",
169
+ type: i3.MatFormField,
170
+ selector: "mat-form-field",
171
+ inputs: [
172
+ "hideRequiredMarker",
173
+ "color",
174
+ "floatLabel",
175
+ "appearance",
176
+ "subscriptSizing",
177
+ "hintLabel"
178
+ ],
179
+ exportAs: ["matFormField"]
180
+ },
181
+ {
182
+ kind: "directive",
183
+ type: i3.MatLabel,
184
+ selector: "mat-label"
185
+ },
186
+ {
187
+ kind: "directive",
188
+ type: i3.MatHint,
189
+ selector: "mat-hint",
190
+ inputs: ["align", "id"]
191
+ },
192
+ {
193
+ kind: "directive",
194
+ type: i3.MatError,
195
+ selector: "mat-error, [matError]",
196
+ inputs: ["id"]
197
+ },
198
+ {
199
+ kind: "directive",
200
+ type: i3.MatPrefix,
201
+ selector: "[matPrefix], [matIconPrefix], [matTextPrefix]",
202
+ inputs: ["matTextPrefix"]
203
+ },
204
+ {
205
+ kind: "directive",
206
+ type: i3.MatSuffix,
207
+ selector: "[matSuffix], [matIconSuffix], [matTextSuffix]",
208
+ inputs: ["matTextSuffix"]
209
+ },
210
+ {
211
+ kind: "component",
212
+ type: i4.LegacyFormlyValidationMessage,
213
+ selector: "formly-validation-message"
214
+ }
215
+ ],
216
+ encapsulation: i0.ViewEncapsulation.None
217
+ });
218
+ }
219
+ };
220
+ i0.ɵɵngDeclareClassMetadata({
221
+ minVersion: "12.0.0",
222
+ version: "22.2.2",
223
+ ngImport: i0,
224
+ type: FormlyWrapperFormField,
225
+ decorators: [{
226
+ type: Component,
227
+ args: [{
228
+ selector: "formly-wrapper-mat-form-field",
229
+ template: `
122
230
  <!-- fix https://github.com/angular/material2/pull/7083 by setting width to 100% -->
123
231
  <mat-form-field
124
232
  [hideRequiredMarker]="true"
125
233
  [floatLabel]="props.floatLabel"
126
234
  [appearance]="props.appearance"
127
- [subscriptSizing]="props.subscriptSizing"
235
+ [subscriptSizing]="props.subscriptSizing ?? (field.validation?.showAllErrors ? 'dynamic' : undefined)"
128
236
  [color]="props.color ?? 'primary'"
129
237
  >
130
238
  <ng-container #fieldComponent></ng-container>
131
239
  @if (props.label && props.hideLabel !== true) {
132
240
  <mat-label>
133
- {{ props.label }}
241
+ @if (props.allowHtml) {
242
+ <span [innerHTML]="props.label"></span>
243
+ } @else {
244
+ {{ props.label }}
245
+ }
134
246
  @if (props.required && props.hideRequiredMarker !== true) {
135
247
  <span aria-hidden="true" class="mat-form-field-required-marker mat-mdc-form-field-required-marker">*</span>
136
248
  }
@@ -175,7 +287,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImpo
175
287
 
176
288
  @if (props.description || props.hintStart; as hint) {
177
289
  <mat-hint>
178
- <ng-container [ngTemplateOutlet]="stringOrTemplate" [ngTemplateOutletContext]="{ content: hint }">
290
+ <ng-container
291
+ [ngTemplateOutlet]="stringOrTemplate"
292
+ [ngTemplateOutletContext]="{ content: hint, allowHtml: props.allowHtml && !!props.description }"
293
+ >
179
294
  </ng-container>
180
295
  </mat-hint>
181
296
  }
@@ -188,184 +303,283 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImpo
188
303
  }
189
304
  </mat-form-field>
190
305
 
191
- <ng-template #stringOrTemplate let-content="content">
306
+ <ng-template #stringOrTemplate let-content="content" let-allowHtml="allowHtml">
192
307
  @if (!content.createEmbeddedView) {
193
- <ng-container>{{ content }}</ng-container>
308
+ @if (allowHtml) {
309
+ <span [innerHTML]="content"></span>
310
+ } @else {
311
+ <ng-container>{{ content }}</ng-container>
312
+ }
194
313
  } @else {
195
314
  <ng-container [ngTemplateOutlet]="content" [ngTemplateOutletContext]="{ field: field }"></ng-container>
196
315
  }
197
316
  </ng-template>
198
- `, encapsulation: ViewEncapsulation.None, standalone: false, styles: ["formly-wrapper-mat-form-field .mat-mdc-form-field,formly-wrapper-mat-form-field .mat-form-field{width:100%}\n"] }]
199
- }], ctorParameters: () => [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i1.FocusMonitor }], propDecorators: { formField: [{
200
- type: ViewChild,
201
- args: [MatFormField, { static: true }]
202
- }] } });
203
-
317
+ `,
318
+ encapsulation: ViewEncapsulation.None,
319
+ standalone: false,
320
+ styles: ["formly-wrapper-mat-form-field .mat-mdc-form-field,formly-wrapper-mat-form-field .mat-form-field{width:100%}\n"]
321
+ }]
322
+ }],
323
+ ctorParameters: () => [
324
+ { type: i0.Renderer2 },
325
+ { type: i0.ElementRef },
326
+ { type: i1.FocusMonitor }
327
+ ],
328
+ propDecorators: { formField: [{
329
+ type: ViewChild,
330
+ args: [MatFormField, { static: true }]
331
+ }] }
332
+ });
204
333
  function withFormlyFormField() {
205
- return {
206
- wrappers: [
207
- {
208
- name: 'form-field',
209
- component: FormlyWrapperFormField,
210
- },
211
- ],
212
- };
213
- }
214
-
215
- class FormlyMatFormFieldModule {
216
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FormlyMatFormFieldModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
217
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.25", ngImport: i0, type: FormlyMatFormFieldModule, declarations: [FormlyWrapperFormField], imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, i4.FormlyModule] }); }
218
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FormlyMatFormFieldModule, imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, FormlyModule.forChild(withFormlyFormField())] }); }
334
+ return { wrappers: [{
335
+ name: "form-field",
336
+ component: FormlyWrapperFormField
337
+ }] };
219
338
  }
220
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FormlyMatFormFieldModule, decorators: [{
221
- type: NgModule,
222
- args: [{
223
- declarations: [FormlyWrapperFormField],
224
- imports: [CommonModule, ReactiveFormsModule, MatFormFieldModule, FormlyModule.forChild(withFormlyFormField())],
225
- schemas: [NO_ERRORS_SCHEMA],
226
- }]
227
- }] });
228
-
229
- class FieldType extends FieldType$1 {
230
- constructor() {
231
- super(...arguments);
232
- this.errorStateMatcher = { isErrorState: () => this.field && this.showError };
233
- this.stateChanges = new Subject();
234
- this._errorState = false;
235
- this._focused = false;
236
- }
237
- set matPrefix(prefix) {
238
- if (prefix) {
239
- this.props.prefix = prefix;
240
- }
241
- }
242
- set matTextPrefix(textPrefix) {
243
- if (textPrefix) {
244
- this.props.textPrefix = textPrefix;
245
- }
246
- }
247
- set matSuffix(suffix) {
248
- if (suffix) {
249
- this.props.suffix = suffix;
250
- }
251
- }
252
- set matTextSuffix(textSuffix) {
253
- if (textSuffix) {
254
- this.props.textSuffix = textSuffix;
255
- }
256
- }
257
- set _controls(controls) {
258
- this.attachControl(controls.length === 1 ? controls.first : this);
259
- }
260
- ngOnDestroy() {
261
- delete this.formField?._control;
262
- this.stateChanges.complete();
263
- }
264
- setDescribedByIds(_ids) { }
265
- onContainerClick(_event) {
266
- this.field.focus = true;
267
- this.stateChanges.next();
268
- }
269
- get errorState() {
270
- const showError = this.options.showError(this);
271
- if (showError !== this._errorState) {
272
- this._errorState = showError;
273
- this.stateChanges.next();
274
- }
275
- return showError;
276
- }
277
- get controlType() {
278
- if (this.props.type) {
279
- return this.props.type;
280
- }
281
- const type = this.field.type;
282
- return type instanceof Type ? type.prototype.constructor.name : type;
283
- }
284
- get focused() {
285
- const focused = !!this.field.focus && !this.disabled;
286
- if (focused !== this._focused) {
287
- this._focused = focused;
288
- this.stateChanges.next();
289
- }
290
- return focused;
291
- }
292
- get disabled() {
293
- return !!this.props.disabled;
294
- }
295
- get required() {
296
- return !!this.props.required;
297
- }
298
- get placeholder() {
299
- return this.props.placeholder || '';
300
- }
301
- get shouldPlaceholderFloat() {
302
- return this.shouldLabelFloat;
303
- }
304
- get value() {
305
- return this.formControl?.value;
306
- }
307
- set value(value) {
308
- this.formControl?.patchValue(value);
309
- }
310
- get ngControl() {
311
- return this.formControl;
312
- }
313
- get empty() {
314
- return this.value == null || this.value === '';
315
- }
316
- get shouldLabelFloat() {
317
- return this.focused || !this.empty;
318
- }
319
- get formField() {
320
- return this.field?.['_formField'];
321
- }
322
- attachControl(control) {
323
- if (this.formField && control !== this.formField._control) {
324
- this.formField._control = control;
325
- // temporary fix for https://github.com/angular/material2/issues/6728
326
- const ngControl = control?.ngControl;
327
- if (ngControl?.valueAccessor?.hasOwnProperty('_formField')) {
328
- ngControl.valueAccessor['_formField'] = this.formField;
329
- }
330
- if (ngControl?.valueAccessor?.hasOwnProperty('_parentFormField')) {
331
- ngControl.valueAccessor['_parentFormField'] = this.formField;
332
- }
333
- ['prefix', 'suffix', 'textPrefix', 'textSuffix'].forEach((type) => _observe(this.field, ['props', type], ({ currentValue }) => currentValue &&
334
- Promise.resolve().then(() => {
335
- this.options.detectChanges(this.field);
336
- })));
337
- // https://github.com/angular/components/issues/16209
338
- const setDescribedByIds = control.setDescribedByIds.bind(control);
339
- control.setDescribedByIds = (ids) => {
340
- setTimeout(() => setDescribedByIds(ids));
341
- };
342
- }
343
- }
344
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FieldType, deps: null, target: i0.ɵɵFactoryTarget.Directive }); }
345
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.25", type: FieldType, isStandalone: true, viewQueries: [{ propertyName: "matPrefix", first: true, predicate: ["matPrefix"], descendants: true }, { propertyName: "matTextPrefix", first: true, predicate: ["matTextPrefix"], descendants: true }, { propertyName: "matSuffix", first: true, predicate: ["matSuffix"], descendants: true }, { propertyName: "matTextSuffix", first: true, predicate: ["matTextSuffix"], descendants: true }, { propertyName: "_controls", predicate: MatFormFieldControl, descendants: true }], usesInheritance: true, ngImport: i0 }); }
346
- }
347
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: FieldType, decorators: [{
348
- type: Directive
349
- }], propDecorators: { matPrefix: [{
350
- type: ViewChild,
351
- args: ['matPrefix']
352
- }], matTextPrefix: [{
353
- type: ViewChild,
354
- args: ['matTextPrefix']
355
- }], matSuffix: [{
356
- type: ViewChild,
357
- args: ['matSuffix']
358
- }], matTextSuffix: [{
359
- type: ViewChild,
360
- args: ['matTextSuffix']
361
- }], _controls: [{
362
- type: ViewChildren,
363
- args: [MatFormFieldControl]
364
- }] } });
365
-
366
- /**
367
- * Generated bundle index. Do not edit.
368
- */
369
-
339
+ var FormlyMatFormFieldModule = class FormlyMatFormFieldModule {
340
+ static {
341
+ this.ɵfac = i0.ɵɵngDeclareFactory({
342
+ minVersion: "12.0.0",
343
+ version: "22.2.2",
344
+ ngImport: i0,
345
+ type: FormlyMatFormFieldModule,
346
+ deps: [],
347
+ target: i0.ɵɵFactoryTarget.NgModule
348
+ });
349
+ }
350
+ static {
351
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
352
+ minVersion: "14.0.0",
353
+ version: "22.2.2",
354
+ ngImport: i0,
355
+ type: FormlyMatFormFieldModule,
356
+ declarations: [FormlyWrapperFormField],
357
+ imports: [
358
+ CommonModule,
359
+ ReactiveFormsModule,
360
+ MatFormFieldModule,
361
+ i4.FormlyModule
362
+ ]
363
+ });
364
+ }
365
+ static {
366
+ this.ɵinj = i0.ɵɵngDeclareInjector({
367
+ minVersion: "12.0.0",
368
+ version: "22.2.2",
369
+ ngImport: i0,
370
+ type: FormlyMatFormFieldModule,
371
+ imports: [
372
+ CommonModule,
373
+ ReactiveFormsModule,
374
+ MatFormFieldModule,
375
+ FormlyModule.forChild(withFormlyFormField())
376
+ ]
377
+ });
378
+ }
379
+ };
380
+ i0.ɵɵngDeclareClassMetadata({
381
+ minVersion: "12.0.0",
382
+ version: "22.2.2",
383
+ ngImport: i0,
384
+ type: FormlyMatFormFieldModule,
385
+ decorators: [{
386
+ type: NgModule,
387
+ args: [{
388
+ declarations: [FormlyWrapperFormField],
389
+ imports: [
390
+ CommonModule,
391
+ ReactiveFormsModule,
392
+ MatFormFieldModule,
393
+ FormlyModule.forChild(withFormlyFormField())
394
+ ],
395
+ schemas: [NO_ERRORS_SCHEMA]
396
+ }]
397
+ }]
398
+ });
399
+ var FieldType = class FieldType extends FieldType$1 {
400
+ constructor() {
401
+ super(...arguments);
402
+ this.errorStateMatcher = { isErrorState: () => this.field && this.showError };
403
+ this.stateChanges = new Subject();
404
+ this._errorState = false;
405
+ this._focused = false;
406
+ }
407
+ set matPrefix(prefix) {
408
+ if (prefix) this.props.prefix = prefix;
409
+ }
410
+ set matTextPrefix(textPrefix) {
411
+ if (textPrefix) this.props.textPrefix = textPrefix;
412
+ }
413
+ set matSuffix(suffix) {
414
+ if (suffix) this.props.suffix = suffix;
415
+ }
416
+ set matTextSuffix(textSuffix) {
417
+ if (textSuffix) this.props.textSuffix = textSuffix;
418
+ }
419
+ set _controls(controls) {
420
+ this.attachControl(controls.length === 1 ? controls.first : this);
421
+ }
422
+ ngOnDestroy() {
423
+ delete this.formField?._control;
424
+ this.stateChanges.complete();
425
+ }
426
+ setDescribedByIds(_ids) {}
427
+ onContainerClick(_event) {
428
+ this.field.focus = true;
429
+ this.stateChanges.next();
430
+ }
431
+ get errorState() {
432
+ const showError = this.options.showError(this);
433
+ if (showError !== this._errorState) {
434
+ this._errorState = showError;
435
+ this.stateChanges.next();
436
+ }
437
+ return showError;
438
+ }
439
+ get controlType() {
440
+ if (this.props.type) return this.props.type;
441
+ const type = this.field.type;
442
+ return type instanceof Type ? type.prototype.constructor.name : type;
443
+ }
444
+ get focused() {
445
+ const focused = !!this.field.focus && !this.disabled;
446
+ if (focused !== this._focused) {
447
+ this._focused = focused;
448
+ this.stateChanges.next();
449
+ }
450
+ return focused;
451
+ }
452
+ get disabled() {
453
+ return !!this.props.disabled;
454
+ }
455
+ get required() {
456
+ return !!this.props.required;
457
+ }
458
+ get placeholder() {
459
+ return this.props.placeholder || "";
460
+ }
461
+ get shouldPlaceholderFloat() {
462
+ return this.shouldLabelFloat;
463
+ }
464
+ get value() {
465
+ return this.formControl?.value;
466
+ }
467
+ set value(value) {
468
+ this.formControl?.patchValue(value);
469
+ }
470
+ get ngControl() {
471
+ return this.formControl;
472
+ }
473
+ get empty() {
474
+ return this.value == null || this.value === "";
475
+ }
476
+ get shouldLabelFloat() {
477
+ return this.focused || !this.empty;
478
+ }
479
+ get formField() {
480
+ return this.field?.["_formField"];
481
+ }
482
+ attachControl(control) {
483
+ if (this.formField && control !== this.formField._control) {
484
+ this.formField._control = control;
485
+ const ngControl = control?.ngControl;
486
+ if (ngControl?.valueAccessor?.hasOwnProperty("_formField")) ngControl.valueAccessor["_formField"] = this.formField;
487
+ if (ngControl?.valueAccessor?.hasOwnProperty("_parentFormField")) ngControl.valueAccessor["_parentFormField"] = this.formField;
488
+ [
489
+ "prefix",
490
+ "suffix",
491
+ "textPrefix",
492
+ "textSuffix"
493
+ ].forEach((type) => ɵobserve(this.field, ["props", type], ({ currentValue }) => currentValue && Promise.resolve().then(() => {
494
+ this.options.detectChanges(this.field);
495
+ })));
496
+ const setDescribedByIds = control.setDescribedByIds.bind(control);
497
+ control.setDescribedByIds = (ids) => {
498
+ setTimeout(() => setDescribedByIds(ids));
499
+ };
500
+ }
501
+ }
502
+ static {
503
+ this.ɵfac = i0.ɵɵngDeclareFactory({
504
+ minVersion: "12.0.0",
505
+ version: "22.2.2",
506
+ ngImport: i0,
507
+ type: FieldType,
508
+ deps: null,
509
+ target: i0.ɵɵFactoryTarget.Directive
510
+ });
511
+ }
512
+ static {
513
+ this.ɵdir = i0.ɵɵngDeclareDirective({
514
+ minVersion: "14.0.0",
515
+ version: "22.2.2",
516
+ type: FieldType,
517
+ isStandalone: true,
518
+ viewQueries: [
519
+ {
520
+ propertyName: "matPrefix",
521
+ first: true,
522
+ predicate: ["matPrefix"],
523
+ descendants: true
524
+ },
525
+ {
526
+ propertyName: "matTextPrefix",
527
+ first: true,
528
+ predicate: ["matTextPrefix"],
529
+ descendants: true
530
+ },
531
+ {
532
+ propertyName: "matSuffix",
533
+ first: true,
534
+ predicate: ["matSuffix"],
535
+ descendants: true
536
+ },
537
+ {
538
+ propertyName: "matTextSuffix",
539
+ first: true,
540
+ predicate: ["matTextSuffix"],
541
+ descendants: true
542
+ },
543
+ {
544
+ propertyName: "_controls",
545
+ predicate: MatFormFieldControl,
546
+ descendants: true
547
+ }
548
+ ],
549
+ usesInheritance: true,
550
+ ngImport: i0
551
+ });
552
+ }
553
+ };
554
+ i0.ɵɵngDeclareClassMetadata({
555
+ minVersion: "12.0.0",
556
+ version: "22.2.2",
557
+ ngImport: i0,
558
+ type: FieldType,
559
+ decorators: [{ type: Directive }],
560
+ propDecorators: {
561
+ matPrefix: [{
562
+ type: ViewChild,
563
+ args: ["matPrefix"]
564
+ }],
565
+ matTextPrefix: [{
566
+ type: ViewChild,
567
+ args: ["matTextPrefix"]
568
+ }],
569
+ matSuffix: [{
570
+ type: ViewChild,
571
+ args: ["matSuffix"]
572
+ }],
573
+ matTextSuffix: [{
574
+ type: ViewChild,
575
+ args: ["matTextSuffix"]
576
+ }],
577
+ _controls: [{
578
+ type: ViewChildren,
579
+ args: [MatFormFieldControl]
580
+ }]
581
+ }
582
+ });
370
583
  export { FieldType, FormlyMatFormFieldModule, withFormlyFormField };
371
- //# sourceMappingURL=ngx-formly-material-form-field.mjs.map
584
+
585
+ //# sourceMappingURL=ngx-formly-material-form-field.mjs.map