@micromag/screen-timeline 0.4.49 → 0.4.51

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.
Files changed (2) hide show
  1. package/es/index.js +195 -179
  2. package/package.json +13 -13
package/es/index.js CHANGED
@@ -4,7 +4,7 @@ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
4
4
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
5
5
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
6
6
  import classNames from 'classnames';
7
- import React, { useMemo, useState, useEffect, useCallback } from 'react';
7
+ import { useMemo, useState, useEffect, useCallback } from 'react';
8
8
  import { ScreenElement } from '@micromag/core/components';
9
9
  import { useScreenSize, useViewerContext, useViewerWebView, useScreenRenderContext, usePlaybackContext, usePlaybackMediaRef, useViewerContainer } from '@micromag/core/contexts';
10
10
  import { useTrackScreenEvent, useActivityDetector, useDebounce, useTrackScreenMedia, useDimensionObserver } from '@micromag/core/hooks';
@@ -19,6 +19,7 @@ import Layout from '@micromag/element-layout';
19
19
  import Scroll from '@micromag/element-scroll';
20
20
  import Text from '@micromag/element-text';
21
21
  import Visual from '@micromag/element-visual';
22
+ import { jsx, jsxs } from 'react/jsx-runtime';
22
23
  import _objectDestructuringEmpty from '@babel/runtime/helpers/objectDestructuringEmpty';
23
24
  import _extends from '@babel/runtime/helpers/extends';
24
25
 
