headless

API select

createSelect

function

createSelect<Item>(config?): SelectWidget<Item>

Create a SelectWidget with given config props

Type Parameters

Item

Parameters

config?: PropsConfig<SelectProps<Item>>

an optional alert config

Returns

SelectWidget<Item>

a SelectWidget


getSelectDefaultConfig

function

getSelectDefaultConfig(): SelectProps<any>

Returns a shallow copy of the default select config.

Returns

SelectProps<any>

a copy of the default config


ItemContext

interface

Item representation built from the items provided in parameters

Type Parameters

T

Properties
id

id: string

Unique id to identify the item


item

item: T

Original item given in the parameters


selected

selected: boolean

Specify if the item is checked


SelectApi

interface

Interface representing the API for a Select component.

Type Parameters

Item

Methods
clear

clear(): void

Clear all the selected items

Returns

void


clearText

clearText(): void

Clear the filter text

Returns

void


close

close(): void

close the select

Returns

void


highlight

highlight(item): void

Highlight the given item, if there is a corresponding match among the visible list

Parameters

item: Item

Returns

void


highlightFirst

highlightFirst(): void

Highlight the first item among the visible list

Returns

void


highlightLast

highlightLast(): void

Highlight the last item among the visible list

Returns

void


highlightNext

highlightNext(): void

Highlight the next item among the visible list. Loop to the first item if needed

Returns

void


highlightPrevious

highlightPrevious(): void

Highlight the previous item among the visible list Loop to the last item if needed

Returns

void


open

open(): void

open the select

Returns

void


select

select(item): void

Select the provided item. The selected list is used to

Parameters

item: Item

the item to select

Returns

void


toggle

toggle(isOpen?): void

Toggle the dropdown menu

Parameters

isOpen?: boolean

If specified, set the menu in the defined state.

Returns

void


toggleItem

toggleItem(item, selected?): void

Toggle the selection of an item

Parameters

item: Item

the item to toggle

selected?: boolean

an optional boolean to enforce the selected/unselected state instead of toggling

Returns

void


unselect

unselect(item): void

Unselect the provided item.

Parameters

item: Item

the item to unselect

Returns

void


SelectDirectives

interface

Interface representing the directives used in the Select component.

Type Parameters

Item

Properties
badgeAttributesDirective

badgeAttributesDirective: Directive<ItemContext<Item>>

A directive that applies all the necessary attributes to the container badges


badgeCloseButtonDirective

badgeCloseButtonDirective: Directive<ItemContext<Item>>

A directive to be applied to a button that closes a badge


floatingDirective

floatingDirective: Directive<void, SSRHTMLElement>

Directive that enables dynamic positioning of menu element


hasFocusDirective

hasFocusDirective: Directive

Directive to be used in the input group and the menu containers


inputContainerDirective

inputContainerDirective: Directive

A directive to be applied to the element that contains the badges and the input


inputDirective

inputDirective: Directive

A directive to be applied to the input


itemAttributesDirective

itemAttributesDirective: Directive<ItemContext<Item>>

A directive that applies all the necessary attributes to the dropdown item


menuAttributesDirective

menuAttributesDirective: Directive

A directive that applies all the necessary attributes to the dropdown menu


referenceDirective

referenceDirective: Directive<void, SSRHTMLElement>

A directive to be applied to the input group element serves as the base for menu positioning


SelectProps

interface

Props for the Select component.

Type Parameters

Item

Properties
allowedPlacements

allowedPlacements: Placement[]

List of allowed placements for the dropdown. This refers to the allowedPlacements from floating UI, given the different Placement possibilities.

Default Value
['bottom-start', 'top-start', 'bottom-end', 'top-end']

ariaLabel

ariaLabel: undefined | string

aria-label used for the input inside the select

Default Value

'Select'


badgeClassName

badgeClassName: string

Class to be added on selected items (displayed in the input zone)

Default Value

''


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


disabled

disabled: boolean

true if the select is disabled

Default Value

false


filterText

filterText: string

Filtered text to be display in the filter input

Default Value

''


id

id: undefined | string

id used for the input inside the select


items

items: Item[]

List of available items for the dropdown

Default Value

[]


loading

loading: boolean

true if a loading process is being done

Default Value

false


menuClassName

menuClassName: string

Class to be added on the dropdown menu container

Default Value

''


menuItemClassName

menuItemClassName: string

Class to be added on menu items

Default Value

''


open

open: boolean

true if the select is open

Default Value

false


selected

selected: Item[]

List of selected item ids

Default Value

[]

Methods
itemIdFn

itemIdFn(item): string

Custom function to get the id of an item By default, the item is returned

Parameters

item: Item

Returns

string

Default Value
(item: any) => '' + item

navSelector

navSelector(node): NodeListOf<HTMLInputElement | HTMLSpanElement>

Retrieves navigable elements within an HTML element containing badges and the input.

Parameters

node: HTMLElement

HTMLElement that contains the badges and the input

Returns

NodeListOf<HTMLInputElement | HTMLSpanElement>

Default Value
(node: HTMLElement) => node.querySelectorAll('.au-select-badge,input')

onFilterTextChange

onFilterTextChange(text): void

Callback called when the text filter change

Parameters

text: string

Filtered text

Returns

void

Default Value
() => {}

onOpenChange

onOpenChange(isOpen): void

Callback called dropdown open state change

Parameters

isOpen: boolean

updated open state

Returns

void

Default Value
() => {}

onSelectedChange

onSelectedChange(selected): void

Callback called when the selection change

Parameters

selected: Item[]

Returns

void

Default Value
() => {}

SelectState

interface

Represents the state of a Select component.

Type Parameters

Item

Properties
ariaLabel

ariaLabel: undefined | string

aria-label used for the input inside the select

Default Value

'Select'


badgeClassName

badgeClassName: string

Class to be added on selected items (displayed in the input zone)

Default Value

''


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


disabled

disabled: boolean

true if the select is disabled

Default Value

false


filterText

filterText: string

Filtered text to be display in the filter input

Default Value

''


highlighted

highlighted: undefined | ItemContext<Item>

Highlighted item context. It is designed to define the highlighted item in the dropdown menu


id

id: undefined | string

id used for the input inside the select


loading

loading: boolean

true if a loading process is being done

Default Value

false


menuClassName

menuClassName: string

Class to be added on the dropdown menu container

Default Value

''


menuItemClassName

menuItemClassName: string

Class to be added on menu items

Default Value

''


open

open: boolean

true if the select is open

Default Value

false


placement

placement: undefined | Placement

Current placement of the dropdown


selected

selected: Item[]

List of selected item ids

Default Value

[]


selectedContexts

selectedContexts: ItemContext<Item>[]

List of selected items to be display


visibleItems

visibleItems: ItemContext<Item>[]

List of item contexts, to be displayed in the menu


SelectWidget

type alias

SelectWidget<Item>: Widget<SelectProps<Item>, SelectState<Item>, SelectApi<Item>, SelectDirectives<Item>>

Represents a Select widget component.

Type Parameters

Item