@blaze-cms/react-page-builder 0.118.0-alpha.2 → 0.119.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +22 -0
  3. package/lib/application/query/index.js +12 -12
  4. package/lib/application/query/index.js.map +1 -1
  5. package/lib/components/Banner/AdSlotRender.js +104 -0
  6. package/lib/components/Banner/AdSlotRender.js.map +1 -0
  7. package/lib/components/Banner/Banner.js +2 -2
  8. package/lib/components/Banner/Banner.js.map +1 -1
  9. package/lib/components/Banner/BannerRender.js +23 -33
  10. package/lib/components/Banner/BannerRender.js.map +1 -1
  11. package/lib/components/Button.js +2 -2
  12. package/lib/components/Button.js.map +1 -1
  13. package/lib/components/Card/CardContainer.js +6 -2
  14. package/lib/components/Card/CardContainer.js.map +1 -1
  15. package/lib/components/Card/CardFactory.js +2 -2
  16. package/lib/components/Card/CardFactory.js.map +1 -1
  17. package/lib/components/Card/CardRender.js +3 -3
  18. package/lib/components/Card/CardRender.js.map +1 -1
  19. package/lib/components/Card/helpers/filter-query-setup.js +7 -7
  20. package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
  21. package/lib/components/CarouselWrapper.js +54 -14
  22. package/lib/components/CarouselWrapper.js.map +1 -1
  23. package/lib/components/DataSummary/DataSummaryFactory.js +2 -2
  24. package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
  25. package/lib/components/DataSummary/DataSummaryRender.js +2 -2
  26. package/lib/components/DataSummary/DataSummaryRender.js.map +1 -1
  27. package/lib/components/EmailConfirm/EmailConfirm.js +2 -2
  28. package/lib/components/EmailConfirm/EmailConfirm.js.map +1 -1
  29. package/lib/components/EmailConfirm/mutation.js +2 -2
  30. package/lib/components/EmailConfirm/mutation.js.map +1 -1
  31. package/lib/components/Image/ImageFactory.js +9 -5
  32. package/lib/components/Image/ImageFactory.js.map +1 -1
  33. package/lib/components/List/ListBuilder.js +21 -21
  34. package/lib/components/List/ListBuilder.js.map +1 -1
  35. package/lib/components/List/ListFactory.js +3 -3
  36. package/lib/components/List/ListFactory.js.map +1 -1
  37. package/lib/components/List/ListRender.js +2 -2
  38. package/lib/components/List/ListRender.js.map +1 -1
  39. package/lib/components/Login/LoggedInMessage.js +1 -1
  40. package/lib/components/Login/LoggedInMessage.js.map +1 -1
  41. package/lib/components/Login/Login.js +2 -2
  42. package/lib/components/Login/Login.js.map +1 -1
  43. package/lib/components/Menu/Menu.js +39 -6
  44. package/lib/components/Menu/Menu.js.map +1 -1
  45. package/lib/components/PasswordReset/PasswordReset.js +2 -2
  46. package/lib/components/PasswordReset/PasswordReset.js.map +1 -1
  47. package/lib/components/PasswordResetRequest/PasswordResetRequest.js +2 -2
  48. package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
  49. package/lib/components/SearchFilter/SearchFilterContainer.js +2 -2
  50. package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  51. package/lib/constants/index.js +8 -2
  52. package/lib/constants/index.js.map +1 -1
  53. package/lib/helpers/build-props-query.js +2 -2
  54. package/lib/helpers/build-props-query.js.map +1 -1
  55. package/lib/hooks/use-get-entity-schema.js +3 -3
  56. package/lib/hooks/use-get-entity-schema.js.map +1 -1
  57. package/lib/hooks/use-get-entity-schemas-as-obj.js +2 -2
  58. package/lib/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
  59. package/lib/hooks/use-get-image-id-from-relation.js +2 -2
  60. package/lib/hooks/use-get-image-id-from-relation.js.map +1 -1
  61. package/lib/hooks/use-get-images.js +2 -2
  62. package/lib/hooks/use-get-images.js.map +1 -1
  63. package/lib/hooks/use-get-single-entity-schema.js +2 -2
  64. package/lib/hooks/use-get-single-entity-schema.js.map +1 -1
  65. package/lib-es/application/query/index.js +1 -5
  66. package/lib-es/application/query/index.js.map +1 -1
  67. package/lib-es/components/Banner/AdSlotRender.js +54 -0
  68. package/lib-es/components/Banner/AdSlotRender.js.map +1 -0
  69. package/lib-es/components/Banner/Banner.js +1 -1
  70. package/lib-es/components/Banner/Banner.js.map +1 -1
  71. package/lib-es/components/Banner/BannerRender.js +21 -29
  72. package/lib-es/components/Banner/BannerRender.js.map +1 -1
  73. package/lib-es/components/Button.js +1 -1
  74. package/lib-es/components/Button.js.map +1 -1
  75. package/lib-es/components/Card/CardContainer.js +7 -3
  76. package/lib-es/components/Card/CardContainer.js.map +1 -1
  77. package/lib-es/components/Card/CardFactory.js +1 -1
  78. package/lib-es/components/Card/CardFactory.js.map +1 -1
  79. package/lib-es/components/Card/CardRender.js +1 -1
  80. package/lib-es/components/Card/CardRender.js.map +1 -1
  81. package/lib-es/components/Card/helpers/filter-query-setup.js +1 -1
  82. package/lib-es/components/Card/helpers/filter-query-setup.js.map +1 -1
  83. package/lib-es/components/CarouselWrapper.js +50 -14
  84. package/lib-es/components/CarouselWrapper.js.map +1 -1
  85. package/lib-es/components/DataSummary/DataSummaryFactory.js +1 -1
  86. package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
  87. package/lib-es/components/DataSummary/DataSummaryRender.js +1 -1
  88. package/lib-es/components/DataSummary/DataSummaryRender.js.map +1 -1
  89. package/lib-es/components/EmailConfirm/EmailConfirm.js +1 -1
  90. package/lib-es/components/EmailConfirm/EmailConfirm.js.map +1 -1
  91. package/lib-es/components/EmailConfirm/mutation.js +1 -1
  92. package/lib-es/components/EmailConfirm/mutation.js.map +1 -1
  93. package/lib-es/components/Image/ImageFactory.js +8 -4
  94. package/lib-es/components/Image/ImageFactory.js.map +1 -1
  95. package/lib-es/components/List/ListBuilder.js +2 -2
  96. package/lib-es/components/List/ListBuilder.js.map +1 -1
  97. package/lib-es/components/List/ListFactory.js +1 -1
  98. package/lib-es/components/List/ListFactory.js.map +1 -1
  99. package/lib-es/components/List/ListRender.js +1 -1
  100. package/lib-es/components/List/ListRender.js.map +1 -1
  101. package/lib-es/components/Login/LoggedInMessage.js +1 -1
  102. package/lib-es/components/Login/LoggedInMessage.js.map +1 -1
  103. package/lib-es/components/Login/Login.js +1 -1
  104. package/lib-es/components/Login/Login.js.map +1 -1
  105. package/lib-es/components/Menu/Menu.js +44 -11
  106. package/lib-es/components/Menu/Menu.js.map +1 -1
  107. package/lib-es/components/PasswordReset/PasswordReset.js +1 -1
  108. package/lib-es/components/PasswordReset/PasswordReset.js.map +1 -1
  109. package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
  110. package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
  111. package/lib-es/components/SearchFilter/SearchFilterContainer.js +1 -1
  112. package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  113. package/lib-es/constants/index.js +4 -1
  114. package/lib-es/constants/index.js.map +1 -1
  115. package/lib-es/helpers/build-props-query.js +2 -2
  116. package/lib-es/helpers/build-props-query.js.map +1 -1
  117. package/lib-es/hooks/use-get-entity-schema.js +1 -1
  118. package/lib-es/hooks/use-get-entity-schema.js.map +1 -1
  119. package/lib-es/hooks/use-get-entity-schemas-as-obj.js +1 -1
  120. package/lib-es/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
  121. package/lib-es/hooks/use-get-image-id-from-relation.js +1 -1
  122. package/lib-es/hooks/use-get-image-id-from-relation.js.map +1 -1
  123. package/lib-es/hooks/use-get-images.js +1 -1
  124. package/lib-es/hooks/use-get-images.js.map +1 -1
  125. package/lib-es/hooks/use-get-single-entity-schema.js +1 -1
  126. package/lib-es/hooks/use-get-single-entity-schema.js.map +1 -1
  127. package/package.json +9 -13
  128. package/src/application/query/index.js +1 -5
  129. package/src/components/Banner/AdSlotRender.js +62 -0
  130. package/src/components/Banner/Banner.js +1 -1
  131. package/src/components/Banner/BannerRender.js +22 -27
  132. package/src/components/Button.js +1 -1
  133. package/src/components/Card/CardContainer.js +5 -1
  134. package/src/components/Card/CardFactory.js +1 -1
  135. package/src/components/Card/CardRender.js +1 -1
  136. package/src/components/Card/helpers/filter-query-setup.js +1 -1
  137. package/src/components/CarouselWrapper.js +64 -19
  138. package/src/components/DataSummary/DataSummaryFactory.js +1 -1
  139. package/src/components/DataSummary/DataSummaryRender.js +1 -1
  140. package/src/components/EmailConfirm/EmailConfirm.js +1 -1
  141. package/src/components/EmailConfirm/mutation.js +1 -1
  142. package/src/components/Image/ImageFactory.js +10 -7
  143. package/src/components/List/ListBuilder.js +2 -2
  144. package/src/components/List/ListFactory.js +1 -1
  145. package/src/components/List/ListRender.js +1 -1
  146. package/src/components/Login/LoggedInMessage.js +1 -1
  147. package/src/components/Login/Login.js +1 -1
  148. package/src/components/Menu/Menu.js +50 -12
  149. package/src/components/PasswordReset/PasswordReset.js +1 -1
  150. package/src/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
  151. package/src/components/SearchFilter/SearchFilterContainer.js +1 -1
  152. package/src/constants/index.js +6 -0
  153. package/src/helpers/build-props-query.js +2 -2
  154. package/src/hooks/use-get-entity-schema.js +1 -1
  155. package/src/hooks/use-get-entity-schemas-as-obj.js +1 -1
  156. package/src/hooks/use-get-image-id-from-relation.js +1 -1
  157. package/src/hooks/use-get-images.js +1 -1
  158. package/src/hooks/use-get-single-entity-schema.js +1 -1
  159. package/tests/unit/src/components/Banner/AdSlotRender.test.js +81 -0
  160. package/tests/unit/src/components/Banner/Banner.test.js +2 -1
  161. package/tests/unit/src/components/Banner/BannerRender.test.js +119 -0
  162. package/tests/unit/src/components/Banner/__snapshots__/AdSlotRender.test.js.snap +54 -0
  163. package/tests/unit/src/components/Banner/__snapshots__/BannerRender.test.js.snap +10 -0
  164. package/tests/unit/src/components/Button.test.js +2 -1
  165. package/tests/unit/src/components/Card/CardRender.test.js +1 -1
  166. package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +4 -4
  167. package/tests/unit/src/components/Carousel/Carousel.test.js +1 -1
  168. package/tests/unit/src/components/DataSummary/DataSummaryFactory.test.js +3 -2
  169. package/tests/unit/src/components/EmailConfirm/EmailConfirm.test.js +2 -1
  170. package/tests/unit/src/components/Image/GlobalLightbox/GlobalLightbox.test.js +10 -6
  171. package/tests/unit/src/components/Image/ImageFactory.test.js +11 -19
  172. package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +34 -1
  173. package/tests/unit/src/components/Image/mocks.js +80 -24
  174. package/tests/unit/src/components/List/ListRender.test.js +2 -1
  175. package/tests/unit/src/components/Login/Login.test.js +2 -1
  176. package/tests/unit/src/components/PasswordReset/PasswordReset.test.js +2 -2
  177. package/tests/unit/src/components/PasswordResetRequest/PasswordResetRequest.test.js +2 -2
  178. package/tests/unit/src/components/SearchFilter/SearchFilterContainer.test.js +2 -1
  179. package/tests/unit/src/components/Video/providers/JWPlayer/JWPlayerProvider.test.js +1 -1
  180. package/tests/unit/src/components/__snapshots__/CarouselWrapper.test.js.snap +12 -12
  181. package/tests/unit/src/helpers/build-props-query.test.js +6 -6
  182. package/tests/unit/src/hooks/use-get-entity-schema-as-obj.test.js +2 -2
  183. package/tests/unit/src/hooks/use-get-image-id-from-relation.test.js +1 -1
  184. package/tests/unit/src/hooks/use-get-images.test.js +4 -14
  185. package/tests/unit/src/hooks/use-get-single-entity-schema.test.js +2 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.118.0-alpha.2",