@@ -326,112 +327,120 @@ function Timeline(_ref) {
326
327
  titleTextStyle = _ref9.textStyle;
327
328
  var _ref0 = description || {},
328
329
  descriptionTextStyle = _ref0.textStyle;
329
- return /*#__PURE__*/React.createElement("div", {
330
+ return /*#__PURE__*/jsx("div", {
330
331
  className: styles.item,
331
- key: "item-".concat(itemI)
332
- }, elementsTypes.map(function (elementType, typeI) {
333
- var elementContent = null;
334
- var hasElement = false;
335
- switch (elementType) {
336
- case 'title':
337
- hasElement = hasItemTitle;
338
- elementContent = /*#__PURE__*/React.createElement("div", {
339
- className: styles.title
340
- }, /*#__PURE__*/React.createElement(ScreenElement, {
341
- placeholder: "title",
342
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
343
- id: "bmO4Ss",
344
- defaultMessage: [{
345
- "type": 0,
346
- "value": "Entry Title"
347
- }]
348
- }),
349
- emptyClassName: styles.empty,
350
- isEmpty: !hasItemTitle
351
- }, hasItemTitle ? /*#__PURE__*/React.createElement(Heading, Object.assign({}, itemTitle, {
352
- textStyle: _objectSpread(_objectSpread({}, itemTitleStyle || null), titleTextStyle)
353
- })) : null));
354
- break;
355
- case 'image':
356
- hasElement = hasImage;
357
- elementContent = /*#__PURE__*/React.createElement("div", {
358
- className: styles.imageContainer
359
- }, /*#__PURE__*/React.createElement(ScreenElement, {
360
- placeholder: "image",
361
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
362
- id: "ebsPd4",
363
- defaultMessage: [{
364
- "type": 0,
365
- "value": "Image"
366
- }]
367
- }),
368
- emptyClassName: styles.empty,
369
- isEmpty: !hasImage
370
- }, hasImage ? /*#__PURE__*/React.createElement(Visual, {
371
- className: styles.image,
372
- videoClassName: styles.video,
373
- loadingMode: "lazy",
374
- media: image,
375
- width: imageWidth,
376
- resolution: resolution,
377
- playing: backgroundPlaying,
378
- active: active,
379
- shouldLoad: mediaShouldLoad,
380
- withoutVideo: isPreview,
381
- onLoaded: onImageLoaded
382
- }) : null));
383
- break;
384
- case 'description':
385
- hasElement = hasDescription;
386
- elementContent = /*#__PURE__*/React.createElement("div", {
387
- className: styles.description
388
- }, /*#__PURE__*/React.createElement(ScreenElement, {
389
- placeholder: "text",
390
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
391
- id: "507VAi",
392
- defaultMessage: [{
393
- "type": 0,
394
- "value": "Description"
395
- }]
396
- }),
397
- emptyClassName: styles.empty,
398
- isEmpty: !hasDescription
399
- }, hasDescription ? /*#__PURE__*/React.createElement(Text, Object.assign({}, description, {
400
- textStyle: _objectSpread(_objectSpread({}, itemDescriptionStyle || null), descriptionTextStyle)
401
- })) : null));
402
- break;
403
- default:
404
- elementContent = null;
405
- hasElement = false;
406
- }
407
- var firstItem = itemI === 0;
408
- var lastItem = itemI === itemsCount - 1;
409
- var lastType = typeI === typesCount - 1;
410
- var topLineHidden = firstItem && typeI <= titleIndex || lastItem && typeI > titleIndex;
411
- var bottomLineHidden = firstItem && typeI < titleIndex || lastItem && typeI >= titleIndex;
412
- return /*#__PURE__*/React.createElement("div", {
413
- key: "element-".concat(elementType),
414
- className: classNames([styles.element, styles["element-".concat(elementType)], _defineProperty({}, styles.hidden, (isView || isStatic) && !hasElement)]),
415
- ref: itemI === 0 ? firstContentRef : null
416
- }, !withoutLine ? /*#__PURE__*/React.createElement("div", {
417
- className: styles.timeline,
418
- ref: itemI === 0 ? firstLineRef : null
419
- }, /*#__PURE__*/React.createElement("div", {
420
- className: classNames([styles.line, _defineProperty({}, styles.hidden, topLineHidden)]),
421
- style: _objectSpread({}, !topLineHidden ? getStyleFromColor(lineColor, 'backgroundColor') : null)
422
- }), elementType === 'title' ? /*#__PURE__*/React.createElement("div", {
423
- className: styles.bullet,
424
- style: _objectSpread(_objectSpread({}, getStyleFromColor(bulletColor, 'borderColor')), bulletFilled ? getStyleFromColor(bulletColor, 'backgroundColor') : null)
425
- }) : null, /*#__PURE__*/React.createElement("div", {
426
- className: classNames([styles.line, _defineProperty({}, styles.hidden, bottomLineHidden)]),
427
- style: _objectSpread({}, !bottomLineHidden ? getStyleFromColor(lineColor, 'backgroundColor') : null)
428
- })) : null, /*#__PURE__*/React.createElement("div", {
429
- className: styles.body,
430
- style: {
431
- marginBottom: lastType && !lastItem ? itemBottomSpacing : 0
332
+ children: elementsTypes.map(function (elementType, typeI) {
333
+ var elementContent = null;
334
+ var hasElement = false;
335
+ switch (elementType) {
336
+ case 'title':
337
+ hasElement = hasItemTitle;
338
+ elementContent = /*#__PURE__*/jsx("div", {
339
+ className: styles.title,
340
+ children: /*#__PURE__*/jsx(ScreenElement, {
341
+ placeholder: "title",
342
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
343
+ id: "bmO4Ss",
344
+ defaultMessage: [{
345
+ "type": 0,
346
+ "value": "Entry Title"
347
+ }]
348
+ }),
349
+ emptyClassName: styles.empty,
350
+ isEmpty: !hasItemTitle,
351
+ children: hasItemTitle ? /*#__PURE__*/jsx(Heading, _objectSpread(_objectSpread({}, itemTitle), {}, {
352
+ textStyle: _objectSpread(_objectSpread({}, itemTitleStyle || null), titleTextStyle)
353
+ })) : null
354
+ })
355
+ });
356
+ break;
357
+ case 'image':
358
+ hasElement = hasImage;
359
+ elementContent = /*#__PURE__*/jsx("div", {
360
+ className: styles.imageContainer,
361
+ children: /*#__PURE__*/jsx(ScreenElement, {
362
+ placeholder: "image",
363
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
364
+ id: "ebsPd4",
365
+ defaultMessage: [{
366
+ "type": 0,
367
+ "value": "Image"
368
+ }]
369
+ }),
370
+ emptyClassName: styles.empty,
371
+ isEmpty: !hasImage,
372
+ children: hasImage ? /*#__PURE__*/jsx(Visual, {
373
+ className: styles.image,
374
+ videoClassName: styles.video,
375
+ loadingMode: "lazy",
376
+ media: image,
377
+ width: imageWidth,
378
+ resolution: resolution,
379
+ playing: backgroundPlaying,
380
+ active: active,
381
+ shouldLoad: mediaShouldLoad,
382
+ withoutVideo: isPreview,
383
+ onLoaded: onImageLoaded
384
+ }) : null
385
+ })
386
+ });
387
+ break;
388
+ case 'description':
389
+ hasElement = hasDescription;
390
+ elementContent = /*#__PURE__*/jsx("div", {
391
+ className: styles.description,
392
+ children: /*#__PURE__*/jsx(ScreenElement, {
393
+ placeholder: "text",
394
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
395
+ id: "507VAi",
396
+ defaultMessage: [{
397
+ "type": 0,
398
+ "value": "Description"
399
+ }]
400
+ }),
401
+ emptyClassName: styles.empty,
402
+ isEmpty: !hasDescription,
403
+ children: hasDescription ? /*#__PURE__*/jsx(Text, _objectSpread(_objectSpread({}, description), {}, {
404
+ textStyle: _objectSpread(_objectSpread({}, itemDescriptionStyle || null), descriptionTextStyle)
405
+ })) : null
406
+ })
407
+ });
408
+ break;
409
+ default:
410
+ elementContent = null;
411
+ hasElement = false;
432
412
  }
