{"version":3,"file":"talenra-ngx-base-shared.mjs","sources":["../../../projects/ngx-base/shared/src/control-base/control-base.directive.ts","../../../projects/ngx-base/shared/src/field-underline/field-underline.types.ts","../../../projects/ngx-base/shared/src/field-underline/field-underline.component.ts","../../../projects/ngx-base/shared/src/i18n/locale.type.ts","../../../projects/ngx-base/shared/src/on-off-control-base/on-off-control-base.component.ts","../../../projects/ngx-base/shared/src/version.ts","../../../projects/ngx-base/shared/talenra-ngx-base-shared.ts"],"sourcesContent":["import { ChangeDetectorRef, Directive, Input, booleanAttribute } from '@angular/core';\nimport { ControlValueAccessor } from '@angular/forms';\n\n/**\n * Generic FormControl implementation. Extended by custom controls.\n */\n@Directive()\nexport class ControlBaseDirective implements ControlValueAccessor {\n  /** Name of the corresponding `FormControl` if used in a reactive form context. */\n  @Input() formControlName = '';\n\n  /** Determinates whether the control is en-/disabled. */\n  @Input({ transform: booleanAttribute })\n  /** Get whether the control is en-/disabled. */\n  get disabled() {\n    return this._disabled;\n  }\n  /** Set whether the control is en-/disabled. */\n  set disabled(value: boolean) {\n    this._disabled = value;\n  }\n  /** @internal */\n  _disabled = false;\n\n  /** Determines whether the control is readonly. */\n  get readonly() {\n    return this._readonly;\n  }\n  /** Set whether the control is readonly. */\n  set readonly(value: boolean) {\n    this._readonly = value;\n  }\n  /** @internal */\n  _readonly: boolean = false;\n\n  /** @internal */\n  public id = '';\n\n  /** The control's current value. */\n  @Input()\n  /** Get the control's current value. */\n  get value() {\n    return this._value;\n  }\n\n  /** Set the control's current value. */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  set value(value: any) {\n    this.setValue(value, true);\n  }\n\n  /** @internal */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  _value: any = null;\n\n  /** @internal */\n  constructor(protected changeDetector: ChangeDetectorRef) {}\n\n  /** @internal */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  writeValue(value: any) {\n    this.setValue(value, false);\n    this.changeDetector.markForCheck();\n  }\n\n  /** @internal */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  protected setValue(value: any, emitEvent: boolean) {\n    this._value = value;\n    if (emitEvent) this.onChange(value);\n  }\n\n  /** @internal */\n  // eslint-disable-next-line @typescript-eslint/no-explicit-any\n  registerOnChange(fn: any): void {\n    this.onChange = fn;\n  }\n\n  /** @internal */\n  public registerOnTouched(fn: () => void): void {\n    this.onTouched = fn;\n  }\n\n  /** @internal */\n  public onTouched = (): void => undefined;\n\n  /** @internal */\n  setDisabledState(isDisabled: boolean): void {\n    this.disabled = isDisabled;\n  }\n\n  /** @internal */\n  // eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\n  public onChange = (_: any) => {};\n}\n","/**\n * Values accepted by the `FieldUnderline`'s `status` property.\n *\n * ### Import\n *\n * ```typescript\n * import { FieldUnderlineStatus } from '@talenra/ngx-base/form-field';\n * ```\n *\n * @see {@link FieldUnderline}\n * @see {@link TFieldUnderlineStatus}\n * @internal\n */\nexport const FieldUnderlineStatus = {\n  Default: 'default',\n  Invalid: 'invalid',\n} as const;\n\n/**\n * Type of values accepted by the `FieldUnderline`'s `status` property.\n *\n * ### Import\n *\n * ```typescript\n * import { TFieldUnderlineStatus } from '@talenra/ngx-base/form-field';\n * ```\n *\n * @see {@link FieldUnderline}\n * @see {@link FieldUnderlineStatus}\n * @internal\n */\nexport type TFieldUnderlineStatus = (typeof FieldUnderlineStatus)[keyof typeof FieldUnderlineStatus];\n","import { booleanAttribute, ChangeDetectionStrategy, Component, input } from '@angular/core';\nimport { FieldUnderlineStatus, TFieldUnderlineStatus } from './field-underline.types';\n\n/**\n * The underline used in FormField and SearchField.\n *\n * @internal\n */\n@Component({\n  selector: 'talenra-field-underline',\n  template: ``,\n  styleUrls: ['./field-underline.component.scss'],\n  changeDetection: ChangeDetectionStrategy.OnPush,\n  host: {\n    '[class.has-focus]': 'hasFocus()',\n    '[class.status--invalid]': `status() === ${FieldUnderlineStatus.Invalid}`,\n  },\n})\nexport class FieldUnderlineComponent {\n  /** Determines whether the associated field is focussed. */\n  public hasFocus = input<boolean, unknown>(false, { transform: booleanAttribute });\n\n  /** Status of the associated field. */\n  public status = input<TFieldUnderlineStatus>(FieldUnderlineStatus.Default);\n}\n","/**\n * Locale values supported by the library.\n *\n * ```html\n * <talenra-date formControlName=\"date1\" dynamicLocale=\"fr-CH\"></talenra-date>\n * ```\n *\n * ```typescript\n * import { Locale, TLocale } from '@talenra/ngx-base/shared';\n * const locale: TLocale = Locale['fr-CH'];\n * ```\n *\n * ### Import\n *\n * ```typescript\n * import { Locale } from '@talenra/ngx-base/shared';\n * ```\n */\nexport const Locale = { 'en-US': 'en-US', 'de-CH': 'de-CH', 'fr-CH': 'fr-CH', 'it-CH': 'it-CH' } as const;\n\n/**\n * Type of locale values supported by the library.\n *\n * ### Import\n *\n * ```typescript\n * import { TLocale } from '@talenra/ngx-base/shared';\n * ```\n */\nexport type TLocale = (typeof Locale)[keyof typeof Locale];\n\n/**\n * Type used for translation maps. Represents a dictionary of translations for different locales. The keys of the\n * dictionary are the locales, and the values are objects containing key-value pairs for translations.\n *\n * ```typescript\n * export const translations: Dictionary = {\n *  'de-CH': {\n *    itemsPerPage: 'Einträge pro Seite',\n *    of: 'von',\n *  },\n *  'fr-CH': {\n *    itemsPerPage: 'Entrées par page',\n *    of: 'de',\n *  },\n *  'it-CH': {\n *    itemsPerPage: 'Voci per pagina',\n *    of: 'di',\n *  },\n *  'en-US': {\n *    itemsPerPage: 'Items per page',\n *    of: 'of',\n *  },\n * ```\n *\n * ### Import\n *\n * ```typescript\n * import { Dictionary } from '@talenra/ngx-base/shared';\n * ```\n */\nexport type Dictionary = Record<TLocale, { [key: string]: string }>;\n","import { ChangeDetectorRef, Component, Input, booleanAttribute, inject } from '@angular/core';\nimport { ControlValueAccessor } from '@angular/forms';\nimport { asapScheduler } from 'rxjs';\nimport { ControlBaseDirective } from '../control-base/control-base.directive';\n\n/**\n * Abstract component for building on-off-controls (e.g. checkbox).\n */\n@Component({ template: `` })\n// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unused-vars\nexport class OnOffControlBaseComponent<T = any> extends ControlBaseDirective implements ControlValueAccessor {\n  /** Label displayed to the user. */\n  @Input() label = '';\n\n  /** Determines whether the control is checked.\n   *\n   * Note: Typically the `checked` property determines the state of the control\n   * presented to the user. In case of the `<talenra-checkbox>`, the displayed state depends\n   * on `checked` _and_ `determinate` state, while the latter takes precedence.\n   */\n  @Input({ transform: booleanAttribute })\n  /** Get whether the control is checked. */\n  get checked(): boolean {\n    return this._checked;\n  }\n\n  /** Set whether the control is checked. */\n  set checked(value: boolean) {\n    if (!!value === this.checked) return;\n    this._checked = !!value;\n  }\n\n  private _checked = false;\n\n  /**\n   * The native element's value attribute. Setting the value will update the checked\n   * state of the control (`false` → unchecked/off, `true` → checked/on).\n   *\n   * Note: A native checkbox element's value and checked state do not neccessarily align.\n   * However, the on-off-controls in this library (e.g. `<talenra-checkbox>`, `<talenra-toggle>`)\n   * keep the control's `value` and `checked` state in sync.\n   */\n  @Input()\n  /** Get the control's value. */\n  get value() {\n    return this._value;\n  }\n\n  /** Set the control's value. */\n  set value(value: boolean) {\n    super.value = value;\n    this.checked = value;\n    this.changeDetector.markForCheck();\n  }\n\n  /** @internal */\n  _value = false;\n\n  protected changeDetector: ChangeDetectorRef = inject(ChangeDetectorRef);\n\n  /** @internal */\n  writeValue(value: boolean) {\n    super.writeValue(value);\n  }\n\n  /** @internal */\n  override setValue(value: boolean, emitEvent: boolean) {\n    this._value = value;\n    this.checked = value;\n    if (emitEvent) this.onChange(value);\n  }\n\n  /** @internal */\n  public handleBlur(): void {\n    // The `onTouched` method is called asynchronously to prevent expression-changed-after-checked error.\n    // cmp. https://github.com/angular/components/blob/31187abae619cf76e7f0a7771ca6e5900a50e90c/src/material/checkbox/checkbox.ts#L395\n    asapScheduler.schedule(() => this.onTouched());\n  }\n}\n","/**\n * Library version for internal usage. For external usage (consumers of the library), use the `version` property from\n * the public API.\n *\n * @internal\n */\nexport const LIB_VERSION: string = '8.0.0';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AAGA;;AAEG;MAEU,oBAAoB,CAAA;;AAK/B,IAAA,IAEI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,SAAS;;;IAGvB,IAAI,QAAQ,CAAC,KAAc,EAAA;AACzB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;;;AAMxB,IAAA,IAAI,QAAQ,GAAA;QACV,OAAO,IAAI,CAAC,SAAS;;;IAGvB,IAAI,QAAQ,CAAC,KAAc,EAAA;AACzB,QAAA,IAAI,CAAC,SAAS,GAAG,KAAK;;;AASxB,IAAA,IAEI,KAAK,GAAA;QACP,OAAO,IAAI,CAAC,MAAM;;;;IAKpB,IAAI,KAAK,CAAC,KAAU,EAAA;AAClB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;;;AAQ5B,IAAA,WAAA,CAAsB,cAAiC,EAAA;QAAjC,IAAc,CAAA,cAAA,GAAd,cAAc;;QA/C3B,IAAe,CAAA,eAAA,GAAG,EAAE;;QAa7B,IAAS,CAAA,SAAA,GAAG,KAAK;;QAWjB,IAAS,CAAA,SAAA,GAAY,KAAK;;QAGnB,IAAE,CAAA,EAAA,GAAG,EAAE;;;QAiBd,IAAM,CAAA,MAAA,GAAQ,IAAI;;AA+BX,QAAA,IAAA,CAAA,SAAS,GAAG,MAAY,SAAS;;;AASjC,QAAA,IAAA,CAAA,QAAQ,GAAG,CAAC,CAAM,KAAI,GAAG;;;;AAjChC,IAAA,UAAU,CAAC,KAAU,EAAA;AACnB,QAAA,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;AAC3B,QAAA,IAAI,CAAC,cAAc,CAAC,YAAY,EAAE;;;;IAK1B,QAAQ,CAAC,KAAU,EAAE,SAAkB,EAAA;AAC/C,QAAA,IAA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