@blaze-cms/react-page-builder 0.126.0-shorthand.2 → 0.126.0
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 +7 -10
- package/README.md +0 -4
- package/lib/components/Banner/BannerRender.js +5 -5
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Banner/helpers.js +2 -2
- package/lib/components/Banner/helpers.js.map +1 -1
- package/lib/components/Card/CardContainer.js +3 -3
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Code/Code.js +4 -7
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/Code/helpers/wrap-script-tags.js +3 -7
- package/lib/components/Code/helpers/wrap-script-tags.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroup.js +13 -4
- package/lib/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupTabs.js +43 -31
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib/components/ContentGroup/constants.js +18 -0
- package/lib/components/ContentGroup/constants.js.map +1 -0
- package/lib/components/ContentGroup/helpers/get-active-tab.js +23 -0
- package/lib/components/ContentGroup/helpers/get-active-tab.js.map +1 -0
- package/lib/components/ContentGroup/helpers/get-sections-data.js +25 -0
- package/lib/components/ContentGroup/helpers/get-sections-data.js.map +1 -0
- package/lib/components/ContentGroup/helpers/index.js +22 -0
- package/lib/components/ContentGroup/helpers/index.js.map +1 -0
- package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
- package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js +1 -1
- package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js +1 -1
- package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +5 -5
- package/lib-es/components/Banner/BannerRender.js.map +1 -1
- package/lib-es/components/Banner/helpers.js +2 -2
- package/lib-es/components/Banner/helpers.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +3 -3
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Code/Code.js +5 -8
- package/lib-es/components/Code/Code.js.map +1 -1
- package/lib-es/components/Code/helpers/wrap-script-tags.js +3 -7
- package/lib-es/components/Code/helpers/wrap-script-tags.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroup.js +14 -5
- package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupTabs.js +48 -39
- package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib-es/components/ContentGroup/constants.js +7 -0
- package/lib-es/components/ContentGroup/constants.js.map +1 -0
- package/lib-es/components/ContentGroup/helpers/get-active-tab.js +10 -0
- package/lib-es/components/ContentGroup/helpers/get-active-tab.js.map +1 -0
- package/lib-es/components/ContentGroup/helpers/get-sections-data.js +15 -0
- package/lib-es/components/ContentGroup/helpers/get-sections-data.js.map +1 -0
- package/lib-es/components/ContentGroup/helpers/index.js +4 -0
- package/lib-es/components/ContentGroup/helpers/index.js.map +1 -0
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js +4 -2
- package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRenderItem.js +1 -1
- package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRenderItem.js +1 -1
- package/lib-es/components/List/components/Full/FullRenderItem.js.map +1 -1
- package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
- package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
- package/package.json +3 -3
- package/src/components/Banner/BannerRender.js +4 -4
- package/src/components/Banner/helpers.js +3 -3
- package/src/components/Card/CardContainer.js +3 -3
- package/src/components/Code/Code.js +4 -6
- package/src/components/Code/helpers/wrap-script-tags.js +3 -7
- package/src/components/ContentGroup/ContentGroup.js +16 -4
- package/src/components/ContentGroup/ContentGroupTabs.js +44 -28
- package/src/components/ContentGroup/constants.js +7 -0
- package/src/components/ContentGroup/helpers/get-active-tab.js +11 -0
- package/src/components/ContentGroup/helpers/get-sections-data.js +7 -0
- package/src/components/ContentGroup/helpers/index.js +4 -0
- package/src/components/ContentGroupSection/ContentGroupSection.js +6 -2
- package/src/components/List/components/Cards/CardsRenderItem.js +1 -1
- package/src/components/List/components/Full/FullRenderItem.js +1 -1
- package/src/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
- package/tests/unit/src/components/Banner/BannerRender.test.js +1 -1
- package/tests/unit/src/components/ContentGroup/ContentGroupTabs.test.js +14 -1
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +88 -2
- package/tests/unit/src/components/ContentGroup/helpers/get-active-tab.test.js +19 -0
- package/tests/unit/src/components/ContentGroup/helpers/get-sections-data.test.js +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"YoutubeEmbeded.js","names":["React","useState","useEffect","PropTypes","useInView","IN_VIEW_CONFIG","getPosterUrl","YT_HQ_FORMAT","YT_IMAGE_URL","YoutubeEmbeded","autoplay","videoId","playlistCoverId","videoTitle","poster","videoParams","announce","noCookie","webp","playlist","onIframeAdded","muted","adNetwork","iframeClass","priority","placeholderOnly","imageData","isIntersecting","outerRef","preconnected","setPreconnected","renderIframe","setRenderIframe","imageSize","displayImage","setImageDetails","encodedId","encodeURIComponent","paramsImp","ytUrl","posterUrl","mutedValue","iframeSrc","parsedWrapperClassname","img","Image","onload","newImageSize","width","src","warmConnections","addIframe","backgroundImage","propTypes","bool","func","string","object","defaultProps"],"sources":["../../../../../src/components/Video/providers/YouTube/YoutubeEmbeded.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { IN_VIEW_CONFIG } from '../../../../constants';\nimport { getPosterUrl, YT_HQ_FORMAT, YT_IMAGE_URL } from './helpers';\n\nconst YoutubeEmbeded = ({\n autoplay,\n videoId,\n playlistCoverId,\n videoTitle,\n poster,\n videoParams,\n announce,\n noCookie,\n webp,\n playlist,\n onIframeAdded,\n muted,\n adNetwork,\n iframeClass,\n priority,\n placeholderOnly,\n imageData\n}) => {\n const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);\n const [preconnected, setPreconnected] = useState(false);\n const [renderIframe, setRenderIframe] = useState(!!autoplay);\n const [{ imageSize, displayImage }, setImageDetails] = useState({\n imageSize: poster,\n displayImage: priority\n });\n\n const encodedId = encodeURIComponent(videoId);\n const paramsImp = videoParams ? `&${videoParams}` : '';\n const ytUrl = noCookie ? 'https://www.youtube-nocookie.com' : 'https://www.youtube.com';\n const posterUrl = getPosterUrl({\n imageData,\n playlistCoverId,\n playlist,\n encodedId,\n imageSize,\n webp\n });\n const mutedValue = muted ? '&mute=1' : '';\n const iframeSrc = !playlist\n ? `${ytUrl}/embed/${encodedId}?autoplay=1${mutedValue}${paramsImp}`\n : `${ytUrl}/embed/videoseries?autoplay=1${mutedValue}&list=${encodedId}${paramsImp}`;\n const parsedWrapperClassname = `yt-facade ${renderIframe ? 'yt-activated' : ''}`;\n\n useEffect(\n () => {\n if ((!priority && !isIntersecting) || imageSize === YT_HQ_FORMAT) return;\n\n const img = new Image();\n // eslint-disable-next-line func-names\n img.onload = function() {\n let newImageSize = imageSize;\n if (this && this.width === 120) newImageSize = YT_HQ_FORMAT;\n setImageDetails({ imageSize: newImageSize, displayImage: true });\n };\n\n img.src = posterUrl;\n },\n [imageSize, isIntersecting, posterUrl, priority]\n );\n\n const warmConnections = () => {\n if (preconnected) return;\n setPreconnected(true);\n };\n\n const addIframe = () => {\n if (renderIframe || placeholderOnly) return;\n onIframeAdded();\n setRenderIframe(true);\n };\n\n return (\n <>\n {preconnected && (\n <>\n <link rel=\"preconnect\" href={YT_IMAGE_URL} />\n <link rel=\"preconnect\" href={ytUrl} />\n <link rel=\"preconnect\" href=\"https://www.google.com\" />\n {adNetwork && (\n <>\n <link rel=\"preconnect\" href=\"https://static.doubleclick.net\" />\n <link rel=\"preconnect\" href=\"https://googleads.g.doubleclick.net\" />\n </>\n )}\n </>\n )}\n <div\n ref={outerRef}\n role=\"button\"\n onPointerOver={warmConnections}\n onClick={addIframe}\n className={parsedWrapperClassname}\n data-title={videoTitle}\n style={{\n backgroundImage: `url(${displayImage ? posterUrl : ''})`\n }}>\n <div\n type=\"button\"\n className=\"yt-facade-button-wrapper\"\n aria-label={`${announce} ${videoTitle}`}>\n <div className=\"yt-facade-button\" />\n </div>\n {renderIframe && (\n <iframe\n className={iframeClass}\n title={videoTitle}\n allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\"\n allowFullScreen\n src={iframeSrc}\n />\n )}\n </div>\n </>\n );\n};\n\nYoutubeEmbeded.propTypes = {\n priority: PropTypes.bool,\n onIframeAdded: PropTypes.func,\n adNetwork: PropTypes.bool,\n autoplay: PropTypes.bool,\n playlist: PropTypes.bool,\n muted: PropTypes.bool,\n webp: PropTypes.bool,\n noCookie: PropTypes.bool,\n videoId: PropTypes.string,\n iframeClass: PropTypes.string,\n poster: PropTypes.string,\n announce: PropTypes.string,\n playlistCoverId: PropTypes.string,\n videoParams: PropTypes.string,\n videoTitle: PropTypes.string,\n placeholderOnly: PropTypes.bool,\n imageData: PropTypes.object\n};\n\nYoutubeEmbeded.defaultProps = {\n priority: true,\n onIframeAdded: () => {},\n adNetwork: false,\n autoplay: false,\n playlist: false,\n muted: false,\n webp: false,\n noCookie: false,\n iframeClass: '',\n poster: 'sddefault',\n announce: 'Watch',\n videoId: '',\n playlistCoverId: '',\n videoParams: '',\n videoTitle: '',\n placeholderOnly: false,\n imageData: {}\n};\n\nexport default YoutubeEmbeded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uB,UAAU,GAAGpB,KAAK,GAAG,SAAS,GAAG,EAAE;EACzC,MAAMqB,SAAS,GAAG,CAACvB,QAAQ,GACtB,GAAEoB,KAAM,UAASH,SAAU,cAAaK,UAAW,GAAEH,SAAU,EAAC,GAChE,GAAEC,KAAM,gCAA+BE,UAAW,SAAQL,SAAU,GAAEE,SAAU,EAAC;EACtF,MAAMK,sBAAsB,GAAI,aAAYZ,YAAY,GAAG,cAAc,GAAG,EAAG,EAAC;EAEhF7B,SAAS,CACP,MAAM;IACJ,IAAK,
|
|
1
|
+
{"version":3,"file":"YoutubeEmbeded.js","names":["React","useState","useEffect","PropTypes","useInView","IN_VIEW_CONFIG","getPosterUrl","YT_HQ_FORMAT","YT_IMAGE_URL","YoutubeEmbeded","autoplay","videoId","playlistCoverId","videoTitle","poster","videoParams","announce","noCookie","webp","playlist","onIframeAdded","muted","adNetwork","iframeClass","priority","placeholderOnly","imageData","isIntersecting","outerRef","preconnected","setPreconnected","renderIframe","setRenderIframe","imageSize","displayImage","setImageDetails","encodedId","encodeURIComponent","paramsImp","ytUrl","posterUrl","mutedValue","iframeSrc","parsedWrapperClassname","isMounted","img","Image","onload","newImageSize","width","src","warmConnections","addIframe","backgroundImage","propTypes","bool","func","string","object","defaultProps"],"sources":["../../../../../src/components/Video/providers/YouTube/YoutubeEmbeded.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { IN_VIEW_CONFIG } from '../../../../constants';\nimport { getPosterUrl, YT_HQ_FORMAT, YT_IMAGE_URL } from './helpers';\n\nconst YoutubeEmbeded = ({\n autoplay,\n videoId,\n playlistCoverId,\n videoTitle,\n poster,\n videoParams,\n announce,\n noCookie,\n webp,\n playlist,\n onIframeAdded,\n muted,\n adNetwork,\n iframeClass,\n priority,\n placeholderOnly,\n imageData\n}) => {\n const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);\n const [preconnected, setPreconnected] = useState(false);\n const [renderIframe, setRenderIframe] = useState(!!autoplay);\n const [{ imageSize, displayImage }, setImageDetails] = useState({\n imageSize: poster,\n displayImage: priority\n });\n\n const encodedId = encodeURIComponent(videoId);\n const paramsImp = videoParams ? `&${videoParams}` : '';\n const ytUrl = noCookie ? 'https://www.youtube-nocookie.com' : 'https://www.youtube.com';\n const posterUrl = getPosterUrl({\n imageData,\n playlistCoverId,\n playlist,\n encodedId,\n imageSize,\n webp\n });\n const mutedValue = muted ? '&mute=1' : '';\n const iframeSrc = !playlist\n ? `${ytUrl}/embed/${encodedId}?autoplay=1${mutedValue}${paramsImp}`\n : `${ytUrl}/embed/videoseries?autoplay=1${mutedValue}&list=${encodedId}${paramsImp}`;\n const parsedWrapperClassname = `yt-facade ${renderIframe ? 'yt-activated' : ''}`;\n\n useEffect(\n () => {\n let isMounted = true;\n if ((!priority && !isIntersecting) || imageSize === YT_HQ_FORMAT) return;\n\n const img = new Image();\n // eslint-disable-next-line func-names\n img.onload = function() {\n let newImageSize = imageSize;\n if (this && this.width === 120) newImageSize = YT_HQ_FORMAT;\n if (isMounted) setImageDetails({ imageSize: newImageSize, displayImage: true });\n };\n\n img.src = posterUrl;\n return () => {\n isMounted = false;\n };\n },\n [imageSize, isIntersecting, posterUrl, priority]\n );\n\n const warmConnections = () => {\n if (preconnected) return;\n setPreconnected(true);\n };\n\n const addIframe = () => {\n if (renderIframe || placeholderOnly) return;\n onIframeAdded();\n setRenderIframe(true);\n };\n\n return (\n <>\n {preconnected && (\n <>\n <link rel=\"preconnect\" href={YT_IMAGE_URL} />\n <link rel=\"preconnect\" href={ytUrl} />\n <link rel=\"preconnect\" href=\"https://www.google.com\" />\n {adNetwork && (\n <>\n <link rel=\"preconnect\" href=\"https://static.doubleclick.net\" />\n <link rel=\"preconnect\" href=\"https://googleads.g.doubleclick.net\" />\n </>\n )}\n </>\n )}\n <div\n ref={outerRef}\n role=\"button\"\n onPointerOver={warmConnections}\n onClick={addIframe}\n className={parsedWrapperClassname}\n data-title={videoTitle}\n style={{\n backgroundImage: `url(${displayImage ? posterUrl : ''})`\n }}>\n <div\n type=\"button\"\n className=\"yt-facade-button-wrapper\"\n aria-label={`${announce} ${videoTitle}`}>\n <div className=\"yt-facade-button\" />\n </div>\n {renderIframe && (\n <iframe\n className={iframeClass}\n title={videoTitle}\n allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\"\n allowFullScreen\n src={iframeSrc}\n />\n )}\n </div>\n </>\n );\n};\n\nYoutubeEmbeded.propTypes = {\n priority: PropTypes.bool,\n onIframeAdded: PropTypes.func,\n adNetwork: PropTypes.bool,\n autoplay: PropTypes.bool,\n playlist: PropTypes.bool,\n muted: PropTypes.bool,\n webp: PropTypes.bool,\n noCookie: PropTypes.bool,\n videoId: PropTypes.string,\n iframeClass: PropTypes.string,\n poster: PropTypes.string,\n announce: PropTypes.string,\n playlistCoverId: PropTypes.string,\n videoParams: PropTypes.string,\n videoTitle: PropTypes.string,\n placeholderOnly: PropTypes.bool,\n imageData: PropTypes.object\n};\n\nYoutubeEmbeded.defaultProps = {\n priority: true,\n onIframeAdded: () => {},\n adNetwork: false,\n autoplay: false,\n playlist: false,\n muted: false,\n webp: false,\n noCookie: false,\n iframeClass: '',\n poster: 'sddefault',\n announce: 'Watch',\n videoId: '',\n playlistCoverId: '',\n videoParams: '',\n videoTitle: '',\n placeholderOnly: false,\n imageData: {}\n};\n\nexport default YoutubeEmbeded;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,oCAAoC;AAC9D,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,YAAY,EAAEC,YAAY,EAAEC,YAAY,QAAQ,WAAW;AAEpE,MAAMC,cAAc,GAAG,CAAC;EACtBC,QAAQ;EACRC,OAAO;EACPC,eAAe;EACfC,UAAU;EACVC,MAAM;EACNC,WAAW;EAC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EvB,SAAS,CAACuD;AACvB,CAAC;AAEDjD,cAAc,CAACkD,YAAY,GAAG;EAC5BnC,QAAQ,EAAE,IAAI;EACdJ,aAAa,EAAE,MAAM,CAAC,CAAC;EACvBE,SAAS,EAAE,KAAK;EAChBZ,QAAQ,EAAE,KAAK;EACfS,QAAQ,EAAE,KAAK;EACfE,KAAK,EAAE,KAAK;EACZH,IAAI,EAAE,KAAK;EACXD,QAAQ,EAAE,KAAK;EACfM,WAAW,EAAE,EAAE;EACfT,MAAM,EAAE,WAAW;EACnBE,QAAQ,EAAE,OAAO;EACjBL,OAAO,EAAE,EAAE;EACXC,eAAe,EAAE,EAAE;EACnBG,WAAW,EAAE,EAAE;EACfF,UAAU,EAAE,EAAE;EACdY,eAAe,EAAE,KAAK;EACtBC,SAAS,EAAE,CAAC;AACd,CAAC;AAED,eAAejB,cAAc"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.126.0
|
|
3
|
+
"version": "0.126.0",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@blaze-react/utils": "0.5.15",
|
|
46
46
|
"core-js": "^3.2.1",
|
|
47
47
|
"entities": "^2.0.0",
|
|
48
|
-
"html-react-parser": "^
|
|
48
|
+
"html-react-parser": "^0.10.0",
|
|
49
49
|
"lodash.at": "^4.6.0",
|
|
50
50
|
"lodash.camelcase": "^4.3.0",
|
|
51
51
|
"lodash.clonedeep": "^4.5.0",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"lib/*",
|
|
88
88
|
"lib-es/*"
|
|
89
89
|
],
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "3426eb3c15ca8bf9c601ebfccff00ad695b9a83a"
|
|
91
91
|
}
|
|
@@ -32,7 +32,7 @@ const BannerRender = ({
|
|
|
32
32
|
asPath,
|
|
33
33
|
action,
|
|
34
34
|
actionKey,
|
|
35
|
-
|
|
35
|
+
cardBannerIndex,
|
|
36
36
|
userPropsData,
|
|
37
37
|
...otherProps
|
|
38
38
|
}) => {
|
|
@@ -79,7 +79,7 @@ const BannerRender = ({
|
|
|
79
79
|
const shouldShowBanner =
|
|
80
80
|
parsedAdunit && parsedSizes && !!parsedSizes.length && isContextualTargetingReady;
|
|
81
81
|
|
|
82
|
-
const customTargetings = setCustomTargetings(targetings,
|
|
82
|
+
const customTargetings = setCustomTargetings(targetings, cardBannerIndex);
|
|
83
83
|
|
|
84
84
|
const targetingArguments = { ...parsedTargetings, ...customTargetings, ...userPropsData };
|
|
85
85
|
|
|
@@ -107,7 +107,7 @@ BannerRender.propTypes = {
|
|
|
107
107
|
entity: PropTypes.string,
|
|
108
108
|
targetings: PropTypes.string,
|
|
109
109
|
sizes: PropTypes.string,
|
|
110
|
-
|
|
110
|
+
cardBannerIndex: PropTypes.number,
|
|
111
111
|
userPropsData: PropTypes.object
|
|
112
112
|
};
|
|
113
113
|
|
|
@@ -119,7 +119,7 @@ BannerRender.defaultProps = {
|
|
|
119
119
|
entity: '',
|
|
120
120
|
targetings: '',
|
|
121
121
|
sizes: '',
|
|
122
|
-
|
|
122
|
+
cardBannerIndex: null,
|
|
123
123
|
userPropsData: {}
|
|
124
124
|
};
|
|
125
125
|
|
|
@@ -20,11 +20,11 @@ const buildTargetingValue = valueTargeting =>
|
|
|
20
20
|
? valueTargeting.replace(/\;|\[|\]/gm, char => (char === ';' ? ',' : '')).split(',')
|
|
21
21
|
: valueTargeting;
|
|
22
22
|
|
|
23
|
-
const setCustomTargetings = (targetings,
|
|
23
|
+
const setCustomTargetings = (targetings, cardBannerIndex) => {
|
|
24
24
|
let bannerTargetings = {};
|
|
25
25
|
|
|
26
|
-
const updatedTargetings =
|
|
27
|
-
? addPosnToTargetings(targetings,
|
|
26
|
+
const updatedTargetings = cardBannerIndex
|
|
27
|
+
? addPosnToTargetings(targetings, cardBannerIndex)
|
|
28
28
|
: targetings;
|
|
29
29
|
|
|
30
30
|
const isValidTargeting = updatedTargetings && typeof updatedTargetings === 'string';
|
|
@@ -41,7 +41,7 @@ const CardContainer = ({
|
|
|
41
41
|
const dynamicWrapperSizes = enableCarousel
|
|
42
42
|
? ''
|
|
43
43
|
: getDynamicGridClasses('grid', itemsPerRow, designConfig);
|
|
44
|
-
let
|
|
44
|
+
let cardBannerIndex = 0;
|
|
45
45
|
const CardWrapper = enableCarousel ? CarouselWrapper : Wrapper;
|
|
46
46
|
|
|
47
47
|
return (
|
|
@@ -55,7 +55,7 @@ const CardContainer = ({
|
|
|
55
55
|
{entities.map(({ baseAdunit, id, ...entityProps }, index) => {
|
|
56
56
|
const extraProps = parsePropsToDisplay(entityProps, propsToDisplay);
|
|
57
57
|
const dynamicKey = [itemId, index].join('-');
|
|
58
|
-
if (baseAdunit)
|
|
58
|
+
if (baseAdunit) cardBannerIndex += 1;
|
|
59
59
|
|
|
60
60
|
const priority = priorityLimit > 0 && index + 1 <= priorityLimit;
|
|
61
61
|
|
|
@@ -66,7 +66,7 @@ const CardContainer = ({
|
|
|
66
66
|
baseAdunit={baseAdunit}
|
|
67
67
|
{...entityProps}
|
|
68
68
|
modifier={modifier}
|
|
69
|
-
|
|
69
|
+
cardBannerIndex={cardBannerIndex}
|
|
70
70
|
/>
|
|
71
71
|
) : (
|
|
72
72
|
<Card
|
|
@@ -7,10 +7,10 @@ import { getClassModifiers } from '../../utils';
|
|
|
7
7
|
import { CODE } from '../../constants';
|
|
8
8
|
import { wrapScriptTags } from './helpers';
|
|
9
9
|
|
|
10
|
-
const Code = memo(({ code: embedCode,
|
|
10
|
+
const Code = memo(({ code: embedCode, ...otherProps }) => {
|
|
11
11
|
if (!embedCode) return null;
|
|
12
12
|
|
|
13
|
-
const parsedCode = parseHTML(embedCode
|
|
13
|
+
const parsedCode = parseHTML(embedCode);
|
|
14
14
|
const wrappedCode = wrapScriptTags(parsedCode);
|
|
15
15
|
const modifiers = getClassModifiers(CODE, { ...otherProps });
|
|
16
16
|
|
|
@@ -19,14 +19,12 @@ const Code = memo(({ code: embedCode, parserOptions, ...otherProps }) => {
|
|
|
19
19
|
|
|
20
20
|
Code.propTypes = {
|
|
21
21
|
code: PropTypes.string,
|
|
22
|
-
modifier: PropTypes.string
|
|
23
|
-
parserOptions: PropTypes.object
|
|
22
|
+
modifier: PropTypes.string
|
|
24
23
|
};
|
|
25
24
|
|
|
26
25
|
Code.defaultProps = {
|
|
27
26
|
code: '',
|
|
28
|
-
modifier: ''
|
|
29
|
-
parserOptions: {}
|
|
27
|
+
modifier: ''
|
|
30
28
|
};
|
|
31
29
|
|
|
32
30
|
export default withTitle(Code);
|
|
@@ -17,13 +17,9 @@ function getWrappedScriptTag(child) {
|
|
|
17
17
|
function wrapScriptTags(parsedCode) {
|
|
18
18
|
if (Array.isArray(parsedCode)) {
|
|
19
19
|
parsedCode.forEach((child, index) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
parsedCode[index] = getWrappedScriptTag(child);
|
|
24
|
-
} catch {
|
|
25
|
-
// catch read-only element errors
|
|
26
|
-
}
|
|
20
|
+
// modify children array as we just want to wrap single components
|
|
21
|
+
// eslint-disable-next-line no-param-reassign
|
|
22
|
+
parsedCode[index] = getWrappedScriptTag(child);
|
|
27
23
|
});
|
|
28
24
|
|
|
29
25
|
return parsedCode;
|
|
@@ -1,14 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import ContentGroupTabs from './ContentGroupTabs';
|
|
4
|
+
import { getSectionsData } from './helpers';
|
|
4
5
|
|
|
5
|
-
const ContentGroup = ({ contentType, ...props }) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return '';
|
|
6
|
+
const ContentGroup = ({ contentType, children, ...props }) => {
|
|
7
|
+
const groupSections = children?.props?.children[1];
|
|
8
|
+
if (!groupSections || !groupSections.length) return '';
|
|
9
|
+
if (contentType !== 'tab' && contentType !== 'sidepanel') return '';
|
|
10
|
+
const sectionsData = getSectionsData(groupSections);
|
|
11
|
+
|
|
12
|
+
return (
|
|
13
|
+
<ContentGroupTabs
|
|
14
|
+
contentType={contentType}
|
|
15
|
+
groupSections={groupSections}
|
|
16
|
+
sectionsData={sectionsData}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
9
20
|
};
|
|
10
21
|
|
|
11
22
|
ContentGroup.propTypes = {
|
|
23
|
+
children: PropTypes.object.isRequired,
|
|
12
24
|
contentType: PropTypes.string.isRequired
|
|
13
25
|
};
|
|
14
26
|
|
|
@@ -1,28 +1,37 @@
|
|
|
1
|
-
import React, { useState } from 'react';
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { getActiveTab } from './helpers';
|
|
5
|
+
import { TAB, TABS, SIDEPANEL, CONTENT_GROUP, PANEL } from './constants';
|
|
3
6
|
|
|
4
|
-
const ContentGroupTabs = ({ name, contentType, modifier,
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
7
|
+
const ContentGroupTabs = ({ name, contentType, modifier, groupSections, sectionsData }) => {
|
|
8
|
+
const router = useRouter();
|
|
9
|
+
const [selectedTab, setSelectedTab] = useState(getActiveTab(sectionsData, ''));
|
|
10
|
+
const { asPath } = router;
|
|
11
|
+
const contentClassame = contentType === TAB ? TABS : SIDEPANEL;
|
|
12
|
+
const mainDivClass = `${CONTENT_GROUP}-${contentClassame}`;
|
|
13
|
+
const contentGroupClass = `${CONTENT_GROUP}-${contentClassame}__buttons-wrapper`;
|
|
14
|
+
const sectionClass = `${CONTENT_GROUP}-${contentClassame}__content-section`;
|
|
15
|
+
|
|
16
|
+
useEffect(
|
|
17
|
+
() => {
|
|
18
|
+
const activeTab = getActiveTab(sectionsData, asPath);
|
|
19
|
+
if (activeTab !== selectedTab) setSelectedTab(activeTab);
|
|
20
|
+
},
|
|
21
|
+
[asPath, sectionsData, selectedTab]
|
|
22
|
+
);
|
|
9
23
|
|
|
10
24
|
return (
|
|
11
|
-
<div className={
|
|
12
|
-
<ul
|
|
13
|
-
className={`content-group${contentClassame}__buttons-wrapper`}
|
|
14
|
-
role="tablist"
|
|
15
|
-
aria-label={name}>
|
|
25
|
+
<div className={mainDivClass}>
|
|
26
|
+
<ul className={contentGroupClass} role="tablist" aria-label={name}>
|
|
16
27
|
{groupSections.map((groupSection, index) => {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const tabId = `tab-${index}`;
|
|
21
|
-
const panelId = `panel-${index}`;
|
|
28
|
+
const [sectionName, sectioLabel] = sectionsData[index];
|
|
29
|
+
const tabId = `${TAB}-${sectionName}`;
|
|
30
|
+
const panelId = `${PANEL}-${sectionName}`;
|
|
22
31
|
const isSelected = selectedTab === tabId;
|
|
23
|
-
const buttonClassName =
|
|
24
|
-
?
|
|
25
|
-
|
|
32
|
+
const buttonClassName = `${CONTENT_GROUP}-${contentClassame}__button${
|
|
33
|
+
isSelected ? '--is-active' : ''
|
|
34
|
+
}`;
|
|
26
35
|
|
|
27
36
|
return (
|
|
28
37
|
<button
|
|
@@ -33,22 +42,29 @@ const ContentGroupTabs = ({ name, contentType, modifier, children, ...props }) =
|
|
|
33
42
|
role="tab"
|
|
34
43
|
aria-selected={isSelected}
|
|
35
44
|
aria-controls={panelId}
|
|
36
|
-
onClick={() =>
|
|
37
|
-
|
|
45
|
+
onClick={() => {
|
|
46
|
+
const baseUrl = asPath.split('#')[0];
|
|
47
|
+
const newUrl = `${baseUrl}#${sectionName}`;
|
|
48
|
+
if (asPath === newUrl) return;
|
|
49
|
+
router.push(`/Resolver`, newUrl, { shallow: true });
|
|
50
|
+
setSelectedTab(tabId);
|
|
51
|
+
}}>
|
|
52
|
+
{sectioLabel}
|
|
38
53
|
</button>
|
|
39
54
|
);
|
|
40
55
|
})}
|
|
41
56
|
</ul>
|
|
42
57
|
{groupSections.map((groupSection, index) => {
|
|
43
|
-
const
|
|
44
|
-
const
|
|
58
|
+
const [sectionName] = sectionsData[index];
|
|
59
|
+
const tabId = `${TAB}-${sectionName}`;
|
|
60
|
+
const panelId = `${PANEL}-${sectionName}`;
|
|
45
61
|
if (selectedTab !== tabId) return null;
|
|
46
62
|
|
|
47
63
|
return (
|
|
48
64
|
<div
|
|
49
|
-
id={
|
|
65
|
+
id={sectionName}
|
|
50
66
|
key={panelId}
|
|
51
|
-
className={
|
|
67
|
+
className={sectionClass}
|
|
52
68
|
role="tabpanel"
|
|
53
69
|
aria-labelledby={tabId}>
|
|
54
70
|
{groupSection}
|
|
@@ -63,12 +79,12 @@ ContentGroupTabs.propTypes = {
|
|
|
63
79
|
name: PropTypes.string.isRequired,
|
|
64
80
|
contentType: PropTypes.string.isRequired,
|
|
65
81
|
modifier: PropTypes.string,
|
|
66
|
-
|
|
82
|
+
groupSections: PropTypes.array.isRequired,
|
|
83
|
+
sectionsData: PropTypes.array.isRequired
|
|
67
84
|
};
|
|
68
85
|
|
|
69
86
|
ContentGroupTabs.defaultProps = {
|
|
70
|
-
modifier: ''
|
|
71
|
-
children: {}
|
|
87
|
+
modifier: ''
|
|
72
88
|
};
|
|
73
89
|
|
|
74
90
|
export default ContentGroupTabs;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TAB } from '../constants';
|
|
2
|
+
|
|
3
|
+
const getActiveTab = (sections, url) => {
|
|
4
|
+
const decodedUrl = decodeURI(url);
|
|
5
|
+
const activeTabName = decodedUrl.split('#')[1];
|
|
6
|
+
const isUrlTabValid = !!sections.find(section => section[0] === activeTabName);
|
|
7
|
+
const tabToUse = (isUrlTabValid && activeTabName) || sections[0][0];
|
|
8
|
+
return `${TAB}-${tabToUse}`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export default getActiveTab;
|
|
@@ -2,10 +2,14 @@ import React from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { hasChildren } from '../../helpers';
|
|
4
4
|
|
|
5
|
-
const ContentGroupSection = ({ children, ...props }) => {
|
|
5
|
+
const ContentGroupSection = ({ children, name, ...props }) => {
|
|
6
6
|
if (!hasChildren(children)) return null;
|
|
7
7
|
|
|
8
|
-
return
|
|
8
|
+
return (
|
|
9
|
+
<div key={name} className="content-group-section">
|
|
10
|
+
{children}
|
|
11
|
+
</div>
|
|
12
|
+
);
|
|
9
13
|
};
|
|
10
14
|
|
|
11
15
|
ContentGroupSection.propTypes = {
|
|
@@ -50,7 +50,7 @@ const FullRenderItem = ({
|
|
|
50
50
|
{!!parsedPropsToDisplay.length && (
|
|
51
51
|
<>{parsedPropsToDisplay.map(prop => (prop ? <span key={prop}>{prop}</span> : null))}</>
|
|
52
52
|
)}
|
|
53
|
-
{shouldRenderBanner && <Banner {...bannerProps}
|
|
53
|
+
{shouldRenderBanner && <Banner {...bannerProps} cardBannerIndex={bannerIndex} />}
|
|
54
54
|
</>
|
|
55
55
|
);
|
|
56
56
|
};
|
|
@@ -50,6 +50,7 @@ const YoutubeEmbeded = ({
|
|
|
50
50
|
|
|
51
51
|
useEffect(
|
|
52
52
|
() => {
|
|
53
|
+
let isMounted = true;
|
|
53
54
|
if ((!priority && !isIntersecting) || imageSize === YT_HQ_FORMAT) return;
|
|
54
55
|
|
|
55
56
|
const img = new Image();
|
|
@@ -57,10 +58,13 @@ const YoutubeEmbeded = ({
|
|
|
57
58
|
img.onload = function() {
|
|
58
59
|
let newImageSize = imageSize;
|
|
59
60
|
if (this && this.width === 120) newImageSize = YT_HQ_FORMAT;
|
|
60
|
-
setImageDetails({ imageSize: newImageSize, displayImage: true });
|
|
61
|
+
if (isMounted) setImageDetails({ imageSize: newImageSize, displayImage: true });
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
img.src = posterUrl;
|
|
65
|
+
return () => {
|
|
66
|
+
isMounted = false;
|
|
67
|
+
};
|
|
64
68
|
},
|
|
65
69
|
[imageSize, isIntersecting, posterUrl, priority]
|
|
66
70
|
);
|
|
@@ -1,14 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
2
3
|
import ContentGroupTabs from '../../../../../src/components/ContentGroup/ContentGroupTabs';
|
|
3
4
|
|
|
5
|
+
jest.mock('next/router', () => ({
|
|
6
|
+
useRouter: jest.fn(() => ({ asPath: 'tabs-url' }))
|
|
7
|
+
}));
|
|
8
|
+
|
|
9
|
+
const mockedProps = {
|
|
10
|
+
name: 'testTabs',
|
|
11
|
+
contentType: 'tab',
|
|
12
|
+
groupSections: [<div>section one</div>, <div>section two</div>],
|
|
13
|
+
sectionsData: [['section-one', 'sectionOne'], ['section-two', 'sectionTwo']]
|
|
14
|
+
};
|
|
15
|
+
|
|
4
16
|
describe('ContentGroupTabs component', () => {
|
|
5
17
|
it('should match snapshot and render tabs content', () => {
|
|
6
|
-
const { asFragment: tabContentGroup } = render(ContentGroupTabs,
|
|
18
|
+
const { asFragment: tabContentGroup } = render(ContentGroupTabs, mockedProps);
|
|
7
19
|
expect(tabContentGroup()).toMatchSnapshot();
|
|
8
20
|
});
|
|
9
21
|
|
|
10
22
|
it('should match snapshot and render sidepanel content', () => {
|
|
11
23
|
const { asFragment: sidepanelContentGroup } = render(ContentGroupTabs, {
|
|
24
|
+
...mockedProps,
|
|
12
25
|
contentType: 'sidepanel'
|
|
13
26
|
});
|
|
14
27
|
expect(sidepanelContentGroup()).toMatchSnapshot();
|
|
@@ -1,5 +1,91 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`ContentGroupTabs component should match snapshot and render sidepanel content 1`] =
|
|
3
|
+
exports[`ContentGroupTabs component should match snapshot and render sidepanel content 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="content-group-sidepanel"
|
|
7
|
+
>
|
|
8
|
+
<ul
|
|
9
|
+
aria-label="testTabs"
|
|
10
|
+
class="content-group-sidepanel__buttons-wrapper"
|
|
11
|
+
role="tablist"
|
|
12
|
+
>
|
|
13
|
+
<button
|
|
14
|
+
aria-controls="panel-section-one"
|
|
15
|
+
aria-selected="true"
|
|
16
|
+
class="content-group-sidepanel__button--is-active"
|
|
17
|
+
id="tab-section-one"
|
|
18
|
+
role="tab"
|
|
19
|
+
type="button"
|
|
20
|
+
>
|
|
21
|
+
sectionOne
|
|
22
|
+
</button>
|
|
23
|
+
<button
|
|
24
|
+
aria-controls="panel-section-two"
|
|
25
|
+
aria-selected="false"
|
|
26
|
+
class="content-group-sidepanel__button"
|
|
27
|
+
id="tab-section-two"
|
|
28
|
+
role="tab"
|
|
29
|
+
type="button"
|
|
30
|
+
>
|
|
31
|
+
sectionTwo
|
|
32
|
+
</button>
|
|
33
|
+
</ul>
|
|
34
|
+
<div
|
|
35
|
+
aria-labelledby="tab-section-one"
|
|
36
|
+
class="content-group-sidepanel__content-section"
|
|
37
|
+
id="section-one"
|
|
38
|
+
role="tabpanel"
|
|
39
|
+
>
|
|
40
|
+
<div>
|
|
41
|
+
section one
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</DocumentFragment>
|
|
46
|
+
`;
|
|
4
47
|
|
|
5
|
-
exports[`ContentGroupTabs component should match snapshot and render tabs content 1`] =
|
|
48
|
+
exports[`ContentGroupTabs component should match snapshot and render tabs content 1`] = `
|
|
49
|
+
<DocumentFragment>
|
|
50
|
+
<div
|
|
51
|
+
class="content-group-tabs"
|
|
52
|
+
>
|
|
53
|
+
<ul
|
|
54
|
+
aria-label="testTabs"
|
|
55
|
+
class="content-group-tabs__buttons-wrapper"
|
|
56
|
+
role="tablist"
|
|
57
|
+
>
|
|
58
|
+
<button
|
|
59
|
+
aria-controls="panel-section-one"
|
|
60
|
+
aria-selected="true"
|
|
61
|
+
class="content-group-tabs__button--is-active"
|
|
62
|
+
id="tab-section-one"
|
|
63
|
+
role="tab"
|
|
64
|
+
type="button"
|
|
65
|
+
>
|
|
66
|
+
sectionOne
|
|
67
|
+
</button>
|
|
68
|
+
<button
|
|
69
|
+
aria-controls="panel-section-two"
|
|
70
|
+
aria-selected="false"
|
|
71
|
+
class="content-group-tabs__button"
|
|
72
|
+
id="tab-section-two"
|
|
73
|
+
role="tab"
|
|
74
|
+
type="button"
|
|
75
|
+
>
|
|
76
|
+
sectionTwo
|
|
77
|
+
</button>
|
|
78
|
+
</ul>
|
|
79
|
+
<div
|
|
80
|
+
aria-labelledby="tab-section-one"
|
|
81
|
+
class="content-group-tabs__content-section"
|
|
82
|
+
id="section-one"
|
|
83
|
+
role="tabpanel"
|
|
84
|
+
>
|
|
85
|
+
<div>
|
|
86
|
+
section one
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</DocumentFragment>
|
|
91
|
+
`;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import getActiveTab from '../../../../../../src/components/ContentGroup/helpers/get-active-tab';
|
|
2
|
+
|
|
3
|
+
const mockedSectionsData = [['sectionname', 'section label'], ['sectionname2', 'anothersection']];
|
|
4
|
+
|
|
5
|
+
describe('getActiveTab helper', () => {
|
|
6
|
+
it('should return url hash if present and it matches one of the tabs', () => {
|
|
7
|
+
const match = getActiveTab(mockedSectionsData, 'www.someurl.com/page1#sectionname2');
|
|
8
|
+
|
|
9
|
+
expect(match).toEqual('tab-sectionname2');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('should return first tab otherwise', () => {
|
|
13
|
+
const noMatch = getActiveTab(mockedSectionsData, 'www.someurl.com/page1#sectionnamewithnomath');
|
|
14
|
+
const noHash = getActiveTab(mockedSectionsData, 'www.someurl.com/page1');
|
|
15
|
+
|
|
16
|
+
expect(noMatch).toEqual('tab-sectionname');
|
|
17
|
+
expect(noHash).toEqual('tab-sectionname');
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import getSectionsData from '../../../../../../src/components/ContentGroup/helpers/get-sections-data';
|
|
2
|
+
|
|
3
|
+
const mockedSections = [
|
|
4
|
+
{ props: { component: { settings: { label: 'labelonne', name: 'nameone' } } } },
|
|
5
|
+
{ props: { component: { settings: { label: 'labelTwo', name: 'nameTwo' } } } }
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
describe('getSectionsData helper', () => {
|
|
9
|
+
it('should return section name and label', () => {
|
|
10
|
+
const match = getSectionsData(mockedSections);
|
|
11
|
+
|
|
12
|
+
expect(match).toEqual([['nameone', 'labelonne'], ['nameTwo', 'labelTwo']]);
|
|
13
|
+
});
|
|
14
|
+
});
|