@bildvitta/quasar-ui-asteroid 2.19.0 → 2.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bildvitta/quasar-ui-asteroid",
3
- "version": "2.19.0",
3
+ "version": "2.20.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -44,13 +44,23 @@ export default {
44
44
 
45
45
  // Events
46
46
  input: {
47
- description: 'Emitted when the component needs to change the model. Is also used by `v-model`.',
47
+ description: 'Emitted when the component needs to change the value.',
48
48
  table: {
49
49
  defaultValue: {
50
50
  detail: JSON.stringify({ value: 'number' }),
51
51
  summary: '{}'
52
52
  }
53
53
  }
54
+ },
55
+
56
+ 'update-model': {
57
+ description: 'Emitted when the user inputs a new value in the component.',
58
+ table: {
59
+ defaultValue: {
60
+ detail: JSON.stringify({ value: 'object' }),
61
+ summary: '{}'
62
+ }
63
+ }
54
64
  }
55
65
  }
56
66
  }
@@ -1,8 +1,8 @@
1
1
  <template>
2
2
  <div>
3
- <q-field v-model="model" v-bind="$attrs">
4
- <template #control="{ emitValue, floatingLabel, id, value: modelValue }">
5
- <input v-show="floatingLabel" :id="id" ref="input" class="q-field__input" :model-value="modelValue" @input="emitValue($event.target.value)">
3
+ <q-field :value="value" v-bind="$attrs">
4
+ <template #control="{ floatingLabel, id }">
5
+ <input v-show="floatingLabel" :id="id" ref="input" class="q-field__input" @blur="emitValue" @click="setSelect" @input="emitUpdateModel($event.target.value)">
6
6
  </template>
7
7
  </q-field>
8
8
  </div>
@@ -66,15 +66,13 @@ export default {
66
66
  computed: {
67
67
  defaultMode () {
68
68
  return defaultModes[this.mode]
69
- },
70
-
71
- model: {
72
- get () {
73
- return this.value
74
- },
69
+ }
70
+ },
75
71
 
76
- set () {
77
- this.$emit('input', this.autoNumeric.getNumber())
72
+ watch: {
73
+ value (value) {
74
+ if (this.autoNumeric) {
75
+ this.autoNumeric.set(value)
78
76
  }
79
77
  }
80
78
  },
@@ -110,13 +108,30 @@ export default {
110
108
  Object.assign(options, this.autonumericProps)
111
109
 
112
110
  this.$nextTick(() => {
113
- this.$refs.input.value = this.value
114
111
  this.autoNumeric = new AutoNumeric(this.$refs.input, options)
112
+ this.autoNumeric.set(this.value)
115
113
  })
116
114
  },
117
115
 
118
116
  beforeDestroy () {
119
117
  this.autoNumeric.remove()
118
+ },
119
+
120
+ methods: {
121
+ setSelect () {
122
+ this.$refs?.input?.select()
123
+ },
124
+
125
+ emitValue () {
126
+ this.$emit('input', this.autoNumeric.getNumber())
127
+ },
128
+
129
+ emitUpdateModel (value) {
130
+ this.$emit('update-model', {
131
+ value,
132
+ raw: this.autoNumeric.getNumber()
133
+ })
134
+ }
120
135
  }
121
136
  }
122
137
  </script>