@bildvitta/quasar-ui-asteroid 2.20.0 → 2.21.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.20.0",
3
+ "version": "2.21.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <q-input ref="mask" v-model="model" v-bind="$attrs" bottom-slots :mask="mask" unmasked-value v-on="listeners">
3
+ <q-input ref="mask" v-model="model" v-bind="$attrs" bottom-slots :mask="mask" unmasked-value v-on="listeners" @paste="onPaste">
4
4
  <slot v-for="(slot, key) in $slots" :slot="key" :name="key" />
5
5
  <template v-for="(slot, key) in $scopedSlots" :slot="key" slot-scope="scope">
6
6
  <slot :name="key" v-bind="scope" />
@@ -65,7 +65,7 @@ export default {
65
65
 
66
66
  watch: {
67
67
  mask () {
68
- const input = this.$refs.mask.$refs.input
68
+ const input = this.getInput()
69
69
 
70
70
  requestAnimationFrame(() => {
71
71
  input.selectionStart = input.value ? input.value.length : ''
@@ -75,6 +75,8 @@ export default {
75
75
 
76
76
  methods: {
77
77
  toggleMask (first, second) {
78
+ if (!this.value.length) return
79
+
78
80
  const length = first.split('#').length - 2
79
81
  return this.value?.length > length ? second : first
80
82
  },
@@ -89,6 +91,22 @@ export default {
89
91
 
90
92
  resetValidation () {
91
93
  return this.inputReference.resetValidation()
94
+ },
95
+
96
+ onPaste (event) {
97
+ if (!this.mask) return
98
+
99
+ const value = event.clipboardData.getData('text')
100
+ const input = this.getInput()
101
+
102
+ requestAnimationFrame(() => {
103
+ this.$emit('input', value)
104
+ input.selectionStart = input.value ? input.value.length : ''
105
+ })
106
+ },
107
+
108
+ getInput () {
109
+ return this.inputReference.$el?.querySelector('input')
92
110
  }
93
111
  }
94
112
  }
@@ -68,7 +68,6 @@ import QasLabel from '../label/QasLabel'
68
68
  import { constructObject } from '../../helpers'
69
69
 
70
70
  import { extend } from 'quasar'
71
- import { camelize } from 'humps'
72
71
 
73
72
  export default {
74
73
  name: 'QasNestedFields',
@@ -213,13 +212,7 @@ export default {
213
212
  },
214
213
 
215
214
  children () {
216
- const field = extend(true, {}, this.field)
217
-
218
- for (const key in field?.children) {
219
- field.children[key].name = camelize(field?.children[key].name)
220
- }
221
-
222
- return field?.children
215
+ return this.field?.children
223
216
  },
224
217
 
225
218
  showDestroyBtn () {
@@ -0,0 +1,15 @@
1
+ import { camelize } from 'humps'
2
+
3
+ export default function camelizeFieldsName (fields) {
4
+ for (const field in fields) {
5
+ const currentField = fields[field]
6
+
7
+ currentField.name = camelize(currentField.name)
8
+
9
+ if (Object.keys(currentField.children || {}).length) {
10
+ camelizeFieldsName(currentField.children)
11
+ }
12
+ }
13
+
14
+ return fields
15
+ }
@@ -1,4 +1,5 @@
1
1
  import base64ToBlob from './base64ToBlob.js'
2
+ import camelizeFieldsName from './camelize-fields-name.js'
2
3
  import constructObject from './constructObject.js'
3
4
  import filterObject from './filter-object.js'
4
5
  import greatestCommonDivisor from './greatestCommonDivisor.js'
@@ -31,6 +32,7 @@ export {
31
32
  // filters
32
33
  asset,
33
34
  booleanLabel,
35
+ camelizeFieldsName,
34
36
  constructObject,
35
37
  date,
36
38
  dateTime,
@@ -1,5 +1,6 @@
1
1
  import { camelize } from 'humps'
2
2
  import { get } from 'lodash'
3
+ import { camelizeFieldsName } from '../helpers'
3
4
 
4
5
  import { NotifyError } from '../plugins'
5
6
 
@@ -64,11 +65,7 @@ export default {
64
65
  },
65
66
 
66
67
  setFields (fields = {}) {
67
- for (const field in fields) {
68
- fields[field].name = camelize(fields[field].name)
69
- }
70
-
71
- this.fields = fields
68
+ this.fields = camelizeFieldsName(fields)
72
69
  },
73
70
 
74
71
  setMetadata (metadata = {}) {