3
+ "version": "0.119.0-alpha.2",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,12 +27,12 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/core-auth-ui": "^0.118.0-alpha.0",
31
- "@blaze-cms/core-errors": "^0.118.0-alpha.0",
30
+ "@blaze-cms/core-auth-ui": "^0.119.0-alpha.0",
31
+ "@blaze-cms/core-errors": "^0.118.0",
32
32
  "@blaze-cms/image-cdn-react": "^0.2.0",
33
- "@blaze-cms/nextjs-components": "^0.118.0-alpha.0",
33
+ "@blaze-cms/nextjs-components": "^0.119.0-alpha.0",
34
34
  "@blaze-cms/setup-ui": "^0.92.0",
35
- "@blaze-cms/utils": "^0.118.0-alpha.0",
35
+ "@blaze-cms/utils": "^0.118.0",
36
36
  "@blaze-react/button": "0.5.19",
37
37
  "@blaze-react/checkboxes": "0.5.31",
38
38
  "@blaze-react/input": "0.5.30",
@@ -42,7 +42,6 @@
42
42
  "@blaze-react/utils": "0.5.15",
43
43
  "core-js": "^3.2.1",
44
44
  "entities": "^2.0.0",
45
- "graphql-tag": "^2.10.1",
46
45
  "html-react-parser": "^0.10.0",
