@meduza/ui-kit-2 0.1.23 → 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 +1228 -1205
- 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/Spoiler.module.css +2 -0
- package/src/Spoiler/index.tsx +2 -2
- package/src/utils/postMessage.ts +6 -1
|
@@ -303,9 +303,10 @@ var viewportSize = (function () {
|
|
|
303
303
|
|
|
304
304
|
var POST_MESSAGE_PREFIX = 'mdzKitMsg';
|
|
305
305
|
|
|
306
|
-
var postMessage = function postMessage(element, action) {
|
|
306
|
+
var postMessage = function postMessage(category, element, action) {
|
|
307
307
|
var target = window.top;
|
|
308
308
|
var msg = POST_MESSAGE_PREFIX + "=" + JSON.stringify({
|
|
309
|
+
category: category,
|
|
309
310
|
element: element,
|
|
310
311
|
action: action
|
|
311
312
|
});
|
|
@@ -457,7 +458,7 @@ var Image = function Image(_ref) {
|
|
|
457
458
|
return;
|
|
458
459
|
}
|
|
459
460
|
|
|
460
|
-
postMessage('fullscreen_click', 'click');
|
|
461
|
+
postMessage('', 'fullscreen_click', 'click');
|
|
461
462
|
lightBox.show(optimized, width, height, alt);
|
|
462
463
|
};
|
|
463
464
|
|
|
@@ -1601,6 +1602,7 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1601
1602
|
title = _ref$block$data.title,
|
|
1602
1603
|
related = _ref$block$data.related,
|
|
1603
1604
|
onlyOn = _ref$block.only_on,
|
|
1605
|
+
trackClick = _ref.trackClick,
|
|
1604
1606
|
styleContext = _ref.styleContext;
|
|
1605
1607
|
var classNames = [[styles$q.root, true], [styles$q[onlyOn], true]];
|
|
1606
1608
|
|
|
@@ -1608,6 +1610,12 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1608
1610
|
classNames = makeStyleContext(classNames, styleContext, styles$q);
|
|
1609
1611
|
}
|
|
1610
1612
|
|
|
1613
|
+
var handleClick = function handleClick(url) {
|
|
1614
|
+
if (trackClick) {
|
|
1615
|
+
postMessage('simpleRelated', 'click', url);
|
|
1616
|
+
}
|
|
1617
|
+
};
|
|
1618
|
+
|
|
1611
1619
|
return React__default.createElement("div", {
|
|
1612
1620
|
"data-testid": "related-block",
|
|
1613
1621
|
className: makeClassName(classNames)
|
|
@@ -1622,7 +1630,10 @@ var RelatedBlock = function RelatedBlock(_ref) {
|
|
|
1622
1630
|
}, React__default.createElement("a", {
|
|
1623
1631
|
href: item.full_url || "/" + item.url,
|
|
1624
1632
|
target: "_blank",
|
|
1625
|
-
rel: "noopener noreferrer"
|
|
1633
|
+
rel: "noopener noreferrer",
|
|
1634
|
+
onClick: function onClick() {
|
|
1635
|
+
return handleClick(item.full_url || item.url);
|
|
1636
|
+
}
|
|
1626
1637
|
}, React__default.createElement("span", {
|
|
1627
1638
|
className: styles$q.first
|
|
1628
1639
|
}, item.title), item.second_title && ' ', item.second_title && React__default.createElement("span", null, item.second_title)));
|
|
@@ -1666,7 +1677,7 @@ var SourceBlock = function SourceBlock(_ref) {
|
|
|
1666
1677
|
}, origin))));
|
|
1667
1678
|
};
|
|
1668
1679
|
|
|
1669
|
-
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"};
|
|
1680
|
+
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"};
|
|
1670
1681
|
|
|
1671
1682
|
/* eslint-disable react/jsx-no-target-blank */
|
|
1672
1683
|
var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
@@ -1686,15 +1697,34 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
|
1686
1697
|
var style = {};
|
|
1687
1698
|
var styleHeader = {};
|
|
1688
1699
|
|
|
1689
|
-
var _useState = React.useState(
|
|
1690
|
-
|
|
1691
|
-
|
|
1700
|
+
var _useState = React.useState('unset'),
|
|
1701
|
+
type = _useState[0],
|
|
1702
|
+
setType = _useState[1];
|
|
1692
1703
|
|
|
1693
1704
|
var cardType = "is" + toCapitalize(layout);
|
|
1694
1705
|
React.useEffect(function () {
|
|
1695
|
-
|
|
1696
|
-
setIsRich(true);
|
|
1706
|
+
setType(Math.random() >= 0.5 ? 'simpleRelated' : 'richRelated');
|
|
1697
1707
|
}, []);
|
|
1708
|
+
|
|
1709
|
+
var _useInView = reactIntersectionObserver.useInView({
|
|
1710
|
+
threshold: 0,
|
|
1711
|
+
triggerOnce: true
|
|
1712
|
+
}),
|
|
1713
|
+
ref = _useInView[0],
|
|
1714
|
+
inView = _useInView[1];
|
|
1715
|
+
|
|
1716
|
+
React.useEffect(function () {
|
|
1717
|
+
if (inView) {
|
|
1718
|
+
if (onlyOn === 'mobile' && window.innerWidth <= 511 || onlyOn === 'desktop' && window.innerWidth >= 512 || !onlyOn) {
|
|
1719
|
+
postMessage(type, url, 'view');
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}, [inView]);
|
|
1723
|
+
|
|
1724
|
+
var handleClick = function handleClick() {
|
|
1725
|
+
postMessage(type, url, 'click');
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1698
1728
|
var classNames = [[styles$s.root, true], [styles$s[cardType], !!layout && !!styles$s[cardType]], [styles$s.hasGradient, !!gradients], [styles$s[onlyOn], !!onlyOn && !!styles$s[onlyOn]]];
|
|
1699
1729
|
var context = ['isInMediaBlock'];
|
|
1700
1730
|
|
|
@@ -1710,17 +1740,31 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
|
|
|
1710
1740
|
style.backgroundImage = generateGradient(gradients.bg_rgb, 'mediaBlockBottom');
|
|
1711
1741
|
}
|
|
1712
1742
|
|
|
1713
|
-
if (
|
|
1714
|
-
return React__default.createElement(
|
|
1715
|
-
|
|
1743
|
+
if (type === 'unset') {
|
|
1744
|
+
return React__default.createElement("div", {
|
|
1745
|
+
className: styles$s.wrapper
|
|
1716
1746
|
});
|
|
1717
1747
|
}
|
|
1718
1748
|
|
|
1749
|
+
if (type === 'simpleRelated') {
|
|
1750
|
+
return React__default.createElement("div", {
|
|
1751
|
+
ref: ref,
|
|
1752
|
+
className: styles$s.wrapper
|
|
1753
|
+
}, React__default.createElement(RelatedBlock, {
|
|
1754
|
+
block: fallback,
|
|
1755
|
+
trackClick: true
|
|
1756
|
+
}));
|
|
1757
|
+
}
|
|
1758
|
+
|
|
1719
1759
|
return React__default.createElement("a", {
|
|
1720
1760
|
"data-testid": "related-rich-block",
|
|
1721
1761
|
className: makeClassName(classNames),
|
|
1722
1762
|
href: url,
|
|
1723
|
-
target: "_blank"
|
|
1763
|
+
target: "_blank",
|
|
1764
|
+
onClick: function onClick() {
|
|
1765
|
+
return handleClick();
|
|
1766
|
+
},
|
|
1767
|
+
ref: ref
|
|
1724
1768
|
}, layout === 'rich' && React__default.createElement(React__default.Fragment, null, React__default.createElement("div", {
|
|
1725
1769
|
className: styles$s.overlay,
|
|
1726
1770
|
style: style
|
|
@@ -2330,7 +2374,7 @@ var Spoiler = function Spoiler(_ref) {
|
|
|
2330
2374
|
setSpoiled(!spoiled);
|
|
2331
2375
|
|
|
2332
2376
|
if (spoiled) {
|
|
2333
|
-
postMessage('closeSpoiler', 'click');
|
|
2377
|
+
postMessage('', 'closeSpoiler', 'click');
|
|
2334
2378
|
var rect = ref.current.getBoundingClientRect();
|
|
2335
2379
|
|
|
2336
2380
|
if (rect.top < 0) {
|
|
@@ -2339,7 +2383,7 @@ var Spoiler = function Spoiler(_ref) {
|
|
|
2339
2383
|
});
|
|
2340
2384
|
}
|
|
2341
2385
|
} else {
|
|
2342
|
-
postMessage('openSpoiler', 'click');
|
|
2386
|
+
postMessage('', 'openSpoiler', 'click');
|
|
2343
2387
|
}
|
|
2344
2388
|
};
|
|
2345
2389
|
|