@blaze-cms/react-page-builder 0.128.0-alpha.3 → 0.128.0-alpha.4

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.
Files changed (29) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/components/DataSummary/DataSummaryFactory.js +2 -1
  3. package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
  4. package/lib/components/DataSummary/helpers/get-link-props.js +23 -0
  5. package/lib/components/DataSummary/helpers/get-link-props.js.map +1 -0
  6. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +7 -12
  7. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  8. package/lib/components/DataSummary/helpers/index.js +7 -0
  9. package/lib/components/DataSummary/helpers/index.js.map +1 -1
  10. package/lib/helpers/build-props-query.js +34 -24
  11. package/lib/helpers/build-props-query.js.map +1 -1
  12. package/lib-es/components/DataSummary/DataSummaryFactory.js +3 -2
  13. package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
  14. package/lib-es/components/DataSummary/helpers/get-link-props.js +6 -0
  15. package/lib-es/components/DataSummary/helpers/get-link-props.js.map +1 -0
  16. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +4 -7
  17. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  18. package/lib-es/components/DataSummary/helpers/index.js +2 -1
  19. package/lib-es/components/DataSummary/helpers/index.js.map +1 -1
  20. package/lib-es/helpers/build-props-query.js +22 -9
  21. package/lib-es/helpers/build-props-query.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/components/DataSummary/DataSummaryFactory.js +3 -2
  24. package/src/components/DataSummary/helpers/get-link-props.js +7 -0
  25. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -8
  26. package/src/components/DataSummary/helpers/index.js +3 -1
  27. package/src/helpers/build-props-query.js +46 -33
  28. package/tests/unit/src/components/DataSummary/helpers/get-link-props.test.js +35 -0
  29. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -3
