Bootstrap

API types

AttributeValue

type alias

AttributeValue: string | number | boolean | undefined

Represents a value that can be assigned to an attribute.


ConfigValidator

type alias

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

Represents a type that validates a configuration object.

Type Parameters

T extends object

The type of the configuration object to be validated.

This type maps each key of the configuration object T to an optional WritableWithDefaultOptions type, allowing for partial validation.


Directive

type alias

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

Represents a directive function that can be applied to an SSRHTMLElement.

Type Parameters

T = void

The type of the arguments passed to the directive.

U extends SSRHTMLElement = SSRHTMLElement

The type of the SSRHTMLElement, defaults to SSRHTMLElement.

Parameters

node: U

The SSRHTMLElement to which the directive is applied.

args: T

The arguments passed to the directive.

Returns

void | object

An optional object that may contain:

  • update: A function to update the directive with new arguments.
  • destroy: A function to clean up when the directive is no longer needed.

DirectiveAndParam

type alias

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

Represents a tuple containing a directive and its associated parameter.

Type Parameters

T

The type of the parameter associated with the directive.

U extends SSRHTMLElement = SSRHTMLElement

The type of the SSRHTMLElement, defaults to SSRHTMLElement.


DirectivesAndOptParam

type alias

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

Represents a mapping of directives and their optional parameters.

Type Parameters

T extends any[]

An array type representing the parameters for the directives.

U extends SSRHTMLElement = SSRHTMLElement

The type of the SSR HTML element, defaults to SSRHTMLElement.


Extends

type alias

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

A conditional type that checks if type T extends type U.

Type Parameters

T

The type to check.

U

The type to check against.

Returns

1 if T extends U, otherwise 0.


INVALID_VALUE

constant

const INVALID_VALUE: unique symbol

A unique symbol representing an invalid value. This can be used as a sentinel value to indicate that a variable or property does not hold a valid value.


IsSlotContent

type alias

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

Type utility to determine if a given type T is or extends SlotContent<any>.

This utility uses conditional types to check if T extends SlotContent<any> or if SlotContent<any> extends T. If either condition is true, it returns T, otherwise it returns 0.

Type Parameters

T

The type to be checked.

Returns

T if T is or extends SlotContent<any>, otherwise 0.


NormalizeValue

type alias

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

A type alias for a function that normalizes a value of type T. The function takes a value of type T and returns either a normalized value of type T or a special constant INVALID_VALUE indicating that the value is invalid.

Type Parameters

T

The type of the value to be normalized.

Parameters

value: T

The value to be normalized.

Returns

T | typeof INVALID_VALUE

The normalized value of type T or INVALID_VALUE if the value is invalid.


PropsConfig

interface

Interface representing the configuration for properties.

Type Parameters

U extends object

An object type representing the properties.

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>: string | Snippet<[Props]>

Represents the content of a slot, which can either be a string or a Snippet.

Type Parameters

Props extends object = object

The type of the properties that the Snippet can accept.

See

https://svelte.dev/docs/svelte/snippet


SSRHTMLElement

interface

Represents a server-side rendered HTML element with limited functionality.

This interface extends a subset of the HTMLElement interface, providing methods to set and remove attributes, manipulate the element's classes, and partially manipulate the element's style.

It inherits the setAttribute and getAttribute methods from the HTMLElement interface.

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.


StyleKey

type alias

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

Represents a key of the CSSStyleDeclaration interface, excluding certain properties and methods.

This is useful for scenarios where you need to work with CSS properties directly without dealing with the methods and other non-style properties of CSSStyleDeclaration.


StyleValue

type alias

StyleValue: string | undefined | null

Represents a value that can be used for styling purposes.

Remarks

This type can be a string representing a style value, or it can be undefined or null. It is useful for scenarios where a style value might be optional or not set.


ValuesOrReadableSignals

type alias

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

A type that maps each property of an object type T to either a ReadableSignal of that property type or the property type itself.

Type Parameters

T extends object

The object type whose properties are being mapped.


ValuesOrWritableSignals

type alias

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

A type that maps the properties of an object type T to either a WritableSignal of the property type or the property type itself.

Type Parameters

T extends object

The object type whose properties are being mapped.


Widget

interface

Represents a generic widget with reactive state, stores, and various functionalities.

Template

The type of the action handlers for user interactions.

Type Parameters

Props extends object = object

The type of the properties that can be passed to the widget.

State extends object = object

The type of the state managed by the widget.

Api extends object = object

The type of the API functions available for interacting with the widget.

Directives extends object = object

The type of the directives used in the widget's template.

Properties
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

A factory function type for creating instances of a widget.

Type Parameters

W extends Widget

The type of the widget that extends the base Widget type.

Parameters

props?: PropsConfig<WidgetProps<W>>

Optional configuration properties for the widget.

Returns

W

An instance of the widget.


WidgetProps

type alias

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

Extracts the type of the argument expected by the patch method of a given type T.

This utility type takes a generic type T which must have a patch method. The patch method should accept an argument that is a partial of some object type U. If T meets this condition, WidgetProps will resolve to the type U. Otherwise, it will resolve to never.

Type Parameters

T extends object

A type that includes a patch method accepting a partial object.


WidgetSlotContext

interface

Represents the context for a widget slot, providing access to the widget and its state.

Extended by
Type Parameters

W extends Widget

The type of the widget.

Properties
api

api: W["api"]

all the api functions to interact with the widget


directives

directives: W["directives"]

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


state

state: WidgetState<W>

the state of the widget


WidgetState

type alias

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

Extracts the state type from a widget type that contains a state$ property.

Type Parameters

T extends object

A type that extends an object with a state$ property of type SubscribableStore<any>.

Returns

The type of the state contained within the state$ property if it extends an object, otherwise never.


WritableWithDefaultOptions

interface

Interface representing options for a writable store with default values.

Type Parameters

T

The type of the value stored.

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 INVALID_VALUE symbol when the provided value is invalid