Skip to content

Commit 013e2d8

Browse files
committed
feat: Vue 2.7 compatibility
1 parent 8355c8a commit 013e2d8

File tree

12 files changed

+1314
-827
lines changed

12 files changed

+1314
-827
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v2.5.0.
2+
3+
> `2022-07-11`
4+
5+
### 🎉 Feature
6+
- Vue `2.7` compatibility.
7+
18
## v2.4.2
29

310
> `2022-05-31`

README.md

Lines changed: 30 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ Learn more: [https://vueform.com](https://vueform.com)
136136
- [Installation](#installation)
137137
- [Using with Vue 3](#using-with-vue-3)
138138
- [Using with Vue 2](#using-with-vue-2)
139-
- [Using with Nuxt.js](#using-with-nuxtjs)
140139
- [Support](#support)
141140
- [Configuration](#configuration)
142141
- [Basic props](#basic-props)
@@ -212,52 +211,42 @@ npm install @vueform/multiselect
212211

213212
## Using with Vue 2
214213

215-
When using Vue 2 install [@vue/composition-api](https://github.com/vuejs/composition-api#npm) via npm/yarn first:
216-
217-
``` bash
218-
npm i @vue/composition-api --save-dev
219-
```
220-
221-
Then install the plugin for Vue:
222-
223-
``` js
224-
import Vue from 'vue'
225-
import VueCompositionAPI from '@vue/composition-api'
226-
227-
Vue.use(VueCompositionAPI)
228-
```
229-
230-
After that make sure to change the imported Multiselect module to:
231-
232-
``` js
233-
import Multiselect from '@vueform/multiselect/dist/multiselect.vue2.js'
234-
```
235-
236-
## Using with Nuxt.js
237-
238-
First you need install [@nuxtjs/composition-api](https://composition-api.nuxtjs.org/getting-started/setup):
214+
``` vue
215+
<template>
216+
<div>
217+
<Multiselect
218+
v-model="value"
219+
:options="options"
220+
/>
221+
</div>
222+
</template>
239223
240-
``` bash
241-
npm i @nuxtjs/composition-api --save
242-
```
224+
<script>
225+
import Multiselect from '@vueform/multiselect/multiselect.vue2.js'
243226
244-
Then you need to enable it as a module in `nuxt.config.js`:
227+
export default {
228+
components: {
229+
Multiselect,
230+
},
231+
data() {
232+
return {
233+
value: null,
234+
options: [
235+
'Batman',
236+
'Robin',
237+
'Joker',
238+
]
239+
}
240+
}
241+
}
242+
</script>
245243
246-
``` js
247-
{
248-
buildModules: [
249-
'@nuxtjs/composition-api/module'
250-
]
251-
}
244+
<style src="@vueform/multiselect/themes/default.css"></style>
252245
```
253246

254-
After that make sure to change the imported module to Vue 2 version of Multiselect:
255-
256-
``` js
257-
import Multiselect from '@vueform/multiselect/dist/multiselect.vue2'
258-
```
247+
#### Using with < Vue 2.7
259248

260-
For more information on using `@nuxtjs/composition-api` read [their documentation](https://composition-api.nuxtjs.org/).
249+
Switch to [`<= 2.4.2`](https://github.com/vueform/multiselect/tree/2.4.2) to use the Multiselect with Vue.js `< 2.7`.
261250

262251
## Support
263252

build/vue2.rollup.config.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ export default [
1212
plugins: [
1313
alias({
1414
entries: [
15-
{ find: 'composition-api', replacement: '@vue/composition-api' },
15+
{ find: 'composition-api', replacement: 'vue' },
1616
]
1717
}),
1818
vue(),
1919
],
20-
external: ['@vue/composition-api'],
20+
external: ['vue'],
2121
},
2222
{
2323
input: 'src/Multiselect.vue',
@@ -27,18 +27,17 @@ export default [
2727
name: 'VueformMultiselect',
2828
globals: {
2929
'vue': 'Vue',
30-
'@vue/composition-api': 'VueCompositionAPI',
3130
}
3231
},
3332
plugins: [
3433
alias({
3534
entries: [
36-
{ find: 'composition-api', replacement: '@vue/composition-api' },
35+
{ find: 'composition-api', replacement: 'vue' },
3736
]
3837
}),
3938
vue(),
4039
terser()
4140
],
42-
external: ['@vue/composition-api', 'vue'],
41+
external: ['vue'],
4342
}
4443
]

dist/multiselect.global.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/multiselect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function useValue (props, context)
7474

7575
/* istanbul ignore next */
7676
// externalValue
77-
const ev = context.expose !== undefined ? modelValue : value;
77+
const ev = modelValue && modelValue.value !== undefined ? modelValue : value;
7878

7979
const plainValue = computed(() => {
8080
return mode.value === 'single' ? iv.value[valueProp.value] : iv.value.map(v=>v[valueProp.value])

dist/multiselect.vue2.global.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/multiselect.vue2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { toRefs, getCurrentInstance, ref, computed, watch, nextTick, onMounted } from '@vue/composition-api';
1+
import { toRefs, getCurrentInstance, ref, computed, watch, nextTick, onMounted } from 'vue';
22

33
function isNullish (val) {
44
return [null, undefined].indexOf(val) !== -1
@@ -74,7 +74,7 @@ function useValue (props, context)
7474

7575
/* istanbul ignore next */
7676
// externalValue
77-
const ev = context.expose !== undefined ? modelValue : value;
77+
const ev = modelValue && modelValue.value !== undefined ? modelValue : value;
7878

7979
const plainValue = computed(() => {
8080
return mode.value === 'single' ? iv.value[valueProp.value] : iv.value.map(v=>v[valueProp.value])

jest/jest.config.vue2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module.exports = {
1515
"/node_modules/"
1616
],
1717
"moduleNameMapper": {
18-
"^composition-api$": "<rootDir>/node_modules/vue-prev-composition-api",
18+
"^composition-api$": "<rootDir>/node_modules/vue-prev",
1919
"^@vue/test-utils$": "<rootDir>/node_modules/vue-prev-test-utils",
2020
"^vue$": "<rootDir>/node_modules/vue-prev",
2121
'^vue-jest$': "<rootDir>/node_modules/vue-prev-jest",

0 commit comments

Comments
 (0)