@kigi/components 1.8.5 → 1.8.7
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 +1 -1
- package/src/components/mbg-input-ie/mbg-input-ie.html +2 -2
- package/src/components/mbg-list/index.ts +4 -5
- package/src/components/mbg-list/mbg-list.html +2 -1
- package/src/components/mbg-list/mbg-list.ts +7 -1
- package/src/components/mbg-progress-circle/mbg-progress-circle.ts +82 -80
- package/src/helpers/ie-directive/ie-directive.ts +60 -28
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<div class="mbg-input-wrapper mbg-input-name-wrapper"
|
|
2
2
|
ng-if="$ctrl.props">
|
|
3
3
|
<input type="text"
|
|
4
|
-
ng-if="$ctrl.state == 'TO' || $ctrl.state == 'MT'"
|
|
4
|
+
ng-if="$ctrl.state == 'TO' || $ctrl.state == 'MT' || $ctrl.state == 'AL'"
|
|
5
5
|
mbg-mask-ie
|
|
6
6
|
ng-model="$ctrl.ngModel"
|
|
7
7
|
name="{{$ctrl.name}}"
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
placeholder="{{ $ctrl.props.placeholder }}" />
|
|
18
18
|
|
|
19
19
|
<input type="text"
|
|
20
|
-
ng-if="!$ctrl.state || ($ctrl.state != 'TO' && $ctrl.state != 'MT')"
|
|
20
|
+
ng-if="!$ctrl.state || ($ctrl.state != 'TO' && $ctrl.state != 'MT' && $ctrl.state != 'AL')"
|
|
21
21
|
ng-model="$ctrl.ngModel"
|
|
22
22
|
name="{{$ctrl.name}}"
|
|
23
23
|
ng-init="$ctrl.onInit()"
|
|
@@ -4,10 +4,9 @@ import { mbgListColumn } from './components/mbg-list-column/mbg-list-column'
|
|
|
4
4
|
import { mbgListRow } from './components/mbg-list-row/mbg-list-row'
|
|
5
5
|
|
|
6
6
|
const mbgListModule = angular
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.name
|
|
7
|
+
.module('mbg.components.mbgList', [])
|
|
8
|
+
.component('mbgList', mbgList)
|
|
9
|
+
.component('mbgListColumn', mbgListColumn)
|
|
10
|
+
.component('mbgListRow', mbgListRow).name
|
|
12
11
|
|
|
13
12
|
export { mbgListModule }
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
</td>
|
|
31
31
|
<td ng-if="$ctrl.radio && !$row.isAdicional">
|
|
32
32
|
<mbg-radio ng-model="$ctrl.selectedMap[$ctrl.removeCircularJson($row.$json)]"
|
|
33
|
-
ng-change="$ctrl.toogleRadio($ctrl.removeCircularJson($row.$json))"
|
|
33
|
+
ng-change="$ctrl.toogleRadio($ctrl.removeCircularJson($row.$json))"
|
|
34
|
+
ng-if="!$ctrl.checkboxIf || $ctrl.checkboxIf({ $row: $row })"></mbg-radio>
|
|
34
35
|
</td>
|
|
35
36
|
<td ng-repeat="column in $ctrl.columns"
|
|
36
37
|
ng-if="!$row.isAdicional && !column.hidden"
|
|
@@ -209,7 +209,13 @@ export class MbgListController {
|
|
|
209
209
|
handleClickRow(row, index) {
|
|
210
210
|
if (this.rowsAdicional !== index && (this.checkbox || this.radio) && this.enableOnSelectByRow) {
|
|
211
211
|
if (this.radio) {
|
|
212
|
-
this.
|
|
212
|
+
if (this.checkboxIf) {
|
|
213
|
+
if (this.checkboxIf({ $row: row })) {
|
|
214
|
+
this.toogleRadio(row.$json)
|
|
215
|
+
}
|
|
216
|
+
} else {
|
|
217
|
+
this.toogleRadio(row.$json)
|
|
218
|
+
}
|
|
213
219
|
} else {
|
|
214
220
|
if (this.checkboxIf) {
|
|
215
221
|
if (this.checkboxIf({ $row: row })) {
|
|
@@ -4,98 +4,100 @@ import * as angular from 'angular'
|
|
|
4
4
|
import { UtilUID } from '../../helpers/util-uid'
|
|
5
5
|
const progressBar = require('progressbar.js')
|
|
6
6
|
class MbgProgressCircleController {
|
|
7
|
-
private unWatchPercentage: any
|
|
8
|
-
private unWatchShow: any
|
|
9
|
-
private progressCircle: any
|
|
10
|
-
private onFinish: Function
|
|
11
|
-
private uidComponent
|
|
12
|
-
private show = false
|
|
13
|
-
private closeOnFinish
|
|
14
|
-
private duration: number
|
|
15
|
-
private percentage
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
8
|
+
private unWatchPercentage: any
|
|
9
|
+
private unWatchShow: any
|
|
10
|
+
private progressCircle: any
|
|
11
|
+
private onFinish: Function
|
|
12
|
+
private uidComponent
|
|
13
|
+
private show = false
|
|
14
|
+
private duration: number
|
|
15
|
+
private percentage
|
|
16
|
+
|
|
17
|
+
constructor(public $scope, public $element, public $attrs, public $timeout) {
|
|
18
|
+
this.percentage = this.percentage || 100
|
|
21
19
|
}
|
|
22
|
-
}
|
|
23
20
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
21
|
+
createProgress() {
|
|
22
|
+
this.duration = this.duration || 1400
|
|
23
|
+
this.uidComponent = UtilUID.generete()
|
|
24
|
+
this.unWatchShow = this.$scope.$watch('$ctrl.show', (value) => {
|
|
25
|
+
this.$timeout(() => {
|
|
26
|
+
value !== undefined && value ? this.addInBody() : this.removeInBody()
|
|
27
|
+
})
|
|
28
|
+
})
|
|
29
|
+
this.$timeout(() => {
|
|
30
|
+
this.progressCircle = new progressBar.Circle('#progress', {
|
|
31
|
+
color: '#666',
|
|
32
|
+
strokeWidth: 4,
|
|
33
|
+
trailWidth: 1,
|
|
34
|
+
easing: 'easeInOut',
|
|
35
|
+
duration: this.duration,
|
|
36
|
+
text: {
|
|
37
|
+
autoStyleContainer: true,
|
|
38
|
+
},
|
|
39
|
+
from: { color: '#666', width: 1 },
|
|
40
|
+
to: { color: '#000', width: 4 },
|
|
41
|
+
step: (state, circle) => {
|
|
42
|
+
const value = Math.round(circle.value() * 100)
|
|
43
|
+
if (value === 0) {
|
|
44
|
+
circle.setText('')
|
|
45
|
+
} else {
|
|
46
|
+
if (this.duration && value === 100) {
|
|
47
|
+
this.$timeout(() => this.show = false, 2000)
|
|
48
|
+
}
|
|
49
|
+
circle.setText(value + '%')
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
})
|
|
53
|
+
this.progressCircle.text.style.fontFamily = '"Raleway", Helvetica, sans-serif'
|
|
54
|
+
this.progressCircle.text.style.fontSize = '2rem'
|
|
55
|
+
this.progressCircle.animate(0.0)
|
|
59
56
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
57
|
+
this.unWatchPercentage = this.$scope.$watch('$ctrl.percentage', (value) => {
|
|
58
|
+
if (this.progressCircle && value !== undefined) {
|
|
59
|
+
this.progressCircle.animate(value / 100)
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
})
|
|
63
|
+
}
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
addInBody() {
|
|
66
|
+
const body = angular.element(document).find('body')
|
|
67
|
+
const list = this.$element.find('div.mbg-progress-circle-wrapper')
|
|
68
|
+
list.attr('uid', this.uidComponent)
|
|
69
|
+
body.append(list)
|
|
70
|
+
}
|
|
74
71
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
removeInBody() {
|
|
73
|
+
const list = angular.element(`[uid="${this.uidComponent}"]`)
|
|
74
|
+
this.$element.find('.mbg-progress-circle-wrapper').append(list)
|
|
75
|
+
}
|
|
79
76
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
$onDestroy() {
|
|
78
|
+
if (this.unWatchPercentage) {
|
|
79
|
+
this.unWatchPercentage()
|
|
80
|
+
}
|
|
83
81
|
}
|
|
84
|
-
|
|
82
|
+
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
MbgProgressCircleController.$inject = [
|
|
85
|
+
MbgProgressCircleController.$inject = [
|
|
86
|
+
'$scope',
|
|
87
|
+
'$element',
|
|
88
|
+
'$attrs',
|
|
89
|
+
'$timeout'
|
|
90
|
+
]
|
|
88
91
|
|
|
89
92
|
const mbgProgressCircle = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
controller: MbgProgressCircleController,
|
|
93
|
+
bindings: {
|
|
94
|
+
percentage: '=?',
|
|
95
|
+
titleProgress: '@?',
|
|
96
|
+
show: '=?',
|
|
97
|
+
duration: '=?'
|
|
98
|
+
},
|
|
99
|
+
template,
|
|
100
|
+
controller: MbgProgressCircleController,
|
|
99
101
|
}
|
|
100
102
|
|
|
101
103
|
export { mbgProgressCircle }
|
|
@@ -8,6 +8,7 @@ export class NgMaskIe {
|
|
|
8
8
|
private $timeout
|
|
9
9
|
private $parse
|
|
10
10
|
private uid: string = UtilUID.generete()
|
|
11
|
+
private ordZero = '0'.charCodeAt(0)
|
|
11
12
|
|
|
12
13
|
constructor() {
|
|
13
14
|
this.restrict = 'A'
|
|
@@ -25,12 +26,12 @@ export class NgMaskIe {
|
|
|
25
26
|
scope.$parent && scope.$parent.$parent && scope.$parent.$parent.$ctrl
|
|
26
27
|
? scope.$parent.$parent.$ctrl.state
|
|
27
28
|
: null
|
|
28
|
-
const valid = this.
|
|
29
|
+
const valid = this.validate(data, state)
|
|
29
30
|
const form = elm.closest('form')
|
|
30
31
|
const formName = form.attr('name')
|
|
31
32
|
const formScope = form.scope()
|
|
32
33
|
if (formName && formScope) {
|
|
33
|
-
this.
|
|
34
|
+
this.setIeValidate(elm, valid)
|
|
34
35
|
if (!valid) {
|
|
35
36
|
elm.addClass('mbg-error')
|
|
36
37
|
} else {
|
|
@@ -65,43 +66,74 @@ export class NgMaskIe {
|
|
|
65
66
|
ngModelController.$formatters.push(formatterView)
|
|
66
67
|
|
|
67
68
|
scope.$on('$destroy', () => {
|
|
68
|
-
this.
|
|
69
|
+
this.setIeValidate(elm, true)
|
|
69
70
|
})
|
|
70
71
|
}
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
validate(ngModel, state) {
|
|
73
74
|
switch (state) {
|
|
74
75
|
case 'TO':
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
76
|
+
return this.validateTO(ngModel)
|
|
77
|
+
case 'MT':
|
|
78
|
+
return this.validateMT(ngModel)
|
|
79
|
+
case 'AL':
|
|
80
|
+
return this.validateAL(ngModel)
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
charToInt(ch) {
|
|
85
|
+
return ch.charCodeAt(0) - this.ordZero
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
intToChar(int) {
|
|
89
|
+
return String.fromCharCode(int + this.ordZero)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
validateAL(ie) {
|
|
93
|
+
let dig = -1
|
|
94
|
+
if (ie.length != 9) return false
|
|
95
|
+
var b = 9,
|
|
96
|
+
soma = 0
|
|
97
|
+
for (var i = 0; i <= 7; i++) {
|
|
98
|
+
soma += this.charToInt(ie.charAt(i)) * b
|
|
99
|
+
--b
|
|
100
|
+
}
|
|
101
|
+
soma *= 10
|
|
102
|
+
dig = soma - Math.floor(soma / 11) * 11
|
|
103
|
+
if (dig == 10) {
|
|
104
|
+
dig = 0
|
|
105
|
+
}
|
|
106
|
+
return this.intToChar(dig) == ie.charAt(8)
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
validateTO(ngModel) {
|
|
110
|
+
if (ngModel && (ngModel.length === 11 || ngModel.length === 9)) {
|
|
111
|
+
const digit = ngModel[ngModel.length - 1]
|
|
112
|
+
let total = 0
|
|
113
|
+
let indexCalc = 0
|
|
114
|
+
for (let index = 9; index >= 2; index--) {
|
|
115
|
+
total += ngModel[indexCalc] * index
|
|
116
|
+
if (ngModel.length === 11 && indexCalc === 1) {
|
|
117
|
+
indexCalc = indexCalc + 3
|
|
93
118
|
} else {
|
|
94
|
-
|
|
119
|
+
indexCalc++
|
|
95
120
|
}
|
|
96
|
-
|
|
97
|
-
|
|
121
|
+
}
|
|
122
|
+
const result = total - Math.floor(total / 11) * 11
|
|
123
|
+
if (result < 2) {
|
|
124
|
+
return Number(digit) === 0
|
|
125
|
+
} else {
|
|
126
|
+
return Number(digit) === 11 - result
|
|
127
|
+
}
|
|
128
|
+
} else {
|
|
129
|
+
return false
|
|
98
130
|
}
|
|
99
131
|
}
|
|
100
132
|
|
|
101
|
-
|
|
133
|
+
validateMT(model, plusZero = '') {
|
|
102
134
|
const lengthZero = plusZero.length
|
|
103
135
|
model = `${plusZero}${model}`
|
|
104
|
-
if (model.length != 11 && lengthZero < 2) return this.
|
|
136
|
+
if (model.length != 11 && lengthZero < 2) return this.validateMT(model, `0`)
|
|
105
137
|
var nro = new Array(11)
|
|
106
138
|
for (var i = 0; i <= 10; i++) nro[i] = parseInt(model[i])
|
|
107
139
|
let b = 3
|
|
@@ -121,7 +153,7 @@ export class NgMaskIe {
|
|
|
121
153
|
return dig == nro[10]
|
|
122
154
|
}
|
|
123
155
|
|
|
124
|
-
|
|
156
|
+
setIeValidate(elm, valid) {
|
|
125
157
|
const form = elm.closest('form')
|
|
126
158
|
const formName = form.attr('name')
|
|
127
159
|
const formScope = form.scope()
|