@kigi/components 1.7.0 → 1.7.3

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.7.0",
3
+ "version": "1.7.3",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -1,34 +1,34 @@
1
1
  <div class="mbg-input-wrapper mbg-input-name-wrapper"
2
2
  ng-if="$ctrl.props">
3
- <input type="text"
4
- ng-if="$ctrl.state == 'TO'"
5
- mbg-mask-ie
6
- ng-model="$ctrl.ngModel"
7
- name="{{$ctrl.name}}"
8
- ng-init="$ctrl.onInit()"
9
- ng-change="$ctrl.onChangeTO()"
10
- ng-required="$ctrl.ngRequired"
11
- ng-disabled="$ctrl.ngDisabled"
12
- ng-blur="$ctrl.ngBlur({ $event })"
13
- ng-focus="$ctrl.ngFocus({ $event })"
14
- ng-keyup="$ctrl.ngKeyup({ $event })"
15
- ng-keypress="$ctrl.ngKeypress({ $event })"
16
- ng-keydown="$ctrl.ngKeydown({ $event })"
17
- placeholder="{{ $ctrl.props.placeholder }}" />
3
+ <input type="text"
4
+ ng-if="$ctrl.state == 'TO' || $ctrl.state == 'MT'"
5
+ mbg-mask-ie
6
+ ng-model="$ctrl.ngModel"
7
+ name="{{$ctrl.name}}"
8
+ ng-init="$ctrl.onInit()"
9
+ ng-change="$ctrl.onChangeTO()"
10
+ ng-required="$ctrl.ngRequired"
11
+ ng-disabled="$ctrl.ngDisabled"
12
+ ng-blur="$ctrl.ngBlur({ $event })"
13
+ ng-focus="$ctrl.ngFocus({ $event })"
14
+ ng-keyup="$ctrl.ngKeyup({ $event })"
15
+ ng-keypress="$ctrl.ngKeypress({ $event })"
16
+ ng-keydown="$ctrl.ngKeydown({ $event })"
17
+ placeholder="{{ $ctrl.props.placeholder }}" />
18
18
 
19
- <input type="text"
20
- ng-if="!$ctrl.state || $ctrl.state != 'TO'"
21
- ng-model="$ctrl.ngModel"
22
- name="{{$ctrl.name}}"
23
- ng-init="$ctrl.onInit()"
24
- ng-change="$ctrl.onChange()"
25
- ng-required="$ctrl.ngRequired"
26
- ng-disabled="$ctrl.ngDisabled"
27
- ng-blur="$ctrl.ngBlur({ $event })"
28
- ng-focus="$ctrl.ngFocus({ $event })"
29
- ng-keyup="$ctrl.ngKeyup({ $event })"
30
- ng-keypress="$ctrl.ngKeypress({ $event })"
31
- ng-keydown="$ctrl.ngKeydown({ $event })"
32
- placeholder="{{ $ctrl.props.placeholder }}"
33
- ui-br-ie-mask="$ctrl.state" />
34
- </div>
19
+ <input type="text"
20
+ ng-if="!$ctrl.state || ($ctrl.state != 'TO' && $ctrl.state != 'MT')"
21
+ ng-model="$ctrl.ngModel"
22
+ name="{{$ctrl.name}}"
23
+ ng-init="$ctrl.onInit()"
24
+ ng-change="$ctrl.onChange()"
25
+ ng-required="$ctrl.ngRequired"
26
+ ng-disabled="$ctrl.ngDisabled"
27
+ ng-blur="$ctrl.ngBlur({ $event })"
28
+ ng-focus="$ctrl.ngFocus({ $event })"
29
+ ng-keyup="$ctrl.ngKeyup({ $event })"
30
+ ng-keypress="$ctrl.ngKeypress({ $event })"
31
+ ng-keydown="$ctrl.ngKeydown({ $event })"
32
+ placeholder="{{ $ctrl.props.placeholder }}"
33
+ ui-br-ie-mask="$ctrl.state" />
34
+ </div>
@@ -5,19 +5,16 @@
5
5
  <th class="grid-center-content">
6
6
  <label>{{ ::$ctrl.y.label }}</label>
7
7
  </th>
8
- <th class="grid-center-content"
9
- colspan="{{ $ctrl.grid.x.length }}">
8
+ <th class="grid-center-content" colspan="{{ $ctrl.grid.x.length }}">
10
9
  <label>{{ ::$ctrl.x.label }}</label>
