@micromag/screen-timeline 0.4.48 → 0.4.50
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/es/index.js +195 -179
- 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
|
|
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__*/
|
|
330
|
+
return /*#__PURE__*/jsx("div", {
|
|
330
331
|
className: styles.item,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
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
|
-
|
|
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__*/
|
|
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
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
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__*/
|
|
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.
|
|
3
|
+
"version": "0.4.50",
|
|
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.
|
|
65
|
-
"@micromag/element-background": "^0.4.
|
|
66
|
-
"@micromag/element-container": "^0.4.
|
|
67
|
-
"@micromag/element-footer": "^0.4.
|
|
68
|
-
"@micromag/element-header": "^0.4.
|
|
69
|
-
"@micromag/element-heading": "^0.4.
|
|
70
|
-
"@micromag/element-layout": "^0.4.
|
|
71
|
-
"@micromag/element-scroll": "^0.4.
|
|
72
|
-
"@micromag/element-text": "^0.4.
|
|
73
|
-
"@micromag/element-visual": "^0.4.
|
|
74
|
-
"@micromag/transforms": "^0.4.
|
|
64
|
+
"@micromag/core": "^0.4.50",
|
|
65
|
+
"@micromag/element-background": "^0.4.50",
|
|
66
|
+
"@micromag/element-container": "^0.4.50",
|
|
67
|
+
"@micromag/element-footer": "^0.4.50",
|
|
68
|
+
"@micromag/element-header": "^0.4.50",
|
|
69
|
+
"@micromag/element-heading": "^0.4.50",
|
|
70
|
+
"@micromag/element-layout": "^0.4.50",
|
|
71
|
+
"@micromag/element-scroll": "^0.4.50",
|
|
72
|
+
"@micromag/element-text": "^0.4.50",
|
|
73
|
+
"@micromag/element-visual": "^0.4.50",
|
|
74
|
+
"@micromag/transforms": "^0.4.50",
|
|
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": "
|
|
84
|
+
"gitHead": "940d5ca98f8f448b79eaa3e2fa685c3ee95185b8",
|
|
85
85
|
"types": "es/index.d.ts"
|
|
86
86
|
}
|