{"version":3,"file":"ngx-t-forms-basic-input-input-element.component-CykKxWu0.mjs","sources":["../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/basic-input-input-element/basic-input-input-element.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/basic-input-input-element/basic-input-input-element.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';\r\nimport { ReactiveFormsModule, FormGroup, FormControl } from '@angular/forms';\r\n\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatInputModule } from '@angular/material/input';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\n\r\nimport { TFormInputStatusComponent } from '../../../t-form-input-status/t-form-input-status.component';\r\nimport { getInputErrorMessage } from '../../../../services/core/t-input-controller/functions/inputErrorMessage';\r\nimport { InputPipeTypes, ITowerStepColumn } from 'ngx-t-forms-types';\r\nimport { InputCustomComponent } from './core/input-custom/input-custom.component';\r\n\r\n@Component({\r\n  selector: 'lib-basic-input-input-element',\r\n  imports: [\r\n    MatFormFieldModule,\r\n    MatInputModule,\r\n    MatIconModule,\r\n    MatButtonModule,\r\n    MatTooltipModule,\r\n    ReactiveFormsModule,\r\n    TFormInputStatusComponent,\r\n    InputCustomComponent,\r\n  ],\r\n  templateUrl: './basic-input-input-element.component.html',\r\n  styleUrl: './basic-input-input-element.component.css',\r\n  changeDetection: ChangeDetectionStrategy.OnPush,\r\n})\r\nexport class BasicInputInputElementComponent {\r\n\r\n  readonly inputConfig = input.required<ITowerStepColumn>();\r\n  readonly formGroup = input.required<FormGroup>();\r\n\r\n  readonly reload = output<void>();\r\n\r\n  protected readonly formControl = computed(\r\n    () => this.formGroup().controls[this.inputConfig().id] as FormControl<unknown>,\r\n  );\r\n\r\n  protected readonly errorMessage = computed(\r\n    () => getInputErrorMessage(this.inputConfig(), this.formGroup()),\r\n  );\r\n\r\n  protected readonly hasError = computed(() => {\r\n    // Correctly access the control within the form group\r\n    const control = this.formGroup().get(this.inputConfig().id);\r\n    return control?.invalid && (control?.touched || control?.dirty);\r\n  });\r\n\r\n  protected readonly currencyPrefix = computed(() => {\r\n    const hasPipe = this.inputConfig().pipe?.pipeType === InputPipeTypes.Currency;\r\n    if (!hasPipe) return undefined;\r\n    return this.inputConfig().pipe?.param;\r\n  });\r\n\r\n  protected passwordStrengthColor(formControlName: string) {\r\n    const form = this.formGroup();\r\n    const value: string = form?.value[formControlName];\r\n    let strongPassword = new RegExp(\r\n      '(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{8,})'\r\n    );\r\n    let mediumPassword = new RegExp(\r\n      '((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{6,}))|((?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9])(?=.{8,}))'\r\n    );\r\n    if (strongPassword.test(value)) {\r\n      return 'var(--ion-color-success)';\r\n    } else if (mediumPassword.test(value)) {\r\n      return 'var(--ion-color-warning)';\r\n    } else {\r\n      return 'var(--ion-color-danger)';\r\n    }\r\n  }\r\n\r\n  protected checkPasswordStrength(formControlName: string) {\r\n    const form = this.formGroup();\r\n\r\n    const value: string = form?.value[formControlName];\r\n    let strongPassword = new RegExp(\r\n      '(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{8,})'\r\n    );\r\n    let mediumPassword = new RegExp(\r\n      '((?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[^A-Za-z0-9])(?=.{6,}))|((?=.*[a-z])(?=.*[A-Z])(?=.*[^A-Za-z0-9])(?=.{8,}))'\r\n    );\r\n    if (strongPassword.test(value)) {\r\n      return 'strong';\r\n    } else if (mediumPassword.test(value)) {\r\n      return 'medium';\r\n    } else {\r\n      return 'weak';\r\n    }\r\n\r\n  }\r\n}\r\n","<ng-container [formGroup]=\"formGroup()\">\r\n  @if (inputConfig(); as classInput) {\r\n  <mat-form-field [appearance]=\"inputConfig().appearance || 'fill'\" subscriptSizing=\"dynamic\">\r\n    <mat-label>\r\n      {{ inputConfig().label }}\r\n      <lib-t-form-input-status [inputConfig]=\"inputConfig()\"></lib-t-form-input-status>\r\n    </mat-label>\r\n    @if(currencyPrefix()){\r\n    <span style=\"color: var(--mat-sys-primary);padding-right: 4px;\" matTextPrefix>{{currencyPrefix()}} </span>\r\n    }\r\n\r\n    <lib-input-custom [inputConfig]=\"inputConfig()\" [required]=\"inputConfig().required\"\r\n      [formControlName]=\"inputConfig().id\"></lib-input-custom>\r\n\r\n    @if(errorMessage()) {\r\n    <mat-error class=\"oneLineTextEllipsis\" matTooltipClass=\"errorToolTip\">{{errorMessage()}}</mat-error>\r\n    }\r\n    <!--     [type]=\"this.inputConfig.showPassword ? 'text' : this.inputConfig.type||'text'\"-->\r\n    <!-- @if(classInput.canRefresh){\r\n        <button\r\n        (click)=\"classInput.refresh()\"\r\n        style=\"  min-width: 1%;\"\r\n          [matTooltip]=\"'Click to refresh this field. This will update any calculated values, fetch latest data from services, or reload available options'\"\r\n          color=\"primary\" matSuffix mat-icon-button>\r\n          <mat-icon>\r\n            sync\r\n          </mat-icon>\r\n        </button>\r\n      } -->\r\n\r\n\r\n    @if(inputConfig().hintLabel || classInput.temporaryHint ){\r\n    <mat-hint class=\"inputHint\">\r\n      {{ classInput.temporaryHint || inputConfig().hintLabel}}\r\n    </mat-hint>\r\n    }\r\n      @if(inputConfig().canReload?.canReload){\r\n        <button  mat-icon-button\r\n        style=\"margin-right: 4px;\"\r\n        matTooltip=\"Click to refresh this field.\"\r\n        class=\"input-sync-button\"\r\n        (click)=\"inputConfig().canReload?.emit()\" matSuffix>\r\n          <mat-icon\r\n          style=\"color:var(--mat-sys-primary)\"\r\n          >sync</mat-icon>\r\n        </button>\r\n      }\r\n\r\n\r\n    <!-- Prefix Icon -->\r\n    @if (inputConfig().prefixIcon) {\r\n      <mat-icon matPrefix>{{ inputConfig().prefixIcon }}</mat-icon>\r\n    }\r\n\r\n    <!-- Suffix Icon or Password Visibility Toggle -->\r\n    <!-- <ng-container *ngIf=\"inputConfig.suffixIcon\">\r\n      <mat-icon *ngIf=\"inputConfig.id !== 'password'\" matSuffix>{{ inputConfig.suffixIcon\r\n        }}</mat-icon>\r\n      <button *ngIf=\"inputConfig.id === 'password'\" (click)=\"classInput.togglePasswordVisibility()\"\r\n        mat-icon-button matSuffix>\r\n        <mat-icon>{{ classInput.showPassword ? 'remove_red_eye' : 'eye_off' }}</mat-icon>\r\n      </button>\r\n    </ng-container> -->\r\n\r\n    <!-- Prefix & Suffix Text -->\r\n    @if (inputConfig().prefixText) {\r\n      <span matPrefix style=\"top: 0\">{{ inputConfig().prefixText }}</span>\r\n    }\r\n    @if (inputConfig().suffixText) {\r\n      <span matSuffix style=\"padding-left: 5px\">{{ inputConfig().suffixText }}</span>\r\n    }\r\n\r\n    <!-- Character Count Hint -->\r\n    @if (inputConfig().maxLength && formGroup()) {\r\n      <mat-hint align=\"end\">\r\n        {{ (formGroup().controls[inputConfig().id]?.value?.length || 0) + '/' + inputConfig().maxLength }}\r\n      </mat-hint>\r\n    }\r\n\r\n    <!-- Password Strength Hint -->\r\n    @if (inputConfig().type === 'password') {\r\n      <mat-hint [style.color]=\"passwordStrengthColor(inputConfig().id)\"\r\n        matTooltip=\"The password should be at least 8 characters long. Have at least one uppercase letter, one lowercase, one digit, one special character.\"\r\n        align=\"end\">\r\n        {{ checkPasswordStrength(inputConfig().id) }} password\r\n      </mat-hint>\r\n    }\r\n    <!-- @if(inputConfig?.canReload){\r\n  <mat-hint  align=\"end\">\r\n\r\n     <button  click=\" canReload.emit()\" style=\"    height: 28px;\r\n    width: 28px;\r\n    padding: 0px;\r\n    font-size: 1em;\" [matTooltip]=\"'Reload ' + inputConfig.label +' resources'\" mat-icon-button>\r\n    <mat-icon>\r\n     sync\r\n    </mat-icon>\r\n\r\n  </button>\r\n  </mat-hint>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