# SelectOptionSource Type documentation

## TypeScript declaration

### [SelectOptionSource](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L15-L56>)

**Kind:** interface

```
import type { SelectOptionSource } from '@siemens/element-ng/select';
```

An interface to define a lazy option source for the [SiSelectComponent](<../../components/SiSelectComponent/index.html#SiSelectComponent>).

```
interface SelectOptionSource<TValue>
```

#### Methods

##### compareOptions

[Source for compareOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L47-L47>)

**Modifiers:** optional

This function is used to sort options.

It is only called if the si-select was able to find all options without querying the option source.

```
compareOptions(a: SelectOption<TValue>, b: SelectOption<TValue>): number
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [a](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L47-L47>) | `SelectOption<TValue>` |  |  |
| [b](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L47-L47>) | `SelectOption<TValue>` |  |  |

**Returns:** [number](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number>)

##### getAllOptions

[Source for getAllOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L31-L31>)

**Modifiers:** optional

Get all available options. If provided, this will be called when no filter value is provided. Otherwise, si-select will only show the selected values.

This function must be implemented if this source is used on a select without a filter.

```
getAllOptions(): Observable<SelectItem<TValue>[]>
```

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[SelectItem](<index.html#t:SelectItem>)`<TValue>[]>`

##### getOptionsForSearch

[Source for getOptionsForSearch](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L40-L40>)

**Modifiers:** optional

Find options for a search value. It will never be called with an empty search value.

This function must be implemented if this source is used on a si-select with a filter.

```
getOptionsForSearch(search: string): Observable<SelectItem<TValue>[]>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [search](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L40-L40>) | `string` |  | • value typed by the user in the search field. |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[SelectItem](<index.html#t:SelectItem>)`<TValue>[]>`

##### getOptionsForValues

[Source for getOptionsForValues](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L22-L22>)

Get options for the provided values. This is basically a resolver function, that resolves values to options.

```
getOptionsForValues(values: TValue[]): Observable<SelectOption<TValue>[]>
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [values](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L22-L22>) | `TValue[]` |  | • values that should be resolved to an option. |

**Returns:** [Observable](<https://rxjs.dev/api/index/class/Observable>)`<`[SelectOption](<index.html#t:SelectOption>)`<TValue>[]>`

##### valuesEqual

[Source for valuesEqual](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L55-L55>)

**Modifiers:** optional

Function to check if two values are equal.

This function must be implemented if the check on reference equality is not enough. For instance, when using objects as value.

```
valuesEqual(optionA: TValue, optionB: TValue): boolean
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [optionA](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L55-L55>) | `TValue` |  |  |
| [optionB](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-option.source.ts#L55-L55>) | `TValue` |  |  |

**Returns:** [boolean](<https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean>)

### Types Documentation

### [SelectItem](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L54-L54>)

**Kind:** type alias

```
import type { SelectItem } from '@siemens/element-ng/select';
```

Alias for [SelectOption](<index.html#t:SelectOption>) or [SelectGroup](<index.html#t:SelectGroup>)

```
type SelectItem<T> = SelectGroup<T> | SelectOption<T>
```

### [SelectOption](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L21-L51>)

**Kind:** interface

```
import type { SelectOption } from '@siemens/element-ng/select';
```

A select option

```
interface SelectOption<T>
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L32-L32>) (optional) | `boolean` | Whether this option is disabled. |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L34-L34>) (optional) | `string` | An optional icon. |
| [iconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L36-L36>) (optional) | `string` | The color of an icon. |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L45-L45>) (optional) | `TranslatableString` | A label to be shown for this option. Is optional if a custom template is provided or if the value should directly be rendered. |
| [stackedIcon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L38-L38>) (optional) | `string` | An optional stacked icon. |
| [stackedIconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L40-L40>) (optional) | `string` | The color of a stacked icon. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L23-L23>) | `"option"` | Defines this to be an option. |
| [typeaheadLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L50-L50>) (optional) | `TranslatableString` | Used for typeahead functionality when filtering is disabled. If provided, this will be used, otherwise the innerText of the rendered element. |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L30-L30>) | `T` | The value if this option. It will be used for formControls and the value property of this `si-select`. The value will internally be checked on equality by using `===`. So an app should either use `string` or ensure that same values are referentially equal. |

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```

### [SelectGroup](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L8-L18>)

**Kind:** interface

```
import type { SelectGroup } from '@siemens/element-ng/select';
```

A select option group

```
interface SelectGroup<T>
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [key](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L12-L12>) (optional) | `string` | An optional key to identify this group in a custom template. |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L14-L14>) (optional) | `TranslatableString` | A label to be shown as header for this group. Is optional if a custom template is provided. |
| [options](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L17-L17>) | `SelectOption<T>[]` | All options that are part of this group. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L10-L10>) | `"group"` | Defines this to be a group. |
