@bildvitta/quasar-ui-asteroid 2.19.0 → 2.22.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.22.0",
4
4
  "description": "",
5
5
  "main": "./src/index.js",
6
6
  "scripts": {
@@ -48,6 +48,12 @@ export default {
48
48
  }
49
49
  },
50
50
 
51
+ computed: {
52
+ labelValue () {
53
+ return this.hideLabel ? '' : this.label
54
+ }
55
+ },
56
+
51
57
  methods: {
52
58
  onClick (item) {
53
59
  if (typeof item.handler === 'function') {
@@ -55,12 +61,6 @@ export default {
55
61
  item.handler(filtered)
56
62
  }
57
63
  }
58
- },
59
-
60
- computed: {
61
- labelValue () {
62
- return this.hideLabel ? '' : this.label
63
- }
64
64
  }
65
65
  }
66
66
  </script>
@@ -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
  }
@@ -121,11 +121,17 @@ export default {
121
121
  this.$router.push({ query })
122
122
  },
123
123
 
124
- async fetchList () {
124
+ async fetchList (externalPayload = {}) {
125
125
  this.isFetching = true
126
126
 
127
+ const payload = {
128
+ ...this.context,
129
+ url: this.url,
130
+ ...externalPayload
131
+ }
132
+
127
133
  try {
128
- const response = await this.$store.dispatch(`${this.entity}/fetchList`, { ...this.context, url: this.url })
134
+ const response = await this.$store.dispatch(`${this.entity}/fetchList`, payload)
129
135
  const { errors, fields, metadata } = response.data
130
136
 
131
137
  this.setErrors(errors)
@@ -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 () {
@@ -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>
@@ -15,7 +15,7 @@
15
15
  </template>
16
16
  </qas-uploader>
17
17
 
18
- <qas-dialog v-model="isOpenedDialog" v-bind="defaultDialogProps" >
18
+ <qas-dialog v-model="isOpenedDialog" v-bind="defaultDialogProps">
19
19
  <template #header>
20
20
  <div class="text-bold text-center">Insira sua assinatura digital no campo abaixo</div>
21
21
  </template>
@@ -43,14 +43,14 @@ import { base64ToBlob } from '../../helpers'
43
43
  import { NotifyError } from '../../plugins'
44
44
 
45
45
  export default {
46
- mixins: [screenMixin],
47
-
48
46
  components: {
49
47
  QasDialog,
50
48
  QasUploader,
51
49
  QasSignaturePad
52
50
  },
53
51
 
52
+ mixins: [screenMixin],
53
+
54
54
  props: {
55
55
  dialogProps: {
56
56
  type: Object,
@@ -70,11 +70,17 @@ export default {
70
70
  },
71
71
 
72
72
  methods: {
73
- async fetchSingle () {
73
+ async fetchSingle (externalPayload = {}) {
74
74
  this.isFetching = true
75
75
 
76
+ const payload = {
77
+ id: this.id,
78
+ url: this.url,
79
+ ...externalPayload
80
+ }
81
+
76
82
  try {
77
- const response = await this.$store.dispatch(`${this.entity}/fetchSingle`, { id: this.id, url: this.url })
83
+ const response = await this.$store.dispatch(`${this.entity}/fetchSingle`, payload)
78
84
  const { errors, fields, metadata } = response.data
79
85
 
80
86
  this.setErrors(errors)
@@ -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 = {}) {