@kigi/components 1.4.5 → 1.4.9

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.4.5",
3
+ "version": "1.4.9",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -72,7 +72,6 @@
72
72
  ng-model="$ctrl.gridValues[$index][$parent.$index].stock"
73
73
  placeholder="0"
74
74
  ng-keydown="$ctrl.onKeydown($event)"
75
- positive-number="true"
76
75
  ng-class="{ 'grid-disable': $ctrl.activeAddOrRemove && !$ctrl.gridValues[$index][$parent.$index].enable }"
77
76
  ng-change="$ctrl.handleGridValues()"
78
77
  ng-model-options="{ debounce: 500 }"
@@ -92,4 +91,4 @@
92
91
  </tr>
93
92
  </tbody>
94
93
  </table>
95
- </div>
94
+ </div>
@@ -53,7 +53,6 @@
53
53
  ng-model="item.stock"
54
54
  ng-keydown="$ctrl.onKeydown($event)"
55
55
  placeholder="0"
56
- positive-number="true"
57
56
  placeholder="Estoque"
58
57
  ng-model-options="{ debounce: 500 }"
59
58
  class="inline-product-stock" />
@@ -72,4 +71,4 @@
72
71
  </div>
73
72
  </div>
74
73
  </div>
75
- </div>
74
+ </div>
@@ -88,12 +88,17 @@
88
88
  <ul class="ul-options"
89
89
  vs-repeat="{size: {{$ctrl.transcludeSize || 'null'}}}">
90
90
  <li ng-mousedown="$ctrl.selectOption(item)"
91
+ class="mbg-item-select"
91
92
  ng-style="$ctrl.transcludeSize && {'min-height': $ctrl.transcludeSize}"
92
93
  ng-repeat="item in $ctrl.data">
93
94
  <div ng-if="$ctrl.transcludeTemplate"
94
95
  mbg-dynamic-html="$ctrl.transcludeTemplate"></div>
95
- <div ng-if="!$ctrl.transcludeTemplate && $ctrl.labelValue">{{item[$ctrl.labelValue]}}</div>
96
- <div ng-if="!$ctrl.transcludeTemplate && !$ctrl.labelValue">{{item}}</div>
96
+ <div ng-if="!$ctrl.transcludeTemplate && $ctrl.labelValue"><span
97
+ ng-class="{'mbg-item-animation': item[$ctrl.labelValue].length > 30}">{{item[$ctrl.labelValue]}}</span>
98
+ </div>
99
+ <div ng-if="!$ctrl.transcludeTemplate && !$ctrl.labelValue"><span
100
+ ng-class="{'mbg-item-animation': item.length > 30}">{{item}}</span>
101
+ </div>
97
102
  <i title="Favoritar"
98
103
  ng-if="$ctrl.enableFavorite"
99
104
  ng-mousedown="$ctrl.favorite($event, item)"
@@ -115,4 +120,4 @@
115
120
  </li>
116
121
  </ul>
117
122
  </div>