package/CHANGELOG.md CHANGED
@@ -3,13 +3,38 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.128.0-alpha.4](https://github.com/thebyte9/blaze/compare/v0.128.0-alpha.3...v0.128.0-alpha.4) (2023-04-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * data summary now uses url if prop matches checks ([68e2119](https://github.com/thebyte9/blaze/commit/68e2119559ac9f0005e16f0c85620aa823b62b76))
12
+
13
+
14
+
15
+ ## [0.127.3](https://github.com/thebyte9/blaze/compare/v0.128.0-alpha.2...v0.127.3) (2023-03-31)
16
+
17
+
18
+
19
+
20
+
6
21
  # [0.128.0-alpha.3](https://github.com/thebyte9/blaze/compare/v0.128.0-alpha.2...v0.128.0-alpha.3) (2023-04-12)
7
22
 
8
- **Note:** Version bump only for package @blaze-cms/react-page-builder
23
+ ## [0.127.3](https://github.com/thebyte9/blaze/compare/v0.127.2...v0.127.3) (2023-03-31)
24
+
25
+ ### Bug Fixes
26
+
27
+ * ignore DOMException errors in ErrorBoundary ([05b66af](https://github.com/thebyte9/blaze/commit/05b66afff5f8cb3ee6618e7a6b5521d8bdfbf7a0))
9
28
 
29
+ # [0.127.0](https://github.com/thebyte9/blaze/compare/v0.126.1...v0.127.0) (2023-02-10)
30
+
31
+ ### Features
10
32
 
33
+ * shorthand story plugins ([#3806](https://github.com/thebyte9/blaze/issues/3806)) ([08d9b82](https://github.com/thebyte9/blaze/commit/08d9b82aa1983291450c616c9bd8fd81f6ddae9d))
11
34
 
35
+ # [0.126.0](https://github.com/thebyte9/blaze/compare/v0.126.0-alpha.6...v0.126.0) (2023-01-17)
12
36
 
37
+ **Note:** Version bump only for package @blaze-cms/react-page-builder
13
38
 
14
39
  # [0.128.0-alpha.2](https://github.com/thebyte9/blaze/compare/v0.128.0-alpha.1...v0.128.0-alpha.2) (2023-03-31)
15
40
 
@@ -53,7 +53,8 @@ var DataSummaryFactory = function DataSummaryFactory(_ref) {
53
53
  if (!data) return null;
54
54
  if (!propsToDisplay || !propsToDisplay.length) return null;
55
55
  var propsToDisplayValues = (0, _helpers.checkPropsToUse)(propsToDisplay);
56
- var propsQueryString = (0, _helpers.buildPropsQuery)(data, propsToDisplayValues);
56
+ var linkProps = (0, _helpers2.getLinkProps)(propsToDisplay);
57
+ var propsQueryString = (0, _helpers.buildPropsQuery)(data, propsToDisplayValues, null, linkProps);
57
58
  var dataSummaryQuery = (0, _helpers2.getDataSummaryQuery)(data, isPreview, propsQueryString);
58
59
  var recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;
59
60
  return /*#__PURE__*/_react["default"].createElement(_DataSummaryRender["default"], {
@@ -1 +1 @@
1
- {"version":3,"file":"DataSummaryFactory.js","names":["_react","_interopRequireWildcard","require","_client","_propTypes","_interopRequireDefault","_nextjsComponents","_query","_helpers","_helpers2","_DataSummaryRender","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","dataSummaryProps","_objectWithoutProperties2","entityForQuery","parent","itemEntity","_useQuery","useQuery","getSingleEntitySchema","variables","id","data","error","loading","_useContext","useContext","MainContext","isPreview","message","length","propsToDisplayValues","checkPropsToUse","propsQueryString","buildPropsQuery","dataSummaryQuery","getDataSummaryQuery","recordId","itemId","createElement","query","htmlTag","propTypes","PropTypes","string","array","bool","number","defaultProps","_default","exports"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n ...dataSummaryProps\n}) => {\n const entityForQuery = useSelectedEntity ? entity : dataSummaryProps.parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n const { isPreview } = useContext(MainContext);\n\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n modifier: '',\n headingStyle: 'h2',\n loopProperties: [],\n loopLimit: 0\n};\n\nexport default DataSummaryFactory;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,u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AAY,GAAG;EAChC3C,IAAI,EAAE,MAAM;EACZF,YAAY,EAAE,EAAE;EAChBC,cAAc,EAAE,EAAE;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE;AACb,CAAC;AAAC,IAAAsC,QAAA,GAEajD,kBAAkB;AAAAkD,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"DataSummaryFactory.js","names":["_react","_interopRequireWildcard","require","_client","_propTypes","_interopRequireDefault","_nextjsComponents","_query","_helpers","_helpers2","_DataSummaryRender","_excluded","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","dataSummaryProps","_objectWithoutProperties2","entityForQuery","parent","itemEntity","_useQuery","useQuery","getSingleEntitySchema","variables","id","data","error","loading","_useContext","useContext","MainContext","isPreview","message","length","propsToDisplayValues","checkPropsToUse","linkProps","getLinkProps","propsQueryString","buildPropsQuery","dataSummaryQuery","getDataSummaryQuery","recordId","itemId","createElement","query","htmlTag","propTypes","PropTypes","string","array","bool","number","defaultProps","_default","exports"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery, getLinkProps } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n ...dataSummaryProps\n}) => {\n const entityForQuery = useSelectedEntity ? entity : dataSummaryProps.parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n const { isPreview } = useContext(MainContext);\n\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const linkProps = getLinkProps(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n modifier: '',\n headingStyle: 'h2',\n loopProperties: [],\n loopLimit: 0\n};\n\nexport default DataSummaryFactory;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAA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AAG;EAChC7C,IAAI,EAAE,MAAM;EACZF,YAAY,EAAE,EAAE;EAChBC,cAAc,EAAE,EAAE;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE;AACb,CAAC;AAAC,IAAAwC,QAAA,GAEanD,kBAAkB;AAAAoD,OAAA,cAAAD,QAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ require("core-js/modules/es.object.define-property.js");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ require("core-js/modules/es.array.filter.js");
9
+ require("core-js/modules/es.object.to-string.js");
10
+ require("core-js/modules/es.array.flat.js");
11
+ require("core-js/modules/es.array.unscopables.flat.js");
12
+ require("core-js/modules/es.array.map.js");
13
+ var getLinkProps = function getLinkProps() {
14
+ var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
15
+ return props.map(function (_ref) {
16
+ var propertiesToDisplay = _ref.propertiesToDisplay,
17
+ enableLink = _ref.enableLink;
18
+ return enableLink && propertiesToDisplay;
19
+ }).flat().filter(Boolean);
20
+ };
21
+ var _default = getLinkProps;
22
+ exports["default"] = _default;
23
+ //# sourceMappingURL=get-link-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-link-props.js","names":["getLinkProps","props","arguments","length","undefined","map","_ref","propertiesToDisplay","enableLink","flat","filter","Boolean","_default","exports"],"sources":["../../../../src/components/DataSummary/helpers/get-link-props.js"],"sourcesContent":["const getLinkProps = (props = []) =>\n props\n .map(({ propertiesToDisplay, enableLink }) => enableLink && propertiesToDisplay)\n .flat()\n .filter(Boolean);\n\nexport default getLinkProps;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAA;EAAA,IAAIC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,OAC9BD,KAAK,CACFI,GAAG,CAAC,UAAAC,IAAA;IAAA,IAAGC,mBAAmB,GAAAD,IAAA,CAAnBC,mBAAmB;MAAEC,UAAU,GAAAF,IAAA,CAAVE,UAAU;IAAA,OAAOA,UAAU,IAAID,mBAAmB;EAAA,EAAC,CAC/EE,IAAI,EAAE,CACNC,MAAM,CAACC,OAAO,CAAC;AAAA;AAAC,IAAAC,QAAA,GAENZ,YAAY;AAAAa,OAAA,cAAAD,QAAA"}
@@ -6,22 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
10
- require("core-js/modules/es.array.includes.js");
11
- require("core-js/modules/es.string.includes.js");
12
9
  require("core-js/modules/es.array.is-array.js");
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
11
  var getLinkToPublishedContent = function getLinkToPublishedContent() {
14
12
  var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
15
13
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16
- if (key.includes('published')) {
17
- var _key$split = key.split('.'),
18
- _key$split2 = (0, _slicedToArray2["default"])(_key$split, 1),
19
- baseKey = _key$split2[0];
20
- if (!props[baseKey]) return '';
21
- var content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
22
- return content && content.url ? content.url : '';
23
- }
24
- return '';
14
+ var _key$split = key.split('.'),
15
+ _key$split2 = (0, _slicedToArray2["default"])(_key$split, 1),
16
+ baseKey = _key$split2[0];
17
+ if (!props[baseKey]) return '';
18
+ var content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
19
+ return content && content.url ? content.url : '';
25
20
  };
26
21
  var _default = getLinkToPublishedContent;
27
22
  exports["default"] = _default;
@@ -1 +1 @@
1
- {"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","arguments","length","undefined","props","includes","_key$split","split","_key$split2","_slicedToArray2","baseKey","content","Array","isArray","url","_default","exports"],"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"mappings":";;;;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAA,EAA6B;EAAA,IAAzBC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IAAEG,KAAK,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACrD,IAAID,GAAG,CAACK,QAAQ,CAAC,WAAW,CAAC,EAAE;IAC7B,IAAAC,UAAA,GAAkBN,GAAG,CAACO,KAAK,CAAC,GAAG,CAAC;MAAAC,WAAA,OAAAC,eAAA,aAAAH,UAAA;MAAzBI,OAAO,GAAAF,WAAA;IACd,IAAI,CAACJ,KAAK,CAACM,OAAO,CAAC,EAAE,OAAO,EAAE;IAE9B,IAAMC,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACT,KAAK,CAACM,OAAO,CAAC,CAAC,GAAGN,KAAK,CAACM,OAAO,CAAC,CAAC,CAAC,CAAC,GAAGN,KAAK,CAACM,OAAO,CAAC;IAClF,OAAOC,OAAO,IAAIA,OAAO,CAACG,GAAG,GAAGH,OAAO,CAACG,GAAG,GAAG,EAAE;EAClD;EACA,OAAO,EAAE;AACX,CAAC;AAAC,IAAAC,QAAA,GAEahB,yBAAyB;AAAAiB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","arguments","length","undefined","props","_key$split","split","_key$split2","_slicedToArray2","baseKey","content","Array","isArray","url","_default","exports"],"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n};\n\nexport default getLinkToPublishedContent;\n"],"mappings":";;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAAyBA,CAAA,EAA6B;EAAA,IAAzBC,GAAG,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAAA,IAAEG,KAAK,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACrD,IAAAI,UAAA,GAAkBL,GAAG,CAACM,KAAK,CAAC,GAAG,CAAC;IAAAC,WAAA,OAAAC,eAAA,aAAAH,UAAA;IAAzBI,OAAO,GAAAF,WAAA;EACd,IAAI,CAACH,KAAK,CAACK,OAAO,CAAC,EAAE,OAAO,EAAE;EAC9B,IAAMC,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACR,KAAK,CAACK,OAAO,CAAC,CAAC,GAAGL,KAAK,CAACK,OAAO,CAAC,CAAC,CAAC,CAAC,GAAGL,KAAK,CAACK,OAAO,CAAC;EAClF,OAAOC,OAAO,IAAIA,OAAO,CAACG,GAAG,GAAGH,OAAO,CAACG,GAAG,GAAG,EAAE;AAClD,CAAC;AAAC,IAAAC,QAAA,GAEaf,yBAAyB;AAAAgB,OAAA,cAAAD,QAAA"}
@@ -29,6 +29,12 @@ Object.defineProperty(exports, "getLinkBasedOnValue", {
29
29
  return _getLinkBasedOnValue["default"];
30
30
  }
31
31
  });
32
+ Object.defineProperty(exports, "getLinkProps", {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _getLinkProps["default"];
36
+ }
37
+ });
32
38
  Object.defineProperty(exports, "getLinkToPublishedContent", {
33
39
  enumerable: true,
34
40
  get: function get() {
@@ -54,4 +60,5 @@ var _stripSummaryPropsContent = _interopRequireDefault(require("./strip-summary-
54
60
  var _buildLoopPropsContent = _interopRequireDefault(require("./build-loop-props-content"));
55
61
  var _parseBooleanValues = _interopRequireDefault(require("./parse-boolean-values"));
56
62
  var _getLinkBasedOnValue = _interopRequireDefault(require("./get-link-based-on-value"));
63
+ var _getLinkProps = _interopRequireDefault(require("./get-link-props"));
57
64
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_getDataSummaryQuery","_interopRequireDefault","require","_buildPropsToDisplayWithContent","_getLinkToPublishedContent","_stripSummaryPropsContent","_buildLoopPropsContent","_parseBooleanValues","_getLinkBasedOnValue"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,mBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,oBAAA,GAAAP,sBAAA,CAAAC,OAAA"}
1
+ {"version":3,"file":"index.js","names":["_getDataSummaryQuery","_interopRequireDefault","require","_buildPropsToDisplayWithContent","_getLinkToPublishedContent","_stripSummaryPropsContent","_buildLoopPropsContent","_parseBooleanValues","_getLinkBasedOnValue","_getLinkProps"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,oBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,+BAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,0BAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,yBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,sBAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,mBAAA,GAAAN,sBAAA,CAAAC,OAAA;AACA,IAAAM,oBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA"}
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports["default"] = void 0;
9
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
9
10
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
10
11
  require("core-js/modules/es.array.filter.js");
11
12
  require("core-js/modules/es.object.to-string.js");
@@ -17,11 +18,11 @@ require("core-js/modules/es.array.iterator.js");
17
18
  require("core-js/modules/es.set.js");
18
19
  require("core-js/modules/es.string.iterator.js");
19
20
  require("core-js/modules/web.dom-collections.iterator.js");
20
- require("core-js/modules/es.array.index-of.js");
21
+ require("core-js/modules/es.array.for-each.js");
22
+ require("core-js/modules/web.dom-collections.for-each.js");
21
23
  require("core-js/modules/es.array.join.js");
22
24
  require("core-js/modules/es.array.map.js");
23
25
  require("core-js/modules/es.array.find.js");
24
- require("core-js/modules/es.string.starts-with.js");
25
26
  var _constants = require("../constants");
26
27
  var defaultProps = [_constants.ID, 'name'];
27
28
  var categoryProps = 'id publishedListingPage{id, url}';
@@ -33,6 +34,7 @@ var checkProps = function checkProps(props) {
33
34
  var buildPropsQuery = function buildPropsQuery(entitySchema) {
34
35
  var extraProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
35
36
  var cardOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
37
+ var linkProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
36
38
  var parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;
37
39
  var extraPropsHaveCategory = !!extraProps.filter(function (prop) {
38
40
  return prop.includes('category.');
@@ -42,33 +44,43 @@ var buildPropsQuery = function buildPropsQuery(entitySchema) {
42
44
  shouldAddCategoryProps = _getTypeBaseProps.shouldAddCategoryProps;
43
45
  var allProps = [].concat((0, _toConsumableArray2["default"])(typeBasedProps), (0, _toConsumableArray2["default"])(extraProps));
44
46
  var uniqueProps = (0, _toConsumableArray2["default"])(new Set((0, _toConsumableArray2["default"])(allProps)));
45
- var basicProps = uniqueProps.filter(function (prop) {
46
- return prop && !prop.includes('.');
47
- }).filter(function (prop, i, arr) {
48
- return arr.indexOf(prop) === i;
47
+ var basicProps = [];
48
+ var nestedProps = {};
49
+ uniqueProps.forEach(function (prop) {
50
+ if (prop) {
51
+ if (!prop.includes('.')) {
52
+ basicProps.push(prop);
53
+ return;
54
+ }
55
+ var _prop$split = prop.split('.'),
56
+ _prop$split2 = (0, _slicedToArray2["default"])(_prop$split, 2),
57
+ base = _prop$split2[0],
58
+ nested = _prop$split2[1];
59
+ if (!nestedProps[base]) nestedProps[base] = [nested];else nestedProps[base].push(nested);
60
+ }
49
61
  });
50
- var complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);
51
- return [].concat((0, _toConsumableArray2["default"])(basicProps), (0, _toConsumableArray2["default"])(complexProps)).join(',');
62
+ var complexProps = buildComplexProps(shouldAddCategoryProps, nestedProps, parsedSchema, linkProps);
63
+ return [].concat(basicProps, (0, _toConsumableArray2["default"])(complexProps)).join(',');
52
64
  };
53
- var buildComplexProps = function buildComplexProps(shouldAddCategoryProps, props, _ref) {
54
- var relations = _ref.relations;
55
- return props.filter(function (prop) {
56
- return prop && prop.includes('.');
57
- }).map(function (nested) {
58
- return nested.split('.')[0];
59
- }).filter(function (prop, i, arr) {
60
- return arr.indexOf(prop) === i;
61
- }).map(function (base) {
65
+ var buildComplexProps = function buildComplexProps(shouldAddCategoryProps, props, _ref, linkProps) {
66
+ var _ref$relations = _ref.relations,
67
+ relations = _ref$relations === void 0 ? [] : _ref$relations,
68
+ _ref$dynamicPropertie = _ref.dynamicProperties,
69
+ dynamicProperties = _ref$dynamicPropertie === void 0 ? {} : _ref$dynamicPropertie;
70
+ return Object.keys(props).map(function (base) {
71
+ var nestedProps = props[base];
72
+ var hasLink = !!linkProps.find(function (linkProp) {
73
+ return linkProp.includes(base);
74
+ });
62
75
  var matchingRelation = relations.find(function (_ref2) {
63
76
  var localField = _ref2.localField;
64
77
  return localField === base;
65
78
  });
66
- var nestedProps = props.filter(function (extraProp, i, arr) {
67
- return extraProp && extraProp.startsWith("".concat(base, ".")) && arr.indexOf(extraProp) === i;
68
- }).map(function (nested) {
69
- return nested.split('.')[1];
79
+ var matchingDynamicProp = Object.keys(dynamicProperties).find(function (dynamicKey) {
80
+ return dynamicKey === base;
70
81
  });
71
82
  if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
83
+ if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
72
84
  var jointNestedProps = nestedProps.join(',');
73
85
  if (base === 'category' && shouldAddCategoryProps) return "".concat(base, "{").concat(jointNestedProps, ", ").concat(categoryProps, "}");
74
86
  if (base.includes('published')) {
@@ -117,9 +129,7 @@ var getContentProps = function getContentProps(isContent) {
117
129
  var getCategoyProps = function getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader) {
118
130
  if (!shouldAddCategoryProps) return [];
119
131
  var props = [];
120
- if (hasCategory) {
121
- props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
122
- }
132
+ if (hasCategory) props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
123
133
  if (hasPreheader) {
124
134
  props.push("".concat(_constants.PREHEADER_PROP, "{name}"));
125
135
  props.push(_constants.HEADLINE_PROP);
@@ -1 +1 @@
1
- {"version":3,"file":"build-props-query.js","names":["_constants","require","defaultProps","ID","categoryProps","checkProps","props","Object","keys","filter","prop","CATEGORY_ID","length","buildPropsQuery","entitySchema","extraProps","arguments","undefined","cardOptions","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","_getTypeBaseProps","getTypeBaseProps","typeBasedProps","shouldAddCategoryProps","allProps","concat","_toConsumableArray2","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","_ref","relations","map","nested","split","base","matchingRelation","find","_ref2","localField","nestedProps","extraProp","startsWith","push","jointNestedProps","isCard","_ref3","_ref3$displayCategory","displayCategory","_ref3$displayThumbnai","displayThumbnail","interfaces","properties","dynamicProperties","isContent","hasCategory","hasPreheader","PREHEADER_PROP","apply","getCategoyProps","getContentProps","url","_ref4","HEADLINE_PROP","_default","exports"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n\n const uniqueProps = [...new Set([...allProps])];\n\n const basicProps = uniqueProps\n .filter(prop => prop && !prop.includes('.'))\n .filter((prop, i, arr) => arr.indexOf(prop) === i);\n const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (shouldAddCategoryProps, props, { relations }) =>\n props\n .filter(prop => prop && prop.includes('.'))\n .map(nested => nested.split('.')[0])\n .filter((prop, i, arr) => arr.indexOf(prop) === i)\n .map(base => {\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const nestedProps = props\n .filter(\n (extraProp, i, arr) =>\n extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i\n )\n .map(nested => nested.split('.')[1]);\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n\n const props = [];\n\n if (hasCategory) {\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n }\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAMC,YAAY,GAAG,CAACC,aAAE,EAAE,MAAM,CAAC;AACjC,IAAMC,aAAa,GAAG,kCAAkC;AAExD,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAGC,KAAK;EAAA,OACtB,CAAC,EAAEA,KAAK,IAAIC,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,OAAKA,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE;AAAA,CAAC;AAExF,IAAMK,eAAe,GAAG,SAAlBA,eAAeA,CAAI1C,sBAAsB,EAAEsC,WAAW,EAAEC,YAAY,EAAK;EAC7E,IAAI,CAACvC,sBAAsB,EAAE,OAAO,EAAE;EAEtC,IAAMpB,KAAK,GAAG,EAAE;EAEhB,IAAI0D,WAAW,EAAE;IACf1D,KAAK,CAAC8C,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EACrF;EAEA,IAAIa,YAAY,EAAE;IAChB3D,KAAK,CAAC8C,IAAI,IAAAxB,MAAA,CAAIsC,yBAAc,YAAS;IACrC5D,KAAK,CAAC8C,IAAI,CAACoB,wBAAa,CAAC;EAC3B;EAEA,OAAOlE,KAAK;AACd,CAAC;AAAC,IAAAmE,QAAA,GAEa5D,eAAe;AAAA6D,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"build-props-query.js","names":["_constants","require","defaultProps","ID","categoryProps","checkProps","props","Object","keys","filter","prop","CATEGORY_ID","length","buildPropsQuery","entitySchema","extraProps","arguments","undefined","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","_getTypeBaseProps","getTypeBaseProps","typeBasedProps","shouldAddCategoryProps","allProps","concat","_toConsumableArray2","uniqueProps","Set","basicProps","nestedProps","forEach","push","_prop$split","split","_prop$split2","_slicedToArray2","base","nested","complexProps","buildComplexProps","join","_ref","_ref$relations","relations","_ref$dynamicPropertie","dynamicProperties","map","hasLink","find","linkProp","matchingRelation","_ref2","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","_ref3","_ref3$displayCategory","displayCategory","_ref3$displayThumbnai","displayThumbnail","interfaces","properties","isContent","hasCategory","hasPreheader","PREHEADER_PROP","apply","getCategoyProps","getContentProps","url","_ref4","HEADLINE_PROP","_default","exports"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAMC,YAAY,GAAG,CAACC,aAAE,EAAE,MAAM,CAAC;AACjC,IAAMC,aAAa,GAAG,kCAAkC;AAExD,IAAMC,UAAU,GAAG,SAAbA,UAAUA,CAAGC,KAAK;EAAA,OACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAAC,UAAAC,IAAI;IAAA,OAA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B,UAAU,GAAAoB,KAAA,CAAVpB,UAAU;IAAA,OAAOA,UAAU,KAAK,OAAO;EAAA,EAAC,EAAE;IAClF/B,cAAc,CAACU,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC;EAC5D;EAEA,OAAO;IAAEV,cAAc,EAAdA,cAAc;IAAEC,sBAAsB,EAAtBA;EAAuB,CAAC;AACnD,CAAC;AAED,IAAMgD,eAAe,GAAG,SAAlBA,eAAeA,CAAGN,SAAS;EAAA,OAAKA,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAE;AAAA,CAAC;AAExF,IAAMK,eAAe,GAAG,SAAlBA,eAAeA,CAAI/C,sBAAsB,EAAE2C,WAAW,EAAEC,YAAY,EAAK;EAC7E,IAAI,CAAC5C,sBAAsB,EAAE,OAAO,EAAE;EACtC,IAAMrB,KAAK,GAAG,EAAE;EAChB,IAAIgE,WAAW,EACbhE,KAAK,CAAC8B,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EAErF,IAAImC,YAAY,EAAE;IAChBjE,KAAK,CAAC8B,IAAI,IAAAP,MAAA,CAAI2C,yBAAc,YAAS;IACrClE,KAAK,CAAC8B,IAAI,CAAC0C,wBAAa,CAAC;EAC3B;EAEA,OAAOxE,KAAK;AACd,CAAC;AAAC,IAAAyE,QAAA,GAEalE,eAAe;AAAAmE,OAAA,cAAAD,QAAA"}
@@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
6
6
  import { MainContext } from '@blaze-cms/nextjs-components';
7
7
  import { getSingleEntitySchema } from '../../application/query';
8
8
  import { buildPropsQuery, checkPropsToUse } from '../../helpers';
9
- import { getDataSummaryQuery } from './helpers';
9
+ import { getDataSummaryQuery, getLinkProps } from './helpers';
10
10
  import DataSummaryRender from './DataSummaryRender';
11
11
  const DataSummaryFactory = _ref => {
12
12
  let {
@@ -40,7 +40,8 @@ const DataSummaryFactory = _ref => {
40
40
  if (!data) return null;
41
41
  if (!propsToDisplay || !propsToDisplay.length) return null;
42
42
  const propsToDisplayValues = checkPropsToUse(propsToDisplay);
43
- const propsQueryString = buildPropsQuery(data, propsToDisplayValues);
43
+ const linkProps = getLinkProps(propsToDisplay);
44
+ const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);
44
45
  const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);
45
46
  const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;
46
47
  return /*#__PURE__*/React.createElement(DataSummaryRender, {
@@ -1 +1 @@
1
- {"version":3,"file":"DataSummaryFactory.js","names":["React","useContext","useQuery","PropTypes","MainContext","getSingleEntitySchema","buildPropsQuery","checkPropsToUse","getDataSummaryQuery","DataSummaryRender","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","dataSummaryProps","_objectWithoutProperties","_excluded","entityForQuery","parent","itemEntity","data","error","loading","variables","id","isPreview","message","length","propsToDisplayValues","propsQueryString","dataSummaryQuery","recordId","itemId","createElement","query","htmlTag","propTypes","string","array","bool","number","defaultProps"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n ...dataSummaryProps\n}) => {\n const entityForQuery = useSelectedEntity ? entity : dataSummaryProps.parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n const { isPreview } = useContext(MainContext);\n\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n modifier: '',\n headingStyle: 'h2',\n loopProperties: [],\n loopLimit: 0\n};\n\nexport default DataSummaryFactory;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,eAAe,EAAEC,eAAe,QAAQ,eAAe;AAChE,SAASC,mBAAmB,QAAQ,WAAW;AAC/C,OAAOC,iBAAiB,MAAM,qBAAqB;AAEnD,MAAMC,kBAAkB,GAAGC,IAAA,IAYrB;EAAA,IAZsB;MAC1BC,MAAM;MACNC,YAAY;MACZC,cAAc;MACdC,IAAI;MACJC,iBAAiB;M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A,QAAS;IACnByB,OAAO,EAAExB;EAAa,EACtB;AAEN,CAAC;AAEDT,kBAAkB,CAACkC,SAAS,GAAG;EAC7B7B,IAAI,EAAEZ,SAAS,CAAC0C,MAAM;EACtBhC,YAAY,EAAEV,SAAS,CAAC2C,KAAK;EAC7BhC,cAAc,EAAEX,SAAS,CAAC2C,KAAK;EAC/BlC,MAAM,EAAET,SAAS,CAAC0C,MAAM;EACxB7B,iBAAiB,EAAEb,SAAS,CAAC4C,IAAI;EACjC9B,YAAY,EAAEd,SAAS,CAAC0C,MAAM;EAC9B3B,QAAQ,EAAEf,SAAS,CAAC0C,MAAM;EAC1B1B,YAAY,EAAEhB,SAAS,CAAC0C,MAAM;EAC9BzB,cAAc,EAAEjB,SAAS,CAAC2C,KAAK;EAC/BzB,SAAS,EAAElB,SAAS,CAAC6C;AACvB,CAAC;AAEDtC,kBAAkB,CAACuC,YAAY,GAAG;EAChClC,IAAI,EAAE,MAAM;EACZF,YAAY,EAAE,EAAE;EAChBC,cAAc,EAAE,EAAE;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE;AACb,CAAC;AAED,eAAeX,kBAAkB"}
1
+ {"version":3,"file":"DataSummaryFactory.js","names":["React","useContext","useQuery","PropTypes","MainContext","getSingleEntitySchema","buildPropsQuery","checkPropsToUse","getDataSummaryQuery","getLinkProps","DataSummaryRender","DataSummaryFactory","_ref","entity","dataRecordId","propsToDisplay","type","useSelectedEntity","elementTitle","modifier","headingStyle","loopProperties","loopLimit","dataSummaryProps","_objectWithoutProperties","_excluded","entityForQuery","parent","itemEntity","data","error","loading","variables","id","isPreview","message","length","propsToDisplayValues","linkProps","propsQueryString","dataSummaryQuery","recordId","itemId","createElement","query","htmlTag","propTypes","string","array","bool","number","defaultProps"],"sources":["../../../src/components/DataSummary/DataSummaryFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { getSingleEntitySchema } from '../../application/query';\nimport { buildPropsQuery, checkPropsToUse } from '../../helpers';\nimport { getDataSummaryQuery, getLinkProps } from './helpers';\nimport DataSummaryRender from './DataSummaryRender';\n\nconst DataSummaryFactory = ({\n entity,\n dataRecordId,\n propsToDisplay,\n type,\n useSelectedEntity,\n elementTitle,\n modifier,\n headingStyle,\n loopProperties,\n loopLimit,\n ...dataSummaryProps\n}) => {\n const entityForQuery = useSelectedEntity ? entity : dataSummaryProps.parent.itemEntity;\n const { data, error, loading } = useQuery(getSingleEntitySchema, {\n variables: { id: entityForQuery }\n });\n const { isPreview } = useContext(MainContext);\n\n if (loading) return '';\n if (error) return error.message;\n if (!data) return null;\n if (!propsToDisplay || !propsToDisplay.length) return null;\n const propsToDisplayValues = checkPropsToUse(propsToDisplay);\n const linkProps = getLinkProps(propsToDisplay);\n const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);\n const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);\n const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;\n\n return (\n <DataSummaryRender\n recordId={recordId}\n propsToDisplay={propsToDisplay}\n loopProperties={loopProperties}\n loopLimit={loopLimit}\n query={dataSummaryQuery}\n type={type}\n elementTitle={elementTitle}\n modifier={modifier}\n htmlTag={headingStyle}\n />\n );\n};\n\nDataSummaryFactory.propTypes = {\n type: PropTypes.string,\n dataRecordId: PropTypes.array,\n propsToDisplay: PropTypes.array,\n entity: PropTypes.string,\n useSelectedEntity: PropTypes.bool,\n elementTitle: PropTypes.string,\n modifier: PropTypes.string,\n headingStyle: PropTypes.string,\n loopProperties: PropTypes.array,\n loopLimit: PropTypes.number\n};\n\nDataSummaryFactory.defaultProps = {\n type: 'text',\n dataRecordId: [],\n propsToDisplay: [],\n useSelectedEntity: true,\n entity: '',\n elementTitle: '',\n modifier: '',\n headingStyle: 'h2',\n loopProperties: [],\n loopLimit: 0\n};\n\nexport default DataSummaryFactory;\n"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,qBAAqB,QAAQ,yBAAyB;AAC/D,SAASC,eAAe,EAAEC,eAAe,QAAQ,eAAe;AAChE,SAASC,mBAAmB,EAAEC,YAAY,QAAQ,WAAW;AAC7D,OAAOC,iBAAiB,MAAM,qBAAqB;AAEnD,MAAMC,kBAAkB,GAAGC,IAAA,IAYrB;EAAA,IAZsB;MAC1BC,MAAM;MACNC,YAAY;MACZC,cAAc;MACdC,IAAI;MACJC,iBAAiB;MACjBC,YAAY;MACZC,QAAQ;MACRC,YAAY;MACZC,cAAc;MACdC;IAEF,CAAC,GAAAV,IAAA;IADIW,gBAAgB,GAAAC,wBAAA,CAAAZ,IAAA,EAAAa,SAAA;EAEnB,MAAMC,cAAc,GAAGT,iBAAiB,GAAGJ,MAAM,GAAGU,gBAAgB,CAACI,MAAM,CAACC,UAAU;EACtF,MAAM;IAAEC,IAAI;IAAEC,KAAK;IAAEC;EAAQ,CAAC,GAAG7B,QAAQ,CAACG,qBAAqB,EAAE;IAC/D2B,SAAS,EAAE;MAAEC,EAAE,EAAEP;IAAe;EAClC,CAAC,CAAC;EACF,MAAM;IAAEQ;EAAU,CAAC,GAAGjC,UAAU,CAACG,WAAW,CAAC;EAE7C,IAAI2B,OAAO,EAAE,OAAO,EAAE;EACtB,IAAID,KAAK,EAAE,OAAOA,KAAK,CAACK,OAAO;EAC/B,IAAI,CAACN,IAAI,EAAE,OAAO,IAAI;EACtB,IAAI,CAACd,cAAc,IAAI,CAACA,cAAc,CAACqB,MAAM,EAAE,OAAO,IAAI;EAC1D,M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EAAE,MAAM;EACZF,YAAY,EAAE,EAAE;EAChBC,cAAc,EAAE,EAAE;EAClBE,iBAAiB,EAAE,IAAI;EACvBJ,MAAM,EAAE,EAAE;EACVK,YAAY,EAAE,EAAE;EAChBC,QAAQ,EAAE,EAAE;EACZC,YAAY,EAAE,IAAI;EAClBC,cAAc,EAAE,EAAE;EAClBC,SAAS,EAAE;AACb,CAAC;AAED,eAAeX,kBAAkB"}
@@ -0,0 +1,6 @@
1
+ const getLinkProps = (props = []) => props.map(({
2
+ propertiesToDisplay,
3
+ enableLink
4
+ }) => enableLink && propertiesToDisplay).flat().filter(Boolean);
5
+ export default getLinkProps;
6
+ //# sourceMappingURL=get-link-props.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-link-props.js","names":["getLinkProps","props","map","propertiesToDisplay","enableLink","flat","filter","Boolean"],"sources":["../../../../src/components/DataSummary/helpers/get-link-props.js"],"sourcesContent":["const getLinkProps = (props = []) =>\n props\n .map(({ propertiesToDisplay, enableLink }) => enableLink && propertiesToDisplay)\n .flat()\n .filter(Boolean);\n\nexport default getLinkProps;\n"],"mappings":"AAAA,MAAMA,YAAY,GAAGA,CAACC,KAAK,GAAG,EAAE,KAC9BA,KAAK,CACFC,GAAG,CAAC,CAAC;EAAEC,mBAAmB;EAAEC;AAAW,CAAC,KAAKA,UAAU,IAAID,mBAAmB,CAAC,CAC/EE,IAAI,EAAE,CACNC,MAAM,CAACC,OAAO,CAAC;AAEpB,eAAeP,YAAY"}
@@ -1,11 +1,8 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
- if (key.includes('published')) {
3
- const [baseKey] = key.split('.');
4
- if (!props[baseKey]) return '';
5
- const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
6
- return content && content.url ? content.url : '';
7
- }
8
- return '';
2
+ const [baseKey] = key.split('.');
3
+ if (!props[baseKey]) return '';
4
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
5
+ return content && content.url ? content.url : '';
9
6
  };
10
7
  export default getLinkToPublishedContent;
11
8
  //# sourceMappingURL=get-link-to-published-content.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","props","includes","baseKey","split","content","Array","isArray","url"],"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"mappings":"AAAA,MAAMA,yBAAyB,GAAGA,CAACC,GAAG,GAAG,EAAE,EAAEC,KAAK,GAAG,CAAC,CAAC,KAAK;EAC1D,IAAID,GAAG,CAACE,QAAQ,CAAC,WAAW,CAAC,EAAE;IAC7B,MAAM,CAACC,OAAO,CAAC,GAAGH,GAAG,CAACI,KAAK,CAAC,GAAG,CAAC;IAChC,IAAI,CAACH,KAAK,CAACE,OAAO,CAAC,EAAE,OAAO,EAAE;IAE9B,MAAME,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACN,KAAK,CAACE,OAAO,CAAC,CAAC,GAAGF,KAAK,CAACE,OAAO,CAAC,CAAC,CAAC,CAAC,GAAGF,KAAK,CAACE,OAAO,CAAC;IAClF,OAAOE,OAAO,IAAIA,OAAO,CAACG,GAAG,GAAGH,OAAO,CAACG,GAAG,GAAG,EAAE;EAClD;EACA,OAAO,EAAE;AACX,CAAC;AAED,eAAeT,yBAAyB"}
1
+ {"version":3,"file":"get-link-to-published-content.js","names":["getLinkToPublishedContent","key","props","baseKey","split","content","Array","isArray","url"],"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n const [baseKey] = key.split('.');\n if (!props[baseKey]) return '';\n const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];\n return content && content.url ? content.url : '';\n};\n\nexport default getLinkToPublishedContent;\n"],"mappings":"AAAA,MAAMA,yBAAyB,GAAGA,CAACC,GAAG,GAAG,EAAE,EAAEC,KAAK,GAAG,CAAC,CAAC,KAAK;EAC1D,MAAM,CAACC,OAAO,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,GAAG,CAAC;EAChC,IAAI,CAACF,KAAK,CAACC,OAAO,CAAC,EAAE,OAAO,EAAE;EAC9B,MAAME,OAAO,GAAGC,KAAK,CAACC,OAAO,CAACL,KAAK,CAACC,OAAO,CAAC,CAAC,GAAGD,KAAK,CAACC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAGD,KAAK,CAACC,OAAO,CAAC;EAClF,OAAOE,OAAO,IAAIA,OAAO,CAACG,GAAG,GAAGH,OAAO,CAACG,GAAG,GAAG,EAAE;AAClD,CAAC;AAED,eAAeR,yBAAyB"}
@@ -5,5 +5,6 @@ import stripSummaryPropsContent from './strip-summary-props-content';
5
5
  import buildLoopPropsContent from './build-loop-props-content';
6
6
  import parseBooleanValues from './parse-boolean-values';
7
7
  import getLinkBasedOnValue from './get-link-based-on-value';
8
- export { getDataSummaryQuery, buildPropsToDisplayWithContent, getLinkToPublishedContent, stripSummaryPropsContent, buildLoopPropsContent, parseBooleanValues, getLinkBasedOnValue };
8
+ import getLinkProps from './get-link-props';
9
+ export { getDataSummaryQuery, buildPropsToDisplayWithContent, getLinkToPublishedContent, stripSummaryPropsContent, buildLoopPropsContent, parseBooleanValues, getLinkBasedOnValue, getLinkProps };
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getDataSummaryQuery","buildPropsToDisplayWithContent","getLinkToPublishedContent","stripSummaryPropsContent","buildLoopPropsContent","parseBooleanValues","getLinkBasedOnValue"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue\n};\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,8BAA8B,MAAM,uCAAuC;AAClF,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAE3D,SACEN,mBAAmB,EACnBC,8BAA8B,EAC9BC,yBAAyB,EACzBC,wBAAwB,EACxBC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB"}
1
+ {"version":3,"file":"index.js","names":["getDataSummaryQuery","buildPropsToDisplayWithContent","getLinkToPublishedContent","stripSummaryPropsContent","buildLoopPropsContent","parseBooleanValues","getLinkBasedOnValue","getLinkProps"],"sources":["../../../../src/components/DataSummary/helpers/index.js"],"sourcesContent":["import getDataSummaryQuery from './get-data-summary-query';\nimport buildPropsToDisplayWithContent from './build-props-to-display-with-content';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport stripSummaryPropsContent from './strip-summary-props-content';\nimport buildLoopPropsContent from './build-loop-props-content';\nimport parseBooleanValues from './parse-boolean-values';\nimport getLinkBasedOnValue from './get-link-based-on-value';\nimport getLinkProps from './get-link-props';\n\nexport {\n getDataSummaryQuery,\n buildPropsToDisplayWithContent,\n getLinkToPublishedContent,\n stripSummaryPropsContent,\n buildLoopPropsContent,\n parseBooleanValues,\n getLinkBasedOnValue,\n getLinkProps\n};\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,8BAA8B,MAAM,uCAAuC;AAClF,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,mBAAmB,MAAM,2BAA2B;AAC3D,OAAOC,YAAY,MAAM,kBAAkB;AAE3C,SACEP,mBAAmB,EACnBC,8BAA8B,EAC9BC,yBAAyB,EACzBC,wBAAwB,EACxBC,qBAAqB,EACrBC,kBAAkB,EAClBC,mBAAmB,EACnBC,YAAY"}
@@ -2,7 +2,7 @@ import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';
2
2
  const defaultProps = [ID, 'name'];
3
3
  const categoryProps = 'id publishedListingPage{id, url}';
4
4
  const checkProps = props => !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);
5
- const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
5
+ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {
6
6
  const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;
7
7
  const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;
8
8
  const {
@@ -11,18 +11,33 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
11
11
  } = getTypeBaseProps(parsedSchema, cardOptions, extraPropsHaveCategory);
12
12
  const allProps = [...typeBasedProps, ...extraProps];
13
13
  const uniqueProps = [...new Set([...allProps])];
14
- const basicProps = uniqueProps.filter(prop => prop && !prop.includes('.')).filter((prop, i, arr) => arr.indexOf(prop) === i);
15
- const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);
14
+ const basicProps = [];
15
+ const nestedProps = {};
16
+ uniqueProps.forEach(prop => {
17
+ if (prop) {
18
+ if (!prop.includes('.')) {
19
+ basicProps.push(prop);
20
+ return;
21
+ }
22
+ const [base, nested] = prop.split('.');
23
+ if (!nestedProps[base]) nestedProps[base] = [nested];else nestedProps[base].push(nested);
24
+ }
25
+ });
26
+ const complexProps = buildComplexProps(shouldAddCategoryProps, nestedProps, parsedSchema, linkProps);
16
27
  return [...basicProps, ...complexProps].join(',');
17
28
  };
18
29
  const buildComplexProps = (shouldAddCategoryProps, props, {
19
- relations
20
- }) => props.filter(prop => prop && prop.includes('.')).map(nested => nested.split('.')[0]).filter((prop, i, arr) => arr.indexOf(prop) === i).map(base => {
30
+ relations = [],
31
+ dynamicProperties = {}
32
+ }, linkProps) => Object.keys(props).map(base => {
33
+ const nestedProps = props[base];
34
+ const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
21
35
  const matchingRelation = relations.find(({
22
36
  localField
23
37
  }) => localField === base);
24
- const nestedProps = props.filter((extraProp, i, arr) => extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i).map(nested => nested.split('.')[1]);
38
+ const matchingDynamicProp = Object.keys(dynamicProperties).find(dynamicKey => dynamicKey === base);
25
39
  if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
40
+ if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
26
41
  const jointNestedProps = nestedProps.join(',');
27
42
  if (base === 'category' && shouldAddCategoryProps) return `${base}{${jointNestedProps}, ${categoryProps}}`;
28
43
  if (base.includes('published')) {
@@ -68,9 +83,7 @@ const getContentProps = isContent => isContent ? ['url', 'sponsored', 'featured'
68
83
  const getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {
69
84
  if (!shouldAddCategoryProps) return [];
70
85
  const props = [];
71
- if (hasCategory) {
72
- props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
73
- }
86
+ if (hasCategory) props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
74
87
  if (hasPreheader) {
75
88
  props.push(`${PREHEADER_PROP}{name}`);
76
89
  props.push(HEADLINE_PROP);
@@ -1 +1 @@
1
- {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","i","arr","indexOf","complexProps","buildComplexProps","join","relations","map","nested","split","base","matchingRelation","find","localField","nestedProps","extraProp","startsWith","push","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","dynamicProperties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n\n const uniqueProps = [...new Set([...allProps])];\n\n const basicProps = uniqueProps\n .filter(prop => prop && !prop.includes('.'))\n .filter((prop, i, arr) => arr.indexOf(prop) === i);\n const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (shouldAddCategoryProps, props, { relations }) =>\n props\n .filter(prop => prop && prop.includes('.'))\n .map(nested => nested.split('.')[0])\n .filter((prop, i, arr) => arr.indexOf(prop) === i)\n .map(base => {\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const nestedProps = props\n .filter(\n (extraProp, i, arr) =>\n extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i\n )\n .map(nested => nested.split('.')[1]);\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n\n const props = [];\n\n if (hasCategory) {\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n }\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n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CAAC,GAAGY,eAAe,CAACJ,SAAS,CAAC,CAAC;EAElD,IAAIF,UAAU,CAACO,GAAG,IAAIN,iBAAiB,CAACM,GAAG,EAAErC,cAAc,CAACwB,IAAI,CAAC,KAAK,CAAC;EAEvE,IAAII,gBAAgB,IAAIf,SAAS,CAACM,IAAI,CAAC,CAAC;IAAEC;EAAW,CAAC,KAAKA,UAAU,KAAK,OAAO,CAAC,EAAE;IAClFpB,cAAc,CAACwB,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC;EAC5D;EAEA,OAAO;IAAExB,cAAc;IAAEC;EAAuB,CAAC;AACnD,CAAC;AAED,MAAMmC,eAAe,GAAGJ,SAAS,IAAKA,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAG;AAExF,MAAMG,eAAe,GAAGA,CAAClC,sBAAsB,EAAEgC,WAAW,EAAEC,YAAY,KAAK;EAC7E,IAAI,CAACjC,sBAAsB,EAAE,OAAO,EAAE;EAEtC,MAAMf,KAAK,GAAG,EAAE;EAEhB,IAAI+C,WAAW,EAAE;IACf/C,KAAK,CAACsC,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EACrF;EAEA,IAAIU,YAAY,EAAE;IAChBhD,KAAK,CAACsC,IAAI,CAAE,GAAE3C,cAAe,QAAO,CAAC;IACrCK,KAAK,CAACsC,IAAI,CAAC1C,aAAa,CAAC;EAC3B;EAEA,OAAOI,KAAK;AACd,CAAC;AAED,eAAeM,eAAe"}
1
+ {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","map","hasLink","find","linkProp","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AAC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AACS,IAAI,CAAC,GAAG2B,eAAe,CAACJ,SAAS,CAAC,CAAC;EAElD,IAAID,UAAU,CAACM,GAAG,IAAIpB,iBAAiB,CAACoB,GAAG,EAAErC,cAAc,CAACS,IAAI,CAAC,KAAK,CAAC;EAEvE,IAAIoB,gBAAgB,IAAIb,SAAS,CAACI,IAAI,CAAC,CAAC;IAAEG;EAAW,CAAC,KAAKA,UAAU,KAAK,OAAO,CAAC,EAAE;IAClFvB,cAAc,CAACS,IAAI,CAAC,UAAU,EAAE,WAAW,EAAE,YAAY,CAAC;EAC5D;EAEA,OAAO;IAAET,cAAc;IAAEC;EAAuB,CAAC;AACnD,CAAC;AAED,MAAMmC,eAAe,GAAGJ,SAAS,IAAKA,SAAS,GAAG,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,GAAG,EAAG;AAExF,MAAMG,eAAe,GAAGA,CAAClC,sBAAsB,EAAEgC,WAAW,EAAEC,YAAY,KAAK;EAC7E,IAAI,CAACjC,sBAAsB,EAAE,OAAO,EAAE;EACtC,MAAMhB,KAAK,GAAG,EAAE;EAChB,IAAIgD,WAAW,EACbhD,KAAK,CAACwB,IAAI,CAAC,eAAe,EAAE,wBAAwB,EAAE,4BAA4B,CAAC;EAErF,IAAIyB,YAAY,EAAE;IAChBjD,KAAK,CAACwB,IAAI,CAAE,GAAE7B,cAAe,QAAO,CAAC;IACrCK,KAAK,CAACwB,IAAI,CAAC5B,aAAa,CAAC;EAC3B;EAEA,OAAOI,KAAK;AACd,CAAC;AAED,eAAeM,eAAe"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.128.0-alpha.3",
3
+ "version": "0.128.0-alpha.4",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -29,7 +29,7 @@
29
29
  "dependencies": {
30
30
  "@blaze-cms/core-auth-ui": "0.128.0-alpha.0",
31
31
  "@blaze-cms/core-errors": "^0.127.0",
32
- "@blaze-cms/core-errors-ui": "0.128.0-alpha.3",
32
+ "@blaze-cms/core-errors-ui": "0.128.0-alpha.4",
33
33
  "@blaze-cms/image-cdn-react": "0.3.0-alpha.5",
34
34
  "@blaze-cms/nextjs-components": "0.128.0-alpha.1",
35
35
  "@blaze-cms/plugin-search-ui": "0.128.0-alpha.0",
@@ -89,5 +89,5 @@
89
89
  "lib/*",
90
90
  "lib-es/*"
91
91
  ],
92
- "gitHead": "71e16abe0163b4f92df1540b25dc709a7865f064"
92
+ "gitHead": "ccd862134d94eac4650b6ee380e7ae51f087ee33"
93
93
  }
@@ -4,7 +4,7 @@ import PropTypes from 'prop-types';
4
4
  import { MainContext } from '@blaze-cms/nextjs-components';
5
5
  import { getSingleEntitySchema } from '../../application/query';
6
6
  import { buildPropsQuery, checkPropsToUse } from '../../helpers';
7
- import { getDataSummaryQuery } from './helpers';
7
+ import { getDataSummaryQuery, getLinkProps } from './helpers';
8
8
  import DataSummaryRender from './DataSummaryRender';
9
9
 
10
10
  const DataSummaryFactory = ({
@@ -31,7 +31,8 @@ const DataSummaryFactory = ({
31
31
  if (!data) return null;
32
32
  if (!propsToDisplay || !propsToDisplay.length) return null;
33
33
  const propsToDisplayValues = checkPropsToUse(propsToDisplay);
34
- const propsQueryString = buildPropsQuery(data, propsToDisplayValues);
34
+ const linkProps = getLinkProps(propsToDisplay);
35
+ const propsQueryString = buildPropsQuery(data, propsToDisplayValues, null, linkProps);
35
36
  const dataSummaryQuery = getDataSummaryQuery(data, isPreview, propsQueryString);
36
37
  const recordId = dataRecordId[0] || dataSummaryProps.parent.itemId;
37
38
 
@@ -0,0 +1,7 @@
1
+ const getLinkProps = (props = []) =>
2
+ props
3
+ .map(({ propertiesToDisplay, enableLink }) => enableLink && propertiesToDisplay)
4
+ .flat()
5
+ .filter(Boolean);
6
+
7
+ export default getLinkProps;
@@ -1,12 +1,8 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
- if (key.includes('published')) {
3
- const [baseKey] = key.split('.');
4
- if (!props[baseKey]) return '';
5
-
6
- const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
7
- return content && content.url ? content.url : '';
8
- }
9
- return '';
2
+ const [baseKey] = key.split('.');
3
+ if (!props[baseKey]) return '';
4
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
5
+ return content && content.url ? content.url : '';
10
6
  };
11
7
 
12
8
  export default getLinkToPublishedContent;
@@ -5,6 +5,7 @@ import stripSummaryPropsContent from './strip-summary-props-content';
5
5
  import buildLoopPropsContent from './build-loop-props-content';
6
6
  import parseBooleanValues from './parse-boolean-values';
7
7
  import getLinkBasedOnValue from './get-link-based-on-value';
8
+ import getLinkProps from './get-link-props';
8
9
 
9
10
  export {
10
11
  getDataSummaryQuery,
@@ -13,5 +14,6 @@ export {
13
14
  stripSummaryPropsContent,
14
15
  buildLoopPropsContent,
15
16
  parseBooleanValues,
16
- getLinkBasedOnValue
17
+ getLinkBasedOnValue,
18
+ getLinkProps
17
19
  };
@@ -6,7 +6,7 @@ const categoryProps = 'id publishedListingPage{id, url}';
6
6
  const checkProps = props =>
7
7
  !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);
8
8
 
9
- const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
9
+ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {
10
10
  const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;
11
11
  const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;
12
12
  const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(
@@ -16,39 +16,55 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null) => {
16
16
  );
17
17
 
18
18
  const allProps = [...typeBasedProps, ...extraProps];
19
-
20
19
  const uniqueProps = [...new Set([...allProps])];
20
+ const basicProps = [];
21
+ const nestedProps = {};
22
+ uniqueProps.forEach(prop => {
23
+ if (prop) {
24
+ if (!prop.includes('.')) {
25
+ basicProps.push(prop);
26
+ return;
27
+ }
28
+ const [base, nested] = prop.split('.');
29
+ if (!nestedProps[base]) nestedProps[base] = [nested];
30
+ else nestedProps[base].push(nested);
31
+ }
32
+ });
33
+
34
+ const complexProps = buildComplexProps(
35
+ shouldAddCategoryProps,
36
+ nestedProps,
37
+ parsedSchema,
38
+ linkProps
39
+ );
21
40
 
22
- const basicProps = uniqueProps
23
- .filter(prop => prop && !prop.includes('.'))
24
- .filter((prop, i, arr) => arr.indexOf(prop) === i);
25
- const complexProps = buildComplexProps(shouldAddCategoryProps, uniqueProps, parsedSchema);
26
41
  return [...basicProps, ...complexProps].join(',');
27
42
  };
28
43
 
29
- const buildComplexProps = (shouldAddCategoryProps, props, { relations }) =>
30
- props
31
- .filter(prop => prop && prop.includes('.'))
32
- .map(nested => nested.split('.')[0])
33
- .filter((prop, i, arr) => arr.indexOf(prop) === i)
34
- .map(base => {
35
- const matchingRelation = relations.find(({ localField }) => localField === base);
36
- const nestedProps = props
37
- .filter(
38
- (extraProp, i, arr) =>
39
- extraProp && extraProp.startsWith(`${base}.`) && arr.indexOf(extraProp) === i
40
- )
41
- .map(nested => nested.split('.')[1]);
42
- if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
43
-
44
- const jointNestedProps = nestedProps.join(',');
45
- if (base === 'category' && shouldAddCategoryProps)
46
- return `${base}{${jointNestedProps}, ${categoryProps}}`;
47
- if (base.includes('published')) {
48
- return `${base}{${jointNestedProps},url}`;
49
- }
50
- return `${base}{${jointNestedProps}}`;
51
- });
44
+ const buildComplexProps = (
45
+ shouldAddCategoryProps,
46
+ props,
47
+ { relations = [], dynamicProperties = {} },
48
+ linkProps
49
+ ) =>
50
+ Object.keys(props).map(base => {
51
+ const nestedProps = props[base];
52
+ const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
53
+ const matchingRelation = relations.find(({ localField }) => localField === base);
54
+ const matchingDynamicProp = Object.keys(dynamicProperties).find(
55
+ dynamicKey => dynamicKey === base
56
+ );
57
+
58
+ if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
59
+ if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
60
+ const jointNestedProps = nestedProps.join(',');
61
+ if (base === 'category' && shouldAddCategoryProps)
62
+ return `${base}{${jointNestedProps}, ${categoryProps}}`;
63
+ if (base.includes('published')) {
64
+ return `${base}{${jointNestedProps},url}`;
65
+ }
66
+ return `${base}{${jointNestedProps}}`;
67
+ });
52
68
 
53
69
  const getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {
54
70
  const isCard = !!cardOptions;
@@ -83,12 +99,9 @@ const getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured
83
99
 
84
100
  const getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {
85
101
  if (!shouldAddCategoryProps) return [];
86
-
87
102
  const props = [];
88
-
89
- if (hasCategory) {
103
+ if (hasCategory)
90
104
  props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');
91
- }
92
105
 
93
106
  if (hasPreheader) {
94
107
  props.push(`${PREHEADER_PROP}{name}`);
@@ -0,0 +1,35 @@
1
+ import '@testing-library/jest-dom/extend-expect';
2
+ import getLinkProps from '../../../../../../src/components/DataSummary/helpers/get-link-props';
3
+
4
+ describe('get link props helper', () => {
5
+ const noProps = getLinkProps();
6
+
7
+ const withEnableLink = getLinkProps([
8
+ { enableLink: true, propertiesToDisplay: ['prop1', 'prop2'] }
9
+ ]);
10
+
11
+ const multipleProps = getLinkProps([
12
+ { enableLink: true, propertiesToDisplay: ['prop1', 'prop2'] },
13
+ { enableLink: true, propertiesToDisplay: ['prop3'] },
14
+ { enableLink: true, propertiesToDisplay: [] },
15
+ { enableLink: false, propertiesToDisplay: ['prop4'] }
16
+ ]);
17
+
18
+ it('should always return an array', () => {
19
+ expect(Array.isArray(noProps)).toEqual(true);
20
+ expect(Array.isArray(withEnableLink)).toEqual(true);
21
+ expect(Array.isArray(multipleProps)).toEqual(true);
22
+ });
23
+
24
+ it('should return empty array if no props are passed', () => {
25
+ expect(noProps).toEqual([]);
26
+ });
27
+
28
+ it('should return props if enableLink is true', () => {
29
+ expect(withEnableLink).toEqual(['prop1', 'prop2']);
30
+ });
31
+
32
+ it('should return props if enableLink is true and props are nested', () => {
33
+ expect(multipleProps).toEqual(['prop1', 'prop2', 'prop3']);
34
+ });
35
+ });
@@ -4,9 +4,6 @@ import getLinkToPublishedContent from '../../../../../../src/components/DataSumm
4
4
  describe('get link to published content', () => {
5
5
  const publishedKey = 'content.published';
6
6
  const content = { url: 'url' };
7
- it('should be a function', () => {
8
- expect(typeof getLinkToPublishedContent).toEqual('function');
9
- });
10
7
 
11
8
  it('should always return a string', () => {
12
9
  const result = getLinkToPublishedContent();