@ngx-formly/bootstrap
Version:
Formly is a dynamic (JSON powered) form library for Angular that bring unmatched maintainability to your application's forms.
195 lines (187 loc) • 9.58 kB
JavaScript
import * as i0 from '@angular/core';
import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core';
import { FieldType, FormlyBootstrapFormFieldModule } from '@ngx-formly/bootstrap/form-field';
import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i2 from '@angular/forms';
import { ReactiveFormsModule } from '@angular/forms';
import * as i3 from '@ngx-formly/core';
import { FormlyModule } from '@ngx-formly/core';
import * as i4 from '@ngx-formly/core/select';
import { FormlySelectModule } from '@ngx-formly/core/select';
class FormlyFieldSelect extends FieldType {
constructor() {
super(...arguments);
this.defaultOptions = {
props: {
compareWith(o1, o2) {
return o1 === o2;
},
},
};
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyFieldSelect, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: FormlyFieldSelect, selector: "formly-field-select", usesInheritance: true, ngImport: i0, template: `
<ng-template #fieldTypeTemplate>
<select
*ngIf="props.multiple; else singleSelect"
class="form-select"
multiple
[formControl]="formControl"
[compareWith]="props.compareWith"
[class.is-invalid]="showError"
[formlyAttributes]="field"
[attr.aria-describedby]="id + '-formly-validation-error'"
[attr.aria-invalid]="showError"
>
<ng-container *ngIf="props.options | formlySelectOptions: field | async as opts">
<ng-container *ngFor="let opt of opts">
<option *ngIf="!opt.group; else optgroup" [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
<ng-template #optgroup>
<optgroup [label]="opt.label">
<option *ngFor="let child of opt.group" [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
</optgroup>
</ng-template>
</ng-container>
</ng-container>
</select>
<ng-template #singleSelect>
<select
class="form-select"
[formControl]="formControl"
[compareWith]="props.compareWith"
[class.is-invalid]="showError"
[formlyAttributes]="field"
[attr.aria-describedby]="id + '-formly-validation-error'"
[attr.aria-invalid]="showError"
>
<option *ngIf="props.placeholder" [ngValue]="undefined">{{ props.placeholder }}</option>
<ng-container *ngIf="props.options | formlySelectOptions: field | async as opts">
<ng-container *ngFor="let opt of opts">
<option *ngIf="!opt.group; else optgroup" [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
<ng-template #optgroup>
<optgroup [label]="opt.label">
<option *ngFor="let child of opt.group" [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
</optgroup>
</ng-template>
</ng-container>
</ng-container>
</select>
</ng-template>
</ng-template>
`, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i2.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.SelectMultipleControlValueAccessor, selector: "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.LegacyFormlyAttributes, selector: "[formlyAttributes]" }, { kind: "pipe", type: i1.AsyncPipe, name: "async" }, { kind: "pipe", type: i4.LegacyFormlySelectOptionsPipe, name: "formlySelectOptions" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyFieldSelect, decorators: [{
type: Component,
args: [{
selector: 'formly-field-select',
template: `
<ng-template #fieldTypeTemplate>
<select
*ngIf="props.multiple; else singleSelect"
class="form-select"
multiple
[formControl]="formControl"
[compareWith]="props.compareWith"
[class.is-invalid]="showError"
[formlyAttributes]="field"
[attr.aria-describedby]="id + '-formly-validation-error'"
[attr.aria-invalid]="showError"
>
<ng-container *ngIf="props.options | formlySelectOptions: field | async as opts">
<ng-container *ngFor="let opt of opts">
<option *ngIf="!opt.group; else optgroup" [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
<ng-template #optgroup>
<optgroup [label]="opt.label">
<option *ngFor="let child of opt.group" [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
</optgroup>
</ng-template>
</ng-container>
</ng-container>
</select>
<ng-template #singleSelect>
<select
class="form-select"
[formControl]="formControl"
[compareWith]="props.compareWith"
[class.is-invalid]="showError"
[formlyAttributes]="field"
[attr.aria-describedby]="id + '-formly-validation-error'"
[attr.aria-invalid]="showError"
>
<option *ngIf="props.placeholder" [ngValue]="undefined">{{ props.placeholder }}</option>
<ng-container *ngIf="props.options | formlySelectOptions: field | async as opts">
<ng-container *ngFor="let opt of opts">
<option *ngIf="!opt.group; else optgroup" [ngValue]="opt.value" [disabled]="opt.disabled">
{{ opt.label }}
</option>
<ng-template #optgroup>
<optgroup [label]="opt.label">
<option *ngFor="let child of opt.group" [ngValue]="child.value" [disabled]="child.disabled">
{{ child.label }}
</option>
</optgroup>
</ng-template>
</ng-container>
</ng-container>
</select>
</ng-template>
</ng-template>
`,
changeDetection: ChangeDetectionStrategy.OnPush,
}]
}] });
function withFormlyFieldSelect() {
return {
types: [
{
name: 'select',
component: FormlyFieldSelect,
wrappers: ['form-field'],
},
{ name: 'enum', extends: 'select' },
],
};
}
class FormlyBootstrapSelectModule {
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapSelectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapSelectModule, declarations: [FormlyFieldSelect], imports: [CommonModule,
ReactiveFormsModule,
FormlyBootstrapFormFieldModule,
FormlySelectModule, i3.FormlyModule] }); }
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapSelectModule, imports: [CommonModule,
ReactiveFormsModule,
FormlyBootstrapFormFieldModule,
FormlySelectModule,
FormlyModule.forChild(withFormlyFieldSelect())] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapSelectModule, decorators: [{
type: NgModule,
args: [{
declarations: [FormlyFieldSelect],
imports: [
CommonModule,
ReactiveFormsModule,
FormlyBootstrapFormFieldModule,
FormlySelectModule,
FormlyModule.forChild(withFormlyFieldSelect()),
],
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
export { FormlyBootstrapSelectModule, FormlyFieldSelect, withFormlyFieldSelect };
//# sourceMappingURL=ngx-formly-bootstrap-select.mjs.map