11
- <a class="grid-adicional-link"
12
- ng-click="$ctrl.onClickExtraButton()">
10
+ <a class="grid-adicional-link" ng-click="$ctrl.onClickExtraButton()">
13
11
  {{ ::$ctrl.extraButtonLabel }}
14
12
  </a>
15
13
  </th>
16
14
  </tr>
17
15
  <tr>
18
16
  <td></td>
19
- <td ng-repeat="xItem in $ctrl.grid.x track by xItem.value"
20
- class="grid-center-content">
17
+ <td ng-repeat="xItem in $ctrl.grid.x track by xItem.value" class="grid-center-content">
21
18
  <label>{{ ::xItem.value }}</label>
22
19
  </td>
23
20
  </tr>
@@ -34,58 +31,43 @@
34
31
  <tr ng-repeat="yItem in $ctrl.grid.y track by yItem.value">
35
32
  <td>
36
33
  <div class="grid-product-item-name-wrapper">
37
- <div class="grid-product-item-circle"
38
- ng-style="{'background': yItem.valueRef}"></div>
34
+ <div class="grid-product-item-circle" ng-style="{'background': yItem.valueRef}"></div>
39
35
  <span>{{ ::yItem.value }}</span>
40
36
  </div>
41
37
  </td>
42
38
  <td ng-repeat="xItem in $ctrl.grid.x track by xItem.value">
43
39
  <div class="grid-transclude-edit-wrapper">
44
- <div ng-show="$ctrl.transcludeTemplate"
45
- mbg-dynamic-html="$ctrl.transcludeTemplate"></div>
40
+ <div ng-show="$ctrl.transcludeTemplate" mbg-dynamic-html="$ctrl.transcludeTemplate"></div>
46
41
  </div>
47
- <div ng-show="!$ctrl.transcludeTemplate"
48
- class="grid-product-edit-wrapper">
49
- <svg height="401pt"
50
- viewBox="0 -1 401.52289 401"
51
- width="401pt"
52
- ng-click="$ctrl.onClickEditButton({ x: xItem, y: yItem })"
53
- ng-show="$ctrl.activeEdit && $ctrl.gridValues[$index][$parent.$index].enable"
54
- xmlns="http://www.w3.org/2000/svg">
42
+ <div ng-show="!$ctrl.transcludeTemplate" class="grid-product-edit-wrapper">
43
+ <svg tabindex="-1" height="401pt" viewBox="0 -1 401.52289 401" width="401pt"
44
+ ng-click="$ctrl.onClickEditButton({ x: xItem, y: yItem })"
45
+ ng-show="$ctrl.activeEdit && $ctrl.gridValues[$index][$parent.$index].enable"
46
+ xmlns="http://www.w3.org/2000/svg">
55
47
  <path
56
- d="m370.589844 250.972656c-5.523438 0-10 4.476563-10 10v88.789063c-.019532 16.5625-13.4375 29.984375-30 30h-280.589844c-16.5625-.015625-29.980469-13.4375-30-30v-260.589844c.019531-16.558594 13.4375-29.980469 30-30h88.789062c5.523438 0 10-4.476563 10-10 0-5.519531-4.476562-10-10-10h-88.789062c-27.601562.03125-49.96875 22.398437-50 50v260.59375c.03125 27.601563 22.398438 49.96875 50 50h280.589844c27.601562-.03125 49.96875-22.398437 50-50v-88.792969c0-5.523437-4.476563-10-10-10zm0 0" />
48
+ d="m370.589844 250.972656c-5.523438 0-10 4.476563-10 10v88.789063c-.019532 16.5625-13.4375 29.984375-30 30h-280.589844c-16.5625-.015625-29.980469-13.4375-30-30v-260.589844c.019531-16.558594 13.4375-29.980469 30-30h88.789062c5.523438 0 10-4.476563 10-10 0-5.519531-4.476562-10-10-10h-88.789062c-27.601562.03125-49.96875 22.398437-50 50v260.59375c.03125 27.601563 22.398438 49.96875 50 50h280.589844c27.601562-.03125 49.96875-22.398437 50-50v-88.792969c0-5.523437-4.476563-10-10-10zm0 0" />
57
49
  <path
