@meduza/ui-kit-2 0.1.41 → 0.1.44

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.
@@ -19,6 +19,7 @@ export interface ImageProps {
19
19
  desktop: boolean;
20
20
  };
21
21
  ratio?: number;
22
+ styleContext?: string[] | string;
22
23
  }
23
24
  export interface PictureProps {
24
25
  source?: string[];
@@ -289,18 +289,20 @@ var Switcher = function Switcher(_ref) {
289
289
  }, children));
290
290
  };
291
291
 
292
+ var makeStyleContext = function makeStyleContext(classNames, styleContext, styles) {
293
+ var context = Array.isArray(styleContext) ? styleContext.filter(function (ctx) {
294
+ return styles[ctx];
295
+ }).map(function (ctx) {
296
+ return [[styles[ctx]], true];
297
+ }) : [[styles[styleContext], !!styleContext && !!styles[styleContext]]];
298
+ return classNames.concat(context);
299
+ };
300
+
292
301
  var BlockContext = /*#__PURE__*/React__default.createContext({
293
302
  lightBox: null
294
303
  });
295
304
  var BlockProvider = BlockContext.Provider;
296
305
 
297
- var viewportSize = (function () {
298
- return {
299
- width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
300
- height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
301
- };
302
- });
303
-
304
306
  var POST_MESSAGE_PREFIX = 'mdzKitMsg';
305
307
 
306
308
  var postMessage = function postMessage(category, element, action) {
@@ -316,29 +318,6 @@ var postMessage = function postMessage(category, element, action) {
316
318
  }
317
319
  };
318
320
 
319
- var MediaQuerySizes = {
320
- MOBILE: 512,
321
- PORTRAIT_TABLET: 768,
322
- LANDSCAPE_TABLET: 1024,
323
- DESKTOP: 1010,
324
- WIDE_DESKTOP: 1200
325
- };
326
- var imageBreakpoints = {
327
- 325: '(min-width: 0)',
328
- 520: '(min-width: 325px)',
329
- 600: '(min-width: 600px)',
330
- 650: '(min-width: 650px)',
331
- 980: '(min-width: 1000px)',
332
- 1335: '(min-width: 1000px)'
333
- };
334
- var imageConditionalKeys = {
335
- xs: [325],
336
- superFull: [1335, 650, 520, 325],
337
- full: [980, 650, 520, 325],
338
- "default": [650, 520, 325],
339
- narrow: [600, 325]
340
- };
341
-
342
321
  var styles$3 = {"root":"Lazy-module_root__2Z72l"};
343
322
 
344
323
  var Lazy = function Lazy(_ref) {
@@ -373,6 +352,29 @@ var Lazy = function Lazy(_ref) {
373
352
  }, visible && children);
374
353
  };
375
354
 
355
+ var MediaQuerySizes = {
356
+ MOBILE: 512,
357
+ PORTRAIT_TABLET: 768,
358
+ LANDSCAPE_TABLET: 1024,
359
+ DESKTOP: 1010,
360
+ WIDE_DESKTOP: 1200
361
+ };
362
+ var imageBreakpoints = {
363
+ 325: '(min-width: 0)',
364
+ 520: '(min-width: 325px)',
365
+ 600: '(min-width: 600px)',
366
+ 650: '(min-width: 650px)',
367
+ 980: '(min-width: 1000px)',
368
+ 1335: '(min-width: 1000px)'
369
+ };
370
+ var imageConditionalKeys = {
371
+ xs: [325],
372
+ superFull: [1335, 650, 520, 325],
373
+ full: [980, 650, 520, 325],
374
+ "default": [650, 520, 325],
375
+ narrow: [600, 325]
376
+ };
377
+
376
378
  var toCamel = function toCamel(s) {
377
379
  return s.replace(/([_][a-z])/gi, function (str) {
378
380
  return str.toUpperCase().replace('_', '');
@@ -431,7 +433,7 @@ var RenderPicture = function RenderPicture(_ref) {
431
433
  }));
432
434
  };
433
435
 
434
- var styles$4 = {"root":"Image-module_root__1vsA_","isLoaded":"Image-module_isLoaded__3XhU5","wrapper":"Image-module_wrapper__3fLjs","fullscreen":"Image-module_fullscreen__29apx"};
436
+ var styles$4 = {"root":"Image-module_root__1vsA_","isLoaded":"Image-module_isLoaded__3XhU5","wrapper":"Image-module_wrapper__3fLjs","fullscreen":"Image-module_fullscreen__29apx","dark":"Image-module_dark__3o0nU"};
435
437
 
