@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.
Files changed (83) hide show
  1. package/CHANGELOG.md +7 -10
  2. package/README.md +0 -4
  3. package/lib/components/Banner/BannerRender.js +5 -5
  4. package/lib/components/Banner/BannerRender.js.map +1 -1
  5. package/lib/components/Banner/helpers.js +2 -2
  6. package/lib/components/Banner/helpers.js.map +1 -1
  7. package/lib/components/Card/CardContainer.js +3 -3
  8. package/lib/components/Card/CardContainer.js.map +1 -1
  9. package/lib/components/Code/Code.js +4 -7
  10. package/lib/components/Code/Code.js.map +1 -1
  11. package/lib/components/Code/helpers/wrap-script-tags.js +3 -7
  12. package/lib/components/Code/helpers/wrap-script-tags.js.map +1 -1
  13. package/lib/components/ContentGroup/ContentGroup.js +13 -4
  14. package/lib/components/ContentGroup/ContentGroup.js.map +1 -1
  15. package/lib/components/ContentGroup/ContentGroupTabs.js +43 -31
  16. package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  17. package/lib/components/ContentGroup/constants.js +18 -0
  18. package/lib/components/ContentGroup/constants.js.map +1 -0
  19. package/lib/components/ContentGroup/helpers/get-active-tab.js +23 -0
  20. package/lib/components/ContentGroup/helpers/get-active-tab.js.map +1 -0
  21. package/lib/components/ContentGroup/helpers/get-sections-data.js +25 -0
  22. package/lib/components/ContentGroup/helpers/get-sections-data.js.map +1 -0
  23. package/lib/components/ContentGroup/helpers/index.js +22 -0
  24. package/lib/components/ContentGroup/helpers/index.js.map +1 -0
  25. package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
  26. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  27. package/lib/components/List/components/Cards/CardsRenderItem.js +1 -1
  28. package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  29. package/lib/components/List/components/Full/FullRenderItem.js +1 -1
  30. package/lib/components/List/components/Full/FullRenderItem.js.map +1 -1
  31. package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
  32. package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
  33. package/lib-es/components/Banner/BannerRender.js +5 -5
  34. package/lib-es/components/Banner/BannerRender.js.map +1 -1
  35. package/lib-es/components/Banner/helpers.js +2 -2
  36. package/lib-es/components/Banner/helpers.js.map +1 -1
  37. package/lib-es/components/Card/CardContainer.js +3 -3
  38. package/lib-es/components/Card/CardContainer.js.map +1 -1
  39. package/lib-es/components/Code/Code.js +5 -8
  40. package/lib-es/components/Code/Code.js.map +1 -1
  41. package/lib-es/components/Code/helpers/wrap-script-tags.js +3 -7
  42. package/lib-es/components/Code/helpers/wrap-script-tags.js.map +1 -1
  43. package/lib-es/components/ContentGroup/ContentGroup.js +14 -5
  44. package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -1
  45. package/lib-es/components/ContentGroup/ContentGroupTabs.js +48 -39
  46. package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  47. package/lib-es/components/ContentGroup/constants.js +7 -0
  48. package/lib-es/components/ContentGroup/constants.js.map +1 -0
  49. package/lib-es/components/ContentGroup/helpers/get-active-tab.js +10 -0
  50. package/lib-es/components/ContentGroup/helpers/get-active-tab.js.map +1 -0
  51. package/lib-es/components/ContentGroup/helpers/get-sections-data.js +15 -0
  52. package/lib-es/components/ContentGroup/helpers/get-sections-data.js.map +1 -0
  53. package/lib-es/components/ContentGroup/helpers/index.js +4 -0
  54. package/lib-es/components/ContentGroup/helpers/index.js.map +1 -0
  55. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +4 -2
  56. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  57. package/lib-es/components/List/components/Cards/CardsRenderItem.js +1 -1
  58. package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  59. package/lib-es/components/List/components/Full/FullRenderItem.js +1 -1
  60. package/lib-es/components/List/components/Full/FullRenderItem.js.map +1 -1
  61. package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
  62. package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
  63. package/package.json +3 -3
  64. package/src/components/Banner/BannerRender.js +4 -4
  65. package/src/components/Banner/helpers.js +3 -3
  66. package/src/components/Card/CardContainer.js +3 -3
  67. package/src/components/Code/Code.js +4 -6
  68. package/src/components/Code/helpers/wrap-script-tags.js +3 -7
  69. package/src/components/ContentGroup/ContentGroup.js +16 -4
  70. package/src/components/ContentGroup/ContentGroupTabs.js +44 -28
  71. package/src/components/ContentGroup/constants.js +7 -0
  72. package/src/components/ContentGroup/helpers/get-active-tab.js +11 -0
  73. package/src/components/ContentGroup/helpers/get-sections-data.js +7 -0
  74. package/src/components/ContentGroup/helpers/index.js +4 -0
  75. package/src/components/ContentGroupSection/ContentGroupSection.js +6 -2
  76. package/src/components/List/components/Cards/CardsRenderItem.js +1 -1
  77. package/src/components/List/components/Full/FullRenderItem.js +1 -1
  78. package/src/components/Video/providers/YouTube/YoutubeEmbeded.js +5 -1
  79. package/tests/unit/src/components/Banner/BannerRender.test.js +1 -1
  80. package/tests/unit/src/components/ContentGroup/ContentGroupTabs.test.js +14 -1
  81. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +88 -2
  82. package/tests/unit/src/components/ContentGroup/helpers/get-active-tab.test.js +19 -0
  83. 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;\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;EACXC,QAAQ;EACRC,QAAQ;EACRC,IAAI;EACJC,QAAQ;EACRC,aAAa;EACbC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,QAAQ;EACRC,eAAe;EACfC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,cAAc,EAAEC,QAAQ,CAAC,GAAGxB,SAAS,CAACC,cAAc,CAAC;EAC5D,MAAM,CAACwB,YAAY,EAAEC,eAAe,CAAC,GAAG7B,QAAQ,CAAC,KAAK,CAAC;EACvD,MAAM,CAAC8B,YAAY,EAAEC,eAAe,CAAC,GAAG/B,QAAQ,CAAC,CAAC,CAACS,QAAQ,CAAC;EAC5D,MAAM,CAAC;IAAEuB,SAAS;IAAEC;EAAa,CAAC,EAAEC,eAAe,CAAC,GAAGlC,QAAQ,CAAC;IAC9DgC,SAAS,EAAEnB,MAAM;IACjBoB,YAAY,EAAEV;EAChB,CAAC,CAAC;EAEF,MAAMY,SAAS,GAAGC,kBAAkB,CAAC1B,OAAO,CAAC;EAC7C,MAAM2B,SAAS,GAAGvB,WAAW,GAAI,IAAGA,WAAY,EAAC,GAAG,EAAE;EACtD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EACrBpC,IAAI,EAAEf,SAAS,CAACmD,IAAI;EACpBrC,QAAQ,EAAEd,SAAS,CAACmD,IAAI;EACxB3C,OAAO,EAAER,SAAS,CAACqD,MAAM;EACzBjC,WAAW,EAAEpB,SAAS,CAACqD,MAAM;EAC7B1C,MAAM,EAAEX,SAAS,CAACqD,MAAM;EACxBxC,QAAQ,EAAEb,SAAS,CAACqD,MAAM;EAC1B5C,eAAe,EAAET,SAAS,CAACqD,MAAM;EACjCzC,WAAW,EAAEZ,SAAS,CAACqD,MAAM;EAC7B3C,UAAU,EAAEV,SAAS,CAACqD,MAAM;EAC5B/B,eAAe,EAAEtB,SAAS,CAACmD,IAAI;EAC/B5B,SAAS,EAAEvB,SAAS,CAACsD;AACvB,CAAC;AAEDhD,cAAc,CAACiD,YAAY,GAAG;EAC5BlC,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"}
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;EACXC,QAAQ;EACRC,QAAQ;EACRC,IAAI;EACJC,QAAQ;EACRC,aAAa;EACbC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,QAAQ;EACRC,eAAe;EACfC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,cAAc,EAAEC,QAAQ,CAAC,GAAGxB,SAAS,CAACC,cAAc,CAAC;EAC5D,MAAM,CAACwB,YAAY,EAAEC,eAAe,CAAC,GAAG7B,QAAQ,CAAC,KAAK,CAAC;EACvD,MAAM,CAAC8B,YAAY,EAAEC,eAAe,CAAC,GAAG/B,QAAQ,CAAC,CAAC,CAACS,QAAQ,CAAC;EAC5D,MAAM,CAAC;IAAEuB,SAAS;IAAEC;EAAa,CAAC,EAAEC,eAAe,CAAC,GAAGlC,QAAQ,CAAC;IAC9DgC,SAAS,EAAEnB,MAAM;IACjBoB,YAAY,EAAEV;EAChB,CAAC,CAAC;EAEF,MAAMY,SAAS,GAAGC,kBAAkB,CAAC1B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-builder",
3
- "version": "0.126.0-shorthand.2",
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": "^3.0.4",
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": "429134189724881c61fa0651826715d56ec824e1"
90
+ "gitHead": "3426eb3c15ca8bf9c601ebfccff00ad695b9a83a"
91
91
  }
