@tagplus/components 4.1.0 → 4.3.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/dist/tp.common.js +1 -1
- package/dist/tp.common.js.map +1 -1
- package/dist/tp.css +11 -11
- package/dist/tp.umd.js +1 -1
- package/dist/tp.umd.js.map +1 -1
- package/dist/tp.umd.min.js +1 -1
- package/dist/tp.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/scss/_helpers.scss +0 -12
- package/src/components/Tip/Tip.vue +25 -35
- package/src/mixins/floatFormatter.js +8 -4
- package/src/utils/currency.js +11 -5
package/package.json
CHANGED
|
@@ -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
|
-
<
|
|
29
|
+
<el-row
|
|
30
30
|
v-else
|
|
31
|
-
:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
|
package/src/utils/currency.js
CHANGED
|
@@ -21,7 +21,7 @@ function format (input, opt = defaults) {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
function unformat (input, precision = defaults.precision) {
|
|
24
|
-
const negative = (`${
|
|
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,16 @@ 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 = (`${
|
|
40
|
+
function formatMoney (input, toString = false, locale = defaults, customPrecision = false) {
|
|
41
|
+
let inputString = (`${input}`)
|
|
42
|
+
|
|
43
|
+
// Caso componente receba props de precisão customizada (ex.: tp-money com precisão diferente da locale padrão).
|
|
44
|
+
if (customPrecision) {
|
|
45
|
+
locale.number.precision = customPrecision
|
|
46
|
+
}
|
|
41
47
|
|
|
42
48
|
// Impede de digitar . ou , porque o formatador já adiciona
|
|
43
49
|
if ((inputString.slice(-1).match(/[.,]/))) {
|
|
@@ -50,12 +56,12 @@ function formatMoney (input, toString = false, locale = defaults) {
|
|
|
50
56
|
input = completeZeros(inputString, locale)
|
|
51
57
|
}
|
|
52
58
|
|
|
53
|
-
const precision = locale.number.precision
|
|
59
|
+
const precision = customPrecision || locale.number.precision
|
|
54
60
|
const numbers = onlyNumbers(input, precision)
|
|
55
61
|
const currency = numbersToCurrency(numbers, precision)
|
|
56
62
|
|
|
57
63
|
if (toString) {
|
|
58
|
-
let num = negative === -1 ? `-${
|
|
64
|
+
let num = negative === -1 ? `-${currency}` : `${currency}`
|
|
59
65
|
|
|
60
66
|
if (locale?.number?.decimal) {
|
|
61
67
|
const decimalChar = locale?.number?.decimal
|