@formixru/b2b-ui 3.0.5 → 3.1.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 +4 -1
- package/src/components/dialog/index.scss +0 -9
- package/src/components/form/index.js +2 -1
- package/src/components/quantity-input/index.scss +2 -8
- package/src/components/quantity-input/index.vue +1 -0
- package/src/components/sidebar/index.scss +0 -7
- package/src/components/tabs/index.js +13 -20
- package/src/utils/error-handler.js +2 -6
- package/src/utils/scroll-to.js +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@formixru/b2b-ui",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -98,5 +98,8 @@
|
|
|
98
98
|
"workerDirectory": [
|
|
99
99
|
".storybook/static"
|
|
100
100
|
]
|
|
101
|
+
},
|
|
102
|
+
"dependencies": {
|
|
103
|
+
"@advdominion/scroll-to": "^1.0.0"
|
|
101
104
|
}
|
|
102
105
|
}
|
|
@@ -54,15 +54,6 @@ $b: '.dialog';
|
|
|
54
54
|
min-height: auto;
|
|
55
55
|
padding: 4px * 10;
|
|
56
56
|
position: relative;
|
|
57
|
-
transition-duration: var(--duration-leave-s);
|
|
58
|
-
transition-property: opacity;
|
|
59
|
-
transition-timing-function: var(--easing-acceleration);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
body:has(.loader_active) & {
|
|
63
|
-
@media (--tablet-landscape-up) {
|
|
64
|
-
opacity: 0.5;
|
|
65
|
-
}
|
|
66
57
|
}
|
|
67
58
|
|
|
68
59
|
#{$b}_overflow & {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* globals SmartCaptcha, SMART_CAPTCHA_KEY */
|
|
2
2
|
|
|
3
|
+
import { scrollTo } from '@advdominion/scroll-to';
|
|
4
|
+
|
|
3
5
|
import { getSmartCaptcha } from '../../utils/get-smart-captcha.js';
|
|
4
|
-
import { scrollTo } from '../../utils/scroll-to.js';
|
|
5
6
|
import { initRequestContent, request } from '../request/index.js';
|
|
6
7
|
|
|
7
8
|
const scrollToError = ($b = document.body) => {
|
|
@@ -123,7 +123,7 @@ $b: '.quantity-input';
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
&__input {
|
|
126
|
-
appearance:
|
|
126
|
+
appearance: textfield;
|
|
127
127
|
background-color: $quantity-input-bg;
|
|
128
128
|
border-bottom: $quantity-input-border-width solid $quantity-input-border-color;
|
|
129
129
|
border-left-style: none;
|
|
@@ -142,15 +142,9 @@ $b: '.quantity-input';
|
|
|
142
142
|
|
|
143
143
|
@include font($quantity-input-font);
|
|
144
144
|
|
|
145
|
-
@media (--tablet-landscape-up) {
|
|
146
|
-
appearance: textfield;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
145
|
&::-webkit-inner-spin-button,
|
|
150
146
|
&::-webkit-outer-spin-button {
|
|
151
|
-
|
|
152
|
-
appearance: none;
|
|
153
|
-
}
|
|
147
|
+
appearance: none;
|
|
154
148
|
}
|
|
155
149
|
|
|
156
150
|
&:disabled {
|
|
@@ -8,9 +8,6 @@ $b: '.sidebar';
|
|
|
8
8
|
position: fixed;
|
|
9
9
|
right: 0;
|
|
10
10
|
top: 0;
|
|
11
|
-
transition-duration: var(--duration-leave-s);
|
|
12
|
-
transition-property: opacity;
|
|
13
|
-
transition-timing-function: var(--easing-acceleration);
|
|
14
11
|
width: calc(100% - 56px);
|
|
15
12
|
z-index: 910;
|
|
16
13
|
|
|
@@ -19,10 +16,6 @@ $b: '.sidebar';
|
|
|
19
16
|
width: 320px;
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
body:has(.loader_active) & {
|
|
23
|
-
opacity: 0.5;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
19
|
&_left {
|
|
27
20
|
left: 0;
|
|
28
21
|
right: auto;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* globals BX */
|
|
2
2
|
|
|
3
|
+
import { scrollTo } from '@advdominion/scroll-to';
|
|
4
|
+
|
|
3
5
|
import { cssVar } from '../../utils/css-var.js';
|
|
4
6
|
import { errorHandler } from '../../utils/error-handler.js';
|
|
5
7
|
import { isInViewport } from '../../utils/is-in-viewport.js';
|
|
6
|
-
import { scrollTo } from '../../utils/scroll-to.js';
|
|
7
8
|
import { hide as hideLoader, show as showLoader } from '../loader/index.js';
|
|
8
9
|
|
|
9
10
|
const setLeftWidth = async ($line, $el) => {
|
|
@@ -21,18 +22,16 @@ const setLeftWidth = async ($line, $el) => {
|
|
|
21
22
|
|
|
22
23
|
export const setInitLineStyles = ($b) => {
|
|
23
24
|
const $nav = $b.querySelector('.tabs__nav');
|
|
24
|
-
const $
|
|
25
|
+
const $items = $nav.querySelectorAll('.tabs__item');
|
|
25
26
|
const $line = $nav.querySelector('.tabs__line');
|
|
26
27
|
|
|
27
|
-
const $el = [...$
|
|
28
|
+
const $el = [...$items].find((el) => {
|
|
28
29
|
return el.disabled || (el.tagName !== 'BUTTON' && !el.href);
|
|
29
30
|
});
|
|
30
31
|
|
|
31
32
|
setLeftWidth($line, $el);
|
|
32
33
|
// Прокручиваем до нужного таба
|
|
33
|
-
|
|
34
|
-
$nav.swiper.slideTo([...$item].indexOf($el));
|
|
35
|
-
}
|
|
34
|
+
$nav.swiper?.slideTo([...$items].indexOf($el));
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
const initTabsContent = ($b) => {
|
|
@@ -46,14 +45,14 @@ const initTabsContent = ($b) => {
|
|
|
46
45
|
export const init = async ($b) => {
|
|
47
46
|
const $nav = $b.querySelector('.tabs__nav');
|
|
48
47
|
const $list = $nav.querySelector('.tabs__list');
|
|
49
|
-
const $
|
|
48
|
+
const $items = $nav.querySelectorAll('.tabs__item');
|
|
50
49
|
const $line = $nav.querySelector('.tabs__line');
|
|
51
50
|
const $content = $b.querySelectorAll('.tabs__content');
|
|
52
51
|
|
|
53
52
|
// Переключаем табы и меняем стили для линии
|
|
54
53
|
const handleItemClick = async (e) => {
|
|
55
54
|
const $el = e.currentTarget;
|
|
56
|
-
const index = [...$
|
|
55
|
+
const index = [...$items].indexOf($el);
|
|
57
56
|
if ($el.tagName === 'BUTTON') {
|
|
58
57
|
if ($el.dataset.tabsFetch && $content[index].innerHTML.trim() === '') {
|
|
59
58
|
showLoader();
|
|
@@ -73,7 +72,7 @@ export const init = async ($b) => {
|
|
|
73
72
|
// Вставляем полученный HTML
|
|
74
73
|
$content[index].innerHTML = data;
|
|
75
74
|
// Переключаем таб
|
|
76
|
-
for (const i of $
|
|
75
|
+
for (const i of $items) i.disabled = false;
|
|
77
76
|
$el.disabled = true;
|
|
78
77
|
for (const [i, c] of $content.entries()) {
|
|
79
78
|
if (i === index) {
|
|
@@ -102,7 +101,7 @@ export const init = async ($b) => {
|
|
|
102
101
|
}
|
|
103
102
|
} else {
|
|
104
103
|
// Переключаем таб
|
|
105
|
-
for (const i of $
|
|
104
|
+
for (const i of $items) i.disabled = false;
|
|
106
105
|
$el.disabled = true;
|
|
107
106
|
for (const [i, c] of $content.entries()) {
|
|
108
107
|
if (i === index) {
|
|
@@ -135,14 +134,14 @@ export const init = async ($b) => {
|
|
|
135
134
|
|
|
136
135
|
if ($nav.swiper) {
|
|
137
136
|
$nav.swiper.destroy();
|
|
138
|
-
for (const i of $
|
|
137
|
+
for (const i of $items) i.removeEventListener('click', handleItemClick);
|
|
139
138
|
}
|
|
140
139
|
|
|
141
140
|
const { default: Swiper } = await import('swiper');
|
|
142
141
|
|
|
143
142
|
$nav.classList.add('swiper');
|
|
144
143
|
$list.classList.add('swiper-wrapper');
|
|
145
|
-
for (const i of $
|
|
144
|
+
for (const i of $items) i.classList.add('swiper-slide');
|
|
146
145
|
|
|
147
146
|
new Swiper($nav, {
|
|
148
147
|
speed: cssVar('--duration-effect-s'),
|
|
@@ -150,6 +149,7 @@ export const init = async ($b) => {
|
|
|
150
149
|
freeMode: true,
|
|
151
150
|
on: {
|
|
152
151
|
init() {
|
|
152
|
+
setInitLineStyles($b); // Устанавливаем стили для линии при загрузке страницы
|
|
153
153
|
if (!this.isBeginning) {
|
|
154
154
|
$nav.classList.toggle('tabs__nav_shadow-start', true);
|
|
155
155
|
}
|
|
@@ -168,14 +168,7 @@ export const init = async ($b) => {
|
|
|
168
168
|
},
|
|
169
169
|
});
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
if ($line) {
|
|
173
|
-
setTimeout(() => {
|
|
174
|
-
setInitLineStyles($b);
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
for (const i of $item) i.addEventListener('click', handleItemClick);
|
|
171
|
+
for (const i of $items) i.addEventListener('click', handleItemClick);
|
|
179
172
|
};
|
|
180
173
|
|
|
181
174
|
document.body.addEventListener('click', async (e) => {
|
|
@@ -42,15 +42,11 @@ export const errorHandler = async (error) => {
|
|
|
42
42
|
}
|
|
43
43
|
const $descr = $dialog.querySelector('.dialog__descr');
|
|
44
44
|
$descr.innerHTML = content;
|
|
45
|
-
$descr.style =
|
|
46
|
-
overflow: auto;
|
|
47
|
-
`;
|
|
45
|
+
$descr.style.overflow = 'auto';
|
|
48
46
|
$dialog.addEventListener(
|
|
49
47
|
'dialog-hidden',
|
|
50
48
|
() => {
|
|
51
|
-
$descr.style =
|
|
52
|
-
overflow: '';
|
|
53
|
-
`;
|
|
49
|
+
$descr.style.overflow = '';
|
|
54
50
|
},
|
|
55
51
|
{
|
|
56
52
|
once: true,
|
package/src/utils/scroll-to.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export const scrollTo = ($el, offset = 0) => {
|
|
2
|
-
return new Promise((resolve) => {
|
|
3
|
-
const observer = new IntersectionObserver((entries) => {
|
|
4
|
-
if (entries[0].isIntersecting) {
|
|
5
|
-
observer.disconnect();
|
|
6
|
-
setTimeout(() => {
|
|
7
|
-
resolve();
|
|
8
|
-
}, 500);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
observer.observe($el);
|
|
12
|
-
|
|
13
|
-
const elementTop = $el.getBoundingClientRect().top + window.pageYOffset;
|
|
14
|
-
const offsetValue = (window.innerHeight * offset) / 100;
|
|
15
|
-
|
|
16
|
-
window.scrollTo({
|
|
17
|
-
top: elementTop - offsetValue,
|
|
18
|
-
behavior: 'smooth',
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
};
|