@meduza/ui-kit-2 0.1.38 → 0.1.39

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.
@@ -332,7 +332,7 @@ var imageConditionalKeys = {
332
332
  narrow: [600, 325]
333
333
  };
334
334
 
335
- var styles$3 = {"root":"Lazy-module_root__2Z72l","visible":"Lazy-module_visible__3-SdX"};
335
+ var styles$3 = {"root":"Lazy-module_root__2Z72l"};
336
336
 
337
337
  var Lazy = function Lazy(_ref) {
338
338
  var children = _ref.children,
@@ -380,7 +380,8 @@ var RenderPicture = function RenderPicture(_ref) {
380
380
  fallbackSource = _ref.fallbackSource,
381
381
  optimized = _ref.optimized,
382
382
  alt = _ref.alt,
383
- display = _ref.display;
383
+ display = _ref.display,
384
+ _onLoad = _ref.onLoad;
384
385
 
385
386
  var _useState = useState(false),
386
387
  fallback = _useState[0],
@@ -416,11 +417,14 @@ var RenderPicture = function RenderPicture(_ref) {
416
417
  }));
417
418
  }), React.createElement("img", {
418
419
  src: fallback ? fallbackSource : 'data:image/gif;base64,R0lGODlhAQABAPAAAPLy8gAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==',
419
- alt: alt
420
+ alt: alt,
421
+ onLoad: function onLoad() {
422
+ return _onLoad(true);
423
+ }
420
424
  }));
421
425
  };
422
426
 
423
- var styles$4 = {"root":"Image-module_root__1vsA_","placeholder":"Image-module_placeholder__1p4ob","wrapper":"Image-module_wrapper__3fLjs","loaded":"Image-module_loaded__w9FVT","fullscreen":"Image-module_fullscreen__29apx"};
427
+ var styles$4 = {"root":"Image-module_root__1vsA_","isLoaded":"Image-module_isLoaded__3XhU5","wrapper":"Image-module_wrapper__3fLjs","fullscreen":"Image-module_fullscreen__29apx"};
424
428
 
