UNPKG

@ngx-formly/bootstrap

Version:

Formly is a dynamic (JSON powered) form library for Angular that bring unmatched maintainability to your application's forms.

131 lines (125 loc) 6.56 kB
import * as i0 from '@angular/core'; import { ChangeDetectionStrategy, Component, NgModule } from '@angular/core'; import { FieldType, FormlyBootstrapFormFieldModule } from '@ngx-formly/bootstrap/form-field'; import * as i2 from '@angular/forms'; import { UntypedFormControl, ReactiveFormsModule } from '@angular/forms'; import * as i1 from '@angular/common'; import { CommonModule } from '@angular/common'; 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 FormlyFieldRadio extends FieldType { constructor() { super(...arguments); this.defaultOptions = { props: { formCheck: 'default', }, }; } get disabledControl() { return new UntypedFormControl({ value: this.formControl.value, disabled: true }); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyFieldRadio, deps: null, target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.13", type: FormlyFieldRadio, selector: "formly-field-radio", usesInheritance: true, ngImport: i0, template: ` <ng-template #fieldTypeTemplate> <div *ngFor="let option of props.options | formlySelectOptions: field | async; let i = index" class="form-check" [class.form-check-inline]="props.formCheck === 'inline'" > <input type="radio" [id]="id + '_' + i" class="form-check-input" [name]="field.name || id" [class.is-invalid]="showError" [attr.value]="option.value" [value]="option.value" [formControl]="option.disabled ? disabledControl : formControl" [formlyAttributes]="field" [attr.aria-describedby]="id + '-formly-validation-error'" [attr.aria-invalid]="showError" /> <label class="form-check-label" [for]="id + '_' + i"> {{ option.label }} </label> </div> </ng-template> `, isInline: true, dependencies: [{ kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i2.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { 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: FormlyFieldRadio, decorators: [{ type: Component, args: [{ selector: 'formly-field-radio', template: ` <ng-template #fieldTypeTemplate> <div *ngFor="let option of props.options | formlySelectOptions: field | async; let i = index" class="form-check" [class.form-check-inline]="props.formCheck === 'inline'" > <input type="radio" [id]="id + '_' + i" class="form-check-input" [name]="field.name || id" [class.is-invalid]="showError" [attr.value]="option.value" [value]="option.value" [formControl]="option.disabled ? disabledControl : formControl" [formlyAttributes]="field" [attr.aria-describedby]="id + '-formly-validation-error'" [attr.aria-invalid]="showError" /> <label class="form-check-label" [for]="id + '_' + i"> {{ option.label }} </label> </div> </ng-template> `, changeDetection: ChangeDetectionStrategy.OnPush, }] }] }); function withFormlyFieldRadio() { return { types: [ { name: 'radio', component: FormlyFieldRadio, wrappers: ['form-field'], }, ], }; } class FormlyBootstrapRadioModule { static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapRadioModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); } static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapRadioModule, declarations: [FormlyFieldRadio], imports: [CommonModule, ReactiveFormsModule, FormlyBootstrapFormFieldModule, FormlySelectModule, i3.FormlyModule] }); } static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapRadioModule, imports: [CommonModule, ReactiveFormsModule, FormlyBootstrapFormFieldModule, FormlySelectModule, FormlyModule.forChild(withFormlyFieldRadio())] }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: FormlyBootstrapRadioModule, decorators: [{ type: NgModule, args: [{ declarations: [FormlyFieldRadio], imports: [ CommonModule, ReactiveFormsModule, FormlyBootstrapFormFieldModule, FormlySelectModule, FormlyModule.forChild(withFormlyFieldRadio()), ], }] }] }); /** * Generated bundle index. Do not edit. */ export { FormlyBootstrapRadioModule, FormlyFieldRadio, withFormlyFieldRadio }; //# sourceMappingURL=ngx-formly-bootstrap-radio.mjs.map