{"version":3,"file":"ngx-t-forms-toggle-input-element.component-XZi6kPnL.mjs","sources":["../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/toggle-input-element/core/toggle/toggle.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/toggle-input-element/core/toggle/toggle.component.html","../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/toggle-input-element/toggle-input-element.component.ts","../../../projects/ngx-t-forms/src/lib/components/t-form-input/elements/toggle-input-element/toggle-input-element.component.html"],"sourcesContent":["import { ChangeDetectionStrategy, Component, ElementRef, inject, input } from '@angular/core';\r\nimport { NgControl } from '@angular/forms';\r\nimport { MatFormFieldControl } from '@angular/material/form-field';\r\nimport { MatSlideToggleChange, MatSlideToggleModule } from '@angular/material/slide-toggle';\r\nimport { OverlayModule } from '@angular/cdk/overlay';\r\nimport { TitleCasePipe } from '@angular/common';\r\nimport { ITowerStepColumn } from 'ngx-t-forms-types';\r\n\r\nimport { BaseCustomInput, BaseCustomInputConfig } from '../../../../../../services/core/t-input-controller/functions/baseCustomInput';\r\n\r\nconst customInputConfig: BaseCustomInputConfig = {\r\n  controlType: 'lib-toggle',\r\n  nextId: 0\r\n};\r\n\r\n@Component({\r\n  selector: 'lib-toggle',\r\n  imports: [MatSlideToggleModule, OverlayModule, TitleCasePipe],\r\n  templateUrl: './toggle.component.html',\r\n  providers: [{ provide: MatFormFieldControl, useExisting: ToggleComponent }],\r\n  styleUrl: './toggle.component.css',\r\n  changeDetection: ChangeDetectionStrategy.OnPush\r\n})\r\nexport class ToggleComponent extends BaseCustomInput<boolean> {\r\n  readonly inputConfig = input.required<ITowerStepColumn>();\r\n\r\n  constructor() {\r\n    super(\r\n      inject(NgControl, { optional: true, self: true }) as NgControl,\r\n      inject<ElementRef<HTMLElement>>(ElementRef),\r\n      customInputConfig\r\n    );\r\n\r\n    // A toggle is binary — it must always hold a value. Seed `false` so an\r\n    // unset toggle is never in a \"no value\" state (which would otherwise read\r\n    // as required while the switch visibly looks off).\r\n    this._value = false;\r\n  }\r\n\r\n  override get empty(): boolean {\r\n    // A toggle always holds a boolean (see `writeValue` + the constructor\r\n    // seed), so it is never empty. `false` is a provided value, not an absent\r\n    // one — mirroring `toggleRequiredValidator`, which passes `true` and `false`.\r\n    return false;\r\n  }\r\n\r\n  /** Coerce any incoming value to a boolean so the control is never null/undefined. */\r\n  override writeValue(value: boolean | null | undefined): void {\r\n    super.writeValue(Boolean(value));\r\n  }\r\n\r\n  override get shouldLabelFloat(): boolean {\r\n    return this.focused || !this.empty;\r\n  }\r\n\r\n  protected changed(event: MatSlideToggleChange): void {\r\n    this.value = event.checked;\r\n    this.onChange(event.checked);\r\n    this.stateChanges.next();\r\n  }\r\n\r\n  protected get isChecked(): boolean {\r\n    return Boolean(this.value);\r\n  }\r\n}\r\n","<ng-template\r\n  cdkConnectedOverlay\r\n  [cdkConnectedOverlayOpen]=\"!!(inputConfig().disabled || inputConfig().readonly)\"\r\n>\r\n  <div class=\"readonly-scrim\"></div>\r\n</ng-template>\r\n\r\n<mat-slide-toggle\r\n  class=\"toggle-control\"\r\n  [disabledInteractive]=\"inputConfig().disabled || inputConfig().readonly\"\r\n  [required]=\"inputConfig().required\"\r\n  [labelPosition]=\"inputConfig().labelPosition || 'after'\"\r\n  (change)=\"changed($event)\"\r\n  [checked]=\"isChecked\"\r\n  [ariaReadOnly]=\"inputConfig().disabled || inputConfig().readonly\"\r\n  [disabled]=\"inputConfig().disabled || inputConfig().readonly\"\r\n>\r\n  @if (inputConfig().falseLabel || inputConfig().trueLabel) {\r\n    @if (inputConfig().labelPosition !== 'after') {\r\n      {{ inputConfig().label | titlecase }}\r\n      <span class=\"spacer\"></span>\r\n      @if (isChecked) {\r\n        <span class=\"true-label\">{{ inputConfig().trueLabel || 'Yes' }}</span>\r\n      } @else {\r\n        <span class=\"false-label\">{{ inputConfig().falseLabel || 'No' }}</span>\r\n      }\r\n    } @else {\r\n      @if (isChecked) {\r\n        <span class=\"true-label\">{{ inputConfig().trueLabel || 'Yes' }}</span>\r\n      } @else {\r\n        <span class=\"false-label\">{{ inputConfig().falseLabel || 'No' }}</span>\r\n      }\r\n      <span class=\"spacer\"></span>\r\n      {{ inputConfig().label | titlecase }}\r\n    }\r\n  }\r\n</mat-slide-toggle>\r\n","import { ChangeDetectionStrategy, Component, computed, input, output } from '@angular/core';\r\nimport { FormGroup, ReactiveFormsModule } from '@angular/forms';\r\nimport { MatFormFieldModule } from '@angular/material/form-field';\r\nimport { MatIconModule } from '@angular/material/icon';\r\nimport { MatButtonModule } from '@angular/material/button';\r\nimport { MatTooltipModule } from '@angular/material/tooltip';\r\nimport type { ITowerStepColumn } from 'ngx-t-forms-types';\r\nimport { TFormInputStatusComponent } from '../../../t-form-input-status/t-form-input-status.component';\r\nimport { ToggleComponent } from './core/toggle/toggle.component';\r\nimport { getInputErrorMessage } from '../../../../services/core/t-input-controller/functions/inputErrorMessage';\r\n\r\n/**\r\n * Wraps `lib-toggle` in a `mat-form-field` and surfaces the configured\r\n * label / hint / error / suffix / prefix metadata for the column.\r\n */\r\n@Component({\r\n  selector: 'lib-toggle-input-element',\r\n  templateUrl: './toggle-input-element.component.html',\r\n  styleUrl: './toggle-input-element.component.css',\r\n  changeDetection: ChangeDetectionStrategy.OnPush,\r\n  imports: [\r\n    ReactiveFormsModule,\r\n    MatFormFieldModule,\r\n    MatIconModule,\r\n    MatButtonModule,\r\n    MatTooltipModule,\r\n    TFormInputStatusComponent,\r\n    ToggleComponent,\r\n  ],\r\n})\r\nexport class ToggleInputElementComponent {\r\n  /** Form-input column definition. */\r\n  readonly inputConfig = input.required<ITowerStepColumn>();\r\n\r\n  /** Reactive form group hosting the control identified by `inputConfig.id`. */\r\n  readonly formGroup = input.required<FormGroup>();\r\n\r\n  /** Emitted when the consumer requests a reload of this input. */\r\n  readonly reload = output<void>();\r\n\r\n  protected readonly errorMessage = computed(() =>\r\n    getInputErrorMessage(this.inputConfig(), this.formGroup()),\r\n  );\r\n}\r\n","<form [formGroup]=\"formGroup()\">\r\n  @if (inputConfig(); as inputConfig) {\r\n    <mat-form-field\r\n      [appearance]=\"inputConfig.appearance || 'fill'\"\r\n      floatLabel=\"always\"\r\n      subscriptSizing=\"dynamic\"\r\n    >\r\n      @if (!(inputConfig.disabled || errorMessage())) {\r\n        <mat-label>\r\n          toggle to select\r\n          <lib-t-form-input-status [inputConfig]=\"inputConfig\"></lib-t-form-input-status>\r\n        </mat-label>\r\n      }\r\n\r\n      <lib-toggle\r\n        [inputConfig]=\"inputConfig\"\r\n        [required]=\"inputConfig.required\"\r\n        [formControlName]=\"inputConfig.id\"\r\n      ></lib-toggle>\r\n\r\n      @if (inputConfig.hintLabel || inputConfig.temporaryHint) {\r\n        <mat-hint class=\"inputHint\">\r\n          {{ inputConfig.temporaryHint || inputConfig.hintLabel }}\r\n        </mat-hint>\r\n      }\r\n\r\n      @if (!!errorMessage()) {\r\n        <mat-error class=\"oneLineTextEllipsis\" matTooltipClass=\"errorToolTip\">{{ errorMessage() }}</mat-error>\r\n      }\r\n\r\n      @if (inputConfig.canReload?.canReload) {\r\n        <button\r\n          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()\"\r\n          matSuffix\r\n        >\r\n          <mat-icon style=\"color: var(--mat-sys-primary)\">sync</mat-icon>\r\n        </button>\r\n      }\r\n\r\n      @if (inputConfig.prefixIcon) {\r\n        <mat-icon matPrefix>{{ inputConfig.prefixIcon }}</mat-icon>\r\n      }\r\n\r\n      @if (inputConfig.suffixIcon && inputConfig.id !== 'password') {\r\n        <mat-icon matSuffix>{{ inputConfig.suffixIcon }}</mat-icon>\r\n      }\r\n\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      @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    </mat-form-field>\r\n  }\r\n</form>\r\n"],"names":["i2","i4"],"mappings":";;;;;;;;;;;;;;;;;;;AAUA,MAAM,iBAAiB,GAA0B;AAC/C,IAAA,WAAW,EAAE,YAAY;AACzB,IAAA,MAAM,EAAE;CACT;AAUK,MAAO,eAAgB,SAAQ,eAAwB,CAAA;AAG3D,IAAA,WAAA,GAAA;QACE,KAAK,CACH,MAAM,CAAC,SAAS,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAc,EAC9D,MAAM,CAA0B,UAAU,CAAC,EAC3C,iBAAiB,CAClB;AAPM,QAAA,IAAA,CAAA,WAAW,GAAG,KAAK,CAAC,QAAQ,iFAAoB;;;;AAYvD,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK;IACrB;AAEA,IAAA,IAAa,KAAK,GAAA;;;;AAIhB,QAAA,OAAO,KAAK;IACd;;AAGS,IAAA,UAAU,CAAC,KAAiC,EAAA;QACnD,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAClC;AAEA,IAAA,IAAa,gBAAgB,GAAA;QAC3B,OAAO,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK;IACpC;AAEU,IAAA,OAAO,CAAC,KAA2B,EAAA;AAC3C,QAAA,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO;AAC1B,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC;AAC5B,QAAA,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;IAC1B;AAEA,IAAA,IAAc,SAAS,GAAA;AACrB,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC;IAC5B;+GAxCW,eAAe,EAA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