UNPKG

@asoftwareworld/form-builder

Version:

ASW Form Builder helps you with rapid development and designed web forms which includes several controls. The key feature of Form Builder is to make your content attractive and effective. We can customize our control at run time and preview the same befor

179 lines (173 loc) 15.8 kB
import * as i0 from '@angular/core'; import { EventEmitter, Component, Input, Output, NgModule } from '@angular/core'; import { AswConfirmDialog, AswConfirmDialogModule } from '@asoftwareworld/form-builder/form-control/confirm-dialog'; import { Constants, AswTextDialog, AswSharedDialogModule } from '@asoftwareworld/form-builder/form-control/core'; import * as i1 from '@angular/material/dialog'; import { MatDialogModule } from '@angular/material/dialog'; import * as i2 from '@angular/common'; import { CommonModule } from '@angular/common'; import * as i3 from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import * as i4 from '@angular/material/input'; import { MatInputModule } from '@angular/material/input'; import * as i5 from '@angular/material/form-field'; import * as i6 from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip'; import * as i7 from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon'; import * as i8 from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button'; import { MatDividerModule } from '@angular/material/divider'; import { MatSelectModule } from '@angular/material/select'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; /** * @license * Copyright ASW (A Software World) All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file */ class AswTextarea { dialog; constants = Constants; /** * TextArea control */ control = null; /** * TextArea control index to help update or delete button from drop area */ controlIndex; isPreviewTemplate = false; textAreaUpdateEvent = new EventEmitter(); textAreaDeleteEvent = new EventEmitter(); aswModelChange = new EventEmitter(); duplicateControl = new EventEmitter(); constructor(dialog) { this.dialog = dialog; } deleteTextAreaDialog(control, controlIndex) { const dialogRef = this.dialog.open(AswConfirmDialog, { width: '350px', data: { name: control.controlType, message: this.constants.messages.waringMessage } }); dialogRef.afterClosed().subscribe(result => { if (result !== undefined) { this.textAreaDeleteEvent.emit(controlIndex); } }); } editTextAreaDialog(control, controlIndex) { const dialogRef = this.dialog.open(AswTextDialog, { disableClose: true, width: '80%', minWidth: '70vw', data: control }); dialogRef.afterClosed().subscribe(result => { if (result !== undefined) { this.textAreaUpdateEvent.emit({ control: result, index: controlIndex }); } }); } onChange(control) { this.aswModelChange.emit(control); } duplicateTextAreaControl(control) { this.duplicateControl.emit(control); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswTextarea, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: AswTextarea, selector: "asw-textarea", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { textAreaUpdateEvent: "textAreaUpdateEvent", textAreaDeleteEvent: "textAreaDeleteEvent", aswModelChange: "aswModelChange", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<ng-container *ngIf=\"control as control\">\r\n <mat-form-field [appearance]=\"control.style\" class=\"asw-mat-form-field {{control.customClass}}\">\r\n <mat-label>{{control.label}}</mat-label>\r\n <textarea matInput type=\"text\"\r\n [id]=\"control.id\"\r\n pattern=\"{{control.pattern}}\"\r\n [placeholder]=\"control.label\"\r\n [(ngModel)]=\"control.value\"\r\n #input=\"ngModel\"\r\n (change)=\"onChange(control)\"\r\n [matTooltip]=\"control.tooltip\"\r\n [maxlength]=\"control.maxlength\"\r\n [minlength]=\"control.minlength\"\r\n [required]=\"control.isRequired\"\r\n [disabled]=\"control.isDisabled ? true : false\"></textarea>\r\n <mat-error class=\"asw-mat-error\" *ngIf=\"input.invalid && (input.dirty || input.touched)\">\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.required\">\r\n {{control.label}} is required\r\n </ng-container>\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.minlength\">\r\n Sorry, {{control.label}} must be at least {{control.minlength}} characters long.\r\n </ng-container>\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.pattern\">\r\n {{control.customErrorMsg}}\r\n </ng-container>\r\n </mat-error>\r\n </mat-form-field>\r\n <ng-template [ngIf]=\"isPreviewTemplate\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Duplicate\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"duplicateTextAreaControl(control)\">\r\n <mat-icon>content_copy</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Edit\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"editTextAreaDialog(control, controlIndex)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Delete\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"deleteTextAreaDialog(control, controlIndex)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div> \r\n </div>\r\n </ng-template> \r\n</ng-container>\r\n", dependencies: [{ kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { kind: "directive", type: i3.MinLengthValidator, selector: "[minlength][formControlName],[minlength][formControl],[minlength][ngModel]", inputs: ["minlength"] }, { kind: "directive", type: i3.MaxLengthValidator, selector: "[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]", inputs: ["maxlength"] }, { kind: "directive", type: i3.PatternValidator, selector: "[pattern][formControlName],[pattern][formControl],[pattern][ngModel]", inputs: ["pattern"] }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { 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: "component", type: i5.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i5.MatLabel, selector: "mat-label" }, { kind: "directive", type: i5.MatError, selector: "mat-error, [matError]", inputs: ["id"] }, { kind: "directive", type: i6.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { kind: "component", type: i7.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "component", type: i8.MatIconButton, selector: "button[mat-icon-button]", exportAs: ["matButton"] }] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswTextarea, decorators: [{ type: Component, args: [{ selector: 'asw-textarea', template: "<ng-container *ngIf=\"control as control\">\r\n <mat-form-field [appearance]=\"control.style\" class=\"asw-mat-form-field {{control.customClass}}\">\r\n <mat-label>{{control.label}}</mat-label>\r\n <textarea matInput type=\"text\"\r\n [id]=\"control.id\"\r\n pattern=\"{{control.pattern}}\"\r\n [placeholder]=\"control.label\"\r\n [(ngModel)]=\"control.value\"\r\n #input=\"ngModel\"\r\n (change)=\"onChange(control)\"\r\n [matTooltip]=\"control.tooltip\"\r\n [maxlength]=\"control.maxlength\"\r\n [minlength]=\"control.minlength\"\r\n [required]=\"control.isRequired\"\r\n [disabled]=\"control.isDisabled ? true : false\"></textarea>\r\n <mat-error class=\"asw-mat-error\" *ngIf=\"input.invalid && (input.dirty || input.touched)\">\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.required\">\r\n {{control.label}} is required\r\n </ng-container>\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.minlength\">\r\n Sorry, {{control.label}} must be at least {{control.minlength}} characters long.\r\n </ng-container>\r\n <ng-container class=\"asw-mat-error\" *ngIf=\"input?.errors?.pattern\">\r\n {{control.customErrorMsg}}\r\n </ng-container>\r\n </mat-error>\r\n </mat-form-field>\r\n <ng-template [ngIf]=\"isPreviewTemplate\">\r\n <div class=\"row\">\r\n <div class=\"col-md-12\">\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Duplicate\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"duplicateTextAreaControl(control)\">\r\n <mat-icon>content_copy</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Edit\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"editTextAreaDialog(control, controlIndex)\">\r\n <mat-icon>edit</mat-icon>\r\n </button>\r\n <button mat-icon-button \r\n type=\"button\" \r\n matTooltip=\"Delete\" \r\n [matTooltipPosition]=\"'below'\" \r\n (click)=\"deleteTextAreaDialog(control, controlIndex)\">\r\n <mat-icon>delete</mat-icon>\r\n </button>\r\n </div> \r\n </div>\r\n </ng-template> \r\n</ng-container>\r\n" }] }], ctorParameters: () => [{ type: i1.MatDialog }], propDecorators: { control: [{ type: Input }], controlIndex: [{ type: Input }], isPreviewTemplate: [{ type: Input }], textAreaUpdateEvent: [{ type: Output }], textAreaDeleteEvent: [{ type: Output }], aswModelChange: [{ type: Output }], duplicateControl: [{ type: Output }] } }); /** * @license * Copyright ASW (A Software World) All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file */ class AswTextareaModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswTextareaModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: AswTextareaModule, declarations: [AswTextarea], imports: [CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatTooltipModule, MatDividerModule, MatIconModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule], exports: [AswTextarea] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswTextareaModule, imports: [CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatTooltipModule, MatDividerModule, MatIconModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswTextareaModule, decorators: [{ type: NgModule, args: [{ imports: [ CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatTooltipModule, MatDividerModule, MatIconModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule ], declarations: [ AswTextarea ], exports: [ AswTextarea ] }] }] }); /** * @license * Copyright ASW (A Software World) All Rights Reserved. * * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file */ /** * Generated bundle index. Do not edit. */ export { AswTextarea, AswTextareaModule }; //# sourceMappingURL=asoftwareworld-form-builder-form-control-textarea.mjs.map