@micromag/viewer 0.3.541 → 0.3.548

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 (3) hide show
  1. package/es/index.js +30 -48
  2. package/package.json +11 -12
  3. package/lib/index.js +0 -4125
package/lib/index.js DELETED
@@ -1,4125 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
6
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
7
- var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
8
- var React = require('react');
9
- var PropTypes = require('prop-types');
10
- var jsxRuntime = require('react/jsx-runtime');
11
- var pathToRegexp = require('path-to-regexp');
12
- var mitt = require('mitt');
13
- var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
14
- var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
15
- var _toArray = require('@babel/runtime/helpers/toArray');
16
- var regexparam = require('regexparam');
17
- var index_js = require('use-sync-external-store/shim/index.js');
18
- var core = require('@micromag/core');
19
- var contexts = require('@micromag/core/contexts');
20
- var intl = require('@micromag/intl');
21
- var screens = require('@micromag/screens');
22
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
23
- var web = require('@react-spring/web');
24
- var classNames = require('classnames');
25
- var reactHelmet = require('react-helmet');
26
- var reactIntl = require('react-intl');
27
- var EventEmitter = require('wolfy87-eventemitter');
28
- var components = require('@micromag/core/components');
29
- var hooks = require('@micromag/core/hooks');
30
- var utils = require('@micromag/core/utils');
31
- var all = require('@micromag/elements/all');
32
- var FocusLock = require('react-focus-lock');
33
- var core$1 = require('@react-spring/core');
34
- var Scroll = require('@micromag/element-scroll');
35
- var ShareOptions = require('@micromag/element-share-options');
36
- var react = require('@use-gesture/react');
37
- var WebView = require('@micromag/element-webview');
38
-
39
- function _interopNamespaceDefault(e) {
40
- var n = Object.create(null);
41
- if (e) {
42
- Object.keys(e).forEach(function (k) {
43
- if (k !== 'default') {
44
- var d = Object.getOwnPropertyDescriptor(e, k);
45
- Object.defineProperty(n, k, d.get ? d : {
46
- enumerable: true,
47
- get: function () { return e[k]; }
48
- });
49
- }
50
- });
51
- }
52
- n.default = e;
53
- return Object.freeze(n);
54
- }
55
-
56
- var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
57
-
58
- var useEffect = React__namespace.useEffect,
59
- useLayoutEffect = React__namespace.useLayoutEffect,
60
- useRef = React__namespace.useRef;
61
-
62
- // React.useInsertionEffect is not available in React <18
63
- // This hack fixes a transpilation issue on some apps
64
- var useBuiltinInsertionEffect = React__namespace['useInsertion' + 'Effect'];
65
-
66
- // Copied from:
67
- // https://github.com/facebook/react/blob/main/packages/shared/ExecutionEnvironment.js
68
- var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
69
-
70
- // Copied from:
71
- // https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.ts
72
- // "React currently throws a warning when using useLayoutEffect on the server.
73
- // To get around it, we can conditionally useEffect on the server (no-op) and
74
- // useLayoutEffect in the browser."
75
- var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
76
-
77
- // useInsertionEffect is already a noop on the server.
78
- // See: https://github.com/facebook/react/blob/main/packages/react-server/src/ReactFizzHooks.js
79
- var useInsertionEffect = useBuiltinInsertionEffect || useIsomorphicLayoutEffect;
80
-
81
- // Userland polyfill while we wait for the forthcoming
82
- // https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
83
- // Note: "A high-fidelity polyfill for useEvent is not possible because
84
- // there is no lifecycle or Hook in React that we can use to switch
85
- // .current at the right timing."
86
- // So we will have to make do with this "close enough" approach for now.
87
- var useEvent = function useEvent(fn) {
88
- var ref = useRef([fn, function () {
89
- return ref[0].apply(ref, arguments);
90
- }]).current;
91
- // Per Dan Abramov: useInsertionEffect executes marginally closer to the
92
- // correct timing for ref synchronization than useLayoutEffect on React 18.
93
- // See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
94
- useInsertionEffect(function () {
95
- ref[0] = fn;
96
- });
97
- return ref[1];
98
- };
99
-
100
- /**
101
- * History API docs @see https://developer.mozilla.org/en-US/docs/Web/API/History
102
- */
103
- var eventPopstate = "popstate";
104
- var eventPushState = "pushState";
105
- var eventReplaceState = "replaceState";
106
- var eventHashchange = "hashchange";
107
- var events = [eventPopstate, eventPushState, eventReplaceState, eventHashchange];
108
- var subscribeToLocationUpdates = function subscribeToLocationUpdates(callback) {
109
- for (var _i = 0, _events = events; _i < _events.length; _i++) {
110
- var event = _events[_i];
111
- addEventListener(event, callback);
112
- }
113
- return function () {
114
- for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
115
- var _event = _events2[_i2];
116
- removeEventListener(_event, callback);
117
- }
118
- };
119
- };
120
- var useLocationProperty = function useLocationProperty(fn, ssrFn) {
121
- return index_js.useSyncExternalStore(subscribeToLocationUpdates, fn, ssrFn);
122
- };
123
- var currentSearch = function currentSearch() {
124
- return location.search;
125
- };
126
- var useSearch = function useSearch() {
127
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
128
- _ref$ssrSearch = _ref.ssrSearch,
129
- ssrSearch = _ref$ssrSearch === void 0 ? "" : _ref$ssrSearch;
130
- return useLocationProperty(currentSearch, function () {
131
- return ssrSearch;
132
- });
133
- };
134
- var currentPathname = function currentPathname() {
135
- return location.pathname;
136
- };
137
- var usePathname = function usePathname() {
138
- var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
139
- ssrPath = _ref2.ssrPath;
140
- return useLocationProperty(currentPathname, ssrPath ? function () {
141
- return ssrPath;
142
- } : currentPathname);
143
- };
144
- var navigate = function navigate(to) {
145
- var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
146
- _ref3$replace = _ref3.replace,
147
- replace = _ref3$replace === void 0 ? false : _ref3$replace,
148
- _ref3$state = _ref3.state,
149
- state = _ref3$state === void 0 ? null : _ref3$state;
150
- return history[replace ? eventReplaceState : eventPushState](state, "", to);
151
- };
152
-
153
- // the 2nd argument of the `useBrowserLocation` return value is a function
154
- // that allows to perform a navigation.
155
- var useBrowserLocation = function useBrowserLocation() {
156
- var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
157
- return [usePathname(opts), navigate];
158
- };
159
- var patchKey = Symbol["for"]("wouter_v3");
160
-
161
- // While History API does have `popstate` event, the only
162
- // proper way to listen to changes via `push/replaceState`
163
- // is to monkey-patch these methods.
164
- //
165
- // See https://stackoverflow.com/a/4585031
166
- if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
167
- var _loop = function _loop() {
168
- var type = _arr[_i3];
169
- var original = history[type];
170
- // TODO: we should be using unstable_batchedUpdates to avoid multiple re-renders,
171
- // however that will require an additional peer dependency on react-dom.
172
- // See: https://github.com/reactwg/react-18/discussions/86#discussioncomment-1567149
173
- history[type] = function () {
174
- var result = original.apply(this, arguments);
175
- var event = new Event(type);
176
- event.arguments = arguments;
177
- dispatchEvent(event);
178
- return result;
179
- };
180
- };
181
- for (var _i3 = 0, _arr = [eventPushState, eventReplaceState]; _i3 < _arr.length; _i3++) {
182
- _loop();
183
- }
184
-
185
- // patch history object only once
186
- // See: https://github.com/molefrog/wouter/issues/167
187
- Object.defineProperty(window, patchKey, {
188
- value: true
189
- });
190
- }
191
-
192
- var _excluded$b = ["children"],
193
- _excluded2 = ["path", "nest", "match"],
194
- _excluded3 = ["to", "href", "onClick", "asChild", "children", "className", "replace", "state"];
195
-
196
- /*
197
- * Transforms `path` into its relative `base` version
198
- * If base isn't part of the path provided returns absolute path e.g. `~/app`
199
- */
200
- var relativePath = function relativePath() {
201
- var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
202
- var path = arguments.length > 1 ? arguments[1] : undefined;
203
- return !path.toLowerCase().indexOf(base.toLowerCase()) ? path.slice(base.length) || "/" : "~" + path;
204
- };
205
- var absolutePath = function absolutePath(to) {
206
- var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
207
- return to[0] === "~" ? to.slice(1) : base + to;
208
- };
209
-
210
- /*
211
- * decodes escape sequences such as %20
212
- */
213
- var unescape = function unescape(str) {
214
- try {
215
- return decodeURI(str);
216
- } catch (_e) {
217
- // fail-safe mode: if string can't be decoded do nothing
218
- return str;
219
- }
220
- };
221
-
222
- /*
223
- * Router and router context. Router is a lightweight object that represents the current
224
- * routing options: how location is managed, base path etc.
225
- *
226
- * There is a default router present for most of the use cases, however it can be overridden
227
- * via the <Router /> component.
228
- */
229
-
230
- var defaultRouter = {
231
- hook: useBrowserLocation,
232
- searchHook: useSearch,
233
- parser: regexparam.parse,
234
- base: "",
235
- // this option is used to override the current location during SSR
236
- ssrPath: undefined,
237
- ssrSearch: undefined,
238
- // customizes how `href` props are transformed for <Link />
239
- hrefs: function hrefs(x) {
240
- return x;
241
- }
242
- };
243
- var RouterCtx = React.createContext(defaultRouter);
244
-
245
- // gets the closest parent router from the context
246
- var useRouter = function useRouter() {
247
- return React.useContext(RouterCtx);
248
- };
249
-
250
- /**
251
- * Parameters context. Used by `useParams()` to get the
252
- * matched params from the innermost `Route` component.
253
- */
254
-
255
- var ParamsCtx = React.createContext({});
256
-
257
- /*
258
- * Part 1, Hooks API: useRoute and useLocation
259
- */
260
-
261
- // Internal version of useLocation to avoid redundant useRouter calls
262
-
263
- var useLocationFromRouter = function useLocationFromRouter(router) {
264
- var _router$hook = router.hook(router),
265
- _router$hook2 = _slicedToArray(_router$hook, 2),
266
- location = _router$hook2[0],
267
- navigate = _router$hook2[1];
268
-
269
- // the function reference should stay the same between re-renders, so that
270
- // it can be passed down as an element prop without any performance concerns.
271
- // (This is achieved via `useEvent`.)
272
- return [unescape(relativePath(router.base, location)), useEvent(function (to, navOpts) {
273
- return navigate(absolutePath(to, router.base), navOpts);
274
- })];
275
- };
276
- var useLocation = function useLocation() {
277
- return useLocationFromRouter(useRouter());
278
- };
279
- var matchRoute = function matchRoute(parser, route, path, loose) {
280
- // when parser is in "loose" mode, `$base` is equal to the
281
- // first part of the route that matches the pattern
282
- // (e.g. for pattern `/a/:b` and path `/a/1/2/3` the `$base` is `a/1`)
283
- // we use this for route nesting
284
- var _parser = parser(route || "*", loose),
285
- pattern = _parser.pattern,
286
- keys = _parser.keys;
287
- var _ref = pattern.exec(path) || [],
288
- _ref2 = _toArray(_ref),
289
- $base = _ref2[0],
290
- matches = _ref2.slice(1);
291
- return $base !== undefined ? [true,
292
- // an object with parameters matched, e.g. { foo: "bar" } for "/:foo"
293
- // we "zip" two arrays here to construct the object
294
- // ["foo"], ["bar"] → { foo: "bar" }
295
- Object.fromEntries(keys.map(function (key, i) {
296
- return [key, matches[i]];
297
- }))].concat(_toConsumableArray(loose ? [$base] : [])) : [false, null];
298
- };
299
-
300
- /*
301
- * Part 2, Low Carb Router API: Router, Route, Link, Switch
302
- */
303
-
304
- var Router = function Router(_ref3) {
305
- var _props$ssrPath$split, _props$ssrPath, _props$hrefs, _props$hook;
306
- var children = _ref3.children,
307
- props = _objectWithoutProperties(_ref3, _excluded$b);
308
- // the router we will inherit from - it is the closest router in the tree,
309
- // unless the custom `hook` is provided (in that case it's the default one)
310
- var parent_ = useRouter();
311
- var parent = props.hook ? defaultRouter : parent_;
312
-
313
- // holds to the context value: the router object
314
- var value = parent;
315
-
316
- // when `ssrPath` contains a `?` character, we can extract the search from it
317
- var _ref4 = (_props$ssrPath$split = (_props$ssrPath = props.ssrPath) === null || _props$ssrPath === void 0 ? void 0 : _props$ssrPath.split("?")) !== null && _props$ssrPath$split !== void 0 ? _props$ssrPath$split : [],
318
- _ref5 = _slicedToArray(_ref4, 2),
319
- path = _ref5[0],
320
- search = _ref5[1];
321
- if (search) props.ssrSearch = search, props.ssrPath = path;
322
-
323
- // hooks can define their own `href` formatter (e.g. for hash location)
324
- props.hrefs = (_props$hrefs = props.hrefs) !== null && _props$hrefs !== void 0 ? _props$hrefs : (_props$hook = props.hook) === null || _props$hook === void 0 ? void 0 : _props$hook.hrefs;
325
-
326
- // what is happening below: to avoid unnecessary rerenders in child components,
327
- // we ensure that the router object reference is stable, unless there are any
328
- // changes that require reload (e.g. `base` prop changes -> all components that
329
- // get the router from the context should rerender, even if the component is memoized).
330
- // the expected behaviour is:
331
- //
332
- // 1) when the resulted router is no different from the parent, use parent
333
- // 2) if the custom `hook` prop is provided, we always inherit from the
334
- // default router instead. this resets all previously overridden options.
335
- // 3) when the router is customized here, it should stay stable between renders
336
- var ref = React.useRef({}),
337
- prev = ref.current,
338
- next = prev;
339
- for (var k in parent) {
340
- var option = k === "base" ? /* base is special case, it is appended to the parent's base */
341
- parent[k] + (props[k] || "") : props[k] || parent[k];
342
- if (prev === next && option !== next[k]) {
343
- ref.current = next = _objectSpread({}, next);
344
- }
345
- next[k] = option;
346
-
347
- // the new router is no different from the parent, use parent
348
- if (option !== parent[k]) value = next;
349
- }
350
- return React.createElement(RouterCtx.Provider, {
351
- value: value,
352
- children: children
353
- });
354
- };
355
- var h_route = function h_route(_ref6, params) {
356
- var children = _ref6.children,
357
- component = _ref6.component;
358
- // React-Router style `component` prop
359
- if (component) return React.createElement(component, {
360
- params: params
361
- });
362
-
363
- // support render prop or plain children
364
- return typeof children === "function" ? children(params) : children;
365
- };
366
- var Route = function Route(_ref7) {
367
- var path = _ref7.path,
368
- nest = _ref7.nest,
369
- match = _ref7.match,
370
- renderProps = _objectWithoutProperties(_ref7, _excluded2);
371
- var router = useRouter();
372
- var _useLocationFromRoute = useLocationFromRouter(router),
373
- _useLocationFromRoute2 = _slicedToArray(_useLocationFromRoute, 1),
374
- location = _useLocationFromRoute2[0];
375
- var _ref8 = // `match` is a special prop to give up control to the parent,
376
- // it is used by the `Switch` to avoid double matching
377
- match !== null && match !== void 0 ? match : matchRoute(router.parser, path, location, nest),
378
- _ref9 = _slicedToArray(_ref8, 3),
379
- matches = _ref9[0],
380
- params = _ref9[1],
381
- base = _ref9[2];
382
- if (!matches) return null;
383
- var children = base ? React.createElement(Router, {
384
- base: base
385
- }, h_route(renderProps, params)) : h_route(renderProps, params);
386
- return React.createElement(ParamsCtx.Provider, {
387
- value: params,
388
- children: children
389
- });
390
- };
391
- var Link = React.forwardRef(function (props, ref) {
392
- var router = useRouter();
393
- var _useLocationFromRoute3 = useLocationFromRouter(router),
394
- _useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
395
- path = _useLocationFromRoute4[0],
396
- navigate = _useLocationFromRoute4[1];
397
- var to = props.to,
398
- _props$href = props.href,
399
- _href = _props$href === void 0 ? to : _props$href,
400
- _onClick = props.onClick,
401
- asChild = props.asChild,
402
- children = props.children,
403
- cls = props.className;
404
- props.replace;
405
- props.state;
406
- var restProps = _objectWithoutProperties(props, _excluded3);
407
- var onClick = useEvent(function (event) {
408
- // ignores the navigation when clicked using right mouse button or
409
- // by holding a special modifier key: ctrl, command, win, alt, shift
410
- if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
411
- _onClick === null || _onClick === void 0 || _onClick(event);
412
- if (!event.defaultPrevented) {
413
- event.preventDefault();
414
- navigate(_href, props);
415
- }
416
- });
417
-
418
- // handle nested routers and absolute paths
419
- var href = router.hrefs(_href[0] === "~" ? _href.slice(1) : router.base + _href, router // pass router as a second argument for convinience
420
- );
421
- return asChild && React.isValidElement(children) ? React.cloneElement(children, {
422
- onClick: onClick,
423
- href: href
424
- }) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
425
- onClick: onClick,
426
- href: href,
427
- // `className` can be a function to apply the class if this link is active
428
- className: cls !== null && cls !== void 0 && cls.call ? cls(path === href) : cls,
429
- children: children,
430
- ref: ref
431
- }));
432
- });
433
- var flattenChildren = function flattenChildren(children) {
434
- return Array.isArray(children) ? children.flatMap(function (c) {
435
- return flattenChildren(c && c.type === React.Fragment ? c.props.children : c);
436
- }) : [children];
437
- };
438
- var Switch = function Switch(_ref10) {
439
- var children = _ref10.children,
440
- location = _ref10.location;
441
- var router = useRouter();
442
- var _useLocationFromRoute5 = useLocationFromRouter(router),
443
- _useLocationFromRoute6 = _slicedToArray(_useLocationFromRoute5, 1),
444
- originalLocation = _useLocationFromRoute6[0];
445
- var _iterator = _createForOfIteratorHelper(flattenChildren(children)),
446
- _step;
447
- try {
448
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
449
- var element = _step.value;
450
- var match = 0;
451
- if (React.isValidElement(element) &&
452
- // we don't require an element to be of type Route,
453
- // but we do require it to contain a truthy `path` prop.
454
- // this allows to use different components that wrap Route
455
- // inside of a switch, for example <AnimatedRoute />.
456
- (match = matchRoute(router.parser, element.props.path, location || originalLocation, element.props.nest))[0]) return React.cloneElement(element, {
457
- match: match
458
- });
459
- }
460
- } catch (err) {
461
- _iterator.e(err);
462
- } finally {
463
- _iterator.f();
464
- }
465
- return null;
466
- };
467
-
468
- /* eslint-disable react/jsx-props-no-spreading */
469
- var RoutesContext = /*#__PURE__*/React.createContext(null);
470
- var useRoutesContext = function useRoutesContext() {
471
- return React.useContext(RoutesContext);
472
- };
473
- var propTypes$o = {
474
- children: PropTypes.node.isRequired,
475
- routes: PropTypes.objectOf(PropTypes.string).isRequired,
476
- basePath: PropTypes.string
477
- };
478
- var defaultProps$o = {
479
- basePath: null
480
- };
481
- function RoutesProvider(_ref) {
482
- var routes = _ref.routes,
483
- basePath = _ref.basePath,
484
- children = _ref.children;
485
- var value = React.useMemo(function () {
486
- return {
487
- routes: routes,
488
- basePath: basePath
489
- };
490
- }, [routes, basePath]);
491
- return /*#__PURE__*/jsxRuntime.jsx(RoutesContext.Provider, {
492
- value: value,
493
- children: children
494
- });
495
- }
496
- RoutesProvider.propTypes = propTypes$o;
497
- RoutesProvider.defaultProps = defaultProps$o;
498
- var compilers = {};
499
- function generatePath(fullPath, data) {
500
- var opts = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
501
- var fullUrlMatches = fullPath.match(/^(https?:\/\/)/);
502
- if (typeof compilers[fullPath] === 'undefined') {
503
- compilers[fullPath] = pathToRegexp.compile(fullPath.replace(/^(https?:\/\/)/, ''), opts);
504
- }
505
- var compiler = compilers[fullPath];
506
- return fullUrlMatches !== null ? "".concat(fullUrlMatches[1]).concat(compiler(data)) : compiler(data);
507
- }
508
- var useUrlGeneratorPathToRepexp = function useUrlGeneratorPathToRepexp() {
509
- var _ref2 = useRoutesContext() || {},
510
- _ref2$routes = _ref2.routes,
511
- routes = _ref2$routes === void 0 ? null : _ref2$routes,
512
- _ref2$basePath = _ref2.basePath,
513
- basePath = _ref2$basePath === void 0 ? null : _ref2$basePath;
514
- var urlGenerator = React.useCallback(function (key, data, opts) {
515
- var path = routes !== null ? routes[key] || null : null;
516
- if (path === null) {
517
- return null;
518
- }
519
- var url = generatePath(path, data, opts);
520
- return basePath !== null ? "".concat(basePath.replace(/\/$/, ''), "/").concat(url.replace(/^\//, '')) : url;
521
- }, [routes, basePath]);
522
- return urlGenerator;
523
- };
524
- var useUrlGeneratorPathToRegexp = useUrlGeneratorPathToRepexp;
525
- var useRoutes = function useRoutes() {
526
- var _useRoutesContext = useRoutesContext(),
527
- routes = _useRoutesContext.routes;
528
- return routes;
529
- };
530
- var useRoutes$1 = useRoutes;
531
- function parseLocation(location) {
532
- var search = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
533
- var hash = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
534
- var _split = (location || '').split('?', 2),
535
- _split2 = _slicedToArray(_split, 2),
536
- pathname = _split2[0],
537
- _split2$ = _split2[1],
538
- searchFromPath = _split2$ === void 0 ? null : _split2$;
539
- var _split3 = (searchFromPath || '').split('#', 2),
540
- _split4 = _slicedToArray(_split3, 2),
541
- searchWithoutHash = _split4[0],
542
- _split4$ = _split4[1],
543
- hashFromPath = _split4$ === void 0 ? null : _split4$;
544
- return {
545
- pathname: pathname !== '' ? pathname : '/',
546
- search: search || searchWithoutHash || null,
547
- hash: hash || hashFromPath || null
548
- };
549
- }
550
- function useMemoryRouter() {
551
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
552
- _ref3$path = _ref3.path,
553
- path = _ref3$path === void 0 ? '/' : _ref3$path,
554
- _ref3$static = _ref3["static"],
555
- staticLocation = _ref3$static === void 0 ? false : _ref3$static;
556
- _ref3.record;
557
- var currentPath = parseLocation(path);
558
- var emitter = mitt();
559
- var navigateImplementation = function navigateImplementation(newPath) {
560
- var newParsedPath = parseLocation(newPath);
561
- currentPath = newParsedPath;
562
- emitter.emit('navigate', path);
563
- };
564
- var navigate = !staticLocation ? navigateImplementation : function () {
565
- return null;
566
- };
567
- var subscribe = function subscribe(cb) {
568
- emitter.on('navigate', cb);
569
- return function () {
570
- return emitter.off('navigate', cb);
571
- };
572
- };
573
- function reset() {
574
- navigateImplementation(path);
575
- }
576
- var locationHook = function locationHook() {
577
- return [React.useSyncExternalStore(subscribe, function () {
578
- return currentPath.pathname;
579
- }), navigate];
580
- };
581
- var searchHook = function searchHook() {
582
- return React.useSyncExternalStore(subscribe, function () {
583
- return currentPath.search || '';
584
- });
585
- };
586
- return {
587
- hook: locationHook,
588
- searchHook: searchHook,
589
- reset: reset,
590
- navigate: navigate
591
- };
592
- }
593
-
594
- // eslint-disable-next-line import/prefer-default-export
595
- var routes = PropTypes.shape({
596
- home: PropTypes.string.isRequired,
597
- screen: PropTypes.string.isRequired
598
- });
599
-
600
- function useKeyboardShortcuts() {
601
- var shortcuts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
602
- var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
603
- _ref$disabled = _ref.disabled,
604
- disabled = _ref$disabled === void 0 ? false : _ref$disabled;
605
- React.useEffect(function () {
606
- var onKey = function onKey(e) {
607
- if (['input', 'textarea'].reduce(function (foundMatch, match) {
608
- return foundMatch || e.target.matches(match);
609
- }, false)) {
610
- return;
611
- }
612
- var key = e.key;
613
- var lowercaseKey = key.toLowerCase();
614
- if (typeof shortcuts[lowercaseKey] !== 'undefined') {
615
- shortcuts[lowercaseKey]();
616
- }
617
- };
618
- if (!disabled) {
619
- window.addEventListener('keydown', onKey);
620
- }
621
- return function () {
622
- if (!disabled) {
623
- window.removeEventListener('keydown', onKey);
624
- }
625
- };
626
- }, [disabled, shortcuts]);
627
- }
628
-
629
- function checkClickable(el) {
630
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
631
- var parentDistance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
632
- var _ref = options || {},
633
- _ref$maxParentDistanc = _ref.maxParentDistance,
634
- maxParentDistance = _ref$maxParentDistanc === void 0 ? 5 : _ref$maxParentDistanc,
635
- _ref$tags = _ref.tags,
636
- tags = _ref$tags === void 0 ? ['BUTTON', 'A', 'INPUT', 'TEXTAREA'] : _ref$tags;
637
- var _ref2 = el || {},
638
- _ref2$tagName = _ref2.tagName,
639
- tagName = _ref2$tagName === void 0 ? null : _ref2$tagName,
640
- _ref2$parentNode = _ref2.parentNode,
641
- parentNode = _ref2$parentNode === void 0 ? null : _ref2$parentNode;
642
- _ref2.dataset;
643
- if (tagName === 'BODY') {
644
- return false;
645
- }
646
-
647
- // Check if video is suspended
648
- // if (
649
- // tagName === 'VIDEO' &&
650
- // typeof dataset.isSuspended !== 'undefined' &&
651
- // (dataset.isSuspended === 'true' || dataset.isSuspended === true)
652
- // ) {
653
- // return true;
654
- // }
655
-
656
- if (tags.map(function (it) {
657
- return it.toLowerCase();
658
- }).indexOf(tagName.toLowerCase()) !== -1) {
659
- return true;
660
- }
661
- if (parentDistance < maxParentDistance) {
662
- return checkClickable(parentNode, options, parentDistance + 1);
663
- }
664
- return false;
665
- }
666
-
667
- function useScreenInteraction() {
668
- var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
669
- screens = _ref.screens,
670
- screenIndex = _ref.screenIndex,
671
- screenWidth = _ref.screenWidth,
672
- _ref$disableCurrentSc = _ref.disableCurrentScreenNavigation,
673
- disableCurrentScreenNavigation = _ref$disableCurrentSc === void 0 ? false : _ref$disableCurrentSc,
674
- _ref$clickOnSiblings = _ref.clickOnSiblings,
675
- clickOnSiblings = _ref$clickOnSiblings === void 0 ? false : _ref$clickOnSiblings,
676
- _ref$nextScreenWidthP = _ref.nextScreenWidthPercent,
677
- nextScreenWidthPercent = _ref$nextScreenWidthP === void 0 ? 0.5 : _ref$nextScreenWidthP,
678
- _ref$onInteract = _ref.onInteract,
679
- onInteract = _ref$onInteract === void 0 ? null : _ref$onInteract,
680
- _ref$onNavigate = _ref.onNavigate,
681
- onNavigate = _ref$onNavigate === void 0 ? null : _ref$onNavigate;
682
- var _useState = React.useState(screens.reduce(function (map, _ref2) {
683
- var id = _ref2.id;
684
- return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, true));
685
- }, {})),
686
- _useState2 = _slicedToArray(_useState, 2),
687
- screensInteractionEnabled = _useState2[0],
688
- setScreensInteractionEnabled = _useState2[1];
689
- var _ref3 = screens[screenIndex] || {},
690
- _ref3$id = _ref3.id,
691
- screenId = _ref3$id === void 0 ? screenIndex : _ref3$id;
692
- var _screensInteractionEn = screensInteractionEnabled[screenId],
693
- currentScreenInteractionEnabled = _screensInteractionEn === void 0 ? true : _screensInteractionEn;
694
- var updateInteraction = React.useCallback(function (newValue) {
695
- var _screensInteractionEn2 = screensInteractionEnabled[screenId],
696
- currentValue = _screensInteractionEn2 === void 0 ? true : _screensInteractionEn2;
697
- if (currentValue !== newValue) {
698
- setScreensInteractionEnabled(screens.reduce(function (map, _ref4) {
699
- var id = _ref4.id;
700
- return screenId === id ? _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, newValue)) : _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, id, typeof screensInteractionEnabled[id] === 'undefined' || screensInteractionEnabled[id] === true));
701
- }, {}));
702
- }
703
- }, [screens, screenId, screensInteractionEnabled, setScreensInteractionEnabled]);
704
- var enableInteraction = React.useCallback(function () {
705
- return updateInteraction(true);
706
- }, [updateInteraction]);
707
- var disableInteraction = React.useCallback(function () {
708
- return updateInteraction(false);
709
- }, [updateInteraction]);
710
- var interact = React.useCallback(function (_ref5) {
711
- var event = _ref5.event,
712
- target = _ref5.target,
713
- currentTarget = _ref5.currentTarget,
714
- x = _ref5.x,
715
- y = _ref5.y,
716
- index = _ref5.index;
717
- if (onInteract !== null) {
718
- onInteract({
719
- event: event,
720
- target: target,
721
- currentTarget: currentTarget,
722
- index: index,
723
- x: x,
724
- y: y
725
- });
726
- }
727
- var screensCount = screens.length;
728
- var tappedCurrent = screenIndex === index;
729
- if (disableCurrentScreenNavigation && tappedCurrent || checkClickable(target) || tappedCurrent && !currentScreenInteractionEnabled) {
730
- return;
731
- }
732
- var _currentTarget$getBou = currentTarget.getBoundingClientRect(),
733
- width = _currentTarget$getBou.width;
734
- var margin = (width - screenWidth) / 2;
735
- var screenPreviousZone = screenWidth * (1 - nextScreenWidthPercent);
736
- var previousZone = margin + screenPreviousZone;
737
- var direction = x < previousZone ? 'previous' : 'next';
738
- var lastIndex = screensCount - 1;
739
- var nextIndex = index;
740
- if (direction === 'previous' && !clickOnSiblings) {
741
- nextIndex = Math.max(0, screenIndex - 1);
742
- } else if (direction === 'next' && !clickOnSiblings) {
743
- nextIndex = Math.min(lastIndex, screenIndex + 1);
744
- }
745
- if (onNavigate !== null) {
746
- onNavigate({
747
- index: index,
748
- newIndex: nextIndex,
749
- direction: direction,
750
- end: index === nextIndex && nextIndex === lastIndex
751
- });
752
- }
753
- }, [screens, screenIndex, screensInteractionEnabled, currentScreenInteractionEnabled, nextScreenWidthPercent, disableCurrentScreenNavigation, clickOnSiblings, onInteract, onNavigate]);
754
- return {
755
- interact: interact,
756
- currentScreenInteractionEnabled: currentScreenInteractionEnabled,
757
- enableInteraction: enableInteraction,
758
- disableInteraction: disableInteraction
759
- };
760
- }
761
-
762
- function checkDraggable(el) {
763
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
764
- var parentDistance = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
765
- var _ref = options || {},
766
- _ref$maxParentDistanc = _ref.maxParentDistance,
767
- maxParentDistance = _ref$maxParentDistanc === void 0 ? 5 : _ref$maxParentDistanc;
768
- var _ref2 = el || {},
769
- _ref2$tagName = _ref2.tagName,
770
- tagName = _ref2$tagName === void 0 ? null : _ref2$tagName,
771
- _ref2$parentNode = _ref2.parentNode,
772
- parentNode = _ref2$parentNode === void 0 ? null : _ref2$parentNode,
773
- _ref2$dataset = _ref2.dataset,
774
- dataset = _ref2$dataset === void 0 ? {} : _ref2$dataset;
775
- if (tagName === 'BODY') {
776
- return false;
777
- }
778
- if (typeof dataset.draggable !== 'undefined') {
779
- return true;
780
- }
781
- if (parentDistance < maxParentDistance) {
782
- return checkDraggable(parentNode, options, parentDistance + 1);
783
- }
784
- return false;
785
- }
786
-
787
- 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"};
788
-
789
- var _excluded$a = ["type", "theme", "size", "href", "external", "direct", "target", "label", "children", "focusable", "active", "icon", "iconPosition", "disabled", "loading", "disableOnLoading", "withoutTheme", "asLink", "ariaLabel", "onClick", "className", "iconClassName", "labelClassName", "refButton"];
790
- var propTypes$n = {
791
- type: PropTypes.string,
792
- theme: core.PropTypes.buttonTheme,
793
- size: core.PropTypes.buttonSize,
794
- href: PropTypes.string,
795
- external: PropTypes.bool,
796
- direct: PropTypes.bool,
797
- target: PropTypes.string,
798
- label: core.PropTypes.label,
799
- children: core.PropTypes.label,
800
- focusable: PropTypes.bool,
801
- active: PropTypes.bool,
802
- icon: PropTypes.node,
803
- iconPosition: PropTypes.oneOf(['left', 'right', 'inline']),
804
- disabled: PropTypes.bool,
805
- loading: PropTypes.bool,
806
- disableOnLoading: PropTypes.bool,
807
- withoutTheme: PropTypes.bool,
808
- asLink: PropTypes.bool,
809
- ariaLabel: PropTypes.string,
810
- className: PropTypes.string,
811
- iconClassName: PropTypes.string,
812
- labelClassName: PropTypes.string,
813
- onClick: PropTypes.func,
814
- refButton: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
815
- current: PropTypes.any // eslint-disable-line
816
- })])
817
- };
818
- var defaultProps$n = {
819
- type: 'button',
820
- theme: null,
821
- size: null,
822
- href: null,
823
- external: false,
824
- direct: false,
825
- target: '_blank',
826
- label: null,
827
- children: null,
828
- focusable: true,
829
- active: false,
830
- icon: null,
831
- iconPosition: 'inline',
832
- disabled: false,
833
- loading: false,
834
- disableOnLoading: true,
835
- withoutTheme: false,
836
- asLink: false,
837
- ariaLabel: null,
838
- className: null,
839
- iconClassName: null,
840
- labelClassName: null,
841
- onClick: null,
842
- refButton: null
843
- };
844
- var Button = function Button(_ref) {
845
- var type = _ref.type,
846
- theme = _ref.theme;
847
- _ref.size;
848
- var href = _ref.href,
849
- external = _ref.external,
850
- direct = _ref.direct,
851
- target = _ref.target,
852
- label = _ref.label,
853
- children = _ref.children,
854
- focusable = _ref.focusable;
855
- _ref.active;
856
- var icon = _ref.icon,
857
- iconPosition = _ref.iconPosition,
858
- disabled = _ref.disabled,
859
- loading = _ref.loading,
860
- disableOnLoading = _ref.disableOnLoading;
861
- _ref.withoutTheme;
862
- var asLink = _ref.asLink,
863
- ariaLabel = _ref.ariaLabel,
864
- onClick = _ref.onClick,
865
- className = _ref.className,
866
- iconClassName = _ref.iconClassName,
867
- labelClassName = _ref.labelClassName,
868
- refButton = _ref.refButton,
869
- props = _objectWithoutProperties(_ref, _excluded$a);
870
- var finalLabel = label || children;
871
- var text = finalLabel !== null ? /*#__PURE__*/React.createElement(components.Label, null, finalLabel) : null;
872
- var hasChildren = label !== null && children !== null;
873
- var hasIcon = icon !== null;
874
- var hasInlineIcon = hasIcon && (iconPosition === 'inline' || text === null);
875
- var hasIconColumns = hasIcon && !hasInlineIcon;
876
- var buttonClassNames = classNames([styles$g.container, styles$g["icon-".concat(iconPosition)], _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$g.withIcon, hasIcon), styles$g.withIconColumns, hasIconColumns), styles$g.withText, text !== null), styles$g.isLink, href !== null), styles$g.asLink, asLink), styles$g.isDisabled, disabled), styles$g.isLoading, loading), className, className !== null)]);
877
- var _ref3 = theme || {},
878
- _ref3$colors = _ref3.colors,
879
- colors = _ref3$colors === void 0 ? null : _ref3$colors;
880
- var _ref4 = colors || {},
881
- _ref4$primary = _ref4.primary,
882
- brandPrimaryColor = _ref4$primary === void 0 ? null : _ref4$primary;
883
- var primaryColor = utils.getStyleFromColor(brandPrimaryColor, 'color');
884
- var buttonStyles = _objectSpread({}, primaryColor);
885
- var content = /*#__PURE__*/React.createElement(React.Fragment, null, hasInlineIcon ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
886
- className: classNames([styles$g.icon, _defineProperty({}, iconClassName, iconClassName !== null)])
887
- }, icon), text !== null ? /*#__PURE__*/React.createElement("span", {
888
- className: classNames([styles$g.label, _defineProperty({}, labelClassName, labelClassName !== null)])
889
- }, text) : null) : null, hasIconColumns ? /*#__PURE__*/React.createElement(React.Fragment, null, iconPosition === 'left' ? /*#__PURE__*/React.createElement("span", {
890
- className: classNames([styles$g.icon, styles$g.left, _defineProperty({}, iconClassName, iconClassName !== null && iconPosition === 'left')])
891
- }, icon) : null, /*#__PURE__*/React.createElement("span", {
892
- className: classNames([styles$g.center, styles$g.label, _defineProperty({}, labelClassName, labelClassName !== null)])
893
- }, text), iconPosition === 'right' ? /*#__PURE__*/React.createElement("span", {
894
- className: classNames([styles$g.icon, styles$g.right, _defineProperty({}, iconClassName, iconClassName !== null && iconPosition === 'right')])
895
- }, icon) : null, hasChildren ? children : null) : null, !hasIcon ? text : null, hasChildren ? children : null);
896
- if (href !== null) {
897
- var linkClassNames = classNames([buttonClassNames, _defineProperty({
898
- disabled: disabled
899
- }, styles$g.linkDisabled, disabled)]);
900
- return external || direct ? /*#__PURE__*/React.createElement("a", Object.assign({}, props, {
901
- href: disabled ? null : href,
902
- className: linkClassNames,
903
- style: buttonStyles,
904
- onClick: onClick,
905
- target: external ? target : null,
906
- ref: refButton,
907
- tabIndex: focusable ? '' : '-1'
908
- }), content) : /*#__PURE__*/React.createElement(Link, Object.assign({}, props, {
909
- href: href,
910
- className: linkClassNames,
911
- style: buttonStyles,
912
- onClick: onClick,
913
- ref: refButton,
914
- tabIndex: focusable ? '' : '-1'
915
- }), content);
916
- }
917
- return /*#__PURE__*/React.createElement("button", Object.assign({}, props, {
918
- type: type,
919
- className: buttonClassNames,
920
- style: buttonStyles,
921
- onClick: onClick,
922
- disabled: disabled || disableOnLoading && loading,
923
- ref: refButton,
924
- "aria-label": ariaLabel,
925
- tabIndex: focusable ? '0' : '-1'
926
- }), content);
927
- };
928
- Button.propTypes = propTypes$n;
929
- Button.defaultProps = defaultProps$n;
930
- var Button$1 = Button;
931
-
932
- var styles$f = {"container":"micromag-viewer-buttons-icon-button-container","label":"micromag-viewer-buttons-icon-button-label","icon":"micromag-viewer-buttons-icon-button-icon"};
933
-
934
- var _excluded$9 = ["iconClassName", "className"];
935
- var propTypes$m = {
936
- iconClassName: PropTypes.string,
937
- className: PropTypes.string
938
- };
939
- var defaultProps$m = {
940
- iconClassName: null,
941
- className: null
942
- };
943
- var IconButton = function IconButton(_ref) {
944
- var iconClassName = _ref.iconClassName,
945
- className = _ref.className,
946
- props = _objectWithoutProperties(_ref, _excluded$9);
947
- return /*#__PURE__*/React.createElement(Button$1, Object.assign({
948
- className: classNames([styles$f.container, _defineProperty({}, className, className !== null)]),
949
- labelClassName: styles$f.label,
950
- iconClassName: classNames([styles$f.icon, _defineProperty({}, iconClassName, iconClassName !== null)])
951
- }, props));
952
- };
953
- IconButton.propTypes = propTypes$m;
954
- IconButton.defaultProps = defaultProps$m;
955
- var IconButton$1 = IconButton;
956
-
957
- var _excluded$8 = ["single", "className"];
958
- var propTypes$l = {
959
- single: PropTypes.bool,
960
- className: PropTypes.string
961
- };
962
- var defaultProps$l = {
963
- single: false,
964
- className: null
965
- };
966
- var CloseMenuButton = function CloseMenuButton(_ref) {
967
- var single = _ref.single,
968
- className = _ref.className,
969
- props = _objectWithoutProperties(_ref, _excluded$8);
970
- var intl = reactIntl.useIntl();
971
- return /*#__PURE__*/React.createElement(IconButton$1, Object.assign({
972
- className: classNames([_defineProperty({}, className, className !== null)]),
973
- label: intl.formatMessage({
974
- id: "dIvwcD",
975
- defaultMessage: [{
976
- "type": 0,
977
- "value": "Close"
978
- }]
979
- }),
980
- icon: /*#__PURE__*/React.createElement("svg", {
981
- width: "19",
982
- height: "23",
983
- viewBox: "0 0 19 23",
984
- fill: "none",
985
- xmlns: "http://www.w3.org/2000/svg"
986
- }, !single ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("mask", {
987
- id: "path-1-inside-1_560_19911",
988
- fill: "currentColor"
989
- }, /*#__PURE__*/React.createElement("path", {
990
- d: "M0 7C0 4.79086 1.79086 3 4 3H12C14.2091 3 16 4.79086 16 7V19C16 21.2091 14.2091 23 12 23H4C1.79086 23 0 21.2091 0 19V7Z"
991
- })), /*#__PURE__*/React.createElement("path", {
992
- d: "M0 3H16H0ZM16 19C16 21.7614 13.7614 24 11 24H4C1.23858 24 -1 21.7614 -1 19H1C1 20.6569 2.34315 22 4 22H12C14.2091 22 16 20.6569 16 19ZM4 24C1.23858 24 -1 21.7614 -1 19V8C-1 5.23858 1.23858 3 4 3C2.34315 3 1 4.79086 1 7V19C1 20.6569 2.34315 22 4 22V24ZM16 3V23V3Z",
993
- fill: "currentColor",
994
- mask: "url(#path-1-inside-1_560_19911)"
995
- })) : null, /*#__PURE__*/React.createElement("rect", {
996
- x: "3.5",
997
- y: "0.5",
998
- width: "15",
999
- height: "19",
1000
- rx: "2.5",
1001
- stroke: "currentColor"
1002
- }), /*#__PURE__*/React.createElement("path", {
1003
- d: "M7.35333 6.35333L14.6467 13.6467",
1004
- stroke: "currentColor",
1005
- strokeLinejoin: "round"
1006
- }), /*#__PURE__*/React.createElement("path", {
1007
- d: "M7.35333 13.6467L14.6467 6.35333",
1008
- stroke: "currentColor"
1009
- }))
1010
- }, props));
1011
- };
1012
- CloseMenuButton.propTypes = propTypes$l;
1013
- CloseMenuButton.defaultProps = defaultProps$l;
1014
- var CloseMenuButton$1 = CloseMenuButton;
1015
-
1016
- var _excluded$7 = ["className", "iconClassName"];
1017
- var propTypes$k = {
1018
- className: PropTypes.string,
1019
- iconClassName: PropTypes.string
1020
- };
1021
- var defaultProps$k = {
1022
- className: null,
1023
- iconClassName: null
1024
- };
1025
- var MenuButton = function MenuButton(_ref) {
1026
- var className = _ref.className;
1027
- _ref.iconClassName;
1028
- var props = _objectWithoutProperties(_ref, _excluded$7);
1029
- var intl = reactIntl.useIntl();
1030
- return /*#__PURE__*/React.createElement(IconButton$1, Object.assign({
1031
- className: classNames([_defineProperty({}, className, className !== null)]),
1032
- label: intl.formatMessage({
1033
- id: "F/gl4b",
1034
- defaultMessage: [{
1035
- "type": 0,
1036
- "value": "Menu"
1037
- }]
1038
- }),
1039
- iconPosition: "right",
1040
- icon: /*#__PURE__*/React.createElement("svg", {
1041
- width: "19",
1042
- height: "23",
1043
- viewBox: "0 0 19 23",
1044
- fill: "none",
1045
- xmlns: "http://www.w3.org/2000/svg"
1046
- }, /*#__PURE__*/React.createElement("mask", {
1047
- id: "path-1-inside-1_572_15622",
1048
- fill: "currentColor"
1049
- }, /*#__PURE__*/React.createElement("path", {
1050
- d: "M0 7C0 4.79086 1.79086 3 4 3H12C14.2091 3 16 4.79086 16 7V19C16 21.2091 14.2091 23 12 23H4C1.79086 23 0 21.2091 0 19V7Z"
1051
- })), /*#__PURE__*/React.createElement("path", {
1052
- d: "M0 3H16H0ZM16 19C16 21.7614 13.7614 24 11 24H4C1.23858 24 -1 21.7614 -1 19H1C1 20.6569 2.34315 22 4 22H12C14.2091 22 16 20.6569 16 19ZM4 24C1.23858 24 -1 21.7614 -1 19V8C-1 5.23858 1.23858 3 4 3C2.34315 3 1 4.79086 1 7V19C1 20.6569 2.34315 22 4 22V24ZM16 3V23V3Z",
1053
- fill: "currentColor",
1054
- mask: "url(#path-1-inside-1_572_15622)"
1055
- }), /*#__PURE__*/React.createElement("rect", {
1056
- x: "3.5",
1057
- y: "0.5",
1058
- width: "15",
1059
- height: "19",
1060
- rx: "2.5",
1061
- stroke: "currentColor"
1062
- }))
1063
- }, props));
1064
- };
1065
- MenuButton.propTypes = propTypes$k;
1066
- MenuButton.defaultProps = defaultProps$k;
1067
- var MenuButton$1 = MenuButton;
1068
-
1069
- var _excluded$6 = ["className"];
1070
- var propTypes$j = {
1071
- className: PropTypes.string
1072
- };
1073
- var defaultProps$j = {
1074
- className: null
1075
- };
1076
- var ShareButton = function ShareButton(_ref) {
1077
- var className = _ref.className,
1078
- props = _objectWithoutProperties(_ref, _excluded$6);
1079
- var intl = reactIntl.useIntl();
1080
- return /*#__PURE__*/React.createElement(IconButton$1, Object.assign({
1081
- className: classNames([_defineProperty({}, className, className !== null)]),
1082
- label: intl.formatMessage({
1083
- id: "7tw6U2",
1084
- defaultMessage: [{
1085
- "type": 0,
1086
- "value": "Share"
1087
- }]
1088
- }),
1089
- iconPosition: "left",
1090
- icon: /*#__PURE__*/React.createElement("svg", {
1091
- width: "16",
1092
- height: "22",
1093
- viewBox: "0 0 16 22",
1094
- fill: "none",
1095
- xmlns: "http://www.w3.org/2000/svg"
1096
- }, /*#__PURE__*/React.createElement("path", {
1097
- fillRule: "evenodd",
1098
- clipRule: "evenodd",
1099
- d: "M7.55806 0.183058C7.80213 -0.0610194 8.19786 -0.0610194 8.44194 0.183058L12.4194 4.16053C12.6635 4.40461 12.6635 4.80034 12.4194 5.04442C12.1753 5.2885 11.7796 5.2885 11.5355 5.04442L8.625 2.13388V11.25H7.375V2.13388L4.46446 5.04442C4.22039 5.2885 3.82466 5.2885 3.58058 5.04442C3.3365 4.80034 3.3365 4.40461 3.58058 4.16053L7.55806 0.183058Z",
1100
- fill: "currentColor"
1101
- }), /*#__PURE__*/React.createElement("path", {
1102
- fillRule: "evenodd",
1103
- clipRule: "evenodd",
1104
- d: "M16 18.25V10.25C16 8.59315 14.6569 7.25 13 7.25C14.1046 7.25 15 8.59315 15 10.25V18.25C15 19.3546 14.1046 20.25 13 20.25H3C1.89543 20.25 1 19.3546 1 18.25V10.25C1 8.59315 1.89543 7.25 3 7.25C1.34315 7.25 0 8.59315 0 10.25V18.25C0 19.9069 1.34315 21.25 3 21.25H13C14.6569 21.25 16 19.9069 16 18.25Z",
1105
- fill: "currentColor"
1106
- }))
1107
- }, props));
1108
- };
1109
- ShareButton.propTypes = propTypes$j;
1110
- ShareButton.defaultProps = defaultProps$j;
1111
- var ShareButton$1 = ShareButton;
1112
-
1113
- var styles$e = {"container":"micromag-viewer-buttons-toggle-button-container","normal":"micromag-viewer-buttons-toggle-button-normal","toggled":"micromag-viewer-buttons-toggle-button-toggled"};
1114
-
1115
- var propTypes$i = {
1116
- className: PropTypes.string,
1117
- progressSpring: PropTypes.object,
1118
- // eslint-disable-line react/forbid-prop-types
1119
- button: PropTypes.node,
1120
- toggledButton: PropTypes.node,
1121
- toggledButtonClassName: PropTypes.string
1122
- };
1123
- var defaultProps$i = {
1124
- className: null,
1125
- progressSpring: null,
1126
- button: null,
1127
- toggledButton: null,
1128
- toggledButtonClassName: null
1129
- };
1130
- var ToggleButton = function ToggleButton(_ref) {
1131
- var className = _ref.className,
1132
- progressSpring = _ref.progressSpring,
1133
- button = _ref.button,
1134
- toggledButton = _ref.toggledButton,
1135
- toggledButtonClassName = _ref.toggledButtonClassName;
1136
- if (button === null) return false;
1137
- return /*#__PURE__*/React.createElement("div", {
1138
- className: classNames([styles$e.container, _defineProperty({}, className, className !== null)])
1139
- }, /*#__PURE__*/React.createElement(web.animated.div, {
1140
- className: styles$e.normal,
1141
- style: {
1142
- transform: progressSpring.to(function (p) {
1143
- return "translateY(".concat(p * -100, "%)");
1144
- })
1145
- }
1146
- }, button), /*#__PURE__*/React.createElement(web.animated.div, {
1147
- className: classNames([styles$e.toggled, _defineProperty({}, toggledButtonClassName, toggledButtonClassName !== null)]),
1148
- style: {
1149
- transform: progressSpring.to(function (p) {
1150
- return "translateY(".concat((p - 1) * -100, "%)");
1151
- })
1152
- }
1153
- }, toggledButton));
1154
- };
1155
- ToggleButton.propTypes = propTypes$i;
1156
- ToggleButton.defaultProps = defaultProps$i;
1157
- var ToggleButton$1 = ToggleButton;
1158
-
1159
- var styles$d = {"backdrop":"micromag-viewer-menus-menu-container-backdrop","heightContainer":"micromag-viewer-menus-menu-container-heightContainer","container":"micromag-viewer-menus-menu-container-container"};
1160
-
1161
- var propTypes$h = {
1162
- className: PropTypes.string,
1163
- progressSpring: PropTypes.object,
1164
- // eslint-disable-line react/forbid-prop-types
1165
- theme: core.PropTypes.viewerTheme,
1166
- children: PropTypes.node
1167
- };
1168
- var defaultProps$h = {
1169
- className: null,
1170
- progressSpring: null,
1171
- theme: null,
1172
- children: null
1173
- };
1174
- var ViewerMenuContainer = function ViewerMenuContainer(_ref) {
1175
- var className = _ref.className,
1176
- progressSpring = _ref.progressSpring,
1177
- viewerTheme = _ref.theme,
1178
- children = _ref.children;
1179
- var _ref2 = viewerTheme || {},
1180
- _ref2$background = _ref2.background,
1181
- background = _ref2$background === void 0 ? null : _ref2$background;
1182
- var _ref3 = background || {},
1183
- _ref3$color = _ref3.color,
1184
- brandBackgroundColor = _ref3$color === void 0 ? null : _ref3$color;
1185
- var backgroundColorStyle = utils.getStyleFromColor(brandBackgroundColor, 'backgroundColor');
1186
- return /*#__PURE__*/React.createElement("div", {
1187
- className: classNames([styles$d.container, _defineProperty({}, className, className !== null)]),
1188
- style: {
1189
- pointerEvents: 'none'
1190
- }
1191
- }, /*#__PURE__*/React.createElement(web.animated.div, {
1192
- className: styles$d.heightContainer,
1193
- style: _objectSpread({
1194
- opacity: progressSpring,
1195
- transform: progressSpring.to(function (p) {
1196
- return "translateY(".concat((1 - p) * -2, "rem)");
1197
- }),
1198
- pointerEvents: progressSpring.to(function (p) {
1199
- return p < 0.25 ? 'none' : 'auto';
1200
- }),
1201
- zIndex: progressSpring.to(function (p) {
1202
- return Math.round(2 + p);
1203
- })
1204
- }, backgroundColorStyle)
1205
- }, children), /*#__PURE__*/React.createElement(web.animated.div, {
1206
- className: styles$d.backdrop,
1207
- style: {
1208
- opacity: progressSpring.to(function (p) {
1209
- return utils.easings.easeOutQuint(p);
1210
- })
1211
- }
1212
- }));
1213
- };
1214
- ViewerMenuContainer.propTypes = propTypes$h;
1215
- ViewerMenuContainer.defaultProps = defaultProps$h;
1216
- var MenuContainer = ViewerMenuContainer;
1217
-
1218
- 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"};
1219
-
1220
- var propTypes$g = {
1221
- current: PropTypes.bool,
1222
- active: PropTypes.bool,
1223
- colors: PropTypes.shape({
1224
- primary: PropTypes.string,
1225
- secondary: PropTypes.string
1226
- }),
1227
- count: PropTypes.number,
1228
- subIndex: PropTypes.number,
1229
- vertical: PropTypes.bool,
1230
- onClick: PropTypes.func,
1231
- className: PropTypes.string
1232
- };
1233
- var defaultProps$g = {
1234
- current: false,
1235
- active: false,
1236
- colors: null,
1237
- count: 1,
1238
- subIndex: 0,
1239
- vertical: false,
1240
- onClick: null,
1241
- className: null
1242
- };
1243
- var ViewerMenuDot = function ViewerMenuDot(_ref) {
1244
- var current = _ref.current,
1245
- active = _ref.active,
1246
- colors = _ref.colors,
1247
- count = _ref.count,
1248
- subIndex = _ref.subIndex,
1249
- vertical = _ref.vertical,
1250
- _onClick = _ref.onClick,
1251
- className = _ref.className;
1252
- var _ref2 = colors || {},
1253
- _ref2$primary = _ref2.primary,
1254
- primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary,
1255
- _ref2$secondary = _ref2.secondary,
1256
- secondary = _ref2$secondary === void 0 ? 'rgba(255, 255, 255, 0.25)' : _ref2$secondary;
1257
- var _useSpring = core$1.useSpring(function () {
1258
- return {
1259
- scaleX: 0,
1260
- config: {
1261
- tension: 200,
1262
- friction: 30
1263
- }
1264
- };
1265
- }),
1266
- _useSpring2 = _slicedToArray(_useSpring, 2),
1267
- dotSpringStyles = _useSpring2[0],
1268
- setDotSpringProps = _useSpring2[1];
1269
- React.useEffect(function () {
1270
- var activeRatio = active ? 1 : 0;
1271
- var ratio = count > 1 && current ? (subIndex + 1) / count : activeRatio;
1272
- var scaleX = ratio;
1273
- setDotSpringProps.start({
1274
- scaleX: scaleX,
1275
- immediate: !current
1276
- });
1277
- }, [active, current, subIndex, count, setDotSpringProps]);
1278
- return /*#__PURE__*/React.createElement("li", {
1279
- className: classNames([styles$c.container, _defineProperty(_defineProperty(_defineProperty({}, styles$c.active, current), styles$c.vertical, vertical), className, className !== null)]),
1280
- "aria-hidden": "true"
1281
- }, /*#__PURE__*/React.createElement("button", {
1282
- type: "button",
1283
- className: styles$c.button,
1284
- onClick: function onClick() {
1285
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1286
- if (e !== null) {
1287
- e.stopPropagation();
1288
- }
1289
- if (_onClick !== null) {
1290
- _onClick();
1291
- }
1292
- },
1293
- tabIndex: "-1"
1294
- }, /*#__PURE__*/React.createElement("div", {
1295
- className: styles$c.dot,
1296
- style: {
1297
- backgroundColor: secondary
1298
- }
1299
- }, /*#__PURE__*/React.createElement(web.animated.div, {
1300
- className: styles$c.progress,
1301
- style: _objectSpread(_objectSpread({}, dotSpringStyles), {}, {
1302
- backgroundColor: primary
1303
- })
1304
- }))));
1305
- };
1306
- ViewerMenuDot.propTypes = propTypes$g;
1307
- ViewerMenuDot.defaultProps = defaultProps$g;
1308
- var MenuDot = ViewerMenuDot;
1309
-
1310
- var styles$b = {"container":"micromag-viewer-menus-menu-dots-container","closeButton":"micromag-viewer-menus-menu-dots-closeButton","items":"micromag-viewer-menus-menu-dots-items","item":"micromag-viewer-menus-menu-dots-item","buttons":"micromag-viewer-menus-menu-dots-buttons","vertical":"micromag-viewer-menus-menu-dots-vertical"};
1311
-
1312
- var _excluded$5 = ["direction", "items", "onClickDot", "onClickScreensMenu", "colors", "closeable", "buttons", "withItemClick", "withoutScreensMenu", "onClose", "className"];
1313
- var propTypes$f = {
1314
- direction: PropTypes.oneOf(['horizontal', 'vertical']),
1315
- items: core.PropTypes.menuItems,
1316
- onClickDot: PropTypes.func,
1317
- onClickScreensMenu: PropTypes.func,
1318
- colors: PropTypes.shape({
1319
- primary: PropTypes.string,
1320
- secondary: PropTypes.string
1321
- }),
1322
- buttons: PropTypes.node,
1323
- closeable: PropTypes.bool,
1324
- withItemClick: PropTypes.bool,
1325
- withoutScreensMenu: PropTypes.bool,
1326
- onClose: PropTypes.func,
1327
- className: PropTypes.string
1328
- };
1329
- var defaultProps$f = {
1330
- direction: 'horizontal',
1331
- items: [],
1332
- onClickDot: null,
1333
- onClickScreensMenu: null,
1334
- colors: null,
1335
- buttons: null,
1336
- closeable: false,
1337
- withItemClick: false,
1338
- withoutScreensMenu: false,
1339
- onClose: null,
1340
- className: null
1341
- };
1342
- var ViewerMenuDots = function ViewerMenuDots(_ref) {
1343
- var direction = _ref.direction,
1344
- items = _ref.items,
1345
- onClickDot = _ref.onClickDot,
1346
- onClickScreensMenu = _ref.onClickScreensMenu,
1347
- colors = _ref.colors,
1348
- closeable = _ref.closeable,
1349
- buttons = _ref.buttons,
1350
- withItemClick = _ref.withItemClick,
1351
- withoutScreensMenu = _ref.withoutScreensMenu,
1352
- onClose = _ref.onClose,
1353
- className = _ref.className,
1354
- props = _objectWithoutProperties(_ref, _excluded$5);
1355
- var _ref2 = colors || {},
1356
- _ref2$primary = _ref2.primary,
1357
- primary = _ref2$primary === void 0 ? 'rgba(255, 255, 255, 1)' : _ref2$primary;
1358
- var intl = reactIntl.useIntl();
1359
- var currentIndex = items.findIndex(function (_ref3) {
1360
- var _ref3$current = _ref3.current,
1361
- current = _ref3$current === void 0 ? false : _ref3$current;
1362
- return current;
1363
- });
1364
- var _ref4 = props || {},
1365
- style = _ref4.style;
1366
- return /*#__PURE__*/React.createElement("nav", {
1367
- className: classNames([styles$b.container, _defineProperty(_defineProperty({}, className, className !== null), styles$b.vertical, direction === 'vertical')]),
1368
- "aria-label": intl.formatMessage({
1369
- id: "bLYuuN",
1370
- defaultMessage: [{
1371
- "type": 0,
1372
- "value": "You are on screen "
1373
- }, {
1374
- "type": 1,
1375
- "value": "current"
1376
- }, {
1377
- "type": 0,
1378
- "value": " of "
1379
- }, {
1380
- "type": 1,
1381
- "value": "total"
1382
- }, {
1383
- "type": 0,
1384
- "value": "."
1385
- }]
1386
- }, {
1387
- current: currentIndex + 1,
1388
- total: items.length
1389
- }),
1390
- style: style
1391
- }, /*#__PURE__*/React.createElement("ul", {
1392
- className: styles$b.items
1393
- }, items.map(function (item, index) {
1394
- var _ref6 = item || {},
1395
- _ref6$current = _ref6.current,
1396
- current = _ref6$current === void 0 ? false : _ref6$current,
1397
- _ref6$count = _ref6.count,
1398
- count = _ref6$count === void 0 ? 1 : _ref6$count,
1399
- _ref6$subIndex = _ref6.subIndex,
1400
- subIndex = _ref6$subIndex === void 0 ? 0 : _ref6$subIndex;
1401
- return /*#__PURE__*/React.createElement(MenuDot, {
1402
- key: "item-".concat(index + 1),
1403
- current: current,
1404
- active: index <= currentIndex,
1405
- colors: colors,
1406
- count: count,
1407
- subIndex: subIndex,
1408
- onClick: function onClick() {
1409
- if ((withItemClick || withoutScreensMenu) && onClickDot !== null) {
1410
- onClickDot(item);
1411
- } else if (!withItemClick && onClickScreensMenu !== null) {
1412
- onClickScreensMenu();
1413
- }
1414
- },
1415
- vertical: direction === 'vertical'
1416
- });
1417
- }), closeable ? /*#__PURE__*/React.createElement("li", {
1418
- className: styles$b.closeButton,
1419
- style: {
1420
- color: primary
1421
- }
1422
- }, /*#__PURE__*/React.createElement("button", {
1423
- type: "button",
1424
- className: styles$b.closeButton,
1425
- onClick: onClose,
1426
- title: intl.formatMessage({
1427
- id: "dj/p/q",
1428
- defaultMessage: [{
1429
- "type": 0,
1430
- "value": "Close"
1431
- }]
1432
- }),
1433
- "aria-label": intl.formatMessage({
1434
- id: "dj/p/q",
1435
- defaultMessage: [{
1436
- "type": 0,
1437
- "value": "Close"
1438
- }]
1439
- })
1440
- }, /*#__PURE__*/React.createElement(components.CloseIcon, null))) : null, buttons !== null ? /*#__PURE__*/React.createElement("div", {
1441
- className: styles$b.buttons
1442
- }, buttons) : null));
1443
- };
1444
- ViewerMenuDots.propTypes = propTypes$f;
1445
- ViewerMenuDots.defaultProps = defaultProps$f;
1446
- var MenuDots = ViewerMenuDots;
1447
-
1448
- var propTypes$e = {
1449
- className: PropTypes.string
1450
- };
1451
- var defaultProps$e = {
1452
- className: null
1453
- };
1454
- var StackIcon = function StackIcon(_ref) {
1455
- var className = _ref.className;
1456
- return /*#__PURE__*/React.createElement("svg", {
1457
- xmlns: "http://www.w3.org/2000/svg",
1458
- width: "11.5px",
1459
- height: "17.5px",
1460
- viewBox: "0 0 11.5 17.5",
1461
- className: classNames([_defineProperty({}, className, className !== null)])
1462
- }, /*#__PURE__*/React.createElement("rect", {
1463
- width: "10",
1464
- height: "16"
1465
- }), /*#__PURE__*/React.createElement("polygon", {
1466
- 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"
1467
- }));
1468
- };
1469
- StackIcon.propTypes = propTypes$e;
1470
- StackIcon.defaultProps = defaultProps$e;
1471
- var StackIcon$1 = StackIcon;
1472
-
1473
- var styles$a = {"button":"micromag-viewer-menus-menu-screen-button","container":"micromag-viewer-menus-menu-screen-container","isCurrent":"micromag-viewer-menus-menu-screen-isCurrent","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","screen":"micromag-viewer-menus-menu-screen-screen","pulse":"micromag-viewer-menus-menu-screen-pulse"};
1474
-
1475
- var propTypes$d = {
1476
- className: PropTypes.string,
1477
- item: core.PropTypes.menuItem,
1478
- index: PropTypes.number,
1479
- onClick: PropTypes.func,
1480
- screenSize: core.PropTypes.screenSize,
1481
- focusable: PropTypes.bool
1482
- };
1483
- var defaultProps$d = {
1484
- className: null,
1485
- item: core.PropTypes.menuItem,
1486
- index: 0,
1487
- onClick: null,
1488
- screenSize: null,
1489
- focusable: true
1490
- };
1491
- var ViewerMenuScreen = function ViewerMenuScreen(_ref) {
1492
- var className = _ref.className,
1493
- item = _ref.item,
1494
- index = _ref.index,
1495
- _onClick = _ref.onClick,
1496
- screenSize = _ref.screenSize,
1497
- focusable = _ref.focusable;
1498
- var intl = reactIntl.useIntl();
1499
- var _ref2 = item || {},
1500
- _ref2$current = _ref2.current,
1501
- current = _ref2$current === void 0 ? false : _ref2$current,
1502
- screen = _ref2.screen,
1503
- _ref2$count = _ref2.count,
1504
- count = _ref2$count === void 0 ? 1 : _ref2$count;
1505
- var _ref3 = screenSize || {},
1506
- screenWidth = _ref3.width,
1507
- screenHeight = _ref3.height;
1508
- var screenAriaLabel = "".concat(intl.formatMessage({
1509
- id: "LkVfwW",
1510
- defaultMessage: [{
1511
- "type": 0,
1512
- "value": "Screen "
1513
- }, {
1514
- "type": 1,
1515
- "value": "index"
1516
- }]
1517
- }, {
1518
- index: index + 1
1519
- })).concat(current ? " ".concat(intl.formatMessage({
1520
- id: "vmrJ8U",
1521
- defaultMessage: [{
1522
- "type": 0,
1523
- "value": "(current screen)"
1524
- }]
1525
- })) : '');
1526
- return /*#__PURE__*/React.createElement("div", {
1527
- className: classNames([styles$a.container, _defineProperty(_defineProperty({}, className, className !== null), styles$a.isCurrent, current)]),
1528
- style: {
1529
- paddingBottom: "".concat(screenHeight / screenWidth * 100, "%")
1530
- }
1531
- }, /*#__PURE__*/React.createElement("button", {
1532
- type: "button",
1533
- className: styles$a.button,
1534
- onClick: function onClick() {
1535
- var e = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1536
- if (e !== null) {
1537
- e.stopPropagation();
1538
- }
1539
- if (_onClick !== null) {
1540
- _onClick(item);
1541
- }
1542
- },
1543
- "aria-label": screenAriaLabel,
1544
- tabIndex: focusable ? '0' : '-1'
1545
- }), /*#__PURE__*/React.createElement("div", {
1546
- className: styles$a.inner
1547
- }, count > 1 ? /*#__PURE__*/React.createElement("div", {
1548
- className: styles$a.subScreenBadge
1549
- }, /*#__PURE__*/React.createElement("span", {
1550
- className: styles$a.subScreenCount
1551
- }, count), /*#__PURE__*/React.createElement(StackIcon$1, {
1552
- className: styles$a.subScreenIcon
1553
- })) : null, screenWidth > 0 && screenHeight > 0 ? /*#__PURE__*/React.createElement(components.ScreenPreview, {
1554
- className: styles$a.screen,
1555
- screenWidth: screenWidth,
1556
- screenHeight: screenHeight,
1557
- screen: screen,
1558
- focusable: focusable,
1559
- active: focusable,
1560
- withSize: true
1561
- }) : null));
1562
- };
1563
- ViewerMenuScreen.propTypes = propTypes$d;
1564
- ViewerMenuScreen.defaultProps = defaultProps$d;
1565
- var MenuScreen = ViewerMenuScreen;
1566
-
1567
- 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","content":"micromag-viewer-menus-menu-preview-content","buttons":"micromag-viewer-menus-menu-preview-buttons","organisation":"micromag-viewer-menus-menu-preview-organisation","icon":"micromag-viewer-menus-menu-preview-icon","titleContainer":"micromag-viewer-menus-menu-preview-titleContainer","headerContainer":"micromag-viewer-menus-menu-preview-headerContainer","badge":"micromag-viewer-menus-menu-preview-badge","title":"micromag-viewer-menus-menu-preview-title","nav":"micromag-viewer-menus-menu-preview-nav","items":"micromag-viewer-menus-menu-preview-items","item":"micromag-viewer-menus-menu-preview-item","inner":"micromag-viewer-menus-menu-preview-inner","frame":"micromag-viewer-menus-menu-preview-frame","screen":"micromag-viewer-menus-menu-preview-screen","intro":"micromag-viewer-menus-menu-preview-intro"};
1568
-
1569
- var _excluded$4 = ["textAlign"];
1570
- var propTypes$c = {
1571
- viewerTheme: core.PropTypes.viewerTheme,
1572
- header: PropTypes.node,
1573
- footer: PropTypes.node,
1574
- screenSize: core.PropTypes.screenSize,
1575
- title: PropTypes.string,
1576
- menuWidth: PropTypes.number,
1577
- items: core.PropTypes.menuItems,
1578
- focusable: PropTypes.bool,
1579
- onClickScreen: PropTypes.func,
1580
- maxThumbsWidth: PropTypes.number,
1581
- paddingTop: PropTypes.number,
1582
- scrollDisabled: PropTypes.bool,
1583
- // @todo to reimplement:
1584
- // shouldLoad: PropTypes.bool,
1585
- // toggleFullscreen: PropTypes.func,
1586
- // fullscreenActive: PropTypes.bool,
1587
- // fullscreenEnabled: PropTypes.bool,
1588
- className: PropTypes.string
1589
- };
1590
- var defaultProps$c = {
1591
- viewerTheme: null,
1592
- header: null,
1593
- footer: null,
1594
- screenSize: null,
1595
- title: null,
1596
- menuWidth: null,
1597
- items: [],
1598
- focusable: true,
1599
- // shouldLoad: true,
1600
- onClickScreen: null,
1601
- maxThumbsWidth: 140,
1602
- paddingTop: null,
1603
- scrollDisabled: false,
1604
- // toggleFullscreen: null,
1605
- // fullscreenActive: false,
1606
- // fullscreenEnabled: false,
1607
- className: null
1608
- };
1609
- var ViewerMenuPreview = function ViewerMenuPreview(_ref) {
1610
- var viewerTheme = _ref.viewerTheme,
1611
- header = _ref.header,
1612
- footer = _ref.footer,
1613
- screenSize = _ref.screenSize,
1614
- title = _ref.title,
1615
- menuWidth = _ref.menuWidth,
1616
- items = _ref.items,
1617
- focusable = _ref.focusable,
1618
- onClickScreen = _ref.onClickScreen,
1619
- maxThumbsWidth = _ref.maxThumbsWidth,
1620
- paddingTop = _ref.paddingTop,
1621
- scrollDisabled = _ref.scrollDisabled,
1622
- className = _ref.className;
1623
- var _useDimensionObserver = hooks.useDimensionObserver(),
1624
- containerRef = _useDimensionObserver.ref,
1625
- _useDimensionObserver2 = _useDimensionObserver.width,
1626
- contentWidth = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
1627
- var thumbsPerLine = Math.max(Math.floor(contentWidth / maxThumbsWidth), 3); // @note cool, should be in recipes
1628
-
1629
- // @todo reimplement the brand logo
1630
- // const { background = null, logo: brandLogo = null } = viewerTheme || {};
1631
- var _ref2 = viewerTheme || {},
1632
- _ref2$background = _ref2.background,
1633
- background = _ref2$background === void 0 ? null : _ref2$background,
1634
- _ref2$textStyles = _ref2.textStyles,
1635
- textStyles = _ref2$textStyles === void 0 ? null : _ref2$textStyles;
1636
- var _ref3 = background || {},
1637
- _ref3$image = _ref3.image,
1638
- image = _ref3$image === void 0 ? null : _ref3$image;
1639
- var _ref4 = image || {},
1640
- _ref4$url = _ref4.url,
1641
- brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
1642
- var brandImageStyle = brandImageUrl !== null ? {
1643
- backgroundImage: "url(".concat(brandImageUrl, ")")
1644
- } : null;
1645
- var _ref5 = textStyles || {},
1646
- _ref5$title = _ref5.title,
1647
- titleStyles = _ref5$title === void 0 ? null : _ref5$title;
1648
- // eslint-disable-next-line no-unused-vars
1649
- var _ref6 = titleStyles || {};
1650
- _ref6.textAlign;
1651
- var otherTitleStyles = _objectWithoutProperties(_ref6, _excluded$4);
1652
- var finalTitleStyles = titleStyles !== null ? utils.getStyleFromText(otherTitleStyles) : null;
1653
- // const { url: brandLogoUrl = null } = brandLogo || {};
1654
- var _useState = React.useState([]),
1655
- _useState2 = _slicedToArray(_useState, 2),
1656
- screensMounted = _useState2[0],
1657
- setScreensMounted = _useState2[1];
1658
- var hasTitle = title !== null;
1659
-
1660
- // @todo optimize all of this the proper way
1661
- // const finalItems = useMemo(
1662
- // () => (!focusable ? items.map((s, i) => (i > 6 ? { screenId: s.screenId } : s)) : items),
1663
- // [items, focusable],
1664
- // );
1665
-
1666
- React.useEffect(function () {
1667
- if (items.length === screensMounted.length) {
1668
- return function () {};
1669
- }
1670
- var timeout = setTimeout(function () {
1671
- setScreensMounted([].concat(_toConsumableArray(screensMounted), [true]));
1672
- }, 40);
1673
- return function () {
1674
- clearTimeout(timeout);
1675
- };
1676
- }, [items, screensMounted, setScreensMounted]);
1677
- var menuPaddingTop = paddingTop + 10;
1678
- return /*#__PURE__*/React.createElement("div", {
1679
- className: classNames([styles$9.container, _defineProperty({}, className, className !== null)]),
1680
- style: _objectSpread(_objectSpread({}, brandImageStyle), {}, {
1681
- width: menuWidth
1682
- }),
1683
- "aria-hidden": focusable ? null : 'true'
1684
- }, /*#__PURE__*/React.createElement("div", {
1685
- className: styles$9.content,
1686
- ref: containerRef
1687
- }, /*#__PURE__*/React.createElement(Scroll, {
1688
- className: styles$9.scroll,
1689
- disabled: scrollDisabled
1690
- }, hasTitle && header === null ? /*#__PURE__*/React.createElement("div", {
1691
- className: styles$9.titleContainer,
1692
- style: {
1693
- paddingTop: menuPaddingTop
1694
- }
1695
- }, /*#__PURE__*/React.createElement("h1", {
1696
- className: styles$9.title,
1697
- style: _objectSpread({}, finalTitleStyles)
1698
- }, title)) : /*#__PURE__*/React.createElement("div", {
1699
- className: styles$9.headerContainer,
1700
- style: {
1701
- paddingTop: menuPaddingTop
1702
- }
1703
- }, header), /*#__PURE__*/React.createElement("nav", {
1704
- className: styles$9.nav,
1705
- style: !hasTitle ? {
1706
- paddingTop: paddingTop
1707
- } : null
1708
- }, /*#__PURE__*/React.createElement("ul", {
1709
- className: styles$9.items
1710
- }, items.map(function (item, index) {
1711
- var _ref8 = item || {},
1712
- screenId = _ref8.screenId;
1713
- var itemStyles = {
1714
- width: "".concat(100 / thumbsPerLine, "%")
1715
- };
1716
- var _ref9 = screenSize || {},
1717
- screenWidth = _ref9.width,
1718
- screenHeight = _ref9.height;
1719
- var screenMounted = screensMounted[index] || false;
1720
- return /*#__PURE__*/React.createElement("li", {
1721
- key: "item-".concat(screenId),
1722
- className: styles$9.item,
1723
- style: itemStyles
1724
- }, /*#__PURE__*/React.createElement("div", {
1725
- className: styles$9.inner
1726
- }, /*#__PURE__*/React.createElement("div", {
1727
- className: classNames([styles$9.frame, _defineProperty({}, styles$9.isLoading, !screenMounted)]),
1728
- style: {
1729
- paddingBottom: "".concat(screenHeight / screenWidth * 100, "%")
1730
- }
1731
- }, screenMounted ? /*#__PURE__*/React.createElement(MenuScreen, {
1732
- className: styles$9.screen,
1733
- item: item,
1734
- index: index,
1735
- screenSize: screenSize,
1736
- onClick: onClickScreen,
1737
- focusable: focusable
1738
- }) : null)));
1739
- }))), footer)));
1740
- };
1741
- ViewerMenuPreview.propTypes = propTypes$c;
1742
- ViewerMenuPreview.defaultProps = defaultProps$c;
1743
- var MenuPreview = ViewerMenuPreview;
1744
-
1745
- 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"};
1746
-
1747
- var propTypes$b = {
1748
- screen: core.PropTypes.screen,
1749
- title: PropTypes.string,
1750
- url: PropTypes.string,
1751
- description: PropTypes.string,
1752
- className: PropTypes.string
1753
- };
1754
- var defaultProps$b = {
1755
- screen: null,
1756
- title: null,
1757
- url: null,
1758
- description: null,
1759
- className: null
1760
- };
1761
- var MicromagPreview = function MicromagPreview(_ref) {
1762
- var screen = _ref.screen,
1763
- title = _ref.title,
1764
- url = _ref.url,
1765
- description = _ref.description,
1766
- className = _ref.className;
1767
- return /*#__PURE__*/React.createElement("div", {
1768
- className: classNames([styles$8.container, _defineProperty({}, className, className)])
1769
- }, /*#__PURE__*/React.createElement("div", {
1770
- className: styles$8.cover
1771
- }, /*#__PURE__*/React.createElement(components.ScreenPreview, {
1772
- screen: screen,
1773
- width: 100,
1774
- height: 150,
1775
- withSize: true
1776
- })), /*#__PURE__*/React.createElement("div", {
1777
- className: styles$8.info
1778
- }, /*#__PURE__*/React.createElement("h3", {
1779
- className: styles$8.title
1780
- }, title), url ? /*#__PURE__*/React.createElement("div", {
1781
- className: styles$8.url
1782
- }, url) : null, /*#__PURE__*/React.createElement("p", null, description)));
1783
- };
1784
- MicromagPreview.propTypes = propTypes$b;
1785
- MicromagPreview.defaultProps = defaultProps$b;
1786
- var MicromagPreview$1 = MicromagPreview;
1787
-
1788
- 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","content":"micromag-viewer-menus-menu-share-content","inner":"micromag-viewer-menus-menu-share-inner","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"};
1789
-
1790
- var propTypes$a = {
1791
- viewerTheme: core.PropTypes.viewerTheme,
1792
- menuWidth: PropTypes.number,
1793
- title: PropTypes.string,
1794
- description: PropTypes.string,
1795
- items: core.PropTypes.menuItems,
1796
- focusable: PropTypes.bool,
1797
- paddingTop: PropTypes.number,
1798
- currentScreenIndex: PropTypes.number,
1799
- shareUrl: PropTypes.string,
1800
- onShare: PropTypes.func,
1801
- className: PropTypes.string
1802
- };
1803
- var defaultProps$a = {
1804
- viewerTheme: null,
1805
- menuWidth: null,
1806
- title: null,
1807
- description: null,
1808
- items: [],
1809
- focusable: true,
1810
- paddingTop: null,
1811
- currentScreenIndex: 0,
1812
- shareUrl: null,
1813
- onShare: null,
1814
- className: null
1815
- };
1816
- var ViewerMenuShare = function ViewerMenuShare(_ref) {
1817
- var viewerTheme = _ref.viewerTheme,
1818
- menuWidth = _ref.menuWidth,
1819
- title = _ref.title,
1820
- description = _ref.description,
1821
- items = _ref.items,
1822
- focusable = _ref.focusable,
1823
- paddingTop = _ref.paddingTop,
1824
- currentScreenIndex = _ref.currentScreenIndex,
1825
- shareUrl = _ref.shareUrl,
1826
- onShare = _ref.onShare,
1827
- className = _ref.className;
1828
- // Viewer theme
1829
- var _ref2 = viewerTheme || {},
1830
- _ref2$background = _ref2.background,
1831
- background = _ref2$background === void 0 ? null : _ref2$background;
1832
- var _ref3 = background || {},
1833
- _ref3$image = _ref3.image,
1834
- image = _ref3$image === void 0 ? null : _ref3$image;
1835
- var _ref4 = image || {},
1836
- _ref4$url = _ref4.url,
1837
- brandImageUrl = _ref4$url === void 0 ? null : _ref4$url;
1838
- var brandImageStyle = brandImageUrl !== null ? {
1839
- backgroundImage: "url(".concat(brandImageUrl, ")")
1840
- } : null;
1841
- var coverScreen = React.useMemo(function () {
1842
- var _ref5 = items[0] || {},
1843
- _ref5$screen = _ref5.screen,
1844
- screen = _ref5$screen === void 0 ? null : _ref5$screen;
1845
- return screen;
1846
- }, [items]);
1847
- var currentScreen = React.useMemo(function () {
1848
- var found = items.find(function (item) {
1849
- var _ref6 = item || {},
1850
- _ref6$current = _ref6.current,
1851
- current = _ref6$current === void 0 ? false : _ref6$current;
1852
- return current;
1853
- });
1854
- var _ref7 = found || {},
1855
- _ref7$screen = _ref7.screen,
1856
- screen = _ref7$screen === void 0 ? null : _ref7$screen;
1857
- return screen;
1858
- }, [items, currentScreenIndex, focusable]);
1859
- var _useState = React.useState(false),
1860
- _useState2 = _slicedToArray(_useState, 2),
1861
- shareCurrentScreen = _useState2[0],
1862
- setShareCurrentScreen = _useState2[1];
1863
- var onShareModeChange = React.useCallback(function () {
1864
- setShareCurrentScreen(function (value) {
1865
- return !value;
1866
- });
1867
- }, [setShareCurrentScreen]);
1868
- var finalShareUrl = React.useMemo(function () {
1869
- return shareCurrentScreen && currentScreenIndex !== 0 ? "".concat(shareUrl, "/").concat(currentScreenIndex + 1) : shareUrl;
1870
- }, [shareUrl, shareCurrentScreen, currentScreenIndex]);
1871
- return /*#__PURE__*/React.createElement("div", {
1872
- className: classNames([styles$7.container, _defineProperty({}, className, className !== null)]),
1873
- style: _objectSpread(_objectSpread({}, brandImageStyle), {}, {
1874
- width: menuWidth
1875
- }),
1876
- "aria-hidden": focusable ? null : 'true'
1877
- }, /*#__PURE__*/React.createElement("div", {
1878
- className: styles$7.content
1879
- }, /*#__PURE__*/React.createElement(Scroll, {
1880
- className: styles$7.scroll
1881
- }, /*#__PURE__*/React.createElement("div", {
1882
- className: styles$7.inner,
1883
- style: {
1884
- paddingTop: paddingTop
1885
- }
1886
- }, /*#__PURE__*/React.createElement("div", {
1887
- className: styles$7.header
1888
- }, /*#__PURE__*/React.createElement(MicromagPreview$1, {
1889
- className: styles$7.preview,
1890
- screen: shareCurrentScreen ? currentScreen : coverScreen,
1891
- title: title,
1892
- url: finalShareUrl,
1893
- description: description
1894
- }), currentScreenIndex !== 0 ? /*#__PURE__*/React.createElement("div", {
1895
- className: styles$7.mode
1896
- }, /*#__PURE__*/React.createElement("label", null, /*#__PURE__*/React.createElement("input", {
1897
- type: "checkbox",
1898
- name: "currentScreen",
1899
- value: "currentScreen",
1900
- onChange: onShareModeChange,
1901
- checked: shareCurrentScreen
1902
- }), /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
1903
- id: "xuPbeq",
1904
- defaultMessage: [{
1905
- "type": 0,
1906
- "value": "Start from the current screen"
1907
- }]
1908
- }))) : null), /*#__PURE__*/React.createElement(ShareOptions, {
1909
- className: styles$7.options,
1910
- itemClassName: styles$7.optionItem,
1911
- buttonClassName: styles$7.optionButton,
1912
- title: title,
1913
- url: finalShareUrl,
1914
- focusable: focusable,
1915
- onShare: onShare,
1916
- theme: viewerTheme,
1917
- shareCurrentScreen: shareCurrentScreen
1918
- })))));
1919
- };
1920
- ViewerMenuShare.propTypes = propTypes$a;
1921
- ViewerMenuShare.defaultProps = defaultProps$a;
1922
- var MenuShare = ViewerMenuShare;
1923
-
1924
- var styles$6 = {"container":"micromag-viewer-container","screenContainer":"micromag-viewer-screenContainer","screensFrame":"micromag-viewer-screensFrame","menuShare":"micromag-viewer-menuShare","menuPreview":"micromag-viewer-menuPreview","menuContainer":"micromag-viewer-menuContainer","landscape":"micromag-viewer-landscape","hideMenu":"micromag-viewer-hideMenu","menuNavContainer":"micromag-viewer-menuNavContainer","menuTopContainer":"micromag-viewer-menuTopContainer","dots":"micromag-viewer-dots","disableMenu":"micromag-viewer-disableMenu","content":"micromag-viewer-content","withoutGestures":"micromag-viewer-withoutGestures","ariaAnnouncement":"micromag-viewer-ariaAnnouncement","accessibilityLinks":"micromag-viewer-accessibilityLinks","accessibilityButton":"micromag-viewer-accessibilityButton","disabled":"micromag-viewer-disabled","tooltip":"micromag-viewer-tooltip","fadeMenu":"micromag-viewer-fadeMenu","withShadow":"micromag-viewer-withShadow","isOpened":"micromag-viewer-isOpened","menuItem":"micromag-viewer-menuItem","menuButton":"micromag-viewer-menuButton","slidingButton":"micromag-viewer-slidingButton","screensMenuButtonToggled":"micromag-viewer-screensMenuButtonToggled","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","shareIncentiveContainer":"micromag-viewer-shareIncentiveContainer","shareIncentive":"micromag-viewer-shareIncentive","shareIncentiveVisible":"micromag-viewer-shareIncentiveVisible"};
1925
-
1926
- var propTypes$9 = {
1927
- story: core.PropTypes.story.isRequired,
1928
- currentScreenIndex: PropTypes.number,
1929
- toggleFullscreen: PropTypes.func,
1930
- fullscreenActive: PropTypes.bool,
1931
- fullscreenEnabled: PropTypes.bool,
1932
- menuDotsButtons: PropTypes.node,
1933
- closeable: PropTypes.bool,
1934
- withShadow: PropTypes.bool,
1935
- trackingEnabled: PropTypes.bool,
1936
- shareBasePath: PropTypes.string,
1937
- theme: core.PropTypes.viewerTheme,
1938
- screenSize: core.PropTypes.screenSize,
1939
- menuWidth: PropTypes.number,
1940
- previewHeader: PropTypes.node,
1941
- previewFooter: PropTypes.node,
1942
- afterShareMenuButton: PropTypes.node,
1943
- beforeScreensMenuButton: PropTypes.node,
1944
- withDotItemClick: PropTypes.bool,
1945
- withoutScreensMenu: PropTypes.bool,
1946
- withoutShareMenu: PropTypes.bool,
1947
- onClickScreen: PropTypes.func,
1948
- // onClickMenu: PropTypes.func,
1949
- onClickCloseViewer: PropTypes.func,
1950
- onChange: PropTypes.func,
1951
- refDots: PropTypes.shape({
1952
- current: PropTypes.any // eslint-disable-line
1953
- })
1954
- };
1955
- var defaultProps$9 = {
1956
- currentScreenIndex: 0,
1957
- toggleFullscreen: null,
1958
- fullscreenActive: false,
1959
- fullscreenEnabled: false,
1960
- menuDotsButtons: null,
1961
- closeable: false,
1962
- withShadow: false,
1963
- trackingEnabled: false,
1964
- shareBasePath: null,
1965
- theme: null,
1966
- screenSize: null,
1967
- menuWidth: null,
1968
- previewHeader: null,
1969
- previewFooter: null,
1970
- afterShareMenuButton: null,
1971
- beforeScreensMenuButton: null,
1972
- withDotItemClick: false,
1973
- withoutScreensMenu: false,
1974
- withoutShareMenu: false,
1975
- onClickScreen: null,
1976
- onChange: null,
1977
- // onClickMenu: null,
1978
- onClickCloseViewer: null,
1979
- refDots: null
1980
- };
1981
- var ViewerMenu = function ViewerMenu(_ref) {
1982
- var story = _ref.story,
1983
- currentScreenIndex = _ref.currentScreenIndex,
1984
- toggleFullscreen = _ref.toggleFullscreen,
1985
- fullscreenActive = _ref.fullscreenActive,
1986
- fullscreenEnabled = _ref.fullscreenEnabled,
1987
- menuDotsButtons = _ref.menuDotsButtons,
1988
- closeable = _ref.closeable,
1989
- withShadow = _ref.withShadow,
1990
- shareBasePath = _ref.shareBasePath,
1991
- trackingEnabled = _ref.trackingEnabled,
1992
- viewerTheme = _ref.theme,
1993
- screenSize = _ref.screenSize,
1994
- menuWidth = _ref.menuWidth,
1995
- previewHeader = _ref.previewHeader,
1996
- previewFooter = _ref.previewFooter,
1997
- afterShareMenuButton = _ref.afterShareMenuButton,
1998
- beforeScreensMenuButton = _ref.beforeScreensMenuButton,
1999
- withDotItemClick = _ref.withDotItemClick,
2000
- withoutScreensMenu = _ref.withoutScreensMenu,
2001
- withoutShareMenu = _ref.withoutShareMenu,
2002
- customOnClickScreen = _ref.onClickScreen,
2003
- onChange = _ref.onChange,
2004
- onClickCloseViewer = _ref.onClickCloseViewer,
2005
- refDots = _ref.refDots;
2006
- var _story$components = story.components,
2007
- screens = _story$components === void 0 ? [] : _story$components,
2008
- _story$title = story.title,
2009
- title = _story$title === void 0 ? null : _story$title,
2010
- _story$metadata = story.metadata,
2011
- metadata = _story$metadata === void 0 ? null : _story$metadata;
2012
- var _ref2 = metadata || {},
2013
- _ref2$description = _ref2.description,
2014
- description = _ref2$description === void 0 ? null : _ref2$description;
2015
- var currentScreen = screens !== null ? screens[currentScreenIndex] || null : null;
2016
- var _ref3 = currentScreen || {},
2017
- _ref3$id = _ref3.id,
2018
- screenId = _ref3$id === void 0 ? null : _ref3$id,
2019
- _ref3$type = _ref3.type,
2020
- screenType = _ref3$type === void 0 ? null : _ref3$type;
2021
- var _ref4 = viewerTheme || {},
2022
- _ref4$menuTheme = _ref4.menuTheme,
2023
- menuTheme = _ref4$menuTheme === void 0 ? null : _ref4$menuTheme;
2024
- var _useViewerSize = contexts.useViewerSize(),
2025
- viewerHeight = _useViewerSize.height;
2026
- var _useState = React.useState(false),
2027
- _useState2 = _slicedToArray(_useState, 2),
2028
- menuOpened = _useState2[0],
2029
- setMenuOpened = _useState2[1];
2030
- var _useState3 = React.useState(false),
2031
- _useState4 = _slicedToArray(_useState3, 2),
2032
- shareOpened = _useState4[0],
2033
- setShareOpened = _useState4[1];
2034
- var _useState5 = React.useState(false),
2035
- _useState6 = _slicedToArray(_useState5, 2),
2036
- menuMounted = _useState6[0],
2037
- setMenuMounted = _useState6[1];
2038
- var _useDimensionObserver = hooks.useDimensionObserver(),
2039
- navContainerRef = _useDimensionObserver.ref,
2040
- _useDimensionObserver2 = _useDimensionObserver.height,
2041
- navContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
2042
- var items = React.useMemo(function () {
2043
- return screens.map(function (it) {
2044
- var children = screens.filter(function (s) {
2045
- return s.parentId === it.id;
2046
- });
2047
- var currentChild = children.find(function (c) {
2048
- return c.id === screenId;
2049
- }) || null;
2050
- var subIndex = children.findIndex(function (c) {
2051
- return c.id === screenId;
2052
- }) + 1;
2053
- return {
2054
- screen: it,
2055
- screenId: it.id,
2056
- current: screenId === it.id || currentChild !== null,
2057
- visible: ((it === null || it === void 0 ? void 0 : it.parentId) || null) === null,
2058
- count: children.length + 1 || 1,
2059
- subIndex: subIndex || 0
2060
- };
2061
- }).filter(function (_ref5) {
2062
- var _ref5$visible = _ref5.visible,
2063
- visible = _ref5$visible === void 0 ? true : _ref5$visible;
2064
- return visible;
2065
- });
2066
- }, [screens, screenId]);
2067
- var trackEvent = hooks.useTrackEvent();
2068
- var trackScreenEvent = React.useCallback(function (cat, action, label) {
2069
- if (trackingEnabled) {
2070
- trackEvent(cat, action, label, {
2071
- screenId: screenId,
2072
- screenIndex: currentScreenIndex,
2073
- screenType: screenType
2074
- });
2075
- }
2076
- }, [trackEvent, screenId, currentScreenIndex, screenType]);
2077
- var shareUrl = React.useMemo(function () {
2078
- var base = typeof window !== 'undefined' ? "".concat(window.location.protocol, "//").concat(window.location.host) : '';
2079
- var isFull = shareBasePath !== null && shareBasePath.indexOf('http') !== -1;
2080
- var partialPath = shareBasePath !== null ? "".concat(base).concat(shareBasePath) : base;
2081
- return shareBasePath !== null && isFull ? shareBasePath.replace(/\/$/, '') : partialPath;
2082
- }, [shareBasePath]);
2083
- var onOpenMenu = React.useCallback(function () {
2084
- setMenuOpened(true);
2085
- setShareOpened(false);
2086
- trackScreenEvent('viewer_menu', 'open_screens_menu');
2087
- }, [setMenuOpened, setShareOpened, trackScreenEvent]);
2088
- var onCloseMenu = React.useCallback(function () {
2089
- setMenuOpened(false);
2090
- setShareOpened(false);
2091
- trackScreenEvent('viewer_menu', 'close_screens_menu');
2092
- }, [setMenuOpened, setShareOpened, trackScreenEvent]);
2093
- var onOpenShare = React.useCallback(function () {
2094
- setShareOpened(true);
2095
- setMenuOpened(false);
2096
- trackScreenEvent('viewer_menu', 'open_share_menu');
2097
- }, [setShareOpened, setMenuOpened, trackScreenEvent]);
2098
- var onCloseShare = React.useCallback(function () {
2099
- setShareOpened(false);
2100
- setMenuOpened(false);
2101
- trackScreenEvent('viewer_menu', 'close_share_menu');
2102
- }, [setShareOpened, setMenuOpened, trackScreenEvent]);
2103
- var onClickScreen = React.useCallback(function (screen) {
2104
- setMenuOpened(false);
2105
- if (customOnClickScreen !== null) {
2106
- customOnClickScreen(screen);
2107
- }
2108
- var index = items.findIndex(function (_ref6) {
2109
- var id = _ref6.id;
2110
- return id === screenId;
2111
- });
2112
- trackScreenEvent('viewer_menu', 'click_screen_change', "Screen ".concat(index + 1));
2113
- }, [customOnClickScreen, setMenuOpened, items, screenId, trackScreenEvent]);
2114
- React.useEffect(function () {
2115
- if (onChange !== null) {
2116
- onChange({
2117
- menuOpen: menuOpened,
2118
- shareOpen: shareOpened
2119
- });
2120
- }
2121
- }, [onChange, menuOpened, shareOpened]);
2122
- var onShare = React.useCallback(function (type) {
2123
- // @todo display something to say thanks for sharing?
2124
- trackScreenEvent('viewer_menu', 'shared_story', type);
2125
- }, [trackScreenEvent]);
2126
- var computeShareProgress = React.useCallback(function (_ref7) {
2127
- var active = _ref7.active,
2128
- _ref7$direction = _slicedToArray(_ref7.direction, 2),
2129
- dy = _ref7$direction[1],
2130
- _ref7$movement = _slicedToArray(_ref7.movement, 2),
2131
- my = _ref7$movement[1],
2132
- _ref7$velocity = _slicedToArray(_ref7.velocity, 2),
2133
- vy = _ref7$velocity[1];
2134
- var progress = Math.max(0, my) / (viewerHeight * 0.8);
2135
- var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
2136
- if (!active) {
2137
- if (reachedThreshold) onOpenShare();
2138
- return reachedThreshold ? 1 : 0;
2139
- }
2140
- return progress;
2141
- }, [onOpenShare, viewerHeight]);
2142
- var computeShareProgressClose = React.useCallback(function (_ref8) {
2143
- var active = _ref8.active,
2144
- _ref8$direction = _slicedToArray(_ref8.direction, 2),
2145
- dy = _ref8$direction[1],
2146
- _ref8$movement = _slicedToArray(_ref8.movement, 2),
2147
- my = _ref8$movement[1],
2148
- _ref8$velocity = _slicedToArray(_ref8.velocity, 2),
2149
- vy = _ref8$velocity[1];
2150
- var progress = Math.max(0, my) / (viewerHeight * 0.8);
2151
- var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
2152
- if (!active) {
2153
- if (reachedThreshold) onCloseShare();
2154
- return reachedThreshold ? 0 : 1;
2155
- }
2156
- return 1 - progress;
2157
- }, [onCloseShare, viewerHeight]);
2158
- var springParams = React.useMemo(function () {
2159
- return {
2160
- config: {
2161
- tension: 300,
2162
- friction: 30
2163
- }
2164
- };
2165
- }, []);
2166
- var _useDragProgress = hooks.useDragProgress({
2167
- progress: shareOpened ? 1 : 0,
2168
- computeProgress: shareOpened ? computeShareProgressClose : computeShareProgress,
2169
- springParams: springParams,
2170
- dragOptions: {
2171
- axis: 'y',
2172
- pointer: {
2173
- keys: false
2174
- }
2175
- }
2176
- }),
2177
- bindShareDrag = _useDragProgress.bind,
2178
- draggingShare = _useDragProgress.dragging,
2179
- shareOpenedProgress = _useDragProgress.progress;
2180
- var computeMenuProgress = React.useCallback(function (_ref9) {
2181
- var active = _ref9.active,
2182
- _ref9$direction = _slicedToArray(_ref9.direction, 2),
2183
- dy = _ref9$direction[1],
2184
- _ref9$movement = _slicedToArray(_ref9.movement, 2),
2185
- my = _ref9$movement[1],
2186
- _ref9$velocity = _slicedToArray(_ref9.velocity, 2),
2187
- vy = _ref9$velocity[1];
2188
- var progress = Math.max(0, my) / (window.innerHeight * 0.8);
2189
- var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
2190
- if (!active) {
2191
- if (reachedThreshold) onOpenMenu();
2192
- return reachedThreshold ? 1 : 0;
2193
- }
2194
- return progress;
2195
- }, [onOpenMenu]);
2196
- var computeMenuProgressClose = React.useCallback(function (_ref10) {
2197
- var active = _ref10.active,
2198
- _ref10$direction = _slicedToArray(_ref10.direction, 2),
2199
- dy = _ref10$direction[1],
2200
- _ref10$movement = _slicedToArray(_ref10.movement, 2),
2201
- my = _ref10$movement[1],
2202
- _ref10$velocity = _slicedToArray(_ref10.velocity, 2),
2203
- vy = _ref10$velocity[1];
2204
- var progress = Math.max(0, my) / (window.innerHeight * 0.8);
2205
- var reachedThreshold = (vy > 0.3 || Math.abs(progress) > 0.3) && dy !== -1;
2206
- if (!active) {
2207
- if (reachedThreshold) onCloseMenu();
2208
- return reachedThreshold ? 0 : 1;
2209
- }
2210
- return 1 - progress;
2211
- }, [onCloseMenu]);
2212
- var _useDragProgress2 = hooks.useDragProgress({
2213
- progress: menuOpened ? 1 : 0,
2214
- computeProgress: menuOpened ? computeMenuProgressClose : computeMenuProgress,
2215
- springParams: springParams,
2216
- drapOptions: {
2217
- axis: 'y',
2218
- pointer: {
2219
- keys: false
2220
- }
2221
- }
2222
- }),
2223
- bindMenuDrag = _useDragProgress2.bind,
2224
- draggingMenu = _useDragProgress2.dragging,
2225
- menuOpenedProgress = _useDragProgress2.progress;
2226
- var keyboardShortcuts = React.useMemo(function () {
2227
- return {
2228
- m: function m() {
2229
- return !menuOpened ? onOpenMenu() : onCloseMenu();
2230
- },
2231
- escape: function escape() {
2232
- return onCloseMenu();
2233
- }
2234
- };
2235
- }, [menuOpened, onOpenMenu, onCloseMenu]);
2236
- useKeyboardShortcuts(keyboardShortcuts);
2237
-
2238
- // @TODO: Fix if needed
2239
- // const menuOpenedProgressValue = menuOpenedProgress ? menuOpenedProgress.value || 0 : 0;
2240
- // const shareOpenedProgressValue = shareOpenedProgress ? shareOpenedProgress.value || 0 : 0;
2241
- // should be zero if either screens menu or share menu is opened
2242
- // const dotsOpacity = useEffect(() => {
2243
- // Math.min(1, Math.max(0, 1 - (menuOpenedProgressValue + shareOpenedProgressValue)));
2244
- // }, [menuOpenedProgressValue, shareOpenedProgressValue]);
2245
-
2246
- React.useEffect(function () {
2247
- if ((menuOpened || draggingMenu) && !menuMounted) {
2248
- setMenuMounted(true);
2249
- } else if (!menuOpened && !draggingMenu && menuMounted) {
2250
- setMenuMounted(false);
2251
- }
2252
- }, [menuOpened, draggingMenu, menuMounted, setMenuMounted]);
2253
- return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
2254
- className: classNames([styles$6.menuNavContainer, _defineProperty(_defineProperty({}, styles$6.withShadow, withShadow), styles$6.isOpened, menuOpened || shareOpened)]),
2255
- ref: refDots,
2256
- style: {
2257
- width: menuWidth
2258
- }
2259
- }, /*#__PURE__*/React.createElement("nav", {
2260
- className: styles$6.menuTopContainer,
2261
- ref: navContainerRef
2262
- }, !withoutShareMenu || afterShareMenuButton !== null ? /*#__PURE__*/React.createElement("div", Object.assign({
2263
- className: styles$6.menuItem
2264
- }, bindShareDrag()), !withoutShareMenu ? /*#__PURE__*/React.createElement(ToggleButton$1, {
2265
- className: styles$6.slidingButton,
2266
- button: /*#__PURE__*/React.createElement(ShareButton$1, {
2267
- className: styles$6.menuButton,
2268
- onClick: onOpenShare,
2269
- theme: menuTheme,
2270
- iconPosition: "left",
2271
- focusable: !shareOpened
2272
- }),
2273
- toggledButton: /*#__PURE__*/React.createElement(FocusLock, {
2274
- group: "share",
2275
- disabled: !shareOpened,
2276
- returnFocus: true
2277
- }, /*#__PURE__*/React.createElement(CloseMenuButton$1, {
2278
- className: styles$6.menuButton,
2279
- onClick: onCloseShare,
2280
- theme: menuTheme,
2281
- iconPosition: "left",
2282
- focusable: shareOpened,
2283
- single: true
2284
- })),
2285
- progressSpring: shareOpenedProgress
2286
- }) : null, afterShareMenuButton) : null, !withoutScreensMenu || beforeScreensMenuButton !== null ? /*#__PURE__*/React.createElement("div", Object.assign({
2287
- className: styles$6.menuItem
2288
- }, bindMenuDrag()), beforeScreensMenuButton, !withoutScreensMenu ? /*#__PURE__*/React.createElement(ToggleButton$1, {
2289
- className: styles$6.slidingButton,
2290
- button: /*#__PURE__*/React.createElement(MenuButton$1, {
2291
- className: styles$6.menuButton,
2292
- iconClassName: styles$6.menuButtonIcon,
2293
- onClick: onOpenMenu,
2294
- theme: menuTheme,
2295
- focusable: !menuOpened
2296
- }),
2297
- toggledButton: /*#__PURE__*/React.createElement(FocusLock, {
2298
- group: "screens",
2299
- disabled: !menuOpened,
2300
- returnFocus: true
2301
- }, /*#__PURE__*/React.createElement(CloseMenuButton$1, {
2302
- className: styles$6.menuButton,
2303
- onClick: onCloseMenu,
2304
- theme: menuTheme,
2305
- iconPosition: "right",
2306
- focusable: menuOpened
2307
- })),
2308
- progressSpring: menuOpenedProgress,
2309
- toggledButtonClassName: styles$6.screensMenuButtonToggled
2310
- }) : null) : null), /*#__PURE__*/React.createElement(MenuDots, Object.assign({}, menuTheme, {
2311
- direction: "horizontal",
2312
- items: items,
2313
- onClickDot: onClickScreen,
2314
- onClickScreensMenu: onOpenMenu,
2315
- buttons: menuDotsButtons,
2316
- closeable: closeable,
2317
- withItemClick: withDotItemClick,
2318
- withoutScreensMenu: withoutScreensMenu,
2319
- withoutShareMenu: withoutShareMenu,
2320
- onClose: onClickCloseViewer,
2321
- className: styles$6.dots
2322
- }))), /*#__PURE__*/React.createElement(MenuContainer, {
2323
- className: styles$6.menuContainer,
2324
- progressSpring: shareOpenedProgress,
2325
- theme: viewerTheme
2326
- }, draggingShare || shareOpened ? /*#__PURE__*/React.createElement(FocusLock, {
2327
- group: "share",
2328
- disabled: !shareOpened,
2329
- returnFocus: true
2330
- }, /*#__PURE__*/React.createElement(MenuShare, {
2331
- viewerTheme: viewerTheme,
2332
- className: styles$6.menuShare,
2333
- title: title,
2334
- description: description,
2335
- menuWidth: menuWidth,
2336
- paddingTop: navContainerHeight,
2337
- focusable: shareOpened,
2338
- items: items,
2339
- currentScreenIndex: currentScreenIndex,
2340
- shareUrl: shareUrl,
2341
- onShare: onShare,
2342
- onClose: onCloseShare
2343
- })) : null), /*#__PURE__*/React.createElement(MenuContainer, {
2344
- className: styles$6.menuContainer,
2345
- progressSpring: menuOpenedProgress,
2346
- theme: viewerTheme
2347
- }, menuMounted ? /*#__PURE__*/React.createElement(FocusLock, {
2348
- group: "screens",
2349
- disabled: !menuOpened,
2350
- returnFocus: true
2351
- }, /*#__PURE__*/React.createElement(MenuPreview, {
2352
- viewerTheme: viewerTheme,
2353
- header: previewHeader,
2354
- footer: previewFooter,
2355
- title: title,
2356
- className: styles$6.menuPreview,
2357
- screenSize: screenSize,
2358
- menuWidth: menuWidth,
2359
- paddingTop: navContainerHeight,
2360
- items: items,
2361
- currentScreenIndex: currentScreenIndex,
2362
- shareUrl: shareUrl,
2363
- onShare: onShare,
2364
- onClickScreen: onClickScreen,
2365
- onClose: onCloseMenu,
2366
- scrollDisabled: draggingMenu,
2367
- toggleFullscreen: toggleFullscreen,
2368
- fullscreenActive: fullscreenActive,
2369
- fullscreenEnabled: fullscreenEnabled
2370
- })) : null));
2371
- };
2372
- ViewerMenu.propTypes = propTypes$9;
2373
- ViewerMenu.defaultProps = defaultProps$9;
2374
- var ViewerMenu$1 = /*#__PURE__*/React.memo(ViewerMenu);
2375
-
2376
- var styles$5 = {"container":"micromag-viewer-screen-container","inner":"micromag-viewer-screen-inner","navigationHint":"micromag-viewer-screen-navigationHint"};
2377
-
2378
- var propTypes$8 = {
2379
- screen: core.PropTypes.screenComponent,
2380
- renderContext: core.PropTypes.renderContext,
2381
- screenState: PropTypes.string,
2382
- current: PropTypes.bool,
2383
- active: PropTypes.bool,
2384
- mediaRef: PropTypes.func,
2385
- width: PropTypes.number,
2386
- index: PropTypes.number,
2387
- height: PropTypes.number,
2388
- scale: PropTypes.number,
2389
- // withNavigationHint: PropTypes.bool, // @todo
2390
- className: PropTypes.string
2391
- };
2392
- var defaultProps$8 = {
2393
- screen: null,
2394
- renderContext: null,
2395
- screenState: null,
2396
- current: false,
2397
- active: true,
2398
- index: null,
2399
- mediaRef: null,
2400
- width: null,
2401
- height: null,
2402
- scale: null,
2403
- // withNavigationHint: false,
2404
- className: null
2405
- };
2406
- function ViewerScreen(_ref) {
2407
- var screen = _ref.screen,
2408
- renderContext = _ref.renderContext,
2409
- index = _ref.index,
2410
- screenState = _ref.screenState,
2411
- active = _ref.active,
2412
- current = _ref.current,
2413
- mediaRef = _ref.mediaRef,
2414
- width = _ref.width,
2415
- height = _ref.height,
2416
- scale = _ref.scale,
2417
- className = _ref.className;
2418
- var _useState = React.useState(active || current),
2419
- _useState2 = _slicedToArray(_useState, 2),
2420
- mounted = _useState2[0],
2421
- setMounted = _useState2[1];
2422
- React.useEffect(function () {
2423
- var timeout = null;
2424
- if (active !== mounted) {
2425
- timeout = setTimeout(function () {
2426
- setMounted(active);
2427
- }, 200);
2428
- }
2429
- return function () {
2430
- if (timeout !== null) {
2431
- clearTimeout(timeout);
2432
- }
2433
- };
2434
- }, [active, mounted, setMounted, index]);
2435
- return /*#__PURE__*/React.createElement("div", {
2436
- className: classNames([styles$5.container, _defineProperty({}, className, className !== null)])
2437
- }, /*#__PURE__*/React.createElement("div", {
2438
- className: styles$5.inner,
2439
- style: {
2440
- width: width,
2441
- height: height,
2442
- transform: scale !== null ? "scale(".concat(scale, ")") : null,
2443
- transformOrigin: scale !== null ? '0 0' : null,
2444
- opacity: mounted ? 1 : null
2445
- }
2446
- }, mounted || current ? /*#__PURE__*/React.createElement(components.Screen, {
2447
- screen: screen,
2448
- renderContext: renderContext,
2449
- screenState: screenState,
2450
- index: index,
2451
- active: active,
2452
- current: current,
2453
- mediaRef: mediaRef
2454
- }) : null));
2455
- }
2456
- ViewerScreen.propTypes = propTypes$8;
2457
- ViewerScreen.defaultProps = defaultProps$8;
2458
-
2459
- var styles$4 = {"container":"micromag-viewer-buttons-navigation-button-container","arrow":"micromag-viewer-buttons-navigation-button-arrow","next":"micromag-viewer-buttons-navigation-button-next","previous":"micromag-viewer-buttons-navigation-button-previous"};
2460
-
2461
- var _excluded$3 = ["direction", "onClick", "className"];
2462
- var propTypes$7 = {
2463
- direction: PropTypes.oneOf(['previous', 'next']),
2464
- onClick: PropTypes.func,
2465
- className: PropTypes.string
2466
- };
2467
- var defaultProps$7 = {
2468
- direction: 'next',
2469
- onClick: null,
2470
- className: null
2471
- };
2472
- var NavigationButton = function NavigationButton(_ref) {
2473
- var direction = _ref.direction,
2474
- _onClick = _ref.onClick,
2475
- className = _ref.className,
2476
- props = _objectWithoutProperties(_ref, _excluded$3);
2477
- return /*#__PURE__*/React.createElement(IconButton$1, Object.assign({
2478
- className: classNames([styles$4.container, styles$4[direction], _defineProperty({}, className, className !== null)]),
2479
- onClick: function onClick(e) {
2480
- e.stopPropagation();
2481
- _onClick();
2482
- },
2483
- iconPosition: direction === 'next' ? 'right' : 'left',
2484
- icon: /*#__PURE__*/React.createElement("svg", {
2485
- className: styles$4.arrow,
2486
- xmlns: "http://www.w3.org/2000/svg",
2487
- width: "10",
2488
- height: "16",
2489
- viewBox: "0 0 10 16",
2490
- fill: "currentColor"
2491
- }, /*#__PURE__*/React.createElement("polygon", {
2492
- 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"
2493
- }))
2494
- }, props));
2495
- };
2496
- NavigationButton.propTypes = propTypes$7;
2497
- NavigationButton.defaultProps = defaultProps$7;
2498
- var NavigationButton$1 = NavigationButton;
2499
-
2500
- 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"};
2501
-
2502
- var propTypes$6 = {
2503
- className: PropTypes.string
2504
- };
2505
- var defaultProps$6 = {
2506
- className: null
2507
- };
2508
- var ArrowHint = function ArrowHint(_ref) {
2509
- var className = _ref.className;
2510
- return /*#__PURE__*/React.createElement("div", {
2511
- className: classNames([styles$3.container, _defineProperty({}, className, className !== null)])
2512
- }, /*#__PURE__*/React.createElement("div", {
2513
- className: styles$3.inner
2514
- }, /*#__PURE__*/React.createElement(components.ArrowIcon, {
2515
- className: styles$3.arrow
2516
- })));
2517
- };
2518
- ArrowHint.propTypes = propTypes$6;
2519
- ArrowHint.defaultProps = defaultProps$6;
2520
- var ArrowHint$1 = ArrowHint;
2521
-
2522
- var styles$2 = {"track":"micromag-viewer-partials-seek-bar-track","progress":"micromag-viewer-partials-seek-bar-progress","inner":"micromag-viewer-partials-seek-bar-inner","progressBarContainer":"micromag-viewer-partials-seek-bar-progressBarContainer","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"};
2523
-
2524
- var stopDragEventsPropagation = {
2525
- onTouchMove: function onTouchMove(e) {
2526
- return e.stopPropagation();
2527
- },
2528
- onTouchStart: function onTouchStart(e) {
2529
- return e.stopPropagation();
2530
- },
2531
- onTouchEnd: function onTouchEnd(e) {
2532
- return e.stopPropagation();
2533
- },
2534
- onPointerMove: function onPointerMove(e) {
2535
- return e.stopPropagation();
2536
- },
2537
- onPointerUp: function onPointerUp(e) {
2538
- return e.stopPropagation();
2539
- },
2540
- onPointerDown: function onPointerDown(e) {
2541
- return e.stopPropagation();
2542
- }
2543
- };
2544
- function getFormattedTimestamp() {
2545
- var secondsWithMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
2546
- if (secondsWithMs === null || secondsWithMs <= 0) {
2547
- return '00:00';
2548
- }
2549
- var parts = "".concat(secondsWithMs).split('.');
2550
- var _ref = parts || [],
2551
- _ref2 = _slicedToArray(_ref, 1),
2552
- _ref2$ = _ref2[0],
2553
- fullSeconds = _ref2$ === void 0 ? 0 : _ref2$;
2554
- var finalFullSeconds = Math.round(fullSeconds);
2555
- var seconds = finalFullSeconds % 60;
2556
- var diff = finalFullSeconds - seconds;
2557
- var minutes = diff > 0 ? diff / 60 : 0;
2558
- return "".concat(String(Math.round(minutes)).padStart(2, '0'), ":").concat(String(Math.round(seconds)).padStart(2, '0'));
2559
- }
2560
- var SHOW_MILLISECONDS_THRESHOLD = 5; // show milliseconds when scrubbing if length of video is shorter than 5 seconds
2561
-
2562
- var propTypes$5 = {
2563
- media: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
2564
- current: PropTypes.any
2565
- }) // eslint-disable-line
2566
- ]),
2567
- playing: PropTypes.bool,
2568
- backgroundColor: PropTypes.string,
2569
- progressColor: PropTypes.string,
2570
- onClick: PropTypes.func,
2571
- onSeek: PropTypes.func,
2572
- onSeekStart: PropTypes.func,
2573
- onSeekEnd: PropTypes.func,
2574
- collapsed: PropTypes.bool,
2575
- focusable: PropTypes.bool,
2576
- className: PropTypes.string,
2577
- withSeekHead: PropTypes.bool
2578
- };
2579
- var defaultProps$5 = {
2580
- media: null,
2581
- playing: false,
2582
- backgroundColor: null,
2583
- progressColor: null,
2584
- onClick: null,
2585
- onSeek: null,
2586
- onSeekStart: null,
2587
- onSeekEnd: null,
2588
- collapsed: false,
2589
- focusable: true,
2590
- className: null,
2591
- withSeekHead: true
2592
- };
2593
- var SeekBar = function SeekBar(_ref3) {
2594
- var media = _ref3.media,
2595
- playing = _ref3.playing,
2596
- backgroundColor = _ref3.backgroundColor,
2597
- progressColor = _ref3.progressColor,
2598
- onClick = _ref3.onClick,
2599
- onSeek = _ref3.onSeek,
2600
- onSeekStart = _ref3.onSeekStart,
2601
- onSeekEnd = _ref3.onSeekEnd,
2602
- collapsed = _ref3.collapsed,
2603
- focusable = _ref3.focusable,
2604
- className = _ref3.className,
2605
- withSeekHead = _ref3.withSeekHead;
2606
- var intl = reactIntl.useIntl();
2607
- var progress = hooks.useMediaProgress(media, {
2608
- disabled: !playing
2609
- });
2610
- var _ref4 = media || {},
2611
- _ref4$currentTime = _ref4.currentTime,
2612
- currentTime = _ref4$currentTime === void 0 ? null : _ref4$currentTime,
2613
- _ref4$duration = _ref4.duration,
2614
- duration = _ref4$duration === void 0 ? null : _ref4$duration;
2615
- var _useState = React.useState(false),
2616
- _useState2 = _slicedToArray(_useState, 2),
2617
- showTimestamp = _useState2[0],
2618
- setShowTimestamp = _useState2[1];
2619
- var startProgressRef = React.useRef(progress);
2620
- var onDrag = React.useCallback(
2621
- // eslint-disable-next-line no-unused-vars
2622
- function (_ref5) {
2623
- var _ref5$xy = _slicedToArray(_ref5.xy, 1),
2624
- xOffset = _ref5$xy[0],
2625
- _ref5$movement = _slicedToArray(_ref5.movement, 1);
2626
- _ref5$movement[0];
2627
- var elapsedTime = _ref5.elapsedTime,
2628
- active = _ref5.active,
2629
- tap = _ref5.tap,
2630
- currentTarget = _ref5.currentTarget;
2631
- if (!active && elapsedTime > 300) {
2632
- return;
2633
- }
2634
- if (collapsed) {
2635
- onClick();
2636
- return;
2637
- }
2638
- var _currentTarget$getBou = currentTarget.getBoundingClientRect(),
2639
- _currentTarget$getBou2 = _currentTarget$getBou.width,
2640
- elWidth = _currentTarget$getBou2 === void 0 ? 0 : _currentTarget$getBou2,
2641
- _currentTarget$getBou3 = _currentTarget$getBou.x,
2642
- xGap = _currentTarget$getBou3 === void 0 ? null : _currentTarget$getBou3;
2643
- var newProgress = null;
2644
- if (tap) {
2645
- newProgress = Math.max(0, Math.min(1, (xOffset - xGap) / elWidth));
2646
- } else {
2647
- // startProgressRef.current + xMovement
2648
- newProgress = Math.max(0, Math.min(1, (xOffset - xGap) / elWidth));
2649
- }
2650
- if (onSeek !== null) {
2651
- onSeek(newProgress, tap);
2652
- }
2653
- }, [onSeek, onClick, collapsed]);
2654
- var onDragStart = React.useCallback(function () {
2655
- startProgressRef.current = progress;
2656
- setShowTimestamp(true);
2657
- if (onSeekStart !== null) {
2658
- onSeekStart();
2659
- }
2660
- }, [progress, onSeekStart, setShowTimestamp]);
2661
- var onDragEnd = React.useCallback(function () {
2662
- if (onSeekEnd !== null) {
2663
- setShowTimestamp(false);
2664
- onSeekEnd();
2665
- }
2666
- }, [onSeekEnd, setShowTimestamp]);
2667
- var bind = react.useGesture({
2668
- onDrag: onDrag,
2669
- onDragStart: onDragStart,
2670
- onDragEnd: onDragEnd
2671
- }, {
2672
- drag: {
2673
- axis: 'x',
2674
- filterTaps: true
2675
- }
2676
- });
2677
- return /*#__PURE__*/React.createElement("div", Object.assign({
2678
- className: classNames([styles$2.container, _defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles$2.withSeekHead, withSeekHead), styles$2.showTimestamp, showTimestamp)])
2679
- }, stopDragEventsPropagation), /*#__PURE__*/React.createElement("div", {
2680
- className: styles$2.inner
2681
- }, /*#__PURE__*/React.createElement("div", {
2682
- className: styles$2.progressBarContainer
2683
- }, /*#__PURE__*/React.createElement("div", {
2684
- className: styles$2.progressBar,
2685
- style: {
2686
- backgroundColor: backgroundColor
2687
- }
2688
- }), /*#__PURE__*/React.createElement("div", {
2689
- className: styles$2.playHead,
2690
- style: {
2691
- left: "".concat(progress * 100, "%"),
2692
- backgroundColor: progressColor
2693
- }
2694
- }, /*#__PURE__*/React.createElement("div", {
2695
- className: styles$2.scrubbedTime,
2696
- style: {
2697
- borderColor: progressColor
2698
- }
2699
- }, getFormattedTimestamp(currentTime, duration < SHOW_MILLISECONDS_THRESHOLD))), /*#__PURE__*/React.createElement("div", {
2700
- className: styles$2.progress,
2701
- style: {
2702
- transform: "scaleX(".concat(progress, ")"),
2703
- backgroundColor: progressColor
2704
- }
2705
- })), /*#__PURE__*/React.createElement("button", Object.assign({}, bind(), {
2706
- type: "button",
2707
- role: "slider",
2708
- "aria-valuemin": 0,
2709
- "aria-valuemax": 100,
2710
- "aria-valuenow": progress,
2711
- "aria-valuetext": intl.formatMessage({
2712
- id: "C1VUEY",
2713
- defaultMessage: [{
2714
- "type": 1,
2715
- "value": "current"
2716
- }, {
2717
- "type": 0,
2718
- "value": " of "
2719
- }, {
2720
- "type": 1,
2721
- "value": "duration"
2722
- }]
2723
- }, {
2724
- current: getFormattedTimestamp(currentTime, duration < SHOW_MILLISECONDS_THRESHOLD),
2725
- duration: getFormattedTimestamp(duration, duration < SHOW_MILLISECONDS_THRESHOLD)
2726
- }),
2727
- "data-draggable": true,
2728
- className: styles$2.track,
2729
- title: intl.formatMessage({
2730
- id: "G1Gyjn",
2731
- defaultMessage: [{
2732
- "type": 0,
2733
- "value": "Seek"
2734
- }]
2735
- }),
2736
- "aria-label": intl.formatMessage({
2737
- id: "2prwZ7",
2738
- defaultMessage: [{
2739
- "type": 0,
2740
- "value": "Progress slider"
2741
- }]
2742
- }),
2743
- tabIndex: focusable ? '0' : '-1'
2744
- }))));
2745
- };
2746
- SeekBar.propTypes = propTypes$5;
2747
- SeekBar.defaultProps = defaultProps$5;
2748
- var SeekBar$1 = SeekBar;
2749
-
2750
- var styles$1 = {"suggest":"micromag-viewer-partials-playback-controls-suggest","playPauseButton":"micromag-viewer-partials-playback-controls-playPauseButton","muteButton":"micromag-viewer-partials-playback-controls-muteButton","container":"micromag-viewer-partials-playback-controls-container","icon":"micromag-viewer-partials-playback-controls-icon","offset":"micromag-viewer-partials-playback-controls-offset","spinner":"micromag-viewer-partials-playback-controls-spinner","withPlayPause":"micromag-viewer-partials-playback-controls-withPlayPause","withSuggestPlay":"micromag-viewer-partials-playback-controls-withSuggestPlay","isCollapsed":"micromag-viewer-partials-playback-controls-isCollapsed","loading":"micromag-viewer-partials-playback-controls-loading","hidden":"micromag-viewer-partials-playback-controls-hidden","notPlaying":"micromag-viewer-partials-playback-controls-notPlaying","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"};
2751
-
2752
- var propTypes$4 = {
2753
- defaultColor: PropTypes.shape({
2754
- color: PropTypes.string,
2755
- alpha: PropTypes.number
2756
- }),
2757
- defaultProgressColor: PropTypes.shape({
2758
- color: PropTypes.string,
2759
- alpha: PropTypes.number
2760
- }),
2761
- withLoading: PropTypes.bool,
2762
- className: PropTypes.string,
2763
- collapsedClassName: PropTypes.string
2764
- };
2765
- var defaultProps$4 = {
2766
- defaultColor: {
2767
- color: '#FFFFFF',
2768
- alpha: 1
2769
- },
2770
- defaultProgressColor: {
2771
- color: '#666',
2772
- alpha: 1
2773
- },
2774
- withLoading: true,
2775
- className: null,
2776
- collapsedClassName: null
2777
- };
2778
- function PlaybackControls(_ref) {
2779
- var defaultColor = _ref.defaultColor,
2780
- defaultProgressColor = _ref.defaultProgressColor,
2781
- withLoading = _ref.withLoading,
2782
- className = _ref.className,
2783
- collapsedClassName = _ref.collapsedClassName;
2784
- var intl = reactIntl.useIntl();
2785
- var _usePlaybackContext = contexts.usePlaybackContext(),
2786
- _usePlaybackContext$m = _usePlaybackContext.media,
2787
- mediaElement = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m,
2788
- _usePlaybackContext$h = _usePlaybackContext.hasAudio,
2789
- hasAudio = _usePlaybackContext$h === void 0 ? null : _usePlaybackContext$h,
2790
- _usePlaybackContext$p = _usePlaybackContext.playing,
2791
- wantedPlaying = _usePlaybackContext$p === void 0 ? false : _usePlaybackContext$p,
2792
- _usePlaybackContext$m2 = _usePlaybackContext.muted,
2793
- wantedMuted = _usePlaybackContext$m2 === void 0 ? true : _usePlaybackContext$m2,
2794
- setPlaying = _usePlaybackContext.setPlaying,
2795
- setMuted = _usePlaybackContext.setMuted,
2796
- controls = _usePlaybackContext.controls,
2797
- controlsSuggestPlay = _usePlaybackContext.controlsSuggestPlay,
2798
- controlsVisible = _usePlaybackContext.controlsVisible,
2799
- controlsTheme = _usePlaybackContext.controlsTheme,
2800
- showControls = _usePlaybackContext.showControls;
2801
- var _useState = React.useState(false),
2802
- _useState2 = _slicedToArray(_useState, 2),
2803
- showLoading = _useState2[0],
2804
- setShowLoading = _useState2[1];
2805
- var mediaUrl = mediaElement !== null ? mediaElement.src : null;
2806
- var mediaReady = hooks.useMediaReady(mediaElement, {
2807
- id: mediaUrl
2808
- });
2809
- var ready = mediaElement === null || mediaReady;
2810
- var finalShowLoading = showLoading && !ready;
2811
- var _useMediaState = hooks.useMediaState(mediaElement, {
2812
- playing: wantedPlaying,
2813
- muted: wantedMuted
2814
- }),
2815
- buffering = _useMediaState.buffering,
2816
- playing = _useMediaState.playing,
2817
- muted = _useMediaState.muted;
2818
-
2819
- // console.log(controlsVisible);
2820
-
2821
- React.useEffect(function () {
2822
- var id = null;
2823
- setShowLoading(false);
2824
- if ((!ready || buffering) && withLoading) {
2825
- id = setTimeout(function () {
2826
- setShowLoading(true);
2827
- }, 1000);
2828
- }
2829
- return function () {
2830
- setShowLoading(false);
2831
- clearTimeout(id);
2832
- };
2833
- }, [ready, buffering, withLoading, setShowLoading]);
2834
- var _useState3 = React.useState({
2835
- color: utils.getColorAsString(defaultColor),
2836
- progressColor: utils.getColorAsString(defaultColor),
2837
- seekBarOnly: false
2838
- }),
2839
- _useState4 = _slicedToArray(_useState3, 2),
2840
- customControlsTheme = _useState4[0],
2841
- setCustomControlsTheme = _useState4[1];
2842
- var _useState5 = React.useState(false),
2843
- _useState6 = _slicedToArray(_useState5, 2),
2844
- wasPlaying = _useState6[0],
2845
- setWasPlaying = _useState6[1];
2846
- React.useEffect(function () {
2847
- var _ref2 = controlsTheme || {},
2848
- color = _ref2.color,
2849
- progressColor = _ref2.progressColor,
2850
- seekBarOnly = _ref2.seekBarOnly;
2851
- setCustomControlsTheme({
2852
- color: utils.getColorAsString(color || defaultColor),
2853
- progressColor: utils.getColorAsString(progressColor || defaultProgressColor),
2854
- seekBarOnly: seekBarOnly
2855
- });
2856
- }, [controlsTheme, setCustomControlsTheme, defaultColor, defaultProgressColor]);
2857
- var onPlay = React.useCallback(function () {
2858
- setPlaying(true);
2859
- if (!controlsVisible && controls) {
2860
- showControls();
2861
- }
2862
- }, [setPlaying, controlsVisible, showControls]);
2863
- var onPause = React.useCallback(function () {
2864
- setPlaying(false);
2865
- if (!controlsVisible && controls) {
2866
- showControls();
2867
- }
2868
- }, [setPlaying, controlsVisible, controls, showControls]);
2869
- var onMute = React.useCallback(function () {
2870
- setMuted(true);
2871
- if (!controlsVisible && controls) {
2872
- showControls();
2873
- }
2874
- }, [setMuted, controlsVisible, showControls]);
2875
- var onUnmute = React.useCallback(function () {
2876
- setMuted(false);
2877
- if (!controlsVisible && controls) {
2878
- showControls();
2879
- }
2880
- }, [setMuted, controlsVisible, showControls]);
2881
- var onSeekStart = React.useCallback(function () {
2882
- setWasPlaying(playing);
2883
- if (playing) {
2884
- setPlaying(false);
2885
- }
2886
- }, [playing, setWasPlaying, setPlaying]);
2887
- var onSeek = React.useCallback(
2888
- // eslint-disable-next-line no-unused-vars
2889
- function (progress) {
2890
- if (mediaElement !== null) {
2891
- mediaElement.currentTime = progress * mediaElement.duration;
2892
- }
2893
- if (!controlsVisible && controls) {
2894
- showControls();
2895
- }
2896
- }, [mediaElement, controlsVisible, controls, showControls]);
2897
- var onSeekEnd = React.useCallback(function () {
2898
- if (wasPlaying) {
2899
- setPlaying(true);
2900
- }
2901
- }, [setPlaying, wasPlaying]);
2902
- var onSeekClick = React.useCallback(function () {
2903
- if (!controlsVisible && controls) {
2904
- showControls();
2905
- }
2906
- }, [controlsVisible, controls, showControls]);
2907
- var hasMedia = mediaElement !== null;
2908
- var mediaHasAudio = hasMedia && (hasAudio === null || hasAudio === true);
2909
- var _ref3 = customControlsTheme || {},
2910
- color = _ref3.color,
2911
- progressColor = _ref3.progressColor,
2912
- seekBarOnly = _ref3.seekBarOnly;
2913
- var isCollapsed = controls && !controlsVisible && playing || !controls && mediaHasAudio;
2914
- var playIcon = playing ? /*#__PURE__*/React.createElement(components.PauseIcon, {
2915
- className: styles$1.icon
2916
- }) : /*#__PURE__*/React.createElement(components.PlayIcon, {
2917
- className: styles$1.icon
2918
- });
2919
- return /*#__PURE__*/React.createElement("div", {
2920
- className: classNames([styles$1.container, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, className, className !== null), styles$1.withPlayPause, controlsVisible && controls && (!seekBarOnly || !playing)), styles$1.withSuggestPlay, controlsSuggestPlay), styles$1.withMute, hasMedia || controls), styles$1.withSeekBar, controls), styles$1.withSeekBarOnly, seekBarOnly), styles$1.isCollapsed, isCollapsed), styles$1.isMuted, muted), collapsedClassName, collapsedClassName !== null && isCollapsed)])
2921
- }, controlsSuggestPlay && !finalShowLoading ? /*#__PURE__*/React.createElement(components.Button, {
2922
- className: classNames([styles$1.suggest]),
2923
- style: {
2924
- color: color
2925
- },
2926
- onClick: playing ? onPause : onPlay,
2927
- focusable: controlsVisible,
2928
- icon: /*#__PURE__*/React.createElement(components.PlayIcon, {
2929
- className: classNames([styles$1.icon, styles$1.offset])
2930
- }),
2931
- "aria-pressed": !playing,
2932
- "aria-label": intl.formatMessage({
2933
- id: "mTqcmA",
2934
- defaultMessage: [{
2935
- "type": 0,
2936
- "value": "Pause"
2937
- }]
2938
- }),
2939
- withoutBootstrapStyles: true
2940
- }) : null, /*#__PURE__*/React.createElement(components.Button, {
2941
- className: classNames([styles$1.playPauseButton, _defineProperty(_defineProperty({}, styles$1.hidden, !controlsVisible || controlsSuggestPlay && !controls), styles$1.loading, finalShowLoading)]),
2942
- style: {
2943
- color: color
2944
- },
2945
- onClick: playing ? onPause : onPlay,
2946
- focusable: controls && controlsVisible && (!seekBarOnly || !playing),
2947
- disabled: finalShowLoading,
2948
- icon: finalShowLoading ? /*#__PURE__*/React.createElement(components.Spinner, {
2949
- className: classNames([styles$1.spinner, styles$1.offset])
2950
- }) : playIcon,
2951
- "aria-pressed": !playing,
2952
- "aria-label": finalShowLoading ? intl.formatMessage({
2953
- id: "YyYrXp",
2954
- defaultMessage: [{
2955
- "type": 0,
2956
- "value": "Loading"
2957
- }]
2958
- }) : intl.formatMessage({
2959
- id: "mTqcmA",
2960
- defaultMessage: [{
2961
- "type": 0,
2962
- "value": "Pause"
2963
- }]
2964
- }),
2965
- withoutBootstrapStyles: true
2966
- }), /*#__PURE__*/React.createElement(SeekBar$1, {
2967
- className: styles$1.seekBar,
2968
- media: mediaElement,
2969
- playing: playing,
2970
- onClick: onSeekClick,
2971
- onSeek: onSeek,
2972
- onSeekStart: onSeekStart,
2973
- onSeekEnd: onSeekEnd,
2974
- focusable: controls && controlsVisible && !seekBarOnly,
2975
- collapsed: isCollapsed,
2976
- withSeekHead: !isCollapsed && !seekBarOnly,
2977
- backgroundColor: color,
2978
- progressColor: progressColor
2979
- }), /*#__PURE__*/React.createElement(components.Button, {
2980
- className: styles$1.muteButton,
2981
- style: {
2982
- color: color
2983
- },
2984
- onClick: muted ? onUnmute : onMute,
2985
- focusable: controlsVisible || mediaHasAudio,
2986
- icon: muted ? /*#__PURE__*/React.createElement(components.UnmuteIcon, {
2987
- className: styles$1.icon
2988
- }) : /*#__PURE__*/React.createElement(components.MuteIcon, {
2989
- className: styles$1.icon
2990
- }),
2991
- "aria-pressed": !muted,
2992
- "aria-label": intl.formatMessage({
2993
- id: "RK/QEY",
2994
- defaultMessage: [{
2995
- "type": 0,
2996
- "value": "Unmute"
2997
- }]
2998
- }),
2999
- withoutBootstrapStyles: true
3000
- }));
3001
- }
3002
- PlaybackControls.propTypes = propTypes$4;
3003
- PlaybackControls.defaultProps = defaultProps$4;
3004
-
3005
- var styles = {"container":"micromag-viewer-partials-web-view-container","focusLock":"micromag-viewer-partials-web-view-focusLock","opened":"micromag-viewer-partials-web-view-opened"};
3006
-
3007
- var _excluded$2 = ["opened", "close", "open", "update", "url"];
3008
- var propTypes$3 = {
3009
- onChange: PropTypes.func,
3010
- className: PropTypes.string,
3011
- style: PropTypes.object
3012
- };
3013
- var defaultProps$3 = {
3014
- onChange: null,
3015
- className: null,
3016
- style: null
3017
- };
3018
- function WebViewContainer(_ref) {
3019
- var onChange = _ref.onChange,
3020
- className = _ref.className,
3021
- style = _ref.style;
3022
- var _useViewerWebView = contexts.useViewerWebView(),
3023
- opened = _useViewerWebView.opened,
3024
- close = _useViewerWebView.close;
3025
- _useViewerWebView.open;
3026
- _useViewerWebView.update;
3027
- var _useViewerWebView$url = _useViewerWebView.url,
3028
- url = _useViewerWebView$url === void 0 ? null : _useViewerWebView$url,
3029
- webViewProps = _objectWithoutProperties(_useViewerWebView, _excluded$2);
3030
- var _useViewerInteraction = contexts.useViewerInteraction(),
3031
- disableInteraction = _useViewerInteraction.disableInteraction,
3032
- enableInteraction = _useViewerInteraction.enableInteraction;
3033
- var _usePlaybackContext = contexts.usePlaybackContext(),
3034
- playing = _usePlaybackContext.playing,
3035
- setPlaying = _usePlaybackContext.setPlaying,
3036
- hideControls = _usePlaybackContext.hideControls,
3037
- showControls = _usePlaybackContext.showControls;
3038
- var wasPlayingRef = React.useRef(playing);
3039
- var _useState = React.useState(url),
3040
- _useState2 = _slicedToArray(_useState, 2),
3041
- currentUrl = _useState2[0],
3042
- setCurrentUrl = _useState2[1];
3043
- var ref = React.useRef(null);
3044
-
3045
- // Handle current webview url
3046
- React.useEffect(function () {
3047
- if (url !== null) {
3048
- setCurrentUrl(url);
3049
- }
3050
- }, [url, setCurrentUrl]);
3051
- var onTransitionEnd = React.useCallback(function () {
3052
- if (url === null) {
3053
- setCurrentUrl(null);
3054
- }
3055
- if (onChange !== null) {
3056
- onChange(opened);
3057
- }
3058
- }, [url, setCurrentUrl, onChange]);
3059
-
3060
- // Disable interaction and pause playback
3061
- React.useEffect(function () {
3062
- if (opened) {
3063
- disableInteraction();
3064
- hideControls();
3065
- wasPlayingRef.current = playing;
3066
- if (playing) {
3067
- setPlaying(false);
3068
- }
3069
- } else {
3070
- enableInteraction();
3071
- showControls();
3072
- if (wasPlayingRef.current && !playing) {
3073
- wasPlayingRef.current = false;
3074
- setPlaying(true);
3075
- }
3076
- }
3077
- }, [opened]);
3078
- var keyboardShortcuts = React.useMemo(function () {
3079
- return {
3080
- escape: function escape() {
3081
- close();
3082
- }
3083
- };
3084
- }, [close]);
3085
- useKeyboardShortcuts(keyboardShortcuts);
3086
- return /*#__PURE__*/React.createElement("div", {
3087
- className: classNames([styles.container, _defineProperty(_defineProperty({}, styles.opened, opened), className, className !== null)]),
3088
- style: style,
3089
- onTransitionEnd: onTransitionEnd,
3090
- ref: ref
3091
- }, /*#__PURE__*/React.createElement(WebView, Object.assign({
3092
- url: url || currentUrl
3093
- }, webViewProps, {
3094
- closeable: opened,
3095
- focusable: opened,
3096
- className: styles.webView,
3097
- onClose: close
3098
- })));
3099
- }
3100
- WebViewContainer.propTypes = propTypes$3;
3101
- WebViewContainer.defaultProps = defaultProps$3;
3102
-
3103
- // @todo export from somewhere else; or use as props in possible component for screen transitions
3104
- var SPRING_CONFIG_TIGHT = {
3105
- tension: 300,
3106
- friction: 35
3107
- }; // tight
3108
- var DRAG_PROGRESS_ACTIVATION_THRESHOLD = 0.3;
3109
- var DRAG_VELOCITY_ACTIVATION_THRESHOLD = 0.3;
3110
- var DEFAULT_TRANSITION_TYPE_LANDSCAPE = 'carousel';
3111
- var DEFAULT_TRANSITION_TYPE_PORTRAIT = 'stack';
3112
- var SHARE_INCENTIVE_TIMEOUT = 6000;
3113
- var propTypes$2 = {
3114
- story: core.PropTypes.story,
3115
- // .isRequired,
3116
- basePath: PropTypes.string,
3117
- theme: core.PropTypes.viewerTheme,
3118
- width: PropTypes.number,
3119
- height: PropTypes.number,
3120
- screen: PropTypes.string,
3121
- screenState: PropTypes.string,
3122
- deviceScreens: core.PropTypes.deviceScreens,
3123
- renderContext: core.PropTypes.renderContext,
3124
- onScreenChange: PropTypes.func,
3125
- tapNextScreenWidthPercent: PropTypes.number,
3126
- storyIsParsed: PropTypes.bool,
3127
- neighborScreensActive: PropTypes.number,
3128
- neighborScreenOffset: PropTypes.number,
3129
- neighborScreenScale: PropTypes.number,
3130
- topSafezoneHeight: PropTypes.number,
3131
- bottomSafezoneHeight: PropTypes.number,
3132
- menuDotsButtons: PropTypes.node,
3133
- menuIsScreenWidth: PropTypes.bool,
3134
- menuHeader: PropTypes.node,
3135
- menuFooter: PropTypes.node,
3136
- shareBasePath: PropTypes.string,
3137
- afterShareMenuButton: PropTypes.node,
3138
- beforeScreensMenuButton: PropTypes.node,
3139
- closeable: PropTypes.bool,
3140
- withMetadata: PropTypes.bool,
3141
- withoutGestures: PropTypes.bool,
3142
- withoutMenu: PropTypes.bool,
3143
- withoutScreensMenu: PropTypes.bool,
3144
- withoutShareMenu: PropTypes.bool,
3145
- withoutMenuShadow: PropTypes.bool,
3146
- withoutFullscreen: PropTypes.bool,
3147
- withoutNavigationArrow: PropTypes.bool,
3148
- withoutTransitions: PropTypes.bool,
3149
- withNeighborScreens: PropTypes.bool,
3150
- withNavigationHint: PropTypes.bool,
3151
- withoutPlaybackControls: PropTypes.bool,
3152
- onClose: PropTypes.func,
3153
- onInteraction: PropTypes.func,
3154
- onEnd: PropTypes.func,
3155
- onViewModeChange: PropTypes.func,
3156
- onMenuChange: PropTypes.func,
3157
- currentScreenMedia: core.PropTypes.ref,
3158
- screensMedias: core.PropTypes.ref,
3159
- screenSizeOptions: PropTypes.shape({
3160
- withoutMaxSize: PropTypes.bool,
3161
- desktopHeightRatio: PropTypes.number,
3162
- screenRatio: PropTypes.number
3163
- }),
3164
- className: PropTypes.string
3165
- };
3166
- var defaultProps$2 = {
3167
- story: null,
3168
- theme: null,
3169
- basePath: null,
3170
- width: null,
3171
- height: null,
3172
- screen: null,
3173
- screenState: null,
3174
- deviceScreens: utils.getDeviceScreens(),
3175
- renderContext: 'view',
3176
- onScreenChange: null,
3177
- tapNextScreenWidthPercent: 0.8,
3178
- storyIsParsed: false,
3179
- neighborScreensActive: 1,
3180
- neighborScreenOffset: 105,
3181
- neighborScreenScale: 0.8,
3182
- topSafezoneHeight: null,
3183
- bottomSafezoneHeight: null,
3184
- menuIsScreenWidth: false,
3185
- menuHeader: null,
3186
- menuFooter: null,
3187
- shareBasePath: null,
3188
- afterShareMenuButton: null,
3189
- beforeScreensMenuButton: null,
3190
- menuDotsButtons: null,
3191
- closeable: false,
3192
- withMetadata: false,
3193
- withNeighborScreens: false,
3194
- withNavigationHint: false,
3195
- withoutGestures: false,
3196
- withoutMenu: false,
3197
- withoutScreensMenu: false,
3198
- withoutShareMenu: false,
3199
- withoutMenuShadow: false,
3200
- withoutFullscreen: false,
3201
- withoutTransitions: false,
3202
- withoutNavigationArrow: false,
3203
- withoutPlaybackControls: false,
3204
- onClose: null,
3205
- onInteraction: null,
3206
- onEnd: null,
3207
- onViewModeChange: null,
3208
- onMenuChange: null,
3209
- currentScreenMedia: null,
3210
- screensMedias: null,
3211
- screenSizeOptions: null,
3212
- className: null
3213
- };
3214
- var Viewer = function Viewer(_ref) {
3215
- var story = _ref.story,
3216
- basePath = _ref.basePath,
3217
- viewerTheme = _ref.theme,
3218
- width = _ref.width,
3219
- height = _ref.height,
3220
- screenId = _ref.screen,
3221
- screenState = _ref.screenState,
3222
- deviceScreens = _ref.deviceScreens,
3223
- renderContext = _ref.renderContext,
3224
- tapNextScreenWidthPercent = _ref.tapNextScreenWidthPercent,
3225
- storyIsParsed = _ref.storyIsParsed,
3226
- neighborScreensActive = _ref.neighborScreensActive,
3227
- neighborScreenOffset = _ref.neighborScreenOffset,
3228
- neighborScreenScale = _ref.neighborScreenScale,
3229
- topSafezoneHeight = _ref.topSafezoneHeight,
3230
- bottomSafezoneHeight = _ref.bottomSafezoneHeight,
3231
- menuIsScreenWidth = _ref.menuIsScreenWidth,
3232
- menuHeader = _ref.menuHeader,
3233
- menuDotsButtons = _ref.menuDotsButtons,
3234
- menuFooter = _ref.menuFooter,
3235
- shareBasePath = _ref.shareBasePath,
3236
- afterShareMenuButton = _ref.afterShareMenuButton,
3237
- beforeScreensMenuButton = _ref.beforeScreensMenuButton,
3238
- closeable = _ref.closeable,
3239
- withMetadata = _ref.withMetadata,
3240
- withoutGestures = _ref.withoutGestures,
3241
- withoutMenu = _ref.withoutMenu,
3242
- withoutScreensMenu = _ref.withoutScreensMenu,
3243
- withoutShareMenu = _ref.withoutShareMenu,
3244
- withoutMenuShadow = _ref.withoutMenuShadow;
3245
- _ref.withoutFullscreen;
3246
- var withoutNavigationArrow = _ref.withoutNavigationArrow,
3247
- withoutTransitions = _ref.withoutTransitions,
3248
- withNeighborScreens = _ref.withNeighborScreens,
3249
- withNavigationHint = _ref.withNavigationHint,
3250
- withoutPlaybackControls = _ref.withoutPlaybackControls,
3251
- onCloseViewer = _ref.onClose,
3252
- onInteraction = _ref.onInteraction,
3253
- onEnd = _ref.onEnd,
3254
- onScreenChange = _ref.onScreenChange,
3255
- onViewModeChange = _ref.onViewModeChange,
3256
- onMenuChange = _ref.onMenuChange,
3257
- currentScreenMedia = _ref.currentScreenMedia,
3258
- screensMedias = _ref.screensMedias,
3259
- screenSizeOptions = _ref.screenSizeOptions,
3260
- className = _ref.className;
3261
- var intl = reactIntl.useIntl();
3262
- /**
3263
- * Screen Data + Processing
3264
- */
3265
- var parsedStory = hooks.useParsedStory(story, {
3266
- disabled: storyIsParsed
3267
- }) || {};
3268
- var _parsedStory$componen = parsedStory.components,
3269
- screens = _parsedStory$componen === void 0 ? [] : _parsedStory$componen,
3270
- _parsedStory$title = parsedStory.title,
3271
- title = _parsedStory$title === void 0 ? null : _parsedStory$title,
3272
- _parsedStory$metadata = parsedStory.metadata,
3273
- metadata = _parsedStory$metadata === void 0 ? null : _parsedStory$metadata,
3274
- _parsedStory$fonts = parsedStory.fonts,
3275
- fonts = _parsedStory$fonts === void 0 ? null : _parsedStory$fonts;
3276
- var screensCount = screens.length;
3277
- var eventsManager = React.useMemo(function () {
3278
- return new EventEmitter();
3279
- }, [parsedStory]);
3280
- var screenIndex = React.useMemo(function () {
3281
- return Math.max(0, screens.findIndex(function (it) {
3282
- return "".concat(it.id) === "".concat(screenId);
3283
- }));
3284
- }, [screenId, screens]);
3285
- var currentScreen = screens[screenIndex] || null;
3286
- var _ref2 = currentScreen || {},
3287
- screenParameters = _ref2.parameters;
3288
- var _ref3 = screenParameters || {},
3289
- screenMetadata = _ref3.metadata;
3290
- var _ref4 = screenMetadata || {},
3291
- _ref4$title = _ref4.title,
3292
- screenTitle = _ref4$title === void 0 ? null : _ref4$title,
3293
- _ref4$description = _ref4.description,
3294
- screenDescription = _ref4$description === void 0 ? null : _ref4$description;
3295
- var finalTitle = screenTitle !== null ? screenTitle : title;
3296
- var finalMetadata = React.useMemo(function () {
3297
- return screenDescription !== null ? _objectSpread(_objectSpread({}, metadata), {}, {
3298
- description: screenDescription
3299
- }) : metadata;
3300
- }, [metadata, screenDescription]);
3301
- var screensMediasRef = React.useRef([]);
3302
- if (currentScreenMedia !== null) {
3303
- currentScreenMedia.current = screensMediasRef.current[screenIndex] || null;
3304
- }
3305
- if (screensMedias !== null) {
3306
- screensMedias.current = screensMediasRef.current;
3307
- }
3308
-
3309
- /**
3310
- * Screen Layout
3311
- */
3312
- var _ref5 = viewerTheme || {},
3313
- textStyles = _ref5.textStyles,
3314
- colors = _ref5.colors;
3315
- var _ref6 = colors || {},
3316
- _ref6$primary = _ref6.primary,
3317
- primaryColor = _ref6$primary === void 0 ? null : _ref6$primary,
3318
- _ref6$focus = _ref6.focus,
3319
- focusColor = _ref6$focus === void 0 ? null : _ref6$focus;
3320
- var finalFocusColor = utils.getColorAsString(focusColor || primaryColor);
3321
- var _ref7 = textStyles || {},
3322
- _ref7$title = _ref7.title,
3323
- themeTextStyle = _ref7$title === void 0 ? null : _ref7$title;
3324
- var _ref8 = themeTextStyle || {},
3325
- _ref8$fontFamily = _ref8.fontFamily,
3326
- themeFont = _ref8$fontFamily === void 0 ? null : _ref8$fontFamily;
3327
-
3328
- // Fonts
3329
- var finalFonts = React.useMemo(function () {
3330
- return [].concat(_toConsumableArray(fonts || []), [themeFont]).filter(function (font) {
3331
- return font !== null;
3332
- });
3333
- }, [fonts]);
3334
- var _useLoadedFonts = hooks.useLoadedFonts(finalFonts);
3335
- _useLoadedFonts.loaded; // eslint-disable-line
3336
-
3337
- var isView = renderContext === 'view';
3338
- var isStatic = renderContext === 'static';
3339
- var isCapture = renderContext === 'capture';
3340
- var isEditor = renderContext === 'edit';
3341
- var withoutScreensTransforms = isStatic || isCapture;
3342
- var _usePlaybackContext = contexts.usePlaybackContext(),
3343
- playing = _usePlaybackContext.playing;
3344
- _usePlaybackContext.setControls;
3345
- var _usePlaybackContext$c = _usePlaybackContext.controls,
3346
- playbackControls = _usePlaybackContext$c === void 0 ? false : _usePlaybackContext$c,
3347
- _usePlaybackContext$c2 = _usePlaybackContext.controlsVisible,
3348
- playbackcontrolsVisible = _usePlaybackContext$c2 === void 0 ? false : _usePlaybackContext$c2,
3349
- _usePlaybackContext$m = _usePlaybackContext.media,
3350
- playbackMedia = _usePlaybackContext$m === void 0 ? null : _usePlaybackContext$m;
3351
- var _useDimensionObserver = hooks.useDimensionObserver(),
3352
- playbackControlsContainerRef = _useDimensionObserver.ref,
3353
- _useDimensionObserver2 = _useDimensionObserver.height,
3354
- playbackControlsContainerHeight = _useDimensionObserver2 === void 0 ? 0 : _useDimensionObserver2;
3355
- var trackScreenView = hooks.useTrackScreenView();
3356
- var _useScreenSizeFromEle = hooks.useScreenSizeFromElement(_objectSpread({
3357
- width: width,
3358
- height: height,
3359
- screens: deviceScreens
3360
- }, screenSizeOptions)),
3361
- containerRef = _useScreenSizeFromEle.ref,
3362
- viewerWidth = _useScreenSizeFromEle.fullWidth,
3363
- viewerHeight = _useScreenSizeFromEle.fullHeight,
3364
- screenSize = _useScreenSizeFromEle.screenSize,
3365
- screenScale = _useScreenSizeFromEle.scale;
3366
- var _ref9 = screenSize || {},
3367
- _ref9$width = _ref9.width,
3368
- screenWidth = _ref9$width === void 0 ? null : _ref9$width,
3369
- _ref9$height = _ref9.height,
3370
- screenHeight = _ref9$height === void 0 ? null : _ref9$height,
3371
- _ref9$landscape = _ref9.landscape,
3372
- landscape = _ref9$landscape === void 0 ? false : _ref9$landscape,
3373
- _ref9$menuOverScreen = _ref9.menuOverScreen,
3374
- menuOverScreen = _ref9$menuOverScreen === void 0 ? false : _ref9$menuOverScreen;
3375
- var screenContainerWidth = screenScale !== null ? screenWidth * screenScale : screenWidth;
3376
- var screenContainerHeight = screenScale !== null ? screenHeight * screenScale : screenHeight;
3377
- var hasSize = screenWidth > 0 && screenHeight > 0;
3378
- var ready = hasSize;
3379
- var trackingEnabled = isView;
3380
- React.useEffect(function () {
3381
- if (trackingEnabled && currentScreen !== null) {
3382
- trackScreenView(currentScreen, screenIndex);
3383
- }
3384
- }, [currentScreen, trackScreenView, trackingEnabled]);
3385
- React.useEffect(function () {
3386
- if (ready && onViewModeChange !== null) {
3387
- onViewModeChange({
3388
- landscape: landscape,
3389
- menuOverScreen: menuOverScreen
3390
- });
3391
- }
3392
- }, [ready, landscape, menuOverScreen, onViewModeChange]);
3393
-
3394
- // CSS variable
3395
- React.useEffect(function () {
3396
- if (containerRef.current === null) {
3397
- return;
3398
- }
3399
- if (finalFocusColor !== null) {
3400
- containerRef.current.style.setProperty('--micromag-focus-color', finalFocusColor);
3401
- }
3402
- }, [finalFocusColor]);
3403
-
3404
- /**
3405
- * Screen Transitions
3406
- */
3407
- var transitionType = landscape && withNeighborScreens ? DEFAULT_TRANSITION_TYPE_LANDSCAPE : DEFAULT_TRANSITION_TYPE_PORTRAIT;
3408
-
3409
- /**
3410
- * Screen Navigation
3411
- */
3412
- var changeIndex = React.useCallback(function (index) {
3413
- if (index === screenIndex) {
3414
- return;
3415
- }
3416
- if (currentScreenMedia !== null) {
3417
- currentScreenMedia.current = screensMediasRef.current[index] || null;
3418
- }
3419
- if (onScreenChange !== null) {
3420
- onScreenChange(screens[index], index);
3421
- }
3422
- }, [screenIndex, screens, onScreenChange]);
3423
- var onScreenNavigate = React.useCallback(function (_ref10) {
3424
- var index = _ref10.index,
3425
- newIndex = _ref10.newIndex,
3426
- end = _ref10.end,
3427
- direction = _ref10.direction;
3428
- if (end && onEnd !== null) {
3429
- onEnd();
3430
- }
3431
- changeIndex(newIndex);
3432
- eventsManager.emit('navigate', {
3433
- index: index,
3434
- newIndex: newIndex,
3435
- direction: direction,
3436
- end: end
3437
- });
3438
- if (end) {
3439
- eventsManager.emit('navigate_end');
3440
- } else {
3441
- eventsManager.emit("navigate_".concat(direction), newIndex);
3442
- }
3443
- }, [onEnd, changeIndex]);
3444
- var gotoPreviousScreen = React.useCallback(function () {
3445
- changeIndex(Math.max(0, screenIndex - 1));
3446
- }, [changeIndex, screenIndex]);
3447
- var gotoNextScreen = React.useCallback(function () {
3448
- changeIndex(Math.min(screens.length - 1, screenIndex + 1));
3449
- }, [changeIndex, screenIndex]);
3450
- var _useState = React.useState(false),
3451
- _useState2 = _slicedToArray(_useState, 2),
3452
- hasInteracted = _useState2[0],
3453
- setHasInteracted = _useState2[1];
3454
- var onInteractionPrivate = React.useCallback(function () {
3455
- if (onInteraction !== null) {
3456
- onInteraction();
3457
- }
3458
- if (!hasInteracted) {
3459
- setHasInteracted(true);
3460
- }
3461
- }, [onInteraction, hasInteracted, setHasInteracted]);
3462
- var _useScreenInteraction = useScreenInteraction({
3463
- screens: screens,
3464
- screenIndex: screenIndex,
3465
- screenWidth: screenContainerWidth,
3466
- disableCurrentScreenNavigation: !isView,
3467
- nextScreenWidthPercent: tapNextScreenWidthPercent,
3468
- onInteract: onInteractionPrivate,
3469
- onNavigate: onScreenNavigate
3470
- }),
3471
- interactWithScreen = _useScreenInteraction.interact,
3472
- currentScreenInteractionEnabled = _useScreenInteraction.currentScreenInteractionEnabled,
3473
- enableInteraction = _useScreenInteraction.enableInteraction,
3474
- disableInteraction = _useScreenInteraction.disableInteraction;
3475
- var onTap = React.useCallback(function (_ref11) {
3476
- var currentTarget = _ref11.currentTarget,
3477
- event = _ref11.event,
3478
- target = _ref11.target,
3479
- _ref11$xy = _slicedToArray(_ref11.xy, 2),
3480
- x = _ref11$xy[0],
3481
- y = _ref11$xy[1];
3482
- if (event) {
3483
- event.stopPropagation();
3484
- }
3485
- interactWithScreen({
3486
- event: event,
3487
- target: target,
3488
- currentTarget: currentTarget,
3489
- index: screenIndex,
3490
- x: x,
3491
- y: y
3492
- });
3493
- }, [interactWithScreen, screenIndex]);
3494
- var computeScreenProgress = React.useCallback(function (_ref12) {
3495
- var active = _ref12.active,
3496
- _ref12$movement = _slicedToArray(_ref12.movement, 1),
3497
- mx = _ref12$movement[0],
3498
- _ref12$velocity = _slicedToArray(_ref12.velocity, 1),
3499
- vx = _ref12$velocity[0];
3500
- var p = mx / screenContainerWidth; // drag "ratio": how much of the screen width has been swiped?
3501
- var forwards = mx < 0; // true if swiping to left (to navigate forwards)
3502
- var newIndex = !forwards ? screenIndex - 1 : screenIndex + 1; // which item index are we moving towards?
3503
- var reachedThreshold = vx > DRAG_VELOCITY_ACTIVATION_THRESHOLD || Math.abs(p) > DRAG_PROGRESS_ACTIVATION_THRESHOLD;
3504
- var reachedBounds = newIndex < 0 || newIndex >= screensCount; // have we reached the end of the stack?
3505
- var damper = reachedBounds ? 0.1 : 1;
3506
- var progress = Math.max(-1, Math.min(1, p * damper));
3507
- if (!active) {
3508
- return reachedThreshold && !reachedBounds ? newIndex : screenIndex;
3509
- }
3510
- return screenIndex - progress;
3511
- }, [screenContainerWidth, screenIndex]);
3512
- var onScreenProgress = React.useCallback(function (progress, _ref13) {
3513
- var active = _ref13.active;
3514
- var delta = Math.abs(progress - screenIndex);
3515
- var reachedBounds = progress < 0 || progress >= screensCount; // have we reached the end of the stack?
3516
- if (!active && delta === 1 && !reachedBounds) {
3517
- onScreenNavigate({
3518
- index: screenIndex,
3519
- newIndex: progress
3520
- });
3521
- }
3522
- }, [onScreenNavigate, screenIndex]);
3523
- var _useState3 = React.useState(true),
3524
- _useState4 = _slicedToArray(_useState3, 2),
3525
- transitioned = _useState4[0],
3526
- setTransitioned = _useState4[1];
3527
- var onTransitionStart = React.useCallback(function () {
3528
- setTransitioned(false);
3529
- }, [setTransitioned]);
3530
- var onTransitionComplete = React.useCallback(function () {
3531
- setTransitioned(true);
3532
- }, [setTransitioned]);
3533
- var springParams = React.useMemo(function () {
3534
- return {
3535
- config: SPRING_CONFIG_TIGHT,
3536
- onStart: onTransitionStart,
3537
- onRest: onTransitionComplete
3538
- };
3539
- }, [onTransitionStart, onTransitionComplete]);
3540
- var menuVisible = screensCount === 0 || currentScreenInteractionEnabled;
3541
- var navigationDisabled = currentScreenInteractionEnabled === false;
3542
- var _useDragProgress = hooks.useDragProgress({
3543
- progress: screenIndex,
3544
- disabled: !isView || withoutTransitions,
3545
- dragDisabled: withoutGestures || !currentScreenInteractionEnabled,
3546
- computeProgress: computeScreenProgress,
3547
- onProgress: onScreenProgress,
3548
- onTap: onTap,
3549
- springParams: springParams,
3550
- dragOptions: {
3551
- filterTaps: true,
3552
- axis: 'x',
3553
- pointer: {
3554
- keys: false
3555
- }
3556
- }
3557
- }),
3558
- isDragging = _useDragProgress.dragging,
3559
- progressSpring = _useDragProgress.progress,
3560
- dragContentBind = _useDragProgress.bind;
3561
- var getScreenStylesByIndex = function getScreenStylesByIndex(index, spring) {
3562
- if (transitionType === 'stack') {
3563
- return {
3564
- zIndex: index,
3565
- opacity: spring.to(function (progress) {
3566
- var t = index - progress;
3567
- var invert = Math.min(1, Math.max(0, -t));
3568
- if (Math.abs(t) > neighborScreensActive) return 0;
3569
- return Math.max(0, 1 - 0.75 * invert + (t + 1));
3570
- }),
3571
- transform: spring.to(function (progress) {
3572
- var t = index - progress;
3573
- var clamped = Math.min(1, Math.max(0, t));
3574
- var invert = Math.min(1, Math.max(0, -t));
3575
- if (Math.abs(t) > neighborScreensActive) return 'translateX(100%)';
3576
- return "translateX(".concat(clamped * 100, "%) scale(").concat(1 - 0.2 * invert, ")");
3577
- }),
3578
- boxShadow: spring.to(function (progress) {
3579
- var t = index - progress;
3580
- if (Math.abs(t) > neighborScreensActive) return null;
3581
- var clamped = Math.min(1, Math.max(0, t));
3582
- return "0 0 ".concat(4 * (1 - clamped), "rem ").concat(-0.5 * (1 - clamped), "rem black");
3583
- })
3584
- };
3585
- }
3586
- return {
3587
- opacity: spring.to(function (progress) {
3588
- var t = index - progress;
3589
- if (Math.abs(t) > neighborScreensActive) return 0;
3590
- var clamped = Math.min(1, Math.max(0, Math.abs(t)));
3591
- return 1 - 0.75 * clamped;
3592
- }),
3593
- transform: spring.to(function (progress) {
3594
- var t = index - progress;
3595
- if (Math.abs(t) > neighborScreensActive) return "translate(100%)";
3596
- var clamped = Math.min(1, Math.max(0, Math.abs(t)));
3597
- return "translateX(".concat(t * neighborScreenOffset, "%) scale(").concat(1 - (1 - neighborScreenScale) * clamped, ")");
3598
- }),
3599
- zIndex: screensCount - index
3600
- };
3601
- };
3602
- var _useFullscreen = hooks.useFullscreen(containerRef.current || null),
3603
- toggleFullscreen = _useFullscreen.toggle,
3604
- fullscreenActive = _useFullscreen.active,
3605
- fullscreenEnabled = _useFullscreen.enabled;
3606
-
3607
- // Get element height
3608
- var _useDimensionObserver3 = hooks.useDimensionObserver(),
3609
- menuDotsContainerRef = _useDimensionObserver3.ref,
3610
- _useDimensionObserver4 = _useDimensionObserver3.height,
3611
- menuDotsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
3612
- var onClickScreen = React.useCallback(function (_ref14) {
3613
- var itemScreenId = _ref14.screenId;
3614
- onInteractionPrivate();
3615
- var index = screens.findIndex(function (_ref15) {
3616
- var id = _ref15.id;
3617
- return id === itemScreenId;
3618
- });
3619
- changeIndex(index);
3620
- }, [onInteractionPrivate, changeIndex]);
3621
- var onContextMenu = React.useCallback(function (e) {
3622
- if (!landscape) {
3623
- e.preventDefault();
3624
- return false;
3625
- }
3626
- return true;
3627
- }, [landscape]);
3628
-
3629
- // hmm?
3630
- var overscrollStyle = /*#__PURE__*/React.createElement("style", {
3631
- type: "text/css"
3632
- }, "body { overscroll-behavior: contain; }");
3633
- var keyboardShortcuts = React.useMemo(function () {
3634
- return {
3635
- f: function f() {
3636
- return toggleFullscreen();
3637
- },
3638
- arrowleft: function arrowleft() {
3639
- if (!checkDraggable(document.activeElement)) {
3640
- gotoPreviousScreen();
3641
- }
3642
- },
3643
- arrowright: function arrowright() {
3644
- if (!checkDraggable(document.activeElement)) {
3645
- gotoNextScreen();
3646
- }
3647
- }
3648
- // ' ': () => gotoNextScreen(),
3649
- };
3650
- }, [gotoPreviousScreen, gotoNextScreen]);
3651
- useKeyboardShortcuts(keyboardShortcuts, {
3652
- disabled: renderContext !== 'view'
3653
- });
3654
-
3655
- // const onClickSkipToContent = useCallback(() => {
3656
- // const contentElement = document.getElementById('content') || null;
3657
- // if (contentElement !== null) {
3658
- // contentElement.focus();
3659
- // }
3660
- // }, []);
3661
-
3662
- var onClickSkipToPlaybackControls = React.useCallback(function () {
3663
- var controlsElement = document.getElementById('controls');
3664
- if (controlsElement) {
3665
- var buttons = controlsElement.querySelectorAll('button[tabindex]');
3666
- var firstFocusableButton = Array.from(buttons).find(function (button) {
3667
- return button.tabIndex >= 0;
3668
- });
3669
- if (firstFocusableButton) {
3670
- firstFocusableButton.focus({
3671
- preventScroll: true
3672
- });
3673
- }
3674
- }
3675
- }, []);
3676
- var _useState5 = React.useState(null),
3677
- _useState6 = _slicedToArray(_useState5, 2),
3678
- currentShareIncentive = _useState6[0],
3679
- setCurrentShareIncentive = _useState6[1];
3680
- var _useState7 = React.useState(false),
3681
- _useState8 = _slicedToArray(_useState7, 2),
3682
- shareIncentiveVisible = _useState8[0],
3683
- setShareIncentiveVisible = _useState8[1];
3684
- var _ref16 = currentScreen || {},
3685
- _ref16$header = _ref16.header,
3686
- header = _ref16$header === void 0 ? null : _ref16$header;
3687
- var _ref17 = header || {},
3688
- _ref17$shareIncentive = _ref17.shareIncentive,
3689
- shareIncentive = _ref17$shareIncentive === void 0 ? null : _ref17$shareIncentive;
3690
- var _ref18 = shareIncentive || {},
3691
- _ref18$active = _ref18.active,
3692
- hasShareIncentive = _ref18$active === void 0 ? false : _ref18$active,
3693
- _ref18$label = _ref18.label,
3694
- shareIncentiveLabel = _ref18$label === void 0 ? null : _ref18$label;
3695
- var _ref19 = currentShareIncentive || {},
3696
- _ref19$label = _ref19.label,
3697
- currentShareIncentiveLabel = _ref19$label === void 0 ? null : _ref19$label;
3698
- var _ref20 = shareIncentiveLabel || {},
3699
- _ref20$body = _ref20.body,
3700
- incentiveLabel = _ref20$body === void 0 ? null : _ref20$body;
3701
- var _ref21 = currentShareIncentiveLabel || {},
3702
- _ref21$body = _ref21.body,
3703
- currentIncentiveLabel = _ref21$body === void 0 ? null : _ref21$body;
3704
- React.useEffect(function () {
3705
- setShareIncentiveVisible(true);
3706
- if (hasShareIncentive && shareIncentiveLabel !== currentShareIncentiveLabel) {
3707
- setCurrentShareIncentive(shareIncentive);
3708
- }
3709
- var timeout = setTimeout(function () {
3710
- if (isView) {
3711
- setShareIncentiveVisible(false);
3712
- }
3713
- }, SHARE_INCENTIVE_TIMEOUT);
3714
- return function () {
3715
- clearTimeout(timeout);
3716
- };
3717
- }, [shareIncentiveLabel, setShareIncentiveVisible, hasShareIncentive, incentiveLabel, currentIncentiveLabel, setCurrentShareIncentive, isView]);
3718
- var _useState9 = React.useState(false),
3719
- _useState10 = _slicedToArray(_useState9, 2),
3720
- preloadNeighbors = _useState10[0],
3721
- setPreloadNeighbors = _useState10[1];
3722
- React.useEffect(function () {
3723
- setPreloadNeighbors(false);
3724
- var timeout = setTimeout(function () {
3725
- setPreloadNeighbors(true);
3726
- }, 1000);
3727
- return function () {
3728
- clearTimeout(timeout);
3729
- };
3730
- }, [screenIndex]);
3731
- var topHeight = 0;
3732
- if (topSafezoneHeight !== null) {
3733
- topHeight = topSafezoneHeight / screenScale;
3734
- } else if (menuOverScreen && currentScreenInteractionEnabled) {
3735
- topHeight = menuDotsContainerHeight / screenScale;
3736
- }
3737
- var bottomHeight = 0;
3738
- if (bottomSafezoneHeight !== null) {
3739
- bottomHeight = bottomSafezoneHeight / screenScale;
3740
- } else if (playbackControls && (playbackcontrolsVisible || !playing) && currentScreenInteractionEnabled) {
3741
- bottomHeight = playbackControlsContainerHeight / screenScale;
3742
- }
3743
- return /*#__PURE__*/React.createElement(contexts.StoryProvider, {
3744
- story: parsedStory
3745
- }, /*#__PURE__*/React.createElement(contexts.ScreenSizeProvider, {
3746
- size: screenSize
3747
- }, /*#__PURE__*/React.createElement(contexts.ViewerProvider, {
3748
- containerRef: containerRef,
3749
- events: eventsManager,
3750
- menuVisible: menuVisible,
3751
- menuOverScreen: menuOverScreen,
3752
- width: viewerWidth,
3753
- height: viewerHeight,
3754
- topHeight: topHeight,
3755
- bottomHeight: bottomHeight,
3756
- bottomSidesWidth: (playbackcontrolsVisible || !playing || playbackMedia !== null) && currentScreenInteractionEnabled ? 60 / screenScale : 0,
3757
- gotoPreviousScreen: gotoPreviousScreen,
3758
- gotoNextScreen: gotoNextScreen,
3759
- disableInteraction: disableInteraction,
3760
- enableInteraction: enableInteraction
3761
- }, withMetadata ? /*#__PURE__*/React.createElement(components.Meta, {
3762
- title: finalTitle,
3763
- metadata: finalMetadata
3764
- }, overscrollStyle) : /*#__PURE__*/React.createElement(reactHelmet.Helmet, null, overscrollStyle), /*#__PURE__*/React.createElement(components.FontFaces, {
3765
- fonts: finalFonts
3766
- }), /*#__PURE__*/React.createElement("div", {
3767
- className: classNames([styles$6.container, screenSize.screens.map(function (screenName) {
3768
- return "story-screen-".concat(screenName);
3769
- }), _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles$6.landscape, landscape), styles$6.withoutGestures, withoutGestures), styles$6.hideMenu, !menuVisible), styles$6.disableMenu, navigationDisabled), styles$6.fadeMenu, playing && playbackControls && !playbackcontrolsVisible), styles$6.ready, ready || withoutScreensTransforms), styles$6.hasInteracted, hasInteracted), styles$6.isDragging, isDragging), className, className)]),
3770
- ref: containerRef,
3771
- onContextMenu: onContextMenu
3772
- }, /*#__PURE__*/React.createElement("div", {
3773
- className: styles$6.ariaAnnouncement,
3774
- id: "announce",
3775
- "aria-live": "polite"
3776
- }, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
3777
- id: "AIr8rM",
3778
- defaultMessage: [{
3779
- "type": 0,
3780
- "value": "Screen "
3781
- }, {
3782
- "type": 1,
3783
- "value": "current"
3784
- }, {
3785
- "type": 0,
3786
- "value": " of "
3787
- }, {
3788
- "type": 1,
3789
- "value": "length"
3790
- }],
3791
- values: {
3792
- current: screenIndex + 1,
3793
- length: screens.length
3794
- }
3795
- })), /*#__PURE__*/React.createElement("nav", {
3796
- "aria-label": intl.formatMessage({
3797
- id: "gfZs4J",
3798
- defaultMessage: [{
3799
- "type": 0,
3800
- "value": "Skip Links"
3801
- }]
3802
- }),
3803
- className: styles$6.accessibilityLinks
3804
- }, /*#__PURE__*/React.createElement(Button$1, {
3805
- onClick: onClickSkipToPlaybackControls,
3806
- "aria-disabled": withoutPlaybackControls || !playbackcontrolsVisible,
3807
- "aria-describedby": "disabledReason",
3808
- className: classNames([styles$6.accessibilityButton, _defineProperty({}, styles$6.disabled, withoutPlaybackControls || !playbackcontrolsVisible)])
3809
- }, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
3810
- id: "CnVj9r",
3811
- defaultMessage: [{
3812
- "type": 0,
3813
- "value": "Skip to controls"
3814
- }]
3815
- })), withoutPlaybackControls || !playbackcontrolsVisible ? /*#__PURE__*/React.createElement("div", {
3816
- role: "tooltip",
3817
- className: styles$6.tooltipBox,
3818
- id: "disabledReason"
3819
- }, /*#__PURE__*/React.createElement("span", {
3820
- className: styles$6.tooltip
3821
- }, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
3822
- id: "YXhRxW",
3823
- defaultMessage: [{
3824
- "type": 0,
3825
- "value": "No controls available"
3826
- }]
3827
- }))) : null), !withoutMenu ? /*#__PURE__*/React.createElement(ViewerMenu$1, {
3828
- story: parsedStory,
3829
- currentScreenIndex: screenIndex,
3830
- withShadow: menuOverScreen && !withoutMenuShadow,
3831
- toggleFullscreen: toggleFullscreen,
3832
- fullscreenActive: fullscreenActive,
3833
- fullscreenEnabled: fullscreenEnabled,
3834
- menuDotsButtons: menuDotsButtons,
3835
- closeable: closeable,
3836
- shareBasePath: shareBasePath || basePath,
3837
- screenSize: screenSize,
3838
- menuWidth: menuIsScreenWidth ? screenContainerWidth : null,
3839
- theme: viewerTheme,
3840
- previewHeader: menuHeader,
3841
- previewFooter: menuFooter,
3842
- trackingEnabled: trackingEnabled,
3843
- onClickScreen: onClickScreen,
3844
- onClickCloseViewer: onCloseViewer,
3845
- onChange: onMenuChange,
3846
- withDotItemClick: screenContainerWidth > 400,
3847
- withoutScreensMenu: withoutScreensMenu,
3848
- withoutShareMenu: withoutShareMenu,
3849
- afterShareMenuButton: afterShareMenuButton,
3850
- beforeScreensMenuButton: beforeScreensMenuButton,
3851
- refDots: menuDotsContainerRef
3852
- }) : null, ready || withoutScreensTransforms ? /*#__PURE__*/React.createElement("div", Object.assign({
3853
- className: styles$6.content
3854
- }, dragContentBind()), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex > 0 && screens.length > 1 ? /*#__PURE__*/React.createElement(NavigationButton$1, {
3855
- direction: "previous",
3856
- className: classNames([styles$6.navButton, styles$6.previous]),
3857
- onClick: gotoPreviousScreen,
3858
- ariaLabel: intl.formatMessage({
3859
- id: "zYH/31",
3860
- defaultMessage: [{
3861
- "type": 0,
3862
- "value": "Go to previous screen"
3863
- }]
3864
- })
3865
- }) : null, /*#__PURE__*/React.createElement("div", {
3866
- className: styles$6.screensFrame,
3867
- style: {
3868
- width: screenContainerWidth,
3869
- height: screenContainerHeight,
3870
- overflow: !withNeighborScreens ? 'hidden' : null
3871
- }
3872
- }, screens.map(function (screen, i) {
3873
- var current = screenIndex === i;
3874
- var active = i >= screenIndex - neighborScreensActive && i <= screenIndex + neighborScreensActive && preloadNeighbors;
3875
- var screenStyles = getScreenStylesByIndex(i, progressSpring);
3876
- return /*#__PURE__*/React.createElement(web.animated.div, {
3877
- key: "screen-viewer-".concat(screen.id || '', "-").concat(i + 1),
3878
- id: current ? 'content' : null,
3879
- "aria-hidden": !current,
3880
- style: screenStyles,
3881
- tabIndex: current ? 0 : -1,
3882
- className: classNames([styles$6.screenContainer, _defineProperty({}, styles$6.current, current)])
3883
- }, screen !== null ? /*#__PURE__*/React.createElement(ViewerScreen, {
3884
- className: styles$6.screen,
3885
- screen: screen,
3886
- screenState: current ? screenState : null,
3887
- index: i,
3888
- current: current,
3889
- active: active || current,
3890
- ready: current && transitioned,
3891
- mediaRef: function mediaRef(ref) {
3892
- screensMediasRef.current[i] = ref;
3893
- },
3894
- renderContext: renderContext,
3895
- width: screenWidth,
3896
- height: screenHeight,
3897
- scale: screenScale
3898
- }) : null);
3899
- })), !withoutNavigationArrow && !withNeighborScreens && !navigationDisabled && screenIndex < screens.length - 1 ? /*#__PURE__*/React.createElement(NavigationButton$1, {
3900
- direction: "next",
3901
- className: classNames([styles$6.navButton, styles$6.next]),
3902
- onClick: gotoNextScreen,
3903
- ariaLabel: intl.formatMessage({
3904
- id: "v9bqYj",
3905
- defaultMessage: [{
3906
- "type": 0,
3907
- "value": "Go to next screen"
3908
- }]
3909
- })
3910
- }) : null, !withoutPlaybackControls ? /*#__PURE__*/React.createElement("div", {
3911
- className: styles$6.playbackControls,
3912
- id: "controls",
3913
- ref: playbackControlsContainerRef
3914
- }, /*#__PURE__*/React.createElement(PlaybackControls, {
3915
- className: styles$6.controls
3916
- })) : null, withNavigationHint && !withNeighborScreens && !navigationDisabled && screenIndex === 0 && !hasInteracted ? /*#__PURE__*/React.createElement(ArrowHint$1, {
3917
- className: styles$6.arrowHint
3918
- }) : null) : null, /*#__PURE__*/React.createElement("div", {
3919
- className: classNames([styles$6.shareIncentiveContainer, _defineProperty({}, styles$6.shareIncentiveVisible, hasShareIncentive && shareIncentiveVisible)]),
3920
- style: {
3921
- top: isEditor ? 10 : menuDotsContainerHeight - 10
3922
- }
3923
- }, /*#__PURE__*/React.createElement(all.ShareIncentive, Object.assign({
3924
- className: styles$6.shareIncentive
3925
- }, currentShareIncentive))), /*#__PURE__*/React.createElement(WebViewContainer, {
3926
- className: styles$6.webView,
3927
- style: {
3928
- maxWidth: Math.max(screenContainerWidth, 600)
3929
- }
3930
- })))));
3931
- };
3932
- Viewer.propTypes = propTypes$2;
3933
- Viewer.defaultProps = defaultProps$2;
3934
- var Viewer$1 = Viewer;
3935
-
3936
- var _excluded$1 = ["story", "pathWithIndex", "children", "onScreenChange"];
3937
- var propTypes$1 = {
3938
- story: core.PropTypes.story,
3939
- // .isRequired,
3940
- pathWithIndex: PropTypes.bool,
3941
- children: PropTypes.func,
3942
- onScreenChange: PropTypes.func
3943
- };
3944
- var defaultProps$1 = {
3945
- story: null,
3946
- pathWithIndex: false,
3947
- children: null,
3948
- onScreenChange: null
3949
- };
3950
- var ViewerRoutes = function ViewerRoutes(_ref) {
3951
- var story = _ref.story,
3952
- pathWithIndex = _ref.pathWithIndex;
3953
- _ref.children;
3954
- var onScreenChange = _ref.onScreenChange,
3955
- otherProps = _objectWithoutProperties(_ref, _excluded$1);
3956
- var routes = useRoutes$1();
3957
- var url = useUrlGeneratorPathToRegexp();
3958
- var _useLocation = useLocation(),
3959
- _useLocation2 = _slicedToArray(_useLocation, 2),
3960
- navigate = _useLocation2[1];
3961
- var _ref2 = story || {},
3962
- _ref2$components = _ref2.components,
3963
- screens = _ref2$components === void 0 ? [] : _ref2$components;
3964
- var finalOnScreenChange = React.useCallback(function (it) {
3965
- var screenIndex = screens.findIndex(function (screen) {
3966
- var screenId = screen.id;
3967
- return screenId === it.id || screen === it;
3968
- });
3969
- navigate(url('screen', {
3970
- screen: pathWithIndex ? screenIndex + 1 : it.id
3971
- }));
3972
- if (onScreenChange !== null) {
3973
- onScreenChange(it);
3974
- }
3975
- }, [navigate, url, pathWithIndex, screens, onScreenChange]);
3976
- return /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
3977
- path: routes.screen
3978
- }, function (_ref3) {
3979
- var _ref3$screen = _ref3.screen,
3980
- screenParam = _ref3$screen === void 0 ? null : _ref3$screen;
3981
- var screenFromIndex = pathWithIndex && screenParam !== null ? screens[parseInt(screenParam, 10) - 1] || null : null;
3982
- var screenId = pathWithIndex ? (screenFromIndex || {}).id || null : screenParam;
3983
- return /*#__PURE__*/React.createElement(Viewer$1, Object.assign({}, otherProps, {
3984
- story: story,
3985
- screen: screenId,
3986
- onScreenChange: finalOnScreenChange
3987
- }));
3988
- }), /*#__PURE__*/React.createElement(Route, null, /*#__PURE__*/React.createElement(Viewer$1, Object.assign({}, otherProps, {
3989
- story: story,
3990
- onScreenChange: finalOnScreenChange
3991
- }))));
3992
- };
3993
- ViewerRoutes.propTypes = propTypes$1;
3994
- ViewerRoutes.defaultProps = defaultProps$1;
3995
- var ViewerRoutes$1 = ViewerRoutes;
3996
-
3997
- var home = "/";
3998
- var screen = "/:screen";
3999
- var defaultRoutes = {
4000
- home: home,
4001
- screen: screen
4002
- };
4003
-
4004
- var _excluded = ["story", "paused", "screenComponents", "memoryRouter", "basePath", "routes", "withoutRouter", "googleApiKey", "visitor", "trackingVariables", "locale", "locales", "translations", "pathWithIndex"];
4005
- var propTypes = {
4006
- story: core.PropTypes.story,
4007
- paused: PropTypes.bool,
4008
- screen: PropTypes.string,
4009
- screenComponents: PropTypes.objectOf(PropTypes.elementType),
4010
- memoryRouter: PropTypes.bool,
4011
- basePath: PropTypes.string,
4012
- routes: routes,
4013
- withoutRouter: PropTypes.bool,
4014
- googleApiKey: PropTypes.string,
4015
- visitor: core.PropTypes.visitor,
4016
- trackingVariables: core.PropTypes.trackingVariables,
4017
- locale: PropTypes.string,
4018
- locales: PropTypes.arrayOf(PropTypes.string),
4019
- translations: PropTypes.objectOf(PropTypes.string),
4020
- pathWithIndex: PropTypes.bool,
4021
- children: PropTypes.func
4022
- };
4023
- var defaultProps = {
4024
- story: null,
4025
- paused: false,
4026
- screen: null,
4027
- screenComponents: null,
4028
- memoryRouter: false,
4029
- basePath: null,
4030
- routes: defaultRoutes,
4031
- withoutRouter: false,
4032
- googleApiKey: null,
4033
- visitor: null,
4034
- trackingVariables: null,
4035
- locale: 'en',
4036
- locales: ['fr', 'en'],
4037
- translations: null,
4038
- pathWithIndex: false,
4039
- children: null
4040
- };
4041
- var ViewerContainer = function ViewerContainer(_ref) {
4042
- var story = _ref.story,
4043
- paused = _ref.paused,
4044
- screenComponents = _ref.screenComponents,
4045
- memoryRouter = _ref.memoryRouter,
4046
- basePath = _ref.basePath,
4047
- routes = _ref.routes,
4048
- withoutRouter = _ref.withoutRouter,
4049
- googleApiKey = _ref.googleApiKey,
4050
- visitor = _ref.visitor,
4051
- trackingVariables = _ref.trackingVariables,
4052
- locale = _ref.locale,
4053
- locales = _ref.locales,
4054
- translations = _ref.translations,
4055
- pathWithIndex = _ref.pathWithIndex,
4056
- otherProps = _objectWithoutProperties(_ref, _excluded);
4057
- var finalTrackingVariables = React.useMemo(function () {
4058
- if (story === null && trackingVariables === null) {
4059
- return null;
4060
- }
4061
- var _story$id = story.id,
4062
- id = _story$id === void 0 ? null : _story$id,
4063
- _story$slug = story.slug,
4064
- slug = _story$slug === void 0 ? null : _story$slug,
4065
- _story$title = story.title,
4066
- title = _story$title === void 0 ? null : _story$title,
4067
- _story$components = story.components,
4068
- components = _story$components === void 0 ? [] : _story$components;
4069
- return _objectSpread({
4070
- storyId: id,
4071
- storySlug: slug,
4072
- storyTitle: title,
4073
- screensCount: (components || []).length
4074
- }, trackingVariables);
4075
- }, [story, trackingVariables]);
4076
- var _ref2 = story || {},
4077
- metadata = _ref2.metadata;
4078
- var _ref3 = metadata || {},
4079
- _ref3$language = _ref3.language,
4080
- finalLocale = _ref3$language === void 0 ? locale : _ref3$language;
4081
- var content = /*#__PURE__*/React.createElement(intl.IntlProvider, {
4082
- locale: finalLocale,
4083
- locales: locales,
4084
- extraMessages: translations
4085
- }, /*#__PURE__*/React.createElement(contexts.GoogleKeysProvider, {
4086
- apiKey: googleApiKey
4087
- }, /*#__PURE__*/React.createElement(contexts.GoogleMapsClientProvider, {
4088
- locale: finalLocale
4089
- }, /*#__PURE__*/React.createElement(screens.ScreensProvider, null, /*#__PURE__*/React.createElement(contexts.ComponentsProvider, {
4090
- namespace: contexts.SCREENS_NAMESPACE,
4091
- components: screenComponents || {}
4092
- }, /*#__PURE__*/React.createElement(contexts.VisitorProvider, {
4093
- visitor: visitor
4094
- }, /*#__PURE__*/React.createElement(contexts.PlaybackProvider, {
4095
- paused: paused
4096
- }, /*#__PURE__*/React.createElement(contexts.TrackingProvider, {
4097
- variables: finalTrackingVariables
4098
- }, withoutRouter ? /*#__PURE__*/React.createElement(Viewer$1, Object.assign({
4099
- story: story,
4100
- basePath: basePath
4101
- }, otherProps)) : /*#__PURE__*/React.createElement(ViewerRoutes$1, Object.assign({
4102
- story: story,
4103
- basePath: basePath,
4104
- pathWithIndex: pathWithIndex
4105
- }, otherProps))))))))));
4106
- var _useMemoryRouter = useMemoryRouter(),
4107
- memoryRouterHook = _useMemoryRouter.hook,
4108
- memoryRouterSearchHook = _useMemoryRouter.searchHook;
4109
- var routerProps = React.useMemo(function () {
4110
- return {
4111
- hook: memoryRouter ? memoryRouterHook : null,
4112
- searchHook: memoryRouter ? memoryRouterSearchHook : null,
4113
- base: !memoryRouter ? basePath : null
4114
- };
4115
- }, [basePath, memoryRouter]);
4116
- return withoutRouter ? content : /*#__PURE__*/React.createElement(Router, routerProps, /*#__PURE__*/React.createElement(RoutesProvider, {
4117
- routes: routes
4118
- }, content));
4119
- };
4120
- ViewerContainer.propTypes = propTypes;
4121
- ViewerContainer.defaultProps = defaultProps;
4122
- var ViewerContainer$1 = ViewerContainer;
4123
-
4124
- exports.Viewer = Viewer$1;
4125
- exports.default = ViewerContainer$1;