58
- d="m376.628906 13.441406c-17.574218-17.574218-46.066406-17.574218-63.640625 0l-178.40625 178.40625c-1.222656 1.222656-2.105469 2.738282-2.566406 4.402344l-23.460937 84.699219c-.964844 3.472656.015624 7.191406 2.5625 9.742187 2.550781 2.546875 6.269531 3.527344 9.742187 2.566406l84.699219-23.464843c1.664062-.460938 3.179687-1.34375 4.402344-2.566407l178.402343-178.410156c17.546875-17.585937 17.546875-46.054687 0-63.640625zm-220.257812 184.90625 146.011718-146.015625 47.089844 47.089844-146.015625 146.015625zm-9.40625 18.875 37.621094 37.625-52.039063 14.417969zm227.257812-142.546875-10.605468 10.605469-47.09375-47.09375 10.609374-10.605469c9.761719-9.761719 25.589844-9.761719 35.351563 0l11.738281 11.734375c9.746094 9.773438 9.746094 25.589844 0 35.359375zm0 0" />
50
+ d="m376.628906 13.441406c-17.574218-17.574218-46.066406-17.574218-63.640625 0l-178.40625 178.40625c-1.222656 1.222656-2.105469 2.738282-2.566406 4.402344l-23.460937 84.699219c-.964844 3.472656.015624 7.191406 2.5625 9.742187 2.550781 2.546875 6.269531 3.527344 9.742187 2.566406l84.699219-23.464843c1.664062-.460938 3.179687-1.34375 4.402344-2.566407l178.402343-178.410156c17.546875-17.585937 17.546875-46.054687 0-63.640625zm-220.257812 184.90625 146.011718-146.015625 47.089844 47.089844-146.015625 146.015625zm-9.40625 18.875 37.621094 37.625-52.039063 14.417969zm227.257812-142.546875-10.605468 10.605469-47.09375-47.09375 10.609374-10.605469c9.761719-9.761719 25.589844-9.761719 35.351563 0l11.738281 11.734375c9.746094 9.773438 9.746094 25.589844 0 35.359375zm0 0" />
59
51
  </svg>
60
- <a class="link"
61
- ng-show="$ctrl.activeAddOrRemove"
62
- ng-click="$ctrl.toogleEnableItem($index, $parent.$index)">
52
+ <a tabindex="-1" class="link" ng-show="$ctrl.activeAddOrRemove"
53
+ ng-click="$ctrl.toogleEnableItem($index, $parent.$index)">
63
54
  {{ $ctrl.gridValues[$index][$parent.$index].enable ? 'Remover' : 'Adicionar'}}
64
55
  </a>
65
- <span ng-show="$ctrl.enableCurrentStock">Estoque:
56
+ <span tabindex="-1" ng-show="$ctrl.enableCurrentStock">Estoque:
66
57
  {{$ctrl.gridValues[$index][$parent.$index].currentStock || '0'}}</span>
67
- <span
68
- ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }">
58
+ <span tabindex="-1"
59
+ ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }">
69
60
  {{$ctrl.inputLabel ? $ctrl.inputLabel : $ctrl.showStock ? 'Estoque' : 'R$ Venda'}}</span>
70
- <input type="number"
71
- ng-show="$ctrl.showStock"
72
- ng-model="$ctrl.gridValues[$index][$parent.$index].stock"
73
- placeholder="0"
74
- ng-keydown="$ctrl.onKeydown($event)"
75
- ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }"
76
- ng-change="$ctrl.handleGridValues()"
77
- ng-model-options="{ debounce: 500 }"
78
- class="grid-product-stock" />
79
- <input type="text"
80
- ng-model="$ctrl.gridValues[$index][$parent.$index].price"
81
- ng-show="$ctrl.enablePrice"
82
- ui-money-mask
83
- ng-disabled="$ctrl.ngDisabled"
84
- onclick="angular.element(this).scope().$ctrl.focusInput(this)"
85
- ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }"
86
- ng-change="$ctrl.handleGridValues()"
87
- class="grid-product-money"
88
- placeholder="0" />
61
+ <input tabindex="0" type="number" ng-show="$ctrl.showStock"
62
+ ng-model="$ctrl.gridValues[$index][$parent.$index].stock" placeholder="0"
63
+ ng-keydown="$ctrl.onKeydown($event)"
64
+ ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }"
65
+ ng-change="$ctrl.handleGridValues()" ng-model-options="{ debounce: 500 }" class="grid-product-stock" />
66
+ <input tabindex="-1" type="text" ng-model="$ctrl.gridValues[$index][$parent.$index].price"
67
+ ng-show="$ctrl.enablePrice" ui-money-mask ng-disabled="$ctrl.ngDisabled"
68
+ onclick="angular.element(this).scope().$ctrl.focusInput(this)"
69
+ ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }"
70
+ ng-change="$ctrl.handleGridValues()" class="grid-product-money" placeholder="0" />
89
71
  </div>
