@micromag/screen-share 0.3.239 → 0.3.246
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 +26 -5
- package/lib/index.js +26 -5
- package/package.json +11 -11
package/es/index.js
CHANGED
|
@@ -30,6 +30,8 @@ var propTypes = {
|
|
|
30
30
|
spacing: PropTypes.number,
|
|
31
31
|
background: PropTypes$1.backgroundElement,
|
|
32
32
|
callToAction: PropTypes$1.callToAction,
|
|
33
|
+
id: PropTypes.string,
|
|
34
|
+
index: PropTypes.number,
|
|
33
35
|
current: PropTypes.bool,
|
|
34
36
|
active: PropTypes.bool,
|
|
35
37
|
transitions: PropTypes$1.transitions,
|
|
@@ -47,6 +49,8 @@ var defaultProps = {
|
|
|
47
49
|
spacing: 20,
|
|
48
50
|
background: null,
|
|
49
51
|
callToAction: null,
|
|
52
|
+
id: null,
|
|
53
|
+
index: null,
|
|
50
54
|
current: true,
|
|
51
55
|
active: true,
|
|
52
56
|
transitions: null,
|
|
@@ -67,6 +71,8 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
67
71
|
spacing = _ref.spacing,
|
|
68
72
|
background = _ref.background,
|
|
69
73
|
callToAction = _ref.callToAction,
|
|
74
|
+
id = _ref.id,
|
|
75
|
+
index = _ref.index,
|
|
70
76
|
current = _ref.current,
|
|
71
77
|
active = _ref.active,
|
|
72
78
|
transitions = _ref.transitions,
|
|
@@ -112,8 +118,24 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
112
118
|
_ref2$pathname = _ref2.pathname,
|
|
113
119
|
pathname = _ref2$pathname === void 0 ? null : _ref2$pathname;
|
|
114
120
|
|
|
115
|
-
|
|
116
|
-
|
|
121
|
+
var parts = pathname.split('/');
|
|
122
|
+
/**
|
|
123
|
+
* for the last portion of the path, if it's equal to the screen index,
|
|
124
|
+
* or the screen id, then don't include it in the share URL.
|
|
125
|
+
* This makes sure we're not doing a `.replace()` that might remove a part
|
|
126
|
+
* from the slug of the current Micromag.
|
|
127
|
+
* (e.g. if the url is `/10-reasons-to-lorem-ipsum` and the share screen
|
|
128
|
+
* is on screen 10, then a string replace would remove the `/10` from the
|
|
129
|
+
* URL)
|
|
130
|
+
*/
|
|
131
|
+
|
|
132
|
+
return parts.reduce(function (acc, part, i) {
|
|
133
|
+
return (// it's equal to the screen index, or equal to the screen ID, or it's empty
|
|
134
|
+
i === parts.length - 1 && parseInt(part, 10) === index || part === id || part === '' ? acc : "".concat(acc, "/").concat(part)
|
|
135
|
+
);
|
|
136
|
+
}, hostname);
|
|
137
|
+
}, [index, id]); // if not share URl was specified, default to the currentURL (without the screen index/id part)
|
|
138
|
+
|
|
117
139
|
var finalShareURL = shareUrl || currentUrl;
|
|
118
140
|
var defaultOptions = options !== null ? ['email', 'facebook', 'twitter', 'linkedin', 'whatsapp', 'facebookMessenger'] : [];
|
|
119
141
|
var selectedOptions = options !== null ? Object.keys(options).reduce(function (acc, key) {
|
|
@@ -125,11 +147,10 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
125
147
|
var onClickShare = useCallback(function (type) {
|
|
126
148
|
if (trackingEnabled) {
|
|
127
149
|
trackEvent('click_share', type, {
|
|
128
|
-
shareUrl:
|
|
150
|
+
shareUrl: finalShareURL
|
|
129
151
|
});
|
|
130
152
|
}
|
|
131
|
-
}, [trackEvent]);
|
|
132
|
-
|
|
153
|
+
}, [trackEvent]);
|
|
133
154
|
var items = [/*#__PURE__*/React.createElement(ScreenElement, {
|
|
134
155
|
key: "title",
|
|
135
156
|
placeholder: "title",
|
package/lib/index.js
CHANGED
|
@@ -49,6 +49,8 @@ var propTypes = {
|
|
|
49
49
|
spacing: PropTypes__default["default"].number,
|
|
50
50
|
background: core.PropTypes.backgroundElement,
|
|
51
51
|
callToAction: core.PropTypes.callToAction,
|
|
52
|
+
id: PropTypes__default["default"].string,
|
|
53
|
+
index: PropTypes__default["default"].number,
|
|
52
54
|
current: PropTypes__default["default"].bool,
|
|
53
55
|
active: PropTypes__default["default"].bool,
|
|
54
56
|
transitions: core.PropTypes.transitions,
|
|
@@ -66,6 +68,8 @@ var defaultProps = {
|
|
|
66
68
|
spacing: 20,
|
|
67
69
|
background: null,
|
|
68
70
|
callToAction: null,
|
|
71
|
+
id: null,
|
|
72
|
+
index: null,
|
|
69
73
|
current: true,
|
|
70
74
|
active: true,
|
|
71
75
|
transitions: null,
|
|
@@ -86,6 +90,8 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
86
90
|
spacing = _ref.spacing,
|
|
87
91
|
background = _ref.background,
|
|
88
92
|
callToAction = _ref.callToAction,
|
|
93
|
+
id = _ref.id,
|
|
94
|
+
index = _ref.index,
|
|
89
95
|
current = _ref.current,
|
|
90
96
|
active = _ref.active,
|
|
91
97
|
transitions = _ref.transitions,
|
|
@@ -131,8 +137,24 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
131
137
|
_ref2$pathname = _ref2.pathname,
|
|
132
138
|
pathname = _ref2$pathname === void 0 ? null : _ref2$pathname;
|
|
133
139
|
|
|
134
|
-
|
|
135
|
-
|
|
140
|
+
var parts = pathname.split('/');
|
|
141
|
+
/**
|
|
142
|
+
* for the last portion of the path, if it's equal to the screen index,
|
|
143
|
+
* or the screen id, then don't include it in the share URL.
|
|
144
|
+
* This makes sure we're not doing a `.replace()` that might remove a part
|
|
145
|
+
* from the slug of the current Micromag.
|
|
146
|
+
* (e.g. if the url is `/10-reasons-to-lorem-ipsum` and the share screen
|
|
147
|
+
* is on screen 10, then a string replace would remove the `/10` from the
|
|
148
|
+
* URL)
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
return parts.reduce(function (acc, part, i) {
|
|
152
|
+
return (// it's equal to the screen index, or equal to the screen ID, or it's empty
|
|
153
|
+
i === parts.length - 1 && parseInt(part, 10) === index || part === id || part === '' ? acc : "".concat(acc, "/").concat(part)
|
|
154
|
+
);
|
|
155
|
+
}, hostname);
|
|
156
|
+
}, [index, id]); // if not share URl was specified, default to the currentURL (without the screen index/id part)
|
|
157
|
+
|
|
136
158
|
var finalShareURL = shareUrl || currentUrl;
|
|
137
159
|
var defaultOptions = options !== null ? ['email', 'facebook', 'twitter', 'linkedin', 'whatsapp', 'facebookMessenger'] : [];
|
|
138
160
|
var selectedOptions = options !== null ? Object.keys(options).reduce(function (acc, key) {
|
|
@@ -144,11 +166,10 @@ var ShareScreen = function ShareScreen(_ref) {
|
|
|
144
166
|
var onClickShare = React.useCallback(function (type) {
|
|
145
167
|
if (trackingEnabled) {
|
|
146
168
|
trackEvent('click_share', type, {
|
|
147
|
-
shareUrl:
|
|
169
|
+
shareUrl: finalShareURL
|
|
148
170
|
});
|
|
149
171
|
}
|
|
150
|
-
}, [trackEvent]);
|
|
151
|
-
|
|
172
|
+
}, [trackEvent]);
|
|
152
173
|
var items = [/*#__PURE__*/React__default["default"].createElement(components.ScreenElement, {
|
|
153
174
|
key: "title",
|
|
154
175
|
placeholder: "title",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/screen-share",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.246",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@babel/runtime": "^7.13.10",
|
|
56
|
-
"@micromag/core": "^0.3.
|
|
57
|
-
"@micromag/element-background": "^0.3.
|
|
58
|
-
"@micromag/element-call-to-action": "^0.3.
|
|
59
|
-
"@micromag/element-container": "^0.3.
|
|
60
|
-
"@micromag/element-heading": "^0.3.
|
|
61
|
-
"@micromag/element-layout": "^0.3.
|
|
62
|
-
"@micromag/element-share-options": "^0.3.
|
|
63
|
-
"@micromag/element-text": "^0.3.
|
|
64
|
-
"@micromag/transforms": "^0.3.
|
|
56
|
+
"@micromag/core": "^0.3.246",
|
|
57
|
+
"@micromag/element-background": "^0.3.246",
|
|
58
|
+
"@micromag/element-call-to-action": "^0.3.246",
|
|
59
|
+
"@micromag/element-container": "^0.3.246",
|
|
60
|
+
"@micromag/element-heading": "^0.3.246",
|
|
61
|
+
"@micromag/element-layout": "^0.3.246",
|
|
62
|
+
"@micromag/element-share-options": "^0.3.246",
|
|
63
|
+
"@micromag/element-text": "^0.3.246",
|
|
64
|
+
"@micromag/transforms": "^0.3.246",
|
|
65
65
|
"classnames": "^2.2.6",
|
|
66
66
|
"lodash": "^4.17.21",
|
|
67
67
|
"prop-types": "^15.7.2",
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"publishConfig": {
|
|
72
72
|
"access": "public"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "473a4ad55684e54d3f1e62e760792ed6e003f8e7"
|
|
75
75
|
}
|