@micromag/viewer 0.3.178 → 0.3.182

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 +17 -13
  2. package/es/index.js +1638 -1202
  3. package/lib/index.js +1654 -1218
  4. package/package.json +10 -10
package/es/index.js CHANGED
@@ -1,9 +1,9 @@
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
- import { BrowserRouter } from 'react-router-dom';
6
+ import { Link, BrowserRouter } from 'react-router-dom';
7
7
  import { PropTypes as PropTypes$1 } from '@micromag/core';
8
8
  import { usePlaybackContext, useViewerWebView, useViewerInteraction, VisitorProvider, ScreenSizeProvider, ViewerProvider, useRoutes, useRoutePush, GoogleKeysProvider, GoogleMapsClientProvider, FieldsProvider, ComponentsProvider, SCREENS_NAMESPACE, UserInteractionProvider, PlaybackProvider, TrackingProvider, RoutesProvider } from '@micromag/core/contexts';
9
9
  import fieldsManager from '@micromag/fields/manager';
@@ -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 { Label, ScreenPreview, Screen, Button as Button$1, Meta, FontFaces } from '@micromag/core/components';
19
+ import { useDimensionObserver, useTrackEvent, useDragProgress, useMediaProgress, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
20
+ import { getStyleFromColor, easings, 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,11 +214,393 @@ 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 styles$g = {"container":"micromag-viewer-buttons-button-container","asLink":"micromag-viewer-buttons-button-asLink","icon":"micromag-viewer-buttons-button-icon","label":"micromag-viewer-buttons-button-label","withIcon":"micromag-viewer-buttons-button-withIcon","right":"micromag-viewer-buttons-button-right","icon-right":"micromag-viewer-buttons-button-icon-right","withIconColumns":"micromag-viewer-buttons-button-withIconColumns","linkDisabled":"micromag-viewer-buttons-button-linkDisabled"};
218
+
219
+ var _excluded$8 = ["type", "theme", "size", "href", "external", "direct", "target", "label", "children", "focusable", "active", "icon", "iconPosition", "disabled", "loading", "disableOnLoading", "withoutTheme", "asLink", "onClick", "className", "iconClassName", "labelClassName", "refButton"];
220
+ var propTypes$n = {
221
+ type: PropTypes.string,
222
+ theme: PropTypes$1.buttonTheme,
223
+ size: PropTypes$1.buttonSize,
224
+ href: PropTypes.string,
225
+ external: PropTypes.bool,
226
+ direct: PropTypes.bool,
227
+ target: PropTypes.string,
228
+ label: PropTypes$1.label,
229
+ children: PropTypes$1.label,
230
+ focusable: PropTypes.bool,
231
+ active: PropTypes.bool,
232
+ icon: PropTypes.node,
233
+ iconPosition: PropTypes.oneOf(['left', 'right', 'inline']),
234
+ disabled: PropTypes.bool,
235
+ loading: PropTypes.bool,
236
+ disableOnLoading: PropTypes.bool,
237
+ withoutTheme: PropTypes.bool,
238
+ asLink: PropTypes.bool,
239
+ className: PropTypes.string,
240
+ iconClassName: PropTypes.string,
241
+ labelClassName: PropTypes.string,
242
+ onClick: PropTypes.func,
243
+ refButton: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
244
+ current: PropTypes.any // eslint-disable-line
245
+
246
+ })])
247
+ };
248
+ var defaultProps$n = {
249
+ type: 'button',
250
+ theme: null,
251
+ size: null,
252
+ href: null,
253
+ external: false,
254
+ direct: false,
255
+ target: '_blank',
256
+ label: null,
257
+ children: null,
258
+ focusable: true,
259
+ active: false,
260
+ icon: null,
261
+ iconPosition: 'inline',
262
+ disabled: false,
263
+ loading: false,
264
+ disableOnLoading: true,
265
+ withoutTheme: false,
266
+ asLink: false,
267
+ className: null,
268
+ iconClassName: null,
269
+ labelClassName: null,
270
+ onClick: null,
271
+ refButton: null
272
+ };
273
+
274
+ var Button = function Button(_ref) {
275
+ var _ref2;
276
+
277
+ var type = _ref.type,
278
+ theme = _ref.theme;
279
+ _ref.size;
280
+ var href = _ref.href,
281
+ external = _ref.external,
282
+ direct = _ref.direct,
283
+ target = _ref.target,
284
+ label = _ref.label,
285
+ children = _ref.children,
286
+ focusable = _ref.focusable;
287
+ _ref.active;
288
+ var icon = _ref.icon,
289
+ iconPosition = _ref.iconPosition,
290
+ disabled = _ref.disabled,
291
+ loading = _ref.loading,
292
+ disableOnLoading = _ref.disableOnLoading;
293
+ _ref.withoutTheme;
294
+ var asLink = _ref.asLink,
295
+ onClick = _ref.onClick,
296
+ className = _ref.className,
297
+ iconClassName = _ref.iconClassName,
298
+ labelClassName = _ref.labelClassName,
299
+ refButton = _ref.refButton,
300
+ props = _objectWithoutProperties(_ref, _excluded$8);
301
+
302
+ var finalLabel = label || children;
303
+ var text = finalLabel !== null ? /*#__PURE__*/React.createElement(Label, null, finalLabel) : null;
304
+ var hasChildren = label !== null && children !== null;
305
+ var hasIcon = icon !== null;
306
+ var hasInlineIcon = hasIcon && (iconPosition === 'inline' || text === null);
307
+ var hasIconColumns = hasIcon && !hasInlineIcon;
308
+ var buttonClassNames = classNames([styles$g.container, styles$g["icon-".concat(iconPosition)], (_ref2 = {}, _defineProperty(_ref2, styles$g.withIcon, hasIcon), _defineProperty(_ref2, styles$g.withIconColumns, hasIconColumns), _defineProperty(_ref2, styles$g.withText, text !== null), _defineProperty(_ref2, styles$g.isLink, href !== null), _defineProperty(_ref2, styles$g.asLink, asLink), _defineProperty(_ref2, styles$g.isDisabled, disabled), _defineProperty(_ref2, styles$g.isLoading, loading), _defineProperty(_ref2, className, className !== null), _ref2)]);
309
+
310
+ var _ref3 = theme || {},
311
+ _ref3$colors = _ref3.colors,
312
+ colors = _ref3$colors === void 0 ? null : _ref3$colors;
313
+
314
+ var _ref4 = colors || {},
315
+ _ref4$primary = _ref4.primary,
316
+ brandPrimaryColor = _ref4$primary === void 0 ? null : _ref4$primary;
317
+
318
+ var primaryColor = getStyleFromColor(brandPrimaryColor, 'color');
319
+
320
+ var buttonStyles = _objectSpread({}, primaryColor);
321
+
322
+ var content = /*#__PURE__*/React.createElement(React.Fragment, null, hasInlineIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
323
+ className: classNames([styles$g.icon, _defineProperty({}, iconClassName, iconClassName !== null)])
324
+ }, icon), text !== null ? /*#__PURE__*/React.createElement("span", {
325
+ className: classNames([styles$g.label, _defineProperty({}, labelClassName, labelClassName !== null)])
326
+ }, text) : null) : null, hasIconColumns ? /*#__PURE__*/React.createElement(React.Fragment, null, iconPosition === 'left' ? /*#__PURE__*/React.createElement("span", {
327
+ className: classNames([styles$g.icon, styles$g.left, _defineProperty({}, iconClassName, iconClassName !== null && iconPosition === 'left')])
328
+ }, icon) : null, /*#__PURE__*/React.createElement("span", {
329
+ className: classNames([styles$g.center, styles$g.label, _defineProperty({}, labelClassName, labelClassName !== null)])
330
+ }, text), iconPosition === 'right' ? /*#__PURE__*/React.createElement("span", {
331
+ className: classNames([styles$g.icon, styles$g.right, _defineProperty({}, iconClassName, iconClassName !== null && iconPosition === 'right')])
332
+ }, icon) : null, hasChildren ? children : null) : null, !hasIcon ? text : null, hasChildren ? children : null);
333
+
334
+ if (href !== null) {
335
+ var linkClassNames = classNames([buttonClassNames, _defineProperty({
336
+ disabled: disabled
337
+ }, styles$g.linkDisabled, disabled)]);
338
+ return external || direct ? /*#__PURE__*/React.createElement("a", Object.assign({}, props, {
339
+ href: disabled ? null : href,
340
+ className: linkClassNames,
341
+ style: buttonStyles,
342
+ onClick: onClick,
343
+ target: external ? target : null,
344
+ ref: refButton,
345
+ tabIndex: focusable ? '' : '-1'
346
+ }), content) : /*#__PURE__*/React.createElement(Link, Object.assign({}, props, {
347
+ to: href,
348
+ className: linkClassNames,
349
+ style: buttonStyles,
350
+ onClick: onClick,
351
+ ref: refButton,
352
+ tabIndex: focusable ? '' : '-1'
353
+ }), content);
354
+ }
355
+
356
+ return /*#__PURE__*/React.createElement("button", Object.assign({}, props, {
357
+ type: type,
358
+ className: buttonClassNames,
359
+ style: buttonStyles,
360
+ onClick: onClick,
361
+ disabled: disabled || disableOnLoading && loading,
362
+ ref: refButton,
363
+ tabIndex: focusable ? '0' : '-1'
364
+ }), content);
365
+ };
366
+
367
+ Button.propTypes = propTypes$n;
368
+ Button.defaultProps = defaultProps$n;
369
+
370
+ var styles$f = {"container":"micromag-viewer-buttons-icon-button-container","icon":"micromag-viewer-buttons-icon-button-icon","label":"micromag-viewer-buttons-icon-button-label"};
371
+
372
+ var _excluded$7 = ["className"];
373
+ var propTypes$m = {
374
+ className: PropTypes.string
375
+ };
376
+ var defaultProps$m = {
377
+ className: null
378
+ };
379
+
380
+ var IconButton = function IconButton(_ref) {
381
+ var className = _ref.className,
382
+ props = _objectWithoutProperties(_ref, _excluded$7);
383
+
384
+ return /*#__PURE__*/React.createElement(Button, Object.assign({
385
+ className: classNames([styles$f.container, _defineProperty({}, className, className !== null)]),
386
+ labelClassName: styles$f.label,
387
+ iconClassName: styles$f.icon
388
+ }, props));
389
+ };
390
+
391
+ IconButton.propTypes = propTypes$m;
392
+ IconButton.defaultProps = defaultProps$m;
393
+
394
+ var _excluded$6 = ["className"];
395
+ var propTypes$l = {
396
+ className: PropTypes.string
397
+ };
398
+ var defaultProps$l = {
399
+ className: null
400
+ };
401
+
402
+ var CloseButton = function CloseButton(_ref) {
403
+ var className = _ref.className,
404
+ props = _objectWithoutProperties(_ref, _excluded$6);
405
+
406
+ var intl = useIntl();
407
+ return /*#__PURE__*/React.createElement(IconButton, Object.assign({
408
+ className: classNames([_defineProperty({}, className, className !== null)]),
409
+ label: intl.formatMessage({
410
+ id: "dj/p/q",
411
+ defaultMessage: [{
412
+ "type": 0,
413
+ "value": "Close"
414
+ }]
415
+ }),
416
+ icon: /*#__PURE__*/React.createElement("svg", {
417
+ xmlns: "http://www.w3.org/2000/svg",
418
+ width: "10",
419
+ height: "16",
420
+ viewBox: "0 0 10 16",
421
+ fill: "currentColor"
422
+ }, /*#__PURE__*/React.createElement("polygon", {
423
+ points: "9.95 4.11 8.89 3.05 5 6.94 1.11 3.05 0.05 4.11 3.94 8 0.05 11.89 1.11 12.95 5 9.06 8.89 12.95 9.95 11.89 6.06 8 9.95 4.11"
424
+ }))
425
+ }, props));
426
+ };
427
+
428
+ CloseButton.propTypes = propTypes$l;
429
+ CloseButton.defaultProps = defaultProps$l;
430
+
431
+ var _excluded$5 = ["className"];
432
+ var propTypes$k = {
433
+ className: PropTypes.string
434
+ };
435
+ var defaultProps$k = {
436
+ className: null
437
+ };
438
+
439
+ var MenuButton = function MenuButton(_ref) {
440
+ var className = _ref.className,
441
+ props = _objectWithoutProperties(_ref, _excluded$5);
442
+
443
+ var intl = useIntl();
444
+ return /*#__PURE__*/React.createElement(IconButton, Object.assign({
445
+ className: classNames([_defineProperty({}, className, className !== null)]),
446
+ label: intl.formatMessage({
447
+ id: "F/gl4b",
448
+ defaultMessage: [{
449
+ "type": 0,
450
+ "value": "Menu"
451
+ }]
452
+ }),
453
+ iconPosition: "right",
454
+ icon: /*#__PURE__*/React.createElement("svg", {
455
+ xmlns: "http://www.w3.org/2000/svg",
456
+ width: "10",
457
+ height: "16",
458
+ viewBox: "0 0 10 16",
459
+ fill: "currentColor"
460
+ }, /*#__PURE__*/React.createElement("rect", {
461
+ width: "10",
462
+ height: "16"
463
+ }))
464
+ }, props));
465
+ };
466
+
467
+ MenuButton.propTypes = propTypes$k;
468
+ MenuButton.defaultProps = defaultProps$k;
469
+
470
+ var _excluded$4 = ["className"];
471
+ var propTypes$j = {
472
+ className: PropTypes.string
473
+ };
474
+ var defaultProps$j = {
475
+ className: null
476
+ };
477
+
478
+ var ShareButton = function ShareButton(_ref) {
479
+ var className = _ref.className,
480
+ props = _objectWithoutProperties(_ref, _excluded$4);
481
+
482
+ var intl = useIntl();
483
+ return /*#__PURE__*/React.createElement(IconButton, Object.assign({
484
+ className: classNames([_defineProperty({}, className, className !== null)]),
485
+ label: intl.formatMessage({
486
+ id: "7tw6U2",
487
+ defaultMessage: [{
488
+ "type": 0,
489
+ "value": "Share"
490
+ }]
491
+ }),
492
+ iconPosition: "left",
493
+ icon: /*#__PURE__*/React.createElement("svg", {
494
+ xmlns: "http://www.w3.org/2000/svg",
495
+ width: "10",
496
+ height: "16",
497
+ viewBox: "0 0 10 16",
498
+ fill: "currentColor"
499
+ }, /*#__PURE__*/React.createElement("polygon", {
500
+ 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"
501
+ }), /*#__PURE__*/React.createElement("polygon", {
502
+ 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"
503
+ }))
504
+ }, props));
505
+ };
506
+
507
+ ShareButton.propTypes = propTypes$j;
508
+ ShareButton.defaultProps = defaultProps$j;
509
+
510
+ var styles$e = {"container":"micromag-viewer-buttons-toggle-button-container","normal":"micromag-viewer-buttons-toggle-button-normal","toggled":"micromag-viewer-buttons-toggle-button-toggled"};
226
511
 
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"};
512
+ var propTypes$i = {
513
+ className: PropTypes.string,
514
+ toggled: PropTypes.number,
515
+ button: PropTypes.node,
516
+ toggledButton: PropTypes.node,
517
+ toggledButtonClassName: PropTypes.string
518
+ };
519
+ var defaultProps$i = {
520
+ className: null,
521
+ toggled: 0,
522
+ button: null,
523
+ toggledButton: null,
524
+ toggledButtonClassName: null
525
+ };
526
+
527
+ var ToggleButton = function ToggleButton(_ref) {
528
+ var className = _ref.className,
529
+ toggled = _ref.toggled,
530
+ button = _ref.button,
531
+ toggledButton = _ref.toggledButton,
532
+ toggledButtonClassName = _ref.toggledButtonClassName;
533
+ if (button === null) return false;
534
+
535
+ var getToggleButtonStyles = function getToggleButtonStyles(t) {
536
+ return {
537
+ transform: "translateY(".concat(t * -100, "%)")
538
+ };
539
+ };
540
+
541
+ return /*#__PURE__*/React.createElement("div", {
542
+ className: classNames([styles$e.container, _defineProperty({}, className, className !== null)])
543
+ }, /*#__PURE__*/React.createElement("div", {
544
+ className: styles$e.normal,
545
+ style: getToggleButtonStyles(toggled)
546
+ }, button), /*#__PURE__*/React.createElement("div", {
547
+ className: classNames([styles$e.toggled, _defineProperty({}, toggledButtonClassName, toggledButtonClassName !== null)]),
548
+ style: getToggleButtonStyles(toggled - 1)
549
+ }, toggledButton));
550
+ };
551
+
552
+ ToggleButton.propTypes = propTypes$i;
553
+ ToggleButton.defaultProps = defaultProps$i;
554
+
555
+ var styles$d = {"backdrop":"micromag-viewer-menus-menu-container-backdrop","container":"micromag-viewer-menus-menu-container-container","heightContainer":"micromag-viewer-menus-menu-container-heightContainer","inner":"micromag-viewer-menus-menu-container-inner"};
228
556
 
