Commit 08b9a525 authored by Jean Rabreau's avatar Jean Rabreau
Browse files

️switch from moment library to date-fns

parent 740f6496
{
"name": "@vue-unistra/unistra-formbuilder",
"version": "2.0.6-test",
"version": "2.0.14-test",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......@@ -2637,6 +2637,11 @@
}
}
},
"date-fns": {
"version": "2.19.0",
"resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.19.0.tgz",
"integrity": "sha512-X3bf2iTPgCAQp9wvjOQytnf5vO5rESYRXlPIVcgSbtT5OTScPcsf9eZU+B/YIkKAtYr5WeCii58BgATrNitlWg=="
},
"de-indent": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/de-indent/-/de-indent-1.0.2.tgz",
......@@ -4732,11 +4737,6 @@
"minimist": "^1.2.5"
}
},
"moment": {
"version": "2.29.1",
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.1.tgz",
"integrity": "sha512-kHmoybcPV8Sqy59DwNDY3Jefr64lK/by/da0ViFcuA4DH0vQg5Q6Ze5VimxkfQNSC+Mls/Kx53s7TjP1RhFEDQ=="
},
"ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
......@@ -7823,9 +7823,9 @@
"dev": true
},
"vue-template-compiler": {
"version": "2.6.11",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.11.tgz",
"integrity": "sha512-KIq15bvQDrcCjpGjrAhx4mUlyyHfdmTaoNfeoATHLAiWB+MU3cx4lOzMwrnUh9cCxy0Lt1T11hAFY6TQgroUAA==",
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/vue-template-compiler/-/vue-template-compiler-2.6.12.tgz",
"integrity": "sha512-OzzZ52zS41YUbkCBfdXShQTe69j1gQDZ9HIX8miuC9C3rBCk9wIRjLiZZLrmX9V+Ftq/YEyv1JaVr5Y/hNtByg==",
"dev": true,
"requires": {
"de-indent": "^1.0.2",
......
......@@ -17,8 +17,8 @@
"lint:config": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"
},
"dependencies": {
"date-fns": "^2.19.0",
"lodash": "^4.17.20",
"moment": "^2.24.0",
"normalizr": "^3.5.0",
"tiptap": "^1.26.6",
"tiptap-extensions": "^1.28.6",
......@@ -35,11 +35,11 @@
"prettier": "^2.2.1",
"rollup-plugin-vue": "5.1.9",
"rollup-plugin-vuetify": "^0.2.4",
"vue-template-compiler": "^2.6.11",
"vue-template-compiler": "^2.6.12",
"vuetify-loader": "^1.4.3"
},
"peerDependencies": {
"vue": "^2.6.11",
"vue": "^2.6.12",
"vuetify": "^2.2.18",
"vuex": "^3.0.1"
}
......
......@@ -52,7 +52,7 @@
</template>
<script>
import moment from 'moment';
import { add, format } from 'date-fns/fp';
import {
usfFieldMixin,
......@@ -87,14 +87,10 @@ export default {
return `${this.field.type}Picker`;
},
dateMin() {
return this.field.minValue && this.field.minUnit
? moment().subtract(this.field.minValue, this.field.minUnit).format('YYYY-MM-DD')
: undefined;
return this.getDateFromDelta(-this.field.minValue, this.field.minUnit);
},
dateMax() {
return this.field.maxValue && this.field.maxUnit
? moment().add(this.field.maxValue, this.field.maxUnit).format('YYYY-MM-DD')
: undefined;
return this.getDateFromDelta(this.field.maxValue, this.field.maxUnit);
},
},
watch: {
......@@ -110,6 +106,16 @@ export default {
}
},
},
methods: {
getDateFromDelta(delta, unit) {
if (delta && unit) {
const duration = {};
duration[unit] = delta;
return format('yyyy-MM-dd')(add(duration)(new Date()));
}
return undefined;
},
},
};
</script>
......
......@@ -146,10 +146,10 @@ export default {
{ label: 'GB', value: 1073741824 },
],
dateUnitOptions: [
{ value: 'd', label: 'Days' },
{ value: 'w', label: 'Weeks' },
{ value: 'M', label: 'Months' },
{ value: 'y', label: 'Years' },
{ value: 'days', label: 'Days' },
{ value: 'weeks', label: 'Weeks' },
{ value: 'months', label: 'Months' },
{ value: 'years', label: 'Years' },
],
dateMinErrorMessages: [],
dateMaxErrorMessages: [],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment