- Type fix, now items array accepts null, undefined or boolean for conditional items.
- Now
itemsprop supports nested array of items like Vue/React render function, nested arrays are converted tovNode[]in render phase.
const items = [
item(...),
users.map((user) => item(user)), // Item[],
itemGroup({
key: '__',
items: [
item(...),
[
customItem(...)
]
]
})
]- Now
itemDefaultsprop accepts a function that hasitempassed as parameter, for type safetycreateItemDefaultsis updated as well.
- Now instead of passing
metato render slot#render="meta"it passed whole item data#render="{ meta, disabled, onSelect }". This will be helpful for detecting disabled state etc.
- Now instead of creating a renderer function on every render, SelectableItems now returns render function from setup and renderer function is created only once per component. This will increase performance a bit but not recognizable.
### Features
-
New
itemDefaultsprop to create default options for all selectable items can be created. -
New
createItemDefaults(options: ItemDefaults)function for default options, this function will wrapwrapperComponentOrTagwithmarkRawif component is given.
- Fixed not wrapping functional components with
markRawinitem()anditemGroup().
- Fixed types of hooks/events.
Context['selectFocusedElement']was incorrect name, fixed to correct oneContext['selectFocusedItem']
-
Now
focusevent/hook has a fourth parameterbyPointer: boolean. If user is focused to an item by pointer this parameter will betrueotherwisefalse. -
Now
DOMFocusevent has four arguments. Frst argument ofDomFocusevent isFocus Event, rest isMeta, Item<Meta>, HTMLElement.
- Removed
itemHoverevent andContext['onHover']hook, use focus with fourth parameter instead.
- Removed unused variables from setup return.
- Updated readme
- Now
ItemOptionshavedisabledoption. Disabled items havevue-selectable-items-item-disabledclass.item({ key: 'myKey', disabled: true })
- If current focused item key doesn't exist anymore, focus will be resetted.
-
itemFocus,itemUnfocus,itemDOMFocus,itemHoveremits are added. -
SelectableItemscomponent now exposesContextas template ref. -
Now all events has 3 arguments; Meta, Item and HTMLElement.
-
New exported functions
filterSelectableAndCustomItemsandfilterSelectableItems. -
Now
onSelectproperty of an item has correct type support. -
-
getItemMetaDataByKeyrenamed asgetItemMetaByKeywith generic support.getItemMetabyKey<Meta = unknown> -
getSelectableItemsnow supports generic.getSelectableItems<Meta = unknown> -
getFocusedElementrenamed asgetFocusedItemElement -
onMouseEnterrenamed asonHover
-
- Updated readme.
itemGroup()anditem()now wraps givenwrapperComponentOrTagwithmarkRawfor performance optimization.itemGroup()anditem()now has type support forwrapperProps.onClick(meta)property ofitem()now has correct types.- Added
data-vue-selectable-items-itemto selectable item elements to help users query items likedocument.activeElement.hasAttribute('data-vue-selectable-items-item').
-
Now each item requires a unique key, old approach was creating a random key for each item but that wasn't a good choice because most people are creating items in a computed and computed creates unique key for each trigger. This makes all items to rerender even if they didn't change.
-
itemGroup, customItem and item functions are now expecting 1 argument as object and has generic meta type support.
-
metaDatarenamed tometaand. -
slotNameoption ofCustomItemrenamed asname.
- Added new functions to
setupprop arguments. - Exported missing types.