@quintype/components 3.0.3-test-react18.0 → 3.0.3-test-react18.1

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 (58) hide show
  1. package/dist/cjs/index.js +330 -1044
  2. package/dist/es/components/access-type.js +51 -229
  3. package/dist/es/components/adbutler-ad.js +10 -14
  4. package/dist/es/components/api-client.js +4 -6
  5. package/dist/es/components/breaking-news-item.js +2 -3
  6. package/dist/es/components/breaking-news.js +1 -15
  7. package/dist/es/components/client-side-only.js +14 -26
  8. package/dist/es/components/collection.js +5 -5
  9. package/dist/es/components/dfp-ad.js +23 -30
  10. package/dist/es/components/eager-load-images.js +1 -9
  11. package/dist/es/components/hamburger-button.js +2 -5
  12. package/dist/es/components/image-gallery.js +10 -13
  13. package/dist/es/components/impl/collection-impl.js +2 -8
  14. package/dist/es/components/impl/gumlet-image.js +8 -15
  15. package/dist/es/components/impl/image-utils.js +3 -3
  16. package/dist/es/components/impl/load-more-stories-manager.js +0 -11
  17. package/dist/es/components/impl/thumbor-image.js +0 -15
  18. package/dist/es/components/infinite-scroll.js +3 -51
  19. package/dist/es/components/infinite-story-base.js +1 -16
  20. package/dist/es/components/lazy-collection.js +8 -8
  21. package/dist/es/components/lazy-load-images.js +36 -66
  22. package/dist/es/components/link-base.js +11 -19
  23. package/dist/es/components/link.js +1 -4
  24. package/dist/es/components/load-more-collection-stories.js +1 -10
  25. package/dist/es/components/load-more-stories-base.js +0 -12
  26. package/dist/es/components/loading-indicator.js +1 -5
  27. package/dist/es/components/menu-item.js +6 -10
  28. package/dist/es/components/menu.js +6 -9
  29. package/dist/es/components/responsive-hero-image.js +1 -3
  30. package/dist/es/components/responsive-image.js +0 -5
  31. package/dist/es/components/responsive-source.js +1 -1
  32. package/dist/es/components/review-rating/review-rating.js +21 -27
  33. package/dist/es/components/review-rating/star-icon.js +3 -5
  34. package/dist/es/components/search-box.js +1 -15
  35. package/dist/es/components/search-page-base.js +1 -10
  36. package/dist/es/components/social-logins/with-facebook-login.js +10 -20
  37. package/dist/es/components/social-logins/with-google-login.js +8 -18
  38. package/dist/es/components/social-logins/with-linkedin-login.js +7 -12
  39. package/dist/es/components/social-logins/with-social-login.js +1 -13
  40. package/dist/es/components/social-logins/with-twitter-login.js +7 -7
  41. package/dist/es/components/social-share.js +1 -15
  42. package/dist/es/components/story-element.js +27 -66
  43. package/dist/es/components/story-elements/dailymotion.js +2 -30
  44. package/dist/es/components/story-elements/jsembed.js +0 -17
  45. package/dist/es/components/story-elements/polltype.js +0 -12
  46. package/dist/es/components/story-elements/table.js +4 -20
  47. package/dist/es/components/story-elements/youtube.js +9 -45
  48. package/dist/es/components/update-on-interval.js +1 -18
  49. package/dist/es/components/with-client-side-only.js +3 -4
  50. package/dist/es/components/with-error.js +1 -12
  51. package/dist/es/components/with-host-url.js +4 -9
  52. package/dist/es/components/with-lazy.js +1 -13
  53. package/dist/es/components/with-member.js +7 -23
  54. package/dist/es/components/with-preview.js +1 -12
  55. package/dist/es/components/wrap-collection-layout.js +4 -16
  56. package/dist/es/store/reducers.js +1 -45
  57. package/dist/es/utils.js +7 -12
  58. package/package.json +6 -4
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { WithSocialLogin } from './with-social-login';
3
+
3
4
  /**
4
5
  * @see {@link WithSocialLogin}
5
6
  * @component
6
7
  * @category Login
7
8
  */