@@ -32,7 +32,7 @@ const BannerRender = ({
32
32
  asPath,
33
33
  action,
34
34
  actionKey,
35
- renderCounter,
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, renderCounter);
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
- renderCounter: PropTypes.number,
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
- renderCounter: null,
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, renderCounter) => {
23
+ const setCustomTargetings = (targetings, cardBannerIndex) => {
24
24
  let bannerTargetings = {};
25
25
 
26
- const updatedTargetings = renderCounter
27
- ? addPosnToTargetings(targetings, renderCounter)
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 renderCounter = 0;
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) renderCounter += 1;
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
- renderCounter={renderCounter}
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, parserOptions, ...otherProps }) => {
10
+ const Code = memo(({ code: embedCode, ...otherProps }) => {
11
11
  if (!embedCode) return null;
12
12
 
13
- const parsedCode = parseHTML(embedCode, parserOptions);
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
- try {
21
- // modify children array as we just want to wrap single components
22
- // eslint-disable-next-line no-param-reassign
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
- if (contentType === 'tab' || contentType === 'sidepanel')
7
- return <ContentGroupTabs contentType={contentType} {...props} />;
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, children, ...props }) => {
5
- const [selectedTab, setSelectedTab] = useState('tab-0');
6
- const groupSections = children?.props?.children[1];
7
- const contentClassame = contentType === 'tab' ? '-tabs' : '-sidepanel';
8
- if (!groupSections || !groupSections.length) return '';
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={`content-group${contentClassame}`}>
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
- props: { component: { settings: { label: sectionLabel } = {} } = {} } = {}
19
- } = groupSection;
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 = isSelected
24
- ? `content-group${contentClassame}__button--is-active`
25
- : `content-group${contentClassame}__button`;
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={() => setSelectedTab(tabId)}>
37
- {sectionLabel}
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 tabId = `tab-${index}`;
44
- const panelId = `panel-${index}`;
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={panelId}
65
+ id={sectionName}
50
66
  key={panelId}
51
- className={`content-group${contentClassame}__content-section`}
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
- children: PropTypes.object
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,7 @@
1
+ const TAB = 'tab';
2
+ const TABS = 'tabs';
3
+ const SIDEPANEL = 'sidepanel';
4
+ const CONTENT_GROUP = 'content-group';
5
+ const PANEL = 'panel';
6
+
7
+ export { TAB, TABS, SIDEPANEL, CONTENT_GROUP, PANEL };
@@ -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;
@@ -0,0 +1,7 @@
1
+ const getSectionsData = sections =>
2
+ sections.map(section => {
3
+ const { props: { component: { settings: { label, name } = {} } = {} } = {} } = section;
4
+ return [name, label];
5
+ });
6
+
7
+ export default getSectionsData;
@@ -0,0 +1,4 @@
1
+ import getSectionsData from './get-sections-data';
2
+ import getActiveTab from './get-active-tab';
3
+
4
+ export { getSectionsData, 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 <div className="content-group-section">{children}</div>;
8
+ return (
9
+ <div key={name} className="content-group-section">
10
+ {children}
11
+ </div>
12
+ );
9
13
  };
10
14
 
11
15
  ContentGroupSection.propTypes = {
@@ -86,7 +86,7 @@ const CardsRenderItem = ({
86
86
  {...cardProps}
87
87
  />
88
88
  </div>
89
- {shouldRenderBanner && <Banner {...bannerProps} renderCounter={bannerIndex} />}
89
+ {shouldRenderBanner && <Banner {...bannerProps} cardBannerIndex={bannerIndex} />}
90
90
  </>
91
91
  );
92
92
  };
@@ -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} renderCounter={bannerIndex} />}
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
  );
@@ -99,7 +99,7 @@ const defaultProps = {
99
99
  entity: '',
100
100
  targetings: '',
101
101
  sizes: '',
102
- renderCounter: null,
102
+ cardBannerIndex: null,
103
103
  ...otherProps
104
104
  };
105
105
 
@@ -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, { contentType: 'tab' });
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`] = `<DocumentFragment />`;
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`] = `<DocumentFragment />`;
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
+ });