createSelect

function

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

Creates a new select widget instance.

Type Parameters

Item

Parameters

config?: PropsConfig<SelectProps<Item>>

config of the modal, either as a store or as an object containing values or stores.

Returns

SelectWidget<Item>

a new select widget instance


getSelectDefaultConfig

function

getSelectDefaultConfig(): SelectProps<any>

Retrieve a shallow copy of the default Select config

Returns

SelectProps<any>

the default Select 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


Select

function

Select<Item>(props): Element

A generic Select component that provides a customizable dropdown selection interface.

Type Parameters

Item

The type of the items in the selection.

Parameters

props: Partial<SelectProps<Item>>

The properties for the Select component.

Returns

Element

The rendered Select component.

The rendered Select component.

Remarks

This component uses a widget context to manage its state and directives. It supports custom badge labels and item labels through the widget configuration.

Component

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


SelectContext

interface

Interface for the slot context of the pagination widget

Extended by
Type Parameters

Item

The type of the items in the Select component.

Properties
api

api: SelectApi<Item>

all the api functions to interact with the widget


directives

directives: SelectDirectives<Item>

directives to be used on html elements in the template of the widget or in the slots


state

state: SelectState<Item>

the state of the widget


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


SelectItemContext

interface

Represents the context for a select item, extending the base SelectContext with additional contextual data specific to an item.

Type Parameters

Item

The type of the item within the select context.

Properties
api

api: SelectApi<Item>

all the api functions to interact with the widget


directives

directives: SelectDirectives<Item>

directives to be used on html elements in the template of the widget or in the slots


itemContext

itemContext: ItemContext<Item>

Contextual data related to an item


state

state: SelectState<Item>

the state of the widget


SelectProps

interface

Represents the properties for the Select component.

Type Parameters

Item

The type of the items in the select component.

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

''


badgeLabel

badgeLabel: SlotContent<SelectItemContext<Item>>

The template to override the way each badge on the left of the input is displayed. This define the content of the badge inside the badge container.

Default Value
({itemContext}: SelectItemContext<any>) => itemContext.item

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


itemLabel

itemLabel: SlotContent<SelectItemContext<Item>>

The template to override the way each item is displayed in the list. This define the content of the badge inside the badge container.

Default Value
({itemContext}: SelectItemContext<any>) => itemContext.item

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

The type of the items in the select component.

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

''


badgeLabel

badgeLabel: SlotContent<SelectItemContext<Item>>

The template to override the way each badge on the left of the input is displayed. This define the content of the badge inside the badge container.

Default Value
({itemContext}: SelectItemContext<any>) => itemContext.item

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


itemLabel

itemLabel: SlotContent<SelectItemContext<Item>>

The template to override the way each item is displayed in the list. This define the content of the badge inside the badge container.

Default Value
({itemContext}: SelectItemContext<any>) => itemContext.item

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

The type of the items that the select widget will handle.