8
-
9
9
  export function WithFacebookLogin(_ref) {
10
10
  var appId = _ref.appId,
11
- children = _ref.children,
12
- scope = _ref.scope,
13
- emailMandatory = _ref.emailMandatory,
14
- redirectUrl = _ref.redirectUrl,
15
- sso = _ref.sso,
16
- isBridgekeeperLogin = _ref.isBridgekeeperLogin;
11
+ children = _ref.children,
12
+ scope = _ref.scope,
13
+ emailMandatory = _ref.emailMandatory,
14
+ redirectUrl = _ref.redirectUrl,
15
+ sso = _ref.sso,
16
+ isBridgekeeperLogin = _ref.isBridgekeeperLogin;
17
17
  return /*#__PURE__*/React.createElement(WithSocialLogin, {
18
18
  provider: 'facebook',
19
19
  initialize: function initialize() {
@@ -31,12 +31,10 @@ export function WithFacebookLogin(_ref) {
31
31
  isBridgekeeperLogin: isBridgekeeperLogin
32
32
  });
33
33
  }
34
-
35
34
  function loadFacebookSDK(appId) {
36
35
  if (global.FB) {
37
36
  return;
38
37
  }
39
-
40
38
  global.fbAsyncInit = global.fbAsyncInit || function () {
41
39
  global.FB.init({
42
40
  appId: appId,
@@ -44,22 +42,18 @@ function loadFacebookSDK(appId) {
44
42
  version: 'v3.1'
45
43
  });
46
44
  };
47
-
48
45
  (function (d, s, id) {
49
46
  var js,
50
- fjs = d.getElementsByTagName(s)[0];
51
-
47
+ fjs = d.getElementsByTagName(s)[0];
52
48
  if (d.getElementById(id)) {
53
49
  return;
54
50
  }
55
-
56
51
  js = d.createElement(s);
57
52
  js.id = id;
58
53
  js.src = "https://connect.facebook.net/en_US/sdk.js";
59
54
  fjs.parentNode.insertBefore(js, fjs);
60
55
  })(document, 'script', 'facebook-jssdk');
61
56
  }
62
-
63
57
  function fbLogin(params) {
64
58
  return new Promise(function (resolve, reject) {
65
59
  return global.FB.login(function (response) {
@@ -69,7 +63,6 @@ function fbLogin(params) {
69
63
  }, params);
70
64
  });
71
65
  }
72
-
73
66
  function fbVerifyEmailExists(token) {
74
67
  return new Promise(function (resolve, reject) {
75
68
  return global.FB.api('/me', {
@@ -79,16 +72,13 @@ function fbVerifyEmailExists(token) {
79
72
  });
80
73
  });
81
74
  }
82
-
83
75
  function loginWithFacebook() {
84
76
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
85
- scope = _ref2.scope,
86
- emailMandatory = _ref2.emailMandatory;
87
-
77
+ scope = _ref2.scope,
78
+ emailMandatory = _ref2.emailMandatory;
88
79
  if (!global.FB) {
89
80
  return Promise.reject('NOT_LOADED');
90
81
  }
91
-
92
82
  return fbLogin({
93
83
  scope: scope
94
84
  }).then(function (token) {
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { WithSocialLogin } from './with-social-login';
3
+
3
4
  /**
4
5
  * @see {@link WithSocialLogin}
5
6
  * @component
6
7
  * @category Login
7
8
  */
8
-
9
9
  export function WithGoogleLogin(_ref) {
10
10
  var clientId = _ref.clientId,
11
- children = _ref.children,
12
- scope = _ref.scope,
13
- emailMandatory = _ref.emailMandatory,
14
- redirectUrl = _ref.redirectUrl,
15
- sso = _ref.sso,
16
- isBridgekeeperLogin = _ref.isBridgekeeperLogin;
11
+ children = _ref.children,
12
+ scope = _ref.scope,
13
+ emailMandatory = _ref.emailMandatory,
14
+ redirectUrl = _ref.redirectUrl,
15
+ sso = _ref.sso,
16
+ isBridgekeeperLogin = _ref.isBridgekeeperLogin;
17
17
  return /*#__PURE__*/React.createElement(WithSocialLogin, {
18
18
  provider: 'google',
19
19
  initialize: function initialize() {
@@ -30,7 +30,6 @@ export function WithGoogleLogin(_ref) {
30
30
  isBridgekeeperLogin: isBridgekeeperLogin
31
31
  });
32
32
  }
33
-
34
33
  var onScriptLoaded = function onScriptLoaded(clientId, scope) {
35
34
  global.gapi.load('client:auth2', function () {
36
35
  return global.gapi.client.init({
@@ -39,21 +38,16 @@ var onScriptLoaded = function onScriptLoaded(clientId, scope) {
39
38
  });
40
39
  });
41
40
  };
42
-
43
41
  var loginWithGoogle = function loginWithGoogle() {
44
42
  var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
45
- emailMandatory = _ref2.emailMandatory;
46
-
43
+ emailMandatory = _ref2.emailMandatory;
47
44
  if (!global.gapi || !global.gapi.client) {
48
45
  return Promise.reject("NOT_LOADED");
49
46
  }
50
-
51
47
  var GoogleAuth = global.gapi.auth2.getAuthInstance();
52
-
53
48
  if (!GoogleAuth) {
54
49
  return Promise.reject("NOT_LOADED");
55
50
  }
56
-
57
51
  return GoogleAuth.signIn().then(function (response) {
58
52
  return emailMandatory && !response.getBasicProfile().getEmail() ? Promise.reject('NO_EMAIL') : {
59
53
  'access-token': response.getAuthResponse().access_token
@@ -62,20 +56,16 @@ var loginWithGoogle = function loginWithGoogle() {
62
56
  return Promise.reject('NOT_GRANTED');
63
57
  });
64
58
  };
65
-
66
59
  var loadGoogleSDK = function loadGoogleSDK(clientId, scope) {
67
60
  if (global.gapi) {
68
61
  return;
69
62
  }
70
-
71
63
  var script = document.createElement('script');
72
64
  script.src = 'https://apis.google.com/js/api.js';
73
65
  script.async = true;
74
66
  script.defer = true;
75
-
76
67
  script.onload = function () {
77
68
  return onScriptLoaded(clientId, scope);
78
69
  };
79
-
80
70
  document.getElementsByTagName('body')[0].appendChild(script);
81
71
  };
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { WithSocialLogin } from './with-social-login';
3
+
3
4
  /**
4
5
  * @see {@link WithSocialLogin}
5
6
  * @component
6
7
  * @category Login
7
8
  */
8
-
9
9
  export function WithLinkedInLogin(_ref) {
10
10
  var clientKey = _ref.clientKey,
11
- children = _ref.children,
12
- scope = _ref.scope,
13
- emailMandatory = _ref.emailMandatory,
14
- redirectUrl = _ref.redirectUrl,
15
- sso = _ref.sso,
16
- isBridgekeeperLogin = _ref.isBridgekeeperLogin;
11
+ children = _ref.children,
12
+ scope = _ref.scope,
13
+ emailMandatory = _ref.emailMandatory,
14
+ redirectUrl = _ref.redirectUrl,
15
+ sso = _ref.sso,
16
+ isBridgekeeperLogin = _ref.isBridgekeeperLogin;
17
17
  return /*#__PURE__*/React.createElement(WithSocialLogin, {
18
18
  provider: 'linkedin',
19
19
  initialize: function initialize() {
@@ -30,12 +30,10 @@ export function WithLinkedInLogin(_ref) {
30
30
  isBridgekeeperLogin: isBridgekeeperLogin
31
31
  });
32
32
  }
33
-
34
33
  var loadLinkedInSdk = function loadLinkedInSdk(clientKey, scope) {
35
34
  if (global.IN) {
36
35
  return;
37
36
  }
38
-
39
37
  var script = document.createElement('script');
40
38
  script.src = '//platform.linkedin.com/in.js';
41
39
  script.type = 'text/javascript';
@@ -44,14 +42,11 @@ var loadLinkedInSdk = function loadLinkedInSdk(clientKey, scope) {
44
42
  script.innerHTML = "\n api_key: ".concat(clientKey, "\n");
45
43
  document.getElementsByTagName('body')[0].appendChild(script);
46
44
  };
47
-
48
45
  var loginWithLinkedIn = function loginWithLinkedIn(_ref2) {
49
46
  var emailMandatory = _ref2.emailMandatory;
50
-
51
47
  if (!global.IN || !global.IN.User) {
52
48
  return Promise.reject("NOT_LOADED");
53
49
  }
54
-
55
50
  return new Promise(function (resolve, reject) {
56
51
  global.IN.User.authorize(function (e) {
57
52
  if (global.IN.User.isAuthorized()) {
@@ -3,14 +3,12 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import { bool, func, string } from 'prop-types';
12
9
  import React from 'react';
13
10
  import { postRequest } from '../api-client';
11
+
14
12
  /**
15
13
  * This is an abstract render props component for logging in with social accounts. The component adds two items to scope: `serverSideLoginPath` for redirecting to server side, and `login` for doing a client side login. Calling `login()` returns a promise which can be used to handle success and failure cases.
16
14
  *
@@ -58,17 +56,12 @@ import { postRequest } from '../api-client';
58
56
  * @hideconstructor
59
57
  * @category Login
60
58
  */
61
-
62
59
  export var WithSocialLogin = /*#__PURE__*/function (_React$Component) {
63
60
  _inherits(WithSocialLogin, _React$Component);
64
-
65
61
  var _super = /*#__PURE__*/_createSuper(WithSocialLogin);
66
-
67
62
  function WithSocialLogin(props) {
68
63
  var _this;
69
-
70
64
  _classCallCheck(this, WithSocialLogin);
71
-
72
65
  _this = _super.call(this, props);
73
66
  _this.bridgekeeperServerLoginPath = "/api/auth/v1/login?auth-provider=".concat(_this.props.provider, "&redirect-url=").concat(_this.props.redirectUrl ? _this.props.redirectUrl : global.location && global.location.origin);
74
67
  _this.defaultServerLoginPath = "/login?auth-provider=".concat(_this.props.provider, "&remote-host=").concat(global.location && global.location.origin);
@@ -76,7 +69,6 @@ export var WithSocialLogin = /*#__PURE__*/function (_React$Component) {
76
69
  _this.serverSideSSOLoginPath = "/login?auth-provider=".concat(_this.props.provider, "&redirect-url=").concat(_this.props.sso && _this.props.redirectUrl ? _this.props.redirectUrl : global.location && global.location.origin);
77
70
  return _this;
78
71
  }
79
-
80
72
  _createClass(WithSocialLogin, [{
81
73
  key: "componentDidMount",
82
74
  value: function componentDidMount() {
@@ -86,7 +78,6 @@ export var WithSocialLogin = /*#__PURE__*/function (_React$Component) {
86
78
  key: "render",
87
79
  value: function render() {
88
80
  var _this2 = this;
89
-
90
81
  return this.props.children({
91
82
  login: function login(props) {
92
83
  return _this2.props.socialLogin.call(_this2, props).then(function (token) {
@@ -97,10 +88,8 @@ export var WithSocialLogin = /*#__PURE__*/function (_React$Component) {
97
88
  });
98
89
  }
99
90
  }]);
100
-
101
91
  return WithSocialLogin;
102
92
  }(React.Component);
103
-
104
93
  function createSession(provider, token) {
105
94
  return postRequest("/api/login/".concat(provider), {
106
95
  token: token,
@@ -109,7 +98,6 @@ function createSession(provider, token) {
109
98
  return r;
110
99
  });
111
100
  }
112
-
113
101
  WithSocialLogin.defaultProps = {
114
102
  initialize: function initialize() {},
115
103
  // function is rebound in WithSocialLogin
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import { WithSocialLogin } from './with-social-login';
3
+
3
4
  /**
4
5
  * @see {@link WithSocialLogin}
5
6
  * @component
6
7
  * @category Login
7
8
  */
8
-
9
9
  export function WithTwitterLogin(_ref) {
10
10
  var clientId = _ref.clientId,
11
- children = _ref.children,
12
- scope = _ref.scope,
13
- emailMandatory = _ref.emailMandatory,
14
- redirectUrl = _ref.redirectUrl,
15
- sso = _ref.sso,
16
- isBridgekeeperLogin = _ref.isBridgekeeperLogin;
11
+ children = _ref.children,
12
+ scope = _ref.scope,
13
+ emailMandatory = _ref.emailMandatory,
14
+ redirectUrl = _ref.redirectUrl,
15
+ sso = _ref.sso,
16
+ isBridgekeeperLogin = _ref.isBridgekeeperLogin;
17
17
  return /*#__PURE__*/React.createElement(WithSocialLogin, {
18
18
  provider: 'twitter',
19
19
  children: children,
@@ -3,20 +3,15 @@ import _createClass from "@babel/runtime/helpers/createClass";
3
3
  import _inherits from "@babel/runtime/helpers/inherits";
4
4
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
5
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
-
7
6
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
8
-
9
7
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
8
  import React from "react";
12
9
  import { connect } from "react-redux";
13
10
  import { withError } from './with-error';
14
-
15
11
  function getNativeShareHandler(canNativeShare, title, fullUrl) {
16
12
  if (!canNativeShare) {
17
13
  return null;
18
14
  }
19
-
20
15
  return function handleShare() {
21
16
  window.navigator.share({
22
17
  title: title,
@@ -24,24 +19,18 @@ function getNativeShareHandler(canNativeShare, title, fullUrl) {
24
19
  })["catch"](console.error);
25
20
  };
26
21
  }
27
-
28
22
  var SocialShareBase = /*#__PURE__*/function (_React$Component) {
29
23
  _inherits(SocialShareBase, _React$Component);
30
-
31
24
  var _super = /*#__PURE__*/_createSuper(SocialShareBase);
32
-
33
25
  function SocialShareBase(props) {
34
26
  var _this;
35
-
36
27
  _classCallCheck(this, SocialShareBase);
37
-
38
28
  _this = _super.call(this, props);
39
29
  _this.state = {
40
30
  canNativeShare: false
41
31
  };
42
32
  return _this;
43
33
  }
44
-
45
34
  _createClass(SocialShareBase, [{
46
35
  key: "componentDidMount",
47
36
  value: function componentDidMount() {
@@ -65,15 +54,14 @@ var SocialShareBase = /*#__PURE__*/function (_React$Component) {
65
54
  }, this.props));
66
55
  }
67
56
  }]);
68
-
69
57
  return SocialShareBase;
70
58
  }(React.Component);
71
-
72
59
  function mapStateToProps(state) {
73
60
  return {
74
61
  publisherUrl: state.qt.config["sketches-host"]
75
62
  };
76
63
  }
64
+
77
65
  /**
78
66
  * This component renders social share component to front end app.
79
67
  *
@@ -111,6 +99,4 @@ function mapStateToProps(state) {
111
99
  * @component
112
100
  * @category Story Page
113
101
  */
114
-
115
-
116
102
  export var SocialShare = /*#__PURE__*/connect(mapStateToProps, {})( /*#__PURE__*/withError(SocialShareBase));
@@ -7,15 +7,10 @@ import _inherits from "@babel/runtime/helpers/inherits";
7
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
9
  var _excluded = ["renderTemplates"];
10
-
11
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
12
-
13
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
14
-
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
12
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
16
-
17
13
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
18
-
19
14
  import classNames from "classnames";
20
15
  import get from "lodash/get";
21
16
  import React from "react";
@@ -27,6 +22,7 @@ import JSEmbed from "./story-elements/jsembed";
27
22
  import Polltype from "./story-elements/polltype";
28
23
  import { Table } from "./story-elements/table";
29
24
  import StoryElementYoutube from "./story-elements/youtube";
25
+
30
26
  /**
31
27
  * This component renders different types of [story elements](https://developers.quintype.com/malibu/terminology#story-elements)
32
28
 
@@ -52,24 +48,18 @@ import StoryElementYoutube from "./story-elements/youtube";
52
48
  * @hideconstructor
53
49
  * @category Story Page
54
50
  */
55
-
56
51
  export var StoryElement = /*#__PURE__*/function (_React$Component) {
57
52
  _inherits(StoryElement, _React$Component);
58
-
59
53
  var _super = /*#__PURE__*/_createSuper(StoryElement);
60
-
61
54
  function StoryElement(props) {
62
55
  var _this;
63
-
64
56
  _classCallCheck(this, StoryElement);
65
-
66
57
  _this = _super.call(this, props);
67
58
  _this.state = {
68
59
  crashed: false
69
60
  };
70
61
  return _this;
71
62
  }
72
-
73
63
  _createClass(StoryElement, [{
74
64
  key: "componentDidCatch",
75
65
  value: function componentDidCatch(error, stack) {
@@ -91,32 +81,27 @@ export var StoryElement = /*#__PURE__*/function (_React$Component) {
91
81
  }
92
82
  }
93
83
  }]);
94
-
95
84
  return StoryElement;
96
85
  }(React.Component);
97
-
98
86
  function StoryElementText(_ref) {
99
87
  var _ref$element = _ref.element,
100
- element = _ref$element === void 0 ? {} : _ref$element,
101
- externalLink = _ref.externalLink;
88
+ element = _ref$element === void 0 ? {} : _ref$element,
89
+ externalLink = _ref.externalLink;
102
90
  var text = element.text || "";
103
-
104
91
  if (externalLink) {
105
92
  text = element.text.replace(/<a/g, '<a target="_blank"');
106
93
  }
107
-
108
94
  return /*#__PURE__*/React.createElement("div", {
109
95
  dangerouslySetInnerHTML: {
110
96
  __html: text
111
97
  }
112
98
  });
113
99
  }
114
-
115
100
  function StoryElementAlsoRead(_ref2) {
116
101
  var element = _ref2.element,
117
- story = _ref2.story,
118
- _ref2$alsoreadText = _ref2.alsoreadText,
119
- alsoreadText = _ref2$alsoreadText === void 0 ? "Also Read: " : _ref2$alsoreadText;
102
+ story = _ref2.story,
103
+ _ref2$alsoreadText = _ref2.alsoreadText,
104
+ alsoreadText = _ref2$alsoreadText === void 0 ? "Also Read: " : _ref2$alsoreadText;
120
105
  var linkedStories = get(story, ["linked-stories"]);
121
106
  var linkedStoryId = get(element, ["metadata", "linked-story-id"]);
122
107
  var linkedStorySlug = get(linkedStories, [linkedStoryId, "slug"]);
@@ -129,15 +114,14 @@ function StoryElementAlsoRead(_ref2) {
129
114
  className: "story-element-text-also-read__label"
130
115
  }, alsoreadText), /*#__PURE__*/React.createElement(Link, linkProps, element.text));
131
116
  }
132
-
133
117
  function StoryElementImage(_ref3) {
134
118
  var element = _ref3.element,
135
- _ref3$story = _ref3.story,
136
- story = _ref3$story === void 0 ? {} : _ref3$story,
137
- imageWidths = _ref3.imageWidths,
138
- imageDefaultWidth = _ref3.imageDefaultWidth,
139
- _ref3$onClick = _ref3.onClick,
140
- onClick = _ref3$onClick === void 0 ? function () {} : _ref3$onClick;
119
+ _ref3$story = _ref3.story,
120
+ story = _ref3$story === void 0 ? {} : _ref3$story,
121
+ imageWidths = _ref3.imageWidths,
122
+ imageDefaultWidth = _ref3.imageDefaultWidth,
123
+ _ref3$onClick = _ref3.onClick,
124
+ onClick = _ref3$onClick === void 0 ? function () {} : _ref3$onClick;
141
125
  return /*#__PURE__*/React.createElement("figure", {}, /*#__PURE__*/React.createElement(ResponsiveImage, {
142
126
  slug: element["image-s3-key"],
143
127
  metadata: element["metadata"],
@@ -163,12 +147,10 @@ function StoryElementImage(_ref3) {
163
147
  className: "story-element-image-attribution"
164
148
  }) : undefined));
165
149
  }
166
-
167
150
  function StoryElementTitle(_ref4) {
168
151
  var element = _ref4.element;
169
152
  return /*#__PURE__*/React.createElement("h2", {}, element.text);
170
153
  }
171
-
172
154
  function StoryElementSoundCloud(_ref5) {
173
155
  var element = _ref5.element;
174
156
  return /*#__PURE__*/React.createElement("iframe", {
@@ -176,7 +158,6 @@ function StoryElementSoundCloud(_ref5) {
176
158
  width: "100%"
177
159
  });
178
160
  }
179
-
180
161
  function StoryElementJsembed(_ref6) {
181
162
  var element = _ref6.element;
182
163
  return /*#__PURE__*/React.createElement(JSEmbed, {
@@ -184,14 +165,12 @@ function StoryElementJsembed(_ref6) {
184
165
  id: element["id"]
185
166
  });
186
167
  }
187
-
188
168
  function StoryElementPolltype(_ref7) {
189
169
  var element = _ref7.element;
190
170
  return /*#__PURE__*/React.createElement(Polltype, {
191
171
  id: element["polltype-id"]
192
172
  });
193
173
  }
194
-
195
174
  function StoryElementTable(_ref8) {
196
175
  var element = _ref8.element;
197
176
  return /*#__PURE__*/React.createElement(Table, {
@@ -200,7 +179,6 @@ function StoryElementTable(_ref8) {
200
179
  hasHeader: element.metadata["has-header"]
201
180
  });
202
181
  }
203
-
204
182
  function StoryElementFile(_ref9) {
205
183
  var element = _ref9.element;
206
184
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -210,9 +188,10 @@ function StoryElementFile(_ref9) {
210
188
  href: element.url,
211
189
  download: true
212
190
  }, "download"));
213
- } // FIXME MISSING: composite
214
- // TODO: Can also support various subtypes (though not needed potentially)
191
+ }
215
192
 
193
+ // FIXME MISSING: composite
194
+ // TODO: Can also support various subtypes (though not needed potentially)
216
195
 
217
196
  var DEFAULT_TEMPLATES = {
218
197
  text: StoryElementText,
@@ -227,19 +206,13 @@ var DEFAULT_TEMPLATES = {
227
206
  "also-read": StoryElementAlsoRead,
228
207
  file: StoryElementFile
229
208
  };
230
-
231
209
  var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
232
210
  _inherits(StoryElementBase, _React$Component2);
233
-
234
211
  var _super2 = /*#__PURE__*/_createSuper(StoryElementBase);
235
-
236
212
  function StoryElementBase(props) {
237
213
  var _this2;
238
-
239
214
  _classCallCheck(this, StoryElementBase);
240
-
241
215
  _this2 = _super2.call(this, props);
242
-
243
216
  _defineProperty(_assertThisInitialized(_this2), "initiateObserver", function () {
244
217
  if (_this2.props.disableAnalytics === true) return false;
245
218
  var options = {
@@ -248,14 +221,11 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
248
221
  threshold: 1.0
249
222
  };
250
223
  _this2.observer = new IntersectionObserver(_this2.observerCallback, options);
251
-
252
224
  _this2.observer.observe(_this2.storyElementRef);
253
225
  });
254
-
255
226
  _defineProperty(_assertThisInitialized(_this2), "destroyObserver", function () {
256
227
  _this2.observer && _this2.observer.disconnect();
257
228
  });
258
-
259
229
  _defineProperty(_assertThisInitialized(_this2), "observerCallback", function (entries) {
260
230
  entries.forEach(function (entry) {
261
231
  if (entry.isIntersecting) {
@@ -263,12 +233,10 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
263
233
  }
264
234
  });
265
235
  });
266
-
267
236
  _this2.observer = null;
268
237
  _this2.storyElementRef = null;
269
238
  return _this2;
270
239
  }
271
-
272
240
  _createClass(StoryElementBase, [{
273
241
  key: "componentDidMount",
274
242
  value: function componentDidMount() {
@@ -290,20 +258,18 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
290
258
  key: "emitElementQlitics",
291
259
  value: function emitElementQlitics() {
292
260
  var _this$props = this.props,
293
- _this$props$story = _this$props.story,
294
- story = _this$props$story === void 0 ? {} : _this$props$story,
295
- _this$props$card = _this$props.card,
296
- card = _this$props$card === void 0 ? {} : _this$props$card,
297
- _this$props$element = _this$props.element,
298
- element = _this$props$element === void 0 ? {} : _this$props$element;
299
-
261
+ _this$props$story = _this$props.story,
262
+ story = _this$props$story === void 0 ? {} : _this$props$story,
263
+ _this$props$card = _this$props.card,
264
+ card = _this$props$card === void 0 ? {} : _this$props$card,
265
+ _this$props$element = _this$props.element,
266
+ element = _this$props$element === void 0 ? {} : _this$props$element;
300
267
  if (global.qlitics) {
301
268
  global.qlitics("track", "story-element-view", getQliticsSchema(story, card, element));
302
269
  } else {
303
270
  global.qlitics = global.qlitics || function () {
304
271
  (qlitics.q = qlitics.q || []).push(arguments);
305
272
  };
306
-
307
273
  global.qlitics("track", "story-element-view", getQliticsSchema(story, card, element));
308
274
  }
309
275
  }
@@ -316,18 +282,15 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
316
282
  key: "render",
317
283
  value: function render() {
318
284
  var _classNames,
319
- _this3 = this;
320
-
285
+ _this3 = this;
321
286
  var storyElement = this.props.element;
322
287
  var typeClassName = "story-element-".concat(storyElement.type);
323
288
  var subtypeClassName = "story-element-".concat(storyElement.type, "-").concat(storyElement.subtype);
324
289
  var storyElementTemplate = this.template();
325
-
326
290
  var _this$props2 = this.props,
327
- _this$props2$renderTe = _this$props2.renderTemplates,
328
- renderTemplates = _this$props2$renderTe === void 0 ? {} : _this$props2$renderTe,
329
- elementProps = _objectWithoutProperties(_this$props2, _excluded);
330
-
291
+ _this$props2$renderTe = _this$props2.renderTemplates,
292
+ renderTemplates = _this$props2$renderTe === void 0 ? {} : _this$props2$renderTe,
293
+ elementProps = _objectWithoutProperties(_this$props2, _excluded);
331
294
  var renderTemplate = renderTemplates[storyElement.subtype] || renderTemplates[storyElement.type];
332
295
  return /*#__PURE__*/React.createElement("div", {
333
296
  className: classNames((_classNames = {
@@ -339,8 +302,6 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
339
302
  }, renderTemplate ? /*#__PURE__*/React.createElement(renderTemplate, _objectSpread({}, elementProps), /*#__PURE__*/React.createElement(storyElementTemplate, Object.assign({}, elementProps))) : /*#__PURE__*/React.createElement(storyElementTemplate, Object.assign({}, elementProps)));
340
303
  }
341
304
  }]);
342
-
343
305
  return StoryElementBase;
344
306
  }(React.Component);
345
-
346
307
  export var STORY_ELEMENT_TEMPLATES = DEFAULT_TEMPLATES;