@meduza/ui-kit-2 1.4.2 → 1.4.4
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/dist/ui-kit-2.cjs.development.js +29 -39
- package/dist/ui-kit-2.cjs.development.js.map +1 -1
- package/dist/ui-kit-2.cjs.production.min.js +1 -1
- package/dist/ui-kit-2.cjs.production.min.js.map +1 -1
- package/dist/ui-kit-2.esm.js +29 -39
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit-game.css +20 -25
- package/dist/ui-kit.css +20 -25
- package/package.json +4 -1
- package/src/RelatedBlock/RelatedBlock.module.css +1 -1
- package/src/RelatedCarousel/RelatedCarousel.module.css +10 -19
- package/src/RelatedCarousel/RelatedCarousel.test.tsx +7 -3
- package/src/RelatedCarousel/index.tsx +33 -50
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +1 -1
- package/src/RichTitle/RichTitle.module.css +5 -4
package/dist/ui-kit-2.esm.js
CHANGED
|
@@ -4,6 +4,7 @@ import dayjs from 'dayjs';
|
|
|
4
4
|
import 'dayjs/locale/ru';
|
|
5
5
|
import relativeTime from 'dayjs/plugin/relativeTime';
|
|
6
6
|
import { Link } from 'react-router-dom';
|
|
7
|
+
import useEmblaCarousel from 'embla-carousel-react';
|
|
7
8
|
|
|
8
9
|
const makeClassName = list => {
|
|
9
10
|
return list.filter(([, active]) => active).map(([className]) => className).join(' ');
|
|
@@ -2668,7 +2669,7 @@ const ListViewSwitcher = ({
|
|
|
2668
2669
|
className: styles$3.list
|
|
2669
2670
|
})));
|
|
2670
2671
|
|
|
2671
|
-
var styles$2 = {"root":"RelatedCarousel-module_root__G-Eub","track":"RelatedCarousel-module_track__UVQ2n","slide":"RelatedCarousel-module_slide__MI9tF","dots":"RelatedCarousel-module_dots__mOSIC","dotsTrack":"RelatedCarousel-module_dotsTrack__V7bnX","dotCell":"RelatedCarousel-module_dotCell__kl64s","dot":"RelatedCarousel-module_dot__Jo52r","isSmall":"RelatedCarousel-module_isSmall__ZP5hd","isTiny":"RelatedCarousel-module_isTiny__mjhtD","isActive":"RelatedCarousel-module_isActive__Nz2aj"};
|
|
2672
|
+
var styles$2 = {"root":"RelatedCarousel-module_root__G-Eub","viewport":"RelatedCarousel-module_viewport__HCzJi","track":"RelatedCarousel-module_track__UVQ2n","slide":"RelatedCarousel-module_slide__MI9tF","dots":"RelatedCarousel-module_dots__mOSIC","dotsTrack":"RelatedCarousel-module_dotsTrack__V7bnX","dotCell":"RelatedCarousel-module_dotCell__kl64s","dot":"RelatedCarousel-module_dot__Jo52r","isSmall":"RelatedCarousel-module_isSmall__ZP5hd","isTiny":"RelatedCarousel-module_isTiny__mjhtD","isActive":"RelatedCarousel-module_isActive__Nz2aj"};
|
|
2672
2673
|
|
|
2673
2674
|
const VISIBLE_DOTS = 6;
|
|
2674
2675
|
const EDGE_DOTS = 2;
|
|
@@ -2703,52 +2704,39 @@ const getDotScale = (index, start, total) => {
|
|
|
2703
2704
|
}
|
|
2704
2705
|
return 'full';
|
|
2705
2706
|
};
|
|
2706
|
-
const getSlideStep = track => {
|
|
2707
|
-
if (!track) {
|
|
2708
|
-
return 0;
|
|
2709
|
-
}
|
|
2710
|
-
const [first, second] = Array.from(track.children);
|
|
2711
|
-
if (!first) {
|
|
2712
|
-
return 0;
|
|
2713
|
-
}
|
|
2714
|
-
return second ? second.offsetLeft - first.offsetLeft : first.offsetWidth;
|
|
2715
|
-
};
|
|
2716
2707
|
const RelatedCarousel = ({
|
|
2717
2708
|
children,
|
|
2718
2709
|
ariaLabel
|
|
2719
2710
|
}) => {
|
|
2720
|
-
const
|
|
2721
|
-
|
|
2711
|
+
const [viewportRef, embla] = useEmblaCarousel({
|
|
2712
|
+
loop: true,
|
|
2713
|
+
align: 'start',
|
|
2714
|
+
containScroll: false
|
|
2715
|
+
});
|
|
2722
2716
|
const [activeIndex, setActiveIndex] = useState(0);
|
|
2723
2717
|
const [dotsStart, setDotsStart] = useState(0);
|
|
2724
2718
|
const slides = React.Children.toArray(children);
|
|
2725
|
-
const lastIndex = slides.length - 1;
|
|
2726
2719
|
const total = slides.length;
|
|
2720
|
+
const handleSelect = useCallback(() => {
|
|
2721
|
+
if (!embla) {
|
|
2722
|
+
return;
|
|
2723
|
+
}
|
|
2724
|
+
const index = embla.selectedScrollSnap();
|
|
2725
|
+
setActiveIndex(index);
|
|
2726
|
+
setDotsStart(start => getDotsStart(index, start, total));
|
|
2727
|
+
}, [embla, total]);
|
|
2727
2728
|
useEffect(() => {
|
|
2728
|
-
|
|
2729
|
-
if (!track) {
|
|
2729
|
+
if (!embla) {
|
|
2730
2730
|
return undefined;
|
|
2731
2731
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
const step = getSlideStep(track);
|
|
2736
|
-
if (!step) {
|
|
2737
|
-
return;
|
|
2738
|
-
}
|
|
2739
|
-
const index = Math.max(0, Math.min(lastIndex, Math.round(track.scrollLeft / step)));
|
|
2740
|
-
setActiveIndex(index);
|
|
2741
|
-
setDotsStart(start => getDotsStart(index, start, lastIndex + 1));
|
|
2742
|
-
});
|
|
2743
|
-
};
|
|
2744
|
-
track.addEventListener('scroll', handleScroll, {
|
|
2745
|
-
passive: true
|
|
2746
|
-
});
|
|
2732
|
+
handleSelect();
|
|
2733
|
+
embla.on('select', handleSelect);
|
|
2734
|
+
embla.on('reInit', handleSelect);
|
|
2747
2735
|
return () => {
|
|
2748
|
-
|
|
2749
|
-
|
|
2736
|
+
embla.off('select', handleSelect);
|
|
2737
|
+
embla.off('reInit', handleSelect);
|
|
2750
2738
|
};
|
|
2751
|
-
}, [
|
|
2739
|
+
}, [embla, handleSelect]);
|
|
2752
2740
|
const dotsStyle = {
|
|
2753
2741
|
'--dotsVisible': Math.min(total, VISIBLE_DOTS),
|
|
2754
2742
|
'--dotsStart': dotsStart
|
|
@@ -2758,13 +2746,15 @@ const RelatedCarousel = ({
|
|
|
2758
2746
|
className: makeClassName([[styles$2.root, true]]),
|
|
2759
2747
|
role: "group",
|
|
2760
2748
|
"aria-label": ariaLabel
|
|
2761
|
-
}, /*#__PURE__*/React.createElement("
|
|
2762
|
-
className: styles$2.
|
|
2763
|
-
ref:
|
|
2764
|
-
},
|
|
2749
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2750
|
+
className: styles$2.viewport,
|
|
2751
|
+
ref: viewportRef
|
|
2752
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
2753
|
+
className: styles$2.track
|
|
2754
|
+
}, slides.map((slide, index) => (/*#__PURE__*/React.createElement("div", {
|
|
2765
2755
|
className: styles$2.slide,
|
|
2766
2756
|
key: index
|
|
2767
|
-
}, slide)))), /*#__PURE__*/React.createElement("div", {
|
|
2757
|
+
}, slide))))), /*#__PURE__*/React.createElement("div", {
|
|
2768
2758
|
"aria-hidden": "true",
|
|
2769
2759
|
className: styles$2.dots,
|
|
2770
2760
|
style: dotsStyle
|