@quintype/components 3.8.8-only-react-v19.2 → 3.8.8

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 (61) hide show
  1. package/dist/cjs/index.js +2041 -1091
  2. package/dist/es/components/access-type.js +822 -574
  3. package/dist/es/components/adbutler-ad.js +14 -10
  4. package/dist/es/components/api-client.js +6 -4
  5. package/dist/es/components/breaking-news-item.js +3 -2
  6. package/dist/es/components/breaking-news.js +23 -7
  7. package/dist/es/components/client-side-only.js +19 -6
  8. package/dist/es/components/collection.js +5 -5
  9. package/dist/es/components/dfp-ad.js +30 -23
  10. package/dist/es/components/eager-load-images.js +17 -7
  11. package/dist/es/components/hamburger-button.js +5 -2
  12. package/dist/es/components/image-gallery.js +13 -10
  13. package/dist/es/components/impl/collection-impl.js +10 -3
  14. package/dist/es/components/impl/gumlet-image.js +19 -10
  15. package/dist/es/components/impl/image-utils.js +4 -3
  16. package/dist/es/components/impl/load-more-stories-manager.js +19 -6
  17. package/dist/es/components/impl/thumbor-image.js +32 -10
  18. package/dist/es/components/infinite-scroll.js +85 -29
  19. package/dist/es/components/infinite-story-base.js +24 -7
  20. package/dist/es/components/lazy-collection.js +8 -8
  21. package/dist/es/components/lazy-load-images.js +43 -10
  22. package/dist/es/components/link-base.js +19 -11
  23. package/dist/es/components/link.js +4 -1
  24. package/dist/es/components/load-more-collection-stories.js +18 -7
  25. package/dist/es/components/load-more-stories-base.js +20 -6
  26. package/dist/es/components/loading-indicator.js +5 -1
  27. package/dist/es/components/menu-item.js +10 -6
  28. package/dist/es/components/menu.js +9 -6
  29. package/dist/es/components/responsive-hero-image.js +3 -1
  30. package/dist/es/components/responsive-image.js +5 -0
  31. package/dist/es/components/responsive-source.js +1 -1
  32. package/dist/es/components/review-rating/review-rating.js +27 -21
  33. package/dist/es/components/review-rating/star-icon.js +5 -3
  34. package/dist/es/components/search-box.js +23 -7
  35. package/dist/es/components/search-page-base.js +18 -7
  36. package/dist/es/components/social-logins/with-facebook-login.js +20 -10
  37. package/dist/es/components/social-logins/with-google-login.js +18 -8
  38. package/dist/es/components/social-logins/with-linkedin-login.js +12 -7
  39. package/dist/es/components/social-logins/with-social-login.js +21 -7
  40. package/dist/es/components/social-logins/with-twitter-login.js +7 -7
  41. package/dist/es/components/social-share.js +24 -8
  42. package/dist/es/components/story-element.js +88 -43
  43. package/dist/es/components/story-elements/brightcove.js +94 -54
  44. package/dist/es/components/story-elements/dailymotion-embed-script.js +39 -13
  45. package/dist/es/components/story-elements/dailymotion.js +61 -19
  46. package/dist/es/components/story-elements/jsembed.js +30 -10
  47. package/dist/es/components/story-elements/jwPlayer.js +24 -9
  48. package/dist/es/components/story-elements/polltype.js +20 -6
  49. package/dist/es/components/story-elements/table.js +34 -16
  50. package/dist/es/components/story-elements/youtube.js +73 -24
  51. package/dist/es/components/update-on-interval.js +52 -31
  52. package/dist/es/components/with-client-side-only.js +4 -3
  53. package/dist/es/components/with-error.js +20 -7
  54. package/dist/es/components/with-host-url.js +9 -4
  55. package/dist/es/components/with-lazy.js +21 -7
  56. package/dist/es/components/with-member.js +33 -14
  57. package/dist/es/components/with-preview.js +20 -7
  58. package/dist/es/components/wrap-collection-layout.js +16 -4
  59. package/dist/es/store/reducers.js +45 -1
  60. package/dist/es/utils.js +12 -7
  61. package/package.json +7 -16
