@blaze-cms/react-page-builder 0.146.0-alpha.0 → 0.146.0-alpha.13
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 +86 -0
- package/lib/components/BackToTop/BackToTop.js +8 -13
- package/lib/components/BackToTop/BackToTop.js.map +1 -1
- package/lib/components/Card/Card.js +19 -12
- package/lib/components/Card/Card.js.map +1 -1
- package/lib/components/Card/CardsContainer.js +8 -4
- package/lib/components/Card/CardsContainer.js.map +1 -1
- package/lib/components/Card/CardsFactory.js +37 -7
- package/lib/components/Card/CardsFactory.js.map +1 -1
- package/lib/components/Card/CardsRender.js +8 -4
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/index.js +6 -6
- package/lib/components/Card/helpers/index.js.map +1 -1
- package/lib/components/Carousel/CarouselImage/CarouselImage.js +3 -1
- package/lib/components/Carousel/CarouselImage/CarouselImage.js.map +1 -1
- package/lib/components/Carousel/CarouselImage/constants.js +9 -0
- package/lib/components/Carousel/CarouselImage/constants.js.map +1 -0
- package/lib/components/CarouselWrapper/DefaultCarousel.js +2 -0
- package/lib/components/CarouselWrapper/DefaultCarousel.js.map +1 -1
- package/lib/components/ContentGroup/ContentGroupTabs.js +1 -2
- package/lib/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/GlobalLightbox.js +3 -3
- package/lib/components/Image/GlobalLightbox/GlobalLightbox.js.map +1 -1
- package/lib/components/Image/GlobalLightbox/NavButton.js +6 -3
- package/lib/components/Image/GlobalLightbox/NavButton.js.map +1 -1
- package/lib/components/Image/Image.js +1 -0
- package/lib/components/Image/Image.js.map +1 -1
- package/lib/components/Image/Lightbox/Lightbox.js +2 -2
- package/lib/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/ItemList/ItemListNew/ItemListNew.js +1 -2
- package/lib/components/ItemList/ItemListNew/ItemListNew.js.map +1 -1
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib/components/List/components/Full/FullRender.js +2 -2
- package/lib/components/List/components/Full/FullRender.js.map +1 -1
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/MenuItem/MenuEntitiesItem.js +203 -0
- package/lib/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +25 -71
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/MenuItemRender.js +104 -0
- package/lib/components/MenuItem/MenuItemRender.js.map +1 -0
- package/lib/components/MenuItem/helpers/index.js +15 -0
- package/lib/components/MenuItem/helpers/index.js.map +1 -0
- package/lib/components/MenuItem/helpers/inject-helper-into-template.js +17 -0
- package/lib/components/MenuItem/helpers/inject-helper-into-template.js.map +1 -0
- 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/FiltersList.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/MobileFormToolbar.js +1 -1
- package/lib/components/SearchFilter/SearchFilter/MobileFormToolbar.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/ResetDesktopForm.js +3 -3
- package/lib/components/SearchFilter/SearchFilter/ResetDesktopForm.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +26 -7
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +23 -28
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +1 -0
- package/lib/components/SearchFilter/components/TextSearch.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/decode-encode.js.map +1 -1
- 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/components/Video/providers/Vimeo/VimeoProvider.js +0 -1
- package/lib/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
- package/lib/helpers/build-filters-query.js +1 -2
- package/lib/helpers/build-filters-query.js.map +1 -1
- package/lib/{components/Card/helpers → helpers}/filter-query-setup.js +10 -7
- package/lib/helpers/filter-query-setup.js.map +1 -0
- package/lib/{components/Card/helpers → helpers}/filters-setup.js +8 -5
- package/lib/helpers/filters-setup.js.map +1 -0
- package/lib/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib/helpers/get-updated-sort-properties.js.map +1 -0
- package/lib/helpers/index.js +42 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/should-return.js.map +1 -0
- package/lib/{components/Card/helpers → helpers}/should-skip-single-query.js +1 -1
- package/lib/helpers/should-skip-single-query.js.map +1 -0
- package/lib/hooks/index.js +14 -0
- package/lib/hooks/index.js.map +1 -1
- package/lib/hooks/use-filter-aggregation-values.js +54 -0
- package/lib/hooks/use-filter-aggregation-values.js.map +1 -0
- package/lib/hooks/use-portal.js +30 -0
- package/lib/hooks/use-portal.js.map +1 -0
- package/lib-es/components/BackToTop/BackToTop.js +11 -17
- package/lib-es/components/BackToTop/BackToTop.js.map +1 -1
- package/lib-es/components/Card/Card.js +19 -12
- package/lib-es/components/Card/Card.js.map +1 -1
- package/lib-es/components/Card/CardsContainer.js +9 -5
- package/lib-es/components/Card/CardsContainer.js.map +1 -1
- package/lib-es/components/Card/CardsFactory.js +40 -9
- package/lib-es/components/Card/CardsFactory.js.map +1 -1
- package/lib-es/components/Card/CardsRender.js +9 -5
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/index.js +6 -6
- package/lib-es/components/Card/helpers/index.js.map +1 -1
- package/lib-es/components/Carousel/CarouselImage/CarouselImage.js +3 -1
- package/lib-es/components/Carousel/CarouselImage/CarouselImage.js.map +1 -1
- package/lib-es/components/Carousel/CarouselImage/constants.js +2 -0
- package/lib-es/components/Carousel/CarouselImage/constants.js.map +1 -0
- package/lib-es/components/CarouselWrapper/DefaultCarousel.js +2 -0
- package/lib-es/components/CarouselWrapper/DefaultCarousel.js.map +1 -1
- package/lib-es/components/ContentGroup/ContentGroupTabs.js +1 -2
- package/lib-es/components/ContentGroup/ContentGroupTabs.js.map +1 -1
- package/lib-es/components/Image/GlobalLightbox/GlobalLightbox.js +3 -3
- package/lib-es/components/Image/GlobalLightbox/GlobalLightbox.js.map +1 -1
- package/lib-es/components/Image/GlobalLightbox/NavButton.js +6 -3
- package/lib-es/components/Image/GlobalLightbox/NavButton.js.map +1 -1
- package/lib-es/components/Image/Image.js +1 -0
- package/lib-es/components/Image/Image.js.map +1 -1
- 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/ItemList/ItemListNew/ItemListNew.js +1 -2
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js.map +1 -1
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/List/components/Cards/CardsRender.js.map +1 -1
- package/lib-es/components/List/components/Full/FullRender.js +2 -2
- package/lib-es/components/List/components/Full/FullRender.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +1 -1
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/MenuItem/MenuEntitiesItem.js +177 -0
- package/lib-es/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +28 -60
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/MenuItem/MenuItemRender.js +84 -0
- package/lib-es/components/MenuItem/MenuItemRender.js.map +1 -0
- package/lib-es/components/MenuItem/helpers/index.js +3 -0
- package/lib-es/components/MenuItem/helpers/index.js.map +1 -0
- package/lib-es/components/MenuItem/helpers/inject-helper-into-template.js +8 -0
- package/lib-es/components/MenuItem/helpers/inject-helper-into-template.js.map +1 -0
- 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/FiltersList.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/MobileFormToolbar.js +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/MobileFormToolbar.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/ResetDesktopForm.js +3 -3
- package/lib-es/components/SearchFilter/SearchFilter/ResetDesktopForm.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +19 -7
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +23 -20
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +1 -0
- package/lib-es/components/SearchFilter/components/TextSearch.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/decode-encode.js.map +1 -1
- 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/components/Video/providers/Vimeo/VimeoProvider.js +0 -1
- package/lib-es/components/Video/providers/Vimeo/VimeoProvider.js.map +1 -1
- package/lib-es/helpers/build-filters-query.js +1 -2
- package/lib-es/helpers/build-filters-query.js.map +1 -1
- package/lib-es/{components/Card/helpers → helpers}/filter-query-setup.js +5 -3
- package/lib-es/helpers/filter-query-setup.js.map +1 -0
- package/lib-es/{components/Card/helpers → helpers}/filters-setup.js +4 -2
- package/lib-es/helpers/filters-setup.js.map +1 -0
- package/lib-es/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib-es/helpers/get-updated-sort-properties.js.map +1 -0
- package/lib-es/helpers/index.js +6 -0
- package/lib-es/helpers/index.js.map +1 -1
- package/lib-es/helpers/should-return.js.map +1 -0
- package/lib-es/{components/Card/helpers → helpers}/should-skip-single-query.js +1 -1
- package/lib-es/helpers/should-skip-single-query.js.map +1 -0
- package/lib-es/hooks/index.js +2 -0
- package/lib-es/hooks/index.js.map +1 -1
- package/lib-es/hooks/use-filter-aggregation-values.js +31 -0
- package/lib-es/hooks/use-filter-aggregation-values.js.map +1 -0
- package/lib-es/hooks/use-portal.js +14 -0
- package/lib-es/hooks/use-portal.js.map +1 -0
- package/package.json +5 -5
- package/src/components/BackToTop/BackToTop.js +6 -11
- package/src/components/Card/Card.js +29 -19
- package/src/components/Card/CardsContainer.js +7 -3
- package/src/components/Card/CardsFactory.js +34 -6
- package/src/components/Card/CardsRender.js +6 -2
- package/src/components/Card/helpers/index.js +6 -6
- package/src/components/Carousel/CarouselImage/CarouselImage.js +3 -1
- package/src/components/Carousel/CarouselImage/constants.js +1 -0
- package/src/components/CarouselWrapper/DefaultCarousel.js +2 -0
- package/src/components/ContentGroup/ContentGroupTabs.js +1 -3
- package/src/components/Image/GlobalLightbox/GlobalLightbox.js +3 -3
- package/src/components/Image/GlobalLightbox/NavButton.js +5 -3
- package/src/components/Image/Image.js +1 -0
- package/src/components/Image/Lightbox/Lightbox.js +1 -1
- package/src/components/ItemList/ItemListNew/ItemListNew.js +1 -4
- package/src/components/List/ListRender.js +0 -1
- package/src/components/List/components/Cards/CardsRender.js +2 -0
- package/src/components/List/components/Full/FullRender.js +2 -1
- package/src/components/Menu/Menu.js +1 -1
- package/src/components/MenuItem/MenuEntitiesItem.js +202 -0
- package/src/components/MenuItem/MenuItem.js +15 -65
- package/src/components/MenuItem/MenuItemRender.js +92 -0
- package/src/components/MenuItem/helpers/index.js +3 -0
- package/src/components/MenuItem/helpers/inject-helper-into-template.js +11 -0
- 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/FiltersList.js +3 -0
- package/src/components/SearchFilter/SearchFilter/MobileFormToolbar.js +1 -1
- package/src/components/SearchFilter/SearchFilter/ResetDesktopForm.js +3 -2
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +26 -10
- package/src/components/SearchFilter/SearchFilterContainer.js +21 -22
- package/src/components/SearchFilter/components/Checkbox.js +3 -1
- package/src/components/SearchFilter/components/Select.js +2 -0
- package/src/components/SearchFilter/components/TextSearch.js +1 -0
- package/src/components/SearchFilter/helpers/build-list-name-query.js +18 -0
- package/src/components/SearchFilter/helpers/decode-encode.js +0 -1
- package/src/components/SearchFilter/helpers/index.js +2 -0
- package/src/components/Video/VideoModal.js +1 -1
- package/src/components/Video/providers/Vimeo/VimeoProvider.js +0 -1
- package/src/helpers/build-filters-query.js +1 -3
- package/src/{components/Card/helpers → helpers}/filter-query-setup.js +5 -3
- package/src/{components/Card/helpers → helpers}/filters-setup.js +5 -2
- package/src/helpers/index.js +6 -0
- package/src/{components/Card/helpers → helpers}/should-skip-single-query.js +1 -1
- package/src/hooks/index.js +2 -0
- package/src/hooks/use-filter-aggregation-values.js +37 -0
- package/src/hooks/use-portal.js +18 -0
- package/tests/unit/src/components/BackToTop/BackToTop.test.js +9 -5
- package/tests/unit/src/components/BackToTop/__snapshots__/BackToTop.test.js.snap +1 -1
- package/tests/unit/src/components/Card/Card.test.js +16 -1
- package/tests/unit/src/components/Card/__snapshots__/Card.test.js.snap +83 -0
- package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +1 -1
- package/tests/unit/src/components/Carousel/CarouselImage/__snapshots__/CarouselImage.test.js.snap +1 -1
- package/tests/unit/src/components/Carousel/__snapshots__/Carousel.test.js.snap +1 -1
- package/tests/unit/src/components/ContentGroup/__snapshots__/ContentGroupTabs.test.js.snap +4 -4
- 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/ItemList/__snapshots__/ItemListNew.test.js.snap +0 -2
- package/tests/unit/src/components/MenuItem/MenuEntitiesItem.test.js +23 -0
- package/tests/unit/src/components/MenuItem/MenuItem.test.js +30 -11
- package/tests/unit/src/components/MenuItem/MenuItemRender.test.js +55 -0
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuEntitiesItem.test.js.snap +3 -0
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +5 -56
- package/tests/unit/src/components/MenuItem/helpers/inject-helper-into-template.test.js +44 -0
- package/tests/unit/src/components/MenuItem/mocks.js +71 -0
- 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/SearchFilter/__snapshots__/MobileFormToolbar.test.js.snap +1 -1
- package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/ResetDesktopForm.test.js.snap +1 -1
- package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/SearchFilter.test.js.snap +19 -17
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +7 -1
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +1 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/TextSearch.test.js.snap +1 -0
- package/tests/unit/src/components/SearchFilterSort/__snapshots__/SearchFilterSort.test.js.snap +1 -0
- package/tests/unit/src/components/Video/providers/Vimeo/__snapshots__/Vimeo.test.js.snap +0 -1
- package/lib/components/Card/helpers/filter-query-setup.js.map +0 -1
- package/lib/components/Card/helpers/filters-setup.js.map +0 -1
- package/lib/components/Card/helpers/get-updated-items-to-display.js.map +0 -1
- package/lib/components/Card/helpers/get-updated-sort-properties.js.map +0 -1
- package/lib/components/Card/helpers/should-return.js.map +0 -1
- package/lib/components/Card/helpers/should-skip-single-query.js.map +0 -1
- package/lib-es/components/Card/helpers/filter-query-setup.js.map +0 -1
- package/lib-es/components/Card/helpers/filters-setup.js.map +0 -1
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +0 -1
- package/lib-es/components/Card/helpers/get-updated-sort-properties.js.map +0 -1
- package/lib-es/components/Card/helpers/should-return.js.map +0 -1
- package/lib-es/components/Card/helpers/should-skip-single-query.js.map +0 -1
- /package/lib/{components/Card/helpers → helpers}/get-updated-items-to-display.js +0 -0
- /package/lib/{components/Card/helpers → helpers}/get-updated-sort-properties.js +0 -0
- /package/lib/{components/Card/helpers → helpers}/should-return.js +0 -0
- /package/lib-es/{components/Card/helpers → helpers}/get-updated-items-to-display.js +0 -0
- /package/lib-es/{components/Card/helpers → helpers}/get-updated-sort-properties.js +0 -0
- /package/lib-es/{components/Card/helpers → helpers}/should-return.js +0 -0
- /package/src/{components/Card/helpers → helpers}/get-updated-items-to-display.js +0 -0
- /package/src/{components/Card/helpers → helpers}/get-updated-sort-properties.js +0 -0
- /package/src/{components/Card/helpers → helpers}/should-return.js +0 -0
|
@@ -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,
|
|
@@ -54,7 +38,8 @@ const SearchFilterContainer = ({
|
|
|
54
38
|
filterByProperty,
|
|
55
39
|
shouldAddFilters,
|
|
56
40
|
listComponentName,
|
|
57
|
-
parent
|
|
41
|
+
parent,
|
|
42
|
+
mobileRefineButtonText
|
|
58
43
|
}) => {
|
|
59
44
|
const { isPreview } = useContext(MainContext);
|
|
60
45
|
const router = useRouter();
|
|
@@ -65,15 +50,26 @@ const SearchFilterContainer = ({
|
|
|
65
50
|
const [urlPath, setUrlPath] = useState(asPath); // used as asPath can take too long to update
|
|
66
51
|
const [filterValues, dispatch] = useReducer(searchFilterReducer, null);
|
|
67
52
|
const { url: currentUrl, query } = parseUrl(urlPath);
|
|
68
|
-
const updatedQuery =
|
|
53
|
+
const updatedQuery = buildListNameQuery(query, listComponentName);
|
|
69
54
|
const { itemId: parentId, itemEntity: parentEntity } = parent;
|
|
70
55
|
|
|
71
56
|
useEffect(
|
|
72
57
|
() => {
|
|
73
|
-
|
|
58
|
+
const { query: newQuery } = parseUrl(asPath);
|
|
59
|
+
const updatedNewQuery = buildListNameQuery(newQuery, listComponentName);
|
|
60
|
+
const newValues = getFilterValues({}, filters, updatedNewQuery);
|
|
61
|
+
if (newValues)
|
|
62
|
+
dispatch({
|
|
63
|
+
newValues,
|
|
64
|
+
shouldSearch: false,
|
|
65
|
+
type: 'update'
|
|
66
|
+
});
|
|
67
|
+
setUrlPath(asPath);
|
|
74
68
|
},
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
75
70
|
[asPath]
|
|
76
71
|
);
|
|
72
|
+
|
|
77
73
|
const { data: mainSchemas = {}, loading: schemasLoading } = useGetEntitySchemasAsObj([
|
|
78
74
|
parentEntity,
|
|
79
75
|
entity
|
|
@@ -186,11 +182,13 @@ const SearchFilterContainer = ({
|
|
|
186
182
|
setDisplaySearchFilter={setDisplaySearchFilter}
|
|
187
183
|
groupAfterMobile={groupAfterMobile}
|
|
188
184
|
groupAfterDesktop={groupAfterDesktop}
|
|
185
|
+
mobileRefineButtonText={mobileRefineButtonText}
|
|
189
186
|
/>
|
|
190
187
|
);
|
|
191
188
|
};
|
|
192
189
|
|
|
193
190
|
SearchFilterContainer.propTypes = {
|
|
191
|
+
mobileRefineButtonText: PropTypes.string,
|
|
194
192
|
entity: PropTypes.string,
|
|
195
193
|
url: PropTypes.string,
|
|
196
194
|
filters: PropTypes.array,
|
|
@@ -216,7 +214,8 @@ SearchFilterContainer.defaultProps = {
|
|
|
216
214
|
filterByProperty: [],
|
|
217
215
|
shouldAddFilters: false,
|
|
218
216
|
listComponentName: '',
|
|
219
|
-
parent: {}
|
|
217
|
+
parent: {},
|
|
218
|
+
mobileRefineButtonText: ''
|
|
220
219
|
};
|
|
221
220
|
|
|
222
221
|
export default withTitle(SearchFilterContainer);
|
|
@@ -84,7 +84,9 @@ const Checkbox = ({
|
|
|
84
84
|
role="button"
|
|
85
85
|
className="see-more"
|
|
86
86
|
onClick={handleCheckboxOptions}
|
|
87
|
-
aria-label={
|
|
87
|
+
aria-label={
|
|
88
|
+
shouldDisplayMore ? `See ${MORE} ${label} options` : `See ${LESS} ${label} options`
|
|
89
|
+
}>
|
|
88
90
|
{shouldDisplayMore ? (
|
|
89
91
|
<>
|
|
90
92
|
<i>
|
|
@@ -17,6 +17,7 @@ const SelectFilter = ({
|
|
|
17
17
|
const filterValue = filterValues[prop] || '';
|
|
18
18
|
const disabledOptions = [];
|
|
19
19
|
const { buckets = [] } = data[prop] || {};
|
|
20
|
+
|
|
20
21
|
const options = buckets
|
|
21
22
|
.map(({ key, doc_count: count }) => {
|
|
22
23
|
if (!count) disabledOptions.push(key);
|
|
@@ -48,6 +49,7 @@ const SelectFilter = ({
|
|
|
48
49
|
onChange={({ value }) => {
|
|
49
50
|
let valueToUse = value;
|
|
50
51
|
if (value === defaultTextValue) valueToUse = '';
|
|
52
|
+
|
|
51
53
|
updateFilterValues({ [prop]: valueToUse }, shouldSearch);
|
|
52
54
|
}}
|
|
53
55
|
disabled={disabledOptions}
|
|
@@ -22,6 +22,7 @@ const TextSearch = ({ label, searchValue, updateFilterValues, elementTitle }) =>
|
|
|
22
22
|
<button
|
|
23
23
|
type="button"
|
|
24
24
|
className="icon-button icon-button--search"
|
|
25
|
+
aria-label="Search"
|
|
25
26
|
onClick={e => {
|
|
26
27
|
e.preventDefault();
|
|
27
28
|
updateFilterValues({ [SEARCH_TERM]: searchValue }, true);
|
|
@@ -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,
|
|
@@ -51,7 +51,6 @@ const VimeoProvider = ({ url, autoplay, loop, imageData }) => {
|
|
|
51
51
|
role="button"
|
|
52
52
|
className={VIDEO_WRAPPER_CLASS_NAME}
|
|
53
53
|
style={videoStyle}
|
|
54
|
-
aria-label="Open video"
|
|
55
54
|
onClick={() => !shouldRenderVideo && setShouldRenderVideo(true)}>
|
|
56
55
|
{shouldRenderVideo && !videoError && wrappedCode}
|
|
57
56
|
{videoError && videoError.message}
|
|
@@ -32,16 +32,14 @@ const builFilterObject = ({ queryKey, value, filters, isRange, isInQuery }) => {
|
|
|
32
32
|
|
|
33
33
|
const buildFiltersQuery = ({
|
|
34
34
|
shouldAddFilters,
|
|
35
|
-
|
|
36
35
|
filterBy,
|
|
37
36
|
filterByProperty,
|
|
38
37
|
rangeValues,
|
|
39
38
|
queryKeys,
|
|
40
39
|
query
|
|
41
40
|
}) => {
|
|
42
|
-
if (!shouldAddFilters) return [];
|
|
43
41
|
const mustFilters = [];
|
|
44
|
-
if (query) {
|
|
42
|
+
if (shouldAddFilters && query) {
|
|
45
43
|
Object.keys(query).forEach(queryKey => {
|
|
46
44
|
if (QUERY_KEYS_TO_IGNORE.includes(queryKey)) return;
|
|
47
45
|
if (!queryKey || !query[queryKey]) return;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import getGenericRenderVariables from './get-generic-render-variables';
|
|
3
|
+
import buildRawQueryBase from './build-raw-query-base';
|
|
4
|
+
import buildSetFilters from './build-set-filters';
|
|
5
|
+
import { DEFAULT_LIMIT } from '../constants';
|
|
4
6
|
|
|
5
7
|
const filterQuerySetup = ({
|
|
6
8
|
getEntitySchemas,
|
|
@@ -13,7 +15,7 @@ const filterQuerySetup = ({
|
|
|
13
15
|
itemsToDisplay,
|
|
14
16
|
entitySameAsCurrentItemEntity,
|
|
15
17
|
entitySchema,
|
|
16
|
-
useRandomSort
|
|
18
|
+
useRandomSort = false
|
|
17
19
|
}) => {
|
|
18
20
|
const stringProps = getStringTypeProps(entity, filterEntityRelations, getEntitySchemas);
|
|
19
21
|
const filterValues =
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import buildQueryFields from './build-query-fields';
|
|
2
|
+
import getInheritedFilters from './get-inherited-filters';
|
|
3
|
+
import getQueryProps from './get-query-props';
|
|
4
|
+
import { getSearchPublishedContent } from '../application/query';
|
|
3
5
|
|
|
4
6
|
const filtersSetup = ({
|
|
5
7
|
entityFields,
|
|
@@ -16,6 +18,7 @@ const filtersSetup = ({
|
|
|
16
18
|
const fields = buildQueryFields(entityFields, entityTypes, isFull);
|
|
17
19
|
const action = getSearchPublishedContent(fields);
|
|
18
20
|
const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);
|
|
21
|
+
|
|
19
22
|
const entitySameAsCurrentItemEntity = entities.includes(itemEntityUpdated);
|
|
20
23
|
const { relations: filterEntityRelations = [] } = filterEntitySchema;
|
|
21
24
|
const queryProps = getQueryProps(inheritedFilters, currentSchema, filterEntitySchema);
|
package/src/helpers/index.js
CHANGED
|
@@ -53,5 +53,11 @@ export { default as appendImages } from './append-images';
|
|
|
53
53
|
export { default as parseTextBlock } from './parse-TextBlock';
|
|
54
54
|
export { default as processDataSummaryValue } from './process-data-summary-value';
|
|
55
55
|
export { default as buildQueryKey } from './build-query-key';
|
|
56
|
+
export { default as filterQuerySetup } from './filter-query-setup';
|
|
57
|
+
export { default as filtersSetup } from './filters-setup';
|
|
58
|
+
export { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';
|
|
59
|
+
export { default as getUpdatedSortProperties } from './get-updated-sort-properties';
|
|
60
|
+
export { default as shouldReturn } from './should-return';
|
|
61
|
+
export { default as shouldSkipSingleQuery } from './should-skip-single-query';
|
|
56
62
|
export { default as buildRawQueryStringified } from './build-raw-query-stringified';
|
|
57
63
|
export { default as buildFiltersQuery } from './build-filters-query';
|
package/src/hooks/index.js
CHANGED
|
@@ -7,3 +7,5 @@ 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';
|
|
11
|
+
export { default as useFilterAggregationValues } from './use-filter-aggregation-values';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
const useFilterAggregationValues = ({ data, filterValues }) => {
|
|
4
|
+
const [stateValues, setStateValues] = useState(data);
|
|
5
|
+
const [prop, setProp] = useState('');
|
|
6
|
+
|
|
7
|
+
useEffect(
|
|
8
|
+
() => {
|
|
9
|
+
if (!stateValues) return setStateValues(data);
|
|
10
|
+
|
|
11
|
+
const lastChangedFilter = filterValues?.[prop];
|
|
12
|
+
|
|
13
|
+
if (!data) return;
|
|
14
|
+
|
|
15
|
+
const newOptions = data[prop];
|
|
16
|
+
const currentOptions = stateValues?.[prop];
|
|
17
|
+
|
|
18
|
+
if (lastChangedFilter === null || lastChangedFilter === '') {
|
|
19
|
+
return setStateValues(prevState => ({
|
|
20
|
+
...data,
|
|
21
|
+
[prop]: newOptions
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
setStateValues(prevState => ({
|
|
26
|
+
...data,
|
|
27
|
+
[prop]: currentOptions
|
|
28
|
+
}));
|
|
29
|
+
},
|
|
30
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
+
[data, prop, filterValues]
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return [stateValues, setStateValues, setProp, prop];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default useFilterAggregationValues;
|
|
@@ -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;
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
|
+
import React from 'react';
|
|
4
5
|
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
-
import { render } from '@
|
|
6
|
+
import { render, screen } from '@testing-library/react';
|
|
6
7
|
import BackToTop from '../../../../../src/components/BackToTop';
|
|
7
8
|
|
|
8
|
-
describe('
|
|
9
|
+
describe('BackToTop component', () => {
|
|
9
10
|
it('should be a function', () => {
|
|
10
11
|
expect(typeof BackToTop).toEqual('function');
|
|
11
12
|
});
|
|
12
13
|
|
|
13
14
|
it('should render without throwing an error and match snapshot', () => {
|
|
14
|
-
const { asFragment } = render(BackToTop
|
|
15
|
-
showAfterPixels: 500
|
|
16
|
-
});
|
|
15
|
+
const { asFragment } = render(<BackToTop showAfterPixels={500} />);
|
|
17
16
|
expect(asFragment()).toMatchSnapshot();
|
|
18
17
|
});
|
|
18
|
+
|
|
19
|
+
it('should not render the button initially', () => {
|
|
20
|
+
render(<BackToTop showAfterPixels={500} />);
|
|
21
|
+
expect(screen.queryByRole('link', { name: /back to top/i })).not.toBeInTheDocument();
|
|
22
|
+
});
|
|
19
23
|
});
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`
|
|
3
|
+
exports[`BackToTop component should render without throwing an error and match snapshot 1`] = `<DocumentFragment />`;
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
* @jest-environment jsdom
|
|
3
3
|
*/
|
|
4
4
|
import React from 'react';
|
|
5
|
-
import { render as _render, act, waitFor } from '@testing-library/react';
|
|
5
|
+
import { render as _render, act, waitFor, screen } from '@testing-library/react';
|
|
6
6
|
import '@testing-library/jest-dom/extend-expect';
|
|
7
|
+
import { setEnvs, deleteEnvs } from '@blaze-cms/tools/test-helpers/test-files/test-env';
|
|
7
8
|
import Card from '../../../../../src/components/Card/Card';
|
|
8
9
|
import { pageBuilderComponentsMocks } from './mockData';
|
|
9
10
|
|
|
@@ -211,4 +212,18 @@ describe('Card component', () => {
|
|
|
211
212
|
});
|
|
212
213
|
expect(getByTestId('full-card')).toBeInTheDocument();
|
|
213
214
|
});
|
|
215
|
+
|
|
216
|
+
it('should render link wrapper', async () => {
|
|
217
|
+
const envs = {
|
|
218
|
+
BLAZE_PB_ADD_CLICK_TO_CARDS: 'true'
|
|
219
|
+
};
|
|
220
|
+
setEnvs(envs);
|
|
221
|
+
const { asFragment } = await render(Card, {
|
|
222
|
+
...componentProps,
|
|
223
|
+
pageBuilderComponents: pageBuilderComponentsMocks
|
|
224
|
+
});
|
|
225
|
+
expect(screen.getByLabelText(componentProps.name)).toBeInTheDocument();
|
|
226
|
+
expect(asFragment()).toMatchSnapshot();
|
|
227
|
+
deleteEnvs(envs);
|
|
228
|
+
});
|
|
214
229
|
});
|
|
@@ -303,6 +303,89 @@ exports[`Card component should render customPreheader and alternativeHeadline in
|
|
|
303
303
|
</DocumentFragment>
|
|
304
304
|
`;
|
|
305
305
|
|
|
306
|
+
exports[`Card component should render link wrapper 1`] = `
|
|
307
|
+
<DocumentFragment>
|
|
308
|
+
<a
|
|
309
|
+
aria-label="mock name"
|
|
310
|
+
class="card card--portrait"
|
|
311
|
+
href="/mockurl"
|
|
312
|
+
>
|
|
313
|
+
<div
|
|
314
|
+
class="card__image card__image--portrait"
|
|
315
|
+
>
|
|
316
|
+
<div
|
|
317
|
+
class="card__image-link"
|
|
318
|
+
gtmid=""
|
|
319
|
+
>
|
|
320
|
+
<img
|
|
321
|
+
alt="test-altText"
|
|
322
|
+
src="test-url"
|
|
323
|
+
/>
|
|
324
|
+
</div>
|
|
325
|
+
</div>
|
|
326
|
+
<div
|
|
327
|
+
class="card__content-wrapper card__content-wrapper--portrait "
|
|
328
|
+
>
|
|
329
|
+
<div
|
|
330
|
+
class="card__content card__content--portrait"
|
|
331
|
+
>
|
|
332
|
+
<div
|
|
333
|
+
class="badge badge--label"
|
|
334
|
+
gtmid=""
|
|
335
|
+
href="published-url"
|
|
336
|
+
>
|
|
337
|
+
category-name
|
|
338
|
+
</div>
|
|
339
|
+
<div
|
|
340
|
+
class="card__title card__title--portrait "
|
|
341
|
+
>
|
|
342
|
+
<div
|
|
343
|
+
gtmid=""
|
|
344
|
+
title="mock name"
|
|
345
|
+
>
|
|
346
|
+
mock name
|
|
347
|
+
</div>
|
|
348
|
+
</div>
|
|
349
|
+
<div
|
|
350
|
+
class="card__item card__item--full"
|
|
351
|
+
data-testid="full-card"
|
|
352
|
+
/>
|
|
353
|
+
<div
|
|
354
|
+
class="card__details card__details--portrait"
|
|
355
|
+
>
|
|
356
|
+
<span
|
|
357
|
+
class=""
|
|
358
|
+
data-testid="some%20description"
|
|
359
|
+
>
|
|
360
|
+
some description
|
|
361
|
+
</span>
|
|
362
|
+
<span
|
|
363
|
+
class=""
|
|
364
|
+
>
|
|
365
|
+
extra props
|
|
366
|
+
</span>
|
|
367
|
+
</div>
|
|
368
|
+
</div>
|
|
369
|
+
<div
|
|
370
|
+
class="card__child-content"
|
|
371
|
+
>
|
|
372
|
+
<div
|
|
373
|
+
class="child_1"
|
|
374
|
+
>
|
|
375
|
+
some stuff
|
|
376
|
+
</div>
|
|
377
|
+
<div
|
|
378
|
+
class="child_2"
|
|
379
|
+
modifier="child-modi"
|
|
380
|
+
>
|
|
381
|
+
another child
|
|
382
|
+
</div>
|
|
383
|
+
</div>
|
|
384
|
+
</div>
|
|
385
|
+
</a>
|
|
386
|
+
</DocumentFragment>
|
|
387
|
+
`;
|
|
388
|
+
|
|
306
389
|
exports[`Card component should render without throwing an error and match snapshot 1`] = `
|
|
307
390
|
<DocumentFragment>
|
|
308
391
|
<div
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '@testing-library/jest-dom/extend-expect';
|
|
2
|
-
import getUpdatedItemsToDisplay from '../../../../../../src/
|
|
2
|
+
import getUpdatedItemsToDisplay from '../../../../../../src/helpers/get-updated-items-to-display';
|
|
3
3
|
|
|
4
4
|
const mockedProps = {
|
|
5
5
|
itemsToDisplay: [
|
|
@@ -11,7 +11,7 @@ exports[`ContentGroupTabs component should match snapshot and render sidepanel c
|
|
|
11
11
|
role="tablist"
|
|
12
12
|
>
|
|
13
13
|
<button
|
|
14
|
-
aria-controls="
|
|
14
|
+
aria-controls="section-one"
|
|
15
15
|
aria-selected="true"
|
|
16
16
|
class="content-group-sidepanel__button--is-active"
|
|
17
17
|
id="tab-section-one"
|
|
@@ -21,7 +21,7 @@ exports[`ContentGroupTabs component should match snapshot and render sidepanel c
|
|
|
21
21
|
sectionOne
|
|
22
22
|
</button>
|
|
23
23
|
<button
|
|
24
|
-
aria-controls="
|
|
24
|
+
aria-controls="section-two"
|
|
25
25
|
aria-selected="false"
|
|
26
26
|
class="content-group-sidepanel__button"
|
|
27
27
|
id="tab-section-two"
|
|
@@ -57,7 +57,7 @@ exports[`ContentGroupTabs component should match snapshot and render tabs conten
|
|
|
57
57
|
role="tablist"
|
|
58
58
|
>
|
|
59
59
|
<button
|
|
60
|
-
aria-controls="
|
|
60
|
+
aria-controls="section-one"
|
|
61
61
|
aria-selected="true"
|
|
62
62
|
class="content-group-tabs__button--is-active"
|
|
63
63
|
id="tab-section-one"
|
|
@@ -67,7 +67,7 @@ exports[`ContentGroupTabs component should match snapshot and render tabs conten
|
|
|
67
67
|
sectionOne
|
|
68
68
|
</button>
|
|
69
69
|
<button
|
|
70
|
-
aria-controls="
|
|
70
|
+
aria-controls="section-two"
|
|
71
71
|
aria-selected="false"
|
|
72
72
|
class="content-group-tabs__button"
|
|
73
73
|
id="tab-section-two"
|
|
@@ -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>
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
exports[`ItemListNew component should match snapshot and render without throwing an error 1`] = `
|
|
4
4
|
<DocumentFragment>
|
|
5
5
|
<button
|
|
6
|
-
aria-label="Create new list_name"
|
|
7
6
|
class="item-list-new button"
|
|
8
7
|
type="button"
|
|
9
8
|
>
|
|
@@ -19,7 +18,6 @@ exports[`ItemListNew component should not render if list not found 1`] = `<Docum
|
|
|
19
18
|
exports[`ItemListNew component should render using listId from query 1`] = `
|
|
20
19
|
<DocumentFragment>
|
|
21
20
|
<button
|
|
22
|
-
aria-label="Create new QUERY-LIST-ID"
|
|
23
21
|
class="item-list-new button"
|
|
24
22
|
type="button"
|
|
25
23
|
>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
4
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
5
|
+
import { render } from '@testing-library/react';
|
|
6
|
+
import MenuEntitiesItem from '../../../../../src/components/MenuItem/MenuEntitiesItem';
|
|
7
|
+
import { MOCKED_MENUITEMS_PROPS } from './mocks';
|
|
8
|
+
|
|
9
|
+
jest.mock('@apollo/client', () => ({
|
|
10
|
+
...jest.requireActual('@apollo/client'),
|
|
11
|
+
useQuery: jest.fn(({ data, loading, error, fetchMore }) => ({ data, loading, error, fetchMore }))
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
jest.mock('@blaze-cms/utils-handlebars', () => ({
|
|
15
|
+
useStringTemplate: jest.fn((parent, [title]) => ({ loading: false, data: [title] }))
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
describe('MenuEntitiesItem component', () => {
|
|
19
|
+
it('should render based on listData received', async () => {
|
|
20
|
+
const { asFragment } = await render(MenuEntitiesItem, MOCKED_MENUITEMS_PROPS);
|
|
21
|
+
expect(asFragment()).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|