@meduza/ui-kit-2 1.4.11-dark.1 → 1.4.12-analytics.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.
@@ -2,4 +2,5 @@ import React from 'react';
2
2
  export interface RelatedCarouselProps {
3
3
  children: React.ReactNode;
4
4
  ariaLabel?: string;
5
+ onSlideChange?: (index: number) => void;
5
6
  }
@@ -1536,6 +1536,11 @@ const ListBlock = ({
1536
1536
 
1537
1537
  var styles$k = {"root":"RelatedBlock-module_root__cr1c-","header":"RelatedBlock-module_header__bfUJD","items":"RelatedBlock-module_items__rzzam","rich":"RelatedBlock-module_rich__1cWdn","first":"RelatedBlock-module_first__ZkcP5","simple":"RelatedBlock-module_simple__m22bj","center":"RelatedBlock-module_center__WVpIJ","isInSlideMaterial":"RelatedBlock-module_isInSlideMaterial__VumDw","mobile":"RelatedBlock-module_mobile__AScBA","desktop":"RelatedBlock-module_desktop__uMXUY"};
1538
1538
 
1539
+ const handleClick = (event, to) => {
1540
+ if (event.button <= 1) {
1541
+ postMessage('related', to, 'click');
1542
+ }
1543
+ };
1539
1544
  const RelatedBlock = ({
1540
1545
  block: {
1541
1546
  data: {
@@ -1557,14 +1562,19 @@ const RelatedBlock = ({
1557
1562
  className: styles$k.header
1558
1563
  }, title), /*#__PURE__*/React.createElement("ul", {
1559
1564
  className: styles$k.items
1560
- }, related.map((item, index) => (/*#__PURE__*/React.createElement("li", {
1561
- key: item.id || index,
1562
- className: styles$k[item.layout]
1563
- }, /*#__PURE__*/React.createElement(reactRouterDom.Link, {
1564
- to: item.full_url || `/${item.url}`
1565
- }, /*#__PURE__*/React.createElement("span", {
1566
- className: styles$k.first
1567
- }, item.title), item.second_title && ' ', item.second_title && /*#__PURE__*/React.createElement("span", null, item.second_title)))))));
1565
+ }, related.map((item, index) => {
1566
+ const to = item.full_url || `/${item.url}`;
1567
+ return /*#__PURE__*/React.createElement("li", {
1568
+ key: item.id || index,
1569
+ className: styles$k[item.layout]
1570
+ }, /*#__PURE__*/React.createElement(reactRouterDom.Link, {
1571
+ to: to,
1572
+ onClick: event => handleClick(event, to),
1573
+ onAuxClick: event => handleClick(event, to)
1574
+ }, /*#__PURE__*/React.createElement("span", {
1575
+ className: styles$k.first
1576
+ }, item.title), item.second_title && ' ', item.second_title && /*#__PURE__*/React.createElement("span", null, item.second_title)));
1577
+ })));
1568
1578
  };
1569
1579
 
1570
1580
  var styles$j = {"root":"SourceBlock-module_root__9dnI4","text":"SourceBlock-module_text__M5-uy","origin":"SourceBlock-module_origin__fyvxH","center":"SourceBlock-module_center__UOMwy","mobile":"SourceBlock-module_mobile__QVEyg","desktop":"SourceBlock-module_desktop__xdXWm","isDark":"SourceBlock-module_isDark__etwk1"};
@@ -2423,10 +2433,17 @@ const RelatedRichBlock = ({
2423
2433
  classNames = makeStyleContext(classNames, styleContext, styles$6);
2424
2434
  context = [...styleContext, 'isInMediaBlock', 'richRelated'];
2425
2435
  }
2436
+ const handleClick = event => {
2437
+ if (event.button <= 1) {
2438
+ postMessage('related', `/${url}`, 'click');
2439
+ }
2440
+ };
2426
2441
  return /*#__PURE__*/React.createElement(reactRouterDom.Link, {
2427
2442
  "data-testid": "related-rich-block",
2428
2443
  className: makeClassName(classNames),
2429
- to: `/${url}`
2444
+ to: `/${url}`,
2445
+ onClick: handleClick,
2446
+ onAuxClick: handleClick
2430
2447
  }, /*#__PURE__*/React.createElement("div", {
2431
2448
  className: styles$6.tag
2432
2449
  }, /*#__PURE__*/React.createElement(Tag, {
@@ -2550,8 +2567,15 @@ const RelatedBook = ({
2550
2567
  const cssProps = {
2551
2568
  '--bgColor': `rgb(${block.data.theme.background_color || '0, 0, 0'})`
2552
2569
  };
2570
+ const handleClick = event => {
2571
+ if (event.button <= 1) {
2572
+ postMessage('related', `/${block.data.url}`, 'click');
2573
+ }
2574
+ };
2553
2575
  return /*#__PURE__*/React.createElement(reactRouterDom.Link, {
2554
2576
  to: `/${block.data.url}`,
2577
+ onClick: handleClick,
2578
+ onAuxClick: handleClick,
2555
2579
  className: makeClassName(classNames),
2556
2580
  style: cssProps
2557
2581
  }, /*#__PURE__*/React.createElement("div", {
@@ -2715,7 +2739,8 @@ const getDotScale = (index, start, total) => {
2715
2739
  };
2716
2740
  const RelatedCarousel = ({
2717
2741
  children,
2718
- ariaLabel
2742
+ ariaLabel,
2743
+ onSlideChange
2719
2744
  }) => {
2720
2745
  const [viewportRef, embla] = useEmblaCarousel({
2721
2746
  loop: true,
@@ -2723,6 +2748,8 @@ const RelatedCarousel = ({
2723
2748
  containScroll: false
2724
2749
  });
2725
2750
  const [activeIndex, setActiveIndex] = React.useState(0);
2751
+ const onSlideChangeRef = React.useRef(onSlideChange);
2752
+ onSlideChangeRef.current = onSlideChange;
2726
2753
  const [dotsStart, setDotsStart] = React.useState(0);
2727
2754
  const slides = React.Children.toArray(children);
2728
2755
  const total = slides.length;
@@ -2732,6 +2759,7 @@ const RelatedCarousel = ({
2732
2759
  }
2733
2760
  const index = embla.selectedScrollSnap();
2734
2761
  setActiveIndex(index);
2762
+ onSlideChangeRef.current?.(index);
2735
2763
  setDotsStart(start => getDotsStart(index, start, total));
2736
2764
  }, [embla, total]);
2737
2765
  React.useEffect(() => {