@formixru/b2b-ui 4.6.0 → 4.6.2

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": "@formixru/b2b-ui",
3
- "version": "4.6.0",
3
+ "version": "4.6.2",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,6 +1,5 @@
1
1
  import { cssVar } from '@advdominion/css-var';
2
2
 
3
- import { mm } from '../../utils/mm.js';
4
3
  import { hide as hideLoader } from '../loader/index.js';
5
4
  import { disableScroll, enableScroll } from '../overlay/index.js';
6
5
  import { initRequestContent, request } from '../request/index.js';
@@ -16,6 +15,18 @@ for (const $b of $sidebars) {
16
15
  }
17
16
  }
18
17
 
18
+ const getSidebarWidth = ($b) => {
19
+ const width = $b.querySelector('.sidebar__wrapper').offsetWidth + $b.querySelector('.sidebar__aside').offsetWidth;
20
+ return $b.classList.contains('sidebar_left') ? width * -1 : width;
21
+ };
22
+
23
+ const slideSidebar = ($b, frames, options) =>
24
+ Promise.all(
25
+ ['aside', 'wrapper'].map(
26
+ (elementName) => $b.querySelector(`.sidebar__${elementName}`).animate(frames, options).finished,
27
+ ),
28
+ );
29
+
19
30
  export const show = async ($b, showBackdrop = 'before') => {
20
31
  if (!$b?.hidden) {
21
32
  return;
@@ -32,16 +43,10 @@ export const show = async ($b, showBackdrop = 'before') => {
32
43
  }
33
44
  $b.hidden = false;
34
45
 
35
- let width = mm('tablet-landscape-up')
36
- ? $b.offsetWidth + $b.querySelector('.sidebar__aside').offsetWidth
37
- : $b.offsetWidth;
38
- if ($b.classList.contains('sidebar_left')) {
39
- width = width * -1;
40
- }
41
- await $b.animate([{ transform: `translateX(${width}px)` }, { transform: 'translateX(0px)' }], {
46
+ await slideSidebar($b, [{ transform: `translateX(${getSidebarWidth($b)}px)` }, { transform: 'translateX(0px)' }], {
42
47
  duration: cssVar('--duration-enter-m'),
43
48
  easing: cssVar('--easing-deceleration'),
44
- }).finished;
49
+ });
45
50
 
46
51
  if (showBackdrop === 'after') {
47
52
  $b.classList.add('sidebar_backdrop');
@@ -62,16 +67,10 @@ export const hide = async ($b) => {
62
67
 
63
68
  $b.classList.remove('sidebar_backdrop');
64
69
 
65
- let width = mm('tablet-landscape-up')
66
- ? $b.offsetWidth + $b.querySelector('.sidebar__aside').offsetWidth
67
- : $b.offsetWidth;
68
- if ($b.classList.contains('sidebar_left')) {
69
- width = width * -1;
70
- }
71
- await $b.animate([{ transform: 'translateX(0px)' }, { transform: `translateX(${width}px)` }], {
70
+ await slideSidebar($b, [{ transform: 'translateX(0px)' }, { transform: `translateX(${getSidebarWidth($b)}px)` }], {
72
71
  duration: cssVar('--duration-leave-m'),
73
72
  easing: cssVar('--easing-acceleration'),
74
- }).finished;
73
+ });
75
74
 
76
75
  $b.hidden = true;
77
76
  if ($b.id !== 'settings-generator') {
@@ -1,6 +1,7 @@
1
1
  @use '../../variables' as *;
2
2
 
3
3
  $b: '.sidebar';
4
+ $sidebar-button-size: 56px;
4
5
 
5
6
  #{$b} {
6
7
  display: flex;
@@ -27,17 +28,13 @@ $b: '.sidebar';
27
28
  }
28
29
 
29
30
  &_backdrop {
30
- @media (--tablet-landscape-up) {
31
- background-color: $sidebar-backdrop-color;
32
- }
31
+ background-color: $sidebar-backdrop-color;
33
32
 
34
33
  // Т. к. .loader исчезает постепенно, с таким же эффектом показываем оверлей, чтобы не было мерцания
35
34
  body:has(.loader_active) & {
36
- @media (--tablet-landscape-up) {
37
- transition-duration: var(--duration-leave-m);
38
- transition-property: background-color;
39
- transition-timing-function: var(--easing-standard);
40
- }
35
+ transition-duration: var(--duration-leave-m);
36
+ transition-property: background-color;
37
+ transition-timing-function: var(--easing-standard);
41
38
  }
42
39
  }
43
40
 
@@ -46,7 +43,7 @@ $b: '.sidebar';
46
43
  display: flex;
47
44
  flex-direction: column;
48
45
  position: absolute;
49
- right: 100%;
46
+ right: calc(100% - $sidebar-button-size);
50
47
  top: 0;
51
48
 
52
49
  @media (--tablet-landscape-up) {
@@ -67,7 +64,7 @@ $b: '.sidebar';
67
64
 
68
65
  #{$b}_left & {
69
66
  align-items: flex-start;
70
- left: 100%;
67
+ left: calc(100% - $sidebar-button-size);
71
68
  right: auto;
72
69
 
73
70
  @media (--tablet-landscape-up) {
@@ -93,12 +90,12 @@ $b: '.sidebar';
93
90
  background-color: $sidebar-disabled-button-bg;
94
91
  color: $sidebar-disabled-button-color;
95
92
  display: flex;
96
- height: 4px * 14;
93
+ height: $sidebar-button-size;
97
94
  justify-content: center;
98
95
  transition-duration: var(--duration-micro-s);
99
96
  transition-property: background-color, color;
100
97
  transition-timing-function: var(--easing-standard);
101
- width: 4px * 14;
98
+ width: $sidebar-button-size;
102
99
 
103
100
  #{$b}_catalog & {
104
101
  @media (--tablet-landscape-up) {
@@ -136,9 +133,9 @@ $b: '.sidebar';
136
133
  color: $sidebar-disabled-button-label-color;
137
134
  height: auto;
138
135
  justify-content: flex-start;
139
- min-height: 4px * 14;
140
- min-width: 4px * 28;
141
- padding: 4px * 4;
136
+ min-height: $sidebar-button-size;
137
+ min-width: 112px;
138
+ padding: 16px;
142
139
  width: 100%;
143
140
 
144
141
  @include font($sidebar-button-label-font);
@@ -155,7 +152,7 @@ $b: '.sidebar';
155
152
 
156
153
  #{$b}_catalog & {
157
154
  @media (--tablet-landscape-up) {
158
- min-width: 4px * 56;
155
+ min-width: 224px;
159
156
  }
160
157
  }
161
158
  }
@@ -163,12 +160,12 @@ $b: '.sidebar';
163
160
 
164
161
  &__button-icon {
165
162
  fill: currentcolor;
166
- height: 4px * 6;
167
- width: 4px * 6;
163
+ height: 24px;
164
+ width: 24px;
168
165
 
169
166
  [data-sidebar-close] & {
170
- height: 4px * 5;
171
- width: 4px * 5;
167
+ height: 20px;
168
+ width: 20px;
172
169
  }
173
170
  }
174
171
 
@@ -185,7 +182,7 @@ $b: '.sidebar';
185
182
  height: 100%;
186
183
  overflow: auto;
187
184
  -webkit-overflow-scrolling: touch;
188
- width: calc(100% - 56px);
185
+ width: calc(100% - $sidebar-button-size);
189
186
 
190
187
  @media (--tablet-landscape-up) {
191
188
  width: 320px;
@@ -205,7 +202,7 @@ $b: '.sidebar';
205
202
 
206
203
  #{$b}_catalog & {
207
204
  @media (--tablet-landscape-up) {
208
- height: calc(100% - (4px * 14 + 1px));
205
+ height: calc(100% - (56px + 1px));
209
206
  }
210
207
  }
211
208
  }
@@ -223,21 +220,21 @@ $b: '.sidebar';
223
220
  flex-direction: column;
224
221
  flex-shrink: 0;
225
222
  justify-content: center;
226
- margin-bottom: 4px * 4;
227
- min-height: 4px * 14;
228
- padding-bottom: 4px * 4;
229
- padding-left: 4px * 4;
230
- padding-right: 4px * 4;
231
- padding-top: 4px * 4 + 1px;
223
+ margin-bottom: 16px;
224
+ min-height: 56px;
225
+ padding-bottom: 16px;
226
+ padding-left: 16px;
227
+ padding-right: 16px;
228
+ padding-top: 16px + 1px;
232
229
 
233
230
  #{$b}_catalog & {
234
231
  @media (--tablet-landscape-up) {
235
232
  background-color: $sidebar-catalog-header-bg;
236
- left: -4px * 56;
233
+ left: -224px;
237
234
  margin-bottom: 0;
238
- padding-left: 4px * 2;
235
+ padding-left: 8px;
239
236
  position: relative;
240
- width: calc(100% + 4px * 56);
237
+ width: calc(100% + 224px);
241
238
  z-index: 1;
242
239
  }
243
240
  }
@@ -248,27 +245,27 @@ $b: '.sidebar';
248
245
  border: $sidebar-header-icon-border-width solid $sidebar-header-icon-border-color;
249
246
  border-radius: 50%;
250
247
  display: flex;
251
- height: 4px * 6;
248
+ height: 24px;
252
249
  justify-content: center;
253
250
  position: relative;
254
- width: 4px * 6;
251
+ width: 24px;
255
252
 
256
253
  @media (--tablet-landscape-up) {
257
254
  background-color: $sidebar-header-icon-bg;
258
255
  border-style: none;
259
- height: 4px * 12;
260
- width: 4px * 12;
256
+ height: 48px;
257
+ width: 48px;
261
258
  }
262
259
  }
263
260
 
264
261
  &__header-icon {
265
262
  fill: $sidebar-header-icon-color;
266
- height: 4px * 4;
267
- width: 4px * 4;
263
+ height: 16px;
264
+ width: 16px;
268
265
 
269
266
  @media (--tablet-landscape-up) {
270
- height: 4px * 6;
271
- width: 4px * 6;
267
+ height: 24px;
268
+ width: 24px;
272
269
  }
273
270
  }
274
271
 
@@ -279,7 +276,7 @@ $b: '.sidebar';
279
276
  @include font($sidebar-header-title-font);
280
277
 
281
278
  @media (--tablet-landscape-up) {
282
- margin-top: 4px * 2;
279
+ margin-top: 8px;
283
280
  }
284
281
  }
285
282
 
@@ -295,7 +292,7 @@ $b: '.sidebar';
295
292
  }
