Bootstrap

API extendWidget

ExtendWidgetAdaptSlotContentProps

type alias

ExtendWidgetAdaptSlotContentProps<Props, ExtraProps, ExtraDirectives>: Props extends WidgetSlotContext<infer U> ? WidgetSlotContext<ExtendWidgetProps<U, ExtraProps, ExtraDirectives>> & Omit<Props, keyof WidgetSlotContext<any>> : Props

Type to adapt the slot content properties of a widget by extending its props, extra props, and extra directives.

Type Parameters

Props extends Record<string, any>

The original properties of the widget slot context.

ExtraProps extends object

Additional properties to extend the widget slot context.

ExtraDirectives extends object

Additional directives to extend the widget slot context.

Remarks

This type conditionally checks if Props extends WidgetSlotContext and, if so, extends the widget slot context with additional properties and directives while omitting the original widget slot context properties.


ExtendWidgetAdaptSlotWidgetProps

type alias

ExtendWidgetAdaptSlotWidgetProps<Props, ExtraProps, ExtraDirectives>: ExtraProps & { [K in keyof Props]: IsSlotContent<Props[K]> extends SlotContent<infer U> ? SlotContent<ExtendWidgetAdaptSlotContentProps<U, ExtraProps, ExtraDirectives>> : Props[K] }

Type definition for extending widget properties with additional properties and directives.

This type takes three generic parameters:

  • Props: The original properties of the widget.
  • ExtraProps: Additional properties to be merged with the original properties.
  • ExtraDirectives: Additional directives to be merged with the original properties.

The resulting type combines ExtraProps with the original Props. For each property in Props, if the property is of type SlotContent, it will be extended with the additional properties and directives.

Type Parameters

Props

The original properties of the widget.

ExtraProps extends object

Additional properties to be merged with the original properties.

ExtraDirectives extends object

Additional directives to be merged with the original properties.


ExtendWidgetInterfaces

type alias

ExtendWidgetInterfaces<Interfaces, ExtraInterfaces>: Interfaces & ExtraInterfaces

Combines two interface types into a single type.

Type Parameters

Interfaces

The base interface type.

ExtraInterfaces

The additional interface type to extend the base interface.


extendWidgetProps

function

extendWidgetProps<W, ExtraProps, ExtraDirectives>(factory, extraPropsDefaults, extraPropsConfig?, overrideDefaults?): WidgetFactory<ExtendWidgetProps<W, ExtraProps, ExtraDirectives>>

Method to extend the original widget with extra props with validator

Type Parameters

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

The type of the widget.

ExtraProps extends object

The type of the additional properties.

ExtraDirectives extends object = object

The type of the additional directives (default is an empty object).

Parameters

factory: WidgetFactory<W>

original widget factory

extraPropsDefaults: ExtraProps

object containing default value for each extra prop

extraPropsConfig?: ConfigValidator<ExtraProps>

object verifying the type of each extra prop

overrideDefaults?: Partial<WidgetState<W>>

object overriding some default props of the widget to extend

Returns

WidgetFactory<ExtendWidgetProps<W, ExtraProps, ExtraDirectives>>

widget factory with the extra props


ExtendWidgetProps

type alias

ExtendWidgetProps<W, ExtraProps, ExtraDirectives>: Widget<ExtendWidgetAdaptSlotWidgetProps<WidgetProps<W>, ExtraProps, ExtraDirectives>, ExtendWidgetAdaptSlotWidgetProps<WidgetState<W>, ExtraProps, ExtraDirectives>, W["api"], ExtendWidgetInterfaces<W["directives"], ExtraDirectives>>

Type extending the original Widget props and state with ExtraProps

Type Parameters

W extends Widget

The base widget type to be extended.

ExtraProps extends object

Additional properties to be added to the widget.

ExtraDirectives extends object = object

Additional directives to be added to the widget. Defaults to an empty object.