headless

API widget

callWidgetFactoryWithConfig

function

callWidgetFactoryWithConfig<W>(factory, options?): WidgetSlotContext<W>

Call a widget factory using provided configs.

Type Parameters
W

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

Parameters
factory

WidgetFactory<W>

the widget factory to call

options?

the optional options

defaultConfig?

Partial<WidgetProps<W>> | ReadableSignal<undefined | Partial<WidgetProps<W>>>

the default config of the widget

events?

Partial<Pick<WidgetProps<W>, keyof WidgetProps<W> & on${string}Change >>

the events of the widget

props?

Partial<WidgetProps<W>>

the props of the widget

widgetConfig?

null | ReadableSignal<undefined | Partial<WidgetProps<W>>>

the config of the widget, overriding the defaultConfig

Returns

WidgetSlotContext<W>

the state, api and directives to track and interact with the widget


createWidgetFactory

function

createWidgetFactory<W, T>(widgetName, factory): WidgetFactory<W, T>

Define a widget factory that can be linked with configuration through the provided widget name.

Type Parameters
W

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

The type of the widget

T

T extends (config?) => W = (config?) => W

The type of the widget factory function. Useful when the widget factory has a generic.

Parameters
widgetName

string

the widget name, used for configuration injection

factory

T

the widget factory function

Returns

WidgetFactory<W, T>

the widget factory