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 | 1x 133x 524x 133x | /**
* Copyright (c) Siemens 2016 - 2026
* SPDX-License-Identifier: MIT
*/
import { computed, Directive, input } from '@angular/core';
import { SelectItem } from '../si-select.types';
import { SI_SELECT_OPTIONS_STRATEGY } from './si-select-options-strategy';
import { SiSelectOptionsStrategyBase } from './si-select-options-strategy.base';
/**
* This directive allows passing {@link SelectItem} to the {@link SiSelectComponent}.
*
* @example
* ```html
* <si-select [options]="[{ type: 'option', value: 'one', label: 'One' }, { type: 'option', value: 'two', label: 'Two' }]"></si-select>
* <si-select [options]="[{ type: 'group', label: 'Group', options [{ type: 'option', value: 1, label: 'One' }, { type: 'option', value: 2, label: 'Two' }] }]"></si-select>
* ```
*/
@Directive({
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'si-select[options]',
providers: [{ provide: SI_SELECT_OPTIONS_STRATEGY, useExisting: SiSelectSimpleOptionsDirective }]
})
export class SiSelectSimpleOptionsDirective<T = string> extends SiSelectOptionsStrategyBase<T> {
/** Options to be shown in select dropdown */
readonly options = input<SelectItem<T>[] | null>();
/**
* By default, values are check on referential equality. Provide a function to customize the behavior.
*
* @defaultValue
* ```
* (a: T, b: T): boolean => a === b
* ```
*/
override readonly optionsEqual = input((a: T, b: T): boolean => a === b, {
// eslint-disable-next-line @angular-eslint/no-input-rename
alias: 'optionEqualCheckFn'
});
override readonly allRows = computed(() => this.options() ?? []);
}
|