90
72
  </td>
91
73
  </tr>
@@ -7,65 +7,45 @@
7
7
  <div class="y-value-col">
8
8
  <label>{{$ctrl.y.label}}</label>
9
9
  </div>
10
- <div class="barcode-col"
11
- ng-hide="$ctrl.hideBarcode">
10
+ <div class="barcode-col" ng-hide="$ctrl.hideBarcode">
12
11
  <label>Código de barras</label>
13
12
  </div>
14
13
  <div class="stock-col">
15
14
  <label>Estoque</label>
16
15
  </div>
17
- <div class="price-col"
18
- ng-hide="$ctrl.hidePrice">
16
+ <div class="price-col" ng-hide="$ctrl.hidePrice">
19
17
  <label>Preço</label>
20
18
  </div>
21
19
  </div>
22
20
  </div>
23
- <div class="inline-content"
24
- ng-style="{'max-height': $ctrl.maxHeight + 'px'}">
21
+ <div class="inline-content" ng-style="{'max-height': $ctrl.maxHeight + 'px'}">
25
22
  <div class="inline-x">
26
- <div class="inline-y"
27
- ng-if="item[$ctrl.activeAttr] === undefined ? true : item[$ctrl.activeAttr]"
28
- ng-repeat="item in $ctrl.ngModel track by $index">
23
+ <div class="inline-y" ng-if="item[$ctrl.activeAttr] === undefined ? true : item[$ctrl.activeAttr]"
24
+ ng-repeat="item in $ctrl.ngModel track by $index">
29
25
  <div class="inline-row"
30
- ng-class="{'default-template': !$ctrl.transcludeTemplate && $parent.$index === 0 && $index === 0}">
26
+ ng-class="{'default-template': !$ctrl.transcludeTemplate && $parent.$index === 0 && $index === 0}">
31
27
  <div class="x-value-col">
32
- <span>{{ item.xDetail.value}}</span>
28
+ <span tabindex="-1">{{ item.xDetail.value}}</span>
33
29
  </div>
34
30
  <div class="y-value-col">
35
- <div class="grid-product-item-circle"
36
- ng-style="{'background': item.yDetail.valueRef}"></div>
37
- <span>{{ item.yDetail.value }}</span>
31
+ <div class="grid-product-item-circle" ng-style="{'background': item.yDetail.valueRef}"></div>
32
+ <span tabindex="-1">{{ item.yDetail.value }}</span>
38
33
  </div>
39
- <div class="barcode-col"
40
- ng-hide="$ctrl.hideBarcode">
41
- <input type="text"
42
- ng-class="{'input-error': item.inputError}"
43
- ng-change="$ctrl.changeBarCode(item)"
44
- onclick="angular.element(this).scope().$ctrl.focusInput(this)"
45
- ng-model="item.barCode"
46
- placeholder="Código de barras"
47
- ng-model-options="{ debounce: 500 }"
48
- class="inline-product-barcode" />
34
+ <div class="barcode-col" ng-hide="$ctrl.hideBarcode">
35
+ <input tabindex="-1" type="text" ng-class="{'input-error': item.inputError}"
36
+ ng-change="$ctrl.changeBarCode(item)" onclick="angular.element(this).scope().$ctrl.focusInput(this)"
37
+ ng-model="item.barCode" placeholder="Código de barras" ng-model-options="{ debounce: 500 }"
38
+ class="inline-product-barcode" />
49
39
  </div>
50
40
  <div class="stock-col">
51
- <input type="number"
52
- onclick="angular.element(this).scope().$ctrl.focusInput(this)"
53
- ng-model="item.stock"
54
- ng-keydown="$ctrl.onKeydown($event)"
55
- placeholder="0"
56
- placeholder="Estoque"
57
- ng-model-options="{ debounce: 500 }"
58
- class="inline-product-stock" />
41
+ <input tabindex="0" type="number" onclick="angular.element(this).scope().$ctrl.focusInput(this)"
42
+ ng-model="item.stock" ng-keydown="$ctrl.onKeydown($event)" placeholder="0" placeholder="Estoque"
43
+ ng-model-options="{ debounce: 500 }" class="inline-product-stock" />
59
44
  </div>
