useWidget
Overview
Generate and provide a widget context for a widget, using the provided props and emit function, including methods to update the widget's value, touch state, force modified recalculation, and focus or blur it.
Signature
useWidget(props, emit)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| props | object | yes | The widget context's reactive props. |
| emit | (event: string, args: any[]) => void | yes | The widget context's component emit function. |
props Properties
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| contextless | boolean | If true, the widget ignores surrounding context like field or form. | ||
| disabled | boolean | Whether the widget is disabled. | ||
| disabledFn | () => boolean | A function that returns a boolean indicating disabled state. | ||
| displayDependencies | string[] | The widget dependencies to register with the field context, if any. | ||
| fieldToWidget | ValueAdapter | The value adapter for turing form values into values suitable for UI concerns. | ||
| help | string | The help text for the widget. | ||
| invalid | boolean | Whether the widget is invalid, when not in a field context. | ||
| label | string | The label to display next to the widget. | ||
| modelValue | any | The widget’s bound value (v-model). | ||
| name | string | The name of the widget. | ||
| required | boolean | Whether the widget is required. Inherits from field context if undefined. | ||
| warning | boolean | Whether the widget is in a warning state, when not in a field context. | ||
| widgetToField | ValueAdapter | The value adapter for the widget values back into form values, for validation and submission concerns. |
Returns
The widget context object.
Source
client/lib/use/useWidget.js:220