@kigi/components 1.8.1 → 1.8.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,64 +1,80 @@
|
|
|
1
1
|
import './mbg-input-text.scss'
|
|
2
2
|
import * as angular from 'angular'
|
|
3
3
|
import template from './mbg-input-text.html'
|
|
4
|
+
import { Capitalize } from '../../helpers/capitalize'
|
|
4
5
|
|
|
5
6
|
class MbgInputTextController {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
private ngChange
|
|
8
|
+
private ngModel
|
|
9
|
+
private ngRequired
|
|
10
|
+
private ngDisabled
|
|
11
|
+
private props
|
|
12
|
+
private ngKeydown
|
|
13
|
+
private ngValue
|
|
14
|
+
private capitalize
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
this.props = {}
|
|
16
|
+
constructor(public $scope, public $element, public $attrs) {
|
|
17
|
+
if ($attrs.ngRequired === '') {
|
|
18
|
+
this.ngRequired = true
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (this.ngValue) {
|
|
22
|
-
this.ngModel = this.ngValue
|
|
23
|
-
}
|
|
20
|
+
if ($attrs.ngDisabled === '') {
|
|
21
|
+
this.ngDisabled = true
|
|
24
22
|
}
|
|
23
|
+
this.props = {}
|
|
24
|
+
}
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
$onInit() {
|
|
27
|
+
if (this.capitalize) {
|
|
28
|
+
this.ngModel = this.capitalizeBool(this.ngModel || '')
|
|
28
29
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (this.ngChange) {
|
|
32
|
-
this.ngChange({ $event })
|
|
33
|
-
}
|
|
30
|
+
if (this.ngValue) {
|
|
31
|
+
this.ngModel = this.ngValue
|
|
34
32
|
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
fillAttributes() {
|
|
36
|
+
// console.log(this.$attrs.$attr.hasOwnProperty('enableKeyboard'))
|
|
37
|
+
}
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
capitalizeBool(str) {
|
|
40
|
+
return Capitalize.format(str)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onChange($event) {
|
|
44
|
+
if (this.capitalize) {
|
|
45
|
+
this.ngModel = this.capitalizeBool(this.ngModel)
|
|
46
|
+
}
|
|
47
|
+
if (this.ngChange) {
|
|
48
|
+
this.ngChange({ $event })
|
|
41
49
|
}
|
|
50
|
+
}
|
|
42
51
|
|
|
52
|
+
onKeydown($event: Event) {
|
|
53
|
+
$event.stopPropagation()
|
|
54
|
+
if (this.ngKeydown) {
|
|
55
|
+
this.ngKeydown({ $event })
|
|
56
|
+
}
|
|
57
|
+
}
|
|
43
58
|
}
|
|
44
59
|
MbgInputTextController.$inject = ['$scope', '$element', '$attrs']
|
|
45
60
|
|
|
46
61
|
const mbgInputText = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
bindings: {
|
|
63
|
+
ngValue: '=?',
|
|
64
|
+
ngModel: '=',
|
|
65
|
+
ngChange: '&?',
|
|
66
|
+
ngRequired: '=?',
|
|
67
|
+
ngDisabled: '=?',
|
|
68
|
+
placeholder: '@?',
|
|
69
|
+
ngBlur: '&?',
|
|
70
|
+
ngFocus: '&?',
|
|
71
|
+
ngKeyup: '&?',
|
|
72
|
+
ngKeypress: '&?',
|
|
73
|
+
ngKeydown: '&?',
|
|
74
|
+
capitalize: '=?',
|
|
75
|
+
},
|
|
76
|
+
template,
|
|
77
|
+
controller: MbgInputTextController,
|
|
62
78
|
}
|
|
63
79
|
|
|
64
80
|
export { mbgInputText }
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Capitalize } from '@kigi/components/src/helpers/capitalize';
|
|
1
2
|
import * as angular from 'angular'
|
|
2
3
|
import './mbg-select.scss'
|
|
3
4
|
import template from './mbg-select.html'
|
|
@@ -42,6 +43,7 @@ class MbgSelectController {
|
|
|
42
43
|
private fixedValue: string
|
|
43
44
|
private transcludeSize: any
|
|
44
45
|
private getCustomModel: Function
|
|
46
|
+
private capitalize
|
|
45
47
|
|
|
46
48
|
constructor(
|
|
47
49
|
public $scope,
|
|
@@ -50,7 +52,7 @@ class MbgSelectController {
|
|
|
50
52
|
public $timeout,
|
|
51
53
|
public $compile,
|
|
52
54
|
public $transclude,
|
|
53
|
-
) {}
|
|
55
|
+
) { }
|
|
54
56
|
|
|
55
57
|
$onInit() {
|
|
56
58
|
this.fixedValue = this.ngValue || 'id'
|
|
@@ -251,6 +253,9 @@ class MbgSelectController {
|
|
|
251
253
|
}
|
|
252
254
|
|
|
253
255
|
onInputChange() {
|
|
256
|
+
if (this.capitalize) {
|
|
257
|
+
this.inputValue = Capitalize.format(this.inputValue)
|
|
258
|
+
}
|
|
254
259
|
if (this.timeoutChange) {
|
|
255
260
|
this.$timeout.cancel(this.timeoutChange)
|
|
256
261
|
}
|
|
@@ -667,6 +672,7 @@ const mbgSelect = {
|
|
|
667
672
|
callbackAddFixedOption: '&?',
|
|
668
673
|
transcludeSize: '=?',
|
|
669
674
|
getCustomModel: '&?',
|
|
675
|
+
capitalize: '=?'
|
|
670
676
|
},
|
|
671
677
|
controller: MbgSelectController,
|
|
672
678
|
template,
|
|
@@ -1,24 +1,46 @@
|
|
|
1
1
|
export namespace Capitalize {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
const prepositions = [
|
|
3
|
+
'de',
|
|
4
|
+
'da',
|
|
5
|
+
'do',
|
|
6
|
+
'dos',
|
|
7
|
+
'de',
|
|
8
|
+
'a',
|
|
9
|
+
'ante',
|
|
10
|
+
'após',
|
|
11
|
+
'até',
|
|
12
|
+
'com',
|
|
13
|
+
'contra',
|
|
14
|
+
'desde',
|
|
15
|
+
'em',
|
|
16
|
+
'entre',
|
|
17
|
+
'para',
|
|
18
|
+
'per',
|
|
19
|
+
'perante',
|
|
20
|
+
'por',
|
|
21
|
+
'sem',
|
|
22
|
+
'sob',
|
|
23
|
+
'sobre',
|
|
24
|
+
'trás',
|
|
25
|
+
]
|
|
8
26
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
export function format(str: string) {
|
|
28
|
+
return (str || '')
|
|
29
|
+
.toLowerCase()
|
|
30
|
+
.replace(/ /g, '')
|
|
31
|
+
.split(' ')
|
|
32
|
+
.map((w, index) =>
|
|
33
|
+
prepositions.filter((e) => e.toLowerCase() === w.toLowerCase()).length === 0
|
|
34
|
+
? w.charAt(0).toUpperCase() + w.slice(1)
|
|
35
|
+
: lowerCase(w, index),
|
|
36
|
+
)
|
|
37
|
+
.join(' ')
|
|
38
|
+
}
|
|
19
39
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
40
|
+
const lowerCase = (str, index) => {
|
|
41
|
+
const lowerCaseString = (str || '').toLowerCase()
|
|
42
|
+
return index === 0
|
|
43
|
+
? lowerCaseString.charAt(0).toUpperCase() + lowerCaseString.slice(1)
|
|
44
|
+
: lowerCaseString
|
|
45
|
+
}
|
|
24
46
|
}
|