@blaze-cms/react-page-builder 0.140.0-core-variants.0 → 0.140.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 (100) hide show
  1. package/CHANGELOG.md +5 -9
  2. package/lib/components/ContentGroup/ContentGroupTabs.js +8 -10
  3. package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  4. package/lib/hooks/helpers/getVariant.js.map +1 -1
  5. package/lib/variants/index.js +1 -13
  6. package/lib/variants/index.js.map +1 -1
  7. package/lib-es/components/ContentGroup/ContentGroupTabs.js +8 -10
  8. package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
  9. package/lib-es/hooks/helpers/getVariant.js.map +1 -1
  10. package/lib-es/variants/index.js +1 -12
  11. package/lib-es/variants/index.js.map +1 -1
  12. package/package.json +4 -4
  13. package/src/components/ContentGroup/ContentGroupTabs.js +8 -11
  14. package/src/hooks/helpers/getVariant.js +0 -1
  15. package/src/variants/index.js +1 -13
  16. package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +0 -2
  17. package/lib/variants/HeroImage/index.js +0 -29
  18. package/lib/variants/HeroImage/index.js.map +0 -1
  19. package/lib/variants/Infographic/Infographic.js +0 -27
  20. package/lib/variants/Infographic/Infographic.js.map +0 -1
  21. package/lib/variants/Infographic/index.js +0 -30
  22. package/lib/variants/Infographic/index.js.map +0 -1
  23. package/lib/variants/Infographic/useInfographic.js +0 -43
  24. package/lib/variants/Infographic/useInfographic.js.map +0 -1
  25. package/lib/variants/LongformGallery/LongformGallery.js +0 -51
  26. package/lib/variants/LongformGallery/LongformGallery.js.map +0 -1
  27. package/lib/variants/LongformGallery/LongformGalleryImage.js +0 -68
  28. package/lib/variants/LongformGallery/LongformGalleryImage.js.map +0 -1
  29. package/lib/variants/LongformGallery/constants.js +0 -19
  30. package/lib/variants/LongformGallery/constants.js.map +0 -1
  31. package/lib/variants/LongformGallery/helpers/index.js +0 -29
  32. package/lib/variants/LongformGallery/helpers/index.js.map +0 -1
  33. package/lib/variants/LongformGallery/helpers/parseImageData.js +0 -42
  34. package/lib/variants/LongformGallery/helpers/parseImageData.js.map +0 -1
  35. package/lib/variants/LongformGallery/helpers/separateImages.js +0 -27
  36. package/lib/variants/LongformGallery/helpers/separateImages.js.map +0 -1
  37. package/lib/variants/LongformGallery/helpers/shouldSkip.js +0 -13
  38. package/lib/variants/LongformGallery/helpers/shouldSkip.js.map +0 -1
  39. package/lib/variants/LongformGallery/index.js +0 -31
  40. package/lib/variants/LongformGallery/index.js.map +0 -1
  41. package/lib/variants/LongformGallery/useLongformGallery.js +0 -63
  42. package/lib/variants/LongformGallery/useLongformGallery.js.map +0 -1
  43. package/lib/variants/LongformRow/index.js +0 -29
  44. package/lib/variants/LongformRow/index.js.map +0 -1
  45. package/lib/variants/ParallaxImageRight/index.js +0 -30
  46. package/lib/variants/ParallaxImageRight/index.js.map +0 -1
  47. package/lib-es/variants/HeroImage/index.js +0 -10
  48. package/lib-es/variants/HeroImage/index.js.map +0 -1
  49. package/lib-es/variants/Infographic/Infographic.js +0 -20
  50. package/lib-es/variants/Infographic/Infographic.js.map +0 -1
  51. package/lib-es/variants/Infographic/index.js +0 -11
  52. package/lib-es/variants/Infographic/index.js.map +0 -1
  53. package/lib-es/variants/Infographic/useInfographic.js +0 -23
  54. package/lib-es/variants/Infographic/useInfographic.js.map +0 -1
  55. package/lib-es/variants/LongformGallery/LongformGallery.js +0 -37
  56. package/lib-es/variants/LongformGallery/LongformGallery.js.map +0 -1
  57. package/lib-es/variants/LongformGallery/LongformGalleryImage.js +0 -56
  58. package/lib-es/variants/LongformGallery/LongformGalleryImage.js.map +0 -1
  59. package/lib-es/variants/LongformGallery/constants.js +0 -18
  60. package/lib-es/variants/LongformGallery/constants.js.map +0 -1
  61. package/lib-es/variants/LongformGallery/helpers/index.js +0 -5
  62. package/lib-es/variants/LongformGallery/helpers/index.js.map +0 -1
  63. package/lib-es/variants/LongformGallery/helpers/parseImageData.js +0 -26
  64. package/lib-es/variants/LongformGallery/helpers/parseImageData.js.map +0 -1
  65. package/lib-es/variants/LongformGallery/helpers/separateImages.js +0 -13
  66. package/lib-es/variants/LongformGallery/helpers/separateImages.js.map +0 -1
  67. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js +0 -3
  68. package/lib-es/variants/LongformGallery/helpers/shouldSkip.js.map +0 -1
  69. package/lib-es/variants/LongformGallery/index.js +0 -12
  70. package/lib-es/variants/LongformGallery/index.js.map +0 -1
  71. package/lib-es/variants/LongformGallery/useLongformGallery.js +0 -48
  72. package/lib-es/variants/LongformGallery/useLongformGallery.js.map +0 -1
  73. package/lib-es/variants/LongformRow/index.js +0 -10
  74. package/lib-es/variants/LongformRow/index.js.map +0 -1
  75. package/lib-es/variants/ParallaxImageRight/index.js +0 -11
  76. package/lib-es/variants/ParallaxImageRight/index.js.map +0 -1
  77. package/src/variants/HeroImage/index.js +0 -8
  78. package/src/variants/Infographic/Infographic.js +0 -14
  79. package/src/variants/Infographic/index.js +0 -10
  80. package/src/variants/Infographic/useInfographic.js +0 -18
  81. package/src/variants/LongformGallery/LongformGallery.js +0 -48
  82. package/src/variants/LongformGallery/LongformGalleryImage.js +0 -62
  83. package/src/variants/LongformGallery/constants.js +0 -21
  84. package/src/variants/LongformGallery/helpers/index.js +0 -5
  85. package/src/variants/LongformGallery/helpers/parseImageData.js +0 -25
  86. package/src/variants/LongformGallery/helpers/separateImages.js +0 -22
  87. package/src/variants/LongformGallery/helpers/shouldSkip.js +0 -3
  88. package/src/variants/LongformGallery/index.js +0 -11
  89. package/src/variants/LongformGallery/useLongformGallery.js +0 -50
  90. package/src/variants/LongformRow/index.js +0 -8
  91. package/src/variants/ParallaxImageRight/index.js +0 -9
  92. package/tests/unit/src/variants/LongFormGallery/LongformGallery.test.js +0 -41
  93. package/tests/unit/src/variants/LongFormGallery/LongformGalleryImage.test.js +0 -44
  94. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGallery.test.js.snap +0 -102
  95. package/tests/unit/src/variants/LongFormGallery/__snapshots__/LongformGalleryImage.test.js.snap +0 -51
  96. package/tests/unit/src/variants/LongFormGallery/constants.js +0 -37
  97. package/tests/unit/src/variants/LongFormGallery/helpers/parseImageData.test.js +0 -53
  98. package/tests/unit/src/variants/LongFormGallery/helpers/separateImages.test.js +0 -54
  99. package/tests/unit/src/variants/LongFormGallery/helpers/shouldSkip.test.js +0 -23
  100. package/tests/unit/src/variants/LongFormGallery/useLongformGallery.test.js +0 -39
