@kigi/components 1.62.1-beta.4 → 1.62.2-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.1-beta.4",
3
+ "version": "1.62.2-beta.1",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -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
- ? this.address.uf.initial
99
- : '',
99
+ ? this.address.uf.initial
100
+ : '',
100
101
  }
101
102
  if (this.ngModel) {
102
103
  this.ngModel.EX = (this.ngModel.country || '').toLowerCase() !== 'brasil'
@@ -152,65 +153,38 @@ class MbgAddressController {
152
153
  }
153
154
 
154
155
  afterLoad() {
155
- const inputPlace = this.$element.find('.input-place')[0]
156
- const autocomplete = new google.maps.places.Autocomplete(inputPlace, { types: ['address'] })
157
-
158
- autocomplete.setFields(['address_component', 'geometry'])
159
-
156
+ const autocomplete = new google.maps.places.Autocomplete(
157
+ this.$element.find('.input-place')[0],
158
+ { types: ['address'] },
159
+ )
160
+ autocomplete.setFields(['address_component'])
160
161
  autocomplete.addListener('place_changed', () => {
161
162
  this.$timeout(() => {
162
163
  const place = autocomplete.getPlace()
163
-
164
- if (!place.address_components) return
165
-
166
- const newAddress: any = {
167
- country: 'Brasil',
168
- }
169
-
170
- for (const component of place.address_components) {
171
- const types = component.types || []
172
- const longName = component.long_name || ''
173
- const shortName = component.short_name || ''
174
-
175
- if (types.includes('route')) {
176
- newAddress.premisse = longName
177
- }
178
-
179
- if (
180
- types.includes('sublocality_level_1') ||
181
- types.includes('sublocality') ||
182
- types.includes('neighborhood')
183
- ) {
184
- newAddress.neighbourhood = longName
185
- }
186
-
187
- if (types.includes('administrative_area_level_2')) {
188
- newAddress.localization = longName
189
- }
190
-
191
- if (types.includes('administrative_area_level_1')) {
192
- newAddress.uf = { name: longName, initial: shortName }
193
- }
194
-
195
- if (types.includes('country')) {
196
- newAddress.country = longName
197
- }
198
-
199
- if (types.includes('postal_code')) {
200
- newAddress.zipCode = longName.replace(/-/g, '')
164
+ if (place.address_components) {
165
+ for (const component of place.address_components) {
166
+ const addressType = component.types[0]
167
+ if (addressType === 'route') {
168
+ this.address.premisse = component.long_name
169
+ }
170
+ if (addressType === 'sublocality_level_1') {
171
+ this.address.neighbourhood = component.long_name
172
+ }
173
+ if (addressType === 'administrative_area_level_2') {
174
+ this.address.localization = component.long_name
175
+ }
176
+ if (addressType === 'administrative_area_level_1') {
177
+ this.address.uf = { name: component.long_name, initial: component.short_name }
178
+ }
179
+ if (addressType === 'country') {
180
+ this.address.country = component.long_name
181
+ }
182
+ if (addressType === 'postal_code') {
183
+ this.address.zipCode = component.long_name.replace(/-/g, '')
184
+ }
185
+ this.focusInputNumber()
201
186
  }
202
187
  }
203
-
204
- this.address = newAddress
205
-
206
- this.focusInputNumber()
207
-
208
- const hasAddressData = newAddress.uf && newAddress.localization && newAddress.premisse
209
- const missingZip = !newAddress.zipCode
210
-
211
- if (hasAddressData && missingZip) {
212
- this.searchAddressInfo()
213
- }
214
188
  })
215
189
  })
216
190
  }
@@ -398,6 +372,7 @@ class MbgAddressController {
398
372
  const responseIbge = await this.mbgAddressService.getIbgeCode(response.data.city)
399
373
  ibgeCode = responseIbge && responseIbge.data && responseIbge.data.id.toString()
400
374
  }
375
+
401
376
  const uf = getStatesBR().filter((state) => {
402
377
  const currUf = state.initial || state
403
378
  const resUf = response.data.uf || response.data.state
@@ -7,8 +7,8 @@
7
7
  ng-change="$ctrl.onChange()"
8
8
  ng-required="$ctrl.ngRequired"
9
9
  ng-disabled="$ctrl.ngDisabled"
10
- ng-blur="$ctrl.ngBlur({ $event })"
11
- ng-focus="$ctrl.ngFocus({ $event })"
10
+ ng-blur="$ctrl.onBlur(); $ctrl.ngBlur({ $event })"
11
+ ng-focus="$ctrl.onFocus(); $ctrl.ngFocus({ $event })"
12
12
  ng-keyup="$ctrl.ngKeyup({ $event })"
13
13
  ng-keypress="$ctrl.ngKeypress({ $event })"
14
14
  ng-keydown="$ctrl.ngKeydown({ $event })"
@@ -18,4 +18,15 @@
18
18
  ng-if="$ctrl.showBtnPassword">
19
19
  <i class="fas {{$ctrl.show ? 'fa-eye' : 'fa-eye-slash' }}"></i>
20
20
  </a>
21
+ <div class="mbg-password-rules-modal"
22
+ ng-if="$ctrl.showRules && $ctrl.rulesVisible">
23
+ <ul>
24
+ <li ng-repeat="rule in $ctrl.rules"
25
+ ng-class="{'rule-valid': rule.check($ctrl.ngModel)}">
26
+ <i class="fas"
27
+ ng-class="rule.check($ctrl.ngModel) ? 'fa-check' : 'fa-circle'"></i>
28
+ {{ rule.label }}
29
+ </li>
30
+ </ul>
31
+ </div>
21
32
  </div>
@@ -11,4 +11,45 @@
11
11
  right: 0;
12
12
  padding: 13px 10px;
13
13
  }
14
+
15
+ .mbg-password-rules-modal {
16
+ position: absolute;
17
+ top: 100%;
18
+ left: 0;
19
+ width: 100%;
20
+ background: #fff;
21
+ border: 1px solid #ddd;
22
+ border-radius: 4px;
23
+ box-shadow: 0 2px 5px rgba(0,0,0,0.1);
24
+ z-index: 1000;
25
+ margin-top: 5px;
26
+ padding: 10px;
27
+
28
+ ul {
29
+ list-style: none;
30
+ padding: 0;
31
+ margin: 0;
32
+
33
+ li {
34
+ font-size: 12px;
35
+ color: #999;
36
+ margin-bottom: 5px;
37
+ display: flex;
38
+ align-items: center;
39
+
40
+ i {
41
+ margin-right: 8px;
42
+ font-size: 10px;
43
+ width: 12px;
44
+ }
45
+
46
+ &.rule-valid {
47
+ color: #28a745;
48
+ i {
49
+ color: #28a745;
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
14
55
  }
@@ -6,6 +6,9 @@ class MbgInputPasswordController {
6
6
  private ngModel
7
7
  private ngRequired
8
8
  private ngDisabled
9
+ private showRules
10
+ private rulesVisible = false
11
+ private rules = []
9
12
  private props
10
13
 
11
14
  constructor(public $scope, public $element, public $attrs) {
@@ -18,7 +21,29 @@ class MbgInputPasswordController {
18
21
  this.props = {
19
22
  placeholder: $attrs.placeholder || '',
20
23
  }
24
+ this.initRules()
21
25
  }
26
+
27
+ initRules() {
28
+ this.rules = [
29
+ { label: 'Mínimo 8 caracteres', check: (val) => !!(val && val.length >= 8) },
30
+ { label: 'Letra maiúscula', check: (val) => !!(val && /[A-Z]/.test(val)) },
31
+ { label: 'Letra minúscula', check: (val) => !!(val && /[a-z]/.test(val)) },
32
+ { label: 'Número', check: (val) => !!(val && /[0-9]/.test(val)) },
33
+ { label: 'Caractere especial (ex.: !@#$%^&*)', check: (val) => !!(val && /[!@#$%^&*]/.test(val)) },
34
+ ]
35
+ }
36
+
37
+ onFocus() {
38
+ if (this.showRules) {
39
+ this.rulesVisible = true
40
+ }
41
+ }
42
+
43
+ onBlur() {
44
+ this.rulesVisible = false
45
+ }
46
+
22
47
  onChange() {
23
48
  if (this.ngChange) {
24
49
  this.ngChange({})
@@ -39,6 +64,7 @@ const mbgInputPassword = {
39
64
  ngKeypress: '&?',
40
65
  ngKeydown: '&?',
41
66
  showBtnPassword: '=?',
67
+ showRules: '=?',
42
68
  },
43
69
  template,
44
70
  controller: MbgInputPasswordController,
@@ -12,6 +12,8 @@ class MbgInputPhoneController {
12
12
  private maxLength: number
13
13
 
14
14
  constructor(public $scope, public $element, public $attrs) {
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
  }
@@ -23,14 +25,6 @@ class MbgInputPhoneController {
23
25
  }
24
26
  }
25
27
 
26
- $onInit() {
27
- this.phoneNumberMask = this.enableCountryCode ? 'countryCode' : 'areaCode'
28
-
29
- if (!this.maxLength) {
30
- this.maxLength = this.enableCountryCode ? 19 : 15
31
- }
32
- }
33
-
34
28
  onChange() {
35
29
  if (this.ngChange) {
36
30
  this.ngChange({})