@quintype/components 2.31.4-lazy-iframe.5 → 2.31.4-lazy-load.2

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/dist/cjs/index.js CHANGED
@@ -46,7 +46,7 @@ var _extends = _interopDefault(require('@babel/runtime/helpers/extends'));
46
46
  var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
47
47
  var classNames = _interopDefault(require('classnames'));
48
48
  var getVideoID = _interopDefault(require('get-video-id'));
49
- require('atob');
49
+ var atob = _interopDefault(require('atob'));
50
50
  var getYouTubeID = _interopDefault(require('get-youtube-id'));
51
51
  var _asyncToGenerator = _interopDefault(require('@babel/runtime/helpers/asyncToGenerator'));
52
52
  var _regeneratorRuntime = _interopDefault(require('@babel/runtime/regenerator'));
@@ -2441,7 +2441,8 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
2441
2441
  opts: _this2.opts,
2442
2442
  onPlay: _this2.onPlayCallback,
2443
2443
  onPause: _this2.onPauseCallback,
2444
- onEnd: _this2.onEndCallback
2444
+ onEnd: _this2.onEndCallback,
2445
+ autoplay: true
2445
2446
  });
2446
2447
  };
2447
2448
 
@@ -2483,29 +2484,99 @@ var StoryElementDailyMotion = function StoryElementDailyMotion(props) {
2483
2484
  });
2484
2485
  };
2485
2486
 
2486
- var JSEmbed = function JSEmbed(props) {
2487
- console.log("###props", props);
2488
- return (
2489
- /*#__PURE__*/
2490
- // <WithLazy margin="0px">
2491
- // {() => {
2492
- // console.log("###lazy loading");
2493
- // return <CustomJSEmbed {...props} />;
2494
- // }}
2495
- // </WithLazy>
2496
- React__default.createElement("div", null, "Lazy")
2497
- );
2498
- };
2499
-
2500
2487
  function _createSuper$f(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$f(); 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); }; }
2501
2488
 
2502
2489
  function _isNativeReflectConstruct$f() { 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; } }
2490
+
2491
+ function cloneScriptNode(node) {
2492
+ var script = document.createElement("script");
2493
+ script.text = node.innerHTML;
2494
+
2495
+ for (var i = node.attributes.length - 1; i >= 0; i--) {
2496
+ script.setAttribute(node.attributes[i].name, node.attributes[i].value);
2497
+ }
2498
+
2499
+ return script;
2500
+ }
2501
+
2502
+ function replaceScriptNodes(node) {
2503
+ if (node.tagName === "SCRIPT") {
2504
+ node.parentNode.replaceChild(cloneScriptNode(node), node);
2505
+ if (window.instgrm) window.instgrm.Embeds.process(); // Temporary fix for instagram element on live blog page.
2506
+ } else {
2507
+ var i = 0;
2508
+ var children = node.childNodes;
2509
+
2510
+ while (i < children.length) {
2511
+ replaceScriptNodes(children[i++]);
2512
+ }
2513
+ }
2514
+ }
2515
+
2516
+ var CustomJSEmbed = /*#__PURE__*/function (_React$Component) {
2517
+ _inherits(CustomJSEmbed, _React$Component);
2518
+
2519
+ var _super = /*#__PURE__*/_createSuper$f(CustomJSEmbed);
2520
+
2521
+ function CustomJSEmbed(props) {
2522
+ var _this;
2523
+
2524
+ _classCallCheck(this, CustomJSEmbed);
2525
+
2526
+ _this = _super.call(this, props);
2527
+ _this.uniqueId = "anagh";
2528
+ return _this;
2529
+ }
2530
+
2531
+ _createClass(CustomJSEmbed, [{
2532
+ key: "shouldComponentUpdate",
2533
+ value: function shouldComponentUpdate(nextProps) {
2534
+ return !(this.props.id === nextProps.id && this.props.embedJS === nextProps.embedJS);
2535
+ }
2536
+ }, {
2537
+ key: "componentDidMount",
2538
+ value: function componentDidMount() {
2539
+ replaceScriptNodes(this.JSEmbed);
2540
+ }
2541
+ }, {
2542
+ key: "componentDidUpdate",
2543
+ value: function componentDidUpdate() {
2544
+ replaceScriptNodes(this.JSEmbed);
2545
+ }
2546
+ }, {
2547
+ key: "getEmbedJS",
2548
+ value: function getEmbedJS() {
2549
+ var embedjs = this.props.embedJS;
2550
+ return embedjs != null ? atob(embedjs) : null;
2551
+ }
2552
+ }, {
2553
+ key: "render",
2554
+ value: function render() {
2555
+ var _this2 = this;
2556
+
2557
+ return /*#__PURE__*/React__default.createElement("div", {
2558
+ ref: function ref(jsembed) {
2559
+ _this2.JSEmbed = jsembed;
2560
+ },
2561
+ dangerouslySetInnerHTML: {
2562
+ __html: this.getEmbedJS()
2563
+ }
2564
+ });
2565
+ }
2566
+ }]);
2567
+
2568
+ return CustomJSEmbed;
2569
+ }(React__default.Component);
2570
+
2571
+ function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); 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); }; }
2572
+
2573
+ function _isNativeReflectConstruct$g() { 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; } }
2503
2574
  var defaultPolltypeHost = 'https://www.polltype.com';
