@micromag/viewer 0.3.176 → 0.3.181

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 (4) hide show
  1. package/assets/css/styles.css +12 -11
  2. package/es/index.js +1269 -1098
  3. package/lib/index.js +1283 -1112
  4. package/package.json +10 -10
package/es/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
3
  import PropTypes from 'prop-types';
4
- import React, { useEffect, useState, useCallback, useRef, useMemo } from 'react';
4
+ import React, { useEffect, useState, useCallback, useMemo, useRef } from 'react';
5
5
  import { Switch, Route, MemoryRouter } from 'react-router';
6
6
  import { BrowserRouter } from 'react-router-dom';
7
7
  import { PropTypes as PropTypes$1 } from '@micromag/core';
@@ -12,28 +12,20 @@ import { ScreensProvider } from '@micromag/screens';
12
12
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
13
13
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
14
14
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
15
- import { useDrag, useGesture } from '@use-gesture/react';
16
15
  import classNames from 'classnames';
17
16
  import { Helmet } from 'react-helmet';
18
- import { FormattedMessage, useIntl } from 'react-intl';
19
17
  import EventEmitter from 'wolfy87-eventemitter';
20
- import { Button, Close, ScreenPreview, Screen, Meta, FontFaces } from '@micromag/core/components';
21
- import { useDocumentEvent, useDimensionObserver, useTrackEvent, useMediaProgress, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
22
- import { getStyleFromColor, getStyleFromText, getColorAsString, getDeviceScreens } from '@micromag/core/utils';
23
- import { useSpring, config } from '@react-spring/core';
24
- import { animated } from '@react-spring/web';
18
+ import { IconButton, ScreenPreview, SlidingButtons, CloseButton, Screen, Button, Meta, FontFaces } from '@micromag/core/components';
19
+ import { useDimensionObserver, useTrackEvent, useDragProgress, useMediaProgress, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
20
+ import { getStyleFromColor, getColorAsString, getDeviceScreens } from '@micromag/core/utils';
21
+ import { useIntl, FormattedMessage } from 'react-intl';
25
22
  import { faTimes } from '@fortawesome/free-solid-svg-icons/faTimes';
26
- import { faShare } from '@fortawesome/free-solid-svg-icons/faShare';
27
23
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
28
- import ShareOptions from '@micromag/element-share-options';
29
- import { faCompress } from '@fortawesome/free-solid-svg-icons/faCompress';
30
- import { faExpand } from '@fortawesome/free-solid-svg-icons/faExpand';
24
+ import { useSpring } from '@react-spring/core';
25
+ import { animated } from '@react-spring/web';
31
26
  import Scroll from '@micromag/element-scroll';
32
- import { faArrowLeft } from '@fortawesome/free-solid-svg-icons/faArrowLeft';
33
- import { faArrowRight } from '@fortawesome/free-solid-svg-icons/faArrowRight';
34
- import { faPause } from '@fortawesome/free-solid-svg-icons/faPause';
35
- import { faPlay } from '@fortawesome/free-solid-svg-icons/faPlay';
36
- import { faVolumeUp } from '@fortawesome/free-solid-svg-icons/faVolumeUp';
27
+ import ShareOptions from '@micromag/element-share-options';
28
+ import { useGesture } from '@use-gesture/react';
37
29
  import WebView from '@micromag/element-webview';
38
30
 
39
31
  var routes = PropTypes.shape({
@@ -197,7 +189,7 @@ function useScreenInteraction() {
197
189
  var relativeX = x - left;
198
190
  var direction = relativeX < width * (1 - nextScreenWidthPercent) ? 'previous' : 'next';
199
191
  var lastIndex = screensCount - 1;
200
- var nextIndex = index;
192
+ var nextIndex = index; // @todo investigate what clickOnSiblings is doing
201
193
 
202
194
  if (direction === 'previous' && !clickOnSiblings) {
203
195
  nextIndex = Math.max(0, screenIndex - 1);
@@ -213,7 +205,7 @@ function useScreenInteraction() {
213
205
  end: index === nextIndex && nextIndex === lastIndex
214
206
  });
215
207
  }
216
- }, [screens, screenIndex, screenIndex, screensInteractionEnabled, currentScreenInteractionEnabled, nextScreenWidthPercent, disableCurrentScreenNavigation, clickOnSiblings, onInteract, onNavigate]);
208
+ }, [screens, screenIndex, screensInteractionEnabled, currentScreenInteractionEnabled, nextScreenWidthPercent, disableCurrentScreenNavigation, clickOnSiblings, onInteract, onNavigate]);
217
209
  return {
218
210
  interact: interact,
219
211
  currentScreenInteractionEnabled: currentScreenInteractionEnabled,
@@ -222,9 +214,137 @@ function useScreenInteraction() {
222
214
  };
223
215
  }
224
216
 
225
- var styles$c = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","menuButton":"micromag-viewer-menus-menu-dots-menuButton","item":"micromag-viewer-menus-menu-dots-item","items":"micromag-viewer-menus-menu-dots-items","menu":"micromag-viewer-menus-menu-dots-menu","menuIcon":"micromag-viewer-menus-menu-dots-menuIcon","vertical":"micromag-viewer-menus-menu-dots-vertical","withShadow":"micromag-viewer-menus-menu-dots-withShadow"};
217
+ var _excluded$5 = ["className", "onClick", "theme"];
218
+ var propTypes$k = {
219
+ className: PropTypes.string,
220
+ onClick: PropTypes.func,
221
+ theme: PropTypes$1.viewerTheme
222
+ };
223
+ var defaultProps$k = {
224
+ className: null,
225
+ onClick: null,
226
+ theme: null
227
+ };
228
+
229
+ var MenuButton = function MenuButton(_ref) {
230
+ var className = _ref.className,
231
+ onClick = _ref.onClick,
232
+ theme = _ref.theme,
233
+ props = _objectWithoutProperties(_ref, _excluded$5);
234
+
235
+ var intl = useIntl();
236
+ return /*#__PURE__*/React.createElement(IconButton, Object.assign({
237
+ className: classNames([_defineProperty({}, className, className !== null)]),
238
+ label: intl.formatMessage({
239
+ id: "F/gl4b",
240
+ defaultMessage: [{
241
+ "type": 0,
242
+ "value": "Menu"
243
+ }]
244
+ }),
245
+ iconPosition: "right",
246
+ icon: /*#__PURE__*/React.createElement("svg", Object.assign({
247
+ xmlns: "http://www.w3.org/2000/svg",
248
+ width: "10",
249
+ height: "16",
250
+ viewBox: "0 0 10 16",
251
+ fill: "currentColor"
252
+ }, theme), /*#__PURE__*/React.createElement("rect", {
253
+ width: "10",
254
+ height: "16"
255
+ })),
256
+ onClick: onClick
257
+ }, props));
258
+ };
259
+
260
+ MenuButton.propTypes = propTypes$k;
261
+ MenuButton.defaultProps = defaultProps$k;
262
+
263
+ var _excluded$4 = ["className", "onClick", "theme"];
264
+ var propTypes$j = {
265
+ className: PropTypes.string,
266
+ onClick: PropTypes.func,
267
+ theme: PropTypes$1.viewerTheme
268
+ };
269
+ var defaultProps$j = {
270
+ className: null,
271
+ onClick: null,
272
+ theme: null
273
+ };
274
+
275
+ var ShareButton = function ShareButton(_ref) {
276
+ var className = _ref.className,
277
+ onClick = _ref.onClick,
278
+ theme = _ref.theme,
279
+ props = _objectWithoutProperties(_ref, _excluded$4);
280
+
281
+ var intl = useIntl();
282
+ return /*#__PURE__*/React.createElement(IconButton, Object.assign({
283
+ className: classNames([_defineProperty({}, className, className !== null)]),
284
+ label: intl.formatMessage({
285
+ id: "7tw6U2",
286
+ defaultMessage: [{
287
+ "type": 0,
288
+ "value": "Share"
289
+ }]
290
+ }),
291
+ iconPosition: "left",
292
+ icon: /*#__PURE__*/React.createElement("svg", Object.assign({
293
+ xmlns: "http://www.w3.org/2000/svg",
294
+ width: "10",
295
+ height: "16",
296
+ viewBox: "0 0 10 16",
297
+ fill: "currentColor"
298
+ }, theme), /*#__PURE__*/React.createElement("polygon", {
299
+ points: "8.5 14.5 1.5 14.5 1.5 8 0 8 0 16 10 16 10 8 8.5 8 8.5 14.5"
300
+ }), /*#__PURE__*/React.createElement("polygon", {
301
+ points: "9.62 4.62 5 0 0.38 4.62 1.44 5.68 4.25 2.87 4.25 11.26 5.75 11.26 5.75 2.87 8.56 5.68 9.62 4.62"
302
+ })),
303
+ onClick: onClick
304
+ }, props));
305
+ };
306
+
307
+ ShareButton.propTypes = propTypes$j;
308
+ ShareButton.defaultProps = defaultProps$j;
309
+
310
+ var styles$d = {"container":"micromag-viewer-menus-menu-container-container","heightContainer":"micromag-viewer-menus-menu-container-heightContainer","inner":"micromag-viewer-menus-menu-container-inner"};
311
+
312
+ var propTypes$i = {
313
+ className: PropTypes.string,
314
+ transitionProgress: PropTypes.number,
315
+ children: PropTypes.node
316
+ };
317
+ var defaultProps$i = {
318
+ className: null,
319
+ transitionProgress: 0,
320
+ children: null
321
+ };
322
+
323
+ var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
324
+ var className = _ref.className,
325
+ transitionProgress = _ref.transitionProgress,
326
+ children = _ref.children;
327
+ return /*#__PURE__*/React.createElement("div", {
328
+ className: classNames([styles$d.container, _defineProperty({}, className, className !== null)]),
329
+ style: {
330
+ pointerEvents: 'none'
331
+ }
332
+ }, /*#__PURE__*/React.createElement("div", {
333
+ className: styles$d.heightContainer,
334
+ style: {
335
+ height: "".concat(transitionProgress * 100, "%"),
336
+ pointerEvents: transitionProgress < 0.25 ? 'none' : 'auto',
337
+ zIndex: Math.round(2 - transitionProgress)
338
+ }
339
+ }, /*#__PURE__*/React.createElement("div", {
340
+ className: styles$d.inner
341
+ }, children)));
342
+ };
343
+
344
+ ViewerMenuContainer.propTypes = propTypes$i;
345
+ ViewerMenuContainer.defaultProps = defaultProps$i;
226
346
 
227
- var styles$b = {"container":"micromag-viewer-menus-menu-dot-container","button":"micromag-viewer-menus-menu-dot-button","dot":"micromag-viewer-menus-menu-dot-dot","subDot":"micromag-viewer-menus-menu-dot-subDot","dots":"micromag-viewer-menus-menu-dot-dots","vertical":"micromag-viewer-menus-menu-dot-vertical"};
347
+ var styles$c = {"button":"micromag-viewer-menus-menu-dot-button","progress":"micromag-viewer-menus-menu-dot-progress","dot":"micromag-viewer-menus-menu-dot-dot","container":"micromag-viewer-menus-menu-dot-container","vertical":"micromag-viewer-menus-menu-dot-vertical","subDot":"micromag-viewer-menus-menu-dot-subDot","dots":"micromag-viewer-menus-menu-dot-dots","outlineBounce":"micromag-viewer-menus-menu-dot-outlineBounce"};
228
348
 
229
349
  var propTypes$h = {
230
350
  current: PropTypes.bool,
@@ -261,290 +381,67 @@ var ViewerMenuDot = function ViewerMenuDot(_ref) {
261
381
  vertical = _ref.vertical,
262
382
  onClick = _ref.onClick,
263
383
  className = _ref.className;
264
- var currentTime = 0;
265
- var duration = 1;
266
- var playing = true;
267
384
 
268
385
  var _ref2 = colors || {},
269
386
  _ref2$primary = _ref2.primary,
270
387
  primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
271
388
  _ref2$secondary = _ref2.secondary,
272
- secondary = _ref2$secondary === void 0 ? 'rgba(200, 200, 200, 0.5)' : _ref2$secondary; // TODO: if approved animate progress
273
-
389
+ secondary = _ref2$secondary === void 0 ? 'rgba(255, 255, 255, 0.25)' : _ref2$secondary;
274
390
 
275
391
  var _useSpring = useSpring(function () {
276
392
  return {
277
- x: 0,
393
+ scaleX: 0,
278
394
  config: {
279
- duration: 0
395
+ tension: 200,
396
+ friction: 30
280
397
  }
281
398
  };
282
399
  }),
283
- _useSpring2 = _slicedToArray(_useSpring, 2);
284
- _useSpring2[0];
285
- var setSpringProps = _useSpring2[1];
400
+ _useSpring2 = _slicedToArray(_useSpring, 2),
401
+ dotSpringStyles = _useSpring2[0],
402
+ setDotSpringProps = _useSpring2[1];
286
403
 
287
404
  useEffect(function () {
288
-
289
- var progress = currentTime / duration;
290
- setSpringProps.start({
291
- reset: true,
292
- immediate: !playing,
293
- from: {
294
- x: progress
295
- },
296
- to: {
297
- x: 1
298
- },
299
- config: {
300
- duration: (duration - currentTime) * 1000
301
- }
302
- });
303
- }, [playing, duration, currentTime, setSpringProps]);
304
- var inner = current && count > 1 ? /*#__PURE__*/React.createElement("span", {
305
- className: styles$b.dots
306
- }, _toConsumableArray(Array(count).keys()).map(function (i) {
307
- return /*#__PURE__*/React.createElement("span", {
308
- className: classNames([styles$b.dot, styles$b.subDot]),
309
- style: {
310
- width: "".concat(parseFloat(1 / count * 100).toFixed(2), "%"),
311
- backgroundColor: active && i <= subIndex ? primary : secondary
312
- }
405
+ var activeRatio = active ? 1 : 0;
406
+ var ratio = count > 1 && current ? (subIndex + 1) / count : activeRatio;
407
+ var scaleX = ratio;
408
+ setDotSpringProps.start({
409
+ scaleX: scaleX,
410
+ immediate: !current
313
411
  });
314
- })) : /*#__PURE__*/React.createElement("span", {
315
- className: styles$b.dot,
316
- style: {
317
- backgroundColor: active ? primary : secondary
318
- }
319
- });
412
+ }, [active, current, subIndex, count, setDotSpringProps]);
320
413
  return /*#__PURE__*/React.createElement("li", {
321
- className: classNames([styles$b.container, (_ref3 = {}, _defineProperty(_ref3, styles$b.active, current), _defineProperty(_ref3, styles$b.vertical, vertical), _defineProperty(_ref3, className, className !== null), _ref3)]),
414
+ className: classNames([styles$c.container, (_ref3 = {}, _defineProperty(_ref3, styles$c.active, current), _defineProperty(_ref3, styles$c.vertical, vertical), _defineProperty(_ref3, className, className !== null), _ref3)]),
322
415
  "aria-hidden": "true"
323
416
  }, /*#__PURE__*/React.createElement("button", {
324
417
  type: "button",
325
- className: styles$b.button,
418
+ className: styles$c.button,
326
419
  onClick: onClick,
327
420
  tabIndex: "-1"
328
- }, inner));
421
+ }, /*#__PURE__*/React.createElement("div", {
422
+ className: styles$c.dot,
423
+ style: {
424
+ backgroundColor: secondary
425
+ }
426
+ }, /*#__PURE__*/React.createElement(animated.div, {
427
+ className: styles$c.progress,
428
+ style: _objectSpread(_objectSpread({}, dotSpringStyles), {}, {
429
+ backgroundColor: primary
430
+ })
431
+ }))));
329
432
  };
330
433
 
331
434
  ViewerMenuDot.propTypes = propTypes$h;
332
435
  ViewerMenuDot.defaultProps = defaultProps$h;
333
436
 
334
- var styles$a = {};
437
+ var styles$b = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","item":"micromag-viewer-menus-menu-dots-item","items":"micromag-viewer-menus-menu-dots-items","vertical":"micromag-viewer-menus-menu-dots-vertical"};
335
438
 