47
46
  "lodash.at": "^4.6.0",
48
47
  "lodash.camelcase": "^4.3.0",
@@ -63,21 +62,18 @@
63
62
  "video-react": "0.14.1"
64
63
  },
65
64
  "peerDependencies": {
65
+ "@apollo/client": "3.x",
66
66
  "draft-js": "^0.11.7",
67
67
  "draft-js-export-html": "^1.4.1",
68
68
  "draftjs-to-html": "0.9.1",
69
- "graphql-tag": "^2.10.1",
70
- "next": "10.0.5",
69
+ "next": "12.x",
71
70
  "prop-types": "^15.7.2",
72
- "react": "^16.13.1",
73
- "react-apollo": "^3.1.1",
71
+ "react": "^17.0.2",
74
72
  "react-icons": ">= 4.3.1"
75
73
  },
76
74
  "devDependencies": {
77
- "@apollo/react-testing": "^3.1.1",
78
75
  "@testing-library/jest-dom": "^5.11.3",
79
76
  "@testing-library/react": "^10.4.8",
80
- "graphql-tag": "^2.10.1",
81
77
  "jest-next-dynamic": "^1.0.1",
82
78
  "prop-types": "^15.7.2",
83
79
  "webpack": "^5.38.1",
@@ -87,5 +83,5 @@
87
83
  "lib/*",
88
84
  "lib-es/*"
89
85
  ],
