@kigi/components 1.42.0 → 1.43.0-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.42.0",
3
+ "version": "1.43.0-beta.1",
4
4
  "description": "@kigi/components",
5
5
  "main": "src/components/index.ts",
6
6
  "scripts": {
@@ -88,6 +88,7 @@ import { mbgImageUploadCropModule } from './mbg-image-upload-crop'
88
88
  import { mbgStoreGoalModule } from './mbg-store-goal'
89
89
  import { mbgStatusLabelModule } from './mbg-status-label'
90
90
  import { mbgAverageCustomerTimeModule } from './mbg-average-customer-time'
91
+ import { mbgTopSellingsProductsModule } from './mbg-top-sellings-products'
91
92
 
92
93
  if (!window['$']) {
93
94
  window['$'] = $
@@ -157,6 +158,7 @@ const mbgComponentsModule = angular
157
158
  mbgStoreGoalModule,
158
159
  mbgStatusLabelModule,
159
160
  mbgAverageCustomerTimeModule,
161
+ mbgTopSellingsProductsModule,
160
162
  ])
161
163
  .config(appConfig)
162
164
  .service('mbgAlert', MbgAlert)
@@ -0,0 +1,8 @@
1
+ import * as angular from 'angular'
2
+ import { mbgTopSellingsProducts } from './mbg-top-sellings-products'
3
+
4
+ const mbgTopSellingsProductsModule = angular
5
+ .module('mbg.components.mbgTopSellingsProducts', [])
6
+ .component('mbgTopSellingsProducts', mbgTopSellingsProducts).name
7
+
8
+ export { mbgTopSellingsProductsModule }
@@ -0,0 +1,110 @@
1
+ <div class="top-sellings-products-wrapper"
2
+ ng-class="{'opacity-dash': $ctrl.isBlockValuesTopSellingsProducts}">
3
+ <div class="panel">
4
+ <div class="description">
5
+ <div class="description-container-dash-selling">
6
+ <p class="description-dash-selling">10 Produtos mais vendidos</p>
7
+ <div class="mbg-h-c-tone-s-icon-dash"
8
+ ng-click="$ctrl.toggleShow(false)">
9
+ <i class="fa fa-lock lock-dash"
10
+ aria-hidden="true"
11
+ uib-tooltip="Sem permissão para visualizar"
12
+ ng-if="$ctrl.isBlockValuesTopSellingsProducts && !$ctrl.hideValue"></i>
13
+ <i ng-if="$ctrl.hideValue"
14
+ disable-animate
15
+ class="far fa-eye"></i>
16
+ <i ng-if="!$ctrl.hideValue && !$ctrl.isBlockValuesTopSellingsProducts"
17
+ disable-animate
18
+ class="far fa-eye-slash"></i>
19
+ </div>
20
+ </div>
21
+ <div class="line-pay-selling"></div>
22
+ </div>
23
+
24
+ <div class="description-header">
25
+ <div class="product-list">
26
+ <div class="product-header">
27
+ <span class="header-sales">Qtd. Vendas</span>
28
+ <span class="header-stock">Estoque</span>
29
+ </div>
30
+
31
+
32
+ <div class="swiper-container">
33
+ <div class="swiper-wrapper">
34
+ <div class="swiper-slide"
35
+ ng-repeat="slide in $ctrl.slides">
36
+ <div class="product-item"
37
+ ng-repeat="item in slide.items">
38
+ <div class="segment-item">
39
+ <span class="rank">{{ $index + 1 }}°</span>
40
+ <span class="name"
41
+ ng-if="$ctrl.hideValue && !$ctrl.isBlockValuesTopSellingsProducts"
42
+ uib-tooltip="{{ item.nameProduct }}"
43
+ tooltip-placement="{{$index === 0 || $index === 1 || item.nameProduct.length > 30 ? 'bottom' :'top' }}">{{
44
+ item.nameProduct
45
+ }}</span>
46
+ <div class="line-block-top"
47
+ ng-if="!$ctrl.hideValue || $ctrl.isBlockValuesTopSellingsProducts"></div>
48
+
49
+ <span class="sales"
50
+ ng-if="$ctrl.hideValue && !$ctrl.isBlockValuesTopSellingsProducts">{{ item.stock
51
+ }}</span>
52
+ <span class="sales"
53
+ ng-if="!$ctrl.hideValue || $ctrl.isBlockValuesTopSellingsProducts"> <i
54
+ class="fa fa-lock lock-dash"
55
+ aria-hidden="true"
56
+ tooltip-placement="left"
57
+ uib-tooltip="Sem permissão para visualizar"></i></span>
58
+
59
+
60
+ <span class="stock"
61
+ ng-if="$ctrl.hideValue && !$ctrl.isBlockValuesTopSellingsProducts">{{ item.stockCount
62
+ }}</span>
63
+ <span class="stock"
64
+ ng-if="!$ctrl.hideValue || $ctrl.isBlockValuesTopSellingsProducts"> <i
65
+ class="fa fa-lock lock-dash"
66
+ aria-hidden="true"
67
+ tooltip-placement="left"
68
+ uib-tooltip="Sem permissão para visualizar"></i></span>
69
+ </div>
70
+ </div>
71
+ </div>
72
+ </div>
73
+ <div class="swiper-pagination"></div>
74
+
75
+ <div class="active-index-top"
76
+ ng-if="$ctrl.indexActiveSlide">
77
+ <label>{{$ctrl.indexActiveSlide}}</label>
78
+ </div>
79
+ <div class="loading-indicator-top">
80
+ <svg id="loading-circle-top"
81
+ width="30"
82
+ height="30"
83
+ viewBox="0 0 100 100">
84
+
85
+ <circle cx="50"
86
+ cy="50"
87
+ r="40"
88
+ stroke="#E9E9E9"
89
+ stroke-width="8"
90
+ fill="none" />
91
+
92
+ <circle id="progress-top"
93
+ cx="50"
94
+ cy="50"
95
+ r="40"
96
+ stroke="#0ebcbd"
97
+ stroke-width="8"
98
+ stroke-dasharray="251.2"
99
+ stroke-dashoffset="251.2"
100
+ fill="none"
101
+ transform="rotate(-90 50 50)" />
102
+ </svg>
103
+ </div>
104
+ </div>
105
+
106
+ </div>
107
+ </div>
108
+
109
+ </div>
110
+ </div>
@@ -0,0 +1,351 @@
1
+ .top-sellings-products-wrapper {
2
+
3
+
4
+ .loading-indicator-top {
5
+ position: absolute;
6
+ top: 90%;
7
+ left: 96%;
8
+ transform: translate(-50%, -50%);
9
+ width: 40px;
10
+ height: 40px;
11
+ }
12
+
13
+ #loading-circle-top {
14
+ position: absolute;
15
+ }
16
+
17
+ .active-index-top {
18
+ display: flex;
19
+ position: relative;
20
+ top: -53px;
21
+ justify-content: center;
22
+ color: #5f5b5b;
23
+ }
24
+
25
+ display: flex;
26
+ align-items: stretch;
27
+ width: 100%;
28
+
29
+ .opacity-dash{
30
+ opacity: 0.6;
31
+ }
32
+
33
+ .panel {
34
+ margin-left: 54px;
35
+ border-radius: 10px;
36
+ background: #FFF;
37
+ box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.05);
38
+ display: flex;
39
+ flex-direction: column;
40
+ width: 100%;
41
+ height: 400px;
42
+
43
+
44
+ .description{
45
+ .description-container-dash-selling {
46
+ padding: 0px 32px;
47
+ flex-grow: 1;
48
+ color: var(--titleColor);
49
+ display: flex;
50
+ justify-content: space-between;
51
+ width: 100%;
52
+ position: relative;
53
+ left: -20px;
54
+ top: -8px;
55
+ font-weight: 600;
56
+ font-size: 14px;
57
+
58
+ .mbg-h-c-tone-s-icon-dash {
59
+ position: relative;
60
+ top: 10px;
61
+ right: -40px;
62
+ transition: opacity 500ms ease;
63
+ opacity: 0.9;
64
+ }
65
+ }
66
+
67
+ .description-dash-selling {
68
+ font-size: 20px;
69
+ color: #5f5b5b;
70
+ }
71
+
72
+ .line-pay-selling {
73
+ background: #737373;
74
+ height: 1px;
75
+ opacity: 0.3;
76
+ position: relative;
77
+ width: 95%;
78
+ top: -8px;
79
+ left: 12px;
80
+ }
81
+ }
82
+
83
+ .description-header {
84
+ flex-direction: column;
85
+ width: 100%;
86
+ display: flex;
87
+ justify-content: center;
88
+ align-items: center;
89
+ }
90
+
91
+
92
+ .product-header {
93
+ display: flex;
94
+ justify-content: end;
95
+ font-weight: bold;
96
+ width: 100%;
97
+ padding: 0px 24px;
98
+ }
99
+
100
+ .product-header span {
101
+ color: #555;
102
+ }
103
+
104
+
105
+ .header-sales {
106
+ width: 23%;
107
+ text-align: right;
108
+ }
109
+
110
+ .header-stock {
111
+ width: 20%;
112
+ text-align: right;
113
+ }
114
+
115
+ .product-list {
116
+ flex-grow: 1;
117
+ width: 100%;
118
+ flex-grow: 1;
119
+ position: relative;
120
+ left: 14px;
121
+ }
122
+
123
+ .product-item {
124
+ display: block;
125
+ padding: 0;
126
+ padding: 0px 23px 0px 0px;
127
+
128
+ }
129
+
130
+ .swiper-container {
131
+ width: 100%;
132
+ overflow: hidden;
133
+ height: 350px;
134
+ position: relative;
135
+ left: -14px;
136
+ padding-left: 10px;
137
+ }
138
+
139
+ .swiper-pagination {
140
+ position: relative;
141
+ top: -38px;
142
+ left: 50%;
143
+ transform: translateX(-50%);
144
+ display: flex;
145
+ gap: 5px;
146
+ }
147
+
148
+ .swiper-pagination-bullet {
149
+ width: 10px;
150
+ height: 10px;
151
+ background-color: #606A90;
152
+ border-radius: 50%;
153
+ opacity: 0.5;
154
+ }
155
+
156
+ .swiper-pagination-bullet-active {
157
+ background-color: #0EBCBD;
158
+ opacity: 1;
159
+ }
160
+
161
+
162
+
163
+
164
+ .segment-item {
165
+ display: flex;
166
+ justify-content: space-between;
167
+ padding: 6px 0;
168
+ }
169
+
170
+ .name {
171
+ width: 70%;
172
+ max-width: 50%;
173
+ white-space: nowrap;
174
+ overflow: hidden;
175
+ text-overflow: ellipsis;
176
+ position: relative;
177
+ left: 8px;
178
+ font-size: 14px;
179
+ color: #5f5b5b;
180
+ }
181
+
182
+ .tooltip-inner {
183
+ background: #0EBCBD !important;
184
+ font-weight: bold;
185
+ color: #FFFFFF;
186
+ }
187
+
188
+ .line-block-top{
189
+ height: 1px;
190
+ background: black;
191
+ width: 60%;
192
+ position: relative;
193
+ left: 10px;
194
+ opacity: 0.3;
195
+ top: 8px;
196
+ }
197
+
198
+ .sales {
199
+ width: 20%;
200
+ text-align: right;
201
+ font-size: 14px;
202
+ color: #5f5b5b;
203
+ position: relative;
204
+ // right: 30px;
205
+ }
206
+
207
+ .stock {
208
+ width: 20%;
209
+ text-align: right;
210
+ font-size: 14px;
211
+ color: #5f5b5b;
212
+ position: relative;
213
+ }
214
+ }
215
+
216
+ }
217
+
218
+ @media screen and (max-width: 1920px) {
219
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .description-dash-selling {
220
+ font-size: 20px;
221
+ color: #5f5b5b;
222
+ position: relative;
223
+ top: 17px;
224
+ }
225
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .mbg-h-c-tone-s-icon-dash{
226
+ position: relative;
227
+ top: 12px;
228
+ }
229
+
230
+ .top-sellings-products-wrapper .panel .description .line-pay-selling {
231
+ background: #737373;
232
+ top: 9px;
233
+ }
234
+
235
+ .top-sellings-products-wrapper .description-header{
236
+ position: relative;
237
+ top: 15px;
238
+ }
239
+ }
240
+
241
+ @media screen and (max-width: 1728px) {
242
+ .top-sellings-products-wrapper .panel {
243
+ margin-left: 55px;
244
+ border-radius: 10px;
245
+ background: #FFF;
246
+ box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.05);
247
+ display: flex;
248
+ flex-direction: column;
249
+ width: 100%;
250
+ height: 400px;
251
+ }
252
+ }
253
+
254
+ @media screen and (max-width: 1536px) {
255
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .description-dash-selling {
256
+ font-size: 17px;
257
+ color: #5f5b5b;
258
+ top: 17px;
259
+ position: relative;
260
+ }
261
+
262
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .mbg-h-c-tone-s-icon-dash{
263
+ position: relative;
264
+ top: 11px;
265
+ }
266
+
267
+ .top-sellings-products-wrapper .panel .description .line-pay-selling {
268
+ background: #737373;
269
+ top: 12px;
270
+ }
271
+
272
+ .top-sellings-products-wrapper .description-header{
273
+ position: relative;
274
+ top: 20px;
275
+ }
276
+ .top-sellings-products-wrapper .panel .description-header .loading-indicator {
277
+ position: absolute;
278
+ left: 97%;
279
+ }
280
+
281
+ .top-sellings-products-wrapper .panel .description-header .name {
282
+ width: 70%;
283
+ position: relative;
284
+ left: 4px;
285
+ }
286
+
287
+ .top-sellings-products-wrapper .panel .description-header .product-list .product-header .header-sales {
288
+ width: 30%;
289
+
290
+ }
291
+ .top-sellings-products-wrapper .panel {
292
+ margin-left: 48px;
293
+ border-radius: 10px;
294
+ background: #FFF;
295
+ box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.05);
296
+ display: flex;
297
+ flex-direction: column;
298
+ width: 100%;
299
+ height: 400px;
300
+ }
301
+ }
302
+
303
+
304
+ @media screen and (max-width: 1366px) {
305
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .description-dash-selling {
306
+ font-size: 20px;
307
+ color: #5f5b5b;
308
+ top: 17px;
309
+ position: relative;
310
+ }
311
+
312
+ .top-sellings-products-wrapper .panel .description .line-pay-selling {
313
+ background: #737373;
314
+ top: 8px;
315
+ }
316
+
317
+ .top-sellings-products-wrapper .panel {
318
+ margin-left: 55px;
319
+ border-radius: 10px;
320
+ background: #FFF;
321
+ box-shadow: 0px 2px 20px rgba(0, 0, 0, 0.05);
322
+ display: flex;
323
+ flex-direction: column;
324
+ width: 100%;
325
+ height: 400px;
326
+ }
327
+ }
328
+
329
+
330
+ @media screen and (max-width: 1024px) {
331
+ .top-sellings-products-wrapper .panel .description .description-container-dash-selling .description-dash-selling {
332
+ font-size: 18px;
333
+ color: #5f5b5b;
334
+ top: 17px;
335
+ position: relative;
336
+ }
337
+
338
+ .top-sellings-products-wrapper .panel .description .line-pay-selling {
339
+ background: #737373;
340
+ top: 10px;
341
+ }
342
+
343
+ .top-sellings-products-wrapper .panel .description-header .product-list .product-header .header-sales {
344
+ width: 31%;
345
+ left: -9px;
346
+ position: relative;
347
+ }
348
+ }
349
+
350
+
351
+
@@ -0,0 +1,181 @@
1
+ import './mbg-top-sellings-products.scss'
2
+ import template from './mbg-top-sellings-products.html'
3
+ import Swiper from 'swiper'
4
+
5
+ class MbgTopSellingsProducts {
6
+ private itemsPerSlide: number = 10
7
+ private slides: Array<any> = []
8
+ private swiper
9
+ private allowedToSee: boolean
10
+ private allowedCallBack: Function
11
+ private hideValue: boolean = false
12
+ private allowDashBoardAutoValues
13
+ private isPermissionTopSellingsProducts
14
+ private isBlockValuesTopSellingsProducts
15
+ private indexActiveSlide
16
+
17
+ constructor(
18
+ public $scope,
19
+ public $element,
20
+ public $attrs,
21
+ public $timeout,
22
+ public $filter,
23
+ public $state,
24
+ ) {}
25
+
26
+ async $onInit() {
27
+ this.isBlockValuesTopSellingsProducts =
28
+ !this.allowedToSee || !this.isPermissionTopSellingsProducts
29
+ this.$scope.$watch(
30
+ '$ctrl.topSellingProducts',
31
+ (data) => {
32
+ if (data) {
33
+ this.createSlides(data)
34
+ this.configSwiperSlides()
35
+ }
36
+ },
37
+ true,
38
+ )
39
+ this.initialize()
40
+ }
41
+
42
+ initialize() {
43
+ if (this.allowDashBoardAutoValues) {
44
+ this.hideValue = this.isPermissionTopSellingsProducts ? true : false
45
+ return
46
+ }
47
+
48
+ if (this.allowedToSee && !this.allowDashBoardAutoValues) {
49
+ this.hideValue =
50
+ this.allowDashBoardAutoValues && this.isPermissionTopSellingsProducts ? true : false
51
+ return
52
+ }
53
+
54
+ this.hideValue = this.allowedToSee && this.isPermissionTopSellingsProducts ? true : false
55
+ }
56
+
57
+ createSlides(data) {
58
+ this.slides = []
59
+ const totalPages = Math.ceil(data.length / this.itemsPerSlide)
60
+ for (let i = 1; i <= totalPages; i++) {
61
+ this.slides.push({
62
+ name: 'Page ' + i,
63
+ items: this.paginate(data, i, this.itemsPerSlide),
64
+ })
65
+ }
66
+
67
+ this.slides.forEach((page) => {
68
+ page.items.forEach((item) => {
69
+ item.stock = parseFloat(item.stock)
70
+ item.stockCount = parseFloat(item.stockCount)
71
+ })
72
+ })
73
+ }
74
+
75
+ paginate(arr, page = 1, pageSize = 10) {
76
+ page--
77
+ return [...arr.slice(page * pageSize, (page + 1) * pageSize)]
78
+ }
79
+
80
+ configSwiperSlides() {
81
+ this.$timeout(() => {
82
+ this.swiper = new Swiper('.swiper-container', {
83
+ speed: 1000,
84
+ autoplay: {
85
+ delay: 50000,
86
+ disableOnInteraction: false,
87
+ },
88
+ pagination: {
89
+ el: '.swiper-pagination',
90
+ clickable: true,
91
+ renderBullet: (index, className) => {
92
+ return `<span class="${className}"></span>`
93
+ },
94
+ },
95
+ })
96
+
97
+ this.indexActiveSlide = '(0 a 30 dias)'
98
+ this.swiper.on('slideChange', () => {
99
+ this.startLoadingAnimation(this.swiper)
100
+ this.indexActiveSlide =
101
+ this.swiper.activeIndex === 0
102
+ ? '(0 a 30 dias)'
103
+ : this.swiper.activeIndex === 1
104
+ ? '(0 a 90 dias)'
105
+ : '(0 a 365 dias)'
106
+ })
107
+
108
+ this.startLoadingAnimation(this.swiper)
109
+ })
110
+ }
111
+
112
+ startLoadingAnimation(swiper) {
113
+ const duration = 50000
114
+ const totalLength = 251.2
115
+
116
+ const progress = document.getElementById('progress-top')
117
+ if (!progress) return
118
+
119
+ let startTime: number | null = null
120
+
121
+ const animate = (timestamp: number) => {
122
+ if (!startTime) startTime = timestamp
123
+ const elapsed = timestamp - startTime
124
+
125
+ const progressPercentage = elapsed / duration
126
+ const currentOffset = totalLength * (1 - progressPercentage)
127
+
128
+ progress.style.strokeDashoffset = `${currentOffset}`
129
+
130
+ if (elapsed < duration) {
131
+ requestAnimationFrame(animate)
132
+ } else {
133
+ progress.style.strokeDashoffset = '0'
134
+ if (swiper.autoplay.running) {
135
+ swiper.autoplay.start()
136
+ }
137
+ }
138
+ }
139
+
140
+ progress.style.strokeDashoffset = `${totalLength}`
141
+ requestAnimationFrame(animate)
142
+ }
143
+
144
+ toggleShow() {
145
+ if (
146
+ (this.allowedToSee !== undefined && !this.allowedToSee) ||
147
+ !this.isPermissionTopSellingsProducts
148
+ ) {
149
+ if (this.allowedCallBack) {
150
+ this.allowedCallBack()
151
+ }
152
+ return
153
+ }
154
+
155
+ this.hideValue = !this.hideValue
156
+ }
157
+ }
158
+
159
+ MbgTopSellingsProducts['$inject'] = [
160
+ '$scope',
161
+ '$element',
162
+ '$attrs',
163
+ '$timeout',
164
+ '$filter',
165
+ '$state',
166
+ ]
167
+
168
+ const mbgTopSellingsProducts = {
169
+ bindings: {
170
+ topSellingProducts: '=?',
171
+ allowedToSee: '=?',
172
+ allowedCallBack: '&?',
173
+ allowDashBoardAutoValues: '=?',
174
+ isPermissionTopSellingsProducts: '=?',
175
+ isBlockValuesTopSellingsProducts: '=?',
176
+ },
177
+ template,
178
+ controller: MbgTopSellingsProducts,
179
+ }
180
+
181
+ export { mbgTopSellingsProducts }