229
557
  var propTypes$h = {
558
+ className: PropTypes.string,
559
+ transitionProgress: PropTypes.number,
560
+ children: PropTypes.node
561
+ };
562
+ var defaultProps$h = {
563
+ className: null,
564
+ transitionProgress: 0,
565
+ children: null
566
+ };
567
+
568
+ var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
569
+ var className = _ref.className,
570
+ transitionProgress = _ref.transitionProgress,
571
+ children = _ref.children;
572
+ return /*#__PURE__*/React.createElement("div", {
573
+ className: classNames([styles$d.container, _defineProperty({}, className, className !== null)]),
574
+ style: {
575
+ pointerEvents: 'none'
576
+ }
577
+ }, /*#__PURE__*/React.createElement("div", {
578
+ className: styles$d.heightContainer,
579
+ style: {
580
+ height: "".concat(transitionProgress * 100, "%"),
581
+ pointerEvents: transitionProgress < 0.25 ? 'none' : 'auto',
582
+ zIndex: Math.round(1 + transitionProgress)
583
+ }
584
+ }, /*#__PURE__*/React.createElement("div", {
585
+ className: styles$d.inner,
586
+ style: {
587
+ paddingTop: "".concat(3 * transitionProgress, "rem"),
588
+ paddingBottom: "".concat(0.5 * transitionProgress, "rem")
589
+ }
590
+ }, children)), /*#__PURE__*/React.createElement("div", {
591
+ className: styles$d.backdrop,
592
+ style: {
593
+ opacity: easings.easeOutQuint(transitionProgress)
594
+ }
595
+ }));
596
+ };
597
+
598
+ ViewerMenuContainer.propTypes = propTypes$h;
599
+ ViewerMenuContainer.defaultProps = defaultProps$h;
600
+
601
+ var styles$c = {"button":"micromag-viewer-menus-menu-dot-button","progress":"micromag-viewer-menus-menu-dot-progress","container":"micromag-viewer-menus-menu-dot-container","vertical":"micromag-viewer-menus-menu-dot-vertical","dot":"micromag-viewer-menus-menu-dot-dot","subDot":"micromag-viewer-menus-menu-dot-subDot","dots":"micromag-viewer-menus-menu-dot-dots","outlineBounce":"micromag-viewer-menus-menu-dot-outlineBounce"};
602
+
603
+ var propTypes$g = {
230
604
  current: PropTypes.bool,
231
605
  active: PropTypes.bool,
232
606
  colors: PropTypes.shape({
@@ -239,7 +613,7 @@ var propTypes$h = {
239
613
  onClick: PropTypes.func,
240
614
  className: PropTypes.string
241
615
  };
242
- var defaultProps$h = {
616
+ var defaultProps$g = {
243
617
  current: false,
244
618
  active: false,
245
619
  colors: null,
@@ -261,347 +635,121 @@ var ViewerMenuDot = function ViewerMenuDot(_ref) {
261
635
  vertical = _ref.vertical,
262
636
  onClick = _ref.onClick,
263
637
  className = _ref.className;
264
- var currentTime = 0;
265
- var duration = 1;
266
- var playing = true;
267
638
 
268
639
  var _ref2 = colors || {},
269
640
  _ref2$primary = _ref2.primary,
270
641
  primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
271
642
  _ref2$secondary = _ref2.secondary,
272
- secondary = _ref2$secondary === void 0 ? 'rgba(200, 200, 200, 0.5)' : _ref2$secondary; // TODO: if approved animate progress
273
-
643
+ secondary = _ref2$secondary === void 0 ? 'rgba(255, 255, 255, 0.25)' : _ref2$secondary;
274
644
 
275
645
  var _useSpring = useSpring(function () {
276
646
  return {
277
- x: 0,
647
+ scaleX: 0,
278
648
  config: {
279
- duration: 0
649
+ tension: 200,
650
+ friction: 30
280
651
  }
281
652
  };
282
653
  }),
283
- _useSpring2 = _slicedToArray(_useSpring, 2);
284
- _useSpring2[0];
285
- var setSpringProps = _useSpring2[1];
654
+ _useSpring2 = _slicedToArray(_useSpring, 2),
655
+ dotSpringStyles = _useSpring2[0],
656
+ setDotSpringProps = _useSpring2[1];
286
657
 
287
658
  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
- }
659
+ var activeRatio = active ? 1 : 0;
660
+ var ratio = count > 1 && current ? (subIndex + 1) / count : activeRatio;
661
+ var scaleX = ratio;
662
+ setDotSpringProps.start({
663
+ scaleX: scaleX,
664
+ immediate: !current
313
665
  });
314
- })) : /*#__PURE__*/React.createElement("span", {
315
- className: styles$b.dot,
316
- style: {
317
- backgroundColor: active ? primary : secondary
318
- }
319
- });
666
+ }, [active, current, subIndex, count, setDotSpringProps]);
320
667
  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)]),
668
+ 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
669
  "aria-hidden": "true"
323
670
  }, /*#__PURE__*/React.createElement("button", {
324
671
  type: "button",
325
- className: styles$b.button,
672
+ className: styles$c.button,
326
673
  onClick: onClick,
327
674
  tabIndex: "-1"
328
- }, inner));
329
- };
330
-
331
- ViewerMenuDot.propTypes = propTypes$h;
332
- ViewerMenuDot.defaultProps = defaultProps$h;
333
-
334
- var styles$a = {};
335
-
336
- 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
- }));
675
+ }, /*#__PURE__*/React.createElement("div", {
676
+ className: styles$c.dot,
677
+ style: {
678
+ backgroundColor: secondary
679
+ }
680
+ }, /*#__PURE__*/React.createElement(animated.div, {
681
+ className: styles$c.progress,
682
+ style: _objectSpread(_objectSpread({}, dotSpringStyles), {}, {
683
+ backgroundColor: primary
684
+ })
685
+ }))));
372
686
  };
373
687
 
374
- MenuIcon.propTypes = propTypes$g;
375
- MenuIcon.defaultProps = defaultProps$g;
688
+ ViewerMenuDot.propTypes = propTypes$g;
689
+ ViewerMenuDot.defaultProps = defaultProps$g;
376
690
 
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"};
691
+ 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"};
378
692
 
693
+ var _excluded$3 = ["direction", "items", "onClickDot", "onClickScreensMenu", "colors", "closeable", "withItemClick", "withoutScreensMenu", "onClose", "className"];
379
694
  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
695
+ direction: PropTypes.oneOf(['horizontal', 'vertical']),
696
+ items: PropTypes$1.menuItems,
697
+ onClickDot: PropTypes.func,
698
+ onClickScreensMenu: PropTypes.func,
699
+ colors: PropTypes.shape({
700
+ primary: PropTypes.string,
701
+ secondary: PropTypes.string
702
+ }),
703
+ closeable: PropTypes.bool,
704
+ withItemClick: PropTypes.bool,
705
+ withoutScreensMenu: PropTypes.bool,
706
+ onClose: PropTypes.func,
707
+ className: PropTypes.string
386
708
  };
387
709
  var defaultProps$f = {
388
- url: null,
389
- title: null,
390
- opened: false,
391
- className: null,
392
- onShare: null,
393
- onCancel: null
710
+ direction: 'horizontal',
711
+ items: [],
712
+ onClickDot: null,
713
+ onClickScreensMenu: null,
714
+ colors: null,
715
+ closeable: false,
716
+ withItemClick: false,
717
+ withoutScreensMenu: false,
718
+ onClose: null,
719
+ className: null
394
720
  };
395
721
 
396
- var ShareModal = function ShareModal(_ref) {
397
- var _ref3;
722
+ var ViewerMenuDots = function ViewerMenuDots(_ref) {
723
+ var _ref5;
398
724
 
399
- var url = _ref.url,
400
- title = _ref.title,
401
- opened = _ref.opened,
725
+ var direction = _ref.direction,
726
+ items = _ref.items,
727
+ onClickDot = _ref.onClickDot,
728
+ onClickScreensMenu = _ref.onClickScreensMenu,
729
+ colors = _ref.colors,
730
+ closeable = _ref.closeable,
731
+ withItemClick = _ref.withItemClick,
732
+ withoutScreensMenu = _ref.withoutScreensMenu,
733
+ onClose = _ref.onClose,
402
734
  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
- };
735
+ props = _objectWithoutProperties(_ref, _excluded$3);
451
736
 
452
- ShareModal.propTypes = propTypes$f;
453
- ShareModal.defaultProps = defaultProps$f;
737
+ var _ref2 = colors || {},
738
+ _ref2$primary = _ref2.primary,
739
+ primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary;
454
740
 
455
- var styles$8 = {"container":"micromag-viewer-partials-share-button-container"};
741
+ var intl = useIntl();
742
+ var currentIndex = items.findIndex(function (_ref3) {
743
+ var _ref3$current = _ref3.current,
744
+ current = _ref3$current === void 0 ? false : _ref3$current;
745
+ return current;
746
+ });
456
747
 
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
- };
748
+ var _ref4 = props || {},
749
+ style = _ref4.style;
475
750
 
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
- direction: PropTypes.oneOf(['horizontal', 'vertical']),
541
- withShadow: PropTypes.bool,
542
- title: PropTypes.string,
543
- items: PropTypes$1.menuItems,
544
- shareUrl: PropTypes.string,
545
- onShare: PropTypes.func,
546
- onClickItem: PropTypes.func,
547
- onClickMenu: PropTypes.func,
548
- colors: PropTypes.shape({
549
- primary: PropTypes.string,
550
- secondary: PropTypes.string
551
- }),
552
- closeable: PropTypes.bool,
553
- withItemClick: PropTypes.bool,
554
- withoutScreensMenu: PropTypes.bool,
555
- onClose: PropTypes.func,
556
- className: PropTypes.string
557
- };
558
- var defaultProps$d = {
559
- direction: 'horizontal',
560
- withShadow: false,
561
- title: null,
562
- items: [],
563
- shareUrl: null,
564
- onShare: null,
565
- onClickItem: null,
566
- onClickMenu: null,
567
- colors: null,
568
- closeable: false,
569
- withItemClick: false,
570
- withoutScreensMenu: false,
571
- onClose: null,
572
- className: null
573
- };
574
-
575
- var ViewerMenuDots = function ViewerMenuDots(_ref) {
576
- var _ref4;
577
-
578
- var direction = _ref.direction,
579
- withShadow = _ref.withShadow,
580
- title = _ref.title,
581
- items = _ref.items,
582
- shareUrl = _ref.shareUrl,
583
- onShare = _ref.onShare,
584
- onClickItem = _ref.onClickItem,
585
- onClickMenu = _ref.onClickMenu,
586
- colors = _ref.colors,
587
- closeable = _ref.closeable,
588
- withItemClick = _ref.withItemClick,
589
- withoutScreensMenu = _ref.withoutScreensMenu,
590
- onClose = _ref.onClose,
591
- className = _ref.className;
592
-
593
- var _ref2 = colors || {},
594
- _ref2$primary = _ref2.primary,
595
- primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary;
596
-
597
- var intl = useIntl();
598
- var currentIndex = items.findIndex(function (_ref3) {
599
- var _ref3$current = _ref3.current,
600
- current = _ref3$current === void 0 ? false : _ref3$current;
601
- return current;
602
- });
603
751
  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)]),
752
+ className: classNames([styles$b.container, (_ref5 = {}, _defineProperty(_ref5, className, className !== null), _defineProperty(_ref5, styles$b.vertical, direction === 'vertical'), _ref5)]),
605
753
  "aria-label": intl.formatMessage({
606
754
  id: "bLYuuN",
607
755
  defaultMessage: [{
@@ -623,17 +771,18 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
623
771
  }, {
624
772
  current: currentIndex + 1,
625
773
  total: items.length
626
- })
774
+ }),
775
+ style: style
627
776
  }, /*#__PURE__*/React.createElement("ul", {
628
- className: styles$c.items
777
+ className: styles$b.items
629
778
  }, 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;
779
+ var _ref6 = item || {},
780
+ _ref6$current = _ref6.current,
781
+ current = _ref6$current === void 0 ? false : _ref6$current,
782
+ _ref6$count = _ref6.count,
783
+ count = _ref6$count === void 0 ? 1 : _ref6$count,
784
+ _ref6$subIndex = _ref6.subIndex,
785
+ subIndex = _ref6$subIndex === void 0 ? 0 : _ref6$subIndex;
637
786
 
638
787
  return /*#__PURE__*/React.createElement(ViewerMenuDot, {
639
788
  key: "item-".concat(index + 1),
@@ -643,56 +792,22 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
643
792
  count: count,
644
793
  subIndex: subIndex,
645
794
  onClick: function onClick() {
646
- if ((withItemClick || withoutScreensMenu) && onClickItem !== null) {
647
- onClickItem(item);
648
- } else if (!withItemClick && onClickMenu !== null) {
649
- onClickMenu();
795
+ if ((withItemClick || withoutScreensMenu) && onClickDot !== null) {
796
+ onClickDot(item);
797
+ } else if (!withItemClick && onClickScreensMenu !== null) {
798
+ onClickScreensMenu();
650
799
  }
651
800
  },
652
801
  vertical: direction === 'vertical'
653
802
  });
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,
803
+ }), closeable ? /*#__PURE__*/React.createElement("li", {
804
+ className: styles$b.closeButton,
690
805
  style: {
691
806
  color: primary
692
807
  }
693
808
  }, /*#__PURE__*/React.createElement("button", {
694
809
  type: "button",
695
- className: styles$c.closeButton,
810
+ className: styles$b.closeButton,
696
811
  onClick: onClose,
697
812
  title: intl.formatMessage({
698
813
  id: "dj/p/q",
@@ -713,13 +828,13 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
713
828
  }))) : null));
714
829
  };
715
830
 
716
- ViewerMenuDots.propTypes = propTypes$d;
717
- ViewerMenuDots.defaultProps = defaultProps$d;
831
+ ViewerMenuDots.propTypes = propTypes$f;
832
+ ViewerMenuDots.defaultProps = defaultProps$f;
718
833
 
