@blaze-cms/react-page-builder 0.123.1-alpha.2 → 0.124.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 (84) hide show
  1. package/CHANGELOG.md +213 -0
  2. package/lib/components/BackToTop/BackToTop.js +94 -0
  3. package/lib/components/BackToTop/BackToTop.js.map +1 -0
  4. package/lib/components/BackToTop/index.js +16 -0
  5. package/lib/components/BackToTop/index.js.map +1 -0
  6. package/lib/components/CarouselWrapper.js +6 -8
  7. package/lib/components/CarouselWrapper.js.map +1 -1
  8. package/lib/components/SearchContent/index.js +5 -2
  9. package/lib/components/SearchContent/index.js.map +1 -1
  10. package/lib/components/Video/Video.js +32 -9
  11. package/lib/components/Video/Video.js.map +1 -1
  12. package/lib/components/Video/VideoModal.js +72 -0
  13. package/lib/components/Video/VideoModal.js.map +1 -0
  14. package/lib/components/Video/VideoRender.js +2 -2
  15. package/lib/components/Video/VideoRender.js.map +1 -1
  16. package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js +7 -15
  17. package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
  18. package/lib/components/Video/providers/YouTube/YouTubeProvider.js +12 -4
  19. package/lib/components/Video/providers/YouTube/YouTubeProvider.js.map +1 -1
  20. package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js +23 -14
  21. package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
  22. package/lib/components/Video/providers/YouTube/helpers/index.js +24 -0
  23. package/lib/components/Video/providers/YouTube/helpers/index.js.map +1 -1
  24. package/lib/components/Wrapper.js +10 -3
  25. package/lib/components/Wrapper.js.map +1 -1
  26. package/lib/components/index.js +5 -0
  27. package/lib/components/index.js.map +1 -1
  28. package/lib/helpers/build-raw-query.js +1 -1
  29. package/lib/helpers/build-raw-query.js.map +1 -1
  30. package/lib-es/components/BackToTop/BackToTop.js +50 -0
  31. package/lib-es/components/BackToTop/BackToTop.js.map +1 -0
  32. package/lib-es/components/BackToTop/index.js +3 -0
  33. package/lib-es/components/BackToTop/index.js.map +1 -0
  34. package/lib-es/components/CarouselWrapper.js +6 -7
  35. package/lib-es/components/CarouselWrapper.js.map +1 -1
  36. package/lib-es/components/SearchContent/index.js +5 -2
  37. package/lib-es/components/SearchContent/index.js.map +1 -1
  38. package/lib-es/components/Video/Video.js +32 -10
  39. package/lib-es/components/Video/Video.js.map +1 -1
  40. package/lib-es/components/Video/VideoModal.js +31 -0
  41. package/lib-es/components/Video/VideoModal.js.map +1 -0
  42. package/lib-es/components/Video/VideoRender.js +2 -2
  43. package/lib-es/components/Video/VideoRender.js.map +1 -1
  44. package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js +6 -11
  45. package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
  46. package/lib-es/components/Video/providers/YouTube/YouTubeProvider.js +12 -4
  47. package/lib-es/components/Video/providers/YouTube/YouTubeProvider.js.map +1 -1
  48. package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js +19 -10
  49. package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js.map +1 -1
  50. package/lib-es/components/Video/providers/YouTube/helpers/index.js +18 -1
  51. package/lib-es/components/Video/providers/YouTube/helpers/index.js.map +1 -1
  52. package/lib-es/components/Wrapper.js +15 -9
  53. package/lib-es/components/Wrapper.js.map +1 -1
  54. package/lib-es/components/index.js +4 -1
  55. package/lib-es/components/index.js.map +1 -1
  56. package/lib-es/helpers/build-raw-query.js +1 -1
  57. package/lib-es/helpers/build-raw-query.js.map +1 -1
  58. package/package.json +3 -3
  59. package/src/components/BackToTop/BackToTop.js +52 -0
  60. package/src/components/BackToTop/index.js +3 -0
  61. package/src/components/CarouselWrapper.js +2 -7
  62. package/src/components/SearchContent/index.js +5 -2
  63. package/src/components/Video/Video.js +39 -12
  64. package/src/components/Video/VideoModal.js +31 -0
  65. package/src/components/Video/VideoRender.js +2 -2
  66. package/src/components/Video/providers/JWPlayer/JWPlayerProvider.js +6 -9
  67. package/src/components/Video/providers/YouTube/YouTubeProvider.js +14 -4
  68. package/src/components/Video/providers/YouTube/YoutubeEmbeded.js +19 -15
  69. package/src/components/Video/providers/YouTube/helpers/index.js +15 -1
  70. package/src/components/Wrapper.js +14 -12
  71. package/src/components/index.js +2 -1
  72. package/src/helpers/build-raw-query.js +2 -1
  73. package/tests/helpers/mocks.js +1 -1
  74. package/tests/unit/src/components/BackToTop/BackToTop.test.js +16 -0
  75. package/tests/unit/src/components/BackToTop/__snapshots__/BackToTop.test.js.snap +3 -0
  76. package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +3 -0
  77. package/tests/unit/src/components/Card/__snapshots__/CardRender.test.js.snap +3 -0
  78. package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +9 -0
  79. package/tests/unit/src/components/Video/Video.test.js +12 -4
  80. package/tests/unit/src/components/Video/VideoModal.test.js +15 -0
  81. package/tests/unit/src/components/Video/__snapshots__/Video.test.js.snap +12 -0
  82. package/tests/unit/src/components/Video/__snapshots__/VideoModal.test.js.snap +13 -0
  83. package/tests/unit/src/components/__snapshots__/Wrapper.test.js.snap +3 -0
  84. package/tests/unit/src/components/__snapshots__/index.test.js.snap +4 -0