2504
2575
 
2505
2576
  var PolltypeBase = /*#__PURE__*/function (_React$Component) {
2506
2577
  _inherits(PolltypeBase, _React$Component);
2507
2578
 
2508
- var _super = /*#__PURE__*/_createSuper$f(PolltypeBase);
2579
+ var _super = /*#__PURE__*/_createSuper$g(PolltypeBase);
2509
2580
 
2510
2581
  function PolltypeBase() {
2511
2582
  _classCallCheck(this, PolltypeBase);
@@ -2551,9 +2622,9 @@ function mapStateToProps$7(state) {
2551
2622
 
2552
2623
  var Polltype = /*#__PURE__*/reactRedux.connect(mapStateToProps$7, {})(PolltypeBase);
2553
2624
 
2554
- function _createSuper$g(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$g(); 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); }; }
2625
+ function _createSuper$h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); 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); }; }
2555
2626
 
2556
- function _isNativeReflectConstruct$g() { 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; } }
2627
+ function _isNativeReflectConstruct$h() { 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; } }
2557
2628
 
2558
2629
  function TableHeader(columns) {
2559
2630
  return /*#__PURE__*/React__default.createElement("thead", null, /*#__PURE__*/React__default.createElement("tr", null, columns.map(function (col) {
@@ -2577,7 +2648,7 @@ function TableView(_ref) {
2577
2648
  var Table = /*#__PURE__*/function (_React$Component) {
2578
2649
  _inherits(Table, _React$Component);
2579
2650
 
2580
- var _super = /*#__PURE__*/_createSuper$g(Table);
2651
+ var _super = /*#__PURE__*/_createSuper$h(Table);
2581
2652
 
2582
2653
  function Table(props) {
2583
2654
  var _this;
@@ -2665,9 +2736,9 @@ function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if
2665
2736
 
2666
2737
  function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$4(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2667
2738
 
2668
- function _createSuper$h(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$h(); 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); }; }
2739
+ function _createSuper$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$i(); 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); }; }
2669
2740
 
2670
- function _isNativeReflectConstruct$h() { 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; } }
2741
+ function _isNativeReflectConstruct$i() { 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; } }
2671
2742
  var YouTube = null;
2672
2743
  var loaderPromise$1 = null;
2673
2744
 
@@ -2693,7 +2764,7 @@ function isLibraryLoaded$1() {
2693
2764
  var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
2694
2765
  _inherits(CustomStoryElementYoutube, _React$Component);
2695
2766
 
2696
- var _super = /*#__PURE__*/_createSuper$h(CustomStoryElementYoutube);
2767
+ var _super = /*#__PURE__*/_createSuper$i(CustomStoryElementYoutube);
2697
2768
 
2698
2769
  function CustomStoryElementYoutube(props) {
2699
2770
  var _this;
@@ -2807,7 +2878,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
2807
2878
  if (this.props.loadIframeOnClick) {
2808
2879
  return /*#__PURE__*/React__default.createElement("div", {
2809
2880
  className: "thumbnail-wrapper"
2810
- }, !this.state.showVideo && /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("button", {
2881
+ }, /*#__PURE__*/React__default.createElement("button", {
2811
2882
  className: "youtube-playBtn",
2812
2883
  onClick: this.renderVideo,
2813
2884
  "aria-label": "Play Video"
@@ -2816,7 +2887,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
2816
2887
  onClick: this.renderVideo,
2817
2888
  src: "https://img.youtube.com/vi/".concat(getYouTubeID(this.props.element.url), "/sddefault.jpg"),
2818
2889
  alt: "video"
2819
- })), this.state.showVideo && isLibraryLoaded$1() && /*#__PURE__*/React__default.createElement("div", {
2890
+ }), this.state.showVideo && isLibraryLoaded$1() && /*#__PURE__*/React__default.createElement("div", {
2820
2891
  className: "youtube-iframe-wrapper"
2821
2892
  }, youtubeIframe()));
2822
2893
  } else if (!this.props.loadIframeOnClick && isLibraryLoaded$1()) {
@@ -2846,9 +2917,9 @@ function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if
2846
2917
 
2847
2918
  function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$5(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
2848
2919
 
2849
- function _createSuper$i(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$i(); 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); }; }
2920
+ function _createSuper$j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$j(); 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); }; }
2850
2921
 
2851
- function _isNativeReflectConstruct$i() { 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; } }
2922
+ function _isNativeReflectConstruct$j() { 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; } }
2852
2923
  /**
2853
2924
  * This component renders different types of [story elements](https://developers.quintype.com/malibu/terminology#story-elements)
2854
2925
 
@@ -2878,7 +2949,7 @@ function _isNativeReflectConstruct$i() { if (typeof Reflect === "undefined" || !
2878
2949
  var StoryElement = /*#__PURE__*/function (_React$Component) {
2879
2950
  _inherits(StoryElement, _React$Component);
2880
2951
 
2881
- var _super = /*#__PURE__*/_createSuper$i(StoryElement);
2952
+ var _super = /*#__PURE__*/_createSuper$j(StoryElement);
2882
2953
 
2883
2954
  function StoryElement(props) {
2884
2955
  var _this;
@@ -3000,12 +3071,10 @@ function StoryElementSoundCloud(_ref5) {
3000
3071
  }
3001
3072
 
3002
3073
  function StoryElementJsembed(_ref6) {
3003
- var element = _ref6.element,
3004
- loadEmbed = _ref6.loadEmbed;
3005
- return /*#__PURE__*/React__default.createElement(JSEmbed, {
3074
+ var element = _ref6.element;
3075
+ return /*#__PURE__*/React__default.createElement(CustomJSEmbed, {
3006
3076
  embedJS: element["embed-js"],
3007
- id: element["id"],
3008
- loadEmbed: loadEmbed
3077
+ id: element["id"]
3009
3078
  });
3010
3079
  }
3011
3080
 
@@ -3042,8 +3111,8 @@ var DEFAULT_TEMPLATES = {
3042
3111
  text: StoryElementText,
3043
3112
  image: StoryElementImage,
3044
3113
  title: StoryElementTitle,
3045
- "youtube-video": StoryElementYoutube,
3046
3114
  "dailymotion-video": StoryElementDailyMotion,
3115
+ "youtube-video": StoryElementYoutube,
3047
3116
  "soundcloud-audio": StoryElementSoundCloud,
3048
3117
  jsembed: StoryElementJsembed,
3049
3118
  polltype: StoryElementPolltype,
@@ -3055,7 +3124,7 @@ var DEFAULT_TEMPLATES = {
3055
3124
  var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
3056
3125
  _inherits(StoryElementBase, _React$Component2);
3057
3126
 
3058
- var _super2 = /*#__PURE__*/_createSuper$i(StoryElementBase);
3127
+ var _super2 = /*#__PURE__*/_createSuper$j(StoryElementBase);
3059
3128
 
3060
3129
  function StoryElementBase(props) {
3061
3130
  var _this2;
@@ -3169,9 +3238,9 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
3169
3238
 
3170
3239
  var STORY_ELEMENT_TEMPLATES = DEFAULT_TEMPLATES;
3171
3240
 
3172
- function _createSuper$j(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$j(); 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); }; }
3241
+ function _createSuper$k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$k(); 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); }; }
3173
3242
 
3174
- function _isNativeReflectConstruct$j() { 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; } }
3243
+ function _isNativeReflectConstruct$k() { 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; } }
3175
3244
 
