import { Component, Input, Output, EventEmitter } from '@angular/core';
import { DefaultCreateSaveCancel } from '../../../lib/create-save-cancel-default';
import { TranslatePipe } from '@ngx-translate/core';
import { IconComponent } from '../../../../icon/icon.component';
import { PopoverTriggerDirective } from '../../../../popover/popover.component';
import { ButtonDirective } from '../../../../button/button.directive';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import * as i0 from "@angular/core";
import * as i1 from "@angular/forms";
export class THeadCreateCancelComponent extends DefaultCreateSaveCancel {
    constructor() {
        super();
        this.create = new EventEmitter();
    }
    ngOnChanges() {
        // ===========================================
        // Call DefaultCreateSaveCancel "ngOnChanges()" life cycle hook.
        // ===========================================
        super.ngOnChanges();
        this.createButtonContent = this.grid.getSetting('add.createButtonContent');
        this.cancelButtonContent = this.grid.getSetting('add.cancelButtonContent');
    }
    onCancel(evt) {
        evt.preventDefault();
        this.grid.createFormShown = false;
        this.cancelCreate.emit();
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: THeadCreateCancelComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "18.2.13", type: THeadCreateCancelComponent, isStandalone: true, selector: "ng2-st-actions", inputs: { grid: "grid", cancelCreate: "cancelCreate" }, outputs: { create: "create" }, usesInheritance: true, usesOnChanges: true, ngImport: i0, template: `
        <div class="form-creator-submit" [formGroup]="editingFormGroup">
          <button type="submit"
            class="slds-m-right--x-small uno-smart-table-action uno-smart-table-action-add-create text-uppercase"
            unoButton
            unoType="green"
            unoSize="small"
            (click)="$event.preventDefault(); create.emit($event)"
            [disabled]="!editingFormGroup.valid"
            [title]="createButtonContent | translate"
        
            uno-popover-trigger
            [unoPopover]="formErrorsTemplate"
            [unoPopoverOpen]="openValidatorPopover"
        
            unoPopoverPlacement="leftBottom"
            unoPopoverNubbin="right-top"
            unoPopoverSize="small"
            unoPopoverTooltip="true"
            [unoPopoverTheme]="grid.getSetting('popoverTheme') || 'info'">
            {{ createButtonContent | translate }}
          </button>
        
          <uno-icon icon="close"
            size="small"
            class="uno-smart-table-action uno-smart-table-action-add-cancel"
            [title]="cancelButtonContent | translate"
            (click)="onCancel($event)">
          </uno-icon>
        </div>
        
        <!-- The "editingFormGroup" ALL Controller's Input Validator errors: -->
        <ng-template #formErrorsTemplate>
          <div class="form-errors-content-container">
            <!--Following errors where found on editing:-->
            @for (cell of grid.dataSet.columns; track cell) {
              <div class="slds-m-top--x-small">
                @if (editingFormGroup.get(cell.id)?.errors) {
                  <div>
                    <b style="color:red;">{{ cell.id }}</b> is invalid!
                    @for (errors of errorsData; track errors) {
                      <div>
                        @if (errors.input === cell.id) {
                          <div>
                            @for (strError of errors.translated; track strError) {
                              <div>
                                {{ strError }}
                              </div>
                            }
                          </div>
                        }
                      </div>
                    }
                  </div>
                }
              </div>
            }
          </div>
        </ng-template>
        `, isInline: true, dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: ButtonDirective, selector: "[unoButton]", inputs: ["unoType", "unoSize"] }, { kind: "directive", type: PopoverTriggerDirective, selector: "[uno-popover-trigger]", inputs: ["unoPopover", "unoPopoverHeader", "unoPopoverFooter", "unoPopoverTemplate", "unoPopoverTemplateData", "hasEdit", "hasDelete", "infoTitle", "infoCreatedBy", "infoModifiedBy", "infoDate", "unoPopoverPlacement", "unoPopoverTheme", "unoPopoverNubbin", "unoPopoverSize", "unoPopoverTooltip", "unoPopoverDelay", "unoPopoverInteractive", "unoPopoverOpen"], outputs: ["unoPopoverToggled", "unoPopoverTemplateEvent"], exportAs: ["unoPopoverTrigger"] }, { kind: "component", type: IconComponent, selector: "uno-icon", inputs: ["svgType", "icon", "withOpacity", "color", "size", "customColor"] }, { kind: "pipe", type: TranslatePipe, name: "translate" }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.13", ngImport: i0, type: THeadCreateCancelComponent, decorators: [{
            type: Component,
            args: [{
                    selector: 'ng2-st-actions',
                    template: `
        <div class="form-creator-submit" [formGroup]="editingFormGroup">
          <button type="submit"
            class="slds-m-right--x-small uno-smart-table-action uno-smart-table-action-add-create text-uppercase"
            unoButton
            unoType="green"
            unoSize="small"
            (click)="$event.preventDefault(); create.emit($event)"
            [disabled]="!editingFormGroup.valid"
            [title]="createButtonContent | translate"
        
            uno-popover-trigger
            [unoPopover]="formErrorsTemplate"
            [unoPopoverOpen]="openValidatorPopover"
        
            unoPopoverPlacement="leftBottom"
            unoPopoverNubbin="right-top"
            unoPopoverSize="small"
            unoPopoverTooltip="true"
            [unoPopoverTheme]="grid.getSetting('popoverTheme') || 'info'">
            {{ createButtonContent | translate }}
          </button>
        
          <uno-icon icon="close"
            size="small"
            class="uno-smart-table-action uno-smart-table-action-add-cancel"
            [title]="cancelButtonContent | translate"
            (click)="onCancel($event)">
          </uno-icon>
        </div>
        
        <!-- The "editingFormGroup" ALL Controller's Input Validator errors: -->
        <ng-template #formErrorsTemplate>
          <div class="form-errors-content-container">
            <!--Following errors where found on editing:-->
            @for (cell of grid.dataSet.columns; track cell) {
              <div class="slds-m-top--x-small">
                @if (editingFormGroup.get(cell.id)?.errors) {
                  <div>
                    <b style="color:red;">{{ cell.id }}</b> is invalid!
                    @for (errors of errorsData; track errors) {
                      <div>
                        @if (errors.input === cell.id) {
                          <div>
                            @for (strError of errors.translated; track strError) {
                              <div>
                                {{ strError }}
                              </div>
                            }
                          </div>
                        }
                      </div>
                    }
                  </div>
                }
              </div>
            }
          </div>
        </ng-template>
        `,
                    standalone: true,
                    imports: [FormsModule, ReactiveFormsModule, ButtonDirective, PopoverTriggerDirective, IconComponent, TranslatePipe]
                }]
        }], ctorParameters: () => [], propDecorators: { grid: [{
                type: Input
            }], cancelCreate: [{
                type: Input
            }], create: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 