436
438
  var Image = function Image(_ref) {
437
439
  var alt = _ref.alt,
@@ -442,7 +444,8 @@ var Image = function Image(_ref) {
442
444
  source = _ref.source,
443
445
  lazy = _ref.lazy,
444
446
  fullscreen = _ref.fullscreen,
445
- ratio = _ref.ratio;
447
+ ratio = _ref.ratio,
448
+ styleContext = _ref.styleContext;
446
449
 
447
450
  var _useContext = React.useContext(BlockContext),
448
451
  lightBox = _useContext.lightBox;
@@ -452,17 +455,7 @@ var Image = function Image(_ref) {
452
455
  setIsLoaded = _useState[1];
453
456
 
454
457
  var handleClick = function handleClick() {
455
- if (!fullscreen || !lightBox || optimized && !optimized.original) {
456
- return;
457
- }
458
-
459
- var _viewportSize = viewportSize(),
460
- viewportWidth = _viewportSize.width;
461
-
462
- var disableFullscreenDesktop = viewportWidth >= MediaQuerySizes.LANDSCAPE_TABLET && !fullscreen.desktop;
463
- var disableFullscreenMobile = viewportWidth < MediaQuerySizes.LANDSCAPE_TABLET && !fullscreen.mobile;
464
-
465
- if (disableFullscreenDesktop || disableFullscreenMobile) {
458
+ if (!lightBox || optimized && !optimized.original) {
466
459
  return;
467
460
  }
468
461
 
@@ -479,8 +472,14 @@ var Image = function Image(_ref) {
479
472
  /* fallback w325 url until w6 was released */
480
473
 
481
474
  var fallbackSource = source && source[0] || optimized.w325 && optimized.w325['1x'] || optimized.original;
475
+ var classNames = [[styles$4.root, true], [styles$4.isLoaded, isLoaded], [styles$4.fullscreen, fullscreen && fullscreen.desktop]];
476
+
477
+ if (styleContext) {
478
+ classNames = makeStyleContext(classNames, styleContext, styles$4);
479
+ }
480
+
482
481
  return React__default.createElement("div", {
483
- className: makeClassName([[styles$4.root, true], [styles$4.isLoaded, isLoaded], [styles$4.fullscreen, fullscreen && fullscreen.desktop]]),
482
+ className: makeClassName(classNames),
484
483
  style: blockStyles,
485
484
  "data-testid": "image"
486
485
  }, React__default.createElement("div", {
@@ -627,6 +626,13 @@ var Footnote = function Footnote(_ref) {
627
626
  }, children));
628
627
  };
629
628
 
629
+ var viewportSize = (function () {
630
+ return {
631
+ width: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
632
+ height: window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight
633
+ };
634
+ });
635
+
630
636
  var styles$7 = {"root":"DotsOnImage-module_root__2XP3Q","isVisible":"DotsOnImage-module_isVisible__Wqqqt","marker":"DotsOnImage-module_marker__lH5cP","show":"DotsOnImage-module_show__2TMBv","dot":"DotsOnImage-module_dot__H1wua","isActive":"DotsOnImage-module_isActive__3hh31","popover":"DotsOnImage-module_popover__35Cpj","isRight":"DotsOnImage-module_isRight__2RsJe","isTop":"DotsOnImage-module_isTop__3zmSK","isLeft":"DotsOnImage-module_isLeft__3quc9","isBottom":"DotsOnImage-module_isBottom__3Nk1T"};
631
637
 
632
638
  var DotsOnImage = function DotsOnImage(_ref) {
@@ -800,15 +806,6 @@ var DotsOnImage = function DotsOnImage(_ref) {
800
806
  })))));
801
807
  };
802
808
 
803
- var makeStyleContext = function makeStyleContext(classNames, styleContext, styles) {
804
- var context = Array.isArray(styleContext) ? styleContext.filter(function (ctx) {
805
- return styles[ctx];
806
- }).map(function (ctx) {
807
- return [[styles[ctx]], true];
808
- }) : [[styles[styleContext], !!styleContext && !!styles[styleContext]]];
809
- return classNames.concat(context);
810
- };
811
-
812
809
  var styles$8 = {"root":"Tag-module_root__3IqWC","small":"Tag-module_small__2IAb7","large":"Tag-module_large__22z_o","dark":"Tag-module_dark__sgnt1","light":"Tag-module_light__1zUhp","gold":"Tag-module_gold__2ksA7","gray":"Tag-module_gray__mGAO_","inherit":"Tag-module_inherit__2QB5U","is1to1":"Tag-module_is1to1__3EDbC","is1to2":"Tag-module_is1to2__3xbC6","isInSuperBlock":"Tag-module_isInSuperBlock__38JE0","is1to3":"Tag-module_is1to3__3j5K-","is1to4":"Tag-module_is1to4__2vq4r","slide":"Tag-module_slide__2nMDw","game":"Tag-module_game__3j5yG","richRelated":"Tag-module_richRelated__2vbQQ","card":"Tag-module_card__1EAeF","live":"Tag-module_live__rwXuR","episode":"Tag-module_episode__3o6gg","podcast":"Tag-module_podcast__VPoll","rich":"Tag-module_rich__2URd9","isInDynamicBlock":"Tag-module_isInDynamicBlock__1YM9I","mobile":"Tag-module_mobile__QQxuv","desktop":"Tag-module_desktop__1Bjsy"};
813
810
 
814
811
  var Tag = function Tag(_ref) {
@@ -1282,7 +1279,8 @@ var EmbedBlock = function EmbedBlock(_ref) {
1282
1279
  height: block.data.height,
1283
1280
  alt: block.data.caption,
1284
1281
  display: block.data.display,
1285
- lazy: block.data.lazy
1282
+ lazy: block.data.lazy,
1283
+ styleContext: styleContext
1286
1284
  }));
1287
1285
  }
1288
1286