719
- var propTypes$c = {
834
+ var propTypes$e = {
720
835
  className: PropTypes.string
721
836
  };
722
- var defaultProps$c = {
837
+ var defaultProps$e = {
723
838
  className: null
724
839
  };
725
840
 
@@ -727,50 +842,143 @@ var StackIcon = function StackIcon(_ref) {
727
842
  var className = _ref.className;
728
843
  return /*#__PURE__*/React.createElement("svg", {
729
844
  xmlns: "http://www.w3.org/2000/svg",
730
- width: "32",
731
- height: "32",
732
- viewBox: "0 0 32 32",
845
+ width: "11.5",
846
+ height: "17.5",
847
+ viewBox: "0 0 11.5 17.5",
733
848
  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"
849
+ }, /*#__PURE__*/React.createElement("rect", {
850
+ width: "10",
851
+ height: "16"
852
+ }), /*#__PURE__*/React.createElement("polygon", {
853
+ 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
854
  }));
737
855
  };
738
856
 
739
- StackIcon.propTypes = propTypes$c;
740
- StackIcon.defaultProps = defaultProps$c;
857
+ StackIcon.propTypes = propTypes$e;
858
+ StackIcon.defaultProps = defaultProps$e;
741
859
 
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"};
860
+ 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
861
 
744
- var propTypes$b = {
862
+ var propTypes$d = {
863
+ className: PropTypes.string,
864
+ item: PropTypes$1.menuItem,
865
+ index: PropTypes.number,
866
+ onClick: PropTypes.func,
867
+ screenSize: PropTypes$1.screenSize,
868
+ focusable: PropTypes.bool
869
+ };
870
+ var defaultProps$d = {
871
+ className: null,
872
+ item: PropTypes$1.menuItem,
873
+ index: 0,
874
+ onClick: null,
875
+ screenSize: null,
876
+ focusable: true
877
+ };
878
+
879
+ var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
880
+ var _ref4;
881
+
882
+ var className = _ref.className,
883
+ item = _ref.item,
884
+ index = _ref.index,
885
+ _onClick = _ref.onClick,
886
+ screenSize = _ref.screenSize,
887
+ focusable = _ref.focusable;
888
+ var intl = useIntl();
889
+
890
+ var _ref2 = item || {},
891
+ _ref2$current = _ref2.current,
892
+ current = _ref2$current === void 0 ? false : _ref2$current,
893
+ screen = _ref2.screen,
894
+ _ref2$count = _ref2.count,
895
+ count = _ref2$count === void 0 ? 1 : _ref2$count;
896
+
897
+ var _ref3 = screenSize || {},
898
+ screenWidth = _ref3.width,
899
+ screenHeight = _ref3.height;
900
+
901
+ var screenAriaLabel = "".concat(intl.formatMessage({
902
+ id: "LkVfwW",
903
+ defaultMessage: [{
904
+ "type": 0,
905
+ "value": "Screen "
906
+ }, {
907
+ "type": 1,
908
+ "value": "index"
909
+ }]
910
+ }, {
911
+ index: index + 1
912
+ })).concat(current ? " ".concat(intl.formatMessage({
913
+ id: "vmrJ8U",
914
+ defaultMessage: [{
915
+ "type": 0,
916
+ "value": "(current screen)"
917
+ }]
918
+ })) : '');
919
+ return /*#__PURE__*/React.createElement("div", {
920
+ className: classNames([styles$a.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$a.isCurrent, current), _ref4)])
921
+ }, /*#__PURE__*/React.createElement("button", {
922
+ type: "button",
923
+ className: styles$a.button,
924
+ onClick: function onClick() {
925
+ if (_onClick !== null) {
926
+ _onClick(item);
927
+ }
928
+ },
929
+ "aria-label": screenAriaLabel,
930
+ tabIndex: focusable ? '0' : '-1'
931
+ }), /*#__PURE__*/React.createElement("div", {
932
+ className: styles$a.inner
933
+ }, count > 1 ? /*#__PURE__*/React.createElement("div", {
934
+ className: styles$a.subScreenBadge
935
+ }, /*#__PURE__*/React.createElement("span", {
936
+ className: styles$a.subScreenCount
937
+ }, count), /*#__PURE__*/React.createElement(StackIcon, {
938
+ className: styles$a.subScreenIcon
939
+ })) : null, screenWidth > 0 && screenHeight > 0 ? /*#__PURE__*/React.createElement(ScreenPreview, {
940
+ className: styles$a.screen,
941
+ screenWidth: screenWidth,
942
+ screenHeight: screenHeight,
943
+ screen: screen,
944
+ focusable: focusable,
945
+ active: focusable,
946
+ withSize: true
947
+ }) : null));
948
+ };
949
+
950
+ ViewerMenuScreen.propTypes = propTypes$d;
951
+ ViewerMenuScreen.defaultProps = defaultProps$d;
952
+
953
+ 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","screen":"micromag-viewer-menus-menu-preview-screen","loading":"micromag-viewer-menus-menu-preview-loading","fillPulse":"micromag-viewer-menus-menu-preview-fillPulse"};
954
+
955
+ var propTypes$c = {
745
956
  viewerTheme: PropTypes$1.viewerTheme,
746
957
  screenSize: PropTypes$1.screenSize,
747
958
  menuWidth: PropTypes.number,
748
- title: PropTypes.string,
749
959
  items: PropTypes$1.menuItems,
750
960
  focusable: PropTypes.bool,
751
- shouldLoad: PropTypes.bool,
752
- onClickItem: PropTypes.func,
753
- onClose: PropTypes.func,
961
+ onClickScreen: PropTypes.func,
754
962
  maxThumbsWidth: PropTypes.number,
755
- toggleFullscreen: PropTypes.func,
756
- fullscreenActive: PropTypes.bool,
757
- fullscreenEnabled: PropTypes.bool,
963
+ // @todo to reimplement:
964
+ // shouldLoad: PropTypes.bool,
965
+ // toggleFullscreen: PropTypes.func,
966
+ // fullscreenActive: PropTypes.bool,
967
+ // fullscreenEnabled: PropTypes.bool,
758
968
  className: PropTypes.string
759
969
  };
760
- var defaultProps$b = {
970
+ var defaultProps$c = {
761
971
  viewerTheme: null,
762
972
  screenSize: null,
763
973
  menuWidth: null,
764
- title: null,
765
974
  items: [],
766
975
  focusable: true,
767
- shouldLoad: true,
768
- onClickItem: null,
769
- onClose: null,
976
+ // shouldLoad: true,
977
+ onClickScreen: null,
770
978
  maxThumbsWidth: 140,
771
- toggleFullscreen: null,
772
- fullscreenActive: false,
773
- fullscreenEnabled: false,
979
+ // toggleFullscreen: null,
980
+ // fullscreenActive: false,
981
+ // fullscreenEnabled: false,
774
982
  className: null
775
983
  };
776
984
 
@@ -778,259 +986,298 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
778
986
  var viewerTheme = _ref.viewerTheme,
779
987
  screenSize = _ref.screenSize,
780
988
  menuWidth = _ref.menuWidth,
781
- title = _ref.title,
782
989
  items = _ref.items,
783
990
  focusable = _ref.focusable,
784
- onClickItem = _ref.onClickItem,
785
- onClose = _ref.onClose,
991
+ onClickScreen = _ref.onClickScreen,
786
992
  maxThumbsWidth = _ref.maxThumbsWidth,
787
- toggleFullscreen = _ref.toggleFullscreen,
788
- fullscreenActive = _ref.fullscreenActive,
789
- fullscreenEnabled = _ref.fullscreenEnabled,
790
993
  className = _ref.className;
791
- var intl = useIntl();
792
-
793
- var _ref2 = screenSize || {},
794
- screenWidth = _ref2.width,
795
- screenHeight = _ref2.height;
796
994
 
797
995
  var _useDimensionObserver = useDimensionObserver(),
798
- firstScreenContainerRef = _useDimensionObserver.ref,
996
+ containerRef = _useDimensionObserver.ref,
799
997
  _useDimensionObserver2 = _useDimensionObserver.width,
800
- thumbWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
998
+ contentWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
801
999
 
802
- var _useDimensionObserver3 = useDimensionObserver(),
803
- containerRef = _useDimensionObserver3.ref,
804
- _useDimensionObserver4 = _useDimensionObserver3.width,
805
- contentWidth = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
1000
+ var thumbsPerLine = Math.max(Math.floor(contentWidth / maxThumbsWidth), 3); // @note cool, should be in recipes
806
1001
 
807
- var thumbsPerLine = Math.max(Math.floor(contentWidth / maxThumbsWidth), 3); // Viewer theme
1002
+ var _ref2 = viewerTheme || {},
1003
+ _ref2$background = _ref2.background,
1004
+ background = _ref2$background === void 0 ? null : _ref2$background;
1005
+ _ref2.logo;
808
1006
 
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;
822
-
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;
828
-
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;
834
-
835
- var _ref7 = image || {},
836
- _ref7$url = _ref7.url,
837
- brandImageUrl = _ref7$url === void 0 ? null : _ref7$url;
838
-
839
- var borderPrimaryColorStyle = getStyleFromColor(brandPrimaryColor, 'borderColor');
840
- var colorSecondaryColorStyle = getStyleFromColor(brandSecondaryColor, 'color');
841
- var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
1007
+ var _ref3 = background || {},
1008
+ _ref3$color = _ref3.color,
1009
+ brandBackgroundColor = _ref3$color === void 0 ? null : _ref3$color,
1010
+ _ref3$image = _ref3.image,
1011
+ image = _ref3$image === void 0 ? null : _ref3$image;
842
1012
 
843
- var _ref8 = brandLogo || {},
844
- _ref8$url = _ref8.url,
845
- brandLogoUrl = _ref8$url === void 0 ? null : _ref8$url;
1013
+ var _ref4 = image || {},
1014
+ _ref4$url = _ref4.url,
1015
+ brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
846
1016
 
1017
+ var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
847
1018
  var brandImageStyle = brandImageUrl !== null ? {
848
1019
  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];
856
-
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;
1020
+ } : null; // @todo reimplement the brand logo
1021
+ // const { url: brandLogoUrl = null } = brandLogo || {};
1022
+ // @todo optimize all of this the proper way
1023
+ // const finalItems = useMemo(
1024
+ // () => (!focusable ? items.map((s, i) => (i > 6 ? { screenId: s.screenId } : s)) : items),
1025
+ // [items, focusable],
1026
+ // );
862
1027
 
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
- 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)]),
1028
+ return /*#__PURE__*/React.createElement("div", {
1029
+ className: classNames([styles$9.container, _defineProperty({}, className, className !== null)]),
883
1030
  style: _objectSpread(_objectSpread(_objectSpread({}, backgroundColorStyle), brandImageStyle), {}, {
884
1031
  width: menuWidth
885
1032
  }),
886
1033
  "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,
1034
+ }, /*#__PURE__*/React.createElement("div", {
1035
+ className: styles$9.content,
944
1036
  ref: containerRef
945
1037
  }, /*#__PURE__*/React.createElement(Scroll, {
946
- className: styles$7.scroll,
947
- onScrolledBottom: onScrolledBottom,
948
- onScrolledNotBottom: onScrolledNotBottom
1038
+ className: styles$9.scroll
949
1039
  }, /*#__PURE__*/React.createElement("nav", {
950
- className: styles$7.nav
1040
+ className: styles$9.nav
951
1041
  }, /*#__PURE__*/React.createElement("ul", {
952
- className: styles$7.items
953
- }, 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
- })) : '');
1042
+ className: styles$9.items
1043
+ }, items.map(function (item, index) {
1044
+ var _ref6 = item || {},
1045
+ screenId = _ref6.screenId,
1046
+ _ref6$screen = _ref6.screen,
1047
+ screen = _ref6$screen === void 0 ? null : _ref6$screen;
1048
+
1049
+ var itemStyles = {
1050
+ width: "".concat(100 / thumbsPerLine, "%")
1051
+ };
978
1052
  return /*#__PURE__*/React.createElement("li", {
979
- className: classNames([styles$7.item, _defineProperty({}, styles$7.active, current)]),
980
1053
  key: "item-".concat(screenId),
1054
+ className: styles$9.item,
1055
+ style: itemStyles
1056
+ }, /*#__PURE__*/React.createElement("div", {
1057
+ className: styles$9.screen
1058
+ }, screen === null ? /*#__PURE__*/React.createElement("svg", {
1059
+ className: styles$9.loading,
1060
+ xmlns: "http://www.w3.org/2000/svg",
1061
+ width: "10",
1062
+ height: "16",
1063
+ viewBox: "0 0 10 16",
981
1064
  style: {
982
- width: "".concat(100 / thumbsPerLine, "%")
1065
+ animationDelay: "".concat(index * -50, "ms")
983
1066
  }
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'
1021
- }));
1067
+ }, /*#__PURE__*/React.createElement("rect", {
1068
+ width: "10",
1069
+ height: "16"
1070
+ })) : /*#__PURE__*/React.createElement(ViewerMenuScreen, {
1071
+ item: item,
1072
+ index: index,
1073
+ screenSize: screenSize,
1074
+ onClick: onClickScreen,
1075
+ focusable: focusable
1076
+ })));
1022
1077
  }))))));
1023
1078
  };
1024
1079
 
1025
- ViewerMenuPreview.propTypes = propTypes$b;
1026
- ViewerMenuPreview.defaultProps = defaultProps$b;
1080
+ ViewerMenuPreview.propTypes = propTypes$c;
1081
+ ViewerMenuPreview.defaultProps = defaultProps$c;
1082
+
1083
+ 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"};
1084
+
1085
+ var propTypes$b = {
1086
+ screen: PropTypes$1.item,
1087
+ title: PropTypes.string,
1088
+ url: PropTypes.string,
1089
+ description: PropTypes.string,
1090
+ className: PropTypes.string
1091
+ };
1092
+ var defaultProps$b = {
1093
+ screen: null,
1094
+ title: null,
1095
+ url: null,
1096
+ description: null,
1097
+ className: null
1098
+ };
1099
+
1100
+ var MicromagPreview = function MicromagPreview(_ref) {
1101
+ var screen = _ref.screen,
1102
+ title = _ref.title,
1103
+ url = _ref.url,
1104
+ description = _ref.description,
1105
+ className = _ref.className;
1106
+ return /*#__PURE__*/React.createElement("div", {
1107
+ className: classNames([styles$8.container, _defineProperty({}, className, className)])
1108
+ }, /*#__PURE__*/React.createElement("div", {
1109
+ className: styles$8.cover
1110
+ }, /*#__PURE__*/React.createElement(ScreenPreview, {
1111
+ screen: screen,
1112
+ width: 100,
1113
+ height: 150,
1114
+ withSize: true
1115
+ })), /*#__PURE__*/React.createElement("div", {
1116
+ className: styles$8.info
1117
+ }, /*#__PURE__*/React.createElement("h3", {
1118
+ className: styles$8.title
1119
+ }, title), url ? /*#__PURE__*/React.createElement("div", {
1120
+ className: styles$8.url
1121
+ }, url) : null, /*#__PURE__*/React.createElement("p", null, description)));
1122
+ };
1123
+
1124
+ MicromagPreview.propTypes = propTypes$b;
1125
+ MicromagPreview.defaultProps = defaultProps$b;
1027
1126
 
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"};
1127
+ var styles$7 = {"scroll":"micromag-viewer-menus-menu-share-scroll","container":"micromag-viewer-menus-menu-share-container","disabled":"micromag-viewer-menus-menu-share-disabled","button":"micromag-viewer-menus-menu-share-button","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","content":"micromag-viewer-menus-menu-share-content"};
1029
1128
 