433
- }, elementContent));
434
- }));
413
+ var firstItem = itemI === 0;
414
+ var lastItem = itemI === itemsCount - 1;
415
+ var lastType = typeI === typesCount - 1;
416
+ var topLineHidden = firstItem && typeI <= titleIndex || lastItem && typeI > titleIndex;
417
+ var bottomLineHidden = firstItem && typeI < titleIndex || lastItem && typeI >= titleIndex;
418
+ return /*#__PURE__*/jsxs("div", {
419
+ className: classNames([styles.element, styles["element-".concat(elementType)], _defineProperty({}, styles.hidden, (isView || isStatic) && !hasElement)]),
420
+ ref: itemI === 0 ? firstContentRef : null,
421
+ children: [!withoutLine ? /*#__PURE__*/jsxs("div", {
422
+ className: styles.timeline,
423
+ ref: itemI === 0 ? firstLineRef : null,
424
+ children: [/*#__PURE__*/jsx("div", {
425
+ className: classNames([styles.line, _defineProperty({}, styles.hidden, topLineHidden)]),
426
+ style: _objectSpread({}, !topLineHidden ? getStyleFromColor(lineColor, 'backgroundColor') : null)
427
+ }), elementType === 'title' ? /*#__PURE__*/jsx("div", {
428
+ className: styles.bullet,
429
+ style: _objectSpread(_objectSpread({}, getStyleFromColor(bulletColor, 'borderColor')), bulletFilled ? getStyleFromColor(bulletColor, 'backgroundColor') : null)
430
+ }) : null, /*#__PURE__*/jsx("div", {
431
+ className: classNames([styles.line, _defineProperty({}, styles.hidden, bottomLineHidden)]),
432
+ style: _objectSpread({}, !bottomLineHidden ? getStyleFromColor(lineColor, 'backgroundColor') : null)
433
+ })]
434
+ }) : null, /*#__PURE__*/jsx("div", {
435
+ className: styles.body,
436
+ style: {
437
+ marginBottom: lastType && !lastItem ? itemBottomSpacing : 0
438
+ },
439
+ children: elementContent
440
+ })]
441
+ }, "element-".concat(elementType));
442
+ })
443
+ }, "item-".concat(itemI));
435
444
  });
436
445
 
437
446
  // Call to Action
@@ -470,85 +479,92 @@ function Timeline(_ref) {
470
479
  });
471
480
  }
472
481
  }, [trackScreenEvent]);
