@ngx-formly/material
Version:
Formly is a dynamic (JSON powered) form library for Angular that bring unmatched maintainability to your application's forms.
139 lines (133 loc) • 7.13 kB
JavaScript
import * as i0 from '@angular/core';
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { FieldType, FormlyMatFormFieldModule } from '@ngx-formly/material/form-field';
import * as i1 from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import * as i2 from '@angular/material/input';
import { MatInputModule } from '@angular/material/input';
import * as i3 from '@ngx-formly/core';
import { FormlyModule } from '@ngx-formly/core';
import * as i4 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i5 from '@ngx-formly/core/select';
import { FormlySelectModule } from '@ngx-formly/core/select';
class FormlyFieldNativeSelect extends FieldType {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyFieldNativeSelect, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: FormlyFieldNativeSelect, selector: "formly-field-mat-native-select", usesInheritance: true, ngImport: i0, template: `
<select
matNativeControl
[id]="id"
[name]="field.name"
[readonly]="props.readonly"
[required]="required"
[errorStateMatcher]="errorStateMatcher"
[formControl]="formControl"
[formlyAttributes]="field"
>
@if (props.placeholder) {
<option [ngValue]="undefined">{{ props.placeholder }}</option>
}
@if (props.options | formlySelectOptions: field | async; as opts) {
@for (opt of opts; track $index) {
@if (!opt.group) {
<option [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
} @else {
<optgroup [label]="opt.label">
@for (child of opt.group; track $index) {
<option [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
}
</optgroup>
}
}
}
</select>
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }, { kind: "pipe", type: i4.AsyncPipe, name: "async" }, { kind: "pipe", type: i5.LegacyFormlySelectOptionsPipe, name: "formlySelectOptions" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyFieldNativeSelect, decorators: [{
type: Component,
args: [{
selector: 'formly-field-mat-native-select',
template: `
<select
matNativeControl
[id]="id"
[name]="field.name"
[readonly]="props.readonly"
[required]="required"
[errorStateMatcher]="errorStateMatcher"
[formControl]="formControl"
[formlyAttributes]="field"
>
@if (props.placeholder) {
<option [ngValue]="undefined">{{ props.placeholder }}</option>
}
@if (props.options | formlySelectOptions: field | async; as opts) {
@for (opt of opts; track $index) {
@if (!opt.group) {
<option [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
} @else {
<optgroup [label]="opt.label">
@for (child of opt.group; track $index) {
<option [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
}
</optgroup>
}
}
}
</select>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
}]
}] });
function withFormlyFieldNativeSelect() {
return {
types: [
{
name: 'native-select',
component: FormlyFieldNativeSelect,
wrappers: ['form-field'],
},
],
};
}
class FormlyMatNativeSelectModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyMatNativeSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: FormlyMatNativeSelectModule, declarations: [FormlyFieldNativeSelect], imports: [CommonModule,
ReactiveFormsModule,
MatInputModule,
FormlyMatFormFieldModule,
FormlySelectModule, i3.FormlyModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyMatNativeSelectModule, imports: [CommonModule,
ReactiveFormsModule,
MatInputModule,
FormlyMatFormFieldModule,
FormlySelectModule,
FormlyModule.forChild(withFormlyFieldNativeSelect())] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyMatNativeSelectModule, decorators: [{
type: NgModule,
args: [{
declarations: [FormlyFieldNativeSelect],
imports: [
CommonModule,
ReactiveFormsModule,
MatInputModule,
FormlyMatFormFieldModule,
FormlySelectModule,
FormlyModule.forChild(withFormlyFieldNativeSelect()),
],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { FormlyFieldNativeSelect, FormlyMatNativeSelectModule, withFormlyFieldNativeSelect };
//# sourceMappingURL=ngx-formly-material-native-select.mjs.map