@blaze-cms/react-page-builder 0.128.0-project-admin-customisations.0 → 0.128.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/CHANGELOG.md +46 -373
  2. package/lib/components/ContentGroupSection/ContentGroupSection.js +4 -1
  3. package/lib/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  4. package/lib/components/DataSummary/DataSummaryFactory.js +2 -1
  5. package/lib/components/DataSummary/DataSummaryFactory.js.map +1 -1
  6. package/lib/components/DataSummary/helpers/get-link-props.js +23 -0
  7. package/lib/components/DataSummary/helpers/get-link-props.js.map +1 -0
  8. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +7 -12
  9. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  10. package/lib/components/DataSummary/helpers/index.js +7 -0
  11. package/lib/components/DataSummary/helpers/index.js.map +1 -1
  12. package/lib/helpers/build-props-query.js +34 -24
  13. package/lib/helpers/build-props-query.js.map +1 -1
  14. package/lib-es/components/ContentGroupSection/ContentGroupSection.js +8 -4
  15. package/lib-es/components/ContentGroupSection/ContentGroupSection.js.map +1 -1
  16. package/lib-es/components/DataSummary/DataSummaryFactory.js +3 -2
  17. package/lib-es/components/DataSummary/DataSummaryFactory.js.map +1 -1
  18. package/lib-es/components/DataSummary/helpers/get-link-props.js +6 -0
  19. package/lib-es/components/DataSummary/helpers/get-link-props.js.map +1 -0
  20. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +4 -7
  21. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  22. package/lib-es/components/DataSummary/helpers/index.js +2 -1
  23. package/lib-es/components/DataSummary/helpers/index.js.map +1 -1
  24. package/lib-es/helpers/build-props-query.js +22 -9
  25. package/lib-es/helpers/build-props-query.js.map +1 -1
  26. package/package.json +10 -10
  27. package/src/components/ContentGroupSection/ContentGroupSection.js +1 -1
  28. package/src/components/DataSummary/DataSummaryFactory.js +3 -2
  29. package/src/components/DataSummary/helpers/get-link-props.js +7 -0
  30. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -8
  31. package/src/components/DataSummary/helpers/index.js +3 -1
  32. package/src/helpers/build-props-query.js +46 -33
  33. package/tests/unit/src/components/DataSummary/helpers/get-link-props.test.js +35 -0
  34. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +0 -3
@@ -7,12 +7,15 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
  require("core-js/modules/es.function.name.js");
10
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
10
11
  var _react = _interopRequireDefault(require("react"));
11
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
12
13
  var _helpers = require("../../helpers");