1030
1129
  var propTypes$a = {
1130
+ viewerTheme: PropTypes$1.viewerTheme,
1131
+ menuWidth: PropTypes.number,
1132
+ title: PropTypes.string,
1133
+ description: PropTypes.string,
1134
+ items: PropTypes$1.menuItems,
1135
+ focusable: PropTypes.bool,
1136
+ // shouldLoad: PropTypes.bool, // @todo still needed? to re-implement?
1137
+ currentScreenIndex: PropTypes.number,
1138
+ shareUrl: PropTypes.string,
1139
+ onShare: PropTypes.func,
1140
+ className: PropTypes.string
1141
+ };
1142
+ var defaultProps$a = {
1143
+ viewerTheme: null,
1144
+ menuWidth: null,
1145
+ title: null,
1146
+ description: null,
1147
+ items: [],
1148
+ focusable: true,
1149
+ currentScreenIndex: 0,
1150
+ shareUrl: null,
1151
+ onShare: null,
1152
+ className: null
1153
+ };
1154
+
1155
+ var ViewerMenuShare = function ViewerMenuShare(_ref) {
1156
+ var viewerTheme = _ref.viewerTheme,
1157
+ menuWidth = _ref.menuWidth,
1158
+ title = _ref.title,
1159
+ description = _ref.description,
1160
+ items = _ref.items,
1161
+ focusable = _ref.focusable,
1162
+ currentScreenIndex = _ref.currentScreenIndex,
1163
+ shareUrl = _ref.shareUrl,
1164
+ onShare = _ref.onShare,
1165
+ className = _ref.className;
1166
+
1167
+ // Viewer theme
1168
+ var _ref2 = viewerTheme || {},
1169
+ _ref2$background = _ref2.background,
1170
+ background = _ref2$background === void 0 ? null : _ref2$background;
1171
+
1172
+ var _ref3 = background || {},
1173
+ _ref3$color = _ref3.color,
1174
+ brandBackgroundColor = _ref3$color === void 0 ? null : _ref3$color,
1175
+ _ref3$image = _ref3.image,
1176
+ image = _ref3$image === void 0 ? null : _ref3$image;
1177
+
1178
+ var _ref4 = image || {},
1179
+ _ref4$url = _ref4.url,
1180
+ brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
1181
+
1182
+ var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
1183
+ var brandImageStyle = brandImageUrl !== null ? {
1184
+ backgroundImage: "url(".concat(brandImageUrl, ")")
1185
+ } : null;
1186
+ var coverScreen = useMemo(function () {
1187
+ var _ref5 = items[0] || {},
1188
+ _ref5$screen = _ref5.screen,
1189
+ screen = _ref5$screen === void 0 ? null : _ref5$screen;
1190
+
1191
+ return screen;
1192
+ }, [items]);
1193
+ var currentScreen = useMemo(function () {
1194
+ var found = items.find(function (item) {
1195
+ var _ref6 = item || {},
1196
+ _ref6$current = _ref6.current,
1197
+ current = _ref6$current === void 0 ? false : _ref6$current;
1198
+
1199
+ return current;
1200
+ });
1201
+
1202
+ var _ref7 = found || {},
1203
+ _ref7$screen = _ref7.screen,
1204
+ screen = _ref7$screen === void 0 ? null : _ref7$screen;
1205
+
1206
+ return screen;
1207
+ }, [items, currentScreenIndex, focusable]);
1208
+
1209
+ var _useState = useState(false),
1210
+ _useState2 = _slicedToArray(_useState, 2),
1211
+ shareCurrentScreen = _useState2[0],
1212
+ setShareCurrentScreen = _useState2[1];
1213
+
1214
+ var onShareModeChange = useCallback(function () {
1215
+ setShareCurrentScreen(function (value) {
1216
+ return !value;
1217
+ });
1218
+ }, [setShareCurrentScreen]);
1219
+
1220
+ var _useState3 = useState(shareUrl),
1221
+ _useState4 = _slicedToArray(_useState3, 2),
1222
+ finalShareUrl = _useState4[0],
1223
+ setFinalShareUrl = _useState4[1];
1224
+
1225
+ useEffect(function () {
1226
+ setFinalShareUrl(shareCurrentScreen && currentScreenIndex !== 0 ? "".concat(shareUrl, "/").concat(currentScreenIndex) : shareUrl);
1227
+ }, [shareCurrentScreen, currentScreenIndex, setFinalShareUrl]);
1228
+ return /*#__PURE__*/React.createElement("div", {
1229
+ className: classNames([styles$7.container, _defineProperty({}, className, className !== null)]),
1230
+ style: _objectSpread(_objectSpread(_objectSpread({}, backgroundColorStyle), brandImageStyle), {}, {
1231
+ width: menuWidth
1232
+ }),
1233
+ "aria-hidden": focusable ? null : 'true'
1234
+ }, /*#__PURE__*/React.createElement("div", {
1235
+ className: styles$7.content
1236
+ }, /*#__PURE__*/React.createElement(Scroll, {
1237
+ className: styles$7.scroll
1238
+ }, /*#__PURE__*/React.createElement("div", {
1239
+ className: styles$7.header
1240
+ }, /*#__PURE__*/React.createElement(MicromagPreview, {
1241
+ className: styles$7.preview,
1242
+ screen: shareCurrentScreen ? currentScreen : coverScreen,
1243
+ title: title,
1244
+ url: finalShareUrl,
1245
+ description: description
1246
+ }), currentScreenIndex !== 0 ? /*#__PURE__*/React.createElement("div", {
1247
+ className: styles$7.mode
1248
+ }, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
1249
+ type: "checkbox",
1250
+ name: "currentScreen",
1251
+ value: "currentScreen",
1252
+ onChange: onShareModeChange,
1253
+ checked: shareCurrentScreen
1254
+ }), /*#__PURE__*/React.createElement(FormattedMessage, {
1255
+ id: "xuPbeq",
1256
+ defaultMessage: [{
1257
+ "type": 0,
1258
+ "value": "Start from the current screen"
1259
+ }]
1260
+ }))) : null), /*#__PURE__*/React.createElement(ShareOptions, {
1261
+ className: styles$7.options,
1262
+ itemClassName: styles$7.optionItem,
1263
+ buttonClassName: styles$7.optionButton,
1264
+ title: title,
1265
+ url: finalShareUrl,
1266
+ focusable: focusable,
1267
+ onShare: onShare,
1268
+ theme: viewerTheme,
1269
+ shareCurrentScreen: shareCurrentScreen
1270
+ }))));
1271
+ };
1272
+
1273
+ ViewerMenuShare.propTypes = propTypes$a;
1274
+ ViewerMenuShare.defaultProps = defaultProps$a;
1275
+
1276
+ 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","withoutGestures":"micromag-viewer-withoutGestures","fadeMenu":"micromag-viewer-fadeMenu","withShadow":"micromag-viewer-withShadow","isOpened":"micromag-viewer-isOpened","menuItem":"micromag-viewer-menuItem","menuItemScreens":"micromag-viewer-menuItemScreens","menuButton":"micromag-viewer-menuButton","slidingButton":"micromag-viewer-slidingButton","screensMenuButtonToggled":"micromag-viewer-screensMenuButtonToggled","isHidden":"micromag-viewer-isHidden","navButton":"micromag-viewer-navButton","previous":"micromag-viewer-previous","next":"micromag-viewer-next","screen":"micromag-viewer-screen","current":"micromag-viewer-current","playbackControls":"micromag-viewer-playbackControls","arrowHint":"micromag-viewer-arrowHint","webView":"micromag-viewer-webView"};
1277
+
1278
+ var propTypes$9 = {
1031
1279
  story: PropTypes$1.story.isRequired,
1032
1280
  currentScreenIndex: PropTypes.number,
1033
- opened: PropTypes.bool,
1034
1281
  toggleFullscreen: PropTypes.func,
1035
1282
  fullscreenActive: PropTypes.bool,
1036
1283
  fullscreenEnabled: PropTypes.bool,
@@ -1043,9 +1290,8 @@ var propTypes$a = {
1043
1290
  menuWidth: PropTypes.number,
1044
1291
  withDotItemClick: PropTypes.bool,
1045
1292
  withoutScreensMenu: PropTypes.bool,
1046
- onRequestOpen: PropTypes.func,
1047
- onRequestClose: PropTypes.func,
1048
- onClickItem: PropTypes.func,
1293
+ withoutShareMenu: PropTypes.bool,
1294
+ onClickScreen: PropTypes.func,
1049
1295
  onClickMenu: PropTypes.func,
1050
1296
  onClickCloseViewer: PropTypes.func,
1051
1297
  refDots: PropTypes.shape({
@@ -1053,9 +1299,8 @@ var propTypes$a = {
1053
1299
 
1054
1300
  })
1055
1301
  };
1056
- var defaultProps$a = {
1302
+ var defaultProps$9 = {
1057
1303
  currentScreenIndex: 0,
1058
- opened: false,
1059
1304
  toggleFullscreen: null,
1060
1305
  fullscreenActive: false,
1061
1306
  fullscreenEnabled: false,
@@ -1068,18 +1313,18 @@ var defaultProps$a = {
1068
1313
  menuWidth: null,
1069
1314
  withDotItemClick: false,
1070
1315
  withoutScreensMenu: false,
1071
- onRequestOpen: null,
1072
- onRequestClose: null,
1073
- onClickItem: null,
1316
+ withoutShareMenu: false,
1317
+ onClickScreen: null,
1074
1318
  onClickMenu: null,
1075
1319
  onClickCloseViewer: null,
1076
1320
  refDots: null
1077
1321
  };
1078
1322
 
1079
1323
  var ViewerMenu = function ViewerMenu(_ref) {
1324
+ var _ref11;
1325
+
1080
1326
  var story = _ref.story,
1081
1327
  currentScreenIndex = _ref.currentScreenIndex,
1082
- opened = _ref.opened,
1083
1328
  toggleFullscreen = _ref.toggleFullscreen,
1084
1329
  fullscreenActive = _ref.fullscreenActive,
1085
1330
  fullscreenEnabled = _ref.fullscreenEnabled,
@@ -1092,23 +1337,43 @@ var ViewerMenu = function ViewerMenu(_ref) {
1092
1337
  menuWidth = _ref.menuWidth,
1093
1338
  withDotItemClick = _ref.withDotItemClick,
1094
1339
  withoutScreensMenu = _ref.withoutScreensMenu,
1095
- onRequestOpen = _ref.onRequestOpen,
1096
- onRequestClose = _ref.onRequestClose,
1097
- customOnClickItem = _ref.onClickItem,
1098
- customOnClickMenu = _ref.onClickMenu,
1099
- onClickCloseViewer = _ref.onClickCloseViewer,
1340
+ withoutShareMenu = _ref.withoutShareMenu,
1341
+ customOnClickScreen = _ref.onClickScreen;
1342
+ _ref.onClickMenu;
1343
+ var onClickCloseViewer = _ref.onClickCloseViewer,
1100
1344
  refDots = _ref.refDots;
1101
1345
  var _story$components = story.components,
1102
1346
  screens = _story$components === void 0 ? [] : _story$components,
1103
1347
  _story$title = story.title,
1104
- title = _story$title === void 0 ? null : _story$title;
1348
+ title = _story$title === void 0 ? null : _story$title,
1349
+ _story$metadata = story.metadata,
1350
+ metadata = _story$metadata === void 0 ? null : _story$metadata;
1351
+
1352
+ var _ref2 = metadata || {},
1353
+ _ref2$description = _ref2.description,
1354
+ description = _ref2$description === void 0 ? null : _ref2$description;
1355
+
1105
1356
  var currentScreen = screens !== null ? screens[currentScreenIndex] || null : null;
1106
1357
 
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;
1358
+ var _ref3 = currentScreen || {},
1359
+ _ref3$id = _ref3.id,
1360
+ screenId = _ref3$id === void 0 ? null : _ref3$id,
1361
+ _ref3$type = _ref3.type,
1362
+ screenType = _ref3$type === void 0 ? null : _ref3$type;
1363
+
1364
+ var _ref4 = viewerTheme || {},
1365
+ _ref4$menuTheme = _ref4.menuTheme,
1366
+ menuTheme = _ref4$menuTheme === void 0 ? null : _ref4$menuTheme;
1367
+
1368
+ var _useState = useState(false),
1369
+ _useState2 = _slicedToArray(_useState, 2),
1370
+ menuOpened = _useState2[0],
1371
+ setMenuOpened = _useState2[1];
1372
+
1373
+ var _useState3 = useState(false),
1374
+ _useState4 = _slicedToArray(_useState3, 2),
1375
+ shareOpened = _useState4[0],
1376
+ setShareOpened = _useState4[1];
1112
1377
 
1113
1378
  var items = useMemo(function () {
1114
1379
  return screens.map(function (it) {
@@ -1129,9 +1394,9 @@ var ViewerMenu = function ViewerMenu(_ref) {
1129
1394
  count: children.length + 1 || 1,
1130
1395
  subIndex: subIndex || 0
1131
1396
  };
1132
- }).filter(function (_ref3) {
1133
- var _ref3$visible = _ref3.visible,
1134
- visible = _ref3$visible === void 0 ? true : _ref3$visible;
1397
+ }).filter(function (_ref5) {
1398
+ var _ref5$visible = _ref5.visible,
1399
+ visible = _ref5$visible === void 0 ? true : _ref5$visible;
1135
1400
  return visible;
1136
1401
  });
1137
1402
  }, [screens, screenId]);
@@ -1146,224 +1411,268 @@ var ViewerMenu = function ViewerMenu(_ref) {
1146
1411
  }
1147
1412
  }, [trackEvent, screenId, currentScreenIndex, screenType]);
1148
1413
  var shareUrl = useMemo(function () {
1149
- var origin = typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
1150
- var path = shareBasePath !== null ? "".concat(origin).concat(shareBasePath) : origin;
1414
+ // @todo validate this
1415
+ // const base =
1416
+ // typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
1417
+ // const path = shareBasePath !== null ? `${base}${shareBasePath}` : base;
1418
+ var base = typeof window !== 'undefined' ? window.location.host : '';
1419
+ var path = shareBasePath !== null ? "".concat(base).concat(shareBasePath) : base;
1151
1420
  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];
1421
+ }, [shareBasePath]); // @note possible to extract some of that logic
1165
1422
 
1166
- var refOpened = useRef(opened);
1167
-
1168
- if (refOpened.current !== opened) {
1169
- refOpened.current = opened;
1170
- }
1423
+ var onOpenMenu = useCallback(function () {
1424
+ setMenuOpened(true);
1425
+ setShareOpened(false);
1426
+ trackScreenEvent('viewer_menu', 'open_screens_menu');
1427
+ }, [setMenuOpened, setShareOpened, trackScreenEvent]);
1428
+ var onCloseMenu = useCallback(function () {
1429
+ setMenuOpened(false);
1430
+ setShareOpened(false);
1431
+ trackScreenEvent('viewer_menu', 'close_screens_menu');
1432
+ }, [setMenuOpened, setShareOpened, trackScreenEvent]);
1433
+ var onOpenShare = useCallback(function () {
1434
+ setShareOpened(true);
1435
+ setMenuOpened(false);
1436
+ trackScreenEvent('viewer_menu', 'open_share_menu');
1437
+ }, [setShareOpened, setMenuOpened, trackScreenEvent]);
1438
+ var onCloseShare = useCallback(function () {
1439
+ setShareOpened(false);
1440
+ setMenuOpened(false);
1441
+ trackScreenEvent('viewer_menu', 'close_share_menu');
1442
+ }, [setShareOpened, setMenuOpened, trackScreenEvent]);
1443
+ var onClickScreen = useCallback(function (screen) {
1444
+ setMenuOpened(false);
1445
+
1446
+ if (customOnClickScreen !== null) {
1447
+ customOnClickScreen(screen);
1448
+ }
1171
1449
 
1172
- useEffect(function () {
1173
- setMenuSpring.start({
1174
- y: opened ? 1 : 0
1450
+ var index = items.findIndex(function (_ref6) {
1451
+ var id = _ref6.id;
1452
+ return id === screenId;
1175
1453
  });
1176
- }, [opened]);
1177
-
1178
- var _useDimensionObserver = useDimensionObserver(),
1179
- menuPreviewContainerRef = _useDimensionObserver.ref,
1180
- _useDimensionObserver2 = _useDimensionObserver.height,
1181
- menuPreviewContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
1454
+ trackScreenEvent('viewer_menu', 'click_screen_change', "Screen ".concat(index + 1));
1455
+ }, [customOnClickScreen, setMenuOpened, items, screenId, trackScreenEvent]);
1456
+ var onShare = useCallback(function (type) {
1457
+ // @todo display something to say thanks for sharing?
1458
+ trackScreenEvent('viewer_menu', 'shared_story', type);
1459
+ }, [trackScreenEvent]);
1460
+ var computeShareProgress = useCallback(function (_ref7) {
1461
+ var active = _ref7.active,
1462
+ _ref7$direction = _slicedToArray(_ref7.direction, 2),
1463
+ dy = _ref7$direction[1],
1464
+ _ref7$movement = _slicedToArray(_ref7.movement, 2),
1465
+ my = _ref7$movement[1],
1466
+ _ref7$velocity = _slicedToArray(_ref7.velocity, 2),
1467
+ vy = _ref7$velocity[1];
1468
+
1469
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1470
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1471
+
1472
+ if (!active) {
1473
+ if (reachedThreshold) onOpenShare();
1474
+ return reachedThreshold ? 1 : 0;
1475
+ }
1182
1476
 
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;
1477
+ return progress;
1478
+ }, [onOpenShare]);
1479
+ var computeShareProgressClose = useCallback(function (_ref8) {
1480
+ var active = _ref8.active,
1481
+ _ref8$direction = _slicedToArray(_ref8.direction, 2),
1482
+ dy = _ref8$direction[1],
1483
+ _ref8$movement = _slicedToArray(_ref8.movement, 2),
1484
+ my = _ref8$movement[1],
1485
+ _ref8$velocity = _slicedToArray(_ref8.velocity, 2),
1486
+ vy = _ref8$velocity[1];
1487
+
1488
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1489
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1490
+
1491
+ if (!active) {
1492
+ if (reachedThreshold) onCloseShare();
1493
+ return reachedThreshold ? 0 : 1;
1201
1494
  }
1202
1495
 
1203
- var isMenuOpened = refOpened.current;
1496
+ return 1 - progress;
1497
+ }, [onCloseShare]);
1204
1498
 
1205
- if (first) {
1206
- if (isMenuOpened) {
1207
- cancel();
1208
- return;
1499
+ var _useDragProgress = useDragProgress({
1500
+ progress: shareOpened ? 1 : 0,
1501
+ computeProgress: shareOpened ? computeShareProgressClose : computeShareProgress,
1502
+ springParams: {
1503
+ config: {
1504
+ tension: 300,
1505
+ friction: 30
1209
1506
  }
1210
1507
  }
1508
+ }),
1509
+ bindShareDrag = _useDragProgress.bind,
1510
+ shareOpenedProgress = _useDragProgress.progress;
1211
1511
 
1212
- var yProgress = Math.max(0, Math.min(1, my / menuPreviewContainerHeight + (isMenuOpened ? 1 : 0)));
1512
+ var computeMenuProgress = useCallback(function (_ref9) {
1513
+ var active = _ref9.active,
1514
+ _ref9$direction = _slicedToArray(_ref9.direction, 2),
1515
+ dy = _ref9$direction[1],
1516
+ _ref9$movement = _slicedToArray(_ref9.movement, 2),
1517
+ my = _ref9$movement[1],
1518
+ _ref9$velocity = _slicedToArray(_ref9.velocity, 2),
1519
+ vy = _ref9$velocity[1];
1213
1520
 
1214
- if (last) {
1215
- var menuNowOpened = dy > 0 && yProgress > 0.1;
1216
- refOpened.current = menuNowOpened;
1217
- setMenuSpring.start({
1218
- y: menuNowOpened ? 1 : 0
1219
- });
1521
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1522
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1220
1523
 
1221
- if (menuNowOpened && onRequestOpen !== null) {
1222
- onRequestOpen();
1223
- } else if (!menuNowOpened && onRequestClose !== null) {
1224
- onRequestClose();
1225
- }
1226
- } else {
1227
- setMenuSpring.start({
1228
- y: yProgress
1229
- });
1524
+ if (!active) {
1525
+ if (reachedThreshold) onOpenMenu();
1526
+ return reachedThreshold ? 1 : 0;
1230
1527
  }
1231
- }, {
1232
- axis: 'y',
1233
- filterTaps: true
1234
- }); // handle preview menu item click
1235
1528
 
1236
- var onClickMenu = useCallback(function (index) {
1237
- if (customOnClickMenu !== null) {
1238
- customOnClickMenu(index);
1529
+ return progress;
1530
+ }, [onOpenMenu]);
1531
+ var computeMenuProgressClose = useCallback(function (_ref10) {
1532
+ var active = _ref10.active,
1533
+ _ref10$direction = _slicedToArray(_ref10.direction, 2),
1534
+ dy = _ref10$direction[1],
1535
+ _ref10$movement = _slicedToArray(_ref10.movement, 2),
1536
+ my = _ref10$movement[1],
1537
+ _ref10$velocity = _slicedToArray(_ref10.velocity, 2),
1538
+ vy = _ref10$velocity[1];
1539
+
1540
+ var progress = Math.max(0, my) / (window.innerHeight * 0.8);
1541
+ var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
1542
+
1543
+ if (!active) {
1544
+ if (reachedThreshold) onCloseMenu();
1545
+ return reachedThreshold ? 0 : 1;
1239
1546
  }
1240
1547
 
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
- }
1548
+ return 1 - progress;
1549
+ }, [onCloseMenu]);
1247
1550
 
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();
1551
+ var _useDragProgress2 = useDragProgress({
1552
+ progress: menuOpened ? 1 : 0,
1553
+ computeProgress: menuOpened ? computeMenuProgressClose : computeMenuProgress,
1554
+ springParams: {
1555
+ config: {
1556
+ tension: 300,
1557
+ friction: 30
1558
+ }
1257
1559
  }
1560
+ }),
1561
+ bindMenuDrag = _useDragProgress2.bind,
1562
+ menuOpenedProgress = _useDragProgress2.progress;
1258
1563
 
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;
1564
+ var keyboardShortcuts = useMemo(function () {
1565
+ return {
1566
+ m: function m() {
1567
+ return !menuOpened ? onOpenMenu() : onCloseMenu();
1568
+ },
1569
+ escape: function escape() {
1570
+ return onCloseMenu();
1571
+ }
1572
+ };
1573
+ }, [menuOpened, onOpenMenu, onCloseMenu]);
1574
+ useKeyboardShortcuts(keyboardShortcuts); // should be zero if either screens menu or share menu is opened
1269
1575
 
1270
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", Object.assign({
1271
- className: styles$6.menuDotsContainer,
1576
+ var dotsOpacity = Math.min(1, Math.max(0, 1 - (menuOpenedProgress + shareOpenedProgress)));
1577
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1578
+ className: classNames([styles$6.menuNavContainer, (_ref11 = {}, _defineProperty(_ref11, styles$6.withShadow, withShadow), _defineProperty(_ref11, styles$6.isOpened, menuOpened || shareOpened), _ref11)]),
1272
1579
  ref: refDots,
1273
1580
  style: {
1274
1581
  width: menuWidth
1275
1582
  }
1276
- }, menuDragBind()), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
1583
+ }, /*#__PURE__*/React.createElement("nav", {
1584
+ className: styles$6.menuTopContainer
1585
+ }, !withoutShareMenu ? /*#__PURE__*/React.createElement("div", Object.assign({
1586
+ className: classNames([styles$6.menuItem, styles$6.menuShare])
1587
+ }, bindShareDrag()), /*#__PURE__*/React.createElement(ToggleButton, {
1588
+ className: styles$6.slidingButton,
1589
+ button: /*#__PURE__*/React.createElement(ShareButton, {
1590
+ className: styles$6.menuButton,
1591
+ onClick: onOpenShare,
1592
+ theme: menuTheme,
1593
+ iconPosition: "left"
1594
+ }),
1595
+ toggledButton: /*#__PURE__*/React.createElement(CloseButton, {
1596
+ className: styles$6.menuButton,
1597
+ onClick: onCloseShare,
1598
+ theme: menuTheme,
1599
+ iconPosition: "left"
1600
+ }),
1601
+ toggled: shareOpenedProgress
1602
+ })) : null, !withoutScreensMenu ? /*#__PURE__*/React.createElement("div", Object.assign({
1603
+ className: classNames([styles$6.menuItem, styles$6.menuItemScreens])
1604
+ }, bindMenuDrag()), /*#__PURE__*/React.createElement(ToggleButton, {
1605
+ className: styles$6.slidingButton,
1606
+ button: /*#__PURE__*/React.createElement(MenuButton, {
1607
+ className: styles$6.menuButton,
1608
+ onClick: onOpenMenu,
1609
+ theme: menuTheme
1610
+ }),
1611
+ toggledButton: /*#__PURE__*/React.createElement(CloseButton, {
1612
+ className: styles$6.menuButton,
1613
+ onClick: onCloseMenu,
1614
+ theme: menuTheme,
1615
+ iconPosition: "right"
1616
+ }),
1617
+ toggled: menuOpenedProgress,
1618
+ toggledButtonClassName: styles$6.screensMenuButtonToggled
1619
+ })) : null), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
1277
1620
  direction: "horizontal",
1278
- withShadow: withShadow,
1279
1621
  items: items,
1280
- title: title,
1281
- shareUrl: shareUrl,
1282
- onShare: onClickShare,
1283
- onClickItem: onClickItem,
1284
- onClickMenu: onClickMenu,
1622
+ onClickDot: onClickScreen,
1623
+ onClickScreensMenu: onOpenMenu,
1285
1624
  closeable: closeable,
1286
1625
  withItemClick: withDotItemClick,
1287
1626
  withoutScreensMenu: withoutScreensMenu,
1627
+ withoutShareMenu: withoutShareMenu,
1288
1628
  onClose: onClickCloseViewer,
1289
- className: styles$6.menuDots
1290
- }))), /*#__PURE__*/React.createElement(animated.div, {
1291
- className: styles$6.menuPreviewContainer,
1292
- style: menuPreviewStyle,
1293
- ref: menuPreviewContainerRef
1294
- }, /*#__PURE__*/React.createElement(ViewerMenuPreview, {
1629
+ className: styles$6.dots,
1630
+ style: {
1631
+ opacity: Math.pow(dotsOpacity, 5),
1632
+ // @note this is like a "quint" easing, meaning it'll go towards 1 slowly first and then fast as it approaches 1
1633
+ pointerEvents: dotsOpacity < 1 ? 'none' : 'auto'
1634
+ }
1635
+ }))), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
1636
+ className: styles$6.menuContainerShare,
1637
+ transitionProgress: shareOpenedProgress
1638
+ }, shareOpenedProgress > 0 ? /*#__PURE__*/React.createElement(ViewerMenuShare, {
1639
+ viewerTheme: viewerTheme,
1640
+ className: styles$6.menuShare,
1641
+ title: title,
1642
+ description: description,
1643
+ menuWidth: menuWidth,
1644
+ focusable: shareOpened,
1645
+ items: items,
1646
+ currentScreenIndex: currentScreenIndex,
1647
+ shareUrl: shareUrl,
1648
+ onShare: onShare,
1649
+ onClose: onCloseShare
1650
+ }) : null), /*#__PURE__*/React.createElement(ViewerMenuContainer, {
1651
+ className: styles$6.menuContainerScreens,
1652
+ transitionProgress: menuOpenedProgress
1653
+ }, menuOpenedProgress > 0 ? /*#__PURE__*/React.createElement(ViewerMenuPreview, {
1295
1654
  viewerTheme: viewerTheme,
1296
1655
  className: styles$6.menuPreview,
1297
1656
  screenSize: screenSize,
1298
1657
  menuWidth: menuWidth,
1299
- focusable: opened,
1300
1658
  items: items,
1301
- onClickItem: onClickItem,
1302
- onClose: onClickClose,
1659
+ currentScreenIndex: currentScreenIndex,
1660
+ shareUrl: shareUrl,
1661
+ onShare: onShare,
1662
+ onClickScreen: onClickScreen,
1663
+ onClose: onCloseMenu,
1303
1664
  toggleFullscreen: toggleFullscreen,
1304
1665
  fullscreenActive: fullscreenActive,
1305
1666
  fullscreenEnabled: fullscreenEnabled
1306
- })));
1667
+ }) : null));
1307
1668
  };
