createWidgetsConfig<
T
>(parent$
?,adaptParentConfig
?):WidgetsConfigStore
<T
>
Creates a new widgets default configuration store, optionally inheriting from a parent store, and containing its own set of widgets configuration properties that override the same properties form the parent configuration.
• T
• parent$?: WidgetsConfigStore
<T
>
optional parent widgets default configuration store.
• adaptParentConfig? = identity
optional function that receives a 2-levels copy of the widgets default configuration from parent$ (or an empty object if parent$ is not specified) and returns the widgets default configuration to be used. It is called only if the configuration is needed, and was not yet computed for the current value of the parent configuration. It is called in a tansu reactive context, so it can use any tansu store and will be called again if those stores change.
the resulting widgets default configuration store, which contains 3 additional properties that are stores: parent$, adaptedParent$ (containing the value computed after the first step), and own$ (that contains only overridding properties). The resulting store is writable, its set function is actually the set function of the own$ store.
The resulting store has a value computed from the parent store in two steps:
mergeInto<
T
>(destination
,source
,levels
):T
Merges source object into destination object, up to the provided number of levels.
• T
• destination: T
destination object
• source: undefined
| T
source object
• levels: number
= Infinity
number of levels to merge
T
the destination object in most cases, or the source in some cases (if the source is not undefined and either levels is smaller than 1 or the source is not an object)
Partial2Levels<
T
>:Partial
<{ [Level1 in keyof T]: Partial<T[Level1]> }
>
• T
useWidgetContext<
Props
>(widgetName
,defaultConfig
?):ReadableSignal
<Partial
<Props
>>
• Props extends object
• widgetName: null
| keyof BootstrapWidgetsConfig
• defaultConfig?: Partial
<Props
>
ReadableSignal
<Partial
<Props
>>
useWidgetWithConfig<
W
>(factory
,props
,widgetName
,defaultProps
?): [WidgetState
<W
>,W
]
• W extends Widget
<object
, object
, object
, object
, object
>
• factory: WidgetFactory
<W
>
• props: undefined
| Partial
<WidgetProps
<W
>>
• widgetName: null
| keyof BootstrapWidgetsConfig
• defaultProps?: Partial
<WidgetProps
<W
>>
[WidgetState
<W
>, W
]
WidgetsConfig:
object
accordion:
AccordionProps
the accordion widget config
alert:
AlertProps
the alert widget config
modal:
ModalProps
<any
>
the modal widget config
pagination:
PaginationProps
the pagination widget config
progressbar:
ProgressbarProps
the progressbar widget config
rating:
RatingProps
the rating widget config
select:
SelectProps
<any
>
the select widget config
slider:
SliderProps
the slider widget config
toast:
ToastProps
the toast widget config
widgetsConfigContext:
Context
<undefined
|WidgetsConfigStore
<WidgetsConfig
>>
widgetsConfigFactory<
Config
>(widgetsConfigContext
):object
A factory to create the use functions and react component to allow widgets to be context-aware.
It can be used when extending the core and creating new widgets.
• Config extends Record
<string
, object
> = WidgetsConfig
• widgetsConfigContext: Context
<undefined
| WidgetsConfigStore
<Config
>> = ...
the widgets config context
object
the use functions and react component
WidgetsDefaultConfig: (
componentInputs
) =>Element
React component that provides in the React context (for all AgnosUI descendant widgets) a new widgets default configuration store that inherits from any widgets default configuration store already defined at an upper level in the React context hierarchy. It contains its own set of widgets configuration properties that override the same properties form the parent configuration.
• componentInputs: DefaultConfigInput
<Config
>
the react component inputs
Element
the resulting widgets default configuration store, which contains 3 additional properties that are stores: parent$, adaptedParent$ (containing the value computed after the first step), and own$ (that contains only overridding properties). The resulting store is writable, its set function is actually the set function of the own$ store.
The configuration is computed from the parent configuration in two steps:
<WidgetsDefaultConfig
adaptParentConfig={(parentConfig) => {
parentConfig.rating = parentConfig.rating ?? {};
parentConfig.rating.className = `${parentConfig.rating.className ?? ''} my-rating-extra-class`
return parentConfig;
}}
rating={{slotStar: MyCustomSlotStar}}
/>
useWidgetContext: <
Props
>(widgetName
,defaultConfig
?) =>ReadableSignal
<Partial
<Props
>>
• Props extends object
• widgetName: null
| keyof Config
• defaultConfig?: Partial
<Props
>
ReadableSignal
<Partial
<Props
>>
useWidgetWithConfig: <
W
>(factory
,props
,widgetName
,defaultProps
?) => [WidgetState
<W
>,W
]
• W extends Widget
<object
, object
, object
, object
, object
>
• factory: WidgetFactory
<W
>
• props: undefined
| Partial
<WidgetProps
<W
>>
• widgetName: null
| keyof Config
• defaultProps?: Partial
<WidgetProps
<W
>>
[WidgetState
<W
>, W
]
widgetsConfigContext:
Context
<undefined
|WidgetsConfigStore
<Config
>>
React context which can be used to provide or consume the widgets default configuration store.
WidgetsConfigStore<
T
>:WritableSignal
<Partial2Levels
<T
>> &object
adaptedParent$:
undefined
|ReadableSignal
<Partial2Levels
<T
>>
own$:
WritableSignal
<Partial2Levels
<T
>>
parent$:
undefined
|WritableSignal
<Partial2Levels
<T
>>
• T
WidgetsDefaultConfig(
__namedParameters
):Element
• __namedParameters: DefaultConfigInput
Element