@blaze-cms/react-page-builder 0.125.0-f-admin-updates.5 → 0.126.0-admin-updates.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 (185) hide show
  1. package/CHANGELOG.md +70 -3
  2. package/README.md +14 -4
  3. package/example.env +1 -0
  4. package/lib/components/Button.js +14 -5
  5. package/lib/components/Button.js.map +1 -1
  6. package/lib/components/Card/Card.js +53 -25
  7. package/lib/components/Card/Card.js.map +1 -1
  8. package/lib/components/Card/CardContainer.js +2 -1
  9. package/lib/components/Card/CardContainer.js.map +1 -1
  10. package/lib/components/Card/constants.js +3 -1
  11. package/lib/components/Card/constants.js.map +1 -1
  12. package/lib/components/ContentGroup/ContentGroup.js +29 -0
  13. package/lib/components/ContentGroup/ContentGroup.js.map +1 -0
  14. package/lib/components/ContentGroup/ContentGroupTabs.js +94 -0
  15. package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -0
  16. package/lib/components/{Login → ContentGroup}/index.js +2 -2
  17. package/lib/components/ContentGroup/index.js.map +1 -0
  18. package/lib/components/ContentGroupSection/ContentGroupSection.js +30 -0
  19. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -0
  20. package/lib/components/{PasswordReset → ContentGroupSection}/index.js +2 -2
  21. package/lib/components/ContentGroupSection/index.js.map +1 -0
  22. package/lib/components/List/ListRender.js.map +1 -1
  23. package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
  24. package/lib/components/List/components/Cards/CardsRenderItem.js +2 -1
  25. package/lib/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  26. package/lib/components/Video/providers/Vimeo/VimeoProvider.js +100 -21
  27. package/lib/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
  28. package/lib/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +34 -0
  29. package/lib/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js.map +1 -0
  30. package/lib/components/{PasswordReset → Video/providers/Vimeo}/helpers/index.js +3 -3
  31. package/lib/components/Video/providers/Vimeo/helpers/index.js.map +1 -0
  32. package/lib/components/index.js +10 -15
  33. package/lib/components/index.js.map +1 -1
  34. package/lib/constants/index.js +4 -14
  35. package/lib/constants/index.js.map +1 -1
  36. package/lib/helpers/build-search-values-text.js +11 -1
  37. package/lib/helpers/build-search-values-text.js.map +1 -1
  38. package/lib/hooks/helpers/get-banners-by-type.js +1 -1
  39. package/lib/hooks/helpers/get-banners-by-type.js.map +1 -1
  40. package/lib/index.js +6 -0
  41. package/lib/index.js.map +1 -1
  42. package/lib-es/components/Button.js +13 -6
  43. package/lib-es/components/Button.js.map +1 -1
  44. package/lib-es/components/Card/Card.js +34 -8
  45. package/lib-es/components/Card/Card.js.map +1 -1
  46. package/lib-es/components/Card/CardContainer.js +2 -1
  47. package/lib-es/components/Card/CardContainer.js.map +1 -1
  48. package/lib-es/components/Card/constants.js +2 -1
  49. package/lib-es/components/Card/constants.js.map +1 -1
  50. package/lib-es/components/ContentGroup/ContentGroup.js +22 -0
  51. package/lib-es/components/ContentGroup/ContentGroup.js.map +1 -0
  52. package/lib-es/components/ContentGroup/ContentGroupTabs.js +72 -0
  53. package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -0
  54. package/lib-es/components/ContentGroup/index.js +3 -0
  55. package/lib-es/components/ContentGroup/index.js.map +1 -0
  56. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +23 -0
  57. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -0
  58. package/lib-es/components/ContentGroupSection/index.js +3 -0
  59. package/lib-es/components/ContentGroupSection/index.js.map +1 -0
  60. package/lib-es/components/List/ListRender.js.map +1 -1
  61. package/lib-es/components/List/components/Cards/CardsRender.js.map +1 -1
  62. package/lib-es/components/List/components/Cards/CardsRenderItem.js +2 -1
  63. package/lib-es/components/List/components/Cards/CardsRenderItem.js.map +1 -1
  64. package/lib-es/components/Video/providers/Vimeo/VimeoProvider.js +50 -21
  65. package/lib-es/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
  66. package/lib-es/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +14 -0
  67. package/lib-es/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js.map +1 -0
  68. package/lib-es/components/Video/providers/Vimeo/helpers/index.js +3 -0
  69. package/lib-es/components/Video/providers/Vimeo/helpers/index.js.map +1 -0
  70. package/lib-es/components/index.js +3 -4
  71. package/lib-es/components/index.js.map +1 -1
  72. package/lib-es/constants/index.js +2 -7
  73. package/lib-es/constants/index.js.map +1 -1
  74. package/lib-es/helpers/build-search-values-text.js +11 -1
  75. package/lib-es/helpers/build-search-values-text.js.map +1 -1
  76. package/lib-es/hooks/helpers/get-banners-by-type.js +1 -1
  77. package/lib-es/hooks/helpers/get-banners-by-type.js.map +1 -1
  78. package/lib-es/index.js +1 -1
  79. package/lib-es/index.js.map +1 -1
  80. package/package.json +7 -6
  81. package/src/components/Button.js +11 -4
  82. package/src/components/Card/Card.js +37 -5
  83. package/src/components/Card/CardContainer.js +2 -1
  84. package/src/components/Card/constants.js +2 -1
  85. package/src/components/ContentGroup/ContentGroup.js +17 -0
  86. package/src/components/ContentGroup/ContentGroupTabs.js +74 -0
  87. package/src/components/ContentGroup/index.js +3 -0
  88. package/src/components/ContentGroupSection/ContentGroupSection.js +17 -0
  89. package/src/components/ContentGroupSection/index.js +3 -0
  90. package/src/components/List/ListRender.js +0 -1
  91. package/src/components/List/components/Cards/CardsRender.js +1 -0
  92. package/src/components/List/components/Cards/CardsRenderItem.js +2 -1
  93. package/src/components/Video/providers/Vimeo/VimeoProvider.js +56 -15
  94. package/src/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.js +15 -0
  95. package/src/components/Video/providers/Vimeo/helpers/index.js +3 -0
  96. package/src/components/index.js +8 -8
  97. package/src/constants/index.js +3 -14
  98. package/src/helpers/build-search-values-text.js +12 -1
  99. package/src/hooks/helpers/get-banners-by-type.js +1 -1
  100. package/src/index.js +1 -1
  101. package/tests/unit/src/components/Button.test.js +7 -0
  102. package/tests/unit/src/components/Card/Card.test.js +18 -7
  103. package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +5 -0
  104. package/tests/unit/src/components/ContentGroup/ContentGroup.test.js +13 -0
  105. package/tests/unit/src/components/ContentGroup/ContentGroupTabs.test.js +16 -0
  106. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroup.test.js.snap +5 -0
  107. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +5 -0
  108. package/tests/unit/src/components/ContentGroupSection/ContentGroupSection.test.js +17 -0
  109. package/tests/unit/src/components/ContentGroupSection/__snapshots__/ContentGroupSection.test.js.snap +15 -0
  110. package/tests/unit/src/components/Video/providers/Vimeo/{Vimeo.js → Vimeo.test.js} +1 -3
  111. package/tests/unit/src/components/Video/providers/Vimeo/__snapshots__/Vimeo.test.js.snap +10 -0
  112. package/tests/unit/src/components/Video/providers/Vimeo/helpers/add-extra-params-to-url.test.js +24 -0
  113. package/tests/unit/src/components/__snapshots__/index.test.js.snap +8 -12
  114. package/tests/unit/src/helpers/build-search-values-text.test.js +2 -5
  115. package/lib/components/Login/LoggedInMessage.js +0 -28
  116. package/lib/components/Login/LoggedInMessage.js.map +0 -1
  117. package/lib/components/Login/Login.js +0 -135
  118. package/lib/components/Login/Login.js.map +0 -1
  119. package/lib/components/Login/LoginForm.js +0 -112
  120. package/lib/components/Login/LoginForm.js.map +0 -1
  121. package/lib/components/Login/helpers/check-gtm-children.js +0 -42
  122. package/lib/components/Login/helpers/check-gtm-children.js.map +0 -1
  123. package/lib/components/Login/helpers/get-url-to-use.js +0 -18
  124. package/lib/components/Login/helpers/get-url-to-use.js.map +0 -1
  125. package/lib/components/Login/helpers/index.js +0 -22
  126. package/lib/components/Login/helpers/index.js.map +0 -1
  127. package/lib/components/Login/index.js.map +0 -1
  128. package/lib/components/PasswordReset/PasswordReset.js +0 -172
  129. package/lib/components/PasswordReset/PasswordReset.js.map +0 -1
  130. package/lib/components/PasswordReset/helpers/index.js.map +0 -1
  131. package/lib/components/PasswordReset/helpers/validatePassword.js +0 -16
  132. package/lib/components/PasswordReset/helpers/validatePassword.js.map +0 -1
  133. package/lib/components/PasswordReset/index.js.map +0 -1
  134. package/lib/components/PasswordResetRequest/PasswordResetRequest.js +0 -114
  135. package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +0 -1
  136. package/lib/components/PasswordResetRequest/index.js +0 -12
  137. package/lib/components/PasswordResetRequest/index.js.map +0 -1
  138. package/lib-es/components/Login/LoggedInMessage.js +0 -18
  139. package/lib-es/components/Login/LoggedInMessage.js.map +0 -1
  140. package/lib-es/components/Login/Login.js +0 -83
  141. package/lib-es/components/Login/Login.js.map +0 -1
  142. package/lib-es/components/Login/LoginForm.js +0 -89
  143. package/lib-es/components/Login/LoginForm.js.map +0 -1
  144. package/lib-es/components/Login/helpers/check-gtm-children.js +0 -35
  145. package/lib-es/components/Login/helpers/check-gtm-children.js.map +0 -1
  146. package/lib-es/components/Login/helpers/get-url-to-use.js +0 -10
  147. package/lib-es/components/Login/helpers/get-url-to-use.js.map +0 -1
  148. package/lib-es/components/Login/helpers/index.js +0 -4
  149. package/lib-es/components/Login/helpers/index.js.map +0 -1
  150. package/lib-es/components/Login/index.js +0 -3
  151. package/lib-es/components/Login/index.js.map +0 -1
  152. package/lib-es/components/PasswordReset/PasswordReset.js +0 -144
  153. package/lib-es/components/PasswordReset/PasswordReset.js.map +0 -1
  154. package/lib-es/components/PasswordReset/helpers/index.js +0 -3
  155. package/lib-es/components/PasswordReset/helpers/index.js.map +0 -1
  156. package/lib-es/components/PasswordReset/helpers/validatePassword.js +0 -7
  157. package/lib-es/components/PasswordReset/helpers/validatePassword.js.map +0 -1
  158. package/lib-es/components/PasswordReset/index.js +0 -3
  159. package/lib-es/components/PasswordReset/index.js.map +0 -1
  160. package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js +0 -92
  161. package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js.map +0 -1
  162. package/lib-es/components/PasswordResetRequest/index.js +0 -3
  163. package/lib-es/components/PasswordResetRequest/index.js.map +0 -1
  164. package/src/components/Login/LoggedInMessage.js +0 -24
  165. package/src/components/Login/Login.js +0 -74
  166. package/src/components/Login/LoginForm.js +0 -81
  167. package/src/components/Login/helpers/check-gtm-children.js +0 -30
  168. package/src/components/Login/helpers/get-url-to-use.js +0 -6
  169. package/src/components/Login/helpers/index.js +0 -4
  170. package/src/components/Login/index.js +0 -3
  171. package/src/components/PasswordReset/PasswordReset.js +0 -120
  172. package/src/components/PasswordReset/helpers/index.js +0 -3
  173. package/src/components/PasswordReset/helpers/validatePassword.js +0 -8
  174. package/src/components/PasswordReset/index.js +0 -3
  175. package/src/components/PasswordResetRequest/PasswordResetRequest.js +0 -82
  176. package/src/components/PasswordResetRequest/index.js +0 -3
  177. package/tests/unit/src/components/Login/Login.test.js +0 -36
  178. package/tests/unit/src/components/Login/__snapshots__/Login.test.js.snap +0 -103
  179. package/tests/unit/src/components/Login/helpers/check-gtm-children.test.js +0 -60
  180. package/tests/unit/src/components/Login/helpers/get-url-to-use.test.js +0 -15
  181. package/tests/unit/src/components/PasswordReset/PasswordReset.test.js +0 -85
  182. package/tests/unit/src/components/PasswordReset/__snapshots__/PasswordReset.test.js.snap +0 -83
  183. package/tests/unit/src/components/PasswordReset/helpers/validatePassword.test.js +0 -21
  184. package/tests/unit/src/components/PasswordResetRequest/PasswordResetRequest.test.js +0 -79
  185. package/tests/unit/src/components/PasswordResetRequest/__snapshots__/PasswordResetRequest.test.js.snap +0 -39
