diff --git a/src/components/VueAutonumeric.vue b/src/components/VueAutonumeric.vue index 7bdad10..bae8889 100644 --- a/src/components/VueAutonumeric.vue +++ b/src/components/VueAutonumeric.vue @@ -62,7 +62,11 @@ OTHER DEALINGS IN THE SOFTWARE. * :options="{ digitGroupSeparator: '.', decimalCharacter: ',', decimalCharacterAlternative: '.', currencySymbol: '\u00a0€', currencySymbolPlacement: 's', roundingMethod: 'U', minimumValue: '0' }" * :value="42042.69" * /> - */ + */ + 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) name: 'VueAutonumeric', @@ -74,9 +78,11 @@ OTHER DEALINGS IN THE SOFTWARE. * @param {function} createElement * @returns {*} */ - render(createElement) { + render() { const isInput = this.tag === 'input'; + console.log(h) + let attributes; if (isInput) { attributes = { @@ -99,7 +105,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 +179,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..866773d 100644 --- a/src/index.js +++ b/src/index.js @@ -2,10 +2,9 @@ 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 VueAutonumeric; +export default { + install (app) { + app.component('vue-autonumeric', VueAutonumeric) + } +} \ No newline at end of file