ngx-form-lib
Version:
Dynamic form library for Angular 18 with Material 3 support. Create complex reactive forms easily using JSON configuration with modern Angular 18 control flow syntax.
21 lines • 10.3 kB
JavaScript
import { Component } from '@angular/core';
import { BaseComponent } from '../../core/components/base/base.component';
import * as i0 from "@angular/core";
import * as i1 from "@angular/material/form-field";
import * as i2 from "../../shared/components/prefix-suffix/prefix-suffix.component";
import * as i3 from "@angular/forms";
import * as i4 from "@angular/material/input";
import * as i5 from "../../shared/pipes/set-parent-config/set-parent-config.pipe";
export class InputComponent extends BaseComponent {
constructor() {
super(...arguments);
this.config = null;
}
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: InputComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: InputComponent, selector: "ngf-input", usesInheritance: true, ngImport: i0, template: "@if (group && config) {\r\n<div [formGroup]=\"group\" class=\"ngf-wrapper ngf-input-wrapper\">\r\n <mat-form-field\r\n class=\"ngf-form-field\"\r\n [color]=\"parentConfig | setParentConfig : config : 'color'\"\r\n [appearance]=\"parentConfig | setParentConfig : config : 'appearance'\"\r\n >\r\n @if (config.label) {\r\n <mat-label [attr.for]=\"config.name\">{{ config.label }}</mat-label>\r\n }\r\n <input\r\n matInput\r\n [formControlName]=\"config.name\"\r\n [id]=\"config.name\"\r\n [type]=\"config.subType\"\r\n />\r\n @if (config.prefix) {\r\n <span matPrefix>\r\n <ngf-prefix-suffix [config]=\"config.prefix\"></ngf-prefix-suffix>\r\n </span>\r\n } @if (config.suffix) {\r\n <span matSuffix>\r\n <ngf-prefix-suffix [config]=\"config.suffix\"></ngf-prefix-suffix>\r\n </span>\r\n } @if (config.hint) {\r\n <mat-hint>{{ config.hint }}</mat-hint>\r\n } @for (validationItem of config.validators; track validationItem.type) {\r\n <mat-error class=\"ngf-field-error\">\r\n @if (group.controls[config.name].hasError(validationItem.type) &&\r\n (group.controls[config.name].dirty ||\r\n group.controls[config.name].touched)) {\r\n <span>{{ validationItem.message }}</span>\r\n @if (validationItem.showDynamicError &&\r\n this.group.controls[config.name].getError(validationItem.type)?.actualLength;\r\n as actualLength) {\r\n <span>\r\n {{ actualLength }}/\r\n {{\r\n this.group.controls[config.name].getError(validationItem.type)\r\n ?.requiredLength\r\n }}\r\n </span>\r\n } }\r\n </mat-error>\r\n }\r\n </mat-form-field>\r\n</div>\r\n}\r\n", dependencies: [{ kind: "component", type: i1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i1.MatLabel, selector: "mat-label" }, { kind: "directive", type: i1.MatHint, selector: "mat-hint", inputs: ["align", "id"] }, { kind: "directive", type: i1.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i1.MatPrefix, selector: "[matPrefix], [matIconPrefix], [matTextPrefix]", inputs: ["matTextPrefix"] }, { kind: "directive", type: i1.MatSuffix, selector: "[matSuffix], [matIconSuffix], [matTextSuffix]", inputs: ["matTextSuffix"] }, { kind: "component", type: i2.PrefixSuffixComponent, selector: "ngf-prefix-suffix", inputs: ["config"] }, { kind: "directive", type: i3.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: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i3.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i3.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "directive", type: i4.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: "pipe", type: i5.SetParentConfigPipe, name: "setParentConfig" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: InputComponent, decorators: [{
type: Component,
args: [{ selector: 'ngf-input', template: "@if (group && config) {\r\n<div [formGroup]=\"group\" class=\"ngf-wrapper ngf-input-wrapper\">\r\n <mat-form-field\r\n class=\"ngf-form-field\"\r\n [color]=\"parentConfig | setParentConfig : config : 'color'\"\r\n [appearance]=\"parentConfig | setParentConfig : config : 'appearance'\"\r\n >\r\n @if (config.label) {\r\n <mat-label [attr.for]=\"config.name\">{{ config.label }}</mat-label>\r\n }\r\n <input\r\n matInput\r\n [formControlName]=\"config.name\"\r\n [id]=\"config.name\"\r\n [type]=\"config.subType\"\r\n />\r\n @if (config.prefix) {\r\n <span matPrefix>\r\n <ngf-prefix-suffix [config]=\"config.prefix\"></ngf-prefix-suffix>\r\n </span>\r\n } @if (config.suffix) {\r\n <span matSuffix>\r\n <ngf-prefix-suffix [config]=\"config.suffix\"></ngf-prefix-suffix>\r\n </span>\r\n } @if (config.hint) {\r\n <mat-hint>{{ config.hint }}</mat-hint>\r\n } @for (validationItem of config.validators; track validationItem.type) {\r\n <mat-error class=\"ngf-field-error\">\r\n @if (group.controls[config.name].hasError(validationItem.type) &&\r\n (group.controls[config.name].dirty ||\r\n group.controls[config.name].touched)) {\r\n <span>{{ validationItem.message }}</span>\r\n @if (validationItem.showDynamicError &&\r\n this.group.controls[config.name].getError(validationItem.type)?.actualLength;\r\n as actualLength) {\r\n <span>\r\n {{ actualLength }}/\r\n {{\r\n this.group.controls[config.name].getError(validationItem.type)\r\n ?.requiredLength\r\n }}\r\n </span>\r\n } }\r\n </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