@kigi/components 1.62.1-beta.4 → 1.62.3-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.3-beta.1",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -152,65 +152,44 @@ class MbgAddressController {
152
152
  }
153
153
 
154
154
  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
-
155
+ const autocomplete = new google.maps.places.Autocomplete(
156
+ this.$element.find('.input-place')[0],
157
+ { types: ['address'] },
158
+ )
159
+ autocomplete.setFields(['address_component'])
160
160
  autocomplete.addListener('place_changed', () => {
161
161
  this.$timeout(() => {
162
162
  const place = autocomplete.getPlace()
163
+ if (place.address_components) {
164
+ for (const component of place.address_components) {
165
+ const types = component.types || []
166
+ if (types.includes('route')) {
167
+ this.address.premisse = component.long_name
168
+ }
163
169
 
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
- }
170
+ if (
171
+ types.includes('sublocality_level_1') ||
172
+ types.includes('sublocality') ||
173
+ types.includes('neighborhood')
174
+ ) {
175
+ this.address.neighbourhood = component.long_name
176
+ }
198
177
 
199
- if (types.includes('postal_code')) {
200
- newAddress.zipCode = longName.replace(/-/g, '')
178
+ if (types.includes('administrative_area_level_2')) {
179
+ this.address.localization = component.long_name
180
+ }
181
+ if (types.includes('administrative_area_level_1')) {
182
+ this.address.uf = { name: component.long_name, initial: component.short_name }
183
+ }
184
+ if (types.includes('country')) {
185
+ this.address.country = component.long_name
186
+ }
187
+ if (types.includes('postal_code')) {
188
+ this.address.zipCode = component.long_name.replace(/-/g, '')
189
+ }
190
+ this.focusInputNumber()
201
191
  }
202
192
  }
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
193
  })
215
194
  })
216
195
  }
@@ -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({})