@kigi/components 1.61.0 → 1.62.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 +2 -2
- package/src/components/mbg-address/mbg-address.ts +11 -6
- package/src/components/mbg-address/services/mbg-address.service.ts +2 -1
- package/src/components/mbg-input-phone/mbg-input-phone.html +14 -14
- package/src/components/mbg-input-phone/mbg-input-phone.ts +3 -0
- package/src/components/mbg-input-text/mbg-input-text.ts +11 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kigi/components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.62.1-beta.1",
|
|
4
4
|
"description": "@kigi/components",
|
|
5
5
|
"main": "src/components/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -100,4 +100,4 @@
|
|
|
100
100
|
"webpack": "^2.5.1",
|
|
101
101
|
"webpack-dev-server": "^2.6.1"
|
|
102
102
|
}
|
|
103
|
-
}
|
|
103
|
+
}
|
|
@@ -51,7 +51,8 @@ class MbgAddressController {
|
|
|
51
51
|
public $timeout,
|
|
52
52
|
public mbgAddressService: MbgAddressService,
|
|
53
53
|
public $uibModal,
|
|
54
|
-
) {
|
|
54
|
+
) {
|
|
55
|
+
}
|
|
55
56
|
|
|
56
57
|
$onInit() {
|
|
57
58
|
if (this.capitalize && this.address) {
|
|
@@ -95,8 +96,8 @@ class MbgAddressController {
|
|
|
95
96
|
state: this.address.state
|
|
96
97
|
? this.address.state
|
|
97
98
|
: this.address.uf && this.address.uf.initial
|
|
98
|
-
|
|
99
|
-
|
|
99
|
+
? this.address.uf.initial
|
|
100
|
+
: '',
|
|
100
101
|
}
|
|
101
102
|
if (this.ngModel) {
|
|
102
103
|
this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
|
|
@@ -206,11 +207,11 @@ class MbgAddressController {
|
|
|
206
207
|
return elmWidth - inputElmWidth - marginRight + 'px'
|
|
207
208
|
}
|
|
208
209
|
|
|
209
|
-
onChangeCep() {
|
|
210
|
+
async onChangeCep() {
|
|
210
211
|
this.resetAddress()
|
|
211
212
|
this.updateSteps()
|
|
212
213
|
if (this.address.zipCode) {
|
|
213
|
-
this.searchAddressByCEP()
|
|
214
|
+
await this.searchAddressByCEP()
|
|
214
215
|
} else {
|
|
215
216
|
this.fullAddress = ``
|
|
216
217
|
}
|
|
@@ -372,7 +373,11 @@ class MbgAddressController {
|
|
|
372
373
|
ibgeCode = responseIbge && responseIbge.data && responseIbge.data.id.toString()
|
|
373
374
|
}
|
|
374
375
|
|
|
375
|
-
const uf = getStatesBR().filter((state) =>
|
|
376
|
+
const uf = getStatesBR().filter((state) => {
|
|
377
|
+
const currUf = state.initial || state
|
|
378
|
+
const resUf = response.data.uf || response.data.state
|
|
379
|
+
return currUf === resUf
|
|
380
|
+
})[0]
|
|
376
381
|
const formalCode = ibgeCode || ''
|
|
377
382
|
const premisse = this.formatFromPremisse(street)
|
|
378
383
|
|
|
@@ -39,8 +39,9 @@ class MbgAddressService {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
async getIbgeCode(municipio: string) {
|
|
42
|
+
const normalizedMunicipio = municipio.normalize('NFD').replace(/[\u0300-\u036f]/g, '')
|
|
42
43
|
try {
|
|
43
|
-
return await this.$http.get(`${this.ibgeGovAPI}/${
|
|
44
|
+
return await this.$http.get(`${this.ibgeGovAPI}/${normalizedMunicipio}`)
|
|
44
45
|
} catch (e) {
|
|
45
46
|
console.log(`Erro ao obter código do IBGE`)
|
|
46
47
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<div class="mbg-input-wrapper mb-input-phone-wrapper"
|
|
2
2
|
ng-if="$ctrl.props"
|
|
3
3
|
mbg-autocomplete-off>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
4
|
+
<input type="text"
|
|
5
|
+
ng-class="{'input-phone': $ctrl.inputPhone}"
|
|
6
|
+
ng-model="$ctrl.ngModel"
|
|
7
|
+
ng-change="$ctrl.onChange()"
|
|
8
|
+
placeholder="{{ $ctrl.props.placeholder }}"
|
|
9
|
+
ng-required="$ctrl.ngRequired"
|
|
10
|
+
ng-disabled="$ctrl.ngDisabled"
|
|
11
|
+
ng-blur="$ctrl.ngBlur({ $event })"
|
|
12
|
+
ng-focus="$ctrl.ngFocus({ $event })"
|
|
13
|
+
ng-keyup="$ctrl.ngKeyup({ $event })"
|
|
14
|
+
ng-keypress="$ctrl.ngKeypress({ $event })"
|
|
15
|
+
ng-keydown="$ctrl.ngKeydown({ $event })"
|
|
16
|
+
ui-br-phone-number-mask="'{{$ctrl.phoneNumberMask}}'"
|
|
17
|
+
maxlength="{{$ctrl.maxLength}}" />
|
|
18
18
|
</div>
|
|
@@ -9,9 +9,11 @@ class MbgInputPhoneController {
|
|
|
9
9
|
private props
|
|
10
10
|
private enableCountryCode: string
|
|
11
11
|
private phoneNumberMask: string
|
|
12
|
+
private maxLength: number
|
|
12
13
|
|
|
13
14
|
constructor(public $scope, public $element, public $attrs) {
|
|
14
15
|
this.phoneNumberMask = this.enableCountryCode ? 'countryCode' : 'areaCode'
|
|
16
|
+
this.maxLength = this.maxLength ? this.maxLength : this.enableCountryCode ? 19 : 15
|
|
15
17
|
if ($attrs.ngRequired === '') {
|
|
16
18
|
this.ngRequired = true
|
|
17
19
|
}
|
|
@@ -45,6 +47,7 @@ const mbgInputPhone = {
|
|
|
45
47
|
ngKeydown: '&?',
|
|
46
48
|
enableCountryCode: '=?',
|
|
47
49
|
inputPhone: '=?',
|
|
50
|
+
maxLength: '=?',
|
|
48
51
|
},
|
|
49
52
|
template,
|
|
50
53
|
controller: MbgInputPhoneController,
|
|
@@ -15,7 +15,7 @@ class MbgInputTextController {
|
|
|
15
15
|
private focusableElements
|
|
16
16
|
private nextIndex
|
|
17
17
|
private onlyNumbers = false
|
|
18
|
-
|
|
18
|
+
private onlyDigits = false
|
|
19
19
|
|
|
20
20
|
constructor(public $scope, public $element, public $attrs) {
|
|
21
21
|
if ($attrs.ngRequired === '') {
|
|
@@ -46,8 +46,15 @@ class MbgInputTextController {
|
|
|
46
46
|
|
|
47
47
|
onChange($event) {
|
|
48
48
|
if (this.onlyNumbers && this.ngModel) {
|
|
49
|
-
this.ngModel = String(this.ngModel)
|
|
49
|
+
this.ngModel = String(this.ngModel)
|
|
50
|
+
.replace(/[^0-9]/g, '')
|
|
51
|
+
.replace(/^0+(\d)/, '$1')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (this.onlyDigits && this.ngModel) {
|
|
55
|
+
this.ngModel = String(this.ngModel).replace(/[^0-9]/g, '')
|
|
50
56
|
}
|
|
57
|
+
|
|
51
58
|
if (this.capitalize) {
|
|
52
59
|
this.ngModel = this.capitalizeBool(this.ngModel)
|
|
53
60
|
}
|
|
@@ -93,7 +100,8 @@ const mbgInputText = {
|
|
|
93
100
|
ngKeydown: '&?',
|
|
94
101
|
capitalize: '=?',
|
|
95
102
|
maxLength: '@?',
|
|
96
|
-
onlyNumbers: '<?'
|
|
103
|
+
onlyNumbers: '<?',
|
|
104
|
+
onlyDigits: '<?',
|
|
97
105
|
},
|
|
98
106
|
template,
|
|
99
107
|
controller: MbgInputTextController,
|