@blaze-cms/react-page-builder 0.141.0-core-styles.3 → 0.141.0-core-variants.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 (101) hide show
  1. package/CHANGELOG.md +9 -45
  2. package/lib/components/ContentGroup/ContentGroupTabs.js +10 -8
  3. package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  4. package/lib/hooks/helpers/getVariant.js.map +1 -1
  5. package/lib/variants/HeroImage/index.js +29 -0
  6. package/lib/variants/HeroImage/index.js.map +1 -0
  7. package/lib/variants/Infographic/Infographic.js +27 -0
  8. package/lib/variants/Infographic/Infographic.js.map +1 -0
  9. package/lib/variants/Infographic/index.js +29 -0
  10. package/lib/variants/Infographic/index.js.map +1 -0
  11. package/lib/variants/Infographic/useInfographic.js +43 -0
  12. package/lib/variants/Infographic/useInfographic.js.map +1 -0
  13. package/lib/variants/LongformGallery/LongformGallery.js +51 -0
  14. package/lib/variants/LongformGallery/LongformGallery.js.map +1 -0
  15. package/lib/variants/LongformGallery/LongformGalleryImage.js +68 -0
  16. package/lib/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
  17. package/lib/variants/LongformGallery/constants.js +19 -0
  18. package/lib/variants/LongformGallery/constants.js.map +1 -0
  19. package/lib/variants/LongformGallery/helpers/index.js +29 -0
  20. package/lib/variants/LongformGallery/helpers/index.js.map +1 -0
  21. package/lib/variants/LongformGallery/helpers/parseImageData.js +42 -0
  22. package/lib/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
  23. package/lib/variants/LongformGallery/helpers/separateImages.js +27 -0
  24. package/lib/variants/LongformGallery/helpers/separateImages.js.map +1 -0
  25. package/lib/variants/LongformGallery/helpers/shouldSkip.js +13 -0
  26. package/lib/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
  27. package/lib/variants/LongformGallery/index.js +31 -0
  28. package/lib/variants/LongformGallery/index.js.map +1 -0
  29. package/lib/variants/LongformGallery/useLongformGallery.js +63 -0
  30. package/lib/variants/LongformGallery/useLongformGallery.js.map +1 -0
  31. package/lib/variants/LongformRow/index.js +29 -0
  32. package/lib/variants/LongformRow/index.js.map +1 -0
  33. package/lib/variants/ParallaxImageTextRight/index.js +30 -0
  34. package/lib/variants/ParallaxImageTextRight/index.js.map +1 -0
  35. package/lib/variants/index.js +13 -1
  36. package/lib/variants/index.js.map +1 -1
  37. package/lib-es/components/ContentGroup/ContentGroupTabs.js +10 -8
  38. package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  39. package/lib-es/hooks/helpers/getVariant.js.map +1 -1
  40. package/lib-es/variants/HeroImage/index.js +10 -0
  41. package/lib-es/variants/HeroImage/index.js.map +1 -0
  42. package/lib-es/variants/Infographic/Infographic.js +20 -0
  43. package/lib-es/variants/Infographic/Infographic.js.map +1 -0
  44. package/lib-es/variants/Infographic/index.js +10 -0
  45. package/lib-es/variants/Infographic/index.js.map +1 -0
  46. package/lib-es/variants/Infographic/useInfographic.js +23 -0
  47. package/lib-es/variants/Infographic/useInfographic.js.map +1 -0
  48. package/lib-es/variants/LongformGallery/LongformGallery.js +37 -0
  49. package/lib-es/variants/LongformGallery/LongformGallery.js.map +1 -0
  50. package/lib-es/variants/LongformGallery/LongformGalleryImage.js +56 -0
  51. package/lib-es/variants/LongformGallery/LongformGalleryImage.js.map +1 -0
  52. package/lib-es/variants/LongformGallery/constants.js +18 -0
  53. package/lib-es/variants/LongformGallery/constants.js.map +1 -0
  54. package/lib-es/variants/LongformGallery/helpers/index.js +5 -0
  55. package/lib-es/variants/LongformGallery/helpers/index.js.map +1 -0
  56. package/lib-es/variants/LongformGallery/helpers/parseImageData.js +26 -0
  57. package/lib-es/variants/LongformGallery/helpers/parseImageData.js.map +1 -0
  58. package/lib-es/variants/LongformGallery/helpers/separateImages.js +13 -0
  59. package/lib-es/variants/LongformGallery/helpers/separateImages.js.map +1 -0
  60. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js +3 -0
  61. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js.map +1 -0
  62. package/lib-es/variants/LongformGallery/index.js +12 -0
  63. package/lib-es/variants/LongformGallery/index.js.map +1 -0
  64. package/lib-es/variants/LongformGallery/useLongformGallery.js +48 -0
  65. package/lib-es/variants/LongformGallery/useLongformGallery.js.map +1 -0
  66. package/lib-es/variants/LongformRow/index.js +10 -0
  67. package/lib-es/variants/LongformRow/index.js.map +1 -0
  68. package/lib-es/variants/ParallaxImageTextRight/index.js +11 -0
  69. package/lib-es/variants/ParallaxImageTextRight/index.js.map +1 -0
  70. package/lib-es/variants/index.js +12 -1
  71. package/lib-es/variants/index.js.map +1 -1
  72. package/package.json +10 -10
  73. package/src/components/ContentGroup/ContentGroupTabs.js +11 -8
  74. package/src/hooks/helpers/getVariant.js +1 -0
  75. package/src/variants/HeroImage/index.js +8 -0
  76. package/src/variants/Infographic/Infographic.js +14 -0
  77. package/src/variants/Infographic/index.js +10 -0
  78. package/src/variants/Infographic/useInfographic.js +18 -0
  79. package/src/variants/LongformGallery/LongformGallery.js +48 -0
  80. package/src/variants/LongformGallery/LongformGalleryImage.js +62 -0
  81. package/src/variants/LongformGallery/constants.js +21 -0
  82. package/src/variants/LongformGallery/helpers/index.js +5 -0
  83. package/src/variants/LongformGallery/helpers/parseImageData.js +25 -0
  84. package/src/variants/LongformGallery/helpers/separateImages.js +22 -0
  85. package/src/variants/LongformGallery/helpers/shouldSkip.js +3 -0
  86. package/src/variants/LongformGallery/index.js +11 -0
  87. package/src/variants/LongformGallery/useLongformGallery.js +50 -0
  88. package/src/variants/LongformRow/index.js +8 -0
  89. package/src/variants/ParallaxImageTextRight/index.js +9 -0
  90. package/src/variants/index.js +13 -1
  91. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +2 -0
  92. package/tests/unit/src/components/PlaceholderIcon/__snapshots__/index.test.js.snap +0 -2
  93. package/tests/unit/src/variants/LongFormGallery/LongformGallery.test.js +41 -0
  94. package/tests/unit/src/variants/LongFormGallery/LongformGalleryImage.test.js +44 -0
  95. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGallery.test.js.snap +102 -0
  96. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap +51 -0
  97. package/tests/unit/src/variants/LongFormGallery/constants.js +37 -0
  98. package/tests/unit/src/variants/LongFormGallery/helpers/parseImageData.test.js +53 -0
  99. package/tests/unit/src/variants/LongFormGallery/helpers/separateImages.test.js +54 -0
  100. package/tests/unit/src/variants/LongFormGallery/helpers/shouldSkip.test.js +23 -0
  101. package/tests/unit/src/variants/LongFormGallery/useLongformGallery.test.js +39 -0