60
- <div class="price-col"
61
- ng-hide="$ctrl.hidePrice">
62
- <input type="text"
63
- onclick="angular.element(this).scope().$ctrl.focusInput(this)"
64
- ng-model="item.price"
65
- ui-money-mask
66
- ng-disabled="$ctrl.ngDisabled"
67
- class="inline-product-money"
68
- placeholder="0" />
45
+ <div class="price-col" ng-hide="$ctrl.hidePrice">
46
+ <input tabindex="-1" type="text" onclick="angular.element(this).scope().$ctrl.focusInput(this)"
47
+ ng-model="item.price" ui-money-mask ng-disabled="$ctrl.ngDisabled" class="inline-product-money"
48
+ placeholder="0" />
69
49
  </div>
70
50
  </div>
71
51
  </div>
@@ -21,7 +21,11 @@ export class NgMaskIe {
21
21
 
22
22
  link(scope, elm, attrs, ngModelController) {
23
23
  scope.$watch(attrs.ngModel, (data) => {
24
- const valid = this.validadeTO(data)
24
+ const state =
25
+ scope.$parent && scope.$parent.$parent && scope.$parent.$parent.$ctrl
26
+ ? scope.$parent.$parent.$ctrl.state
27
+ : null
28
+ const valid = this.validade(data, state)
25
29
  const form = elm.closest('form')
26
30
  const formName = form.attr('name')
27
31
  const formScope = form.scope()
@@ -65,28 +69,56 @@ export class NgMaskIe {
65
69
  })
66
70
  }
67
71
 
68
- validadeTO(ngModel) {
69
- if (ngModel && (ngModel.length === 11 || ngModel.length === 9)) {
70
- const digit = ngModel[ngModel.length - 1]
71
- let total = 0
72
- let indexCalc = 0
73
- for (let index = 9; index >= 2; index--) {
74
- total += ngModel[indexCalc] * index
75
- if (ngModel.length === 11 && indexCalc === 1) {
76
- indexCalc = indexCalc + 3
72
+ validade(ngModel, state) {
73
+ switch (state) {
74
+ case 'TO':
75
+ if (ngModel && (ngModel.length === 11 || ngModel.length === 9)) {
76
+ const digit = ngModel[ngModel.length - 1]
77
+ let total = 0
78
+ let indexCalc = 0
79
+ for (let index = 9; index >= 2; index--) {
80
+ total += ngModel[indexCalc] * index
81
+ if (ngModel.length === 11 && indexCalc === 1) {
82
+ indexCalc = indexCalc + 3
83
+ } else {
84
+ indexCalc++
85
+ }
86
+ }
87
+ const result = total - Math.floor(total / 11) * 11
88
+ if (result < 2) {
89
+ return Number(digit) === 0
90
+ } else {
91
+ return Number(digit) === 11 - result
92
+ }
77
93
  } else {
78
- indexCalc++
94
+ return false
79
95
  }
80
- }
81
- const result = total - Math.floor(total / 11) * 11
82
- if (result < 2) {
83
- return Number(digit) === 0
84
- } else {
85
- return Number(digit) === 11 - result
86
- }
96
+ case 'MT':
97
+ return this.validadeMT(ngModel)
98
+ }
99
+ }
100
+
101
+ validadeMT(model, plusZero = '') {
102
+ const lengthZero = plusZero.length
103
+ model = `${plusZero}${model}`
104
+ if (model.length != 11 && lengthZero < 2) return this.validadeMT(model, `0`)
105
+ var nro = new Array(11)
106
+ for (var i = 0; i <= 10; i++) nro[i] = parseInt(model[i])
107
+ let b = 3
108
+ let soma = 0,
109
+ dig = 0
110
+ for (i = 0; i <= 9; i++) {
111
+ soma += nro[i] * b
112
+ b--
113
+ if (b == 1) b = 9
114
+ }
115
+ i = soma % 11
116
+ if (i <= 1) {
117
+ dig = 0
87
118
  } else {
88
- return false
119
+ dig = 11 - i
89
120
  }
121
+ return dig == nro[10]
90
122
  }
91
123
 
92
124
  setIeValidade(elm, valid) {