118
- </div>
123
+ </div>
@@ -1,5 +1,6 @@
1
1
  .mbg-select-wrapper {
2
2
  position: relative;
3
+
3
4
  .mbg-select-input-fake {
4
5
  border: 1px solid #ddd;
5
6
  background: #fff;
@@ -131,7 +132,8 @@
131
132
  transform: rotate(40deg);
132
133
  opacity: 0.4;
133
134
 
134
- &:hover, &.fixed {
135
+ &:hover,
136
+ &.fixed {
135
137
  transform: rotate(0deg);
136
138
  opacity: 1;
137
139
  }
@@ -170,3 +172,35 @@ mbg-select[disabled="disabled"] {
170
172
  font-weight: 500;
171
173
  }
172
174
  }
175
+
176
+ .mbg-item-select {
177
+ span.mbg-item-animation {
178
+ left: 0;
179
+ transition-delay: 1s;
180
+ }
181
+
182
+ &:hover {
183
+ text-overflow: initial;
184
+
185
+ span.mbg-item-animation {
186
+ display: inline-block;
187
+ position: relative;
188
+ animation: animation-select-label 5s infinite;
189
+ }
190
+ }
191
+ }
192
+
193
+ @keyframes animation-select-label {
194
+ 0% {
195
+ transform: translateX(0%);
196
+ }
197
+ 15% {
198
+ transform: translateX(0%);
199
+ }
200
+ 80% {
201
+ transform: translateX(-50%);
202
+ }
203
+ 100% {
204
+ transform: translateX(0%);
205
+ }
206
+ }
@@ -41,6 +41,7 @@ class MbgSelectController {
41
41
  private fixedOptionId: any
42
42
  private fixedValue: string
43
43
  private transcludeSize: any
44
+ private getCustomModel: Function
44
45
 
45
46
  constructor(
46
47
  public $scope,
@@ -387,7 +388,7 @@ class MbgSelectController {
387
388
  }
388
389
 
389
390
  setModel() {
390
- this.$timeout(() => {
391
+ this.$timeout(async () => {
391
392
  if (this.fetch) {
392
393
  const currentOption = this.getOptionFocused()
393
394
  if (currentOption[0]) {
@@ -399,10 +400,10 @@ class MbgSelectController {
399
400
  item = isNaN(this.inputValue) ? this.inputValue : Number(this.inputValue)
400
401
  }
401
402
  }
402
- this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
403
+ await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
403
404
  }
404
405
  } else {
405
- this.updateModelValue(this.inputValue)
406
+ await this.updateModelValue(this.inputValue)
406
407
  }
407
408
  this.executeCallback()
408
409
  if (this.onSelect) {
@@ -419,12 +420,12 @@ class MbgSelectController {
419
420
  }
420
421
  }
421
422
 
422
- selectOption(item, isNew?: boolean) {
423
+ async selectOption(item, isNew?: boolean) {
423
424
  this.data = []
424
425
  this.executeCallback(isNew)
425
426
  this.pressEnter = false
426
427
  this.hasFocus = false
427
- this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
428
+ await this.updateModelValue(this.ngValue ? item[this.ngValue] : item)
428
429
  if (this.onSelect) {
429
430
  this.onSelect({ value: this.ngModel })
430
431
  }
@@ -516,8 +517,41 @@ class MbgSelectController {
516
517
  }
517
518
 
518
519
  updateModelValue(value) {
519
- this.ngModel = value
520
- this.updateInputValue()
520
+ return new Promise((resolve) => {
521
+ if (this.getCustomModel) {
522
+ const response: any = this.getCustomModel({ value })
523
+ this.isLoading = true
524
+ if (response && response.then) {
525
+ if (response && response.then) {
526
+ response
527
+ .then((responseCustomModel) => {
528
+ this.ngModel =
529
+ responseCustomModel && responseCustomModel.data
530
+ ? responseCustomModel.data
531
+ : responseCustomModel
532
+ this.updateInputValue()
533
+ this.isLoading = false
534
+ resolve(true)
535
+ return
536
+ })
537
+ .catch(() => {
538
+ this.isLoading = false
539
+ resolve(true)
540
+ })
541
+ }
542
+ } else {
543
+ this.ngModel = response
544
+ this.updateInputValue()
545
+ this.isLoading = false
546
+ resolve(true)
547
+ return
548
+ }
549
+ } else {
550
+ this.ngModel = value
551
+ this.updateInputValue()
552
+ resolve(true)
553
+ }
554
+ })
521
555
  }
522
556
 
523
557
  updateInputValue() {
@@ -632,6 +666,7 @@ const mbgSelect = {
632
666
  fixedOptionId: '=?',
633
667
  callbackAddFixedOption: '&?',
634
668
  transcludeSize: '=?',
669
+ getCustomModel: '&?',
635
670
  },
636
671
  controller: MbgSelectController,
637
672
  template,