@blaze-cms/react-page-builder 0.124.0-alpha.9 → 0.124.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +303 -0
- package/README.md +8 -0
- package/lib/application/query/index.js +8 -2
- package/lib/application/query/index.js.map +1 -1
- package/lib/components/Button.js +18 -5
- package/lib/components/Button.js.map +1 -1
- package/lib/components/Card/CardContainer.js +3 -7
- package/lib/components/Card/CardContainer.js.map +1 -1
- package/lib/components/Card/CardFactory.js +6 -3
- package/lib/components/Card/CardFactory.js.map +1 -1
- package/lib/components/CarouselWrapper.js +2 -2
- package/lib/components/CarouselWrapper.js.map +1 -1
- package/lib/components/Image/ImageRender.js +5 -1
- package/lib/components/Image/ImageRender.js.map +1 -1
- package/lib/components/ItemList/ItemListButton/ItemListButton.js +161 -0
- package/lib/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib/components/ItemList/ItemListButton/index.js +16 -0
- package/lib/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js +83 -0
- package/lib/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib/components/ItemList/ItemListCounter/index.js +16 -0
- package/lib/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js +87 -0
- package/lib/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib/components/ItemList/ItemListNew/index.js +16 -0
- package/lib/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib/components/ItemList/constants.js +19 -0
- package/lib/components/ItemList/constants.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js +17 -0
- package/lib/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js +23 -0
- package/lib/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js +28 -0
- package/lib/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib/components/ItemList/helpers/index.js +50 -0
- package/lib/components/ItemList/helpers/index.js.map +1 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js +22 -0
- package/lib/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js +51 -0
- package/lib/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib/components/ItemList/hooks/index.js +18 -0
- package/lib/components/ItemList/hooks/index.js.map +1 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js +45 -0
- package/lib/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib/components/LazyImage/LazyImage.js +5 -1
- package/lib/components/LazyImage/LazyImage.js.map +1 -1
- package/lib/components/List/ListBuilder.js +12 -6
- package/lib/components/List/ListBuilder.js.map +1 -1
- package/lib/components/List/ListFactory.js +34 -7
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/has-required-item-list-details.js +29 -0
- package/lib/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib/components/List/helpers/index.js +8 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/Menu/Menu.js +41 -28
- package/lib/components/Menu/Menu.js.map +1 -1
- package/lib/components/Menu/MenuContext.js +20 -0
- package/lib/components/Menu/MenuContext.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +26 -7
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/SearchContent/SearchContent.js +183 -0
- package/lib/components/SearchContent/SearchContent.js.map +1 -0
- package/lib/components/SearchContent/SearchContentItems.js +51 -0
- package/lib/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib/components/SearchContent/SearchContentResults.js +45 -0
- package/lib/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js +42 -0
- package/lib/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib/components/SearchContent/index.js +2 -301
- package/lib/components/SearchContent/index.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +16 -66
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +87 -23
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Checkbox.js +19 -9
- package/lib/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.js +27 -11
- package/lib/components/SearchFilter/components/Select.js.map +1 -1
- package/lib/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +87 -0
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +18 -3
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -1
- package/lib/components/SearchFilter/helpers/index.js +8 -0
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/helpers/parse-filter-value.js +3 -7
- package/lib/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib/components/index.js +16 -1
- package/lib/components/index.js.map +1 -1
- package/lib/constants/index.js +3 -1
- package/lib/constants/index.js.map +1 -1
- package/lib/helpers/build-raw-query.js.map +1 -1
- package/lib/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/lib-es/application/query/index.js +45 -1
- package/lib-es/application/query/index.js.map +1 -1
- package/lib-es/components/Button.js +18 -6
- package/lib-es/components/Button.js.map +1 -1
- package/lib-es/components/Card/CardContainer.js +3 -7
- package/lib-es/components/Card/CardContainer.js.map +1 -1
- package/lib-es/components/Card/CardFactory.js +7 -4
- package/lib-es/components/Card/CardFactory.js.map +1 -1
- package/lib-es/components/CarouselWrapper.js +2 -2
- package/lib-es/components/CarouselWrapper.js.map +1 -1
- package/lib-es/components/Image/ImageRender.js +4 -1
- package/lib-es/components/Image/ImageRender.js.map +1 -1
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js +111 -0
- package/lib-es/components/ItemList/ItemListButton/ItemListButton.js.map +1 -0
- package/lib-es/components/ItemList/ItemListButton/index.js +3 -0
- package/lib-es/components/ItemList/ItemListButton/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js +60 -0
- package/lib-es/components/ItemList/ItemListCounter/ItemListCounter.js.map +1 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js +3 -0
- package/lib-es/components/ItemList/ItemListCounter/index.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js +64 -0
- package/lib-es/components/ItemList/ItemListNew/ItemListNew.js.map +1 -0
- package/lib-es/components/ItemList/ItemListNew/index.js +3 -0
- package/lib-es/components/ItemList/ItemListNew/index.js.map +1 -0
- package/lib-es/components/ItemList/constants.js +6 -0
- package/lib-es/components/ItemList/constants.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js +7 -0
- package/lib-es/components/ItemList/helpers/get-item-list-data.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/lib-es/components/ItemList/helpers/get-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js +13 -0
- package/lib-es/components/ItemList/helpers/get-item-list-ids.js.map +1 -0
- package/lib-es/components/ItemList/helpers/index.js +6 -0
- package/lib-es/components/ItemList/helpers/index.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js +10 -0
- package/lib-es/components/ItemList/helpers/set-item-list-id.js.map +1 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/lib-es/components/ItemList/helpers/set-param-and-redirect.js.map +1 -0
- package/lib-es/components/ItemList/hooks/index.js +2 -0
- package/lib-es/components/ItemList/hooks/index.js.map +1 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js +26 -0
- package/lib-es/components/ItemList/hooks/use-item-list-id.js.map +1 -0
- package/lib-es/components/LazyImage/LazyImage.js +4 -1
- package/lib-es/components/LazyImage/LazyImage.js.map +1 -1
- package/lib-es/components/List/ListBuilder.js +12 -6
- package/lib-es/components/List/ListBuilder.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +33 -9
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/has-required-item-list-details.js +20 -0
- package/lib-es/components/List/helpers/has-required-item-list-details.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +1 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/Menu/Menu.js +54 -46
- package/lib-es/components/Menu/Menu.js.map +1 -1
- package/lib-es/components/Menu/MenuContext.js +6 -0
- package/lib-es/components/Menu/MenuContext.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +24 -9
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/SearchContent/SearchContent.js +129 -0
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentItems.js +33 -0
- package/lib-es/components/SearchContent/SearchContentItems.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentResults.js +31 -0
- package/lib-es/components/SearchContent/SearchContentResults.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js +30 -0
- package/lib-es/components/SearchContent/SearchContentToggleIcon.js.map +1 -0
- package/lib-es/components/SearchContent/index.js +1 -205
- package/lib-es/components/SearchContent/index.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js +2 -4
- package/lib-es/components/SearchFilter/SearchFilter/FiltersList.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +10 -43
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +70 -15
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Checkbox.js +18 -9
- package/lib-es/components/SearchFilter/components/Checkbox.js.map +1 -1
- package/lib-es/components/SearchFilter/components/Select.js +23 -8
- package/lib-es/components/SearchFilter/components/Select.js.map +1 -1
- package/lib-es/components/SearchFilter/components/TextSearch.js +1 -5
- package/lib-es/components/SearchFilter/components/TextSearch.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +54 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-query.js +1 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/lib-es/components/SearchFilter/helpers/build-raw-query-stringified.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +13 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.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/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/lib-es/components/SearchFilter/helpers/parse-filter-value.js.map +1 -1
- package/lib-es/components/index.js +10 -1
- package/lib-es/components/index.js.map +1 -1
- package/lib-es/constants/index.js +2 -1
- package/lib-es/constants/index.js.map +1 -1
- package/lib-es/helpers/build-raw-query.js.map +1 -1
- package/lib-es/hooks/helpers/append-gtm-classname.js +1 -0
- package/lib-es/hooks/helpers/append-gtm-classname.js.map +1 -1
- package/package.json +5 -4
- package/src/application/query/index.js +51 -1
- package/src/components/Button.js +27 -5
- package/src/components/Card/CardContainer.js +2 -6
- package/src/components/Card/CardFactory.js +5 -3
- package/src/components/CarouselWrapper.js +2 -2
- package/src/components/Image/ImageRender.js +3 -0
- package/src/components/ItemList/ItemListButton/ItemListButton.js +94 -0
- package/src/components/ItemList/ItemListButton/index.js +3 -0
- package/src/components/ItemList/ItemListCounter/ItemListCounter.js +52 -0
- package/src/components/ItemList/ItemListCounter/index.js +3 -0
- package/src/components/ItemList/ItemListNew/ItemListNew.js +51 -0
- package/src/components/ItemList/ItemListNew/index.js +3 -0
- package/src/components/ItemList/constants.js +5 -0
- package/src/components/ItemList/helpers/get-item-list-data.js +6 -0
- package/src/components/ItemList/helpers/get-item-list-id.js +11 -0
- package/src/components/ItemList/helpers/get-item-list-ids.js +10 -0
- package/src/components/ItemList/helpers/index.js +5 -0
- package/src/components/ItemList/helpers/set-item-list-id.js +9 -0
- package/src/components/ItemList/helpers/set-param-and-redirect.js +20 -0
- package/src/components/ItemList/hooks/index.js +1 -0
- package/src/components/ItemList/hooks/use-item-list-id.js +27 -0
- package/src/components/LazyImage/LazyImage.js +11 -1
- package/src/components/List/ListBuilder.js +10 -5
- package/src/components/List/ListFactory.js +48 -12
- package/src/components/List/helpers/has-required-item-list-details.js +14 -0
- package/src/components/List/helpers/index.js +1 -0
- package/src/components/Menu/Menu.js +61 -54
- package/src/components/Menu/MenuContext.js +5 -0
- package/src/components/MenuItem/MenuItem.js +39 -14
- package/src/components/SearchContent/SearchContent.js +136 -0
- package/src/components/SearchContent/SearchContentItems.js +28 -0
- package/src/components/SearchContent/SearchContentResults.js +27 -0
- package/src/components/SearchContent/SearchContentToggleIcon.js +27 -0
- package/src/components/SearchContent/index.js +1 -217
- package/src/components/SearchFilter/SearchFilter/FiltersList.js +30 -37
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +10 -25
- package/src/components/SearchFilter/SearchFilterContainer.js +61 -16
- package/src/components/SearchFilter/components/Checkbox.js +23 -8
- package/src/components/SearchFilter/components/Select.js +18 -11
- package/src/components/SearchFilter/components/TextSearch.js +1 -3
- package/src/components/SearchFilter/helpers/build-filters-query.js +40 -0
- package/src/components/SearchFilter/helpers/build-query.js +3 -1
- package/src/components/SearchFilter/helpers/build-raw-query-stringified.js +2 -1
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +12 -1
- package/src/components/SearchFilter/helpers/index.js +3 -1
- package/src/components/SearchFilter/helpers/parse-filter-value.js +3 -3
- package/src/components/index.js +10 -1
- package/src/constants/index.js +2 -0
- package/src/helpers/build-raw-query.js +1 -0
- package/src/hooks/helpers/append-gtm-classname.js +3 -0
- package/tests/unit/src/components/Button.test.js +55 -1
- package/tests/unit/src/components/ItemList/ItemListButton.test.js +175 -0
- package/tests/unit/src/components/ItemList/ItemListCounter.test.js +65 -0
- package/tests/unit/src/components/ItemList/ItemListNew.test.js +164 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListButton.test.js.snap +107 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListCounter.test.js.snap +31 -0
- package/tests/unit/src/components/ItemList/__snapshots__/ItemListNew.test.js.snap +27 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-data.test.js +28 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-id.test.js +20 -0
- package/tests/unit/src/components/ItemList/helpers/get-item-list-ids.test.js +19 -0
- package/tests/unit/src/components/ItemList/helpers/set-item-list-id.test.js +13 -0
- package/tests/unit/src/components/ItemList/helpers/set-param-and-redirect.test.js +30 -0
- package/tests/unit/src/components/ItemList/hooks/use-item-list-id.test.js +32 -0
- package/tests/unit/src/components/List/helpers/has-required-item-list-details.test.js +30 -0
- package/tests/unit/src/components/Menu/Menu.test.js +9 -3
- package/tests/unit/src/components/Menu/__snapshots__/Menu.test.js.snap +12 -11
- package/tests/unit/src/components/MenuItem/MenuItem.test.js +1 -1
- package/tests/unit/src/components/MenuItem/SubMenu.test.js +5 -1
- package/tests/unit/src/components/MenuItem/__snapshots__/MenuItem.test.js.snap +54 -10
- package/tests/unit/src/components/SearchContent/SearchContent.test.js +29 -0
- package/tests/unit/src/components/SearchContent/__snapshots__/SearchContent.test.js.snap +9 -0
- package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +3 -6
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Checkbox.test.js.snap +2 -0
- package/tests/unit/src/components/SearchFilter/components/__snapshots__/Select.test.js.snap +4 -0
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +2 -2
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +25 -11
- package/tests/unit/src/components/SearchFilter/helpers/parse-filter-value.test.js +1 -1
- package/tests/unit/src/components/__snapshots__/index.test.js.snap +12 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { BsBookmarkStarFill, BsBookmarkCheckFill, BsBookmarkStar, BsBookmarkXFill } from 'react-icons/bs';
|
|
4
|
+
import { useQuery, useMutation } from '@apollo/client';
|
|
5
|
+
import { getItemList, addItemsToList, removeItemsFromList } from '../../../application/query';
|
|
6
|
+
import { getItemListData, setItemListId } from '../helpers';
|
|
7
|
+
import { useItemListId } from '../hooks';
|
|
8
|
+
|
|
9
|
+
const ItemListButton = ({
|
|
10
|
+
listName,
|
|
11
|
+
parent,
|
|
12
|
+
modifier
|
|
13
|
+
}) => {
|
|
14
|
+
const {
|
|
15
|
+
itemId,
|
|
16
|
+
itemEntity
|
|
17
|
+
} = parent;
|
|
18
|
+
const [isHover, setIsHover] = useState(false);
|
|
19
|
+
const {
|
|
20
|
+
listId
|
|
21
|
+
} = useItemListId({
|
|
22
|
+
listName
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const getIcon = () => {
|
|
26
|
+
if (isInList) return isHover ? BsBookmarkXFill : BsBookmarkCheckFill;
|
|
27
|
+
return isHover ? BsBookmarkStarFill : BsBookmarkStar;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const {
|
|
31
|
+
data,
|
|
32
|
+
error,
|
|
33
|
+
loading
|
|
34
|
+
} = useQuery(getItemList, {
|
|
35
|
+
variables: {
|
|
36
|
+
id: listId
|
|
37
|
+
},
|
|
38
|
+
skip: !listId
|
|
39
|
+
});
|
|
40
|
+
const [addListItem] = useMutation(addItemsToList, {
|
|
41
|
+
onCompleted: ({
|
|
42
|
+
addItemsToList: listAddResult
|
|
43
|
+
}) => {
|
|
44
|
+
const {
|
|
45
|
+
result: {
|
|
46
|
+
id
|
|
47
|
+
}
|
|
48
|
+
} = listAddResult;
|
|
49
|
+
|
|
50
|
+
if (!listId) {
|
|
51
|
+
setItemListId(listName, id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const [removeListItem] = useMutation(removeItemsFromList);
|
|
56
|
+
|
|
57
|
+
const clickHandler = () => {
|
|
58
|
+
setIsHover(false);
|
|
59
|
+
isInList ? removeListItem({
|
|
60
|
+
variables: {
|
|
61
|
+
listId,
|
|
62
|
+
listItems: [{
|
|
63
|
+
itemId,
|
|
64
|
+
itemEntity
|
|
65
|
+
}]
|
|
66
|
+
},
|
|
67
|
+
skip: !listId
|
|
68
|
+
}) : addListItem({
|
|
69
|
+
variables: {
|
|
70
|
+
name: listName,
|
|
71
|
+
id: listId,
|
|
72
|
+
listItems: [{
|
|
73
|
+
itemId,
|
|
74
|
+
itemEntity
|
|
75
|
+
}]
|
|
76
|
+
},
|
|
77
|
+
skip: !listId
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
if (loading) return '';
|
|
82
|
+
if (error) return error.message;
|
|
83
|
+
const listItems = getItemListData(data);
|
|
84
|
+
const isInList = !!listItems.find(({
|
|
85
|
+
itemId: idToCheck,
|
|
86
|
+
itemEntity: entityToCheck
|
|
87
|
+
}) => idToCheck === itemId && entityToCheck === itemEntity);
|
|
88
|
+
const Icon = getIcon();
|
|
89
|
+
const stateClassName = isInList ? 'item-list-button--selected' : '';
|
|
90
|
+
const className = ['item-list-button', stateClassName, modifier].filter(Boolean).join(' ');
|
|
91
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
92
|
+
className: className,
|
|
93
|
+
role: "button",
|
|
94
|
+
onClick: clickHandler,
|
|
95
|
+
onMouseEnter: () => setIsHover(true),
|
|
96
|
+
onMouseLeave: () => setIsHover(false)
|
|
97
|
+
}, /*#__PURE__*/React.createElement("i", null, /*#__PURE__*/React.createElement(Icon, null)));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
ItemListButton.propTypes = {
|
|
101
|
+
parent: PropTypes.object,
|
|
102
|
+
listName: PropTypes.string,
|
|
103
|
+
modifier: PropTypes.string
|
|
104
|
+
};
|
|
105
|
+
ItemListButton.defaultProps = {
|
|
106
|
+
parent: {},
|
|
107
|
+
listName: '',
|
|
108
|
+
modifier: ''
|
|
109
|
+
};
|
|
110
|
+
export default ItemListButton;
|
|
111
|
+
//# sourceMappingURL=ItemListButton.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemListButton.js","names":["React","useState","PropTypes","BsBookmarkStarFill","BsBookmarkCheckFill","BsBookmarkStar","BsBookmarkXFill","useQuery","useMutation","getItemList","addItemsToList","removeItemsFromList","getItemListData","setItemListId","useItemListId","ItemListButton","listName","parent","modifier","itemId","itemEntity","isHover","setIsHover","listId","getIcon","isInList","data","error","loading","variables","id","skip","addListItem","onCompleted","listAddResult","result","removeListItem","clickHandler","listItems","name","message","find","idToCheck","entityToCheck","Icon","stateClassName","className","filter","Boolean","join","propTypes","object","string","defaultProps"],"sources":["../../../../src/components/ItemList/ItemListButton/ItemListButton.js"],"sourcesContent":["import React, { useState } from 'react';\nimport PropTypes from 'prop-types';\nimport {\n BsBookmarkStarFill,\n BsBookmarkCheckFill,\n BsBookmarkStar,\n BsBookmarkXFill\n} from 'react-icons/bs';\nimport { useQuery, useMutation } from '@apollo/client';\nimport { getItemList, addItemsToList, removeItemsFromList } from '../../../application/query';\nimport { getItemListData, setItemListId } from '../helpers';\nimport { useItemListId } from '../hooks';\n\nconst ItemListButton = ({ listName, parent, modifier }) => {\n const { itemId, itemEntity } = parent;\n const [isHover, setIsHover] = useState(false);\n const { listId } = useItemListId({ listName });\n\n const getIcon = () => {\n if (isInList) return isHover ? BsBookmarkXFill : BsBookmarkCheckFill;\n return isHover ? BsBookmarkStarFill : BsBookmarkStar;\n };\n\n const { data, error, loading } = useQuery(getItemList, {\n variables: { id: listId },\n skip: !listId\n });\n\n const [addListItem] = useMutation(addItemsToList, {\n onCompleted: ({ addItemsToList: listAddResult }) => {\n const {\n result: { id }\n } = listAddResult;\n\n if (!listId) {\n setItemListId(listName, id);\n }\n }\n });\n\n const [removeListItem] = useMutation(removeItemsFromList);\n\n const clickHandler = () => {\n setIsHover(false);\n isInList\n ? removeListItem({\n variables: { listId, listItems: [{ itemId, itemEntity }] },\n skip: !listId\n })\n : addListItem({\n variables: { name: listName, id: listId, listItems: [{ itemId, itemEntity }] },\n skip: !listId\n });\n };\n\n if (loading) return '';\n if (error) return error.message;\n\n const listItems = getItemListData(data);\n const isInList = !!listItems.find(\n ({ itemId: idToCheck, itemEntity: entityToCheck }) =>\n idToCheck === itemId && entityToCheck === itemEntity\n );\n const Icon = getIcon();\n const stateClassName = isInList ? 'item-list-button--selected' : '';\n const className = ['item-list-button', stateClassName, modifier].filter(Boolean).join(' ');\n\n return (\n <div\n className={className}\n role=\"button\"\n onClick={clickHandler}\n onMouseEnter={() => setIsHover(true)}\n onMouseLeave={() => setIsHover(false)}>\n <i>\n <Icon />\n </i>\n </div>\n );\n};\n\nItemListButton.propTypes = {\n parent: PropTypes.object,\n listName: PropTypes.string,\n modifier: PropTypes.string\n};\n\nItemListButton.defaultProps = {\n parent: {},\n listName: '',\n modifier: ''\n};\n\nexport default ItemListButton;\n"],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ItemListButton"],"sources":["../../../../src/components/ItemList/ItemListButton/index.js"],"sourcesContent":["import ItemListButton from './ItemListButton';\n\nexport default ItemListButton;\n"],"mappings":"AAAA,OAAOA,cAAP,MAA2B,kBAA3B;AAEA,eAAeA,cAAf"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { useQuery } from '@apollo/client';
|
|
5
|
+
import { BsBookmarkStarFill, BsBookmarkStar } from 'react-icons/bs';
|
|
6
|
+
import { getItemList } from '../../../application/query';
|
|
7
|
+
import { useItemListId } from '../hooks';
|
|
8
|
+
import { getItemListData } from '../helpers';
|
|
9
|
+
|
|
10
|
+
const ItemListCounter = ({
|
|
11
|
+
listName,
|
|
12
|
+
modifier,
|
|
13
|
+
url
|
|
14
|
+
}) => {
|
|
15
|
+
const router = useRouter();
|
|
16
|
+
const {
|
|
17
|
+
listId
|
|
18
|
+
} = useItemListId({
|
|
19
|
+
listName
|
|
20
|
+
});
|
|
21
|
+
const {
|
|
22
|
+
data,
|
|
23
|
+
error,
|
|
24
|
+
loading
|
|
25
|
+
} = useQuery(getItemList, {
|
|
26
|
+
variables: {
|
|
27
|
+
id: listId
|
|
28
|
+
},
|
|
29
|
+
skip: !listId
|
|
30
|
+
});
|
|
31
|
+
if (loading) return '';
|
|
32
|
+
if (error) return error.message;
|
|
33
|
+
const listItems = getItemListData(data);
|
|
34
|
+
const listLength = listItems.length;
|
|
35
|
+
const CounterIcon = listLength ? BsBookmarkStarFill : BsBookmarkStar;
|
|
36
|
+
|
|
37
|
+
const handleClick = () => router.push('/Resolver', `${url}?itemListId=${listId}`);
|
|
38
|
+
|
|
39
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
40
|
+
role: "button",
|
|
41
|
+
type: "button",
|
|
42
|
+
className: `item-list-counter ${modifier}`,
|
|
43
|
+
onClick: handleClick
|
|
44
|
+
}, /*#__PURE__*/React.createElement(CounterIcon, null), /*#__PURE__*/React.createElement("span", {
|
|
45
|
+
className: "item-list-counter__badge"
|
|
46
|
+
}, listLength));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
ItemListCounter.propTypes = {
|
|
50
|
+
url: PropTypes.string,
|
|
51
|
+
listName: PropTypes.string,
|
|
52
|
+
modifier: PropTypes.string
|
|
53
|
+
};
|
|
54
|
+
ItemListCounter.defaultProps = {
|
|
55
|
+
url: '',
|
|
56
|
+
listName: '',
|
|
57
|
+
modifier: ''
|
|
58
|
+
};
|
|
59
|
+
export default ItemListCounter;
|
|
60
|
+
//# sourceMappingURL=ItemListCounter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemListCounter.js","names":["React","PropTypes","useRouter","useQuery","BsBookmarkStarFill","BsBookmarkStar","getItemList","useItemListId","getItemListData","ItemListCounter","listName","modifier","url","router","listId","data","error","loading","variables","id","skip","message","listItems","listLength","length","CounterIcon","handleClick","push","propTypes","string","defaultProps"],"sources":["../../../../src/components/ItemList/ItemListCounter/ItemListCounter.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { useQuery } from '@apollo/client';\nimport { BsBookmarkStarFill, BsBookmarkStar } from 'react-icons/bs';\nimport { getItemList } from '../../../application/query';\nimport { useItemListId } from '../hooks';\nimport { getItemListData } from '../helpers';\n\nconst ItemListCounter = ({ listName, modifier, url }) => {\n const router = useRouter();\n const { listId } = useItemListId({ listName });\n\n const { data, error, loading } = useQuery(getItemList, {\n variables: { id: listId },\n skip: !listId\n });\n\n if (loading) return '';\n if (error) return error.message;\n\n const listItems = getItemListData(data);\n const listLength = listItems.length;\n const CounterIcon = listLength ? BsBookmarkStarFill : BsBookmarkStar;\n\n const handleClick = () => router.push('/Resolver', `${url}?itemListId=${listId}`);\n\n return (\n <div\n role=\"button\"\n type=\"button\"\n className={`item-list-counter ${modifier}`}\n onClick={handleClick}>\n <CounterIcon />\n <span className=\"item-list-counter__badge\">{listLength}</span>\n </div>\n );\n};\n\nItemListCounter.propTypes = {\n url: PropTypes.string,\n listName: PropTypes.string,\n modifier: PropTypes.string\n};\n\nItemListCounter.defaultProps = {\n url: '',\n listName: '',\n modifier: ''\n};\n\nexport default ItemListCounter;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,SAASC,kBAAT,EAA6BC,cAA7B,QAAmD,gBAAnD;AACA,SAASC,WAAT,QAA4B,4BAA5B;AACA,SAASC,aAAT,QAA8B,UAA9B;AACA,SAASC,eAAT,QAAgC,YAAhC;;AAEA,MAAMC,eAAe,GAAG,CAAC;EAAEC,QAAF;EAAYC,QAAZ;EAAsBC;AAAtB,CAAD,KAAiC;EACvD,MAAMC,MAAM,GAAGX,SAAS,EAAxB;EACA,MAAM;IAAEY;EAAF,IAAaP,aAAa,CAAC;IAAEG;EAAF,CAAD,CAAhC;EAEA,MAAM;IAAEK,IAAF;IAAQC,KAAR;IAAeC;EAAf,IAA2Bd,QAAQ,CAACG,WAAD,EAAc;IACrDY,SAAS,EAAE;MAAEC,EAAE,EAAEL;IAAN,CAD0C;IAErDM,IAAI,EAAE,CAACN;EAF8C,CAAd,CAAzC;EAKA,IAAIG,OAAJ,EAAa,OAAO,EAAP;EACb,IAAID,KAAJ,EAAW,OAAOA,KAAK,CAACK,OAAb;EAEX,MAAMC,SAAS,GAAGd,eAAe,CAACO,IAAD,CAAjC;EACA,MAAMQ,UAAU,GAAGD,SAAS,CAACE,MAA7B;EACA,MAAMC,WAAW,GAAGF,UAAU,GAAGnB,kBAAH,GAAwBC,cAAtD;;EAEA,MAAMqB,WAAW,GAAG,MAAMb,MAAM,CAACc,IAAP,CAAY,WAAZ,EAA0B,GAAEf,GAAI,eAAcE,MAAO,EAArD,CAA1B;;EAEA,oBACE;IACE,IAAI,EAAC,QADP;IAEE,IAAI,EAAC,QAFP;IAGE,SAAS,EAAG,qBAAoBH,QAAS,EAH3C;IAIE,OAAO,EAAEe;EAJX,gBAKE,oBAAC,WAAD,OALF,eAME;IAAM,SAAS,EAAC;EAAhB,GAA4CH,UAA5C,CANF,CADF;AAUD,CA5BD;;AA8BAd,eAAe,CAACmB,SAAhB,GAA4B;EAC1BhB,GAAG,EAAEX,SAAS,CAAC4B,MADW;EAE1BnB,QAAQ,EAAET,SAAS,CAAC4B,MAFM;EAG1BlB,QAAQ,EAAEV,SAAS,CAAC4B;AAHM,CAA5B;AAMApB,eAAe,CAACqB,YAAhB,GAA+B;EAC7BlB,GAAG,EAAE,EADwB;EAE7BF,QAAQ,EAAE,EAFmB;EAG7BC,QAAQ,EAAE;AAHmB,CAA/B;AAMA,eAAeF,eAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ItemListCounter"],"sources":["../../../../src/components/ItemList/ItemListCounter/index.js"],"sourcesContent":["import ItemListCounter from './ItemListCounter';\n\nexport default ItemListCounter;\n"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,mBAA5B;AAEA,eAAeA,eAAf"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useRouter } from 'next/router';
|
|
4
|
+
import { useQuery } from '@apollo/client';
|
|
5
|
+
import BlazeButton from '@blaze-react/button';
|
|
6
|
+
import { parseUrl } from 'query-string';
|
|
7
|
+
import { getItemList } from '../../../application/query';
|
|
8
|
+
import { useItemListId } from '../hooks';
|
|
9
|
+
import { getItemListData, setItemListId, setParamAndRedirect } from '../helpers';
|
|
10
|
+
import { LIST_ITEM_QUERY_PARAM } from '../constants';
|
|
11
|
+
|
|
12
|
+
const ItemListNew = ({
|
|
13
|
+
listName,
|
|
14
|
+
modifier,
|
|
15
|
+
text
|
|
16
|
+
}) => {
|
|
17
|
+
const router = useRouter();
|
|
18
|
+
const {
|
|
19
|
+
query: {
|
|
20
|
+
[LIST_ITEM_QUERY_PARAM]: listItemId
|
|
21
|
+
} = {}
|
|
22
|
+
} = parseUrl(router.asPath);
|
|
23
|
+
const {
|
|
24
|
+
listId
|
|
25
|
+
} = useItemListId({
|
|
26
|
+
listName
|
|
27
|
+
});
|
|
28
|
+
const listIdToUse = listItemId || listId;
|
|
29
|
+
const {
|
|
30
|
+
data,
|
|
31
|
+
error,
|
|
32
|
+
loading
|
|
33
|
+
} = useQuery(getItemList, {
|
|
34
|
+
variables: {
|
|
35
|
+
id: listIdToUse
|
|
36
|
+
},
|
|
37
|
+
skip: !listIdToUse
|
|
38
|
+
});
|
|
39
|
+
if (loading) return '';
|
|
40
|
+
if (error) return error.message;
|
|
41
|
+
const listItems = getItemListData(data);
|
|
42
|
+
if (!listItems.length) return '';
|
|
43
|
+
|
|
44
|
+
const handleClick = () => {
|
|
45
|
+
setItemListId(listName, '');
|
|
46
|
+
setParamAndRedirect(router);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return /*#__PURE__*/React.createElement(BlazeButton, {
|
|
50
|
+
className: `item-list-new ${modifier}`,
|
|
51
|
+
onClick: handleClick
|
|
52
|
+
}, text);
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
ItemListNew.propTypes = {
|
|
56
|
+
listName: PropTypes.string.isRequired,
|
|
57
|
+
modifier: PropTypes.string,
|
|
58
|
+
text: PropTypes.string.isRequired
|
|
59
|
+
};
|
|
60
|
+
ItemListNew.defaultProps = {
|
|
61
|
+
modifier: ''
|
|
62
|
+
};
|
|
63
|
+
export default ItemListNew;
|
|
64
|
+
//# sourceMappingURL=ItemListNew.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItemListNew.js","names":["React","PropTypes","useRouter","useQuery","BlazeButton","parseUrl","getItemList","useItemListId","getItemListData","setItemListId","setParamAndRedirect","LIST_ITEM_QUERY_PARAM","ItemListNew","listName","modifier","text","router","query","listItemId","asPath","listId","listIdToUse","data","error","loading","variables","id","skip","message","listItems","length","handleClick","propTypes","string","isRequired","defaultProps"],"sources":["../../../../src/components/ItemList/ItemListNew/ItemListNew.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { useQuery } from '@apollo/client';\nimport BlazeButton from '@blaze-react/button';\nimport { parseUrl } from 'query-string';\nimport { getItemList } from '../../../application/query';\nimport { useItemListId } from '../hooks';\nimport { getItemListData, setItemListId, setParamAndRedirect } from '../helpers';\nimport { LIST_ITEM_QUERY_PARAM } from '../constants';\n\nconst ItemListNew = ({ listName, modifier, text }) => {\n const router = useRouter();\n const { query: { [LIST_ITEM_QUERY_PARAM]: listItemId } = {} } = parseUrl(router.asPath);\n\n const { listId } = useItemListId({ listName });\n const listIdToUse = listItemId || listId;\n const { data, error, loading } = useQuery(getItemList, {\n variables: { id: listIdToUse },\n skip: !listIdToUse\n });\n\n if (loading) return '';\n if (error) return error.message;\n\n const listItems = getItemListData(data);\n if (!listItems.length) return '';\n\n const handleClick = () => {\n setItemListId(listName, '');\n setParamAndRedirect(router);\n };\n\n return (\n <BlazeButton className={`item-list-new ${modifier}`} onClick={handleClick}>\n {text}\n </BlazeButton>\n );\n};\n\nItemListNew.propTypes = {\n listName: PropTypes.string.isRequired,\n modifier: PropTypes.string,\n text: PropTypes.string.isRequired\n};\n\nItemListNew.defaultProps = {\n modifier: ''\n};\n\nexport default ItemListNew;\n"],"mappings":"AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,SAAT,QAA0B,aAA1B;AACA,SAASC,QAAT,QAAyB,gBAAzB;AACA,OAAOC,WAAP,MAAwB,qBAAxB;AACA,SAASC,QAAT,QAAyB,cAAzB;AACA,SAASC,WAAT,QAA4B,4BAA5B;AACA,SAASC,aAAT,QAA8B,UAA9B;AACA,SAASC,eAAT,EAA0BC,aAA1B,EAAyCC,mBAAzC,QAAoE,YAApE;AACA,SAASC,qBAAT,QAAsC,cAAtC;;AAEA,MAAMC,WAAW,GAAG,CAAC;EAAEC,QAAF;EAAYC,QAAZ;EAAsBC;AAAtB,CAAD,KAAkC;EACpD,MAAMC,MAAM,GAAGd,SAAS,EAAxB;EACA,MAAM;IAAEe,KAAK,EAAE;MAAE,CAACN,qBAAD,GAAyBO;IAA3B,IAA0C;EAAnD,IAA0Db,QAAQ,CAACW,MAAM,CAACG,MAAR,CAAxE;EAEA,MAAM;IAAEC;EAAF,IAAab,aAAa,CAAC;IAAEM;EAAF,CAAD,CAAhC;EACA,MAAMQ,WAAW,GAAGH,UAAU,IAAIE,MAAlC;EACA,MAAM;IAAEE,IAAF;IAAQC,KAAR;IAAeC;EAAf,IAA2BrB,QAAQ,CAACG,WAAD,EAAc;IACrDmB,SAAS,EAAE;MAAEC,EAAE,EAAEL;IAAN,CAD0C;IAErDM,IAAI,EAAE,CAACN;EAF8C,CAAd,CAAzC;EAKA,IAAIG,OAAJ,EAAa,OAAO,EAAP;EACb,IAAID,KAAJ,EAAW,OAAOA,KAAK,CAACK,OAAb;EAEX,MAAMC,SAAS,GAAGrB,eAAe,CAACc,IAAD,CAAjC;EACA,IAAI,CAACO,SAAS,CAACC,MAAf,EAAuB,OAAO,EAAP;;EAEvB,MAAMC,WAAW,GAAG,MAAM;IACxBtB,aAAa,CAACI,QAAD,EAAW,EAAX,CAAb;IACAH,mBAAmB,CAACM,MAAD,CAAnB;EACD,CAHD;;EAKA,oBACE,oBAAC,WAAD;IAAa,SAAS,EAAG,iBAAgBF,QAAS,EAAlD;IAAqD,OAAO,EAAEiB;EAA9D,GACGhB,IADH,CADF;AAKD,CA3BD;;AA6BAH,WAAW,CAACoB,SAAZ,GAAwB;EACtBnB,QAAQ,EAAEZ,SAAS,CAACgC,MAAV,CAAiBC,UADL;EAEtBpB,QAAQ,EAAEb,SAAS,CAACgC,MAFE;EAGtBlB,IAAI,EAAEd,SAAS,CAACgC,MAAV,CAAiBC;AAHD,CAAxB;AAMAtB,WAAW,CAACuB,YAAZ,GAA2B;EACzBrB,QAAQ,EAAE;AADe,CAA3B;AAIA,eAAeF,WAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ItemListNew"],"sources":["../../../../src/components/ItemList/ItemListNew/index.js"],"sourcesContent":["import ItemListNew from './ItemListNew';\n\nexport default ItemListNew;\n"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,eAAxB;AAEA,eAAeA,WAAf"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const ITEM_LIST_BUTTON = 'itemlistbutton';
|
|
2
|
+
export const ITEM_LIST_COUNTER = 'itemlistcounter';
|
|
3
|
+
export const ITEM_LIST_NEW = 'itemlistnew';
|
|
4
|
+
export const LIST_ITEM_LOCAL_KEY = 'blaze_item_list_';
|
|
5
|
+
export const LIST_ITEM_QUERY_PARAM = 'itemListId';
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","names":["ITEM_LIST_BUTTON","ITEM_LIST_COUNTER","ITEM_LIST_NEW","LIST_ITEM_LOCAL_KEY","LIST_ITEM_QUERY_PARAM"],"sources":["../../../src/components/ItemList/constants.js"],"sourcesContent":["export const ITEM_LIST_BUTTON = 'itemlistbutton';\nexport const ITEM_LIST_COUNTER = 'itemlistcounter';\nexport const ITEM_LIST_NEW = 'itemlistnew';\nexport const LIST_ITEM_LOCAL_KEY = 'blaze_item_list_';\nexport const LIST_ITEM_QUERY_PARAM = 'itemListId';\n"],"mappings":"AAAA,OAAO,MAAMA,gBAAgB,GAAG,gBAAzB;AACP,OAAO,MAAMC,iBAAiB,GAAG,iBAA1B;AACP,OAAO,MAAMC,aAAa,GAAG,aAAtB;AACP,OAAO,MAAMC,mBAAmB,GAAG,kBAA5B;AACP,OAAO,MAAMC,qBAAqB,GAAG,YAA9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-item-list-data.js","names":["getItemListData","data","getItemList","listItems"],"sources":["../../../../src/components/ItemList/helpers/get-item-list-data.js"],"sourcesContent":["const getItemListData = data => {\n if (data && data.getItemList && data.getItemList.listItems) return data.getItemList.listItems;\n return [];\n};\n\nexport default getItemListData;\n"],"mappings":"AAAA,MAAMA,eAAe,GAAGC,IAAI,IAAI;EAC9B,IAAIA,IAAI,IAAIA,IAAI,CAACC,WAAb,IAA4BD,IAAI,CAACC,WAAL,CAAiBC,SAAjD,EAA4D,OAAOF,IAAI,CAACC,WAAL,CAAiBC,SAAxB;EAC5D,OAAO,EAAP;AACD,CAHD;;AAKA,eAAeH,eAAf"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LIST_ITEM_LOCAL_KEY } from '../constants';
|
|
2
|
+
|
|
3
|
+
const getItemListId = (listName, queryId) => {
|
|
4
|
+
if (queryId) return queryId;
|
|
5
|
+
if (!listName || typeof localStorage === 'undefined') return '';
|
|
6
|
+
const localListName = `${LIST_ITEM_LOCAL_KEY}${listName}`;
|
|
7
|
+
return localStorage.getItem(localListName) || '';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default getItemListId;
|
|
11
|
+
//# sourceMappingURL=get-item-list-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-item-list-id.js","names":["LIST_ITEM_LOCAL_KEY","getItemListId","listName","queryId","localStorage","localListName","getItem"],"sources":["../../../../src/components/ItemList/helpers/get-item-list-id.js"],"sourcesContent":["import { LIST_ITEM_LOCAL_KEY } from '../constants';\n\nconst getItemListId = (listName, queryId) => {\n if (queryId) return queryId;\n if (!listName || typeof localStorage === 'undefined') return '';\n\n const localListName = `${LIST_ITEM_LOCAL_KEY}${listName}`;\n return localStorage.getItem(localListName) || '';\n};\n\nexport default getItemListId;\n"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,cAApC;;AAEA,MAAMC,aAAa,GAAG,CAACC,QAAD,EAAWC,OAAX,KAAuB;EAC3C,IAAIA,OAAJ,EAAa,OAAOA,OAAP;EACb,IAAI,CAACD,QAAD,IAAa,OAAOE,YAAP,KAAwB,WAAzC,EAAsD,OAAO,EAAP;EAEtD,MAAMC,aAAa,GAAI,GAAEL,mBAAoB,GAAEE,QAAS,EAAxD;EACA,OAAOE,YAAY,CAACE,OAAb,CAAqBD,aAArB,KAAuC,EAA9C;AACD,CAND;;AAQA,eAAeJ,aAAf"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import getItemListData from './get-item-list-data';
|
|
2
|
+
|
|
3
|
+
const getItemListIds = data => {
|
|
4
|
+
const itemListElements = getItemListData(data);
|
|
5
|
+
return itemListElements.length ? itemListElements.map(({
|
|
6
|
+
itemId
|
|
7
|
+
}) => ({
|
|
8
|
+
displayItems: [itemId]
|
|
9
|
+
})) : null;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export default getItemListIds;
|
|
13
|
+
//# sourceMappingURL=get-item-list-ids.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-item-list-ids.js","names":["getItemListData","getItemListIds","data","itemListElements","length","map","itemId","displayItems"],"sources":["../../../../src/components/ItemList/helpers/get-item-list-ids.js"],"sourcesContent":["import getItemListData from './get-item-list-data';\n\nconst getItemListIds = data => {\n const itemListElements = getItemListData(data);\n return itemListElements.length\n ? itemListElements.map(({ itemId }) => ({ displayItems: [itemId] }))\n : null;\n};\n\nexport default getItemListIds;\n"],"mappings":"AAAA,OAAOA,eAAP,MAA4B,sBAA5B;;AAEA,MAAMC,cAAc,GAAGC,IAAI,IAAI;EAC7B,MAAMC,gBAAgB,GAAGH,eAAe,CAACE,IAAD,CAAxC;EACA,OAAOC,gBAAgB,CAACC,MAAjB,GACHD,gBAAgB,CAACE,GAAjB,CAAqB,CAAC;IAAEC;EAAF,CAAD,MAAiB;IAAEC,YAAY,EAAE,CAACD,MAAD;EAAhB,CAAjB,CAArB,CADG,GAEH,IAFJ;AAGD,CALD;;AAOA,eAAeL,cAAf"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as getItemListId } from './get-item-list-id';
|
|
2
|
+
export { default as getItemListIds } from './get-item-list-ids';
|
|
3
|
+
export { default as getItemListData } from './get-item-list-data';
|
|
4
|
+
export { default as setItemListId } from './set-item-list-id';
|
|
5
|
+
export { default as setParamAndRedirect } from './set-param-and-redirect';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","getItemListId","getItemListIds","getItemListData","setItemListId","setParamAndRedirect"],"sources":["../../../../src/components/ItemList/helpers/index.js"],"sourcesContent":["export { default as getItemListId } from './get-item-list-id';\nexport { default as getItemListIds } from './get-item-list-ids';\nexport { default as getItemListData } from './get-item-list-data';\nexport { default as setItemListId } from './set-item-list-id';\nexport { default as setParamAndRedirect } from './set-param-and-redirect';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,aAApB,QAAyC,oBAAzC;AACA,SAASD,OAAO,IAAIE,cAApB,QAA0C,qBAA1C;AACA,SAASF,OAAO,IAAIG,eAApB,QAA2C,sBAA3C;AACA,SAASH,OAAO,IAAII,aAApB,QAAyC,oBAAzC;AACA,SAASJ,OAAO,IAAIK,mBAApB,QAA+C,0BAA/C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { LIST_ITEM_LOCAL_KEY } from '../constants';
|
|
2
|
+
|
|
3
|
+
const setItemListId = (listName, id) => {
|
|
4
|
+
const localListName = `${LIST_ITEM_LOCAL_KEY}${listName}`;
|
|
5
|
+
localStorage.setItem(localListName, id);
|
|
6
|
+
window.dispatchEvent(new Event('storage'));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default setItemListId;
|
|
10
|
+
//# sourceMappingURL=set-item-list-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-item-list-id.js","names":["LIST_ITEM_LOCAL_KEY","setItemListId","listName","id","localListName","localStorage","setItem","window","dispatchEvent","Event"],"sources":["../../../../src/components/ItemList/helpers/set-item-list-id.js"],"sourcesContent":["import { LIST_ITEM_LOCAL_KEY } from '../constants';\n\nconst setItemListId = (listName, id) => {\n const localListName = `${LIST_ITEM_LOCAL_KEY}${listName}`;\n localStorage.setItem(localListName, id);\n window.dispatchEvent(new Event('storage'));\n};\n\nexport default setItemListId;\n"],"mappings":"AAAA,SAASA,mBAAT,QAAoC,cAApC;;AAEA,MAAMC,aAAa,GAAG,CAACC,QAAD,EAAWC,EAAX,KAAkB;EACtC,MAAMC,aAAa,GAAI,GAAEJ,mBAAoB,GAAEE,QAAS,EAAxD;EACAG,YAAY,CAACC,OAAb,CAAqBF,aAArB,EAAoCD,EAApC;EACAI,MAAM,CAACC,aAAP,CAAqB,IAAIC,KAAJ,CAAU,SAAV,CAArB;AACD,CAJD;;AAMA,eAAeR,aAAf"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LIST_ITEM_QUERY_PARAM } from '../constants';
|
|
2
|
+
const placeholderBase = 'https://blazecms.app'; // placeholder for URL, removed later
|
|
3
|
+
|
|
4
|
+
const setParamAndRedirect = (router, value) => {
|
|
5
|
+
const currentUrl = new URL(router.asPath, placeholderBase);
|
|
6
|
+
|
|
7
|
+
if (value) {
|
|
8
|
+
currentUrl.searchParams.set(LIST_ITEM_QUERY_PARAM, value);
|
|
9
|
+
} else if (!currentUrl.searchParams.get(LIST_ITEM_QUERY_PARAM)) return;else {
|
|
10
|
+
currentUrl.searchParams.delete(LIST_ITEM_QUERY_PARAM);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const newUrl = currentUrl.toString().replace(placeholderBase, '');
|
|
14
|
+
router.push('/Resolver', newUrl, {
|
|
15
|
+
shallow: true
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default setParamAndRedirect;
|
|
20
|
+
//# sourceMappingURL=set-param-and-redirect.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-param-and-redirect.js","names":["LIST_ITEM_QUERY_PARAM","placeholderBase","setParamAndRedirect","router","value","currentUrl","URL","asPath","searchParams","set","get","delete","newUrl","toString","replace","push","shallow"],"sources":["../../../../src/components/ItemList/helpers/set-param-and-redirect.js"],"sourcesContent":["import { LIST_ITEM_QUERY_PARAM } from '../constants';\n\nconst placeholderBase = 'https://blazecms.app'; // placeholder for URL, removed later\n\nconst setParamAndRedirect = (router, value) => {\n const currentUrl = new URL(router.asPath, placeholderBase);\n if (value) {\n currentUrl.searchParams.set(LIST_ITEM_QUERY_PARAM, value);\n } else if (!currentUrl.searchParams.get(LIST_ITEM_QUERY_PARAM)) return;\n else {\n currentUrl.searchParams.delete(LIST_ITEM_QUERY_PARAM);\n }\n\n const newUrl = currentUrl.toString().replace(placeholderBase, '');\n router.push('/Resolver', newUrl, {\n shallow: true\n });\n};\n\nexport default setParamAndRedirect;\n"],"mappings":"AAAA,SAASA,qBAAT,QAAsC,cAAtC;AAEA,MAAMC,eAAe,GAAG,sBAAxB,C,CAAgD;;AAEhD,MAAMC,mBAAmB,GAAG,CAACC,MAAD,EAASC,KAAT,KAAmB;EAC7C,MAAMC,UAAU,GAAG,IAAIC,GAAJ,CAAQH,MAAM,CAACI,MAAf,EAAuBN,eAAvB,CAAnB;;EACA,IAAIG,KAAJ,EAAW;IACTC,UAAU,CAACG,YAAX,CAAwBC,GAAxB,CAA4BT,qBAA5B,EAAmDI,KAAnD;EACD,CAFD,MAEO,IAAI,CAACC,UAAU,CAACG,YAAX,CAAwBE,GAAxB,CAA4BV,qBAA5B,CAAL,EAAyD,OAAzD,KACF;IACHK,UAAU,CAACG,YAAX,CAAwBG,MAAxB,CAA+BX,qBAA/B;EACD;;EAED,MAAMY,MAAM,GAAGP,UAAU,CAACQ,QAAX,GAAsBC,OAAtB,CAA8Bb,eAA9B,EAA+C,EAA/C,CAAf;EACAE,MAAM,CAACY,IAAP,CAAY,WAAZ,EAAyBH,MAAzB,EAAiC;IAC/BI,OAAO,EAAE;EADsB,CAAjC;AAGD,CAbD;;AAeA,eAAed,mBAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","useItemListId"],"sources":["../../../../src/components/ItemList/hooks/index.js"],"sourcesContent":["export { default as useItemListId } from './use-item-list-id';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,aAApB,QAAyC,oBAAzC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { getItemListId } from '../helpers';
|
|
3
|
+
|
|
4
|
+
const useItemListId = ({
|
|
5
|
+
listName
|
|
6
|
+
}) => {
|
|
7
|
+
const idFromStorage = getItemListId(listName);
|
|
8
|
+
const [listId, setListId] = useState(idFromStorage);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const storageEventHandler = () => {
|
|
11
|
+
const newId = getItemListId(listName);
|
|
12
|
+
setListId(newId);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
window.addEventListener('storage', storageEventHandler);
|
|
16
|
+
return () => {
|
|
17
|
+
window.removeEventListener('storage', storageEventHandler);
|
|
18
|
+
};
|
|
19
|
+
}, [listName]);
|
|
20
|
+
return {
|
|
21
|
+
listId
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default useItemListId;
|
|
26
|
+
//# sourceMappingURL=use-item-list-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-item-list-id.js","names":["useState","useEffect","getItemListId","useItemListId","listName","idFromStorage","listId","setListId","storageEventHandler","newId","window","addEventListener","removeEventListener"],"sources":["../../../../src/components/ItemList/hooks/use-item-list-id.js"],"sourcesContent":["import { useState, useEffect } from 'react';\nimport { getItemListId } from '../helpers';\n\nconst useItemListId = ({ listName }) => {\n const idFromStorage = getItemListId(listName);\n const [listId, setListId] = useState(idFromStorage);\n\n useEffect(\n () => {\n const storageEventHandler = () => {\n const newId = getItemListId(listName);\n setListId(newId);\n };\n\n window.addEventListener('storage', storageEventHandler);\n\n return () => {\n window.removeEventListener('storage', storageEventHandler);\n };\n },\n [listName]\n );\n\n return { listId };\n};\n\nexport default useItemListId;\n"],"mappings":"AAAA,SAASA,QAAT,EAAmBC,SAAnB,QAAoC,OAApC;AACA,SAASC,aAAT,QAA8B,YAA9B;;AAEA,MAAMC,aAAa,GAAG,CAAC;EAAEC;AAAF,CAAD,KAAkB;EACtC,MAAMC,aAAa,GAAGH,aAAa,CAACE,QAAD,CAAnC;EACA,MAAM,CAACE,MAAD,EAASC,SAAT,IAAsBP,QAAQ,CAACK,aAAD,CAApC;EAEAJ,SAAS,CACP,MAAM;IACJ,MAAMO,mBAAmB,GAAG,MAAM;MAChC,MAAMC,KAAK,GAAGP,aAAa,CAACE,QAAD,CAA3B;MACAG,SAAS,CAACE,KAAD,CAAT;IACD,CAHD;;IAKAC,MAAM,CAACC,gBAAP,CAAwB,SAAxB,EAAmCH,mBAAnC;IAEA,OAAO,MAAM;MACXE,MAAM,CAACE,mBAAP,CAA2B,SAA3B,EAAsCJ,mBAAtC;IACD,CAFD;EAGD,CAZM,EAaP,CAACJ,QAAD,CAbO,CAAT;EAgBA,OAAO;IAAEE;EAAF,CAAP;AACD,CArBD;;AAuBA,eAAeH,aAAf"}
|
|
@@ -4,6 +4,7 @@ const _excluded = ["src", "alt", "sizeKey", "priority"];
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
|
|
7
|
+
import Head from 'next/head';
|
|
7
8
|
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
8
9
|
import { IN_VIEW_CONFIG } from '../../constants';
|
|
9
10
|
|
|
@@ -18,12 +19,14 @@ const LazyImage = _ref => {
|
|
|
18
19
|
|
|
19
20
|
const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);
|
|
20
21
|
const shouldRender = priority || isIntersecting;
|
|
22
|
+
const HeadComponent = priority ? Head : null;
|
|
21
23
|
return /*#__PURE__*/React.createElement("span", {
|
|
22
24
|
ref: outerRef
|
|
23
25
|
}, shouldRender && /*#__PURE__*/React.createElement(ResponsiveImage, _extends({
|
|
24
26
|
src: src,
|
|
25
27
|
alt: alt,
|
|
26
|
-
sizeKey: sizeKey
|
|
28
|
+
sizeKey: sizeKey,
|
|
29
|
+
HeadComponent: HeadComponent
|
|
27
30
|
}, props)));
|
|
28
31
|
};
|
|
29
32
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LazyImage.js","names":["React","PropTypes","ResponsiveImage","useInView","IN_VIEW_CONFIG","LazyImage","src","alt","sizeKey","priority","props","isIntersecting","outerRef","shouldRender","propTypes","string","isRequired","bool","defaultProps"],"sources":["../../../src/components/LazyImage/LazyImage.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { ResponsiveImage } from '@blaze-cms/image-cdn-react';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { IN_VIEW_CONFIG } from '../../constants';\n\nconst LazyImage = ({ src, alt, sizeKey, priority, ...props }) => {\n const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);\n const shouldRender = priority || isIntersecting;\n\n return (\n <span ref={outerRef}>\n {shouldRender && <ResponsiveImage
|
|
1
|
+
{"version":3,"file":"LazyImage.js","names":["React","PropTypes","ResponsiveImage","Head","useInView","IN_VIEW_CONFIG","LazyImage","src","alt","sizeKey","priority","props","isIntersecting","outerRef","shouldRender","HeadComponent","propTypes","string","isRequired","bool","defaultProps"],"sources":["../../../src/components/LazyImage/LazyImage.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { ResponsiveImage } from '@blaze-cms/image-cdn-react';\nimport Head from 'next/head';\nimport { useInView } from '@blaze-react/utils/lib/customHooks';\nimport { IN_VIEW_CONFIG } from '../../constants';\n\nconst LazyImage = ({ src, alt, sizeKey, priority, ...props }) => {\n const [isIntersecting, outerRef] = useInView(IN_VIEW_CONFIG);\n const shouldRender = priority || isIntersecting;\n const HeadComponent = priority ? Head : null;\n\n return (\n <span ref={outerRef}>\n {shouldRender && (\n <ResponsiveImage\n src={src}\n alt={alt}\n sizeKey={sizeKey}\n HeadComponent={HeadComponent}\n {...props}\n />\n )}\n </span>\n );\n};\n\nLazyImage.propTypes = {\n src: PropTypes.string.isRequired,\n alt: PropTypes.string,\n sizeKey: PropTypes.string.isRequired,\n priority: PropTypes.bool\n};\n\nLazyImage.defaultProps = {\n alt: '',\n priority: false\n};\n\nexport default LazyImage;\n"],"mappings":";;;AAAA,OAAOA,KAAP,MAAkB,OAAlB;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,SAASC,eAAT,QAAgC,4BAAhC;AACA,OAAOC,IAAP,MAAiB,WAAjB;AACA,SAASC,SAAT,QAA0B,oCAA1B;AACA,SAASC,cAAT,QAA+B,iBAA/B;;AAEA,MAAMC,SAAS,GAAG,QAA+C;EAAA,IAA9C;IAAEC,GAAF;IAAOC,GAAP;IAAYC,OAAZ;IAAqBC;EAArB,CAA8C;EAAA,IAAZC,KAAY;;EAC/D,MAAM,CAACC,cAAD,EAAiBC,QAAjB,IAA6BT,SAAS,CAACC,cAAD,CAA5C;EACA,MAAMS,YAAY,GAAGJ,QAAQ,IAAIE,cAAjC;EACA,MAAMG,aAAa,GAAGL,QAAQ,GAAGP,IAAH,GAAU,IAAxC;EAEA,oBACE;IAAM,GAAG,EAAEU;EAAX,GACGC,YAAY,iBACX,oBAAC,eAAD;IACE,GAAG,EAAEP,GADP;IAEE,GAAG,EAAEC,GAFP;IAGE,OAAO,EAAEC,OAHX;IAIE,aAAa,EAAEM;EAJjB,GAKMJ,KALN,EAFJ,CADF;AAaD,CAlBD;;AAoBAL,SAAS,CAACU,SAAV,GAAsB;EACpBT,GAAG,EAAEN,SAAS,CAACgB,MAAV,CAAiBC,UADF;EAEpBV,GAAG,EAAEP,SAAS,CAACgB,MAFK;EAGpBR,OAAO,EAAER,SAAS,CAACgB,MAAV,CAAiBC,UAHN;EAIpBR,QAAQ,EAAET,SAAS,CAACkB;AAJA,CAAtB;AAOAb,SAAS,CAACc,YAAV,GAAyB;EACvBZ,GAAG,EAAE,EADkB;EAEvBE,QAAQ,EAAE;AAFa,CAAzB;AAKA,eAAeJ,SAAf"}
|
|
@@ -46,13 +46,15 @@ const ListBuilder = props => {
|
|
|
46
46
|
requiredSchema,
|
|
47
47
|
searchValues,
|
|
48
48
|
azFilter,
|
|
49
|
-
sortProperties
|
|
49
|
+
sortProperties,
|
|
50
|
+
itemListIds
|
|
50
51
|
} = props;
|
|
51
52
|
const isInfinite = paginationType === INFINITE;
|
|
52
53
|
const listComponent = getListComponent(isCard, paginationType);
|
|
53
54
|
const propsToDisplayValues = checkPropsToUse(propsToDisplay);
|
|
54
55
|
const entityFields = buildPropsQuery(entitySchema, propsToDisplayValues, props) || '';
|
|
55
|
-
const
|
|
56
|
+
const itemsToDisplayToUse = itemListIds || itemsToDisplay;
|
|
57
|
+
const limitToUse = limit || itemsToDisplayToUse.length;
|
|
56
58
|
const shouldApplyDefaultSort = !sortProperties || !sortProperties.length;
|
|
57
59
|
const itemsPerPageToUse = getItemsPerPageToUse(itemsPerPage, limitToUse);
|
|
58
60
|
const initialOffset = getCurrentOffset(offset, itemsPerPageToUse, paginationIndex, limitToUse);
|
|
@@ -76,7 +78,7 @@ const ListBuilder = props => {
|
|
|
76
78
|
filterOperator,
|
|
77
79
|
relations,
|
|
78
80
|
stringProps
|
|
79
|
-
}, itemId,
|
|
81
|
+
}, itemId, itemsToDisplayToUse, shouldApplyDefaultSort, {
|
|
80
82
|
shouldReturnAggs: true,
|
|
81
83
|
isAZ
|
|
82
84
|
});
|
|
@@ -106,7 +108,7 @@ const ListBuilder = props => {
|
|
|
106
108
|
relations,
|
|
107
109
|
stringProps,
|
|
108
110
|
azFilter
|
|
109
|
-
}, itemId,
|
|
111
|
+
}, itemId, itemsToDisplayToUse, shouldApplyDefaultSort, {
|
|
110
112
|
shouldReturnAggs: false,
|
|
111
113
|
isAZ
|
|
112
114
|
});
|
|
@@ -130,7 +132,9 @@ const ListBuilder = props => {
|
|
|
130
132
|
listAggregations: updatedAggregations,
|
|
131
133
|
isAZ: isAZ,
|
|
132
134
|
azFilter: azFilter
|
|
133
|
-
}, props
|
|
135
|
+
}, props, {
|
|
136
|
+
itemsToDisplay: itemsToDisplayToUse
|
|
137
|
+
}));
|
|
134
138
|
};
|
|
135
139
|
|
|
136
140
|
ListBuilder.propTypes = {
|
|
@@ -159,11 +163,13 @@ ListBuilder.propTypes = {
|
|
|
159
163
|
filterOperator: PropTypes.string.isRequired,
|
|
160
164
|
paginationType: PropTypes.string,
|
|
161
165
|
azFilter: PropTypes.string,
|
|
162
|
-
sortProperties: PropTypes.array
|
|
166
|
+
sortProperties: PropTypes.array,
|
|
167
|
+
itemListIds: PropTypes.array
|
|
163
168
|
};
|
|
164
169
|
ListBuilder.defaultProps = {
|
|
165
170
|
entityData: {},
|
|
166
171
|
itemsToDisplay: [],
|
|
172
|
+
itemListIds: null,
|
|
167
173
|
limit: 0,
|
|
168
174
|
omitWrappers: false,
|
|
169
175
|
offset: 0,
|