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

177 lines (171 loc) 13 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, AswMultiSelectDialog, 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/form-field'; import * as i5 from '@angular/material/checkbox'; import { MatCheckboxModule } from '@angular/material/checkbox'; import * as i6 from '@angular/material/icon'; import { MatIconModule } from '@angular/material/icon'; import * as i7 from '@angular/material/tooltip'; import { MatTooltipModule } from '@angular/material/tooltip'; import * as i8 from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button'; import { MatDividerModule } from '@angular/material/divider'; import { MatInputModule } from '@angular/material/input'; 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 AswCheckbox { dialog; constants = Constants; control = null; controlIndex; isPreviewTemplate = false; checkboxUpdateEvent = new EventEmitter(); checkboxDeleteEvent = new EventEmitter(); selectionChange = new EventEmitter(); duplicateControl = new EventEmitter(); constructor(dialog) { this.dialog = dialog; } deleteCheckboxDialog(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.checkboxDeleteEvent.emit(controlIndex); } }); } editCheckboxDialog(control, controlIndex) { const dialogRef = this.dialog.open(AswMultiSelectDialog, { disableClose: true, width: '80%', minWidth: '70vw', data: control }); dialogRef.afterClosed().subscribe(result => { if (result !== undefined) { this.checkboxUpdateEvent.emit({ control: result, index: controlIndex }); } }); } onSelectionChange(control) { this.selectionChange.emit(control); } duplicateCheckboxControl(control) { this.duplicateControl.emit(control); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswCheckbox, deps: [{ token: i1.MatDialog }], target: i0.ɵɵFactoryTarget.Component }); static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "18.2.11", type: AswCheckbox, selector: "asw-checkbox", inputs: { control: "control", controlIndex: "controlIndex", isPreviewTemplate: "isPreviewTemplate" }, outputs: { checkboxUpdateEvent: "checkboxUpdateEvent", checkboxDeleteEvent: "checkboxDeleteEvent", selectionChange: "selectionChange", duplicateControl: "duplicateControl" }, ngImport: i0, template: "<ng-container *ngIf=\"control as control\">\r\n <mat-label>{{control.label}}</mat-label>\r\n <div *ngFor=\"let option of control.options\">\r\n <mat-checkbox color=\"primary\"\r\n [class]=\"control.customClass\"\r\n [matTooltip]=\"option.value\"\r\n [(ngModel)]=\"option.isChecked\"\r\n (change)=\"onSelectionChange(control)\"\r\n [required]=\"control.isRequired\"\r\n [disabled]=\"control.isDisabled ? true : false\">\r\n {{option.value}}\r\n </mat-checkbox>\r\n </div>\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)=\"duplicateCheckboxControl(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)=\"editCheckboxDialog(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)=\"deleteCheckboxDialog(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.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { 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.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i4.MatLabel, selector: "mat-label" }, { kind: "component", type: i5.MatCheckbox, selector: "mat-checkbox", inputs: ["aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "disableRipple", "tabIndex", "color", "disabledInteractive", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { kind: "component", type: i6.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { kind: "directive", type: i7.MatTooltip, selector: "[matTooltip]", inputs: ["matTooltipPosition", "matTooltipPositionAtOrigin", "matTooltipDisabled", "matTooltipShowDelay", "matTooltipHideDelay", "matTooltipTouchGestures", "matTooltip", "matTooltipClass"], exportAs: ["matTooltip"] }, { 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: AswCheckbox, decorators: [{ type: Component, args: [{ selector: 'asw-checkbox', template: "<ng-container *ngIf=\"control as control\">\r\n <mat-label>{{control.label}}</mat-label>\r\n <div *ngFor=\"let option of control.options\">\r\n <mat-checkbox color=\"primary\"\r\n [class]=\"control.customClass\"\r\n [matTooltip]=\"option.value\"\r\n [(ngModel)]=\"option.isChecked\"\r\n (change)=\"onSelectionChange(control)\"\r\n [required]=\"control.isRequired\"\r\n [disabled]=\"control.isDisabled ? true : false\">\r\n {{option.value}}\r\n </mat-checkbox>\r\n </div>\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)=\"duplicateCheckboxControl(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)=\"editCheckboxDialog(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)=\"deleteCheckboxDialog(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 }], checkboxUpdateEvent: [{ type: Output }], checkboxDeleteEvent: [{ type: Output }], selectionChange: [{ 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 AswCheckboxModule { static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswCheckboxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.11", ngImport: i0, type: AswCheckboxModule, declarations: [AswCheckbox], imports: [CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatDividerModule, MatCheckboxModule, MatIconModule, MatTooltipModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule], exports: [AswCheckbox] }); static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswCheckboxModule, imports: [CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatDividerModule, MatCheckboxModule, MatIconModule, MatTooltipModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule] }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.11", ngImport: i0, type: AswCheckboxModule, decorators: [{ type: NgModule, args: [{ imports: [ CommonModule, FormsModule, ReactiveFormsModule, MatInputModule, MatSelectModule, MatDialogModule, MatSlideToggleModule, MatDividerModule, MatCheckboxModule, MatIconModule, MatTooltipModule, AswConfirmDialogModule, MatButtonModule, AswSharedDialogModule ], declarations: [ AswCheckbox ], exports: [ AswCheckbox ] }] }] }); /** * @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 { AswCheckbox, AswCheckboxModule }; //# sourceMappingURL=asoftwareworld-form-builder-form-control-checkbox.mjs.map