@kigi/components 1.62.8-beta.1 → 1.63.1-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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kigi/components",
3
- "version": "1.62.8-beta.1",
3
+ "version": "1.63.1-beta.1",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -43,16 +43,13 @@ class MbgInputCpfCnpjController {
43
43
  }
44
44
 
45
45
  ngBlur(evt) {
46
- this.valid = evt.$event.target.value
47
- this.valid = this.valid.toString()
48
- this.valid = this.valid.replace(/[^0-9]/g, '')
49
- if (this.valid.length === 11) {
50
- this.validCpf(this.valid)
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
- return false
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 {
@@ -3,7 +3,7 @@
3
3
  // Used by: mbg-input-cpfcnpj, mbg-input-cnpj
4
4
  // ---------------------------------------------------------------------------
5
5
 
6
- import { isValidCnpj, normalizeCnpj } from '@kigi/components/src/helpers/cnpj-validador'
6
+ import { isValidCnpj, normalizeCnpj } from './cnpj-validador'
7
7
  export { isValidCnpj as isValidAlphanumericCnpj }
8
8
  export { normalizeCnpj as normalizeAlphanumericCnpj }
9
9
 
@@ -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) return true
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
  }