@blaze-cms/react-page-builder 0.146.0-core-styles.3 → 0.146.0-core-styles.7
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 +22 -0
- package/lib/components/Image/Lightbox/Lightbox.js +2 -2
- package/lib/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/Modal/Modal.js +2 -2
- package/lib/components/Modal/Modal.js.map +1 -1
- package/lib/components/ModalAdapter/ModalAdapter.js +21 -0
- package/lib/components/ModalAdapter/ModalAdapter.js.map +1 -0
- package/lib/components/ModalAdapter/index.js +11 -0
- package/lib/components/ModalAdapter/index.js.map +1 -0
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +14 -25
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-list-name-query.js +31 -0
- package/lib/components/SearchFilter/helpers/build-list-name-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +7 -0
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/Video/VideoModal.js +2 -2
- package/lib/components/Video/VideoModal.js.map +1 -1
- package/lib/helpers/build-filters-query.js.map +1 -1
- package/lib/hooks/index.js +7 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/use-portal.js +30 -0
- package/lib/hooks/use-portal.js.map +1 -0
- package/lib-es/components/Image/Lightbox/Lightbox.js +1 -1
- package/lib-es/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib-es/components/Modal/Modal.js +1 -1
- package/lib-es/components/Modal/Modal.js.map +1 -1
- package/lib-es/components/ModalAdapter/ModalAdapter.js +13 -0
- package/lib-es/components/ModalAdapter/ModalAdapter.js.map +1 -0
- package/lib-es/components/ModalAdapter/index.js +3 -0
- package/lib-es/components/ModalAdapter/index.js.map +1 -0
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +14 -17
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-list-name-query.js +15 -0
- package/lib-es/components/SearchFilter/helpers/build-list-name-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +2 -1
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/Video/VideoModal.js +1 -1
- package/lib-es/components/Video/VideoModal.js.map +1 -1
- package/lib-es/helpers/build-filters-query.js.map +1 -1
- package/lib-es/hooks/index.js +1 -0
- package/lib-es/hooks/index.js.map +1 -1
- package/lib-es/hooks/use-portal.js +14 -0
- package/lib-es/hooks/use-portal.js.map +1 -0
- package/package.json +2 -2
- package/src/components/Image/Lightbox/Lightbox.js +1 -1
- package/src/components/Modal/Modal.js +1 -1
- package/src/components/ModalAdapter/ModalAdapter.js +12 -0
- package/src/components/ModalAdapter/index.js +3 -0
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +1 -2
- package/src/components/SearchFilter/SearchFilterContainer.js +10 -21
- package/src/components/SearchFilter/helpers/build-list-name-query.js +18 -0
- package/src/components/SearchFilter/helpers/index.js +2 -0
- package/src/components/Video/VideoModal.js +1 -1
- package/src/helpers/build-filters-query.js +0 -1
- package/src/hooks/index.js +1 -0
- package/src/hooks/use-portal.js +18 -0
- package/tests/unit/src/components/Image/Lightbox/Lightbox.test.js +4 -0
- package/tests/unit/src/components/Image/Lightbox/__snapshots__/Lightbox.test.js.snap +3 -38
- package/tests/unit/src/components/Modal/Modal.test.js +4 -0
- package/tests/unit/src/components/Modal/__snapshots__/Modal.test.js.snap +7 -42
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +7 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.146.0-core-styles.
|
|
3
|
+
"version": "0.146.0-core-styles.7",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"lib/*",
|
|
91
91
|
"lib-es/*"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "b811f3e32b6d7faaaf35fad93a76a0b7bbf76468"
|
|
94
94
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Modal from '@blaze-react/modal';
|
|
4
3
|
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
5
4
|
import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
|
|
5
|
+
import Modal from '../../ModalAdapter';
|
|
6
6
|
import BlazeLink from '../../BlazeLink';
|
|
7
7
|
import { IN_VIEW_CONFIG } from '../../../constants';
|
|
8
8
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import BlazeModal from '
|
|
3
|
+
import BlazeModal from '../ModalAdapter';
|
|
4
4
|
import { renderChildren, updateChildrensParent, hasChildren } from '../../helpers';
|
|
5
5
|
|
|
6
6
|
const Modal = ({ children, elementTitle, onClose, ...otherProps }) => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Modal from '@blaze-react/modal';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { usePortal } from '../../hooks';
|
|
5
|
+
|
|
6
|
+
const ModalAdapter = ({ ...props }) => {
|
|
7
|
+
const target = usePortal();
|
|
8
|
+
|
|
9
|
+
return ReactDOM.createPortal(<Modal {...props} />, target);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default ModalAdapter;
|
|
@@ -3,11 +3,10 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import debounce from 'lodash.debounce';
|
|
5
5
|
import FiltersList from './FiltersList';
|
|
6
|
-
import { isDeviceDesktop, getResponsiveFilterClassnames, buildUrlQuery } from '../helpers';
|
|
7
|
-
|
|
8
6
|
import CloseMobileForm from './CloseMobileForm';
|
|
9
7
|
import ResetDesktopForm from './ResetDesktopForm';
|
|
10
8
|
import MobileFormToolbar from './MobileFormToolbar';
|
|
9
|
+
import { isDeviceDesktop, getResponsiveFilterClassnames, buildUrlQuery } from '../helpers';
|
|
11
10
|
import { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';
|
|
12
11
|
|
|
13
12
|
const SearchFilter = ({
|
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
buildNewUrl,
|
|
12
12
|
getFilterValues,
|
|
13
13
|
getFilterRangesAndCheckboxesValues,
|
|
14
|
-
getUpdatedFilterBy
|
|
14
|
+
getUpdatedFilterBy,
|
|
15
|
+
buildListNameQuery
|
|
15
16
|
} from './helpers';
|
|
16
17
|
import {
|
|
17
18
|
getEntityData,
|
|
@@ -25,23 +26,6 @@ import { SCROLL_OFFSET } from '../../constants';
|
|
|
25
26
|
import searchFilterReducer from './searchFilterReducer';
|
|
26
27
|
import { useGetEntitySchemasAsObj } from '../../hooks';
|
|
27
28
|
|
|
28
|
-
const getFiltersUrlQuery = (query, listName) => {
|
|
29
|
-
if (!listName) return query;
|
|
30
|
-
const updatedQuery = {};
|
|
31
|
-
const listKey = `pb[${listName}]`;
|
|
32
|
-
Object.keys(query).forEach(queryKey => {
|
|
33
|
-
const isListKey = queryKey.indexOf(`${listName}`) !== -1;
|
|
34
|
-
if (!isListKey) return;
|
|
35
|
-
const decodedQueryValue = Array.isArray(query[queryKey])
|
|
36
|
-
? query[queryKey].map(value => decodeURIComponent(value))
|
|
37
|
-
: decodeURIComponent(query[queryKey]);
|
|
38
|
-
const strippedKey = queryKey.substring(listKey.length + 1, queryKey.length - 1);
|
|
39
|
-
if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
return updatedQuery;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
29
|
const SearchFilterContainer = ({
|
|
46
30
|
entity,
|
|
47
31
|
url,
|
|
@@ -65,15 +49,20 @@ const SearchFilterContainer = ({
|
|
|
65
49
|
const [urlPath, setUrlPath] = useState(asPath); // used as asPath can take too long to update
|
|
66
50
|
const [filterValues, dispatch] = useReducer(searchFilterReducer, null);
|
|
67
51
|
const { url: currentUrl, query } = parseUrl(urlPath);
|
|
68
|
-
const updatedQuery =
|
|
52
|
+
const updatedQuery = buildListNameQuery(query, listComponentName);
|
|
69
53
|
const { itemId: parentId, itemEntity: parentEntity } = parent;
|
|
70
54
|
|
|
71
55
|
useEffect(
|
|
72
56
|
() => {
|
|
73
|
-
if (asPath)
|
|
57
|
+
if (!asPath) return;
|
|
58
|
+
const { query: newQuery } = parseUrl(asPath);
|
|
59
|
+
const asPathQuery = buildListNameQuery(newQuery, listComponentName);
|
|
60
|
+
if (asPathQuery) dispatch({ newValues: asPathQuery, shouldSearch: false, type: 'update' });
|
|
61
|
+
setUrlPath(asPath);
|
|
74
62
|
},
|
|
75
|
-
[asPath]
|
|
63
|
+
[asPath, listComponentName]
|
|
76
64
|
);
|
|
65
|
+
|
|
77
66
|
const { data: mainSchemas = {}, loading: schemasLoading } = useGetEntitySchemasAsObj([
|
|
78
67
|
parentEntity,
|
|
79
68
|
entity
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const buildListNameQuery = (query, listName) => {
|
|
2
|
+
if (!listName) return query;
|
|
3
|
+
const updatedQuery = {};
|
|
4
|
+
const listKey = `pb[${listName}]`;
|
|
5
|
+
Object.keys(query).forEach(queryKey => {
|
|
6
|
+
const isListKey = queryKey.indexOf(`${listName}`) !== -1;
|
|
7
|
+
if (!isListKey) return;
|
|
8
|
+
const decodedQueryValue = Array.isArray(query[queryKey])
|
|
9
|
+
? query[queryKey].map(value => decodeURIComponent(value))
|
|
10
|
+
: decodeURIComponent(query[queryKey]);
|
|
11
|
+
const strippedKey = queryKey.substring(listKey.length + 1, queryKey.length - 1);
|
|
12
|
+
if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
return updatedQuery;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default buildListNameQuery;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import buildListNameQuery from './build-list-name-query';
|
|
1
2
|
import buildNewUrl from './build-new-url';
|
|
2
3
|
import { decodeValue, encodeValue } from './decode-encode';
|
|
3
4
|
import checkIfRangeUpdated from './check-if-range-updated';
|
|
@@ -16,6 +17,7 @@ import getUpdatedFilterBy from './get-updated-filter-by';
|
|
|
16
17
|
import buildUrlQuery from './build-url-query';
|
|
17
18
|
|
|
18
19
|
export {
|
|
20
|
+
buildListNameQuery,
|
|
19
21
|
buildNewUrl,
|
|
20
22
|
decodeValue,
|
|
21
23
|
encodeValue,
|
package/src/hooks/index.js
CHANGED
|
@@ -7,3 +7,4 @@ export { default as useGetSingleEntitySchema } from './use-get-single-entity-sch
|
|
|
7
7
|
export { default as useCheckMobileScreen } from './use-check-mobile-screen';
|
|
8
8
|
export { default as useBannerInsertion } from './use-banner-insertion';
|
|
9
9
|
export { default as useAppSyncEventHook } from './use-app-sync-event-hook';
|
|
10
|
+
export { default as usePortal } from './use-portal';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
function usePortal() {
|
|
4
|
+
const rootElemRef = React.useRef(document.createElement('div'));
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
document.body.appendChild(rootElemRef.current);
|
|
8
|
+
|
|
9
|
+
const element = rootElemRef.current;
|
|
10
|
+
return function removeElement() {
|
|
11
|
+
element.remove();
|
|
12
|
+
};
|
|
13
|
+
}, []);
|
|
14
|
+
|
|
15
|
+
return rootElemRef.current;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default usePortal;
|
|
@@ -10,6 +10,10 @@ jest.mock('../../../../../../src/components/Banner', () =>
|
|
|
10
10
|
jest.fn().mockImplementation(() => <span>Banner</span>)
|
|
11
11
|
);
|
|
12
12
|
|
|
13
|
+
jest.mock('../../../../../../src/components/ModalAdapter', () =>
|
|
14
|
+
jest.fn().mockImplementation(({ children }) => children)
|
|
15
|
+
);
|
|
16
|
+
|
|
13
17
|
const mockProps = {
|
|
14
18
|
imageUrl: 'some-url',
|
|
15
19
|
altTxt: 'atl text',
|
|
@@ -3,48 +3,13 @@
|
|
|
3
3
|
exports[`LightBox component should render without throwing an error and match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="
|
|
7
|
-
/>
|
|
8
|
-
<div
|
|
9
|
-
class=" modal modal--show modal--full-screen"
|
|
6
|
+
class="row row--display-row"
|
|
10
7
|
>
|
|
11
8
|
<div
|
|
12
|
-
class="
|
|
13
|
-
>
|
|
14
|
-
<div
|
|
15
|
-
class="modal__title"
|
|
16
|
-
/>
|
|
17
|
-
<div
|
|
18
|
-
class="modal__close"
|
|
19
|
-
role="button"
|
|
20
|
-
>
|
|
21
|
-
<i
|
|
22
|
-
class="material-icons"
|
|
23
|
-
>
|
|
24
|
-
close
|
|
25
|
-
</i>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
<div
|
|
29
|
-
class="modal__content"
|
|
30
|
-
>
|
|
31
|
-
<div
|
|
32
|
-
class="row row--display-row"
|
|
33
|
-
>
|
|
34
|
-
<div
|
|
35
|
-
class="column column--two-thirds"
|
|
36
|
-
>
|
|
37
|
-
<div
|
|
38
|
-
class="image"
|
|
39
|
-
/>
|
|
40
|
-
</div>
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
<div
|
|
44
|
-
class="modal__footer"
|
|
9
|
+
class="column column--two-thirds"
|
|
45
10
|
>
|
|
46
11
|
<div
|
|
47
|
-
class="
|
|
12
|
+
class="image"
|
|
48
13
|
/>
|
|
49
14
|
</div>
|
|
50
15
|
</div>
|
|
@@ -19,6 +19,10 @@ const props = {
|
|
|
19
19
|
]
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
+
jest.mock('../../../../../src/components/ModalAdapter', () =>
|
|
23
|
+
jest.fn().mockImplementation(({ children }) => children)
|
|
24
|
+
);
|
|
25
|
+
|
|
22
26
|
describe('Modal component', () => {
|
|
23
27
|
it('should be defined', () => {
|
|
24
28
|
expect(Modal).toBeDefined();
|
|
@@ -3,50 +3,15 @@
|
|
|
3
3
|
exports[`Modal component should render without throwing an error and match snapshot 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<div
|
|
6
|
-
class="
|
|
7
|
-
|
|
6
|
+
class="child_1"
|
|
7
|
+
>
|
|
8
|
+
some stuff
|
|
9
|
+
</div>
|
|
8
10
|
<div
|
|
9
|
-
class="
|
|
11
|
+
class="child_2"
|
|
12
|
+
modifier="child-modi"
|
|
10
13
|
>
|
|
11
|
-
|
|
12
|
-
class="modal__header"
|
|
13
|
-
>
|
|
14
|
-
<div
|
|
15
|
-
class="modal__title"
|
|
16
|
-
/>
|
|
17
|
-
<div
|
|
18
|
-
class="modal__close"
|
|
19
|
-
role="button"
|
|
20
|
-
>
|
|
21
|
-
<i
|
|
22
|
-
class="material-icons"
|
|
23
|
-
>
|
|
24
|
-
close
|
|
25
|
-
</i>
|
|
26
|
-
</div>
|
|
27
|
-
</div>
|
|
28
|
-
<div
|
|
29
|
-
class="modal__content"
|
|
30
|
-
>
|
|
31
|
-
<div
|
|
32
|
-
class="child_1"
|
|
33
|
-
>
|
|
34
|
-
some stuff
|
|
35
|
-
</div>
|
|
36
|
-
<div
|
|
37
|
-
class="child_2"
|
|
38
|
-
modifier="child-modi"
|
|
39
|
-
>
|
|
40
|
-
another child
|
|
41
|
-
</div>
|
|
42
|
-
</div>
|
|
43
|
-
<div
|
|
44
|
-
class="modal__footer"
|
|
45
|
-
>
|
|
46
|
-
<div
|
|
47
|
-
class="modal__button"
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
14
|
+
another child
|
|
50
15
|
</div>
|
|
51
16
|
</DocumentFragment>
|
|
52
17
|
`;
|
package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`SearchFilter container should match snapshot 1`] =
|
|
3
|
+
exports[`SearchFilter container should match snapshot 1`] = `
|
|
4
|
+
<DocumentFragment>
|
|
5
|
+
<div>
|
|
6
|
+
Mocked component
|
|
7
|
+
</div>
|
|
8
|
+
</DocumentFragment>
|
|
9
|
+
`;
|
|
4
10
|
|
|
5
11
|
exports[`SearchFilter container should return null if no filters are passed 1`] = `<DocumentFragment />`;
|