Bootstrap

API types

AttributeValue

type alias

AttributeValue: string | number | boolean | undefined


ConfigValidator

type alias

ConfigValidator<T>: { [K in keyof T]?: WritableWithDefaultOptions<T[K]> }

Type Parameters

T extends object


ContextWidget

type alias

ContextWidget<W>: Pick<W, "actions" | "api" | "directives" | "state$" | "stores">

Type Parameters

W extends Widget


Directive

type alias

Directive<T, U>: (node, args) => void | object

Type Parameters

T = void

U extends SSRHTMLElement = SSRHTMLElement

Parameters

node: U

args: T

Returns

void | object


DirectiveAndParam

type alias

DirectiveAndParam<T, U>: [Directive<T, U>, T]

Type Parameters

T

U extends SSRHTMLElement = SSRHTMLElement


DirectivesAndOptParam

type alias

DirectivesAndOptParam<T, U>: { [K in keyof T]: Directive<void, U> | DirectiveAndParam<T[K], U> }

Type Parameters

T extends any[]

U extends SSRHTMLElement = SSRHTMLElement


Extends

type alias

Extends<T, U>: T extends U ? 1 : 0

Type Parameters

T

U


INVALID_VALUE

constant

const INVALID_VALUE: typeof INVALID_VALUE


IsSlotContent

type alias

IsSlotContent<T>: Extends<T, SlotContent<any>> | Extends<SlotContent<any>, T> extends 1 ? T : 0

Type Parameters

T


NormalizeValue

type alias

NormalizeValue<T>: (value) => T | typeof INVALID_VALUE

Type Parameters

T

Parameters

value: T

Returns

T | typeof INVALID_VALUE


PropsConfig

interface
Type Parameters

U extends object

Properties
config?

optional config: ReadableSignal<Partial<U>> | ValuesOrReadableSignals<Partial<U>>

Either a store of objects containing, for each property, the default value, or an object containing, for each property, either a store containing the default value or the default value itself.


props?

optional props: ValuesOrWritableSignals<U>

Object containing, for each property, either its initial value, or a store that will contain the value at any time. When the value of a property is undefined or invalid, the value from the config is used.


SlotContent

type alias

SlotContent<Props>: CoreSlotContent<Props> | (props) => React.ReactNode | React.ComponentType<Props> | React.ReactNode

Type Parameters

Props extends object = object


SSRHTMLElement

interface

Subset of HTMLElement that is available in a server side rendering context.

Properties
classList

classList: Pick<DOMTokenList, "remove" | "add" | "toggle">

Object allowing to manipulate the classes of the element.


style

style: Partial<Record<StyleKey, StyleValue>>

Object allowing to manipulate the style of the element.

Methods
removeAttribute

removeAttribute(qualifiedName): void

Removes element's first attribute whose qualified name is qualifiedName.

MDN Reference

Parameters

qualifiedName: string

Returns

void


setAttribute

setAttribute(qualifiedName, value): void

Sets the value of element's first attribute whose qualified name is qualifiedName to value.

MDN Reference

Parameters

qualifiedName: string

value: string

Returns

void


StyleKey

type alias

StyleKey: Exclude<keyof CSSStyleDeclaration, "length" | "item" | "parentRule" | "getPropertyValue" | "getPropertyPriority" | "setProperty" | "removeProperty" | *typeof* Symbol.iterator | number | "cssText">


StyleValue

type alias

StyleValue: string | undefined | null


toSlotContextWidget

function

toSlotContextWidget<W>(w): ContextWidget<W>

Extract actions, api, directives, state and stores from the widget to be passed to slots as context.

Type Parameters

W extends Widget<object, object, object, object, object>

Parameters

w: W

the widget

Returns

ContextWidget<W>

the slot context


ValuesOrReadableSignals

type alias

ValuesOrReadableSignals<T>: { [K in keyof T]?: ReadableSignal<T[K] | undefined> | T[K] }

Type Parameters

T extends object


ValuesOrWritableSignals

type alias

ValuesOrWritableSignals<T>: { [K in keyof T]?: WritableSignal<T[K] | undefined> | T[K] }

Type Parameters

T extends object


Widget

interface
Type Parameters

Props extends object = object

State extends object = object

Api extends object = object

Actions extends object = object

Directives extends object = object

Properties
actions

actions: Actions

all the handlers that should be connected to user interactions i.e. click, keyboard and touch interactions. typically, the handlers are event listeners that call api functions to affect the widget state


api

api: Api

all the api functions to interact with the widget


directives

directives: Directives

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


state$

state$: ReadableSignal<State>

the reactive state of the widget, combining all the values served by the stores


stores

stores: { [K in string | number | symbol as `${K & string}$`]: ReadableSignal<State[K]> }

the different stores of the widget, all reactive

Methods
patch

patch(parameters): void

Modify the parameter values, and recalculate the stores accordingly

Parameters

parameters: Partial<Props>

Returns

void


WidgetFactory

type alias

WidgetFactory<W>: (props?) => W

Type Parameters

W extends Widget

Parameters

props?: PropsConfig<WidgetProps<W>>

Returns

W


WidgetProps

type alias

WidgetProps<T>: T extends object ? U : never

Type Parameters

T extends object


WidgetSlotContext

interface
Type Parameters

W extends Widget

Properties
state

state: WidgetState<W>

the state of the widget


widget

widget: ContextWidget<W>

the widget


WidgetState

type alias

WidgetState<T>: T extends object ? U : never

Type Parameters

T extends object


WritableWithDefaultOptions

interface
Type Parameters

T

Properties
equal()?

optional equal: (a, b) => boolean

the equal function, allowing to compare two values. used to check if a previous and current values are equals.

Parameters

a: T

b: T

Returns

boolean


normalizeValue?

optional normalizeValue: NormalizeValue<T>

the normalize value function. should return the invalidValue symbol when the provided value is invalid