@blaze-cms/react-page-builder 0.118.0-alpha.2 → 0.119.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -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/Menu/Menu.js +39 -6
- package/lib/components/Menu/Menu.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 +50 -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/Menu/Menu.js +44 -11
- package/lib-es/components/Menu/Menu.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 +9 -13
- 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 +64 -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/Menu/Menu.js +50 -12
- 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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.119.0-alpha.2",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,12 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/core-auth-ui": "^0.
|
|
31
|
-
"@blaze-cms/core-errors": "^0.118.0
|
|
30
|
+
"@blaze-cms/core-auth-ui": "^0.119.0-alpha.0",
|
|
31
|
+
"@blaze-cms/core-errors": "^0.118.0",
|
|
32
32
|
"@blaze-cms/image-cdn-react": "^0.2.0",
|
|
33
|
-
"@blaze-cms/nextjs-components": "^0.
|
|
33
|
+
"@blaze-cms/nextjs-components": "^0.119.0-alpha.0",
|
|
34
34
|
"@blaze-cms/setup-ui": "^0.92.0",
|
|
35
|
-
"@blaze-cms/utils": "^0.118.0
|
|
35
|
+
"@blaze-cms/utils": "^0.118.0",
|
|
36
36
|
"@blaze-react/button": "0.5.19",
|
|
37
37
|
"@blaze-react/checkboxes": "0.5.31",
|
|
38
38
|
"@blaze-react/input": "0.5.30",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
"@blaze-react/utils": "0.5.15",
|
|
43
43
|
"core-js": "^3.2.1",
|
|
44
44
|
"entities": "^2.0.0",
|
|
45
|
-
"graphql-tag": "^2.10.1",
|
|
46
45
|
"html-react-parser": "^0.10.0",
|
|
47
46
|
"lodash.at": "^4.6.0",
|
|
48
47
|
"lodash.camelcase": "^4.3.0",
|
|
@@ -63,21 +62,18 @@
|
|
|
63
62
|
"video-react": "0.14.1"
|
|
64
63
|
},
|
|
65
64
|
"peerDependencies": {
|
|
65
|
+
"@apollo/client": "3.x",
|
|
66
66
|
"draft-js": "^0.11.7",
|
|
67
67
|
"draft-js-export-html": "^1.4.1",
|
|
68
68
|
"draftjs-to-html": "0.9.1",
|
|
69
|
-
"
|
|
70
|
-
"next": "10.0.5",
|
|
69
|
+
"next": "12.x",
|
|
71
70
|
"prop-types": "^15.7.2",
|
|
72
|
-
"react": "^
|
|
73
|
-
"react-apollo": "^3.1.1",
|
|
71
|
+
"react": "^17.0.2",
|
|
74
72
|
"react-icons": ">= 4.3.1"
|
|
75
73
|
},
|
|
76
74
|
"devDependencies": {
|
|
77
|
-
"@apollo/react-testing": "^3.1.1",
|
|
78
75
|
"@testing-library/jest-dom": "^5.11.3",
|
|
79
76
|
"@testing-library/react": "^10.4.8",
|
|
80
|
-
"graphql-tag": "^2.10.1",
|
|
81
77
|
"jest-next-dynamic": "^1.0.1",
|
|
82
78
|
"prop-types": "^15.7.2",
|
|
83
79
|
"webpack": "^5.38.1",
|
|
@@ -87,5 +83,5 @@
|
|
|
87
83
|
"lib/*",
|
|
88
84
|
"lib-es/*"
|
|
89
85
|
],
|
|
90
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "48eacb8ab1011f1c45fdfe51312388e92b9776ba"
|
|
91
87
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import gql from '
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
2
|
import upperFirst from 'lodash.upperfirst';
|
|
3
3
|
|
|
4
4
|
const defaultSchemaProps = `
|
|
@@ -63,8 +63,6 @@ const getFiles = gql`
|
|
|
63
63
|
query getFiles($where: JSON!) {
|
|
64
64
|
getFiles(where: $where) {
|
|
65
65
|
id
|
|
66
|
-
location
|
|
67
|
-
mimetype
|
|
68
66
|
url
|
|
69
67
|
data
|
|
70
68
|
}
|
|
@@ -75,8 +73,6 @@ const getFileById = gql`
|
|
|
75
73
|
query getFile($id: String!) {
|
|
76
74
|
getFile(id: $id) {
|
|
77
75
|
id
|
|
78
|
-
location
|
|
79
|
-
mimetype
|
|
80
76
|
url
|
|
81
77
|
data
|
|
82
78
|
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { AdSlot } from 'react-dfp';
|
|
3
|
+
import PropTypes from 'prop-types';
|
|
4
|
+
import { BANNER_LOADING, BANNER_EMPTY, BANNER_LOADED } from '../../constants';
|
|
5
|
+
|
|
6
|
+
const AdSlotRender = ({
|
|
7
|
+
shouldShowBanner,
|
|
8
|
+
sizeMapping,
|
|
9
|
+
sizeId,
|
|
10
|
+
parsedAdunit,
|
|
11
|
+
parsedSizes,
|
|
12
|
+
targetingArguments
|
|
13
|
+
}) => {
|
|
14
|
+
const [loadingStatus, setLoadingStatus] = useState(BANNER_LOADING);
|
|
15
|
+
|
|
16
|
+
const bannerClass = `banner-${sizeId}`;
|
|
17
|
+
|
|
18
|
+
const styles =
|
|
19
|
+
loadingStatus === BANNER_LOADING &&
|
|
20
|
+
sizeMapping
|
|
21
|
+
.map(({ sizes: styleSizes, viewport: [minWidth] }) => {
|
|
22
|
+
const minHeight = Math.min(...styleSizes.map(([, height]) => height));
|
|
23
|
+
return `@media(min-width:${minWidth}px){.${bannerClass}{min-height:${minHeight}px;}`;
|
|
24
|
+
})
|
|
25
|
+
.sort();
|
|
26
|
+
const className = `ad-slot ad-slot-${loadingStatus} ${bannerClass}`;
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<>
|
|
30
|
+
{styles && <style>{styles}</style>}
|
|
31
|
+
<div className={className}>
|
|
32
|
+
{shouldShowBanner && (
|
|
33
|
+
<AdSlot
|
|
34
|
+
adUnit={parsedAdunit}
|
|
35
|
+
sizes={parsedSizes}
|
|
36
|
+
targetingArguments={targetingArguments}
|
|
37
|
+
sizeMapping={sizeMapping}
|
|
38
|
+
onSlotRender={({ event: { isEmpty } }) => {
|
|
39
|
+
const newLoadingStatus = isEmpty ? BANNER_EMPTY : BANNER_LOADED;
|
|
40
|
+
setLoadingStatus(newLoadingStatus);
|
|
41
|
+
}}
|
|
42
|
+
/>
|
|
43
|
+
)}
|
|
44
|
+
</div>
|
|
45
|
+
</>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
AdSlotRender.propTypes = {
|
|
50
|
+
shouldShowBanner: PropTypes.bool.isRequired,
|
|
51
|
+
sizeMapping: PropTypes.array.isRequired,
|
|
52
|
+
sizeId: PropTypes.string.isRequired,
|
|
53
|
+
parsedAdunit: PropTypes.string.isRequired,
|
|
54
|
+
parsedSizes: PropTypes.array,
|
|
55
|
+
targetingArguments: PropTypes.object.isRequired
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
AdSlotRender.defaultProps = {
|
|
59
|
+
parsedSizes: null
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export default AdSlotRender;
|
|
@@ -2,7 +2,7 @@ import React, { useContext } from 'react';
|
|
|
2
2
|
import { MainContext } from '@blaze-cms/nextjs-components';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import flatten from 'lodash.flatten';
|
|
5
|
-
import { useQuery } from '@apollo/
|
|
5
|
+
import { useQuery } from '@apollo/client';
|
|
6
6
|
import { useRouter } from 'next/router';
|
|
7
7
|
import { getSingleEntitySchema } from '../../application/query';
|
|
8
8
|
import Wrapper from '../Wrapper';
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { AdSlot } from 'react-dfp';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
1
|
import React from 'react';
|
|
4
|
-
import
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useQuery } from '@apollo/client';
|
|
5
|
+
|
|
5
6
|
import { generateSingleItemQuery, getCount } from '../../application/query';
|
|
6
7
|
import {
|
|
7
8
|
buildBannerSizes,
|
|
8
9
|
buildContextualTargeting,
|
|
9
10
|
buildParsedAdunit,
|
|
10
11
|
buildSizeMapping,
|
|
11
|
-
getMaxBannerHeight,
|
|
12
|
-
getMinBannerHeight,
|
|
13
12
|
setCustomTargetings
|
|
14
13
|
} from './helpers';
|
|
15
14
|
import {
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
PUBLISHED
|
|
20
19
|
} from '../../constants';
|
|
21
20
|
import { withTitle } from '../../HOC';
|
|
21
|
+
import AdSlotRender from './AdSlotRender';
|
|
22
22
|
|
|
23
23
|
const BannerRender = ({
|
|
24
24
|
baseAdunit,
|
|
@@ -43,8 +43,6 @@ const BannerRender = ({
|
|
|
43
43
|
skip: id && id !== itemId
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
const parsedTargetings = buildContextualTargeting(actionKey, entityRecordData, propsToDisplay);
|
|
47
|
-
|
|
48
46
|
const { data: bannerData = {} } = useQuery(
|
|
49
47
|
generateSingleItemQuery(GET_BANNER, BANNER_QUERY_PROPS),
|
|
50
48
|
{
|
|
@@ -52,13 +50,6 @@ const BannerRender = ({
|
|
|
52
50
|
skip: !sizeId
|
|
53
51
|
}
|
|
54
52
|
);
|
|
55
|
-
const { entityData } = bannerData;
|
|
56
|
-
const { sizes: bannerSizes } = entityData || {};
|
|
57
|
-
|
|
58
|
-
const sizeMapping = buildSizeMapping(sizeId, bannerSizes);
|
|
59
|
-
const parsedSizes = buildBannerSizes(sizeId, bannerSizes, sizes);
|
|
60
|
-
const maxBannerHeight = getMaxBannerHeight(bannerSizes);
|
|
61
|
-
const minBannerHeight = getMinBannerHeight(bannerSizes);
|
|
62
53
|
|
|
63
54
|
const { data = {} } = useQuery(getCount(COUNT_CONTENT_HIERARCHIES), {
|
|
64
55
|
variables: {
|
|
@@ -71,6 +62,14 @@ const BannerRender = ({
|
|
|
71
62
|
}
|
|
72
63
|
});
|
|
73
64
|
|
|
65
|
+
const parsedTargetings = buildContextualTargeting(actionKey, entityRecordData, propsToDisplay);
|
|
66
|
+
|
|
67
|
+
const { entityData } = bannerData;
|
|
68
|
+
const { sizes: bannerSizes } = entityData || {};
|
|
69
|
+
|
|
70
|
+
const sizeMapping = buildSizeMapping(sizeId, bannerSizes);
|
|
71
|
+
const parsedSizes = buildBannerSizes(sizeId, bannerSizes, sizes);
|
|
72
|
+
|
|
74
73
|
const { countContentHierarchies } = data;
|
|
75
74
|
|
|
76
75
|
const parsedAdunit = buildParsedAdunit(asPath, countContentHierarchies, baseAdunit, adunit);
|
|
@@ -80,23 +79,19 @@ const BannerRender = ({
|
|
|
80
79
|
const shouldShowBanner =
|
|
81
80
|
parsedAdunit && parsedSizes && !!parsedSizes.length && isContextualTargetingReady;
|
|
82
81
|
|
|
83
|
-
if (!shouldShowBanner) return null;
|
|
84
82
|
const customTargetings = setCustomTargetings(targetings, cardBannerIndex);
|
|
85
|
-
|
|
86
|
-
maxHeight: maxBannerHeight,
|
|
87
|
-
minHeight: minBannerHeight
|
|
88
|
-
};
|
|
83
|
+
|
|
89
84
|
const targetingArguments = { ...parsedTargetings, ...customTargetings };
|
|
90
85
|
|
|
91
86
|
return (
|
|
92
|
-
<
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
87
|
+
<AdSlotRender
|
|
88
|
+
shouldShowBanner={!!shouldShowBanner}
|
|
89
|
+
sizeMapping={sizeMapping}
|
|
90
|
+
sizeId={sizeId}
|
|
91
|
+
parsedAdunit={parsedAdunit}
|
|
92
|
+
parsedSizes={parsedSizes}
|
|
93
|
+
targetingArguments={targetingArguments}
|
|
94
|
+
/>
|
|
100
95
|
);
|
|
101
96
|
};
|
|
102
97
|
|
package/src/components/Button.js
CHANGED
|
@@ -3,7 +3,7 @@ import { useCookies } from 'react-cookie';
|
|
|
3
3
|
import { useRouter } from 'next/router';
|
|
4
4
|
import BlazeButton from '@blaze-react/button';
|
|
5
5
|
import { handleLogout } from '@blaze-cms/core-auth-ui';
|
|
6
|
-
import { useApolloClient } from '
|
|
6
|
+
import { useApolloClient } from '@apollo/client';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import ClickWrapper from './ClickWrapper';
|
|
9
9
|
import BlazeLink from './BlazeLink';
|
|
@@ -28,6 +28,8 @@ const CardContainer = ({
|
|
|
28
28
|
enableCarousel,
|
|
29
29
|
bannerModifier,
|
|
30
30
|
priorityLimit,
|
|
31
|
+
enableAutoScroll,
|
|
32
|
+
autoScrollTimer,
|
|
31
33
|
...cardProps
|
|
32
34
|
}) => {
|
|
33
35
|
const entities = getEntitiesWithBanner(cardData, cardProps);
|
|
@@ -44,7 +46,9 @@ const CardContainer = ({
|
|
|
44
46
|
className={dynamicWrapperSizes}
|
|
45
47
|
modifiers={gridModifier}
|
|
46
48
|
itemsPerRow={itemsPerRow}
|
|
47
|
-
bannerModifier={bannerModifier}
|
|
49
|
+
bannerModifier={bannerModifier}
|
|
50
|
+
enableAutoScroll={enableAutoScroll}
|
|
51
|
+
autoScrollTimer={autoScrollTimer}>
|
|
48
52
|
{entities.map(({ baseAdunit, id, ...entityProps }, index) => {
|
|
49
53
|
const extraProps = parsePropsToDisplay(entityProps, propsToDisplay);
|
|
50
54
|
const dynamicKey = [itemId, index].join('-');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getStringTypeProps } from '@blaze-cms/utils';
|
|
1
|
+
import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';
|
|
2
2
|
import { getGenericRenderVariables, buildRawQueryBase, buildSetFilters } from '../../../helpers';
|
|
3
3
|
import { DEFAULT_LIMIT } from '../../../constants';
|
|
4
4
|
|
|
@@ -2,17 +2,46 @@ import React, { useRef, useState, useEffect } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa';
|
|
4
4
|
|
|
5
|
-
const CarouselWrapper = ({
|
|
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 id = setInterval(scrollCheck, autoScrollTimer);
|
|
21
|
+
function scrollCheck() {
|
|
22
|
+
if (!autoScrollRef.current) {
|
|
23
|
+
clearInterval(id);
|
|
24
|
+
} else {
|
|
25
|
+
handleButtonNavigation(true);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
13
28
|
|
|
14
|
-
|
|
15
|
-
|
|
29
|
+
return () => clearInterval(id);
|
|
30
|
+
},
|
|
31
|
+
[autoScrollTimer, shouldAutoScroll]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
useEffect(
|
|
35
|
+
() => {
|
|
36
|
+
const {
|
|
37
|
+
current: { offsetWidth, scrollWidth }
|
|
38
|
+
} = ref;
|
|
39
|
+
if (scrollWidth <= offsetWidth)
|
|
40
|
+
setButtonDisplays({ displayLeft: false, displayRight: false });
|
|
41
|
+
setShouldAutoScroll(enableAutoScroll);
|
|
42
|
+
},
|
|
43
|
+
[enableAutoScroll]
|
|
44
|
+
);
|
|
16
45
|
|
|
17
46
|
const handleScroll = () => {
|
|
18
47
|
const {
|
|
@@ -24,36 +53,48 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
|
|
|
24
53
|
};
|
|
25
54
|
|
|
26
55
|
const handleButtonNavigation = direction => {
|
|
56
|
+
if (!ref || !ref.current) return;
|
|
27
57
|
const {
|
|
28
|
-
current: { offsetWidth, scrollLeft }
|
|
58
|
+
current: { offsetWidth, scrollLeft, scrollWidth }
|
|
29
59
|
} = ref;
|
|
30
|
-
|
|
60
|
+
|
|
61
|
+
if (autoScrollRef.current && scrollLeft + offsetWidth >= scrollWidth) {
|
|
62
|
+
ref.current.scrollLeft = 0;
|
|
63
|
+
} else {
|
|
64
|
+
ref.current.scrollLeft = direction ? scrollLeft + offsetWidth : scrollLeft - offsetWidth;
|
|
65
|
+
}
|
|
31
66
|
};
|
|
32
67
|
|
|
33
68
|
const { displayLeft, displayRight } = buttonDisplay;
|
|
34
|
-
const wrapperClassName = `
|
|
35
|
-
const contentClassName = `
|
|
69
|
+
const wrapperClassName = `cards-carousel${bannerModifier}`;
|
|
70
|
+
const contentClassName = `cards-carousel--content items-per-row-${itemsPerRow}`;
|
|
36
71
|
|
|
37
72
|
return (
|
|
38
73
|
<div className={wrapperClassName}>
|
|
39
|
-
<div className="
|
|
74
|
+
<div className="cards-carousel--left-button-wrapper">
|
|
40
75
|
{displayLeft && (
|
|
41
76
|
<button
|
|
42
77
|
type="button"
|
|
43
|
-
className="
|
|
44
|
-
onClick={() =>
|
|
78
|
+
className="cards-carousel--button-back icon-button icon"
|
|
79
|
+
onClick={() => {
|
|
80
|
+
setShouldAutoScroll(false);
|
|
81
|
+
handleButtonNavigation();
|
|
82
|
+
}}>
|
|
45
83
|
<i>
|
|
46
84
|
<FaAngleLeft />
|
|
47
85
|
</i>
|
|
48
86
|
</button>
|
|
49
87
|
)}
|
|
50
88
|
</div>
|
|
51
|
-
<div className="
|
|
89
|
+
<div className="cards-carousel--right-button-wrapper">
|
|
52
90
|
{displayRight && (
|
|
53
91
|
<button
|
|
54
92
|
type="button"
|
|
55
|
-
className="
|
|
56
|
-
onClick={() =>
|
|
93
|
+
className="cards-carousel--button-forward icon-button icon"
|
|
94
|
+
onClick={() => {
|
|
95
|
+
setShouldAutoScroll(false);
|
|
96
|
+
handleButtonNavigation(true);
|
|
97
|
+
}}>
|
|
57
98
|
<i>
|
|
58
99
|
<FaAngleRight />
|
|
59
100
|
</i>
|
|
@@ -70,13 +111,17 @@ const CarouselWrapper = ({ children, bannerModifier, itemsPerRow }) => {
|
|
|
70
111
|
CarouselWrapper.propTypes = {
|
|
71
112
|
bannerModifier: PropTypes.string,
|
|
72
113
|
itemsPerRow: PropTypes.number,
|
|
73
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
114
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
115
|
+
enableAutoScroll: PropTypes.bool,
|
|
116
|
+
autoScrollTimer: PropTypes.number
|
|
74
117
|
};
|
|
75
118
|
|
|
76
119
|
CarouselWrapper.defaultProps = {
|
|
77
120
|
itemsPerRow: 0,
|
|
78
121
|
bannerModifier: '',
|
|
79
|
-
children: []
|
|
122
|
+
children: [],
|
|
123
|
+
enableAutoScroll: false,
|
|
124
|
+
autoScrollTimer: 0
|
|
80
125
|
};
|
|
81
126
|
|
|
82
127
|
export default CarouselWrapper;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { useQuery } from '@apollo/
|
|
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';
|
|
@@ -1,42 +1,80 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import BlazeButton from '@blaze-react/button';
|
|
4
|
-
import { MdMenu } from 'react-icons/md';
|
|
4
|
+
import { MdMenu, MdClose } from 'react-icons/md';
|
|
5
5
|
import { useCheckMobileScreen } from '../../hooks';
|
|
6
6
|
import { HIDDEN } from '../../constants';
|
|
7
7
|
|
|
8
|
-
const Menu = ({
|
|
8
|
+
const Menu = ({
|
|
9
|
+
children,
|
|
10
|
+
collapse,
|
|
11
|
+
modifier,
|
|
12
|
+
mobileMenuModifier,
|
|
13
|
+
mobileMenuChildrenModifier,
|
|
14
|
+
mobileIconAlignment,
|
|
15
|
+
mobileButtonModifier,
|
|
16
|
+
hamburgerIconModifier,
|
|
17
|
+
closeIconModifier,
|
|
18
|
+
...rest
|
|
19
|
+
}) => {
|
|
9
20
|
const isMobile = useCheckMobileScreen();
|
|
10
21
|
const [showMobileMenu, setShowMobileMenu] = useState(false);
|
|
11
22
|
|
|
12
23
|
const shouldDisplayCollapsed = collapse && isMobile;
|
|
13
|
-
const mobileButtonClass = shouldDisplayCollapsed && isMobile ?
|
|
24
|
+
const mobileButtonClass = shouldDisplayCollapsed && isMobile ? mobileButtonModifier : HIDDEN;
|
|
14
25
|
const shouldDisplayChildren = shouldDisplayCollapsed ? showMobileMenu : true;
|
|
15
|
-
const
|
|
26
|
+
const childrenDesktopModifier =
|
|
27
|
+
shouldDisplayChildren && !isMobile ? modifier : `${modifier} ${HIDDEN}`;
|
|
28
|
+
|
|
29
|
+
const childrenMobileModifier =
|
|
30
|
+
shouldDisplayChildren && isMobile ? `${mobileMenuChildrenModifier}` : ` ${HIDDEN}`;
|
|
31
|
+
|
|
32
|
+
const isMobileMenuExpanded = showMobileMenu ? `${mobileMenuModifier}` : '';
|
|
16
33
|
|
|
17
34
|
return (
|
|
18
35
|
<>
|
|
19
36
|
{collapse && (
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
<div className="top-0 absolute z-50">
|
|
38
|
+
<div
|
|
39
|
+
className={`flex w-screen z-50 justify-${mobileIconAlignment} ${isMobileMenuExpanded}`}>
|
|
40
|
+
<BlazeButton
|
|
41
|
+
className={mobileButtonClass}
|
|
42
|
+
onClick={() => setShowMobileMenu(!showMobileMenu)}>
|
|
43
|
+
<i>
|
|
44
|
+
{showMobileMenu ? (
|
|
45
|
+
<MdClose className={closeIconModifier} />
|
|
46
|
+
) : (
|
|
47
|
+
<MdMenu className={hamburgerIconModifier} />
|
|
48
|
+
)}
|
|
49
|
+
</i>
|
|
50
|
+
</BlazeButton>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
27
53
|
)}
|
|
28
|
-
<ul className={
|
|
54
|
+
<ul className={isMobile ? childrenMobileModifier : childrenDesktopModifier}>{children}</ul>
|
|
29
55
|
</>
|
|
30
56
|
);
|
|
31
57
|
};
|
|
32
58
|
|
|
33
59
|
Menu.propTypes = {
|
|
34
60
|
collapse: PropTypes.bool.isRequired,
|
|
61
|
+
hamburgerIconModifier: PropTypes.string,
|
|
62
|
+
closeIconModifier: PropTypes.string,
|
|
63
|
+
mobileButtonModifier: PropTypes.string,
|
|
64
|
+
mobileMenuModifier: PropTypes.string,
|
|
65
|
+
mobileMenuChildrenModifier: PropTypes.string,
|
|
35
66
|
modifier: PropTypes.string,
|
|
67
|
+
mobileIconAlignment: PropTypes.string,
|
|
36
68
|
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
37
69
|
};
|
|
38
70
|
|
|
39
71
|
Menu.defaultProps = {
|
|
72
|
+
hamburgerIconModifier: '',
|
|
73
|
+
closeIconModifier: '',
|
|
74
|
+
mobileButtonModifier: '',
|
|
75
|
+
mobileIconAlignment: '',
|
|
76
|
+
mobileMenuModifier: '',
|
|
77
|
+
mobileMenuChildrenModifier: '',
|
|
40
78
|
modifier: '',
|
|
41
79
|
children: []
|
|
42
80
|
};
|
|
@@ -2,7 +2,7 @@ import React, { useState } from 'react';
|
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import Input from '@blaze-react/input';
|
|
4
4
|
import Button from '@blaze-react/button';
|
|
5
|
-
import { useMutation } from '
|
|
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';
|