useItems

Commons
stable

Normalises the polymorphic items prop accepted by list-based components (Select, Combobox, Autocomplete, List). Transforms raw item arrays into internal list item descriptors and provides bidirectional model value transformers (in from model, out to model) that respect returnObject mode and a custom value comparator.

API

Signature

Full TypeScript signature sourced from the composable file.

typescript

Consumed interfaces

IItemProps
IInternalListItem

API

Parameters

Input parameters accepted by this composable.

props
required
IItemProps & { itemType?: string }
Component props extending IItemProps (items, itemTitle, itemValue, itemProps, returnObject, valueComparator). itemType is an optional tag used during transformation.

API

Return values

Properties and methods exposed by the composable return object.

items
Computed array of normalised internal list items derived from props.items. Recomputes whenever props.items changes.
transformIn
Converts an array of model values (or raw objects in returnObject mode) to the matching internal list item descriptors. Handles null-item and custom comparator edge cases.
transformOut
Converts selected internal list items back to the model value format: raw objects when returnObject is true, item values otherwise.

Usage

Examples

Ready-to-paste usage snippets.

Normalise a string item list

vue

Round-trip with transformIn / transformOut

vue