@formixru/b2b-ui 3.2.0 → 3.3.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 +1 -1
- package/src/components/tabs/index.js +53 -79
- package/src/components/total/index.scss +14 -15
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
/* globals BX */
|
|
2
|
-
|
|
3
1
|
import { scrollTo } from '@advdominion/scroll-to';
|
|
4
2
|
|
|
5
3
|
import { cssVar } from '../../utils/css-var.js';
|
|
6
|
-
import { errorHandler } from '../../utils/error-handler.js';
|
|
7
4
|
import { isInViewport } from '../../utils/is-in-viewport.js';
|
|
8
|
-
import {
|
|
5
|
+
import { request } from '../request/index.js';
|
|
9
6
|
|
|
10
7
|
const setLeftWidth = async ($line, $el) => {
|
|
11
8
|
const $label = $el.querySelector('.tabs__label');
|
|
@@ -42,6 +39,34 @@ const initTabsContent = ($b) => {
|
|
|
42
39
|
}
|
|
43
40
|
};
|
|
44
41
|
|
|
42
|
+
const changeTab = ($el) => {
|
|
43
|
+
const $b = $el.closest('.tabs');
|
|
44
|
+
const $items = $b.querySelectorAll('.tabs__item');
|
|
45
|
+
const $content = $b.querySelectorAll('.tabs__content');
|
|
46
|
+
|
|
47
|
+
const index = [...$items].indexOf($el);
|
|
48
|
+
|
|
49
|
+
for (const [i, $item] of $items.entries()) {
|
|
50
|
+
$item.disabled = i === index;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
for (const [i, $c] of $content.entries()) {
|
|
54
|
+
if (i === index) {
|
|
55
|
+
$c.hidden = false;
|
|
56
|
+
for (const $el of $c.querySelectorAll('.swiper')) {
|
|
57
|
+
$el.swiper?.update();
|
|
58
|
+
}
|
|
59
|
+
for (const $el of $c.querySelectorAll('.tabs')) {
|
|
60
|
+
setInitLineStyles($el);
|
|
61
|
+
}
|
|
62
|
+
// Инициализируем полученный HTML
|
|
63
|
+
initTabsContent($content[index]);
|
|
64
|
+
} else {
|
|
65
|
+
$c.hidden = true;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
45
70
|
export const init = async ($b) => {
|
|
46
71
|
const $nav = $b.querySelector('.tabs__nav');
|
|
47
72
|
const $list = $nav.querySelector('.tabs__list');
|
|
@@ -55,71 +80,14 @@ export const init = async ($b) => {
|
|
|
55
80
|
const index = [...$items].indexOf($el);
|
|
56
81
|
if ($el.tagName === 'BUTTON') {
|
|
57
82
|
if ($el.dataset.tabsFetch && $content[index].innerHTML.trim() === '') {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
'X-Requested-With': 'XMLHttpRequest',
|
|
64
|
-
'X-Session-Id': BX.message('bitrix_sessid'),
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
if (!response.ok) {
|
|
68
|
-
throw response;
|
|
69
|
-
}
|
|
70
|
-
const data = await response.text();
|
|
71
|
-
hideLoader();
|
|
72
|
-
// Вставляем полученный HTML
|
|
73
|
-
$content[index].innerHTML = data;
|
|
74
|
-
// Переключаем таб
|
|
75
|
-
for (const i of $items) i.disabled = false;
|
|
76
|
-
$el.disabled = true;
|
|
77
|
-
for (const [i, c] of $content.entries()) {
|
|
78
|
-
if (i === index) {
|
|
79
|
-
c.hidden = false;
|
|
80
|
-
for (const swiperEl of c.querySelectorAll('.swiper')) {
|
|
81
|
-
if (swiperEl.swiper) {
|
|
82
|
-
swiperEl.swiper.update();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
for (const tabsEl of c.querySelectorAll('.tabs')) {
|
|
86
|
-
setInitLineStyles(tabsEl);
|
|
87
|
-
}
|
|
88
|
-
// Инициализируем полученный HTML
|
|
89
|
-
initTabsContent($content[index]);
|
|
90
|
-
} else {
|
|
91
|
-
c.hidden = true;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
} catch (error) {
|
|
95
|
-
hideLoader();
|
|
96
|
-
if (error.status === 401) {
|
|
97
|
-
location.reload();
|
|
98
|
-
} else {
|
|
99
|
-
errorHandler(error);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
83
|
+
const { content } = await request({ url: $el.dataset.tabsFetch });
|
|
84
|
+
// Вставляем полученный HTML
|
|
85
|
+
$content[index].innerHTML = content;
|
|
86
|
+
// Переключаем таб
|
|
87
|
+
changeTab($el);
|
|
102
88
|
} else {
|
|
103
89
|
// Переключаем таб
|
|
104
|
-
|
|
105
|
-
$el.disabled = true;
|
|
106
|
-
for (const [i, c] of $content.entries()) {
|
|
107
|
-
if (i === index) {
|
|
108
|
-
c.hidden = false;
|
|
109
|
-
for (const swiperEl of c.querySelectorAll('.swiper')) {
|
|
110
|
-
if (swiperEl.swiper) {
|
|
111
|
-
swiperEl.swiper.update();
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
for (const tabsEl of c.querySelectorAll('.tabs')) {
|
|
115
|
-
setInitLineStyles(tabsEl);
|
|
116
|
-
}
|
|
117
|
-
// Инициализируем полученный HTML
|
|
118
|
-
initTabsContent($content[index]);
|
|
119
|
-
} else {
|
|
120
|
-
c.hidden = true;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
90
|
+
changeTab($el);
|
|
123
91
|
}
|
|
124
92
|
|
|
125
93
|
if ($nav.swiper) {
|
|
@@ -134,41 +102,47 @@ export const init = async ($b) => {
|
|
|
134
102
|
|
|
135
103
|
if ($nav.swiper) {
|
|
136
104
|
$nav.swiper.destroy();
|
|
137
|
-
for (const
|
|
105
|
+
for (const $item of $items) {
|
|
106
|
+
$item.removeEventListener('click', handleItemClick);
|
|
107
|
+
}
|
|
138
108
|
}
|
|
139
109
|
|
|
140
110
|
const { default: Swiper } = await import('swiper');
|
|
141
111
|
|
|
142
112
|
$nav.classList.add('swiper');
|
|
143
113
|
$list.classList.add('swiper-wrapper');
|
|
144
|
-
for (const
|
|
114
|
+
for (const $item of $items) {
|
|
115
|
+
$item.classList.add('swiper-slide');
|
|
116
|
+
}
|
|
145
117
|
|
|
146
118
|
new Swiper($nav, {
|
|
147
119
|
speed: cssVar('--duration-effect-s'),
|
|
148
120
|
slidesPerView: 'auto',
|
|
149
121
|
freeMode: true,
|
|
150
122
|
on: {
|
|
151
|
-
init() {
|
|
123
|
+
init(swiper) {
|
|
152
124
|
setInitLineStyles($b); // Устанавливаем стили для линии при загрузке страницы
|
|
153
|
-
if (!
|
|
125
|
+
if (!swiper.isBeginning) {
|
|
154
126
|
$nav.classList.toggle('tabs__nav_shadow-start', true);
|
|
155
127
|
}
|
|
156
|
-
if (!
|
|
128
|
+
if (!swiper.isEnd) {
|
|
157
129
|
$nav.classList.toggle('tabs__nav_shadow-end', true);
|
|
158
130
|
}
|
|
159
131
|
},
|
|
160
|
-
sliderMove() {
|
|
161
|
-
$nav.classList.toggle('tabs__nav_shadow-start', !
|
|
162
|
-
$nav.classList.toggle('tabs__nav_shadow-end', !
|
|
132
|
+
sliderMove(swiper) {
|
|
133
|
+
$nav.classList.toggle('tabs__nav_shadow-start', !swiper.isBeginning);
|
|
134
|
+
$nav.classList.toggle('tabs__nav_shadow-end', !swiper.isEnd);
|
|
163
135
|
},
|
|
164
|
-
transitionStart() {
|
|
165
|
-
$nav.classList.toggle('tabs__nav_shadow-start', !
|
|
166
|
-
$nav.classList.toggle('tabs__nav_shadow-end', !
|
|
136
|
+
transitionStart(swiper) {
|
|
137
|
+
$nav.classList.toggle('tabs__nav_shadow-start', !swiper.isBeginning);
|
|
138
|
+
$nav.classList.toggle('tabs__nav_shadow-end', !swiper.isEnd);
|
|
167
139
|
},
|
|
168
140
|
},
|
|
169
141
|
});
|
|
170
142
|
|
|
171
|
-
for (const
|
|
143
|
+
for (const $item of $items) {
|
|
144
|
+
$item.addEventListener('click', handleItemClick);
|
|
145
|
+
}
|
|
172
146
|
};
|
|
173
147
|
|
|
174
148
|
document.body.addEventListener('click', async (e) => {
|
|
@@ -7,7 +7,7 @@ $b: '.total';
|
|
|
7
7
|
border-radius: $total-radius;
|
|
8
8
|
display: flex;
|
|
9
9
|
flex-direction: column;
|
|
10
|
-
padding:
|
|
10
|
+
padding: 24px 16px;
|
|
11
11
|
|
|
12
12
|
@include dark-border;
|
|
13
13
|
@include font($total-font);
|
|
@@ -16,8 +16,7 @@ $b: '.total';
|
|
|
16
16
|
align-items: center;
|
|
17
17
|
flex-direction: row;
|
|
18
18
|
justify-content: space-between;
|
|
19
|
-
padding
|
|
20
|
-
padding-right: 4px * 8;
|
|
19
|
+
padding: 24px;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
&_shadow {
|
|
@@ -35,11 +34,11 @@ $b: '.total';
|
|
|
35
34
|
&__wrapper {
|
|
36
35
|
display: flex;
|
|
37
36
|
flex-direction: column;
|
|
38
|
-
margin-top:
|
|
37
|
+
margin-top: 24px;
|
|
39
38
|
|
|
40
39
|
@media (--tablet-landscape-up) {
|
|
41
40
|
flex-direction: row;
|
|
42
|
-
margin-left:
|
|
41
|
+
margin-left: 32px;
|
|
43
42
|
margin-top: 0;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
@@ -56,18 +55,18 @@ $b: '.total';
|
|
|
56
55
|
justify-content: space-between;
|
|
57
56
|
|
|
58
57
|
&:not(:first-child) {
|
|
59
|
-
margin-top:
|
|
58
|
+
margin-top: 12px;
|
|
60
59
|
}
|
|
61
60
|
}
|
|
62
61
|
|
|
63
62
|
&__specs-label {
|
|
64
63
|
color: $total-specs-label-color;
|
|
65
|
-
margin-right:
|
|
64
|
+
margin-right: 24px;
|
|
66
65
|
|
|
67
66
|
@include font($total-specs-label-font);
|
|
68
67
|
|
|
69
68
|
@media (--tablet-landscape-up) {
|
|
70
|
-
max-width:
|
|
69
|
+
max-width: 100px;
|
|
71
70
|
}
|
|
72
71
|
}
|
|
73
72
|
|
|
@@ -87,13 +86,13 @@ $b: '.total';
|
|
|
87
86
|
justify-content: center;
|
|
88
87
|
|
|
89
88
|
&:not(:first-child) {
|
|
90
|
-
margin-top:
|
|
89
|
+
margin-top: 12px;
|
|
91
90
|
|
|
92
91
|
@media (--tablet-landscape-up) {
|
|
93
92
|
border-left: $total-amount-list-separator-width solid $total-amount-list-separator-color;
|
|
94
|
-
margin-left:
|
|
93
|
+
margin-left: 24px;
|
|
95
94
|
margin-top: 0;
|
|
96
|
-
padding-left:
|
|
95
|
+
padding-left: 24px;
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
}
|
|
@@ -104,7 +103,7 @@ $b: '.total';
|
|
|
104
103
|
justify-content: space-between;
|
|
105
104
|
|
|
106
105
|
&:not(:first-child) {
|
|
107
|
-
margin-top:
|
|
106
|
+
margin-top: 16px;
|
|
108
107
|
}
|
|
109
108
|
|
|
110
109
|
&_big {
|
|
@@ -114,7 +113,7 @@ $b: '.total';
|
|
|
114
113
|
|
|
115
114
|
&__amount-label {
|
|
116
115
|
color: $total-amount-label-color;
|
|
117
|
-
margin-right:
|
|
116
|
+
margin-right: 24px;
|
|
118
117
|
|
|
119
118
|
@include font($total-amount-label-font);
|
|
120
119
|
}
|
|
@@ -153,10 +152,10 @@ $b: '.total';
|
|
|
153
152
|
}
|
|
154
153
|
|
|
155
154
|
&__promocode {
|
|
156
|
-
margin-top:
|
|
155
|
+
margin-top: 16px;
|
|
157
156
|
|
|
158
157
|
@media (--tablet-landscape-up) {
|
|
159
|
-
width:
|
|
158
|
+
width: 340px;
|
|
160
159
|
}
|
|
161
160
|
}
|
|
162
161
|
}
|