/*
 * Copyright © 2023 Robert Bosch GmbH Copyright © 2023 Robert Bosch Manufacturing Solutions GmbH, Germany. All rights reserved.
 */

import { BooleanInput, coerceBooleanProperty } from '@angular/cdk/coercion';
import { ChangeDetectionStrategy, Component, HostBinding, Input } from '@angular/core';

/**
 * Displays a labeled value with various options to format the display of the value. The value can either be provided
 * as is or using content projection.
 */
@Component({
  selector: 'bci-label-value-pair',
  templateUrl: './label-value-pair.component.html',
  styleUrls: ['./label-value-pair.component.scss'],
  changeDetection: ChangeDetectionStrategy.OnPush
})
export class LabelValuePairComponent {
  @Input({required: true})
  label: string;

  @Input({required: false})
  value: number | boolean | string;

  /** Whether to enable text wrapping. Disabled by default. */
  @Input({required: false})
  get wrap(): boolean {
    return this._wrap;
  }

  set wrap(value: BooleanInput) {
    this._wrap = coerceBooleanProperty(value);
  }

  /** Whether to align both label and value to the right. Disabled by default. */
  @Input({required: false})
  get rightAlign(): boolean {
    return this._rightAlign;
  }

  set rightAlign(value: BooleanInput) {
    this._rightAlign = coerceBooleanProperty(value);
  }

  /** Whether to align the value right to left. Disabled by default. */
  @Input({required: false})
  get rightToLeft(): boolean {
    return this._rightToLeft;
  }

  set rightToLeft(value: BooleanInput) {
    this._rightToLeft = coerceBooleanProperty(value);
  }

  /** Whether the label is bold. Enabled by default. */
  @Input({required: false})
  get boldLabel(): boolean {
    return this._boldLabel;
  }

  set boldLabel(value: BooleanInput) {
    this._boldLabel = coerceBooleanProperty(value);
  }


  /** Whether the value is bold. Disabled by default. */
  @Input({required: false})
  get boldValue(): boolean {
    return this._boldValue;
  }

  set boldValue(value: BooleanInput) {
    this._boldValue = coerceBooleanProperty(value);
  }


  @HostBinding('class.bci-label-value-pair') hostClass = true;

  private _wrap = false;

  private _rightAlign = false;

  private _rightToLeft = false;

  private _boldLabel = true;

  private _boldValue = false;
}
