@blaze-cms/react-page-builder 0.146.0-alpha.4 → 0.146.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/components/Card/helpers/index.js +6 -6
- package/lib/components/Card/helpers/index.js.map +1 -1
- package/lib/components/MenuItem/MenuEntitiesItem.js +203 -0
- package/lib/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib/components/MenuItem/MenuItem.js +25 -68
- package/lib/components/MenuItem/MenuItem.js.map +1 -1
- package/lib/components/MenuItem/MenuItemRender.js +103 -0
- package/lib/components/MenuItem/MenuItemRender.js.map +1 -0
- 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-es/components/Card/helpers/index.js +6 -6
- package/lib-es/components/Card/helpers/index.js.map +1 -1
- package/lib-es/components/MenuItem/MenuEntitiesItem.js +177 -0
- package/lib-es/components/MenuItem/MenuEntitiesItem.js.map +1 -0
- package/lib-es/components/MenuItem/MenuItem.js +28 -57
- package/lib-es/components/MenuItem/MenuItem.js.map +1 -1
- package/lib-es/components/MenuItem/MenuItemRender.js +83 -0
- package/lib-es/components/MenuItem/MenuItemRender.js.map +1 -0
- 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/package.json +2 -2
- package/src/components/Card/helpers/index.js +6 -6
- package/src/components/MenuItem/MenuEntitiesItem.js +202 -0
- package/src/components/MenuItem/MenuItem.js +15 -58
- package/src/components/MenuItem/MenuItemRender.js +91 -0
- 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/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +1 -1
- 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/mocks.js +71 -0
- 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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useState, useContext, useEffect } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FaChevronDown, FaChevronUp } from 'react-icons/fa';
|
|
4
|
+
import { useStringTemplate } from '@blaze-cms/utils-handlebars';
|
|
5
|
+
import { HOVER, MOUSE_ENTER, MOUSE_LEAVE, HIDDEN } from '../../constants';
|
|
6
|
+
import { hasChildren } from '../../helpers';
|
|
7
|
+
import BlazeLink from '../BlazeLink';
|
|
8
|
+
import MenuContext from '../Menu/MenuContext';
|
|
9
|
+
const MenuItemRender = ({
|
|
10
|
+
children,
|
|
11
|
+
eventType,
|
|
12
|
+
text,
|
|
13
|
+
modifier,
|
|
14
|
+
url,
|
|
15
|
+
parent
|
|
16
|
+
}) => {
|
|
17
|
+
const [displayChildren, setDisplayChildren] = useState(false);
|
|
18
|
+
const {
|
|
19
|
+
showMobileMenu
|
|
20
|
+
} = useContext(MenuContext);
|
|
21
|
+
const {
|
|
22
|
+
loading: loadingText,
|
|
23
|
+
data: [textToUse]
|
|
24
|
+
} = useStringTemplate(parent, [text]);
|
|
25
|
+
const {
|
|
26
|
+
loading: loadingUrl,
|
|
27
|
+
data: [urlToUse]
|
|
28
|
+
} = useStringTemplate(parent, [url]);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!showMobileMenu) setDisplayChildren(false);
|
|
31
|
+
}, [showMobileMenu]);
|
|
32
|
+
if (loadingUrl || loadingText) return '';
|
|
33
|
+
const isHoverEvent = eventType === HOVER;
|
|
34
|
+
const childrenDisplayClass = displayChildren ? '' : HIDDEN;
|
|
35
|
+
const handleItemEvent = ({
|
|
36
|
+
type
|
|
37
|
+
}) => {
|
|
38
|
+
if (isHoverEvent) {
|
|
39
|
+
if (type === MOUSE_ENTER) {
|
|
40
|
+
setDisplayChildren(true);
|
|
41
|
+
}
|
|
42
|
+
if (type === MOUSE_LEAVE) {
|
|
43
|
+
setDisplayChildren(false);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const hasValidChildren = hasChildren(children);
|
|
48
|
+
return /*#__PURE__*/React.createElement("li", {
|
|
49
|
+
className: modifier,
|
|
50
|
+
onMouseEnter: handleItemEvent,
|
|
51
|
+
onMouseLeave: handleItemEvent
|
|
52
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: "menu--item--link"
|
|
54
|
+
}, urlToUse ? /*#__PURE__*/React.createElement(BlazeLink, {
|
|
55
|
+
href: urlToUse
|
|
56
|
+
}, textToUse) : /*#__PURE__*/React.createElement("span", {
|
|
57
|
+
role: "button",
|
|
58
|
+
onClick: handleItemEvent
|
|
59
|
+
}, textToUse), hasValidChildren && /*#__PURE__*/React.createElement("i", {
|
|
60
|
+
role: "button",
|
|
61
|
+
className: "menu--item--link--icon",
|
|
62
|
+
onClick: () => setDisplayChildren(!displayChildren)
|
|
63
|
+
}, displayChildren ? /*#__PURE__*/React.createElement(FaChevronUp, null) : /*#__PURE__*/React.createElement(FaChevronDown, null))), hasValidChildren && /*#__PURE__*/React.createElement("div", {
|
|
64
|
+
className: `menu--item-children ${childrenDisplayClass}`
|
|
65
|
+
}, children));
|
|
66
|
+
};
|
|
67
|
+
MenuItemRender.propTypes = {
|
|
68
|
+
modifier: PropTypes.string,
|
|
69
|
+
text: PropTypes.string,
|
|
70
|
+
url: PropTypes.string,
|
|
71
|
+
eventType: PropTypes.string.isRequired,
|
|
72
|
+
parent: PropTypes.object,
|
|
73
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
74
|
+
};
|
|
75
|
+
MenuItemRender.defaultProps = {
|
|
76
|
+
url: '',
|
|
77
|
+
modifier: '',
|
|
78
|
+
text: '',
|
|
79
|
+
children: null,
|
|
80
|
+
parent: {}
|
|
81
|
+
};
|
|
82
|
+
export default MenuItemRender;
|
|
83
|
+
//# sourceMappingURL=MenuItemRender.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuItemRender.js","names":["React","useState","useContext","useEffect","PropTypes","FaChevronDown","FaChevronUp","useStringTemplate","HOVER","MOUSE_ENTER","MOUSE_LEAVE","HIDDEN","hasChildren","BlazeLink","MenuContext","MenuItemRender","children","eventType","text","modifier","url","parent","displayChildren","setDisplayChildren","showMobileMenu","loading","loadingText","data","textToUse","loadingUrl","urlToUse","isHoverEvent","childrenDisplayClass","handleItemEvent","type","hasValidChildren","createElement","className","onMouseEnter","onMouseLeave","href","role","onClick","propTypes","string","isRequired","object","oneOfType","arrayOf","node","defaultProps"],"sources":["../../../src/components/MenuItem/MenuItemRender.js"],"sourcesContent":["import React, { useState, useContext, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { FaChevronDown, FaChevronUp } from 'react-icons/fa';\nimport { useStringTemplate } from '@blaze-cms/utils-handlebars';\nimport { HOVER, MOUSE_ENTER, MOUSE_LEAVE, HIDDEN } from '../../constants';\nimport { hasChildren } from '../../helpers';\nimport BlazeLink from '../BlazeLink';\nimport MenuContext from '../Menu/MenuContext';\n\nconst MenuItemRender = ({ children, eventType, text, modifier, url, parent }) => {\n const [displayChildren, setDisplayChildren] = useState(false);\n const { showMobileMenu } = useContext(MenuContext);\n const {\n loading: loadingText,\n data: [textToUse]\n } = useStringTemplate(parent, [text]);\n\n const {\n loading: loadingUrl,\n data: [urlToUse]\n } = useStringTemplate(parent, [url]);\n\n useEffect(\n () => {\n if (!showMobileMenu) setDisplayChildren(false);\n },\n [showMobileMenu]\n );\n\n if (loadingUrl || loadingText) return '';\n\n const isHoverEvent = eventType === HOVER;\n const childrenDisplayClass = displayChildren ? '' : HIDDEN;\n\n const handleItemEvent = ({ type }) => {\n if (isHoverEvent) {\n if (type === MOUSE_ENTER) {\n setDisplayChildren(true);\n }\n if (type === MOUSE_LEAVE) {\n setDisplayChildren(false);\n }\n }\n };\n const hasValidChildren = hasChildren(children);\n\n return (\n <li className={modifier} onMouseEnter={handleItemEvent} onMouseLeave={handleItemEvent}>\n <div className=\"menu--item--link\">\n {urlToUse ? (\n <BlazeLink href={urlToUse}>{textToUse}</BlazeLink>\n ) : (\n <span role=\"button\" onClick={handleItemEvent}>\n {textToUse}\n </span>\n )}\n {hasValidChildren && (\n <i\n role=\"button\"\n className=\"menu--item--link--icon\"\n onClick={() => setDisplayChildren(!displayChildren)}>\n {displayChildren ? <FaChevronUp /> : <FaChevronDown />}\n </i>\n )}\n </div>\n\n {hasValidChildren && (\n <div className={`menu--item-children ${childrenDisplayClass}`}>{children}</div>\n )}\n </li>\n );\n};\n\nMenuItemRender.propTypes = {\n modifier: PropTypes.string,\n text: PropTypes.string,\n url: PropTypes.string,\n eventType: PropTypes.string.isRequired,\n parent: PropTypes.object,\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])\n};\n\nMenuItemRender.defaultProps = {\n url: '',\n modifier: '',\n text: '',\n children: null,\n parent: {}\n};\n\nexport default MenuItemRender;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,UAAU,EAAEC,SAAS,QAAQ,OAAO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tCxB,MAAM,EAAEjB,SAAS,CAAC0C,MAAM;EACxB9B,QAAQ,EAAEZ,SAAS,CAAC2C,SAAS,CAAC,CAAC3C,SAAS,CAAC4C,OAAO,CAAC5C,SAAS,CAAC6C,IAAI,CAAC,EAAE7C,SAAS,CAAC6C,IAAI,CAAC;AACnF,CAAC;AAEDlC,cAAc,CAACmC,YAAY,GAAG;EAC5B9B,GAAG,EAAE,EAAE;EACPD,QAAQ,EAAE,EAAE;EACZD,IAAI,EAAE,EAAE;EACRF,QAAQ,EAAE,IAAI;EACdK,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAeN,cAAc"}
|
|
@@ -2,8 +2,10 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
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
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
4
|
import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import getGenericRenderVariables from './get-generic-render-variables';
|
|
6
|
+
import buildRawQueryBase from './build-raw-query-base';
|
|
7
|
+
import buildSetFilters from './build-set-filters';
|
|
8
|
+
import { DEFAULT_LIMIT } from '../constants';
|
|
7
9
|
const filterQuerySetup = ({
|
|
8
10
|
getEntitySchemas,
|
|
9
11
|
entity,
|
|
@@ -15,7 +17,7 @@ const filterQuerySetup = ({
|
|
|
15
17
|
itemsToDisplay,
|
|
16
18
|
entitySameAsCurrentItemEntity,
|
|
17
19
|
entitySchema,
|
|
18
|
-
useRandomSort
|
|
20
|
+
useRandomSort = false
|
|
19
21
|
}) => {
|
|
20
22
|
const stringProps = getStringTypeProps(entity, filterEntityRelations, getEntitySchemas);
|
|
21
23
|
const filterValues = updatedFilterBy && updatedFilterBy.length ? buildSetFilters(_objectSpread(_objectSpread({}, variableProps), {}, {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-query-setup.js","names":["getStringTypeProps","getGenericRenderVariables","buildRawQueryBase","buildSetFilters","DEFAULT_LIMIT","filterQuerySetup","getEntitySchemas","entity","updatedFilterBy","variableProps","docType","filterOperator","filterEntityRelations","itemsToDisplay","entitySameAsCurrentItemEntity","entitySchema","useRandomSort","stringProps","filterValues","length","_objectSpread","filterBy","rawQuery","bool","relations","addListFiltersToQuery","limit","settingsLimit","requestLimit","Number","variables","filterProps"],"sources":["../../src/helpers/filter-query-setup.js"],"sourcesContent":["import { getStringTypeProps } from '@blaze-cms/utils/src/helpers';\nimport getGenericRenderVariables from './get-generic-render-variables';\nimport buildRawQueryBase from './build-raw-query-base';\nimport buildSetFilters from './build-set-filters';\nimport { DEFAULT_LIMIT } from '../constants';\n\nconst filterQuerySetup = ({\n getEntitySchemas,\n entity,\n updatedFilterBy,\n variableProps,\n docType,\n filterOperator,\n filterEntityRelations,\n itemsToDisplay,\n entitySameAsCurrentItemEntity,\n entitySchema,\n useRandomSort = false\n}) => {\n const stringProps = getStringTypeProps(entity, filterEntityRelations, getEntitySchemas);\n const filterValues =\n updatedFilterBy && updatedFilterBy.length\n ? buildSetFilters({ ...variableProps, filterBy: updatedFilterBy })\n : buildSetFilters(variableProps);\n\n const rawQuery = {\n bool: buildRawQueryBase({\n docType,\n filterValues,\n filterOperator,\n relations: filterEntityRelations,\n stringProps,\n itemsToDisplay,\n addListFiltersToQuery: true,\n entity,\n entitySchema\n })\n };\n\n // increase limit to get extra item in case results contain current parent\n const { limit: settingsLimit } = variableProps;\n const limit = settingsLimit || DEFAULT_LIMIT; // all falsey should use default\n const requestLimit = entitySameAsCurrentItemEntity ? Number(limit) + 1 : limit;\n const variables = getGenericRenderVariables({\n relations: filterEntityRelations,\n filterProps: { ...variableProps, limit: requestLimit },\n stringProps,\n rawQuery,\n useRandomSort\n });\n\n return { variables, limit };\n};\n\nexport default filterQuerySetup;\n"],"mappings":";;;AAAA,SAASA,kBAAkB,QAAQ,8BAA8B;AACjE,OAAOC,yBAAyB,MAAM,gCAAgC;AACtE,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,SAASC,aAAa,QAAQ,cAAc;AAE5C,MAAMC,gBAAgB,GAAGA,CAAC;EACxBC,gBAAgB;EAChBC,MAAM;EACNC,eAAe;EACfC,aAAa;EACbC,OAAO;EACPC,cAAc;EACdC,qBAAqB;EACrBC,cAAc;EACdC,6BAA6B;EAC7BC,YAAY;EACZC,aAAa,GAAG;AAClB,CAAC,KAAK;EACJ,MAAMC,WAAW,GAAGjB,kBAAkB,CAACO,MAAM,EAAEK,qBAAqB,EAAEN,gBAAgB,CAAC;EACvF,MAAMY,YAAY,GAChBV,eAAe,IAAIA,eAAe,CAACW,MAAM,GACrChB,eAAe,CAAAiB,aAAA,CAAAA,aAAA,KAAMX,aAAa;IAAEY,QAAQ,EAAEb;EAAe,EAAE,CAAC,GAChEL,eAAe,CAACM,aAAa,CAAC;EAEpC,MAAMa,QAAQ,GAAG;IACfC,IAAI,EAAErB,iBAAiB,CAAC;MACtBQ,OAAO;MACPQ,YAAY;MACZP,cAAc;MACda,SAAS,EAAEZ,qBAAqB;MAChCK,WAAW;MACXJ,cAAc;MACdY,qBAAqB,EAAE,IAAI;MAC3BlB,MAAM;MACNQ;IACF,CAAC;EACH,CAAC;;EAED;EACA,MAAM;IAAEW,KAAK,EAAEC;EAAc,CAAC,GAAGlB,aAAa;EAC9C,MAAMiB,KAAK,GAAGC,aAAa,IAAIvB,aAAa,CAAC,CAAC;EAC9C,MAAMwB,YAAY,GAAGd,6BAA6B,GAAGe,MAAM,CAACH,KAAK,CAAC,GAAG,CAAC,GAAGA,KAAK;EAC9E,MAAMI,SAAS,GAAG7B,yBAAyB,CAAC;IAC1CuB,SAAS,EAAEZ,qBAAqB;IAChCmB,WAAW,EAAAX,aAAA,CAAAA,aAAA,KAAOX,aAAa;MAAEiB,KAAK,EAAEE;IAAY,EAAE;IACtDX,WAAW;IACXK,QAAQ;IACRN;EACF,CAAC,CAAC;EAEF,OAAO;IAAEc,SAAS;IAAEJ;EAAM,CAAC;AAC7B,CAAC;AAED,eAAerB,gBAAgB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import buildQueryFields from './build-query-fields';
|
|
2
|
+
import getInheritedFilters from './get-inherited-filters';
|
|
3
|
+
import getQueryProps from './get-query-props';
|
|
4
|
+
import { getSearchPublishedContent } from '../application/query';
|
|
3
5
|
const filtersSetup = ({
|
|
4
6
|
entityFields,
|
|
5
7
|
entityTypes,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters-setup.js","names":["buildQueryFields","getInheritedFilters","getQueryProps","getSearchPublishedContent","filtersSetup","entityFields","entityTypes","filterBy","filterByProperty","entities","currentSchema","filterEntitySchema","isPreview","itemEntityUpdated","isFull","fields","action","inheritedFilters","entitySameAsCurrentItemEntity","includes","relations","filterEntityRelations","queryProps","actions","getAction","get","getPublished"],"sources":["../../src/helpers/filters-setup.js"],"sourcesContent":["import buildQueryFields from './build-query-fields';\nimport getInheritedFilters from './get-inherited-filters';\nimport getQueryProps from './get-query-props';\nimport { getSearchPublishedContent } from '../application/query';\n\nconst filtersSetup = ({\n entityFields,\n entityTypes,\n filterBy,\n filterByProperty,\n entities,\n currentSchema,\n filterEntitySchema,\n isPreview,\n itemEntityUpdated,\n isFull\n}) => {\n const fields = buildQueryFields(entityFields, entityTypes, isFull);\n const action = getSearchPublishedContent(fields);\n const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);\n\n const entitySameAsCurrentItemEntity = entities.includes(itemEntityUpdated);\n const { relations: filterEntityRelations = [] } = filterEntitySchema;\n const queryProps = getQueryProps(inheritedFilters, currentSchema, filterEntitySchema);\n const { actions = {} } = currentSchema || {};\n const getAction = isPreview ? actions.get : actions.getPublished;\n\n return {\n getAction,\n queryProps,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n entitySameAsCurrentItemEntity,\n action,\n filterEntityRelations\n };\n};\n\nexport default filtersSetup;\n"],"mappings":"AAAA,OAAOA,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,mBAAmB,MAAM,yBAAyB;AACzD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,SAASC,yBAAyB,QAAQ,sBAAsB;AAEhE,MAAMC,YAAY,GAAGA,CAAC;EACpBC,YAAY;EACZC,WAAW;EACXC,QAAQ;EACRC,gBAAgB;EAChBC,QAAQ;EACRC,aAAa;EACbC,kBAAkB;EAClBC,SAAS;EACTC,iBAAiB;EACjBC;AACF,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGf,gBAAgB,CAACK,YAAY,EAAEC,WAAW,EAAEQ,MAAM,CAAC;EAClE,MAAME,MAAM,GAAGb,yBAAyB,CAACY,MAAM,CAAC;EAChD,MAAME,gBAAgB,GAAGhB,mBAAmB,CAACM,QAAQ,EAAEC,gBAAgB,CAAC;EAExE,MAAMU,6BAA6B,GAAGT,QAAQ,CAACU,QAAQ,CAACN,iBAAiB,CAAC;EAC1E,MAAM;IAAEO,SAAS,EAAEC,qBAAqB,GAAG;EAAG,CAAC,GAAGV,kBAAkB;EACpE,MAAMW,UAAU,GAAGpB,aAAa,CAACe,gBAAgB,EAAEP,aAAa,EAAEC,kBAAkB,CAAC;EACrF,MAAM;IAAEY,OAAO,GAAG,CAAC;EAAE,CAAC,GAAGb,aAAa,IAAI,CAAC,CAAC;EAC5C,MAAMc,SAAS,GAAGZ,SAAS,GAAGW,OAAO,CAACE,GAAG,GAAGF,OAAO,CAACG,YAAY;EAEhE,OAAO;IACLF,SAAS;IACTF,UAAU;IACVL,gBAAgB;IAChBP,aAAa;IACbC,kBAAkB;IAClBO,6BAA6B;IAC7BF,MAAM;IACNK;EACF,CAAC;AACH,CAAC;AAED,eAAejB,YAAY"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-updated-items-to-display.js","names":["getUpdatedItemsToDisplay","parentSchema","parentEntityData","itemsToDisplay","inheritedFilters","idProp","find","filter","indexOf","properties","entityKey","split","queryValue","Object","keys","propKey","relation","entityIdentifier","parentValues","updatedItemsToDisplay","Array","isArray","forEach","value","push","displayItems"],"sources":["../../src/helpers/get-updated-items-to-display.js"],"sourcesContent":["const getUpdatedItemsToDisplay = ({\n parentSchema,\n parentEntityData,\n itemsToDisplay = [],\n inheritedFilters = []\n}) => {\n const idProp = inheritedFilters.find(filter => filter.indexOf('id/') === 0);\n\n if (!idProp || !parentSchema || !parentEntityData) return itemsToDisplay;\n const { properties } = parentSchema;\n const [, entityKey] = idProp.split('/');\n if (!properties || !entityKey) return itemsToDisplay;\n const queryValue = Object.keys(properties).find(\n propKey =>\n properties[propKey] &&\n properties[propKey].relation &&\n properties[propKey].relation.entityIdentifier === entityKey\n );\n const parentValues = parentEntityData[queryValue];\n if (!parentValues) return itemsToDisplay;\n const updatedItemsToDisplay = [...itemsToDisplay];\n if (Array.isArray(parentValues)) {\n parentValues.forEach(value => {\n updatedItemsToDisplay.push({ displayItems: [value] });\n });\n } else {\n updatedItemsToDisplay.push({ displayItems: [parentValues] });\n }\n return updatedItemsToDisplay;\n};\n\nexport default getUpdatedItemsToDisplay;\n"],"mappings":"AAAA,MAAMA,wBAAwB,GAAGA,CAAC;EAChCC,YAAY;EACZC,gBAAgB;EAChBC,cAAc,GAAG,EAAE;EACnBC,gBAAgB,GAAG;AACrB,CAAC,KAAK;EACJ,MAAMC,MAAM,GAAGD,gBAAgB,CAACE,IAAI,CAACC,MAAM,IAAIA,MAAM,CAACC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;EAE3E,IAAI,CAACH,MAAM,IAAI,CAACJ,YAAY,IAAI,CAACC,gBAAgB,EAAE,OAAOC,cAAc;EACxE,MAAM;IAAEM;EAAW,CAAC,GAAGR,YAAY;EACnC,MAAM,GAAGS,SAAS,CAAC,GAAGL,MAAM,CAACM,KAAK,CAAC,GAAG,CAAC;EACvC,IAAI,CAACF,UAAU,IAAI,CAACC,SAAS,EAAE,OAAOP,cAAc;EACpD,MAAMS,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACL,UAAU,CAAC,CAACH,IAAI,CAC7CS,OAAO,IACLN,UAAU,CAACM,OAAO,CAAC,IACnBN,UAAU,CAACM,OAAO,CAAC,CAACC,QAAQ,IAC5BP,UAAU,CAACM,OAAO,CAAC,CAACC,QAAQ,CAACC,gBAAgB,KAAKP,SACtD,CAAC;EACD,MAAMQ,YAAY,GAAGhB,gBAAgB,CAACU,UAAU,CAAC;EACjD,IAAI,CAACM,YAAY,EAAE,OAAOf,cAAc;EACxC,MAAMgB,qBAAqB,GAAG,CAAC,GAAGhB,cAAc,CAAC;EACjD,IAAIiB,KAAK,CAACC,OAAO,CAACH,YAAY,CAAC,EAAE;IAC/BA,YAAY,CAACI,OAAO,CAACC,KAAK,IAAI;MAC5BJ,qBAAqB,CAACK,IAAI,CAAC;QAAEC,YAAY,EAAE,CAACF,KAAK;MAAE,CAAC,CAAC;IACvD,CAAC,CAAC;EACJ,CAAC,MAAM;IACLJ,qBAAqB,CAACK,IAAI,CAAC;MAAEC,YAAY,EAAE,CAACP,YAAY;IAAE,CAAC,CAAC;EAC9D;EACA,OAAOC,qBAAqB;AAC9B,CAAC;AAED,eAAenB,wBAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-updated-sort-properties.js","names":["getUpdatedSortProperties","sort","sortby","sortProperties","updatedSortProperties","length","unshift","propsToDisplay","sortbyFilters","map","filter","Boolean","flat"],"sources":["../../src/helpers/get-updated-sort-properties.js"],"sourcesContent":["const getUpdatedSortProperties = (sort, sortby, sortProperties = []) => {\n const updatedSortProperties = [...sortProperties];\n if (!updatedSortProperties.length && sort) {\n updatedSortProperties.unshift({ sort, propsToDisplay: sortby });\n }\n\n const sortbyFilters = updatedSortProperties\n .map(({ propsToDisplay }) => propsToDisplay)\n .filter(Boolean)\n .flat();\n return [updatedSortProperties, sortbyFilters];\n};\n\nexport default getUpdatedSortProperties;\n"],"mappings":"AAAA,MAAMA,wBAAwB,GAAGA,CAACC,IAAI,EAAEC,MAAM,EAAEC,cAAc,GAAG,EAAE,KAAK;EACtE,MAAMC,qBAAqB,GAAG,CAAC,GAAGD,cAAc,CAAC;EACjD,IAAI,CAACC,qBAAqB,CAACC,MAAM,IAAIJ,IAAI,EAAE;IACzCG,qBAAqB,CAACE,OAAO,CAAC;MAAEL,IAAI;MAAEM,cAAc,EAAEL;IAAO,CAAC,CAAC;EACjE;EAEA,MAAMM,aAAa,GAAGJ,qBAAqB,CACxCK,GAAG,CAAC,CAAC;IAAEF;EAAe,CAAC,KAAKA,cAAc,CAAC,CAC3CG,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,CAAC;EACT,OAAO,CAACR,qBAAqB,EAAEI,aAAa,CAAC;AAC/C,CAAC;AAED,eAAeR,wBAAwB"}
|
package/lib-es/helpers/index.js
CHANGED
|
@@ -53,6 +53,12 @@ export { default as appendImages } from './append-images';
|
|
|
53
53
|
export { default as parseTextBlock } from './parse-TextBlock';
|
|
54
54
|
export { default as processDataSummaryValue } from './process-data-summary-value';
|
|
55
55
|
export { default as buildQueryKey } from './build-query-key';
|
|
56
|
+
export { default as filterQuerySetup } from './filter-query-setup';
|
|
57
|
+
export { default as filtersSetup } from './filters-setup';
|
|
58
|
+
export { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';
|
|
59
|
+
export { default as getUpdatedSortProperties } from './get-updated-sort-properties';
|
|
60
|
+
export { default as shouldReturn } from './should-return';
|
|
61
|
+
export { default as shouldSkipSingleQuery } from './should-skip-single-query';
|
|
56
62
|
export { default as buildRawQueryStringified } from './build-raw-query-stringified';
|
|
57
63
|
export { default as buildFiltersQuery } from './build-filters-query';
|
|
58
64
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","buildInheritedFilters","buildLinkExtraProps","buildPropsQuery","buildQueryFields","buildRawQuery","buildRawQueryBase","buildSearchValuesCheckboxSelect","buildSearchValuesText","buildSetFilters","checkPropsToUse","getElasticsearchOperator","getClickWrapperOptions","getEntitiesWithBanner","getEntityData","getEntityRenderProps","getGenericProps","getGenericRenderVariables","getImageIds","getInheritedFilters","getModifiers","getNotEqualQuery","getPaginationIndex","getParsedSummaryValue","getQueryFilters","getQueryProps","getRequiredSchemas","getSearchFilterType","getUnpublishedEntityName","getWrappedValueWithLink","getItemsToDisplayIds","isBrowser","isFilterEntitysId","isObject","isUsingRelationImage","parsePropsToDisplay","renderChildren","shouldRenderWaypoint","shouldShowProperty","sortResponseData","splitChildren","getCurrentOffset","updateChildrensParent","getDisplayCountData","buildImageProperties","getUpdatedFilterBy","checkForError","removeUnwantedCharacters","hasChildren","removeExtraItems","getParsedPropValues","getSanitizedPropValues","appendImages","parseTextBlock","processDataSummaryValue","buildQueryKey","buildRawQueryStringified","buildFiltersQuery"],"sources":["../../src/helpers/index.js"],"sourcesContent":["export { default as buildInheritedFilters } from './build-inherited-filters';\nexport { default as buildLinkExtraProps } from './build-link-extra-props';\nexport { default as buildPropsQuery } from './build-props-query';\nexport { default as buildQueryFields } from './build-query-fields';\nexport { default as buildRawQuery } from './build-raw-query';\nexport { default as buildRawQueryBase } from './build-raw-query-base';\nexport { default as buildSearchValuesCheckboxSelect } from './build-search-values-checkbox-select';\nexport { default as buildSearchValuesText } from './build-search-values-text';\nexport { default as buildSetFilters } from './build-set-filters';\nexport { default as checkPropsToUse } from './check-props-to-use';\nexport { default as getElasticsearchOperator } from './get-elasticsearch-operator';\nexport { default as getClickWrapperOptions } from './get-click-wrapper-options';\nexport { default as getEntitiesWithBanner } from './get-entities-with-banner';\nexport { default as getEntityData } from './get-entity-data';\nexport { default as getEntityRenderProps } from './get-entity-render-props';\nexport { default as getGenericProps } from './get-generic-props';\nexport { default as getGenericRenderVariables } from './get-generic-render-variables';\nexport { default as getImageIds } from './get-image-ids';\nexport { default as getInheritedFilters } from './get-inherited-filters';\nexport { default as getModifiers } from './get-modifiers';\nexport { default as getNotEqualQuery } from './get-not-equal-query';\nexport { default as getPaginationIndex } from './get-pagination-index';\nexport { default as getParsedSummaryValue } from './get-parsed-summary-value';\nexport { default as getQueryFilters } from './get-query-filters';\nexport { default as getQueryProps } from './get-query-props';\nexport { default as getRequiredSchemas } from './get-required-schemas';\nexport { default as getSearchFilterType } from './get-search-filter-type';\nexport { default as getUnpublishedEntityName } from './get-unpublished-entity-name';\nexport { default as getWrappedValueWithLink } from './get-wrapped-value-with-link';\nexport { default as getItemsToDisplayIds } from './get-items-to-display-ids';\nexport { default as isBrowser } from './is-browser';\nexport { default as isFilterEntitysId } from './is-filter-entitys-id';\nexport { default as isObject } from './is-object';\nexport { default as isUsingRelationImage } from './is-using-relation-image';\nexport { default as parsePropsToDisplay } from './parse-props-to-display';\nexport { default as renderChildren } from './render-children';\nexport { default as shouldRenderWaypoint } from './should-render-waypoint';\nexport { default as shouldShowProperty } from './should-show-property';\nexport { default as sortResponseData } from './sort-response-data';\nexport { default as splitChildren } from './split-children';\nexport { default as getCurrentOffset } from './get-current-offset';\nexport { default as updateChildrensParent } from './update-childrens-parent';\nexport { default as getDisplayCountData } from './get-display-count-data';\nexport { default as buildImageProperties } from './build-image-properties';\nexport { default as getUpdatedFilterBy } from './get-updated-filter-by';\nexport { default as checkForError } from './check-for-error';\nexport { default as removeUnwantedCharacters } from './remove-unwanted-characters';\nexport { default as hasChildren } from './has-children';\nexport { default as removeExtraItems } from './remove-extra-items';\nexport { default as getParsedPropValues } from './get-parsed-prop-values';\nexport { default as getSanitizedPropValues } from './get-sanitized-prop-values';\nexport { default as appendImages } from './append-images';\nexport { default as parseTextBlock } from './parse-TextBlock';\nexport { default as processDataSummaryValue } from './process-data-summary-value';\nexport { default as buildQueryKey } from './build-query-key';\nexport { default as buildRawQueryStringified } from './build-raw-query-stringified';\nexport { default as buildFiltersQuery } from './build-filters-query';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAAqB,QAAQ,2BAA2B;AAC5E,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,0BAA0B;AACzE,SAASF,OAAO,IAAIG,eAAe,QAAQ,qBAAqB;AAChE,SAASH,OAAO,IAAII,gBAAgB,QAAQ,sBAAsB;AAClE,SAASJ,OAAO,IAAIK,aAAa,QAAQ,mBAAmB;AAC5D,SAASL,OAAO,IAAIM,iBAAiB,QAAQ,wBAAwB;AACrE,SAASN,OAAO,IAAIO,+BAA+B,QAAQ,uCAAuC;AAClG,SAASP,OAAO,IAAIQ,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASR,OAAO,IAAIS,eAAe,QAAQ,qBAAqB;AAChE,SAAST,OAAO,IAAIU,eAAe,QAAQ,sBAAsB;AACjE,SAASV,OAAO,IAAIW,wBAAwB,QAAQ,8BAA8B;AAClF,SAASX,OAAO,IAAIY,sBAAsB,QAAQ,6BAA6B;AAC/E,SAASZ,OAAO,IAAIa,qBAAqB,QAAQ,4BAA4B;AAC7E,SAASb,OAAO,IAAIc,aAAa,QAAQ,mBAAmB;AAC5D,SAASd,OAAO,IAAIe,oBAAoB,QAAQ,2BAA2B;AAC3E,SAASf,OAAO,IAAIgB,eAAe,QAAQ,qBAAqB;AAChE,SAAShB,OAAO,IAAIiB,yBAAyB,QAAQ,gCAAgC;AACrF,SAASjB,OAAO,IAAIkB,WAAW,QAAQ,iBAAiB;AACxD,SAASlB,OAAO,IAAImB,mBAAmB,QAAQ,yBAAyB;A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A0B;AACzE,SAAS3C,OAAO,IAAI4C,oBAAoB,QAAQ,0BAA0B;AAC1E,SAAS5C,OAAO,IAAI6C,kBAAkB,QAAQ,yBAAyB;AACvE,SAAS7C,OAAO,IAAI8C,aAAa,QAAQ,mBAAmB;AAC5D,SAAS9C,OAAO,IAAI+C,wBAAwB,QAAQ,8BAA8B;AAClF,SAAS/C,OAAO,IAAIgD,WAAW,QAAQ,gBAAgB;AACvD,SAAShD,OAAO,IAAIiD,gBAAgB,QAAQ,sBAAsB;AAClE,SAASjD,OAAO,IAAIkD,mBAAmB,QAAQ,0BAA0B;AACzE,SAASlD,OAAO,IAAImD,sBAAsB,QAAQ,6BAA6B;AAC/E,SAASnD,OAAO,IAAIoD,YAAY,QAAQ,iBAAiB;AACzD,SAASpD,OAAO,IAAIqD,cAAc,QAAQ,mBAAmB;AAC7D,SAASrD,OAAO,IAAIsD,uBAAuB,QAAQ,8BAA8B;AACjF,SAAStD,OAAO,IAAIuD,aAAa,QAAQ,mBAAmB;AAC5D,SAASvD,OAAO,IAAIwD,wBAAwB,QAAQ,+BAA+B;AACnF,
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","buildInheritedFilters","buildLinkExtraProps","buildPropsQuery","buildQueryFields","buildRawQuery","buildRawQueryBase","buildSearchValuesCheckboxSelect","buildSearchValuesText","buildSetFilters","checkPropsToUse","getElasticsearchOperator","getClickWrapperOptions","getEntitiesWithBanner","getEntityData","getEntityRenderProps","getGenericProps","getGenericRenderVariables","getImageIds","getInheritedFilters","getModifiers","getNotEqualQuery","getPaginationIndex","getParsedSummaryValue","getQueryFilters","getQueryProps","getRequiredSchemas","getSearchFilterType","getUnpublishedEntityName","getWrappedValueWithLink","getItemsToDisplayIds","isBrowser","isFilterEntitysId","isObject","isUsingRelationImage","parsePropsToDisplay","renderChildren","shouldRenderWaypoint","shouldShowProperty","sortResponseData","splitChildren","getCurrentOffset","updateChildrensParent","getDisplayCountData","buildImageProperties","getUpdatedFilterBy","checkForError","removeUnwantedCharacters","hasChildren","removeExtraItems","getParsedPropValues","getSanitizedPropValues","appendImages","parseTextBlock","processDataSummaryValue","buildQueryKey","filterQuerySetup","filtersSetup","getUpdatedItemsToDisplay","getUpdatedSortProperties","shouldReturn","shouldSkipSingleQuery","buildRawQueryStringified","buildFiltersQuery"],"sources":["../../src/helpers/index.js"],"sourcesContent":["export { default as buildInheritedFilters } from './build-inherited-filters';\nexport { default as buildLinkExtraProps } from './build-link-extra-props';\nexport { default as buildPropsQuery } from './build-props-query';\nexport { default as buildQueryFields } from './build-query-fields';\nexport { default as buildRawQuery } from './build-raw-query';\nexport { default as buildRawQueryBase } from './build-raw-query-base';\nexport { default as buildSearchValuesCheckboxSelect } from './build-search-values-checkbox-select';\nexport { default as buildSearchValuesText } from './build-search-values-text';\nexport { default as buildSetFilters } from './build-set-filters';\nexport { default as checkPropsToUse } from './check-props-to-use';\nexport { default as getElasticsearchOperator } from './get-elasticsearch-operator';\nexport { default as getClickWrapperOptions } from './get-click-wrapper-options';\nexport { default as getEntitiesWithBanner } from './get-entities-with-banner';\nexport { default as getEntityData } from './get-entity-data';\nexport { default as getEntityRenderProps } from './get-entity-render-props';\nexport { default as getGenericProps } from './get-generic-props';\nexport { default as getGenericRenderVariables } from './get-generic-render-variables';\nexport { default as getImageIds } from './get-image-ids';\nexport { default as getInheritedFilters } from './get-inherited-filters';\nexport { default as getModifiers } from './get-modifiers';\nexport { default as getNotEqualQuery } from './get-not-equal-query';\nexport { default as getPaginationIndex } from './get-pagination-index';\nexport { default as getParsedSummaryValue } from './get-parsed-summary-value';\nexport { default as getQueryFilters } from './get-query-filters';\nexport { default as getQueryProps } from './get-query-props';\nexport { default as getRequiredSchemas } from './get-required-schemas';\nexport { default as getSearchFilterType } from './get-search-filter-type';\nexport { default as getUnpublishedEntityName } from './get-unpublished-entity-name';\nexport { default as getWrappedValueWithLink } from './get-wrapped-value-with-link';\nexport { default as getItemsToDisplayIds } from './get-items-to-display-ids';\nexport { default as isBrowser } from './is-browser';\nexport { default as isFilterEntitysId } from './is-filter-entitys-id';\nexport { default as isObject } from './is-object';\nexport { default as isUsingRelationImage } from './is-using-relation-image';\nexport { default as parsePropsToDisplay } from './parse-props-to-display';\nexport { default as renderChildren } from './render-children';\nexport { default as shouldRenderWaypoint } from './should-render-waypoint';\nexport { default as shouldShowProperty } from './should-show-property';\nexport { default as sortResponseData } from './sort-response-data';\nexport { default as splitChildren } from './split-children';\nexport { default as getCurrentOffset } from './get-current-offset';\nexport { default as updateChildrensParent } from './update-childrens-parent';\nexport { default as getDisplayCountData } from './get-display-count-data';\nexport { default as buildImageProperties } from './build-image-properties';\nexport { default as getUpdatedFilterBy } from './get-updated-filter-by';\nexport { default as checkForError } from './check-for-error';\nexport { default as removeUnwantedCharacters } from './remove-unwanted-characters';\nexport { default as hasChildren } from './has-children';\nexport { default as removeExtraItems } from './remove-extra-items';\nexport { default as getParsedPropValues } from './get-parsed-prop-values';\nexport { default as getSanitizedPropValues } from './get-sanitized-prop-values';\nexport { default as appendImages } from './append-images';\nexport { default as parseTextBlock } from './parse-TextBlock';\nexport { default as processDataSummaryValue } from './process-data-summary-value';\nexport { default as buildQueryKey } from './build-query-key';\nexport { default as filterQuerySetup } from './filter-query-setup';\nexport { default as filtersSetup } from './filters-setup';\nexport { default as getUpdatedItemsToDisplay } from './get-updated-items-to-display';\nexport { default as getUpdatedSortProperties } from './get-updated-sort-properties';\nexport { default as shouldReturn } from './should-return';\nexport { default as shouldSkipSingleQuery } from './should-skip-single-query';\nexport { default as buildRawQueryStringified } from './build-raw-query-stringified';\nexport { default as buildFiltersQuery } from './build-filters-query';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,qBAAqB,QAAQ,2BAA2B;AAC5E,SAASD,OAAO,IAAIE,mBAAmB,QAAQ,0BAA0B;AACzE,SAASF,OAAO,IAAIG,eAAe,QAAQ,qBAAqB;AAChE,SAASH,OAAO,IAAII,gBAAgB,QAAQ,sBAAsB;AAClE,SAASJ,OAAO,IAAIK,a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AAmB;AAC7D,SAASrD,OAAO,IAAIsD,uBAAuB,QAAQ,8BAA8B;AACjF,SAAStD,OAAO,IAAIuD,aAAa,QAAQ,mBAAmB;AAC5D,SAASvD,OAAO,IAAIwD,gBAAgB,QAAQ,sBAAsB;AAClE,SAASxD,OAAO,IAAIyD,YAAY,QAAQ,iBAAiB;AACzD,SAASzD,OAAO,IAAI0D,wBAAwB,QAAQ,gCAAgC;AACpF,SAAS1D,OAAO,IAAI2D,wBAAwB,QAAQ,+BAA+B;AACnF,SAAS3D,OAAO,IAAI4D,YAAY,QAAQ,iBAAiB;AACzD,SAAS5D,OAAO,IAAI6D,qBAAqB,QAAQ,4BAA4B;AAC7E,SAAS7D,OAAO,IAAI8D,wBAAwB,QAAQ,+BAA+B;AACnF,SAAS9D,OAAO,IAAI+D,iBAAiB,QAAQ,uBAAuB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-return.js","names":["shouldReturn","args","filter","Boolean","length"],"sources":["../../src/helpers/should-return.js"],"sourcesContent":["const shouldReturn = (...args) => !!args.filter(Boolean).length;\n\nexport default shouldReturn;\n"],"mappings":"AAAA,MAAMA,YAAY,GAAGA,CAAC,GAAGC,IAAI,KAAK,CAAC,CAACA,IAAI,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,MAAM;AAE/D,eAAeJ,YAAY"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ID } from '
|
|
1
|
+
import { ID } from '../constants';
|
|
2
2
|
const shouldSkipSingleQuery = (loading, getAction, queryProps) => loading || !getAction || queryProps === ID;
|
|
3
3
|
export default shouldSkipSingleQuery;
|
|
4
4
|
//# sourceMappingURL=should-skip-single-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"should-skip-single-query.js","names":["ID","shouldSkipSingleQuery","loading","getAction","queryProps"],"sources":["../../src/helpers/should-skip-single-query.js"],"sourcesContent":["import { ID } from '../constants';\n\nconst shouldSkipSingleQuery = (loading, getAction, queryProps) =>\n loading || !getAction || queryProps === ID;\n\nexport default shouldSkipSingleQuery;\n"],"mappings":"AAAA,SAASA,EAAE,QAAQ,cAAc;AAEjC,MAAMC,qBAAqB,GAAGA,CAACC,OAAO,EAAEC,SAAS,EAAEC,UAAU,KAC3DF,OAAO,IAAI,CAACC,SAAS,IAAIC,UAAU,KAAKJ,EAAE;AAE5C,eAAeC,qBAAqB"}
|
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.7",
|
|
4
4
|
"description": "Blaze react page builder",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"lib/*",
|
|
91
91
|
"lib-es/*"
|
|
92
92
|
],
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "e70d7a64657047bd5150d40d509595a6cff26709"
|
|
94
94
|
}
|
|
@@ -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';
|
|
@@ -0,0 +1,202 @@
|
|
|
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
|
+
const hasNoItemsToDisplayOrFilter = !updatedItemsToDisplay.length && !updatedFilterBy;
|
|
138
|
+
|
|
139
|
+
const { data = {} } = useQuery(action, {
|
|
140
|
+
variables,
|
|
141
|
+
skip: shouldReturn(
|
|
142
|
+
hasNoItemsToDisplayOrFilter,
|
|
143
|
+
singleItemQueryLoading,
|
|
144
|
+
singleItemQueryError,
|
|
145
|
+
entityObjloading,
|
|
146
|
+
entityObjError,
|
|
147
|
+
schemaLoading,
|
|
148
|
+
schemaError
|
|
149
|
+
)
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
const { results } = data[SEARCH_PUBLISHED_CONTENT] || {};
|
|
153
|
+
|
|
154
|
+
if (!results) return null;
|
|
155
|
+
|
|
156
|
+
return results.map(item => {
|
|
157
|
+
const itemParent = {
|
|
158
|
+
itemId: item.id,
|
|
159
|
+
itemEntity: graphqlEntityMap[item.__typename]
|
|
160
|
+
};
|
|
161
|
+
return <MenuItemRender {...props} parent={itemParent} url={item.url || props.url} />;
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
MenuEntitiesItem.propTypes = {
|
|
166
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
167
|
+
eventType: PropTypes.string.isRequired,
|
|
168
|
+
modifier: PropTypes.string,
|
|
169
|
+
parent: PropTypes.object,
|
|
170
|
+
text: PropTypes.string,
|
|
171
|
+
url: PropTypes.string,
|
|
172
|
+
entities: PropTypes.array,
|
|
173
|
+
limit: PropTypes.number,
|
|
174
|
+
offset: PropTypes.number,
|
|
175
|
+
sortby: PropTypes.array,
|
|
176
|
+
filterBy: PropTypes.array,
|
|
177
|
+
sort: PropTypes.string,
|
|
178
|
+
operator: PropTypes.string.isRequired,
|
|
179
|
+
filterOperator: PropTypes.string.isRequired,
|
|
180
|
+
sortProperties: PropTypes.array,
|
|
181
|
+
filterByProperty: PropTypes.array,
|
|
182
|
+
itemsToDisplay: PropTypes.array
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
MenuEntitiesItem.defaultProps = {
|
|
186
|
+
children: null,
|
|
187
|
+
modifier: '',
|
|
188
|
+
limit: 0,
|
|
189
|
+
offset: 0,
|
|
190
|
+
itemsToDisplay: [],
|
|
191
|
+
sort: '',
|
|
192
|
+
sortby: [],
|
|
193
|
+
sortProperties: [],
|
|
194
|
+
filterByProperty: [],
|
|
195
|
+
parent: {},
|
|
196
|
+
filterBy: [],
|
|
197
|
+
text: '',
|
|
198
|
+
url: '',
|
|
199
|
+
entities: []
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export default MenuEntitiesItem;
|
|
@@ -1,76 +1,33 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { hasChildren } from '../../helpers';
|
|
6
|
-
import BlazeLink from '../BlazeLink';
|
|
7
|
-
import MenuContext from '../Menu/MenuContext';
|
|
3
|
+
import MenuItemRender from './MenuItemRender';
|
|
4
|
+
import MenuEntitiesItem from './MenuEntitiesItem';
|
|
8
5
|
|
|
9
|
-
const MenuItem = ({
|
|
10
|
-
const
|
|
11
|
-
const { showMobileMenu } = useContext(MenuContext);
|
|
6
|
+
const MenuItem = ({ entities, parent, ...props }) => {
|
|
7
|
+
const hasEntities = entities && entities.length;
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
() => {
|
|
15
|
-
if (!showMobileMenu) setDisplayChildren(false);
|
|
16
|
-
},
|
|
17
|
-
[showMobileMenu]
|
|
18
|
-
);
|
|
9
|
+
if (!hasEntities) return <MenuItemRender parent={parent} {...props} />;
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
const childrenDisplayClass = displayChildren ? '' : HIDDEN;
|
|
22
|
-
|
|
23
|
-
const handleItemEvent = ({ type }) => {
|
|
24
|
-
if (isHoverEvent) {
|
|
25
|
-
if (type === MOUSE_ENTER) {
|
|
26
|
-
setDisplayChildren(true);
|
|
27
|
-
}
|
|
28
|
-
if (type === MOUSE_LEAVE) {
|
|
29
|
-
setDisplayChildren(false);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
const hasValidChildren = hasChildren(children);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<li className={modifier} onMouseEnter={handleItemEvent} onMouseLeave={handleItemEvent}>
|
|
37
|
-
<div className="menu--item--link">
|
|
38
|
-
{url ? (
|
|
39
|
-
<BlazeLink href={url}>{text}</BlazeLink>
|
|
40
|
-
) : (
|
|
41
|
-
<span role="button" onClick={handleItemEvent}>
|
|
42
|
-
{text}
|
|
43
|
-
</span>
|
|
44
|
-
)}
|
|
45
|
-
{hasValidChildren && (
|
|
46
|
-
<i
|
|
47
|
-
role="button"
|
|
48
|
-
className="menu--item--link--icon"
|
|
49
|
-
onClick={() => setDisplayChildren(!displayChildren)}>
|
|
50
|
-
{displayChildren ? <FaChevronUp /> : <FaChevronDown />}
|
|
51
|
-
</i>
|
|
52
|
-
)}
|
|
53
|
-
</div>
|
|
54
|
-
{hasValidChildren && (
|
|
55
|
-
<div className={`menu--item-children ${childrenDisplayClass}`}>{children}</div>
|
|
56
|
-
)}
|
|
57
|
-
</li>
|
|
58
|
-
);
|
|
11
|
+
return <MenuEntitiesItem entities={entities} parent={parent} {...props} />;
|
|
59
12
|
};
|
|
60
13
|
|
|
61
14
|
MenuItem.propTypes = {
|
|
15
|
+
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
|
|
16
|
+
eventType: PropTypes.string.isRequired,
|
|
62
17
|
modifier: PropTypes.string,
|
|
18
|
+
parent: PropTypes.object,
|
|
63
19
|
text: PropTypes.string,
|
|
64
20
|
url: PropTypes.string,
|
|
65
|
-
|
|
66
|
-
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node])
|
|
21
|
+
entities: PropTypes.array
|
|
67
22
|
};
|
|
68
23
|
|
|
69
24
|
MenuItem.defaultProps = {
|
|
70
|
-
|
|
25
|
+
children: null,
|
|
71
26
|
modifier: '',
|
|
27
|
+
parent: {},
|
|
72
28
|
text: '',
|
|
73
|
-
|
|
29
|
+
url: '',
|
|
30
|
+
entities: []
|
|
74
31
|
};
|
|
75
32
|
|
|
76
33
|
export default MenuItem;
|