473
- return /*#__PURE__*/React.createElement("div", {
482
+ return /*#__PURE__*/jsxs("div", {
474
483
  className: classNames([styles.container, className, _defineProperty(_defineProperty(_defineProperty({}, styles.isPlaceholder, isPlaceholder), styles["".concat(bulletShape, "BulletShape")], bulletShape !== null), styles.withoutLines, itemsCount < 2)]),
475
- "data-screen-ready": ready
476
- }, /*#__PURE__*/React.createElement(Container, {
477
- width: width,
478
- height: height,
479
- className: styles.content
480
- }, /*#__PURE__*/React.createElement(Scroll, {
481
- className: styles.scroll,
482
- verticalAlign: "middle",
483
- disabled: scrollingDisabled,
484
- onScrolledTrigger: onScrolledTrigger,
485
- onScrolledBottom: onScrolledBottom,
486
- onScrolledNotBottom: onScrolledNotBottom,
487
- withShadow: true
488
- }, /*#__PURE__*/React.createElement(Layout, {
489
- style: !isPlaceholder ? {
490
- padding: spacing,
491
- paddingTop: (!isPreview ? viewerTopHeight : 0) + (hasHeader ? spacing / 2 : spacing),
492
- paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight || spacing)
493
- } : null
494
- }, !isPlaceholder && hasHeader ? /*#__PURE__*/React.createElement("div", {
495
- style: {
496
- paddingBottom: spacing
497
- }
498
- }, /*#__PURE__*/React.createElement(Header, header)) : null, /*#__PURE__*/React.createElement(ScreenElement, {
499
- placeholder: "Title",
500
- emptyLabel: /*#__PURE__*/React.createElement(FormattedMessage, {
501
- id: "BSTWf8",
502
- defaultMessage: [{
503
- "type": 0,
504
- "value": "Title"
505
- }]
506
- }),
507
- emptyClassName: classNames([styles.empty, styles.emptyTitle]),
508
- isEmpty: !hasTitle
509
- }, hasTitle ? /*#__PURE__*/React.createElement(Heading, Object.assign({
510
- className: styles.title
511
- }, title)) : null), timelineElements)), !isPlaceholder && hasFooter ? /*#__PURE__*/React.createElement("div", {
512
- ref: footerRef,
513
- className: classNames([styles.callToAction, _defineProperty({}, styles.disabled, !scrolledBottom)]),
514
- style: {
515
- transform: current && !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
516
- paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
517
- paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
518
- paddingTop: spacing / 2,
519
- paddingBottom: spacing / 2
520
- }
521
- }, /*#__PURE__*/React.createElement(Footer, footerProps)) : null), audioAlternativeMedia !== null ? /*#__PURE__*/React.createElement(Audio, Object.assign({}, finalAudioAlternative, {
522
- paused: !audioPlaying,
523
- mediaRef: mediaRef,
524
- muted: muted,
525
- className: styles.audio,
526
- shouldLoad: mediaShouldLoad,
527
- onReady: onAudioReady,
528
- onPlay: onAudioPlay,
529
- onPause: onAudioPause,
530
- onTimeUpdate: onAudioTimeUpdate,
531
- onProgressStep: onAudioProgressStep,
532
- onDurationChange: onAudioDurationChange,
533
- onSeeked: onAudioSeeked,
534
- onEnded: onAudioEnded
535
- })) : null, !isPlaceholder ? /*#__PURE__*/React.createElement(Background, {
536
- background: background,
537
- width: width,
538
- height: height,
539
- resolution: imageResolution,
540
- playing: backgroundPlaying,
541
- muted: muted,
542
- shouldLoad: mediaShouldLoad,
543
- mediaRef: audioAlternativeMedia === null ? mediaRef : null,
544
- withoutVideo: isPreview,
545
- className: styles.background
546
- }) : null);
484
+ "data-screen-ready": ready,
485
+ children: [/*#__PURE__*/jsxs(Container, {
486
+ width: width,
487
+ height: height,
488
+ className: styles.content,
489
+ children: [/*#__PURE__*/jsx(Scroll, {
490
+ className: styles.scroll,
491
+ verticalAlign: "middle",
492
+ disabled: scrollingDisabled,
493
+ onScrolledTrigger: onScrolledTrigger,
494
+ onScrolledBottom: onScrolledBottom,
495
+ onScrolledNotBottom: onScrolledNotBottom,
496
+ withShadow: true,
497
+ children: /*#__PURE__*/jsxs(Layout, {
498
+ style: !isPlaceholder ? {
499
+ padding: spacing,
500
+ paddingTop: (!isPreview ? viewerTopHeight : 0) + (hasHeader ? spacing / 2 : spacing),
501
+ paddingBottom: (current && !isPreview ? viewerBottomHeight : 0) + (footerHeight || spacing)
502
+ } : null,
503
+ children: [!isPlaceholder && hasHeader ? /*#__PURE__*/jsx("div", {
504
+ style: {
505
+ paddingBottom: spacing
506
+ },
507
+ children: /*#__PURE__*/jsx(Header, _objectSpread({}, header))
508
+ }) : null, /*#__PURE__*/jsx(ScreenElement, {
509
+ placeholder: "Title",
510
+ emptyLabel: /*#__PURE__*/jsx(FormattedMessage, {
511
+ id: "BSTWf8",
512
+ defaultMessage: [{
513
+ "type": 0,
514
+ "value": "Title"
515
+ }]
516
+ }),
517
+ emptyClassName: classNames([styles.empty, styles.emptyTitle]),
518
+ isEmpty: !hasTitle,
519
+ children: hasTitle ? /*#__PURE__*/jsx(Heading, _objectSpread({
520
+ className: styles.title
521
+ }, title)) : null
522
+ }), timelineElements]
523
+ })
524
+ }), !isPlaceholder && hasFooter ? /*#__PURE__*/jsx("div", {
525
+ ref: footerRef,
526
+ className: classNames([styles.callToAction, _defineProperty({}, styles.disabled, !scrolledBottom)]),
527
+ style: {
528
+ transform: current && !isPreview ? "translate(0, -".concat(viewerBottomHeight, "px)") : null,
529
+ paddingLeft: Math.max(spacing / 2, viewerBottomSidesWidth),
530
+ paddingRight: Math.max(spacing / 2, viewerBottomSidesWidth),
531
+ paddingTop: spacing / 2,
532
+ paddingBottom: spacing / 2
533
+ },
534
+ children: /*#__PURE__*/jsx(Footer, _objectSpread({}, footerProps))
535
+ }) : null]
536
+ }), audioAlternativeMedia !== null ? /*#__PURE__*/jsx(Audio, _objectSpread(_objectSpread({}, finalAudioAlternative), {}, {
537
+ paused: !audioPlaying,
538
+ mediaRef: mediaRef,
539
+ muted: muted,
540
+ className: styles.audio,
541
+ shouldLoad: mediaShouldLoad,
542
+ onReady: onAudioReady,
543
+ onPlay: onAudioPlay,
544
+ onPause: onAudioPause,
545
+ onTimeUpdate: onAudioTimeUpdate,
546
+ onProgressStep: onAudioProgressStep,
547
+ onDurationChange: onAudioDurationChange,
548
+ onSeeked: onAudioSeeked,
549
+ onEnded: onAudioEnded
550
+ })) : null, !isPlaceholder ? /*#__PURE__*/jsx(Background, {
551
+ background: background,
552
+ width: width,
553
+ height: height,
554
+ resolution: imageResolution,
555
+ playing: backgroundPlaying,
556
+ muted: muted,
557
+ shouldLoad: mediaShouldLoad,
558
+ mediaRef: audioAlternativeMedia === null ? mediaRef : null,
559
+ withoutVideo: isPreview,
560
+ className: styles.background
561
+ }) : null]
562
+ });
547
563
  }
