From 1a9859eb1098b861229a5ff2f94cc9592e87db09 Mon Sep 17 00:00:00 2001 From: Eric Johansson Date: Fri, 2 Oct 2020 15:11:41 +0200 Subject: [PATCH 1/5] Changed breaking approach in index.js, added install function for vue 3 compatibility --- src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 68b20e3..951736e 100644 --- a/src/index.js +++ b/src/index.js @@ -8,4 +8,8 @@ if (typeof window !== 'undefined' && window.Vue) { export { VueAutonumeric }; -export default VueAutonumeric; +export default { + install (app) { + app.component('vue-autonumeric', VueAutonumeric) + } +} \ No newline at end of file From 022afe08922b284e1ae609211ce1a7ff42ea25b4 Mon Sep 17 00:00:00 2001 From: Eric Johansson Date: Fri, 2 Oct 2020 15:16:03 +0200 Subject: [PATCH 2/5] Imported h function from vue and updated render funktion in VueAutonumeric.vue for vue 3 compatibility --- src/components/VueAutonumeric.vue | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/VueAutonumeric.vue b/src/components/VueAutonumeric.vue index 7bdad10..1253055 100644 --- a/src/components/VueAutonumeric.vue +++ b/src/components/VueAutonumeric.vue @@ -62,7 +62,10 @@ OTHER DEALINGS IN THE SOFTWARE. * :options="{ digitGroupSeparator: '.', decimalCharacter: ',', decimalCharacterAlternative: '.', currencySymbol: '\u00a0€', currencySymbolPlacement: 's', roundingMethod: 'U', minimumValue: '0' }" * :value="42042.69" * /> - */ + */ + import { h } from 'vue' + + export default { //TODO If an html value attribute is set in the source, then the 'linked' component sharing the same v-model are not updated with the value nor formatted on load (it takes precedence over the changes made by other inputs, and always keep `value` to the initial value) name: 'VueAutonumeric', @@ -74,7 +77,7 @@ OTHER DEALINGS IN THE SOFTWARE. * @param {function} createElement * @returns {*} */ - render(createElement) { + render() { const isInput = this.tag === 'input'; let attributes; @@ -89,7 +92,7 @@ OTHER DEALINGS IN THE SOFTWARE. }; } - return createElement(this.tag, { + return h(this.tag, { attrs: attributes, ref : 'autoNumericElement', on : { From 6700faac06ae7cd704eaf907f4c3266a3548cf93 Mon Sep 17 00:00:00 2001 From: Eric Johansson Date: Fri, 2 Oct 2020 15:18:42 +0200 Subject: [PATCH 3/5] Changed name of prop object from 'value' to 'modelValue', since 'value' is breaking in vue 3 --- src/components/VueAutonumeric.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/VueAutonumeric.vue b/src/components/VueAutonumeric.vue index 1253055..e516eb8 100644 --- a/src/components/VueAutonumeric.vue +++ b/src/components/VueAutonumeric.vue @@ -102,7 +102,7 @@ OTHER DEALINGS IN THE SOFTWARE. }, props: { - value: { + modelValue: { required: false, validator(val) { return typeof val === 'number' || typeof val === 'string' || val === '' || val === null; @@ -176,7 +176,7 @@ OTHER DEALINGS IN THE SOFTWARE. mounted() { // Initialize the autoNumeric element this.anElement = new AutoNumeric(this.$refs.autoNumericElement, this.initialOptions); - this.anElement.set(this.value); + this.anElement.set(this.modelValue); // The `v-model` must be updated with that default value on startup this.updateVModel(); //FIXME Send the `event.timeStamp` info here }, From 5be659354ed51cead3c0b1d444cafc02bbcdffca Mon Sep 17 00:00:00 2001 From: Eric Johansson Date: Thu, 22 Oct 2020 15:56:54 +0200 Subject: [PATCH 4/5] cleaner export of component --- src/index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/index.js b/src/index.js index 951736e..866773d 100644 --- a/src/index.js +++ b/src/index.js @@ -2,11 +2,6 @@ import VueAutonumeric from './components/VueAutonumeric.vue'; // Expose component to global scope /* eslint no-undef : 0 */ -if (typeof window !== 'undefined' && window.Vue) { - Vue.component('vue-autonumeric', VueAutonumeric); -} - -export { VueAutonumeric }; export default { install (app) { From 478c714b2798944d1ba6961cfc438928fd636fe7 Mon Sep 17 00:00:00 2001 From: Eric Johansson Date: Fri, 23 Oct 2020 13:41:04 +0200 Subject: [PATCH 5/5] importing h as createElement --- src/components/VueAutonumeric.vue | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/VueAutonumeric.vue b/src/components/VueAutonumeric.vue index e516eb8..bae8889 100644 --- a/src/components/VueAutonumeric.vue +++ b/src/components/VueAutonumeric.vue @@ -65,6 +65,7 @@ OTHER DEALINGS IN THE SOFTWARE. */ import { h } from 'vue' + const createElement = h export default { //TODO If an html value attribute is set in the source, then the 'linked' component sharing the same v-model are not updated with the value nor formatted on load (it takes precedence over the changes made by other inputs, and always keep `value` to the initial value) @@ -80,6 +81,8 @@ OTHER DEALINGS IN THE SOFTWARE. render() { const isInput = this.tag === 'input'; + console.log(h) + let attributes; if (isInput) { attributes = { @@ -92,7 +95,7 @@ OTHER DEALINGS IN THE SOFTWARE. }; } - return h(this.tag, { + return createElement(this.tag, { attrs: attributes, ref : 'autoNumericElement', on : {