Skip to content

Commit 2d33143

Browse files
committed
feat(light): upgrade to vue3
issue: #4 BREAKING CHANGE: no vue2 support
1 parent 96fe7e6 commit 2d33143

File tree

6 files changed

+30
-46
lines changed

6 files changed

+30
-46
lines changed

light/build/rollup.config.js

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import commonjs from '@rollup/plugin-commonjs'; // Convert CommonJS modules to ES6
2+
import css from 'rollup-plugin-css-only';
23
import vue from 'rollup-plugin-vue'; // Handle .vue SFC files
3-
import buble from '@rollup/plugin-buble'; // Transpile/polyfill with reasonable browser support
4-
import css from 'rollup-plugin-css-only'
54
export default {
65
input: 'src/index.js', // Path relative to package.json
76
output: {
@@ -17,11 +16,5 @@ export default {
1716
compileTemplate: true, // Explicitly convert template to render function
1817
}),
1918
commonjs(),
20-
/*buble({
21-
objectAssign: 'Object.assign',
22-
transforms: {
23-
forOf: false
24-
}
25-
}), // Transpile to ES5*/
2619
],
2720
};

light/dev/example-usage.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<template>
2-
<VueCronEditor v-model="value">
3-
4-
</VueCronEditor>
2+
<div>
3+
<VueCronEditor :value="value" @update:value="value = $event">
4+
</VueCronEditor>
5+
<div><br />cron expression: {{value}}</div>
6+
</div>
57
</template>
68

79
<script>

light/dev/serve.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
import Vue from 'vue'
2-
import example from './example-usage.vue'
1+
import { createApp } from 'vue';
2+
import example from './example-usage.vue';
33

4-
Vue.config.productionTip = false
5-
6-
new Vue({
7-
render: h => h(example),
8-
}).$mount('#app')
4+
const app = createApp(example)
5+
app.mount('#app');

light/package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
"build:unpkg": "yarn rollup --config build/rollup.config.js --format iife --file dist/light.min.js"
2222
},
2323
"dependencies": {
24-
"@vue-js-cron/core": "2.1.1"
25-
},
26-
"devDependencies": {
27-
"@vue/cli-service": "^4.5.15",
28-
"rollup-plugin-css-only": "^3.1.0"
24+
"@vue-js-cron/core": "^2.1.1"
2925
},
26+
"devDependencies": {},
3027
"files": [
3128
"package.json",
3229
"dist",

light/src/CronEditor.vue

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11

22
<template>
3-
<CronCore v-bind="$attrs" @input="$emit('input', $event)" @error="$emit('error', $event)">
4-
<template #default="{fields, period}">
5-
6-
<span class="vcron-editor">
7-
<span>{{period.prefix}}</span>
8-
<custom-select v-bind="period.attrs" v-on="period.events" :items="period.items" item-value="id" :cols="cols('period')" :width="width('period')" />
9-
<span>{{period.suffix}}</span>
10-
11-
12-
<template v-for="f in fields">
13-
<span :key="f.id+'prefix'">{{f.prefix}}</span>
14-
<custom-select v-bind="f.attrs" v-on="f.events" :items="f.items" :key="f.id" :cols="cols(f.id)" :width="width(f.id)" multiple>{{f.selectedStr}}</custom-select>
15-
<span :key="f.id+'suffix'">{{f.suffix}}</span>
16-
</template>
17-
18-
</span>
19-
20-
</template>
3+
<CronCore v-bind="$attrs" @update:value="$emit('update:value', $event)" @error="$emit('error', $event)" v-slot="{fields, period}">
4+
<span class="vcron-editor">
5+
<span>{{period.prefix}}</span>
6+
<custom-select v-bind="period.attrs" v-on="period.events" :items="period.items" item-value="id" :cols="cols('period')" :width="width('period')" />
7+
<span>{{period.suffix}}</span>
8+
9+
10+
<template v-for="f in fields" :key="f.id">
11+
<span>{{f.prefix}}</span>
12+
<custom-select v-bind="f.attrs" v-on="f.events" :items="f.items" :cols="cols(f.id)" :width="width(f.id)" multiple>{{f.selectedStr}}</custom-select>
13+
<span>{{f.suffix}}</span>
14+
</template>
15+
</span>
2116
</CronCore>
22-
2317
</template>
2418

2519
<script>
@@ -53,6 +47,7 @@ export default {
5347
else return 'unset'
5448
}
5549
}
56-
}
50+
},
51+
emits:['update:value', 'error']
5752
}
5853
</script>

light/src/components/CustomSelect.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ export default {
3030
default: false
3131
},
3232
value: {
33-
type: String | Array | Object,
34-
default(){
35-
return this.multiple ? [] : null
33+
type: [String, Array, Object],
34+
default(props){
35+
return props.multiple ? [] : null
3636
},
3737
},
3838
items: {

0 commit comments

Comments
 (0)