548
564
 
549
565
  function TimelineIllustratedScreen(_ref) {
550
566
  var props = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
551
- return /*#__PURE__*/React.createElement(Timeline, Object.assign({}, props, {
567
+ return /*#__PURE__*/jsx(Timeline, _objectSpread(_objectSpread({}, props), {}, {
552
568
  illustrated: true
553
569
  }));
554
570
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-timeline",
3
- "version": "0.4.49",
3
+ "version": "0.4.51",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -61,17 +61,17 @@
61
61
  },
62
62
  "dependencies": {
63
63
  "@babel/runtime": "^7.28.6",
64
- "@micromag/core": "^0.4.49",
65
- "@micromag/element-background": "^0.4.49",
66
- "@micromag/element-container": "^0.4.49",
67
- "@micromag/element-footer": "^0.4.49",
68
- "@micromag/element-header": "^0.4.49",
69
- "@micromag/element-heading": "^0.4.49",
70
- "@micromag/element-layout": "^0.4.49",
71
- "@micromag/element-scroll": "^0.4.49",
72
- "@micromag/element-text": "^0.4.49",
73
- "@micromag/element-visual": "^0.4.49",
74
- "@micromag/transforms": "^0.4.49",
64
+ "@micromag/core": "^0.4.51",
65
+ "@micromag/element-background": "^0.4.51",
66
+ "@micromag/element-container": "^0.4.51",
67
+ "@micromag/element-footer": "^0.4.51",
68
+ "@micromag/element-header": "^0.4.51",
69
+ "@micromag/element-heading": "^0.4.51",
70
+ "@micromag/element-layout": "^0.4.51",
71
+ "@micromag/element-scroll": "^0.4.51",
72
+ "@micromag/element-text": "^0.4.51",
73
+ "@micromag/element-visual": "^0.4.51",
74
+ "@micromag/transforms": "^0.4.51",
75
75
  "classnames": "^2.2.6",
76
76
  "lodash": "^4.17.23",
77
77
  "react-intl": "^8.1.3 || ^10.0.0",
@@ -81,6 +81,6 @@
81
81
  "access": "public",
82
82
  "registry": "https://registry.npmjs.org/"
83
83
  },
84
- "gitHead": "0a225ff29387217cccb0fcc5a731e23c74bd202e",
84
+ "gitHead": "985a2370829c9ac8901ea97bf20bfc98ab158439",
85
85
  "types": "es/index.d.ts"
86
86
  }