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

98.29% Statements 115/117
90.9% Branches 10/11
100% Functions 6/6
98.29% Lines 115/117

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 116 117 1181x 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 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 9x 1x 1x 1x 1x 1x     1x 1x 1x 1x 2x 2x 1x 1x 1x 6x 6x 1x 1x 1x 19x 19x 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,
  ItemLoadResult,
  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,
    },
  ],
  standalone: false,
})
export class ExtSearchComboboxComponent<T>
  extends BaseExtSearchSingleFieldComponent
  implements FocusableElementOwner
{
  /**
   * Items to display in the picker.
   */
  @Input()
  public items?: (searchVal: string) => Promise<ItemLoadResult<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;
  }
}