@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
@@ -3,11 +3,8 @@ 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 emptyWebGif from 'empty-web-gif';
13
10
  import omit from '@babel/runtime/helpers/objectWithoutProperties';
@@ -16,13 +13,11 @@ import { FocusedImage } from "quintype-js";
16
13
  import { USED_PARAMS, hashString } from './image-utils';
17
14
  export function responsiveProps(props) {
18
15
  var image = new FocusedImage(props.slug, props.metadata);
19
-
20
16
  function generatePath(size) {
21
17
  return "//" + props.imageCDN + "/" + image.path(props.aspectRatio, Object.assign({
22
18
  w: size
23
19
  }, props.imgParams));
24
20
  }
25
-
26
21
  return {
27
22
  src: generatePath(props.defaultWidth),
28
23
  srcSet: props.widths ? props.widths.map(function (size) {
@@ -33,43 +28,34 @@ export function responsiveProps(props) {
33
28
  }
34
29
  export var ThumborImage = /*#__PURE__*/function (_React$Component) {
35
30
  _inherits(ThumborImage, _React$Component);
36
-
37
31
  var _super = /*#__PURE__*/_createSuper(ThumborImage);
38
-
39
32
  function ThumborImage(props, context) {
40
33
  var _this;
41
-
42
34
  _classCallCheck(this, ThumborImage);
43
-
44
35
  _this = _super.call(this, props, context);
45
36
  _this.state = {
46
37
  showImage: !_this.shouldLazyLoad()
47
38
  };
48
39
  return _this;
49
40
  }
50
-
51
41
  _createClass(ThumborImage, [{
52
42
  key: "shouldLazyLoad",
53
43
  value: function shouldLazyLoad() {
54
44
  if (this.props.eager === true) {
55
45
  return false;
56
46
  }
57
-
58
47
  if (this.context.lazyLoadEagerPredicate && this.context.lazyLoadEagerPredicate(this.props.eager)) {
59
48
  return false;
60
49
  }
61
-
62
50
  if (this.context.lazyLoadObserveImage && this.context.lazyLoadUnobserveImage) {
63
51
  return true;
64
52
  }
65
-
66
53
  return false;
67
54
  }
68
55
  }, {
69
56
  key: "render",
70
57
  value: function render() {
71
58
  var _this2 = this;
72
-
73
59
  var imageProps = this.state.showImage ? responsiveProps(this.props) : {
74
60
  src: emptyWebGif
75
61
  };
@@ -98,7 +84,6 @@ export var ThumborImage = /*#__PURE__*/function (_React$Component) {
98
84
  });
99
85
  }
100
86
  }]);
101
-
102
87
  return ThumborImage;
103
88
  }(React.Component);
104
89
  ThumborImage.contextTypes = {
@@ -5,35 +5,27 @@ import _createClass from "@babel/runtime/helpers/createClass";
5
5
  import _inherits from "@babel/runtime/helpers/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
-
9
8
  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); }; }
10
-
11
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
+ import React from "react";
12
11
 
13
- import React from "react"; // An item in the infinite scroll
14
-
12
+ // An item in the infinite scroll
15
13
  var ScrollItem = /*#__PURE__*/function (_React$Component) {
16
14
  _inherits(ScrollItem, _React$Component);
17
-
18
15
  var _super = /*#__PURE__*/_createSuper(ScrollItem);
19
-
20
16
  function ScrollItem(props) {
21
17
  var _this;
22
-
23
18
  _classCallCheck(this, ScrollItem);
24
-
25
19
  _this = _super.call(this, props);
26
20
  _this.state = {
27
21
  minHeight: props.minHeight
28
22
  };
29
23
  return _this;
30
24
  }
31
-
32
25
  _createClass(ScrollItem, [{
33
26
  key: "render",
34
27
  value: function render() {
35
28
  var _this2 = this;
36
-
37
29
  return /*#__PURE__*/React.createElement("div", {
38
30
  ref: function ref(node) {
39
31
  return _this2.node = node;
@@ -63,7 +55,6 @@ var ScrollItem = /*#__PURE__*/function (_React$Component) {
63
55
  key: "componentDidMount",
64
56
  value: function componentDidMount() {
65
57
  var _this3 = this;
66
-
67
58
  this.props.observers.forEach(function (observer) {
68
59
  return observer && observer.observe(_this3.node);
69
60
  });
@@ -72,33 +63,24 @@ var ScrollItem = /*#__PURE__*/function (_React$Component) {
72
63
  key: "componentWillUnmount",
73
64
  value: function componentWillUnmount() {
74
65
  var _this4 = this;
75
-
76
66
  this.props.observers.forEach(function (observer) {
77
67
  return observer && observer.unobserve(_this4.node);
78
68
  });
79
69
  }
80
70
  }]);
81
-
82
71
  return ScrollItem;
83
72
  }(React.Component); // When this becomes visible, we call loadMore()
84
-
85
-
86
73
  var ScrollLoadMore = /*#__PURE__*/function (_React$Component2) {
87
74
  _inherits(ScrollLoadMore, _React$Component2);
88
-
89
75
  var _super2 = /*#__PURE__*/_createSuper(ScrollLoadMore);
90
-
91
76
  function ScrollLoadMore() {
92
77
  _classCallCheck(this, ScrollLoadMore);
93
-
94
78
  return _super2.apply(this, arguments);
95
79
  }
96
-
97
80
  _createClass(ScrollLoadMore, [{
98
81
  key: "render",
99
82
  value: function render() {
100
83
  var _this5 = this;
101
-
102
84
  return /*#__PURE__*/React.createElement("div", {
103
85
  ref: function ref(node) {
104
86
  return _this5.node = node;
@@ -110,7 +92,6 @@ var ScrollLoadMore = /*#__PURE__*/function (_React$Component2) {
110
92
  key: "componentDidMount",
111
93
  value: function componentDidMount() {
112
94
  var _this6 = this;
113
-
114
95
  this.props.observers.forEach(function (observer) {
115
96
  return observer && observer.observe(_this6.node);
116
97
  });
@@ -119,27 +100,19 @@ var ScrollLoadMore = /*#__PURE__*/function (_React$Component2) {
119
100
  key: "componentWillUnmount",
120
101
  value: function componentWillUnmount() {
121
102
  var _this7 = this;
122
-
123
103
  this.props.observers.forEach(function (observer) {
124
104
  return observer && observer.unobserve(_this7.node);
125
105
  });
126
106
  }
127
107
  }]);
128
-
129
108
  return ScrollLoadMore;
130
109
  }(React.Component); // Basic Infinite Scroll, toggles showing items
131
-
132
-
133
110
  var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
134
111
  _inherits(InfiniteScrollBase, _React$Component3);
135
-
136
112
  var _super3 = /*#__PURE__*/_createSuper(InfiniteScrollBase);
137
-
138
113
  function InfiniteScrollBase(props) {
139
114
  var _this8;
140
-
141
115
  _classCallCheck(this, InfiniteScrollBase);
142
-
143
116
  _this8 = _super3.call(this, props);
144
117
  var initiallyShow = props.initiallyShow || 1;
145
118
  _this8.state = {
@@ -148,7 +121,6 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
148
121
  return arr;
149
122
  }, {})
150
123
  };
151
-
152
124
  if (global.IntersectionObserver) {
153
125
  _this8.loadObserver = new IntersectionObserver(function (x) {
154
126
  return _this8.intersectionCallback(x);
@@ -156,10 +128,8 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
156
128
  rootMargin: props.loadMargin || "200px 0px 500px"
157
129
  });
158
130
  }
159
-
160
131
  return _this8;
161
132
  }
162
-
163
133
  _createClass(InfiniteScrollBase, [{
164
134
  key: "componentWillUnmount",
165
135
  value: function componentWillUnmount() {
@@ -169,7 +139,6 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
169
139
  key: "intersectionCallback",
170
140
  value: function intersectionCallback(entries) {
171
141
  var _this9 = this;
172
-
173
142
  var visibleComponents = this.state.visibleComponents;
174
143
  entries.forEach(function (entry) {
175
144
  // Stupid browsers like UC and Mi don't correctly support the spec
@@ -180,9 +149,7 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
180
149
  return;
181
150
  }
182
151
  }
183
-
184
152
  var item = entry.target.getAttribute("data-infinite-scroll");
185
-
186
153
  if (item == 'load-more' && entry.isIntersecting) {
187
154
  _this9.props.loadNext();
188
155
  } else {
@@ -198,7 +165,6 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
198
165
  key: "render",
199
166
  value: function render() {
200
167
  var _this10 = this;
201
-
202
168
  return /*#__PURE__*/React.createElement("div", null, this.props.items.map(function (data, index) {
203
169
  return /*#__PURE__*/React.createElement(ScrollItem, {
204
170
  observers: _this10.props.observers.concat([_this10.loadObserver]),
@@ -214,24 +180,16 @@ var InfiniteScrollBase = /*#__PURE__*/function (_React$Component3) {
214
180
  }));
215
181
  }
216
182
  }]);
217
-
218
183
  return InfiniteScrollBase;
219
184
  }(React.Component); // Calls a callback when an item covers bottom 20% of the screen (to change URL)
220
-
221
-
222
185
  function withFocusObserver(Component) {
223
186
  return /*#__PURE__*/function (_React$Component4) {
224
187
  _inherits(WithFocusObserver, _React$Component4);
225
-
226
188
  var _super4 = _createSuper(WithFocusObserver);
227
-
228
189
  function WithFocusObserver(props) {
229
190
  var _this11;
230
-
231
191
  _classCallCheck(this, WithFocusObserver);
232
-
233
192
  _this11 = _super4.call(this, props);
234
-
235
193
  if (global.IntersectionObserver) {
236
194
  _this11.focusObserver = new IntersectionObserver(function (x) {
237
195
  return _this11.focusCallback(x);
@@ -239,10 +197,8 @@ function withFocusObserver(Component) {
239
197
  rootMargin: "-".concat(100 - props.focusCallbackAt, "% 0px -").concat(props.focusCallbackAt, "%")
240
198
  });
241
199
  }
242
-
243
200
  return _this11;
244
201
  }
245
-
246
202
  _createClass(WithFocusObserver, [{
247
203
  key: "componentWillUnmount",
248
204
  value: function componentWillUnmount() {
@@ -252,10 +208,8 @@ function withFocusObserver(Component) {
252
208
  key: "focusCallback",
253
209
  value: function focusCallback(entries) {
254
210
  var _this12 = this;
255
-
256
211
  entries.forEach(function (entry) {
257
212
  var item = entry.target.getAttribute("data-infinite-scroll");
258
-
259
213
  if (entry.isIntersecting) {
260
214
  _this12.props.onFocus(item);
261
215
  }
@@ -269,16 +223,14 @@ function withFocusObserver(Component) {
269
223
  }));
270
224
  }
271
225
  }]);
272
-
273
226
  return WithFocusObserver;
274
227
  }(React.Component);
275
228
  }
229
+
276
230
  /**
277
231
  * This component can be used to implement InfiniteScroll. This is an internal component.
278
232
  * @private
279
233
  * @category Other
280
234
  * @component
281
235
  */
282
-
283
-
284
236
  export var InfiniteScroll = /*#__PURE__*/withFocusObserver(InfiniteScrollBase);
@@ -3,15 +3,13 @@ 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 get from "lodash/get";
13
10
  import { InfiniteScroll } from "./infinite-scroll.js";
14
11
  import { removeDuplicateStories } from '../utils';
12
+
15
13
  /**
16
14
  * This component can be used to implement InfiniteScroll on the story page. You will need to specify the function which renders the story (which will recieve props.index and props.story), and functions for triggering analytics.
17
15
  *
@@ -59,17 +57,12 @@ import { removeDuplicateStories } from '../utils';
59
57
  * @component
60
58
  * @category Story Page
61
59
  */
62
-
63
60
  export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
64
61
  _inherits(InfiniteStoryBase, _React$Component);
65
-
66
62
  var _super = /*#__PURE__*/_createSuper(InfiniteStoryBase);
67
-
68
63
  function InfiniteStoryBase(props) {
69
64
  var _this;
70
-
71
65
  _classCallCheck(this, InfiniteStoryBase);
72
-
73
66
  _this = _super.call(this, props);
74
67
  _this.state = {
75
68
  moreItems: [],
@@ -79,7 +72,6 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
79
72
  };
80
73
  return _this;
81
74
  }
82
-
83
75
  _createClass(InfiniteStoryBase, [{
84
76
  key: "allItems",
85
77
  value: function allItems() {
@@ -89,18 +81,14 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
89
81
  key: "onFocus",
90
82
  value: function onFocus(index) {
91
83
  var _this2 = this;
92
-
93
84
  var item = this.allItems()[index];
94
-
95
85
  if (!this.props.doNotChangeUrl) {
96
86
  var storyPath = item.story.url ? new URL(item.story.url).pathname : "/" + item.story.slug;
97
87
  var metaTitle = get(item, ['story', 'seo', 'meta-title'], item.story.headline);
98
88
  var title = get(item, ["customSeo", "title"], metaTitle);
99
89
  global.app.maybeSetUrl(storyPath, title);
100
90
  }
101
-
102
91
  this.props.onItemFocus && this.props.onItemFocus(item, index);
103
-
104
92
  if (!this.state.seenStoryIds.includes(item.story.id)) {
105
93
  this.setState({
106
94
  seenStoryIds: this.state.seenStoryIds.concat([item.story.id])
@@ -113,7 +101,6 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
113
101
  key: "loadMore",
114
102
  value: function loadMore() {
115
103
  var _this3 = this;
116
-
117
104
  if (this.state.loading) return;
118
105
  var pageNumber = this.state.pageNumber;
119
106
  var story = get(this.props.data, ['story'], {});
@@ -135,7 +122,6 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
135
122
  key: "render",
136
123
  value: function render() {
137
124
  var _this4 = this;
138
-
139
125
  return /*#__PURE__*/React.createElement(InfiniteScroll, {
140
126
  render: this.props.render,
141
127
  items: this.allItems(),
@@ -151,6 +137,5 @@ export var InfiniteStoryBase = /*#__PURE__*/function (_React$Component) {
151
137
  });
152
138
  }
153
139
  }]);
154
-
155
140
  return InfiniteStoryBase;
156
141
  }(React.Component);
@@ -4,6 +4,7 @@ import React from 'react';
4
4
  import { InfiniteScroll } from './infinite-scroll';
5
5
  import { string, object, func } from 'prop-types';
6
6
  import { StoryNotImplemented, CollectionNotImplemented, renderCollectionItem } from './impl/collection-impl';
7
+
7
8
  /**
8
9
  * This component can be used to render a collection, but with the components being lazy. This takes all the same options as Collection, but with a `lazyAfter` prop.
9
10
  * This Component also accepts extra props, which will be passed down to collection templates.
@@ -27,15 +28,13 @@ import { StoryNotImplemented, CollectionNotImplemented, renderCollectionItem } f
27
28
  * @category Collection Page
28
29
  * @component
29
30
  */
30
-
31
31
  export function LazyCollection(_ref) {
32
32
  var className = _ref.className,
33
- collection = _ref.collection,
34
- collectionTemplates = _ref.collectionTemplates,
35
- storyTemplates = _ref.storyTemplates,
36
- lazyAfter = _ref.lazyAfter,
37
- otherProps = _objectWithoutProperties(_ref, _excluded);
38
-
33
+ collection = _ref.collection,
34
+ collectionTemplates = _ref.collectionTemplates,
35
+ storyTemplates = _ref.storyTemplates,
36
+ lazyAfter = _ref.lazyAfter,
37
+ otherProps = _objectWithoutProperties(_ref, _excluded);
39
38
  return /*#__PURE__*/React.createElement("div", {
40
39
  className: className
41
40
  }, /*#__PURE__*/React.createElement(InfiniteScroll, {
@@ -49,7 +48,8 @@ export function LazyCollection(_ref) {
49
48
  },
50
49
  initiallyShow: lazyAfter,
51
50
  neverHideItem: true,
52
- showAllOnLegacyBrowser: true // No Op
51
+ showAllOnLegacyBrowser: true
52
+ // No Op
53
53
  ,
54
54
  focusCallbackAt: 20,
55
55
  onFocus: function onFocus() {}
@@ -4,27 +4,20 @@ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
4
4
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
5
5
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
6
6
  import _createClass from "@babel/runtime/helpers/createClass";
7
-
8
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); }; }
9
-
10
8
  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; } }
11
-
12
9
  import { func, string } from 'prop-types';
13
10
  import React from "react";
14
-
15
11
  var IntersectionObserverWrapper = /*#__PURE__*/function () {
16
12
  function IntersectionObserverWrapper(callback) {
17
13
  _classCallCheck(this, IntersectionObserverWrapper);
18
-
19
14
  this.observedItems = [];
20
15
  this.callback = callback;
21
16
  }
22
-
23
17
  _createClass(IntersectionObserverWrapper, [{
24
18
  key: "start",
25
19
  value: function start(margin) {
26
20
  var _this = this;
27
-
28
21
  this.observer = new global.IntersectionObserver(function (entries) {
29
22
  return _this.onObservation(entries);
30
23
  }, {
@@ -33,9 +26,8 @@ var IntersectionObserverWrapper = /*#__PURE__*/function () {
33
26
  });
34
27
  this.observedItems.forEach(function (_ref) {
35
28
  var _ref2 = _slicedToArray(_ref, 2),
36
- dom = _ref2[0],
37
- component = _ref2[1];
38
-
29
+ dom = _ref2[0],
30
+ component = _ref2[1];
39
31
  return _this.observer.observe(dom);
40
32
  });
41
33
  }
@@ -43,7 +35,6 @@ var IntersectionObserverWrapper = /*#__PURE__*/function () {
43
35
  key: "onObservation",
44
36
  value: function onObservation(entries) {
45
37
  var _this2 = this;
46
-
47
38
  entries.filter(function (entry) {
48
39
  return entry.isIntersecting === undefined || entry.isIntersecting;
49
40
  }).map(function (entry) {
@@ -52,12 +43,9 @@ var IntersectionObserverWrapper = /*#__PURE__*/function () {
52
43
  var index = _this2.observedItems.findIndex(function (x) {
53
44
  return x[0] === dom;
54
45
  });
55
-
56
46
  if (index > -1) {
57
47
  var component = _this2.observedItems[index][1];
58
-
59
48
  _this2.callback(component);
60
-
61
49
  _this2.unregister(dom, component);
62
50
  }
63
51
  });
@@ -74,7 +62,6 @@ var IntersectionObserverWrapper = /*#__PURE__*/function () {
74
62
  var index = this.observedItems.findIndex(function (x) {
75
63
  return x[0] === dom;
76
64
  });
77
-
78
65
  if (index > -1) {
79
66
  this.observedItems.splice(index, 1);
80
67
  this.observer && this.observer.unobserve(dom);
@@ -86,17 +73,13 @@ var IntersectionObserverWrapper = /*#__PURE__*/function () {
86
73
  this.observer.disconnect();
87
74
  }
88
75
  }]);
89
-
90
76
  return IntersectionObserverWrapper;
91
77
  }();
92
-
93
78
  var StubObserverWrapper = /*#__PURE__*/function () {
94
79
  function StubObserverWrapper(callback) {
95
80
  _classCallCheck(this, StubObserverWrapper);
96
-
97
81
  this.callback = callback;
98
82
  }
99
-
100
83
  _createClass(StubObserverWrapper, [{
101
84
  key: "register",
102
85
  value: function register(dom, component) {
@@ -112,65 +95,54 @@ var StubObserverWrapper = /*#__PURE__*/function () {
112
95
  key: "disconnect",
113
96
  value: function disconnect() {}
114
97
  }]);
115
-
116
98
  return StubObserverWrapper;
117
- }();
118
- /**
119
- * This component will ensure all {@link ResponsiveImages} that are in its descendent path will be loaded async. By default, the image is loaded with an empty gif, and the image becomes visible when the image scrolls 250 from the edge of the screen.
120
- *
121
- * You can use {@link EagerLoadImages} or `eager={true}` to force the image to be eager. If `EagerLoadImages` is passed a predicate, then images that pass a matching value to `eager` will be rendered eagerly.
122
- *
123
- * Example
124
- * ```javascript
125
- * import { LazyLoadImages, EagerLoadImages } from '@quintype/components';
126
- *
127
- * function LazyLoadSecondImage() {
128
- * return <div>
129
- * <ResponsiveImage slug={props["eager-image-1"]} />
130
- * <LazyLoadImages margin={"450px"}>
131
- * <div>
132
- * <UnrelatedContent/>
133
- * <ResponsiveImage slug={props["lazy-image-1"]} />
134
- * <ResponsiveImage slug={props["lazy-image-forced-to-be-eager"]} eager/>
135
- * <ResponsiveImage slug={props["lazy-image-2"]} />
136
- * <EagerLoadImages>
137
- * <ResponsiveImage slug={props["lazy-image-forced-to-be-eager"]} />
138
- * </EagerLoadImages>
139
- * <EagerLoadImages predicate={(token) => token % 2 === 0}>
140
- * <ResponsiveImage slug={props["lazy-image"]} eager={1} />
141
- * <ResponsiveImage slug={props["eager-image"]} eager={2} />
142
- * </EagerLoadImages>
143
- * </div>
144
- * </LazyLoadImages>
145
- * <ResponsiveImage slug={props["eager-image-2"]} />
146
- * </div>
147
- * }
148
- * ```
149
- * @component
150
- * @category Images
151
- */
152
-
153
-
99
+ }(); /**
100
+ * This component will ensure all {@link ResponsiveImages} that are in its descendent path will be loaded async. By default, the image is loaded with an empty gif, and the image becomes visible when the image scrolls 250 from the edge of the screen.
101
+ *
102
+ * You can use {@link EagerLoadImages} or `eager={true}` to force the image to be eager. If `EagerLoadImages` is passed a predicate, then images that pass a matching value to `eager` will be rendered eagerly.
103
+ *
104
+ * Example
105
+ * ```javascript
106
+ * import { LazyLoadImages, EagerLoadImages } from '@quintype/components';
107
+ *
108
+ * function LazyLoadSecondImage() {
109
+ * return <div>
110
+ * <ResponsiveImage slug={props["eager-image-1"]} />
111
+ * <LazyLoadImages margin={"450px"}>
112
+ * <div>
113
+ * <UnrelatedContent/>
114
+ * <ResponsiveImage slug={props["lazy-image-1"]} />
115
+ * <ResponsiveImage slug={props["lazy-image-forced-to-be-eager"]} eager/>
116
+ * <ResponsiveImage slug={props["lazy-image-2"]} />
117
+ * <EagerLoadImages>
118
+ * <ResponsiveImage slug={props["lazy-image-forced-to-be-eager"]} />
119
+ * </EagerLoadImages>
120
+ * <EagerLoadImages predicate={(token) => token % 2 === 0}>
121
+ * <ResponsiveImage slug={props["lazy-image"]} eager={1} />
122
+ * <ResponsiveImage slug={props["eager-image"]} eager={2} />
123
+ * </EagerLoadImages>
124
+ * </div>
125
+ * </LazyLoadImages>
126
+ * <ResponsiveImage slug={props["eager-image-2"]} />
127
+ * </div>
128
+ * }
129
+ * ```
130
+ * @component
131
+ * @category Images
132
+ */
154
133
  export var LazyLoadImages = /*#__PURE__*/function (_React$Component) {
155
134
  _inherits(LazyLoadImages, _React$Component);
156
-
157
135
  var _super = /*#__PURE__*/_createSuper(LazyLoadImages);
158
-
159
136
  function LazyLoadImages(props) {
160
137
  var _this3;
161
-
162
138
  _classCallCheck(this, LazyLoadImages);
163
-
164
139
  _this3 = _super.call(this, props);
165
-
166
140
  var callback = function callback(component) {
167
141
  return component.showImage();
168
142
  };
169
-
170
143
  _this3.observerWrapper = global.IntersectionObserver ? new IntersectionObserverWrapper(callback) : new StubObserverWrapper(callback);
171
144
  return _this3;
172
145
  }
173
-
174
146
  _createClass(LazyLoadImages, [{
175
147
  key: "componentDidMount",
176
148
  value: function componentDidMount() {
@@ -185,7 +157,6 @@ export var LazyLoadImages = /*#__PURE__*/function (_React$Component) {
185
157
  key: "getChildContext",
186
158
  value: function getChildContext() {
187
159
  var _this4 = this;
188
-
189
160
  return {
190
161
  lazyLoadObserveImage: function lazyLoadObserveImage(dom, component) {
191
162
  return dom && _this4.observerWrapper.register(dom, component);
@@ -201,7 +172,6 @@ export var LazyLoadImages = /*#__PURE__*/function (_React$Component) {
201
172
  return this.props.children;
202
173
  }
203
174
  }]);
204
-
205
175
  return LazyLoadImages;
206
176
  }(React.Component);
207
177
  LazyLoadImages.childContextTypes = {