425
429
  var Image = function Image(_ref) {
426
430
  var alt = _ref.alt,
@@ -436,6 +440,10 @@ var Image = function Image(_ref) {
436
440
  var _useContext = useContext(BlockContext),
437
441
  lightBox = _useContext.lightBox;
438
442
 
443
+ var _useState = useState(false),
444
+ isLoaded = _useState[0],
445
+ setIsLoaded = _useState[1];
446
+
439
447
  var handleClick = function handleClick() {
440
448
  if (!fullscreen || !lightBox || optimized && !optimized.original) {
441
449
  return;
@@ -455,17 +463,17 @@ var Image = function Image(_ref) {
455
463
  lightBox.show(optimized, width, height, alt);
456
464
  };
457
465
 
458
- var pictureStyles = {
459
- paddingBottom: 100 / (ratio || width / height) + "%"
460
- };
461
466
  var blockStyles = {
462
467
  maxWidth: width <= 649 ? width : '100%'
463
468
  };
469
+ var pictureStyles = {
470
+ paddingBottom: 100 / (ratio || width / height) + "%"
471
+ };
464
472
  /* fallback w325 url until w6 was released */
465
473
 
466
474
  var fallbackSource = source && source[0] || optimized.w325 && optimized.w325['1x'] || optimized.original;
467
475
  return React.createElement("div", {
468
- className: makeClassName([[styles$4.root, true], [styles$4.fullscreen, fullscreen && fullscreen.desktop]]),
476
+ className: makeClassName([[styles$4.root, true], [styles$4.isLoaded, !isLoaded], [styles$4.fullscreen, fullscreen && fullscreen.desktop]]),
469
477
  style: blockStyles,
470
478
  "data-testid": "image"
471
479
  }, React.createElement("div", {
@@ -486,7 +494,8 @@ var Image = function Image(_ref) {
486
494
  source: source,
487
495
  optimized: optimized,
488
496
  alt: alt,
489
- display: display
497
+ display: display,
498
+ onLoad: setIsLoaded
490
499
  })), React.createElement("noscript", null, React.createElement("img", {
491
500
  src: fallbackSource,
492
501
  alt: alt
@@ -495,7 +504,8 @@ var Image = function Image(_ref) {
495
504
  source: source,
496
505
  optimized: optimized,
497
506
  alt: alt,
498
- display: display
507
+ display: display,
508
+ onLoad: setIsLoaded
499
509
  })));
500
510
  };
501
511
 
@@ -1135,7 +1145,7 @@ var DangerousHTML = function DangerousHTML(_ref) {
1135
1145
  }));
1136
1146
  };
1137
1147
 
1138
- var styles$i = {"root":"EmbedBlock-module_root__28k9U","object":"EmbedBlock-module_object__2_UZ7","objectWrap":"EmbedBlock-module_objectWrap__1aDVd","gameEmbed":"EmbedBlock-module_gameEmbed__AZQSo","proportional":"EmbedBlock-module_proportional__3lAv4","default":"EmbedBlock-module_default__LSDny","xs":"EmbedBlock-module_xs__1hFgW","full":"EmbedBlock-module_full__1TEjx","super_full":"EmbedBlock-module_super_full__1Fn9A","figure":"EmbedBlock-module_figure__vAvcN","dark":"EmbedBlock-module_dark__1be2G","isInGroupedBlock":"EmbedBlock-module_isInGroupedBlock__3r_i-","control":"EmbedBlock-module_control__xr8dZ","raw_html":"EmbedBlock-module_raw_html__MQoAA","mobileFullwidth":"EmbedBlock-module_mobileFullwidth__QFFLH","isInCard":"EmbedBlock-module_isInCard__37rtq","isInSlide":"EmbedBlock-module_isInSlide__2ea5q","cc":"EmbedBlock-module_cc__1BQ5g","isInAnswer":"EmbedBlock-module_isInAnswer__tLlgs","picture":"EmbedBlock-module_picture__186q0","wrapper":"EmbedBlock-module_wrapper__33XvX","mobile":"EmbedBlock-module_mobile__1P-eo","desktop":"EmbedBlock-module_desktop__SF5a_"};
1148
+ var styles$i = {"root":"EmbedBlock-module_root__28k9U","object":"EmbedBlock-module_object__2_UZ7","objectWrap":"EmbedBlock-module_objectWrap__1aDVd","gameEmbed":"EmbedBlock-module_gameEmbed__AZQSo","proportional":"EmbedBlock-module_proportional__3lAv4","default":"EmbedBlock-module_default__LSDny","xs":"EmbedBlock-module_xs__1hFgW","full":"EmbedBlock-module_full__1TEjx","super_full":"EmbedBlock-module_super_full__1Fn9A","figure":"EmbedBlock-module_figure__vAvcN","dark":"EmbedBlock-module_dark__1be2G","isInGroupedBlock":"EmbedBlock-module_isInGroupedBlock__3r_i-","control":"EmbedBlock-module_control__xr8dZ","raw_html":"EmbedBlock-module_raw_html__MQoAA","mobileFullwidth":"EmbedBlock-module_mobileFullwidth__QFFLH","isInCard":"EmbedBlock-module_isInCard__37rtq","isInSlide":"EmbedBlock-module_isInSlide__2ea5q","cc":"EmbedBlock-module_cc__1BQ5g","isInSensitiveBlock":"EmbedBlock-module_isInSensitiveBlock__3wWYF","isInAnswer":"EmbedBlock-module_isInAnswer__tLlgs","picture":"EmbedBlock-module_picture__186q0","wrapper":"EmbedBlock-module_wrapper__33XvX","mobile":"EmbedBlock-module_mobile__1P-eo","desktop":"EmbedBlock-module_desktop__SF5a_"};
1139
1149
 
1140
1150
  var EmbedGif = function EmbedGif(_ref) {
1141
1151
  var gif = _ref.gif,
@@ -1597,7 +1607,6 @@ var RelatedBlock = function RelatedBlock(_ref) {
1597
1607
  title = _ref$block$data.title,
1598
1608
  related = _ref$block$data.related,
1599
1609
  onlyOn = _ref$block.only_on,
1600
- trackClick = _ref.trackClick,
1601
1610
  styleContext = _ref.styleContext;
1602
1611
  var classNames = [[styles$q.root, true], [styles$q[onlyOn], true]];
1603
1612
 
@@ -1605,12 +1614,6 @@ var RelatedBlock = function RelatedBlock(_ref) {
1605
1614
  classNames = makeStyleContext(classNames, styleContext, styles$q);
1606
1615
  }
1607
1616
 
1608
- var handleClick = function handleClick(url) {
1609
- if (trackClick) {
1610
- postMessage('simpleRelated', url, 'click');
1611
- }
1612
- };
1613
-
1614
1617
  return React.createElement("div", {
1615
1618
  "data-testid": "related-block",
1616
1619
  className: makeClassName(classNames)
@@ -1625,10 +1628,7 @@ var RelatedBlock = function RelatedBlock(_ref) {
1625
1628
  }, React.createElement("a", {
1626
1629
  href: item.full_url || "/" + item.url,
1627
1630
  target: "_blank",
1628
- rel: "noopener noreferrer",
1629
- onClick: function onClick() {
1630
- return handleClick(item.full_url || item.url);
1631
- }
1631
+ rel: "noopener noreferrer"
1632
1632
  }, React.createElement("span", {
1633
1633
  className: styles$q.first
1634
1634
  }, item.title), item.second_title && ' ', item.second_title && React.createElement("span", null, item.second_title)));
@@ -1672,7 +1672,7 @@ var SourceBlock = function SourceBlock(_ref) {
1672
1672
  }, origin))));
