@tagplus/components 1.2.18 → 1.2.19

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
@@ -8,7 +8,7 @@
8
8
  "email": "bruno@tagplus.com.br"
9
9
  }
10
10
  ],
11
- "version": "1.2.18",
11
+ "version": "1.2.19",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -43,26 +43,25 @@
43
43
  "test:unit": "vue-cli-service test:unit"
44
44
  },
45
45
  "dependencies": {
46
- "@vue/babel-preset-app": "^5.0.8",
47
- "axios": "^0.27.2",
46
+ "axios": "^0.27.0",
48
47
  "core-js": "^3.21.1",
49
48
  "element-theme-chalk": "^2.13",
50
49
  "element-ui": "2.15.8",
51
50
  "js-cookie": "^3.0.1",
52
- "vue": "^2.7.10",
51
+ "vue": "^2.6.14",
53
52
  "vue-axios": "^2.1.5",
54
53
  "vue-i18n": "^8.14.0"
55
54
  },
56
55
  "devDependencies": {
57
- "@babel/core": "^7.18.13",
58
- "@babel/eslint-parser": "^7.18.9",
59
- "@vue/cli-plugin-babel": "^5.0.8",
60
- "@vue/cli-plugin-unit-jest": "^5.0.8",
61
- "@vue/cli-service": "^5.0.8",
56
+ "@babel/core": "^7.18.5",
57
+ "@babel/eslint-parser": "^7.17.0",
58
+ "@vue/cli-plugin-babel": "^5.0.3",
59
+ "@vue/cli-plugin-unit-jest": "^5.0.3",
60
+ "@vue/cli-service": "^5.0.3",
62
61
  "@vue/test-utils": "^1.0.0-beta.31",
63
62
  "@vuese/cli": "^2.10.0",
64
63
  "babel-jest": "^24.9.0",
65
- "babel-plugin-module-resolver": "^4.1.0",
64
+ "babel-plugin-module-resolver": "^3.2.0",
66
65
  "babel-plugin-require-context-hook": "^1.0.0",
67
66
  "eslint": "^8.9.0",
68
67
  "eslint-config-prettier": "^8.4.0",
@@ -74,10 +73,10 @@
74
73
  "eslint-plugin-promise": "^6.0.0",
75
74
  "eslint-plugin-vue": "^9.1.1",
76
75
  "node-sass": "^4.14.1",
77
- "nodemon": "^2.0.19",
78
- "prettier": "^2.7.1",
76
+ "nodemon": "^2.0.2",
77
+ "prettier": "^2.5.1",
79
78
  "sass-loader": "^7.1.0",
80
- "vue-template-compiler": "^2.7.10",
79
+ "vue-template-compiler": "^2.6.10",
81
80
  "webpack": "4.46.0"
82
81
  }
83
82
  }
@@ -308,9 +308,17 @@ export default {
308
308
  this.setCurrentValue(newVal)
309
309
  },
310
310
  handleBlur (event) {
311
+ if (!this.value && this.stringDefaultsZero && !this.precision) {
312
+ this.currentValue = 0
313
+ }
314
+
311
315
  this.$emit('blur', event)
312
316
  },
313
317
  handleFocus (event) {
318
+ if (!this.value && !this.precision) {
319
+ this.currentValue = ''
320
+ }
321
+
314
322
  this.$emit('focus', event)
315
323
  },
316
324
 
@@ -33,19 +33,12 @@ function unformat (input, precision = defaults.precision) {
33
33
  * @returns
34
34
  */
35
35
  function formatMoney (input, toString = false, locale = defaults) {
36
- let inputString = ('' + input)
37
- // Impede de digitar . ou , porque o formatador já adiciona
38
- if ((inputString.slice(-1).match(/[.,]/))) {
39
- inputString = inputString.substring(0, inputString.length - 1)
40
- }
41
-
42
- const negative = inputString.indexOf('-') >= 0 ? -1 : 1
36
+ const negative = ('' + input).indexOf('-') >= 0 ? -1 : 1
37
+ const precision = locale.number.precision
43
38
 
44
39
  if (toString) {
45
- input = completeZeros(inputString, locale)
40
+ input = completeZeros(('' + input), precision)
46
41
  }
47
-
48
- const precision = locale.number.precision
49
42
  const numbers = onlyNumbers(input, precision)
50
43
  const currency = numbersToCurrency(numbers, precision)
51
44
  if (toString) {
@@ -61,17 +54,13 @@ function formatMoney (input, toString = false, locale = defaults) {
61
54
  }
62
55
  }
63
56
 
64
- function completeZeros (input, locale) {
65
- const precision = locale?.number?.precision || defaults.precision
66
- const decimal = locale?.number?.decimal || defaults.decimal
67
- let i = input.lastIndexOf('.')
68
- const j = input.lastIndexOf(',')
69
- i = i > j ? i : j
57
+ function completeZeros (input, precision = defaults.precision) {
58
+ const i = input.indexOf('.')
70
59
  const qntDecimais = i ? input.length - i - 1 : 0
71
60
 
72
61
  // correção para decimal quebrado
73
62
  if (i === -1) {
74
- input = input + decimal + '0'.repeat(precision)
63
+ input = input + '.' + '0'.repeat(precision)
75
64
  } else if (i && qntDecimais < precision) {
76
65
  input = input + '0'.repeat(precision - qntDecimais)
77
66
  }