439
+ var _excluded$3 = ["direction", "items", "onClickDot", "onClickScreensMenu", "colors", "closeable", "withItemClick", "withoutScreensMenu", "onClose", "className"];
336
440
  var propTypes$g = {
337
- size: PropTypes.number,
338
- spacing: PropTypes.number,
339
- color: PropTypes.string,
340
- className: PropTypes.string
341
- };
342
- var defaultProps$g = {
343
- size: 100,
344
- spacing: 8,
345
- color: 'white',
346
- className: null
347
- };
348
-
349
- var MenuIcon = function MenuIcon(_ref) {
350
- var size = _ref.size,
351
- spacing = _ref.spacing,
352
- color = _ref.color,
353
- className = _ref.className;
354
- var squareSize = (size - 2 * spacing) / 3;
355
- return /*#__PURE__*/React.createElement("svg", {
356
- className: classNames([styles$a.container, _defineProperty({}, className, className !== null)]),
357
- xmlns: "http://www.w3.org/2000/svg",
358
- viewBox: "0 0 ".concat(size, " ").concat(size),
359
- "aria-hidden": "true"
360
- }, _toConsumableArray(new Array(9)).map(function (square, squareI) {
361
- var x = squareI % 3 * (squareSize + spacing);
362
- var y = Math.floor(squareI / 3) * (squareSize + spacing);
363
- return /*#__PURE__*/React.createElement("rect", {
364
- key: "square-".concat(squareI),
365
- fill: color,
366
- x: x,
367
- y: y,
368
- width: squareSize,
369
- height: squareSize
370
- });
371
- }));
372
- };
373
-
374
- MenuIcon.propTypes = propTypes$g;
375
- MenuIcon.defaultProps = defaultProps$g;
376
-
377
- var styles$9 = {"close":"micromag-viewer-partials-share-modal-close","container":"micromag-viewer-partials-share-modal-container","opened":"micromag-viewer-partials-share-modal-opened","modal":"micromag-viewer-partials-share-modal-modal","header":"micromag-viewer-partials-share-modal-header","heading":"micromag-viewer-partials-share-modal-heading","closeIcon":"micromag-viewer-partials-share-modal-closeIcon","shareOptions":"micromag-viewer-partials-share-modal-shareOptions"};
378
-
379
- var propTypes$f = {
380
- url: PropTypes.string,
381
- title: PropTypes.string,
382
- opened: PropTypes.bool,
383
- className: PropTypes.string,
384
- onShare: PropTypes.func,
385
- onCancel: PropTypes.func
386
- };
387
- var defaultProps$f = {
388
- url: null,
389
- title: null,
390
- opened: false,
391
- className: null,
392
- onShare: null,
393
- onCancel: null
394
- };
395
-
396
- var ShareModal = function ShareModal(_ref) {
397
- var _ref3;
398
-
399
- var url = _ref.url,
400
- title = _ref.title,
401
- opened = _ref.opened,
402
- className = _ref.className,
403
- onShare = _ref.onShare,
404
- onCancel = _ref.onCancel;
405
- var modalRef = useRef();
406
- var onDocumentClick = useCallback(function (e) {
407
- var _ref2 = e || {},
408
- target = _ref2.target;
409
-
410
- if (!modalRef.current || modalRef.current.contains(target)) {
411
- return;
412
- }
413
-
414
- onCancel();
415
- }, [opened, onCancel]);
416
- useDocumentEvent('click', onDocumentClick, opened);
417
- return /*#__PURE__*/React.createElement("div", {
418
- className: classNames([styles$9.container, (_ref3 = {}, _defineProperty(_ref3, className, className), _defineProperty(_ref3, styles$9.opened, opened), _ref3)]),
419
- "aria-hidden": opened ? null : '-1'
420
- }, /*#__PURE__*/React.createElement("div", {
421
- className: styles$9.modal,
422
- ref: modalRef
423
- }, /*#__PURE__*/React.createElement("div", {
424
- className: styles$9.header
425
- }, /*#__PURE__*/React.createElement("h2", {
426
- className: styles$9.heading
427
- }, /*#__PURE__*/React.createElement(FormattedMessage, {
428
- id: "oL4ueH",
429
- defaultMessage: [{
430
- "type": 0,
431
- "value": "Share"
432
- }]
433
- })), /*#__PURE__*/React.createElement(Button, {
434
- className: styles$9.close,
435
- onClick: onCancel,
436
- focusable: opened
437
- }, /*#__PURE__*/React.createElement(Close, {
438
- className: styles$9.closeIcon,
439
- border: "none"
440
- }))), /*#__PURE__*/React.createElement("div", {
441
- className: styles$9.content
442
- }, /*#__PURE__*/React.createElement(ShareOptions, {
443
- className: styles$9.shareOptions,
444
- title: title,
445
- url: url,
446
- focusable: opened,
447
- onShare: onShare,
448
- onClose: onCancel
449
- }))));
450
- };
451
-
452
- ShareModal.propTypes = propTypes$f;
453
- ShareModal.defaultProps = defaultProps$f;
454
-
455
- var styles$8 = {"container":"micromag-viewer-partials-share-button-container"};
456
-
457
- var propTypes$e = {
458
- title: PropTypes.string,
459
- url: PropTypes.string,
460
- className: PropTypes.string,
461
- buttonClassName: PropTypes.string,
462
- onShare: PropTypes.func,
463
- children: PropTypes.node,
464
- focusable: PropTypes.bool
465
- };
466
- var defaultProps$e = {
467
- title: null,
468
- url: null,
469
- className: null,
470
- buttonClassName: null,
471
- onShare: null,
472
- children: null,
473
- focusable: false
474
- };
475
-
476
- var ShareButton = function ShareButton(_ref) {
477
- var title = _ref.title,
478
- url = _ref.url,
479
- className = _ref.className,
480
- buttonClassName = _ref.buttonClassName,
481
- onShare = _ref.onShare,
482
- children = _ref.children,
483
- focusable = _ref.focusable;
484
- var intl = useIntl();
485
-
486
- var _useState = useState(false),
487
- _useState2 = _slicedToArray(_useState, 2),
488
- storyShareModalOpened = _useState2[0],
489
- setStoryShareModalOpened = _useState2[1];
490
-
491
- var onShareIconClick = useCallback(function () {
492
- setStoryShareModalOpened(function (opened) {
493
- return !opened;
494
- });
495
- }, [setStoryShareModalOpened, storyShareModalOpened]);
496
- var onStoryShared = useCallback(function (type) {
497
- setStoryShareModalOpened(false);
498
-
499
- if (onShare !== null) {
500
- onShare(type);
501
- }
502
- }, [setStoryShareModalOpened, onShare]);
503
- var onStoryShareCanceled = useCallback(function () {
504
- setStoryShareModalOpened(false);
505
- }, [setStoryShareModalOpened]);
506
- return /*#__PURE__*/React.createElement("div", {
507
- className: classNames([styles$8.container, _defineProperty({}, className, className !== null)])
508
- }, /*#__PURE__*/React.createElement(Button, {
509
- className: classNames([_defineProperty({}, buttonClassName, buttonClassName !== null)]),
510
- onClick: onShareIconClick,
511
- title: intl.formatMessage({
512
- id: "7tw6U2",
513
- defaultMessage: [{
514
- "type": 0,
515
- "value": "Share"
516
- }]
517
- }),
518
- "aria-label": intl.formatMessage({
519
- id: "7tw6U2",
520
- defaultMessage: [{
521
- "type": 0,
522
- "value": "Share"
523
- }]
524
- }),
525
- focusable: focusable
526
- }, children), /*#__PURE__*/React.createElement(ShareModal, {
527
- className: styles$8.shareModal,
528
- opened: storyShareModalOpened,
529
- title: title,
530
- url: url,
531
- onShare: onStoryShared,
532
- onCancel: onStoryShareCanceled
533
- }));
534
- };
535
-
536
- ShareButton.propTypes = propTypes$e;
537
- ShareButton.defaultProps = defaultProps$e;
538
-
539
- var propTypes$d = {
540
441
  direction: PropTypes.oneOf(['horizontal', 'vertical']),
541
- withShadow: PropTypes.bool,
542
- title: PropTypes.string,
543
442
  items: PropTypes$1.menuItems,
544
- shareUrl: PropTypes.string,
545
- onShare: PropTypes.func,
546
- onClickItem: PropTypes.func,
547
- onClickMenu: PropTypes.func,
443
+ onClickDot: PropTypes.func,
444
+ onClickScreensMenu: PropTypes.func,
548
445
  colors: PropTypes.shape({
549
446
  primary: PropTypes.string,
550
447
  secondary: PropTypes.string
@@ -555,15 +452,11 @@ var propTypes$d = {
555
452
  onClose: PropTypes.func,
556
453
  className: PropTypes.string
557
454
  };
558
- var defaultProps$d = {
455
+ var defaultProps$g = {
559
456
  direction: 'horizontal',
560
- withShadow: false,
561
- title: null,
562
457
  items: [],
563
- shareUrl: null,
564
- onShare: null,
565
- onClickItem: null,
566
- onClickMenu: null,
458
+ onClickDot: null,
459
+ onClickScreensMenu: null,
567
460
  colors: null,
568
461
  closeable: false,
569
462
  withItemClick: false,
@@ -573,22 +466,19 @@ var defaultProps$d = {
573
466
  };
574
467
 
575
468
  var ViewerMenuDots = function ViewerMenuDots(_ref) {
576
- var _ref4;
469
+ var _ref5;
577
470
 
578
471
  var direction = _ref.direction,
579
- withShadow = _ref.withShadow,
580
- title = _ref.title,
581
472
  items = _ref.items,
582
- shareUrl = _ref.shareUrl,
583
- onShare = _ref.onShare,
584
- onClickItem = _ref.onClickItem,
585
- onClickMenu = _ref.onClickMenu,
473
+ onClickDot = _ref.onClickDot,
474
+ onClickScreensMenu = _ref.onClickScreensMenu,
586
475
  colors = _ref.colors,
587
476
  closeable = _ref.closeable,
588
477
  withItemClick = _ref.withItemClick,
589
478
  withoutScreensMenu = _ref.withoutScreensMenu,
590
479
  onClose = _ref.onClose,
591
- className = _ref.className;
480
+ className = _ref.className,
481
+ props = _objectWithoutProperties(_ref, _excluded$3);
592
482
 
593
483
  var _ref2 = colors || {},
594
484
  _ref2$primary = _ref2.primary,
@@ -600,8 +490,12 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
600
490
  current = _ref3$current === void 0 ? false : _ref3$current;
601
491
  return current;
602
492
  });
493
+
494
+ var _ref4 = props || {},
495
+ style = _ref4.style;
496
+
603
497
  return /*#__PURE__*/React.createElement("nav", {
604
- className: classNames([styles$c.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$c.vertical, direction === 'vertical'), _defineProperty(_ref4, styles$c.withShadow, withShadow), _ref4)]),
498
+ className: classNames([styles$b.container, (_ref5 = {}, _defineProperty(_ref5, className, className !== null), _defineProperty(_ref5, styles$b.vertical, direction === 'vertical'), _ref5)]),
605
499
  "aria-label": intl.formatMessage({
606
500
  id: "bLYuuN",
607
501
  defaultMessage: [{
@@ -623,17 +517,18 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
623
517
  }, {
624
518
  current: currentIndex + 1,
625
519
  total: items.length
626
- })
520
+ }),
521
+ style: style
627
522
  }, /*#__PURE__*/React.createElement("ul", {
628
- className: styles$c.items
523
+ className: styles$b.items
629
524
  }, items.map(function (item, index) {
630
- var _ref5 = item || {},
631
- _ref5$current = _ref5.current,
632
- current = _ref5$current === void 0 ? false : _ref5$current,
633
- _ref5$count = _ref5.count,
634
- count = _ref5$count === void 0 ? 1 : _ref5$count,
635
- _ref5$subIndex = _ref5.subIndex,
636
- subIndex = _ref5$subIndex === void 0 ? 0 : _ref5$subIndex;
525
+ var _ref6 = item || {},
526
+ _ref6$current = _ref6.current,
527
+ current = _ref6$current === void 0 ? false : _ref6$current,
528
+ _ref6$count = _ref6.count,
529
+ count = _ref6$count === void 0 ? 1 : _ref6$count,
530
+ _ref6$subIndex = _ref6.subIndex,
531
+ subIndex = _ref6$subIndex === void 0 ? 0 : _ref6$subIndex;
637
532
 
638
533
  return /*#__PURE__*/React.createElement(ViewerMenuDot, {
639
534
  key: "item-".concat(index + 1),
@@ -643,56 +538,22 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
643
538
  count: count,
644
539
  subIndex: subIndex,
645
540
  onClick: function onClick() {
646
- if ((withItemClick || withoutScreensMenu) && onClickItem !== null) {
647
- onClickItem(item);
648
- } else if (!withItemClick && onClickMenu !== null) {
649
- onClickMenu();
541
+ if ((withItemClick || withoutScreensMenu) && onClickDot !== null) {
542
+ onClickDot(item);
543
+ } else if (!withItemClick && onClickScreensMenu !== null) {
544
+ onClickScreensMenu();
650
545
  }
651
546
  },
652
547
  vertical: direction === 'vertical'
653
548
  });
654
- }), /*#__PURE__*/React.createElement("li", {
655
- className: styles$c.menu
656
- }, /*#__PURE__*/React.createElement(ShareButton, {
657
- className: styles$c.shareButton,
658
- buttonClassName: styles$c.menuButton,
659
- onShare: onShare,
660
- url: shareUrl,
661
- title: title
662
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
663
- className: styles$c.icon,
664
- icon: faShare
665
- }))), !withoutScreensMenu ? /*#__PURE__*/React.createElement("li", {
666
- className: styles$c.menu
667
- }, /*#__PURE__*/React.createElement(MenuIcon, {
668
- className: styles$c.menuIcon,
669
- color: primary
670
- }), /*#__PURE__*/React.createElement("button", {
671
- type: "button",
672
- title: intl.formatMessage({
673
- id: "F/gl4b",
674
- defaultMessage: [{
675
- "type": 0,
676
- "value": "Menu"
677
- }]
678
- }),
679
- "aria-label": intl.formatMessage({
680
- id: "F/gl4b",
681
- defaultMessage: [{
682
- "type": 0,
683
- "value": "Menu"
684
- }]
685
- }),
686
- className: styles$c.menuButton,
687
- onClick: onClickMenu
688
- })) : null, closeable ? /*#__PURE__*/React.createElement("li", {
689
- className: styles$c.closeButton,
549
+ }), closeable ? /*#__PURE__*/React.createElement("li", {
550
+ className: styles$b.closeButton,
690
551
  style: {
691
552
  color: primary
692
553
  }
693
554
  }, /*#__PURE__*/React.createElement("button", {
694
555
  type: "button",
695
- className: styles$c.closeButton,
556
+ className: styles$b.closeButton,
696
557
  onClick: onClose,
697
558
  title: intl.formatMessage({
698
559
  id: "dj/p/q",
@@ -713,64 +574,159 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
713
574
  }))) : null));
714
575
  };
715
576
 
716
- ViewerMenuDots.propTypes = propTypes$d;
717
- ViewerMenuDots.defaultProps = defaultProps$d;
577
+ ViewerMenuDots.propTypes = propTypes$g;
578
+ ViewerMenuDots.defaultProps = defaultProps$g;
718
579
 
719
- var propTypes$c = {
580
+ var propTypes$f = {
720
581
  className: PropTypes.string
721
582
  };
722
- var defaultProps$c = {
583
+ var defaultProps$f = {
723
584
  className: null
724
585
  };
725
586
 
726
587
  var StackIcon = function StackIcon(_ref) {
727
588
  var className = _ref.className;
728
589
  return /*#__PURE__*/React.createElement("svg", {
729
- xmlns: "http://www.w3.org/2000/svg",
730
- width: "32",
731
- height: "32",
732
- viewBox: "0 0 32 32",
590
+ xmlns: "http://www.w3.org/2000/svg" // width="32"
591
+ // height="32"
592
+ // viewBox="0 0 32 32"
593
+ ,
594
+ width: "11.5",
595
+ height: "17.5",
596
+ viewBox: "0 0 11.5 17.5",
733
597
  className: classNames([_defineProperty({}, className, className !== null)])
734
- }, /*#__PURE__*/React.createElement("path", {
735
- d: "M22.33.15H5A2.9,2.9,0,0,0,2.12,3V23.25H5V3H22.33Zm4.33,5.78H10.78A2.9,2.9,0,0,0,7.89,8.81V29a2.9,2.9,0,0,0,2.89,2.89H26.66A2.89,2.89,0,0,0,29.55,29V8.81A2.88,2.88,0,0,0,26.66,5.93Zm0,23.09Z"
598
+ }, /*#__PURE__*/React.createElement("rect", {
599
+ width: "10",
600
+ height: "16"
601
+ }), /*#__PURE__*/React.createElement("polygon", {
602
+ points: "10.5 1.5 10.5 16.5 1.5 16.5 1.5 17.5 11.5 17.5 11.5 1.5 10.5 1.5"
736
603
  }));
737
604
  };
738
605
 
739
- StackIcon.propTypes = propTypes$c;
740
- StackIcon.defaultProps = defaultProps$c;
606
+ StackIcon.propTypes = propTypes$f;
607
+ StackIcon.defaultProps = defaultProps$f;
741
608
 
742
- var styles$7 = {"container":"micromag-viewer-menus-menu-preview-container","screenButton":"micromag-viewer-menus-menu-preview-screenButton","activeScreenBorder":"micromag-viewer-menus-menu-preview-activeScreenBorder","scroll":"micromag-viewer-menus-menu-preview-scroll","header":"micromag-viewer-menus-menu-preview-header","button":"micromag-viewer-menus-menu-preview-button","shareButton":"micromag-viewer-menus-menu-preview-shareButton","disabled":"micromag-viewer-menus-menu-preview-disabled","icon":"micromag-viewer-menus-menu-preview-icon","buttons":"micromag-viewer-menus-menu-preview-buttons","organisation":"micromag-viewer-menus-menu-preview-organisation","title":"micromag-viewer-menus-menu-preview-title","content":"micromag-viewer-menus-menu-preview-content","nav":"micromag-viewer-menus-menu-preview-nav","item":"micromag-viewer-menus-menu-preview-item","items":"micromag-viewer-menus-menu-preview-items","active":"micromag-viewer-menus-menu-preview-active","itemContent":"micromag-viewer-menus-menu-preview-itemContent","screenContainer":"micromag-viewer-menus-menu-preview-screenContainer","subScreenBadge":"micromag-viewer-menus-menu-preview-subScreenBadge","subScreenCount":"micromag-viewer-menus-menu-preview-subScreenCount","subScreenIcon":"micromag-viewer-menus-menu-preview-subScreenIcon","screenContent":"micromag-viewer-menus-menu-preview-screenContent"};
609
+ var styles$a = {"button":"micromag-viewer-menus-menu-screen-button","container":"micromag-viewer-menus-menu-screen-container","isCurrent":"micromag-viewer-menus-menu-screen-isCurrent","pulse":"micromag-viewer-menus-menu-screen-pulse","inner":"micromag-viewer-menus-menu-screen-inner","subScreenBadge":"micromag-viewer-menus-menu-screen-subScreenBadge","subScreenCount":"micromag-viewer-menus-menu-screen-subScreenCount","subScreenIcon":"micromag-viewer-menus-menu-screen-subScreenIcon"};
743
610
 
744
- var propTypes$b = {
745
- viewerTheme: PropTypes$1.viewerTheme,
611
+ var propTypes$e = {
612
+ className: PropTypes.string,
613
+ item: PropTypes$1.menuItem,
614
+ index: PropTypes.number,
615
+ onClick: PropTypes.func,
746
616
  screenSize: PropTypes$1.screenSize,
747
- menuWidth: PropTypes.number,
748
- title: PropTypes.string,
749
- items: PropTypes$1.menuItems,
750
- focusable: PropTypes.bool,
751
- shouldLoad: PropTypes.bool,
752
- onClickItem: PropTypes.func,
753
- onClose: PropTypes.func,
754
- maxThumbsWidth: PropTypes.number,
755
- toggleFullscreen: PropTypes.func,
756
- fullscreenActive: PropTypes.bool,
757
- fullscreenEnabled: PropTypes.bool,
758
- className: PropTypes.string
617
+ focusable: PropTypes.bool
759
618
  };
760
- var defaultProps$b = {
761
- viewerTheme: null,
619
+ var defaultProps$e = {
620
+ className: null,
621
+ item: PropTypes$1.menuItem,
622
+ index: 0,
623
+ onClick: null,
762
624
  screenSize: null,
763
- menuWidth: null,
764
- title: null,
765
- items: [],
766
- focusable: true,
767
- shouldLoad: true,
768
- onClickItem: null,
769
- onClose: null,
625
+ focusable: true
626
+ };
627
+
628
+ var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
629
+ var _ref4;
630
+
631
+ var className = _ref.className,
632
+ item = _ref.item,
633
+ index = _ref.index,
634
+ _onClick = _ref.onClick,
635
+ screenSize = _ref.screenSize,
636
+ focusable = _ref.focusable;
637
+ var intl = useIntl();
638
+
639
+ var _ref2 = item || {},
640
+ _ref2$current = _ref2.current,
641
+ current = _ref2$current === void 0 ? false : _ref2$current,
642
+ screen = _ref2.screen,
643
+ _ref2$count = _ref2.count,
644
+ count = _ref2$count === void 0 ? 1 : _ref2$count;
645
+
646
+ var _ref3 = screenSize || {},
647
+ screenWidth = _ref3.width,
648
+ screenHeight = _ref3.height;
649
+
650
+ var screenAriaLabel = "".concat(intl.formatMessage({
651
+ id: "LkVfwW",
652
+ defaultMessage: [{
653
+ "type": 0,
654
+ "value": "Screen "
655
+ }, {
656
+ "type": 1,
657
+ "value": "index"
658
+ }]
659
+ }, {
660
+ index: index + 1
661
+ })).concat(current ? " ".concat(intl.formatMessage({
662
+ id: "vmrJ8U",
663
+ defaultMessage: [{
664
+ "type": 0,
665
+ "value": "(current screen)"
666
+ }]
667
+ })) : '');
668
+ return /*#__PURE__*/React.createElement("div", {
669
+ className: classNames([styles$a.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$a.isCurrent, current), _ref4)])
670
+ }, /*#__PURE__*/React.createElement("button", {
671
+ type: "button",
672
+ className: styles$a.button,
673
+ onClick: function onClick() {
674
+ if (_onClick !== null) {
675
+ _onClick(item);
676
+ }
677
+ },
678
+ "aria-label": screenAriaLabel,
679
+ tabIndex: focusable ? '0' : '-1'
680
+ }), /*#__PURE__*/React.createElement("div", {
681
+ className: styles$a.inner
682
+ }, count > 1 ? /*#__PURE__*/React.createElement("div", {
683
+ className: styles$a.subScreenBadge
684
+ }, /*#__PURE__*/React.createElement("span", {
685
+ className: styles$a.subScreenCount
686
+ }, count), /*#__PURE__*/React.createElement(StackIcon, {
687
+ className: styles$a.subScreenIcon
688
+ })) : null, screenWidth > 0 && screenHeight > 0 ? /*#__PURE__*/React.createElement(ScreenPreview, {
689
+ className: styles$a.screen,
690
+ screenWidth: screenWidth,
691
+ screenHeight: screenHeight,
692
+ screen: screen,
693
+ focusable: focusable,
694
+ active: focusable,
695
+ withSize: true
696
+ }) : null));
697
+ };
698
+
699
+ ViewerMenuScreen.propTypes = propTypes$e;
700
+ ViewerMenuScreen.defaultProps = defaultProps$e;
701
+
702
+ var styles$9 = {"scroll":"micromag-viewer-menus-menu-preview-scroll","container":"micromag-viewer-menus-menu-preview-container","disabled":"micromag-viewer-menus-menu-preview-disabled","screenButton":"micromag-viewer-menus-menu-preview-screenButton","buttons":"micromag-viewer-menus-menu-preview-buttons","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","title":"micromag-viewer-menus-menu-preview-title","content":"micromag-viewer-menus-menu-preview-content","nav":"micromag-viewer-menus-menu-preview-nav","item":"micromag-viewer-menus-menu-preview-item","items":"micromag-viewer-menus-menu-preview-items"};
703
+
704
+ var propTypes$d = {
705
+ viewerTheme: PropTypes$1.viewerTheme,
706
+ screenSize: PropTypes$1.screenSize,
707
+ menuWidth: PropTypes.number,
708
+ items: PropTypes$1.menuItems,
709
+ focusable: PropTypes.bool,
710
+ onClickScreen: PropTypes.func,
711
+ maxThumbsWidth: PropTypes.number,
712
+ // shouldLoad: PropTypes.bool, // @todo still needed? to re-implement?
713
+ // toggleFullscreen: PropTypes.func,
714
+ // fullscreenActive: PropTypes.bool,
715
+ // fullscreenEnabled: PropTypes.bool,
716
+ className: PropTypes.string
717
+ };
718
+ var defaultProps$d = {
719
+ viewerTheme: null,
720
+ screenSize: null,
721
+ menuWidth: null,
722
+ items: [],
723
+ focusable: true,
724
+ // shouldLoad: true,
725
+ onClickScreen: null,
770
726
  maxThumbsWidth: 140,
771
- toggleFullscreen: null,
772
- fullscreenActive: false,
773
- fullscreenEnabled: false,
727
+ // toggleFullscreen: null,
728
+ // fullscreenActive: false,
729
+ // fullscreenEnabled: false,
774
730
  className: null
775
731
  };
776
732
 
@@ -778,259 +734,313 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
778
734
  var viewerTheme = _ref.viewerTheme,
779
735
  screenSize = _ref.screenSize,
780
736
  menuWidth = _ref.menuWidth,
781
- title = _ref.title,
782
737
  items = _ref.items,
783
738
  focusable = _ref.focusable,
784
- onClickItem = _ref.onClickItem,
785
- onClose = _ref.onClose,
739
+ onClickScreen = _ref.onClickScreen,
786
740
  maxThumbsWidth = _ref.maxThumbsWidth,
787
- toggleFullscreen = _ref.toggleFullscreen,
788
- fullscreenActive = _ref.fullscreenActive,
789
- fullscreenEnabled = _ref.fullscreenEnabled,
790
741
  className = _ref.className;
791
- var intl = useIntl();
792
-
793
- var _ref2 = screenSize || {},
794
- screenWidth = _ref2.width,
795
- screenHeight = _ref2.height;
796
742
 
797
743
  var _useDimensionObserver = useDimensionObserver(),
798
- firstScreenContainerRef = _useDimensionObserver.ref,
744
+ containerRef = _useDimensionObserver.ref,
799
745
  _useDimensionObserver2 = _useDimensionObserver.width,
800
- thumbWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
801
-
802
- var _useDimensionObserver3 = useDimensionObserver(),
803
- containerRef = _useDimensionObserver3.ref,
804
- _useDimensionObserver4 = _useDimensionObserver3.width,
805
- contentWidth = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
746
+ contentWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
806
747
 
807
748
  var thumbsPerLine = Math.max(Math.floor(contentWidth / maxThumbsWidth), 3); // Viewer theme
749
+ // @todo room for improvement here probably
750
+ // @todo also re-implement!!
808
751
 
809
- var _ref3 = viewerTheme || {},
810
- _ref3$colors = _ref3.colors,
811
- colors = _ref3$colors === void 0 ? null : _ref3$colors,
812
- _ref3$background = _ref3.background,
813
- background = _ref3$background === void 0 ? null : _ref3$background,
814
- _ref3$textStyles = _ref3.textStyles,
815
- textStyles = _ref3$textStyles === void 0 ? null : _ref3$textStyles,
816
- _ref3$logo = _ref3.logo,
817
- brandLogo = _ref3$logo === void 0 ? null : _ref3$logo;
818
-
819
- var _ref4 = textStyles || {},
820
- _ref4$title = _ref4.title,
821
- brandTextStyle = _ref4$title === void 0 ? null : _ref4$title;
752
+ var _ref2 = viewerTheme || {},
753
+ _ref2$colors = _ref2.colors,
754
+ colors = _ref2$colors === void 0 ? null : _ref2$colors,
755
+ _ref2$background = _ref2.background,
756
+ background = _ref2$background === void 0 ? null : _ref2$background;
757
+ _ref2.logo;
822
758
 
823
- var _ref5 = colors || {},
824
- _ref5$primary = _ref5.primary,
825
- brandPrimaryColor = _ref5$primary === void 0 ? null : _ref5$primary,
826
- _ref5$secondary = _ref5.secondary,
827
- brandSecondaryColor = _ref5$secondary === void 0 ? null : _ref5$secondary;
759
+ var _ref3 = colors || {};
760
+ _ref3.primary;
761
+ _ref3.secondary;
828
762
 
829
- var _ref6 = background || {},
830
- _ref6$color = _ref6.color,
831
- brandBackgroundColor = _ref6$color === void 0 ? null : _ref6$color,
832
- _ref6$image = _ref6.image,
833
- image = _ref6$image === void 0 ? null : _ref6$image;
763
+ var _ref4 = background || {},
764
+ _ref4$color = _ref4.color,
765
+ brandBackgroundColor = _ref4$color === void 0 ? null : _ref4$color,
766
+ _ref4$image = _ref4.image,
767
+ image = _ref4$image === void 0 ? null : _ref4$image;
834
768
 
835
- var _ref7 = image || {},
836
- _ref7$url = _ref7.url,
837
- brandImageUrl = _ref7$url === void 0 ? null : _ref7$url;
769
+ var _ref5 = image || {},
770
+ _ref5$url = _ref5.url,
771
+ brandImageUrl = _ref5$url === void 0 ? null : _ref5$url; // const borderPrimaryColorStyle = getStyleFromColor(brandPrimaryColor, 'borderColor');
772
+ // const colorSecondaryColorStyle = getStyleFromColor(brandSecondaryColor, 'color');
838
773
 
839
- var borderPrimaryColorStyle = getStyleFromColor(brandPrimaryColor, 'borderColor');
840
- var colorSecondaryColorStyle = getStyleFromColor(brandSecondaryColor, 'color');
841
- var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
842
774
 
843
- var _ref8 = brandLogo || {},
844
- _ref8$url = _ref8.url,
845
- brandLogoUrl = _ref8$url === void 0 ? null : _ref8$url;
775
+ var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor'); // const { url: brandLogoUrl = null } = brandLogo || {};
846
776
 
847
777
  var brandImageStyle = brandImageUrl !== null ? {
848
778
  backgroundImage: "url(".concat(brandImageUrl, ")")
849
- } : null;
850
- var titleStyle = brandTextStyle !== null ? getStyleFromText(brandTextStyle) : null;
851
-
852
- var _useState = useState(false),
853
- _useState2 = _slicedToArray(_useState, 2),
854
- scrolledBottom = _useState2[0],
855
- setScrolledBottom = _useState2[1];
779
+ } : null; // @todo could probably use some work to avoid the visual jump from 3 screens to all of them
856
780
 
857
- var dragBind = useDrag(function (_ref9) {
858
- var _ref9$direction = _slicedToArray(_ref9.direction, 2),
859
- dy = _ref9$direction[1],
860
- last = _ref9.last,
861
- tap = _ref9.tap;
862
-
863
- if (!tap && last && scrolledBottom && dy < 0 && onClose !== null) {
864
- onClose();
865
- }
866
- }, {
867
- filterTaps: true,
868
- eventOptions: {
869
- capture: true
870
- }
871
- });
872
- var onScrolledBottom = useCallback(function () {
873
- setScrolledBottom(true);
874
- }, [setScrolledBottom]);
875
- var onScrolledNotBottom = useCallback(function () {
876
- setScrolledBottom(false);
877
- }, [setScrolledBottom]);
878
781
  var finalItems = useMemo(function () {
879
- return !focusable ? items.slice(0, 3) : items;
880
- }, [items, focusable]);
881
- return /*#__PURE__*/React.createElement("div", Object.assign({
882
- className: classNames([styles$7.container, _defineProperty({}, className, className !== null)]),
782
+ return !focusable ? items.map(function (s, i) {
783
+ return i > 3 ? {
784
+ screenId: s.screenId
785
+ } : s;
786
+ }) : items;
787
+ }, [items, focusable]); // @todo bookmarks
788
+ // const bookmarks = finalItems.reduce((acc, it) => {
789
+ // const { screen = null } = it || {};
790
+ // const { bookmark = null } = screen || {};
791
+ // return bookmark !== null ? [...acc, bookmark] : acc; // merge with array or return original array
792
+ // }, []);
793
+
794
+ return /*#__PURE__*/React.createElement("div", {
795
+ className: classNames([styles$9.container, _defineProperty({}, className, className !== null)]),
883
796
  style: _objectSpread(_objectSpread(_objectSpread({}, backgroundColorStyle), brandImageStyle), {}, {
884
797
  width: menuWidth
885
798
  }),
886
799
  "aria-hidden": focusable ? null : 'true'
887
- }, dragBind()), /*#__PURE__*/React.createElement("div", {
888
- className: styles$7.header
889
- }, brandLogoUrl !== null ? /*#__PURE__*/React.createElement("div", {
890
- className: styles$7.organisation,
891
- style: {
892
- backgroundImage: "url(".concat(brandLogoUrl, ")")
893
- }
894
- }) : null, /*#__PURE__*/React.createElement("div", {
895
- className: styles$7.title,
896
- style: titleStyle
897
- }, title), /*#__PURE__*/React.createElement("div", {
898
- className: styles$7.buttons,
899
- style: colorSecondaryColorStyle
900
- }, fullscreenEnabled ? /*#__PURE__*/React.createElement(Button, {
901
- className: styles$7.button,
902
- onClick: toggleFullscreen,
903
- title: intl.formatMessage({
904
- id: "AuxqcG",
905
- defaultMessage: [{
906
- "type": 0,
907
- "value": "Fullscreen"
908
- }]
909
- }),
910
- "aria-label": intl.formatMessage({
911
- id: "AuxqcG",
912
- defaultMessage: [{
913
- "type": 0,
914
- "value": "Fullscreen"
915
- }]
916
- }),
917
- focusable: focusable
918
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
919
- className: styles$7.icon,
920
- icon: fullscreenActive ? faCompress : faExpand
921
- })) : null, /*#__PURE__*/React.createElement(Button, {
922
- className: styles$7.button,
923
- onClick: onClose,
924
- title: intl.formatMessage({
925
- id: "dj/p/q",
926
- defaultMessage: [{
927
- "type": 0,
928
- "value": "Close"
929
- }]
930
- }),
931
- "aria-label": intl.formatMessage({
932
- id: "dj/p/q",
933
- defaultMessage: [{
934
- "type": 0,
935
- "value": "Close"
936
- }]
937
- }),
938
- focusable: focusable
939
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
940
- className: styles$7.icon,
941
- icon: faTimes
942
- })))), /*#__PURE__*/React.createElement("div", {
943
- className: styles$7.content,
800
+ }, /*#__PURE__*/React.createElement("div", {
801
+ className: styles$9.content,
944
802
  ref: containerRef
945
803
  }, /*#__PURE__*/React.createElement(Scroll, {
946
- className: styles$7.scroll,
947
- onScrolledBottom: onScrolledBottom,
948
- onScrolledNotBottom: onScrolledNotBottom
804
+ className: styles$9.scroll
949
805
  }, /*#__PURE__*/React.createElement("nav", {
950
- className: styles$7.nav
806
+ className: styles$9.nav
951
807
  }, /*#__PURE__*/React.createElement("ul", {
952
- className: styles$7.items
808
+ className: styles$9.items
953
809
  }, finalItems.map(function (item, index) {
954
- var screenId = item.screenId,
955
- _item$current = item.current,
956
- current = _item$current === void 0 ? false : _item$current,
957
- screen = item.screen,
958
- _item$count = item.count,
959
- count = _item$count === void 0 ? 1 : _item$count;
960
- var screenAriaLabel = "".concat(intl.formatMessage({
961
- id: "LkVfwW",
962
- defaultMessage: [{
963
- "type": 0,
964
- "value": "Screen "
965
- }, {
966
- "type": 1,
967
- "value": "index"
968
- }]
969
- }, {
970
- index: index + 1
971
- })).concat(current ? " ".concat(intl.formatMessage({
972
- id: "vmrJ8U",
973
- defaultMessage: [{
974
- "type": 0,
975
- "value": "(current screen)"
976
- }]
977
- })) : '');
810
+ var _ref7 = item || {},
811
+ screenId = _ref7.screenId;
812
+
813
+ var itemStyles = {
814
+ width: "".concat(100 / thumbsPerLine, "%")
815
+ };
978
816
  return /*#__PURE__*/React.createElement("li", {
979
- className: classNames([styles$7.item, _defineProperty({}, styles$7.active, current)]),
980
817
  key: "item-".concat(screenId),
981
- style: {
982
- width: "".concat(100 / thumbsPerLine, "%")
983
- }
984
- }, /*#__PURE__*/React.createElement("div", {
985
- className: styles$7.itemContent
986
- }, /*#__PURE__*/React.createElement("div", {
987
- className: styles$7.screenContainer,
988
- ref: index === 0 ? firstScreenContainerRef : null
989
- }, count > 1 ? /*#__PURE__*/React.createElement("div", {
990
- className: styles$7.subScreenBadge
991
- }, /*#__PURE__*/React.createElement("span", {
992
- className: styles$7.subScreenCount
993
- }, count), /*#__PURE__*/React.createElement(StackIcon, {
994
- className: styles$7.subScreenIcon
995
- })) : null, screenWidth > 0 && screenHeight > 0 ? /*#__PURE__*/React.createElement(ScreenPreview, {
996
- screenWidth: screenWidth,
997
- screenHeight: screenHeight,
998
- width: thumbWidth,
999
- screen: screen,
1000
- focusable: focusable,
1001
- active: focusable,
1002
- withSize: true
1003
- }) : null, current ? /*#__PURE__*/React.createElement("div", {
1004
- className: styles$7.activeScreenBorder,
1005
- style: borderPrimaryColorStyle
1006
- }) : null)), /*#__PURE__*/React.createElement("button", {
1007
- type: "button",
1008
- className: styles$7.screenButton,
1009
- onClick: function onClick() {
1010
- if (onClickItem !== null) {
1011
- onClickItem(item);
1012
- }
1013
- },
1014
- "aria-label": screenAriaLabel,
1015
- onKeyUp: function onKeyUp(e) {
1016
- if (e.key === 'Enter' && onClickItem !== null) {
1017
- onClickItem(item);
1018
- }
1019
- },
1020
- tabIndex: focusable ? '0' : '-1'
818
+ className: styles$9.item,
819
+ style: itemStyles
820
+ }, item === null ? 'loading' : /*#__PURE__*/React.createElement(ViewerMenuScreen, {
821
+ className: styles$9.screenPreview,
822
+ item: item,
823
+ index: index,
824
+ screenSize: screenSize,
825
+ onClick: onClickScreen,
826
+ focusable: focusable
1021
827
  }));
1022
828
  }))))));
1023
829
  };
1024
830
 
1025
- ViewerMenuPreview.propTypes = propTypes$b;
1026
- ViewerMenuPreview.defaultProps = defaultProps$b;
831
+ ViewerMenuPreview.propTypes = propTypes$d;
832
+ ViewerMenuPreview.defaultProps = defaultProps$d;
833
+
834
+ var styles$8 = {"container":"micromag-viewer-partials-micromag-preview-container","cover":"micromag-viewer-partials-micromag-preview-cover","info":"micromag-viewer-partials-micromag-preview-info","url":"micromag-viewer-partials-micromag-preview-url","title":"micromag-viewer-partials-micromag-preview-title"};
835
+
836
+ var propTypes$c = {
837
+ screen: PropTypes$1.item,
838
+ title: PropTypes.string,
839
+ url: PropTypes.string,
840
+ description: PropTypes.string,
841
+ className: PropTypes.string
842
+ };
843
+ var defaultProps$c = {
844
+ screen: null,
845
+ title: null,
846
+ url: null,
847
+ description: null,
848
+ className: null
849
+ };
850
+
851
+ var MicromagPreview = function MicromagPreview(_ref) {
852
+ var screen = _ref.screen,
853
+ title = _ref.title,
854
+ url = _ref.url,
855
+ description = _ref.description,
856
+ className = _ref.className;
857
+ return /*#__PURE__*/React.createElement("div", {
858
+ className: classNames([styles$8.container, _defineProperty({}, className, className)])
859
+ }, /*#__PURE__*/React.createElement("div", {
860
+ className: styles$8.cover
861
+ }, /*#__PURE__*/React.createElement(ScreenPreview, {
862
+ screen: screen,
863
+ width: 100,
864
+ height: 150,
865
+ withSize: true
866
+ })), /*#__PURE__*/React.createElement("div", {
867
+ className: styles$8.info
868
+ }, /*#__PURE__*/React.createElement("h3", {
869
+ className: styles$8.title
870
+ }, title), url ? /*#__PURE__*/React.createElement("div", {
871
+ className: styles$8.url
872
+ }, url) : null, /*#__PURE__*/React.createElement("p", null, description)));
873
+ };
1027
874
 
1028
- var styles$6 = {"container":"micromag-viewer-container","menuPreview":"micromag-viewer-menuPreview","menuPreviewContainer":"micromag-viewer-menuPreviewContainer","screenContainer":"micromag-viewer-screenContainer","screen":"micromag-viewer-screen","content":"micromag-viewer-content","menuDotsContainer":"micromag-viewer-menuDotsContainer","menuDots":"micromag-viewer-menuDots","navButton":"micromag-viewer-navButton","previous":"micromag-viewer-previous","next":"micromag-viewer-next","current":"micromag-viewer-current","landscape":"micromag-viewer-landscape","visible":"micromag-viewer-visible","withSiblings":"micromag-viewer-withSiblings","playbackControlsContainer":"micromag-viewer-playbackControlsContainer","playbackControls":"micromag-viewer-playbackControls","webView":"micromag-viewer-webView","hideMenu":"micromag-viewer-hideMenu","ready":"micromag-viewer-ready"};
875
+ MicromagPreview.propTypes = propTypes$c;
876
+ MicromagPreview.defaultProps = defaultProps$c;
877
+
878
+ var styles$7 = {"scroll":"micromag-viewer-menus-menu-share-scroll","container":"micromag-viewer-menus-menu-share-container","disabled":"micromag-viewer-menus-menu-share-disabled","screenButton":"micromag-viewer-menus-menu-share-screenButton","organisation":"micromag-viewer-menus-menu-share-organisation","icon":"micromag-viewer-menus-menu-share-icon","header":"micromag-viewer-menus-menu-share-header","mode":"micromag-viewer-menus-menu-share-mode","bump":"micromag-viewer-menus-menu-share-bump","options":"micromag-viewer-menus-menu-share-options","optionButton":"micromag-viewer-menus-menu-share-optionButton","content":"micromag-viewer-menus-menu-share-content"};
879
+
880
+ var propTypes$b = {
881
+ viewerTheme: PropTypes$1.viewerTheme,
882
+ menuWidth: PropTypes.number,
883
+ title: PropTypes.string,
884
+ description: PropTypes.string,
885
+ items: PropTypes$1.menuItems,
886
+ focusable: PropTypes.bool,
887
+ // shouldLoad: PropTypes.bool, // @todo still needed? to re-implement?
888
+ currentScreenIndex: PropTypes.number,
889
+ shareUrl: PropTypes.string,
890
+ onShare: PropTypes.func,
891
+ className: PropTypes.string
892
+ };
893
+ var defaultProps$b = {
894
+ viewerTheme: null,
895
+ menuWidth: null,
896
+ title: null,
897
+ description: null,
898
+ items: [],
899
+ focusable: true,
900
+ currentScreenIndex: 0,
901
+ shareUrl: null,
902
+ onShare: null,
903
+ className: null
904
+ };
905
+
906
+ var ViewerMenuShare = function ViewerMenuShare(_ref) {
907
+ var viewerTheme = _ref.viewerTheme,
908
+ menuWidth = _ref.menuWidth,
909
+ title = _ref.title,
910
+ description = _ref.description,
911
+ items = _ref.items,
912
+ focusable = _ref.focusable,
913
+ currentScreenIndex = _ref.currentScreenIndex,
914
+ shareUrl = _ref.shareUrl,
915
+ onShare = _ref.onShare,
916
+ className = _ref.className;
917
+
918
+ // Viewer theme
919
+ // @todo room for improvement here probably
920
+ var _ref2 = viewerTheme || {},
921
+ _ref2$colors = _ref2.colors,
922
+ colors = _ref2$colors === void 0 ? null : _ref2$colors,
923
+ _ref2$background = _ref2.background,
924
+ background = _ref2$background === void 0 ? null : _ref2$background;
925
+ _ref2.logo;
926
+ // @todo could get from theme provider? need to re-implement
927
+
928
+
929
+ var _ref3 = colors || {};
930
+ _ref3.primary;
931
+ _ref3.secondary;
932
+
933
+ var _ref4 = background || {},
934
+ _ref4$color = _ref4.color,
935
+ brandBackgroundColor = _ref4$color === void 0 ? null : _ref4$color,
936
+ _ref4$image = _ref4.image,
937
+ image = _ref4$image === void 0 ? null : _ref4$image;
938
+
939
+ var _ref5 = image || {},
940
+ _ref5$url = _ref5.url,
941
+ brandImageUrl = _ref5$url === void 0 ? null : _ref5$url; // const borderPrimaryColorStyle = getStyleFromColor(brandPrimaryColor, 'borderColor');
942
+ // const colorSecondaryColorStyle = getStyleFromColor(brandSecondaryColor, 'color');
943
+
944
+
945
+ var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor'); // const { url: brandLogoUrl = null } = brandLogo || {};
946
+
947
+ var brandImageStyle = brandImageUrl !== null ? {
948
+ backgroundImage: "url(".concat(brandImageUrl, ")")
949
+ } : null;
950
+ var coverScreen = useMemo(function () {
951
+ var _ref6 = items[0] || {},
952
+ _ref6$screen = _ref6.screen,
953
+ screen = _ref6$screen === void 0 ? null : _ref6$screen;
954
+
955
+ return screen;
956
+ }, [items]);
957
+ var currentScreen = useMemo(function () {
958
+ var found = items.find(function (item) {
959
+ var _ref7 = item || {},
960
+ _ref7$current = _ref7.current,
961
+ current = _ref7$current === void 0 ? false : _ref7$current;
962
+
963
+ return current;
964
+ });
965
+
966
+ var _ref8 = found || {},
967
+ _ref8$screen = _ref8.screen,
968
+ screen = _ref8$screen === void 0 ? null : _ref8$screen;
969
+
970
+ return screen;
971
+ }, [items, currentScreenIndex, focusable]);
972
+
973
+ var _useState = useState(false),
974
+ _useState2 = _slicedToArray(_useState, 2),
975
+ shareCurrentScreen = _useState2[0],
976
+ setShareCurrentScreen = _useState2[1];
977
+
978
+ var onShareModeChange = useCallback(function () {
979
+ setShareCurrentScreen(function (value) {
980
+ return !value;
981
+ });
982
+ }, [setShareCurrentScreen]);
983
+
984
+ var _useState3 = useState(shareUrl),
985
+ _useState4 = _slicedToArray(_useState3, 2),
986
+ finalShareUrl = _useState4[0],
987
+ setFinalShareUrl = _useState4[1];
988
+
989
+ useEffect(function () {
990
+ setFinalShareUrl(shareCurrentScreen && currentScreenIndex !== 0 ? "".concat(shareUrl, "/").concat(currentScreenIndex) : shareUrl);
991
+ }, [shareCurrentScreen, currentScreenIndex, setFinalShareUrl]);
992
+ return /*#__PURE__*/React.createElement("div", {
993
+ className: classNames([styles$7.container, _defineProperty({}, className, className !== null)]),
994
+ style: _objectSpread(_objectSpread(_objectSpread({}, backgroundColorStyle), brandImageStyle), {}, {
995
+ width: menuWidth
996
+ }),
997
+ "aria-hidden": focusable ? null : 'true'
998
+ }, /*#__PURE__*/React.createElement("div", {
999
+ className: styles$7.content
1000
+ }, /*#__PURE__*/React.createElement(Scroll, {
1001
+ className: styles$7.scroll
1002
+ }, /*#__PURE__*/React.createElement("div", {
1003
+ className: styles$7.header
1004
+ }, /*#__PURE__*/React.createElement(MicromagPreview, {
1005
+ className: styles$7.preview,
1006
+ screen: shareCurrentScreen ? currentScreen : coverScreen,
1007
+ title: title,
1008
+ url: finalShareUrl,
1009
+ description: description
1010
+ }), currentScreenIndex !== 0 ? /*#__PURE__*/React.createElement("div", {
1011
+ className: styles$7.mode
1012
+ }, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
1013
+ type: "checkbox",
1014
+ name: "currentScreen",
1015
+ value: "currentScreen",
1016
+ onChange: onShareModeChange,
1017
+ checked: shareCurrentScreen
1018
+ }), /*#__PURE__*/React.createElement(FormattedMessage, {
1019
+ id: "xuPbeq",
1020
+ defaultMessage: [{
1021
+ "type": 0,
1022
+ "value": "Start from the current screen"
1023
+ }]
1024
+ }))) : null), /*#__PURE__*/React.createElement(ShareOptions, {
1025
+ className: styles$7.options,
1026
+ itemClassName: styles$7.optionItem,
1027
+ buttonClassName: styles$7.optionButton,
1028
+ title: title,
1029
+ url: finalShareUrl,
1030
+ focusable: focusable,
1031
+ onShare: onShare,
1032
+ shareCurrentScreen: shareCurrentScreen
1033
+ }))));
1034
+ };
1035
+
1036
+ ViewerMenuShare.propTypes = propTypes$b;
1037
+ ViewerMenuShare.defaultProps = defaultProps$b;
1038
+
1039
+ var styles$6 = {"container":"micromag-viewer-container","screenContainer":"micromag-viewer-screenContainer","screensFrame":"micromag-viewer-screensFrame","landscape":"micromag-viewer-landscape","hideMenu":"micromag-viewer-hideMenu","menuNavContainer":"micromag-viewer-menuNavContainer","dots":"micromag-viewer-dots","menuTopContainer":"micromag-viewer-menuTopContainer","content":"micromag-viewer-content","fadeMenu":"micromag-viewer-fadeMenu","withShadow":"micromag-viewer-withShadow","isOpened":"micromag-viewer-isOpened","menuItem":"micromag-viewer-menuItem","menuScreens":"micromag-viewer-menuScreens","slidingButton":"micromag-viewer-slidingButton","menuButton":"micromag-viewer-menuButton","isHidden":"micromag-viewer-isHidden","navButton":"micromag-viewer-navButton","previous":"micromag-viewer-previous","next":"micromag-viewer-next","isDragging":"micromag-viewer-isDragging","withoutGestures":"micromag-viewer-withoutGestures","screen":"micromag-viewer-screen","current":"micromag-viewer-current","playbackControls":"micromag-viewer-playbackControls","webView":"micromag-viewer-webView"};
1029
1040
 