1673
1673
  };
1674
1674
 
1675
- var styles$s = {"root":"SensitiveBlock-module_root__2iJbD","container":"SensitiveBlock-module_container__1Wtix","overlay":"SensitiveBlock-module_overlay__hfDVS","content":"SensitiveBlock-module_content__sNpxZ","button":"SensitiveBlock-module_button__3BGZK","default":"SensitiveBlock-module_default__2HgmZ","full":"SensitiveBlock-module_full__3Hph9","super_full":"SensitiveBlock-module_super_full__14UOv","visible":"SensitiveBlock-module_visible__1B-NV"};
1675
+ var styles$s = {"root":"SensitiveBlock-module_root__2iJbD","container":"SensitiveBlock-module_container__1Wtix","overlay":"SensitiveBlock-module_overlay__hfDVS","content":"SensitiveBlock-module_content__sNpxZ","button":"SensitiveBlock-module_button__3BGZK","default":"SensitiveBlock-module_default__2HgmZ","full":"SensitiveBlock-module_full__3Hph9","media":"SensitiveBlock-module_media__3wnlo","super_full":"SensitiveBlock-module_super_full__14UOv","visible":"SensitiveBlock-module_visible__1B-NV","isInCard":"SensitiveBlock-module_isInCard__1L-lu","isInSlide":"SensitiveBlock-module_isInSlide__f_Ql2"};
1676
1676
 