@@ -1,8 +0,0 @@
1
- const LongformRow = {
2
- getSettings: componentSettings => ({
3
- ...componentSettings,
4
- modifier: 'longform-row'
5
- })
6
- };
7
-
8
- export default LongformRow;
@@ -1,9 +0,0 @@
1
- const ParallaxImageRight = {
2
- getSettings: componentSettings => ({
3
- ...componentSettings,
4
- parallax: true,
5
- modifier: 'image-children-right'
6
- })
7
- };
8
-
9
- export default ParallaxImageRight;
@@ -1,41 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import React from 'react';
5
- import '@testing-library/jest-dom/extend-expect';
6
- import { render, screen, waitFor } from '@testing-library/react';
7
- import { MockedProvider } from '@apollo/client/testing';
8
- import LongformGallery from '../../../../../src/variants/LongformGallery/LongformGallery';
9
- import { IMAGE_MOCKS } from './constants';
10
-
11
- const mockedProps = {
12
- imageIds: ['1', '2', '3'],
13
- priorityLimit: [0]
14
- };
15
-
16
- describe('LongformGallery', () => {
17
- it('renders LongformGallery without error', async () => {
18
- const { asFragment } = render(
19
- <MockedProvider mocks={IMAGE_MOCKS}>
20
- <LongformGallery {...mockedProps} />
21
- </MockedProvider>
22
- );
23
- await waitFor(() => {
24
- expect(screen.getByTestId('secondary-images')).toBeInTheDocument();
25
- });
26
- expect(asFragment()).toMatchSnapshot();
27
- expect(screen.getByTestId('longform-gallery')).toBeInTheDocument();
28
- });
29
-
30
- it('renders LongformGallery with two-group modifier if images length is 4', async () => {
31
- const { asFragment } = render(
32
- <MockedProvider mocks={IMAGE_MOCKS}>
33
- <LongformGallery {...mockedProps} imageIds={['1', '2', '3', '4']} />
34
- </MockedProvider>
35
- );
36
- await waitFor(() => {
37
- expect(screen.getByTestId('secondary-images')).toBeInTheDocument();
38
- });
39
- expect(asFragment()).toMatchSnapshot();
40
- });
41
- });
@@ -1,44 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import React from 'react';
5
- import { render, screen, fireEvent } from '@testing-library/react';
6
- import '@testing-library/jest-dom/extend-expect';
7
- import LongformGalleryImage from '../../../../../src/variants/LongformGallery/LongformGalleryImage';
8
-
9
- const mockedProps = {
10
- url: 'https://mock-url/image-id-1.jpg',
11
- id: 'image-id-1',
12
- caption: '',
13
- altText: '',
14
- priority: true,
15
- className: 'longform-gallery__images__image main-image',
16
- handleImageOnClick: jest.fn()
17
- };
18
-
19
- describe('LongformGalleryImage component', () => {
20
- it('should be a function', () => {
21
- expect(typeof LongformGalleryImage).toEqual('function');
22
- });
23
-
24
- it('renders LongformGalleryImage component', () => {
25
- const { asFragment } = render(<LongformGalleryImage {...mockedProps} />);
26
- expect(asFragment()).toMatchSnapshot();
27
- expect(screen.getByTestId('longform-gallery__images__image__container')).toBeInTheDocument();
28
- });
29
-
30
- it('renders LongformGalleryImage component', () => {
31
- const { asFragment } = render(
32
- <LongformGalleryImage {...mockedProps} caption="some image caption" />
33
- );
34
- expect(asFragment()).toMatchSnapshot();
35
- expect(screen.getByTestId('longform-gallery__images__image__details')).toBeInTheDocument();
36
- });
37
-
38
- it('calls handleImageOnClick when image is clicked', () => {
39
- render(<LongformGalleryImage {...mockedProps} />);
40
- const image = screen.getByTestId('longform-gallery__images__image__container');
41
- fireEvent.click(image);
42
- expect(mockedProps.handleImageOnClick).toHaveBeenCalledWith(mockedProps.id);
43
- });
44
- });
@@ -1,102 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`LongformGallery renders LongformGallery with two-group modifier if images length is 4 1`] = `
4
- <DocumentFragment>
5
- <div
6
- class="longform-gallery"
7
- data-testid="longform-gallery"
8
- >
9
- <div
10
- class="longform-gallery__images main-images"
11
- >
12
- <div
13
- class="longform-gallery__images__image main-image"
14
- >
15
- <div
16
- class="longform-gallery__images__image__container"
17
- data-testid="longform-gallery__images__image__container"
18
- role="button"
19
- />
20
- </div>
21
- <div
22
- class="longform-gallery__images__image main-image"
23
- >
24
- <div
25
- class="longform-gallery__images__image__container"
26
- data-testid="longform-gallery__images__image__container"
27
- role="button"
28
- />
29
- </div>
30
- </div>
31
- <div
32
- class="longform-gallery__images secondary-images"
33
- data-testid="secondary-images"
34
- >
35
- <div
36
- class="longform-gallery__images__image secondary-image two-group"
37
- >
38
- <div
39
- class="longform-gallery__images__image__container"
40
- data-testid="longform-gallery__images__image__container"
41
- role="button"
42
- />
43
- </div>
44
- <div
45
- class="longform-gallery__images__image secondary-image two-group"
46
- >
47
- <div
48
- class="longform-gallery__images__image__container"
49
- data-testid="longform-gallery__images__image__container"
50
- role="button"
51
- />
52
- </div>
53
- </div>
54
- </div>
55
- </DocumentFragment>
56
- `;
57
-
58
- exports[`LongformGallery renders LongformGallery without error 1`] = `
59
- <DocumentFragment>
60
- <div
61
- class="longform-gallery"
62
- data-testid="longform-gallery"
63
- >
64
- <div
65
- class="longform-gallery__images main-images"
66
- >
67
- <div
68
- class="longform-gallery__images__image main-image"
69
- >
70
- <div
71
- class="longform-gallery__images__image__container"
72
- data-testid="longform-gallery__images__image__container"
73
- role="button"
74
- />
75
- </div>
76
- <div
77
- class="longform-gallery__images__image main-image"
78
- >
79
- <div
80
- class="longform-gallery__images__image__container"
81
- data-testid="longform-gallery__images__image__container"
82
- role="button"
83
- />
84
- </div>
85
- </div>
86
- <div
87
- class="longform-gallery__images secondary-images"
88
- data-testid="secondary-images"
89
- >
90
- <div
91
- class="longform-gallery__images__image secondary-image"
92
- >
93
- <div
94
- class="longform-gallery__images__image__container"
95
- data-testid="longform-gallery__images__image__container"
96
- role="button"
97
- />
98
- </div>
99
- </div>
100
- </div>
101
- </DocumentFragment>
102
- `;
@@ -1,51 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`LongformGalleryImage component renders LongformGalleryImage component 1`] = `
4
- <DocumentFragment>
5
- <div
6
- class="longform-gallery__images__image main-image"
7
- >
8
- <div
9
- class="longform-gallery__images__image__container"
10
- data-testid="longform-gallery__images__image__container"
11
- role="button"
12
- >
13
- <img
14
- alt=""
15
- role="button"
16
- src="https://mock-url/image-id-1.jpg"
17
- />
18
- </div>
19
- </div>
20
- </DocumentFragment>
21
- `;
22
-
23
- exports[`LongformGalleryImage component renders LongformGalleryImage component 2`] = `
24
- <DocumentFragment>
25
- <div
26
- class="longform-gallery__images__image main-image"
27
- >
28
- <div
29
- class="longform-gallery__images__image__container"
30
- data-testid="longform-gallery__images__image__container"
31
- role="button"
32
- >
33
- <img
34
- alt=""
35
- role="button"
36
- src="https://mock-url/image-id-1.jpg"
37
- />
38
- </div>
39
- <div
40
- class="longform-gallery__images__image__details"
41
- data-testid="longform-gallery__images__image__details"
42
- >
43
- <div
44
- class="longform-gallery__images__image__details__caption"
45
- >
46
- some image caption
47
- </div>
48
- </div>
49
- </div>
50
- </DocumentFragment>
51
- `;
@@ -1,37 +0,0 @@
1
- import { GET_IMAGES_QUERY } from '../../../../../src/variants/LongformGallery/constants';
2
-
3
- const IMAGE_MOCKS = [
4
- {
5
- request: {
6
- query: GET_IMAGES_QUERY,
7
- variables: { where: { id: { _in: ['1', '2', '3'] } } }
8
- },
9
- result: {
10
- data: {
11
- getImages: [
12
- { id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} },
13
- { id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} },
14
- { id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} }
15
- ]
16
- }
17
- }
18
- },
19
- {
20
- request: {
21
- query: GET_IMAGES_QUERY,
22
- variables: { where: { id: { _in: ['1', '2', '3', '4'] } } }
23
- },
24
- result: {
25
- data: {
26
- getImages: [
27
- { id: '1', url: 'image1.jpg', caption: 'Caption 1', data: {} },
28
- { id: '2', url: 'image2.jpg', caption: 'Caption 2', data: {} },
29
- { id: '3', url: 'image3.jpg', caption: 'Caption 3', data: {} },
30
- { id: '4', url: 'image4.jpg', caption: 'Caption 4', data: {} }
31
- ]
32
- }
33
- }
34
- }
35
- ];
36
-
37
- export { IMAGE_MOCKS };
@@ -1,53 +0,0 @@
1
- import { parseImageData } from '../../../../../../src/variants/LongformGallery/helpers';
2
-
3
- describe('parseImageData', () => {
4
- const mockImage = {
5
- id: '1',
6
- url: 'image.jpg',
7
- data: {
8
- caption: 'Image Caption'
9
- }
10
- };
11
-
12
- it('parses image data with caption when shouldDisplayCaption is true', () => {
13
- const parsedData = parseImageData(mockImage, 0, 2, true);
14
-
15
- expect(parsedData).toEqual({
16
- id: '1',
17
- url: 'image.jpg',
18
- caption: 'Image Caption',
19
- priority: true,
20
- altText: '',
21
- credits: '',
22
- hrefUrl: ''
23
- });
24
- });
25
-
26
- it('parses image data without caption when shouldDisplayCaption is false', () => {
27
- const parsedData = parseImageData(mockImage, 0, 2, false);
28
-
29
- expect(parsedData).toEqual({
30
- id: '1',
31
- url: 'image.jpg',
32
- caption: '',
33
- priority: true,
34
- altText: '',
35
- credits: '',
36
- hrefUrl: ''
37
- });
38
- });
39
-
40
- it('parses image data with default values when data is undefined', () => {
41
- const parsedData = parseImageData({ id: '1', url: 'image.jpg' }, 0, 2, true);
42
-
43
- expect(parsedData).toEqual({
44
- id: '1',
45
- url: 'image.jpg',
46
- caption: '',
47
- priority: true,
48
- altText: '',
49
- credits: '',
50
- hrefUrl: ''
51
- });
52
- });
53
- });
@@ -1,54 +0,0 @@
1
- import { separateImages } from '../../../../../../src/variants/LongformGallery/helpers';
2
-
3
- describe('separateImages', () => {
4
- const mockImages = [
5
- { id: '1', url: 'image1.jpg', data: { caption: 'Caption 1' } },
6
- { id: '2', url: 'image2.jpg', data: { caption: 'Caption 2' } },
7
- { id: '3', url: 'image3.jpg', data: { caption: 'Caption 3' } }
8
- ];
9
-
10
- it('returns empty arrays for undefined or empty images', () => {
11
- const result = separateImages(undefined, 2, true);
12
- expect(result).toEqual([[], []]);
13
-
14
- const resultEmptyArray = separateImages([], 2, true);
15
- expect(resultEmptyArray).toEqual([[], []]);
16
- });
17
-
18
- it('returns mainImages and secondaryImages arrays', () => {
19
- const [mainImages, secondaryImages] = separateImages(mockImages, 2, true);
20
-
21
- expect(mainImages).toHaveLength(2);
22
- expect(mainImages[0]).toEqual({
23
- id: '1',
24
- url: 'image1.jpg',
25
- caption: 'Caption 1',
26
- priority: true,
27
- altText: '',
28
- credits: '',
29
- hrefUrl: ''
30
- });
31
-
32
- expect(mainImages[1]).toEqual({
33
- id: '2',
34
- url: 'image2.jpg',
35
- caption: 'Caption 2',
36
- priority: true,
37
- altText: '',
38
- credits: '',
39
- hrefUrl: ''
40
- });
41
-
42
- expect(secondaryImages).toHaveLength(1);
43
- expect(secondaryImages[0]).toHaveLength(1);
44
- expect(secondaryImages[0][0]).toEqual({
45
- id: '3',
46
- url: 'image3.jpg',
47
- caption: 'Caption 3',
48
- priority: true,
49
- altText: '',
50
- credits: '',
51
- hrefUrl: ''
52
- });
53
- });
54
- });
@@ -1,23 +0,0 @@
1
- import { shouldSkip } from '../../../../../../src/variants/LongformGallery/helpers';
2
-
3
- describe('shouldSkip', () => {
4
- it('returns true when ids is undefined', () => {
5
- const result = shouldSkip(undefined);
6
- expect(result).toBe(true);
7
- });
8
-
9
- it('returns true when ids is an empty array', () => {
10
- const result = shouldSkip([]);
11
- expect(result).toBe(true);
12
- });
13
-
14
- it('returns false when ids is a non-empty array', () => {
15
- const result = shouldSkip(['1', '2', '3']);
16
- expect(result).toBe(false);
17
- });
18
-
19
- it('returns false when ids is a non-array value', () => {
20
- const result = shouldSkip('not an array');
21
- expect(result).toBe(false);
22
- });
23
- });
@@ -1,39 +0,0 @@
1
- /**
2
- * @jest-environment jsdom
3
- */
4
- import React from 'react';
5
- import { renderHook } from '@testing-library/react-hooks';
6
- import { MockedProvider } from '@apollo/client/testing';
7
- import useLongformGallery from '../../../../../src/variants/LongformGallery/useLongformGallery';
8
- import { IMAGE_MOCKS } from './constants';
9
-
10
- describe('useLongformGallery', () => {
11
- it('returns data, loading, error, mainImages, secondaryImages, and handleImageOnClick', async () => {
12
- const { result, waitForNextUpdate } = renderHook(
13
- () =>
14
- useLongformGallery({
15
- imageIds: ['1', '2', '3'],
16
- enableLightbox: true,
17
- toggleModal: jest.fn(),
18
- handleSelectedImage: jest.fn()
19
- }),
20
- {
21
- wrapper: ({ children }) => <MockedProvider mocks={IMAGE_MOCKS}>{children}</MockedProvider>
22
- }
23
- );
24
-
25
- expect(result.current.data).toBeUndefined();
26
- expect(result.current.loading).toBe(true);
27
- expect(result.current.error).toBeUndefined();
28
- expect(result.current.mainImages).toEqual([]);
29
- expect(result.current.secondaryImages).toEqual([]);
30
-
31
- await waitForNextUpdate();
32
-
33
- expect(result.current.data).toBeDefined();
34
- expect(result.current.loading).toBe(false);
35
- expect(result.current.error).toBeUndefined();
36
- expect(result.current.mainImages).toHaveLength(2);
37
- expect(result.current.secondaryImages).toHaveLength(1);
38
- });
39
- });