Skip to content

Commit

Permalink
v0.4.0 (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
kadiryazici authored Oct 24, 2022
1 parent 05aa442 commit 3e823b1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 1 deletion.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# 0.4.0
### Features
- New `itemDefaults` prop to create default options for all selectable items can be created.

- New `createItemDefaults(options: ItemDefaults)` function for default options, this function will wrap `wrapperComponentOrTag` with `markRaw` if component is given.

### Bug Fixes
- Fixed not wrapping functional components with `markRaw` in `item()` and `itemGroup()`.

<br>

# 0.3.1
### Bug Fixes
- Fixed types of hooks/events.
Expand Down
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ Let's explain everything step by step.
// onMounted, Composables, Keyboard Handling (see examples) and more setup specific stuff.
// NOTE: This function will only run once on setup phase.
setup?: (context: Context) => void;

// Default options for all selectable items.
itemDefaults?: ItemDefaults;
}
```

Expand Down Expand Up @@ -459,6 +462,51 @@ Let's explain everything step by step.
}
```

## Item Defaults
If you want to give default options to all selectable items, you can use `itemDefaults: ItemDefaults` prop.


It is recommended to use `createItemDefaults(options?: Partial<ItemDefaults>)` function to create options because if `wrapperComponentOrTag` is component it'll be wrapped by `markRaw` not to slow performance.

```html
<script setup>
import { createItemDefaults, SelectableItems, items } from 'vue-selectable-items';
import MyWrapper from './MyWrapper.vue';
const items = [
item({
key: 'myitem',
meta: 'Item 1',
elementAttrs: {
onMouseMove() {
console.log('Other thing');
}
}
})
]
const itemDefaults = createItemDefaults({
elementTag: 'button',
// All attrs and props will be merged with item specific options.
elementAttrs: {
tabindex: '0',
outline: 'none',
// This will not override local onMouseMove attr on item, they will be merged.
onMouseMove() {
console.log('Something');
}
},
wrapperComponentOrTag: MyWrapper,
wrapperProps: {
someValue: true
}
})
</script>
<template>
<SelectableItems :items="items" :itemDefaults="itemDefaults"/>
</template>
```
## Context

Context is an object of functions, you can access it via `setup` prop and `template ref`.
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vue-selectable-items",
"version": "0.3.1",
"version": "0.4.0",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/types/index.d.ts",
Expand Down

0 comments on commit 3e823b1

Please sign in to comment.