All files / lib/ext-search/ext-search-combobox ext-search-combobox.component.ts

100% Statements 115/115
100% Branches 10/10
100% Functions 6/6
100% Lines 115/115

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 1161x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 3x 3x 1x 1x 1x 15x 15x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import {
  Converter,
  FocusableElementOwner,
  InvalidControlValue,
  Item,
  Nullable,
  WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import { ComboBoxComponent } from '../../combobox/combobox.component';
import { BaseExtSearchComponent } from '../base-ext-search/base-ext-search-field.component';
import { BaseExtSearchSingleFieldComponent } from '../base-ext-search/base-ext-search-single-field.component';
 
@Component({
  selector: 'gc-ext-search-combobox',
  templateUrl: './ext-search-combobox.component.html',
  styleUrls: ['ext-search-combobox.component.css'],
  providers: [
    {
      provide: BaseExtSearchComponent,
      useExisting: ExtSearchComboboxComponent,
    },
  ],
})
export class ExtSearchComboboxComponent<T>
  extends BaseExtSearchSingleFieldComponent
  implements FocusableElementOwner
{
  /**
   * Items to display in the picker.
   */
  @Input()
  public items?: (searchVal: string) => Promise<readonly T[]>;
 
  /**
   * Selected item.
   */
  @Input()
  public value: Nullable<T | InvalidControlValue> = null;
 
  /**
   * Adapts the domain type T to the internal Item structure.
   */
  @Input()
  public itemAdapter: Converter<T, Item> | undefined = undefined;
 
  /**
   * Marks the input field as required.
   */
  @Input()
  public required = false;
 
  /**
   * Fires on a input slot value change.
   */
  @Output()
  public readonly valueChange: EventEmitter<Nullable<T | InvalidControlValue>> =
    new EventEmitter<Nullable<T | InvalidControlValue>>();
 
  /** @ignore */
  @ViewChild('comboBoxField')
  protected comboBoxField?: ComboBoxComponent<T>;
 
  /**
   * Overrides focus border visibility.
   */
  protected hideFocusBorder = false;
 
  /**
   * Helps with resizing the input field.
   * @ignore
   */
  protected _sizeHelperText = '';
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-combobox',
  );
 
  public override focusChild(): boolean {
    if (this.comboBoxField) {
      return this.comboBoxField.focusChild();
    }
    return false;
  }
 
  /** @ignore */
  protected handleValueChange(): void {
    this.valueChange.emit(this.value);
  }
 
  /** @ignore */
  protected handleFocusBorderVisibility(hideFocusBorder: boolean) {
    this.hideFocusBorder = hideFocusBorder;
  }
 
  /** @ignore */
  protected handleInput(value: string): void {
    this._sizeHelperText = value;
  }
}