@blaze-cms/react-page-builder 0.118.0 → 0.119.0-alpha.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.
- package/CHANGELOG.md +14 -0
- package/README.md +22 -0
- package/lib/application/query/index.js +12 -12
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/Banner/AdSlotRender.js +104 -0
- package/lib/components/Banner/AdSlotRender.js.map +1 -0
- package/lib/components/Banner/Banner.js +2 -2
- package/lib/components/Banner/Banner.js.map +1 -1
- package/lib/components/Banner/BannerRender.js +23 -33
- package/lib/components/Banner/BannerRender.js.map +1 -1
- package/lib/components/Button.js +2 -2
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardContainer.js +6 -2
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/CardFactory.js +2 -2
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/Card/CardRender.js +3 -3
- package/lib/components/Card/CardRender.js.map +1 -1
- package/lib/components/Card/helpers/filter-query-setup.js +7 -7
- package/lib/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib/components/CarouselWrapper.js +54 -14
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryFactory.js +2 -2
- package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib/components/DataSummary/DataSummaryRender.js +2 -2
- package/lib/components/DataSummary/DataSummaryRender.js.map +1 -1
- package/lib/components/EmailConfirm/EmailConfirm.js +2 -2
- package/lib/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib/components/EmailConfirm/mutation.js +2 -2
- package/lib/components/EmailConfirm/mutation.js.map +1 -1
- package/lib/components/Image/ImageFactory.js +9 -5
- package/lib/components/Image/ImageFactory.js.map +1 -1
- package/lib/components/List/ListBuilder.js +21 -21
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +3 -3
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/ListRender.js +2 -2
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/Login/LoggedInMessage.js +1 -1
- package/lib/components/Login/LoggedInMessage.js.map +1 -1
- package/lib/components/Login/Login.js +2 -2
- package/lib/components/Login/Login.js.map +1 -1
- package/lib/components/PasswordReset/PasswordReset.js +2 -2
- package/lib/components/PasswordReset/PasswordReset.js.map +1 -1
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js +2 -2
- package/lib/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +2 -2
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/constants/index.js +8 -2
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-props-query.js +2 -2
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/hooks/use-get-entity-schema.js +3 -3
- package/lib/hooks/use-get-entity-schema.js.map +1 -1
- package/lib/hooks/use-get-entity-schemas-as-obj.js +2 -2
- package/lib/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
- package/lib/hooks/use-get-image-id-from-relation.js +2 -2
- package/lib/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib/hooks/use-get-images.js +2 -2
- package/lib/hooks/use-get-images.js.map +1 -1
- package/lib/hooks/use-get-single-entity-schema.js +2 -2
- package/lib/hooks/use-get-single-entity-schema.js.map +1 -1
- package/lib-es/application/query/index.js +1 -5
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Banner/AdSlotRender.js +54 -0
- package/lib-es/components/Banner/AdSlotRender.js.map +1 -0
- package/lib-es/components/Banner/Banner.js +1 -1
- package/lib-es/components/Banner/Banner.js.map +1 -1
- package/lib-es/components/Banner/BannerRender.js +21 -29
- package/lib-es/components/Banner/BannerRender.js.map +1 -1
- package/lib-es/components/Button.js +1 -1
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +7 -3
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +1 -1
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/Card/CardRender.js +1 -1
- package/lib-es/components/Card/CardRender.js.map +1 -1
- package/lib-es/components/Card/helpers/filter-query-setup.js +1 -1
- package/lib-es/components/Card/helpers/filter-query-setup.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +52 -14
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryFactory.js +1 -1
- package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
- package/lib-es/components/DataSummary/DataSummaryRender.js +1 -1
- package/lib-es/components/DataSummary/DataSummaryRender.js.map +1 -1
- package/lib-es/components/EmailConfirm/EmailConfirm.js +1 -1
- package/lib-es/components/EmailConfirm/EmailConfirm.js.map +1 -1
- package/lib-es/components/EmailConfirm/mutation.js +1 -1
- package/lib-es/components/EmailConfirm/mutation.js.map +1 -1
- package/lib-es/components/Image/ImageFactory.js +8 -4
- package/lib-es/components/Image/ImageFactory.js.map +1 -1
- package/lib-es/components/List/ListBuilder.js +2 -2
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +1 -1
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/ListRender.js +1 -1
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/Login/LoggedInMessage.js +1 -1
- package/lib-es/components/Login/LoggedInMessage.js.map +1 -1
- package/lib-es/components/Login/Login.js +1 -1
- package/lib-es/components/Login/Login.js.map +1 -1
- package/lib-es/components/PasswordReset/PasswordReset.js +1 -1
- package/lib-es/components/PasswordReset/PasswordReset.js.map +1 -1
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
- package/lib-es/components/PasswordResetRequest/PasswordResetRequest.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/constants/index.js +4 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +2 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/hooks/use-get-entity-schema.js +1 -1
- package/lib-es/hooks/use-get-entity-schema.js.map +1 -1
- package/lib-es/hooks/use-get-entity-schemas-as-obj.js +1 -1
- package/lib-es/hooks/use-get-entity-schemas-as-obj.js.map +1 -1
- package/lib-es/hooks/use-get-image-id-from-relation.js +1 -1
- package/lib-es/hooks/use-get-image-id-from-relation.js.map +1 -1
- package/lib-es/hooks/use-get-images.js +1 -1
- package/lib-es/hooks/use-get-images.js.map +1 -1
- package/lib-es/hooks/use-get-single-entity-schema.js +1 -1
- package/lib-es/hooks/use-get-single-entity-schema.js.map +1 -1
- package/package.json +7 -11
- package/src/application/query/index.js +1 -5
- package/src/components/Banner/AdSlotRender.js +62 -0
- package/src/components/Banner/Banner.js +1 -1
- package/src/components/Banner/BannerRender.js +22 -27
- package/src/components/Button.js +1 -1
- package/src/components/Card/CardContainer.js +5 -1
- package/src/components/Card/CardFactory.js +1 -1
- package/src/components/Card/CardRender.js +1 -1
- package/src/components/Card/helpers/filter-query-setup.js +1 -1
- package/src/components/CarouselWrapper.js +65 -19
- package/src/components/DataSummary/DataSummaryFactory.js +1 -1
- package/src/components/DataSummary/DataSummaryRender.js +1 -1
- package/src/components/EmailConfirm/EmailConfirm.js +1 -1
- package/src/components/EmailConfirm/mutation.js +1 -1
- package/src/components/Image/ImageFactory.js +10 -7
- package/src/components/List/ListBuilder.js +2 -2
- package/src/components/List/ListFactory.js +1 -1
- package/src/components/List/ListRender.js +1 -1
- package/src/components/Login/LoggedInMessage.js +1 -1
- package/src/components/Login/Login.js +1 -1
- package/src/components/PasswordReset/PasswordReset.js +1 -1
- package/src/components/PasswordResetRequest/PasswordResetRequest.js +1 -1
- package/src/components/SearchFilter/SearchFilterContainer.js +1 -1
- package/src/constants/index.js +6 -0
- package/src/helpers/build-props-query.js +2 -2
- package/src/hooks/use-get-entity-schema.js +1 -1
- package/src/hooks/use-get-entity-schemas-as-obj.js +1 -1
- package/src/hooks/use-get-image-id-from-relation.js +1 -1
- package/src/hooks/use-get-images.js +1 -1
- package/src/hooks/use-get-single-entity-schema.js +1 -1
- package/tests/unit/src/components/Banner/AdSlotRender.test.js +81 -0
- package/tests/unit/src/components/Banner/Banner.test.js +2 -1
- package/tests/unit/src/components/Banner/BannerRender.test.js +119 -0
- package/tests/unit/src/components/Banner/__snapshots__/AdSlotRender.test.js.snap +54 -0
- package/tests/unit/src/components/Banner/__snapshots__/BannerRender.test.js.snap +10 -0
- package/tests/unit/src/components/Button.test.js +2 -1
- package/tests/unit/src/components/Card/CardRender.test.js +1 -1
- package/tests/unit/src/components/Card/__snapshots__/CardContainer.test.js.snap +4 -4
- package/tests/unit/src/components/Carousel/Carousel.test.js +1 -1
- package/tests/unit/src/components/DataSummary/DataSummaryFactory.test.js +3 -2
- package/tests/unit/src/components/EmailConfirm/EmailConfirm.test.js +2 -1
- package/tests/unit/src/components/Image/GlobalLightbox/GlobalLightbox.test.js +10 -6
- package/tests/unit/src/components/Image/ImageFactory.test.js +11 -19
- package/tests/unit/src/components/Image/__snapshots__/ImageFactory.test.js.snap +34 -1
- package/tests/unit/src/components/Image/mocks.js +80 -24
- package/tests/unit/src/components/List/ListRender.test.js +2 -1
- package/tests/unit/src/components/Login/Login.test.js +2 -1
- package/tests/unit/src/components/PasswordReset/PasswordReset.test.js +2 -2
- package/tests/unit/src/components/PasswordResetRequest/PasswordResetRequest.test.js +2 -2
- package/tests/unit/src/components/SearchFilter/SearchFilterContainer.test.js +2 -1
- package/tests/unit/src/components/Video/providers/JWPlayer/JWPlayerProvider.test.js +1 -1
- package/tests/unit/src/components/__snapshots__/CarouselWrapper.test.js.snap +12 -12
- package/tests/unit/src/helpers/build-props-query.test.js +6 -6
- package/tests/unit/src/hooks/use-get-entity-schema-as-obj.test.js +2 -2
- package/tests/unit/src/hooks/use-get-image-id-from-relation.test.js +1 -1
- package/tests/unit/src/hooks/use-get-images.test.js +4 -14
- package/tests/unit/src/hooks/use-get-single-entity-schema.test.js +2 -4
|
@@ -2,17 +2,48 @@ 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 = ({
|
|
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
|
-
|
|
11
|
-
current
|
|
12
|
-
|
|
17
|
+
useEffect(
|
|
18
|
+
() => {
|
|
19
|
+
autoScrollRef.current = shouldAutoScroll;
|
|
20
|
+
const autoScroll = () => {
|
|
21
|
+
const id = setInterval(scrollCheck, autoScrollTimer);
|
|
22
|
+
function scrollCheck() {
|
|
23
|
+
if (!autoScrollRef.current) {
|
|
24
|
+
clearInterval(id);
|
|
25
|
+
} else {
|
|
26
|
+
handleButtonNavigation(true);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
13
30
|
|
|
14
|
-
|
|
15
|
-
|
|
31
|
+
if (autoScrollRef.current) autoScroll();
|
|
32
|
+
},
|
|
33
|
+
[autoScrollTimer, shouldAutoScroll]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
useEffect(
|
|
37
|
+
() => {
|
|
38
|
+
const {
|
|
39
|
+
current: { offsetWidth, scrollWidth }
|
|
40
|
+
} = ref;
|
|
41
|
+
if (scrollWidth <= offsetWidth)
|
|
42
|
+
setButtonDisplays({ displayLeft: false, displayRight: false });
|
|
43
|
+
setShouldAutoScroll(enableAutoScroll);
|
|
44
|
+
},
|
|
45
|
+
[enableAutoScroll]
|
|
46
|
+
);
|
|
16
47
|
|
|
17
48
|
const handleScroll = () => {
|
|
18
49
|
const {
|
|
@@ -25,35 +56,46 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
|
|
|
25
56
|
|
|
26
57
|
const handleButtonNavigation = direction => {
|
|
27
58
|
const {
|
|
28
|
-
current: { offsetWidth, scrollLeft }
|
|
59
|
+
current: { offsetWidth, scrollLeft, scrollWidth }
|
|
29
60
|
} = ref;
|
|
30
|
-
|
|
61
|
+
|
|
62
|
+
if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {
|
|
63
|
+
ref.current.scrollLeft = 0;
|
|
64
|
+
} else {
|
|
65
|
+
ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;
|
|
66
|
+
}
|
|
31
67
|
};
|
|
32
68
|
|
|
33
69
|
const { displayLeft, displayRight } = buttonDisplay;
|
|
34
|
-
const wrapperClassName = `
|
|
35
|
-
const contentClassName = `
|
|
70
|
+
const wrapperClassName = `cards-carousel${bannerModifier}`;
|
|
71
|
+
const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;
|
|
36
72
|
|
|
37
73
|
return (
|
|
38
74
|
<div className={wrapperClassName}>
|
|
39
|
-
<div className="
|
|
75
|
+
<div className="cards-carousel--left-button-wrapper">
|
|
40
76
|
{displayLeft && (
|
|
41
77
|
<button
|
|
42
78
|
type="button"
|
|
43
|
-
className="
|
|
44
|
-
onClick={() =>
|
|
79
|
+
className="cards-carousel__button-back icon-button icon"
|
|
80
|
+
onClick={() => {
|
|
81
|
+
setShouldAutoScroll(false);
|
|
82
|
+
handleButtonNavigation();
|
|
83
|
+
}}>
|
|
45
84
|
<i>
|
|
46
85
|
<FaAngleLeft />
|
|
47
86
|
</i>
|
|
48
87
|
</button>
|
|
49
88
|
)}
|
|
50
89
|
</div>
|
|
51
|
-
<div className="
|
|
90
|
+
<div className="cards-carousel--right-button-wrapper">
|
|
52
91
|
{displayRight && (
|
|
53
92
|
<button
|
|
54
93
|
type="button"
|
|
55
|
-
className="
|
|
56
|
-
onClick={() =>
|
|
94
|
+
className="cards-carousel--button-forward icon-button icon"
|
|
95
|
+
onClick={() => {
|
|
96
|
+
setShouldAutoScroll(false);
|
|
97
|
+
handleButtonNavigation(true);
|
|
98
|
+
}}>
|
|
57
99
|
<i>
|
|
58
100
|
<FaAngleRight />
|
|
59
101
|
</i>
|
|
@@ -70,13 +112,17 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
|
|
|
70
112
|
CarouselWrapper.propTypes = {
|
|
71
113
|
bannerModifier: PropTypes.string,
|
|
72
114
|
itemsPerRow: PropTypes.number,
|
|
73
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
115
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
116
|
+
enableAutoScroll: PropTypes.bool,
|
|
117
|
+
autoScrollTimer: PropTypes.number
|
|
74
118
|
};
|
|
75
119
|
|
|
76
120
|
CarouselWrapper.defaultProps = {
|
|
77
121
|
itemsPerRow: 0,
|
|
78
122
|
bannerModifier: '',
|
|
79
|
-
children: []
|
|
123
|
+
children: [],
|
|
124
|
+
enableAutoScroll: false,
|
|
125
|
+
autoScrollTimer: 0
|
|
80
126
|
};
|
|
81
127
|
|
|
82
128
|
export default CarouselWrapper;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { useQuery } from '@apollo/
|
|
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,6 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { useMutation } from '
|
|
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';
|
|
@@ -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 =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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/
|
|
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,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 '
|
|
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';
|
|
@@ -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 '
|
|
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';
|
|
@@ -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 '
|
|
5
|
+
import { useMutation } from '@apollo/client';
|
|
6
6
|
import { useRouter } from 'next/router';
|
|
7
7
|
import { checkIfLoggedIn, REQUEST_USER_PASSWORD_RESET_MUTATION } from '@blaze-cms/core-auth-ui';
|
|
8
8
|
import { GRAPH_QL_ERROR } from '../../constants';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React, { useState, useRef } from 'react';
|
|
2
2
|
import { useRouter } from 'next/router';
|
|
3
|
-
import { useQuery } from '@apollo/
|
|
3
|
+
import { useQuery } from '@apollo/client';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import { parseUrl, stringify } from 'query-string';
|
|
6
6
|
import SearchFilter from './SearchFilter';
|
package/src/constants/index.js
CHANGED
|
@@ -194,10 +194,16 @@ const ALL_AZ_SORT = {
|
|
|
194
194
|
|
|
195
195
|
const SCROLL_OFFSET = process.env.BLAZE_SCROLL_OFFSET || 50;
|
|
196
196
|
|
|
197
|
+
const BANNER_LOADING = 'loading';
|
|
198
|
+
const BANNER_EMPTY = 'empty';
|
|
199
|
+
const BANNER_LOADED = 'loaded';
|
|
197
200
|
const ANCHOR_TAG = 'a';
|
|
198
201
|
const TARGET_BLANK = '_blank';
|
|
199
202
|
|
|
200
203
|
export {
|
|
204
|
+
BANNER_LOADING,
|
|
205
|
+
BANNER_EMPTY,
|
|
206
|
+
BANNER_LOADED,
|
|
201
207
|
BLANK_SPACE_UNICODE_STRING,
|
|
202
208
|
BOLD_TAG,
|
|
203
209
|
BUTTON,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';
|
|
2
2
|
|
|
3
3
|
const defaultProps = [ID, 'name'];
|
|
4
|
-
const categoryProps = 'publishedListingPage{url}';
|
|
4
|
+
const categoryProps = 'id publishedListingPage{id, url}';
|
|
5
5
|
|
|
6
6
|
const checkProps = props =>
|
|
7
7
|
!!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);
|
|
@@ -77,7 +77,7 @@ const getContentProps = (isContent, displayThumbnail) => {
|
|
|
77
77
|
if (!isContent) return [];
|
|
78
78
|
|
|
79
79
|
const props = ['url', 'sponsored', 'featured'];
|
|
80
|
-
if (displayThumbnail) props.push('image.url', 'image.data');
|
|
80
|
+
if (displayThumbnail) props.push('image.id', 'image.url', 'image.data');
|
|
81
81
|
|
|
82
82
|
return props;
|
|
83
83
|
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
+
import { render, fireEvent, waitFor } from '@testing-library/react';
|
|
4
|
+
import AdSlotRender from '../../../../../src/components/Banner/AdSlotRender';
|
|
5
|
+
|
|
6
|
+
jest.mock('react-dfp', () => {
|
|
7
|
+
const AdSlot = ({ onSlotRender }) => (
|
|
8
|
+
// eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
|
|
9
|
+
<div
|
|
10
|
+
data-testid="adslot-test"
|
|
11
|
+
role="button"
|
|
12
|
+
onMouseLeave={() => onSlotRender({ event: { isEmpty: true } })}
|
|
13
|
+
onMouseOver={() => onSlotRender({ event: { isEmpty: false } })}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
return { AdSlot };
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const slotTestId = 'adslot-test';
|
|
20
|
+
const sizeMapping = [
|
|
21
|
+
{
|
|
22
|
+
viewport: [970, 250],
|
|
23
|
+
sizes: [[970, 250], [970, 528]]
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
viewport: [320, 100],
|
|
27
|
+
sizes: [[320, 100]]
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
viewport: [728, 90],
|
|
31
|
+
sizes: [[320, 100]]
|
|
32
|
+
}
|
|
33
|
+
];
|
|
34
|
+
|
|
35
|
+
const defaultProps = {
|
|
36
|
+
shouldShowBanner: true,
|
|
37
|
+
sizeMapping,
|
|
38
|
+
sizeId: 'sizeId',
|
|
39
|
+
parsedAdunit: 'unit-name',
|
|
40
|
+
parsedSizes: [],
|
|
41
|
+
targetingArguments: {}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
describe('Banner render component', () => {
|
|
45
|
+
it('should not render AdSlot if shouldShowBanner=false but should render styles and wrapper', () => {
|
|
46
|
+
const { asFragment, container, getByTestId } = render(
|
|
47
|
+
<AdSlotRender {...defaultProps} shouldShowBanner={false} />
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
expect(container.childNodes[0].nodeName).toEqual('STYLE');
|
|
51
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
52
|
+
expect(() => getByTestId(slotTestId)).toThrow();
|
|
53
|
+
expect(asFragment()).toMatchSnapshot();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('AdSlot loading', () => {
|
|
57
|
+
it('should render AdSlot', () => {
|
|
58
|
+
const { asFragment, container, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
59
|
+
expect(getByTestId('adslot-test')).toBeDefined();
|
|
60
|
+
expect(container.childNodes[1]).toHaveClass('ad-slot ad-slot-loading banner-sizeId');
|
|
61
|
+
expect(asFragment()).toMatchSnapshot();
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should change class and remove styles after loaded events', async () => {
|
|
65
|
+
const { asFragment, container, getByTestId } = render(<AdSlotRender {...defaultProps} />);
|
|
66
|
+
const adSlot = getByTestId(slotTestId);
|
|
67
|
+
|
|
68
|
+
fireEvent.mouseOver(adSlot);
|
|
69
|
+
await waitFor(() =>
|
|
70
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-loaded banner-sizeId')
|
|
71
|
+
);
|
|
72
|
+
expect(asFragment()).toMatchSnapshot();
|
|
73
|
+
|
|
74
|
+
fireEvent.mouseLeave(adSlot);
|
|
75
|
+
await waitFor(() =>
|
|
76
|
+
expect(container.childNodes[0]).toHaveClass('ad-slot ad-slot-empty banner-sizeId')
|
|
77
|
+
);
|
|
78
|
+
expect(asFragment()).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -2,7 +2,8 @@ import '@testing-library/jest-dom/extend-expect';
|
|
|
2
2
|
import { render } from '@blaze-cms/tools/test-helpers/test-functions';
|
|
3
3
|
import Banner from '../../../../../src/components/Banner/Banner';
|
|
4
4
|
|
|
5
|
-
jest.mock('@apollo/
|
|
5
|
+
jest.mock('@apollo/client', () => ({
|
|
6
|
+
...jest.requireActual('@apollo/client'),
|
|
6
7
|
useQuery: jest.fn(({ data, loading, error }) => ({ data, loading, error }))
|
|
7
8
|
}));
|
|
8
9
|
jest.mock('next/router', () => ({
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
|
+
import { render } from '@testing-library/react';
|
|
5
|
+
import BannerRender from '../../../../../src/components/Banner/BannerRender';
|
|
6
|
+
import { getAction, generateSingleItemQuery, getCount } from '../../../../../src/application/query';
|
|
7
|
+
import {
|
|
8
|
+
BANNER_QUERY_PROPS,
|
|
9
|
+
COUNT_CONTENT_HIERARCHIES,
|
|
10
|
+
GET_BANNER,
|
|
11
|
+
PUBLISHED
|
|
12
|
+
} from '../../../../../src/constants';
|
|
13
|
+
|
|
14
|
+
const actionKey = 'getPublishedPage';
|
|
15
|
+
const id = 'record id';
|
|
16
|
+
const action = getAction(actionKey, 'id, name');
|
|
17
|
+
const getEntityDataMock = {
|
|
18
|
+
request: {
|
|
19
|
+
query: action,
|
|
20
|
+
variables: {
|
|
21
|
+
id
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
result: {
|
|
25
|
+
data: {
|
|
26
|
+
[actionKey]: {
|
|
27
|
+
id,
|
|
28
|
+
name: 'record name'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const sizeId = 'sizeId';
|
|
35
|
+
const sizes = [
|
|
36
|
+
{
|
|
37
|
+
width: 320,
|
|
38
|
+
height: 100,
|
|
39
|
+
viewports: [
|
|
40
|
+
{
|
|
41
|
+
width: 320,
|
|
42
|
+
height: 100
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
|
46
|
+
];
|
|
47
|
+
const getBannerMock = {
|
|
48
|
+
request: {
|
|
49
|
+
query: generateSingleItemQuery(GET_BANNER, BANNER_QUERY_PROPS),
|
|
50
|
+
variables: { id: sizeId },
|
|
51
|
+
skip: false
|
|
52
|
+
},
|
|
53
|
+
result: {
|
|
54
|
+
data: {
|
|
55
|
+
entityData: {
|
|
56
|
+
sizes,
|
|
57
|
+
id,
|
|
58
|
+
__typename: 'Banner'
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getCountMock = {
|
|
65
|
+
request: {
|
|
66
|
+
query: getCount(COUNT_CONTENT_HIERARCHIES),
|
|
67
|
+
variables: {
|
|
68
|
+
where: {
|
|
69
|
+
parentId: id,
|
|
70
|
+
childEntity: {
|
|
71
|
+
_ilike: `${PUBLISHED}_%`
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
result: {
|
|
77
|
+
data: {
|
|
78
|
+
entityData: {
|
|
79
|
+
sizes,
|
|
80
|
+
id,
|
|
81
|
+
__typename: 'Banner'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
const mocks = [getEntityDataMock, getBannerMock, getCountMock];
|
|
88
|
+
|
|
89
|
+
const otherProps = { id };
|
|
90
|
+
const defaultProps = {
|
|
91
|
+
parent: {},
|
|
92
|
+
asPath: 'path',
|
|
93
|
+
action,
|
|
94
|
+
actionKey,
|
|
95
|
+
adunit: '',
|
|
96
|
+
baseAdunit: '',
|
|
97
|
+
sizeId,
|
|
98
|
+
propsToDisplay: [],
|
|
99
|
+
entity: '',
|
|
100
|
+
targetings: '',
|
|
101
|
+
sizes: '',
|
|
102
|
+
cardBannerIndex: null,
|
|
103
|
+
...otherProps
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const setup = (props = defaultProps) =>
|
|
107
|
+
render(
|
|
108
|
+
<MockedProvider mocks={mocks}>
|
|
109
|
+
<BannerRender {...props} />
|
|
110
|
+
</MockedProvider>
|
|
111
|
+
);
|
|
112
|
+
|
|
113
|
+
describe('Banner render component', () => {
|
|
114
|
+
it('should render', () => {
|
|
115
|
+
const { asFragment } = setup();
|
|
116
|
+
|
|
117
|
+
expect(asFragment()).toMatchSnapshot();
|
|
118
|
+
});
|
|
119
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Banner render component AdSlot loading should change class and remove styles after loaded events 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div
|
|
6
|
+
class="ad-slot ad-slot-loaded banner-sizeId"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
data-testid="adslot-test"
|
|
10
|
+
role="button"
|
|
11
|
+
/>
|
|
12
|
+
</div>
|
|
13
|
+
</DocumentFragment>
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
exports[`Banner render component AdSlot loading should change class and remove styles after loaded events 2`] = `
|
|
17
|
+
<DocumentFragment>
|
|
18
|
+
<div
|
|
19
|
+
class="ad-slot ad-slot-empty banner-sizeId"
|
|
20
|
+
>
|
|
21
|
+
<div
|
|
22
|
+
data-testid="adslot-test"
|
|
23
|
+
role="button"
|
|
24
|
+
/>
|
|
25
|
+
</div>
|
|
26
|
+
</DocumentFragment>
|
|
27
|
+
`;
|
|
28
|
+
|
|
29
|
+
exports[`Banner render component AdSlot loading should render AdSlot 1`] = `
|
|
30
|
+
<DocumentFragment>
|
|
31
|
+
<style>
|
|
32
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}@media(min-width:728px){.banner-sizeId{min-height:100px;}@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
33
|
+
</style>
|
|
34
|
+
<div
|
|
35
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
36
|
+
>
|
|
37
|
+
<div
|
|
38
|
+
data-testid="adslot-test"
|
|
39
|
+
role="button"
|
|
40
|
+
/>
|
|
41
|
+
</div>
|
|
42
|
+
</DocumentFragment>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Banner render component should not render AdSlot if shouldShowBanner=false but should render styles and wrapper 1`] = `
|
|
46
|
+
<DocumentFragment>
|
|
47
|
+
<style>
|
|
48
|
+
@media(min-width:320px){.banner-sizeId{min-height:100px;}@media(min-width:728px){.banner-sizeId{min-height:100px;}@media(min-width:970px){.banner-sizeId{min-height:250px;}
|
|
49
|
+
</style>
|
|
50
|
+
<div
|
|
51
|
+
class="ad-slot ad-slot-loading banner-sizeId"
|
|
52
|
+
/>
|
|
53
|
+
</DocumentFragment>
|
|
54
|
+
`;
|
|
@@ -3,7 +3,8 @@ import { act, render } from '@testing-library/react';
|
|
|
3
3
|
import '@testing-library/jest-dom/extend-expect';
|
|
4
4
|
import Button from '../../../../src/components/Button';
|
|
5
5
|
|
|
6
|
-
jest.mock('
|
|
6
|
+
jest.mock('@apollo/client', () => ({
|
|
7
|
+
...jest.requireActual('@apollo/client'),
|
|
7
8
|
useApolloClient: jest.fn(() => ({ resetStore: () => null }))
|
|
8
9
|
}));
|
|
9
10
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import '@testing-library/jest-dom/extend-expect';
|
|
3
|
-
import { MockedProvider } from '@apollo/
|
|
3
|
+
import { MockedProvider } from '@apollo/client/testing';
|
|
4
4
|
import { render, act } from '@testing-library/react';
|
|
5
5
|
import {
|
|
6
6
|
CARD_RENDER_ENTITY_DATA_MOCK,
|