3176
3245
  function getNativeShareHandler(canNativeShare, title, fullUrl) {
3177
3246
  if (!canNativeShare) {
@@ -3189,7 +3258,7 @@ function getNativeShareHandler(canNativeShare, title, fullUrl) {
3189
3258
  var SocialShareBase = /*#__PURE__*/function (_React$Component) {
3190
3259
  _inherits(SocialShareBase, _React$Component);
3191
3260
 
3192
- var _super = /*#__PURE__*/_createSuper$j(SocialShareBase);
3261
+ var _super = /*#__PURE__*/_createSuper$k(SocialShareBase);
3193
3262
 
3194
3263
  function SocialShareBase(props) {
3195
3264
  var _this;
@@ -3655,15 +3724,15 @@ LoadMoreButton.defaultProps = {
3655
3724
  text: 'Load more'
3656
3725
  };
3657
3726
 
3658
- function _createSuper$k(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$k(); 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); }; }
3727
+ function _createSuper$l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$l(); 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); }; }
3659
3728
 
3660
- function _isNativeReflectConstruct$k() { 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; } }
3729
+ function _isNativeReflectConstruct$l() { 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; } }
3661
3730
  var loadedMember = false;
3662
3731
 
3663
3732
  var WithMemberBase = /*#__PURE__*/function (_React$Component) {
3664
3733
  _inherits(WithMemberBase, _React$Component);
3665
3734
 
3666
- var _super = /*#__PURE__*/_createSuper$k(WithMemberBase);
3735
+ var _super = /*#__PURE__*/_createSuper$l(WithMemberBase);
3667
3736
 
3668
3737
  function WithMemberBase(props) {
3669
3738
  var _this;
@@ -3792,9 +3861,9 @@ function mapDispatchToProps$6(dispatch, ownProps) {
3792
3861
 
3793
3862
  var WithMember = /*#__PURE__*/reactRedux.connect(mapStateToProps$9, mapDispatchToProps$6)(WithMemberBase);
3794
3863
 
3795
- function _createSuper$l(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$l(); 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); }; }
3864
+ function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); 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); }; }
3796
3865
 