1308
1669
 
1309
- ViewerMenu.propTypes = propTypes$a;
1310
- ViewerMenu.defaultProps = defaultProps$a;
1311
-
1312
- var styles$5 = {"container":"micromag-viewer-partials-hand-tap-container","circle":"micromag-viewer-partials-hand-tap-circle","pulse":"micromag-viewer-partials-hand-tap-pulse","hand":"micromag-viewer-partials-hand-tap-hand","panY":"micromag-viewer-partials-hand-tap-panY","inner":"micromag-viewer-partials-hand-tap-inner","shadowFade":"micromag-viewer-partials-hand-tap-shadowFade"};
1313
-
1314
- var propTypes$9 = {
1315
- color: PropTypes.string,
1316
- className: PropTypes.string
1317
- };
1318
- var defaultProps$9 = {
1319
- color: 'currentColor',
1320
- className: null
1321
- };
1322
-
1323
- var HandIcon = function HandIcon(_ref) {
1324
- var color = _ref.color,
1325
- className = _ref.className;
1326
- return /*#__PURE__*/React.createElement("svg", {
1327
- className: className,
1328
- xmlns: "http://www.w3.org/2000/svg",
1329
- viewBox: "0 0 367.24 482.87"
1330
- }, /*#__PURE__*/React.createElement("path", {
1331
- d: "M488.84,255.91a44.68,44.68,0,0,0-19.15,4.3A44.77,44.77,0,0,0,406,226.49a44.75,44.75,0,0,0-62.67-32.66V105.4a44.81,44.81,0,1,0-89.61,0V265.17l-1.15-2.7a44.78,44.78,0,1,0-82.84,34.06l64.87,157.76.34.73a156.29,156.29,0,0,0,141.42,88.44c86.7,0,157.24-70.53,157.24-157.26V300.7a44.82,44.82,0,0,0-44.78-44.79ZM507.46,386.2c0,72.3-58.78,131.1-131.07,131.1a130.29,130.29,0,0,1-117.73-73.36L193.93,286.61a18.64,18.64,0,1,1,34.53-14.07L279.91,394V105.4a18.64,18.64,0,1,1,37.28,0v196a13.08,13.08,0,0,0,26.16,0V234.56a18.64,18.64,0,0,1,37.27,0v89.95a13.07,13.07,0,1,0,26.13,0V266.86a18.64,18.64,0,1,1,37.28,0v80.71h0s0,.08,0,.11a13.08,13.08,0,0,0,26.15,0v-47a18.63,18.63,0,1,1,37.26,0v85.5Z",
1332
- transform: "translate(-166.38 -60.59)",
1333
- fill: color,
1334
- fillRule: "evenodd"
1335
- }));
1336
- };
1670
+ ViewerMenu.propTypes = propTypes$9;
1671
+ ViewerMenu.defaultProps = defaultProps$9;
1337
1672
 
1338
- HandIcon.propTypes = propTypes$9;
1339
- HandIcon.defaultProps = defaultProps$9;
1673
+ var styles$5 = {"container":"micromag-viewer-screen-container","navigationHint":"micromag-viewer-screen-navigationHint"};
1340
1674
 
1341
1675
  var propTypes$8 = {
1342
- className: PropTypes.string
1343
- };
1344
- var defaultProps$8 = {
1345
- className: null
1346
- };
1347
-
1348
- var HandTap = function HandTap(_ref) {
1349
- var className = _ref.className;
1350
- return /*#__PURE__*/React.createElement("div", {
1351
- className: classNames([styles$5.container, _defineProperty({}, className, className !== null)])
1352
- }, /*#__PURE__*/React.createElement("div", {
1353
- className: styles$5.inner
1354
- }, /*#__PURE__*/React.createElement("div", {
1355
- className: styles$5.circle
1356
- }), /*#__PURE__*/React.createElement(HandIcon, {
1357
- className: styles$5.hand
1358
- })));
1359
- };
1360
-
1361
- HandTap.propTypes = propTypes$8;
1362
- HandTap.defaultProps = defaultProps$8;
1363
-
1364
- var styles$4 = {"container":"micromag-viewer-screen-container","handTap":"micromag-viewer-screen-handTap"};
1365
-
1366
- var propTypes$7 = {
1367
1676
  screen: PropTypes$1.screenComponent,
1368
1677
  renderContext: PropTypes$1.renderContext,
1369
1678
  screenState: PropTypes.string,
@@ -1373,10 +1682,10 @@ var propTypes$7 = {
1373
1682
  width: PropTypes.number,
1374
1683
  height: PropTypes.number,
1375
1684
  scale: PropTypes.number,
1376
- withNavigationHint: PropTypes.func,
1685
+ // withNavigationHint: PropTypes.bool, // @todo
1377
1686
  className: PropTypes.string
1378
1687
  };
1379
- var defaultProps$7 = {
1688
+ var defaultProps$8 = {
1380
1689
  screen: null,
1381
1690
  renderContext: null,
1382
1691
  screenState: null,
@@ -1386,7 +1695,7 @@ var defaultProps$7 = {
1386
1695
  width: null,
1387
1696
  height: null,
1388
1697
  scale: null,
1389
- withNavigationHint: false,
1698
+ // withNavigationHint: false,
1390
1699
  className: null
1391
1700
  };
1392
1701
 
@@ -1400,10 +1709,9 @@ function ViewerScreen(_ref) {
1400
1709
  width = _ref.width,
1401
1710
  height = _ref.height,
1402
1711
  scale = _ref.scale,
1403
- withNavigationHint = _ref.withNavigationHint,
1404
1712
  className = _ref.className;
1405
1713
  return /*#__PURE__*/React.createElement("div", {
1406
- className: classNames([styles$4.container, _defineProperty({}, className, className !== null)])
1714
+ className: classNames([styles$5.container, _defineProperty({}, className, className !== null)])
1407
1715
  }, /*#__PURE__*/React.createElement("div", {
1408
1716
  style: {
1409
1717
  width: width,
@@ -1418,62 +1726,131 @@ function ViewerScreen(_ref) {
1418
1726
  active: active,
1419
1727
  current: current,
1420
1728
  mediaRef: mediaRef
1421
- })), withNavigationHint ? /*#__PURE__*/React.createElement(HandTap, {
1422
- className: styles$4.handTap
1423
- }) : null);
1729
+ })));
1424
1730
  }
