Skip to content

Commit

Permalink
feat: Vue 2.7 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
adamberecz committed Jul 11, 2022
1 parent 4e85520 commit 3673d4b
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 54 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v2.1.0

> `2022-07-11`
### 🎉 Features
- Vue.js `2.7` compatibility

## v2.0.10

> `2022-05-11`
Expand Down
63 changes: 22 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ Learn more: [https://vueform.com](https://vueform.com)
* [Installation](#installation)
* [Using with Vue 3](#using-with-vue-3)
* [Using with Vue 2](#using-with-vue-2)
* [Using with Nuxt.js](#using-with-nuxtjs)
* [Support](#support)
* [Configuration](#configuration)
* [Basic props](#basic-props)
Expand Down Expand Up @@ -147,52 +146,34 @@ npm install @vueform/slider

### Using with Vue 2

When using Vue 2 install [@vue/composition-api](https://github.com/vuejs/composition-api#npm) via npm/yarn first:

``` bash
npm i @vue/composition-api --save-dev
```

Then install the plugin for Vue:

``` js
import Vue from 'vue'
import VueCompositionAPI from '@vue/composition-api'

Vue.use(VueCompositionAPI)
```

After that make sure to change the imported Slider module to:

``` js
import Slider from '@vueform/slider/dist/slider.vue2.js'
```

### Using with Nuxt.js

First you need install [@nuxtjs/composition-api](https://composition-api.nuxtjs.org/getting-started/setup):
``` vue
<template>
<div>
<Slider v-model="value" />
</div>
</template>
``` bash
npm i @nuxtjs/composition-api --save
```
<script>
import Slider from '@vueform/slider/dist/slider.vue2.js'
Then you need to enable it as a module in `nuxt.config.js`:
export default {
components: {
Slider,
},
data() {
return {
value: 20
}
}
}
</script>
``` js
{
buildModules: [
'@nuxtjs/composition-api/module'
]
}
<style src="@vueform/slider/themes/default.css"></style>
```

After that make sure to change the imported module to Vue 2 version of Slider:

``` js
import Slider from '@vueform/slider/dist/slider.vue2'
```
#### Using with < Vue 2.7

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

## Support

Expand Down
6 changes: 3 additions & 3 deletions build/vue2.rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default [
vue(),
alias({
entries: [
{ find: 'composition-api', replacement: '@vue/composition-api' },
{ find: 'composition-api', replacement: 'vue' },
]
}),
nodeResolve({
Expand All @@ -29,7 +29,7 @@ export default [
}),
terser(),
],
external: ['@vue/composition-api'],
external: ['vue'],
},
{
input: 'src/Slider.vue',
Expand All @@ -38,7 +38,7 @@ export default [
format: 'iife',
name: 'VueformSlider',
globals: {
'composition-api': 'VueCompositionAPI',
'composition-api': 'Vue',
'vue': 'Vue',
}
},
Expand Down
2 changes: 1 addition & 1 deletion dist/slider.global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/slider.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/slider.vue2.global.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/slider.vue2.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jest/jest.config.vue2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
"/node_modules/"
],
"moduleNameMapper": {
"^composition-api$": "<rootDir>/node_modules/vue-prev-composition-api",
"^composition-api$": "<rootDir>/node_modules/vue-prev",
"^@vue/test-utils$": "<rootDir>/node_modules/vue-prev-test-utils",
"^vue$": "<rootDir>/node_modules/vue-prev",
'^vue-jest$': "<rootDir>/node_modules/vue-prev-jest",
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": "@vueform/slider",
"version": "2.0.10",
"version": "2.1.0",
"private": false,
"description": "Vue 3 slider component with multihandles, tooltips merging and formatting.",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function useValue (props, context, dependencies)
// ================ DATA ================

/* istanbul ignore next */
const value = context.expose !== undefined ? modelValue : baseValue
const value = modelValue && modelValue.value !== undefined ? modelValue : baseValue

const initialValue = ref(value.value)

Expand Down
2 changes: 0 additions & 2 deletions tests/unit/helpers/vue2.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { mount, createLocalVue } from '@vue/test-utils'
import CompositionApi from 'composition-api'
import Slider from './../../../src/Slider'

export const createSlider = (props = {}, options = {}) => {
const localVue = createLocalVue()
localVue.use(CompositionApi)

let config = {
localVue,
Expand Down
2 changes: 1 addition & 1 deletion themes/default.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3673d4b

Please sign in to comment.