90
- "gitHead": "04cc8794eb8f3b5291270ec6cb14d9efd916bc9b"
86
+ "gitHead": "48eacb8ab1011f1c45fdfe51312388e92b9776ba"
91
87
  }
@@ -1,4 +1,4 @@
1
- import gql from 'graphql-tag';
1
+ import { gql } from '@apollo/client';
2
2
  import upperFirst from 'lodash.upperfirst';
3
3
 
4
4
  const defaultSchemaProps = `
@@ -63,8 +63,6 @@ const getFiles = gql`
63
63
  query getFiles($where: JSON!) {
64
64
  getFiles(where: $where) {
65
65
  id
66
- location
67
- mimetype
68
66
  url
69
67
  data
70
68
  }
@@ -75,8 +73,6 @@ const getFileById = gql`
75
73
  query getFile($id: String!) {
76
74
  getFile(id: $id) {
77
75
  id
78
- location
79
- mimetype
80
76
  url
81
77
  data
82
78
  }
@@ -0,0 +1,62 @@
1
+ import React, { useState } from 'react';
2
+ import { AdSlot } from 'react-dfp';
3
+ import PropTypes from 'prop-types';
4
+ import { BANNER_LOADING, BANNER_EMPTY, BANNER_LOADED } from '../../constants';
5
+
6
+ const AdSlotRender = ({
7
+ shouldShowBanner,
8
+ sizeMapping,
9
+ sizeId,
10
+ parsedAdunit,
11
+ parsedSizes,
12
+ targetingArguments
13
+ }) => {
14
+ const [loadingStatus, setLoadingStatus] = useState(BANNER_LOADING);
15
+
16
+ const bannerClass = `banner-${sizeId}`;
17
+
18
+ const styles =
19
+ loadingStatus === BANNER_LOADING &&
20
+ sizeMapping
21
+ .map(({ sizes: styleSizes, viewport: [minWidth] }) => {
22
+ const minHeight = Math.min(...styleSizes.map(([, height]) => height));
23
+ return `@media(min-width:${minWidth}px){.${bannerClass}{min-height:${minHeight}px;}`;
24
+ })
25
+ .sort();
26
+ const className = `ad-slot ad-slot-${loadingStatus} ${bannerClass}`;
27
+
28
+ return (
29
+ <>
30
+ {styles && <style>{styles}</style>}
31
+ <div className={className}>
32
+ {shouldShowBanner && (
33
+ <AdSlot
34
+ adUnit={parsedAdunit}
35
+ sizes={parsedSizes}
36
+ targetingArguments={targetingArguments}
37
+ sizeMapping={sizeMapping}
38
+ onSlotRender={({ event: { isEmpty } }) => {
39
+ const newLoadingStatus = isEmpty ? BANNER_EMPTY : BANNER_LOADED;
40
+ setLoadingStatus(newLoadingStatus);
41
+ }}
42
+ />
43
+ )}
44
+ </div>
45
+ </>
46
+ );
47
+ };
48
+
49
+ AdSlotRender.propTypes = {
50
+ shouldShowBanner: PropTypes.bool.isRequired,
51
+ sizeMapping: PropTypes.array.isRequired,
52
+ sizeId: PropTypes.string.isRequired,
53
+ parsedAdunit: PropTypes.string.isRequired,
54
+ parsedSizes: PropTypes.array,
55
+ targetingArguments: PropTypes.object.isRequired
56
+ };
57
+
58
+ AdSlotRender.defaultProps = {
59
+ parsedSizes: null
60
+ };
61
+
62
+ export default AdSlotRender;
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
2
2
  import { MainContext } from '@blaze-cms/nextjs-components';
3
3
  import PropTypes from 'prop-types';
4
4
  import flatten from 'lodash.flatten';
5
- import { useQuery } from '@apollo/react-hooks';
5
+ import { useQuery } from '@apollo/client';
6
6
  import { useRouter } from 'next/router';
7
7
  import { getSingleEntitySchema } from '../../application/query';
8
8
  import Wrapper from '../Wrapper';
@@ -1,15 +1,14 @@
1
- import { AdSlot } from 'react-dfp';
2
- import PropTypes from 'prop-types';
3
1
  import React from 'react';
4
- import { useQuery } from 'react-apollo';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { useQuery } from '@apollo/client';
5
+
5
6
  import { generateSingleItemQuery, getCount } from '../../application/query';
6
7
  import {
7
8
  buildBannerSizes,
8
9
  buildContextualTargeting,
9
10
  buildParsedAdunit,
10
11
  buildSizeMapping,
11
- getMaxBannerHeight,
12
- getMinBannerHeight,
13
12
  setCustomTargetings
14
13
  } from './helpers';
15
14
  import {
@@ -19,6 +18,7 @@ import {
19
18
  PUBLISHED
20
19
  } from '../../constants';
21
20
  import { withTitle } from '../../HOC';
21
+ import AdSlotRender from './AdSlotRender';
22
22
 
23
23
  const BannerRender = ({
24
24
  baseAdunit,
@@ -43,8 +43,6 @@ const BannerRender = ({
43
43
  skip: id && id !== itemId
44
44
  });
45
45
 
46
- const parsedTargetings = buildContextualTargeting(actionKey, entityRecordData, propsToDisplay);
47
-
48
46
  const { data: bannerData = {} } = useQuery(
49
47
  generateSingleItemQuery(GET_BANNER, BANNER_QUERY_PROPS),
50
48
  {
@@ -52,13 +50,6 @@ const BannerRender = ({
52
50
  skip: !sizeId
53
51
  }
54
52
  );
55
- const { entityData } = bannerData;
56
- const { sizes: bannerSizes } = entityData || {};
57
-
58
- const sizeMapping = buildSizeMapping(sizeId, bannerSizes);
59
- const parsedSizes = buildBannerSizes(sizeId, bannerSizes, sizes);
60
- const maxBannerHeight = getMaxBannerHeight(bannerSizes);
61
- const minBannerHeight = getMinBannerHeight(bannerSizes);
62
53
 
63
54
  const { data = {} } = useQuery(getCount(COUNT_CONTENT_HIERARCHIES), {
64
55
  variables: {
@@ -71,6 +62,14 @@ const BannerRender = ({
71
62
  }
72
63
  });
73
64
 
65
+ const parsedTargetings = buildContextualTargeting(actionKey, entityRecordData, propsToDisplay);
66
+
67
+ const { entityData } = bannerData;
68
+ const { sizes: bannerSizes } = entityData || {};
69
+
70
+ const sizeMapping = buildSizeMapping(sizeId, bannerSizes);
71
+ const parsedSizes = buildBannerSizes(sizeId, bannerSizes, sizes);
72
+
74
73
  const { countContentHierarchies } = data;
75
74
 
76
75
  const parsedAdunit = buildParsedAdunit(asPath, countContentHierarchies, baseAdunit, adunit);
@@ -80,23 +79,19 @@ const BannerRender = ({
80
79
  const shouldShowBanner =
81
80
  parsedAdunit && parsedSizes && !!parsedSizes.length && isContextualTargetingReady;
82
81
 
83
- if (!shouldShowBanner) return null;
84
82
  const customTargetings = setCustomTargetings(targetings, cardBannerIndex);
85
- const style = {
86
- maxHeight: maxBannerHeight,
87
- minHeight: minBannerHeight
88
- };
83
+
89
84
  const targetingArguments = { ...parsedTargetings, ...customTargetings };
90
85
 
91
86
  return (
92
- <div className="ad-slot" style={style}>
93
- <AdSlot
94
- adUnit={parsedAdunit}
95
- sizes={parsedSizes}
96
- targetingArguments={targetingArguments}
97
- sizeMapping={sizeMapping}
98
- />
99
- </div>
87
+ <AdSlotRender
88
+ shouldShowBanner={!!shouldShowBanner}
89
+ sizeMapping={sizeMapping}
90
+ sizeId={sizeId}
91
+ parsedAdunit={parsedAdunit}
92
+ parsedSizes={parsedSizes}
93
+ targetingArguments={targetingArguments}
94
+ />
100
95
  );
101
96
  };
102
97
 
@@ -3,7 +3,7 @@ import { useCookies } from 'react-cookie';
3
3
  import { useRouter } from 'next/router';
4
4
  import BlazeButton from '@blaze-react/button';
5
5
  import { handleLogout } from '@blaze-cms/core-auth-ui';
6
- import { useApolloClient } from 'react-apollo';
6
+ import { useApolloClient } from '@apollo/client';
7
7
  import PropTypes from 'prop-types';
8
8
  import ClickWrapper from './ClickWrapper';
9
9
  import BlazeLink from './BlazeLink';
@@ -28,6 +28,8 @@ const CardContainer = ({
28
28
  enableCarousel,
29
29
  bannerModifier,
30
30
  priorityLimit,
31
+ enableAutoScroll,
32
+ autoScrollTimer,
31
33
  ...cardProps
32
34
  }) => {
33
35
  const entities = getEntitiesWithBanner(cardData, cardProps);
@@ -44,7 +46,9 @@ const CardContainer = ({
44
46
  className={dynamicWrapperSizes}
45
47
  modifiers={gridModifier}
46
48
  itemsPerRow={itemsPerRow}
47
- bannerModifier={bannerModifier}>
49
+ bannerModifier={bannerModifier}
50
+ enableAutoScroll={enableAutoScroll}
51
+ autoScrollTimer={autoScrollTimer}>
48
52
  {entities.map(({ baseAdunit, id, ...entityProps }, index) => {
49
53
  const extraProps = parsePropsToDisplay(entityProps, propsToDisplay);
50
54
  const dynamicKey = [itemId, index].join('-');
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useQuery } from '@apollo/react-hooks';
2
+ import { useQuery } from '@apollo/client';
3
3
  import PropTypes from 'prop-types';
4
4
  import { getSingleEntitySchema } from '../../application/query';
5
5
  import CardRender from './CardRender';
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { useQuery } from 'react-apollo';
2
+ import { useQuery } from '@apollo/client';
3
3
  import dynamic from 'next/dynamic';
4
4
  import PropTypes from 'prop-types';
5
5
  import { MainContext } from '@blaze-cms/nextjs-components';
@@ -1,4 +1,4 @@
1
- import { getStringTypeProps } from '@blaze-cms/utils';
1
+ import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';
2
2
  import { getGenericRenderVariables, buildRawQueryBase, buildSetFilters } from '../../../helpers';
3
3
  import { DEFAULT_LIMIT } from '../../../constants';
4
4
 
@@ -2,17 +2,46 @@ import React, { useRef, useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { FaAngleLeft, FaAngleRight } from 'react-icons/fa';
4
4
 
5
- const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
5
+ const CarouselWrapper = ({
6
+ children,
7
+ bannerModifier,
8
+ itemsPerRow,
9
+ enableAutoScroll,
10
+ autoScrollTimer
11
+ }) => {
6
12
  const ref = useRef();
7
13
  const [buttonDisplay, setButtonDisplays] = useState({ displayLeft: false, displayRight: true });
14
+ const [shouldAutoScroll, setShouldAutoScroll] = useState(false);
15
+ const autoScrollRef = useRef();
8
16
 
9
- useEffect(() => {
10
- const {
11
- current: { offsetWidth, scrollWidth }
12
- } = ref;
17
+ useEffect(
18
+ () => {
19
+ autoScrollRef.current = shouldAutoScroll;
20
+ const id = setInterval(scrollCheck, autoScrollTimer);
21
+ function scrollCheck() {
22
+ if (!autoScrollRef.current) {
23
+ clearInterval(id);
24
+ } else {
25
+ handleButtonNavigation(true);
26
+ }
27
+ }
13
28
 
14
- if (scrollWidth <= offsetWidth) setButtonDisplays({ displayLeft: false, displayRight: false });
15
- }, []);
29
+ return () => clearInterval(id);
30
+ },
31
+ [autoScrollTimer, shouldAutoScroll]
32
+ );
33
+
34
+ useEffect(
35
+ () => {
36
+ const {
37
+ current: { offsetWidth, scrollWidth }
38
+ } = ref;
39
+ if (scrollWidth <= offsetWidth)
40
+ setButtonDisplays({ displayLeft: false, displayRight: false });
41
+ setShouldAutoScroll(enableAutoScroll);
42
+ },
43
+ [enableAutoScroll]
44
+ );
16
45
 
17
46
  const handleScroll = () => {
18
47
  const {
@@ -24,36 +53,48 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
24
53
  };
25
54
 
26
55
  const handleButtonNavigation = direction => {
56
+ if (!ref || !ref.current) return;
27
57
  const {
28
- current: { offsetWidth, scrollLeft }
58
+ current: { offsetWidth, scrollLeft, scrollWidth }
29
59
  } = ref;
30
- ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;
60
+
61
+ if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {
62
+ ref.current.scrollLeft = 0;
63
+ } else {
64
+ ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;
65
+ }
31
66
  };
32
67
 
33
68
  const { displayLeft, displayRight } = buttonDisplay;
34
- const wrapperClassName = `card-carousel relative gap-2${bannerModifier}`;
35
- const contentClassName = `card-carousel__content card-carousel__content--items-per-row-${itemsPerRow} flex flex-nowrap p-4 gap-4 overflow-x-scroll`;
69
+ const wrapperClassName = `cards-carousel${bannerModifier}`;
70
+ const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;
36
71
 
37
72
  return (
38
73
  <div className={wrapperClassName}>
39
- <div className="card-carousel__button-wrapper absolute left-0 h-full flex justify-center items-center z-10">
74
+ <div className="cards-carousel--left-button-wrapper">
40
75
  {displayLeft && (
41
76
  <button
42
77
  type="button"
43
- className="card-carousel__button-back icon-button"
44
- onClick={() => handleButtonNavigation()}>
78
+ className="cards-carousel--button-back icon-button icon"
79
+ onClick={() => {
80
+ setShouldAutoScroll(false);
81
+ handleButtonNavigation();
82
+ }}>
45
83
  <i>
46
84
  <FaAngleLeft />
47
85
  </i>
48
86
  </button>
49
87
  )}
50
88
  </div>
51
- <div className="card-carousel__button-wrapper absolute right-0 h-full flex justify-center items-center z-10">
89
+ <div className="cards-carousel--right-button-wrapper">
52
90
  {displayRight && (
53
91
  <button
54
92
  type="button"
55
- className="card-carousel__button-forward icon-button icon"
56
- onClick={() => handleButtonNavigation(true)}>
93
+ className="cards-carousel--button-forward icon-button icon"
94
+ onClick={() => {
95
+ setShouldAutoScroll(false);
96
+ handleButtonNavigation(true);
97
+ }}>
57
98
  <i>
58
99
  <FaAngleRight />
59
100
  </i>
@@ -70,13 +111,17 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
70
111
  CarouselWrapper.propTypes = {
71
112
  bannerModifier: PropTypes.string,
72
113
  itemsPerRow: PropTypes.number,
73
- children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
114
+ children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
115
+ enableAutoScroll: PropTypes.bool,
116
+ autoScrollTimer: PropTypes.number
74
117
  };
75
118
 
76
119
  CarouselWrapper.defaultProps = {
77
120
  itemsPerRow: 0,
78
121
  bannerModifier: '',
79
- children: []
122
+ children: [],
123
+ enableAutoScroll: false,
124
+ autoScrollTimer: 0
80
125
  };
81
126
 
82
127
  export default CarouselWrapper;
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { useQuery } from '@apollo/react-hooks';
2
+ import { useQuery } from '@apollo/client';
3
3
  import PropTypes from 'prop-types';
4
4
  import { MainContext } from '@blaze-cms/nextjs-components';
5
5
  import { getSingleEntitySchema } from '../../application/query';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useQuery } from '@apollo/react-hooks';
2
+ import { useQuery } from '@apollo/client';
3
3
  import PropTypes from 'prop-types';
4
4
  import { summaryComponents } from './DataSummaryTypes';
5
5
  import { getClassModifiers } from '../../utils';
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { useMutation } from 'react-apollo';
3
+ import { useMutation } from '@apollo/client';
4
4
  import { useRouter } from 'next/router';
5
5
  import { parseUrl } from 'query-string';
6
6
  import EMAIL_CONFIRM_MUTATION from './mutation';
@@ -1,4 +1,4 @@
1
- import gql from 'graphql-tag';
1
+ import { gql } from '@apollo/client';
2
2
 
3
3
  const EMAIL_CONFIRM_MUTATION = gql`
4
4
  mutation confirmUserEmail($token: String!) {
@@ -17,7 +17,7 @@ const ImageFactory = props => {
17
17
  const isUsingRelationImage = checkIfUsingRelationImage(entity, fetchFromRelation, imageRelation);
18
18
  const { data: { getEntitySchema = {} } = {} } = useGetSingleEntitySchema(entity, !entity);
19
19
  const { actions = {} } = getEntitySchema;
20
- const { data: relationData } = useGetImageIdFromRelation(
20
+ const { data: relationData, loading: relationLoading } = useGetImageIdFromRelation(
21
21
  itemId,
22
22
  imageRelation,
23
23
  actions,
@@ -25,16 +25,19 @@ const ImageFactory = props => {
25
25
  isPreview
26
26
  );
27
27
 
28
- const updatedImageIds = getImageIds(imageRelation, relationData, imageId);
29
-
30
- const { data: { getFiles: files = [] } = {}, loading, error } = useGetImages(
31
- updatedImageIds,
32
- true
28
+ const updatedImageIds = relationLoading
29
+ ? null
30
+ : getImageIds(imageRelation, relationData, imageId);
31
+ const imageIds =
32
+ updatedImageIds && updatedImageIds.length === 1 ? updatedImageIds[0] : updatedImageIds;
33
+ const { data: { getFile, getFiles = [] } = {}, loading, error } = useGetImages(
34
+ imageIds,
35
+ updatedImageIds && updatedImageIds.length > 1
33
36
  );
34
-
35
37
  if (error) return error.message;
36
38
  if (loading) return '';
37
39
 
40
+ const files = getFile ? [getFile] : getFiles;
38
41
  return files.map(({ id, data: imageData = {}, url: imageUrl = '' }) => {
39
42
  if (!imageUrl) return null;
40
43
  return <Image key={id} {...props} imageData={imageData} imageUrl={imageUrl} />;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { useQuery } from '@apollo/react-hooks';
4
- import { getStringTypeProps } from '@blaze-cms/utils';
3
+ import { useQuery } from '@apollo/client';
4
+ import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';
5
5
  import {
6
6
  CardRenderWithInfiniteScroll,
7
7
  CardsRender,
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { useQuery } from '@apollo/react-hooks';
2
+ import { useQuery } from '@apollo/client';
3
3
  import { parseUrl } from 'query-string';
4
4
  import PropTypes from 'prop-types';
5
5
  import { useRouter } from 'next/router';
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { useQuery } from '@apollo/react-hooks';
2
+ import { useQuery } from '@apollo/client';
3
3
  import PropTypes from 'prop-types';
4
4
  import ListPagination from './components/Pagination';
5
5
  import ListHeader from './components/Header';
@@ -17,7 +17,7 @@ const LoggedInMessage = ({ goToUrl, urlToUse }) => (
17
17
  );
18
18
 
19
19
  LoggedInMessage.propTypes = {
20
- goToUrl: PropTypes.string.isRequired,
20
+ goToUrl: PropTypes.func.isRequired,
21
21
  urlToUse: PropTypes.string.isRequired
22
22
  };
23
23
 
@@ -1,7 +1,7 @@
1
1
  import React, { useState } from 'react';
2
2
  import { handleLogin, checkIfLoggedIn, LOGIN_MUTATION } from '@blaze-cms/core-auth-ui';
3
3
  import PropTypes from 'prop-types';
4
- import { useMutation } from 'react-apollo';
4
+ import { useMutation } from '@apollo/client';
5
5
  import { useRouter } from 'next/router';
6
6
  import { parseUrl } from 'query-string';
7
7
  import LoggedInMessage from './LoggedInMessage';
@@ -1,42 +1,80 @@
1
1
  import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import BlazeButton from '@blaze-react/button';
4
- import { MdMenu } from 'react-icons/md';
4
+ import { MdMenu, MdClose } from 'react-icons/md';
5
5
  import { useCheckMobileScreen } from '../../hooks';
6
6
  import { HIDDEN } from '../../constants';
7
7
 
8
- const Menu = ({ children, collapse, modifier }) => {
8
+ const Menu = ({
9
+ children,
10
+ collapse,
11
+ modifier,
12
+ mobileMenuModifier,
13
+ mobileMenuChildrenModifier,
14
+ mobileIconAlignment,
15
+ mobileButtonModifier,
16
+ hamburgerIconModifier,
17
+ closeIconModifier,
18
+ ...rest
19
+ }) => {
9
20
  const isMobile = useCheckMobileScreen();
10
21
  const [showMobileMenu, setShowMobileMenu] = useState(false);
11
22
 
12
23
  const shouldDisplayCollapsed = collapse && isMobile;
13
- const mobileButtonClass = shouldDisplayCollapsed && isMobile ? '' : HIDDEN;
24
+ const mobileButtonClass = shouldDisplayCollapsed && isMobile ? mobileButtonModifier : HIDDEN;
14
25
  const shouldDisplayChildren = shouldDisplayCollapsed ? showMobileMenu : true;
15
- const childrenDisplayClass = shouldDisplayChildren ? modifier : `${modifier} ${HIDDEN}`;
26
+ const childrenDesktopModifier =
27
+ shouldDisplayChildren && !isMobile ? modifier : `${modifier} ${HIDDEN}`;
28
+
29
+ const childrenMobileModifier =
30
+ shouldDisplayChildren && isMobile ? `${mobileMenuChildrenModifier}` : ` ${HIDDEN}`;
31
+
32
+ const isMobileMenuExpanded = showMobileMenu ? `${mobileMenuModifier}` : '';
16
33
 
17
34
  return (
18
35
  <>
19
36
  {collapse && (
20
- <BlazeButton
21
- className={mobileButtonClass}
22
- onClick={() => setShowMobileMenu(!showMobileMenu)}>
23
- <i>
24
- <MdMenu />
25
- </i>
26
- </BlazeButton>
37
+ <div className="top-0 absolute z-50">
38
+ <div
39
+ className={`flex w-screen z-50 justify-${mobileIconAlignment} ${isMobileMenuExpanded}`}>
40
+ <BlazeButton
41
+ className={mobileButtonClass}
42
+ onClick={() => setShowMobileMenu(!showMobileMenu)}>
43
+ <i>
44
+ {showMobileMenu ? (
45
+ <MdClose className={closeIconModifier} />
46
+ ) : (
47
+ <MdMenu className={hamburgerIconModifier} />
48
+ )}
49
+ </i>
50
+ </BlazeButton>
51
+ </div>
52
+ </div>
27
53
  )}
28
- <ul className={childrenDisplayClass}>{children}</ul>
54
+ <ul className={isMobile ? childrenMobileModifier : childrenDesktopModifier}>{children}</ul>
29
55
  </>
30
56
  );
31
57
  };
32
58
 
33
59
  Menu.propTypes = {
34
60
  collapse: PropTypes.bool.isRequired,
61
+ hamburgerIconModifier: PropTypes.string,
62
+ closeIconModifier: PropTypes.string,
63
+ mobileButtonModifier: PropTypes.string,
64
+ mobileMenuModifier: PropTypes.string,
65
+ mobileMenuChildrenModifier: PropTypes.string,
35
66
  modifier: PropTypes.string,
67
+ mobileIconAlignment: PropTypes.string,
36
68
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
37
69
  };
38
70
 
39
71
  Menu.defaultProps = {
72
+ hamburgerIconModifier: '',
73
+ closeIconModifier: '',
74
+ mobileButtonModifier: '',
75
+ mobileIconAlignment: '',
76
+ mobileMenuModifier: '',
77
+ mobileMenuChildrenModifier: '',
40
78
  modifier: '',
41
79
  children: []
42
80
  };
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import Input from '@blaze-react/input';
4
4
  import Button from '@blaze-react/button';
5
- import { useMutation } from 'react-apollo';
5
+ import { useMutation } from '@apollo/client';
6
6
  import { useRouter } from 'next/router';
7
7
  import { parseUrl } from 'query-string';
8
8
  import { RESET_USER_PASSWORD_MUTATION } from '@blaze-cms/core-auth-ui';