1425
1731
 
1426
- ViewerScreen.propTypes = propTypes$7;
1427
- ViewerScreen.defaultProps = defaultProps$7;
1732
+ ViewerScreen.propTypes = propTypes$8;
1733
+ ViewerScreen.defaultProps = defaultProps$8;
1734
+
1735
+ var styles$4 = {"arrow":"micromag-viewer-buttons-navigation-button-arrow","next":"micromag-viewer-buttons-navigation-button-next","previous":"micromag-viewer-buttons-navigation-button-previous"};
1736
+
1737
+ var propTypes$7 = {
1738
+ direction: PropTypes.oneOf(['previous', 'next']),
1739
+ onClick: PropTypes.func,
1740
+ className: PropTypes.string
1741
+ };
1742
+ var defaultProps$7 = {
1743
+ direction: 'next',
1744
+ onClick: null,
1745
+ className: null
1746
+ };
1747
+
1748
+ var NavigationButton = function NavigationButton(_ref) {
1749
+ var direction = _ref.direction,
1750
+ onClick = _ref.onClick,
1751
+ className = _ref.className;
1752
+ return /*#__PURE__*/React.createElement(IconButton, {
1753
+ className: classNames([styles$4.container, styles$4[direction], _defineProperty({}, className, className !== null)]),
1754
+ onClick: onClick,
1755
+ iconPosition: direction === 'next' ? 'right' : 'left',
1756
+ icon: /*#__PURE__*/React.createElement("svg", {
1757
+ className: styles$4.arrow,
1758
+ xmlns: "http://www.w3.org/2000/svg",
1759
+ width: "10",
1760
+ height: "16",
1761
+ viewBox: "0 0 10 16",
1762
+ fill: "currentColor"
1763
+ }, /*#__PURE__*/React.createElement("polygon", {
1764
+ 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"
1765
+ })),
1766
+ label: /*#__PURE__*/React.createElement("span", {
1767
+ className: "sr-only"
1768
+ }, direction === 'previous' ? /*#__PURE__*/React.createElement(FormattedMessage, {
1769
+ id: "zYH/31",
1770
+ defaultMessage: [{
1771
+ "type": 0,
1772
+ "value": "Go to previous screen"
1773
+ }]
1774
+ }) : /*#__PURE__*/React.createElement(FormattedMessage, {
1775
+ id: "v9bqYj",
1776
+ defaultMessage: [{
1777
+ "type": 0,
1778
+ "value": "Go to next screen"
1779
+ }]
1780
+ }))
1781
+ });
1782
+ };
1783
+
1784
+ NavigationButton.propTypes = propTypes$7;
1785
+ NavigationButton.defaultProps = defaultProps$7;
1428
1786
 
1429
- var styles$3 = {"container":"micromag-viewer-partials-navigation-button-container"};
1787
+ var styles$3 = {"container":"micromag-viewer-partials-arrow-hint-container","inner":"micromag-viewer-partials-arrow-hint-inner","shadowFade":"micromag-viewer-partials-arrow-hint-shadowFade","arrow":"micromag-viewer-partials-arrow-hint-arrow","panX":"micromag-viewer-partials-arrow-hint-panX"};
1430
1788
 
1431
1789
  var propTypes$6 = {
1432
- direction: PropTypes.oneOf(['previous', 'next']),
1433
- onClick: null,
1434
1790
  className: PropTypes.string
1435
1791
  };
1436
1792
  var defaultProps$6 = {
1437
- direction: 'next',
1438
- onClick: null,
1439
1793
  className: null
1440
1794
  };
1441
1795
 
1442
- var NavigationButton = function NavigationButton(_ref) {
1443
- var direction = _ref.direction,
1444
- onClick = _ref.onClick,
1445
- 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, {
1796
+ var ArrowHint = function ArrowHint(_ref) {
1797
+ var className = _ref.className;
1798
+ return /*#__PURE__*/React.createElement("div", {
1799
+ className: classNames([styles$3.container, _defineProperty({}, className, className !== null)])
1800
+ }, /*#__PURE__*/React.createElement("div", {
1801
+ className: styles$3.inner
1802
+ }, /*#__PURE__*/React.createElement("svg", {
1451
1803
  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
- })));
1804
+ xmlns: "http://www.w3.org/2000/svg",
1805
+ width: "10",
1806
+ height: "16",
1807
+ viewBox: "0 0 10 16",
1808
+ fill: "currentColor"
1809
+ }, /*#__PURE__*/React.createElement("polygon", {
1810
+ 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"
1811
+ }))));
1812
+ };
1813
+
1814
+ ArrowHint.propTypes = propTypes$6;
1815
+ ArrowHint.defaultProps = defaultProps$6;
1816
+
1817
+ 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"};
1818
+
1819
+ var stopDragEventsPropagation = {
1820
+ onTouchMove: function onTouchMove(e) {
1821
+ return e.stopPropagation();
1822
+ },
1823
+ onTouchStart: function onTouchStart(e) {
1824
+ return e.stopPropagation();
1825
+ },
1826
+ onTouchEnd: function onTouchEnd(e) {
1827
+ return e.stopPropagation();
1828
+ },
1829
+ onPointerMove: function onPointerMove(e) {
1830
+ return e.stopPropagation();
1831
+ },
1832
+ onPointerUp: function onPointerUp(e) {
1833
+ return e.stopPropagation();
1834
+ },
1835
+ onPointerDown: function onPointerDown(e) {
1836
+ return e.stopPropagation();
1837
+ }
1468
1838
  };
1469
1839
 
1470
- NavigationButton.propTypes = propTypes$6;
1471
- NavigationButton.defaultProps = defaultProps$6;
1840
+ function getFormattedTimestamp(s) {
1841
+ var withMilliseconds = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1842
+ var sparts = withMilliseconds ? "".concat(s).split('.') : [];
1843
+ var ms = sparts.length > 1 ? ":".concat(sparts[1].substring(0, 3)) : '';
1844
+ return (s - (s %= 60)) / 60 + (9 < s ? ':' : ':0') + ~~s + ms; // eslint-disable-line
1845
+ }
1472
1846
 
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"};
1847
+ var SHOW_MILLISECONDS_THRESHOLD = 5; // show milliseconds when scrubbing if length of video is shorter than 5 seconds
1474
1848
 
1475
1849
  var propTypes$5 = {
1476
- media: PropTypes.node,
1850
+ media: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
1851
+ current: PropTypes.any
1852
+ }) // eslint-disable-line
1853
+ ]),
1477
1854
  playing: PropTypes.bool,
1478
1855
  backgroundColor: PropTypes.string,
1479
1856
  progressColor: PropTypes.string,
@@ -1498,7 +1875,7 @@ var defaultProps$5 = {
1498
1875
  };
1499
1876
 
1500
1877
  var SeekBar = function SeekBar(_ref) {
1501
- var _ref3;
1878
+ var _ref4;
1502
1879
 
1503
1880
  var media = _ref.media,
1504
1881
  playing = _ref.playing,
@@ -1514,13 +1891,26 @@ var SeekBar = function SeekBar(_ref) {
1514
1891
  var progress = useMediaProgress(media, {
1515
1892
  disabled: !playing
1516
1893
  });
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;
1894
+
1895
+ var _ref2 = media || {},
1896
+ _ref2$currentTime = _ref2.currentTime,
1897
+ currentTime = _ref2$currentTime === void 0 ? null : _ref2$currentTime,
1898
+ _ref2$duration = _ref2.duration,
1899
+ duration = _ref2$duration === void 0 ? null : _ref2$duration;
1900
+
1901
+ var _useState = useState(false),
1902
+ _useState2 = _slicedToArray(_useState, 2),
1903
+ showTimestamp = _useState2[0],
1904
+ setShowTimestamp = _useState2[1];
1905
+
1906
+ var onDrag = useCallback(function (_ref3) {
1907
+ _ref3.event;
1908
+ var _ref3$xy = _slicedToArray(_ref3.xy, 1),
1909
+ x = _ref3$xy[0],
1910
+ elapsedTime = _ref3.elapsedTime,
1911
+ active = _ref3.active,
1912
+ tap = _ref3.tap,
1913
+ currentTarget = _ref3.currentTarget;
1524
1914
 
1525
1915
  if (!active && elapsedTime > 300) {
1526
1916
  return;
@@ -1537,15 +1927,18 @@ var SeekBar = function SeekBar(_ref) {
1537
1927
  }
1538
1928
  }, [onSeek]);
1539
1929
  var onDragStart = useCallback(function () {
1930
+ setShowTimestamp(true);
1931
+
1540
1932
  if (onSeekStart !== null) {
1541
1933
  onSeekStart();
1542
1934
  }
1543
- }, [onSeekStart]);
1935
+ }, [onSeekStart, setShowTimestamp]);
1544
1936
  var onDragEnd = useCallback(function () {
1545
1937
  if (onSeekEnd !== null) {
1938
+ setShowTimestamp(false);
1546
1939
  onSeekEnd();
1547
1940
  }
1548
- }, [onSeekEnd]);
1941
+ }, [onSeekEnd, setShowTimestamp]);
1549
1942
  var bind = useGesture({
1550
1943
  onDrag: onDrag,
1551
1944
  onDragStart: onDragStart,
@@ -1556,9 +1949,9 @@ var SeekBar = function SeekBar(_ref) {
1556
1949
  filterTaps: true
1557
1950
  }
1558
1951
  });
1559
- return /*#__PURE__*/React.createElement("div", {
1560
- className: classNames([styles$2.container, (_ref3 = {}, _defineProperty(_ref3, className, className !== null), _defineProperty(_ref3, styles$2.withSeekHead, withSeekHead), _ref3)])
1561
- }, /*#__PURE__*/React.createElement("div", {
1952
+ return /*#__PURE__*/React.createElement("div", Object.assign({
1953
+ className: classNames([styles$2.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$2.withSeekHead, withSeekHead), _defineProperty(_ref4, styles$2.showTimestamp, showTimestamp), _ref4)])
1954
+ }, stopDragEventsPropagation), /*#__PURE__*/React.createElement("div", {
1562
1955
  className: styles$2.inner
1563
1956
  }, /*#__PURE__*/React.createElement("div", {
1564
1957
  className: styles$2.progressBar,
@@ -1571,7 +1964,12 @@ var SeekBar = function SeekBar(_ref) {
1571
1964
  left: "".concat(progress * 100, "%"),
1572
1965
  backgroundColor: progressColor
1573
1966
  }
1574
- }), /*#__PURE__*/React.createElement("div", {
1967
+ }, /*#__PURE__*/React.createElement("div", {
1968
+ className: styles$2.scrubbedTime,
1969
+ style: {
1970
+ borderColor: progressColor
1971
+ }
1972
+ }, getFormattedTimestamp(currentTime, duration < SHOW_MILLISECONDS_THRESHOLD))), /*#__PURE__*/React.createElement("div", {
1575
1973
  className: styles$2.progress,
1576
1974
  style: {
1577
1975
  transform: "scaleX(".concat(progress, ")"),
@@ -1601,7 +1999,7 @@ var SeekBar = function SeekBar(_ref) {
1601
1999
  SeekBar.propTypes = propTypes$5;
1602
2000
  SeekBar.defaultProps = defaultProps$5;
1603
2001
 
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"};
2002
+ 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
2003
 
1606
2004
  var propTypes$4 = {
1607
2005
  className: PropTypes.string,
@@ -1706,7 +2104,8 @@ function PlaybackControls(_ref) {
1706
2104
  setPlaying(true);
1707
2105
  }
1708
2106
  }, [setPlaying, wasPlaying]);
1709
- var mediaHasAudio = mediaElement !== null && (hasAudio === null || hasAudio === true);
2107
+ var hasMedia = mediaElement !== null;
2108
+ var mediaHasAudio = hasMedia && (hasAudio === null || hasAudio === true);
1710
2109
 
1711
2110
  var _ref3 = customControlsTheme || {},
1712
2111
  color = _ref3.color,
@@ -1715,33 +2114,55 @@ function PlaybackControls(_ref) {
1715
2114
 
1716
2115
  var isCollapsed = controls && !controlsVisible && playing || !controls && mediaHasAudio;
1717
2116
  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",
2117
+ 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)])
2118
+ }, /*#__PURE__*/React.createElement(Button$1, {
1721
2119
  className: styles$1.playPauseButton,
1722
2120
  style: {
1723
2121
  color: color
1724
2122
  },
1725
2123
  onClick: playing ? onPause : onPlay,
1726
- title: intl.formatMessage({
1727
- id: "ahSpiH",
2124
+ focusable: controlsVisible,
2125
+ icon: playing ? /*#__PURE__*/React.createElement("svg", {
2126
+ className: styles$1.icon,
2127
+ xmlns: "http://www.w3.org/2000/svg",
2128
+ width: "10",
2129
+ height: "16",
2130
+ viewBox: "0 0 10 16",
2131
+ fill: "currentColor"
2132
+ }, /*#__PURE__*/React.createElement("rect", {
2133
+ x: "1",
2134
+ y: "3.27",
2135
+ width: "3",
2136
+ height: "9.69"
2137
+ }), /*#__PURE__*/React.createElement("rect", {
2138
+ x: "6",
2139
+ y: "3.27",
2140
+ width: "3",
2141
+ height: "9.69"
2142
+ })) : /*#__PURE__*/React.createElement("svg", {
2143
+ className: styles$1.icon,
2144
+ xmlns: "http://www.w3.org/2000/svg",
2145
+ width: "10",
2146
+ height: "16",
2147
+ viewBox: "0 0 10 16",
2148
+ fill: "currentColor"
2149
+ }, /*#__PURE__*/React.createElement("path", {
2150
+ d: "M1,3.16V12.84l8-4.84L1,3.16"
2151
+ })),
2152
+ "aria-label": playing ? intl.formatMessage({
2153
+ id: "mTqcmA",
1728
2154
  defaultMessage: [{
1729
2155
  "type": 0,
1730
- "value": "Play"
2156
+ "value": "Pause"
1731
2157
  }]
1732
- }),
1733
- "aria-label": intl.formatMessage({
2158
+ }) : intl.formatMessage({
1734
2159
  id: "ahSpiH",
1735
2160
  defaultMessage: [{
1736
2161
  "type": 0,
1737
2162
  "value": "Play"
1738
2163
  }]
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, {
2164
+ })
2165
+ }), /*#__PURE__*/React.createElement(SeekBar, {
1745
2166
  className: styles$1.seekBar,
1746
2167
  media: mediaElement,
1747
2168
  playing: playing,
@@ -1752,32 +2173,54 @@ function PlaybackControls(_ref) {
1752
2173
  withSeekHead: !isCollapsed && !seekBarOnly,
1753
2174
  backgroundColor: color,
1754
2175
  progressColor: progressColor
1755
- }), /*#__PURE__*/React.createElement("button", {
1756
- type: "button",
1757
- className: classNames([styles$1.muteButton, _defineProperty({}, styles$1.isMuted, muted)]),
2176
+ }), /*#__PURE__*/React.createElement(Button$1, {
2177
+ className: styles$1.muteButton,
1758
2178
  style: {
1759
2179
  color: color
1760
2180
  },
1761
2181
  onClick: muted ? onUnmute : onMute,
1762
- title: intl.formatMessage({
1763
- id: "vzg8Es",
2182
+ focusable: controlsVisible || mediaHasAudio,
2183
+ icon: muted ? /*#__PURE__*/React.createElement("svg", {
2184
+ xmlns: "http://www.w3.org/2000/svg",
2185
+ width: "10",
2186
+ height: "16",
2187
+ viewBox: "0 0 10 16",
2188
+ className: styles$1.icon,
2189
+ fill: "currentColor"
2190
+ }, /*#__PURE__*/React.createElement("polygon", {
2191
+ 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"
2192
+ }), /*#__PURE__*/React.createElement("polygon", {
2193
+ 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"
2194
+ })) : /*#__PURE__*/React.createElement("svg", {
2195
+ xmlns: "http://www.w3.org/2000/svg",
2196
+ width: "10",
2197
+ height: "16",
2198
+ viewBox: "0 0 10 16",
2199
+ className: styles$1.icon,
2200
+ fill: "currentColor"
2201
+ }, /*#__PURE__*/React.createElement("polygon", {
2202
+ 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"
2203
+ }), /*#__PURE__*/React.createElement("circle", {
2204
+ cx: "6.14",
2205
+ cy: "8",
2206
+ r: ".99"
2207
+ }), /*#__PURE__*/React.createElement("path", {
2208
+ 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"
2209
+ })),
2210
+ "aria-label": muted ? intl.formatMessage({
2211
+ id: "RK/QEY",
1764
2212
  defaultMessage: [{
1765
2213
  "type": 0,
1766
- "value": "Mute"
2214
+ "value": "Unmute"
1767
2215
  }]
1768
- }),
1769
- "aria-label": intl.formatMessage({
2216
+ }) : intl.formatMessage({
1770
2217
  id: "vzg8Es",
1771
2218
  defaultMessage: [{
1772
2219
  "type": 0,
1773
2220
  "value": "Mute"
1774
2221
  }]
1775
- }),
1776
- tabIndex: controlsVisible || mediaHasAudio ? '0' : '-1'
1777
- }, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
1778
- className: styles$1.icon,
1779
- icon: faVolumeUp
1780
- })));
2222
+ })
2223
+ }));
1781
2224
  }
