@kigi/components 1.63.3-beta.1 → 1.63.5-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
|
@@ -95,8 +95,8 @@ class MbgAddressController {
|
|
|
95
95
|
state: this.address.state
|
|
96
96
|
? this.address.state
|
|
97
97
|
: this.address.uf && this.address.uf.initial
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
? this.address.uf.initial
|
|
99
|
+
: '',
|
|
100
100
|
}
|
|
101
101
|
if (this.ngModel) {
|
|
102
102
|
this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
|
|
@@ -311,17 +311,27 @@ class MbgAddressController {
|
|
|
311
311
|
if (!this.ngModel) {
|
|
312
312
|
return {}
|
|
313
313
|
}
|
|
314
|
-
const
|
|
314
|
+
const currentStateSignal =
|
|
315
|
+
this.ngModel.state ||
|
|
316
|
+
(this.address && this.address.state) ||
|
|
317
|
+
(this.address && this.address.uf && this.address.uf.initial)
|
|
318
|
+
|
|
319
|
+
const uf = getStatesBR().filter((state) => state.initial === currentStateSignal)[0]
|
|
320
|
+
|
|
315
321
|
return {
|
|
316
322
|
EX: (this.ngModel.country || '').toLowerCase() !== 'brasil',
|
|
317
323
|
country: this.ngModel.country || this.address.country,
|
|
318
|
-
state: this.ngModel.state,
|
|
324
|
+
state: this.ngModel.state || (uf ? uf.initial : ''),
|
|
319
325
|
countryCode: this.ngModel.countryCode,
|
|
320
|
-
zipCode: this.address.zipCode
|
|
326
|
+
zipCode: this.address.zipCode
|
|
327
|
+
? this.address.zipCode
|
|
328
|
+
: this.ngModel.zipCode
|
|
329
|
+
? this.ngModel.zipCode.replace('-', '')
|
|
330
|
+
: '',
|
|
321
331
|
neighbourhood: this.address.neighbourhood
|
|
322
332
|
? this.address.neighbourhood
|
|
323
333
|
: this.ngModel.neighbourhood,
|
|
324
|
-
localization: this.ngModel.localization,
|
|
334
|
+
localization: this.ngModel.localization || (this.address ? this.address.localization : ''),
|
|
325
335
|
premisse: this.address.premisse
|
|
326
336
|
? this.address.premisse
|
|
327
337
|
: this.formatFromPremisse(this.ngModel.premisse),
|
|
@@ -26,7 +26,6 @@ export class NgMaskIe {
|
|
|
26
26
|
scope.$watch(attrs.ngModel, (data) => {
|
|
27
27
|
const state = getState()
|
|
28
28
|
const valid = this.validate(data, state)
|
|
29
|
-
console.log('[mbg-mask-ie] watch — data:', data, '| state:', state, '| valid:', valid)
|
|
30
29
|
|
|
31
30
|
ngModelController.$setValidity('ie', !!valid)
|
|
32
31
|
|
|
@@ -82,7 +81,6 @@ export class NgMaskIe {
|
|
|
82
81
|
}
|
|
83
82
|
|
|
84
83
|
validate(ngModel, state) {
|
|
85
|
-
console.log('[mbg-mask-ie] validate — ngModel:', ngModel, '| state:', state)
|
|
86
84
|
switch (state) {
|
|
87
85
|
case 'TO':
|
|
88
86
|
return this.validateTO(ngModel)
|
|
@@ -214,26 +212,20 @@ export class NgMaskIe {
|
|
|
214
212
|
}
|
|
215
213
|
|
|
216
214
|
validateRS(ie) {
|
|
217
|
-
console.log('[validateRS] ie recebido:', ie)
|
|
218
215
|
const digits = (ie || '').replace(/\D/g, '')
|
|
219
|
-
console.log('[validateRS] digits (só números):', digits, '| length:', digits.length)
|
|
220
216
|
const padded = digits.length === 9 ? '0' + digits : digits
|
|
221
|
-
console.log('[validateRS] padded:', padded, '| length:', padded.length)
|
|
222
217
|
if (padded.length !== 10) {
|
|
223
|
-
console.log('[validateRS] INVÁLIDO — length esperado 10, recebido:', padded.length)
|
|
224
218
|
return false
|
|
225
219
|
}
|
|
226
220
|
const weights = [2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
227
221
|
let sum = 0
|
|
228
222
|
for (let i = 0; i < weights.length; i++) {
|
|
229
223
|
const partial = parseInt(padded[i]) * weights[i]
|
|
230
|
-
console.log(`[validateRS] i=${i} dígito=${padded[i]} peso=${weights[i]} parcial=${partial}`)
|
|
231
224
|
sum += partial
|
|
232
225
|
}
|
|
233
226
|
const remainder = sum % 11
|
|
234
227
|
const dv = remainder < 2 ? 0 : 11 - remainder
|
|
235
228
|
const dvIe = parseInt(padded[9])
|
|
236
|
-
console.log('[validateRS] soma:', sum, '| resto:', remainder, '| dv calculado:', dv, '| dv do IE:', dvIe, '| VÁLIDO:', dv === dvIe)
|
|
237
229
|
return dv === dvIe
|
|
238
230
|
}
|
|
239
231
|
|