@micromag/viewer 0.2.412 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/css/styles.css +7 -6
- package/es/index.js +954 -634
- package/lib/index.js +966 -645
- package/package.json +8 -8
package/es/index.js
CHANGED
|
@@ -1,105 +1,314 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
2
|
import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
|
|
3
|
-
import React, { useRef, useCallback, useMemo, useState, useEffect } from 'react';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
4
|
+
import React, { useEffect, useState, useCallback, useRef, useMemo } from 'react';
|
|
5
5
|
import { Switch, Route, MemoryRouter } from 'react-router';
|
|
6
6
|
import { BrowserRouter } from 'react-router-dom';
|
|
7
|
-
import { ScreensProvider } from '@micromag/screens';
|
|
8
|
-
import { IntlProvider } from '@micromag/intl';
|
|
9
|
-
import fieldsManager from '@micromag/fields/manager';
|
|
10
7
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
11
|
-
import { ScreenSizeProvider, ViewerProvider, useRoutes, useRoutePush, GoogleKeysProvider, GoogleMapsClientProvider, FieldsProvider, UserInteractionProvider, TrackingProvider, RoutesProvider } from '@micromag/core/contexts';
|
|
8
|
+
import { ScreenSizeProvider, ViewerProvider, useRoutes, useRoutePush, GoogleKeysProvider, GoogleMapsClientProvider, FieldsProvider, ComponentsProvider, SCREENS_NAMESPACE, UserInteractionProvider, TrackingProvider, RoutesProvider } from '@micromag/core/contexts';
|
|
9
|
+
import fieldsManager from '@micromag/fields/manager';
|
|
10
|
+
import { IntlProvider } from '@micromag/intl';
|
|
11
|
+
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 { useSpring, config } from '@react-spring/core';
|
|
16
|
-
import { animated } from '@react-spring/web';
|
|
17
|
-
import { useDrag } from '@use-gesture/react';
|
|
18
15
|
import classNames from 'classnames';
|
|
19
16
|
import { Helmet } from 'react-helmet';
|
|
20
17
|
import { useIntl, FormattedMessage } from 'react-intl';
|
|
21
|
-
import {
|
|
22
|
-
import { useDocumentEvent, useParsedStory, useLoadedFonts, useTrackScreenView,
|
|
18
|
+
import { Button, ScreenPreview, Screen, Meta, FontFaces } from '@micromag/core/components';
|
|
19
|
+
import { useDocumentEvent, useResizeObserver, useTrackEvent, useParsedStory, useLoadedFonts, useTrackScreenView, useScreenSizeFromElement, useFullscreen } from '@micromag/core/hooks';
|
|
23
20
|
import { getStyleFromColor, getStyleFromText, getDeviceScreens } from '@micromag/core/utils';
|
|
21
|
+
import { useSpring, config } from '@react-spring/core';
|
|
22
|
+
import { animated } from '@react-spring/web';
|
|
23
|
+
import { useDrag } from '@use-gesture/react';
|
|
24
24
|
import { faTimes, faShare, faCompress, faExpand } from '@fortawesome/free-solid-svg-icons';
|
|
25
25
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
26
26
|
import Scroll from '@micromag/element-scroll';
|
|
27
27
|
import { FacebookShareButton, FacebookIcon, TwitterShareButton, TwitterIcon, EmailShareButton, EmailIcon } from 'react-share';
|
|
28
|
+
import EventEmitter from 'wolfy87-eventemitter';
|
|
29
|
+
|
|
30
|
+
var home = "/";
|
|
31
|
+
var screen = "/:screen";
|
|
32
|
+
var defaultRoutes = {
|
|
33
|
+
home: home,
|
|
34
|
+
screen: screen
|
|
35
|
+
};
|
|
28
36
|
|
|
29
37
|
var routes = PropTypes.shape({
|
|
30
38
|
home: PropTypes.string.isRequired,
|
|
31
39
|
screen: PropTypes.string.isRequired
|
|
32
40
|
});
|
|
33
41
|
|
|
34
|
-
|
|
42
|
+
function useKeyboardShortcuts() {
|
|
43
|
+
var shortcuts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
35
44
|
|
|
36
|
-
var
|
|
45
|
+
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
46
|
+
_ref$disabled = _ref.disabled,
|
|
47
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled;
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
var onKey = function onKey(e) {
|
|
51
|
+
if (['input', 'textarea'].reduce(function (foundMatch, match) {
|
|
52
|
+
return foundMatch || e.target.matches(match);
|
|
53
|
+
}, false)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var key = e.key;
|
|
58
|
+
var lowercaseKey = key.toLowerCase();
|
|
59
|
+
|
|
60
|
+
if (typeof shortcuts[lowercaseKey] !== 'undefined') {
|
|
61
|
+
shortcuts[lowercaseKey]();
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (!disabled) {
|
|
66
|
+
window.addEventListener('keydown', onKey);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return function () {
|
|
70
|
+
if (!disabled) {
|
|
71
|
+
window.removeEventListener('keydown', onKey);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}, [disabled]);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function checkClickable(el) {
|
|
78
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
79
|
+
var distance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
80
|
+
|
|
81
|
+
var _ref = options || {},
|
|
82
|
+
_ref$maxDistance = _ref.maxDistance,
|
|
83
|
+
maxDistance = _ref$maxDistance === void 0 ? 5 : _ref$maxDistance,
|
|
84
|
+
_ref$tags = _ref.tags,
|
|
85
|
+
tags = _ref$tags === void 0 ? ['BUTTON', 'A', 'INPUT', 'TEXTAREA'] : _ref$tags;
|
|
86
|
+
|
|
87
|
+
var _ref2 = el || {},
|
|
88
|
+
_ref2$tagName = _ref2.tagName,
|
|
89
|
+
tagName = _ref2$tagName === void 0 ? null : _ref2$tagName,
|
|
90
|
+
_ref2$parentNode = _ref2.parentNode,
|
|
91
|
+
parentNode = _ref2$parentNode === void 0 ? null : _ref2$parentNode;
|
|
92
|
+
|
|
93
|
+
if (tagName === 'BODY') {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (tags.map(function (it) {
|
|
98
|
+
return it.toLowerCase();
|
|
99
|
+
}).indexOf(tagName.toLowerCase()) > -1) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (distance < maxDistance) {
|
|
104
|
+
return checkClickable(parentNode, options, distance + 1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function useScreenInteraction() {
|
|
111
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
112
|
+
screens = _ref.screens,
|
|
113
|
+
screenId = _ref.screenId,
|
|
114
|
+
screenWidth = _ref.screenWidth,
|
|
115
|
+
_ref$isView = _ref.isView,
|
|
116
|
+
isView = _ref$isView === void 0 ? false : _ref$isView,
|
|
117
|
+
_ref$clickOnSiblings = _ref.clickOnSiblings,
|
|
118
|
+
clickOnSiblings = _ref$clickOnSiblings === void 0 ? false : _ref$clickOnSiblings,
|
|
119
|
+
_ref$nextScreenWidthP = _ref.nextScreenWidthPercent,
|
|
120
|
+
nextScreenWidthPercent = _ref$nextScreenWidthP === void 0 ? 0.5 : _ref$nextScreenWidthP,
|
|
121
|
+
_ref$eventsManager = _ref.eventsManager,
|
|
122
|
+
eventsManager = _ref$eventsManager === void 0 ? null : _ref$eventsManager,
|
|
123
|
+
_ref$onClick = _ref.onClick,
|
|
124
|
+
onClick = _ref$onClick === void 0 ? null : _ref$onClick,
|
|
125
|
+
_ref$onEnd = _ref.onEnd,
|
|
126
|
+
onEnd = _ref$onEnd === void 0 ? null : _ref$onEnd,
|
|
127
|
+
_ref$onChangeScreen = _ref.onChangeScreen,
|
|
128
|
+
onChangeScreen = _ref$onChangeScreen === void 0 ? null : _ref$onChangeScreen;
|
|
129
|
+
|
|
130
|
+
var _useState = useState(screens.reduce(function (map, _ref2) {
|
|
131
|
+
var id = _ref2.id;
|
|
132
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, true));
|
|
133
|
+
}, {})),
|
|
134
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
135
|
+
screensInteractionEnabled = _useState2[0],
|
|
136
|
+
setScreensInteractionEnabled = _useState2[1];
|
|
137
|
+
|
|
138
|
+
var screenIndex = screens.findIndex(function (_ref3) {
|
|
139
|
+
var id = _ref3.id;
|
|
140
|
+
return id === screenId;
|
|
141
|
+
});
|
|
142
|
+
var _screensInteractionEn = screensInteractionEnabled[screenId],
|
|
143
|
+
currentScreenInteractionEnabled = _screensInteractionEn === void 0 ? true : _screensInteractionEn;
|
|
144
|
+
var updateInteraction = useCallback(function (newValue) {
|
|
145
|
+
var _screensInteractionEn2 = screensInteractionEnabled[screenId],
|
|
146
|
+
currentValue = _screensInteractionEn2 === void 0 ? true : _screensInteractionEn2;
|
|
147
|
+
|
|
148
|
+
if (currentValue !== newValue) {
|
|
149
|
+
setScreensInteractionEnabled(screens.reduce(function (map, _ref4) {
|
|
150
|
+
var id = _ref4.id;
|
|
151
|
+
return screenId === id ? _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, newValue)) : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, typeof screensInteractionEnabled[id] === 'undefined' || screensInteractionEnabled[id] === true));
|
|
152
|
+
}, {}));
|
|
153
|
+
}
|
|
154
|
+
}, [screens, screenId, screensInteractionEnabled, setScreensInteractionEnabled]);
|
|
155
|
+
var enableInteraction = useCallback(function () {
|
|
156
|
+
return updateInteraction(true);
|
|
157
|
+
}, [updateInteraction]);
|
|
158
|
+
var disableInteraction = useCallback(function () {
|
|
159
|
+
return updateInteraction(false);
|
|
160
|
+
}, [updateInteraction]);
|
|
161
|
+
var onScreenClick = useCallback(function (e, index) {
|
|
162
|
+
if (onClick !== null) {
|
|
163
|
+
onClick(e, index);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var screensCount = screens.length;
|
|
167
|
+
var tappedCurrent = screenIndex === index;
|
|
168
|
+
eventsManager.emit('tap', e, index);
|
|
169
|
+
|
|
170
|
+
if (!isView && tappedCurrent || checkClickable(e.target) || tappedCurrent && !currentScreenInteractionEnabled) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
var nextIndex = screenIndex;
|
|
175
|
+
|
|
176
|
+
var _e$currentTarget$getB = e.currentTarget.getBoundingClientRect(),
|
|
177
|
+
_e$currentTarget$getB2 = _e$currentTarget$getB.left,
|
|
178
|
+
contentX = _e$currentTarget$getB2 === void 0 ? 0 : _e$currentTarget$getB2;
|
|
179
|
+
|
|
180
|
+
var tapX = e.clientX;
|
|
181
|
+
var hasTappedLeft = tappedCurrent ? tapX - contentX < screenWidth * (1 - nextScreenWidthPercent) : screenIndex > index;
|
|
182
|
+
|
|
183
|
+
if (hasTappedLeft) {
|
|
184
|
+
nextIndex = clickOnSiblings ? index : Math.max(0, screenIndex - 1);
|
|
185
|
+
eventsManager.emit('tap_previous', nextIndex);
|
|
186
|
+
} else {
|
|
187
|
+
nextIndex = clickOnSiblings ? index : Math.min(screensCount - 1, screenIndex + 1);
|
|
188
|
+
var isLastScreen = screenIndex === screensCount - 1;
|
|
189
|
+
|
|
190
|
+
if (isLastScreen && onEnd !== null) {
|
|
191
|
+
eventsManager.emit('tap_end');
|
|
192
|
+
onEnd();
|
|
193
|
+
} else {
|
|
194
|
+
eventsManager.emit('tap_next', nextIndex);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
eventsManager.emit('change_screen', nextIndex);
|
|
199
|
+
onChangeScreen(nextIndex);
|
|
200
|
+
}, [screenWidth, screens, screenIndex, eventsManager, onClick, onEnd, onChangeScreen, screenIndex, screensInteractionEnabled, currentScreenInteractionEnabled, nextScreenWidthPercent, isView, clickOnSiblings]);
|
|
201
|
+
return {
|
|
202
|
+
onClick: onScreenClick,
|
|
203
|
+
currentScreenInteractionEnabled: currentScreenInteractionEnabled,
|
|
204
|
+
enableInteraction: enableInteraction,
|
|
205
|
+
disableInteraction: disableInteraction
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
var styles$7 = {"container":"micromag-viewer-container","menuPreview":"micromag-viewer-menuPreview","menuPreviewContainer":"micromag-viewer-menuPreviewContainer","screen":"micromag-viewer-screen","screenInner":"micromag-viewer-screenInner","content":"micromag-viewer-content","menuDotsContainer":"micromag-viewer-menuDotsContainer","menuDots":"micromag-viewer-menuDots","current":"micromag-viewer-current","landscape":"micromag-viewer-landscape","visible":"micromag-viewer-visible","withSibblings":"micromag-viewer-withSibblings","hideMenu":"micromag-viewer-hideMenu","ready":"micromag-viewer-ready"};
|
|
210
|
+
|
|
211
|
+
var styles$6 = {"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"};
|
|
212
|
+
|
|
213
|
+
var styles$5 = {"container":"micromag-viewer-menus-menu-dot-container","button":"micromag-viewer-menus-menu-dot-button","dot":"micromag-viewer-menus-menu-dot-dot","vertical":"micromag-viewer-menus-menu-dot-vertical"};
|
|
214
|
+
|
|
215
|
+
var propTypes$a = {
|
|
41
216
|
current: PropTypes.bool,
|
|
42
217
|
active: PropTypes.bool,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
218
|
+
colors: PropTypes.shape({
|
|
219
|
+
primary: PropTypes.string,
|
|
220
|
+
secondary: PropTypes.string
|
|
221
|
+
}),
|
|
222
|
+
vertical: PropTypes.bool,
|
|
223
|
+
onClick: PropTypes.func,
|
|
224
|
+
className: PropTypes.string
|
|
48
225
|
};
|
|
49
|
-
var defaultProps$
|
|
50
|
-
screen: null,
|
|
51
|
-
renderContext: null,
|
|
226
|
+
var defaultProps$a = {
|
|
52
227
|
current: false,
|
|
53
|
-
active:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
getMediaRef: null
|
|
228
|
+
active: false,
|
|
229
|
+
colors: null,
|
|
230
|
+
vertical: false,
|
|
231
|
+
onClick: null,
|
|
232
|
+
className: null
|
|
59
233
|
};
|
|
60
234
|
|
|
61
|
-
var
|
|
62
|
-
var
|
|
235
|
+
var ViewerMenuDot = function ViewerMenuDot(_ref) {
|
|
236
|
+
var _ref3;
|
|
63
237
|
|
|
64
|
-
var
|
|
65
|
-
renderContext = _ref.renderContext,
|
|
238
|
+
var current = _ref.current,
|
|
66
239
|
active = _ref.active,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
className: classNames([styles$5.container, (_ref2 = {}, _defineProperty(_ref2, styles$5.active, active), _defineProperty(_ref2, styles$5.current, current), _ref2)]),
|
|
75
|
-
"aria-hidden": current ? null : 'true'
|
|
76
|
-
}, /*#__PURE__*/React.createElement(Screen, {
|
|
77
|
-
screen: screen,
|
|
78
|
-
renderContext: renderContext,
|
|
79
|
-
active: active,
|
|
80
|
-
current: current,
|
|
81
|
-
onPrevious: onPrevious,
|
|
82
|
-
onNext: onNext,
|
|
83
|
-
onEnableInteraction: onEnableInteraction,
|
|
84
|
-
onDisableInteraction: onDisableInteraction,
|
|
85
|
-
getMediaRef: getMediaRef
|
|
86
|
-
})) : null;
|
|
87
|
-
};
|
|
240
|
+
colors = _ref.colors,
|
|
241
|
+
vertical = _ref.vertical,
|
|
242
|
+
onClick = _ref.onClick,
|
|
243
|
+
className = _ref.className;
|
|
244
|
+
var currentTime = 0;
|
|
245
|
+
var duration = 1;
|
|
246
|
+
var playing = true;
|
|
88
247
|
|
|
89
|
-
|
|
90
|
-
|
|
248
|
+
var _ref2 = colors || {},
|
|
249
|
+
_ref2$primary = _ref2.primary,
|
|
250
|
+
primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
|
|
251
|
+
_ref2$secondary = _ref2.secondary,
|
|
252
|
+
secondary = _ref2$secondary === void 0 ? 'rgba(200, 200, 200, 0.5)' : _ref2$secondary; // TODO: if approved animate progress
|
|
91
253
|
|
|
92
|
-
var styles$4 = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","item":"micromag-viewer-menus-menu-dots-item","button":"micromag-viewer-menus-menu-dots-button","menuButton":"micromag-viewer-menus-menu-dots-menuButton","items":"micromag-viewer-menus-menu-dots-items","dot":"micromag-viewer-menus-menu-dots-dot","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"};
|
|
93
254
|
|
|
94
|
-
var
|
|
255
|
+
var _useSpring = useSpring(function () {
|
|
256
|
+
return {
|
|
257
|
+
x: 0,
|
|
258
|
+
config: {
|
|
259
|
+
duration: 0
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
}),
|
|
263
|
+
_useSpring2 = _slicedToArray(_useSpring, 2);
|
|
264
|
+
_useSpring2[0];
|
|
265
|
+
var setSpringProps = _useSpring2[1];
|
|
95
266
|
|
|
96
|
-
|
|
267
|
+
useEffect(function () {
|
|
268
|
+
|
|
269
|
+
var progress = currentTime / duration;
|
|
270
|
+
setSpringProps.start({
|
|
271
|
+
reset: true,
|
|
272
|
+
immediate: !playing,
|
|
273
|
+
from: {
|
|
274
|
+
x: progress
|
|
275
|
+
},
|
|
276
|
+
to: {
|
|
277
|
+
x: 1
|
|
278
|
+
},
|
|
279
|
+
config: {
|
|
280
|
+
duration: (duration - currentTime) * 1000
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
}, [playing, duration, currentTime, setSpringProps]);
|
|
284
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
285
|
+
className: classNames([styles$5.container, (_ref3 = {}, _defineProperty(_ref3, styles$5.active, current), _defineProperty(_ref3, styles$5.vertical, vertical), _defineProperty(_ref3, className, className !== null), _ref3)]),
|
|
286
|
+
"aria-hidden": "true"
|
|
287
|
+
}, /*#__PURE__*/React.createElement("button", {
|
|
288
|
+
type: "button",
|
|
289
|
+
className: styles$5.button,
|
|
290
|
+
onClick: onClick,
|
|
291
|
+
tabIndex: "-1"
|
|
292
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
293
|
+
className: styles$5.dot,
|
|
294
|
+
style: {
|
|
295
|
+
backgroundColor: active ? primary : secondary
|
|
296
|
+
}
|
|
297
|
+
})));
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
ViewerMenuDot.propTypes = propTypes$a;
|
|
301
|
+
ViewerMenuDot.defaultProps = defaultProps$a;
|
|
302
|
+
|
|
303
|
+
var styles$4 = {};
|
|
304
|
+
|
|
305
|
+
var propTypes$9 = {
|
|
97
306
|
size: PropTypes.number,
|
|
98
307
|
spacing: PropTypes.number,
|
|
99
308
|
color: PropTypes.string,
|
|
100
309
|
className: PropTypes.string
|
|
101
310
|
};
|
|
102
|
-
var defaultProps$
|
|
311
|
+
var defaultProps$9 = {
|
|
103
312
|
size: 100,
|
|
104
313
|
spacing: 8,
|
|
105
314
|
color: 'white',
|
|
@@ -113,7 +322,7 @@ var MenuIcon = function MenuIcon(_ref) {
|
|
|
113
322
|
className = _ref.className;
|
|
114
323
|
var squareSize = (size - 2 * spacing) / 3;
|
|
115
324
|
return /*#__PURE__*/React.createElement("svg", {
|
|
116
|
-
className: classNames([styles$
|
|
325
|
+
className: classNames([styles$4.container, _defineProperty({}, className, className !== null)]),
|
|
117
326
|
xmlns: "http://www.w3.org/2000/svg",
|
|
118
327
|
viewBox: "0 0 ".concat(size, " ").concat(size),
|
|
119
328
|
"aria-hidden": "true"
|
|
@@ -131,57 +340,66 @@ var MenuIcon = function MenuIcon(_ref) {
|
|
|
131
340
|
}));
|
|
132
341
|
};
|
|
133
342
|
|
|
134
|
-
MenuIcon.propTypes = propTypes$
|
|
135
|
-
MenuIcon.defaultProps = defaultProps$
|
|
343
|
+
MenuIcon.propTypes = propTypes$9;
|
|
344
|
+
MenuIcon.defaultProps = defaultProps$9;
|
|
136
345
|
|
|
137
|
-
var propTypes$
|
|
346
|
+
var propTypes$8 = {
|
|
138
347
|
direction: PropTypes.oneOf(['horizontal', 'vertical']),
|
|
139
348
|
withShadow: PropTypes.bool,
|
|
140
349
|
items: PropTypes$1.menuItems,
|
|
141
|
-
current: PropTypes.number,
|
|
142
350
|
onClickItem: PropTypes.func,
|
|
351
|
+
onClickMenu: PropTypes.func,
|
|
143
352
|
colors: PropTypes.shape({
|
|
144
353
|
primary: PropTypes.string,
|
|
145
354
|
secondary: PropTypes.string
|
|
146
355
|
}),
|
|
147
356
|
closeable: PropTypes.bool,
|
|
357
|
+
withItemClick: PropTypes.bool,
|
|
358
|
+
withoutScreensMenu: PropTypes.bool,
|
|
148
359
|
onClose: PropTypes.func,
|
|
149
360
|
className: PropTypes.string
|
|
150
361
|
};
|
|
151
|
-
var defaultProps$
|
|
362
|
+
var defaultProps$8 = {
|
|
152
363
|
direction: 'horizontal',
|
|
153
364
|
withShadow: false,
|
|
154
365
|
items: [],
|
|
155
|
-
current: 0,
|
|
156
366
|
onClickItem: null,
|
|
367
|
+
onClickMenu: null,
|
|
157
368
|
colors: null,
|
|
158
369
|
closeable: false,
|
|
370
|
+
withItemClick: false,
|
|
371
|
+
withoutScreensMenu: false,
|
|
159
372
|
onClose: null,
|
|
160
373
|
className: null
|
|
161
374
|
};
|
|
162
375
|
|
|
163
376
|
var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
164
|
-
var
|
|
377
|
+
var _ref4;
|
|
165
378
|
|
|
166
379
|
var direction = _ref.direction,
|
|
167
380
|
withShadow = _ref.withShadow,
|
|
168
381
|
items = _ref.items,
|
|
169
|
-
current = _ref.current,
|
|
170
382
|
onClickItem = _ref.onClickItem,
|
|
383
|
+
onClickMenu = _ref.onClickMenu,
|
|
171
384
|
colors = _ref.colors,
|
|
172
385
|
closeable = _ref.closeable,
|
|
386
|
+
withItemClick = _ref.withItemClick,
|
|
387
|
+
withoutScreensMenu = _ref.withoutScreensMenu,
|
|
173
388
|
onClose = _ref.onClose,
|
|
174
389
|
className = _ref.className;
|
|
175
390
|
|
|
176
391
|
var _ref2 = colors || {},
|
|
177
392
|
_ref2$primary = _ref2.primary,
|
|
178
|
-
primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary
|
|
179
|
-
_ref2$secondary = _ref2.secondary,
|
|
180
|
-
secondary = _ref2$secondary === void 0 ? 'rgba(200, 200, 200, 0.5)' : _ref2$secondary;
|
|
393
|
+
primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary;
|
|
181
394
|
|
|
182
395
|
var intl = useIntl();
|
|
396
|
+
var currentIndex = items.findIndex(function (_ref3) {
|
|
397
|
+
var _ref3$current = _ref3.current,
|
|
398
|
+
current = _ref3$current === void 0 ? false : _ref3$current;
|
|
399
|
+
return current;
|
|
400
|
+
});
|
|
183
401
|
return /*#__PURE__*/React.createElement("nav", {
|
|
184
|
-
className: classNames([styles$
|
|
402
|
+
className: classNames([styles$6.container, (_ref4 = {}, _defineProperty(_ref4, className, className !== null), _defineProperty(_ref4, styles$6.vertical, direction === 'vertical'), _defineProperty(_ref4, styles$6.withShadow, withShadow), _ref4)]),
|
|
185
403
|
"aria-label": intl.formatMessage({
|
|
186
404
|
id: "bLYuuN",
|
|
187
405
|
defaultMessage: [{
|
|
@@ -201,35 +419,32 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
|
201
419
|
"value": "."
|
|
202
420
|
}]
|
|
203
421
|
}, {
|
|
204
|
-
current:
|
|
422
|
+
current: currentIndex + 1,
|
|
205
423
|
total: items.length
|
|
206
424
|
})
|
|
207
425
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
208
|
-
className: styles$
|
|
426
|
+
className: styles$6.items
|
|
209
427
|
}, items.map(function (item, index) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
"
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
428
|
+
var _item$current = item.current,
|
|
429
|
+
current = _item$current === void 0 ? false : _item$current;
|
|
430
|
+
return /*#__PURE__*/React.createElement(ViewerMenuDot, {
|
|
431
|
+
key: "item-".concat(index + 1),
|
|
432
|
+
current: current,
|
|
433
|
+
active: index <= currentIndex,
|
|
434
|
+
colors: colors,
|
|
217
435
|
onClick: function onClick() {
|
|
218
|
-
if (onClickItem !== null) {
|
|
219
|
-
onClickItem(
|
|
436
|
+
if ((withItemClick || withoutScreensMenu) && onClickItem !== null) {
|
|
437
|
+
onClickItem(item);
|
|
438
|
+
} else if (!withItemClick && onClickMenu !== null) {
|
|
439
|
+
onClickMenu();
|
|
220
440
|
}
|
|
221
441
|
},
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
backgroundColor: index <= current ? primary : secondary
|
|
227
|
-
}
|
|
228
|
-
}))) : null;
|
|
229
|
-
}), /*#__PURE__*/React.createElement("li", {
|
|
230
|
-
className: styles$4.menu
|
|
442
|
+
vertical: direction === 'vertical'
|
|
443
|
+
});
|
|
444
|
+
}), !withoutScreensMenu ? /*#__PURE__*/React.createElement("li", {
|
|
445
|
+
className: styles$6.menu
|
|
231
446
|
}, /*#__PURE__*/React.createElement(MenuIcon, {
|
|
232
|
-
className: styles$
|
|
447
|
+
className: styles$6.menuIcon,
|
|
233
448
|
color: primary
|
|
234
449
|
}), /*#__PURE__*/React.createElement("button", {
|
|
235
450
|
type: "button",
|
|
@@ -247,20 +462,16 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
|
247
462
|
"value": "Menu"
|
|
248
463
|
}]
|
|
249
464
|
}),
|
|
250
|
-
className: styles$
|
|
251
|
-
onClick:
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
})), closeable ? /*#__PURE__*/React.createElement("li", {
|
|
257
|
-
className: styles$4.closeButton,
|
|
465
|
+
className: styles$6.menuButton,
|
|
466
|
+
onClick: onClickMenu
|
|
467
|
+
})) : null, closeable ? /*#__PURE__*/React.createElement("li", {
|
|
468
|
+
className: styles$6.closeButton,
|
|
258
469
|
style: {
|
|
259
470
|
color: primary
|
|
260
471
|
}
|
|
261
472
|
}, /*#__PURE__*/React.createElement("button", {
|
|
262
473
|
type: "button",
|
|
263
|
-
className: styles$
|
|
474
|
+
className: styles$6.closeButton,
|
|
264
475
|
onClick: onClose,
|
|
265
476
|
title: intl.formatMessage({
|
|
266
477
|
id: "dj/p/q",
|
|
@@ -281,14 +492,14 @@ var ViewerMenuDots = function ViewerMenuDots(_ref) {
|
|
|
281
492
|
}))) : null));
|
|
282
493
|
};
|
|
283
494
|
|
|
284
|
-
ViewerMenuDots.propTypes = propTypes$
|
|
285
|
-
ViewerMenuDots.defaultProps = defaultProps$
|
|
495
|
+
ViewerMenuDots.propTypes = propTypes$8;
|
|
496
|
+
ViewerMenuDots.defaultProps = defaultProps$8;
|
|
286
497
|
|
|
287
|
-
var styles$
|
|
498
|
+
var styles$3 = {"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","screenContent":"micromag-viewer-menus-menu-preview-screenContent"};
|
|
288
499
|
|
|
289
|
-
var styles$
|
|
500
|
+
var styles$2 = {"container":"micromag-viewer-partials-share-modal-container","content":"micromag-viewer-partials-share-modal-content","opened":"micromag-viewer-partials-share-modal-opened"};
|
|
290
501
|
|
|
291
|
-
var propTypes$
|
|
502
|
+
var propTypes$7 = {
|
|
292
503
|
url: PropTypes.string,
|
|
293
504
|
title: PropTypes.string,
|
|
294
505
|
opened: PropTypes.bool,
|
|
@@ -296,7 +507,7 @@ var propTypes$5 = {
|
|
|
296
507
|
onShare: PropTypes.func,
|
|
297
508
|
onCancel: PropTypes.func
|
|
298
509
|
};
|
|
299
|
-
var defaultProps$
|
|
510
|
+
var defaultProps$7 = {
|
|
300
511
|
url: null,
|
|
301
512
|
title: null,
|
|
302
513
|
opened: false,
|
|
@@ -349,13 +560,13 @@ var ShareModal = function ShareModal(_ref) {
|
|
|
349
560
|
}, [opened, onCancel]);
|
|
350
561
|
useDocumentEvent('click', onDocumentClick, opened);
|
|
351
562
|
return /*#__PURE__*/React.createElement("div", {
|
|
352
|
-
className: classNames([styles$
|
|
563
|
+
className: classNames([styles$2.container, (_ref2 = {}, _defineProperty(_ref2, className, className), _defineProperty(_ref2, styles$2.opened, opened), _ref2)]),
|
|
353
564
|
ref: containerRef,
|
|
354
565
|
"aria-hidden": opened ? null : '-1'
|
|
355
566
|
}, /*#__PURE__*/React.createElement("div", {
|
|
356
|
-
className: styles$
|
|
567
|
+
className: styles$2.content
|
|
357
568
|
}, /*#__PURE__*/React.createElement("div", {
|
|
358
|
-
className: styles$
|
|
569
|
+
className: styles$2.buttons
|
|
359
570
|
}, /*#__PURE__*/React.createElement(FacebookShareButton, Object.assign({}, shareButtonProps, {
|
|
360
571
|
quote: title,
|
|
361
572
|
beforeOnClick: function beforeOnClick() {
|
|
@@ -380,12 +591,12 @@ var ShareModal = function ShareModal(_ref) {
|
|
|
380
591
|
}), /*#__PURE__*/React.createElement(EmailIcon, shareIconProps)))));
|
|
381
592
|
};
|
|
382
593
|
|
|
383
|
-
ShareModal.propTypes = propTypes$
|
|
384
|
-
ShareModal.defaultProps = defaultProps$
|
|
594
|
+
ShareModal.propTypes = propTypes$7;
|
|
595
|
+
ShareModal.defaultProps = defaultProps$7;
|
|
385
596
|
|
|
386
|
-
var styles = {"container":"micromag-viewer-partials-share-button-container","shareModal":"micromag-viewer-partials-share-button-shareModal"};
|
|
597
|
+
var styles$1 = {"container":"micromag-viewer-partials-share-button-container","shareModal":"micromag-viewer-partials-share-button-shareModal"};
|
|
387
598
|
|
|
388
|
-
var propTypes$
|
|
599
|
+
var propTypes$6 = {
|
|
389
600
|
title: PropTypes.string,
|
|
390
601
|
url: PropTypes.string,
|
|
391
602
|
className: PropTypes.string,
|
|
@@ -394,7 +605,7 @@ var propTypes$4 = {
|
|
|
394
605
|
children: PropTypes.node,
|
|
395
606
|
focusable: PropTypes.bool
|
|
396
607
|
};
|
|
397
|
-
var defaultProps$
|
|
608
|
+
var defaultProps$6 = {
|
|
398
609
|
title: null,
|
|
399
610
|
url: null,
|
|
400
611
|
className: null,
|
|
@@ -435,7 +646,7 @@ var ShareButton = function ShareButton(_ref) {
|
|
|
435
646
|
setStoryShareModalOpened(false);
|
|
436
647
|
}, [setStoryShareModalOpened]);
|
|
437
648
|
return /*#__PURE__*/React.createElement("div", {
|
|
438
|
-
className: classNames([styles.container, _defineProperty({}, className, className !== null)])
|
|
649
|
+
className: classNames([styles$1.container, _defineProperty({}, className, className !== null)])
|
|
439
650
|
}, /*#__PURE__*/React.createElement(Button, {
|
|
440
651
|
className: classNames([_defineProperty({}, buttonClassName, buttonClassName !== null)]),
|
|
441
652
|
onClick: onShareIconClick,
|
|
@@ -455,7 +666,7 @@ var ShareButton = function ShareButton(_ref) {
|
|
|
455
666
|
}),
|
|
456
667
|
focusable: focusable
|
|
457
668
|
}, children), /*#__PURE__*/React.createElement(ShareModal, {
|
|
458
|
-
className: styles.shareModal,
|
|
669
|
+
className: styles$1.shareModal,
|
|
459
670
|
opened: storyShareModalOpened,
|
|
460
671
|
title: title,
|
|
461
672
|
url: url,
|
|
@@ -464,16 +675,16 @@ var ShareButton = function ShareButton(_ref) {
|
|
|
464
675
|
}));
|
|
465
676
|
};
|
|
466
677
|
|
|
467
|
-
ShareButton.propTypes = propTypes$
|
|
468
|
-
ShareButton.defaultProps = defaultProps$
|
|
678
|
+
ShareButton.propTypes = propTypes$6;
|
|
679
|
+
ShareButton.defaultProps = defaultProps$6;
|
|
469
680
|
|
|
470
|
-
var propTypes$
|
|
681
|
+
var propTypes$5 = {
|
|
471
682
|
viewerTheme: PropTypes$1.viewerTheme,
|
|
472
|
-
|
|
683
|
+
screenSize: PropTypes$1.screenSize,
|
|
684
|
+
menuWidth: PropTypes.number,
|
|
473
685
|
title: PropTypes.string,
|
|
474
686
|
shareUrl: PropTypes.string,
|
|
475
687
|
items: PropTypes$1.menuItems,
|
|
476
|
-
current: PropTypes.number,
|
|
477
688
|
focusable: PropTypes.bool,
|
|
478
689
|
onClickItem: PropTypes.func,
|
|
479
690
|
onClose: PropTypes.func,
|
|
@@ -484,13 +695,13 @@ var propTypes$3 = {
|
|
|
484
695
|
fullscreenEnabled: PropTypes.bool,
|
|
485
696
|
className: PropTypes.string
|
|
486
697
|
};
|
|
487
|
-
var defaultProps$
|
|
698
|
+
var defaultProps$5 = {
|
|
488
699
|
viewerTheme: null,
|
|
489
|
-
|
|
700
|
+
screenSize: null,
|
|
701
|
+
menuWidth: null,
|
|
490
702
|
title: null,
|
|
491
703
|
shareUrl: null,
|
|
492
704
|
items: [],
|
|
493
|
-
current: 0,
|
|
494
705
|
focusable: true,
|
|
495
706
|
onClickItem: null,
|
|
496
707
|
onClose: null,
|
|
@@ -504,11 +715,11 @@ var defaultProps$3 = {
|
|
|
504
715
|
|
|
505
716
|
var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
506
717
|
var viewerTheme = _ref.viewerTheme,
|
|
507
|
-
|
|
718
|
+
screenSize = _ref.screenSize,
|
|
719
|
+
menuWidth = _ref.menuWidth,
|
|
508
720
|
title = _ref.title,
|
|
509
721
|
shareUrl = _ref.shareUrl,
|
|
510
722
|
items = _ref.items,
|
|
511
|
-
current = _ref.current,
|
|
512
723
|
focusable = _ref.focusable,
|
|
513
724
|
onClickItem = _ref.onClickItem,
|
|
514
725
|
onClose = _ref.onClose,
|
|
@@ -519,82 +730,74 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
519
730
|
fullscreenEnabled = _ref.fullscreenEnabled,
|
|
520
731
|
className = _ref.className;
|
|
521
732
|
var intl = useIntl();
|
|
522
|
-
var screenSizeRatio = "".concat(3 / 2 / thumbsPerLine * 100, "%");
|
|
523
|
-
var screenRatioHeight = screenWidth * 3 / 2;
|
|
524
|
-
var hasSize = screenWidth > 0;
|
|
525
|
-
var hasItems = items !== null && items.length > 0;
|
|
526
|
-
|
|
527
|
-
var _useState = useState(null),
|
|
528
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
529
|
-
thumbSize = _useState2[0],
|
|
530
|
-
setThumbSize = _useState2[1];
|
|
531
|
-
|
|
532
|
-
var firstScreenContainerRef = useRef(null);
|
|
533
|
-
useEffect(function () {
|
|
534
|
-
if (hasItems && hasSize && firstScreenContainerRef.current !== null) {
|
|
535
|
-
var _firstScreenContainer = firstScreenContainerRef.current,
|
|
536
|
-
offsetWidth = _firstScreenContainer.offsetWidth,
|
|
537
|
-
offsetHeight = _firstScreenContainer.offsetHeight;
|
|
538
|
-
setThumbSize({
|
|
539
|
-
width: offsetWidth,
|
|
540
|
-
height: offsetHeight
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
}, [screenWidth, hasItems, hasSize]); // Viewer theme
|
|
544
|
-
|
|
545
|
-
var _ref2 = viewerTheme || {},
|
|
546
|
-
_ref2$colors = _ref2.colors,
|
|
547
|
-
colors = _ref2$colors === void 0 ? null : _ref2$colors,
|
|
548
|
-
_ref2$background = _ref2.background,
|
|
549
|
-
background = _ref2$background === void 0 ? null : _ref2$background,
|
|
550
|
-
_ref2$textStyles = _ref2.textStyles,
|
|
551
|
-
textStyles = _ref2$textStyles === void 0 ? null : _ref2$textStyles,
|
|
552
|
-
_ref2$logo = _ref2.logo,
|
|
553
|
-
brandLogo = _ref2$logo === void 0 ? null : _ref2$logo;
|
|
554
|
-
|
|
555
|
-
var _ref3 = textStyles || {},
|
|
556
|
-
_ref3$title = _ref3.title,
|
|
557
|
-
brandTextStyle = _ref3$title === void 0 ? null : _ref3$title;
|
|
558
|
-
|
|
559
|
-
var _ref4 = colors || {},
|
|
560
|
-
_ref4$primary = _ref4.primary,
|
|
561
|
-
brandPrimaryColor = _ref4$primary === void 0 ? null : _ref4$primary,
|
|
562
|
-
_ref4$secondary = _ref4.secondary,
|
|
563
|
-
brandSecondaryColor = _ref4$secondary === void 0 ? null : _ref4$secondary;
|
|
564
733
|
|
|
565
|
-
var
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
_ref5$image = _ref5.image,
|
|
569
|
-
image = _ref5$image === void 0 ? null : _ref5$image;
|
|
734
|
+
var _ref2 = screenSize || {},
|
|
735
|
+
screenWidth = _ref2.width,
|
|
736
|
+
screenHeight = _ref2.height;
|
|
570
737
|
|
|
571
|
-
var
|
|
572
|
-
|
|
573
|
-
|
|
738
|
+
var _useResizeObserver = useResizeObserver(),
|
|
739
|
+
firstScreenContainerRef = _useResizeObserver.ref,
|
|
740
|
+
firstScreenContentRect = _useResizeObserver.entry.contentRect;
|
|
741
|
+
|
|
742
|
+
var _ref3 = firstScreenContentRect || {},
|
|
743
|
+
_ref3$width = _ref3.width,
|
|
744
|
+
thumbWidth = _ref3$width === void 0 ? 0 : _ref3$width;
|
|
745
|
+
|
|
746
|
+
var screenScale = thumbWidth / screenWidth; // Viewer theme
|
|
747
|
+
|
|
748
|
+
var _ref4 = viewerTheme || {},
|
|
749
|
+
_ref4$colors = _ref4.colors,
|
|
750
|
+
colors = _ref4$colors === void 0 ? null : _ref4$colors,
|
|
751
|
+
_ref4$background = _ref4.background,
|
|
752
|
+
background = _ref4$background === void 0 ? null : _ref4$background,
|
|
753
|
+
_ref4$textStyles = _ref4.textStyles,
|
|
754
|
+
textStyles = _ref4$textStyles === void 0 ? null : _ref4$textStyles,
|
|
755
|
+
_ref4$logo = _ref4.logo,
|
|
756
|
+
brandLogo = _ref4$logo === void 0 ? null : _ref4$logo;
|
|
757
|
+
|
|
758
|
+
var _ref5 = textStyles || {},
|
|
759
|
+
_ref5$title = _ref5.title,
|
|
760
|
+
brandTextStyle = _ref5$title === void 0 ? null : _ref5$title;
|
|
761
|
+
|
|
762
|
+
var _ref6 = colors || {},
|
|
763
|
+
_ref6$primary = _ref6.primary,
|
|
764
|
+
brandPrimaryColor = _ref6$primary === void 0 ? null : _ref6$primary,
|
|
765
|
+
_ref6$secondary = _ref6.secondary,
|
|
766
|
+
brandSecondaryColor = _ref6$secondary === void 0 ? null : _ref6$secondary;
|
|
767
|
+
|
|
768
|
+
var _ref7 = background || {},
|
|
769
|
+
_ref7$color = _ref7.color,
|
|
770
|
+
brandBackgroundColor = _ref7$color === void 0 ? null : _ref7$color,
|
|
771
|
+
_ref7$image = _ref7.image,
|
|
772
|
+
image = _ref7$image === void 0 ? null : _ref7$image;
|
|
773
|
+
|
|
774
|
+
var _ref8 = image || {},
|
|
775
|
+
_ref8$url = _ref8.url,
|
|
776
|
+
brandImageUrl = _ref8$url === void 0 ? null : _ref8$url;
|
|
574
777
|
|
|
575
778
|
var borderPrimaryColorStyle = getStyleFromColor(brandPrimaryColor, 'borderColor');
|
|
576
779
|
var colorSecondaryColorStyle = getStyleFromColor(brandSecondaryColor, 'color');
|
|
577
780
|
var backgroundColorStyle = getStyleFromColor(brandBackgroundColor, 'backgroundColor');
|
|
578
781
|
|
|
579
|
-
var
|
|
580
|
-
|
|
581
|
-
brandLogoUrl =
|
|
782
|
+
var _ref9 = brandLogo || {},
|
|
783
|
+
_ref9$url = _ref9.url,
|
|
784
|
+
brandLogoUrl = _ref9$url === void 0 ? null : _ref9$url;
|
|
582
785
|
|
|
583
786
|
var brandImageStyle = brandImageUrl !== null ? {
|
|
584
787
|
backgroundImage: "url(".concat(brandImageUrl, ")")
|
|
585
788
|
} : null;
|
|
586
789
|
var titleStyle = brandTextStyle !== null ? getStyleFromText(brandTextStyle) : null;
|
|
587
790
|
|
|
588
|
-
var
|
|
589
|
-
|
|
590
|
-
scrolledBottom =
|
|
591
|
-
setScrolledBottom =
|
|
791
|
+
var _useState = useState(false),
|
|
792
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
793
|
+
scrolledBottom = _useState2[0],
|
|
794
|
+
setScrolledBottom = _useState2[1];
|
|
592
795
|
|
|
593
|
-
var dragBind = useDrag(function (
|
|
594
|
-
var
|
|
595
|
-
dy =
|
|
596
|
-
last =
|
|
597
|
-
tap =
|
|
796
|
+
var dragBind = useDrag(function (_ref10) {
|
|
797
|
+
var _ref10$direction = _slicedToArray(_ref10.direction, 2),
|
|
798
|
+
dy = _ref10$direction[1],
|
|
799
|
+
last = _ref10.last,
|
|
800
|
+
tap = _ref10.tap;
|
|
598
801
|
|
|
599
802
|
if (!tap && last && scrolledBottom && dy < 0 && onClose !== null) {
|
|
600
803
|
onClose();
|
|
@@ -611,37 +814,37 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
611
814
|
var onScrolledNotBottom = useCallback(function () {
|
|
612
815
|
setScrolledBottom(false);
|
|
613
816
|
}, [setScrolledBottom]);
|
|
614
|
-
return
|
|
615
|
-
className: classNames([styles$
|
|
817
|
+
return /*#__PURE__*/React.createElement("div", Object.assign({
|
|
818
|
+
className: classNames([styles$3.container, _defineProperty({}, className, className !== null)]),
|
|
616
819
|
style: _objectSpread(_objectSpread(_objectSpread({}, backgroundColorStyle), brandImageStyle), {}, {
|
|
617
|
-
width:
|
|
820
|
+
width: menuWidth
|
|
618
821
|
}),
|
|
619
822
|
"aria-hidden": focusable ? null : 'true'
|
|
620
823
|
}, dragBind()), /*#__PURE__*/React.createElement("div", {
|
|
621
|
-
className: styles$
|
|
824
|
+
className: styles$3.header
|
|
622
825
|
}, brandLogoUrl !== null ? /*#__PURE__*/React.createElement("div", {
|
|
623
|
-
className: styles$
|
|
826
|
+
className: styles$3.organisation,
|
|
624
827
|
style: {
|
|
625
828
|
backgroundImage: "url(".concat(brandLogoUrl, ")")
|
|
626
829
|
}
|
|
627
830
|
}) : null, /*#__PURE__*/React.createElement("div", {
|
|
628
|
-
className: styles$
|
|
831
|
+
className: styles$3.title,
|
|
629
832
|
style: titleStyle
|
|
630
833
|
}, title), /*#__PURE__*/React.createElement("div", {
|
|
631
|
-
className: styles$
|
|
834
|
+
className: styles$3.buttons,
|
|
632
835
|
style: colorSecondaryColorStyle
|
|
633
836
|
}, /*#__PURE__*/React.createElement(ShareButton, {
|
|
634
|
-
className: styles$
|
|
635
|
-
buttonClassName: styles$
|
|
837
|
+
className: styles$3.shareButton,
|
|
838
|
+
buttonClassName: styles$3.button,
|
|
636
839
|
onShare: onShare,
|
|
637
840
|
url: shareUrl,
|
|
638
841
|
title: title,
|
|
639
842
|
focusable: focusable
|
|
640
843
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
641
|
-
className: styles$
|
|
844
|
+
className: styles$3.icon,
|
|
642
845
|
icon: faShare
|
|
643
846
|
})), fullscreenEnabled ? /*#__PURE__*/React.createElement(Button, {
|
|
644
|
-
className: styles$
|
|
847
|
+
className: styles$3.button,
|
|
645
848
|
onClick: toggleFullscreen,
|
|
646
849
|
title: intl.formatMessage({
|
|
647
850
|
id: "AuxqcG",
|
|
@@ -659,10 +862,10 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
659
862
|
}),
|
|
660
863
|
focusable: focusable
|
|
661
864
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
662
|
-
className: styles$
|
|
865
|
+
className: styles$3.icon,
|
|
663
866
|
icon: fullscreenActive ? faCompress : faExpand
|
|
664
867
|
})) : null, /*#__PURE__*/React.createElement(Button, {
|
|
665
|
-
className: styles$
|
|
868
|
+
className: styles$3.button,
|
|
666
869
|
onClick: onClose,
|
|
667
870
|
title: intl.formatMessage({
|
|
668
871
|
id: "dj/p/q",
|
|
@@ -680,20 +883,23 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
680
883
|
}),
|
|
681
884
|
focusable: focusable
|
|
682
885
|
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
683
|
-
className: styles$
|
|
886
|
+
className: styles$3.icon,
|
|
684
887
|
icon: faTimes
|
|
685
888
|
})))), /*#__PURE__*/React.createElement("div", {
|
|
686
|
-
className: styles$
|
|
889
|
+
className: styles$3.content
|
|
687
890
|
}, /*#__PURE__*/React.createElement(Scroll, {
|
|
688
|
-
className: styles$
|
|
891
|
+
className: styles$3.scroll,
|
|
689
892
|
onScrolledBottom: onScrolledBottom,
|
|
690
893
|
onScrolledNotBottom: onScrolledNotBottom
|
|
691
894
|
}, /*#__PURE__*/React.createElement("nav", {
|
|
692
|
-
className: styles$
|
|
895
|
+
className: styles$3.nav
|
|
693
896
|
}, /*#__PURE__*/React.createElement("ul", {
|
|
694
|
-
className: styles$
|
|
897
|
+
className: styles$3.items
|
|
695
898
|
}, items.map(function (item, index) {
|
|
696
|
-
var
|
|
899
|
+
var _item$current = item.current,
|
|
900
|
+
current = _item$current === void 0 ? false : _item$current,
|
|
901
|
+
screen = item.screen;
|
|
902
|
+
var screenAriaLabel = "".concat(intl.formatMessage({
|
|
697
903
|
id: "LkVfwW",
|
|
698
904
|
defaultMessage: [{
|
|
699
905
|
"type": 0,
|
|
@@ -704,89 +910,427 @@ var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
|
|
|
704
910
|
}]
|
|
705
911
|
}, {
|
|
706
912
|
index: index + 1
|
|
707
|
-
})
|
|
708
|
-
var isCurrentScreenLabel = current === index ? " ".concat(intl.formatMessage({
|
|
913
|
+
})).concat(current ? " ".concat(intl.formatMessage({
|
|
709
914
|
id: "vmrJ8U",
|
|
710
915
|
defaultMessage: [{
|
|
711
916
|
"type": 0,
|
|
712
917
|
"value": "(current screen)"
|
|
713
918
|
}]
|
|
714
|
-
})) : '';
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
className: classNames([styles$2.item, _defineProperty({}, styles$2.active, current === index)]),
|
|
919
|
+
})) : '');
|
|
920
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
921
|
+
className: classNames([styles$3.item, _defineProperty({}, styles$3.active, current)]),
|
|
718
922
|
key: "item-".concat(index),
|
|
719
923
|
style: {
|
|
720
|
-
paddingBottom: screenSizeRatio,
|
|
721
924
|
width: "".concat(100 / thumbsPerLine, "%")
|
|
722
925
|
}
|
|
723
926
|
}, /*#__PURE__*/React.createElement("div", {
|
|
724
|
-
className: styles$
|
|
725
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
726
|
-
className: styles$2.screenContainer,
|
|
727
|
-
ref: index === 0 ? firstScreenContainerRef : null
|
|
927
|
+
className: styles$3.itemContent
|
|
728
928
|
}, /*#__PURE__*/React.createElement("div", {
|
|
729
|
-
className: styles$
|
|
730
|
-
|
|
929
|
+
className: styles$3.screenContainer,
|
|
930
|
+
ref: index === 0 ? firstScreenContainerRef : null,
|
|
931
|
+
style: {
|
|
932
|
+
height: screenHeight * screenScale
|
|
933
|
+
}
|
|
934
|
+
}, screenWidth > 0 && screenHeight > 0 ? /*#__PURE__*/React.createElement("div", {
|
|
935
|
+
className: styles$3.screenContent,
|
|
936
|
+
style: {
|
|
731
937
|
width: screenWidth,
|
|
732
|
-
height:
|
|
733
|
-
transform: "scale(".concat(
|
|
734
|
-
}
|
|
938
|
+
height: screenHeight,
|
|
939
|
+
transform: "scale(".concat(screenScale)
|
|
940
|
+
},
|
|
735
941
|
"aria-hidden": "true"
|
|
736
942
|
}, /*#__PURE__*/React.createElement(ScreenPreview, {
|
|
737
943
|
width: screenWidth,
|
|
738
|
-
height:
|
|
739
|
-
screen:
|
|
944
|
+
height: screenHeight,
|
|
945
|
+
screen: screen,
|
|
740
946
|
focusable: false
|
|
741
|
-
})), current
|
|
742
|
-
className: styles$
|
|
947
|
+
})) : null, current ? /*#__PURE__*/React.createElement("div", {
|
|
948
|
+
className: styles$3.activeScreenBorder,
|
|
743
949
|
style: borderPrimaryColorStyle
|
|
744
950
|
}) : null)), /*#__PURE__*/React.createElement("button", {
|
|
745
951
|
type: "button",
|
|
746
|
-
className: styles$
|
|
952
|
+
className: styles$3.screenButton,
|
|
747
953
|
onClick: function onClick() {
|
|
748
|
-
onClickItem
|
|
954
|
+
if (onClickItem !== null) {
|
|
955
|
+
onClickItem(item);
|
|
956
|
+
}
|
|
749
957
|
},
|
|
750
958
|
"aria-label": screenAriaLabel,
|
|
751
959
|
onKeyUp: function onKeyUp(e) {
|
|
752
|
-
if (e.key === 'Enter') {
|
|
753
|
-
onClickItem(
|
|
960
|
+
if (e.key === 'Enter' && onClickItem !== null) {
|
|
961
|
+
onClickItem(item);
|
|
754
962
|
}
|
|
755
963
|
},
|
|
756
964
|
tabIndex: focusable ? '0' : '-1'
|
|
757
|
-
}))
|
|
758
|
-
}))))))
|
|
965
|
+
}));
|
|
966
|
+
}))))));
|
|
759
967
|
};
|
|
760
968
|
|
|
761
|
-
ViewerMenuPreview.propTypes = propTypes$
|
|
762
|
-
ViewerMenuPreview.defaultProps = defaultProps$
|
|
969
|
+
ViewerMenuPreview.propTypes = propTypes$5;
|
|
970
|
+
ViewerMenuPreview.defaultProps = defaultProps$5;
|
|
763
971
|
|
|
764
|
-
var propTypes$
|
|
765
|
-
story: PropTypes$1.story,
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
screen: PropTypes.string,
|
|
772
|
-
deviceScreens: PropTypes$1.deviceScreens,
|
|
773
|
-
renderContext: PropTypes$1.renderContext,
|
|
774
|
-
onScreenChange: PropTypes.func,
|
|
775
|
-
tapNextScreenWidthPercent: PropTypes.number,
|
|
776
|
-
neighborScreensActive: PropTypes.number,
|
|
777
|
-
storyIsParsed: PropTypes.bool,
|
|
778
|
-
landscapeScreenMargin: PropTypes.number,
|
|
779
|
-
withMetadata: PropTypes.bool,
|
|
780
|
-
withoutMenu: PropTypes.bool,
|
|
781
|
-
withoutFullscreen: PropTypes.bool,
|
|
972
|
+
var propTypes$4 = {
|
|
973
|
+
story: PropTypes$1.story.isRequired,
|
|
974
|
+
currentScreenIndex: PropTypes.number,
|
|
975
|
+
opened: PropTypes.bool,
|
|
976
|
+
toggleFullscreen: PropTypes.func,
|
|
977
|
+
fullscreenActive: PropTypes.bool,
|
|
978
|
+
fullscreenEnabled: PropTypes.bool,
|
|
782
979
|
closeable: PropTypes.bool,
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
980
|
+
withShadow: PropTypes.bool,
|
|
981
|
+
trackingEnabled: PropTypes.bool,
|
|
982
|
+
shareBasePath: PropTypes.string,
|
|
983
|
+
theme: PropTypes$1.viewerTheme,
|
|
984
|
+
screenSize: PropTypes$1.screenSize,
|
|
985
|
+
menuWidth: PropTypes.number,
|
|
986
|
+
withDotItemClick: PropTypes.bool,
|
|
987
|
+
withoutScreensMenu: PropTypes.bool,
|
|
988
|
+
onRequestOpen: PropTypes.func,
|
|
989
|
+
onRequestClose: PropTypes.func,
|
|
990
|
+
onClickItem: PropTypes.func,
|
|
991
|
+
onClickMenu: PropTypes.func,
|
|
992
|
+
onClickCloseViewer: PropTypes.func,
|
|
993
|
+
refDots: PropTypes.shape({
|
|
994
|
+
current: PropTypes.any // eslint-disable-line
|
|
995
|
+
|
|
996
|
+
})
|
|
997
|
+
};
|
|
998
|
+
var defaultProps$4 = {
|
|
999
|
+
currentScreenIndex: 0,
|
|
1000
|
+
opened: false,
|
|
1001
|
+
toggleFullscreen: null,
|
|
1002
|
+
fullscreenActive: false,
|
|
1003
|
+
fullscreenEnabled: false,
|
|
1004
|
+
closeable: false,
|
|
1005
|
+
withShadow: false,
|
|
1006
|
+
trackingEnabled: false,
|
|
1007
|
+
shareBasePath: null,
|
|
1008
|
+
theme: null,
|
|
1009
|
+
screenSize: null,
|
|
1010
|
+
menuWidth: null,
|
|
1011
|
+
withDotItemClick: false,
|
|
1012
|
+
withoutScreensMenu: false,
|
|
1013
|
+
onRequestOpen: null,
|
|
1014
|
+
onRequestClose: null,
|
|
1015
|
+
onClickItem: null,
|
|
1016
|
+
onClickMenu: null,
|
|
1017
|
+
onClickCloseViewer: null,
|
|
1018
|
+
refDots: null
|
|
1019
|
+
};
|
|
1020
|
+
|
|
1021
|
+
var ViewerMenu = function ViewerMenu(_ref) {
|
|
1022
|
+
var story = _ref.story,
|
|
1023
|
+
currentScreenIndex = _ref.currentScreenIndex,
|
|
1024
|
+
opened = _ref.opened,
|
|
1025
|
+
toggleFullscreen = _ref.toggleFullscreen,
|
|
1026
|
+
fullscreenActive = _ref.fullscreenActive,
|
|
1027
|
+
fullscreenEnabled = _ref.fullscreenEnabled,
|
|
1028
|
+
closeable = _ref.closeable,
|
|
1029
|
+
withShadow = _ref.withShadow,
|
|
1030
|
+
shareBasePath = _ref.shareBasePath,
|
|
1031
|
+
trackingEnabled = _ref.trackingEnabled,
|
|
1032
|
+
viewerTheme = _ref.theme,
|
|
1033
|
+
screenSize = _ref.screenSize,
|
|
1034
|
+
menuWidth = _ref.menuWidth,
|
|
1035
|
+
withDotItemClick = _ref.withDotItemClick,
|
|
1036
|
+
withoutScreensMenu = _ref.withoutScreensMenu,
|
|
1037
|
+
onRequestOpen = _ref.onRequestOpen,
|
|
1038
|
+
onRequestClose = _ref.onRequestClose,
|
|
1039
|
+
customOnClickItem = _ref.onClickItem,
|
|
1040
|
+
customOnClickMenu = _ref.onClickMenu,
|
|
1041
|
+
onClickCloseViewer = _ref.onClickCloseViewer,
|
|
1042
|
+
refDots = _ref.refDots;
|
|
1043
|
+
var _story$components = story.components,
|
|
1044
|
+
screens = _story$components === void 0 ? [] : _story$components,
|
|
1045
|
+
_story$title = story.title,
|
|
1046
|
+
title = _story$title === void 0 ? null : _story$title;
|
|
1047
|
+
var currentScreen = screens !== null ? screens[currentScreenIndex] || null : null;
|
|
1048
|
+
|
|
1049
|
+
var _ref2 = currentScreen || {},
|
|
1050
|
+
_ref2$id = _ref2.id,
|
|
1051
|
+
screenId = _ref2$id === void 0 ? null : _ref2$id,
|
|
1052
|
+
_ref2$type = _ref2.type,
|
|
1053
|
+
screenType = _ref2$type === void 0 ? null : _ref2$type;
|
|
1054
|
+
|
|
1055
|
+
var items = useMemo(function () {
|
|
1056
|
+
return screens.filter(function (_ref3) {
|
|
1057
|
+
var _ref3$parentId = _ref3.parentId,
|
|
1058
|
+
parentId = _ref3$parentId === void 0 ? null : _ref3$parentId;
|
|
1059
|
+
return parentId === null;
|
|
1060
|
+
}).map(function (it) {
|
|
1061
|
+
return {
|
|
1062
|
+
screen: it,
|
|
1063
|
+
screenId: it.id,
|
|
1064
|
+
current: screenId === it.id
|
|
1065
|
+
};
|
|
1066
|
+
});
|
|
1067
|
+
}, [screens, screenId]);
|
|
1068
|
+
var trackEvent = useTrackEvent();
|
|
1069
|
+
var trackScreenEvent = useCallback(function (cat, action, label) {
|
|
1070
|
+
if (trackingEnabled) {
|
|
1071
|
+
trackEvent(cat, action, label, {
|
|
1072
|
+
screenId: screenId,
|
|
1073
|
+
screenIndex: currentScreenIndex,
|
|
1074
|
+
screenType: screenType
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}, [trackEvent, screenId, currentScreenIndex, screenType]);
|
|
1078
|
+
var shareUrl = useMemo(function () {
|
|
1079
|
+
var origin = typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
|
|
1080
|
+
var path = shareBasePath !== null ? "".concat(origin).concat(shareBasePath) : origin;
|
|
1081
|
+
return path;
|
|
1082
|
+
}, [shareBasePath]);
|
|
1083
|
+
|
|
1084
|
+
var _useSpring = useSpring(function () {
|
|
1085
|
+
return {
|
|
1086
|
+
y: 0,
|
|
1087
|
+
config: _objectSpread(_objectSpread({}, config.stiff), {}, {
|
|
1088
|
+
clamp: true
|
|
1089
|
+
})
|
|
1090
|
+
};
|
|
1091
|
+
}),
|
|
1092
|
+
_useSpring2 = _slicedToArray(_useSpring, 2),
|
|
1093
|
+
menuY = _useSpring2[0].y,
|
|
1094
|
+
setMenuSpring = _useSpring2[1];
|
|
1095
|
+
|
|
1096
|
+
var refOpened = useRef(opened);
|
|
1097
|
+
|
|
1098
|
+
if (refOpened.current !== opened) {
|
|
1099
|
+
refOpened.current = opened;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
useEffect(function () {
|
|
1103
|
+
setMenuSpring.start({
|
|
1104
|
+
y: opened ? 1 : 0
|
|
1105
|
+
});
|
|
1106
|
+
}, [opened]);
|
|
1107
|
+
|
|
1108
|
+
var _useResizeObserver = useResizeObserver(),
|
|
1109
|
+
menuPreviewContainerRef = _useResizeObserver.ref,
|
|
1110
|
+
menuPreviewContainerRect = _useResizeObserver.entry.contentRect;
|
|
1111
|
+
|
|
1112
|
+
var _ref4 = menuPreviewContainerRect || {},
|
|
1113
|
+
_ref4$height = _ref4.height,
|
|
1114
|
+
menuPreviewContainerHeight = _ref4$height === void 0 ? 0 : _ref4$height;
|
|
1115
|
+
|
|
1116
|
+
var menuPreviewStyle = {
|
|
1117
|
+
transform: menuY.to(function (y) {
|
|
1118
|
+
return "translateY(".concat(y * menuPreviewContainerHeight, "px)");
|
|
1119
|
+
})
|
|
1120
|
+
};
|
|
1121
|
+
var menuDragBind = useDrag(function (_ref5) {
|
|
1122
|
+
var _ref5$movement = _slicedToArray(_ref5.movement, 2),
|
|
1123
|
+
my = _ref5$movement[1],
|
|
1124
|
+
first = _ref5.first,
|
|
1125
|
+
last = _ref5.last,
|
|
1126
|
+
_ref5$direction = _slicedToArray(_ref5.direction, 2),
|
|
1127
|
+
dy = _ref5$direction[1],
|
|
1128
|
+
cancel = _ref5.cancel,
|
|
1129
|
+
canceled = _ref5.canceled,
|
|
1130
|
+
tap = _ref5.tap;
|
|
1131
|
+
|
|
1132
|
+
if (canceled || tap) {
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1136
|
+
var isMenuOpened = refOpened.current;
|
|
1137
|
+
|
|
1138
|
+
if (first) {
|
|
1139
|
+
if (isMenuOpened) {
|
|
1140
|
+
cancel();
|
|
1141
|
+
return;
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
1144
|
+
|
|
1145
|
+
var yProgress = Math.max(0, Math.min(1, my / menuPreviewContainerHeight + (isMenuOpened ? 1 : 0)));
|
|
1146
|
+
|
|
1147
|
+
if (last) {
|
|
1148
|
+
var menuNowOpened = dy > 0 && yProgress > 0.1;
|
|
1149
|
+
refOpened.current = menuNowOpened;
|
|
1150
|
+
setMenuSpring.start({
|
|
1151
|
+
y: menuNowOpened ? 1 : 0
|
|
1152
|
+
});
|
|
1153
|
+
|
|
1154
|
+
if (menuNowOpened && onRequestOpen !== null) {
|
|
1155
|
+
onRequestOpen();
|
|
1156
|
+
} else if (!menuNowOpened && onRequestClose !== null) {
|
|
1157
|
+
onRequestClose();
|
|
1158
|
+
}
|
|
1159
|
+
} else {
|
|
1160
|
+
setMenuSpring.start({
|
|
1161
|
+
y: yProgress
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
}, {
|
|
1165
|
+
axis: 'y',
|
|
1166
|
+
filterTaps: true
|
|
1167
|
+
}); // handle preview menu item click
|
|
1168
|
+
|
|
1169
|
+
var onClickMenu = useCallback(function (index) {
|
|
1170
|
+
if (customOnClickMenu !== null) {
|
|
1171
|
+
customOnClickMenu(index);
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
trackScreenEvent('viewer_menu', 'click_open', 'Menu icon');
|
|
1175
|
+
}, [customOnClickMenu, trackScreenEvent]);
|
|
1176
|
+
var onClickItem = useCallback(function (item) {
|
|
1177
|
+
if (customOnClickItem !== null) {
|
|
1178
|
+
customOnClickItem(item);
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
var index = items.findIndex(function (_ref6) {
|
|
1182
|
+
var id = _ref6.id;
|
|
1183
|
+
return id === screenId;
|
|
1184
|
+
});
|
|
1185
|
+
trackScreenEvent('viewer_menu', 'click_screen_change', "Screen ".concat(index + 1));
|
|
1186
|
+
}, [customOnClickItem, items, screenId, trackScreenEvent]);
|
|
1187
|
+
var onClickClose = useCallback(function () {
|
|
1188
|
+
if (onRequestClose !== null) {
|
|
1189
|
+
onRequestClose();
|
|
1190
|
+
}
|
|
1191
|
+
|
|
1192
|
+
trackScreenEvent('viewer_menu', 'click_close', 'Close icon');
|
|
1193
|
+
}, [onRequestClose, trackScreenEvent]); // Handle preview menu share click
|
|
1194
|
+
|
|
1195
|
+
var onClickShare = useCallback(function (type) {
|
|
1196
|
+
return trackScreenEvent('viewer_menu', 'click_share', type);
|
|
1197
|
+
}, [trackScreenEvent]);
|
|
1198
|
+
|
|
1199
|
+
var _ref7 = viewerTheme || {},
|
|
1200
|
+
_ref7$menuTheme = _ref7.menuTheme,
|
|
1201
|
+
menuTheme = _ref7$menuTheme === void 0 ? null : _ref7$menuTheme;
|
|
1202
|
+
|
|
1203
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", Object.assign({
|
|
1204
|
+
className: styles$7.menuDotsContainer,
|
|
1205
|
+
ref: refDots,
|
|
1206
|
+
style: {
|
|
1207
|
+
width: menuWidth
|
|
1208
|
+
}
|
|
1209
|
+
}, menuDragBind()), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
|
|
1210
|
+
direction: "horizontal",
|
|
1211
|
+
withShadow: withShadow,
|
|
1212
|
+
items: items,
|
|
1213
|
+
onClickItem: onClickItem,
|
|
1214
|
+
onClickMenu: onClickMenu,
|
|
1215
|
+
closeable: closeable,
|
|
1216
|
+
withItemClick: withDotItemClick,
|
|
1217
|
+
withoutScreensMenu: withoutScreensMenu,
|
|
1218
|
+
onClose: onClickCloseViewer,
|
|
1219
|
+
className: styles$7.menuDots
|
|
1220
|
+
}))), /*#__PURE__*/React.createElement(animated.div, {
|
|
1221
|
+
className: styles$7.menuPreviewContainer,
|
|
1222
|
+
style: menuPreviewStyle,
|
|
1223
|
+
ref: menuPreviewContainerRef
|
|
1224
|
+
}, /*#__PURE__*/React.createElement(ViewerMenuPreview, {
|
|
1225
|
+
viewerTheme: viewerTheme,
|
|
1226
|
+
title: title,
|
|
1227
|
+
shareUrl: shareUrl,
|
|
1228
|
+
className: styles$7.menuPreview,
|
|
1229
|
+
screenSize: screenSize,
|
|
1230
|
+
menuWidth: menuWidth,
|
|
1231
|
+
focusable: opened,
|
|
1232
|
+
items: items,
|
|
1233
|
+
onClickItem: onClickItem,
|
|
1234
|
+
onClose: onClickClose,
|
|
1235
|
+
onShare: onClickShare,
|
|
1236
|
+
toggleFullscreen: toggleFullscreen,
|
|
1237
|
+
fullscreenActive: fullscreenActive,
|
|
1238
|
+
fullscreenEnabled: fullscreenEnabled
|
|
1239
|
+
})));
|
|
1240
|
+
};
|
|
1241
|
+
|
|
1242
|
+
ViewerMenu.propTypes = propTypes$4;
|
|
1243
|
+
ViewerMenu.defaultProps = defaultProps$4;
|
|
1244
|
+
|
|
1245
|
+
var styles = {"container":"micromag-viewer-screen-container","current":"micromag-viewer-screen-current"};
|
|
1246
|
+
|
|
1247
|
+
var propTypes$3 = {
|
|
1248
|
+
screen: PropTypes$1.screenComponent,
|
|
1249
|
+
renderContext: PropTypes$1.renderContext,
|
|
1250
|
+
screenState: PropTypes.string,
|
|
1251
|
+
current: PropTypes.bool,
|
|
1252
|
+
active: PropTypes.bool,
|
|
1253
|
+
onPrevious: PropTypes.func,
|
|
1254
|
+
onNext: PropTypes.func,
|
|
1255
|
+
onEnableInteraction: PropTypes.func,
|
|
1256
|
+
onDisableInteraction: PropTypes.func,
|
|
1257
|
+
getMediaRef: PropTypes.func
|
|
1258
|
+
};
|
|
1259
|
+
var defaultProps$3 = {
|
|
1260
|
+
screen: null,
|
|
1261
|
+
renderContext: null,
|
|
1262
|
+
screenState: null,
|
|
1263
|
+
current: false,
|
|
1264
|
+
active: true,
|
|
1265
|
+
onPrevious: null,
|
|
1266
|
+
onNext: null,
|
|
1267
|
+
onEnableInteraction: null,
|
|
1268
|
+
onDisableInteraction: null,
|
|
1269
|
+
getMediaRef: null
|
|
1270
|
+
};
|
|
1271
|
+
|
|
1272
|
+
var ViewerScreen = function ViewerScreen(_ref) {
|
|
1273
|
+
var _ref2;
|
|
1274
|
+
|
|
1275
|
+
var screen = _ref.screen,
|
|
1276
|
+
renderContext = _ref.renderContext,
|
|
1277
|
+
screenState = _ref.screenState,
|
|
1278
|
+
active = _ref.active,
|
|
1279
|
+
current = _ref.current,
|
|
1280
|
+
onPrevious = _ref.onPrevious,
|
|
1281
|
+
onNext = _ref.onNext,
|
|
1282
|
+
onEnableInteraction = _ref.onEnableInteraction,
|
|
1283
|
+
onDisableInteraction = _ref.onDisableInteraction,
|
|
1284
|
+
getMediaRef = _ref.getMediaRef;
|
|
1285
|
+
return screen !== null ? /*#__PURE__*/React.createElement("div", {
|
|
1286
|
+
className: classNames([styles.container, (_ref2 = {}, _defineProperty(_ref2, styles.active, active), _defineProperty(_ref2, styles.current, current), _ref2)]),
|
|
1287
|
+
"aria-hidden": current ? null : 'true'
|
|
1288
|
+
}, /*#__PURE__*/React.createElement(Screen, {
|
|
1289
|
+
screen: screen,
|
|
1290
|
+
renderContext: renderContext,
|
|
1291
|
+
screenState: screenState,
|
|
1292
|
+
active: active,
|
|
1293
|
+
current: current,
|
|
1294
|
+
onPrevious: onPrevious,
|
|
1295
|
+
onNext: onNext,
|
|
1296
|
+
onEnableInteraction: onEnableInteraction,
|
|
1297
|
+
onDisableInteraction: onDisableInteraction,
|
|
1298
|
+
getMediaRef: getMediaRef
|
|
1299
|
+
})) : null;
|
|
1300
|
+
};
|
|
1301
|
+
|
|
1302
|
+
ViewerScreen.propTypes = propTypes$3;
|
|
1303
|
+
ViewerScreen.defaultProps = defaultProps$3;
|
|
1304
|
+
|
|
1305
|
+
var propTypes$2 = {
|
|
1306
|
+
story: PropTypes$1.story,
|
|
1307
|
+
// .isRequired,
|
|
1308
|
+
basePath: PropTypes.string,
|
|
1309
|
+
theme: PropTypes$1.viewerTheme,
|
|
1310
|
+
width: PropTypes.number,
|
|
1311
|
+
height: PropTypes.number,
|
|
1312
|
+
screen: PropTypes.string,
|
|
1313
|
+
screenState: PropTypes.string,
|
|
1314
|
+
deviceScreens: PropTypes$1.deviceScreens,
|
|
1315
|
+
renderContext: PropTypes$1.renderContext,
|
|
1316
|
+
onScreenChange: PropTypes.func,
|
|
1317
|
+
tapNextScreenWidthPercent: PropTypes.number,
|
|
1318
|
+
neighborScreensActive: PropTypes.number,
|
|
1319
|
+
storyIsParsed: PropTypes.bool,
|
|
1320
|
+
landscapeScreenMargin: PropTypes.number,
|
|
1321
|
+
withMetadata: PropTypes.bool,
|
|
1322
|
+
withoutMenu: PropTypes.bool,
|
|
1323
|
+
withoutScreensMenu: PropTypes.bool,
|
|
1324
|
+
withoutFullscreen: PropTypes.bool,
|
|
1325
|
+
withLandscapeSiblingsScreens: PropTypes.bool,
|
|
1326
|
+
closeable: PropTypes.bool,
|
|
1327
|
+
onClose: PropTypes.func,
|
|
1328
|
+
onInteraction: PropTypes.func,
|
|
1329
|
+
onEnd: PropTypes.func,
|
|
1330
|
+
onViewModeChange: PropTypes.func,
|
|
1331
|
+
currentScreenMedia: PropTypes$1.ref,
|
|
1332
|
+
screensMedias: PropTypes$1.ref,
|
|
1333
|
+
screenSizeOptions: PropTypes.shape({
|
|
790
1334
|
withoutMaxSize: PropTypes.bool,
|
|
791
1335
|
desktopHeightRatio: PropTypes.number,
|
|
792
1336
|
screenRatio: PropTypes.number
|
|
@@ -800,16 +1344,19 @@ var defaultProps$2 = {
|
|
|
800
1344
|
width: null,
|
|
801
1345
|
height: null,
|
|
802
1346
|
screen: null,
|
|
1347
|
+
screenState: null,
|
|
803
1348
|
deviceScreens: getDeviceScreens(),
|
|
804
1349
|
renderContext: 'view',
|
|
805
1350
|
onScreenChange: null,
|
|
806
|
-
tapNextScreenWidthPercent: 0.
|
|
1351
|
+
tapNextScreenWidthPercent: 0.8,
|
|
807
1352
|
neighborScreensActive: 2,
|
|
808
1353
|
storyIsParsed: false,
|
|
809
|
-
landscapeScreenMargin:
|
|
1354
|
+
landscapeScreenMargin: 20,
|
|
810
1355
|
withMetadata: false,
|
|
811
1356
|
withoutMenu: false,
|
|
1357
|
+
withoutScreensMenu: false,
|
|
812
1358
|
withoutFullscreen: false,
|
|
1359
|
+
withLandscapeSiblingsScreens: false,
|
|
813
1360
|
closeable: false,
|
|
814
1361
|
onClose: null,
|
|
815
1362
|
onInteraction: null,
|
|
@@ -822,7 +1369,7 @@ var defaultProps$2 = {
|
|
|
822
1369
|
};
|
|
823
1370
|
|
|
824
1371
|
var Viewer = function Viewer(_ref) {
|
|
825
|
-
var
|
|
1372
|
+
var _ref12;
|
|
826
1373
|
|
|
827
1374
|
var story = _ref.story,
|
|
828
1375
|
basePath = _ref.basePath,
|
|
@@ -830,6 +1377,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
830
1377
|
width = _ref.width,
|
|
831
1378
|
height = _ref.height,
|
|
832
1379
|
screenId = _ref.screen,
|
|
1380
|
+
screenState = _ref.screenState,
|
|
833
1381
|
deviceScreens = _ref.deviceScreens,
|
|
834
1382
|
renderContext = _ref.renderContext,
|
|
835
1383
|
onScreenChange = _ref.onScreenChange,
|
|
@@ -838,10 +1386,12 @@ var Viewer = function Viewer(_ref) {
|
|
|
838
1386
|
storyIsParsed = _ref.storyIsParsed,
|
|
839
1387
|
landscapeScreenMargin = _ref.landscapeScreenMargin,
|
|
840
1388
|
withMetadata = _ref.withMetadata,
|
|
841
|
-
withoutMenu = _ref.withoutMenu
|
|
1389
|
+
withoutMenu = _ref.withoutMenu,
|
|
1390
|
+
withoutScreensMenu = _ref.withoutScreensMenu;
|
|
842
1391
|
_ref.withoutFullscreen;
|
|
843
|
-
var
|
|
844
|
-
|
|
1392
|
+
var withLandscapeSiblingsScreens = _ref.withLandscapeSiblingsScreens,
|
|
1393
|
+
closeable = _ref.closeable,
|
|
1394
|
+
onCloseViewer = _ref.onClose,
|
|
845
1395
|
onInteraction = _ref.onInteraction,
|
|
846
1396
|
onEnd = _ref.onEnd,
|
|
847
1397
|
onViewModeChange = _ref.onViewModeChange,
|
|
@@ -860,7 +1410,10 @@ var Viewer = function Viewer(_ref) {
|
|
|
860
1410
|
_parsedStory$metadata = parsedStory.metadata,
|
|
861
1411
|
metadata = _parsedStory$metadata === void 0 ? null : _parsedStory$metadata,
|
|
862
1412
|
_parsedStory$fonts = parsedStory.fonts,
|
|
863
|
-
fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
|
|
1413
|
+
fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
|
|
1414
|
+
var eventsManager = useMemo(function () {
|
|
1415
|
+
return new EventEmitter();
|
|
1416
|
+
}, [parsedStory]); // Viewer Theme
|
|
864
1417
|
|
|
865
1418
|
var _ref2 = viewerTheme || {},
|
|
866
1419
|
textStyles = _ref2.textStyles;
|
|
@@ -884,17 +1437,11 @@ var Viewer = function Viewer(_ref) {
|
|
|
884
1437
|
_useLoadedFonts.loaded; // eslint-disable-line
|
|
885
1438
|
|
|
886
1439
|
|
|
887
|
-
var shareUrl = useMemo(function () {
|
|
888
|
-
var origin = typeof window !== 'undefined' ? window.location.origin.replace(/\/+$/, '') : '';
|
|
889
|
-
var path = basePath !== null ? "".concat(origin).concat(basePath) : origin;
|
|
890
|
-
return path;
|
|
891
|
-
}, [basePath]);
|
|
892
1440
|
var isView = renderContext === 'view';
|
|
893
1441
|
var isStatic = renderContext === 'static';
|
|
894
1442
|
var isCapture = renderContext === 'capture';
|
|
895
1443
|
var withoutScreensTransforms = isStatic || isCapture;
|
|
896
1444
|
var trackScreenView = useTrackScreenView();
|
|
897
|
-
var trackEvent = useTrackEvent();
|
|
898
1445
|
var contentRef = useRef(null); // Get screen size
|
|
899
1446
|
|
|
900
1447
|
var _useScreenSizeFromEle = useScreenSizeFromElement(_objectSpread({
|
|
@@ -924,30 +1471,12 @@ var Viewer = function Viewer(_ref) {
|
|
|
924
1471
|
landscape: landscape
|
|
925
1472
|
});
|
|
926
1473
|
}
|
|
927
|
-
}, [ready, landscape, onViewModeChange]);
|
|
928
|
-
|
|
929
|
-
var _useResizeObserver = useResizeObserver(),
|
|
930
|
-
menuDotsContainerRef = _useResizeObserver.ref,
|
|
931
|
-
menuDotsContainerRect = _useResizeObserver.entry.contentRect;
|
|
932
|
-
|
|
933
|
-
var _ref6 = menuDotsContainerRect || {},
|
|
934
|
-
_ref6$height = _ref6.height,
|
|
935
|
-
menuDotsContainerHeight = _ref6$height === void 0 ? 0 : _ref6$height; // Get preview menu height
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
var _useResizeObserver2 = useResizeObserver(),
|
|
939
|
-
menuPreviewContainerRef = _useResizeObserver2.ref,
|
|
940
|
-
menuPreviewContainerRect = _useResizeObserver2.entry.contentRect;
|
|
941
|
-
|
|
942
|
-
var _ref7 = menuPreviewContainerRect || {},
|
|
943
|
-
_ref7$height = _ref7.height,
|
|
944
|
-
menuPreviewContainerHeight = _ref7$height === void 0 ? 0 : _ref7$height;
|
|
945
|
-
|
|
1474
|
+
}, [ready, landscape, onViewModeChange]);
|
|
946
1475
|
var screensMediasRef = useRef([]); // Screen index
|
|
947
1476
|
|
|
948
1477
|
var screenIndex = useMemo(function () {
|
|
949
1478
|
return Math.max(0, screens.findIndex(function (it) {
|
|
950
|
-
return
|
|
1479
|
+
return "".concat(it.id) === "".concat(screenId);
|
|
951
1480
|
}));
|
|
952
1481
|
}, [screenId, screens]);
|
|
953
1482
|
|
|
@@ -974,13 +1503,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
974
1503
|
}, [screenIndex, screens, onScreenChange]); // Track screen view
|
|
975
1504
|
|
|
976
1505
|
var trackingEnabled = isView;
|
|
977
|
-
var
|
|
978
|
-
var currentScreen = validIndex ? screens[screenIndex] : null;
|
|
979
|
-
|
|
980
|
-
var _ref8 = currentScreen || {},
|
|
981
|
-
_ref8$type = _ref8.type,
|
|
982
|
-
screenType = _ref8$type === void 0 ? null : _ref8$type;
|
|
983
|
-
|
|
1506
|
+
var currentScreen = screens[screenIndex] || null;
|
|
984
1507
|
useEffect(function () {
|
|
985
1508
|
if (trackingEnabled && currentScreen !== null) {
|
|
986
1509
|
trackScreenView(currentScreen, screenIndex);
|
|
@@ -997,247 +1520,60 @@ var Viewer = function Viewer(_ref) {
|
|
|
997
1520
|
currentScreenRef.current.focus();
|
|
998
1521
|
}, [changeIndex]);
|
|
999
1522
|
var screensCount = screens.length;
|
|
1000
|
-
|
|
1001
|
-
var _useState = useState(screens.map(function () {
|
|
1002
|
-
return true;
|
|
1003
|
-
})),
|
|
1004
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1005
|
-
screensInteractionEnabled = _useState2[0],
|
|
1006
|
-
setScreensInteractionEnabled = _useState2[1];
|
|
1007
|
-
|
|
1008
|
-
var currentScreenInteractionEnabled = screensInteractionEnabled[screenIndex];
|
|
1009
|
-
var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
|
|
1010
|
-
useEffect(function () {
|
|
1011
|
-
setScreensInteractionEnabled(_toConsumableArray(Array(screensCount).keys()).map(function () {
|
|
1012
|
-
return true;
|
|
1013
|
-
}));
|
|
1014
|
-
}, [screensCount]);
|
|
1015
|
-
var onEnableInteraction = useCallback(function () {
|
|
1016
|
-
if (!screensInteractionEnabled[screenIndex]) {
|
|
1017
|
-
var newArray = _toConsumableArray(screensInteractionEnabled);
|
|
1018
|
-
|
|
1019
|
-
newArray[screenIndex] = true;
|
|
1020
|
-
setScreensInteractionEnabled(newArray);
|
|
1021
|
-
}
|
|
1022
|
-
}, [screenIndex, screensInteractionEnabled, setScreensInteractionEnabled]);
|
|
1023
|
-
var onDisableInteraction = useCallback(function () {
|
|
1024
|
-
if (screensInteractionEnabled[screenIndex]) {
|
|
1025
|
-
var newArray = _toConsumableArray(screensInteractionEnabled);
|
|
1026
|
-
|
|
1027
|
-
newArray[screenIndex] = false;
|
|
1028
|
-
setScreensInteractionEnabled(newArray);
|
|
1029
|
-
}
|
|
1030
|
-
}, [screenIndex, screensInteractionEnabled, setScreensInteractionEnabled]); // handle screenClick
|
|
1031
|
-
|
|
1032
1523
|
var onInteractionPrivate = useCallback(function () {
|
|
1033
1524
|
if (onInteraction !== null) {
|
|
1034
1525
|
onInteraction();
|
|
1035
1526
|
}
|
|
1036
1527
|
}, [onInteraction]);
|
|
1037
|
-
var onScreenClick = useCallback(function (e, index) {
|
|
1038
|
-
onInteractionPrivate();
|
|
1039
|
-
|
|
1040
|
-
var checkClickable = function checkClickable(el) {
|
|
1041
|
-
var maxDistance = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
|
|
1042
|
-
var distance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1043
|
-
|
|
1044
|
-
var _ref9 = el || {},
|
|
1045
|
-
_ref9$tagName = _ref9.tagName,
|
|
1046
|
-
tagName = _ref9$tagName === void 0 ? null : _ref9$tagName,
|
|
1047
|
-
_ref9$parentNode = _ref9.parentNode,
|
|
1048
|
-
parentNode = _ref9$parentNode === void 0 ? null : _ref9$parentNode;
|
|
1049
1528
|
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
return checkClickable(parentNode, maxDistance, distance + 1);
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
return false;
|
|
1065
|
-
};
|
|
1066
|
-
|
|
1067
|
-
var tappedCurrent = screenIndex === index;
|
|
1068
|
-
|
|
1069
|
-
if (!isView && tappedCurrent || checkClickable(e.target)) {
|
|
1070
|
-
return;
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
var it = screens[screenIndex] || null;
|
|
1074
|
-
var interactionEnabled = screensInteractionEnabled[screenIndex];
|
|
1075
|
-
|
|
1076
|
-
if (it === null || tappedCurrent && !interactionEnabled) {
|
|
1077
|
-
return;
|
|
1078
|
-
}
|
|
1079
|
-
|
|
1080
|
-
var nextIndex = screenIndex;
|
|
1081
|
-
|
|
1082
|
-
var _e$currentTarget$getB = e.currentTarget.getBoundingClientRect(),
|
|
1083
|
-
_e$currentTarget$getB2 = _e$currentTarget$getB.left,
|
|
1084
|
-
contentX = _e$currentTarget$getB2 === void 0 ? 0 : _e$currentTarget$getB2;
|
|
1085
|
-
|
|
1086
|
-
var tapX = e.clientX;
|
|
1087
|
-
var hasTappedLeft = tappedCurrent ? tapX - contentX < screenWidth * (1 - tapNextScreenWidthPercent) : screenIndex > index;
|
|
1088
|
-
|
|
1089
|
-
if (hasTappedLeft) {
|
|
1090
|
-
nextIndex = landscape ? index : Math.max(0, screenIndex - 1);
|
|
1091
|
-
} else {
|
|
1092
|
-
nextIndex = landscape ? index : Math.min(screens.length - 1, screenIndex + 1);
|
|
1093
|
-
var isLastScreen = screenIndex === screens.length - 1;
|
|
1094
|
-
|
|
1095
|
-
if (isLastScreen && onEnd !== null) {
|
|
1096
|
-
onEnd();
|
|
1097
|
-
}
|
|
1098
|
-
}
|
|
1099
|
-
|
|
1100
|
-
changeIndex(nextIndex);
|
|
1101
|
-
}, [onScreenChange, screenWidth, screens, changeIndex, screenIndex, screensInteractionEnabled, isView, onInteractionPrivate, onEnd]); // swipe menu open
|
|
1102
|
-
|
|
1103
|
-
var menuOpened = useRef(false);
|
|
1104
|
-
|
|
1105
|
-
var _useState3 = useState(false),
|
|
1106
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1107
|
-
previewMenuOpen = _useState4[0],
|
|
1108
|
-
setPreviewMenuOpen = _useState4[1];
|
|
1109
|
-
|
|
1110
|
-
var _useSpring = useSpring(function () {
|
|
1111
|
-
return {
|
|
1112
|
-
y: 0,
|
|
1113
|
-
config: _objectSpread(_objectSpread({}, config.stiff), {}, {
|
|
1114
|
-
clamp: true
|
|
1115
|
-
})
|
|
1116
|
-
};
|
|
1529
|
+
var _useScreenInteraction = useScreenInteraction({
|
|
1530
|
+
screens: screens,
|
|
1531
|
+
screenId: screenId,
|
|
1532
|
+
screenWidth: screenWidth,
|
|
1533
|
+
isView: isView,
|
|
1534
|
+
clickOnSiblings: landscape && withLandscapeSiblingsScreens,
|
|
1535
|
+
nextScreenWidthPercent: tapNextScreenWidthPercent,
|
|
1536
|
+
events: eventsManager,
|
|
1537
|
+
onClick: onInteractionPrivate,
|
|
1538
|
+
onEnd: onEnd,
|
|
1539
|
+
onChangeScreen: changeIndex
|
|
1117
1540
|
}),
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
var menuPreviewStyle = {
|
|
1123
|
-
transform: menuY.to(function (y) {
|
|
1124
|
-
return "translateY(".concat(y * menuPreviewContainerHeight, "px)");
|
|
1125
|
-
})
|
|
1126
|
-
};
|
|
1127
|
-
var menuDragBind = useDrag(function (_ref10) {
|
|
1128
|
-
var _ref10$movement = _slicedToArray(_ref10.movement, 2),
|
|
1129
|
-
my = _ref10$movement[1],
|
|
1130
|
-
first = _ref10.first,
|
|
1131
|
-
last = _ref10.last,
|
|
1132
|
-
_ref10$direction = _slicedToArray(_ref10.direction, 2),
|
|
1133
|
-
dy = _ref10$direction[1],
|
|
1134
|
-
cancel = _ref10.cancel,
|
|
1135
|
-
canceled = _ref10.canceled,
|
|
1136
|
-
tap = _ref10.tap;
|
|
1137
|
-
|
|
1138
|
-
if (canceled || tap) {
|
|
1139
|
-
return;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
var isMenuOpened = menuOpened.current;
|
|
1143
|
-
|
|
1144
|
-
if (first) {
|
|
1145
|
-
if (isMenuOpened) {
|
|
1146
|
-
cancel();
|
|
1147
|
-
return;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
|
|
1151
|
-
var yProgress = Math.max(0, Math.min(1, my / menuPreviewContainerHeight + (isMenuOpened ? 1 : 0)));
|
|
1152
|
-
|
|
1153
|
-
if (last) {
|
|
1154
|
-
var menuNowOpened = dy > 0 && yProgress > 0.1;
|
|
1155
|
-
menuOpened.current = menuNowOpened;
|
|
1156
|
-
setMenuSpring.start({
|
|
1157
|
-
y: menuNowOpened ? 1 : 0
|
|
1158
|
-
});
|
|
1159
|
-
setPreviewMenuOpen(menuNowOpened);
|
|
1160
|
-
} else {
|
|
1161
|
-
setMenuSpring.start({
|
|
1162
|
-
y: yProgress
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
}, {
|
|
1166
|
-
axis: 'y',
|
|
1167
|
-
filterTaps: true
|
|
1168
|
-
});
|
|
1541
|
+
onScreenClick = _useScreenInteraction.onClick,
|
|
1542
|
+
currentScreenInteractionEnabled = _useScreenInteraction.currentScreenInteractionEnabled,
|
|
1543
|
+
enableInteraction = _useScreenInteraction.enableInteraction,
|
|
1544
|
+
disableInteraction = _useScreenInteraction.disableInteraction; // swipe menu open
|
|
1169
1545
|
|
|
1170
|
-
var setPreviewMenu = function setPreviewMenu(opened) {
|
|
1171
|
-
setMenuSpring.start({
|
|
1172
|
-
y: opened ? 1 : 0
|
|
1173
|
-
});
|
|
1174
|
-
menuOpened.current = opened;
|
|
1175
|
-
setPreviewMenuOpen(opened);
|
|
1176
|
-
};
|
|
1177
1546
|
|
|
1178
|
-
var
|
|
1179
|
-
setPreviewMenu(true);
|
|
1180
|
-
}, [setMenuSpring, setPreviewMenuOpen]);
|
|
1181
|
-
var closePreviewMenu = useCallback(function () {
|
|
1182
|
-
setPreviewMenu(false);
|
|
1183
|
-
}, [setMenuSpring, setPreviewMenuOpen]); // Handle dot menu item click
|
|
1547
|
+
var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
|
|
1184
1548
|
|
|
1185
|
-
var
|
|
1549
|
+
var _useState = useState(false),
|
|
1550
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
1551
|
+
menuOpened = _useState2[0],
|
|
1552
|
+
setMenuOpened = _useState2[1];
|
|
1553
|
+
|
|
1554
|
+
var onMenuRequestOpen = useCallback(function () {
|
|
1555
|
+
return setMenuOpened(true);
|
|
1556
|
+
}, [setMenuOpened]);
|
|
1557
|
+
var onMenuRequestClose = useCallback(function () {
|
|
1558
|
+
return setMenuOpened(false);
|
|
1559
|
+
}, [setMenuOpened]);
|
|
1560
|
+
var onClickMenu = useCallback(function () {
|
|
1186
1561
|
onInteractionPrivate();
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
if (trackingEnabled) {
|
|
1197
|
-
var trackAction = goToScreen ? 'click_screen_change' : 'click_open';
|
|
1198
|
-
var trackLabel = clickedOnDot ? "Screen ".concat(index + 1) : 'Menu icon';
|
|
1199
|
-
trackEvent('viewer_menu', trackAction, trackLabel, {
|
|
1200
|
-
screenId: screenId,
|
|
1201
|
-
screenType: screenType,
|
|
1202
|
-
screenIndex: index
|
|
1203
|
-
});
|
|
1204
|
-
}
|
|
1205
|
-
}, [changeIndex, landscape, trackingEnabled, trackEvent, screenType, onInteractionPrivate]); // handle preview menu item click
|
|
1206
|
-
|
|
1207
|
-
var onClickPreviewMenuItem = useCallback(function (index) {
|
|
1562
|
+
setMenuOpened(true);
|
|
1563
|
+
}, [changeIndex, onInteractionPrivate, setMenuOpened]);
|
|
1564
|
+
var onClickMenuItem = useCallback(function (_ref6) {
|
|
1565
|
+
var itemScreenId = _ref6.screenId;
|
|
1566
|
+
onInteractionPrivate();
|
|
1567
|
+
var index = screens.findIndex(function (_ref7) {
|
|
1568
|
+
var id = _ref7.id;
|
|
1569
|
+
return id === itemScreenId;
|
|
1570
|
+
});
|
|
1208
1571
|
changeIndex(index);
|
|
1209
|
-
closePreviewMenu();
|
|
1210
1572
|
|
|
1211
|
-
if (
|
|
1212
|
-
|
|
1213
|
-
screenId: screenId,
|
|
1214
|
-
screenType: screenType,
|
|
1215
|
-
screenIndex: index
|
|
1216
|
-
});
|
|
1217
|
-
}
|
|
1218
|
-
}, [changeIndex, trackingEnabled, trackEvent, screenId, screenType]); // Handle preview menu close click
|
|
1219
|
-
|
|
1220
|
-
var onClickPreviewMenuClose = useCallback(function () {
|
|
1221
|
-
closePreviewMenu();
|
|
1222
|
-
|
|
1223
|
-
if (trackingEnabled) {
|
|
1224
|
-
trackEvent('viewer_menu', 'click_close', 'Close icon', {
|
|
1225
|
-
screenId: screenId,
|
|
1226
|
-
screenIndex: screenIndex,
|
|
1227
|
-
screenType: screenType
|
|
1228
|
-
});
|
|
1229
|
-
}
|
|
1230
|
-
}, [closePreviewMenu, trackingEnabled, trackEvent, screenId, screenIndex, screenType]); // Handle preview menu share click
|
|
1231
|
-
|
|
1232
|
-
var onClickShare = useCallback(function (type) {
|
|
1233
|
-
if (trackingEnabled) {
|
|
1234
|
-
trackEvent('viewer_menu', 'click_share', type, {
|
|
1235
|
-
screenId: screenId,
|
|
1236
|
-
screenIndex: screenIndex,
|
|
1237
|
-
screenType: screenType
|
|
1238
|
-
});
|
|
1573
|
+
if (menuOpened) {
|
|
1574
|
+
setMenuOpened(false);
|
|
1239
1575
|
}
|
|
1240
|
-
}, [
|
|
1576
|
+
}, [onInteractionPrivate, changeIndex, menuOpened, setMenuOpened]);
|
|
1241
1577
|
var onContextMenu = useCallback(function (e) {
|
|
1242
1578
|
if (!landscape) {
|
|
1243
1579
|
e.preventDefault();
|
|
@@ -1256,62 +1592,43 @@ var Viewer = function Viewer(_ref) {
|
|
|
1256
1592
|
fullscreenEnabled = _useFullscreen.enabled; // Keyboard Events
|
|
1257
1593
|
|
|
1258
1594
|
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
return
|
|
1263
|
-
},
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
case 'escape':
|
|
1280
|
-
closePreviewMenu();
|
|
1281
|
-
break;
|
|
1282
|
-
|
|
1283
|
-
case 'arrowleft':
|
|
1284
|
-
gotoPreviousScreen();
|
|
1285
|
-
break;
|
|
1286
|
-
|
|
1287
|
-
case 'arrowright':
|
|
1288
|
-
case ' ':
|
|
1289
|
-
// spacebar
|
|
1290
|
-
gotoNextScreen();
|
|
1291
|
-
break;
|
|
1595
|
+
var keyboardShortcuts = useMemo(function () {
|
|
1596
|
+
return {
|
|
1597
|
+
f: function f() {
|
|
1598
|
+
return toggleFullscreen();
|
|
1599
|
+
},
|
|
1600
|
+
m: function m() {
|
|
1601
|
+
return setMenuOpened(!menuOpened);
|
|
1602
|
+
},
|
|
1603
|
+
escape: function escape() {
|
|
1604
|
+
return setMenuOpened(false);
|
|
1605
|
+
},
|
|
1606
|
+
arrowleft: function arrowleft() {
|
|
1607
|
+
return gotoPreviousScreen();
|
|
1608
|
+
},
|
|
1609
|
+
arrowright: function arrowright() {
|
|
1610
|
+
return gotoNextScreen();
|
|
1611
|
+
},
|
|
1612
|
+
' ': function _() {
|
|
1613
|
+
return gotoNextScreen();
|
|
1292
1614
|
}
|
|
1293
1615
|
};
|
|
1616
|
+
}, [menuOpened, setMenuOpened, gotoPreviousScreen, gotoNextScreen]);
|
|
1617
|
+
useKeyboardShortcuts(keyboardShortcuts, {
|
|
1618
|
+
disabled: renderContext !== 'view'
|
|
1619
|
+
});
|
|
1294
1620
|
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
}
|
|
1298
|
-
|
|
1299
|
-
return function () {
|
|
1300
|
-
window.removeEventListener('keydown', onKey);
|
|
1301
|
-
};
|
|
1302
|
-
}, [renderContext, closePreviewMenu, gotoPreviousScreen, gotoNextScreen]);
|
|
1303
|
-
|
|
1304
|
-
var _ref11 = currentScreen || {},
|
|
1305
|
-
screenParameters = _ref11.parameters;
|
|
1621
|
+
var _ref8 = currentScreen || {},
|
|
1622
|
+
screenParameters = _ref8.parameters;
|
|
1306
1623
|
|
|
1307
|
-
var
|
|
1308
|
-
screenMetadata =
|
|
1624
|
+
var _ref9 = screenParameters || {},
|
|
1625
|
+
screenMetadata = _ref9.metadata;
|
|
1309
1626
|
|
|
1310
|
-
var
|
|
1311
|
-
|
|
1312
|
-
screenTitle =
|
|
1313
|
-
|
|
1314
|
-
screenDescription =
|
|
1627
|
+
var _ref10 = screenMetadata || {},
|
|
1628
|
+
_ref10$title = _ref10.title,
|
|
1629
|
+
screenTitle = _ref10$title === void 0 ? null : _ref10$title,
|
|
1630
|
+
_ref10$description = _ref10.description,
|
|
1631
|
+
screenDescription = _ref10$description === void 0 ? null : _ref10$description;
|
|
1315
1632
|
|
|
1316
1633
|
var finalTitle = screenTitle !== null ? screenTitle : title;
|
|
1317
1634
|
var finalMetadata = useMemo(function () {
|
|
@@ -1320,84 +1637,88 @@ var Viewer = function Viewer(_ref) {
|
|
|
1320
1637
|
}) : metadata;
|
|
1321
1638
|
}, [metadata]);
|
|
1322
1639
|
|
|
1323
|
-
var
|
|
1324
|
-
|
|
1325
|
-
|
|
1640
|
+
var _useResizeObserver = useResizeObserver(),
|
|
1641
|
+
menuDotsContainerRef = _useResizeObserver.ref,
|
|
1642
|
+
menuDotsContainerRect = _useResizeObserver.entry.contentRect;
|
|
1643
|
+
|
|
1644
|
+
var _ref11 = menuDotsContainerRect || {},
|
|
1645
|
+
_ref11$height = _ref11.height,
|
|
1646
|
+
menuDotsContainerHeight = _ref11$height === void 0 ? 0 : _ref11$height;
|
|
1326
1647
|
|
|
1327
1648
|
return /*#__PURE__*/React.createElement(ScreenSizeProvider, {
|
|
1328
1649
|
size: screenSize
|
|
1329
1650
|
}, /*#__PURE__*/React.createElement(ViewerProvider, {
|
|
1651
|
+
events: eventsManager,
|
|
1330
1652
|
menuVisible: menuVisible,
|
|
1331
1653
|
menuSize: menuDotsContainerHeight,
|
|
1332
1654
|
gotoPreviousScreen: gotoPreviousScreen,
|
|
1333
|
-
gotoNextScreen: gotoNextScreen
|
|
1655
|
+
gotoNextScreen: gotoNextScreen,
|
|
1656
|
+
disableInteraction: disableInteraction,
|
|
1657
|
+
enableInteraction: enableInteraction
|
|
1334
1658
|
}, withMetadata ? /*#__PURE__*/React.createElement(Meta, {
|
|
1335
1659
|
title: finalTitle,
|
|
1336
1660
|
metadata: finalMetadata
|
|
1337
1661
|
}, overscrollStyle) : /*#__PURE__*/React.createElement(Helmet, null, overscrollStyle), /*#__PURE__*/React.createElement(FontFaces, {
|
|
1338
1662
|
fonts: finalFonts
|
|
1339
1663
|
}), /*#__PURE__*/React.createElement("div", {
|
|
1340
|
-
className: classNames([styles$
|
|
1664
|
+
className: classNames([styles$7.container, screenSize.screens.map(function (screenName) {
|
|
1341
1665
|
return "story-screen-".concat(screenName);
|
|
1342
|
-
}), (
|
|
1666
|
+
}), (_ref12 = {}, _defineProperty(_ref12, styles$7.landscape, landscape), _defineProperty(_ref12, styles$7.withSibblings, withLandscapeSiblingsScreens), _defineProperty(_ref12, styles$7.hideMenu, !menuVisible), _defineProperty(_ref12, styles$7.ready, ready || withoutScreensTransforms), _defineProperty(_ref12, className, className), _ref12)]),
|
|
1343
1667
|
ref: containerRef,
|
|
1344
1668
|
onContextMenu: onContextMenu
|
|
1345
|
-
}, !withoutMenu ? /*#__PURE__*/React.createElement(
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
width: screenWidth
|
|
1350
|
-
}
|
|
1351
|
-
}, menuDragBind()), /*#__PURE__*/React.createElement(ViewerMenuDots, Object.assign({}, menuTheme, {
|
|
1352
|
-
direction: "horizontal",
|
|
1669
|
+
}, !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu, {
|
|
1670
|
+
story: parsedStory,
|
|
1671
|
+
currentScreenIndex: screenIndex,
|
|
1672
|
+
opened: menuOpened,
|
|
1353
1673
|
withShadow: menuOverScreen,
|
|
1354
|
-
items: screens,
|
|
1355
|
-
current: screenIndex,
|
|
1356
|
-
onClickItem: onClickDotsMenuItem,
|
|
1357
|
-
closeable: closeable,
|
|
1358
|
-
onClose: onClose,
|
|
1359
|
-
className: styles$6.menuDots
|
|
1360
|
-
}))), /*#__PURE__*/React.createElement(animated.div, {
|
|
1361
|
-
className: styles$6.menuPreviewContainer,
|
|
1362
|
-
style: menuPreviewStyle,
|
|
1363
|
-
ref: menuPreviewContainerRef
|
|
1364
|
-
}, /*#__PURE__*/React.createElement(ViewerMenuPreview, {
|
|
1365
|
-
viewerTheme: viewerTheme,
|
|
1366
|
-
title: title,
|
|
1367
|
-
shareUrl: shareUrl,
|
|
1368
|
-
className: styles$6.menuPreview,
|
|
1369
|
-
screenWidth: screenWidth,
|
|
1370
|
-
focusable: previewMenuOpen,
|
|
1371
|
-
items: screens,
|
|
1372
|
-
current: screenIndex,
|
|
1373
|
-
onClickItem: onClickPreviewMenuItem,
|
|
1374
|
-
onClose: onClickPreviewMenuClose,
|
|
1375
|
-
onShare: onClickShare,
|
|
1376
1674
|
toggleFullscreen: toggleFullscreen,
|
|
1377
1675
|
fullscreenActive: fullscreenActive,
|
|
1378
|
-
fullscreenEnabled: fullscreenEnabled
|
|
1379
|
-
|
|
1676
|
+
fullscreenEnabled: fullscreenEnabled,
|
|
1677
|
+
closeable: closeable,
|
|
1678
|
+
shareBasePath: basePath,
|
|
1679
|
+
screenSize: screenSize,
|
|
1680
|
+
menuWidth: screenWidth,
|
|
1681
|
+
trackingEnabled: trackingEnabled,
|
|
1682
|
+
onClickItem: onClickMenuItem,
|
|
1683
|
+
onClickMenu: onClickMenu,
|
|
1684
|
+
onClickCloseViewer: onCloseViewer,
|
|
1685
|
+
onRequestOpen: onMenuRequestOpen,
|
|
1686
|
+
onRequestClose: onMenuRequestClose,
|
|
1687
|
+
withDotItemClick: screenWidth > 400,
|
|
1688
|
+
withoutScreensMenu: withoutScreensMenu,
|
|
1689
|
+
refDots: menuDotsContainerRef
|
|
1690
|
+
}) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", {
|
|
1380
1691
|
ref: contentRef,
|
|
1381
|
-
className: styles$
|
|
1692
|
+
className: styles$7.content
|
|
1382
1693
|
}, screens.map(function (scr, i) {
|
|
1694
|
+
var _ref13;
|
|
1695
|
+
|
|
1383
1696
|
var current = i === screenIndex;
|
|
1384
1697
|
var active = i > screenIndex - neighborScreensActive && i < screenIndex + neighborScreensActive;
|
|
1385
1698
|
var viewerScreen = /*#__PURE__*/React.createElement(ViewerScreen, {
|
|
1386
1699
|
screen: scr,
|
|
1700
|
+
screenState: current ? screenState : null,
|
|
1387
1701
|
renderContext: renderContext,
|
|
1388
1702
|
index: i,
|
|
1389
1703
|
current: current,
|
|
1390
1704
|
active: active,
|
|
1391
1705
|
onPrevious: gotoPreviousScreen,
|
|
1392
1706
|
onNext: gotoNextScreen,
|
|
1393
|
-
onEnableInteraction:
|
|
1394
|
-
onDisableInteraction:
|
|
1707
|
+
onEnableInteraction: enableInteraction,
|
|
1708
|
+
onDisableInteraction: disableInteraction,
|
|
1395
1709
|
getMediaRef: function getMediaRef(mediaRef) {
|
|
1396
1710
|
screensMediasRef.current[i] = mediaRef;
|
|
1397
1711
|
}
|
|
1398
1712
|
});
|
|
1399
1713
|
var key = "screen-viewer-".concat(scr.id || '', "-").concat(i + 1);
|
|
1400
|
-
var screenTransform =
|
|
1714
|
+
var screenTransform = null;
|
|
1715
|
+
|
|
1716
|
+
if (landscape) {
|
|
1717
|
+
screenTransform = withLandscapeSiblingsScreens ? "translateX(calc(".concat((screenWidth + landscapeScreenMargin) * (i - screenIndex), "px - 50%)) scale(").concat(current ? 1 : 0.9, ")") : null;
|
|
1718
|
+
} else {
|
|
1719
|
+
screenTransform = "translateX(".concat(current ? 0 : '100%', ")");
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1401
1722
|
return /*#__PURE__*/React.createElement(React.Fragment, {
|
|
1402
1723
|
key: key
|
|
1403
1724
|
}, current && screenIndex > 0 ? /*#__PURE__*/React.createElement("button", {
|
|
@@ -1418,7 +1739,7 @@ var Viewer = function Viewer(_ref) {
|
|
|
1418
1739
|
height: landscape ? screenHeight : null,
|
|
1419
1740
|
transform: !withoutScreensTransforms ? screenTransform : null
|
|
1420
1741
|
},
|
|
1421
|
-
className: classNames([styles$
|
|
1742
|
+
className: classNames([styles$7.screen, (_ref13 = {}, _defineProperty(_ref13, styles$7.current, current), _defineProperty(_ref13, styles$7.visible, current || withLandscapeSiblingsScreens), _ref13)]),
|
|
1422
1743
|
tabIndex: active ? '0' : '-1'
|
|
1423
1744
|
/* eslint-disable-line */
|
|
1424
1745
|
,
|
|
@@ -1510,17 +1831,11 @@ var ViewerRoutes = function ViewerRoutes(_ref) {
|
|
|
1510
1831
|
ViewerRoutes.propTypes = propTypes$1;
|
|
1511
1832
|
ViewerRoutes.defaultProps = defaultProps$1;
|
|
1512
1833
|
|
|
1513
|
-
var
|
|
1514
|
-
var screen = "/:screen";
|
|
1515
|
-
var defaultRoutes = {
|
|
1516
|
-
home: home,
|
|
1517
|
-
screen: screen
|
|
1518
|
-
};
|
|
1519
|
-
|
|
1520
|
-
var _excluded = ["story", "memoryRouter", "basePath", "routes", "withoutRouter", "googleApiKey", "trackingVariables", "locale", "locales", "translations"];
|
|
1834
|
+
var _excluded = ["story", "screenComponents", "memoryRouter", "basePath", "routes", "withoutRouter", "googleApiKey", "trackingVariables", "locale", "locales", "translations"];
|
|
1521
1835
|
var propTypes = {
|
|
1522
1836
|
story: PropTypes$1.story,
|
|
1523
1837
|
screen: PropTypes.string,
|
|
1838
|
+
screenComponents: PropTypes.objectOf(PropTypes.elementType),
|
|
1524
1839
|
memoryRouter: PropTypes.bool,
|
|
1525
1840
|
basePath: PropTypes.string,
|
|
1526
1841
|
routes: routes,
|
|
@@ -1535,6 +1850,7 @@ var propTypes = {
|
|
|
1535
1850
|
var defaultProps = {
|
|
1536
1851
|
story: null,
|
|
1537
1852
|
screen: null,
|
|
1853
|
+
screenComponents: null,
|
|
1538
1854
|
memoryRouter: false,
|
|
1539
1855
|
basePath: null,
|
|
1540
1856
|
routes: defaultRoutes,
|
|
@@ -1549,6 +1865,7 @@ var defaultProps = {
|
|
|
1549
1865
|
|
|
1550
1866
|
var ViewerContainer = function ViewerContainer(_ref) {
|
|
1551
1867
|
var story = _ref.story,
|
|
1868
|
+
screenComponents = _ref.screenComponents,
|
|
1552
1869
|
memoryRouter = _ref.memoryRouter,
|
|
1553
1870
|
basePath = _ref.basePath,
|
|
1554
1871
|
routes = _ref.routes,
|
|
@@ -1599,7 +1916,10 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
1599
1916
|
locale: finalLocale
|
|
1600
1917
|
}, /*#__PURE__*/React.createElement(FieldsProvider, {
|
|
1601
1918
|
manager: fieldsManager
|
|
1602
|
-
}, /*#__PURE__*/React.createElement(ScreensProvider, null, /*#__PURE__*/React.createElement(
|
|
1919
|
+
}, /*#__PURE__*/React.createElement(ScreensProvider, null, /*#__PURE__*/React.createElement(ComponentsProvider, {
|
|
1920
|
+
namespace: SCREENS_NAMESPACE,
|
|
1921
|
+
components: screenComponents || {}
|
|
1922
|
+
}, /*#__PURE__*/React.createElement(UserInteractionProvider, null, /*#__PURE__*/React.createElement(TrackingProvider, {
|
|
1603
1923
|
variables: finalTrackingVariables
|
|
1604
1924
|
}, withoutRouter ? /*#__PURE__*/React.createElement(Viewer, Object.assign({
|
|
1605
1925
|
story: story,
|
|
@@ -1607,7 +1927,7 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
1607
1927
|
}, otherProps)) : /*#__PURE__*/React.createElement(ViewerRoutes, Object.assign({
|
|
1608
1928
|
story: story,
|
|
1609
1929
|
basePath: basePath
|
|
1610
|
-
}, otherProps)))))))));
|
|
1930
|
+
}, otherProps))))))))));
|
|
1611
1931
|
return withoutRouter ? content : /*#__PURE__*/React.createElement(Router, {
|
|
1612
1932
|
basename: !memoryRouter ? basePath : null
|
|
1613
1933
|
}, /*#__PURE__*/React.createElement(RoutesProvider, {
|