1030
1041
  var propTypes$a = {
1031
1042
  story: PropTypes$1.story.isRequired,
1032
1043
  currentScreenIndex: PropTypes.number,
1033
- opened: PropTypes.bool,
1034
1044
  toggleFullscreen: PropTypes.func,
1035
1045
  fullscreenActive: PropTypes.bool,
1036
1046
  fullscreenEnabled: PropTypes.bool,
@@ -1043,9 +1053,8 @@ var propTypes$a = {
1043
1053
  menuWidth: PropTypes.number,
1044
1054
  withDotItemClick: PropTypes.bool,
1045
1055
  withoutScreensMenu: PropTypes.bool,
1046
- onRequestOpen: PropTypes.func,
1047
- onRequestClose: PropTypes.func,
1048
- onClickItem: PropTypes.func,
1056
+ withoutShareMenu: PropTypes.bool,
1057
+ onClickScreen: PropTypes.func,
1049
1058
  onClickMenu: PropTypes.func,
1050
1059
  onClickCloseViewer: PropTypes.func,
1051
1060
  refDots: PropTypes.shape({
@@ -1055,7 +1064,6 @@ var propTypes$a = {
1055
1064
  };
1056
1065
  var defaultProps$a = {
1057
1066
  currentScreenIndex: 0,
1058
- opened: false,
1059
1067
  toggleFullscreen: null,
1060
1068
  fullscreenActive: false,
1061
1069
  fullscreenEnabled: false,
@@ -1068,18 +1076,18 @@ var defaultProps$a = {
1068
1076
  menuWidth: null,
1069
1077
  withDotItemClick: false,
1070
1078
  withoutScreensMenu: false,
1071
- onRequestOpen: null,
1072
- onRequestClose: null,
1073
- onClickItem: null,
1079
+ withoutShareMenu: false,
1080
+ onClickScreen: null,
1074
1081
  onClickMenu: null,
1075
1082
  onClickCloseViewer: null,
1076
1083
  refDots: null
1077
1084
  };
1078
1085
 
1079
1086
  var ViewerMenu = function ViewerMenu(_ref) {
1087
+ var _ref9;
1088
+
1080
1089
  var story = _ref.story,
1081
1090
  currentScreenIndex = _ref.currentScreenIndex,
1082
- opened = _ref.opened,
1083
1091
  toggleFullscreen = _ref.toggleFullscreen,
1084
1092
  fullscreenActive = _ref.fullscreenActive,
1085
1093
  fullscreenEnabled = _ref.fullscreenEnabled,
@@ -1092,23 +1100,43 @@ var ViewerMenu = function ViewerMenu(_ref) {
1092
1100
  menuWidth = _ref.menuWidth,
1093
1101
  withDotItemClick = _ref.withDotItemClick,
1094
1102
  withoutScreensMenu = _ref.withoutScreensMenu,
1095
- onRequestOpen = _ref.onRequestOpen,
1096
- onRequestClose = _ref.onRequestClose,
1097
- customOnClickItem = _ref.onClickItem,
1098
- customOnClickMenu = _ref.onClickMenu,
1099
- onClickCloseViewer = _ref.onClickCloseViewer,
1103
+ withoutShareMenu = _ref.withoutShareMenu,
1104
+ customOnClickScreen = _ref.onClickScreen;
1105
+ _ref.onClickMenu;
1106
+ var onClickCloseViewer = _ref.onClickCloseViewer,
1100
1107
  refDots = _ref.refDots;
1101
1108
  var _story$components = story.components,
1102
1109
  screens = _story$components === void 0 ? [] : _story$components,
1103
1110
  _story$title = story.title,
1104
- title = _story$title === void 0 ? null : _story$title;
1111
+ title = _story$title === void 0 ? null : _story$title,
1112
+ _story$metadata = story.metadata,
1113
+ metadata = _story$metadata === void 0 ? null : _story$metadata;
1114
+
1115
+ var _ref2 = metadata || {},
1116
+ _ref2$description = _ref2.description,
1117
+ description = _ref2$description === void 0 ? null : _ref2$description;
1118
+
1105
1119
  var currentScreen = screens !== null ? screens[currentScreenIndex] || null : null;
1106
1120
 
1107
- var _ref2 = currentScreen || {},
1108
- _ref2$id = _ref2.id,
1109
- screenId = _ref2$id === void 0 ? null : _ref2$id,
1110
- _ref2$type = _ref2.type,
1111
- screenType = _ref2$type === void 0 ? null : _ref2$type;
1121
+ var _ref3 = currentScreen || {},
1122
+ _ref3$id = _ref3.id,
1123
+ screenId = _ref3$id === void 0 ? null : _ref3$id,
1124
+ _ref3$type = _ref3.type,
1125
+ screenType = _ref3$type === void 0 ? null : _ref3$type;
1126
+
1127
+ var _ref4 = viewerTheme || {},
1128
+ _ref4$menuTheme = _ref4.menuTheme,
1129
+ menuTheme = _ref4$menuTheme === void 0 ? null : _ref4$menuTheme;
1130
+
1131
+ var _useState = useState(false),
1132
+ _useState2 = _slicedToArray(_useState, 2),
1133
+ menuOpened = _useState2[0],
1134
+ setMenuOpened = _useState2[1];
1135
+
1136
+ var _useState3 = useState(false),
1137
+ _useState4 = _slicedToArray(_useState3, 2),
1138
+ shareOpened = _useState4[0],
1139
+ setShareOpened = _useState4[1];
1112
1140
 
1113
1141
  var items = useMemo(function () {
1114
1142
  return screens.map(function (it) {
@@ -1129,9 +1157,9 @@ var ViewerMenu = function ViewerMenu(_ref) {
1129
1157
  count: children.length + 1 || 1,
1130
1158
  subIndex: subIndex || 0
1131
1159
  };
1132
- }).filter(function (_ref3) {
1133
- var _ref3$visible = _ref3.visible,
1134
- visible = _ref3$visible === void 0 ? true : _ref3$visible;
1160
+ }).filter(function (_ref5) {
1161
+ var _ref5$visible = _ref5.visible,
1162
+ visible = _ref5$visible === void 0 ? true : _ref5$visible;
1135
1163
  return visible;
1136
1164
  });
1137
1165
  }, [screens, screenId]);
@@ -1146,160 +1174,223 @@ var ViewerMenu = function ViewerMenu(_ref) {
1146
1174
  }
1147
1175
  }, [trackEvent, screenId, currentScreenIndex, screenType]);
1148
1176
  var shareUrl = useMemo(function () {
1149
- var origin = typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
1150
- var path = shareBasePath !== null ? "".concat(origin).concat(shareBasePath) : origin;
1177
+ // @todo validate this
1178
+ // const base =
1179
+ // typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
1180
+ // const path = shareBasePath !== null ? `${base}${shareBasePath}` : base;
1181
+ var base = typeof window !== 'undefined' ? window.location.host : '';
1182
+ var path = shareBasePath !== null ? "".concat(base).concat(shareBasePath) : base;
1151
1183
  return path;
1152
- }, [shareBasePath]);
1153
-
1154
- var _useSpring = useSpring(function () {
1155
- return {
1156
- y: 0,
1157
- config: _objectSpread(_objectSpread({}, config.stiff), {}, {
1158
- clamp: true
1159
- })
1160
- };
1161
- }),
1162
- _useSpring2 = _slicedToArray(_useSpring, 2),
1163
- menuY = _useSpring2[0].y,
1164
- setMenuSpring = _useSpring2[1];
1165
-
1166
- var refOpened = useRef(opened);
1167
-
1168
- if (refOpened.current !== opened) {
1169
- refOpened.current = opened;
1170
- }
1171
-
1172
- useEffect(function () {
1173
- setMenuSpring.start({
1174
- y: opened ? 1 : 0
1175
- });
1176
- }, [opened]);
1184
+ }, [shareBasePath]); // @todo sorta not super good here
1177
1185
 
1178
- var _useDimensionObserver = useDimensionObserver(),
1179
- menuPreviewContainerRef = _useDimensionObserver.ref,
1180
- _useDimensionObserver2 = _useDimensionObserver.height,
1181
- menuPreviewContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
1182
-
1183
- var menuPreviewStyle = {
1184
- transform: menuY.to(function (y) {
1185
- return "translateY(".concat(y * menuPreviewContainerHeight, "px)");
1186
- })
1187
- };
1188
- var menuDragBind = useDrag(function (_ref4) {
1189
- var _ref4$movement = _slicedToArray(_ref4.movement, 2),
1190
- my = _ref4$movement[1],
1191
- first = _ref4.first,
1192
- last = _ref4.last,
1193
- _ref4$direction = _slicedToArray(_ref4.direction, 2),
1194
- dy = _ref4$direction[1],
1195
- cancel = _ref4.cancel,
1196
- canceled = _ref4.canceled,
1197
- tap = _ref4.tap;
1198
-
1199
- if (canceled || tap) {
1200
- return;
1186
+ var onOpenMenu = useCallback(function () {
1187
+ setMenuOpened(true);
1188
+ setShareOpened(false);
1189
+ trackScreenEvent('viewer_menu', 'open_screens_menu');
1190
+ }, [setMenuOpened, setShareOpened, trackScreenEvent]);
1191
+ var onCloseMenu = useCallback(function () {
1192
+ setMenuOpened(false);
1193
+ setShareOpened(false);
1194
+ trackScreenEvent('viewer_menu', 'close_screens_menu');
1195
+ }, [setMenuOpened, setShareOpened, trackScreenEvent]);
1196
+ var onOpenShare = useCallback(function () {
1197
+ setShareOpened(true);
1198
+ setMenuOpened(false);
1199
+ trackScreenEvent('viewer_menu', 'open_share_menu');
1200
+ }, [setShareOpened, setMenuOpened, trackScreenEvent]);
1201
+ var onCloseShare = useCallback(function () {
1202
+ setShareOpened(false);
1203
+ setMenuOpened(false);
1204
+ trackScreenEvent('viewer_menu', 'close_share_menu');
1205
+ }, [setShareOpened, setMenuOpened, trackScreenEvent]);
1206
+ var onClickScreen = useCallback(function (screen) {
1207
+ setMenuOpened(false);
1208
+
1209
+ if (customOnClickScreen !== null) {
1210
+ customOnClickScreen(screen);
1201
1211
  }
1202
1212
 
1203
- var isMenuOpened = refOpened.current;
1204
-
1205
- if (first) {
1206
- if (isMenuOpened) {
1207
- cancel();
1208
- return;
1209
- }
1213
+ var index = items.findIndex(function (_ref6) {
1214
+ var id = _ref6.id;
1215
+ return id === screenId;
1216
+ });
1217
+ trackScreenEvent('viewer_menu', 'click_screen_change', "Screen ".concat(index + 1));
1218
+ }, [customOnClickScreen, setMenuOpened, items, screenId, trackScreenEvent]);
1219
+ var onShare = useCallback(function (type) {
1220
+ // @todo display something to say thanks for sharing?
1221
+ trackScreenEvent('viewer_menu', 'shared_story', type);
1222
+ }, [trackScreenEvent]);
1223
+ var computeShareProgress = useCallback(function (_ref7) {
1224
+ var active = _ref7.active,
1225
+ _ref7$direction = _slicedToArray(_ref7.direction, 2),
1226
+ dy = _ref7$direction[1],
1227
+ _ref7$movement = _slicedToArray(_ref7.movement, 2),
1228
+ my = _ref7$movement[1],
1229
+ _ref7$velocity = _slicedToArray(_ref7.velocity, 2),
1230
+ vy = _ref7$velocity[1];
1231
+
1232
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1233
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1234
+
1235
+ if (!active) {
1236
+ if (reachedThreshold) onOpenShare();
1237
+ return reachedThreshold ? 1 : 0;
1210
1238
  }
1211
1239
 
1212
- var yProgress = Math.max(0, Math.min(1, my / menuPreviewContainerHeight + (isMenuOpened ? 1 : 0)));
1213
-
1214
- if (last) {
1215
- var menuNowOpened = dy > 0 && yProgress > 0.1;
1216
- refOpened.current = menuNowOpened;
1217
- setMenuSpring.start({
1218
- y: menuNowOpened ? 1 : 0
1219
- });
1240
+ return progress;
1241
+ }, [menuOpened, onOpenShare]);
1220
1242
 
1221
- if (menuNowOpened && onRequestOpen !== null) {
1222
- onRequestOpen();
1223
- } else if (!menuNowOpened && onRequestClose !== null) {
1224
- onRequestClose();
1243
+ var _useDragProgress = useDragProgress({
1244
+ progress: shareOpened ? 1 : 0,
1245
+ computeProgress: computeShareProgress,
1246
+ springParams: {
1247
+ config: {
1248
+ tension: 300,
1249
+ friction: 30
1225
1250
  }
1226
- } else {
1227
- setMenuSpring.start({
1228
- y: yProgress
1229
- });
1230
1251
  }
1231
- }, {
1232
- axis: 'y',
1233
- filterTaps: true
1234
- }); // handle preview menu item click
1235
-
1236
- var onClickMenu = useCallback(function (index) {
1237
- if (customOnClickMenu !== null) {
1238
- customOnClickMenu(index);
1252
+ }),
1253
+ bindShareDrag = _useDragProgress.bind,
1254
+ isDraggingShare = _useDragProgress.dragging,
1255
+ shareOpenedProgress = _useDragProgress.progress;
1256
+
1257
+ var computeMenuProgress = useCallback(function (_ref8) {
1258
+ var active = _ref8.active,
1259
+ _ref8$direction = _slicedToArray(_ref8.direction, 2),
1260
+ dy = _ref8$direction[1],
1261
+ _ref8$movement = _slicedToArray(_ref8.movement, 2),
1262
+ my = _ref8$movement[1],
1263
+ _ref8$velocity = _slicedToArray(_ref8.velocity, 2),
1264
+ vy = _ref8$velocity[1];
1265
+
1266
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1267
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1268
+
1269
+ if (!active) {
1270
+ if (reachedThreshold) onOpenMenu();
1271
+ return reachedThreshold ? 1 : 0;
1239
1272
  }
1240
1273
 
1241
- trackScreenEvent('viewer_menu', 'click_open', 'Menu icon');
1242
- }, [customOnClickMenu, trackScreenEvent]);
1243
- var onClickItem = useCallback(function (item) {
1244
- if (customOnClickItem !== null) {
1245
- customOnClickItem(item);
1246
- }
1274
+ return progress;
1275
+ }, [menuOpened, onOpenMenu]);
1247
1276
 
1248
- var index = items.findIndex(function (_ref5) {
1249
- var id = _ref5.id;
1250
- return id === screenId;
1251
- });
1252
- trackScreenEvent('viewer_menu', 'click_screen_change', "Screen ".concat(index + 1));
1253
- }, [customOnClickItem, items, screenId, trackScreenEvent]);
1254
- var onClickClose = useCallback(function () {
1255
- if (onRequestClose !== null) {
1256
- onRequestClose();
1277
+ var _useDragProgress2 = useDragProgress({
1278
+ progress: menuOpened ? 1 : 0,
1279
+ computeProgress: computeMenuProgress,
1280
+ springParams: {
1281
+ config: {
1282
+ tension: 300,
1283
+ friction: 30
1284
+ }
1257
1285
  }
1286
+ }),
1287
+ bindMenuDrag = _useDragProgress2.bind,
1288
+ isDraggingMenu = _useDragProgress2.dragging,
1289
+ menuOpenedProgress = _useDragProgress2.progress;
1258
1290
 
1259
- trackScreenEvent('viewer_menu', 'click_close', 'Close icon');
1260
- }, [onRequestClose, trackScreenEvent]); // Handle preview menu share click
1261
-
1262
- var onClickShare = useCallback(function (type) {
1263
- return trackScreenEvent('viewer_menu', 'click_share', type);
1264
- }, [trackScreenEvent]);
1265
-
1266
- var _ref6 = viewerTheme || {},
1267
- _ref6$menuTheme = _ref6.menuTheme,
1268
- menuTheme = _ref6$menuTheme === void 0 ? null : _ref6$menuTheme;
1291
+ var keyboardShortcuts = useMemo(function () {
1292
+ return {
1293
+ m: function m() {
1294
+ return !menuOpened ? onOpenMenu() : onCloseMenu();
1295
+ },
1296
+ escape: function escape() {
1297
+ return onCloseMenu();
1298
+ }
1299
+ };
1300
+ }, [menuOpened, onOpenMenu, onCloseMenu]);
1301
+ useKeyboardShortcuts(keyboardShortcuts); // should be zero if either screens menu or share menu is opened
1269
1302
 
1270
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", Object.assign({
1271
- className: styles$6.menuDotsContainer,
1303
+ var dotsOpacity = Math.min(1, Math.max(0, 1 - (menuOpenedProgress + shareOpenedProgress)));
1304
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1305
+ className: classNames([styles$6.menuNavContainer, (_ref9 = {}, _defineProperty(_ref9, styles$6.withShadow, withShadow), _defineProperty(_ref9, styles$6.isOpened, menuOpened || shareOpened), _ref9)]),
1272
1306
  ref: refDots,
1273
1307
  style: {
1274
1308
  width: menuWidth
1275
1309
  }
1276
- }, menuDragBind()), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
1310
+ }, /*#__PURE__*/React.createElement("nav", {
1311
+ className: styles$6.menuTopContainer
1312
+ }, !withoutShareMenu ? /*#__PURE__*/React.createElement("div", Object.assign({
1313
+ className: classNames([styles$6.menuItem, styles$6.menuShare])
1314
+ }, bindShareDrag()), /*#__PURE__*/React.createElement(SlidingButtons, {
1315
+ className: styles$6.slidingButton,
1316
+ current: shareOpenedProgress,
1317
+ immediate: isDraggingShare,
1318
+ buttons: [ShareButton, CloseButton],
1319
+ buttonsProps: [{
1320
+ key: 'share',
1321
+ className: styles$6.menuButton,
1322
+ onClick: onOpenShare,
1323
+ theme: menuTheme
1324
+ }, {
1325
+ key: 'close-share',
1326
+ className: styles$6.menuButton,
1327
+ onClick: onCloseShare,
1328
+ theme: menuTheme,
1329
+ iconPosition: 'left'
1330
+ }]
1331
+ })) : null, !withoutScreensMenu ? /*#__PURE__*/React.createElement("div", Object.assign({
1332
+ className: classNames([styles$6.menuItem, styles$6.menuScreens])
1333
+ }, bindMenuDrag()), /*#__PURE__*/React.createElement(SlidingButtons, {
1334
+ className: styles$6.slidingButton,
1335
+ current: menuOpenedProgress,
1336
+ immediate: isDraggingMenu,
1337
+ buttons: [MenuButton, CloseButton],
1338
+ buttonsProps: [{
1339
+ key: 'menu',
1340
+ className: styles$6.menuButton,
1341
+ onClick: onOpenMenu,
1342
+ theme: menuTheme
1343
+ }, {
1344
+ key: 'close-menu',
1345
+ className: styles$6.menuButton,
1346
+ onClick: onCloseMenu,
1347
+ theme: menuTheme,
1348
+ iconPosition: 'right'
1349
+ }]
1350
+ })) : null), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
1277
1351
  direction: "horizontal",
1278
- withShadow: withShadow,
1279
1352
  items: items,
1280
- title: title,
1281
- shareUrl: shareUrl,
1282
- onShare: onClickShare,
1283
- onClickItem: onClickItem,
1284
- onClickMenu: onClickMenu,
1353
+ onClickDot: onClickScreen,
1354
+ onClickMenu: onOpenMenu,
1285
1355
  closeable: closeable,
1286
1356
  withItemClick: withDotItemClick,
1287
1357
  withoutScreensMenu: withoutScreensMenu,
1358
+ withoutShareMenu: withoutShareMenu,
1288
1359
  onClose: onClickCloseViewer,
1289
- className: styles$6.menuDots
1290
- }))), /*#__PURE__*/React.createElement(animated.div, {
1291
- className: styles$6.menuPreviewContainer,
1292
- style: menuPreviewStyle,
1293
- ref: menuPreviewContainerRef
1360
+ className: styles$6.dots,
1361
+ style: {
1362
+ opacity: dotsOpacity
1363
+ }
1364
+ }))), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
1365
+ className: styles$6.menuContainerShare,
1366
+ transitionProgress: shareOpenedProgress
1367
+ }, /*#__PURE__*/React.createElement(ViewerMenuShare, {
1368
+ viewerTheme: viewerTheme,
1369
+ className: styles$6.menuShare,
1370
+ title: title,
1371
+ description: description,
1372
+ menuWidth: menuWidth,
1373
+ focusable: shareOpened,
1374
+ items: items,
1375
+ currentScreenIndex: currentScreenIndex,
1376
+ shareUrl: shareUrl,
1377
+ onShare: onShare,
1378
+ onClose: onCloseShare
1379
+ })), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
1380
+ className: styles$6.menuContainerScreens,
1381
+ transitionProgress: menuOpenedProgress
1294
1382
  }, /*#__PURE__*/React.createElement(ViewerMenuPreview, {
1295
1383
  viewerTheme: viewerTheme,
1296
1384
  className: styles$6.menuPreview,
1297
1385
  screenSize: screenSize,
1298
1386
  menuWidth: menuWidth,
1299
- focusable: opened,
1387
+ focusable: menuOpened,
1300
1388
  items: items,
1301
- onClickItem: onClickItem,
1302
- onClose: onClickClose,
1389
+ currentScreenIndex: currentScreenIndex,
1390
+ shareUrl: shareUrl,
1391
+ onShare: onShare,
1392
+ onClickScreen: onClickScreen,
1393
+ onClose: onCloseMenu,
1303
1394
  toggleFullscreen: toggleFullscreen,
1304
1395
  fullscreenActive: fullscreenActive,
1305
1396
  fullscreenEnabled: fullscreenEnabled
@@ -1373,7 +1464,7 @@ var propTypes$7 = {
1373
1464
  width: PropTypes.number,
1374
1465
  height: PropTypes.number,
1375
1466
  scale: PropTypes.number,
1376
- withNavigationHint: PropTypes.func,
1467
+ withNavigationHint: PropTypes.bool,
1377
1468
  className: PropTypes.string
1378
1469
  };
1379
1470
  var defaultProps$7 = {
@@ -1426,11 +1517,11 @@ function ViewerScreen(_ref) {
1426
1517
  ViewerScreen.propTypes = propTypes$7;
1427
1518
  ViewerScreen.defaultProps = defaultProps$7;
1428
1519
 
1429
- var styles$3 = {"container":"micromag-viewer-partials-navigation-button-container"};
1520
+ var styles$3 = {"arrow":"micromag-viewer-buttons-navigation-button-arrow","next":"micromag-viewer-buttons-navigation-button-next","previous":"micromag-viewer-buttons-navigation-button-previous"};
1430
1521
 
1431
1522
  var propTypes$6 = {
1432
1523
  direction: PropTypes.oneOf(['previous', 'next']),
1433
- onClick: null,
1524
+ onClick: PropTypes.func,
1434
1525
  className: PropTypes.string
1435
1526
  };
1436
1527
  var defaultProps$6 = {
@@ -1443,37 +1534,57 @@ var NavigationButton = function NavigationButton(_ref) {
1443
1534
  var direction = _ref.direction,
1444
1535
  onClick = _ref.onClick,
1445
1536
  className = _ref.className;
1446
- return /*#__PURE__*/React.createElement("button", {
1447
- type: "button",
1448
- className: classNames([styles$3.container, _defineProperty({}, className, className !== null)]),
1449
- onClick: onClick
1450
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1451
- className: styles$3.arrow,
1452
- icon: direction === 'previous' ? faArrowLeft : faArrowRight
1453
- }), /*#__PURE__*/React.createElement("span", {
1454
- className: "sr-only"
1455
- }, direction === 'previous' ? /*#__PURE__*/React.createElement(FormattedMessage, {
1456
- id: "zYH/31",
1457
- defaultMessage: [{
1458
- "type": 0,
1459
- "value": "Go to previous screen"
1460
- }]
1461
- }) : /*#__PURE__*/React.createElement(FormattedMessage, {
1462
- id: "v9bqYj",
1463
- defaultMessage: [{
1464
- "type": 0,
1465
- "value": "Go to next screen"
1466
- }]
1467
- })));
1537
+ return /*#__PURE__*/React.createElement(Button, {
1538
+ className: classNames([styles$3.container, styles$3[direction], _defineProperty({}, className, className !== null)]),
1539
+ onClick: onClick,
1540
+ iconPosition: direction === 'next' ? 'right' : 'left',
1541
+ icon: /*#__PURE__*/React.createElement("svg", {
1542
+ className: styles$3.arrow,
1543
+ xmlns: "http://www.w3.org/2000/svg",
1544
+ width: "10",
1545
+ height: "16",
1546
+ viewBox: "0 0 10 16",
1547
+ fill: "currentColor"
1548
+ }, /*#__PURE__*/React.createElement("polygon", {
1549
+ points: "9.62 4.62 5 0 0.38 4.62 1.44 5.68 4.25 2.87 4.25 14.39 5.75 14.39 5.75 2.87 8.56 5.68 9.62 4.62"
1550
+ })),
1551
+ label: /*#__PURE__*/React.createElement("span", {
1552
+ className: "sr-only"
1553
+ }, direction === 'previous' ? /*#__PURE__*/React.createElement(FormattedMessage, {
1554
+ id: "zYH/31",
1555
+ defaultMessage: [{
1556
+ "type": 0,
1557
+ "value": "Go to previous screen"
1558
+ }]
1559
+ }) : /*#__PURE__*/React.createElement(FormattedMessage, {
1560
+ id: "v9bqYj",
1561
+ defaultMessage: [{
1562
+ "type": 0,
1563
+ "value": "Go to next screen"
1564
+ }]
1565
+ }))
1566
+ });
1468
1567
  };
1469
1568
 
1470
1569
  NavigationButton.propTypes = propTypes$6;
1471
1570
  NavigationButton.defaultProps = defaultProps$6;
1472
1571
 
1473
- var styles$2 = {"track":"micromag-viewer-partials-seek-bar-track","progress":"micromag-viewer-partials-seek-bar-progress","inner":"micromag-viewer-partials-seek-bar-inner","progressBar":"micromag-viewer-partials-seek-bar-progressBar","playHead":"micromag-viewer-partials-seek-bar-playHead","withSeekHead":"micromag-viewer-partials-seek-bar-withSeekHead","time":"micromag-viewer-partials-seek-bar-time"};
1572
+ var styles$2 = {"track":"micromag-viewer-partials-seek-bar-track","progress":"micromag-viewer-partials-seek-bar-progress","inner":"micromag-viewer-partials-seek-bar-inner","progressBar":"micromag-viewer-partials-seek-bar-progressBar","playHead":"micromag-viewer-partials-seek-bar-playHead","withSeekHead":"micromag-viewer-partials-seek-bar-withSeekHead","scrubbedTime":"micromag-viewer-partials-seek-bar-scrubbedTime","showTimestamp":"micromag-viewer-partials-seek-bar-showTimestamp"};
1573
+
1574
+ function getFormattedTimestamp(s) {
1575
+ var withMilliseconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1576
+ var sparts = withMilliseconds ? "".concat(s).split('.') : [];
1577
+ var ms = sparts.length > 1 ? ":".concat(sparts[1].substring(0, 3)) : '';
1578
+ return (s - (s %= 60)) / 60 + (9 < s ? ':' : ':0') + ~~s + ms; // eslint-disable-line
1579
+ }
1580
+
1581
+ var SHOW_MILLISECONDS_THRESHOLD = 5; // show milliseconds when scrubbing if length of video is shorter than 5 seconds
1474
1582
 
1475
1583
  var propTypes$5 = {
1476
- media: PropTypes.node,
1584
+ media: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1585
+ current: PropTypes.any
1586
+ }) // eslint-disable-line
1587
+ ]),
1477
1588
  playing: PropTypes.bool,
1478
1589
  backgroundColor: PropTypes.string,
1479
1590
  progressColor: PropTypes.string,
@@ -1498,7 +1609,7 @@ var defaultProps$5 = {
1498
1609
  };
1499
1610
 
1500
1611
  var SeekBar = function SeekBar(_ref) {
1501
- var _ref3;
1612
+ var _ref4;
1502
1613
 
1503
1614
  var media = _ref.media,
1504
1615
  playing = _ref.playing,
@@ -1514,13 +1625,28 @@ var SeekBar = function SeekBar(_ref) {
1514
1625
  var progress = useMediaProgress(media, {
1515
1626
  disabled: !playing
1516
1627
  });
1517
- var onDrag = useCallback(function (_ref2) {
1518
- var _ref2$xy = _slicedToArray(_ref2.xy, 1),
1519
- x = _ref2$xy[0],
1520
- elapsedTime = _ref2.elapsedTime,
1521
- active = _ref2.active,
1522
- tap = _ref2.tap,
1523
- currentTarget = _ref2.currentTarget;
1628
+
1629
+ var _ref2 = media || {},
1630
+ _ref2$currentTime = _ref2.currentTime,
1631
+ currentTime = _ref2$currentTime === void 0 ? null : _ref2$currentTime,
1632
+ _ref2$duration = _ref2.duration,
1633
+ duration = _ref2$duration === void 0 ? null : _ref2$duration;
1634
+
1635
+ var _useState = useState(false),
1636
+ _useState2 = _slicedToArray(_useState, 2),
1637
+ showTimestamp = _useState2[0],
1638
+ setShowTimestamp = _useState2[1];
1639
+
1640
+ var onDrag = useCallback(function (_ref3) {
1641
+ var event = _ref3.event,
1642
+ _ref3$xy = _slicedToArray(_ref3.xy, 1),
1643
+ x = _ref3$xy[0],
1644
+ elapsedTime = _ref3.elapsedTime,
1645
+ active = _ref3.active,
1646
+ tap = _ref3.tap,
1647
+ currentTarget = _ref3.currentTarget;
1648
+
1649
+ event.stopPropagation();
1524
1650
 
1525
1651
  if (!active && elapsedTime > 300) {
1526
1652
  return;
@@ -1536,16 +1662,21 @@ var SeekBar = function SeekBar(_ref) {
1536
1662
  onSeek(newProgress, tap);
1537
1663
  }
1538
1664
  }, [onSeek]);
1539
- var onDragStart = useCallback(function () {
1665
+ var onDragStart = useCallback(function (event) {
1666
+ setShowTimestamp(true);
1667
+
1540
1668
  if (onSeekStart !== null) {
1541
1669
  onSeekStart();
1542
1670
  }
1543
- }, [onSeekStart]);
1671
+
1672
+ event.stopPropagation();
1673
+ }, [onSeekStart, setShowTimestamp]);
1544
1674
  var onDragEnd = useCallback(function () {
1545
1675
  if (onSeekEnd !== null) {
1676
+ setShowTimestamp(false);
1546
1677
  onSeekEnd();
1547
1678
  }
1548
- }, [onSeekEnd]);
1679
+ }, [onSeekEnd, setShowTimestamp]);
1549
1680
  var bind = useGesture({
1550
1681
  onDrag: onDrag,
1551
1682
  onDragStart: onDragStart,
@@ -1557,7 +1688,7 @@ var SeekBar = function SeekBar(_ref) {
1557
1688
  }
1558
1689
  });
1559
1690
  return /*#__PURE__*/React.createElement("div", {
1560
- className: classNames([styles$2.container, (_ref3 = {}, _defineProperty(_ref3, className, className !== null), _defineProperty(_ref3, styles$2.withSeekHead, withSeekHead), _ref3)])
1691
+ className: classNames([styles$2.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$2.withSeekHead, withSeekHead), _defineProperty(_ref4, styles$2.showTimestamp, showTimestamp), _ref4)])
1561
1692
  }, /*#__PURE__*/React.createElement("div", {
1562
1693
  className: styles$2.inner
1563
1694
  }, /*#__PURE__*/React.createElement("div", {
@@ -1571,7 +1702,12 @@ var SeekBar = function SeekBar(_ref) {
1571
1702
  left: "".concat(progress * 100, "%"),
1572
1703
  backgroundColor: progressColor
1573
1704
  }
1574
- }), /*#__PURE__*/React.createElement("div", {
1705
+ }, /*#__PURE__*/React.createElement("div", {
1706
+ className: styles$2.scrubbedTime,
1707
+ style: {
1708
+ borderColor: progressColor
1709
+ }
1710
+ }, getFormattedTimestamp(currentTime, duration < SHOW_MILLISECONDS_THRESHOLD))), /*#__PURE__*/React.createElement("div", {
1575
1711
  className: styles$2.progress,
1576
1712
  style: {
1577
1713
  transform: "scaleX(".concat(progress, ")"),
@@ -1601,7 +1737,7 @@ var SeekBar = function SeekBar(_ref) {
1601
1737
  SeekBar.propTypes = propTypes$5;
1602
1738
  SeekBar.defaultProps = defaultProps$5;
1603
1739
 
1604
- var styles$1 = {"muteButton":"micromag-viewer-partials-playback-controls-muteButton","playPauseButton":"micromag-viewer-partials-playback-controls-playPauseButton","container":"micromag-viewer-partials-playback-controls-container","icon":"micromag-viewer-partials-playback-controls-icon","withPlayPause":"micromag-viewer-partials-playback-controls-withPlayPause","isCollapsed":"micromag-viewer-partials-playback-controls-isCollapsed","isMuted":"micromag-viewer-partials-playback-controls-isMuted","withMute":"micromag-viewer-partials-playback-controls-withMute","seekBar":"micromag-viewer-partials-playback-controls-seekBar","withSeekBarOnly":"micromag-viewer-partials-playback-controls-withSeekBarOnly","withSeekBar":"micromag-viewer-partials-playback-controls-withSeekBar"};
1740
+ var styles$1 = {"muteButton":"micromag-viewer-partials-playback-controls-muteButton","playPauseButton":"micromag-viewer-partials-playback-controls-playPauseButton","container":"micromag-viewer-partials-playback-controls-container","icon":"micromag-viewer-partials-playback-controls-icon","withPlayPause":"micromag-viewer-partials-playback-controls-withPlayPause","isCollapsed":"micromag-viewer-partials-playback-controls-isCollapsed","isMuted":"micromag-viewer-partials-playback-controls-isMuted","withMute":"micromag-viewer-partials-playback-controls-withMute","withSeekBar":"micromag-viewer-partials-playback-controls-withSeekBar","seekBar":"micromag-viewer-partials-playback-controls-seekBar","withSeekBarOnly":"micromag-viewer-partials-playback-controls-withSeekBarOnly"};
1605
1741
 
1606
1742
  var propTypes$4 = {
1607
1743
  className: PropTypes.string,
@@ -1706,7 +1842,8 @@ function PlaybackControls(_ref) {
1706
1842
  setPlaying(true);
1707
1843
  }
1708
1844
  }, [setPlaying, wasPlaying]);
1709
- var mediaHasAudio = mediaElement !== null && (hasAudio === null || hasAudio === true);
1845
+ var hasMedia = mediaElement !== null;
1846
+ var mediaHasAudio = hasMedia && (hasAudio === null || hasAudio === true);
1710
1847
 
1711
1848
  var _ref3 = customControlsTheme || {},
1712
1849
  color = _ref3.color,
@@ -1715,33 +1852,55 @@ function PlaybackControls(_ref) {
1715
1852
 
1716
1853
  var isCollapsed = controls && !controlsVisible && playing || !controls && mediaHasAudio;
1717
1854
  return /*#__PURE__*/React.createElement("div", {
1718
- className: classNames([styles$1.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$1.withPlayPause, controls && !seekBarOnly), _defineProperty(_ref4, styles$1.withMute, mediaHasAudio || controls), _defineProperty(_ref4, styles$1.withSeekBar, controls), _defineProperty(_ref4, styles$1.withSeekBarOnly, seekBarOnly), _defineProperty(_ref4, styles$1.isCollapsed, isCollapsed), _defineProperty(_ref4, collapsedClassName, collapsedClassName !== null && isCollapsed), _ref4)])
1719
- }, /*#__PURE__*/React.createElement("button", {
1720
- type: "button",
1855
+ className: classNames([styles$1.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$1.withPlayPause, controls && !seekBarOnly), _defineProperty(_ref4, styles$1.withMute, hasMedia || controls), _defineProperty(_ref4, styles$1.withSeekBar, controls), _defineProperty(_ref4, styles$1.withSeekBarOnly, seekBarOnly), _defineProperty(_ref4, styles$1.isCollapsed, isCollapsed), _defineProperty(_ref4, styles$1.isMuted, muted), _defineProperty(_ref4, collapsedClassName, collapsedClassName !== null && isCollapsed), _ref4)])
1856
+ }, /*#__PURE__*/React.createElement(Button, {
1721
1857
  className: styles$1.playPauseButton,
1722
1858
  style: {
1723
1859
  color: color
1724
1860
  },
1725
1861
  onClick: playing ? onPause : onPlay,
1726
- title: intl.formatMessage({
1727
- id: "ahSpiH",
1862
+ focusable: controlsVisible,
1863
+ icon: playing ? /*#__PURE__*/React.createElement("svg", {
1864
+ className: styles$1.icon,
1865
+ xmlns: "http://www.w3.org/2000/svg",
1866
+ width: "10",
1867
+ height: "16",
1868
+ viewBox: "0 0 10 16",
1869
+ fill: "currentColor"
1870
+ }, /*#__PURE__*/React.createElement("rect", {
1871
+ x: "1",
1872
+ y: "3.27",
1873
+ width: "3",
1874
+ height: "9.69"
1875
+ }), /*#__PURE__*/React.createElement("rect", {
1876
+ x: "6",
1877
+ y: "3.27",
1878
+ width: "3",
1879
+ height: "9.69"
1880
+ })) : /*#__PURE__*/React.createElement("svg", {
1881
+ className: styles$1.icon,
1882
+ xmlns: "http://www.w3.org/2000/svg",
1883
+ width: "10",
1884
+ height: "16",
1885
+ viewBox: "0 0 10 16",
1886
+ fill: "currentColor"
1887
+ }, /*#__PURE__*/React.createElement("path", {
1888
+ d: "M1,3.16V12.84l8-4.84L1,3.16"
1889
+ })),
1890
+ "aria-label": playing ? intl.formatMessage({
1891
+ id: "mTqcmA",
1728
1892
  defaultMessage: [{
1729
1893
  "type": 0,
1730
- "value": "Play"
1894
+ "value": "Pause"
1731
1895
  }]
1732
- }),
1733
- "aria-label": intl.formatMessage({
1896
+ }) : intl.formatMessage({
1734
1897
  id: "ahSpiH",
1735
1898
  defaultMessage: [{
1736
1899
  "type": 0,
1737
1900
  "value": "Play"
1738
1901
  }]
1739
- }),
1740
- tabIndex: controlsVisible ? '0' : '-1'
1741
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1742
- className: styles$1.icon,
1743
- icon: playing ? faPause : faPlay
1744
- })), /*#__PURE__*/React.createElement(SeekBar, {
1902
+ })
1903
+ }), /*#__PURE__*/React.createElement(SeekBar, {
1745
1904
  className: styles$1.seekBar,
1746
1905
  media: mediaElement,
1747
1906
  playing: playing,
@@ -1752,32 +1911,54 @@ function PlaybackControls(_ref) {
1752
1911
  withSeekHead: !isCollapsed && !seekBarOnly,
1753
1912
  backgroundColor: color,
1754
1913
  progressColor: progressColor
1755
- }), /*#__PURE__*/React.createElement("button", {
1756
- type: "button",
1757
- className: classNames([styles$1.muteButton, _defineProperty({}, styles$1.isMuted, muted)]),
1914
+ }), /*#__PURE__*/React.createElement(Button, {
1915
+ className: styles$1.muteButton,
1758
1916
  style: {
1759
1917
  color: color
1760
1918
  },
1761
1919
  onClick: muted ? onUnmute : onMute,
1762
- title: intl.formatMessage({
1763
- id: "vzg8Es",
1920
+ focusable: controlsVisible || mediaHasAudio,
1921
+ icon: muted ? /*#__PURE__*/React.createElement("svg", {
1922
+ xmlns: "http://www.w3.org/2000/svg",
1923
+ width: "10",
1924
+ height: "16",
1925
+ viewBox: "0 0 10 16",
1926
+ className: styles$1.icon,
1927
+ fill: "currentColor"
1928
+ }, /*#__PURE__*/React.createElement("polygon", {
1929
+ points: "2.75 4.63 1.24 6 0 6 0 10 1.24 10 4.54 13 4.54 3 2.75 4.63"
1930
+ }), /*#__PURE__*/React.createElement("polygon", {
1931
+ points: "10 6.63 8.94 5.57 7.58 6.93 6.21 5.57 5.15 6.63 6.52 7.99 5.15 9.35 6.21 10.43 7.58 9.06 8.94 10.43 10 9.35 8.64 7.99 10 6.63"
1932
+ })) : /*#__PURE__*/React.createElement("svg", {
1933
+ xmlns: "http://www.w3.org/2000/svg",
1934
+ width: "10",
1935
+ height: "16",
1936
+ viewBox: "0 0 10 16",
1937
+ className: styles$1.icon,
1938
+ fill: "currentColor"
1939
+ }, /*#__PURE__*/React.createElement("polygon", {
1940
+ points: "2.75 4.63 1.24 6 0 6 0 10 1.24 10 4.54 13 4.54 3 2.75 4.63"
1941
+ }), /*#__PURE__*/React.createElement("circle", {
1942
+ cx: "6.14",
1943
+ cy: "8",
1944
+ r: ".99"
1945
+ }), /*#__PURE__*/React.createElement("path", {
1946
+ d: "M6.14,11.88v-1.5c1.31,0,2.38-1.07,2.38-2.38s-1.07-2.38-2.38-2.38v-1.5c2.14,0,3.88,1.74,3.88,3.88s-1.74,3.88-3.88,3.88Z"
1947
+ })),
1948
+ "aria-label": muted ? intl.formatMessage({
1949
+ id: "RK/QEY",
1764
1950
  defaultMessage: [{
1765
1951
  "type": 0,
1766
- "value": "Mute"
1952
+ "value": "Unmute"
1767
1953
  }]
1768
- }),
1769
- "aria-label": intl.formatMessage({
1954
+ }) : intl.formatMessage({
1770
1955
  id: "vzg8Es",
1771
1956
  defaultMessage: [{
1772
1957
  "type": 0,
1773
1958
  "value": "Mute"
1774
1959
  }]
1775
- }),
1776
- tabIndex: controlsVisible || mediaHasAudio ? '0' : '-1'
1777
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1778
- className: styles$1.icon,
1779
- icon: faVolumeUp
1780
- })));
1960
+ })
1961
+ }));
1781
1962
  }