296
293
 
297
294
  &:not(:first-child) {
298
- margin-top: 4px * 2;
295
+ margin-top: 8px;
299
296
  }
300
297
 
301
298
  &:first-child:last-child {
@@ -315,7 +312,7 @@ $b: '.sidebar';
315
312
  }
316
313
 
317
314
  &:not(:first-child) {
318
- margin-top: 4px * 2;
315
+ margin-top: 8px;
319
316
  }
320
317
 
321
318
  &:first-child:last-child {
@@ -327,18 +324,18 @@ $b: '.sidebar';
327
324
  text-align: left;
328
325
 
329
326
  @media (--tablet-landscape-up) {
330
- margin-left: 4px * 2;
331
- margin-right: 4px * 2;
327
+ margin-left: 8px;
328
+ margin-right: 8px;
332
329
  }
333
330
  }
334
331
  }
335
332
 
336
333
  &__header-link {
337
- margin-top: 4px * 2;
334
+ margin-top: 8px;
338
335
 
339
336
  @media (--tablet-landscape-up) {
340
337
  flex-shrink: 0;
341
- margin-left: 4px * 2;
338
+ margin-left: 8px;
342
339
  margin-top: 0;
343
340
  }
344
341
  }
@@ -346,33 +343,33 @@ $b: '.sidebar';
346
343
  &__sub-title {
347
344
  background-color: $sidebar-sub-title-bg;
348
345
  color: $sidebar-sub-title-color;
349
- margin-bottom: 4px * 4;
350
- padding: 4px * 2 4px * 4;
346
+ margin-bottom: 16px;
347
+ padding: 8px 16px;
351
348
  text-align: center;
352
349
 
353
350
  @include font($sidebar-sub-title-font);
354
351
 
355
352
  #{$b}__header + & {
356
- margin-top: -4px * 4;
353
+ margin-top: -16px;
357
354
 
358
355
  @media (--tablet-landscape-up) {
359
- margin-top: -4px * 8;
356
+ margin-top: -32px;
360
357
  }
361
358
  }
