@ecomplus/storefront-components 1.0.0-beta.194 → 1.0.0-beta.195
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/CHANGELOG.md +4 -0
- package/LICENSE +21 -0
- package/dist/1.storefront-components.min.js.map +1 -1
- package/dist/2.storefront-components.min.js.map +1 -1
- package/dist/3.storefront-components.min.js.map +1 -1
- package/dist/storefront-components.min.js.map +1 -1
- package/package.json +3 -2
- package/src/js/InputDocNumber.js +20 -16
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecomplus/storefront-components",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.195",
|
|
4
4
|
"description": "Vue components for E-Com Plus Storefront",
|
|
5
5
|
"main": "dist/storefront-components.min.js",
|
|
6
6
|
"scripts": {
|
|
@@ -49,5 +49,6 @@
|
|
|
49
49
|
"vue": "2.6.14",
|
|
50
50
|
"vue-cleave-component": "^2.1.3",
|
|
51
51
|
"vue-social-sharing": "^3.0.9"
|
|
52
|
-
}
|
|
52
|
+
},
|
|
53
|
+
"gitHead": "7bd93207fb4aabba3ee8811f764db781771e227f"
|
|
53
54
|
}
|
package/src/js/InputDocNumber.js
CHANGED
|
@@ -22,37 +22,40 @@ export default {
|
|
|
22
22
|
type: [String, Number],
|
|
23
23
|
required: true
|
|
24
24
|
},
|
|
25
|
-
isCompany: Boolean
|
|
25
|
+
isCompany: Boolean,
|
|
26
|
+
allowBoth: Boolean
|
|
26
27
|
},
|
|
27
28
|
|
|
28
29
|
computed: {
|
|
29
30
|
placeholder () {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
if (countryCode === 'BR') {
|
|
32
|
+
if (this.allowBoth) return 'CPF / CNPJ'
|
|
33
|
+
return this.isCompany ? 'CNPJ' : 'CPF'
|
|
34
|
+
}
|
|
35
|
+
return i18n(i19docNumber)
|
|
35
36
|
},
|
|
36
37
|
|
|
37
38
|
pattern () {
|
|
38
39
|
if (countryCode === 'BR') {
|
|
39
|
-
if (this.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return '[\\d]{3}\\..{10}'
|
|
43
|
-
}
|
|
40
|
+
if (this.allowBoth) return '[\\d]{11}|[\\d]{14}'
|
|
41
|
+
if (this.isCompany) return '[\\d]{2}\\..{15}'
|
|
42
|
+
return '[\\d]{3}\\..{10}'
|
|
44
43
|
}
|
|
45
44
|
return '[\\d]+{9,19}'
|
|
46
45
|
},
|
|
47
46
|
|
|
48
47
|
isInvalid () {
|
|
49
48
|
if (countryCode === 'BR') {
|
|
50
|
-
const docNumber = this.localValue.toString().replace(
|
|
49
|
+
const docNumber = this.localValue.toString().replace(/\D/g, '')
|
|
50
|
+
if (this.allowBoth) {
|
|
51
|
+
if (docNumber.length === 11) return !validateCPF(this.localValue)
|
|
52
|
+
if (docNumber.length === 14) return !validateCNPJ(this.localValue)
|
|
53
|
+
return false
|
|
54
|
+
}
|
|
55
|
+
const docNumberLegacy = this.localValue.toString().replace(/D/g, '')
|
|
51
56
|
if (this.isCompany) {
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
} else if (docNumber.length === 11) {
|
|
57
|
+
if (docNumberLegacy.length === 14) return !validateCNPJ(this.localValue)
|
|
58
|
+
} else if (docNumberLegacy.length === 11) {
|
|
56
59
|
return !validateCPF(this.localValue)
|
|
57
60
|
}
|
|
58
61
|
}
|
|
@@ -69,6 +72,7 @@ export default {
|
|
|
69
72
|
},
|
|
70
73
|
|
|
71
74
|
cleaveOptions () {
|
|
75
|
+
if (this.allowBoth) return { blocks: [30] }
|
|
72
76
|
return countryCode === 'BR'
|
|
73
77
|
? this.isCompany
|
|
74
78
|
? { blocks: [2, 3, 3, 4, 2], delimiters: ['.', '.', '/', '-'] }
|