3797
- function _isNativeReflectConstruct$l() { 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; } }
3866
+ function _isNativeReflectConstruct$m() { 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; } }
3798
3867
  /**
3799
3868
  * This higher order function can be used for the home or story page preview. It takes a component, and a function to map the story into props suitable for the component
3800
3869
  *
@@ -3828,7 +3897,7 @@ function WithPreview(klazz, updateData) {
3828
3897
  return /*#__PURE__*/function (_React$Component) {
3829
3898
  _inherits(WithPreviewWrapper, _React$Component);
3830
3899
 
3831
- var _super = _createSuper$l(WithPreviewWrapper);
3900
+ var _super = _createSuper$m(WithPreviewWrapper);
3832
3901
 
3833
3902
  function WithPreviewWrapper(props) {
3834
3903
  var _this;
@@ -3876,9 +3945,9 @@ function WithPreview(klazz, updateData) {
3876
3945
  }(React__default.Component);
3877
3946
  }
3878
3947
 
3879
- function _createSuper$m(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$m(); 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); }; }
3948
+ function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); 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); }; }
3880
3949
 
3881
- function _isNativeReflectConstruct$m() { 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; } }
3950
+ function _isNativeReflectConstruct$n() { 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; } }
3882
3951
  /**
3883
3952
  * 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.
3884
3953
  *
@@ -3930,7 +3999,7 @@ function _isNativeReflectConstruct$m() { if (typeof Reflect === "undefined" || !
3930
3999
  var WithSocialLogin = /*#__PURE__*/function (_React$Component) {
3931
4000
  _inherits(WithSocialLogin, _React$Component);
3932
4001
 
3933
- var _super = /*#__PURE__*/_createSuper$m(WithSocialLogin);
4002
+ var _super = /*#__PURE__*/_createSuper$n(WithSocialLogin);
3934
4003
 
3935
4004
  function WithSocialLogin(props) {
3936
4005
  var _this;
@@ -4255,9 +4324,9 @@ var loginWithLinkedIn = function loginWithLinkedIn(_ref2) {
4255
4324
  });
4256
4325
  };
4257
4326
 
4258
- function _createSuper$n(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$n(); 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); }; }
4327
+ function _createSuper$o(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$o(); 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); }; }
4259
4328
 
4260
- function _isNativeReflectConstruct$n() { 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; } }
4329
+ function _isNativeReflectConstruct$o() { 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; } }
4261
4330
  /**
4262
4331
  * This render props component willupdate it's children via props while executing data loaders sent as props to the component.
4263
4332
  *
@@ -4289,7 +4358,7 @@ function _isNativeReflectConstruct$n() { if (typeof Reflect === "undefined" || !
4289
4358
  var UpdateOnInterval = /*#__PURE__*/function (_React$Component) {
4290
4359
  _inherits(UpdateOnInterval, _React$Component);
4291
4360
 
4292
- var _super = /*#__PURE__*/_createSuper$n(UpdateOnInterval);
4361
+ var _super = /*#__PURE__*/_createSuper$o(UpdateOnInterval);
4293
4362
 
4294
4363
  function UpdateOnInterval(props) {
4295
4364
  var _this;
@@ -4395,14 +4464,14 @@ function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if
4395
4464
 
4396
4465
  function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$6(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
4397
4466
 
4398
- function _createSuper$o(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$o(); 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); }; }
4467
+ function _createSuper$p(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct$p(); 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); }; }
4399
4468
 
