diff --git a/src/components/VueAutonumeric.vue b/src/components/VueAutonumeric.vue index 7bdad10..e516eb8 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 : { @@ -99,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; @@ -173,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 }, 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