@micromag/viewer 0.3.635 → 0.3.637
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/index.js +27 -8
- package/package.json +11 -10
package/es/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
|
|
|
5
5
|
import React, { useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
6
6
|
import { Link, useLocation, Switch, Route, Router } from 'wouter';
|
|
7
7
|
import { PropTypes as PropTypes$1 } from '@micromag/core';
|
|
8
|
-
import { useViewerSize, usePlaybackContext, useViewerWebView, useViewerInteraction, StoryProvider, ScreenSizeProvider, ViewerProvider, GoogleKeysProvider, GoogleMapsClientProvider, ComponentsProvider, SCREENS_NAMESPACE, VisitorProvider, PlaybackProvider, TrackingProvider } from '@micromag/core/contexts';
|
|
8
|
+
import { useViewerSize, usePlaybackContext, useViewerWebView, useViewerInteraction, useStory, StoryProvider, ScreenSizeProvider, ViewerProvider, GoogleKeysProvider, GoogleMapsClientProvider, ComponentsProvider, SCREENS_NAMESPACE, VisitorProvider, PlaybackProvider, TrackingProvider } from '@micromag/core/contexts';
|
|
9
9
|
import { IntlProvider } from '@micromag/intl';
|
|
10
10
|
import { ScreensProvider } from '@micromag/screens';
|
|
11
11
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
@@ -25,6 +25,7 @@ import { useSpring } from '@react-spring/core';
|
|
|
25
25
|
import Scroll from '@micromag/element-scroll';
|
|
26
26
|
import ShareOptions from '@micromag/element-share-options';
|
|
27
27
|
import { useGesture } from '@use-gesture/react';
|
|
28
|
+
import queryString from 'query-string';
|
|
28
29
|
import WebView from '@micromag/element-webview';
|
|
29
30
|
|
|
30
31
|
// eslint-disable-next-line import/prefer-default-export
|
|
@@ -2469,7 +2470,7 @@ PlaybackControls.defaultProps = defaultProps$4;
|
|
|
2469
2470
|
|
|
2470
2471
|
var styles = {"container":"micromag-viewer-partials-web-view-container","opened":"micromag-viewer-partials-web-view-opened"};
|
|
2471
2472
|
|
|
2472
|
-
var _excluded$2 = ["opened", "close", "open", "update", "url"];
|
|
2473
|
+
var _excluded$2 = ["opened", "close", "open", "update", "url", "source"];
|
|
2473
2474
|
var propTypes$3 = {
|
|
2474
2475
|
onChange: PropTypes.func,
|
|
2475
2476
|
className: PropTypes.string,
|
|
@@ -2491,6 +2492,8 @@ function WebViewContainer(_ref) {
|
|
|
2491
2492
|
_useViewerWebView.update;
|
|
2492
2493
|
var _useViewerWebView$url = _useViewerWebView.url,
|
|
2493
2494
|
url = _useViewerWebView$url === undefined ? null : _useViewerWebView$url,
|
|
2495
|
+
_useViewerWebView$sou = _useViewerWebView.source,
|
|
2496
|
+
source = _useViewerWebView$sou === undefined ? null : _useViewerWebView$sou,
|
|
2494
2497
|
webViewProps = _objectWithoutProperties(_useViewerWebView, _excluded$2);
|
|
2495
2498
|
var _useViewerInteraction = useViewerInteraction(),
|
|
2496
2499
|
disableInteraction = _useViewerInteraction.disableInteraction,
|
|
@@ -2505,6 +2508,8 @@ function WebViewContainer(_ref) {
|
|
|
2505
2508
|
_useState2 = _slicedToArray(_useState, 2),
|
|
2506
2509
|
currentUrl = _useState2[0],
|
|
2507
2510
|
setCurrentUrl = _useState2[1];
|
|
2511
|
+
var _useStory = useStory(),
|
|
2512
|
+
storyTitle = _useStory.title;
|
|
2508
2513
|
var ref = useRef(null);
|
|
2509
2514
|
|
|
2510
2515
|
// Handle current webview url
|
|
@@ -2548,13 +2553,23 @@ function WebViewContainer(_ref) {
|
|
|
2548
2553
|
};
|
|
2549
2554
|
}, [close]);
|
|
2550
2555
|
useKeyboardShortcuts(keyboardShortcuts);
|
|
2556
|
+
var webViewUrl = url || currentUrl;
|
|
2557
|
+
var finalUrl = useMemo(function () {
|
|
2558
|
+
var currentQueryString = queryString.parse(webViewUrl !== null && webViewUrl.indexOf('?') !== -1 ? webViewUrl.split('?')[1] : '');
|
|
2559
|
+
return webViewUrl !== null ? "".concat(webViewUrl.split('?')[0], "?").concat(queryString.stringify(_objectSpread({
|
|
2560
|
+
utm_source: 'Micromag',
|
|
2561
|
+
utm_medium: source || 'webview',
|
|
2562
|
+
utm_campaign: storyTitle
|
|
2563
|
+
}, currentQueryString))) : url;
|
|
2564
|
+
}, [webViewUrl, source]);
|
|
2551
2565
|
return /*#__PURE__*/React.createElement("div", {
|
|
2552
2566
|
className: classNames([styles.container, _defineProperty(_defineProperty({}, styles.opened, opened), className, className !== null)]),
|
|
2553
2567
|
style: style,
|
|
2554
2568
|
onTransitionEnd: onTransitionEnd,
|
|
2555
2569
|
ref: ref
|
|
2556
2570
|
}, /*#__PURE__*/React.createElement(WebView, Object.assign({
|
|
2557
|
-
url:
|
|
2571
|
+
url: finalUrl,
|
|
2572
|
+
source: source
|
|
2558
2573
|
}, webViewProps, {
|
|
2559
2574
|
closeable: opened,
|
|
2560
2575
|
focusable: opened,
|
|
@@ -3495,7 +3510,7 @@ var defaultRoutes = {
|
|
|
3495
3510
|
screen: screen
|
|
3496
3511
|
};
|
|
3497
3512
|
|
|
3498
|
-
var _excluded = ["story", "paused", "screenComponents", "memoryRouter", "basePath", "routes", "withoutRouter", "googleApiKey", "visitor", "
|
|
3513
|
+
var _excluded = ["story", "paused", "screenComponents", "memoryRouter", "basePath", "routes", "withoutRouter", "googleApiKey", "visitor", "locale", "locales", "translations", "pathWithIndex", "trackingVariables", "trackingDisabled", "trackingPaused"];
|
|
3499
3514
|
var propTypes = {
|
|
3500
3515
|
story: PropTypes$1.story,
|
|
3501
3516
|
paused: PropTypes.bool,
|
|
@@ -3507,12 +3522,13 @@ var propTypes = {
|
|
|
3507
3522
|
withoutRouter: PropTypes.bool,
|
|
3508
3523
|
googleApiKey: PropTypes.string,
|
|
3509
3524
|
visitor: PropTypes$1.visitor,
|
|
3510
|
-
trackingVariables: PropTypes$1.trackingVariables,
|
|
3511
3525
|
locale: PropTypes.string,
|
|
3512
3526
|
locales: PropTypes.arrayOf(PropTypes.string),
|
|
3513
3527
|
translations: PropTypes.objectOf(PropTypes.string),
|
|
3514
3528
|
pathWithIndex: PropTypes.bool,
|
|
3529
|
+
trackingVariables: PropTypes$1.trackingVariables,
|
|
3515
3530
|
trackingDisabled: PropTypes.bool,
|
|
3531
|
+
trackingPaused: PropTypes.bool,
|
|
3516
3532
|
children: PropTypes.func
|
|
3517
3533
|
};
|
|
3518
3534
|
var defaultProps = {
|
|
@@ -3526,12 +3542,13 @@ var defaultProps = {
|
|
|
3526
3542
|
withoutRouter: false,
|
|
3527
3543
|
googleApiKey: null,
|
|
3528
3544
|
visitor: null,
|
|
3529
|
-
trackingVariables: null,
|
|
3530
3545
|
locale: 'en',
|
|
3531
3546
|
locales: ['fr', 'en'],
|
|
3532
3547
|
translations: null,
|
|
3533
3548
|
pathWithIndex: false,
|
|
3549
|
+
trackingVariables: null,
|
|
3534
3550
|
trackingDisabled: false,
|
|
3551
|
+
trackingPaused: false,
|
|
3535
3552
|
children: null
|
|
3536
3553
|
};
|
|
3537
3554
|
var ViewerContainer = function ViewerContainer(_ref) {
|
|
@@ -3544,12 +3561,13 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
3544
3561
|
withoutRouter = _ref.withoutRouter,
|
|
3545
3562
|
googleApiKey = _ref.googleApiKey,
|
|
3546
3563
|
visitor = _ref.visitor,
|
|
3547
|
-
trackingVariables = _ref.trackingVariables,
|
|
3548
3564
|
locale = _ref.locale,
|
|
3549
3565
|
locales = _ref.locales,
|
|
3550
3566
|
translations = _ref.translations,
|
|
3551
3567
|
pathWithIndex = _ref.pathWithIndex,
|
|
3568
|
+
trackingVariables = _ref.trackingVariables,
|
|
3552
3569
|
trackingDisabled = _ref.trackingDisabled,
|
|
3570
|
+
trackingPaused = _ref.trackingPaused,
|
|
3553
3571
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
3554
3572
|
var finalTrackingVariables = useMemo(function () {
|
|
3555
3573
|
if (story === null && trackingVariables === null) {
|
|
@@ -3593,7 +3611,8 @@ var ViewerContainer = function ViewerContainer(_ref) {
|
|
|
3593
3611
|
paused: paused
|
|
3594
3612
|
}, /*#__PURE__*/React.createElement(TrackingProvider, {
|
|
3595
3613
|
variables: finalTrackingVariables,
|
|
3596
|
-
disabled: trackingDisabled
|
|
3614
|
+
disabled: trackingDisabled,
|
|
3615
|
+
paused: trackingPaused
|
|
3597
3616
|
}, withoutRouter ? /*#__PURE__*/React.createElement(Viewer, Object.assign({
|
|
3598
3617
|
story: story,
|
|
3599
3618
|
basePath: basePath
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/viewer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.637",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@babel/runtime": "^7.13.10",
|
|
66
66
|
"@folklore/routes": "^0.2.36",
|
|
67
|
-
"@micromag/core": "^0.3.
|
|
68
|
-
"@micromag/element-badge": "^0.3.
|
|
69
|
-
"@micromag/element-scroll": "^0.3.
|
|
70
|
-
"@micromag/element-share-options": "^0.3.
|
|
71
|
-
"@micromag/element-webview": "^0.3.
|
|
72
|
-
"@micromag/elements": "^0.3.
|
|
73
|
-
"@micromag/intl": "^0.3.
|
|
74
|
-
"@micromag/screens": "^0.3.
|
|
67
|
+
"@micromag/core": "^0.3.637",
|
|
68
|
+
"@micromag/element-badge": "^0.3.637",
|
|
69
|
+
"@micromag/element-scroll": "^0.3.637",
|
|
70
|
+
"@micromag/element-share-options": "^0.3.637",
|
|
71
|
+
"@micromag/element-webview": "^0.3.637",
|
|
72
|
+
"@micromag/elements": "^0.3.637",
|
|
73
|
+
"@micromag/intl": "^0.3.637",
|
|
74
|
+
"@micromag/screens": "^0.3.637",
|
|
75
75
|
"@react-spring/core": "^9.6.1",
|
|
76
76
|
"@react-spring/web": "^9.6.1",
|
|
77
77
|
"@use-gesture/react": "^10.3.0",
|
|
@@ -79,6 +79,7 @@
|
|
|
79
79
|
"detect-pointer-events": "^1.0.2",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
81
|
"prop-types": "^15.7.2",
|
|
82
|
+
"query-string": "^9.1.1",
|
|
82
83
|
"react-focus-lock": "^2.11.2",
|
|
83
84
|
"react-helmet": "^6.1.0",
|
|
84
85
|
"react-intl": "^6.6.4",
|
|
@@ -91,5 +92,5 @@
|
|
|
91
92
|
"access": "public",
|
|
92
93
|
"registry": "https://registry.npmjs.org/"
|
|
93
94
|
},
|
|
94
|
-
"gitHead": "
|
|
95
|
+
"gitHead": "8f06c2a525d71dc47183af7786284632a04332e1"
|
|
95
96
|
}
|