@tagplus/components 4.1.0 → 4.3.1

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": "4.1.0",
11
+ "version": "4.3.1",
12
12
  "main": "./dist/tp.common.js",
13
13
  "directories": {
14
14
  "lib": "src/lib"
@@ -92,27 +92,15 @@
92
92
  display: block;
93
93
  }
94
94
 
95
- .flexContent {
96
- display: flex;
97
- }
98
-
99
95
  .justify-between {
100
96
  justify-content: space-between;
101
97
  }
102
98
 
103
- .justify-content-end {
104
- justify-content: end;
105
- }
106
-
107
99
  .text-helper-info {
108
100
  font-size: 13px;
109
101
  color: #565b66;
110
102
  }
111
103
 
112
- .c-pointer {
113
- cursor: pointer;
114
- }
115
-
116
104
  .no-font-weight {
117
105
  font-weight: initial !important;
118
106
  }
@@ -26,43 +26,33 @@
26
26
  />
27
27
  </el-col>
28
28
  </el-row>
29
- <div
29
+ <el-row
30
30
  v-else
31
- :class="closed ? 'c-pointer' : ''"
32
- @click="closed = false"
33
- >
34
- <el-row
35
- :id="`${_id}`"
36
- type="flex"
37
- align="middle"
38
- justify="space-between"
39
- :class="tptipclasses"
31
+ :id="`${_id}`"
32
+ type="flex"
33
+ align="middle"
34
+ justify="space-between"
35
+ :class="tptipclasses">
36
+ <el-col
37
+ :span="17"
40
38
  >
41
- <!-- Titulo -->
42
- <el-col
43
- :span="17"
44
- >
45
- <el-row align="middle" type="flex" style="min-width:25px; margin:15px; padding: auto">
46
- <em class="far fa-lightbulb-on" />
47
- <b class="tp-title">{{ title }}</b>
48
- </el-row>
49
- </el-col>
50
-
51
- <!-- Close/Open Btn -->
52
- <el-col :span="3" class="flexContent justify-content-end">
53
- <em :class="closed ? 'fa fa-plus' : 'fa fa-minus'" class="tp-close-button" @click.stop="closed = !closed" />
54
- </el-col>
55
-
56
- <!-- Texto -->
57
- <el-col :class="'tp-text ' + (closed ? 'tp-vanish' : '' )" :span="24">
58
- <div
59
- :id="`${_id}-text`"
60
- style="margin:15px; margin-left:0px"
61
- v-html="text"
62
- />
63
- </el-col>
64
- </el-row>
65
- </div>
39
+ <el-row align="middle" type="flex" style="min-width:25px; margin:15px; padding: auto">
40
+ <em class="far fa-lightbulb-on" />
41
+ <b class="tp-title">{{ title }}</b>
42
+ </el-row>
43
+ </el-col>
44
+ <el-col :span="3" class="flexContent justify-content-end">
45
+ <em class="fa fa-ellipsis-h tp-close-button" @click="closed = !closed" />
46
+ </el-col>
47
+
48
+ <el-col :class="'tp-text ' + (closed ? 'tp-vanish' : '' )" :span="24">
49
+ <div
50
+ :id="`${_id}-text`"
51
+ style="margin:15px; margin-left:0px"
52
+ v-html="text"
53
+ />
54
+ </el-col>
55
+ </el-row>
66
56
  </template>
67
57
 
68
58
  <script>
@@ -14,6 +14,10 @@ export default {
14
14
  allowEmpty: {
15
15
  type: Boolean,
16
16
  default: false
17
+ },
18
+
19
+ customPrecision: {
20
+ default: false
17
21
  }
18
22
  },
19
23
 
@@ -28,21 +32,21 @@ export default {
28
32
  immediate: true,
29
33
  handler (newValue, oldValue) {
30
34
  if (newValue === '' && this.allowEmpty) { this.formattedValue = ''; return }
31
- this.formattedValue = formatMoney(newValue, true, this.locale)
35
+ this.formattedValue = formatMoney(newValue, true, this.locale, this.customPrecision)
32
36
  }
33
37
  }
34
38
  },
35
39
 
36
40
  methods: {
37
41
  input (evt) {
38
- this.formattedValue = formatMoney(evt, true, this.locale)
39
- const moneyFormatado = formatMoney(evt, false, this.locale)
42
+ this.formattedValue = formatMoney(evt, true, this.locale, this.customPrecision)
43
+ const moneyFormatado = formatMoney(evt, false, this.locale, this.customPrecision)
40
44
 
41
45
  this.$emit('input', moneyFormatado)
42
46
  },
43
47
 
44
48
  handleChange (evt) {
45
- this.$emit('change', formatMoney(evt, false, this.locale))
49
+ this.$emit('change', formatMoney(evt, false, this.locale, this.customPrecision))
46
50
  }
47
51
  }
48
52
 
@@ -21,7 +21,7 @@ function format (input, opt = defaults) {
21
21
  }
22
22
 
23
23
  function unformat (input, precision = defaults.precision) {
24
- const negative = (`${ input}`).indexOf('-') >= 0 ? -1 : 1
24
+ const negative = (`${input}`).indexOf('-') >= 0 ? -1 : 1
25
25
  const numbers = onlyNumbers(input)
26
26
  const currency = numbersToCurrency(numbers, precision)
27
27
 
@@ -34,10 +34,12 @@ function unformat (input, precision = defaults.precision) {
34
34
  * @param {Float} input Valor
35
35
  * @param {Boolean} toString Se o retorno será float ou string
36
36
  * @param {Object} locale Configuração de localidade para saber número de casas decimais (precision) e caracter de decimal (decimal)
37
+ * @param {Number} customPrecision Caso o usuário queira sobrescrever o número de casas decimais (precision) da configuração de localidade.
37
38
  * @returns
38
39
  */
39
- function formatMoney (input, toString = false, locale = defaults) {
40
- let inputString = (`${ input}`)
40
+ function formatMoney (input, toString = false, locale = defaults, customPrecision = false) {
41
+ console.log(' customPrecision-> ', customPrecision)
42
+ let inputString = (`${input}`)
41
43
 
42
44
  // Impede de digitar . ou , porque o formatador já adiciona
43
45
  if ((inputString.slice(-1).match(/[.,]/))) {
@@ -50,12 +52,14 @@ function formatMoney (input, toString = false, locale = defaults) {
50
52
  input = completeZeros(inputString, locale)
51
53
  }
52
54
 
53
- const precision = locale.number.precision
55
+ const precision = customPrecision || locale.number.precision
56
+ console.log(' precision-> ', precision)
57
+
54
58
  const numbers = onlyNumbers(input, precision)
55
59
  const currency = numbersToCurrency(numbers, precision)
56
60
 
57
61
  if (toString) {
58
- let num = negative === -1 ? `-${ currency}` : `${ currency}`
62
+ let num = negative === -1 ? `-${currency}` : `${currency}`
59
63
 
60
64
  if (locale?.number?.decimal) {
61
65
  const decimalChar = locale?.number?.decimal