@@ -4,7 +4,7 @@ import YoutubeEmbeded from './YoutubeEmbeded';
4
4
  import { getYouTubeID, booleanToNumber } from './helpers';
5
5
  import { VIDEO_WRAPPER_CLASS_NAME } from '../../../../constants';
6
6
 
7
- const YouTubeProvider = ({ url, autoplay, loop }) => {
7
+ const YouTubeProvider = ({ url, autoplay, loop, placeholderOnly, imageData }) => {
8
8
  const videoId = getYouTubeID(url);
9
9
 
10
10
  if (!videoId) return null;
@@ -12,7 +12,13 @@ const YouTubeProvider = ({ url, autoplay, loop }) => {
12
12
 
13
13
  return (
14
14
  <div className={VIDEO_WRAPPER_CLASS_NAME}>
15
- <YoutubeEmbeded autoplay={autoplay} videoId={videoId} params={params} />
15
+ <YoutubeEmbeded
16
+ autoplay={autoplay}
17
+ videoId={videoId}
18
+ params={params}
19
+ placeholderOnly={placeholderOnly}
20
+ imageData={imageData}
21
+ />
16
22
  </div>
17
23
  );
18
24
  };
@@ -20,12 +26,16 @@ const YouTubeProvider = ({ url, autoplay, loop }) => {
20
26
  YouTubeProvider.propTypes = {
21
27
  url: PropTypes.string.isRequired,
22
28
  autoplay: PropTypes.bool,
23
- loop: PropTypes.bool
29
+ loop: PropTypes.bool,
30
+ placeholderOnly: PropTypes.bool,
31
+ imageData: PropTypes.object
24
32
  };
25
33
 
26
34
  YouTubeProvider.defaultProps = {
27
35
  autoplay: false,
28
- loop: false
36
+ loop: false,
37
+ placeholderOnly: false,
38
+ imageData: {}
29
39
  };
30
40
 
31
41
  export default YouTubeProvider;
@@ -2,9 +2,7 @@ import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { useInView } from '@blaze-react/utils/lib/customHooks';
4
4
  import { IN_VIEW_CONFIG } from '../../../../constants';
5
-
6
- const YT_HQ_FORMAT = 'hqdefault';
7
- const YT_IMAGE_URL = 'https://i.ytimg.com';
5
+ import { getPosterUrl, YT_HQ_FORMAT, YT_IMAGE_URL } from './helpers';
8
6
 
9
7
  const YoutubeEmbeded = ({
10
8
  autoplay,
@@ -21,7 +19,9 @@ const YoutubeEmbeded = ({
21
19
  muted,
22
20
  adNetwork,
23
21
  iframeClass,
24
- priority
22
+ priority,
23
+ placeholderOnly,
24
+ imageData
25
25
  }) => {
26
26
  const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);
27
27
  const [preconnected, setPreconnected] = useState(false);
@@ -32,16 +32,16 @@ const YoutubeEmbeded = ({
32
32
  });
33
33
 
34
34
  const encodedId = encodeURIComponent(videoId);
35
- const videoPlaylisCovertId =
36
- typeof playlistCoverId === 'string' ? encodeURIComponent(playlistCoverId) : null;
37
35
  const paramsImp = videoParams ? `&${videoParams}` : '';
38
- const format = webp ? 'webp' : 'jpg';
39
- const vi = webp ? 'vi_webp' : 'vi';
40
- const posterUrl = !playlist
41
- ? `${YT_IMAGE_URL}/${vi}/${encodedId}/${imageSize}.${format}`
42
- : `${YT_IMAGE_URL}/${vi}/${videoPlaylisCovertId}/${imageSize}.${format}`;
43
36
  const ytUrl = noCookie ? 'https://www.youtube-nocookie.com' : 'https://www.youtube.com';
44
-
37
+ const posterUrl = getPosterUrl({
38
+ imageData,
39
+ playlistCoverId,
40
+ playlist,
41
+ encodedId,
42
+ imageSize,
43
+ webp
44
+ });
45
45
  const mutedValue = muted ? '&mute=1' : '';
46
46
  const iframeSrc = !playlist
47
47
  ? `${ytUrl}/embed/${encodedId}?autoplay=1${mutedValue}${paramsImp}`
@@ -71,7 +71,7 @@ const YoutubeEmbeded = ({
71
71
  };
72
72
 
73
73
  const addIframe = () => {
74
- if (renderIframe) return;
74
+ if (renderIframe || placeholderOnly) return;
75
75
  onIframeAdded();
76
76
  setRenderIframe(true);
77
77
  };
@@ -136,7 +136,9 @@ YoutubeEmbeded.propTypes = {
136
136
  announce: PropTypes.string,
137
137
  playlistCoverId: PropTypes.string,
138
138
  videoParams: PropTypes.string,
139
- videoTitle: PropTypes.string
139
+ videoTitle: PropTypes.string,
140
+ placeholderOnly: PropTypes.bool,
141
+ imageData: PropTypes.object
140
142
  };
141
143
 
142
144
  YoutubeEmbeded.defaultProps = {
@@ -154,7 +156,9 @@ YoutubeEmbeded.defaultProps = {
154
156
  videoId: '',
155
157
  playlistCoverId: '',
156
158
  videoParams: '',
157
- videoTitle: ''
159
+ videoTitle: '',
160
+ placeholderOnly: false,
161
+ imageData: {}
158
162
  };
159
163
 
160
164
  export default YoutubeEmbeded;
@@ -1,4 +1,6 @@
1
1
  const YOUTUBE_REGEX = /^.*((m\.)?youtu\.be\/|vi?\/|u\/\w\/|embed\/|\?vi?=|\&vi?=)([^#\&\?]*).*/;
2
+ const YT_IMAGE_URL = 'https://i.ytimg.com';
3
+ const YT_HQ_FORMAT = 'hqdefault';
2
4
 
3
5
  function getYouTubeID(uri) {
4
6
  const [, , , videoId] = uri.match(YOUTUBE_REGEX) || [];
@@ -9,4 +11,16 @@ function booleanToNumber(flag) {
9
11
  return flag ? 1 : 0;
10
12
  }
11
13
 
12
- export { getYouTubeID, booleanToNumber };
14
+ const getPosterUrl = ({ imageData, playlistCoverId, playlist, encodedId, imageSize, webp }) => {
15
+ if (imageData && imageData.url) return imageData.url;
16
+ const videoPlaylisCovertId =
17
+ typeof playlistCoverId === 'string' ? encodeURIComponent(playlistCoverId) : null;
18
+
19
+ const format = webp ? 'webp' : 'jpg';
20
+ const vi = webp ? 'vi_webp' : 'vi';
21
+ return !playlist
22
+ ? `${YT_IMAGE_URL}/${vi}/${encodedId}/${imageSize}.${format}`
23
+ : `${YT_IMAGE_URL}/${vi}/${videoPlaylisCovertId}/${imageSize}.${format}`;
24
+ };
25
+
26
+ export { getYouTubeID, booleanToNumber, getPosterUrl, YT_IMAGE_URL, YT_HQ_FORMAT };
@@ -1,18 +1,20 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
 
4
- const Wrapper = React.forwardRef(({ children, className, modifiers, style, tagType }, ref) => {
5
- const TagType = !tagType || tagType === 'Default' ? 'div' : tagType;
6
- return (
7
- <>
8
- {children && (
9
- <TagType ref={ref} className={`${className} ${modifiers}`} style={style}>
10
- {children}
11
- </TagType>
12
- )}
13
- </>
14
- );
15
- });
4
+ const Wrapper = React.forwardRef(
5
+ ({ children, className, modifiers, style, tagType, ...props }, ref) => {
6
+ const TagType = !tagType || tagType === 'Default' ? 'div' : tagType;
7
+ return (
8
+ <>
9
+ {children && (
10
+ <TagType ref={ref} className={`${className} ${modifiers}`} style={style} {...props}>
11
+ {children}
12
+ </TagType>
13
+ )}
14
+ </>
15
+ );
16
+ }
17
+ );
16
18
 
17
19
  Wrapper.propTypes = {
18
20
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]).isRequired,
@@ -41,5 +41,6 @@ export default {
41
41
  passwordresetrequest: dynamic(() =>
42
42
  import(/* webpackChunkName: "blazePbPasswordResetRequest" */ './PasswordResetRequest')
43
43
  ),
44
- breadcrumb: dynamic(() => import(/* webpackChunkName: "blazePbBreadcrumb" */ './Breadcrumb'))
44
+ breadcrumb: dynamic(() => import(/* webpackChunkName: "blazePbBreadcrumb" */ './Breadcrumb')),
45
+ backtotop: dynamic(() => import(/* webpackChunkName: "blazePbBackToTop" */ './BackToTop'))
45
46
  };
@@ -71,7 +71,8 @@ const buildRawQuery = (
71
71
  type: 'number',
72
72
  script: {
73
73
  lang: 'painless',
74
- source: "doc['_id'].value != null ? params.sortOrder.indexOf(doc['_id'].value) : 0",
74
+ source:
75
+ "!doc['id.keyword'].empty ? params.sortOrder.indexOf(doc['id.keyword'].value) : 0",
75
76
  params: {
76
77
  sortOrder: itemsToDisplayIds
77
78
  }
@@ -2096,7 +2096,7 @@ const RAW_QUERY_WITH_SHOULD_APPLY_SORT = {
2096
2096
  type: 'number',
2097
2097
  script: {
2098
2098
  lang: 'painless',
2099
- source: "doc['_id'].value != null ? params.sortOrder.indexOf(doc['_id'].value) : 0",
2099
+ source: "!doc['id.keyword'].empty ? params.sortOrder.indexOf(doc['id.keyword'].value) : 0",
2100
2100
  params: {
2101
2101
  sortOrder: ITEMS_TO_DISPLAY
2102
2102
  }
@@ -0,0 +1,16 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import { render } from '@blaze-cms/tools/test-helpers/test-functions';
3
+ import BackToTop from '../../../../../src/components/BackToTop';
4
+
5
+ describe('Breadcrumb component', () => {
6
+ it('should be a function', () => {
7
+ expect(typeof BackToTop).toEqual('function');
8
+ });
9
+
10
+ it('should render without throwing an error and match snapshot', () => {
11
+ const { asFragment } = render(BackToTop, {
12
+ showAfterPixels: 500
13
+ });
14
+ expect(asFragment()).toMatchSnapshot();
15
+ });
16
+ });
@@ -0,0 +1,3 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Breadcrumb component should render without throwing an error and match snapshot 1`] = `<DocumentFragment />`;
@@ -96,7 +96,10 @@ exports[`CardContainer component should render with carousel if option is enable
96
96
  exports[`CardContainer component should render without throwing error and match snapshot 1`] = `
97
97
  <DocumentFragment>
98
98
  <div
99
+ autoscrolltimer="0"
100
+ bannermodifier=""
99
101
  class="grid grid-cols-1 "
102
+ itemsperrow="1"
100
103
  >
101
104
  <div
102
105
  class="card card--portrait"
@@ -5,7 +5,10 @@ exports[`CardRender component should render empty string if parent matches resul
5
5
  exports[`CardRender component should render without throwing an error and match snapshot 1`] = `
6
6
  <DocumentFragment>
7
7
  <div
8
+ autoscrolltimer="0"
9
+ bannermodifier=""
8
10
  class="grid grid-cols-1 grid--one"
11
+ itemsperrow="1"
9
12
  >
10
13
  <div
11
14
  class="card card--portrait"
@@ -4,6 +4,9 @@ exports[`ImageFactory component should render image 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
6
  class="image "
7
+ entity=""
8
+ imagerelation="publishedPage.otherImageIds"
9
+ parent="[object Object]"
7
10
  >
8
11
  <a
9
12
  class="image__wrapper"
@@ -24,6 +27,9 @@ exports[`ImageFactory component should render image fetching data from relation
24
27
  <DocumentFragment>
25
28
  <div
26
29
  class="image "
30
+ entity="page"
31
+ imagerelation="publishedPage.otherImageIds"
32
+ parent="[object Object]"
27
33
  >
28
34
  <a
29
35
  class="image__wrapper"
@@ -39,6 +45,9 @@ exports[`ImageFactory component should render image fetching data from relation
39
45
  </div>
40
46
  <div
41
47
  class="image "
48
+ entity="page"
49
+ imagerelation="publishedPage.otherImageIds"
50
+ parent="[object Object]"
42
51
  >
43
52
  <a
44
53
  class="image__wrapper"
@@ -3,10 +3,18 @@ import '@testing-library/jest-dom/extend-expect';
3
3
  import { render } from '@testing-library/react';
4
4
  import Video from '../../../../../src/components/Video';
5
5
 
6
+ jest.mock('../../../../../src/hooks/use-get-images', () =>
7
+ jest.fn(() => ({ data: { getFile: { url: 'poster-url' } } }))
8
+ );
9
+
6
10
  jest.mock('../../../../../src/components/Video/VideoRender', () =>
7
11
  jest.fn(({ provider, modifier }) => <div data-testid={`VideoRender-${provider}-${modifier}`} />)
8
12
  );
9
13
 
14
+ jest.mock('../../../../../src/components/Video/VideoModal', () =>
15
+ jest.fn(() => <div>video modal</div>)
16
+ );
17
+
10
18
  const getMockedProps = overrides => ({
11
19
  url: 'https://www.youtube.com/watch?v=mockedID',
12
20
  modifier: 'mocked-modifier',
@@ -18,10 +26,6 @@ const getMockedProps = overrides => ({
18
26
  describe('Video component', () => {
19
27
  const mockedProps = getMockedProps();
20
28
 
21
- it('should be defined', () => {
22
- expect(Video).toBeDefined();
23
- });
24
-
25
29
  it('should match snapshot', () => {
26
30
  const { asFragment } = render(<Video {...mockedProps} />);
27
31
  expect(asFragment()).toMatchSnapshot();
@@ -60,4 +64,8 @@ describe('Video component', () => {
60
64
  expect(getByText(caption)).toBeDefined();
61
65
  expect(asFragment()).toMatchSnapshot();
62
66
  });
67
+ it('should video in modal if playInModal is true', () => {
68
+ const { asFragment } = render(<Video {...mockedProps} playInModal />);
69
+ expect(asFragment()).toMatchSnapshot();
70
+ });
63
71
  });
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ import '@testing-library/jest-dom/extend-expect';
3
+ import { render } from '@testing-library/react';
4
+ import VideoModal from '../../../../../src/components/Video/VideoModal';
5
+
6
+ jest.mock('../../../../../src/components/Video/VideoRender', () =>
7
+ jest.fn(({ provider, modifier }) => <div data-testid={`VideoRender-${provider}-${modifier}`} />)
8
+ );
9
+
10
+ describe('VideoModal component', () => {
11
+ it('should match snapshot', () => {
12
+ const { asFragment } = render(<VideoModal />);
13
+ expect(asFragment()).toMatchSnapshot();
14
+ });
15
+ });
@@ -45,3 +45,15 @@ exports[`Video component should render caption 1`] = `
45
45
  </div>
46
46
  </DocumentFragment>
47
47
  `;
48
+
49
+ exports[`Video component should video in modal if playInModal is true 1`] = `
50
+ <DocumentFragment>
51
+ <div
52
+ class="video video--youtube mocked-modifier"
53
+ >
54
+ <div>
55
+ video modal
56
+ </div>
57
+ </div>
58
+ </DocumentFragment>
59
+ `;
@@ -0,0 +1,13 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`VideoModal component should match snapshot 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ role="button"
7
+ >
8
+ <div
9
+ data-testid="VideoRender-undefined-undefined"
10
+ />
11
+ </div>
12
+ </DocumentFragment>
13
+ `;
@@ -3,6 +3,7 @@
3
3
  exports[`Wrapper component should handle Default value and render default tag 1`] = `
4
4
  <DocumentFragment>
5
5
  <div
6
+ backgroundimage="test-id"
6
7
  class="row wide desktop tablet mobile"
7
8
  >
8
9
  &lt;span /&gt;&lt;span /&gt;&lt;WithTitle(TextBlock) /&gt;
@@ -13,6 +14,7 @@ exports[`Wrapper component should handle Default value and render default tag 1`
13
14
  exports[`Wrapper component should render with custom tag 1`] = `
14
15
  <DocumentFragment>
15
16
  <article
17
+ backgroundimage="test-id"
16
18
  class="row wide desktop tablet mobile"
17
19
  >
18
20
  &lt;span /&gt;&lt;span /&gt;&lt;WithTitle(TextBlock) /&gt;
@@ -23,6 +25,7 @@ exports[`Wrapper component should render with custom tag 1`] = `
23
25
  exports[`Wrapper component should render without throwing an error and match snapshot 1`] = `
24
26
  <DocumentFragment>
25
27
  <div
28
+ backgroundimage="test-id"
26
29
  class="row wide desktop tablet mobile"
27
30
  >
28
31
  &lt;span /&gt;&lt;span /&gt;&lt;WithTitle(TextBlock) /&gt;
@@ -2,6 +2,10 @@
2
2
 
3
3
  exports[`Components should match snapshot 1`] = `
4
4
  Object {
5
+ "backtotop": Object {
6
+ "$$typeof": Symbol(react.forward_ref),
7
+ "render": [Function],
8
+ },
5
9
  "banner": Object {
6
10
  "$$typeof": Symbol(react.forward_ref),
7
11
  "render": [Function],