@blaze-cms/react-page-builder 0.146.0-alpha.2 → 0.146.0-alpha.21
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 +132 -0
- package/lib/components/Card/Card.js +14 -9
- 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/Image/Lightbox/Lightbox.js +2 -2
- package/lib/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib/components/List/ListRender.js.map +1 -1
- package/lib/components/MenuItem/MenuEntitiesItem.js +204 -0
- package/lib/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +25 -68
- 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/SearchFilter.js +22 -4
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +22 -27
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/components/Select.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/Video.js +2 -1
- package/lib/components/Video/Video.js.map +1 -1
- package/lib/components/Video/VideoContext.js +12 -0
- package/lib/components/Video/VideoContext.js.map +1 -0
- package/lib/components/Video/VideoModal.js +2 -2
- package/lib/components/Video/VideoModal.js.map +1 -1
- package/lib/components/Video/VideoRender.js +36 -3
- package/lib/components/Video/VideoRender.js.map +1 -1
- package/lib/components/Video/constants.js +14 -0
- package/lib/components/Video/constants.js.map +1 -0
- package/lib/components/Video/helpers/emit-gtm-event.js +31 -0
- package/lib/components/Video/helpers/emit-gtm-event.js.map +1 -0
- package/lib/components/Video/providers/JWPlayer/JWPlayerController.js +28 -8
- package/lib/components/Video/providers/JWPlayer/JWPlayerController.js.map +1 -1
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js +16 -4
- package/lib/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.js +57 -0
- package/lib/components/Video/providers/YouTube/YoutubeEmbeded.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/Card/Card.js +14 -9
- 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/Image/Lightbox/Lightbox.js +1 -1
- package/lib-es/components/Image/Lightbox/Lightbox.js.map +1 -1
- package/lib-es/components/List/ListRender.js.map +1 -1
- package/lib-es/components/MenuItem/MenuEntitiesItem.js +178 -0
- package/lib-es/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +28 -57
- 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/SearchFilter.js +15 -4
- 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/Select.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/Video.js +2 -1
- package/lib-es/components/Video/Video.js.map +1 -1
- package/lib-es/components/Video/VideoContext.js +6 -0
- package/lib-es/components/Video/VideoContext.js.map +1 -0
- package/lib-es/components/Video/VideoModal.js +1 -1
- package/lib-es/components/Video/VideoModal.js.map +1 -1
- package/lib-es/components/Video/VideoRender.js +28 -3
- package/lib-es/components/Video/VideoRender.js.map +1 -1
- package/lib-es/components/Video/constants.js +7 -0
- package/lib-es/components/Video/constants.js.map +1 -0
- package/lib-es/components/Video/helpers/emit-gtm-event.js +25 -0
- package/lib-es/components/Video/helpers/emit-gtm-event.js.map +1 -0
- package/lib-es/components/Video/providers/JWPlayer/JWPlayerController.js +28 -4
- package/lib-es/components/Video/providers/JWPlayer/JWPlayerController.js.map +1 -1
- package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js +10 -4
- package/lib-es/components/Video/providers/JWPlayer/JWPlayerProvider.js.map +1 -1
- package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.js +60 -2
- package/lib-es/components/Video/providers/YouTube/YoutubeEmbeded.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 +7 -7
- package/src/components/Card/Card.js +25 -16
- 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/Image/Lightbox/Lightbox.js +1 -1
- package/src/components/List/ListRender.js +0 -1
- package/src/components/MenuItem/MenuEntitiesItem.js +204 -0
- package/src/components/MenuItem/MenuItem.js +15 -58
- 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/SearchFilter.js +16 -5
- package/src/components/SearchFilter/SearchFilterContainer.js +21 -22
- package/src/components/SearchFilter/components/Select.js +2 -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/Video.js +1 -1
- package/src/components/Video/VideoContext.js +7 -0
- package/src/components/Video/VideoModal.js +1 -1
- package/src/components/Video/VideoRender.js +28 -3
- package/src/components/Video/constants.js +6 -0
- package/src/components/Video/helpers/emit-gtm-event.js +25 -0
- package/src/components/Video/providers/JWPlayer/JWPlayerController.js +21 -4
- package/src/components/Video/providers/JWPlayer/JWPlayerProvider.js +7 -5
- package/src/components/Video/providers/YouTube/YoutubeEmbeded.js +65 -2
- 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/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/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/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 -51
- 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/__snapshots__/SearchFilterContainer.test.js.snap +7 -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
package/lib-es/hooks/index.js
CHANGED
|
@@ -7,4 +7,6 @@ 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';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","useGetEntitySchema","useGetEntitySchemasAsObj","useGetImageIdFromRelation","useGetImages","usePageBuilder","useGetSingleEntitySchema","useCheckMobileScreen","useBannerInsertion","useAppSyncEventHook"],"sources":["../../src/hooks/index.js"],"sourcesContent":["export { default as useGetEntitySchema } from './use-get-entity-schema';\nexport { default as useGetEntitySchemasAsObj } from './use-get-entity-schemas-as-obj';\nexport { default as useGetImageIdFromRelation } from './use-get-image-id-from-relation';\nexport { default as useGetImages } from './use-get-images';\nexport { default as usePageBuilder } from './use-page-builder';\nexport { default as useGetSingleEntitySchema } from './use-get-single-entity-schema';\nexport { default as useCheckMobileScreen } from './use-check-mobile-screen';\nexport { default as useBannerInsertion } from './use-banner-insertion';\nexport { default as useAppSyncEventHook } from './use-app-sync-event-hook';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAAkB,QAAQ,yBAAyB;AACvE,SAASD,OAAO,IAAIE,wBAAwB,QAAQ,iCAAiC;AACrF,SAASF,OAAO,IAAIG,yBAAyB,QAAQ,kCAAkC;AACvF,SAASH,OAAO,IAAII,YAAY,QAAQ,kBAAkB;AAC1D,SAASJ,OAAO,IAAIK,cAAc,QAAQ,oBAAoB;AAC9D,SAASL,OAAO,IAAIM,wBAAwB,QAAQ,gCAAgC;AACpF,SAASN,OAAO,IAAIO,oBAAoB,QAAQ,2BAA2B;AAC3E,SAASP,OAAO,IAAIQ,kBAAkB,QAAQ,wBAAwB;AACtE,SAASR,OAAO,IAAIS,mBAAmB,QAAQ,2BAA2B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","useGetEntitySchema","useGetEntitySchemasAsObj","useGetImageIdFromRelation","useGetImages","usePageBuilder","useGetSingleEntitySchema","useCheckMobileScreen","useBannerInsertion","useAppSyncEventHook","usePortal","useFilterAggregationValues"],"sources":["../../src/hooks/index.js"],"sourcesContent":["export { default as useGetEntitySchema } from './use-get-entity-schema';\nexport { default as useGetEntitySchemasAsObj } from './use-get-entity-schemas-as-obj';\nexport { default as useGetImageIdFromRelation } from './use-get-image-id-from-relation';\nexport { default as useGetImages } from './use-get-images';\nexport { default as usePageBuilder } from './use-page-builder';\nexport { default as useGetSingleEntitySchema } from './use-get-single-entity-schema';\nexport { default as useCheckMobileScreen } from './use-check-mobile-screen';\nexport { default as useBannerInsertion } from './use-banner-insertion';\nexport { default as useAppSyncEventHook } from './use-app-sync-event-hook';\nexport { default as usePortal } from './use-portal';\nexport { default as useFilterAggregationValues } from './use-filter-aggregation-values';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAAkB,QAAQ,yBAAyB;AACvE,SAASD,OAAO,IAAIE,wBAAwB,QAAQ,iCAAiC;AACrF,SAASF,OAAO,IAAIG,yBAAyB,QAAQ,kCAAkC;AACvF,SAASH,OAAO,IAAII,YAAY,QAAQ,kBAAkB;AAC1D,SAASJ,OAAO,IAAIK,cAAc,QAAQ,oBAAoB;AAC9D,SAASL,OAAO,IAAIM,wBAAwB,QAAQ,gCAAgC;AACpF,SAASN,OAAO,IAAIO,oBAAoB,QAAQ,2BAA2B;AAC3E,SAASP,OAAO,IAAIQ,kBAAkB,QAAQ,wBAAwB;AACtE,SAASR,OAAO,IAAIS,mBAAmB,QAAQ,2BAA2B;AAC1E,SAAST,OAAO,IAAIU,SAAS,QAAQ,cAAc;AACnD,SAASV,OAAO,IAAIW,0BAA0B,QAAQ,iCAAiC","ignoreList":[]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
const useFilterAggregationValues = ({
|
|
6
|
+
data,
|
|
7
|
+
filterValues
|
|
8
|
+
}) => {
|
|
9
|
+
const [stateValues, setStateValues] = useState(data);
|
|
10
|
+
const [prop, setProp] = useState('');
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!stateValues) return setStateValues(data);
|
|
13
|
+
const lastChangedFilter = filterValues === null || filterValues === void 0 ? void 0 : filterValues[prop];
|
|
14
|
+
if (!data) return;
|
|
15
|
+
const newOptions = data[prop];
|
|
16
|
+
const currentOptions = stateValues === null || stateValues === void 0 ? void 0 : stateValues[prop];
|
|
17
|
+
if (lastChangedFilter === null || lastChangedFilter === '') {
|
|
18
|
+
return setStateValues(prevState => _objectSpread(_objectSpread({}, data), {}, {
|
|
19
|
+
[prop]: newOptions
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
setStateValues(prevState => _objectSpread(_objectSpread({}, data), {}, {
|
|
23
|
+
[prop]: currentOptions
|
|
24
|
+
}));
|
|
25
|
+
},
|
|
26
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
27
|
+
[data, prop, filterValues]);
|
|
28
|
+
return [stateValues, setStateValues, setProp, prop];
|
|
29
|
+
};
|
|
30
|
+
export default useFilterAggregationValues;
|
|
31
|
+
//# sourceMappingURL=use-filter-aggregation-values.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-filter-aggregation-values.js","names":["useEffect","useState","useFilterAggregationValues","data","filterValues","stateValues","setStateValues","prop","setProp","lastChangedFilter","newOptions","currentOptions","prevState","_objectSpread"],"sources":["../../src/hooks/use-filter-aggregation-values.js"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nconst useFilterAggregationValues = ({ data, filterValues }) => {\n const [stateValues, setStateValues] = useState(data);\n const [prop, setProp] = useState('');\n\n useEffect(\n () => {\n if (!stateValues) return setStateValues(data);\n\n const lastChangedFilter = filterValues?.[prop];\n\n if (!data) return;\n\n const newOptions = data[prop];\n const currentOptions = stateValues?.[prop];\n\n if (lastChangedFilter === null || lastChangedFilter === '') {\n return setStateValues(prevState => ({\n ...data,\n [prop]: newOptions\n }));\n }\n\n setStateValues(prevState => ({\n ...data,\n [prop]: currentOptions\n }));\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [data, prop, filterValues]\n );\n\n return [stateValues, setStateValues, setProp, prop];\n};\n\nexport default useFilterAggregationValues;\n"],"mappings":";;;AAAA,SAASA,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAE3C,MAAMC,0BAA0B,GAAGA,CAAC;EAAEC,IAAI;EAAEC;AAAa,CAAC,KAAK;EAC7D,MAAM,CAACC,WAAW,EAAEC,cAAc,CAAC,GAAGL,QAAQ,CAACE,IAAI,CAAC;EACpD,MAAM,CAACI,IAAI,EAAEC,OAAO,CAAC,GAAGP,QAAQ,CAAC,EAAE,CAAC;EAEpCD,SAAS,CACP,MAAM;IACJ,IAAI,CAACK,WAAW,EAAE,OAAOC,cAAc,CAACH,IAAI,CAAC;IAE7C,MAAMM,iBAAiB,GAAGL,YAAY,aAAZA,YAAY,uBAAZA,YAAY,CAAGG,IAAI,CAAC;IAE9C,IAAI,CAACJ,IAAI,EAAE;IAEX,MAAMO,UAAU,GAAGP,IAAI,CAACI,IAAI,CAAC;IAC7B,MAAMI,cAAc,GAAGN,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAGE,IAAI,CAAC;IAE1C,IAAIE,iBAAiB,KAAK,IAAI,IAAIA,iBAAiB,KAAK,EAAE,EAAE;MAC1D,OAAOH,cAAc,CAACM,SAAS,IAAAC,aAAA,CAAAA,aAAA,KAC1BV,IAAI;QACP,CAACI,IAAI,GAAGG;MAAU,EAClB,CAAC;IACL;IAEAJ,cAAc,CAACM,SAAS,IAAAC,aAAA,CAAAA,aAAA,KACnBV,IAAI;MACP,CAACI,IAAI,GAAGI;IAAc,EACtB,CAAC;EACL,CAAC;EACD;EACA,CAACR,IAAI,EAAEI,IAAI,EAAEH,YAAY,CAC3B,CAAC;EAED,OAAO,CAACC,WAAW,EAAEC,cAAc,EAAEE,OAAO,EAAED,IAAI,CAAC;AACrD,CAAC;AAED,eAAeL,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
|
+
function usePortal() {
|
|
3
|
+
const rootElemRef = React.useRef(document.createElement('div'));
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
document.body.appendChild(rootElemRef.current);
|
|
6
|
+
const element = rootElemRef.current;
|
|
7
|
+
return function removeElement() {
|
|
8
|
+
element.remove();
|
|
9
|
+
};
|
|
10
|
+
}, []);
|
|
11
|
+
return rootElemRef.current;
|
|
12
|
+
}
|
|
13
|
+
export default usePortal;
|
|
14
|
+
//# sourceMappingURL=use-portal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-portal.js","names":["React","useEffect","usePortal","rootElemRef","useRef","document","createElement","body","appendChild","current","element","removeElement","remove"],"sources":["../../src/hooks/use-portal.js"],"sourcesContent":["import React, { useEffect } from 'react';\n\nfunction usePortal() {\n const rootElemRef = React.useRef(document.createElement('div'));\n\n useEffect(() => {\n document.body.appendChild(rootElemRef.current);\n\n const element = rootElemRef.current;\n return function removeElement() {\n element.remove();\n };\n }, []);\n\n return rootElemRef.current;\n}\n\nexport default usePortal;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AAExC,SAASC,SAASA,CAAA,EAAG;EACnB,MAAMC,WAAW,GAAGH,KAAK,CAACI,MAAM,CAACC,QAAQ,CAACC,aAAa,CAAC,KAAK,CAAC,CAAC;EAE/DL,SAAS,CAAC,MAAM;IACdI,QAAQ,CAACE,IAAI,CAACC,WAAW,CAACL,WAAW,CAACM,OAAO,CAAC;IAE9C,MAAMC,OAAO,GAAGP,WAAW,CAACM,OAAO;IACnC,OAAO,SAASE,aAAaA,CAAA,EAAG;MAC9BD,OAAO,CAACE,MAAM,CAAC,CAAC;IAClB,CAAC;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,WAAW,CAACM,OAAO;AAC5B;AAEA,eAAeP,SAAS","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/react-page-builder",
|
|
3
|
-
"version": "0.146.0-alpha.
|
|
3
|
+
"version": "0.146.0-alpha.21",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,15 +27,15 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/core-auth-ui": "
|
|
30
|
+
"@blaze-cms/core-auth-ui": "0.146.0-alpha.21",
|
|
31
31
|
"@blaze-cms/core-errors": "^0.140.3",
|
|
32
32
|
"@blaze-cms/core-errors-ui": "^0.140.3",
|
|
33
|
-
"@blaze-cms/image-cdn-react": "0.3.0-alpha.
|
|
34
|
-
"@blaze-cms/nextjs-components": "
|
|
35
|
-
"@blaze-cms/plugin-search-ui": "
|
|
33
|
+
"@blaze-cms/image-cdn-react": "0.3.0-alpha.7",
|
|
34
|
+
"@blaze-cms/nextjs-components": "0.146.0-alpha.17",
|
|
35
|
+
"@blaze-cms/plugin-search-ui": "0.146.0-alpha.17",
|
|
36
36
|
"@blaze-cms/setup-ui": "^0.140.3",
|
|
37
37
|
"@blaze-cms/utils": "^0.144.0",
|
|
38
|
-
"@blaze-cms/utils-handlebars": "
|
|
38
|
+
"@blaze-cms/utils-handlebars": "0.146.0-alpha.17",
|
|
39
39
|
"@blaze-react/breadcrumb": "0.8.0-alpha.60",
|
|
40
40
|
"@blaze-react/button": "0.8.0-alpha.82",
|
|
41
41
|
"@blaze-react/checkboxes": "0.5.31",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"lib/*",
|
|
91
91
|
"lib-es/*"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "c4cc6f2e171bca55ee4f015d75899abf79e40f08"
|
|
94
94
|
}
|
|
@@ -99,48 +99,57 @@ const Card = ({
|
|
|
99
99
|
if (shouldTriggerRouteChange) router.push(`/Resolver`, url);
|
|
100
100
|
};
|
|
101
101
|
|
|
102
|
-
// todo:
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
102
|
+
// todo: asses whether we make link wrapper default after wider testing with BLAZE_PB_ADD_CLICK_TO_CARDS
|
|
103
|
+
const useLinkWrapper = url && process.env.BLAZE_PB_ADD_CLICK_TO_CARDS;
|
|
104
|
+
const clickProps = useLinkWrapper
|
|
105
|
+
? {
|
|
106
|
+
onClick: handleCardClick,
|
|
107
|
+
href: url,
|
|
108
|
+
ariaLabel: name
|
|
109
|
+
}
|
|
110
|
+
: {};
|
|
111
|
+
const CardWrapper = useLinkWrapper ? BlazeLink : 'div';
|
|
112
|
+
const childLinkHref = useLinkWrapper ? undefined : url;
|
|
113
|
+
const ChildLinkWrapper = useLinkWrapper ? 'div' : BlazeLink;
|
|
114
|
+
|
|
110
115
|
return (
|
|
111
116
|
<Wrapper {...wrapperProps}>
|
|
112
|
-
<
|
|
117
|
+
<CardWrapper className={classNameWithModifiers} {...clickProps}>
|
|
113
118
|
{shouldDisplayThumbnail && (
|
|
114
119
|
<div className={getModifiers('card__image', modifiers)}>
|
|
115
|
-
<
|
|
120
|
+
<ChildLinkWrapper
|
|
121
|
+
gtmId={gtmId}
|
|
122
|
+
href={childLinkHref}
|
|
123
|
+
className="card__image-link"
|
|
124
|
+
scroll>
|
|
116
125
|
<LazyImage
|
|
117
126
|
src={imageSrc}
|
|
118
127
|
alt={altText}
|
|
119
128
|
sizeKey={dynamicSizeKey}
|
|
120
129
|
priority={priority}
|
|
121
130
|
/>
|
|
122
|
-
</
|
|
131
|
+
</ChildLinkWrapper>
|
|
123
132
|
</div>
|
|
124
133
|
)}
|
|
125
134
|
<div className={contentWrapperModifier}>
|
|
126
135
|
<div className={getModifiers('card__content', modifiers)}>
|
|
127
136
|
{displayCategory &&
|
|
128
137
|
(publishedListingPage ? (
|
|
129
|
-
<
|
|
138
|
+
<ChildLinkWrapper
|
|
130
139
|
gtmId={gtmId}
|
|
131
140
|
href={publishedListingPage}
|
|
132
141
|
className="badge badge--label"
|
|
133
142
|
scroll>
|
|
134
143
|
{preHeader.name}
|
|
135
|
-
</
|
|
144
|
+
</ChildLinkWrapper>
|
|
136
145
|
) : (
|
|
137
146
|
<div className="badge badge--label">{label}</div>
|
|
138
147
|
))}
|
|
139
148
|
{displayTitle && (
|
|
140
149
|
<div className={titleWrapperModifier}>
|
|
141
|
-
<
|
|
150
|
+
<ChildLinkWrapper title={linkTitle} gtmId={gtmId} href={childLinkHref} scroll>
|
|
142
151
|
{headline}
|
|
143
|
-
</
|
|
152
|
+
</ChildLinkWrapper>
|
|
144
153
|
</div>
|
|
145
154
|
)}
|
|
146
155
|
{!!pageBuilderComponents.length && (
|
|
@@ -175,7 +184,7 @@ const Card = ({
|
|
|
175
184
|
<div className="card__child-content">{renderChildren(cardChildren)}</div>
|
|
176
185
|
)}
|
|
177
186
|
</div>
|
|
178
|
-
</
|
|
187
|
+
</CardWrapper>
|
|
179
188
|
</Wrapper>
|
|
180
189
|
);
|
|
181
190
|
};
|
|
@@ -36,6 +36,7 @@ const CardContainer = ({
|
|
|
36
36
|
autoScrollTimer,
|
|
37
37
|
overlayModifier,
|
|
38
38
|
titleOverlayModifier,
|
|
39
|
+
VariantComponent,
|
|
39
40
|
...cardProps
|
|
40
41
|
}) => {
|
|
41
42
|
const { itemId } = useContext(MainContext);
|
|
@@ -47,7 +48,8 @@ const CardContainer = ({
|
|
|
47
48
|
const dynamicWrapperSizes = enableCarousel
|
|
48
49
|
? ''
|
|
49
50
|
: getDynamicGridClasses('grid', itemsPerRow, designConfig);
|
|
50
|
-
const
|
|
51
|
+
const InitialWrapper = enableCarousel ? CarouselWrapper : Wrapper;
|
|
52
|
+
const CardWrapper = VariantComponent || InitialWrapper;
|
|
51
53
|
let bannerIndex = 0;
|
|
52
54
|
|
|
53
55
|
return (
|
|
@@ -154,7 +156,8 @@ CardContainer.propTypes = {
|
|
|
154
156
|
enableOverlay: PropTypes.bool,
|
|
155
157
|
overlayModifier: PropTypes.string,
|
|
156
158
|
titleOverlayModifier: PropTypes.string,
|
|
157
|
-
autoScrollTimer: PropTypes.number
|
|
159
|
+
autoScrollTimer: PropTypes.number,
|
|
160
|
+
VariantComponent: PropTypes.func
|
|
158
161
|
};
|
|
159
162
|
|
|
160
163
|
CardContainer.defaultProps = {
|
|
@@ -179,7 +182,8 @@ CardContainer.defaultProps = {
|
|
|
179
182
|
enableOverlay: false,
|
|
180
183
|
autoScrollTimer: 0,
|
|
181
184
|
overlayModifier: '',
|
|
182
|
-
titleOverlayModifier: ''
|
|
185
|
+
titleOverlayModifier: '',
|
|
186
|
+
VariantComponent: null
|
|
183
187
|
};
|
|
184
188
|
|
|
185
189
|
export default withTitle(CardContainer);
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useQuery } from '@apollo/client';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { useRouter } from 'next/router';
|
|
5
|
+
import { parseUrl } from 'query-string';
|
|
6
|
+
import { getSingleEntitySchema, getItemList } from '../../application/query';
|
|
5
7
|
import CardsRender from './CardsRender';
|
|
6
8
|
import { buildPropsQuery, getGenericProps, checkPropsToUse } from '../../helpers';
|
|
7
9
|
import { WITH_BANNER } from '../../constants';
|
|
10
|
+
import { getItemListId, getItemListIds } from '../ItemList/helpers';
|
|
8
11
|
|
|
9
12
|
const CardsFactory = ({
|
|
10
13
|
entity,
|
|
@@ -12,15 +15,32 @@ const CardsFactory = ({
|
|
|
12
15
|
propsToDisplay,
|
|
13
16
|
itemsToDisplay,
|
|
14
17
|
itemListName,
|
|
18
|
+
VariantComponent,
|
|
15
19
|
...cardProps
|
|
16
20
|
}) => {
|
|
17
21
|
const entityTouse = entities && entities.length ? entities[0] : entity;
|
|
22
|
+
const router = useRouter();
|
|
23
|
+
const { asPath } = router;
|
|
24
|
+
const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');
|
|
25
|
+
|
|
26
|
+
const { query: { itemListId: queryItemListId } = {} } = parseUrl(parsedQuery);
|
|
27
|
+
|
|
18
28
|
const { data, error, loading } = useQuery(getSingleEntitySchema, {
|
|
19
29
|
variables: { id: entityTouse }
|
|
20
30
|
});
|
|
21
31
|
|
|
22
|
-
|
|
23
|
-
|
|
32
|
+
const itemListId = getItemListId(itemListName, queryItemListId);
|
|
33
|
+
|
|
34
|
+
const { data: itemListData = {}, loading: itemListLoading, error: itemListError } = useQuery(
|
|
35
|
+
getItemList,
|
|
36
|
+
{
|
|
37
|
+
variables: { id: itemListId },
|
|
38
|
+
skip: !itemListId
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (loading || itemListLoading) return '';
|
|
43
|
+
if (error || itemListError) return error.message || itemListError.message;
|
|
24
44
|
if (!data) return null;
|
|
25
45
|
|
|
26
46
|
const propsToDisplayValues = checkPropsToUse(propsToDisplay);
|
|
@@ -28,13 +48,19 @@ const CardsFactory = ({
|
|
|
28
48
|
const { gridModifier, ...cardRenderProps } = getGenericProps(cardProps);
|
|
29
49
|
const extraModifierForBanner = cardRenderProps.banner ? WITH_BANNER : '';
|
|
30
50
|
|
|
51
|
+
const itemListIds = getItemListIds(itemListData);
|
|
52
|
+
const itemsToDisplayToUse = itemListIds || itemsToDisplay;
|
|
53
|
+
|
|
54
|
+
if (itemListName && !itemListIds) return null;
|
|
55
|
+
|
|
31
56
|
return (
|
|
32
57
|
<CardsRender
|
|
33
58
|
gridModifier={`${gridModifier}${extraModifierForBanner}`}
|
|
34
59
|
bannerModifier={extraModifierForBanner}
|
|
35
|
-
itemsToDisplay={
|
|
60
|
+
itemsToDisplay={itemsToDisplayToUse}
|
|
36
61
|
propsToDisplay={propsToDisplay}
|
|
37
62
|
entityFields={extraProps}
|
|
63
|
+
VariantComponent={VariantComponent}
|
|
38
64
|
{...cardRenderProps}
|
|
39
65
|
entity={entityTouse}
|
|
40
66
|
entities={entities}
|
|
@@ -47,7 +73,8 @@ CardsFactory.propTypes = {
|
|
|
47
73
|
propsToDisplay: PropTypes.array,
|
|
48
74
|
itemsToDisplay: PropTypes.array,
|
|
49
75
|
itemListName: PropTypes.string,
|
|
50
|
-
entities: PropTypes.array
|
|
76
|
+
entities: PropTypes.array,
|
|
77
|
+
VariantComponent: PropTypes.func
|
|
51
78
|
};
|
|
52
79
|
|
|
53
80
|
CardsFactory.defaultProps = {
|
|
@@ -55,7 +82,8 @@ CardsFactory.defaultProps = {
|
|
|
55
82
|
itemsToDisplay: [],
|
|
56
83
|
itemListName: '',
|
|
57
84
|
entity: null,
|
|
58
|
-
entities: null
|
|
85
|
+
entities: null,
|
|
86
|
+
VariantComponent: null
|
|
59
87
|
};
|
|
60
88
|
|
|
61
89
|
export default CardsFactory;
|
|
@@ -34,6 +34,7 @@ const CardsRender = ({
|
|
|
34
34
|
entityFields,
|
|
35
35
|
itemsToDisplay,
|
|
36
36
|
children,
|
|
37
|
+
VariantComponent,
|
|
37
38
|
...otherProps
|
|
38
39
|
}) => {
|
|
39
40
|
const { isPreview } = useContext(MainContext);
|
|
@@ -204,6 +205,7 @@ const CardsRender = ({
|
|
|
204
205
|
gtmChildren={gtmChildren}
|
|
205
206
|
cardChildren={regularChildren}
|
|
206
207
|
graphqlEntityMap={graphqlEntityMap}
|
|
208
|
+
VariantComponent={VariantComponent}
|
|
207
209
|
{...variableProps}
|
|
208
210
|
/>
|
|
209
211
|
</>
|
|
@@ -215,13 +217,15 @@ CardsRender.propTypes = {
|
|
|
215
217
|
entity: PropTypes.string.isRequired,
|
|
216
218
|
entityFields: PropTypes.string.isRequired,
|
|
217
219
|
itemsToDisplay: PropTypes.array,
|
|
218
|
-
entities: PropTypes.array
|
|
220
|
+
entities: PropTypes.array,
|
|
221
|
+
VariantComponent: PropTypes.func
|
|
219
222
|
};
|
|
220
223
|
|
|
221
224
|
CardsRender.defaultProps = {
|
|
222
225
|
children: [],
|
|
223
226
|
itemsToDisplay: [],
|
|
224
|
-
entities: []
|
|
227
|
+
entities: [],
|
|
228
|
+
VariantComponent: null
|
|
225
229
|
};
|
|
226
230
|
|
|
227
231
|
export default CardsRender;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export { default as getPublishedListingUrl } from './get-published-listing-url';
|
|
2
2
|
export { default as useDynamicSizeKey } from './use-dynamic-size-key';
|
|
3
3
|
export { default as getDynamicGridClasses } from './get-dynamic-grid-classes';
|
|
4
|
-
export { default as filtersSetup } from '
|
|
5
|
-
export { default as filterQuerySetup } from '
|
|
6
|
-
export { default as shouldReturn } from '
|
|
7
|
-
export { default as shouldSkipSingleQuery } from '
|
|
8
|
-
export { default as getUpdatedSortProperties } from '
|
|
9
|
-
export { default as getUpdatedItemsToDisplay } from '
|
|
4
|
+
export { default as filtersSetup } from '../../../helpers/filters-setup';
|
|
5
|
+
export { default as filterQuerySetup } from '../../../helpers/filter-query-setup';
|
|
6
|
+
export { default as shouldReturn } from '../../../helpers/should-return';
|
|
7
|
+
export { default as shouldSkipSingleQuery } from '../../../helpers/should-skip-single-query';
|
|
8
|
+
export { default as getUpdatedSortProperties } from '../../../helpers/get-updated-sort-properties';
|
|
9
|
+
export { default as getUpdatedItemsToDisplay } from '../../../helpers/get-updated-items-to-display';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React, { Fragment } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import Modal from '@blaze-react/modal';
|
|
4
3
|
import { useInView } from '@blaze-react/utils/lib/customHooks';
|
|
5
4
|
import { ResponsiveImage } from '@blaze-cms/image-cdn-react';
|
|
5
|
+
import Modal from '../../ModalAdapter';
|
|
6
6
|
import BlazeLink from '../../BlazeLink';
|
|
7
7
|
import { IN_VIEW_CONFIG } from '../../../constants';
|
|
8
8
|
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useQuery } from '@apollo/client';
|
|
4
|
+
import MenuItemRender from './MenuItemRender';
|
|
5
|
+
import {
|
|
6
|
+
buildPropsQuery,
|
|
7
|
+
getEntityData,
|
|
8
|
+
getRequiredSchemas,
|
|
9
|
+
getUnpublishedEntityName,
|
|
10
|
+
getUpdatedFilterBy,
|
|
11
|
+
filterQuerySetup,
|
|
12
|
+
filtersSetup,
|
|
13
|
+
getUpdatedItemsToDisplay,
|
|
14
|
+
getUpdatedSortProperties,
|
|
15
|
+
shouldReturn,
|
|
16
|
+
shouldSkipSingleQuery
|
|
17
|
+
} from '../../helpers';
|
|
18
|
+
import { useGetEntitySchemasAsObj } from '../../hooks';
|
|
19
|
+
import { generateSingleItemQuery } from '../../application/query';
|
|
20
|
+
import { AND, SEARCH_PUBLISHED_CONTENT } from '../../constants';
|
|
21
|
+
|
|
22
|
+
const MenuEntitiesItem = ({ entities, parent, ...props }) => {
|
|
23
|
+
const { itemEntity: parentEntity, itemId: parentId } = parent;
|
|
24
|
+
const {
|
|
25
|
+
operator: filterOperator = AND,
|
|
26
|
+
filterByProperty = [],
|
|
27
|
+
sortProperties = [],
|
|
28
|
+
itemsToDisplay,
|
|
29
|
+
filterBy = [],
|
|
30
|
+
sortby,
|
|
31
|
+
sort
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
const unpublishedEntityName = getUnpublishedEntityName(parentEntity);
|
|
35
|
+
|
|
36
|
+
const [updatedSortProperties, sortbyFilters] = getUpdatedSortProperties(
|
|
37
|
+
sort,
|
|
38
|
+
sortby,
|
|
39
|
+
sortProperties
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const {
|
|
43
|
+
data: mainSchemas = {},
|
|
44
|
+
loading: entityObjloading,
|
|
45
|
+
error: entityObjError
|
|
46
|
+
} = useGetEntitySchemasAsObj([unpublishedEntityName, ...entities]);
|
|
47
|
+
|
|
48
|
+
const [filterEntity] = entities;
|
|
49
|
+
|
|
50
|
+
const { [filterEntity]: filterEntitySchema = {} } = mainSchemas;
|
|
51
|
+
|
|
52
|
+
const entitiesTypes = entities.map(entity => getEntityData(entity, mainSchemas[entity]));
|
|
53
|
+
const graphqlEntityMap = entitiesTypes.reduce(
|
|
54
|
+
(acc, entityType) => ({ ...acc, [entityType.entityType]: entityType.entity }),
|
|
55
|
+
{}
|
|
56
|
+
);
|
|
57
|
+
const docTypes = entitiesTypes.map(({ docType }) => docType);
|
|
58
|
+
const entityTypes = entitiesTypes.map(({ entityType }) => entityType);
|
|
59
|
+
|
|
60
|
+
const entityFields = buildPropsQuery(filterEntitySchema, ['name', 'url']) || '';
|
|
61
|
+
const parentSchema = mainSchemas[unpublishedEntityName] || {};
|
|
62
|
+
|
|
63
|
+
const {
|
|
64
|
+
entitySameAsCurrentItemEntity,
|
|
65
|
+
filterEntityRelations,
|
|
66
|
+
inheritedFilters,
|
|
67
|
+
queryProps,
|
|
68
|
+
getAction,
|
|
69
|
+
action
|
|
70
|
+
} = filtersSetup({
|
|
71
|
+
itemEntityUpdated: unpublishedEntityName,
|
|
72
|
+
currentSchema: parentSchema,
|
|
73
|
+
filterEntitySchema,
|
|
74
|
+
filterByProperty,
|
|
75
|
+
entityFields,
|
|
76
|
+
entityTypes,
|
|
77
|
+
filterBy,
|
|
78
|
+
entities
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
const {
|
|
82
|
+
data: { entityData: parentEntityData = {} } = {},
|
|
83
|
+
error: singleItemQueryError,
|
|
84
|
+
loading: singleItemQueryLoading
|
|
85
|
+
} = useQuery(generateSingleItemQuery(getAction, queryProps), {
|
|
86
|
+
variables: { id: parentId },
|
|
87
|
+
skip: shouldSkipSingleQuery(entityObjloading, getAction, queryProps)
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
const {
|
|
91
|
+
data: requiredSchema = {},
|
|
92
|
+
loading: schemaLoading,
|
|
93
|
+
error: schemaError
|
|
94
|
+
} = useGetEntitySchemasAsObj(
|
|
95
|
+
getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema),
|
|
96
|
+
entityObjloading
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const getEntitySchemas = Object.values(requiredSchema);
|
|
100
|
+
|
|
101
|
+
const updatedItemsToDisplay = getUpdatedItemsToDisplay({
|
|
102
|
+
inheritedFilters,
|
|
103
|
+
parentEntityData,
|
|
104
|
+
itemsToDisplay,
|
|
105
|
+
parentSchema
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
const variableProps = {
|
|
109
|
+
sortProperties: updatedSortProperties,
|
|
110
|
+
filterByProperty,
|
|
111
|
+
sortby: null,
|
|
112
|
+
sort: null,
|
|
113
|
+
filterBy
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const updatedFilterBy = getUpdatedFilterBy(
|
|
117
|
+
inheritedFilters,
|
|
118
|
+
parentEntityData,
|
|
119
|
+
filterEntitySchema,
|
|
120
|
+
parentSchema,
|
|
121
|
+
parentId,
|
|
122
|
+
variableProps
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const { variables } = filterQuerySetup({
|
|
126
|
+
itemsToDisplay: updatedItemsToDisplay,
|
|
127
|
+
entitySameAsCurrentItemEntity,
|
|
128
|
+
filterEntityRelations,
|
|
129
|
+
entity: filterEntity,
|
|
130
|
+
docType: docTypes,
|
|
131
|
+
getEntitySchemas,
|
|
132
|
+
updatedFilterBy,
|
|
133
|
+
variableProps,
|
|
134
|
+
filterOperator
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
variables.limit = props.limit || undefined;
|
|
138
|
+
|
|
139
|
+
const hasNoItemsToDisplayOrFilter = !updatedItemsToDisplay.length && !updatedFilterBy;
|
|
140
|
+
|
|
141
|
+
const { data = {} } = useQuery(action, {
|
|
142
|
+
variables,
|
|
143
|
+
skip: shouldReturn(
|
|
144
|
+
hasNoItemsToDisplayOrFilter,
|
|
145
|
+
singleItemQueryLoading,
|
|
146
|
+
singleItemQueryError,
|
|
147
|
+
entityObjloading,
|
|
148
|
+
entityObjError,
|
|
149
|
+
schemaLoading,
|
|
150
|
+
schemaError
|
|
151
|
+
)
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
const { results } = data[SEARCH_PUBLISHED_CONTENT] || {};
|
|
155
|
+
|
|
156
|
+
if (!results) return null;
|
|
157
|
+
|
|
158
|
+
return results.map(item => {
|
|
159
|
+
const itemParent = {
|
|
160
|
+
itemId: item.id,
|
|
161
|
+
itemEntity: graphqlEntityMap[item.__typename]
|
|
162
|
+
};
|
|
163
|
+
return <MenuItemRender {...props} parent={itemParent} url={item.url || props.url} />;
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
MenuEntitiesItem.propTypes = {
|
|
168
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
169
|
+
eventType: PropTypes.string.isRequired,
|
|
170
|
+
modifier: PropTypes.string,
|
|
171
|
+
parent: PropTypes.object,
|
|
172
|
+
text: PropTypes.string,
|
|
173
|
+
url: PropTypes.string,
|
|
174
|
+
entities: PropTypes.array,
|
|
175
|
+
limit: PropTypes.number,
|
|
176
|
+
offset: PropTypes.number,
|
|
177
|
+
sortby: PropTypes.array,
|
|
178
|
+
filterBy: PropTypes.array,
|
|
179
|
+
sort: PropTypes.string,
|
|
180
|
+
operator: PropTypes.string.isRequired,
|
|
181
|
+
filterOperator: PropTypes.string.isRequired,
|
|
182
|
+
sortProperties: PropTypes.array,
|
|
183
|
+
filterByProperty: PropTypes.array,
|
|
184
|
+
itemsToDisplay: PropTypes.array
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
MenuEntitiesItem.defaultProps = {
|
|
188
|
+
children: null,
|
|
189
|
+
modifier: '',
|
|
190
|
+
limit: 0,
|
|
191
|
+
offset: 0,
|
|
192
|
+
itemsToDisplay: [],
|
|
193
|
+
sort: '',
|
|
194
|
+
sortby: [],
|
|
195
|
+
sortProperties: [],
|
|
196
|
+
filterByProperty: [],
|
|
197
|
+
parent: {},
|
|
198
|
+
filterBy: [],
|
|
199
|
+
text: '',
|
|
200
|
+
url: '',
|
|
201
|
+
entities: []
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
export default MenuEntitiesItem;
|