@blaze-cms/react-page-builder 0.110.0-alpha.2 → 0.111.0-alpha.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/CHANGELOG.md +41 -0
- package/lib/components/Banner/BannerRender.js +4 -1
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Image/Image.js +10 -14
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/ImageFactory.js +1 -1
- package/lib/components/Image/ImageFactory.js.map +1 -1
- package/lib/components/Image/ImageRender.js +3 -5
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js +8 -3
- package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderWrapper.js +15 -4
- package/lib/components/List/components/Cards/CardsRenderWrapper.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js +8 -1
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js +10 -5
- package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib/components/List/helpers/get-items-per-page-to-use.js +2 -1
- package/lib/components/List/helpers/get-items-per-page-to-use.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +4 -1
- package/lib-es/components/Banner/BannerRender.js.map +1 -1
- package/lib-es/components/Image/Image.js +7 -9
- package/lib-es/components/Image/Image.js.map +1 -1
- package/lib-es/components/Image/ImageFactory.js +1 -1
- package/lib-es/components/Image/ImageFactory.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +2 -4
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRenderItem.js +9 -4
- package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRenderWrapper.js +15 -5
- package/lib-es/components/List/components/Cards/CardsRenderWrapper.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRender.js +7 -1
- package/lib-es/components/List/components/Full/FullRender.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRenderItem.js +9 -4
- package/lib-es/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib-es/components/List/helpers/get-items-per-page-to-use.js +4 -1
- package/lib-es/components/List/helpers/get-items-per-page-to-use.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Banner/BannerRender.js +3 -2
- package/src/components/Image/Image.js +6 -12
- package/src/components/Image/ImageFactory.js +1 -1
- package/src/components/Image/ImageRender.js +7 -11
- package/src/components/List/components/Cards/CardsRenderItem.js +8 -4
- package/src/components/List/components/Cards/CardsRenderWrapper.js +31 -19
- package/src/components/List/components/Full/FullRender.js +21 -12
- package/src/components/List/components/Full/FullRenderItem.js +6 -4
- package/src/components/List/helpers/get-items-per-page-to-use.js +4 -4
- package/tests/unit/src/components/Image/Image.test.js +4 -0
- package/tests/unit/src/components/Image/ImageFactory.test.js +4 -4
- package/tests/unit/src/components/Image/ImageRender.test.js +0 -6
- package/tests/unit/src/components/Image/__snapshots__/Image.test.js.snap +0 -3
- package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +6 -4
- package/tests/unit/src/components/LazyImage/LazyImage.test.js +0 -4
- package/tests/unit/src/components/List/helpers/get-items-per-page-to-use.test.js +24 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
1
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
3
|
|
|
3
4
|
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; }
|
|
@@ -11,7 +12,6 @@ import { MainContext } from '@blaze-cms/nextjs-components';
|
|
|
11
12
|
import BuildPBComponents from '../../../../hooks/helpers/buildPBComponents';
|
|
12
13
|
import Banner from '../../../Banner';
|
|
13
14
|
import { parsePropsToDisplay, shouldRenderWaypoint } from '../../../../helpers';
|
|
14
|
-
import { checkIfShouldRenderBanner } from '../helpers';
|
|
15
15
|
|
|
16
16
|
const FullRenderItem = ({
|
|
17
17
|
isInfinite,
|
|
@@ -28,7 +28,9 @@ const FullRenderItem = ({
|
|
|
28
28
|
parent,
|
|
29
29
|
pageBuilderID,
|
|
30
30
|
displayCount,
|
|
31
|
-
|
|
31
|
+
shouldRenderBanner,
|
|
32
|
+
bannerProps,
|
|
33
|
+
bannerIndex
|
|
32
34
|
}) => {
|
|
33
35
|
const {
|
|
34
36
|
hasGTM
|
|
@@ -37,7 +39,6 @@ const FullRenderItem = ({
|
|
|
37
39
|
const parsedPropsToDisplay = parsePropsToDisplay(entityProps, propsToDisplay);
|
|
38
40
|
const currentItemIndex = initialOffset + index;
|
|
39
41
|
const renderWaypoint = isInfinite && shouldRenderWaypoint(index, currentListLength, currentItemIndex, listTotal);
|
|
40
|
-
const shouldRenderBanner = !!bannerProps && checkIfShouldRenderBanner(index, bannerProps);
|
|
41
42
|
return /*#__PURE__*/React.createElement(React.Fragment, null, renderWaypoint && /*#__PURE__*/React.createElement(Waypoint, {
|
|
42
43
|
onEnter: triggerInfiniteScroll
|
|
43
44
|
}), displayCount && /*#__PURE__*/React.createElement("div", {
|
|
@@ -57,7 +58,9 @@ const FullRenderItem = ({
|
|
|
57
58
|
pageBuilderID
|
|
58
59
|
})), !!parsedPropsToDisplay.length && /*#__PURE__*/React.createElement(React.Fragment, null, parsedPropsToDisplay.map(prop => prop ? /*#__PURE__*/React.createElement("span", {
|
|
59
60
|
key: prop
|
|
60
|
-
}, prop) : null)), shouldRenderBanner && /*#__PURE__*/React.createElement(Banner, bannerProps
|
|
61
|
+
}, prop) : null)), shouldRenderBanner && /*#__PURE__*/React.createElement(Banner, _extends({}, bannerProps, {
|
|
62
|
+
cardBannerIndex: bannerIndex
|
|
63
|
+
})));
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
FullRenderItem.propTypes = {
|
|
@@ -74,6 +77,8 @@ FullRenderItem.propTypes = {
|
|
|
74
77
|
itemId: PropTypes.string.isRequired,
|
|
75
78
|
index: PropTypes.number.isRequired,
|
|
76
79
|
isInfinite: PropTypes.bool.isRequired,
|
|
80
|
+
shouldRenderBanner: PropTypes.bool.isRequired,
|
|
81
|
+
bannerIndex: PropTypes.number.isRequired,
|
|
77
82
|
propsToDisplay: PropTypes.array,
|
|
78
83
|
data: PropTypes.array,
|
|
79
84
|
itemsToDisplay: PropTypes.array,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/components/List/components/Full/FullRenderItem.js"],"names":["React","useContext","PropTypes","Waypoint","MainContext","BuildPBComponents","Banner","parsePropsToDisplay","shouldRenderWaypoint","
|
|
1
|
+
{"version":3,"sources":["../../../../../src/components/List/components/Full/FullRenderItem.js"],"names":["React","useContext","PropTypes","Waypoint","MainContext","BuildPBComponents","Banner","parsePropsToDisplay","shouldRenderWaypoint","FullRenderItem","isInfinite","pageBuilderComponents","entityProps","propsToDisplay","entity","index","itemId","listTotal","initialOffset","currentListLength","triggerInfiniteScroll","parent","pageBuilderID","displayCount","shouldRenderBanner","bannerProps","bannerIndex","hasGTM","parsedPropsToDisplay","currentItemIndex","renderWaypoint","itemEntity","length","map","prop","propTypes","array","object","isRequired","number","bool","func","string","data","itemsToDisplay","defaultProps"],"mappings":";;;;;;;AAAA,OAAOA,KAAP,IAAgBC,UAAhB,QAAkC,OAAlC;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,SAASC,WAAT,QAA4B,8BAA5B;AACA,OAAOC,iBAAP,MAA8B,6CAA9B;AACA,OAAOC,MAAP,MAAmB,iBAAnB;AACA,SAASC,mBAAT,EAA8BC,oBAA9B,QAA0D,qBAA1D;;AAEA,MAAMC,cAAc,GAAG,CAAC;AACtBC,EAAAA,U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W,EAAExB,SAAS,CAACqC,MAAV,CAAiBD,UAfL;AAgBzBzB,EAAAA,cAAc,EAAEX,SAAS,CAACkC,KAhBD;AAiBzBO,EAAAA,IAAI,EAAEzC,SAAS,CAACkC,KAjBS;AAkBzBQ,EAAAA,cAAc,EAAE1C,SAAS,CAACkC,KAlBD;AAmBzBX,EAAAA,WAAW,EAAEvB,SAAS,CAACmC;AAnBE,CAA3B;AAsBA5B,cAAc,CAACoC,YAAf,GAA8B;AAC5BlC,EAAAA,qBAAqB,EAAE,IADK;AAE5BgC,EAAAA,IAAI,EAAE,EAFsB;AAG5B9B,EAAAA,cAAc,EAAE,EAHY;AAI5B+B,EAAAA,cAAc,EAAE,EAJY;AAK5BxB,EAAAA,qBAAqB,EAAE,IALK;AAM5BK,EAAAA,WAAW,EAAE;AANe,CAA9B;AASA,eAAehB,cAAf","sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\nimport { Waypoint } from 'react-waypoint';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport BuildPBComponents from '../../../../hooks/helpers/buildPBComponents';\nimport Banner from '../../../Banner';\nimport { parsePropsToDisplay, shouldRenderWaypoint } from '../../../../helpers';\n\nconst FullRenderItem = ({\n isInfinite,\n pageBuilderComponents,\n entityProps,\n propsToDisplay,\n entity,\n index,\n itemId,\n listTotal,\n initialOffset,\n currentListLength,\n triggerInfiniteScroll,\n parent,\n pageBuilderID,\n displayCount,\n shouldRenderBanner,\n bannerProps,\n bannerIndex\n}) => {\n const { hasGTM } = useContext(MainContext);\n if (!pageBuilderComponents) return null;\n const parsedPropsToDisplay = parsePropsToDisplay(entityProps, propsToDisplay);\n const currentItemIndex = initialOffset + index;\n const renderWaypoint =\n isInfinite && shouldRenderWaypoint(index, currentListLength, currentItemIndex, listTotal);\n\n return (\n <>\n {renderWaypoint && <Waypoint onEnter={triggerInfiniteScroll} />}\n {displayCount && (\n <div className=\"heading heading--section heading--section--count\">\n <span className=\"section-number\">{currentItemIndex + 1}</span>\n <span className=\"section-total\">/{listTotal}</span>\n </div>\n )}\n <div className=\"list__item list__item--full\">\n {BuildPBComponents(pageBuilderComponents, {\n parent: { ...parent, itemId, itemEntity: entity },\n hasGTM,\n pageBuilderID\n })}\n </div>\n {!!parsedPropsToDisplay.length && (\n <>{parsedPropsToDisplay.map(prop => (prop ? <span key={prop}>{prop}</span> : null))}</>\n )}\n {shouldRenderBanner && <Banner {...bannerProps} cardBannerIndex={bannerIndex} />}\n </>\n );\n};\n\nFullRenderItem.propTypes = {\n pageBuilderComponents: PropTypes.array,\n entityProps: PropTypes.object.isRequired,\n parent: PropTypes.object.isRequired,\n currentListLength: PropTypes.number.isRequired,\n listTotal: PropTypes.number.isRequired,\n initialOffset: PropTypes.number.isRequired,\n displayCount: PropTypes.bool.isRequired,\n triggerInfiniteScroll: PropTypes.func,\n entity: PropTypes.string.isRequired,\n pageBuilderID: PropTypes.string.isRequired,\n itemId: PropTypes.string.isRequired,\n index: PropTypes.number.isRequired,\n isInfinite: PropTypes.bool.isRequired,\n shouldRenderBanner: PropTypes.bool.isRequired,\n bannerIndex: PropTypes.number.isRequired,\n propsToDisplay: PropTypes.array,\n data: PropTypes.array,\n itemsToDisplay: PropTypes.array,\n bannerProps: PropTypes.object\n};\n\nFullRenderItem.defaultProps = {\n pageBuilderComponents: null,\n data: [],\n propsToDisplay: [],\n itemsToDisplay: [],\n triggerInfiniteScroll: null,\n bannerProps: null\n};\n\nexport default FullRenderItem;\n"],"file":"FullRenderItem.js"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { DEFAULT_LIMIT } from '../../../constants';
|
|
2
2
|
|
|
3
|
-
const getItemsPerPageToUse = (itemsPerPage, limitToUse) =>
|
|
3
|
+
const getItemsPerPageToUse = (itemsPerPage, limitToUse) => {
|
|
4
|
+
if (limitToUse && itemsPerPage >= limitToUse) return limitToUse;
|
|
5
|
+
return itemsPerPage || limitToUse || DEFAULT_LIMIT;
|
|
6
|
+
};
|
|
4
7
|
|
|
5
8
|
export default getItemsPerPageToUse;
|
|
6
9
|
//# sourceMappingURL=get-items-per-page-to-use.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/components/List/helpers/get-items-per-page-to-use.js"],"names":["DEFAULT_LIMIT","getItemsPerPageToUse","itemsPerPage","limitToUse"],"mappings":"AAAA,SAASA,aAAT,QAA8B,oBAA9B;;AAEA,MAAMC,oBAAoB,GAAG,CAACC,YAAD,EAAeC,UAAf,
|
|
1
|
+
{"version":3,"sources":["../../../../src/components/List/helpers/get-items-per-page-to-use.js"],"names":["DEFAULT_LIMIT","getItemsPerPageToUse","itemsPerPage","limitToUse"],"mappings":"AAAA,SAASA,aAAT,QAA8B,oBAA9B;;AAEA,MAAMC,oBAAoB,GAAG,CAACC,YAAD,EAAeC,UAAf,KAA8B;AACzD,MAAIA,UAAU,IAAID,YAAY,IAAIC,UAAlC,EAA8C,OAAOA,UAAP;AAC9C,SAAOD,YAAY,IAAIC,UAAhB,IAA8BH,aAArC;AACD,CAHD;;AAKA,eAAeC,oBAAf","sourcesContent":["import { DEFAULT_LIMIT } from '../../../constants';\n\nconst getItemsPerPageToUse = (itemsPerPage, limitToUse) => {\n if (limitToUse && itemsPerPage >= limitToUse) return limitToUse;\n return itemsPerPage || limitToUse || DEFAULT_LIMIT;\n};\n\nexport default getItemsPerPageToUse;\n"],"file":"get-items-per-page-to-use.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.111.0-alpha.2",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"lib/*",
|
|
89
89
|
"lib-es/*"
|
|
90
90
|
],
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "f3efa34b54fecfe15f81505509af8ccc1d3d66f9"
|
|
92
92
|
}
|
|
@@ -79,20 +79,21 @@ const BannerRender = ({
|
|
|
79
79
|
const isContextualTargetingReady = isContextualTargetingSet || !propsToDisplay.length;
|
|
80
80
|
const shouldShowBanner =
|
|
81
81
|
parsedAdunit && parsedSizes && !!parsedSizes.length && isContextualTargetingReady;
|
|
82
|
+
|
|
82
83
|
if (!shouldShowBanner) return null;
|
|
83
84
|
const customTargetings = setCustomTargetings(targetings, cardBannerIndex);
|
|
84
|
-
|
|
85
85
|
const style = {
|
|
86
86
|
maxHeight: maxBannerHeight,
|
|
87
87
|
minHeight: minBannerHeight
|
|
88
88
|
};
|
|
89
|
+
const targetingArguments = { ...parsedTargetings, ...customTargetings };
|
|
89
90
|
|
|
90
91
|
return (
|
|
91
92
|
<div className="ad-slot" style={style}>
|
|
92
93
|
<AdSlot
|
|
93
94
|
adUnit={parsedAdunit}
|
|
94
95
|
sizes={parsedSizes}
|
|
95
|
-
targetingArguments={
|
|
96
|
+
targetingArguments={targetingArguments}
|
|
96
97
|
sizeMapping={sizeMapping}
|
|
97
98
|
/>
|
|
98
99
|
</div>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import { Waypoint } from 'react-waypoint';
|
|
3
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
4
4
|
import Wrapper from '../Wrapper';
|
|
5
5
|
import ImageRender from './ImageRender';
|
|
6
6
|
import ImageDetails from './ImageDetails';
|
|
7
7
|
import getClassModifiers from '../../utils/get-class-modifiers';
|
|
8
8
|
import { getImageData } from '../../utils';
|
|
9
9
|
import { getDisplayCountData, shouldShowProperty, buildImageProperties } from '../../helpers';
|
|
10
|
-
import {
|
|
10
|
+
import { IMAGE, HERO, IN_VIEW_CONFIG } from '../../constants';
|
|
11
11
|
|
|
12
12
|
const Image = ({
|
|
13
13
|
url,
|
|
@@ -32,8 +32,7 @@ const Image = ({
|
|
|
32
32
|
...otherProps
|
|
33
33
|
}) => {
|
|
34
34
|
const [displayLightbox, setDisplayLightbox] = useState(false);
|
|
35
|
-
const [isIntersecting,
|
|
36
|
-
|
|
35
|
+
const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);
|
|
37
36
|
const { caption, altText, hrefUrl } = getImageData(otherProps, imageData);
|
|
38
37
|
|
|
39
38
|
const href = url || hrefUrl;
|
|
@@ -70,19 +69,14 @@ const Image = ({
|
|
|
70
69
|
});
|
|
71
70
|
const { shouldDisplayCount, countMessage } = getDisplayCountData(displayCount, images);
|
|
72
71
|
const sizeKey = [IMAGE, isHero ? HERO : '', _modifier].filter(Boolean).join(':');
|
|
73
|
-
|
|
72
|
+
const shouldDisplayImage = !!imageUrl && isIntersecting;
|
|
74
73
|
return (
|
|
75
|
-
<Wrapper className={wrapperClassName} modifiers={modifiers} {...otherProps}>
|
|
76
|
-
<Waypoint
|
|
77
|
-
onEnter={() => !isIntersecting && setIsIntersecting(true)}
|
|
78
|
-
bottomOffset={WAYPOINT_BOTTOM_OFFSET}
|
|
79
|
-
/>
|
|
74
|
+
<Wrapper ref={outerRef} className={wrapperClassName} modifiers={modifiers} {...otherProps}>
|
|
80
75
|
{elementTitle && <h2 className="heading heading--section">{elementTitle}</h2>}
|
|
81
|
-
{
|
|
76
|
+
{shouldDisplayImage && (
|
|
82
77
|
<ImgWrapper {...imgWrapperProps}>
|
|
83
78
|
<ImageRender
|
|
84
79
|
{...otherProps}
|
|
85
|
-
isIntersecting={isIntersecting}
|
|
86
80
|
alt={altText}
|
|
87
81
|
imageUrl={imageUrl}
|
|
88
82
|
handleEnableLightbox={handleEnableLightbox}
|
|
@@ -4,7 +4,6 @@ import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
|
|
|
4
4
|
import Lightbox from './Lightbox';
|
|
5
5
|
|
|
6
6
|
const ImageRender = ({
|
|
7
|
-
isIntersecting,
|
|
8
7
|
alt,
|
|
9
8
|
imageUrl,
|
|
10
9
|
handleEnableLightbox,
|
|
@@ -24,15 +23,13 @@ const ImageRender = ({
|
|
|
24
23
|
const imageStyle = enableLightbox ? { cursor: 'pointer' } : style;
|
|
25
24
|
return (
|
|
26
25
|
<>
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/>
|
|
35
|
-
)}
|
|
26
|
+
<ResponsiveImage
|
|
27
|
+
sizeKey={sizeKey}
|
|
28
|
+
alt={alt}
|
|
29
|
+
src={imageUrl}
|
|
30
|
+
onClick={handleEnableLightbox}
|
|
31
|
+
style={imageStyle}
|
|
32
|
+
/>
|
|
36
33
|
{displayLightbox && (
|
|
37
34
|
<Lightbox
|
|
38
35
|
imageUrl={imageUrl}
|
|
@@ -49,7 +46,6 @@ const ImageRender = ({
|
|
|
49
46
|
};
|
|
50
47
|
|
|
51
48
|
ImageRender.propTypes = {
|
|
52
|
-
isIntersecting: PropTypes.bool.isRequired,
|
|
53
49
|
displayLightbox: PropTypes.bool.isRequired,
|
|
54
50
|
enableLightbox: PropTypes.bool.isRequired,
|
|
55
51
|
alt: PropTypes.string,
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { Waypoint } from 'react-waypoint';
|
|
4
4
|
import Card from '../../../Card/Card';
|
|
5
5
|
import { shouldRenderWaypoint, renderChildren, parsePropsToDisplay } from '../../../../helpers';
|
|
6
|
-
import { checkIfShouldRenderGtm
|
|
6
|
+
import { checkIfShouldRenderGtm } from '../helpers';
|
|
7
7
|
import Banner from '../../../Banner';
|
|
8
8
|
|
|
9
9
|
const CardsRenderItem = ({
|
|
@@ -18,7 +18,9 @@ const CardsRenderItem = ({
|
|
|
18
18
|
modifier,
|
|
19
19
|
gridModifier,
|
|
20
20
|
propsToDisplayModifiers,
|
|
21
|
-
propsToDisplay
|
|
21
|
+
propsToDisplay,
|
|
22
|
+
shouldRenderBanner,
|
|
23
|
+
bannerIndex
|
|
22
24
|
}) => {
|
|
23
25
|
const {
|
|
24
26
|
initialOffset,
|
|
@@ -40,7 +42,7 @@ const CardsRenderItem = ({
|
|
|
40
42
|
isInfinite && shouldRenderWaypoint(index, currentListLength, currentItemIndex, listTotal);
|
|
41
43
|
const shouldRenderGtm =
|
|
42
44
|
gtmChildren && checkIfShouldRenderGtm(itemsPerPage, currentListLength, index);
|
|
43
|
-
|
|
45
|
+
|
|
44
46
|
const parsedPropsToDisplay = parsePropsToDisplay(cardProps, propsToDisplay);
|
|
45
47
|
|
|
46
48
|
return (
|
|
@@ -72,7 +74,7 @@ const CardsRenderItem = ({
|
|
|
72
74
|
{...cardProps}
|
|
73
75
|
/>
|
|
74
76
|
</div>
|
|
75
|
-
{shouldRenderBanner && <Banner {...bannerProps} />}
|
|
77
|
+
{shouldRenderBanner && <Banner {...bannerProps} cardBannerIndex={bannerIndex} />}
|
|
76
78
|
</>
|
|
77
79
|
);
|
|
78
80
|
};
|
|
@@ -83,6 +85,8 @@ CardsRenderItem.propTypes = {
|
|
|
83
85
|
index: PropTypes.number.isRequired,
|
|
84
86
|
currentListLength: PropTypes.number.isRequired,
|
|
85
87
|
propsToDisplayModifiers: PropTypes.array.isRequired,
|
|
88
|
+
shouldRenderBanner: PropTypes.bool.isRequired,
|
|
89
|
+
bannerIndex: PropTypes.number.isRequired,
|
|
86
90
|
bannerProps: PropTypes.object,
|
|
87
91
|
gridModifier: PropTypes.string,
|
|
88
92
|
propsToDisplay: PropTypes.array,
|
|
@@ -3,34 +3,46 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import CardsRenderItem from './CardsRenderItem';
|
|
4
4
|
import Wrapper from '../../../Wrapper';
|
|
5
5
|
import { withTitle } from '../../../../HOC';
|
|
6
|
+
import { checkIfShouldRenderBanner } from '../helpers';
|
|
6
7
|
|
|
7
|
-
const CardsRenderWrapper = ({ orderedListData, gridModifier, ...props }) =>
|
|
8
|
-
|
|
9
|
-
{orderedListData.map((cardProps, index) => {
|
|
10
|
-
const { id } = cardProps;
|
|
8
|
+
const CardsRenderWrapper = ({ orderedListData, gridModifier, bannerProps, ...props }) => {
|
|
9
|
+
let bannerIndex = 0;
|
|
11
10
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
return (
|
|
12
|
+
<Wrapper className="grid" modifiers={gridModifier}>
|
|
13
|
+
{orderedListData.map((cardProps, index) => {
|
|
14
|
+
const { id } = cardProps;
|
|
15
|
+
const shouldRenderBanner = !!bannerProps && checkIfShouldRenderBanner(index, bannerProps);
|
|
16
|
+
if (shouldRenderBanner) bannerIndex += 1;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<CardsRenderItem
|
|
20
|
+
key={id}
|
|
21
|
+
index={index}
|
|
22
|
+
cardProps={cardProps}
|
|
23
|
+
gridModifier={gridModifier}
|
|
24
|
+
listProps={props}
|
|
25
|
+
shouldRenderBanner={shouldRenderBanner}
|
|
26
|
+
bannerProps={bannerProps}
|
|
27
|
+
bannerIndex={bannerIndex}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
})}
|
|
32
|
+
</Wrapper>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
25
35
|
|
|
26
36
|
CardsRenderWrapper.propTypes = {
|
|
27
37
|
orderedListData: PropTypes.array.isRequired,
|
|
28
38
|
gridModifier: PropTypes.string.isRequired,
|
|
29
|
-
imagesData: PropTypes.array
|
|
39
|
+
imagesData: PropTypes.array,
|
|
40
|
+
bannerProps: PropTypes.object
|
|
30
41
|
};
|
|
31
42
|
|
|
32
43
|
CardsRenderWrapper.defaultProps = {
|
|
33
|
-
imagesData: []
|
|
44
|
+
imagesData: [],
|
|
45
|
+
bannerProps: {}
|
|
34
46
|
};
|
|
35
47
|
|
|
36
48
|
export default withTitle(CardsRenderWrapper);
|
|
@@ -5,6 +5,7 @@ import FullRenderItem from './FullRenderItem';
|
|
|
5
5
|
import ListPagination from '../Pagination';
|
|
6
6
|
import { LOAD_MORE } from '../../../../constants';
|
|
7
7
|
import { BANNER } from '../../constants';
|
|
8
|
+
import { checkIfShouldRenderBanner } from '../helpers';
|
|
8
9
|
|
|
9
10
|
const FullRender = ({ orderedListData, paginationType, ...props }) => {
|
|
10
11
|
const pageBuilderID = uuid();
|
|
@@ -12,22 +13,30 @@ const FullRender = ({ orderedListData, paginationType, ...props }) => {
|
|
|
12
13
|
const bannerProps = banner
|
|
13
14
|
? { hasBanner, parent, entity, propsToDisplay, ...banner, type: BANNER }
|
|
14
15
|
: null;
|
|
16
|
+
let bannerIndex = 0;
|
|
15
17
|
|
|
16
18
|
return (
|
|
17
19
|
<>
|
|
18
20
|
<div className="list list--full">
|
|
19
|
-
{orderedListData.map(({ id, ...entityProps }, i) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
{orderedListData.map(({ id, ...entityProps }, i) => {
|
|
22
|
+
const shouldRenderBanner = !!bannerProps && checkIfShouldRenderBanner(i, bannerProps);
|
|
23
|
+
if (shouldRenderBanner) bannerIndex += 1;
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<FullRenderItem
|
|
27
|
+
key={id}
|
|
28
|
+
{...props}
|
|
29
|
+
{...entityProps}
|
|
30
|
+
index={i}
|
|
31
|
+
itemId={id}
|
|
32
|
+
pageBuilderID={pageBuilderID}
|
|
33
|
+
entityProps={entityProps}
|
|
34
|
+
shouldRenderBanner={shouldRenderBanner}
|
|
35
|
+
bannerProps={bannerProps}
|
|
36
|
+
bannerIndex={bannerIndex}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
})}
|
|
31
40
|
</div>
|
|
32
41
|
{paginationType === LOAD_MORE && (
|
|
33
42
|
<ListPagination paginationType={paginationType} {...props} />
|
|
@@ -5,7 +5,6 @@ import { MainContext } from '@blaze-cms/nextjs-components';
|
|
|
5
5
|
import BuildPBComponents from '../../../../hooks/helpers/buildPBComponents';
|
|
6
6
|
import Banner from '../../../Banner';
|
|
7
7
|
import { parsePropsToDisplay, shouldRenderWaypoint } from '../../../../helpers';
|
|
8
|
-
import { checkIfShouldRenderBanner } from '../helpers';
|
|
9
8
|
|
|
10
9
|
const FullRenderItem = ({
|
|
11
10
|
isInfinite,
|
|
@@ -22,7 +21,9 @@ const FullRenderItem = ({
|
|
|
22
21
|
parent,
|
|
23
22
|
pageBuilderID,
|
|
24
23
|
displayCount,
|
|
25
|
-
|
|
24
|
+
shouldRenderBanner,
|
|
25
|
+
bannerProps,
|
|
26
|
+
bannerIndex
|
|
26
27
|
}) => {
|
|
27
28
|
const { hasGTM } = useContext(MainContext);
|
|
28
29
|
if (!pageBuilderComponents) return null;
|
|
@@ -30,7 +31,6 @@ const FullRenderItem = ({
|
|
|
30
31
|
const currentItemIndex = initialOffset + index;
|
|
31
32
|
const renderWaypoint =
|
|
32
33
|
isInfinite && shouldRenderWaypoint(index, currentListLength, currentItemIndex, listTotal);
|
|
33
|
-
const shouldRenderBanner = !!bannerProps && checkIfShouldRenderBanner(index, bannerProps);
|
|
34
34
|
|
|
35
35
|
return (
|
|
36
36
|
<>
|
|
@@ -51,7 +51,7 @@ const FullRenderItem = ({
|
|
|
51
51
|
{!!parsedPropsToDisplay.length && (
|
|
52
52
|
<>{parsedPropsToDisplay.map(prop => (prop ? <span key={prop}>{prop}</span> : null))}</>
|
|
53
53
|
)}
|
|
54
|
-
{shouldRenderBanner && <Banner {...bannerProps} />}
|
|
54
|
+
{shouldRenderBanner && <Banner {...bannerProps} cardBannerIndex={bannerIndex} />}
|
|
55
55
|
</>
|
|
56
56
|
);
|
|
57
57
|
};
|
|
@@ -70,6 +70,8 @@ FullRenderItem.propTypes = {
|
|
|
70
70
|
itemId: PropTypes.string.isRequired,
|
|
71
71
|
index: PropTypes.number.isRequired,
|
|
72
72
|
isInfinite: PropTypes.bool.isRequired,
|
|
73
|
+
shouldRenderBanner: PropTypes.bool.isRequired,
|
|
74
|
+
bannerIndex: PropTypes.number.isRequired,
|
|
73
75
|
propsToDisplay: PropTypes.array,
|
|
74
76
|
data: PropTypes.array,
|
|
75
77
|
itemsToDisplay: PropTypes.array,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { DEFAULT_LIMIT } from '../../../constants';
|
|
2
2
|
|
|
3
|
-
const getItemsPerPageToUse = (itemsPerPage, limitToUse) =>
|
|
4
|
-
(limitToUse && itemsPerPage >= limitToUse)
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const getItemsPerPageToUse = (itemsPerPage, limitToUse) => {
|
|
4
|
+
if (limitToUse && itemsPerPage >= limitToUse) return limitToUse;
|
|
5
|
+
return itemsPerPage || limitToUse || DEFAULT_LIMIT;
|
|
6
|
+
};
|
|
7
7
|
|
|
8
8
|
export default getItemsPerPageToUse;
|
|
@@ -7,6 +7,10 @@ jest.mock('../../../../../src/components/Image/ImageRender', () =>
|
|
|
7
7
|
jest.fn(({ alt, imageUrl, sizeKey }) => <img alt={alt} src={imageUrl} data-testid={sizeKey} />)
|
|
8
8
|
);
|
|
9
9
|
|
|
10
|
+
jest.mock('@blaze-react/utils/lib/customHooks', () => ({
|
|
11
|
+
useInView: jest.fn(() => [true, null])
|
|
12
|
+
}));
|
|
13
|
+
|
|
10
14
|
const renderComponent = props => {
|
|
11
15
|
const _render = render(<Image {...props} />);
|
|
12
16
|
return { ..._render };
|
|
@@ -5,16 +5,16 @@ import { MockedRoot } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
|
5
5
|
import ImageFactory from '../../../../../src/components/Image/ImageFactory';
|
|
6
6
|
import { MOCK_BASIC, MOCK_NO_URL, MOCK_WITH_ERR } from './mocks';
|
|
7
7
|
|
|
8
|
+
jest.mock('@blaze-react/utils/lib/customHooks', () => ({
|
|
9
|
+
useInView: jest.fn(() => [true, null])
|
|
10
|
+
}));
|
|
11
|
+
|
|
8
12
|
const setup = async (props, mocks) => (
|
|
9
13
|
<MockedRoot mocks={mocks} addTypename={false}>
|
|
10
14
|
<ImageFactory {...props} />
|
|
11
15
|
</MockedRoot>
|
|
12
16
|
);
|
|
13
17
|
|
|
14
|
-
jest.mock('react-waypoint', () => ({
|
|
15
|
-
Waypoint: jest.fn(() => <div>Test Component</div>)
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
18
|
const renderComponent = async component => {
|
|
19
19
|
let renderResults;
|
|
20
20
|
|
|
@@ -19,12 +19,6 @@ const mockedProps = {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
describe('Image Render component', () => {
|
|
22
|
-
it('should render if not interseting and lightbox not displaying', () => {
|
|
23
|
-
const { container } = render(<ImageRender {...mockedProps} isIntersecting={false} />);
|
|
24
|
-
|
|
25
|
-
expect(container).toBeEmptyDOMElement();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
22
|
it('should render image', () => {
|
|
29
23
|
const { container, asFragment } = render(<ImageRender {...mockedProps} />);
|
|
30
24
|
expect(container.childNodes[0].nodeName).toEqual('IMG');
|
|
@@ -5,15 +5,17 @@ exports[`ImageFactory component should render image 1`] = `
|
|
|
5
5
|
<div
|
|
6
6
|
class="image "
|
|
7
7
|
>
|
|
8
|
-
<div>
|
|
9
|
-
Test Component
|
|
10
|
-
</div>
|
|
11
8
|
<a
|
|
12
9
|
class="image__wrapper"
|
|
13
10
|
href="http://www.url-test-prop.com"
|
|
14
11
|
rel="noopener nofollow"
|
|
15
12
|
target="_blank"
|
|
16
|
-
|
|
13
|
+
>
|
|
14
|
+
<img
|
|
15
|
+
alt=""
|
|
16
|
+
src="test-url"
|
|
17
|
+
/>
|
|
18
|
+
</a>
|
|
17
19
|
</div>
|
|
18
20
|
</DocumentFragment>
|
|
19
21
|
`;
|
|
@@ -16,10 +16,6 @@ const props = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
describe('LazyImage component', () => {
|
|
19
|
-
it('should be defined', () => {
|
|
20
|
-
expect(LazyImage).toBeDefined();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
19
|
it('should not load image when not in view', () => {
|
|
24
20
|
const queryByAltText = lazyImageTest(false);
|
|
25
21
|
expect(queryByAltText(props.alt)).toBeNull();
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import getItemsPerPageToUse from '../../../../../../src/components/List/helpers/get-items-per-page-to-use';
|
|
2
|
+
|
|
3
|
+
export default getItemsPerPageToUse;
|
|
4
|
+
describe('getItemsPerPageToUse helper function', () => {
|
|
5
|
+
it('should return limit if passed and itemsPerPage is greater', () => {
|
|
6
|
+
const withLimit = getItemsPerPageToUse(12, 3);
|
|
7
|
+
expect(withLimit).toEqual(3);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it('should return itemsPerPage if passed and is lower than limit', () => {
|
|
11
|
+
const withLimit = getItemsPerPageToUse(12, 15);
|
|
12
|
+
expect(withLimit).toEqual(12);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('should return limit if no itemsPerPage is passed', () => {
|
|
16
|
+
const withLimit = getItemsPerPageToUse(null, 5);
|
|
17
|
+
expect(withLimit).toEqual(5);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should return 50 if no itemsPerPage or limit is passed', () => {
|
|
21
|
+
const withLimit = getItemsPerPageToUse(null, null);
|
|
22
|
+
expect(withLimit).toEqual(50);
|
|
23
|
+
});
|
|
24
|
+
});
|