362
359
  }
363
360
 
364
361
  &__specs {
365
362
  &:last-child {
366
- margin-bottom: 4px * 6;
363
+ margin-bottom: 24px;
367
364
  }
368
365
  }
369
366
 
370
367
  &__action-list {
371
- margin-top: 4px * 6;
372
- padding: 0 4px * 4;
368
+ margin-top: 24px;
369
+ padding: 0 16px;
373
370
 
374
371
  &:last-child {
375
- margin-bottom: 4px * 6;
372
+ margin-bottom: 24px;
376
373
  }
377
374
  }
378
375
 
@@ -380,13 +377,13 @@ $b: '.sidebar';
380
377
  width: 100%;
381
378
 
382
379
  &:not(:first-child) {
383
- margin-top: 4px * 4;
380
+ margin-top: 16px;
384
381
  }
385
382
  }
386
383
 
387
384
  &__descr {
388
385
  color: $sidebar-descr-color;
389
- margin-top: 4px * 2;
386
+ margin-top: 8px;
390
387
  width: 100%;
391
388
 
392
389
  @include font($sidebar-descr-font);
@@ -401,8 +398,8 @@ $b: '.sidebar';
401
398
  > svg {
402
399
  display: block;
403
400
  fill: $sidebar-descr-icon-color;
404
- height: 4px * 4;
405
- width: 4px * 4;
401
+ height: 16px;
402
+ width: 16px;
406
403
  }
407
404
  }