1677
1677
  var SensitiveBlock = function SensitiveBlock(_ref) {
1678
1678
  var block = _ref.block,
@@ -1692,9 +1692,17 @@ var SensitiveBlock = function SensitiveBlock(_ref) {
1692
1692
  isVisible(true);
1693
1693
  };
1694
1694
 
1695
+ var classNames = [[styles$s.root, true], [styles$s.visible, visible], [styles$s[display], display && styles$s[display]]];
1696
+ var context = ['isInSensitiveBlock'];
1697
+
1698
+ if (styleContext) {
1699
+ classNames = makeStyleContext(classNames, styleContext, styles$s);
1700
+ context = [].concat(styleContext, ['isInSensitiveBlock']);
1701
+ }
1702
+
1695
1703
  return React.createElement("div", {
1696
1704
  "data-testid": "sensitive-block",
1697
- className: makeClassName([[styles$s.root, true], [styles$s.visible, visible], [styles$s[display], display && styles$s[display]]])
1705
+ className: makeClassName(classNames)
1698
1706
  }, React.createElement("div", {
1699
1707
  className: styles$s.container
1700
1708
  }, React.createElement("div", {
@@ -1719,7 +1727,7 @@ var SensitiveBlock = function SensitiveBlock(_ref) {
1719
1727
  className: styles$s.media
1720
1728
  }, React.createElement(EmbedBlockContainer, {
1721
1729
  block: block.item,
1722
- styleContext: ['isInSensitiveBlock']
1730
+ styleContext: context
1723
1731
  }))), cc && React.createElement("figcaption", {
1724
1732
  className: styles$s.figcaption
1725
1733
  }, React.createElement(MediaCaption, {
@@ -2379,7 +2387,6 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
2379
2387
  onlyOn = _ref$block.only_on,
2380
2388
  _ref$block$data = _ref$block.data,
2381
2389
  blocks = _ref$block$data.blocks,
2382
- fallback = _ref$block$data.fallback,
2383
2390
  url = _ref$block$data.url,
2384
2391
  _ref$block$data$cover = _ref$block$data.cover,
2385
2392
  urls = _ref$block$data$cover.urls,
@@ -2390,15 +2397,7 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
2390
2397
  styleContext = _ref.styleContext;
2391
2398
  var style = {};
2392
2399
  var styleHeader = {};
2393
-
2394
- var _useState = useState('unset'),
2395
- type = _useState[0],
2396
- setType = _useState[1];
2397
-
2398
2400
  var cardType = "is" + toCapitalize(layout);
2399
- useEffect(function () {
2400
- setType(Math.random() >= 0.5 ? 'simpleRelated' : 'richRelated');
2401
- }, []);
2402
2401
 
2403
2402
  var _useInView = useInView({
2404
2403
  threshold: 0,
@@ -2410,13 +2409,13 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
2410
2409
  useEffect(function () {
2411
2410
  if (inView) {
2412
2411
  if (onlyOn === 'mobile' && window.innerWidth <= 511 || onlyOn === 'desktop' && window.innerWidth >= 512 || !onlyOn) {
2413
- postMessage(type, url, 'view');
2412
+ postMessage('richRelated', url, 'view');
2414
2413
  }
2415
2414
  }
2416
2415
  }, [inView]);
2417
2416
 
2418
2417
  var handleClick = function handleClick() {
2419
- postMessage(type, url, 'click');
2418
+ postMessage('richRelated', url, 'click');
2420
2419
  };
2421
2420
 
2422
2421
  var classNames = [[styles$B.root, true], [styles$B[cardType], !!layout && !!styles$B[cardType]], [styles$B.hasGradient, !!gradients], [styles$B[onlyOn], !!onlyOn && !!styles$B[onlyOn]]];
@@ -2437,23 +2436,6 @@ var RelatedRichBlock = function RelatedRichBlock(_ref) {
2437
2436
  }
2438
2437
  }
2439
2438
 
2440
- if (type === 'unset') {
2441
- return React.createElement("div", {
2442
- className: styles$B.wrapper
2443
- });
2444
- }
2445
-
2446
- if (type === 'simpleRelated') {
2447
- return React.createElement("div", {
2448
- ref: ref,
2449
- className: styles$B.wrapper
2450
- }, React.createElement(RelatedBlock, {
2451
- block: fallback,
2452
- trackClick: true,
2453
- styleContext: styleContext
2454
- }));
2455
- }
2456
-
2457
2439
  return React.createElement("a", {
2458
2440
  "data-testid": "related-rich-block",
2459
2441
  className: makeClassName(classNames),