@meduza/ui-kit-2 0.1.24 → 0.1.25
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/RelatedBlock/RelatedBlock.types.d.ts +1 -0
- package/dist/ui-kit-2.cjs.development.js +59 -15
- 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 +59 -15
- package/dist/ui-kit-2.esm.js.map +1 -1
- package/dist/ui-kit.css +1139 -1118
- package/dist/utils/postMessage.d.ts +1 -1
- package/package.json +1 -1
- package/src/Image/index.tsx +1 -1
- package/src/RelatedBlock/RelatedBlock.types.ts +1 -0
- package/src/RelatedBlock/index.tsx +10 -0
- package/src/RelatedRichBlock/RelatedRichBlock.module.css +14 -3
- package/src/RelatedRichBlock/RelatedRichBlock.stories.tsx +1 -0
- package/src/RelatedRichBlock/index.tsx +37 -5
- package/src/RelatedRichBlock/mock.json +5 -5
- package/src/Spoiler/index.tsx +2 -2
- package/src/utils/postMessage.ts +6 -1
package/dist/ui-kit-2.esm.js
CHANGED
|
@@ -296,9 +296,10 @@ var viewportSize = (function () {
|
|
|
296
296
|
|
|
297
297
|
var POST_MESSAGE_PREFIX = 'mdzKitMsg';
|
|
298
298
|
|
|
299
|
-
var postMessage = function postMessage(element, action) {
|
|
299
|
+
var postMessage = function postMessage(category, element, action) {
|
|
300
300
|
var target = window.top;
|
|
301
301
|
var msg = POST_MESSAGE_PREFIX + "=" + JSON.stringify({
|
|
302
|
+
category: category,
|
|
302
303
|
element: element,
|
|
303
304
|
action: action
|
|
304
305
|
});
|
|
@@ -450,7 +451,7 @@ var Image = function Image(_ref) {
|
|
|
450
451
|
return;
|
|
451
452
|
}
|
|
452
453
|
|
|
453
|
-
postMessage('fullscreen_click', 'click');
|
|
454
|
+
postMessage('', 'fullscreen_click', 'click');
|
|
454
455
|
lightBox.show(optimized, width, height, alt);
|
|
455
456
|
};
|
|
456
457
|
|
|
@@ -1594,6 +1595,7 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1594
1595
|
title = _ref$block$data.title,
|
|
1595
1596
|
related = _ref$block$data.related,
|
|
1596
1597
|
onlyOn = _ref$block.only_on,
|
|
1598
|
+
trackClick = _ref.trackClick,
|
|
1597
1599
|
styleContext = _ref.styleContext;
|
|
1598
1600
|
var classNames = [[styles$q.root, true], [styles$q[onlyOn], true]];
|
|
1599
1601
|
|
|
@@ -1601,6 +1603,12 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1601
1603
|
classNames = makeStyleContext(classNames, styleContext, styles$q);
|
|
1602
1604
|
}
|
|
1603
1605
|
|
|
1606
|
+
var handleClick = function handleClick(url) {
|
|
1607
|
+
if (trackClick) {
|
|
1608
|
+
postMessage('simpleRelated', 'click', url);
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
|
|
1604
1612
|
return React.createElement("div", {
|
|
1605
1613
|
"data-testid": "related-block",
|
|
1606
1614
|
className: makeClassName(classNames)
|
|
@@ -1615,7 +1623,10 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1615
1623
|
}, React.createElement("a", {
|
|
1616
1624
|
href: item.full_url || "/" + item.url,
|
|
1617
1625
|
target: "_blank",
|
|
1618
|
-
rel: "noopener noreferrer"
|
|
1626
|
+
rel: "noopener noreferrer",
|
|
1627
|
+
onClick: function onClick() {
|
|
1628
|
+
return handleClick(item.full_url || item.url);
|
|
1629
|
+
}
|
|
1619
1630
|
}, React.createElement("span", {
|
|
1620
1631
|
className: styles$q.first
|
|
1621
1632
|
}, item.title), item.second_title && ' ', item.second_title && React.createElement("span", null, item.second_title)));
|
|
@@ -1659,7 +1670,7 @@ var SourceBlock = function SourceBlock(_ref) {
|
|
|
1659
1670
|
}, origin))));
|
|
1660
1671
|
};
|
|
1661
1672
|
|
|
1662
|
-
var styles$s = {"root":"RelatedRichBlock-module_root__3NYmj","overlay":"RelatedRichBlock-module_overlay__3XSg_","overlayHeader":"RelatedRichBlock-module_overlayHeader__2Nmbv","isRich":"RelatedRichBlock-module_isRich__1LnA4","body":"RelatedRichBlock-module_body__1ZHZS","isCard":"RelatedRichBlock-module_isCard__2naDz","hasGradient":"RelatedRichBlock-module_hasGradient__27LOk","cover":"RelatedRichBlock-module_cover__3yygp","tag":"RelatedRichBlock-module_tag__3OLyG","dark":"RelatedRichBlock-module_dark__3Y1fE","light":"RelatedRichBlock-module_light__2mUxL","mobile":"RelatedRichBlock-module_mobile__JpCS4","desktop":"RelatedRichBlock-module_desktop__trL0D"};
|
|
1673
|
+
var styles$s = {"root":"RelatedRichBlock-module_root__3NYmj","wrapper":"RelatedRichBlock-module_wrapper__1eLIQ","overlay":"RelatedRichBlock-module_overlay__3XSg_","overlayHeader":"RelatedRichBlock-module_overlayHeader__2Nmbv","isRich":"RelatedRichBlock-module_isRich__1LnA4","body":"RelatedRichBlock-module_body__1ZHZS","isCard":"RelatedRichBlock-module_isCard__2naDz","hasGradient":"RelatedRichBlock-module_hasGradient__27LOk","cover":"RelatedRichBlock-module_cover__3yygp","tag":"RelatedRichBlock-module_tag__3OLyG","dark":"RelatedRichBlock-module_dark__3Y1fE","light":"RelatedRichBlock-module_light__2mUxL","mobile":"RelatedRichBlock-module_mobile__JpCS4","desktop":"RelatedRichBlock-module_desktop__trL0D"};
|
|
1663
1674
|
|
|
1664
1675
|
/* eslint-disable react/jsx-no-target-blank */
|
|
1665
1676
|
var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
@@ -1679,15 +1690,34 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
|
1679
1690
|
var style = {};
|
|
1680
1691
|
var styleHeader = {};
|
|
1681
1692
|
|
|
1682
|
-
var _useState = useState(
|
|
1683
|
-
|
|
1684
|
-
|
|
1693
|
+
var _useState = useState('unset'),
|
|
1694
|
+
type = _useState[0],
|
|
1695
|
+
setType = _useState[1];
|
|
1685
1696
|
|
|
1686
1697
|
var cardType = "is" + toCapitalize(layout);
|
|
1687
1698
|
useEffect(function () {
|
|
1688
|
-
|
|
1689
|
-
setIsRich(true);
|
|
1699
|
+
setType(Math.random() >= 0.5 ? 'simpleRelated' : 'richRelated');
|
|
1690
1700
|
}, []);
|
|
1701
|
+
|
|
1702
|
+
var _useInView = useInView({
|
|
1703
|
+
threshold: 0,
|
|
1704
|
+
triggerOnce: true
|
|
1705
|
+
}),
|
|
1706
|
+
ref = _useInView[0],
|
|
1707
|
+
inView = _useInView[1];
|
|
1708
|
+
|
|
1709
|
+
useEffect(function () {
|
|
1710
|
+
if (inView) {
|
|
1711
|
+
if (onlyOn === 'mobile' && window.innerWidth <= 511 || onlyOn === 'desktop' && window.innerWidth >= 512 || !onlyOn) {
|
|
1712
|
+
postMessage(type, url, 'view');
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
}, [inView]);
|
|
1716
|
+
|
|
1717
|
+
var handleClick = function handleClick() {
|
|
1718
|
+
postMessage(type, url, 'click');
|
|
1719
|
+
};
|
|
1720
|
+
|
|
1691
1721
|
var classNames = [[styles$s.root, true], [styles$s[cardType], !!layout && !!styles$s[cardType]], [styles$s.hasGradient, !!gradients], [styles$s[onlyOn], !!onlyOn && !!styles$s[onlyOn]]];
|
|
1692
1722
|
var context = ['isInMediaBlock'];
|
|
1693
1723
|
|
|
@@ -1703,17 +1733,31 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
|
1703
1733
|
style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
|
|
1704
1734
|
}
|
|
1705
1735
|
|
|
1706
|
-
if (
|
|
1707
|
-
return React.createElement(
|
|
1708
|
-
|
|
1736
|
+
if (type === 'unset') {
|
|
1737
|
+
return React.createElement("div", {
|
|
1738
|
+
className: styles$s.wrapper
|
|
1709
1739
|
});
|
|
1710
1740
|
}
|
|
1711
1741
|
|
|
1742
|
+
if (type === 'simpleRelated') {
|
|
1743
|
+
return React.createElement("div", {
|
|
1744
|
+
ref: ref,
|
|
1745
|
+
className: styles$s.wrapper
|
|
1746
|
+
}, React.createElement(RelatedBlock, {
|
|
1747
|
+
block: fallback,
|
|
1748
|
+
trackClick: true
|
|
1749
|
+
}));
|
|
1750
|
+
}
|
|
1751
|
+
|
|
1712
1752
|
return React.createElement("a", {
|
|
1713
1753
|
"data-testid": "related-rich-block",
|
|
1714
1754
|
className: makeClassName(classNames),
|
|
1715
1755
|
href: url,
|
|
1716
|
-
target: "_blank"
|
|
1756
|
+
target: "_blank",
|
|
1757
|
+
onClick: function onClick() {
|
|
1758
|
+
return handleClick();
|
|
1759
|
+
},
|
|
1760
|
+
ref: ref
|
|
1717
1761
|
}, layout === 'rich' && React.createElement(React.Fragment, null, React.createElement("div", {
|
|
1718
1762
|
className: styles$s.overlay,
|
|
1719
1763
|
style: style
|
|
@@ -2323,7 +2367,7 @@ var Spoiler = function Spoiler(_ref) {
|
|
|
2323
2367
|
setSpoiled(!spoiled);
|
|
2324
2368
|
|
|
2325
2369
|
if (spoiled) {
|
|
2326
|
-
postMessage('closeSpoiler', 'click');
|
|
2370
|
+
postMessage('', 'closeSpoiler', 'click');
|
|
2327
2371
|
var rect = ref.current.getBoundingClientRect();
|
|
2328
2372
|
|
|
2329
2373
|
if (rect.top < 0) {
|
|
@@ -2332,7 +2376,7 @@ var Spoiler = function Spoiler(_ref) {
|
|
|
2332
2376
|
});
|
|
2333
2377
|
}
|
|
2334
2378
|
} else {
|
|
2335
|
-
postMessage('openSpoiler', 'click');
|
|
2379
|
+
postMessage('', 'openSpoiler', 'click');
|
|
2336
2380
|
}
|
|
2337
2381
|
};
|
|
2338
2382
|
|