@salutejs/plasma-new-hope 0.326.0-canary.2013.15538813402.0 → 0.326.0-canary.2013.15555525626.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/cjs/components/Carousel/CarouselNew/Carousel.css +5 -7
- package/cjs/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/cjs/components/Carousel/CarouselNew/Carousel.js.map +1 -1
- package/cjs/components/Carousel/CarouselNew/Carousel.styles.js +4 -13
- package/cjs/components/Carousel/CarouselNew/Carousel.styles.js.map +1 -1
- package/cjs/components/Carousel/CarouselNew/{Carousel.styles_1fs4wwn.css → Carousel.styles_a2t6qm.css} +2 -2
- package/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -61
- package/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js.map +1 -1
- package/cjs/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/cjs/components/Carousel/CarouselOld/CarouselItem.js.map +1 -1
- package/{es/components/Carousel/CarouselOld/CarouselItem_uvoxfy.css → cjs/components/Carousel/CarouselOld/CarouselItem_1meatnt.css} +1 -1
- package/cjs/index.css +6 -8
- package/cjs/index.js +1 -1
- package/emotion/cjs/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/emotion/cjs/components/Carousel/CarouselNew/Carousel.styles.js +17 -12
- package/emotion/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -60
- package/emotion/cjs/components/Carousel/CarouselNew/ui/index.js +0 -11
- package/emotion/cjs/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/emotion/cjs/components/Carousel/index.js +4 -4
- package/emotion/cjs/examples/plasma_b2c/components/Carousel/Carousel.config.js +3 -3
- package/emotion/cjs/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +22 -15
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.js +1 -1
- package/emotion/cjs/examples/plasma_web/components/Carousel/Carousel.stories.tsx +92 -32
- package/emotion/es/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/emotion/es/components/Carousel/CarouselNew/Carousel.styles.js +17 -12
- package/emotion/es/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -60
- package/emotion/es/components/Carousel/CarouselNew/ui/index.js +0 -1
- package/emotion/es/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/emotion/es/components/Carousel/index.js +1 -1
- package/emotion/es/examples/plasma_b2c/components/Carousel/Carousel.config.js +4 -4
- package/emotion/es/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +22 -15
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.js +2 -2
- package/emotion/es/examples/plasma_web/components/Carousel/Carousel.stories.tsx +92 -32
- package/es/components/Carousel/CarouselNew/Carousel.css +5 -7
- package/es/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/es/components/Carousel/CarouselNew/Carousel.js.map +1 -1
- package/es/components/Carousel/CarouselNew/Carousel.styles.js +4 -13
- package/es/components/Carousel/CarouselNew/Carousel.styles.js.map +1 -1
- package/es/components/Carousel/CarouselNew/{Carousel.styles_1fs4wwn.css → Carousel.styles_a2t6qm.css} +2 -2
- package/es/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -61
- package/es/components/Carousel/CarouselNew/hooks/useCarousel.js.map +1 -1
- package/es/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/es/components/Carousel/CarouselOld/CarouselItem.js.map +1 -1
- package/{cjs/components/Carousel/CarouselOld/CarouselItem_uvoxfy.css → es/components/Carousel/CarouselOld/CarouselItem_1meatnt.css} +1 -1
- package/es/index.css +6 -8
- package/es/index.js +1 -1
- package/package.json +5 -5
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/styled-components/cjs/components/Carousel/CarouselNew/Carousel.styles.js +2 -5
- package/styled-components/cjs/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -60
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/index.js +0 -11
- package/styled-components/cjs/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/styled-components/cjs/components/Carousel/index.js +4 -4
- package/styled-components/cjs/examples/plasma_b2c/components/Carousel/Carousel.config.js +2 -2
- package/styled-components/cjs/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +22 -15
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.js +1 -1
- package/styled-components/cjs/examples/plasma_web/components/Carousel/Carousel.stories.tsx +92 -32
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.js +6 -11
- package/styled-components/es/components/Carousel/CarouselNew/Carousel.styles.js +2 -5
- package/styled-components/es/components/Carousel/CarouselNew/hooks/useCarousel.js +17 -60
- package/styled-components/es/components/Carousel/CarouselNew/ui/index.js +0 -1
- package/styled-components/es/components/Carousel/CarouselOld/CarouselItem.js +1 -1
- package/styled-components/es/components/Carousel/index.js +1 -1
- package/styled-components/es/examples/plasma_b2c/components/Carousel/Carousel.config.js +2 -2
- package/styled-components/es/examples/plasma_b2c/components/Carousel/Carousel.stories.tsx +22 -15
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.config.js +14 -2
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.js +2 -2
- package/styled-components/es/examples/plasma_web/components/Carousel/Carousel.stories.tsx +92 -32
- package/types/components/Carousel/CarouselNew/Carousel.d.ts.map +1 -1
- package/types/components/Carousel/CarouselNew/Carousel.styles.d.ts +1 -4
- package/types/components/Carousel/CarouselNew/Carousel.styles.d.ts.map +1 -1
- package/types/components/Carousel/CarouselNew/Carousel.types.d.ts +6 -67
- package/types/components/Carousel/CarouselNew/Carousel.types.d.ts.map +1 -1
- package/types/components/Carousel/CarouselNew/hooks/useCarousel.d.ts +4 -6
- package/types/components/Carousel/CarouselNew/hooks/useCarousel.d.ts.map +1 -1
- package/types/components/Carousel/CarouselNew/ui/index.d.ts +0 -1
- package/types/components/Carousel/CarouselNew/ui/index.d.ts.map +1 -1
- package/types/components/Carousel/CarouselOld/CarouselItem.d.ts.map +1 -1
- package/types/components/Carousel/index.d.ts +1 -1
- package/types/components/Carousel/index.d.ts.map +1 -1
- package/cjs/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -62
- package/cjs/components/Carousel/CarouselNew/hooks/useDragScroll.js.map +0 -1
- package/emotion/cjs/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -65
- package/emotion/cjs/components/Carousel/CarouselNew/ui/Item/Item.js +0 -38
- package/emotion/es/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -59
- package/emotion/es/components/Carousel/CarouselNew/ui/Item/Item.js +0 -31
- package/es/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -58
- package/es/components/Carousel/CarouselNew/hooks/useDragScroll.js.map +0 -1
- package/styled-components/cjs/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -65
- package/styled-components/cjs/components/Carousel/CarouselNew/ui/Item/Item.js +0 -37
- package/styled-components/es/components/Carousel/CarouselNew/hooks/useDragScroll.js +0 -59
- package/styled-components/es/components/Carousel/CarouselNew/ui/Item/Item.js +0 -30
- package/types/components/Carousel/CarouselNew/hooks/useDragScroll.d.ts +0 -2
- package/types/components/Carousel/CarouselNew/hooks/useDragScroll.d.ts.map +0 -1
- package/types/components/Carousel/CarouselNew/ui/Item/Item.d.ts +0 -4
- package/types/components/Carousel/CarouselNew/ui/Item/Item.d.ts.map +0 -1
@@ -13,8 +13,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
|
|
13
13
|
/**
|
14
14
|
* Подсчет смещения из-за паддингов.
|
15
15
|
*/
|
16
|
-
var getCalculatedOffset = exports.getCalculatedOffset = function getCalculatedOffset(scrollEl, trackEl
|
17
|
-
var paddingProp =
|
16
|
+
var getCalculatedOffset = exports.getCalculatedOffset = function getCalculatedOffset(scrollEl, trackEl) {
|
17
|
+
var paddingProp = 'paddingLeft';
|
18
18
|
return parseInt(getComputedStyle(scrollEl)[paddingProp], 10) + parseInt(getComputedStyle(trackEl)[paddingProp], 10);
|
19
19
|
};
|
20
20
|
var positionModByScrollAlign = function positionModByScrollAlign(_ref) {
|
@@ -23,11 +23,9 @@ var positionModByScrollAlign = function positionModByScrollAlign(_ref) {
|
|
23
23
|
carouselSize = _ref.carouselSize,
|
24
24
|
itemSize = _ref.itemSize,
|
25
25
|
offset = _ref.offset,
|
26
|
-
scrollStart = _ref.scrollStart
|
27
|
-
axis = _ref.axis;
|
26
|
+
scrollStart = _ref.scrollStart;
|
28
27
|
if (scrollAlign === 'start') {
|
29
|
-
var
|
30
|
-
var paddingOffset = axis === 'y' ? offset - itemSize / 2 + inaccuracy : 0;
|
28
|
+
var paddingOffset = 0;
|
31
29
|
return position + paddingOffset;
|
32
30
|
}
|
33
31
|
if (scrollAlign === 'center') {
|
@@ -51,47 +49,30 @@ var positionModByScrollAlign = function positionModByScrollAlign(_ref) {
|
|
51
49
|
* Подсчет скролла до переданного индекса.
|
52
50
|
*/
|
53
51
|
var getCalculatedPos = exports.getCalculatedPos = function getCalculatedPos(_ref2) {
|
52
|
+
var _items$item$offsetWid2, _items$item2;
|
54
53
|
var scrollEl = _ref2.scrollEl,
|
55
54
|
items = _ref2.items,
|
56
|
-
axis = _ref2.axis,
|
57
55
|
index = _ref2.index,
|
58
56
|
offset = _ref2.offset,
|
59
57
|
scrollAlign = _ref2.scrollAlign;
|
60
58
|
var position = scrollAlign === 'center' ? offset : 0;
|
61
|
-
var carouselSize;
|
62
|
-
var itemSize;
|
63
|
-
var scrollStart;
|
64
59
|
if (items.item(index) === null) {
|
65
60
|
return position;
|
66
61
|
}
|
67
62
|
for (var i = 0; i < index; i++) {
|
68
|
-
|
69
|
-
|
70
|
-
position += (_items$item$offsetWid = (_items$item = items.item(i)) === null || _items$item === void 0 ? void 0 : _items$item.offsetWidth) !== null && _items$item$offsetWid !== void 0 ? _items$item$offsetWid : 0;
|
71
|
-
} else {
|
72
|
-
var _items$item$offsetHei, _items$item2;
|
73
|
-
position += (_items$item$offsetHei = (_items$item2 = items.item(i)) === null || _items$item2 === void 0 ? void 0 : _items$item2.offsetHeight) !== null && _items$item$offsetHei !== void 0 ? _items$item$offsetHei : 0;
|
74
|
-
}
|
75
|
-
}
|
76
|
-
if (axis === 'x') {
|
77
|
-
var _items$item$offsetWid2, _items$item3;
|
78
|
-
carouselSize = scrollEl.offsetWidth;
|
79
|
-
itemSize = (_items$item$offsetWid2 = (_items$item3 = items.item(index)) === null || _items$item3 === void 0 ? void 0 : _items$item3.offsetWidth) !== null && _items$item$offsetWid2 !== void 0 ? _items$item$offsetWid2 : 0;
|
80
|
-
scrollStart = scrollEl.scrollLeft;
|
81
|
-
} else {
|
82
|
-
var _items$item$offsetHei2, _items$item4;
|
83
|
-
carouselSize = scrollEl.offsetHeight;
|
84
|
-
itemSize = (_items$item$offsetHei2 = (_items$item4 = items.item(index)) === null || _items$item4 === void 0 ? void 0 : _items$item4.offsetHeight) !== null && _items$item$offsetHei2 !== void 0 ? _items$item$offsetHei2 : 0;
|
85
|
-
scrollStart = scrollEl.scrollTop;
|
63
|
+
var _items$item$offsetWid, _items$item;
|
64
|
+
position += (_items$item$offsetWid = (_items$item = items.item(i)) === null || _items$item === void 0 ? void 0 : _items$item.offsetWidth) !== null && _items$item$offsetWid !== void 0 ? _items$item$offsetWid : 0;
|
86
65
|
}
|
66
|
+
var carouselSize = scrollEl.offsetWidth;
|
67
|
+
var itemSize = (_items$item$offsetWid2 = (_items$item2 = items.item(index)) === null || _items$item2 === void 0 ? void 0 : _items$item2.offsetWidth) !== null && _items$item$offsetWid2 !== void 0 ? _items$item$offsetWid2 : 0;
|
68
|
+
var scrollStart = scrollEl.scrollLeft;
|
87
69
|
return positionModByScrollAlign({
|
88
70
|
scrollAlign: scrollAlign,
|
89
71
|
position: position,
|
90
72
|
carouselSize: carouselSize,
|
91
73
|
itemSize: itemSize,
|
92
74
|
offset: offset,
|
93
|
-
scrollStart: scrollStart
|
94
|
-
axis: axis
|
75
|
+
scrollStart: scrollStart
|
95
76
|
});
|
96
77
|
};
|
97
78
|
var DEFAULT_DURATION = 300;
|
@@ -145,11 +126,10 @@ var animatedScrollToX = exports.animatedScrollToX = function animatedScrollToX(e
|
|
145
126
|
var scrollToPos = exports.scrollToPos = function scrollToPos(_ref3) {
|
146
127
|
var scrollEl = _ref3.scrollEl,
|
147
128
|
pos = _ref3.pos,
|
148
|
-
axis = _ref3.axis,
|
149
129
|
animated = _ref3.animated,
|
150
130
|
duration = _ref3.duration,
|
151
131
|
timingFunction = _ref3.timingFunction;
|
152
|
-
if (
|
132
|
+
if (Math.abs(pos - scrollEl.scrollLeft) > 1) {
|
153
133
|
if (animated) {
|
154
134
|
animatedScrollToX(scrollEl, pos, duration, timingFunction);
|
155
135
|
} else {
|
@@ -337,7 +317,7 @@ var useCarousel = exports.useCarousel = function useCarousel(_ref4) {
|
|
337
317
|
}
|
338
318
|
}
|
339
319
|
}, throttleMs);
|
340
|
-
}, [
|
320
|
+
}, [debouncedOnIndexChange, detectActive, detectThreshold, scrollAlign, throttleMs]);
|
341
321
|
|
342
322
|
/**
|
343
323
|
* Прокрутка до нужной позиции индекса.
|
@@ -351,21 +331,19 @@ var useCarousel = exports.useCarousel = function useCarousel(_ref4) {
|
|
351
331
|
pos: getCalculatedPos({
|
352
332
|
scrollEl: scrollEl,
|
353
333
|
items: items,
|
354
|
-
axis: axis,
|
355
334
|
index: i,
|
356
335
|
offset: offset.current,
|
357
336
|
scrollAlign: scrollAlign
|
358
|
-
})
|
359
|
-
axis: axis
|
337
|
+
})
|
360
338
|
});
|
361
339
|
prevIndex.current = i;
|
362
340
|
}
|
363
|
-
}, [
|
341
|
+
}, [scrollAlign]);
|
364
342
|
(0, _react.useEffect)(function () {
|
365
343
|
if (scrollRef.current && trackRef.current) {
|
366
|
-
offset.current = getCalculatedOffset(scrollRef.current, trackRef.current
|
344
|
+
offset.current = getCalculatedOffset(scrollRef.current, trackRef.current);
|
367
345
|
}
|
368
|
-
}, [
|
346
|
+
}, []);
|
369
347
|
|
370
348
|
/**
|
371
349
|
* Операции на маунте/анмаунте компонента.
|
@@ -383,27 +361,6 @@ var useCarousel = exports.useCarousel = function useCarousel(_ref4) {
|
|
383
361
|
};
|
384
362
|
}, [throttledDetectActiveItem]);
|
385
363
|
|
386
|
-
/**
|
387
|
-
* Нужно вызвать только при первом рендере
|
388
|
-
*/
|
389
|
-
// useEffect(() => {
|
390
|
-
// requestAnimationFrame(() => {
|
391
|
-
// /**
|
392
|
-
// * Прокрутка до начального индекса.
|
393
|
-
// */
|
394
|
-
// toIndex(index);
|
395
|
-
//
|
396
|
-
// /**
|
397
|
-
// * Если на момент запуска карусель уже находится на нужной позиции,
|
398
|
-
// * событие скролла не произойдет, не сработает и определение центра,
|
399
|
-
// * необходимо вызвать его вручную.
|
400
|
-
// */
|
401
|
-
// throttledDetectActiveItem();
|
402
|
-
// });
|
403
|
-
//
|
404
|
-
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
405
|
-
// }, []);
|
406
|
-
|
407
364
|
/**
|
408
365
|
* Прокрутка до нужной позиции индекса, если индекс изменился.
|
409
366
|
*/
|
@@ -3,17 +3,6 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
var _Item = /*#__PURE__*/require("./Item/Item");
|
7
|
-
Object.keys(_Item).forEach(function (key) {
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
9
|
-
if (key in exports && exports[key] === _Item[key]) return;
|
10
|
-
Object.defineProperty(exports, key, {
|
11
|
-
enumerable: true,
|
12
|
-
get: function get() {
|
13
|
-
return _Item[key];
|
14
|
-
}
|
15
|
-
});
|
16
|
-
});
|
17
6
|
var _Dots = /*#__PURE__*/require("./Dots/Dots");
|
18
7
|
Object.keys(_Dots).forEach(function (key) {
|
19
8
|
if (key === "default" || key === "__esModule") return;
|
@@ -13,7 +13,7 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i
|
|
13
13
|
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
14
14
|
var StyledItem = /*#__PURE__*/_styledComponents["default"].div.withConfig({
|
15
15
|
componentId: "plasma-new-hope__sc-1b1k2uh-0"
|
16
|
-
})(["scroll-snap-align:", ";scroll-snap-stop:", ";"], function (_ref) {
|
16
|
+
})(["scroll-snap-align:", ";scroll-snap-stop:", ";padding:0 var(--temporary-carousel-padding);"], function (_ref) {
|
17
17
|
var scrollSnapAlign = _ref.scrollSnapAlign;
|
18
18
|
return scrollSnapAlign || 'none';
|
19
19
|
}, function (_ref2) {
|
@@ -33,16 +33,16 @@ Object.defineProperty(exports, "carouselNewRoot", {
|
|
33
33
|
return _Carousel3.carouselNewRoot;
|
34
34
|
}
|
35
35
|
});
|
36
|
-
Object.defineProperty(exports, "
|
36
|
+
Object.defineProperty(exports, "carouselNewTokens", {
|
37
37
|
enumerable: true,
|
38
38
|
get: function get() {
|
39
|
-
return
|
39
|
+
return _Carousel4.tokens;
|
40
40
|
}
|
41
41
|
});
|
42
|
-
Object.defineProperty(exports, "
|
42
|
+
Object.defineProperty(exports, "carouselRoot", {
|
43
43
|
enumerable: true,
|
44
44
|
get: function get() {
|
45
|
-
return
|
45
|
+
return _Carousel.carouselRoot;
|
46
46
|
}
|
47
47
|
});
|
48
48
|
var _Carousel = /*#__PURE__*/require("./CarouselOld/Carousel");
|
@@ -9,11 +9,11 @@ var _Carousel = /*#__PURE__*/require("../../../../components/Carousel");
|
|
9
9
|
var config = exports.config = {
|
10
10
|
defaults: {
|
11
11
|
view: 'default',
|
12
|
-
size: '
|
12
|
+
size: 's'
|
13
13
|
},
|
14
14
|
variations: {
|
15
15
|
view: {
|
16
|
-
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--surface-transparent-tertiary);", ":var(--surface-solid-default);"], _Carousel.
|
16
|
+
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--surface-transparent-tertiary);", ":var(--surface-solid-default);"], _Carousel.carouselNewTokens.paginationDotBackground, _Carousel.carouselNewTokens.paginationDotActiveBackground)
|
17
17
|
},
|
18
18
|
size: {
|
19
19
|
s: /*#__PURE__*/(0, _styledComponents.css)([""])
|
@@ -12,6 +12,7 @@ import { Carousel, CarouselItem } from './Carousel';
|
|
12
12
|
type StoryCarouselProps = ComponentProps<typeof Carousel> & {
|
13
13
|
slides: number;
|
14
14
|
visibleDots: number;
|
15
|
+
paginationDisabled: boolean;
|
15
16
|
paginationCentered: boolean;
|
16
17
|
};
|
17
18
|
|
@@ -35,40 +36,48 @@ const meta: Meta<StoryCarouselProps> = {
|
|
35
36
|
},
|
36
37
|
},
|
37
38
|
align: {
|
38
|
-
options: ['start', 'center', 'end'],
|
39
|
+
options: ['start', 'center', 'end', 'activeDirection'],
|
39
40
|
control: {
|
40
41
|
type: 'inline-radio',
|
41
42
|
},
|
42
43
|
},
|
43
|
-
isDragScrollDisabled: {
|
44
|
-
control: 'boolean',
|
45
|
-
},
|
46
44
|
slides: {
|
47
45
|
control: 'number',
|
48
46
|
},
|
49
47
|
visibleDots: {
|
50
48
|
control: 'number',
|
51
49
|
},
|
52
|
-
|
50
|
+
controlArrowsDisabled: {
|
53
51
|
control: 'boolean',
|
54
52
|
},
|
55
|
-
|
56
|
-
control: '
|
53
|
+
paginationDisabled: {
|
54
|
+
control: 'boolean',
|
55
|
+
},
|
56
|
+
paginationCentered: {
|
57
|
+
control: 'boolean',
|
57
58
|
},
|
58
59
|
},
|
59
60
|
args: {
|
60
61
|
view: 'default',
|
61
62
|
size: 's',
|
62
63
|
align: 'center',
|
63
|
-
isDragScrollDisabled: false,
|
64
64
|
visibleDots: 6,
|
65
65
|
slides: 10,
|
66
|
+
controlArrowsDisabled: false,
|
67
|
+
paginationDisabled: false,
|
66
68
|
paginationCentered: false,
|
67
|
-
gap: '20px',
|
68
69
|
},
|
69
70
|
parameters: {
|
70
71
|
controls: {
|
71
|
-
include: [
|
72
|
+
include: [
|
73
|
+
'align',
|
74
|
+
'visibleDots',
|
75
|
+
'slides',
|
76
|
+
'controlArrowsDisabled',
|
77
|
+
'paginationDisabled',
|
78
|
+
'paginationCentered',
|
79
|
+
'gap',
|
80
|
+
],
|
72
81
|
},
|
73
82
|
},
|
74
83
|
};
|
@@ -81,7 +90,7 @@ const StyledCard = styled.div`
|
|
81
90
|
justify-content: center;
|
82
91
|
position: relative;
|
83
92
|
border-radius: 8px;
|
84
|
-
width:
|
93
|
+
width: 400px;
|
85
94
|
height: 370px;
|
86
95
|
background-color: #add8e6;
|
87
96
|
font-size: 30px;
|
@@ -91,9 +100,8 @@ const StoryDefault = ({
|
|
91
100
|
align,
|
92
101
|
visibleDots,
|
93
102
|
slides,
|
103
|
+
paginationDisabled,
|
94
104
|
paginationCentered,
|
95
|
-
isDragScrollDisabled,
|
96
|
-
gap,
|
97
105
|
...rest
|
98
106
|
}: StoryCarouselProps) => {
|
99
107
|
const items = Array(slides)
|
@@ -109,9 +117,8 @@ const StoryDefault = ({
|
|
109
117
|
<Carousel
|
110
118
|
detectActive
|
111
119
|
scrollAlign={align}
|
112
|
-
isDragScrollDisabled={isDragScrollDisabled}
|
113
|
-
gap={gap}
|
114
120
|
paginationOptions={{
|
121
|
+
disabled: paginationDisabled,
|
115
122
|
visibleDots,
|
116
123
|
centered: paginationCentered,
|
117
124
|
}}
|
@@ -4,7 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.config = void 0;
|
7
|
+
var _styledComponents = /*#__PURE__*/require("styled-components");
|
8
|
+
var _Carousel = /*#__PURE__*/require("../../../../components/Carousel");
|
7
9
|
var config = exports.config = {
|
8
|
-
defaults: {
|
9
|
-
|
10
|
+
defaults: {
|
11
|
+
view: 'default',
|
12
|
+
size: 's'
|
13
|
+
},
|
14
|
+
variations: {
|
15
|
+
view: {
|
16
|
+
"default": /*#__PURE__*/(0, _styledComponents.css)(["", ":var(--surface-transparent-tertiary);", ":var(--surface-solid-default);"], _Carousel.carouselNewTokens.paginationDotBackground, _Carousel.carouselNewTokens.paginationDotActiveBackground)
|
17
|
+
},
|
18
|
+
size: {
|
19
|
+
s: /*#__PURE__*/(0, _styledComponents.css)([""])
|
20
|
+
}
|
21
|
+
}
|
10
22
|
};
|
@@ -14,5 +14,5 @@ exports.mergedConfig = void 0;
|
|
14
14
|
var _Carousel = /*#__PURE__*/require("../../../../components/Carousel");
|
15
15
|
var _engines = /*#__PURE__*/require("../../../../engines");
|
16
16
|
var _Carousel2 = /*#__PURE__*/require("./Carousel.config");
|
17
|
-
var mergedConfig = exports.mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Carousel.
|
17
|
+
var mergedConfig = exports.mergedConfig = /*#__PURE__*/(0, _engines.mergeConfig)(_Carousel.carouselNewConfig, _Carousel2.config);
|
18
18
|
var Carousel = exports.Carousel = /*#__PURE__*/(0, _engines.component)(mergedConfig);
|
@@ -2,76 +2,136 @@ import * as React from 'react';
|
|
2
2
|
import type { ComponentProps } from 'react';
|
3
3
|
import type { Meta, StoryObj } from '@storybook/react';
|
4
4
|
import styled from 'styled-components';
|
5
|
+
import { getConfigVariations } from '@salutejs/plasma-sb-utils';
|
5
6
|
|
6
7
|
import { WithTheme } from '../../../_helpers';
|
7
8
|
|
9
|
+
import { config } from './Carousel.config';
|
8
10
|
import { Carousel, CarouselItem } from './Carousel';
|
9
11
|
|
10
|
-
type StoryCarouselProps = ComponentProps<typeof Carousel
|
12
|
+
type StoryCarouselProps = ComponentProps<typeof Carousel> & {
|
13
|
+
slides: number;
|
14
|
+
visibleDots: number;
|
15
|
+
paginationDisabled: boolean;
|
16
|
+
paginationCentered: boolean;
|
17
|
+
};
|
18
|
+
|
19
|
+
const { views, sizes } = getConfigVariations(config);
|
11
20
|
|
12
21
|
const meta: Meta<StoryCarouselProps> = {
|
13
22
|
title: 'web/Navigation/Carousel',
|
14
23
|
component: Carousel,
|
15
24
|
decorators: [WithTheme],
|
16
25
|
argTypes: {
|
26
|
+
view: {
|
27
|
+
options: views,
|
28
|
+
control: {
|
29
|
+
type: 'select',
|
30
|
+
},
|
31
|
+
},
|
32
|
+
size: {
|
33
|
+
options: sizes,
|
34
|
+
control: {
|
35
|
+
type: 'inline-radio',
|
36
|
+
},
|
37
|
+
},
|
17
38
|
align: {
|
18
|
-
options: ['
|
39
|
+
options: ['start', 'center', 'end', 'activeDirection'],
|
19
40
|
control: {
|
20
41
|
type: 'inline-radio',
|
21
42
|
},
|
22
43
|
},
|
23
|
-
|
44
|
+
slides: {
|
45
|
+
control: 'number',
|
46
|
+
},
|
47
|
+
visibleDots: {
|
48
|
+
control: 'number',
|
49
|
+
},
|
50
|
+
controlArrowsDisabled: {
|
51
|
+
control: 'boolean',
|
52
|
+
},
|
53
|
+
paginationDisabled: {
|
54
|
+
control: 'boolean',
|
55
|
+
},
|
56
|
+
paginationCentered: {
|
24
57
|
control: 'boolean',
|
25
58
|
},
|
26
59
|
},
|
27
60
|
args: {
|
61
|
+
view: 'default',
|
62
|
+
size: 's',
|
28
63
|
align: 'center',
|
29
|
-
|
64
|
+
visibleDots: 6,
|
65
|
+
slides: 10,
|
66
|
+
controlArrowsDisabled: false,
|
67
|
+
paginationDisabled: false,
|
68
|
+
paginationCentered: false,
|
30
69
|
},
|
31
70
|
parameters: {
|
32
71
|
controls: {
|
33
|
-
include: [
|
72
|
+
include: [
|
73
|
+
'align',
|
74
|
+
'visibleDots',
|
75
|
+
'slides',
|
76
|
+
'controlArrowsDisabled',
|
77
|
+
'paginationDisabled',
|
78
|
+
'paginationCentered',
|
79
|
+
'gap',
|
80
|
+
],
|
34
81
|
},
|
35
82
|
},
|
36
83
|
};
|
37
84
|
|
38
85
|
export default meta;
|
39
86
|
|
40
|
-
const items = Array(25)
|
41
|
-
.fill({
|
42
|
-
title: 'Заголовок',
|
43
|
-
})
|
44
|
-
.map(({ title }, i) => ({
|
45
|
-
id: i,
|
46
|
-
title: `${title} ${i}`,
|
47
|
-
}));
|
48
|
-
|
49
87
|
const StyledCard = styled.div`
|
88
|
+
display: flex;
|
89
|
+
align-items: center;
|
90
|
+
justify-content: center;
|
50
91
|
position: relative;
|
51
92
|
border-radius: 8px;
|
52
|
-
width:
|
53
|
-
height:
|
54
|
-
padding: 8px;
|
93
|
+
width: 400px;
|
94
|
+
height: 370px;
|
55
95
|
background-color: #add8e6;
|
96
|
+
font-size: 30px;
|
56
97
|
`;
|
57
98
|
|
58
|
-
const StoryDefault = ({
|
59
|
-
|
99
|
+
const StoryDefault = ({
|
100
|
+
align,
|
101
|
+
visibleDots,
|
102
|
+
slides,
|
103
|
+
paginationDisabled,
|
104
|
+
paginationCentered,
|
105
|
+
...rest
|
106
|
+
}: StoryCarouselProps) => {
|
107
|
+
const items = Array(slides)
|
108
|
+
.fill(1)
|
109
|
+
.map((_, i) => ({
|
110
|
+
id: i,
|
111
|
+
title: i,
|
112
|
+
}));
|
60
113
|
|
61
114
|
return (
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
115
|
+
<>
|
116
|
+
<div style={{ width: '600px' }}>
|
117
|
+
<Carousel
|
118
|
+
detectActive
|
119
|
+
scrollAlign={align}
|
120
|
+
paginationOptions={{
|
121
|
+
disabled: paginationDisabled,
|
122
|
+
visibleDots,
|
123
|
+
centered: paginationCentered,
|
124
|
+
}}
|
125
|
+
{...rest}
|
126
|
+
>
|
127
|
+
{items.map((item, i) => (
|
128
|
+
<CarouselItem key={i} scrollSnapAlign={align}>
|
129
|
+
<StyledCard>{item.title}</StyledCard>
|
130
|
+
</CarouselItem>
|
131
|
+
))}
|
132
|
+
</Carousel>
|
133
|
+
</div>
|
134
|
+
</>
|
75
135
|
);
|
76
136
|
};
|
77
137
|
|
@@ -12,7 +12,6 @@ import { base as sizeCSS } from "./variations/_size/base";
|
|
12
12
|
import { base as viewCSS } from "./variations/_view/base";
|
13
13
|
import { base, CarouselWrapper, CarouselTrack, ControlsWrapper, IconButton } from "./Carousel.styles";
|
14
14
|
import { useCarousel } from "./hooks/useCarousel";
|
15
|
-
import { useDragScroll } from "./hooks/useDragScroll";
|
16
15
|
import { Dots } from "./ui";
|
17
16
|
|
18
17
|
/**
|
@@ -22,11 +21,11 @@ export var carouselNewRoot = function carouselNewRoot(Root) {
|
|
22
21
|
return /*#__PURE__*/forwardRef(function (_ref, ref) {
|
23
22
|
var view = _ref.view,
|
24
23
|
size = _ref.size,
|
25
|
-
scrollAlign = _ref.scrollAlign,
|
24
|
+
_ref$scrollAlign = _ref.scrollAlign,
|
25
|
+
scrollAlign = _ref$scrollAlign === void 0 ? 'center' : _ref$scrollAlign,
|
26
26
|
children = _ref.children,
|
27
|
-
_ref$
|
28
|
-
|
29
|
-
gap = _ref.gap,
|
27
|
+
_ref$controlArrowsDis = _ref.controlArrowsDisabled,
|
28
|
+
controlArrowsDisabled = _ref$controlArrowsDis === void 0 ? 'false' : _ref$controlArrowsDis,
|
30
29
|
paginationOptions = _ref.paginationOptions,
|
31
30
|
className = _ref.className,
|
32
31
|
style = _ref.style;
|
@@ -48,14 +47,13 @@ export var carouselNewRoot = function carouselNewRoot(Root) {
|
|
48
47
|
}),
|
49
48
|
scrollRef = _useCarousel.scrollRef,
|
50
49
|
trackRef = _useCarousel.trackRef;
|
51
|
-
useDragScroll(scrollRef, isDragScrollDisabled);
|
52
50
|
return /*#__PURE__*/React.createElement(Root, {
|
53
51
|
className: className,
|
54
52
|
style: style,
|
55
53
|
size: size,
|
56
54
|
view: view,
|
57
55
|
ref: ref
|
58
|
-
}, /*#__PURE__*/React.createElement(ControlsWrapper, null, index !== 0 && /*#__PURE__*/React.createElement(IconButton, {
|
56
|
+
}, /*#__PURE__*/React.createElement(ControlsWrapper, null, index !== 0 && !controlArrowsDisabled && /*#__PURE__*/React.createElement(IconButton, {
|
59
57
|
pin: "circle-circle",
|
60
58
|
onClick: handleClickLeft
|
61
59
|
}, _IconDisclosureLeft || (_IconDisclosureLeft = /*#__PURE__*/React.createElement(IconDisclosureLeft, {
|
@@ -65,10 +63,7 @@ export var carouselNewRoot = function carouselNewRoot(Root) {
|
|
65
63
|
ref: scrollRef
|
66
64
|
}, /*#__PURE__*/React.createElement(CarouselTrack, {
|
67
65
|
ref: trackRef
|
68
|
-
|
69
|
-
,
|
70
|
-
gap: gap
|
71
|
-
}, children)), index !== slidesAmount - 1 && /*#__PURE__*/React.createElement(IconButton, {
|
66
|
+
}, children)), index !== slidesAmount - 1 && !controlArrowsDisabled && /*#__PURE__*/React.createElement(IconButton, {
|
72
67
|
className: classes.rightControlButton,
|
73
68
|
pin: "circle-circle",
|
74
69
|
onClick: handleClickRight
|
@@ -8,13 +8,10 @@ export var IconButtonComponent = /*#__PURE__*/component(mergedConfig);
|
|
8
8
|
export var base = /*#__PURE__*/css(["position:relative;"]);
|
9
9
|
export var CarouselWrapper = /*#__PURE__*/styled.div.withConfig({
|
10
10
|
componentId: "plasma-new-hope__sc-vln28v-0"
|
11
|
-
})(["position:relative;margin:
|
11
|
+
})(["position:relative;margin-left:calc(var(--temporary-carousel-padding) * -1);margin-right:calc(var(--temporary-carousel-padding) * -1);padding:0;list-style:none;-ms-overflow-style:none;scrollbar-width:none;::-webkit-scrollbar{display:none;}overflow-x:auto;overflow-y:hidden;scroll-behavior:smooth;scroll-snap-type:x mandatory;user-select:none;-webkit-tap-highlight-color:rgba(0,0,0,0);--temporary-carousel-padding:0.625rem;"]);
|
12
12
|
export var CarouselTrack = /*#__PURE__*/styled.div.withConfig({
|
13
13
|
componentId: "plasma-new-hope__sc-vln28v-1"
|
14
|
-
})(["display:inline-flex;flex-direction:row;
|
15
|
-
var gap = _ref.gap;
|
16
|
-
return gap || 0;
|
17
|
-
});
|
14
|
+
})(["display:inline-flex;flex-direction:row;"]);
|
18
15
|
export var IconButton = /*#__PURE__*/styled(IconButtonComponent).withConfig({
|
19
16
|
componentId: "plasma-new-hope__sc-vln28v-2"
|
20
17
|
})(["position:absolute;top:50%;transform:translateY(-50%);left:0.75rem;z-index:10;", ":var(--text-primary);", ":var(--surface-transparent-secondary);", ":var(", ");", ":var(--surface-transparent-secondary-hover);", ":var(--surface-transparent-secondary-active);", ":2.5rem;", ":2.5rem;", ":1rem;", ":0.625rem;&.", "{left:auto;right:0.75rem;}"], iconButtonTokens.iconButtonColor, iconButtonTokens.iconButtonBackgroundColor, iconButtonTokens.iconButtonLoadingBackgroundColor, iconButtonTokens.iconButtonBackgroundColor, iconButtonTokens.iconButtonBackgroundColorHover, iconButtonTokens.iconButtonBackgroundColorActive, iconButtonTokens.iconButtonHeight, iconButtonTokens.iconButtonWidth, iconButtonTokens.iconButtonPadding, iconButtonTokens.iconButtonRadius, classes.rightControlButton);
|