Skip to content

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

NameTypeRequiredDescription
propsobjectyesThe widget context's reactive props.
emit(event: string, args: any[]) => voidyesThe widget context's component emit function.

props Properties

NameTypeRequiredDefaultDescription
contextlessbooleanIf true, the widget ignores surrounding context like field or form.
disabledbooleanWhether the widget is disabled.
disabledFn() => booleanA function that returns a boolean indicating disabled state.
displayDependenciesstring[]The widget dependencies to register with the field context, if any.
fieldToWidgetValueAdapterThe value adapter for turing form values into values suitable for UI concerns.
helpstringThe help text for the widget.
invalidbooleanWhether the widget is invalid, when not in a field context.
labelstringThe label to display next to the widget.
modelValueanyThe widget’s bound value (v-model).
namestringThe name of the widget.
requiredbooleanWhether the widget is required. Inherits from field context if undefined.
warningbooleanWhether the widget is in a warning state, when not in a field context.
widgetToFieldValueAdapterThe value adapter for the widget values back into form values, for validation and submission concerns.

Returns

WidgetContext

The widget context object.

Source

client/lib/use/useWidget.js:220

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2