408
405
 
@@ -412,7 +409,7 @@ $b: '.sidebar';
412
409
 
413
410
  &__footer {
414
411
  flex-shrink: 0;
415
- margin-top: 4px * 4;
412
+ margin-top: 16px;
416
413
  }
417
414
 
418
415
  &__toggle-wrapper {
@@ -423,13 +420,13 @@ $b: '.sidebar';
423
420
  }
424
421
 
425
422
  &__toggle {
426
- margin-bottom: 4px * 2;
427
- margin-top: 4px * 4;
423
+ margin-bottom: 8px;
424
+ margin-top: 16px;
428
425
 
429
426
  @media (--tablet-landscape-up) {
430
427
  flex-shrink: 0;
431
428
  margin-bottom: 0;
432
- margin-left: 4px * 4;
429
+ margin-left: 16px;
433
430
  margin-top: 0;
434
431
  }
435
432
  }
@@ -17,25 +17,14 @@ const setLeftWidth = async ($line, $el) => {
17
17
  }).finished;
18
18
  };
19
19
 
20
- const setActive = ($el, active) => {
21
- if ($el.tagName === 'BUTTON') {
22
- $el.disabled = active;
23
- } else if (active) {
24
- $el.dataset.disabled = '';
25
- } else {
26
- delete $el.dataset.disabled;
27
- }
28
- };
29
-
30
20
  export const setInitLineStyles = ($b) => {
31
21
  const $nav = $b.querySelector('.tabs__nav');
32
22
  const $items = $nav.querySelectorAll('.tabs__item');
33
23
  const $line = $nav.querySelector('.tabs__line');
34
24
 
35
- const $el =
36
- [...$items].find((el) => {
37
- return el.tagName === 'BUTTON' ? el.disabled : el.dataset.disabled !== undefined;
38
- }) || $items[0];
25
+ const $el = [...$items].find((el) => {
26
+ return el.disabled || (el.tagName !== 'BUTTON' && !el.href);
27
+ });
39
28
 
40
29
  setLeftWidth($line, $el);
41
30
  // Прокручиваем до нужного таба
@@ -58,7 +47,7 @@ const changeTab = ($el) => {
58
47
  const index = [...$items].indexOf($el);
59
48
 
60
49
  for (const [i, $item] of $items.entries()) {
61
- setActive($item, i === index);
50
+ $item.disabled = i === index;
62
51
  }
63
52
 
64
53
  for (const [i, $c] of $content.entries()) {
@@ -89,28 +78,25 @@ export const init = async ($b) => {
89
78
  const handleItemClick = async (e) => {
90
79
  const $el = e.currentTarget;
91
80
  const index = [...$items].indexOf($el);
81
+ if ($el.tagName === 'BUTTON') {
82
+ if ($el.dataset.tabsFetch && $content[index].innerHTML.trim() === '') {
83
+ const { content } = await request({ url: $el.dataset.tabsFetch });
84
+ // Вставляем полученный HTML
85
+ $content[index].innerHTML = content;
86
+ // Переключаем таб
87
+ changeTab($el);
88
+ } else {
89
+ // Переключаем таб
90
+ changeTab($el);
91
+ }
92
92
 
93
- if ($el.tagName === 'A') {
94
- e.preventDefault();
95
- }
96
-
97
- if ($el.dataset.tabsFetch && $content[index].innerHTML.trim() === '') {
98
- const { content } = await request({ url: $el.dataset.tabsFetch });
99
- // Вставляем полученный HTML
100
- $content[index].innerHTML = content;
101
- // Переключаем таб
102
- changeTab($el);
103
- } else {
104
- // Переключаем таб
105
- changeTab($el);
106
- }
107
-
108
- if ($nav.swiper) {
109
- $nav.swiper.slideTo(index);
110
- }
93
+ if ($nav.swiper) {
94
+ $nav.swiper.slideTo(index);
95
+ }
111
96
 
112
- if ($line) {
113
- setLeftWidth($line, $el);
97
+ if ($line) {
98
+ setLeftWidth($line, $el);
99
+ }
114
100
  }
115
101
  };
116
102
 
@@ -111,11 +111,6 @@ $b: '.tabs';
111
111
  &.swiper-slide {
112
112
  width: auto;
113
113
  }
114
-
115
- &[data-disabled] {
116
- color: $font-color-primary;
117
- pointer-events: none;
118
- }
119
114
  }
120
115
 
121
116
  &__label {