@kigi/components 1.62.8-beta.1 → 1.62.9-beta.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
|
@@ -43,16 +43,13 @@ class MbgInputCpfCnpjController {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
ngBlur(evt) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (
|
|
50
|
-
this.
|
|
51
|
-
}
|
|
52
|
-
if (this.valid.length === 14) {
|
|
53
|
-
isValidCnpj(this.valid)
|
|
46
|
+
const raw = `${evt.$event.target.value || ''}`.replace(/[^A-Za-z0-9]/g, '').toUpperCase()
|
|
47
|
+
if (raw.length === 11) {
|
|
48
|
+
this.valid = this.validCpf(raw)
|
|
49
|
+
} else if (raw.length === 14) {
|
|
50
|
+
this.valid = isValidCnpj(raw)
|
|
54
51
|
} else {
|
|
55
|
-
|
|
52
|
+
this.valid = false
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
55
|
|
|
@@ -11,7 +11,7 @@ const WEIGHTS_D1 = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
|
11
11
|
const WEIGHTS_D2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
12
12
|
|
|
13
13
|
function charToValue(char: string): number {
|
|
14
|
-
return char.charCodeAt(0)
|
|
14
|
+
return char.charCodeAt(0) - 48
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
function calcDigit(base: string, weights: number[]): number {
|
|
@@ -94,7 +94,10 @@ function isDocumentValid(value: string): boolean {
|
|
|
94
94
|
return isValidCpf(value)
|
|
95
95
|
}
|
|
96
96
|
if (isCnpjCandidate(value)) {
|
|
97
|
-
if (value.length < 14)
|
|
97
|
+
if (value.length < 14) {
|
|
98
|
+
if (hasLetters(value)) return false
|
|
99
|
+
return true
|
|
100
|
+
}
|
|
98
101
|
if (value.length > 14) return false
|
|
99
102
|
return isValidCnpj(value)
|
|
100
103
|
}
|
|
@@ -139,6 +142,7 @@ class MbgDocumentMaskDirective {
|
|
|
139
142
|
const clean = normalizeCnpj(modelValue || '')
|
|
140
143
|
if (!clean || !isCnpjCandidate(clean)) return true
|
|
141
144
|
if (clean.length < 14) {
|
|
145
|
+
if (hasLetters(clean)) return false
|
|
142
146
|
if (clean.length >= 12 && /[A-Z]/.test(clean.slice(12))) return false
|
|
143
147
|
return true
|
|
144
148
|
}
|