1782
2225
 
1783
2226
  PlaybackControls.propTypes = propTypes$4;
@@ -1870,6 +2313,15 @@ function WebViewContainer(_ref) {
1870
2313
  WebViewContainer.propTypes = propTypes$3;
1871
2314
  WebViewContainer.defaultProps = defaultProps$3;
1872
2315
 
2316
+ var SPRING_CONFIG_TIGHT = {
2317
+ tension: 300,
2318
+ friction: 35
2319
+ }; // tight
2320
+
2321
+ var DRAG_PROGRESS_ACTIVATION_THRESHOLD = 0.3;
2322
+ var DRAG_VELOCITY_ACTIVATION_THRESHOLD = 0.3;
2323
+ var DEFAULT_TRANSITION_TYPE_LANDSCAPE = 'carousel';
2324
+ var DEFAULT_TRANSITION_TYPE_PORTRAIT = 'stack';
1873
2325
  var propTypes$2 = {
1874
2326
  story: PropTypes$1.story,
1875
2327
  // .isRequired,
@@ -1884,16 +2336,20 @@ var propTypes$2 = {
1884
2336
  visitor: PropTypes$1.visitor,
1885
2337
  onScreenChange: PropTypes.func,
1886
2338
  tapNextScreenWidthPercent: PropTypes.number,
1887
- neighborScreensActive: PropTypes.number,
1888
- neighborScreensMounted: PropTypes.number,
1889
2339
  storyIsParsed: PropTypes.bool,
1890
- landscapeScreenMargin: PropTypes.number,
2340
+ neighborScreensActive: PropTypes.number,
2341
+ neighborScreenOffset: PropTypes.number,
2342
+ neighborScreenScale: PropTypes.number,
1891
2343
  withMetadata: PropTypes.bool,
2344
+ withoutGestures: PropTypes.bool,
1892
2345
  withoutMenu: PropTypes.bool,
1893
2346
  withoutScreensMenu: PropTypes.bool,
2347
+ withoutShareMenu: PropTypes.bool,
1894
2348
  withoutMenuShadow: PropTypes.bool,
1895
2349
  withoutFullscreen: PropTypes.bool,
1896
- withLandscapeSiblingsScreens: PropTypes.bool,
2350
+ withoutNavigationArrow: PropTypes.bool,
2351
+ withoutTransitions: PropTypes.bool,
2352
+ withNeighborScreens: PropTypes.bool,
1897
2353
  withNavigationHint: PropTypes.bool,
1898
2354
  withoutPlaybackControls: PropTypes.bool,
1899
2355
  closeable: PropTypes.bool,
@@ -1924,17 +2380,21 @@ var defaultProps$2 = {
1924
2380
  visitor: null,
1925
2381
  onScreenChange: null,
1926
2382
  tapNextScreenWidthPercent: 0.8,
1927
- neighborScreensActive: 1,
1928
- neighborScreensMounted: 1,
1929
2383
  storyIsParsed: false,
1930
- landscapeScreenMargin: 20,
2384
+ neighborScreensActive: 2,
2385
+ neighborScreenOffset: 105,
2386
+ neighborScreenScale: 0.8,
1931
2387
  withMetadata: false,
2388
+ withNeighborScreens: false,
2389
+ withNavigationHint: false,
2390
+ withoutGestures: false,
1932
2391
  withoutMenu: false,
1933
2392
  withoutScreensMenu: false,
2393
+ withoutShareMenu: false,
1934
2394
  withoutMenuShadow: false,
1935
2395
  withoutFullscreen: false,
1936
- withLandscapeSiblingsScreens: false,
1937
- withNavigationHint: false,
2396
+ withoutTransitions: false,
2397
+ withoutNavigationArrow: false,
1938
2398
  withoutPlaybackControls: false,
1939
2399
  menuIsScreenWidth: false,
1940
2400
  closeable: false,
@@ -1962,16 +2422,20 @@ var Viewer = function Viewer(_ref) {
1962
2422
  renderContext = _ref.renderContext,
1963
2423
  visitor = _ref.visitor,
1964
2424
  tapNextScreenWidthPercent = _ref.tapNextScreenWidthPercent,
1965
- neighborScreensActive = _ref.neighborScreensActive,
1966
- neighborScreensMounted = _ref.neighborScreensMounted,
1967
2425
  storyIsParsed = _ref.storyIsParsed,
1968
- landscapeScreenMargin = _ref.landscapeScreenMargin,
2426
+ neighborScreensActive = _ref.neighborScreensActive,
2427
+ neighborScreenOffset = _ref.neighborScreenOffset,
2428
+ neighborScreenScale = _ref.neighborScreenScale,
1969
2429
  withMetadata = _ref.withMetadata,
2430
+ withoutGestures = _ref.withoutGestures,
1970
2431
  withoutMenu = _ref.withoutMenu,
1971
2432
  withoutScreensMenu = _ref.withoutScreensMenu,
2433
+ withoutShareMenu = _ref.withoutShareMenu,
1972
2434
  withoutMenuShadow = _ref.withoutMenuShadow;
1973
2435
  _ref.withoutFullscreen;
1974
- var withLandscapeSiblingsScreens = _ref.withLandscapeSiblingsScreens,
2436
+ var withoutNavigationArrow = _ref.withoutNavigationArrow,
2437
+ withoutTransitions = _ref.withoutTransitions,
2438
+ withNeighborScreens = _ref.withNeighborScreens,
1975
2439
  withNavigationHint = _ref.withNavigationHint,
1976
2440
  withoutPlaybackControls = _ref.withoutPlaybackControls,
1977
2441
  menuIsScreenWidth = _ref.menuIsScreenWidth,
@@ -1985,7 +2449,10 @@ var Viewer = function Viewer(_ref) {
1985
2449
  screensMedias = _ref.screensMedias,
1986
2450
  screenSizeOptions = _ref.screenSizeOptions,
1987
2451
  className = _ref.className;
1988
- var intl = useIntl();
2452
+
2453
+ /**
2454
+ * Screen Data + Processing
2455
+ */
1989
2456
  var parsedStory = useParsedStory(story, {
1990
2457
  disabled: storyIsParsed
1991
2458
  }) || {};
@@ -1997,20 +2464,59 @@ var Viewer = function Viewer(_ref) {
1997
2464
  metadata = _parsedStory$metadata === void 0 ? null : _parsedStory$metadata,
1998
2465
  _parsedStory$fonts = parsedStory.fonts,
1999
2466
  fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
2467
+ var screensCount = screens.length;
2000
2468
  var eventsManager = useMemo(function () {
2001
2469
  return new EventEmitter();
2002
- }, [parsedStory]); // Viewer Theme
2470
+ }, [parsedStory]);
2471
+ var screenIndex = useMemo(function () {
2472
+ return Math.max(0, screens.findIndex(function (it) {
2473
+ return "".concat(it.id) === "".concat(screenId);
2474
+ }));
2475
+ }, [screenId, screens]);
2476
+ var currentScreen = screens[screenIndex] || null;
2003
2477
 
2004
- var _ref2 = viewerTheme || {},
2005
- textStyles = _ref2.textStyles;
2478
+ var _ref2 = currentScreen || {},
2479
+ screenParameters = _ref2.parameters;
2480
+
2481
+ var _ref3 = screenParameters || {},
2482
+ screenMetadata = _ref3.metadata;
2483
+
2484
+ var _ref4 = screenMetadata || {},
2485
+ _ref4$title = _ref4.title,
2486
+ screenTitle = _ref4$title === void 0 ? null : _ref4$title,
2487
+ _ref4$description = _ref4.description,
2488
+ screenDescription = _ref4$description === void 0 ? null : _ref4$description;
2489
+
2490
+ var finalTitle = screenTitle !== null ? screenTitle : title;
2491
+ var finalMetadata = useMemo(function () {
2492
+ return screenDescription !== null ? _objectSpread(_objectSpread({}, metadata), {}, {
2493
+ description: screenDescription
2494
+ }) : metadata;
2495
+ }, [metadata, screenDescription]);
2496
+ var screensMediasRef = useRef([]);
2497
+
2498
+ if (currentScreenMedia !== null) {
2499
+ currentScreenMedia.current = screensMediasRef.current[screenIndex] || null;
2500
+ }
2501
+
2502
+ if (screensMedias !== null) {
2503
+ screensMedias.current = screensMediasRef.current;
2504
+ }
2505
+ /**
2506
+ * Screen Layout
2507
+ */
2006
2508
 
2007
- var _ref3 = textStyles || {},
2008
- _ref3$title = _ref3.title,
2009
- themeTextStyle = _ref3$title === void 0 ? null : _ref3$title;
2010
2509
 
2011
- var _ref4 = themeTextStyle || {},
2012
- _ref4$fontFamily = _ref4.fontFamily,
2013
- themeFont = _ref4$fontFamily === void 0 ? null : _ref4$fontFamily; // Fonts
2510
+ var _ref5 = viewerTheme || {},
2511
+ textStyles = _ref5.textStyles;
2512
+
2513
+ var _ref6 = textStyles || {},
2514
+ _ref6$title = _ref6.title,
2515
+ themeTextStyle = _ref6$title === void 0 ? null : _ref6$title;
2516
+
2517
+ var _ref7 = themeTextStyle || {},
2518
+ _ref7$fontFamily = _ref7.fontFamily,
2519
+ themeFont = _ref7$fontFamily === void 0 ? null : _ref7$fontFamily; // Fonts
2014
2520
 
2015
2521
 
2016
2522
  var finalFonts = useMemo(function () {
@@ -2037,8 +2543,12 @@ var Viewer = function Viewer(_ref) {
2037
2543
  _usePlaybackContext$m = _usePlaybackContext.media,
2038
2544
  playbackMedia = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m;
2039
2545
 
2040
- var trackScreenView = useTrackScreenView();
2041
- var contentRef = useRef(null); // Get screen size
2546
+ var _useDimensionObserver = useDimensionObserver(),
2547
+ playbackControlsContainerRef = _useDimensionObserver.ref,
2548
+ _useDimensionObserver2 = _useDimensionObserver.height,
2549
+ playbackControlsContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
2550
+
2551
+ var trackScreenView = useTrackScreenView(); // Get screen size
2042
2552
 
2043
2553
  var _useScreenSizeFromEle = useScreenSizeFromElement(_objectSpread({
2044
2554
  width: width,
@@ -2049,21 +2559,26 @@ var Viewer = function Viewer(_ref) {
2049
2559
  screenSize = _useScreenSizeFromEle.screenSize,
2050
2560
  screenScale = _useScreenSizeFromEle.scale;
2051
2561
 
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;
2562
+ var _ref8 = screenSize || {},
2563
+ _ref8$width = _ref8.width,
2564
+ screenWidth = _ref8$width === void 0 ? null : _ref8$width,
2565
+ _ref8$height = _ref8.height,
2566
+ screenHeight = _ref8$height === void 0 ? null : _ref8$height,
2567
+ _ref8$landscape = _ref8.landscape,
2568
+ landscape = _ref8$landscape === void 0 ? false : _ref8$landscape,
2569
+ _ref8$menuOverScreen = _ref8.menuOverScreen,
2570
+ menuOverScreen = _ref8$menuOverScreen === void 0 ? false : _ref8$menuOverScreen;
2061
2571
 
2062
2572
  var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
2063
2573
  var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
2064
2574
  var hasSize = screenWidth > 0 && screenHeight > 0;
2065
- var ready = hasSize; // && fontsLoaded;
2066
-
2575
+ var ready = hasSize;
2576
+ var trackingEnabled = isView;
2577
+ useEffect(function () {
2578
+ if (trackingEnabled && currentScreen !== null) {
2579
+ trackScreenView(currentScreen, screenIndex);
2580
+ }
2581
+ }, [currentScreen, trackScreenView, trackingEnabled]);
2067
2582
  useEffect(function () {
2068
2583
  if (ready && onViewModeChange !== null) {
2069
2584
  onViewModeChange({
@@ -2072,21 +2587,14 @@ var Viewer = function Viewer(_ref) {
2072
2587
  });
2073
2588
  }
2074
2589
  }, [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
- }
2590
+ /**
2591
+ * Screen Transitions
2592
+ */
2086
2593
 
2087
- if (screensMedias !== null) {
2088
- screensMedias.current = screensMediasRef.current;
2089
- }
2594
+ var transitionType = landscape && withNeighborScreens ? DEFAULT_TRANSITION_TYPE_LANDSCAPE : DEFAULT_TRANSITION_TYPE_PORTRAIT;
2595
+ /**
2596
+ * Screen Navigation
2597
+ */
2090
2598
 
2091
2599
  var changeIndex = useCallback(function (index) {
2092
2600
  if (index === screenIndex) {
@@ -2100,23 +2608,37 @@ var Viewer = function Viewer(_ref) {
2100
2608
  if (onScreenChange !== null) {
2101
2609
  onScreenChange(screens[index], index);
2102
2610
  }
2103
- }, [screenIndex, screens, onScreenChange]); // Track screen view
2611
+ }, [screenIndex, screens, onScreenChange]);
2612
+ var onScreenNavigate = useCallback(function (_ref9) {
2613
+ var index = _ref9.index,
2614
+ newIndex = _ref9.newIndex,
2615
+ end = _ref9.end,
2616
+ direction = _ref9.direction;
2104
2617
 
2105
- var trackingEnabled = isView;
2106
- var currentScreen = screens[screenIndex] || null;
2107
- useEffect(function () {
2108
- if (trackingEnabled && currentScreen !== null) {
2109
- trackScreenView(currentScreen, screenIndex);
2618
+ if (end && onEnd !== null) {
2619
+ onEnd();
2110
2620
  }
2111
- }, [currentScreen, trackScreenView, trackingEnabled]); // Handle interaction enable
2112
2621
 
2622
+ changeIndex(newIndex);
2623
+ eventsManager.emit('navigate', {
2624
+ index: index,
2625
+ newIndex: newIndex,
2626
+ direction: direction,
2627
+ end: end
2628
+ });
2629
+
2630
+ if (end) {
2631
+ eventsManager.emit('navigate_end');
2632
+ } else {
2633
+ eventsManager.emit("navigate_".concat(direction), newIndex);
2634
+ }
2635
+ }, [onEnd, changeIndex]);
2113
2636
  var gotoPreviousScreen = useCallback(function () {
2114
2637
  changeIndex(Math.max(0, screenIndex - 1));
2115
- }, [changeIndex]);
2638
+ }, [changeIndex, screenIndex]);
2116
2639
  var gotoNextScreen = useCallback(function () {
2117
2640
  changeIndex(Math.min(screens.length - 1, screenIndex + 1));
2118
- }, [changeIndex]);
2119
- var screensCount = screens.length;
2641
+ }, [changeIndex, screenIndex]);
2120
2642
 
2121
2643
  var _useState = useState(false),
2122
2644
  _useState2 = _slicedToArray(_useState, 2),
@@ -2132,37 +2654,12 @@ var Viewer = function Viewer(_ref) {
2132
2654
  setHasInteracted(true);
2133
2655
  }
2134
2656
  }, [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
2657
 
2160
2658
  var _useScreenInteraction = useScreenInteraction({
2161
2659
  screens: screens,
2162
2660
  screenIndex: screenIndex,
2163
2661
  screenWidth: screenContainerWidth,
2164
2662
  disableCurrentScreenNavigation: !isView,
2165
- clickOnSiblings: landscape && withLandscapeSiblingsScreens,
2166
2663
  nextScreenWidthPercent: tapNextScreenWidthPercent,
2167
2664
  onInteract: onInteractionPrivate,
2168
2665
  onNavigate: onScreenNavigate
@@ -2170,102 +2667,127 @@ var Viewer = function Viewer(_ref) {
2170
2667
  interactWithScreen = _useScreenInteraction.interact,
2171
2668
  currentScreenInteractionEnabled = _useScreenInteraction.currentScreenInteractionEnabled,
2172
2669
  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;
2670
+ disableInteraction = _useScreenInteraction.disableInteraction;
2671
+
2672
+ var onTap = useCallback(function (_ref10) {
2673
+ var currentTarget = _ref10.currentTarget,
2674
+ event = _ref10.event,
2675
+ target = _ref10.target,
2676
+ _ref10$xy = _slicedToArray(_ref10.xy, 2),
2677
+ x = _ref10$xy[0],
2678
+ y = _ref10$xy[1];
2679
+
2680
+ interactWithScreen({
2681
+ event: event,
2682
+ target: target,
2683
+ currentTarget: currentTarget,
2684
+ index: screenIndex,
2685
+ x: x,
2686
+ y: y
2687
+ });
2688
+ }, [interactWithScreen, screenIndex]);
2689
+ var computeScreenProgress = useCallback(function (_ref11) {
2690
+ var active = _ref11.active,
2691
+ _ref11$movement = _slicedToArray(_ref11.movement, 1),
2692
+ mx = _ref11$movement[0],
2693
+ _ref11$velocity = _slicedToArray(_ref11.velocity, 1),
2694
+ vx = _ref11$velocity[0];
2695
+
2696
+ var p = mx / screenContainerWidth; // drag "ratio": how much of the screen width has been swiped?
2697
+
2698
+ var forwards = mx < 0; // true if swiping to left (to navigate forwards)
2699
+
2700
+ var newIndex = !forwards ? screenIndex - 1 : screenIndex + 1; // which item index are we moving towards?
2701
+
2702
+ var reachedThreshold = vx > DRAG_VELOCITY_ACTIVATION_THRESHOLD || Math.abs(p) > DRAG_PROGRESS_ACTIVATION_THRESHOLD;
2703
+ var reachedBounds = newIndex < 0 || newIndex >= screensCount; // have we reached the end of the stack?
2704
+
2705
+ var damper = reachedBounds ? 0.1 : 1;
2706
+ var progress = Math.max(-1, Math.min(1, p * damper));
2707
+
2708
+ if (!active) {
2709
+ return reachedThreshold && !reachedBounds ? newIndex : screenIndex;
2211
2710
  }
2212
2711
 
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;
2712
+ return screenIndex - progress;
2713
+ }, [screenContainerWidth, screenIndex]);
2714
+ var onScreenProgress = useCallback(function (progress, _ref12) {
2715
+ var active = _ref12.active;
2716
+ var delta = Math.abs(progress - screenIndex);
2717
+ var reachedBounds = progress < 0 || progress >= screensCount; // have we reached the end of the stack?
2219
2718
 
2220
- var hasTappedLeft = x - contentX < contentWidth * 0.5;
2221
- var nextIndex = hasTappedLeft ? Math.max(0, screenIndex - 1) : Math.min(screensCount - 1, screenIndex + 1);
2719
+ if (!active && delta === 1 && !reachedBounds) {
2222
2720
  onScreenNavigate({
2223
2721
  index: screenIndex,
2224
- newIndex: nextIndex
2722
+ newIndex: progress
2225
2723
  });
2226
2724
  }
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;
2725
+ }, [onScreenNavigate, screenIndex]);
2726
+ var springParams = useMemo(function () {
2727
+ return {
2728
+ config: SPRING_CONFIG_TIGHT
2729
+ };
2730
+ }, []);
2731
+
2732
+ var _useDragProgress = useDragProgress({
2733
+ progress: screenIndex,
2734
+ disabled: !isView || withoutTransitions,
2735
+ dragDisabled: withoutGestures,
2736
+ computeProgress: computeScreenProgress,
2737
+ onProgress: onScreenProgress,
2738
+ onTap: onTap,
2739
+ springParams: springParams
2740
+ }),
2741
+ isDragging = _useDragProgress.dragging,
2742
+ screenIndexProgress = _useDragProgress.progress,
2743
+ dragContentBind = _useDragProgress.bind;
2744
+
2745
+ var getScreenStylesByIndex = function getScreenStylesByIndex(index, progress) {
2746
+ if (transitionType === 'stack') {
2747
+ var _t = index - progress;
2233
2748
 
2234
- if (key === 'Enter' && withLandscapeSiblingsScreens && landscape && i !== screenIndex) {
2235
- changeIndex(i);
2749
+ var _clamped = Math.min(1, Math.max(0, _t));
2750
+
2751
+ var invert = Math.min(1, Math.max(0, -_t));
2752
+ var opacity = Math.max(0, 1 - 0.75 * invert + (_t + 1));
2753
+ return {
2754
+ opacity: opacity,
2755
+ transform: "translateX(".concat(_clamped * 100, "%) scale(").concat(1 - 0.2 * invert, ")"),
2756
+ boxShadow: "0 0 ".concat(4 * (1 - _clamped), "rem ").concat(-0.5 * (1 - _clamped), "rem black"),
2757
+ zIndex: index
2758
+ };
2236
2759
  }
2237
- }, [withLandscapeSiblingsScreens, changeIndex, landscape, screenIndex]); // swipe menu open
2238
2760
 
2239
- var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
2761
+ var t = index - progress;
2762
+ var clamped = Math.min(1, Math.max(0, Math.abs(t)));
2763
+ return {
2764
+ opacity: 1 - 0.75 * clamped,
2765
+ transform: "translateX(".concat(t * neighborScreenOffset, "%) scale(").concat(1 - (1 - neighborScreenScale) * clamped, ")"),
2766
+ zIndex: screensCount - index
2767
+ };
2768
+ };
2240
2769
 
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;
2770
+ var _useFullscreen = useFullscreen(containerRef.current || null),
2771
+ toggleFullscreen = _useFullscreen.toggle,
2772
+ fullscreenActive = _useFullscreen.active,
2773
+ fullscreenEnabled = _useFullscreen.enabled;
2774
+
2775
+ var menuVisible = screensCount === 0 || currentScreenInteractionEnabled; // Get element height
2776
+
2777
+ var _useDimensionObserver3 = useDimensionObserver(),
2778
+ menuDotsContainerRef = _useDimensionObserver3.ref,
2779
+ _useDimensionObserver4 = _useDimensionObserver3.height,
2780
+ menuDotsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
2781
+
2782
+ var onClickScreen = useCallback(function (_ref13) {
2783
+ var itemScreenId = _ref13.screenId;
2258
2784
  onInteractionPrivate();
2259
- var index = screens.findIndex(function (_ref11) {
2260
- var id = _ref11.id;
2785
+ var index = screens.findIndex(function (_ref14) {
2786
+ var id = _ref14.id;
2261
2787
  return id === itemScreenId;
2262
2788
  });
2263
2789
  changeIndex(index);
2264
-
2265
- if (menuOpened) {
2266
- setMenuOpened(false);
2267
- }
2268
- }, [onInteractionPrivate, changeIndex, menuOpened, setMenuOpened]);
2790
+ }, [onInteractionPrivate, changeIndex]);
2269
2791
  var onContextMenu = useCallback(function (e) {
2270
2792
  if (!landscape) {
2271
2793
  e.preventDefault();
@@ -2273,28 +2795,16 @@ var Viewer = function Viewer(_ref) {
2273
2795
  }
2274
2796
 
2275
2797
  return true;
2276
- }, [landscape]);
2798
+ }, [landscape]); // hmm?
2799
+
2277
2800
  var overscrollStyle = /*#__PURE__*/React.createElement("style", {
2278
2801
  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
-
2802
+ }, "body { overscroll-behavior: contain; }");
2287
2803
  var keyboardShortcuts = useMemo(function () {
2288
2804
  return {
2289
2805
  f: function f() {
2290
2806
  return toggleFullscreen();
2291
2807
  },
2292
- m: function m() {
2293
- return setMenuOpened(!menuOpened);
2294
- },
2295
- escape: function escape() {
2296
- return setMenuOpened(false);
2297
- },
2298
2808
  arrowleft: function arrowleft() {
2299
2809
  return gotoPreviousScreen();
2300
2810
  },
@@ -2305,55 +2815,10 @@ var Viewer = function Viewer(_ref) {
2305
2815
  return gotoNextScreen();
2306
2816
  }
2307
2817
  };
2308
- }, [menuOpened, setMenuOpened, gotoPreviousScreen, gotoNextScreen]);
2818
+ }, [gotoPreviousScreen, gotoNextScreen]);
2309
2819
  useKeyboardShortcuts(keyboardShortcuts, {
2310
2820
  disabled: renderContext !== 'view'
2311
2821
  });
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
2822
  return /*#__PURE__*/React.createElement(VisitorProvider, {
2358
2823
  visitor: visitor
2359
2824
  }, /*#__PURE__*/React.createElement(ScreenSizeProvider, {
@@ -2378,13 +2843,12 @@ var Viewer = function Viewer(_ref) {
2378
2843
  }), /*#__PURE__*/React.createElement("div", {
2379
2844
  className: classNames([styles$6.container, screenSize.screens.map(function (screenName) {
2380
2845
  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)]),
2846
+ }), (_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
2847
  ref: containerRef,
2383
2848
  onContextMenu: onContextMenu
2384
2849
  }, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu, {
2385
2850
  story: parsedStory,
2386
2851
  currentScreenIndex: screenIndex,
2387
- opened: menuOpened,
2388
2852
  withShadow: menuOverScreen && !withoutMenuShadow,
2389
2853
  toggleFullscreen: toggleFullscreen,
2390
2854
  fullscreenActive: fullscreenActive,
@@ -2393,94 +2857,66 @@ var Viewer = function Viewer(_ref) {
2393
2857
  shareBasePath: basePath,
2394
2858
  screenSize: screenSize,
2395
2859
  menuWidth: menuIsScreenWidth ? screenContainerWidth : null,
2860
+ theme: viewerTheme,
2396
2861
  trackingEnabled: trackingEnabled,
2397
- onClickItem: onClickMenuItem,
2398
- onClickMenu: onClickMenu,
2862
+ onClickScreen: onClickScreen,
2399
2863
  onClickCloseViewer: onCloseViewer,
2400
- onRequestOpen: onMenuRequestOpen,
2401
- onRequestClose: onMenuRequestClose,
2402
2864
  withDotItemClick: screenContainerWidth > 400,
2403
2865
  withoutScreensMenu: withoutScreensMenu,
2866
+ withoutShareMenu: withoutShareMenu,
2404
2867
  refDots: menuDotsContainerRef
2405
2868
  }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", Object.assign({
2406
- ref: contentRef,
2407
2869
  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%', ")");
2870
+ }, dragContentBind()), !withoutNavigationArrow && !withNeighborScreens && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
2871
+ direction: "previous",
2872
+ className: classNames([styles$6.navButton, styles$6.previous]),
2873
+ onClick: gotoPreviousScreen
2874
+ }) : null, /*#__PURE__*/React.createElement("div", {
2875
+ className: styles$6.screensFrame,
2876
+ style: {
2877
+ width: screenContainerWidth,
2878
+ height: screenContainerHeight,
2879
+ overflow: !withNeighborScreens ? 'hidden' : null
2420
2880
  }
2881
+ }, screens.map(function (screen, i) {
2882
+ var current = i === Math.round(screenIndexProgress); // base current on transition
2421
2883
 
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, {
2884
+ var active = i >= screenIndex - neighborScreensActive && i <= screenIndex + neighborScreensActive;
2885
+ var defaultStyles = {
2886
+ opacity: current ? 1 : 0
2887
+ };
2888
+ var screenStyles = active ? getScreenStylesByIndex(i, screenIndexProgress) : defaultStyles;
2889
+ return /*#__PURE__*/React.createElement("div", {
2890
+ key: "screen-viewer-".concat(screen.id || '', "-").concat(i + 1),
2891
+ style: screenStyles,
2892
+ className: classNames([styles$6.screenContainer, _defineProperty({}, styles$6.current, current)])
2893
+ }, screen !== null && active ? /*#__PURE__*/React.createElement(ViewerScreen, {
2454
2894
  className: styles$6.screen,
2455
- screen: mountedScreen,
2895
+ screen: screen,
2456
2896
  screenState: current ? screenState : null,
2457
- renderContext: renderContext,
2458
2897
  index: i,
2459
2898
  current: current,
2460
2899
  active: active,
2461
2900
  mediaRef: function mediaRef(ref) {
2462
2901
  screensMediasRef.current[i] = ref;
2463
2902
  },
2903
+ renderContext: renderContext,
2464
2904
  width: screenWidth,
2465
2905
  height: screenHeight,
2466
- 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", {
2906
+ scale: screenScale
2907
+ }) : null);
2908
+ })), !withoutNavigationArrow && !withNeighborScreens && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton, {
2909
+ direction: "next",
2910
+ className: classNames([styles$6.navButton, styles$6.next]),
2911
+ onClick: gotoNextScreen
2912
+ }) : null, !withoutPlaybackControls ? /*#__PURE__*/React.createElement("div", {
2474
2913
  className: styles$6.playbackControls,
2475
2914
  ref: playbackControlsContainerRef
2476
- }, /*#__PURE__*/React.createElement("div", {
2477
- className: styles$6.playbackControlsContainer,
2478
- style: {
2479
- width: screenContainerWidth
2480
- }
2481
2915
  }, /*#__PURE__*/React.createElement(PlaybackControls, {
2482
2916
  className: styles$6.controls
2483
- }))) : null) : null, /*#__PURE__*/React.createElement(WebViewContainer, {
2917
+ })) : null, withNavigationHint && !withNeighborScreens && screenIndex === 0 && !hasInteracted ? /*#__PURE__*/React.createElement(ArrowHint, {
2918
+ className: styles$6.arrowHint
2919
+ }) : null) : null, /*#__PURE__*/React.createElement(WebViewContainer, {
2484
2920
  className: styles$6.webView,
2485
2921
  style: {
2486
2922
  maxWidth: Math.max(screenContainerWidth, 600)