@quintype/components 3.8.7-fix-jsembed-element.0 → 3.8.8-add-collection-index.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.
package/dist/cjs/index.js CHANGED
@@ -21,10 +21,10 @@ var _extends = require('@babel/runtime/helpers/extends');
21
21
  var emptyWebGif = require('empty-web-gif');
22
22
  var quintypeJs = require('quintype-js');
23
23
  var reactHelmet = require('react-helmet');
24
+ var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
24
25
  var classNames = require('classnames');
25
26
  var _asyncToGenerator = require('@babel/runtime/helpers/asyncToGenerator');
26
27
  var _regeneratorRuntime = require('@babel/runtime/regenerator');
27
- var _assertThisInitialized = require('@babel/runtime/helpers/assertThisInitialized');
28
28
  var getVideoID = require('get-video-id');
29
29
  var getYouTubeID = require('get-youtube-id');
30
30
  var ReactDOM = require('react-dom');
@@ -63,10 +63,10 @@ var _toConsumableArray__default = /*#__PURE__*/_interopDefaultLegacy(_toConsumab
63
63
  var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
64
64
  var _extends__default = /*#__PURE__*/_interopDefaultLegacy(_extends);
65
65
  var emptyWebGif__default = /*#__PURE__*/_interopDefaultLegacy(emptyWebGif);
66
+ var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
66
67
  var classNames__default = /*#__PURE__*/_interopDefaultLegacy(classNames);
67
68
  var _asyncToGenerator__default = /*#__PURE__*/_interopDefaultLegacy(_asyncToGenerator);
68
69
  var _regeneratorRuntime__default = /*#__PURE__*/_interopDefaultLegacy(_regeneratorRuntime);
69
- var _assertThisInitialized__default = /*#__PURE__*/_interopDefaultLegacy(_assertThisInitialized);
70
70
  var getVideoID__default = /*#__PURE__*/_interopDefaultLegacy(getVideoID);
71
71
  var getYouTubeID__default = /*#__PURE__*/_interopDefaultLegacy(getYouTubeID);
72
72
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
@@ -1394,7 +1394,8 @@ function renderCollectionItem(collectionItem, index, collectionTemplates, storyT
1394
1394
  key: "".concat(index, "-").concat(collectionItem.id),
1395
1395
  index: index,
1396
1396
  collection: collectionItem,
1397
- metadata: collectionItem["associated-metadata"] || {}
1397
+ metadata: collectionItem["associated-metadata"] || {},
1398
+ collectionIndex: collectionItem === null || collectionItem === void 0 ? void 0 : collectionItem["collectionIndex"]
1398
1399
  }, otherProps));
1399
1400
 
1400
1401
  case "story":
@@ -1926,10 +1927,14 @@ function responsiveProps(props) {
1926
1927
  }, props.imgParams));
1927
1928
  }
1928
1929
 
1930
+ var resolvePath = function resolvePath(size) {
1931
+ return props.shouldDecodeImage ? decodeURIComponent(generatePath(size)) : generatePath(size);
1932
+ };
1933
+
1929
1934
  var imageProps = {
1930
- src: generatePath(props.defaultWidth),
1935
+ src: resolvePath(props.defaultWidth),
1931
1936
  srcSet: props.widths ? props.widths.map(function (size) {
1932
- return "".concat(generatePath(size), " ").concat(size, "w");
1937
+ return "".concat(resolvePath(size), " ").concat(size, "w");
1933
1938
  }).join(',') : undefined,
1934
1939
  key: hashString(props.slug),
1935
1940
  sizes: props === null || props === void 0 ? void 0 : props.sizes
@@ -3752,38 +3757,47 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
3752
3757
  _classCallCheck__default["default"](this, StoryElementBase);
3753
3758
 
3754
3759
  _this2 = _super2.call(this, props);
3760
+
3761
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this2), "initiateObserver", function () {
3762
+ if (_this2.props.disableAnalytics === true) return false;
3763
+ var options = {
3764
+ root: null,
3765
+ rootMargin: "0px",
3766
+ threshold: 1.0
3767
+ };
3768
+ _this2.observer = new IntersectionObserver(_this2.observerCallback, options);
3769
+
3770
+ _this2.observer.observe(_this2.storyElementRef);
3771
+ });
3772
+
3773
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this2), "destroyObserver", function () {
3774
+ _this2.observer && _this2.observer.disconnect();
3775
+ });
3776
+
3777
+ _defineProperty__default["default"](_assertThisInitialized__default["default"](_this2), "observerCallback", function (entries) {
3778
+ entries.forEach(function (entry) {
3779
+ if (entry.isIntersecting) {
3780
+ _this2.emitElementQlitics();
3781
+ }
3782
+ });
3783
+ });
3784
+
3755
3785
  _this2.observer = null;
3756
3786
  _this2.storyElementRef = null;
3757
3787
  return _this2;
3758
- } // componentDidMount() {
3759
- // this.initiateObserver();
3760
- // }
3761
- // componentWillUnmount() {
3762
- // this.destroyObserver();
3763
- // }
3764
- // initiateObserver = () => {
3765
- // if (this.props.disableAnalytics === true) return false;
3766
- // const options = {
3767
- // root: null,
3768
- // rootMargin: "200px",
3769
- // threshold: 1.0,
3770
- // };
3771
- // this.observer = new IntersectionObserver(this.observerCallback, options);
3772
- // this.observer.observe(this.storyElementRef);
3773
- // };
3774
- // destroyObserver = () => {
3775
- // this.observer && this.observer.disconnect();
3776
- // };
3777
- // observerCallback = (entries) => {
3778
- // entries.forEach((entry) => {
3779
- // if (entry.isIntersecting) {
3780
- // this.emitElementQlitics();
3781
- // }
3782
- // });
3783
- // };
3784
-
3788
+ }
3785
3789
 