@@ -0,0 +1,5 @@
1
+ import parseImageData from './parseImageData';
2
+ import separateImages from './separateImages';
3
+ import shouldSkip from './shouldSkip';
4
+ export { parseImageData, separateImages, shouldSkip };
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["parseImageData","separateImages","shouldSkip"],"sources":["../../../../src/variants/LongformGallery/helpers/index.js"],"sourcesContent":["import parseImageData from './parseImageData';\nimport separateImages from './separateImages';\nimport shouldSkip from './shouldSkip';\n\nexport { parseImageData, separateImages, shouldSkip };\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,UAAU,MAAM,cAAc;AAErC,SAASF,cAAc,EAAEC,cAAc,EAAEC,UAAU"}
@@ -0,0 +1,26 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import parseHTML from 'html-react-parser';
5
+ import { PROPS_TO_CHECK } from '../constants';
6
+ const parseImageData = (image, index, priorityLimit, shouldDisplayCaption) => {
7
+ const {
8
+ data = {}
9
+ } = image;
10
+ const parsedData = {};
11
+ PROPS_TO_CHECK.forEach(dataKey => {
12
+ const value = data && data[dataKey];
13
+ if (dataKey === 'caption') {
14
+ parsedData[dataKey] = shouldDisplayCaption && !!value ? parseHTML(value) : '';
15
+ return;
16
+ }
17
+ parsedData[dataKey] = value || '';
18
+ });
19
+ return _objectSpread(_objectSpread({}, parsedData), {}, {
20
+ id: image.id,
21
+ url: image.url,
22
+ priority: index < priorityLimit
23
+ });
24
+ };
25
+ export default parseImageData;
26
+ //# sourceMappingURL=parseImageData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseImageData.js","names":["parseHTML","PROPS_TO_CHECK","parseImageData","image","index","priorityLimit","shouldDisplayCaption","data","parsedData","forEach","dataKey","value","_objectSpread","id","url","priority"],"sources":["../../../../src/variants/LongformGallery/helpers/parseImageData.js"],"sourcesContent":["import parseHTML from 'html-react-parser';\nimport { PROPS_TO_CHECK } from '../constants';\n\nconst parseImageData = (image, index, priorityLimit, shouldDisplayCaption) => {\n const { data = {} } = image;\n const parsedData = {};\n\n PROPS_TO_CHECK.forEach(dataKey => {\n const value = data && data[dataKey];\n if (dataKey === 'caption') {\n parsedData[dataKey] = shouldDisplayCaption && !!value ? parseHTML(value) : '';\n return;\n }\n parsedData[dataKey] = value || '';\n });\n\n return {\n ...parsedData,\n id: image.id,\n url: image.url,\n priority: index < priorityLimit\n };\n};\n\nexport default parseImageData;\n"],"mappings":";;;AAAA,OAAOA,SAAS,MAAM,mBAAmB;AACzC,SAASC,cAAc,QAAQ,cAAc;AAE7C,MAAMC,cAAc,GAAGA,CAACC,KAAK,EAAEC,KAAK,EAAEC,aAAa,EAAEC,oBAAoB,KAAK;EAC5E,MAAM;IAAEC,IAAI,GAAG,CAAC;EAAE,CAAC,GAAGJ,KAAK;EAC3B,MAAMK,UAAU,GAAG,CAAC,CAAC;EAErBP,cAAc,CAACQ,OAAO,CAACC,OAAO,IAAI;IAChC,MAAMC,KAAK,GAAGJ,IAAI,IAAIA,IAAI,CAACG,OAAO,CAAC;IACnC,IAAIA,OAAO,KAAK,SAAS,EAAE;MACzBF,UAAU,CAACE,OAAO,CAAC,GAAGJ,oBAAoB,IAAI,CAAC,CAACK,KAAK,GAAGX,SAAS,CAACW,KAAK,CAAC,GAAG,EAAE;MAC7E;IACF;IACAH,UAAU,CAACE,OAAO,CAAC,GAAGC,KAAK,IAAI,EAAE;EACnC,CAAC,CAAC;EAEF,OAAAC,aAAA,CAAAA,aAAA,KACKJ,UAAU;IACbK,EAAE,EAAEV,KAAK,CAACU,EAAE;IACZC,GAAG,EAAEX,KAAK,CAACW,GAAG;IACdC,QAAQ,EAAEX,KAAK,GAAGC;EAAa;AAEnC,CAAC;AAED,eAAeH,cAAc"}
@@ -0,0 +1,13 @@
1
+ import parseImageData from './parseImageData';
2
+ const separateImages = (images, priorityLimit, shouldDisplayCaption) => {
3
+ if (!images || !images.length) return [[], []];
4
+ const mainImages = images.slice(0, 2).map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));
5
+ const secondaryImages = [];
6
+ for (let i = 2; i < images.length; i += 3) {
7
+ const parsedImages = images.slice(i, i + 3).map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));
8
+ secondaryImages.push(parsedImages);
9
+ }
10
+ return [mainImages, secondaryImages];
11
+ };
12
+ export default separateImages;
13
+ //# sourceMappingURL=separateImages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"separateImages.js","names":["parseImageData","separateImages","images","priorityLimit","shouldDisplayCaption","length","mainImages","slice","map","image","index","secondaryImages","i","parsedImages","push"],"sources":["../../../../src/variants/LongformGallery/helpers/separateImages.js"],"sourcesContent":["import parseImageData from './parseImageData';\n\nconst separateImages = (images, priorityLimit, shouldDisplayCaption) => {\n if (!images || !images.length) return [[], []];\n\n const mainImages = images\n .slice(0, 2)\n .map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));\n\n const secondaryImages = [];\n\n for (let i = 2; i < images.length; i += 3) {\n const parsedImages = images\n .slice(i, i + 3)\n .map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));\n secondaryImages.push(parsedImages);\n }\n\n return [mainImages, secondaryImages];\n};\n\nexport default separateImages;\n"],"mappings":"AAAA,OAAOA,cAAc,MAAM,kBAAkB;AAE7C,MAAMC,cAAc,GAAGA,CAACC,MAAM,EAAEC,aAAa,EAAEC,oBAAoB,KAAK;EACtE,IAAI,CAACF,MAAM,IAAI,CAACA,MAAM,CAACG,MAAM,EAAE,OAAO,CAAC,EAAE,EAAE,EAAE,CAAC;EAE9C,MAAMC,UAAU,GAAGJ,MAAM,CACtBK,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CACXC,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKV,cAAc,CAACS,KAAK,EAAEC,KAAK,EAAEP,aAAa,EAAEC,oBAAoB,CAAC,CAAC;EAE3F,MAAMO,eAAe,GAAG,EAAE;EAE1B,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGV,MAAM,CAACG,MAAM,EAAEO,CAAC,IAAI,CAAC,EAAE;IACzC,MAAMC,YAAY,GAAGX,MAAM,CACxBK,KAAK,CAACK,CAAC,EAAEA,CAAC,GAAG,CAAC,CAAC,CACfJ,GAAG,CAAC,CAACC,KAAK,EAAEC,KAAK,KAAKV,cAAc,CAACS,KAAK,EAAEC,KAAK,EAAEP,aAAa,EAAEC,oBAAoB,CAAC,CAAC;IAC3FO,eAAe,CAACG,IAAI,CAACD,YAAY,CAAC;EACpC;EAEA,OAAO,CAACP,UAAU,EAAEK,eAAe,CAAC;AACtC,CAAC;AAED,eAAeV,cAAc"}
@@ -0,0 +1,3 @@
1
+ const shouldSkip = ids => !ids || Array.isArray(ids) && !ids.length;
2
+ export default shouldSkip;
3
+ //# sourceMappingURL=shouldSkip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shouldSkip.js","names":["shouldSkip","ids","Array","isArray","length"],"sources":["../../../../src/variants/LongformGallery/helpers/shouldSkip.js"],"sourcesContent":["const shouldSkip = ids => !ids || (Array.isArray(ids) && !ids.length);\n\nexport default shouldSkip;\n"],"mappings":"AAAA,MAAMA,UAAU,GAAGC,GAAG,IAAI,CAACA,GAAG,IAAKC,KAAK,CAACC,OAAO,CAACF,GAAG,CAAC,IAAI,CAACA,GAAG,CAACG,MAAO;AAErE,eAAeJ,UAAU"}
@@ -0,0 +1,12 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import LongformGalleryComponent from './LongformGallery';
5
+ const LongformGallery = {
6
+ VariantComponent: LongformGalleryComponent,
7
+ getSettings: componentSettings => _objectSpread(_objectSpread({}, componentSettings), {}, {
8
+ modifier: 'longformGallery'
9
+ })
10
+ };
11
+ export default LongformGallery;
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["LongformGalleryComponent","LongformGallery","VariantComponent","getSettings","componentSettings","_objectSpread","modifier"],"sources":["../../../src/variants/LongformGallery/index.js"],"sourcesContent":["import LongformGalleryComponent from './LongformGallery';\n\nconst LongformGallery = {\n VariantComponent: LongformGalleryComponent,\n getSettings: componentSettings => ({\n ...componentSettings,\n modifier: 'longformGallery'\n })\n};\n\nexport default LongformGallery;\n"],"mappings":";;;AAAA,OAAOA,wBAAwB,MAAM,mBAAmB;AAExD,MAAMC,eAAe,GAAG;EACtBC,gBAAgB,EAAEF,wBAAwB;EAC1CG,WAAW,EAAEC,iBAAiB,IAAAC,aAAA,CAAAA,aAAA,KACzBD,iBAAiB;IACpBE,QAAQ,EAAE;EAAiB;AAE/B,CAAC;AAED,eAAeL,eAAe"}
@@ -0,0 +1,48 @@
1
+ import { useQuery } from '@apollo/client';
2
+ import { GET_IMAGES_QUERY } from './constants';
3
+ import { separateImages, shouldSkip } from './helpers';
4
+ const useLongformGallery = ({
5
+ imageIds = [],
6
+ priorityLimit = 0,
7
+ shouldDisplayCaption = false,
8
+ enableLightbox = false,
9
+ toggleModal = () => {},
10
+ handleSelectedImage = () => {}
11
+ }) => {
12
+ const skip = shouldSkip(imageIds);
13
+ const {
14
+ data,
15
+ loading,
16
+ error
17
+ } = useQuery(GET_IMAGES_QUERY, {
18
+ variables: {
19
+ where: {
20
+ id: {
21
+ _in: imageIds
22
+ }
23
+ }
24
+ },
25
+ skip
26
+ });
27
+ const {
28
+ getImages
29
+ } = data || {};
30
+ const [mainImages, secondaryImages] = separateImages(getImages, priorityLimit, shouldDisplayCaption);
31
+ const handleImageOnClick = clickedImageId => {
32
+ if (!enableLightbox) return;
33
+ toggleModal();
34
+ handleSelectedImage(clickedImageId);
35
+ };
36
+ const secondaryImageClassname = imageIds.length === 4 ? 'longform-gallery__images__image secondary-image two-group' : 'longform-gallery__images__image secondary-image';
37
+ return {
38
+ data,
39
+ loading,
40
+ error,
41
+ mainImages,
42
+ secondaryImages,
43
+ secondaryImageClassname,
44
+ handleImageOnClick
45
+ };
46
+ };
47
+ export default useLongformGallery;
48
+ //# sourceMappingURL=useLongformGallery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useLongformGallery.js","names":["useQuery","GET_IMAGES_QUERY","separateImages","shouldSkip","useLongformGallery","imageIds","priorityLimit","shouldDisplayCaption","enableLightbox","toggleModal","handleSelectedImage","skip","data","loading","error","variables","where","id","_in","getImages","mainImages","secondaryImages","handleImageOnClick","clickedImageId","secondaryImageClassname","length"],"sources":["../../../src/variants/LongformGallery/useLongformGallery.js"],"sourcesContent":["import { useQuery } from '@apollo/client';\nimport { GET_IMAGES_QUERY } from './constants';\nimport { separateImages, shouldSkip } from './helpers';\n\nconst useLongformGallery = ({\n imageIds = [],\n priorityLimit = 0,\n shouldDisplayCaption = false,\n enableLightbox = false,\n toggleModal = () => {},\n handleSelectedImage = () => {}\n}) => {\n const skip = shouldSkip(imageIds);\n\n const { data, loading, error } = useQuery(GET_IMAGES_QUERY, {\n variables: { where: { id: { _in: imageIds } } },\n skip\n });\n\n const { getImages } = data || {};\n\n const [mainImages, secondaryImages] = separateImages(\n getImages,\n priorityLimit,\n shouldDisplayCaption\n );\n\n const handleImageOnClick = clickedImageId => {\n if (!enableLightbox) return;\n toggleModal();\n handleSelectedImage(clickedImageId);\n };\n\n const secondaryImageClassname =\n imageIds.length === 4\n ? 'longform-gallery__images__image secondary-image two-group'\n : 'longform-gallery__images__image secondary-image';\n\n return {\n data,\n loading,\n error,\n mainImages,\n secondaryImages,\n secondaryImageClassname,\n handleImageOnClick\n };\n};\n\nexport default useLongformGallery;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,gBAAgB,QAAQ,aAAa;AAC9C,SAASC,cAAc,EAAEC,UAAU,QAAQ,WAAW;AAEtD,MAAMC,kBAAkB,GAAGA,CAAC;EAC1BC,QAAQ,GAAG,EAAE;EACbC,aAAa,GAAG,CAAC;EACjBC,oBAAoB,GAAG,KAAK;EAC5BC,cAAc,GAAG,KAAK;EACtBC,WAAW,GAAGA,CAAA,KAAM,CAAC,CAAC;EACtBC,mBAAmB,GAAGA,CAAA,KAAM,CAAC;AAC/B,CAAC,KAAK;EACJ,MAAMC,IAAI,GAAGR,UAAU,CAACE,QAAQ,CAAC;EAEjC,MAAM;IAAEO,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGd,QAAQ,CAACC,gBAAgB,EAAE;IAC1Dc,SAAS,EAAE;MAAEC,KAAK,EAAE;QAAEC,EAAE,EAAE;UAAEC,GAAG,EAAEb;QAAS;MAAE;IAAE,CAAC;IAC/CM;EACF,CAAC,CAAC;EAEF,MAAM;IAAEQ;EAAU,CAAC,GAAGP,IAAI,IAAI,CAAC,CAAC;EAEhC,MAAM,CAACQ,UAAU,EAAEC,eAAe,CAAC,GAAGnB,cAAc,CAClDiB,SAAS,EACTb,aAAa,EACbC,oBACF,CAAC;EAED,MAAMe,kBAAkB,GAAGC,cAAc,IAAI;IAC3C,IAAI,CAACf,cAAc,EAAE;IACrBC,WAAW,CAAC,CAAC;IACbC,mBAAmB,CAACa,cAAc,CAAC;EACrC,CAAC;EAED,MAAMC,uBAAuB,GAC3BnB,QAAQ,CAACoB,MAAM,KAAK,CAAC,GACjB,2DAA2D,GAC3D,iDAAiD;EAEvD,OAAO;IACLb,IAAI;IACJC,OAAO;IACPC,KAAK;IACLM,UAAU;IACVC,eAAe;IACfG,uBAAuB;IACvBF;EACF,CAAC;AACH,CAAC;AAED,eAAelB,kBAAkB"}
@@ -0,0 +1,10 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ const LongformRow = {
5
+ getSettings: componentSettings => _objectSpread(_objectSpread({}, componentSettings), {}, {
6
+ modifier: 'longform-row'
7
+ })
8
+ };
9
+ export default LongformRow;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["LongformRow","getSettings","componentSettings","_objectSpread","modifier"],"sources":["../../../src/variants/LongformRow/index.js"],"sourcesContent":["const LongformRow = {\n getSettings: componentSettings => ({\n ...componentSettings,\n modifier: 'longform-row'\n })\n};\n\nexport default LongformRow;\n"],"mappings":";;;AAAA,MAAMA,WAAW,GAAG;EAClBC,WAAW,EAAEC,iBAAiB,IAAAC,aAAA,CAAAA,aAAA,KACzBD,iBAAiB;IACpBE,QAAQ,EAAE;EAAc;AAE5B,CAAC;AAED,eAAeJ,WAAW"}
@@ -0,0 +1,11 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ const ParallaxImageTextRight = {
5
+ getSettings: componentSettings => _objectSpread(_objectSpread({}, componentSettings), {}, {
6
+ parallax: true,
7
+ modifier: 'image-children-right'
8
+ })
9
+ };
10
+ export default ParallaxImageTextRight;
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["ParallaxImageTextRight","getSettings","componentSettings","_objectSpread","parallax","modifier"],"sources":["../../../src/variants/ParallaxImageTextRight/index.js"],"sourcesContent":["const ParallaxImageTextRight = {\n getSettings: componentSettings => ({\n ...componentSettings,\n parallax: true,\n modifier: 'image-children-right'\n })\n};\n\nexport default ParallaxImageTextRight;\n"],"mappings":";;;AAAA,MAAMA,sBAAsB,GAAG;EAC7BC,WAAW,EAAEC,iBAAiB,IAAAC,aAAA,CAAAA,aAAA,KACzBD,iBAAiB;IACpBE,QAAQ,EAAE,IAAI;IACdC,QAAQ,EAAE;EAAsB;AAEpC,CAAC;AAED,eAAeL,sBAAsB"}
@@ -1,2 +1,13 @@
1
- export default {};
1
+ import heroImage from './HeroImage';
2
+ import infographic from './Infographic';
3
+ import longformGallery from './LongformGallery';
4
+ import longformRow from './LongformRow';
5
+ import parallaxImageTextRight from './ParallaxImageTextRight';
6
+ export default {
7
+ heroImage,
8
+ infographic,
9
+ longformGallery,
10
+ longformRow,
11
+ parallaxImageTextRight
12
+ };
2
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../src/variants/index.js"],"sourcesContent":["export default {};\n"],"mappings":"AAAA,eAAe,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","names":["heroImage","infographic","longformGallery","longformRow","parallaxImageTextRight"],"sources":["../../src/variants/index.js"],"sourcesContent":["import heroImage from './HeroImage';\nimport infographic from './Infographic';\nimport longformGallery from './LongformGallery';\nimport longformRow from './LongformRow';\nimport parallaxImageTextRight from './ParallaxImageTextRight';\n\nexport default {\n heroImage,\n infographic,\n longformGallery,\n longformRow,\n parallaxImageTextRight\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,aAAa;AACnC,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,eAAe,MAAM,mBAAmB;AAC/C,OAAOC,WAAW,MAAM,eAAe;AACvC,OAAOC,sBAAsB,MAAM,0BAA0B;AAE7D,eAAe;EACbJ,SAAS;EACTC,WAAW;EACXC,eAAe;EACfC,WAAW;EACXC;AACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.141.0-core-styles.3",
3
+ "version": "0.141.0-core-variants.0",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,15 +27,15 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/core-auth-ui": "0.140.2-core-styles.1",
31
- "@blaze-cms/core-errors": "0.140.2-core-styles.1",
32
- "@blaze-cms/core-errors-ui": "0.140.2-core-styles.1",
30
+ "@blaze-cms/core-auth-ui": "0.141.0-core-variants.0",
31
+ "@blaze-cms/core-errors": "^0.139.0",
32
+ "@blaze-cms/core-errors-ui": "^0.139.0",
33
33
  "@blaze-cms/image-cdn-react": "0.3.0-alpha.6",
34
- "@blaze-cms/nextjs-components": "0.141.0-core-styles.0",
35
- "@blaze-cms/plugin-search-ui": "0.141.0-core-styles.3",
36
- "@blaze-cms/setup-ui": "0.140.2-core-styles.1",
37
- "@blaze-cms/utils": "0.140.2-core-styles.1",
38
- "@blaze-cms/utils-handlebars": "0.141.0-core-styles.0",
34
+ "@blaze-cms/nextjs-components": "0.141.0-core-variants.0",
35
+ "@blaze-cms/plugin-search-ui": "0.141.0-core-variants.0",
36
+ "@blaze-cms/setup-ui": "^0.139.0",
37
+ "@blaze-cms/utils": "^0.139.0",
38
+ "@blaze-cms/utils-handlebars": "0.141.0-core-variants.0",
39
39
  "@blaze-react/breadcrumb": "0.8.0-alpha.60",
40
40
  "@blaze-react/button": "0.5.19",
41
41
  "@blaze-react/checkboxes": "0.5.31",
@@ -89,5 +89,5 @@
89
89
  "lib/*",
90
90
  "lib-es/*"
91
91
  ],