@@ -1,15 +1,21 @@
1
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
5
  import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
5
7
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
8
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _inherits from "@babel/runtime/helpers/inherits";
8
9
  var _excluded = ["renderTemplates"];
9
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
10
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
11
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
12
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
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
+
15
+ 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
+ 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
+
13
19
  import classNames from "classnames";
14
20
  import get from "lodash/get";
15
21
  import React from "react";
@@ -24,7 +30,6 @@ import StoryElementJwPlayer from "./story-elements/jwPlayer";
24
30
  import Polltype from "./story-elements/polltype";
25
31
  import { Table } from "./story-elements/table";
26
32
  import StoryElementYoutube from "./story-elements/youtube";
27
-
28
33
  /**
29
34
  * This component renders different types of [story elements](https://developers.quintype.com/malibu/terminology#story-elements)
30
35
 
@@ -50,18 +55,25 @@ import StoryElementYoutube from "./story-elements/youtube";
50
55
  * @hideconstructor
51
56
  * @category Story Page
52
57
  */
58
+
53
59
  export var StoryElement = /*#__PURE__*/function (_React$Component) {
60
+ _inherits(StoryElement, _React$Component);
61
+
62
+ var _super = /*#__PURE__*/_createSuper(StoryElement);
63
+
54
64
  function StoryElement(props) {
55
65
  var _this;
66
+
56
67
  _classCallCheck(this, StoryElement);
57
- _this = _callSuper(this, StoryElement, [props]);
68
+
69
+ _this = _super.call(this, props);
58
70
  _this.state = {
59
71
  crashed: false
60
72
  };
61
73
  return _this;
62
74
  }
63
- _inherits(StoryElement, _React$Component);
64
- return _createClass(StoryElement, [{
75
+
76
+ _createClass(StoryElement, [{
65
77
  key: "componentDidCatch",
66
78
  value: function componentDidCatch(error, stack) {
67
79
  this.setState({
@@ -82,26 +94,32 @@ export var StoryElement = /*#__PURE__*/function (_React$Component) {
82
94
  }
83
95
  }
84
96
  }]);
97
+
98
+ return StoryElement;
85
99
  }(React.Component);
100
+
86
101
  function StoryElementText(_ref) {
87
102
  var _ref$element = _ref.element,
88
- element = _ref$element === void 0 ? {} : _ref$element,
89
- externalLink = _ref.externalLink;
103
+ element = _ref$element === void 0 ? {} : _ref$element,
104
+ externalLink = _ref.externalLink;
90
105
  var text = element.text || "";
106
+
91
107
  if (externalLink) {
92
108
  text = element.text.replace(/<a/g, '<a target="_blank"');
93
109
  }
110
+
94
111
  return /*#__PURE__*/React.createElement("div", {
95
112
  dangerouslySetInnerHTML: {
96
113
  __html: text
97
114
  }
98
115
  });
99
116
  }
117
+
100
118
  function StoryElementAlsoRead(_ref2) {
101
119
  var element = _ref2.element,
102
- story = _ref2.story,
103
- _ref2$alsoreadText = _ref2.alsoreadText,
104
- alsoreadText = _ref2$alsoreadText === void 0 ? "Also Read: " : _ref2$alsoreadText;
120
+ story = _ref2.story,
121
+ _ref2$alsoreadText = _ref2.alsoreadText,
122
+ alsoreadText = _ref2$alsoreadText === void 0 ? "Also Read: " : _ref2$alsoreadText;
105
123
  var linkedStories = get(story, ["linked-stories"]);
106
124
  var linkedStoryId = get(element, ["metadata", "linked-story-id"]);
107
125
  var linkedStorySlug = get(linkedStories, [linkedStoryId, "slug"]);
@@ -114,14 +132,15 @@ function StoryElementAlsoRead(_ref2) {
114
132
  className: "story-element-text-also-read__label"
115
133
  }, alsoreadText), /*#__PURE__*/React.createElement(Link, linkProps, element.text));
116
134
  }
135
+
117
136
  function StoryElementImage(_ref3) {
118
137
  var element = _ref3.element,
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;
138
+ _ref3$story = _ref3.story,
139
+ story = _ref3$story === void 0 ? {} : _ref3$story,
140
+ imageWidths = _ref3.imageWidths,
141
+ imageDefaultWidth = _ref3.imageDefaultWidth,
142
+ _ref3$onClick = _ref3.onClick,
143
+ onClick = _ref3$onClick === void 0 ? function () {} : _ref3$onClick;
125
144
  return /*#__PURE__*/React.createElement("figure", {}, /*#__PURE__*/React.createElement(ResponsiveImage, {
126
145
  slug: element["image-s3-key"],
127
146
  metadata: element["metadata"],
@@ -147,10 +166,12 @@ function StoryElementImage(_ref3) {
147
166
  className: "story-element-image-attribution"
148
167
  }) : undefined));
149
168
  }
169
+
150
170
  function StoryElementTitle(_ref4) {
151
171
  var element = _ref4.element;
152
172
  return /*#__PURE__*/React.createElement("h2", {}, element.text);
153
173
  }
174
+
154
175
  function StoryElementSoundCloud(_ref5) {
155
176
  var element = _ref5.element;
156
177
  return /*#__PURE__*/React.createElement("iframe", {
@@ -158,6 +179,7 @@ function StoryElementSoundCloud(_ref5) {
158
179
  width: "100%"
159
180
  });
160
181
  }
182
+
161
183
  function StoryElementJsembed(_ref6) {
162
184
  var element = _ref6.element;
163
185
  return /*#__PURE__*/React.createElement(JSEmbed, {
@@ -165,12 +187,14 @@ function StoryElementJsembed(_ref6) {
165
187
  id: element["id"]
166
188
  });
167
189
  }
190
+
168
191
  function StoryElementPolltype(_ref7) {
169
192
  var element = _ref7.element;
170
193
  return /*#__PURE__*/React.createElement(Polltype, {
171
194
  id: element["polltype-id"]
172
195
  });
173
196
  }
197
+
174
198
  function StoryElementTable(_ref8) {
175
199
  var element = _ref8.element;
176
200
  return /*#__PURE__*/React.createElement(Table, {
@@ -179,6 +203,7 @@ function StoryElementTable(_ref8) {
179
203
  hasHeader: element.metadata["has-header"]
180
204
  });
181
205
  }
206
+
182
207
  function StoryElementFile(_ref9) {
183
208
  var element = _ref9.element;
184
209
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
@@ -188,11 +213,10 @@ function StoryElementFile(_ref9) {
188
213
  href: element.url,
189
214
  download: true
190
215
  }, "download"));
191
- }
192
-
193
- // FIXME MISSING: composite
216
+ } // FIXME MISSING: composite
194
217
  // TODO: Can also support various subtypes (though not needed potentially)
195
218
 
219
+
196
220
  var DEFAULT_TEMPLATES = {
197
221
  text: StoryElementText,
198
222
  image: StoryElementImage,
@@ -209,12 +233,20 @@ var DEFAULT_TEMPLATES = {
209
233
  "brightcove-video": StoryElementBrightcove,
210
234
  "jwplayer": StoryElementJwPlayer
211
235
  };
236
+
212
237
  var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
238
+ _inherits(StoryElementBase, _React$Component2);
239
+
240
+ var _super2 = /*#__PURE__*/_createSuper(StoryElementBase);
241
+
213
242
  function StoryElementBase(props) {
214
243
  var _this2;
244
+
215
245
  _classCallCheck(this, StoryElementBase);
216
- _this2 = _callSuper(this, StoryElementBase, [props]);
217
- _defineProperty(_this2, "initiateObserver", function () {
246
+
247
+ _this2 = _super2.call(this, props);
248
+
249
+ _defineProperty(_assertThisInitialized(_this2), "initiateObserver", function () {
218
250
  if (_this2.props.disableAnalytics === true) return false;
219
251
  var options = {
220
252
  root: null,
@@ -222,24 +254,28 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
222
254
  threshold: 1.0
223
255
  };
224
256
  _this2.observer = new IntersectionObserver(_this2.observerCallback, options);
257
+
225
258
  _this2.observer.observe(_this2.storyElementRef);
226
259
  });
227
- _defineProperty(_this2, "destroyObserver", function () {
260
+
261
+ _defineProperty(_assertThisInitialized(_this2), "destroyObserver", function () {
228
262
  _this2.observer && _this2.observer.disconnect();
229
263
  });
230
- _defineProperty(_this2, "observerCallback", function (entries) {
264
+
265
+ _defineProperty(_assertThisInitialized(_this2), "observerCallback", function (entries) {
231
266
  entries.forEach(function (entry) {
232
267
  if (entry.isIntersecting) {
233
268
  _this2.emitElementQlitics();
234
269
  }
235
270
  });
236
271
  });
272
+
237
273
  _this2.observer = null;
238
274
  _this2.storyElementRef = null;
239
275
  return _this2;
240
276
  }
241
- _inherits(StoryElementBase, _React$Component2);
242
- return _createClass(StoryElementBase, [{
277
+
278
+ _createClass(StoryElementBase, [{
243
279
  key: "componentDidMount",
244
280
  value: function componentDidMount() {
245
281
  this.initiateObserver();
@@ -260,18 +296,20 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
260
296
  key: "emitElementQlitics",
261
297
  value: function emitElementQlitics() {
262
298
  var _this$props = this.props,
263
- _this$props$story = _this$props.story,
264
- story = _this$props$story === void 0 ? {} : _this$props$story,
265
- _this$props$card = _this$props.card,
266
- card = _this$props$card === void 0 ? {} : _this$props$card,
267
- _this$props$element = _this$props.element,
268
- element = _this$props$element === void 0 ? {} : _this$props$element;
299
+ _this$props$story = _this$props.story,
300
+ story = _this$props$story === void 0 ? {} : _this$props$story,
301
+ _this$props$card = _this$props.card,
302
+ card = _this$props$card === void 0 ? {} : _this$props$card,
303
+ _this$props$element = _this$props.element,
304
+ element = _this$props$element === void 0 ? {} : _this$props$element;
305
+
269
306
  if (global.qlitics) {
270
307
  global.qlitics("track", "story-element-view", getQliticsSchema(story, card, element));
271
308
  } else {
272
309
  global.qlitics = global.qlitics || function () {
273
310
  (qlitics.q = qlitics.q || []).push(arguments);
274
311
  };
312
+
275
313
  global.qlitics("track", "story-element-view", getQliticsSchema(story, card, element));
276
314
  }
277
315
  }
@@ -283,25 +321,32 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
283
321
  }, {
284
322
  key: "render",
285
323
  value: function render() {
286
- var _this3 = this;
324
+ var _classNames,
325
+ _this3 = this;
326
+
287
327
  var storyElement = this.props.element;
288
328
  var typeClassName = "story-element-".concat(storyElement.type);
289
329
  var subtypeClassName = "story-element-".concat(storyElement.type, "-").concat(storyElement.subtype);
290
330
  var storyElementTemplate = this.template();
331
+
291
332
  var _this$props2 = this.props,
292
- _this$props2$renderTe = _this$props2.renderTemplates,
293
- renderTemplates = _this$props2$renderTe === void 0 ? {} : _this$props2$renderTe,
294
- elementProps = _objectWithoutProperties(_this$props2, _excluded);
333
+ _this$props2$renderTe = _this$props2.renderTemplates,
334
+ renderTemplates = _this$props2$renderTe === void 0 ? {} : _this$props2$renderTe,
335
+ elementProps = _objectWithoutProperties(_this$props2, _excluded);
336
+
295
337
  var renderTemplate = renderTemplates[storyElement.subtype] || renderTemplates[storyElement.type];
296
338
  return /*#__PURE__*/React.createElement("div", {
297
- className: classNames(_defineProperty(_defineProperty({
339
+ className: classNames((_classNames = {
298
340
  "story-element": true
299
- }, typeClassName, true), subtypeClassName, !!storyElement.subtype)),
300
- ref: function ref(_ref0) {
301
- return _this3.storyElementRef = _ref0;
341
+ }, _defineProperty(_classNames, typeClassName, true), _defineProperty(_classNames, subtypeClassName, !!storyElement.subtype), _classNames)),
342
+ ref: function ref(_ref10) {
343
+ return _this3.storyElementRef = _ref10;
302
344
  }
303
345
  }, renderTemplate ? /*#__PURE__*/React.createElement(renderTemplate, _objectSpread({}, elementProps), /*#__PURE__*/React.createElement(storyElementTemplate, Object.assign({}, elementProps))) : /*#__PURE__*/React.createElement(storyElementTemplate, Object.assign({}, elementProps)));
304
346
  }
305
347
  }]);
348
+
349
+ return StoryElementBase;
306
350
  }(React.Component);
351
+
307
352
  export var STORY_ELEMENT_TEMPLATES = DEFAULT_TEMPLATES;
@@ -6,41 +6,53 @@ import { bool, object } from "prop-types";
6
6
  import React, { useEffect, useRef, useState } from "react";
7
7
  import { disconnectObserver, initiateNewObserver } from "../../utils";
8
8
  import { WithLazy } from "../with-lazy";
9
+
9
10
  var BrightcoveElement = function BrightcoveElement(props) {
10
11
  var _window4;
12
+
11
13
  var _props$element = props.element,
12
- element = _props$element === void 0 ? {} : _props$element,
13
- loadIframeOnClick = props.loadIframeOnClick,
14
- _props$policyKey = props.policyKey,
15
- policyKey = _props$policyKey === void 0 ? "" : _props$policyKey;
14
+ element = _props$element === void 0 ? {} : _props$element,
15
+ loadIframeOnClick = props.loadIframeOnClick,
16
+ _props$policyKey = props.policyKey,
17
+ policyKey = _props$policyKey === void 0 ? "" : _props$policyKey;
18
+
16
19
  var _get = get(element, ["metadata"], {}),
17
- accountId = _get["account-id"],
18
- videoId = _get["video-id"],
19
- playerId = _get["player-id"];
20
+ accountId = _get["account-id"],
21
+ videoId = _get["video-id"],
22
+ playerId = _get["player-id"];
23
+
20
24
  var _useState = useState(false),
21
- _useState2 = _slicedToArray(_useState, 2),
22
- showVideo = _useState2[0],
23
- setVideoToggle = _useState2[1];
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ showVideo = _useState2[0],
27
+ setVideoToggle = _useState2[1];
28
+
24
29
  var _useState3 = useState(""),
25
- _useState4 = _slicedToArray(_useState3, 2),
26
- posterImage = _useState4[0],
27
- setPosterImage = _useState4[1];
30
+ _useState4 = _slicedToArray(_useState3, 2),
31
+ posterImage = _useState4[0],
32
+ setPosterImage = _useState4[1];
33
+
28
34
  var _useState5 = useState(null),
29
- _useState6 = _slicedToArray(_useState5, 2),
30
- myPlayer = _useState6[0],
31
- setMyPlayer = _useState6[1];
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ myPlayer = _useState6[0],
37
+ setMyPlayer = _useState6[1];
38
+
32
39
  var _useState7 = useState(false),
33
- _useState8 = _slicedToArray(_useState7, 2),
34
- thumbnailClicked = _useState8[0],
35
- setThumbnailClicked = _useState8[1];
40
+ _useState8 = _slicedToArray(_useState7, 2),
41
+ thumbnailClicked = _useState8[0],
42
+ setThumbnailClicked = _useState8[1];
43
+
36
44
  var videoRef = useRef();
37
45
  var videoPausedByObserver = useRef(); // To check if the video is not click paused by user but paused by intersection observer, Its implemented this way because we cannot capture the click-pause event as videos are playing in iframe
46
+
38
47
  var observerRef = useRef(); // To Observe video element for intersection
39
48
 
40
49
  var loadLibrary = function loadLibrary() {
41
50
  var _window;
51
+
42
52
  if (!((_window = window) !== null && _window !== void 0 && _window.BrightcovePlayerLoader)) {
43
- return import(/* webpackChunkName: "qtc-react-brightcove" */"@brightcove/react-player-loader").then(function (module) {
53
+ return import(
54
+ /* webpackChunkName: "qtc-react-brightcove" */
55
+ "@brightcove/react-player-loader").then(function (module) {
44
56
  window.BrightcovePlayerLoader = module["default"];
45
57
  setVideoToggle(true);
46
58
  })["catch"](function (err) {
@@ -48,8 +60,10 @@ var BrightcoveElement = function BrightcoveElement(props) {
48
60
  return Promise.reject();
49
61
  });
50
62
  }
63
+
51
64
  setVideoToggle(true);
52
65
  };
66
+
53
67
  useEffect(function () {
54
68
  if (!loadIframeOnClick) {
55
69
  loadLibrary();
@@ -66,16 +80,20 @@ var BrightcoveElement = function BrightcoveElement(props) {
66
80
  observerRef.current && disconnectObserver(observerRef.current);
67
81
  };
68
82
  }, [myPlayer, thumbnailClicked]);
83
+
69
84
  function intersectionCallback(entries) {
70
85
  var videoInViewPort = entries === null || entries === void 0 ? void 0 : entries[0].isIntersecting;
71
86
  if (videoInViewPort) myPlayer.play();else {
72
87
  videoPausedByObserver.current = true; // before the below line fires the pause event we set the videoPausedByObserver Ref to true, this lets the pause events callback to know that the video is not click-paused by the user but paused by the intersection observer
88
+
73
89
  myPlayer.pause();
74
90
  }
75
91
  }
92
+
76
93
  function startObserver() {
77
94
  var targetElement = videoRef.current;
78
95
  var observer = observerRef.current;
96
+
79
97
  if (observer) {
80
98
  observer.observe(targetElement);
81
99
  } else {
@@ -83,17 +101,21 @@ var BrightcoveElement = function BrightcoveElement(props) {
83
101
  observerRef.current = intersectionObserver;
84
102
  }
85
103
  }
104
+
86
105
  function handleVideoPause() {
87
106
  var observer = observerRef.current;
88
107
  var isVideoPausedByObserver = videoPausedByObserver.current;
108
+
89
109
  if (isVideoPausedByObserver) {
90
110
  videoPausedByObserver.current = false; // This is a clean up to set videoPausedByObserver back to false
91
111
  } else {
92
112
  disconnectObserver(observer);
93
113
  }
94
114
  }
115
+
95
116
  var brightcoveIframe = function brightcoveIframe() {
96
117
  var _window2;
118
+
97
119
  var BrightcovePlayerLoader = (_window2 = window) === null || _window2 === void 0 ? void 0 : _window2.BrightcovePlayerLoader;
98
120
  return /*#__PURE__*/React.createElement(BrightcovePlayerLoader, {
99
121
  accountId: accountId,
@@ -110,59 +132,75 @@ var BrightcoveElement = function BrightcoveElement(props) {
110
132
  }
111
133
  });
112
134
  };
135
+
113
136
  var getPoster = /*#__PURE__*/function () {
114
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
137
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
115
138
  var _yield$yield$fetch$js, videos;
116
- return _regeneratorRuntime.wrap(function (_context) {
117
- while (1) switch (_context.prev = _context.next) {
118
- case 0:
119
- if (posterImage) {
120
- _context.next = 3;
121
- break;
122
- }
123
- _context.next = 1;
124
- return fetch("https://edge.api.brightcove.com/playback/v1/accounts/".concat(accountId, "/videos?q=id:").concat(videoId), {
125
- headers: {
126
- "BCOV-Policy": policyKey
139
+
140
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
141
+ while (1) {
142
+ switch (_context.prev = _context.next) {
143
+ case 0:
144
+ if (posterImage) {
145
+ _context.next = 8;
146
+ break;
127
147
  }
128
- });
129
- case 1:
130
- _context.next = 2;
131
- return _context.sent.json();
132
- case 2:
133
- _yield$yield$fetch$js = _context.sent;
134
- videos = _yield$yield$fetch$js.videos;
135
- setPosterImage(videos[0].poster || "");
136
- case 3:
137
- case "end":
138
- return _context.stop();
148
+
149
+ _context.next = 3;
150
+ return fetch("https://edge.api.brightcove.com/playback/v1/accounts/".concat(accountId, "/videos?q=id:").concat(videoId), {
151
+ headers: {
152
+ "BCOV-Policy": policyKey
153
+ }
154
+ });
155
+
156
+ case 3:
157
+ _context.next = 5;
158
+ return _context.sent.json();
159
+
160
+ case 5:
161
+ _yield$yield$fetch$js = _context.sent;
162
+ videos = _yield$yield$fetch$js.videos;
163
+ setPosterImage(videos[0].poster || "");
164
+
165
+ case 8:
166
+ case "end":
167
+ return _context.stop();
168
+ }
139
169
  }
140
170
  }, _callee);
141
171
  }));
172
+
142
173
  return function getPoster() {
143
174
  return _ref.apply(this, arguments);
144
175
  };
145
176
  }();
177
+
146
178
  if (loadIframeOnClick) {
147
179
  var _window3;
180
+
148
181
  if (!showVideo) {
149
182
  getPoster();
150
183
  }
184
+
151
185
  return /*#__PURE__*/React.createElement("div", {
152
186
  className: "brightcove-wrapper",
153
187
  ref: videoRef
154
188
  }, !showVideo && /*#__PURE__*/React.createElement("div", {
155
- onClick: /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
156
- return _regeneratorRuntime.wrap(function (_context2) {
157
- while (1) switch (_context2.prev = _context2.next) {
158
- case 0:
159
- _context2.next = 1;
160
- return loadLibrary();
161
- case 1:
162
- setThumbnailClicked(true);
163
- case 2:
164
- case "end":
165
- return _context2.stop();
189
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
190
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
191
+ while (1) {
192
+ switch (_context2.prev = _context2.next) {
193
+ case 0:
194
+ _context2.next = 2;
195
+ return loadLibrary();
196
+
197
+ case 2:
198
+ setThumbnailClicked(true);
199
+
200
+ case 3:
201
+ case "end":
202
+ return _context2.stop();
203
+ }
166
204
  }
167
205
  }, _callee2);
168
206
  }))
@@ -185,6 +223,7 @@ var BrightcoveElement = function BrightcoveElement(props) {
185
223
  return null;
186
224
  }
187
225
  };
226
+
188
227
  var StoryElementBrightcove = function StoryElementBrightcove(props) {
189
228
  return /*#__PURE__*/React.createElement(WithLazy, {
190
229
  margin: "0px"
@@ -192,4 +231,5 @@ var StoryElementBrightcove = function StoryElementBrightcove(props) {
192
231
  return /*#__PURE__*/React.createElement(BrightcoveElement, props);
193
232
  });
194
233
  };
234
+
195
235
  export default StoryElementBrightcove;