headless

API accordion

AccordionApi

interface

Interface representing the API for an accordion component.

Methods
collapse

collapse(itemId): Promise<void>

Given the itemId, will collapse the corresponding accordion-item.

If the itemId is not valid, nothing will happen.

Parameters
itemId

string

Returns

Promise<void>

A promise that resolves when the collapse operation is completed.


collapseAll

collapseAll(): Promise<void>

It will collapse all the accordion-items in the accordion.

Returns

Promise<void>

A promise that resolves when all the collapse operations are completed.


expand

expand(itemId): Promise<void>

Given the itemId, will expand the corresponding accordion-item.

If the itemId is not valid, nothing will happen.

Parameters
itemId

string

Returns

Promise<void>

A promise that resolves when the expand operation is completed.


expandAll

expandAll(): Promise<void>

It will expand all the items in the accordion.

If closeOthers is true it will expand only the last accordion-item.

Returns

Promise<void>

A promise that resolves when all the expand operations are completed.


registerItem

registerItem(itemConfig?): AccordionItemWidget

Creates a new accordionItem.

Parameters
itemConfig?

PropsConfig<AccordionItemProps>

Returns

AccordionItemWidget


toggle

toggle(itemId): Promise<void>

Given the itemId, will toggle the corresponding accordion-item.

Parameters
itemId

string

Returns

Promise<void>

A promise that resolves when the toggle operation is completed. If the itemId is not valid, nothing will happen.


AccordionDirectives

interface

Interface representing the directives used in the Accordion component.

Properties
accordionDirective

accordionDirective: Directive

Directive to put on the accordion DOM element


AccordionItemApi

interface

Interface representing the API for an accordion item.

Methods
collapse

collapse(): Promise<void>

It will collapse the accordion-item.

Returns

Promise<void>

A promise that resolves when the collapse operation is completed.


expand

expand(): Promise<void>

It will expand the accordion-item.

Returns

Promise<void>

A promise that resolves when the expand operation is completed.


initDone

initDone(): void

Method to be called after the initialization to allow animations.

Returns

void


toggle

toggle(): Promise<void>

It will toggle the accordion-item.

Returns

Promise<void>

A promise that resolves when the toggle operation is completed.


AccordionItemDirectives

interface

Interface representing the directives used in an accordion item.

Properties
bodyContainerAttrsDirective

bodyContainerAttrsDirective: Directive

Directive to apply aria attributes to the expanded body panel


bodyContainerDirective

bodyContainerDirective: Directive

Directive to be put on the accordion-item body container. It will handle the animation.


bodyDirective

bodyDirective: Directive

Directive to put on the accordion-item body.


buttonDirective

buttonDirective: Directive

Directive to put on the button element that will control the collapsing of the accordion-item.


headerDirective

headerDirective: Directive

Directive to put on the accordion-item header that will contain the button element.


itemDirective

itemDirective: Directive

Directive to be put on the accordion-item. It will handle adding the accordion-item to the accordion.


toggleDirective

toggleDirective: Directive

Directive to use in special cases, if the accordion header does not use a button element to control the collapsing.


transitionDirective

transitionDirective: Directive

Directive to apply the itemTransition


AccordionItemProps

interface

Properties for an AccordionItem component.

Properties
animated

animated: boolean

If true, accordion-item will be animated.


bodyClassName

bodyClassName: string

CSS classes to add on the accordion-item body DOM element.


bodyContainerClassName

bodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.


buttonClassName

buttonClassName: string

CSS classes to add on the accordion-item collapse DOM element.


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


destroyOnHide

destroyOnHide: boolean

If true, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.


disabled

disabled: boolean

If true, the accordion-item will be disabled. It will not react to user's clicks, but still will be possible to toggle programmatically.


headerClassName

headerClassName: string

CSS classes to add on the accordion-item header DOM element.


headingLevel

headingLevel: 1 | 2 | 3 | 4 | 5 | 6

The html heading level to use for the accordion-item-header.


id

id: string

The id of the accordion-item. It can be used for controlling the accordion-item via the accordion api.


onHidden

onHidden: () => void

An event fired when an item is hidden.

Returns

void


onShown

onShown: () => void

An event fired when an item is shown.

Returns

void


onVisibleChange

onVisibleChange: (visible) => void

An event fired when the visible value changes.

Event payload is the new value of visible.

Parameters
visible

boolean

Returns

void


transition

transition: TransitionFn

The transition to use for the accordion-item body-container when the accordion-item is toggled.


visible

visible: boolean

If true, the accordion-item will be visible (expanded). Otherwise, it will be hidden (collapsed).


AccordionItemState

interface

Represents the state of an accordion item.

Properties
bodyClassName

bodyClassName: string

CSS classes to add on the accordion-item body DOM element.


bodyContainerClassName

bodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.


