Skip to content

Vue 3 compatible #53

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/components/VueAutonumeric.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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 = {
Expand All @@ -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;
Expand Down Expand Up @@ -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
},
Expand Down
11 changes: 5 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}