92
- "gitHead": "d0eaddbf6a1e2cca4c955c0e95345354c24e7fd0"
92
+ "gitHead": "575e2c9a6dcb15af4072847bd66677affb1abedc"
93
93
  }
@@ -4,7 +4,7 @@ import { useRouter } from 'next/router';
4
4
  import { getActiveTab } from './helpers';
5
5
  import { TAB, TABS, SIDEPANEL, CONTENT_GROUP, PANEL } from './constants';
6
6
 
7
- const ContentGroupTabs = ({ name, contentType, modifier, groupSections, sectionsData }) => {
7
+ const ContentGroupTabs = ({ name, contentType, groupSections, sectionsData, VariantComponent }) => {
8
8
  const router = useRouter();
9
9
  const [selectedTab, setSelectedTab] = useState(getActiveTab(sectionsData, ''));
10
10
  const { asPath } = router;
@@ -21,10 +21,12 @@ const ContentGroupTabs = ({ name, contentType, modifier, groupSections, sections
21
21
  [asPath, sectionsData, selectedTab]
22
22
  );
23
23
 
24
+ const WrapperComponent = VariantComponent || 'div';
25
+
24
26
  return (
25
27
  <div className={mainDivClass}>
26
28
  <ul className={contentGroupClass} role="tablist" aria-label={name}>
27
- {groupSections.map((groupSection, index) => {
29
+ {groupSections.map((_, index) => {
28
30
  const [sectionName, sectioLabel] = sectionsData[index];
29
31
  const tabId = `${TAB}-${sectionName}`;
30
32
  const panelId = `${PANEL}-${sectionName}`;
@@ -61,14 +63,15 @@ const ContentGroupTabs = ({ name, contentType, modifier, groupSections, sections
61
63
  if (selectedTab !== tabId) return null;
62
64
 
63
65
  return (
64
- <div
65
- id={sectionName}
66
+ <WrapperComponent
66
67
  key={panelId}
68
+ id={sectionName}
67
69
  className={sectionClass}
68
70
  role="tabpanel"
71
+ tabId={tabId}
69
72
  aria-labelledby={tabId}>
70
73
  {groupSection}
71
- </div>
74
+ </WrapperComponent>
72
75
  );
73
76
  })}
74
77
  </div>
@@ -78,13 +81,13 @@ const ContentGroupTabs = ({ name, contentType, modifier, groupSections, sections
78
81
  ContentGroupTabs.propTypes = {
79
82
  name: PropTypes.string.isRequired,
80
83
  contentType: PropTypes.string.isRequired,
81
- modifier: PropTypes.string,
82
84
  groupSections: PropTypes.array.isRequired,
83
- sectionsData: PropTypes.array.isRequired
85
+ sectionsData: PropTypes.array.isRequired,
86
+ VariantComponent: PropTypes.func
84
87
  };
85
88
 
86
89
  ContentGroupTabs.defaultProps = {
87
- modifier: ''
90
+ VariantComponent: null
88
91
  };
89
92
 
90
93
  export default ContentGroupTabs;
@@ -3,6 +3,7 @@ import { variantHandler } from '../../utils';
3
3
  export default function getVariant(settings) {
4
4
  const { variant } = settings;
5
5
  if (!variant) return [null, {}];
6
+
6
7
  const { VariantComponent, getSettings } = variantHandler.get(variant) || {};
7
8
  const variantSettings =
8
9
  !!getSettings && typeof getSettings === 'function' ? getSettings(settings) : settings;
@@ -0,0 +1,8 @@
1
+ const HeroImage = {
2
+ getSettings: componentSettings => ({
3
+ ...componentSettings,
4
+ modifier: 'hero-image'
5
+ })
6
+ };
7
+
8
+ export default HeroImage;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import useInfographic from './useInfographic';
3
+
4
+ const Infographic = props => {
5
+ const { contentRef, id, className, tabId, children } = useInfographic(props);
6
+
7
+ return (
8
+ <div ref={contentRef} id={id} className={className} role="tabpanel" aria-labelledby={tabId}>
9
+ {children}
10
+ </div>
11
+ );
12
+ };
13
+
14
+ export default Infographic;
@@ -0,0 +1,10 @@
1
+ import InfographicComponent from './Infographic';
2
+
3
+ const Infographic = {
4
+ getSettings: componentSettings => ({
5
+ ...componentSettings
6
+ }),
7
+ VariantComponent: InfographicComponent
8
+ };
9
+
10
+ export default Infographic;
@@ -0,0 +1,18 @@
1
+ import { useInView } from '@blaze-react/utils/lib/customHooks';
2
+
3
+ const useInfographic = ({ className: _className, ...props }) => {
4
+ const [isIntersecting, contentRef] = useInView({
5
+ once: true,
6
+ offset: '200px'
7
+ });
8
+
9
+ const className = `${_className} infographic${isIntersecting ? ' infographic__active' : ''}`;
10
+
11
+ return {
12
+ ...props,
13
+ className,
14
+ contentRef
15
+ };
16
+ };
17
+
18
+ export default useInfographic;
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import useLongformGallery from './useLongformGallery';
3
+ import LongformGalleryImage from './LongformGalleryImage';
4
+
5
+ const LongformGallery = props => {
6
+ const {
7
+ error,
8
+ mainImages,
9
+ secondaryImages,
10
+ secondaryImageClassname,
11
+ handleImageOnClick
12
+ } = useLongformGallery(props);
13
+
14
+ if (error) return null;
15
+
16
+ return (
17
+ <div className="longform-gallery" data-testid="longform-gallery">
18
+ <div className="longform-gallery__images main-images">
19
+ {mainImages.map(mainImageData => (
20
+ <LongformGalleryImage
21
+ key={mainImageData.id}
22
+ {...mainImageData}
23
+ className="longform-gallery__images__image main-image"
24
+ handleImageOnClick={handleImageOnClick}
25
+ />
26
+ ))}
27
+ </div>
28
+ {secondaryImages.map((secondaryImagesGroup, i) => (
29
+ <div
30
+ // eslint-disable-next-line react/no-array-index-key
31
+ key={i}
32
+ data-testid="secondary-images"
33
+ className="longform-gallery__images secondary-images">
34
+ {secondaryImagesGroup.map(secondaryImage => (
35
+ <LongformGalleryImage
36
+ key={secondaryImage.id}
37
+ {...secondaryImage}
38
+ className={secondaryImageClassname}
39
+ handleImageOnClick={handleImageOnClick}
40
+ />
41
+ ))}
42
+ </div>
43
+ ))}
44
+ </div>
45
+ );
46
+ };
47
+
48
+ export default LongformGallery;
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import Head from 'next/head';
4
+ import { useInView } from '@blaze-react/utils/lib/customHooks';
5
+ import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
6
+ import { IN_VIEW_CONFIG } from './constants';
7
+
8
+ const LongformGalleryImage = ({
9
+ id,
10
+ url,
11
+ caption,
12
+ altText,
13
+ priority,
14
+ className,
15
+ handleImageOnClick,
16
+ ...props
17
+ }) => {
18
+ const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);
19
+ const shouldRender = priority || isIntersecting;
20
+ const HeadComponent = priority ? Head : null;
21
+
22
+ return (
23
+ <div ref={outerRef} className={className}>
24
+ <div
25
+ role="button"
26
+ className="longform-gallery__images__image__container"
27
+ data-testid="longform-gallery__images__image__container"
28
+ onClick={() => handleImageOnClick(id)}>
29
+ {shouldRender && (
30
+ <ResponsiveImage
31
+ sizeKey="carousel"
32
+ role="button"
33
+ src={url}
34
+ alt={altText}
35
+ priority={priority}
36
+ HeadComponent={HeadComponent}
37
+ {...props}
38
+ />
39
+ )}
40
+ </div>
41
+ {!!caption && (
42
+ <div
43
+ className="longform-gallery__images__image__details"
44
+ data-testid="longform-gallery__images__image__details">
45
+ <div className="longform-gallery__images__image__details__caption">{caption}</div>
46
+ </div>
47
+ )}
48
+ </div>
49
+ );
50
+ };
51
+
52
+ LongformGalleryImage.propTypes = {
53
+ id: PropTypes.string.isRequired,
54
+ url: PropTypes.string.isRequired,
55
+ caption: PropTypes.string.isRequired,
56
+ altText: PropTypes.string.isRequired,
57
+ priority: PropTypes.bool.isRequired,
58
+ className: PropTypes.string.isRequired,
59
+ handleImageOnClick: PropTypes.func.isRequired
60
+ };
61
+
62
+ export default LongformGalleryImage;
@@ -0,0 +1,21 @@
1
+ import { gql } from '@apollo/client';
2
+
3
+ const GET_IMAGES_QUERY = gql`
4
+ query getImages($where: JSON!) {
5
+ getImages: getFiles(where: $where) {
6
+ id
7
+ url
8
+ data
9
+ }
10
+ }
11
+ `;
12
+
13
+ const PROPS_TO_CHECK = ['altText', 'caption', 'hrefUrl', 'credits'];
14
+
15
+ const IN_VIEW_CONFIG = {
16
+ once: true,
17
+ offset: '200px',
18
+ bottomOffset: '-200px'
19
+ };
20
+
21
+ export { GET_IMAGES_QUERY, IN_VIEW_CONFIG, PROPS_TO_CHECK };
@@ -0,0 +1,5 @@
1
+ import parseImageData from './parseImageData';
2
+ import separateImages from './separateImages';
3
+ import shouldSkip from './shouldSkip';
4
+
5
+ export { parseImageData, separateImages, shouldSkip };
@@ -0,0 +1,25 @@
1
+ import parseHTML from 'html-react-parser';
2
+ import { PROPS_TO_CHECK } from '../constants';
3
+
4
+ const parseImageData = (image, index, priorityLimit, shouldDisplayCaption) => {
5
+ const { data = {} } = image;
6
+ const parsedData = {};
7
+
8
+ PROPS_TO_CHECK.forEach(dataKey => {
9
+ const value = data && data[dataKey];
10
+ if (dataKey === 'caption') {
11
+ parsedData[dataKey] = shouldDisplayCaption && !!value ? parseHTML(value) : '';
12
+ return;
13
+ }
14
+ parsedData[dataKey] = value || '';
15
+ });
16
+
17
+ return {
18
+ ...parsedData,
19
+ id: image.id,
20
+ url: image.url,
21
+ priority: index < priorityLimit
22
+ };
23
+ };
24
+
25
+ export default parseImageData;
@@ -0,0 +1,22 @@
1
+ import parseImageData from './parseImageData';
2
+
3
+ const separateImages = (images, priorityLimit, shouldDisplayCaption) => {
4
+ if (!images || !images.length) return [[], []];
5
+
6
+ const mainImages = images
7
+ .slice(0, 2)
8
+ .map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));
9
+
10
+ const secondaryImages = [];
11
+
12
+ for (let i = 2; i < images.length; i += 3) {
13
+ const parsedImages = images
14
+ .slice(i, i + 3)
15
+ .map((image, index) => parseImageData(image, index, priorityLimit, shouldDisplayCaption));
16
+ secondaryImages.push(parsedImages);
17
+ }
18
+
19
+ return [mainImages, secondaryImages];
20
+ };
21
+
22
+ export default separateImages;
@@ -0,0 +1,3 @@
1
+ const shouldSkip = ids => !ids || (Array.isArray(ids) && !ids.length);
2
+
3
+ export default shouldSkip;
@@ -0,0 +1,11 @@
1
+ import LongformGalleryComponent from './LongformGallery';
2
+
3
+ const LongformGallery = {
4
+ VariantComponent: LongformGalleryComponent,
5
+ getSettings: componentSettings => ({
6
+ ...componentSettings,
7
+ modifier: 'longformGallery'
8
+ })
9
+ };
10
+
11
+ export default LongformGallery;
@@ -0,0 +1,50 @@
1
+ import { useQuery } from '@apollo/client';
2
+ import { GET_IMAGES_QUERY } from './constants';
3
+ import { separateImages, shouldSkip } from './helpers';
4
+
5
+ const useLongformGallery = ({
6
+ imageIds = [],
7
+ priorityLimit = 0,
8
+ shouldDisplayCaption = false,
9
+ enableLightbox = false,
10
+ toggleModal = () => {},
11
+ handleSelectedImage = () => {}
12
+ }) => {
13
+ const skip = shouldSkip(imageIds);
14
+
15
+ const { data, loading, error } = useQuery(GET_IMAGES_QUERY, {
16
+ variables: { where: { id: { _in: imageIds } } },
17
+ skip
18
+ });
19
+
20
+ const { getImages } = data || {};
21
+
22
+ const [mainImages, secondaryImages] = separateImages(
23
+ getImages,
24
+ priorityLimit,
25
+ shouldDisplayCaption
26
+ );
27
+
28
+ const handleImageOnClick = clickedImageId => {
29
+ if (!enableLightbox) return;
30
+ toggleModal();
31
+ handleSelectedImage(clickedImageId);
32
+ };
33
+
34
+ const secondaryImageClassname =
35
+ imageIds.length === 4
36
+ ? 'longform-gallery__images__image secondary-image two-group'
37
+ : 'longform-gallery__images__image secondary-image';
38
+
39
+ return {
40
+ data,
41
+ loading,
42
+ error,
43
+ mainImages,
44
+ secondaryImages,
45
+ secondaryImageClassname,
46
+ handleImageOnClick
47
+ };
48
+ };
49
+
50
+ export default useLongformGallery;
@@ -0,0 +1,8 @@
1
+ const LongformRow = {
2
+ getSettings: componentSettings => ({
3
+ ...componentSettings,
4
+ modifier: 'longform-row'
5
+ })
6
+ };
7
+
8
+ export default LongformRow;