1782
1963
 
1783
1964
  PlaybackControls.propTypes = propTypes$4;
@@ -1870,6 +2051,15 @@ function WebViewContainer(_ref) {
1870
2051
  WebViewContainer.propTypes = propTypes$3;
1871
2052
  WebViewContainer.defaultProps = defaultProps$3;
1872
2053
 
2054
+ var SPRING_CONFIG_TIGHT = {
2055
+ tension: 300,
2056
+ friction: 35
2057
+ }; // tight
2058
+
2059
+ var DRAG_PROGRESS_ACTIVATION_THRESHOLD = 0.3;
2060
+ var DRAG_VELOCITY_ACTIVATION_THRESHOLD = 0.3;
2061
+ var DEFAULT_TRANSITION_TYPE_LANDSCAPE = 'carousel';
2062
+ var DEFAULT_TRANSITION_TYPE_PORTRAIT = 'stack';
1873
2063
  var propTypes$2 = {
1874
2064
  story: PropTypes$1.story,
1875
2065
  // .isRequired,
@@ -1885,15 +2075,19 @@ var propTypes$2 = {
1885
2075
  onScreenChange: PropTypes.func,
1886
2076
  tapNextScreenWidthPercent: PropTypes.number,
1887
2077
  neighborScreensActive: PropTypes.number,
1888
- neighborScreensMounted: PropTypes.number,
1889
2078
  storyIsParsed: PropTypes.bool,
1890
- landscapeScreenMargin: PropTypes.number,
2079
+ // landscapeScreenMargin: PropTypes.number,
2080
+ // landscapeSmallScreenScale: PropTypes.number,
1891
2081
  withMetadata: PropTypes.bool,
2082
+ withoutGestures: PropTypes.bool,
1892
2083
  withoutMenu: PropTypes.bool,
1893
2084
  withoutScreensMenu: PropTypes.bool,
2085
+ withoutShareMenu: PropTypes.bool,
1894
2086
  withoutMenuShadow: PropTypes.bool,
1895
2087
  withoutFullscreen: PropTypes.bool,
1896
- withLandscapeSiblingsScreens: PropTypes.bool,
2088
+ withoutNavigationArrow: PropTypes.bool,
2089
+ withoutTransitions: PropTypes.bool,
2090
+ withNeighborScreens: PropTypes.bool,
1897
2091
  withNavigationHint: PropTypes.bool,
1898
2092
  withoutPlaybackControls: PropTypes.bool,
1899
2093
  closeable: PropTypes.bool,
@@ -1925,16 +2119,20 @@ var defaultProps$2 = {
1925
2119
  onScreenChange: null,
1926
2120
  tapNextScreenWidthPercent: 0.8,
1927
2121
  neighborScreensActive: 1,
1928
- neighborScreensMounted: 1,
1929
2122
  storyIsParsed: false,
1930
- landscapeScreenMargin: 20,
2123
+ // landscapeScreenMargin: 20,
2124
+ // landscapeSmallScreenScale: 0.9,
1931
2125
  withMetadata: false,
2126
+ withNeighborScreens: false,
2127
+ withNavigationHint: false,
2128
+ withoutGestures: false,
1932
2129
  withoutMenu: false,
1933
2130
  withoutScreensMenu: false,
2131
+ withoutShareMenu: false,
1934
2132
  withoutMenuShadow: false,
1935
2133
  withoutFullscreen: false,
1936
- withLandscapeSiblingsScreens: false,
1937
- withNavigationHint: false,
2134
+ withoutTransitions: false,
2135
+ withoutNavigationArrow: false,
1938
2136
  withoutPlaybackControls: false,
1939
2137
  menuIsScreenWidth: false,
1940
2138
  closeable: false,
@@ -1963,15 +2161,17 @@ var Viewer = function Viewer(_ref) {
1963
2161
  visitor = _ref.visitor,
1964
2162
  tapNextScreenWidthPercent = _ref.tapNextScreenWidthPercent,
1965
2163
  neighborScreensActive = _ref.neighborScreensActive,
1966
- neighborScreensMounted = _ref.neighborScreensMounted,
1967
2164
  storyIsParsed = _ref.storyIsParsed,
1968
- landscapeScreenMargin = _ref.landscapeScreenMargin,
1969
2165
  withMetadata = _ref.withMetadata,
2166
+ withoutGestures = _ref.withoutGestures,
1970
2167
  withoutMenu = _ref.withoutMenu,
1971
2168
  withoutScreensMenu = _ref.withoutScreensMenu,
2169
+ withoutShareMenu = _ref.withoutShareMenu,
1972
2170
  withoutMenuShadow = _ref.withoutMenuShadow;
1973
2171
  _ref.withoutFullscreen;
1974
- var withLandscapeSiblingsScreens = _ref.withLandscapeSiblingsScreens,
2172
+ var withoutNavigationArrow = _ref.withoutNavigationArrow;
2173
+ _ref.withoutTransitions;
2174
+ var withNeighborScreens = _ref.withNeighborScreens,
1975
2175
  withNavigationHint = _ref.withNavigationHint,
1976
2176
  withoutPlaybackControls = _ref.withoutPlaybackControls,
1977
2177
  menuIsScreenWidth = _ref.menuIsScreenWidth,
@@ -1985,7 +2185,10 @@ var Viewer = function Viewer(_ref) {
1985
2185
  screensMedias = _ref.screensMedias,
1986
2186
  screenSizeOptions = _ref.screenSizeOptions,
1987
2187
  className = _ref.className;
1988
- var intl = useIntl();
2188
+
2189
+ /**
2190
+ * Screen Data + Processing
2191
+ */
1989
2192
  var parsedStory = useParsedStory(story, {
1990
2193
  disabled: storyIsParsed
1991
2194
  }) || {};
@@ -1997,20 +2200,59 @@ var Viewer = function Viewer(_ref) {
1997
2200
  metadata = _parsedStory$metadata === void 0 ? null : _parsedStory$metadata,
1998
2201
  _parsedStory$fonts = parsedStory.fonts,
1999
2202
  fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
2203
+ var screensCount = screens.length;
2000
2204
  var eventsManager = useMemo(function () {
2001
2205
  return new EventEmitter();
2002
- }, [parsedStory]); // Viewer Theme
2206
+ }, [parsedStory]);
2207
+ var screenIndex = useMemo(function () {
2208
+ return Math.max(0, screens.findIndex(function (it) {
2209
+ return "".concat(it.id) === "".concat(screenId);
2210
+ }));
2211
+ }, [screenId, screens]);
2212
+ var currentScreen = screens[screenIndex] || null;
2213
+
2214
+ var _ref2 = currentScreen || {},
2215
+ screenParameters = _ref2.parameters;
2216
+
2217
+ var _ref3 = screenParameters || {},
2218
+ screenMetadata = _ref3.metadata;
2219
+
2220
+ var _ref4 = screenMetadata || {},
2221
+ _ref4$title = _ref4.title,
2222
+ screenTitle = _ref4$title === void 0 ? null : _ref4$title,
2223
+ _ref4$description = _ref4.description,
2224
+ screenDescription = _ref4$description === void 0 ? null : _ref4$description;
2225
+
2226
+ var finalTitle = screenTitle !== null ? screenTitle : title;
2227
+ var finalMetadata = useMemo(function () {
2228
+ return screenDescription !== null ? _objectSpread(_objectSpread({}, metadata), {}, {
2229
+ description: screenDescription
2230
+ }) : metadata;
2231
+ }, [metadata, screenDescription]);
2232
+ var screensMediasRef = useRef([]);
2233
+
2234
+ if (currentScreenMedia !== null) {
2235
+ currentScreenMedia.current = screensMediasRef.current[screenIndex] || null;
2236
+ }
2237
+
2238
+ if (screensMedias !== null) {
2239
+ screensMedias.current = screensMediasRef.current;
2240
+ }
2241
+ /**
2242
+ * Screen Layout
2243
+ */
2003
2244
 
2004
- var _ref2 = viewerTheme || {},
2005
- textStyles = _ref2.textStyles;
2006
2245
 
2007
- var _ref3 = textStyles || {},
2008
- _ref3$title = _ref3.title,
2009
- themeTextStyle = _ref3$title === void 0 ? null : _ref3$title;
2246
+ var _ref5 = viewerTheme || {},
2247
+ textStyles = _ref5.textStyles;
2010
2248
 
2011
- var _ref4 = themeTextStyle || {},
2012
- _ref4$fontFamily = _ref4.fontFamily,
2013
- themeFont = _ref4$fontFamily === void 0 ? null : _ref4$fontFamily; // Fonts
2249
+ var _ref6 = textStyles || {},
2250
+ _ref6$title = _ref6.title,
2251
+ themeTextStyle = _ref6$title === void 0 ? null : _ref6$title;
2252
+
2253
+ var _ref7 = themeTextStyle || {},
2254
+ _ref7$fontFamily = _ref7.fontFamily,
2255
+ themeFont = _ref7$fontFamily === void 0 ? null : _ref7$fontFamily; // Fonts
2014
2256
 
2015
2257
 
2016
2258
  var finalFonts = useMemo(function () {
@@ -2037,8 +2279,12 @@ var Viewer = function Viewer(_ref) {
2037
2279
  _usePlaybackContext$m = _usePlaybackContext.media,
2038
2280
  playbackMedia = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m;
2039
2281
 
2040
- var trackScreenView = useTrackScreenView();
2041
- var contentRef = useRef(null); // Get screen size
2282
+ var _useDimensionObserver = useDimensionObserver(),
2283
+ playbackControlsContainerRef = _useDimensionObserver.ref,
2284
+ _useDimensionObserver2 = _useDimensionObserver.height,
2285
+ playbackControlsContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
2286
+
2287
+ var trackScreenView = useTrackScreenView(); // Get screen size
2042
2288
 
2043
2289
  var _useScreenSizeFromEle = useScreenSizeFromElement(_objectSpread({
2044
2290
  width: width,
@@ -2049,21 +2295,26 @@ var Viewer = function Viewer(_ref) {
2049
2295
  screenSize = _useScreenSizeFromEle.screenSize,
2050
2296
  screenScale = _useScreenSizeFromEle.scale;
2051
2297
 
2052
- var _ref5 = screenSize || {},
2053
- _ref5$width = _ref5.width,
2054
- screenWidth = _ref5$width === void 0 ? null : _ref5$width,
2055
- _ref5$height = _ref5.height,
2056
- screenHeight = _ref5$height === void 0 ? null : _ref5$height,
2057
- _ref5$landscape = _ref5.landscape,
2058
- landscape = _ref5$landscape === void 0 ? false : _ref5$landscape,
2059
- _ref5$menuOverScreen = _ref5.menuOverScreen,
2060
- menuOverScreen = _ref5$menuOverScreen === void 0 ? false : _ref5$menuOverScreen;
2298
+ var _ref8 = screenSize || {},
2299
+ _ref8$width = _ref8.width,
2300
+ screenWidth = _ref8$width === void 0 ? null : _ref8$width,
2301
+ _ref8$height = _ref8.height,
2302
+ screenHeight = _ref8$height === void 0 ? null : _ref8$height,
2303
+ _ref8$landscape = _ref8.landscape,
2304
+ landscape = _ref8$landscape === void 0 ? false : _ref8$landscape,
2305
+ _ref8$menuOverScreen = _ref8.menuOverScreen,
2306
+ menuOverScreen = _ref8$menuOverScreen === void 0 ? false : _ref8$menuOverScreen;
2061
2307
 
2062
2308
  var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
2063
2309
  var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
2064
2310
  var hasSize = screenWidth > 0 && screenHeight > 0;
2065
- var ready = hasSize; // && fontsLoaded;
2066
-
2311
+ var ready = hasSize;
2312
+ var trackingEnabled = isView;
2313
+ useEffect(function () {
2314
+ if (trackingEnabled && currentScreen !== null) {
2315
+ trackScreenView(currentScreen, screenIndex);
2316
+ }
2317
+ }, [currentScreen, trackScreenView, trackingEnabled]);
2067
2318
  useEffect(function () {
2068
2319
  if (ready && onViewModeChange !== null) {
2069
2320
  onViewModeChange({
@@ -2072,21 +2323,14 @@ var Viewer = function Viewer(_ref) {
2072
2323
  });
2073
2324
  }
2074
2325
  }, [ready, landscape, menuOverScreen, onViewModeChange]);
2075
- var screensMediasRef = useRef([]); // Screen index
2076
-
2077
- var screenIndex = useMemo(function () {
2078
- return Math.max(0, screens.findIndex(function (it) {
2079
- return "".concat(it.id) === "".concat(screenId);
2080
- }));
2081
- }, [screenId, screens]);
2082
-
2083
- if (currentScreenMedia !== null) {
2084
- currentScreenMedia.current = screensMediasRef.current[screenIndex] || null;
2085
- }
2326
+ /**
2327
+ * Screen Transitions
2328
+ */
2086
2329
 
2087
- if (screensMedias !== null) {
2088
- screensMedias.current = screensMediasRef.current;
2089
- }
2330
+ var transitionType = landscape && withNeighborScreens ? DEFAULT_TRANSITION_TYPE_LANDSCAPE : DEFAULT_TRANSITION_TYPE_PORTRAIT;
2331
+ /**
2332
+ * Screen Navigation
2333
+ */
2090
2334
 
2091
2335
  var changeIndex = useCallback(function (index) {
2092
2336
  if (index === screenIndex) {
@@ -2100,23 +2344,37 @@ var Viewer = function Viewer(_ref) {
2100
2344
  if (onScreenChange !== null) {
2101
2345
  onScreenChange(screens[index], index);
2102
2346
  }
2103
- }, [screenIndex, screens, onScreenChange]); // Track screen view
2347
+ }, [screenIndex, screens, onScreenChange]);
2348
+ var onScreenNavigate = useCallback(function (_ref9) {
2349
+ var index = _ref9.index,
2350
+ newIndex = _ref9.newIndex,
2351
+ end = _ref9.end,
2352
+ direction = _ref9.direction;
2104
2353
 
2105
- var trackingEnabled = isView;
2106
- var currentScreen = screens[screenIndex] || null;
2107
- useEffect(function () {
2108
- if (trackingEnabled && currentScreen !== null) {
2109
- trackScreenView(currentScreen, screenIndex);
2354
+ if (end && onEnd !== null) {
2355
+ onEnd();
2110
2356
  }
2111
- }, [currentScreen, trackScreenView, trackingEnabled]); // Handle interaction enable
2112
2357
 
2358
+ changeIndex(newIndex);
2359
+ eventsManager.emit('navigate', {
2360
+ index: index,
2361
+ newIndex: newIndex,
2362
+ direction: direction,
2363
+ end: end
2364
+ });
2365
+
2366
+ if (end) {
2367
+ eventsManager.emit('navigate_end');
2368
+ } else {
2369
+ eventsManager.emit("navigate_".concat(direction), newIndex);
2370
+ }
2371
+ }, [onEnd, changeIndex]);
2113
2372
  var gotoPreviousScreen = useCallback(function () {
2114
2373
  changeIndex(Math.max(0, screenIndex - 1));
2115
- }, [changeIndex]);
2374
+ }, [changeIndex, screenIndex]);
2116
2375
  var gotoNextScreen = useCallback(function () {
2117
2376
  changeIndex(Math.min(screens.length - 1, screenIndex + 1));
2118
- }, [changeIndex]);
2119
- var screensCount = screens.length;
2377
+ }, [changeIndex, screenIndex]);
2120
2378
 
2121
2379
  var _useState = useState(false),
2122
2380
  _useState2 = _slicedToArray(_useState, 2),
@@ -2132,37 +2390,12 @@ var Viewer = function Viewer(_ref) {
2132
2390
  setHasInteracted(true);
2133
2391
  }
2134
2392
  }, [onInteraction, hasInteracted, setHasInteracted]);
2135
- var onScreenNavigate = useCallback(function (_ref6) {
2136
- var index = _ref6.index,
2137
- newIndex = _ref6.newIndex,
2138
- end = _ref6.end,
2139
- direction = _ref6.direction;
2140
-
2141
- if (end && onEnd !== null) {
2142
- onEnd();
2143
- }
2144
-
2145
- changeIndex(newIndex);
2146
- eventsManager.emit('navigate', {
2147
- newIndex: newIndex,
2148
- index: index,
2149
- direction: direction,
2150
- end: end
2151
- });
2152
-
2153
- if (end) {
2154
- eventsManager.emit('navigate_end');
2155
- } else {
2156
- eventsManager.emit("navigate_".concat(direction), newIndex);
2157
- }
2158
- }, [onEnd, changeIndex]);
2159
2393
 
2160
2394
  var _useScreenInteraction = useScreenInteraction({
2161
2395
  screens: screens,
2162
2396
  screenIndex: screenIndex,
2163
2397
  screenWidth: screenContainerWidth,
2164
2398
  disableCurrentScreenNavigation: !isView,
2165
- clickOnSiblings: landscape && withLandscapeSiblingsScreens,
2166
2399
  nextScreenWidthPercent: tapNextScreenWidthPercent,
2167
2400
  onInteract: onInteractionPrivate,
2168
2401
  onNavigate: onScreenNavigate
@@ -2170,102 +2403,127 @@ var Viewer = function Viewer(_ref) {
2170
2403
  interactWithScreen = _useScreenInteraction.interact,
2171
2404
  currentScreenInteractionEnabled = _useScreenInteraction.currentScreenInteractionEnabled,
2172
2405
  enableInteraction = _useScreenInteraction.enableInteraction,
2173
- disableInteraction = _useScreenInteraction.disableInteraction; // Handle tap on screens
2174
-
2175
-
2176
- var onDragScreen = useCallback(function (_ref7) {
2177
- var _ref7$args = _slicedToArray(_ref7.args, 1),
2178
- tapScreenIndex = _ref7$args[0],
2179
- event = _ref7.event,
2180
- target = _ref7.target,
2181
- currentTarget = _ref7.currentTarget,
2182
- tap = _ref7.tap,
2183
- _ref7$xy = _slicedToArray(_ref7.xy, 2),
2184
- x = _ref7$xy[0],
2185
- y = _ref7$xy[1];
2186
-
2187
- if (tap) {
2188
- interactWithScreen({
2189
- event: event,
2190
- target: target,
2191
- currentTarget: currentTarget,
2192
- index: tapScreenIndex,
2193
- x: x,
2194
- y: y
2195
- });
2196
- }
2197
- }, [interactWithScreen]);
2198
- var dragScreenBind = useDrag(onDragScreen, {
2199
- filterTaps: true
2200
- }); // Handles tap when landscape (space around current screen)
2201
-
2202
- var onDragContent = useCallback(function (_ref8) {
2203
- var tap = _ref8.tap,
2204
- target = _ref8.target,
2205
- currentTarget = _ref8.currentTarget,
2206
- _ref8$xy = _slicedToArray(_ref8.xy, 1),
2207
- x = _ref8$xy[0];
2208
-
2209
- if (!landscape || withLandscapeSiblingsScreens || target !== contentRef.current) {
2210
- return;
2406
+ disableInteraction = _useScreenInteraction.disableInteraction;
2407
+
2408
+ var onTap = useCallback(function (_ref10) {
2409
+ var currentTarget = _ref10.currentTarget,
2410
+ event = _ref10.event,
2411
+ target = _ref10.target,
2412
+ _ref10$xy = _slicedToArray(_ref10.xy, 2),
2413
+ x = _ref10$xy[0],
2414
+ y = _ref10$xy[1];
2415
+
2416
+ interactWithScreen({
2417
+ event: event,
2418
+ target: target,
2419
+ currentTarget: currentTarget,
2420
+ index: screenIndex,
2421
+ x: x,
2422
+ y: y
2423
+ });
2424
+ }, [interactWithScreen, screenIndex]);
2425
+ var computeScreenProgress = useCallback(function (_ref11) {
2426
+ var active = _ref11.active,
2427
+ _ref11$movement = _slicedToArray(_ref11.movement, 1),
2428
+ mx = _ref11$movement[0],
2429
+ _ref11$velocity = _slicedToArray(_ref11.velocity, 1),
2430
+ vx = _ref11$velocity[0];
2431
+
2432
+ var p = mx / screenContainerWidth; // drag "ratio": how much of the screen width has been swiped?
2433
+
2434
+ var forwards = mx < 0; // true if swiping to left (to navigate forwards)
2435
+
2436
+ var newIndex = !forwards ? screenIndex - 1 : screenIndex + 1; // which item index are we moving towards?
2437
+
2438
+ var reachedThreshold = vx > DRAG_VELOCITY_ACTIVATION_THRESHOLD || Math.abs(p) > DRAG_PROGRESS_ACTIVATION_THRESHOLD;
2439
+ var reachedBounds = newIndex < 0 || newIndex >= screensCount; // have we reached the end of the stack?
2440
+
2441
+ var damper = reachedBounds ? 0.1 : 1;
2442
+ var progress = Math.max(-1, Math.min(1, p * damper));
2443
+
2444
+ if (!active) {
2445
+ return reachedThreshold && !reachedBounds ? newIndex : screenIndex;
2211
2446
  }
2212
2447
 
2213
- if (tap) {
2214
- var _currentTarget$getBou = currentTarget.getBoundingClientRect(),
2215
- _currentTarget$getBou2 = _currentTarget$getBou.left,
2216
- contentX = _currentTarget$getBou2 === void 0 ? 0 : _currentTarget$getBou2,
2217
- _currentTarget$getBou3 = _currentTarget$getBou.width,
2218
- contentWidth = _currentTarget$getBou3 === void 0 ? 0 : _currentTarget$getBou3;
2448
+ return screenIndex - progress;
2449
+ }, [screenContainerWidth, screenIndex]);
2450
+ var onScreenProgress = useCallback(function (progress, _ref12) {
2451
+ var active = _ref12.active;
2452
+ var delta = Math.abs(progress - screenIndex);
2453
+ var reachedBounds = progress < 0 || progress >= screensCount; // have we reached the end of the stack?
2219
2454
 
2220
- var hasTappedLeft = x - contentX < contentWidth * 0.5;
2221
- var nextIndex = hasTappedLeft ? Math.max(0, screenIndex - 1) : Math.min(screensCount - 1, screenIndex + 1);
2455
+ if (!active && delta === 1 && !reachedBounds) {
2222
2456
  onScreenNavigate({
2223
2457
  index: screenIndex,
2224
- newIndex: nextIndex
2458
+ newIndex: progress
2225
2459
  });
2226
2460
  }
2227
- }, [screenIndex, screensCount, landscape, withLandscapeSiblingsScreens]);
2228
- var dragContentBind = useDrag(onDragContent, {
2229
- filterTaps: true
2230
- });
2231
- var onScreenKeyUp = useCallback(function (_ref9, i) {
2232
- var key = _ref9.key;
2461
+ }, [onScreenNavigate, screenIndex]);
2462
+ var springParams = useMemo(function () {
2463
+ return {
2464
+ config: SPRING_CONFIG_TIGHT
2465
+ };
2466
+ }, []);
2467
+
2468
+ var _useDragProgress = useDragProgress({
2469
+ progress: screenIndex,
2470
+ disabled: !isView,
2471
+ dragDisabled: withoutGestures,
2472
+ computeProgress: computeScreenProgress,
2473
+ onProgress: onScreenProgress,
2474
+ onTap: onTap,
2475
+ springParams: springParams
2476
+ }),
2477
+ isDragging = _useDragProgress.dragging,
2478
+ screenIndexProgress = _useDragProgress.progress,
2479
+ dragContentBind = _useDragProgress.bind;
2480
+
2481
+ var getScreenStylesByIndex = function getScreenStylesByIndex(index, progress) {
2482
+ if (transitionType === 'stack') {
2483
+ var _t = index - progress;
2484
+
2485
+ var _clamped = Math.min(1, Math.max(0, _t));
2233
2486
 
2234
- if (key === 'Enter' && withLandscapeSiblingsScreens && landscape && i !== screenIndex) {
2235
- changeIndex(i);
2487
+ var invert = Math.min(1, Math.max(0, -_t));
2488
+ var opacity = Math.max(0, 1 - 0.75 * invert + (_t + 1));
2489
+ return {
2490
+ opacity: opacity,
2491
+ transform: "translateX(".concat(_clamped * 100, "%) scale(").concat(1 - 0.2 * invert, ")"),
2492
+ boxShadow: "0 0 ".concat(4 * (1 - _clamped), "rem ").concat(-0.5 * (1 - _clamped), "rem black"),
2493
+ zIndex: index
2494
+ };
2236
2495
  }
2237
- }, [withLandscapeSiblingsScreens, changeIndex, landscape, screenIndex]); // swipe menu open
2238
2496
 
2239
- var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
2497
+ var t = index - progress;
2498
+ var clamped = Math.min(1, Math.max(0, Math.abs(t)));
2499
+ return {
2500
+ opacity: 1 - 0.75 * clamped,
2501
+ transform: "translateX(".concat(t * 105, "%) scale(").concat(1 - 0.2 * clamped, ")"),
2502
+ zIndex: screensCount - index
2503
+ };
2504
+ };
2240
2505
 
2241
- var _useState3 = useState(false),
2242
- _useState4 = _slicedToArray(_useState3, 2),
2243
- menuOpened = _useState4[0],
2244
- setMenuOpened = _useState4[1];
2245
-
2246
- var onMenuRequestOpen = useCallback(function () {
2247
- return setMenuOpened(true);
2248
- }, [setMenuOpened]);
2249
- var onMenuRequestClose = useCallback(function () {
2250
- return setMenuOpened(false);
2251
- }, [setMenuOpened]);
2252
- var onClickMenu = useCallback(function () {
2253
- onInteractionPrivate();
2254
- setMenuOpened(true);
2255
- }, [changeIndex, onInteractionPrivate, setMenuOpened]);
2256
- var onClickMenuItem = useCallback(function (_ref10) {
2257
- var itemScreenId = _ref10.screenId;
2506
+ var _useFullscreen = useFullscreen(containerRef.current || null),
2507
+ toggleFullscreen = _useFullscreen.toggle,
2508
+ fullscreenActive = _useFullscreen.active,
2509
+ fullscreenEnabled = _useFullscreen.enabled;
2510
+
2511
+ var menuVisible = screensCount === 0 || currentScreenInteractionEnabled; // Get element height
2512
+
2513
+ var _useDimensionObserver3 = useDimensionObserver(),
2514
+ menuDotsContainerRef = _useDimensionObserver3.ref,
2515
+ _useDimensionObserver4 = _useDimensionObserver3.height,
2516
+ menuDotsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
2517
+
2518
+ var onClickScreen = useCallback(function (_ref13) {
2519
+ var itemScreenId = _ref13.screenId;
2258
2520
  onInteractionPrivate();
2259
- var index = screens.findIndex(function (_ref11) {
2260
- var id = _ref11.id;
2521
+ var index = screens.findIndex(function (_ref14) {
2522
+ var id = _ref14.id;
2261
2523
  return id === itemScreenId;
2262
2524
  });
2263
2525
  changeIndex(index);
2264
-
2265
- if (menuOpened) {
2266
- setMenuOpened(false);
2267
- }
2268
- }, [onInteractionPrivate, changeIndex, menuOpened, setMenuOpened]);
2526
+ }, [onInteractionPrivate, changeIndex]);
2269
2527
  var onContextMenu = useCallback(function (e) {
2270
2528
  if (!landscape) {
2271
2529
  e.preventDefault();
@@ -2273,28 +2531,16 @@ var Viewer = function Viewer(_ref) {
2273
2531
  }
2274
2532
 
2275
2533
  return true;
2276
- }, [landscape]);
2534
+ }, [landscape]); // hmm?
2535
+
2277
2536
  var overscrollStyle = /*#__PURE__*/React.createElement("style", {
2278
2537
  type: "text/css"
2279
- }, "body { overscroll-behavior: contain; }"); // Fullscreen
2280
-
2281
- var _useFullscreen = useFullscreen(containerRef.current || null),
2282
- toggleFullscreen = _useFullscreen.toggle,
2283
- fullscreenActive = _useFullscreen.active,
2284
- fullscreenEnabled = _useFullscreen.enabled; // Keyboard Events
2285
-
2286
-
2538
+ }, "body { overscroll-behavior: contain; }");
2287
2539
  var keyboardShortcuts = useMemo(function () {
2288
2540
  return {
2289
2541
  f: function f() {
2290
2542
  return toggleFullscreen();
2291
2543
  },
2292
- m: function m() {
2293
- return setMenuOpened(!menuOpened);
2294
- },
2295
- escape: function escape() {
2296
- return setMenuOpened(false);
2297
- },
2298
2544
  arrowleft: function arrowleft() {
2299
2545
  return gotoPreviousScreen();
2300
2546
  },
@@ -2305,55 +2551,10 @@ var Viewer = function Viewer(_ref) {
2305
2551
  return gotoNextScreen();
2306
2552
  }
2307
2553
  };
2308
- }, [menuOpened, setMenuOpened, gotoPreviousScreen, gotoNextScreen]);
2554
+ }, [gotoPreviousScreen, gotoNextScreen]);
2309
2555
  useKeyboardShortcuts(keyboardShortcuts, {
2310
2556
  disabled: renderContext !== 'view'
2311
2557
  });
2312
-
2313
- var _ref12 = currentScreen || {},
2314
- screenParameters = _ref12.parameters;
2315
-
2316
- var _ref13 = screenParameters || {},
2317
- screenMetadata = _ref13.metadata;
2318
-
2319
- var _ref14 = screenMetadata || {},
2320
- _ref14$title = _ref14.title,
2321
- screenTitle = _ref14$title === void 0 ? null : _ref14$title,
2322
- _ref14$description = _ref14.description,
2323
- screenDescription = _ref14$description === void 0 ? null : _ref14$description;
2324
-
2325
- var finalTitle = screenTitle !== null ? screenTitle : title;
2326
- var finalMetadata = useMemo(function () {
2327
- return screenDescription !== null ? _objectSpread(_objectSpread({}, metadata), {}, {
2328
- description: screenDescription
2329
- }) : metadata;
2330
- }, [metadata, screenDescription]); // Get element height
2331
-
2332
- var _useDimensionObserver = useDimensionObserver(),
2333
- menuDotsContainerRef = _useDimensionObserver.ref,
2334
- _useDimensionObserver2 = _useDimensionObserver.height,
2335
- menuDotsContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
2336
-
2337
- var _useDimensionObserver3 = useDimensionObserver(),
2338
- playbackControlsContainerRef = _useDimensionObserver3.ref,
2339
- _useDimensionObserver4 = _useDimensionObserver3.height,
2340
- playbackControlsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
2341
-
2342
- var _useMemo = useMemo(function () {
2343
- return neighborScreensMounted !== null ? {
2344
- startIndex: Math.max(screenIndex - (neighborScreensActive + neighborScreensMounted), 0),
2345
- endIndex: Math.min(screenIndex + (neighborScreensActive + neighborScreensMounted), screensCount)
2346
- } : {
2347
- startIndex: 0,
2348
- endIndex: screensCount - 1
2349
- };
2350
- }, [screenIndex, neighborScreensActive, neighborScreensMounted, screensCount]),
2351
- mountedScreenStartIndex = _useMemo.startIndex,
2352
- mountedScreenEndIndex = _useMemo.endIndex;
2353
-
2354
- var mountedScreens = useMemo(function () {
2355
- return neighborScreensMounted != null ? screens.slice(mountedScreenStartIndex, mountedScreenEndIndex) : screens;
2356
- }, [screens, mountedScreenStartIndex, mountedScreenEndIndex, neighborScreensActive, neighborScreensMounted]);
2357
2558
  return /*#__PURE__*/React.createElement(VisitorProvider, {
2358
2559
  visitor: visitor
2359
2560
  }, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
@@ -2378,13 +2579,12 @@ var Viewer = function Viewer(_ref) {
2378
2579
  }), /*#__PURE__*/React.createElement("div", {
2379
2580
  className: classNames([styles$6.container, screenSize.screens.map(function (screenName) {
2380
2581
  return "story-screen-".concat(screenName);
2381
- }), (_ref15 = {}, _defineProperty(_ref15, styles$6.landscape, landscape), _defineProperty(_ref15, styles$6.withSiblings, withLandscapeSiblingsScreens), _defineProperty(_ref15, styles$6.hideMenu, !menuVisible), _defineProperty(_ref15, styles$6.ready, ready || withoutScreensTransforms), _defineProperty(_ref15, styles$6.hasInteracted, hasInteracted), _defineProperty(_ref15, className, className), _ref15)]),
2582
+ }), (_ref15 = {}, _defineProperty(_ref15, styles$6.landscape, landscape), _defineProperty(_ref15, styles$6.withoutGestures, withoutGestures), _defineProperty(_ref15, styles$6.hideMenu, !menuVisible), _defineProperty(_ref15, styles$6.fadeMenu, playing && playbackControls && !playbackcontrolsVisible), _defineProperty(_ref15, styles$6.ready, ready || withoutScreensTransforms), _defineProperty(_ref15, styles$6.hasInteracted, hasInteracted), _defineProperty(_ref15, styles$6.isDragging, isDragging), _defineProperty(_ref15, className, className), _ref15)]),
2382
2583
  ref: containerRef,
2383
2584
  onContextMenu: onContextMenu
2384
2585
  }, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu, {
2385
2586
  story: parsedStory,
2386
2587
  currentScreenIndex: screenIndex,
2387
- opened: menuOpened,
2388
2588
  withShadow: menuOverScreen && !withoutMenuShadow,
2389
2589
  toggleFullscreen: toggleFullscreen,
2390
2590
  fullscreenActive: fullscreenActive,
@@ -2394,93 +2594,64 @@ var Viewer = function Viewer(_ref) {
2394
2594
  screenSize: screenSize,
2395
2595
  menuWidth: menuIsScreenWidth ? screenContainerWidth : null,
2396
2596
  trackingEnabled: trackingEnabled,
2397
- onClickItem: onClickMenuItem,
2398
- onClickMenu: onClickMenu,
2597
+ onClickScreen: onClickScreen,
2399
2598
  onClickCloseViewer: onCloseViewer,
2400
- onRequestOpen: onMenuRequestOpen,
2401
- onRequestClose: onMenuRequestClose,
2402
2599
  withDotItemClick: screenContainerWidth > 400,
2403
2600
  withoutScreensMenu: withoutScreensMenu,
2601
+ withoutShareMenu: withoutShareMenu,
2404
2602
  refDots: menuDotsContainerRef
2405
2603
  }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", Object.assign({
2406
- ref: contentRef,
2407
2604
  className: styles$6.content
2408
- }, dragContentBind()), mountedScreens.map(function (mountedScreen, mountedIndex) {
2409
- var _ref16;
2410
-
2411
- var i = mountedScreenStartIndex + mountedIndex;
2412
- var current = i === parseInt(screenIndex, 10);
2413
- var active = i >= screenIndex - neighborScreensActive && i <= screenIndex + neighborScreensActive;
2414
- var screenTransform = null;
2415
-
2416
- if (landscape) {
2417
- screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenContainerWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
2418
- } else {
2419
- screenTransform = "translateX(".concat(current ? 0 : '100%', ")");
2605
+ }, dragContentBind()), !withoutNavigationArrow && !withNeighborScreens && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
2606
+ direction: "previous",
2607
+ className: classNames([styles$6.navButton, styles$6.previous]),
2608
+ onClick: gotoPreviousScreen
2609
+ }) : null, /*#__PURE__*/React.createElement("div", {
2610
+ className: styles$6.screensFrame,
2611
+ style: {
2612
+ width: screenContainerWidth,
2613
+ height: screenContainerHeight,
2614
+ overflow: !withNeighborScreens ? 'hidden' : null
2420
2615
  }
2616
+ }, screens.map(function (screen, i) {
2617
+ // const current = i === parseInt(screenIndex, 10);
2618
+ var current = i === Math.round(screenIndexProgress); // base current on transition
2421
2619
 
2422
- return /*#__PURE__*/React.createElement(React.Fragment, {
2423
- key: "screen-viewer-".concat(mountedScreen.id || '', "-").concat(i + 1)
2424
- }, /*#__PURE__*/React.createElement("div", Object.assign({
2425
- style: {
2426
- width: screenContainerWidth,
2427
- height: screenContainerHeight,
2428
- transform: !withoutScreensTransforms ? screenTransform : null
2429
- },
2430
- className: classNames([styles$6.screenContainer, (_ref16 = {}, _defineProperty(_ref16, styles$6.current, current), _defineProperty(_ref16, styles$6.visible, current || withLandscapeSiblingsScreens), _ref16)]) // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
2431
- ,
2432
- tabIndex: !active ? -1 : null,
2433
- "aria-hidden": !current,
2434
- "aria-label": intl.formatMessage({
2435
- id: "LkVfwW",
2436
- defaultMessage: [{
2437
- "type": 0,
2438
- "value": "Screen "
2439
- }, {
2440
- "type": 1,
2441
- "value": "index"
2442
- }]
2443
- }, {
2444
- index: i + 1
2445
- }),
2446
- onKeyUp: function onKeyUp(e) {
2447
- return onScreenKeyUp(e, i);
2448
- }
2449
- }, dragScreenBind(i)), current && screenIndex > 0 ? /*#__PURE__*/React.createElement(NavigationButton, {
2450
- direction: "previous",
2451
- className: classNames([styles$6.navButton, styles$6.previous]),
2452
- onClick: gotoPreviousScreen
2453
- }) : null, mountedScreen !== null ? /*#__PURE__*/React.createElement(ViewerScreen, {
2620
+ var active = i >= screenIndex - neighborScreensActive && i <= screenIndex + neighborScreensActive;
2621
+ var defaultStyles = {
2622
+ opacity: current ? 1 : 0
2623
+ };
2624
+ var screenStyles = active ? getScreenStylesByIndex(i, screenIndexProgress) : defaultStyles;
2625
+ return /*#__PURE__*/React.createElement("div", {
2626
+ key: "screen-viewer-".concat(screen.id || '', "-").concat(i + 1),
2627
+ style: screenStyles,
2628
+ className: classNames([styles$6.screenContainer, _defineProperty({}, styles$6.current, current)])
2629
+ }, screen !== null && active ? /*#__PURE__*/React.createElement(ViewerScreen, {
2454
2630
  className: styles$6.screen,
2455
- screen: mountedScreen,
2631
+ screen: screen,
2456
2632
  screenState: current ? screenState : null,
2457
- renderContext: renderContext,
2458
2633
  index: i,
2459
2634
  current: current,
2460
2635
  active: active,
2461
2636
  mediaRef: function mediaRef(ref) {
2462
2637
  screensMediasRef.current[i] = ref;
2463
2638
  },
2639
+ renderContext: renderContext,
2464
2640
  width: screenWidth,
2465
2641
  height: screenHeight,
2466
2642
  scale: screenScale,
2467
- withNavigationHint: withNavigationHint && !withLandscapeSiblingsScreens && current && screenIndex === 0 && !hasInteracted
2468
- }) : null, current && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
2469
- direction: "next",
2470
- className: classNames([styles$6.navButton, styles$6.next]),
2471
- onClick: gotoNextScreen
2472
- }) : null));
2473
- }), !withoutPlaybackControls ? /*#__PURE__*/React.createElement("div", {
2643
+ withNavigationHint: withNavigationHint && !withNeighborScreens && current && screenIndex === 0 && !hasInteracted
2644
+ }) : null);
2645
+ })), !withoutNavigationArrow && !withNeighborScreens && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
2646
+ direction: "next",
2647
+ className: classNames([styles$6.navButton, styles$6.next]),
2648
+ onClick: gotoNextScreen
2649
+ }) : null, !withoutPlaybackControls ? /*#__PURE__*/React.createElement("div", {
2474
2650
  className: styles$6.playbackControls,
2475
2651
  ref: playbackControlsContainerRef
2476
- }, /*#__PURE__*/React.createElement("div", {
2477
- className: styles$6.playbackControlsContainer,
2478
- style: {
2479
- width: screenContainerWidth
2480
- }
2481
2652
  }, /*#__PURE__*/React.createElement(PlaybackControls, {
2482
2653
  className: styles$6.controls
2483
- }))) : null) : null, /*#__PURE__*/React.createElement(WebViewContainer, {
2654
+ })) : null) : null, /*#__PURE__*/React.createElement(WebViewContainer, {
2484
2655
  className: styles$6.webView,
2485
2656
  style: {
2486
2657
  maxWidth: Math.max(screenContainerWidth, 600)