Skip to content

Commit bdbd1c8

Browse files
Merge pull request #1 from hirenkeraliya/upgrade-vue-3
2 parents 605b841 + 37ecc2d commit bdbd1c8

24 files changed

+250
-215
lines changed

babel.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
module.exports = {
22
'presets': [
33
['@babel/preset-env', {
4-
'modules': false
4+
'modules': false,
5+
'targets': {
6+
'node': 'current',
7+
},
58
}]
69
],
710
'env': {

example/main.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
import Vue from 'vue'
1+
import { createApp } from 'vue';
22
import Demo from './Demo.vue'
33

4-
Vue.config.productionTip = false
4+
const app = createApp(Demo);
55

6-
/* eslint-disable no-new */
7-
new Vue({
8-
el: '#app',
9-
render: h => h(Demo)
10-
})
6+
app.mount("#app");

package.json

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuejs-datepicker",
3-
"version": "1.6.2",
3+
"version": "2.0.0",
44
"description": "A simple Vue.js datepicker component. Supports disabling of dates, inline mode, translations",
55
"keywords": [
66
"vue",
@@ -36,9 +36,8 @@
3636
"lint",
3737
"test"
3838
],
39-
"dependencies": {},
4039
"peerDependencies": {
41-
"vue": "^2.6.10"
40+
"vue": "^3.3.4"
4241
},
4342
"devDependencies": {
4443
"@babel/cli": "^7.4.4",
@@ -51,44 +50,45 @@
5150
"@babel/preset-stage-2": "^7.0.0",
5251
"@babel/register": "^7.4.4",
5352
"@babel/runtime": "^7.4.5",
54-
"@vue/test-utils": "^1.0.0-beta.12",
55-
"autoprefixer": "^8.3.0",
53+
"@rollup/plugin-babel": "^6.0.3",
54+
"@vue/compiler-sfc": "^3.3.4",
55+
"@vue/test-utils": "^2.4.1",
56+
"@vue/vue3-jest": "^29.2.4",
57+
"autoprefixer": "^10.4.14",
5658
"babel-eslint": "^7.1.1",
57-
"babel-jest": "^24.8.0",
59+
"babel-jest": "^29.6.2",
5860
"chalk": "^1.1.3",
5961
"connect-history-api-fallback": "^1.3.0",
6062
"coveralls": "^3.0.4",
6163
"eslint": "^3.19.0",
6264
"eslint-config-standard": "^6.2.1",
6365
"eslint-friendly-formatter": "^2.0.7",
64-
"eslint-plugin-html": "^2.0.0",
66+
"eslint-plugin-html": "^2.0.3",
6567
"eslint-plugin-promise": "^3.4.0",
6668
"eslint-plugin-standard": "^2.0.1",
6769
"eventsource-polyfill": "^0.9.6",
68-
"jest": "^24.8.0",
70+
"jest": "^29.6.2",
71+
"jest-environment-jsdom": "^29.6.2",
6972
"jest-serializer-vue": "^2.0.2",
7073
"lolex": "^1.5.2",
7174
"opn": "^4.0.2",
7275
"ora": "^1.2.0",
7376
"parse5": "^2.1.0",
7477
"pre-commit": "^1.2.2",
7578
"rimraf": "^2.6.0",
76-
"rollup": "^1.16.2",
77-
"rollup-plugin-babel": "^4.3.3",
79+
"rollup": "^2.79.1",
7880
"rollup-plugin-commonjs": "^10.0.0",
7981
"rollup-plugin-livereload": "^1.0.1",
8082
"rollup-plugin-node-resolve": "^5.0.4",
81-
"rollup-plugin-postcss": "^2.0.3",
83+
"rollup-plugin-postcss": "^4.0.2",
8284
"rollup-plugin-replace": "^2.0.0",
8385
"rollup-plugin-serve": "^1.0.1",
8486
"rollup-plugin-terser": "^5.0.0",
85-
"rollup-plugin-vue": "^5.0.0",
87+
"rollup-plugin-vue": "^6.0.0",
8688
"semver": "^5.3.0",
8789
"shelljs": "^0.8.3",
8890
"stylus": "^0.54.5",
89-
"vue": "^2.6.10",
90-
"vue-jest": "^4.0.0-beta.2",
91-
"vue-server-renderer": "^2.6.10",
92-
"vue-template-compiler": "^2.6.10"
91+
"vue": "^3.3.4",
92+
"vue-server-renderer": "^2.6.10"
9393
}
94-
}
94+
}

scripts/build-locale.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import fs from 'fs'
22
import path from 'path'
3-
import {terser} from 'rollup-plugin-terser'
4-
import babel from 'rollup-plugin-babel'
3+
import { terser } from 'rollup-plugin-terser'
4+
import babel from '@rollup/plugin-babel'
55
import commonjs from 'rollup-plugin-commonjs'
66