3786
3790
  _createClass__default["default"](StoryElementBase, [{
3791
+ key: "componentDidMount",
3792
+ value: function componentDidMount() {
3793
+ this.initiateObserver();
3794
+ }
3795
+ }, {
3796
+ key: "componentWillUnmount",
3797
+ value: function componentWillUnmount() {
3798
+ this.destroyObserver();
3799
+ }
3800
+ }, {
3787
3801
  key: "template",
3788
3802
  value: function template() {
3789
3803
  var storyElement = this.props.element;
@@ -25,7 +25,8 @@ export function renderCollectionItem(collectionItem, index, collectionTemplates,
25
25
  key: "".concat(index, "-").concat(collectionItem.id),
26
26
  index: index,
27
27
  collection: collectionItem,
28
- metadata: collectionItem["associated-metadata"] || {}
28
+ metadata: collectionItem["associated-metadata"] || {},
29
+ collectionIndex: collectionItem === null || collectionItem === void 0 ? void 0 : collectionItem["collectionIndex"]
29
30
  }, otherProps));
30
31
 
31
32
  case "story":
@@ -31,10 +31,14 @@ export function responsiveProps(props) {
31
31
  }, props.imgParams));
32
32
  }
33
33
 
34
+ var resolvePath = function resolvePath(size) {
35
+ return props.shouldDecodeImage ? decodeURIComponent(generatePath(size)) : generatePath(size);
36
+ };
37
+
34
38
  var imageProps = {
35
- src: generatePath(props.defaultWidth),
39
+ src: resolvePath(props.defaultWidth),
36
40
  srcSet: props.widths ? props.widths.map(function (size) {
37
- return "".concat(generatePath(size), " ").concat(size, "w");
41
+ return "".concat(resolvePath(size), " ").concat(size, "w");
38
42
  }).join(',') : undefined,
39
43
  key: hashString(props.slug),
40
44
  sizes: props === null || props === void 0 ? void 0 : props.sizes
@@ -1,5 +1,6 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
1
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
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";
5
6
  import _inherits from "@babel/runtime/helpers/inherits";
@@ -244,38 +245,47 @@ var StoryElementBase = /*#__PURE__*/function (_React$Component2) {
244
245
  _classCallCheck(this, StoryElementBase);
245
246
 
246
247
  _this2 = _super2.call(this, props);
248
+
249
+ _defineProperty(_assertThisInitialized(_this2), "initiateObserver", function () {
250
+ if (_this2.props.disableAnalytics === true) return false;
251
+ var options = {
252
+ root: null,
253
+ rootMargin: "0px",
254
+ threshold: 1.0
255
+ };
256
+ _this2.observer = new IntersectionObserver(_this2.observerCallback, options);
257
+
258
+ _this2.observer.observe(_this2.storyElementRef);
259
+ });
260
+
261
+ _defineProperty(_assertThisInitialized(_this2), "destroyObserver", function () {
262
+ _this2.observer && _this2.observer.disconnect();
263
+ });
264
+
265
+ _defineProperty(_assertThisInitialized(_this2), "observerCallback", function (entries) {
266
+ entries.forEach(function (entry) {
267
+ if (entry.isIntersecting) {
268
+ _this2.emitElementQlitics();
269
+ }
270
+ });
271
+ });
272
+
247
273
  _this2.observer = null;
248
274
  _this2.storyElementRef = null;
249
275
  return _this2;
250
- } // componentDidMount() {
251
- // this.initiateObserver();
252
- // }
253
- // componentWillUnmount() {
254
- // this.destroyObserver();
255
- // }
256
- // initiateObserver = () => {
257
- // if (this.props.disableAnalytics === true) return false;
258
- // const options = {
259
- // root: null,
260
- // rootMargin: "200px",
261
- // threshold: 1.0,
262
- // };
263
- // this.observer = new IntersectionObserver(this.observerCallback, options);
264
- // this.observer.observe(this.storyElementRef);
265
- // };
266
- // destroyObserver = () => {
267
- // this.observer && this.observer.disconnect();
268
- // };
269
- // observerCallback = (entries) => {
270
- // entries.forEach((entry) => {
271
- // if (entry.isIntersecting) {
272
- // this.emitElementQlitics();
273
- // }
274
- // });
275
- // };
276
-
276
+ }
277
277
 
278
278
  _createClass(StoryElementBase, [{
279
+ key: "componentDidMount",
280
+ value: function componentDidMount() {
281
+ this.initiateObserver();
282
+ }
283
+ }, {
284
+ key: "componentWillUnmount",
285
+ value: function componentWillUnmount() {
286
+ this.destroyObserver();
287
+ }
288
+ }, {
279
289
  key: "template",
280
290
  value: function template() {
281
291
  var storyElement = this.props.element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/components",
3
- "version": "3.8.7-fix-jsembed-element.0",
3
+ "version": "3.8.8-add-collection-index.1",
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",