@micromag/viewer 0.3.634 → 0.3.636
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 +18 -4
- package/package.json +4 -3
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,14 +2553,23 @@ function WebViewContainer(_ref) {
|
|
|
2548
2553
|
};
|
|
2549
2554
|
}, [close]);
|
|
2550
2555
|
useKeyboardShortcuts(keyboardShortcuts);
|
|
2551
|
-
|
|
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]);
|
|
2552
2565
|
return /*#__PURE__*/React.createElement("div", {
|
|
2553
2566
|
className: classNames([styles.container, _defineProperty(_defineProperty({}, styles.opened, opened), className, className !== null)]),
|
|
2554
2567
|
style: style,
|
|
2555
2568
|
onTransitionEnd: onTransitionEnd,
|
|
2556
2569
|
ref: ref
|
|
2557
2570
|
}, /*#__PURE__*/React.createElement(WebView, Object.assign({
|
|
2558
|
-
url:
|
|
2571
|
+
url: finalUrl,
|
|
2572
|
+
source: source
|
|
2559
2573
|
}, webViewProps, {
|
|
2560
2574
|
closeable: opened,
|
|
2561
2575
|
focusable: opened,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/viewer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.636",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"@micromag/element-webview": "^0.3.628",
|
|
72
72
|
"@micromag/elements": "^0.3.628",
|
|
73
73
|
"@micromag/intl": "^0.3.628",
|
|
74
|
-
"@micromag/screens": "^0.3.
|
|
74
|
+
"@micromag/screens": "^0.3.636",
|
|
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": "97a9840e7df9d9d9e5854b927597fadc11c423c1"
|
|
95
96
|
}
|