@tagplus/components 0.2.103 → 0.2.106

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
@@ -7,7 +7,7 @@
7
7
  "email": "bruno@tagplus.com.br"
8
8
  }
9
9
  ],
10
- "version": "0.2.103",
10
+ "version": "0.2.106",
11
11
  "main": "./dist/tp.common.js",
12
12
  "directories": {
13
13
  "lib": "src/lib"
@@ -302,11 +302,7 @@ export default {
302
302
  } else if (this.value && typeof this.value === 'object') {
303
303
  if (!this.value[this.valueKey]) {
304
304
  if (process.env.DEBUG === 'true') {
305
- throw new TypeError(
306
- 'Autosuggest this.value doesn\'t have a valueKey \'' +
307
- this.valueKey +
308
- '\' key'
309
- )
305
+ console.error(`Autosuggest '${this.$options.name}' option doesn't have a valueKey '${this.valueKey}' key`)
310
306
  }
311
307
  } else {
312
308
  newVal = this.value[this.valueKey]
@@ -462,12 +458,7 @@ export default {
462
458
  } else if (val && typeof val === 'object') {
463
459
  // Se val for Object converte para outro tipo
464
460
  if (!this.value[this.valueKey]) {
465
- // eslint-disable-next-line
466
- console.log(
467
- 'Autosuggest this.value doesn\'t have a valueKey \'' +
468
- this.valueKey +
469
- '\' key'
470
- )
461
+ console.error(`Autosuggest '${this.$options.name}' option doesn't have a valueKey '${this.valueKey}' key`)
471
462
  } else {
472
463
  // Se mandou a label no objeto value
473
464
  if (this.value[this.labelKey]) {
@@ -0,0 +1,67 @@
1
+ <script>
2
+ import { InputNumber } from 'element-ui'
3
+
4
+ export default {
5
+ name: 'TpInputNumber',
6
+
7
+ extends: InputNumber,
8
+
9
+ props: {
10
+ usarVirgula: {
11
+ type: Boolean,
12
+ default: true
13
+ }
14
+ },
15
+
16
+ computed: {
17
+ displayValue() {
18
+ if (this.userInput !== null) {
19
+ return this.userInput
20
+ }
21
+ let currentValue = this.currentValue
22
+
23
+ if (typeof currentValue === 'number') {
24
+ if (this.stepStrictly) {
25
+ const stepPrecision = this.getPrecision(this.step)
26
+ const precisionFactor = Math.pow(10, stepPrecision)
27
+ currentValue =
28
+ (Math.round(currentValue / this.step) *
29
+ precisionFactor *
30
+ this.step) /
31
+ precisionFactor
32
+ }
33
+
34
+ if (this.precision !== undefined) {
35
+ currentValue = currentValue.toFixed(this.precision)
36
+ }
37
+ }
38
+
39
+ if (this.usarVirgula) {
40
+ currentValue = (currentValue + '').replace('.', ',')
41
+ }
42
+ return currentValue
43
+ }
44
+ },
45
+
46
+ methods: {
47
+ handleInput(value) {
48
+ this.userInput = value
49
+ this.$emit('change', Number(value.replace(',', '.')))
50
+ },
51
+
52
+ handleInputChange(value) {
53
+ let newVal
54
+ if (value === '') {
55
+ newVal = undefined
56
+ } else {
57
+ newVal = Number(value.replace(',', '.'))
58
+ }
59
+
60
+ if (!isNaN(newVal) || value === '') {
61
+ this.setCurrentValue(newVal)
62
+ }
63
+ this.userInput = null
64
+ }
65
+ }
66
+ }
67
+ </script>
@@ -0,0 +1,3 @@
1
+ import InputNumber from './InputNumber'
2
+
3
+ export default InputNumber
@@ -368,7 +368,7 @@ export default {
368
368
  this.value.forEach((item) => {
369
369
  if (!item[this.valueKey]) {
370
370
  if (process.env.DEBUG === 'true') {
371
- throw new TypeError('Autosuggest this.value doesn\'t have a valueKey \'' + this.valueKey + '\' key')
371
+ console.error(`Multisuggest '${this.$options.name}' option doesn't have a valueKey '${this.valueKey}' key`)
372
372
  }
373
373
  }
374
374
  })
@@ -530,7 +530,7 @@ export default {
530
530
  else if (val && typeof val === 'object') {
531
531
  // Se val for Object converte para outro tipo
532
532
  if (!val[this.valueKey]) {
533
- throw new TypeError('Multisuggest option doesn\'t have a valueKey \'' + this.valueKey + '\' key')
533
+ console.error(`Multisuggest '${this.$options.name}' option doesn't have a valueKey '${this.valueKey}' key`)
534
534
  } else {
535
535
  // Se mandou a label no objeto value
536
536
  if (val[this.labelKey]) {
@@ -8,6 +8,7 @@ import Loader from './Loader'
8
8
  import Skeleton from './Skeleton'
9
9
  import Tip from './Tip'
10
10
  import Multisuggest from './Multisuggest'
11
+ import InputNumber from './InputNumber'
11
12
 
12
13
  export {
13
14
  Autosuggest,
@@ -19,5 +20,6 @@ export {
19
20
  Loader,
20
21
  Skeleton,
21
22
  Tip,
22
- Multisuggest
23
+ Multisuggest,
24
+ InputNumber
23
25
  }