buttonClassName

buttonClassName: string

CSS classes to add on the accordion-item collapse DOM element.


className

className: string

CSS classes to be applied on the widget main container

Default Value

''


disabled

disabled: boolean

If true, the accordion-item will be disabled. It will not react to user's clicks, but still will be possible to toggle programmatically.


headerClassName

headerClassName: string

CSS classes to add on the accordion-item header DOM element.


headingLevel

headingLevel: 1 | 2 | 3 | 4 | 5 | 6

The html heading level to use for the accordion-item-header.


id

id: string

The id of the accordion-item. It can be used for controlling the accordion-item via the accordion api.


shouldBeInDOM

shouldBeInDOM: boolean

If true the content of the accordion-item collapse should be in DOM. Its value depends on the value of the visible and destroyOnHide.


visible

visible: boolean

If true, the accordion-item will be visible (expanded). Otherwise, it will be hidden (collapsed).


AccordionItemWidget

type alias

AccordionItemWidget = Widget<AccordionItemProps, AccordionItemState, AccordionItemApi, AccordionItemDirectives>

Represents a widget for an accordion item.


AccordionProps

interface

Properties for the Accordion component.

Properties
className

className: string

CSS classes to be applied on the widget main container

Default Value

''


closeOthers

closeOthers: boolean

If true, only one accordion-item at the time can stay open.

Default Value

false


itemAnimated

itemAnimated: boolean

If true, accordion-item will be animated.

Default Value

true


itemBodyClassName

itemBodyClassName: string

CSS classes to add on the accordion-item body DOM element.

Default Value

''


itemBodyContainerClassName

itemBodyContainerClassName: string

CSS classes to add on the accordion-item body container DOM element. The accordion-item body container is the DOM element on what the itemTransition is applied.

Default Value

''


itemButtonClassName

itemButtonClassName: string

CSS classes to add on the accordion-item toggle button DOM element.

Default Value

''


itemClassName

itemClassName: string

CSS classes to add on the accordion-item DOM element.

Default Value

''


itemDestroyOnHide

itemDestroyOnHide: boolean

If true, the accordion-item body container will be removed from the DOM when the accordion-item is collapsed. It will be just hidden otherwise.

Default Value

true


itemHeaderClassName

itemHeaderClassName: string

CSS classes to add on the accordion-item header DOM element.

Default Value

''


itemHeadingLevel

itemHeadingLevel: 1 | 2 | 3 | 4 | 5 | 6

The html heading level to use for the accordion-item-header.

Default Value

2


itemTransition

itemTransition: TransitionFn

The transition to use for the accordion-item body-container when the accordion-item is toggled.

Default Value
() => {}

onItemHidden

onItemHidden: (itemId) => void

An event fired when an item is hidden.

Event payload is the id of the item.

Parameters
itemId

string

Returns

void

Default Value
() => {}

onItemShown

onItemShown: (itemId) => void

An event fired when an item is shown.

Event payload is the id of the item.

Parameters
itemId

string

Returns

void

Default Value
() => {}

AccordionState

interface

Represents the state of an Accordion component.

Properties
className

className: string

CSS classes to be applied on the widget main container

Default Value

''


itemWidgets

itemWidgets: AccordionItemWidget[]

Array containing all the accordion-items contained in the accordion.


AccordionWidget

type alias

AccordionWidget = Widget<AccordionProps, AccordionState, AccordionApi, AccordionDirectives>

Represents an Accordion widget with specific properties, state, API, and directives.


createAccordion

constant

const createAccordion: WidgetFactory<AccordionWidget>

Creates a new Accordion widget instance.

Param

config

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

Returns

a new accordion widget instance


createAccordionItem

function

createAccordionItem(config?): AccordionItemWidget

Creates a new AccordionItem widget instance.

Parameters
config?

PropsConfig<AccordionItemProps>

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

Returns

AccordionItemWidget

a new accordion item widget instance


factoryCreateAccordion

function

factoryCreateAccordion(itemFactory?, accordionItemProps?, accordionConfig?, accordionValidator?): WidgetFactory<AccordionWidget>

Create an accordion WidgetFactory based on an item factory and the list of item props that should inherit from the parent accordion

Parameters
itemFactory?

WidgetFactory<AccordionItemWidget> = createAccordionItem

the item factory

accordionItemProps?

string[] = coreAccordionItemProps

the list of item props

accordionConfig?

AccordionProps = defaultAccordionConfig

the default accordion config

accordionValidator?

ConfigValidator<AccordionProps> = configAccordionValidator

the validator of props

Returns

WidgetFactory<AccordionWidget>

the accordion widget factory


getAccordionDefaultConfig

function

getAccordionDefaultConfig(): AccordionProps

Retrieve a shallow copy of the default accordion config

Returns

AccordionProps

the default accordion config