@@ -66,7 +66,8 @@ const CardsRenderItem = ({
66
66
  id={id}
67
67
  entity={entity}
68
68
  gridModifier={gridModifier}
69
- propsToDisplay={parsedPropsToDisplay}
69
+ propsToDisplay={propsToDisplay}
70
+ parsedPropsToDisplay={parsedPropsToDisplay}
70
71
  propsToDisplayModifiers={propsToDisplayModifiers}
71
72
  modifier={modifier}
72
73
  style={style}
@@ -1,20 +1,59 @@
1
- import React from 'react';
1
+ import React, { useEffect, useState, useRef } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import ReactPlayer from 'react-player';
3
+ import parseHTML from 'html-react-parser';
4
+ import { addExtraParamsToUrl } from './helpers';
5
+ import { wrapScriptTags } from '../../../Code/helpers';
4
6
  import { VIDEO_WRAPPER_CLASS_NAME } from '../../../../constants';
5
7
 
6
- const VimeoProvider = ({ url, autoplay, loop }) => {
7
- if (!url) return null;
8
+ const VimeoProvider = ({ url, autoplay, loop, imageData }) => {
9
+ const inputEl = useRef(null);
10
+ const [videoData, setVideoData] = useState(null);
11
+ const [videoError, setVideoError] = useState(null);
12
+ const [shouldRenderVideo, setShouldRenderVideo] = useState(!!autoplay);
13
+
14
+ useEffect(
15
+ () => {
16
+ async function fetchVideoData(videoUrl) {
17
+ try {
18
+ const res = await fetch(videoUrl);
19
+ const data = await res.json();
20
+ setVideoData(data);
21
+ } catch (err) {
22
+ setVideoError(err);
23
+ }
24
+ }
25
+ if (url) {
26
+ const currentHeight = inputEl.current.clientHeight;
27
+ const urlWithParams = addExtraParamsToUrl(url, {
28
+ autoplay: true,
29
+ loop,
30
+ height: currentHeight
31
+ });
32
+ fetchVideoData(urlWithParams);
33
+ }
34
+ },
35
+ [autoplay, loop, url]
36
+ );
37
+
38
+ const { thumbnail_url_with_play_button: thumbnailUrl, html = '' } = videoData || {};
39
+ const imageUrl = imageData && imageData.url;
40
+ const backgroundUrl = imageUrl || thumbnailUrl;
41
+ const videoStyle = {};
42
+ if (!shouldRenderVideo && backgroundUrl)
43
+ videoStyle.backgroundImage = `url(${!shouldRenderVideo ? backgroundUrl : ''})`;
44
+ if (inputEl && inputEl.current) videoStyle.maxheight = inputEl.current.clientHeight;
45
+ const parsedCode = parseHTML(html);
46
+ const wrappedCode = wrapScriptTags(parsedCode);
47
+
8
48
  return (
9
- <div className={VIDEO_WRAPPER_CLASS_NAME}>
10
- <ReactPlayer
11
- url={url}
12
- config={{
13
- vimeo: {
14
- playerOptions: { autoplay: { autoplay }, loop: { loop } }
15
- }
16
- }}
17
- />
49
+ <div
50
+ ref={inputEl}
51
+ role="button"
52
+ className={VIDEO_WRAPPER_CLASS_NAME}
53
+ style={videoStyle}
54
+ onClick={() => !shouldRenderVideo && setShouldRenderVideo(true)}>
55
+ {shouldRenderVideo && !videoError && wrappedCode}
56
+ {videoError && videoError.message}
18
57
  </div>
19
58
  );
20
59
  };
@@ -22,12 +61,14 @@ const VimeoProvider = ({ url, autoplay, loop }) => {
22
61
  VimeoProvider.propTypes = {
23
62
  url: PropTypes.string.isRequired,
24
63
  autoplay: PropTypes.bool,
25
- loop: PropTypes.bool
64
+ loop: PropTypes.bool,
65
+ imageData: PropTypes.object
26
66
  };
27
67
 
28
68
  VimeoProvider.defaultProps = {
29
69
  autoplay: false,
30
- loop: false
70
+ loop: false,
71
+ imageData: null
31
72
  };
32
73
 
33
74
  export default VimeoProvider;
@@ -0,0 +1,15 @@
1
+ import { VIMEO_OEMBED_URL } from '../../../../../constants';
2
+
3
+ const addExtraParamsToUrl = (url, queryParams = {}) => {
4
+ const paramsWithValues = {};
5
+ Object.keys(queryParams).forEach(key => {
6
+ if (queryParams[key]) {
7
+ paramsWithValues[key] = queryParams[key];
8
+ }
9
+ });
10
+ const parsedParams = new URLSearchParams(paramsWithValues);
11
+ const stringParams = parsedParams.toString();
12
+ return `${VIMEO_OEMBED_URL}?url=${url}${stringParams ? `&${stringParams}` : ''}`;
13
+ };
14
+
15
+ export default addExtraParamsToUrl;
@@ -0,0 +1,3 @@
1
+ import addExtraParamsToUrl from './add-extra-params-to-url';
2
+
3
+ export { addExtraParamsToUrl };
@@ -28,19 +28,13 @@ export default {
28
28
  ),
29
29
  modal: dynamic(() => import(/* webpackChunkName: "blazePbModal" */ './Modal')),
30
30
  code: dynamic(() => import(/* webpackChunkName: "blazePbCode" */ './Code')),
31
- login: dynamic(() => import(/* webpackChunkName: "blazePbLogin" */ './Login')),
32
31
  menu: dynamic(() => import(/* webpackChunkName: "blazePbMenu" */ './Menu')),
33
32
  menuitem: dynamic(() => import(/* webpackChunkName: "blazePbMenuItem" */ './MenuItem')),
34
33
  submenu: dynamic(() => import(/* webpackChunkName: "blazePbSubMenu" */ './SubMenu')),
35
34
  emailconfirm: dynamic(() =>
36
35
  import(/* webpackChunkName: "blazePbEmailConfirm" */ './EmailConfirm')
37
36
  ),
38
- passwordreset: dynamic(() =>
39
- import(/* webpackChunkName: "blazePbPasswordReset" */ './PasswordReset')
40
- ),
41
- passwordresetrequest: dynamic(() =>
42
- import(/* webpackChunkName: "blazePbPasswordResetRequest" */ './PasswordResetRequest')
43
- ),
37
+
44
38
  breadcrumb: dynamic(() => import(/* webpackChunkName: "blazePbBreadcrumb" */ './Breadcrumb')),
45
39
  itemlistbutton: dynamic(() =>
46
40
  import(/* webpackChunkName: "blazePbItemListButton" */ './ItemList/ItemListButton')
@@ -51,5 +45,11 @@ export default {
51
45
  itemlistnew: dynamic(() =>
52
46
  import(/* webpackChunkName: "blazePbItemListNew" */ './ItemList/ItemListNew')
53
47
  ),
54
- backtotop: dynamic(() => import(/* webpackChunkName: "blazePbBackToTop" */ './BackToTop'))
48
+ backtotop: dynamic(() => import(/* webpackChunkName: "blazePbBackToTop" */ './BackToTop')),
49
+ contentgroup: dynamic(() =>
50
+ import(/* webpackChunkName: "blazePbContentGroup" */ './ContentGroup')
51
+ ),
52
+ contentgroupsection: dynamic(() =>
53
+ import(/* webpackChunkName: "blazePbContentGroupSection" */ './ContentGroupSection')
54
+ )
55
55
  };
@@ -35,10 +35,7 @@ const CATEGORY_ID = 'categoryId';
35
35
  const PUBLISHED = 'published';
36
36
  const ID = 'id';
37
37
  const LINK = 'link';
38
- const EMAIL = 'email';
39
- const PASSWORD = 'password';
40
38
  const LOGOUT = 'logout';
41
- const LOGIN_FORM = 'loginForm';
42
39
  const GRAPH_QL_ERROR = 'GraphQL error: ';
43
40
  const HOVER = 'hover';
44
41
  const MOUSE_ENTER = 'mouseenter';
@@ -120,6 +117,7 @@ const PROPS_TO_CHECK = [
120
117
 
121
118
  const JW_PLAYER_TYPE_FILE = 'file';
122
119
  const VIDEO_WRAPPER_CLASS_NAME = 'video__wrapper';
120
+ const VIMEO_OEMBED_URL = 'https://vimeo.com/api/oembed.json';
123
121
  const BREAKPOINT_SIZES = {
124
122
  sm: 'sm',
125
123
  md: 'md',
@@ -130,10 +128,6 @@ const BREAKPOINT_SIZES = {
130
128
 
131
129
  const MAX_BANNER_HEIGHT = 250;
132
130
  const MIN_BANNER_HEIGHT = 90;
133
- const PASSWORD_REGEX = /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\s).{8,}$/;
134
- const PASSWORD_VALIDATION_MESSAGE =
135
- 'Must contain 8 or more characters with a mix of upper & lower case letters, numbers & symbols and no spaces';
136
- const PASSWORD_CONFIRM_MESSAGE = 'Passwords must match';
137
131
  const ALLOWED_BLOCK_TYPES = ['p', 'ul', 'ol'];
138
132
 
139
133
  const PREHEADER_PROP = 'alternativePreHeader';
@@ -287,8 +281,6 @@ export {
287
281
  LOAD_MORE,
288
282
  CLASSIC,
289
283
  BREAKPOINT_SIZES,
290
- EMAIL,
291
- PASSWORD,
292
284
  LOGOUT,
293
285
  MIN_BANNER_HEIGHT,
294
286
  MAX_BANNER_HEIGHT,
@@ -305,10 +297,6 @@ export {
305
297
  HIDDEN,
306
298
  MENU_ITEM,
307
299
  SUB_MENU,
308
- LOGIN_FORM,
309
- PASSWORD_REGEX,
310
- PASSWORD_VALIDATION_MESSAGE,
311
- PASSWORD_CONFIRM_MESSAGE,
312
300
  ELEMENT,
313
301
  ALLOWED_BLOCK_TYPES,
314
302
  PREHEADER_PROP,
@@ -322,5 +310,6 @@ export {
322
310
  TARGET_BLANK,
323
311
  DATA_SUMMARY_EMAIL_REGEX,
324
312
  DATA_SUMMARY_URL_REGEX,
325
- DATA_SUMMARY_TEL_REGEX
313
+ DATA_SUMMARY_TEL_REGEX,
314
+ VIMEO_OEMBED_URL
326
315
  };
@@ -1,7 +1,17 @@
1
1
  const buildSearchValuesText = ({ propsToDisplay }, { search_term: searchTerm }) =>
2
2
  propsToDisplay.reduce((acc, field, index) => {
3
3
  if (field && searchTerm) {
4
- acc[index] = {
4
+ if (index === 0) {
5
+ acc[index] = {
6
+ match: {
7
+ pageBuilderIndexed: {
8
+ query: searchTerm,
9
+ fuzziness: 'AUTO'
10
+ }
11
+ }
12
+ };
13
+ }
14
+ acc[index + 1] = {
5
15
  match: {
6
16
  [field]: {
7
17
  query: searchTerm,
@@ -12,4 +22,5 @@ const buildSearchValuesText = ({ propsToDisplay }, { search_term: searchTerm })
12
22
  }
13
23
  return acc;
14
24
  }, []);
25
+
15
26
  export default buildSearchValuesText;
@@ -15,7 +15,7 @@ const getBannersByType = (items, bannerType) => {
15
15
  type === PB_TYPE_BANNER && insertionType === PB_TYPE_TEXTBLOCK
16
16
  );
17
17
 
18
- const hasTextBlockBanners = textBlockBanners && textBlockBanners.length;
18
+ const hasTextBlockBanners = !!textBlockBanners && !!textBlockBanners.length;
19
19
 
20
20
  return [hasTextBlockBanners, textBlockBanners];
21
21
  }
package/src/index.js CHANGED
@@ -11,7 +11,7 @@ export {
11
11
  getSingleEntitySchema,
12
12
  getUser
13
13
  } from './application/query';
14
- export { buildPropsQuery, getUnpublishedEntityName, renderChildren } from './helpers';
14
+ export { buildPropsQuery, getUnpublishedEntityName, renderChildren, hasChildren } from './helpers';
15
15
  export { withTitle } from './HOC';
16
16
  export { useGetEntitySchema, useGetEntitySchemasAsObj, useGetSingleEntitySchema } from './hooks';
17
17
  export { summaryComponents } from './components/DataSummary/DataSummaryTypes';
@@ -12,6 +12,13 @@ jest.mock('next/router', () => ({
12
12
  useRouter: jest.fn(() => ({ asPath: '' }))
13
13
  }));
14
14
 
15
+ jest.mock('@blaze-cms/utils-handlebars', () => ({
16
+ useStringTemplate: jest.fn((parent, [text, after, url]) => ({
17
+ loading: false,
18
+ data: [text, after, url]
19
+ }))
20
+ }));
21
+
15
22
  const componentProps = {
16
23
  type: 'icon',
17
24
  text: 'test',
@@ -16,8 +16,17 @@ const render = async (Component, props) => {
16
16
  };
17
17
 
18
18
  const CATEGORY = 'category-name';
19
- const firstPropToDisplay = 'some description';
20
- const secondPropToDisplay = 'extra props';
19
+
20
+ const propsToDisplay = [
21
+ {
22
+ htmlAttribute: 'data-testid'
23
+ }
24
+ ];
25
+ const getMockedParsedProp = children => <>{children}</>;
26
+ const firstPropValue = 'some description';
27
+ const secondPropValue = 'extra props';
28
+ const firstPropToDisplay = getMockedParsedProp(['', '', firstPropValue, '', '']);
29
+ const secondPropToDisplay = getMockedParsedProp(['', '', secondPropValue, '', '']);
21
30
 
22
31
  const componentProps = {
23
32
  id: 'id',
@@ -41,7 +50,8 @@ const componentProps = {
41
50
  displayCategory: true,
42
51
  displayThumbnail: true,
43
52
  displayTitle: true,
44
- propsToDisplay: [firstPropToDisplay, secondPropToDisplay]
53
+ propsToDisplay,
54
+ parsedPropsToDisplay: [firstPropToDisplay, secondPropToDisplay]
45
55
  };
46
56
 
47
57
  const preHeaderName = 'Pre header';
@@ -54,7 +64,8 @@ jest.mock('../../../../../src/components/LazyImage', () => ({ src, alt }) => (
54
64
 
55
65
  describe('Card component', () => {
56
66
  it('should render without throwing an error and match snapshot', async () => {
57
- const { asFragment } = await render(Card, componentProps);
67
+ const { asFragment, getByTestId } = await render(Card, componentProps);
68
+ expect(getByTestId(encodeURIComponent(firstPropValue))).toBeDefined();
58
69
  expect(asFragment()).toMatchSnapshot();
59
70
  });
60
71
 
@@ -159,8 +170,8 @@ describe('Card component', () => {
159
170
  const { getByText } = await render(Card, componentProps);
160
171
 
161
172
  await waitFor(() => {
162
- expect(getByText(firstPropToDisplay)).toBeInTheDocument();
163
- expect(getByText(secondPropToDisplay)).toBeInTheDocument();
173
+ expect(getByText(firstPropValue)).toBeInTheDocument();
174
+ expect(getByText(secondPropValue)).toBeInTheDocument();
164
175
  });
165
176
  });
166
177
 
@@ -170,7 +181,7 @@ describe('Card component', () => {
170
181
  const { getByText } = await render(Card, { ...componentProps, ...propsToDisplayModifiers });
171
182
 
172
183
  await waitFor(() => {
173
- const span = getByText(firstPropToDisplay).closest('span');
184
+ const span = getByText(firstPropValue).closest('span');
174
185
  expect(span).not.toHaveAttribute(modifier);
175
186
  });
176
187
  });
@@ -44,6 +44,7 @@ exports[`Card component should not render alternative headline if alternativePre
44
44
  >
45
45
  <span
46
46
  class=""
47
+ data-testid="some%20description"
47
48
  >
48
49
  some description
49
50
  </span>
@@ -112,6 +113,7 @@ exports[`Card component should not render alternative headline if displayCategor
112
113
  >
113
114
  <span
114
115
  class=""
116
+ data-testid="some%20description"
115
117
  >
116
118
  some description
117
119
  </span>
@@ -186,6 +188,7 @@ exports[`Card component should not render preHeader if alternativeHeadline is no
186
188
  >
187
189
  <span
188
190
  class=""
191
+ data-testid="some%20description"
189
192
  >
190
193
  some description
191
194
  </span>
@@ -259,6 +262,7 @@ exports[`Card component should render customPreheader and alternativeHeadline in
259
262
  >
260
263
  <span
261
264
  class=""
265
+ data-testid="some%20description"
262
266
  >
263
267
  some description
264
268
  </span>
@@ -333,6 +337,7 @@ exports[`Card component should render without throwing an error and match snapsh
333
337
  >
334
338
  <span
335
339
  class=""
340
+ data-testid="some%20description"
336
341
  >
337
342
  some description
338
343
  </span>
@@ -0,0 +1,13 @@
1
+ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
2
+ import ContentGroup from '../../../../../src/components/ContentGroup/ContentGroup';
3
+
4
+ describe('ContentGroup component', () => {
5
+ it('should match snapshot and render based on contentType prop', () => {
6
+ const { asFragment: tabContentGroup } = render(ContentGroup, { contentType: 'tab' });
7
+ const { asFragment: sidepanelContentGroup } = render(ContentGroup, {
8
+ contentType: 'sidepanel'
9
+ });
10
+ expect(tabContentGroup()).toMatchSnapshot();
11
+ expect(sidepanelContentGroup()).toMatchSnapshot();
12
+ });
13
+ });
@@ -0,0 +1,16 @@
1
+ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
2
+ import ContentGroupTabs from '../../../../../src/components/ContentGroup/ContentGroupTabs';
3
+
4
+ describe('ContentGroupTabs component', () => {
5
+ it('should match snapshot and render tabs content', () => {
6
+ const { asFragment: tabContentGroup } = render(ContentGroupTabs, { contentType: 'tab' });
7
+ expect(tabContentGroup()).toMatchSnapshot();
8
+ });
9
+
10
+ it('should match snapshot and render sidepanel content', () => {
11
+ const { asFragment: sidepanelContentGroup } = render(ContentGroupTabs, {
12
+ contentType: 'sidepanel'
13
+ });
14
+ expect(sidepanelContentGroup()).toMatchSnapshot();
15
+ });
16
+ });
@@ -0,0 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ContentGroup component should match snapshot and render based on contentType prop 1`] = `<DocumentFragment />`;
4
+
5
+ exports[`ContentGroup component should match snapshot and render based on contentType prop 2`] = `<DocumentFragment />`;
@@ -0,0 +1,5 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ContentGroupTabs component should match snapshot and render sidepanel content 1`] = `<DocumentFragment />`;
4
+
5
+ exports[`ContentGroupTabs component should match snapshot and render tabs content 1`] = `<DocumentFragment />`;
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
3
+ import ContentGroupSection from '../../../../../src/components/ContentGroupSection/ContentGroupSection';
4
+
5
+ describe('ContentGroupSection component', () => {
6
+ it('should not render if section has no children', () => {
7
+ const { asFragment: contentGroupSection } = render(ContentGroupSection);
8
+ expect(contentGroupSection()).toMatchSnapshot();
9
+ });
10
+
11
+ it('should render if section has children', () => {
12
+ const { asFragment: contentGroupSection } = render(ContentGroupSection, {
13
+ children: [<div>child div</div>]
14
+ });
15
+ expect(contentGroupSection()).toMatchSnapshot();
16
+ });
17
+ });
@@ -0,0 +1,15 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`ContentGroupSection component should not render if section has no children 1`] = `<DocumentFragment />`;
4
+
5
+ exports[`ContentGroupSection component should render if section has children 1`] = `
6
+ <DocumentFragment>
7
+ <div
8
+ class="content-group-section"
9
+ >
10
+ <div>
11
+ child div
12
+ </div>
13
+ </div>
14
+ </DocumentFragment>
15
+ `;
@@ -3,10 +3,8 @@ import '@testing-library/jest-dom/extend-expect';
3
3
  import VimeoProvider from '../../../../../../../src/components/Video/providers/Vimeo/VimeoProvider';
4
4
 
5
5
  describe('VimeoProvider component', () => {
6
- const props = { url: 'https://player.vimeo.com/video/XXXXXX' };
7
-
8
6
  it('should render without throwing error and match snapshot', async () => {
9
- const { asFragment } = render(VimeoProvider, props);
7
+ const { asFragment } = render(VimeoProvider, {});
10
8
  expect(asFragment()).toMatchSnapshot();
11
9
  });
12
10
  });
@@ -0,0 +1,10 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`VimeoProvider component should render without throwing error and match snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="video__wrapper"
7
+ role="button"
8
+ />
9
+ </DocumentFragment>
10
+ `;
@@ -0,0 +1,24 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import { addExtraParamsToUrl } from '../../../../../../../../src/components/Video/providers/Vimeo/helpers';
3
+
4
+ const mockUrl = 'https://www.vimeo.com/12938920';
5
+
6
+ describe('addExtraParamsToUrl helper function', () => {
7
+ it('should return url with params based on props', () => {
8
+ const newUrl = addExtraParamsToUrl(mockUrl);
9
+ const newUrlWithAutoplay = addExtraParamsToUrl(mockUrl, { autoplay: true, loop: false });
10
+ const newUrlWithHeight = addExtraParamsToUrl(mockUrl, {
11
+ autoplay: false,
12
+ loop: false,
13
+ height: '21132px'
14
+ });
15
+
16
+ expect(newUrl).toEqual('https://vimeo.com/api/oembed.json?url=https://www.vimeo.com/12938920');
17
+ expect(newUrlWithAutoplay).toEqual(
18
+ 'https://vimeo.com/api/oembed.json?url=https://www.vimeo.com/12938920&autoplay=true'
19
+ );
20
+ expect(newUrlWithHeight).toEqual(
21
+ 'https://vimeo.com/api/oembed.json?url=https://www.vimeo.com/12938920&height=21132px'
22
+ );
23
+ });
24
+ });
@@ -34,6 +34,14 @@ Object {
34
34
  "$$typeof": Symbol(react.forward_ref),
35
35
  "render": [Function],
36
36
  },
37
+ "contentgroup": Object {
38
+ "$$typeof": Symbol(react.forward_ref),
39
+ "render": [Function],
40
+ },
41
+ "contentgroupsection": Object {
42
+ "$$typeof": Symbol(react.forward_ref),
43
+ "render": [Function],
44
+ },
37
45
  "datasummary": Object {
38
46
  "$$typeof": Symbol(react.forward_ref),
39
47
  "render": [Function],
@@ -62,10 +70,6 @@ Object {
62
70
  "$$typeof": Symbol(react.forward_ref),
63
71
  "render": [Function],
64
72
  },
65
- "login": Object {
66
- "$$typeof": Symbol(react.forward_ref),
67
- "render": [Function],
68
- },
69
73
  "menu": Object {
70
74
  "$$typeof": Symbol(react.forward_ref),
71
75
  "render": [Function],
@@ -78,14 +82,6 @@ Object {
78
82
  "$$typeof": Symbol(react.forward_ref),
79
83
  "render": [Function],
80
84
  },
81
- "passwordreset": Object {
82
- "$$typeof": Symbol(react.forward_ref),
83
- "render": [Function],
84
- },
85
- "passwordresetrequest": Object {
86
- "$$typeof": Symbol(react.forward_ref),
87
- "render": [Function],
88
- },
89
85
  "row": Object {
90
86
  "$$typeof": Symbol(react.forward_ref),
91
87
  "render": [Function],
@@ -16,10 +16,6 @@ describe('build search values for text input', () => {
16
16
  const searchValuesEmpty = buildSearchValuesText({ propsToDisplay: [] }, query);
17
17
  const searchValuesNoQueryParams = buildSearchValuesText(textFilter, {});
18
18
 
19
- it('should be a function', () => {
20
- expect(typeof buildSearchValuesText).toEqual('function');
21
- });
22
-
23
19
  it('should always return an array', () => {
24
20
  expect(Array.isArray(searchValues)).toEqual(true);
25
21
  expect(Array.isArray(searchValuesEmpty)).toEqual(true);
@@ -27,12 +23,13 @@ describe('build search values for text input', () => {
27
23
 
28
24
  it('should return an array with correct data', () => {
29
25
  const searchArray = [
26
+ { match: { pageBuilderIndexed: { query: 'something', fuzziness: 'AUTO' } } },
30
27
  { match: { name: { query: 'something', fuzziness: 'AUTO' } } },
31
28
  { match: { metaTitle: { query: 'something', fuzziness: 'AUTO' } } }
32
29
  ];
33
30
  expect(searchValues).toEqual(searchArray);
34
31
  expect(searchValuesEmpty).toEqual([]);
35
- expect(searchValues.length).toBe(2);
32
+ expect(searchValues.length).toBe(3);
36
33
  expect(searchValuesEmpty.length).toBe(0);
37
34
  expect(searchValuesNoQueryParams.length).toBe(0);
38
35
  });
@@ -1,28 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.object.define-property.js");
4
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports["default"] = void 0;
9
- var _react = _interopRequireDefault(require("react"));
10
- var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var LoggedInMessage = function LoggedInMessage(_ref) {
12
- var goToUrl = _ref.goToUrl,
13
- urlToUse = _ref.urlToUse;
14
- return /*#__PURE__*/_react["default"].createElement("span", null, "You are already logged in please", ' ', /*#__PURE__*/_react["default"].createElement("a", {
15
- onClick: function onClick(e) {
16
- e.preventDefault();
17
- goToUrl(true);
18
- },
19
- href: urlToUse
20
- }, "click here"), ' ', "to reload your content access");
21
- };
22
- LoggedInMessage.propTypes = {
23
- goToUrl: _propTypes["default"].func.isRequired,
24
- urlToUse: _propTypes["default"].string.isRequired
25
- };
26
- var _default = LoggedInMessage;
27
- exports["default"] = _default;
28
- //# sourceMappingURL=LoggedInMessage.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LoggedInMessage.js","names":["LoggedInMessage","goToUrl","urlToUse","e","preventDefault","propTypes","PropTypes","func","isRequired","string"],"sources":["../../../src/components/Login/LoggedInMessage.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst LoggedInMessage = ({ goToUrl, urlToUse }) => (\n <span>\n You are already logged in please{' '}\n <a\n onClick={e => {\n e.preventDefault();\n goToUrl(true);\n }}\n href={urlToUse}>\n click here\n </a>{' '}\n to reload your content access\n </span>\n);\n\nLoggedInMessage.propTypes = {\n goToUrl: PropTypes.func.isRequired,\n urlToUse: PropTypes.string.isRequired\n};\n\nexport default LoggedInMessage;\n"],"mappings":";;;;;;;;AAAA;AACA;AAEA,IAAMA,eAAe,GAAG,SAAlBA,eAAe;EAAA,IAAMC,OAAO,QAAPA,OAAO;IAAEC,QAAQ,QAARA,QAAQ;EAAA,oBAC1C,kFACmC,GAAG,eACpC;IACE,OAAO,EAAE,iBAAAC,CAAC,EAAI;MACZA,CAAC,CAACC,cAAc,EAAE;MAClBH,OAAO,CAAC,IAAI,CAAC;IACf,CAAE;IACF,IAAI,EAAEC;EAAS,gBAEb,EAAC,GAAG,kCAEH;AAAA,CACR;AAEDF,eAAe,CAACK,SAAS,GAAG;EAC1BJ,OAAO,EAAEK,qBAAS,CAACC,IAAI,CAACC,UAAU;EAClCN,QAAQ,EAAEI,qBAAS,CAACG,MAAM,CAACD;AAC7B,CAAC;AAAC,eAEaR,eAAe;AAAA"}