77
const files = fs.readdirSync('./src/locale/translations')
@@ -15,7 +15,7 @@ const config = files.map(file => {
1515
},
1616
plugins: [
1717
commonjs(),
18-
babel({exclude: 'node_modules/**'}),
18+
babel({ exclude: 'node_modules/**' }),
1919
terser()
2020
]
2121
}
@@ -30,7 +30,7 @@ const index = {
3030
},
3131
plugins: [
3232
commonjs(),
33-
babel({exclude: 'node_modules/**'}),
33+
babel({ exclude: 'node_modules/**' }),
3434
terser()
3535
]
3636
}

scripts/build.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path'
2-
import {terser} from 'rollup-plugin-terser'
2+
import { terser } from 'rollup-plugin-terser'
33
import vue from 'rollup-plugin-vue'
4-
import babel from 'rollup-plugin-babel'
4+
import babel from '@rollup/plugin-babel'
55
import postcss from 'rollup-plugin-postcss'
66
import autoprefixer from 'autoprefixer'
77
import commonjs from 'rollup-plugin-commonjs'
@@ -24,10 +24,10 @@ export default [{
2424
}
2525
],
2626
plugins: [
27-
vue({css: true}),
28-
postcss({plugins: [autoprefixer()]}),
27+
vue({ css: true }),
28+
postcss({ plugins: [autoprefixer()] }),
2929
commonjs(),
30-
babel({exclude: 'node_modules/**'})
30+
babel({ exclude: 'node_modules/**' })
3131
]
3232
}, {
3333
input: path.join(__dirname, '..', 'src', 'components', 'Datepicker.vue'),
@@ -37,10 +37,10 @@ export default [{
3737
name: 'vuejsDatepicker'
3838
},
3939
plugins: [
40-
vue({css: true}),
41-
postcss({plugins: [autoprefixer()]}),
40+
vue({ css: true }),
41+
postcss({ plugins: [autoprefixer()] }),
4242
commonjs(),
4343
terser(),
44-
babel({exclude: 'node_modules/**'})
44+
babel({ exclude: 'node_modules/**' })
4545
]
4646
}]

scripts/serve.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import path from 'path'
22
import serve from 'rollup-plugin-serve'
33
import livereload from 'rollup-plugin-livereload'
44
import vue from 'rollup-plugin-vue'
5-
import babel from 'rollup-plugin-babel'
5+
import babel from '@rollup/plugin-babel'
66
import resolve from 'rollup-plugin-node-resolve'
77
import replace from 'rollup-plugin-replace'
88
import common from 'rollup-plugin-commonjs'
9+
import postcss from 'rollup-plugin-postcss'
10+
import autoprefixer from 'autoprefixer'
911

1012
export default {
1113
input: path.join(__dirname, '..', 'example', 'main.js'),
@@ -19,23 +21,24 @@ export default {
1921
vue({
2022
css: true
2123
}),
24+
postcss({ plugins: [autoprefixer()] }),
2225
replace({
2326
'process.env.NODE_ENV': JSON.stringify('development')
2427
}),
2528
resolve({
2629
mainFields: ['module', 'main']
2730
}),
2831
common(),
29-
babel({exclude: 'node_modules/**'}),
32+
babel({ exclude: 'node_modules/**' }),
3033
serve({
3134
open: true,
3235
contentBase: path.join(__dirname, '..', 'example'),
33-
host: 'localhost',
34-
port: 10001
36+
host: '0.0.0.0',
37+
port: 3000
3538
}),
3639
livereload({
3740
verbose: true,
3841
watch: path.join(__dirname, '..', 'example')
3942
})
4043
]
41-
}
44+
}

