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 | 1x 15x 9x 22x | /**
* Copyright (c) Siemens 2016 - 2025
* SPDX-License-Identifier: MIT
*/
import { Directive } from '@angular/core';
import { NG_VALUE_ACCESSOR } from '@angular/forms';
import { SiSelectSelectionStrategy } from './si-select-selection-strategy';
/**
* The directive enables the multi-select behavior.
* Otherwise, use the {@link SiSelectSingleValueDirective} directive.
*
* @example
* ```html
* <si-select multi [(value)]="multiValue" [options]="[
* { id: 'good', title: 'Good' },
* { id: 'average', title: 'Average' },
* { id: 'poor', title: 'Poor' }
* ]"></si-select>
* ```
*/
@Directive({
// eslint-disable-next-line @angular-eslint/directive-selector
selector: 'si-select[multi]',
providers: [
{ provide: SiSelectSelectionStrategy, useExisting: SiSelectMultiValueDirective },
{
provide: NG_VALUE_ACCESSOR,
useExisting: SiSelectMultiValueDirective,
multi: true
}
]
})
export class SiSelectMultiValueDirective<T> extends SiSelectSelectionStrategy<T, T[]> {
/**
* {@inheritDoc SiSelectSelectionStrategy#allowMultiple}
* @defaultValue true
*/
override readonly allowMultiple = true;
protected fromArrayValue(value: T[]): T[] {
return value;
}
protected toArrayValue(value: T[] | undefined): T[] {
return value ?? [];
}
}
|