4400
- function _isNativeReflectConstruct$o() { 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; } }
4469
+ function _isNativeReflectConstruct$p() { 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; } }
4401
4470
 
4402
4471
  var AccessTypeBase = /*#__PURE__*/function (_React$Component) {
4403
4472
  _inherits(AccessTypeBase, _React$Component);
4404
4473
 
4405
- var _super = /*#__PURE__*/_createSuper$o(AccessTypeBase);
4474
+ var _super = /*#__PURE__*/_createSuper$p(AccessTypeBase);
4406
4475
 
4407
4476
  function AccessTypeBase(props) {
4408
4477
  var _this;
@@ -177,12 +177,10 @@ function StoryElementSoundCloud(_ref5) {
177
177
  }
178
178
 
179
179
  function StoryElementJsembed(_ref6) {
180
- var element = _ref6.element,
181
- loadEmbed = _ref6.loadEmbed;
180
+ var element = _ref6.element;
182
181
  return /*#__PURE__*/React.createElement(JSEmbed, {
183
182
  embedJS: element["embed-js"],
184
- id: element["id"],
185
- loadEmbed: loadEmbed
183
+ id: element["id"]
186
184
  });
187
185
  }
188
186
 
@@ -219,8 +217,8 @@ var DEFAULT_TEMPLATES = {
219
217
  text: StoryElementText,
220
218
  image: StoryElementImage,
221
219
  title: StoryElementTitle,
222
- "youtube-video": StoryElementYoutube,
223
220
  "dailymotion-video": StoryElementDailyMotion,
221
+ "youtube-video": StoryElementYoutube,
224
222
  "soundcloud-audio": StoryElementSoundCloud,
225
223
  jsembed: StoryElementJsembed,
226
224
  polltype: StoryElementPolltype,
@@ -117,7 +117,8 @@ var CustomStoryElementDailyMotion = /*#__PURE__*/function (_React$Component) {
117
117
  opts: _this2.opts,
118
118
  onPlay: _this2.onPlayCallback,
119
119
  onPause: _this2.onPauseCallback,
120
- onEnd: _this2.onEndCallback
120
+ onEnd: _this2.onEndCallback,
121
+ autoplay: true
121
122
  });
122
123
  };
123
124
 
@@ -1,8 +1,18 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+
7
+ 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
+ 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
+
2
11
  import atob from "atob";
3
- import React, { useEffect, useState } from "react";
12
+ import { PropTypes } from "prop-types";
13
+ import React from "react";
4
14
 
5
- var cloneScriptNode = function cloneScriptNode(node) {
15
+ function cloneScriptNode(node) {
6
16
  var script = document.createElement("script");
7
17
  script.text = node.innerHTML;
8
18
 
@@ -11,9 +21,9 @@ var cloneScriptNode = function cloneScriptNode(node) {
11
21
  }
12
22
 
13
23
  return script;
14
- };
24
+ }
15
25
 
16
- var replaceScriptNodes = function replaceScriptNodes(node) {
26
+ function replaceScriptNodes(node) {
17
27
  if (node.tagName === "SCRIPT") {
18
28
  node.parentNode.replaceChild(cloneScriptNode(node), node);
19
29
  if (window.instgrm) window.instgrm.Embeds.process(); // Temporary fix for instagram element on live blog page.
@@ -25,49 +35,61 @@ var replaceScriptNodes = function replaceScriptNodes(node) {
25
35
  replaceScriptNodes(children[i++]);
26
36
  }
27
37
  }
28
- };
29
-
30
- var CustomJSEmbed = function CustomJSEmbed(props) {
31
- var _useState = useState(null),
32
- _useState2 = _slicedToArray(_useState, 2),
33
- JSEmbed = _useState2[0],
34
- setJSEmbed = _useState2[1];
35
-
36
- useEffect(function () {
37
- JSEmbed && replaceScriptNodes(JSEmbed);
38
- }, []);
39
- useEffect(function () {
40
- JSEmbed && replaceScriptNodes(JSEmbed);
41
- }, [JSEmbed]);
42
-
43
- var getEmbedJS = function getEmbedJS() {
44
- var embedjs = props.embedJS;
45
- var embed = embedjs != null ? atob(embedjs) : null;
46
- return embed;
47
- };
48
-
49
- return /*#__PURE__*/React.createElement("div", {
50
- ref: function ref(jsembed) {
51
- setJSEmbed(jsembed);
52
- },
53
- dangerouslySetInnerHTML: {
54
- __html: getEmbedJS()
38
+ }
39
+
40
+ var CustomJSEmbed = /*#__PURE__*/function (_React$Component) {
41
+ _inherits(CustomJSEmbed, _React$Component);
42
+
43
+ var _super = /*#__PURE__*/_createSuper(CustomJSEmbed);
44
+
45
+ function CustomJSEmbed(props) {
46
+ var _this;
47
+
48
+ _classCallCheck(this, CustomJSEmbed);
49
+
50
+ _this = _super.call(this, props);
51
+ _this.uniqueId = "anagh";
52
+ return _this;
53
+ }
54
+
55
+ _createClass(CustomJSEmbed, [{
56
+ key: "shouldComponentUpdate",
57
+ value: function shouldComponentUpdate(nextProps) {
58
+ return !(this.props.id === nextProps.id && this.props.embedJS === nextProps.embedJS);
59
+ }
60
+ }, {
61
+ key: "componentDidMount",
62
+ value: function componentDidMount() {
63
+ replaceScriptNodes(this.JSEmbed);
64
+ }
65
+ }, {
66
+ key: "componentDidUpdate",
67
+ value: function componentDidUpdate() {
68
+ replaceScriptNodes(this.JSEmbed);
69
+ }
70
+ }, {
71
+ key: "getEmbedJS",
72
+ value: function getEmbedJS() {
73
+ var embedjs = this.props.embedJS;
74
+ return embedjs != null ? atob(embedjs) : null;
55
75
  }
56
- });
57
- };
58
-
59
- var JSEmbed = function JSEmbed(props) {
60
- console.log("###props", props);
61
- return (
62
- /*#__PURE__*/
63
- // <WithLazy margin="0px">
64
- // {() => {
65
- // console.log("###lazy loading");
66
- // return <CustomJSEmbed {...props} />;
67
- // }}
68
- // </WithLazy>
69
- React.createElement("div", null, "Lazy")
70
- );
71
- };
72
-
73
- export default JSEmbed;
76
+ }, {
77
+ key: "render",
78
+ value: function render() {
79
+ var _this2 = this;
80
+
81
+ return /*#__PURE__*/React.createElement("div", {
82
+ ref: function ref(jsembed) {
83
+ _this2.JSEmbed = jsembed;
84
+ },
85
+ dangerouslySetInnerHTML: {
86
+ __html: this.getEmbedJS()
87
+ }
88
+ });
89
+ }
90
+ }]);
91
+
92
+ return CustomJSEmbed;
93
+ }(React.Component);
94
+
95
+ export { CustomJSEmbed as default };
@@ -158,7 +158,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
158
158
  if (this.props.loadIframeOnClick) {
159
159
  return /*#__PURE__*/React.createElement("div", {
160
160
  className: "thumbnail-wrapper"
161
- }, !this.state.showVideo && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("button", {
161
+ }, /*#__PURE__*/React.createElement("button", {
162
162
  className: "youtube-playBtn",
163
163
  onClick: this.renderVideo,
164
164
  "aria-label": "Play Video"
@@ -167,7 +167,7 @@ var CustomStoryElementYoutube = /*#__PURE__*/function (_React$Component) {
167
167
  onClick: this.renderVideo,
168
168
  src: "https://img.youtube.com/vi/".concat(getYouTubeID(this.props.element.url), "/sddefault.jpg"),
169
169
  alt: "video"
170
- })), this.state.showVideo && isLibraryLoaded() && /*#__PURE__*/React.createElement("div", {
170
+ }), this.state.showVideo && isLibraryLoaded() && /*#__PURE__*/React.createElement("div", {
171
171
  className: "youtube-iframe-wrapper"
172
172
  }, youtubeIframe()));
173
173
  } else if (!this.props.loadIframeOnClick && isLibraryLoaded()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "2.31.4-lazy-iframe.5",
3
+ "version": "2.31.4-lazy-load.2",
4
4
  "description": "Components to help build Quintype Node.js apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/es/index.js",