14
+ var _excluded = ["children", "name"];
13
15
  var ContentGroupSection = function ContentGroupSection(_ref) {
14
16
  var children = _ref.children,
15
- name = _ref.name;
17
+ name = _ref.name,
18
+ props = (0, _objectWithoutProperties2["default"])(_ref, _excluded);
16
19
  if (!(0, _helpers.hasChildren)(children)) return null;
17
20
  return /*#__PURE__*/_react["default"].createElement("div", {
18
21
  key: name,
@@ -1 +1 @@
1
- {"version":3,"file":"ContentGroupSection.js","names":["_react","_interopRequireDefault","require","_propTypes","_helpers","ContentGroupSection","_ref","children","name","hasChildren","createElement","key","className","propTypes","PropTypes","oneOfType","arrayOf","node","string","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name }) => {\n if (!hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":";;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAMG,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAAC,IAAA,EAA2B;EAAA,IAArBC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;EAC3C,IAAI,CAAC,IAAAC,oBAAW,EAACF,QAAQ,CAAC,EAAE,OAAO,IAAI;EAEvC,oBACEP,MAAA,YAAAU,aAAA;IAAKC,GAAG,EAAEH,IAAK;IAACI,SAAS,EAAC;EAAuB,GAC9CL,QAAQ,CACL;AAEV,CAAC;AAEDF,mBAAmB,CAACQ,SAAS,GAAG;EAC9BN,QAAQ,EAAEO,qBAAS,CAACC,SAAS,CAAC,CAACD,qBAAS,CAACE,OAAO,CAACF,qBAAS,CAACG,IAAI,CAAC,EAAEH,qBAAS,CAACG,IAAI,CAAC,CAAC;EAClFT,IAAI,EAAEM,qBAAS,CAACI;AAClB,CAAC;AAEDb,mBAAmB,CAACc,YAAY,GAAG;EAAEZ,QAAQ,EAAE,IAAI;EAAEC,IAAI,EAAE;AAAG,CAAC;AAAC,IAAAY,QAAA,GAEjDf,mBAAmB;AAAAgB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"ContentGroupSection.js","names":["_react","_interopRequireDefault","require","_propTypes","_helpers","_excluded","ContentGroupSection","_ref","children","name","props","_objectWithoutProperties2","hasChildren","createElement","key","className","propTypes","PropTypes","oneOfType","arrayOf","node","string","defaultProps","_default","exports"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name, ...props }) => {\n if (!hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAA4C,IAAAG,SAAA;AAE5C,IAAMC,mBAAmB,GAAG,SAAtBA,mBAAmBA,CAAAC,IAAA,EAAqC;EAAA,IAA/BC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;IAAEC,IAAI,GAAAF,IAAA,CAAJE,IAAI;IAAKC,KAAK,OAAAC,yBAAA,aAAAJ,IAAA,EAAAF,SAAA;EACrD,IAAI,CAAC,IAAAO,oBAAW,EAACJ,QAAQ,CAAC,EAAE,OAAO,IAAI;EAEvC,oBACER,MAAA,YAAAa,aAAA;IAAKC,GAAG,EAAEL,IAAK;IAACM,SAAS,EAAC;EAAuB,GAC9CP,QAAQ,CACL;AAEV,CAAC;AAEDF,mBAAmB,CAACU,SAAS,GAAG;EAC9BR,QAAQ,EAAES,qBAAS,CAACC,SAAS,CAAC,CAACD,qBAAS,CAACE,OAAO,CAACF,qBAAS,CAACG,IAAI,CAAC,EAAEH,qBAAS,CAACG,IAAI,CAAC,CAAC;EAClFX,IAAI,EAAEQ,qBAAS,CAACI;AAClB,CAAC;AAEDf,mBAAmB,CAACgB,YAAY,GAAG;EAAEd,QAAQ,EAAE,IAAI;EAAEC,IAAI,EAAE;AAAG,CAAC;AAAC,IAAAc,QAAA,GAEjDjB,mBAAmB;AAAAkB,OAAA,cAAAD,QAAA"}
@@ -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,uBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAC,sBAAA,CAAAH,OAAA;A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AiB,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,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,QAAA,GAAAN,OAAA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AAE,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,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAAC,UAAAC,IAAI;IAAA,OAAIA,IAAI,KAAKC,sBA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K,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,OAAIA,IAAI,KAAKC,sBAAW;EAAA,EAAC,CAACC,MAAM,CAAC;AAAA;AAE7E,IAAMC,eAAe,GAAG,SAAlBA,eA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Ac,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"}
@@ -1,10 +1,14 @@
1
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
2
+ const _excluded = ["children", "name"];
1
3
  import React from 'react';
2
4
  import PropTypes from 'prop-types';
3
5
  import { hasChildren } from '../../helpers';
4
- const ContentGroupSection = ({
5
- children,
6
- name
7
- }) => {
6
+ const ContentGroupSection = _ref => {
7
+ let {
8
+ children,
9
+ name
10
+ } = _ref,
11
+ props = _objectWithoutProperties(_ref, _excluded);
8
12
  if (!hasChildren(children)) return null;
9
13
  return /*#__PURE__*/React.createElement("div", {
10
14
  key: name,
@@ -1 +1 @@
1
- {"version":3,"file":"ContentGroupSection.js","names":["React","PropTypes","hasChildren","ContentGroupSection","children","name","createElement","key","className","propTypes","oneOfType","arrayOf","node","string","defaultProps"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name }) => {\n if (!hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,mBAAmB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAK,CAAC,KAAK;EAClD,IAAI,CAACH,WAAW,CAACE,QAAQ,CAAC,EAAE,OAAO,IAAI;EAEvC,oBACEJ,KAAA,CAAAM,aAAA;IAAKC,GAAG,EAAEF,IAAK;IAACG,SAAS,EAAC;EAAuB,GAC9CJ,QAAQ,CACL;AAEV,CAAC;AAEDD,mBAAmB,CAACM,SAAS,GAAG;EAC9BL,QAAQ,EAAEH,SAAS,CAACS,SAAS,CAAC,CAACT,SAAS,CAACU,OAAO,CAACV,SAAS,CAACW,IAAI,CAAC,EAAEX,SAAS,CAACW,IAAI,CAAC,CAAC;EAClFP,IAAI,EAAEJ,SAAS,CAACY;AAClB,CAAC;AAEDV,mBAAmB,CAACW,YAAY,GAAG;EAAEV,QAAQ,EAAE,IAAI;EAAEC,IAAI,EAAE;AAAG,CAAC;AAE/D,eAAeF,mBAAmB"}
1
+ {"version":3,"file":"ContentGroupSection.js","names":["React","PropTypes","hasChildren","ContentGroupSection","_ref","children","name","props","_objectWithoutProperties","_excluded","createElement","key","className","propTypes","oneOfType","arrayOf","node","string","defaultProps"],"sources":["../../../src/components/ContentGroupSection/ContentGroupSection.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { hasChildren } from '../../helpers';\n\nconst ContentGroupSection = ({ children, name, ...props }) => {\n if (!hasChildren(children)) return null;\n\n return (\n <div key={name} className=\"content-group-section\">\n {children}\n </div>\n );\n};\n\nContentGroupSection.propTypes = {\n children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),\n name: PropTypes.string\n};\n\nContentGroupSection.defaultProps = { children: null, name: '' };\n\nexport default ContentGroupSection;\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,WAAW,QAAQ,eAAe;AAE3C,MAAMC,mBAAmB,GAAGC,IAAA,IAAkC;EAAA,IAAjC;MAAEC,QAAQ;MAAEC;IAAe,CAAC,GAAAF,IAAA;IAAPG,KAAK,GAAAC,wBAAA,CAAAJ,IAAA,EAAAK,SAAA;EACrD,IAAI,CAACP,WAAW,CAACG,QAAQ,CAAC,EAAE,OAAO,IAAI;EAEvC,oBACEL,KAAA,CAAAU,aAAA;IAAKC,GAAG,EAAEL,IAAK;IAACM,SAAS,EAAC;EAAuB,GAC9CP,QAAQ,CACL;AAEV,CAAC;AAEDF,mBAAmB,CAACU,SAAS,GAAG;EAC9BR,QAAQ,EAAEJ,SAAS,CAACa,SAAS,CAAC,CAACb,SAAS,CAACc,OAAO,CAACd,SAAS,CAACe,IAAI,CAAC,EAAEf,SAAS,CAACe,IAAI,CAAC,CAAC;EAClFV,IAAI,EAAEL,SAAS,CAACgB;AAClB,CAAC;AAEDd,mBAAmB,CAACe,YAAY,GAAG;EAAEb,QAAQ,EAAE,IAAI;EAAEC,IAAI,EAAE;AAAG,CAAC;AAE/D,eAAeH,mBAAmB"}
@@ -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;AA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AAA,CAAChC,iBAAiB;IAChB8B,QAAQ,EAAEA,QAAS;IACnBzB,cAAc,EAAEA,cAAe;IAC/BM,cAAc,EAAEA,cAAe;IAC/BC,SAAS,EAAEA,SAAU;IACrBqB,KAAK,EAAEJ,gBAAiB;IACxBvB,IAAI,EAAEA,IAAK;IACXE,YAAY,EAAEA,YAAa;IAC3BC,QAAQ,EAAEA,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,U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M;EAC9B5B,QAAQ,EAAEhB,SAAS,CAAC4C,MAAM;EAC1B3B,YAAY,EAAEjB,SAAS,CAAC4C,MAAM;EAC9B1B,cAAc,EAAElB,SAAS,CAAC6C,KAAK;EAC/B1B,SAAS,EAAEnB,SAAS,CAAC+C;AACvB,CAAC;AAEDvC,kBAAkB,CAACwC,YAAY,GAAG;EAChCnC,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"}
@@ -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);