@formixru/b2b-ui 4.5.3 → 4.6.0

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.5.3",
3
+ "version": "4.6.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,14 +17,25 @@ 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
+
20
30
  export const setInitLineStyles = ($b) => {
21
31
  const $nav = $b.querySelector('.tabs__nav');
22
32
  const $items = $nav.querySelectorAll('.tabs__item');
23
33
  const $line = $nav.querySelector('.tabs__line');
24
34
 
25
- const $el = [...$items].find((el) => {
26
- return el.disabled || (el.tagName !== 'BUTTON' && !el.href);
27
- });
35
+ const $el =
36
+ [...$items].find((el) => {
37
+ return el.tagName === 'BUTTON' ? el.disabled : el.dataset.disabled !== undefined;
38
+ }) || $items[0];
28
39
 
29
40
  setLeftWidth($line, $el);
30
41
  // Прокручиваем до нужного таба
@@ -47,7 +58,7 @@ const changeTab = ($el) => {
47
58
  const index = [...$items].indexOf($el);
48
59
 
49
60
  for (const [i, $item] of $items.entries()) {
50
- $item.disabled = i === index;
61
+ setActive($item, i === index);
51
62
  }
52
63
 
53
64
  for (const [i, $c] of $content.entries()) {
@@ -78,25 +89,28 @@ export const init = async ($b) => {
78
89
  const handleItemClick = async (e) => {
79
90
  const $el = e.currentTarget;
80
91
  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 ($nav.swiper) {
94
- $nav.swiper.slideTo(index);
95
- }
93
+ if ($el.tagName === 'A') {
94
+ e.preventDefault();
95
+ }
96
96
 
97
- if ($line) {
98
- setLeftWidth($line, $el);
99
- }
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
+ }
111
+
112
+ if ($line) {
113
+ setLeftWidth($line, $el);
100
114
  }
101
115
  };
102
116
 
@@ -111,6 +111,11 @@ $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
+ }
114
119
  }
115
120
 
116
121
  &__label {
@@ -132,6 +137,10 @@ $b: '.tabs';
132
137
  top: -1px;
133
138
 
134
139
  @include font($tabs-counter-font);
140
+
141
+ &:empty {
142
+ display: none;
143
+ }
135
144
  }
136
145
 
137
146
  &__line {