Skip to content

Commit 3673d4b

Browse files
committed
feat: Vue 2.7 compatibility
1 parent 4e85520 commit 3673d4b

12 files changed

+40
-54
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## v2.1.0
2+
3+
> `2022-07-11`
4+
5+
### 🎉 Features
6+
- Vue.js `2.7` compatibility
7+
18
## v2.0.10
29

310
> `2022-05-11`

README.md

+22-41
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ Learn more: [https://vueform.com](https://vueform.com)
9393
* [Installation](#installation)
9494
* [Using with Vue 3](#using-with-vue-3)
9595
* [Using with Vue 2](#using-with-vue-2)
96-
* [Using with Nuxt.js](#using-with-nuxtjs)
9796
* [Support](#support)
9897
* [Configuration](#configuration)
9998
* [Basic props](#basic-props)
@@ -147,52 +146,34 @@ npm install @vueform/slider
147146

148147
### Using with Vue 2
149148

150-
When using Vue 2 install [@vue/composition-api](https://github.com/vuejs/composition-api#npm) via npm/yarn first:
151-
152-
``` bash
153-
npm i @vue/composition-api --save-dev
154-
```
155-
156-
Then install the plugin for Vue:
157-
158-
``` js
159-
import Vue from 'vue'
160-
import VueCompositionAPI from '@vue/composition-api'
161-
162-
Vue.use(VueCompositionAPI)
163-
```
164-
165-
After that make sure to change the imported Slider module to:
166-
167-
``` js
168-
import Slider from '@vueform/slider/dist/slider.vue2.js'
169-
```
170-
171-
### Using with Nuxt.js
172-
173-
First you need install [@nuxtjs/composition-api](https://composition-api.nuxtjs.org/getting-started/setup):
149+
``` vue
150+
<template>
151+
<div>
152+
<Slider v-model="value" />
153+
</div>
154+
</template>
174155
175-
``` bash
176-
npm i @nuxtjs/composition-api --save
177-
```
156+
<script>
157+
import Slider from '@vueform/slider/dist/slider.vue2.js'
178158
179-
Then you need to enable it as a module in `nuxt.config.js`:
159+
export default {
160+
components: {
161+
Slider,
162+
},
163+
data() {
164+
return {
165+
value: 20
166+
}
167+
}
168+
}
169+
</script>
180170
181-
``` js
182-
{
183-
buildModules: [
184-
'@nuxtjs/composition-api/module'
185-
]
186-
}
171+
<style src="@vueform/slider/themes/default.css"></style>
187172
```
188173

189-
After that make sure to change the imported module to Vue 2 version of Slider:
190-
191-
``` js
192-
import Slider from '@vueform/slider/dist/slider.vue2'
193-
```
174+
#### Using with < Vue 2.7
194175

195-
For more information on using `@nuxtjs/composition-api` read [their documentation](https://composition-api.nuxtjs.org/).
176+
Switch to [`<= 2.0.10`](https://github.com/vueform/slider/tree/2.0.10) to use the Slider with Vue.js `< 2.7`.
196177

197178
## Support
198179

build/vue2.rollup.config.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default [
1616
vue(),
1717
alias({
1818
entries: [
19-
{ find: 'composition-api', replacement: '@vue/composition-api' },
19+
{ find: 'composition-api', replacement: 'vue' },
2020
]
2121
}),
2222
nodeResolve({
@@ -29,7 +29,7 @@ export default [
2929
}),
3030
terser(),
3131
],
32-
external: ['@vue/composition-api'],
32+
external: ['vue'],
3333
},
3434
{
3535
input: 'src/Slider.vue',
@@ -38,7 +38,7 @@ export default [
3838
format: 'iife',
3939
name: 'VueformSlider',
4040
globals: {
41-
'composition-api': 'VueCompositionAPI',
41+
'composition-api': 'Vue',
4242
'vue': 'Vue',
4343
}
4444
},

dist/slider.global.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/slider.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/slider.vue2.global.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/slider.vue2.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jest/jest.config.vue2.js

+1-1
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",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@vueform/slider",
3-
"version": "2.0.10",
3+
"version": "2.1.0",
44
"private": false,
55
"description": "Vue 3 slider component with multihandles, tooltips merging and formatting.",
66
"license": "MIT",

src/composables/useValue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export default function useValue (props, context, dependencies)
88
// ================ DATA ================
99

1010
/* istanbul ignore next */
11-
const value = context.expose !== undefined ? modelValue : baseValue
11+
const value = modelValue && modelValue.value !== undefined ? modelValue : baseValue
1212

1313
const initialValue = ref(value.value)
1414

tests/unit/helpers/vue2.js

-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import { mount, createLocalVue } from '@vue/test-utils'
2-
import CompositionApi from 'composition-api'
32
import Slider from './../../../src/Slider'
43

54
export const createSlider = (props = {}, options = {}) => {
65
const localVue = createLocalVue()
7-
localVue.use(CompositionApi)
86

97
let config = {
108
localVue,

themes/default.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)