src/components/Datepicker.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default {
108108
PickerYear
109109
},
110110
props: {
111-
value: {
111+
modelValue: {
112112
validator: val => utils.validateDateInput(val)
113113
},
114114
name: String,
@@ -187,7 +187,7 @@ export default {
187187
}
188188
},
189189
watch: {
190-
value (value) {
190+
modelValue (value) {
191191
this.setValue(value)
192192
},
193193
openDate () {
@@ -331,7 +331,7 @@ export default {
331331
this.selectedDate = date
332332
this.setPageDate(date)
333333
this.$emit('selected', date)
334-
this.$emit('input', date)
334+
this.$emit('update:modelValue', date)
335335
},
336336
/**
337337
* Clear the selected date
@@ -340,7 +340,7 @@ export default {
340340
this.selectedDate = null
341341
this.setPageDate()
342342
this.$emit('selected', null)
343-
this.$emit('input', null)
343+
this.$emit('update:modelValue', null)
344344
this.$emit('cleared')
345345
},
346346
/**
@@ -445,8 +445,8 @@ export default {
445445
* Initiate the component
446446
*/
447447
init () {
448-
if (this.value) {
449-
this.setValue(this.value)
448+
if (this.modelValue) {
449+
this.setValue(this.modelValue)
450450
}
451451
if (this.isInline) {
452452
this.setInitialView()
@@ -462,4 +462,4 @@ export default {
462462
</script>
463463
<style lang="stylus">
464464
@import '../styles/style'
465-
</style>
465+
</style>

test/unit/jest.conf.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const path = require('path')
22

33
module.exports = {
4+
testEnvironment: 'jsdom',
5+
testEnvironmentOptions: {
6+
customExportConditions: ["node", "node-addons"],
7+
},
48
rootDir: path.resolve(__dirname, '../../'),
59
moduleFileExtensions: [
610
'js',
@@ -12,7 +16,7 @@ module.exports = {
1216
},
1317
transform: {
1418
'^.+\\.js$': 'babel-jest',
15-
'.*\\.(vue)$': 'vue-jest'
19+
'.*\\.(vue)$': '@vue/vue3-jest'
1620
},
1721
setupFiles: ['<rootDir>/test/unit/setup'],
1822
coverageDirectory: '<rootDir>/test/unit/coverage',

test/unit/setup.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
import Vue from 'vue'
2-
3-
Vue.config.productionTip = false
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import DateInput from '@/components/DateInput.vue'
2-
import {shallow} from '@vue/test-utils'
3-
import {en} from '@/locale'
2+
import { mount } from '@vue/test-utils'
3+
import { en } from '@/locale'
44

55
describe('DateInput', () => {
66
let wrapper
77

88
beforeEach(() => {
9-
wrapper = shallow(DateInput, {
9+
wrapper = mount(DateInput, {
10+
shallow: true,
1011
propsData: {
1112
selectedDate: new Date(2018, 2, 24),
1213
format: 'dd MMM yyyy',
@@ -19,8 +20,8 @@ describe('DateInput', () => {
1920
expect(wrapper.findAll('input')).toHaveLength(1)
2021
})
2122

22-
it('nulls date', () => {
23-
wrapper.setProps({
23+
it('nulls date', async () => {
24+
await wrapper.setProps({
2425
selectedDate: null
2526
})
2627
expect(wrapper.vm.formattedValue).toBeNull()
@@ -32,8 +33,8 @@ describe('DateInput', () => {
3233
expect(wrapper.find('input').element.value).toEqual('24 Mar 2018')
3334
})
3435

35-
it('delegates date formatting', () => {
36-
wrapper.setProps({
36+
it('delegates date formatting', async () => {
37+
await wrapper.setProps({
3738
selectedDate: new Date(2016, 1, 15),
3839
format: () => '2016/1/15'
3940
})
@@ -46,31 +47,31 @@ describe('DateInput', () => {
4647
expect(wrapper.emitted().showCalendar).toBeTruthy()
4748
})
4849

49-
it('adds bootstrap classes', () => {
50-
wrapper.setProps({
50+
it('adds bootstrap classes', async () => {
51+
await wrapper.setProps({
5152
bootstrapStyling: true
5253
})
5354
expect(wrapper.find('input').element.classList).toContain('form-control')
5455
})
5556

56-
it('appends bootstrap classes', () => {
57-
wrapper.setProps({
57+
it('appends bootstrap classes', async () => {
58+
await wrapper.setProps({
5859
inputClass: 'someClass',
5960
bootstrapStyling: true
6061
})
6162
expect(wrapper.find('input').element.classList).toContain('form-control')
6263
expect(wrapper.find('input').element.classList).toContain('someClass')
6364
})
6465

65-
it('can be disabled', () => {
66-
wrapper.setProps({
66+
it('can be disabled', async () => {
67+
await wrapper.setProps({
6768
disabled: true
6869
})
6970
expect(wrapper.find('input').attributes().disabled).toBeDefined()
7071
})
7172

72-
it('accepts a function as a formatter', () => {
73-
wrapper.setMethods({
73+
it('accepts a function as a formatter', async () => {
74+
await wrapper.setProps({
7475
format: () => '!'
7576
})
7677
expect(wrapper.find('input').element.value).toEqual('!')
@@ -80,4 +81,4 @@ describe('DateInput', () => {
8081
wrapper.find('input').trigger('blur')
8182
expect(wrapper.emitted('closeCalendar')).toBeTruthy()
8283
})
83-
})
84+
})

0 commit comments

Comments
 (0)