@blaze-cms/react-page-builder 0.130.1 → 0.131.0-admin-updates.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/lib/components/Card/CardsRender.js +13 -6
- package/lib/components/Card/CardsRender.js.map +1 -1
- package/lib/components/Card/helpers/get-updated-items-to-display.js +55 -0
- package/lib/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib/components/Card/helpers/index.js +7 -0
- package/lib/components/Card/helpers/index.js.map +1 -1
- package/lib/components/Code/Code.js +7 -3
- package/lib/components/Code/Code.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js +3 -1
- package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -2
- package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib/components/List/ListFactory.js +16 -11
- package/lib/components/List/ListFactory.js.map +1 -1
- package/lib/components/List/helpers/get-list-query.js +43 -0
- package/lib/components/List/helpers/get-list-query.js.map +1 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js +21 -0
- package/lib/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib/components/List/helpers/index.js +14 -0
- package/lib/components/List/helpers/index.js.map +1 -1
- package/lib/components/List/helpers/strip-query-key.js +14 -0
- package/lib/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib/components/SearchContent/SearchContent.js +8 -6
- package/lib/components/SearchContent/SearchContent.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +17 -11
- package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/SearchFilter/SearchFilterContainer.js +63 -85
- package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js +3 -1
- package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib/components/SearchFilter/helpers/build-new-url.js +17 -0
- package/lib/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js +48 -0
- package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +32 -0
- package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js +31 -0
- package/lib/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib/components/SearchFilter/helpers/index.js +18 -11
- package/lib/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib/components/SearchFilter/index.js.map +1 -1
- package/lib/components/SearchFilter/searchFilterReducer.js +45 -0
- package/lib/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib/components/SearchFilterSort/SearchFilterSort.js +31 -11
- package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +19 -5
- package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib/components/SearchFilterSort/helpers/update-sort.js +9 -5
- package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib/helpers/build-inherited-filters.js +2 -0
- package/lib/helpers/build-inherited-filters.js.map +1 -1
- package/lib/helpers/build-props-query.js +5 -2
- package/lib/helpers/build-props-query.js.map +1 -1
- package/lib/helpers/build-query-key.js +16 -0
- package/lib/helpers/build-query-key.js.map +1 -0
- package/lib/helpers/build-set-filters.js +5 -1
- package/lib/helpers/build-set-filters.js.map +1 -1
- package/lib/helpers/get-query-filters.js +6 -8
- package/lib/helpers/get-query-filters.js.map +1 -1
- package/lib/helpers/get-query-props.js +13 -2
- package/lib/helpers/get-query-props.js.map +1 -1
- package/lib/helpers/get-wrapped-value-with-link.js +2 -3
- package/lib/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib/helpers/index.js +14 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/parse-props-to-display.js +13 -8
- package/lib/helpers/parse-props-to-display.js.map +1 -1
- package/lib/helpers/process-data-summary-value.js +56 -0
- package/lib/helpers/process-data-summary-value.js.map +1 -0
- package/lib-es/components/Card/CardsRender.js +14 -7
- package/lib-es/components/Card/CardsRender.js.map +1 -1
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
- package/lib-es/components/Card/helpers/index.js +1 -0
- package/lib-es/components/Card/helpers/index.js.map +1 -1
- package/lib-es/components/Code/Code.js +8 -4
- package/lib-es/components/Code/Code.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +3 -1
- package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js +4 -3
- package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
- package/lib-es/components/List/ListFactory.js +16 -12
- package/lib-es/components/List/ListFactory.js.map +1 -1
- package/lib-es/components/List/helpers/get-list-query.js +24 -0
- package/lib-es/components/List/helpers/get-list-query.js.map +1 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js +12 -0
- package/lib-es/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
- package/lib-es/components/List/helpers/index.js +2 -0
- package/lib-es/components/List/helpers/index.js.map +1 -1
- package/lib-es/components/List/helpers/strip-query-key.js +6 -0
- package/lib-es/components/List/helpers/strip-query-key.js.map +1 -0
- package/lib-es/components/SearchContent/SearchContent.js +8 -6
- package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +18 -11
- package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
- package/lib-es/components/SearchFilter/SearchFilterContainer.js +47 -72
- package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js +2 -0
- package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
- package/lib-es/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/lib-es/components/SearchFilter/helpers/build-new-url.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js +30 -0
- package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +18 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js +19 -0
- package/lib-es/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
- package/lib-es/components/SearchFilter/helpers/index.js +5 -4
- package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
- package/lib-es/components/SearchFilter/index.js +2 -2
- package/lib-es/components/SearchFilter/index.js.map +1 -1
- package/lib-es/components/SearchFilter/searchFilterReducer.js +28 -0
- package/lib-es/components/SearchFilter/searchFilterReducer.js.map +1 -0
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js +26 -10
- package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +21 -4
- package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js +8 -4
- package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
- package/lib-es/helpers/build-inherited-filters.js +2 -0
- package/lib-es/helpers/build-inherited-filters.js.map +1 -1
- package/lib-es/helpers/build-props-query.js +4 -2
- package/lib-es/helpers/build-props-query.js.map +1 -1
- package/lib-es/helpers/build-query-key.js +7 -0
- package/lib-es/helpers/build-query-key.js.map +1 -0
- package/lib-es/helpers/build-set-filters.js +5 -1
- package/lib-es/helpers/build-set-filters.js.map +1 -1
- package/lib-es/helpers/get-query-filters.js +6 -8
- package/lib-es/helpers/get-query-filters.js.map +1 -1
- package/lib-es/helpers/get-query-props.js +10 -2
- package/lib-es/helpers/get-query-props.js.map +1 -1
- package/lib-es/helpers/get-wrapped-value-with-link.js +2 -2
- package/lib-es/helpers/get-wrapped-value-with-link.js.map +1 -1
- package/lib-es/helpers/index.js +2 -0
- package/lib-es/helpers/index.js.map +1 -1
- package/lib-es/helpers/parse-props-to-display.js +12 -9
- package/lib-es/helpers/parse-props-to-display.js.map +1 -1
- package/lib-es/helpers/process-data-summary-value.js +36 -0
- package/lib-es/helpers/process-data-summary-value.js.map +1 -0
- package/package.json +10 -10
- package/src/components/Card/CardsRender.js +27 -7
- package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
- package/src/components/Card/helpers/index.js +1 -0
- package/src/components/Code/Code.js +7 -3
- package/src/components/DataSummary/helpers/build-loop-props-content.js +4 -1
- package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +6 -3
- package/src/components/List/ListFactory.js +25 -15
- package/src/components/List/helpers/get-list-query.js +28 -0
- package/src/components/List/helpers/get-list-specific-search-filter.js +10 -0
- package/src/components/List/helpers/index.js +2 -0
- package/src/components/List/helpers/strip-query-key.js +6 -0
- package/src/components/SearchContent/SearchContent.js +8 -6
- package/src/components/SearchFilter/SearchFilter/SearchFilter.js +21 -12
- package/src/components/SearchFilter/SearchFilterContainer.js +57 -69
- package/src/components/SearchFilter/helpers/build-filters-query.js +9 -1
- package/src/components/SearchFilter/helpers/build-new-url.js +8 -0
- package/src/components/SearchFilter/helpers/build-url-query.js +31 -0
- package/src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +17 -0
- package/src/components/SearchFilter/helpers/get-filter-values.js +21 -0
- package/src/components/SearchFilter/helpers/index.js +9 -7
- package/src/components/SearchFilter/index.js +2 -2
- package/src/components/SearchFilter/searchFilterReducer.js +15 -0
- package/src/components/SearchFilterSort/SearchFilterSort.js +18 -8
- package/src/components/SearchFilterSort/helpers/handle-sort-update.js +14 -5
- package/src/components/SearchFilterSort/helpers/update-sort.js +7 -3
- package/src/helpers/build-inherited-filters.js +3 -1
- package/src/helpers/build-props-query.js +4 -2
- package/src/helpers/build-query-key.js +7 -0
- package/src/helpers/build-set-filters.js +2 -1
- package/src/helpers/get-query-filters.js +4 -4
- package/src/helpers/get-query-props.js +12 -4
- package/src/helpers/get-wrapped-value-with-link.js +6 -3
- package/src/helpers/index.js +2 -0
- package/src/helpers/parse-props-to-display.js +25 -21
- package/src/helpers/process-data-summary-value.js +22 -0
- package/tests/helpers/mocks.js +3 -5
- package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
- package/tests/unit/src/components/Code/Code.test.js +5 -0
- package/tests/unit/src/components/Code/__snapshots__/Code.test.js.snap +8 -0
- package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +9 -0
- package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +1 -7
- package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +10 -10
- package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +24 -7
- package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +10 -10
- package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +4 -1
- package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +26 -19
- package/tests/unit/src/components/SearchFilterSort/helpers/update-sort.test.js +10 -1
- package/tests/unit/src/helpers/__snapshots__/get-wrapped-value-with-link.test.js.snap +18 -0
- package/tests/unit/src/helpers/build-props-query.test.js +25 -0
- package/tests/unit/src/helpers/get-wrapped-value-with-link.test.js +2 -2
- package/tests/unit/src/helpers/parse-props-to-display.test.js +4 -0
- package/tests/unit/src/helpers/prcoess-data-summary-value.test.js +52 -0
- package/lib/components/SearchFilter/helpers/build-new-query.js +0 -15
- package/lib/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/build-query.js +0 -37
- package/lib/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +0 -43
- package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/build-query.js +0 -23
- package/lib-es/components/SearchFilter/helpers/build-query.js.map +0 -1
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +0 -26
- package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
- package/src/components/SearchFilter/helpers/build-new-query.js +0 -6
- package/src/components/SearchFilter/helpers/build-query.js +0 -26
- package/src/components/SearchFilter/helpers/get-initial-filter-values.js +0 -30
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
-
const _excluded = ["code", "parserOptions"];
|
|
3
|
+
const _excluded = ["code", "parserOptions", "disableWrapper"];
|
|
4
4
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
import React, { memo } from 'react';
|
|
@@ -14,13 +14,15 @@ import { wrapScriptTags } from './helpers';
|
|
|
14
14
|
const Code = memo(_ref => {
|
|
15
15
|
let {
|
|
16
16
|
code: embedCode,
|
|
17
|
-
parserOptions
|
|
17
|
+
parserOptions,
|
|
18
|
+
disableWrapper
|
|
18
19
|
} = _ref,
|
|
19
20
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
20
21
|
if (!embedCode) return null;
|
|
21
22
|
const parsedCode = parseHTML(embedCode, parserOptions);
|
|
22
23
|
const wrappedCode = wrapScriptTags(parsedCode);
|
|
23
24
|
const modifiers = getClassModifiers(CODE, _objectSpread({}, otherProps));
|
|
25
|
+
if (disableWrapper) return wrappedCode;
|
|
24
26
|
return /*#__PURE__*/React.createElement(Wrapper, {
|
|
25
27
|
modifiers: modifiers
|
|
26
28
|
}, wrappedCode);
|
|
@@ -28,12 +30,14 @@ const Code = memo(_ref => {
|
|
|
28
30
|
Code.propTypes = {
|
|
29
31
|
code: PropTypes.string,
|
|
30
32
|
modifier: PropTypes.string,
|
|
31
|
-
parserOptions: PropTypes.object
|
|
33
|
+
parserOptions: PropTypes.object,
|
|
34
|
+
disableWrapper: PropTypes.bool
|
|
32
35
|
};
|
|
33
36
|
Code.defaultProps = {
|
|
34
37
|
code: '',
|
|
35
38
|
modifier: '',
|
|
36
|
-
parserOptions: {}
|
|
39
|
+
parserOptions: {},
|
|
40
|
+
disableWrapper: false
|
|
37
41
|
};
|
|
38
42
|
export default withTitle(Code);
|
|
39
43
|
//# sourceMappingURL=Code.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Code.js","names":["React","memo","PropTypes","parseHTML","Wrapper","withTitle","getClassModifiers","CODE","wrapScriptTags","Code","_ref","code","embedCode","parserOptions","otherProps","_objectWithoutProperties","_excluded","parsedCode","wrappedCode","modifiers","_objectSpread","createElement","propTypes","string","modifier","object","defaultProps"],"sources":["../../../src/components/Code/Code.js"],"sourcesContent":["import React, { memo } from 'react';\nimport PropTypes from 'prop-types';\nimport parseHTML from 'html-react-parser';\nimport Wrapper from '../Wrapper';\nimport { withTitle } from '../../HOC';\nimport { getClassModifiers } from '../../utils';\nimport { CODE } from '../../constants';\nimport { wrapScriptTags } from './helpers';\n\nconst Code = memo(({ code: embedCode, parserOptions, ...otherProps }) => {\n if (!embedCode) return null;\n\n const parsedCode = parseHTML(embedCode, parserOptions);\n const wrappedCode = wrapScriptTags(parsedCode);\n const modifiers = getClassModifiers(CODE, { ...otherProps });\n\n return <Wrapper modifiers={modifiers}>{wrappedCode}</Wrapper>;\n});\n\nCode.propTypes = {\n code: PropTypes.string,\n modifier: PropTypes.string,\n parserOptions: PropTypes.object\n};\n\nCode.defaultProps = {\n code: '',\n modifier: '',\n parserOptions: {}\n};\n\nexport default withTitle(Code);\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,IAAI,GAAGR,IAAI,CAACS,IAAA,
|
|
1
|
+
{"version":3,"file":"Code.js","names":["React","memo","PropTypes","parseHTML","Wrapper","withTitle","getClassModifiers","CODE","wrapScriptTags","Code","_ref","code","embedCode","parserOptions","disableWrapper","otherProps","_objectWithoutProperties","_excluded","parsedCode","wrappedCode","modifiers","_objectSpread","createElement","propTypes","string","modifier","object","bool","defaultProps"],"sources":["../../../src/components/Code/Code.js"],"sourcesContent":["import React, { memo } from 'react';\nimport PropTypes from 'prop-types';\nimport parseHTML from 'html-react-parser';\nimport Wrapper from '../Wrapper';\nimport { withTitle } from '../../HOC';\nimport { getClassModifiers } from '../../utils';\nimport { CODE } from '../../constants';\nimport { wrapScriptTags } from './helpers';\n\nconst Code = memo(({ code: embedCode, parserOptions, disableWrapper, ...otherProps }) => {\n if (!embedCode) return null;\n\n const parsedCode = parseHTML(embedCode, parserOptions);\n const wrappedCode = wrapScriptTags(parsedCode);\n const modifiers = getClassModifiers(CODE, { ...otherProps });\n\n if (disableWrapper) return wrappedCode;\n\n return <Wrapper modifiers={modifiers}>{wrappedCode}</Wrapper>;\n});\n\nCode.propTypes = {\n code: PropTypes.string,\n modifier: PropTypes.string,\n parserOptions: PropTypes.object,\n disableWrapper: PropTypes.bool\n};\n\nCode.defaultProps = {\n code: '',\n modifier: '',\n parserOptions: {},\n disableWrapper: false\n};\n\nexport default withTitle(Code);\n"],"mappings":";;;;;AAAA,OAAOA,KAAK,IAAIC,IAAI,QAAQ,OAAO;AACnC,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,SAAS,MAAM,mBAAmB;AACzC,OAAOC,OAAO,MAAM,YAAY;AAChC,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,iBAAiB,QAAQ,aAAa;AAC/C,SAASC,IAAI,QAAQ,iBAAiB;AACtC,SAASC,cAAc,QAAQ,WAAW;AAE1C,MAAMC,IAAI,GAAGR,IAAI,CAACS,IAAA,IAAuE;EAAA,IAAtE;MAAEC,IAAI,EAAEC,SAAS;MAAEC,aAAa;MAAEC;IAA8B,CAAC,GAAAJ,IAAA;IAAZK,UAAU,GAAAC,wBAAA,CAAAN,IAAA,EAAAO,SAAA;EAChF,IAAI,CAACL,SAAS,EAAE,OAAO,IAAI;EAE3B,MAAMM,UAAU,GAAGf,SAAS,CAACS,SAAS,EAAEC,aAAa,CAAC;EACtD,MAAMM,WAAW,GAAGX,cAAc,CAACU,UAAU,CAAC;EAC9C,MAAME,SAAS,GAAGd,iBAAiB,CAACC,IAAI,EAAAc,aAAA,KAAON,UAAU,CAAE,CAAC;EAE5D,IAAID,cAAc,EAAE,OAAOK,WAAW;EAEtC,oBAAOnB,KAAA,CAAAsB,aAAA,CAAClB,OAAO;IAACgB,SAAS,EAAEA;EAAU,GAAED,WAAqB,CAAC;AAC/D,CAAC,CAAC;AAEFV,IAAI,CAACc,SAAS,GAAG;EACfZ,IAAI,EAAET,SAAS,CAACsB,MAAM;EACtBC,QAAQ,EAAEvB,SAAS,CAACsB,MAAM;EAC1BX,aAAa,EAAEX,SAAS,CAACwB,MAAM;EAC/BZ,cAAc,EAAEZ,SAAS,CAACyB;AAC5B,CAAC;AAEDlB,IAAI,CAACmB,YAAY,GAAG;EAClBjB,IAAI,EAAE,EAAE;EACRc,QAAQ,EAAE,EAAE;EACZZ,aAAa,EAAE,CAAC,CAAC;EACjBC,cAAc,EAAE;AAClB,CAAC;AAED,eAAeT,SAAS,CAACI,IAAI,CAAC"}
|
|
@@ -3,6 +3,7 @@ import flatten from 'lodash.flatten';
|
|
|
3
3
|
import getLinkToPublishedContent from './get-link-to-published-content';
|
|
4
4
|
import getLoopPropsLimit from './get-loop-props-limit';
|
|
5
5
|
import getPropValue from './get-prop-value';
|
|
6
|
+
import { processDataSummaryValue } from '../../../helpers';
|
|
6
7
|
const getLoopValue = value => {
|
|
7
8
|
const {
|
|
8
9
|
keyField
|
|
@@ -45,8 +46,9 @@ const buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, d
|
|
|
45
46
|
const loopValue = loopValues[key];
|
|
46
47
|
const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];
|
|
47
48
|
if (!propValue) return null;
|
|
49
|
+
const processedValue = processDataSummaryValue(propValue, options);
|
|
48
50
|
const linkToPublishedContent = getLinkToPublishedContent(key, data);
|
|
49
|
-
return [upperFirst(label),
|
|
51
|
+
return [upperFirst(label), processedValue, linkToPublishedContent, modifier];
|
|
50
52
|
});
|
|
51
53
|
})).filter(Boolean);
|
|
52
54
|
loopPropsWithContent.push(propsArray);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-loop-props-content.js","names":["upperFirst","flatten","getLinkToPublishedContent","getLoopPropsLimit","getPropValue","getLoopValue","value","keyField","separateValues","propsToDisplay","loopProps","data","regularValues","loopValues","forEach","options","propertiesToDisplay","prop","isArrayValue","Array","isArray","isLoopableProp","includes","buildLoopPropsContent","limit","loopPropsWithContent","loopLimit","i","propsArray","map","label","modifier","key","loopValue","propValue","linkToPublishedContent","filter","Boolean","push"],"sources":["../../../../src/components/DataSummary/helpers/build-loop-props-content.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport flatten from 'lodash.flatten';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport getLoopPropsLimit from './get-loop-props-limit';\nimport getPropValue from './get-prop-value';\n\nconst getLoopValue = value => {\n const { keyField } = value;\n return value[keyField];\n};\n\nconst separateValues = (propsToDisplay, loopProps, data) => {\n const regularValues = {};\n const loopValues = {};\n\n propsToDisplay.forEach(options => {\n const { propertiesToDisplay } = options;\n propertiesToDisplay.forEach(prop => {\n const value = getPropValue(prop, data, options);\n const isArrayValue = Array.isArray(value);\n if (!value) return;\n const isLoopableProp = loopProps.includes(prop) && isArrayValue;\n\n if (isLoopableProp) {\n loopValues[prop] = value;\n } else {\n regularValues[prop] = value;\n }\n });\n });\n return [regularValues, loopValues];\n};\n\nconst buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, data = {}) => {\n const loopPropsWithContent = [];\n const [regularValues, loopValues] = separateValues(propsToDisplay, loopProps, data);\n\n const loopLimit = getLoopPropsLimit(loopValues, limit);\n\n for (let i = 0; i < loopLimit; i += 1) {\n const propsArray = flatten(\n propsToDisplay.map(options => {\n const { propertiesToDisplay, label, modifier = '' } = options;\n\n return propertiesToDisplay.map(key => {\n const loopValue = loopValues[key];\n const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];\n if (!propValue) return null;\n const linkToPublishedContent = getLinkToPublishedContent(key, data);\n return [upperFirst(label),
|
|
1
|
+
{"version":3,"file":"build-loop-props-content.js","names":["upperFirst","flatten","getLinkToPublishedContent","getLoopPropsLimit","getPropValue","processDataSummaryValue","getLoopValue","value","keyField","separateValues","propsToDisplay","loopProps","data","regularValues","loopValues","forEach","options","propertiesToDisplay","prop","isArrayValue","Array","isArray","isLoopableProp","includes","buildLoopPropsContent","limit","loopPropsWithContent","loopLimit","i","propsArray","map","label","modifier","key","loopValue","propValue","processedValue","linkToPublishedContent","filter","Boolean","push"],"sources":["../../../../src/components/DataSummary/helpers/build-loop-props-content.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport flatten from 'lodash.flatten';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport getLoopPropsLimit from './get-loop-props-limit';\nimport getPropValue from './get-prop-value';\nimport { processDataSummaryValue } from '../../../helpers';\n\nconst getLoopValue = value => {\n const { keyField } = value;\n return value[keyField];\n};\n\nconst separateValues = (propsToDisplay, loopProps, data) => {\n const regularValues = {};\n const loopValues = {};\n\n propsToDisplay.forEach(options => {\n const { propertiesToDisplay } = options;\n propertiesToDisplay.forEach(prop => {\n const value = getPropValue(prop, data, options);\n const isArrayValue = Array.isArray(value);\n if (!value) return;\n const isLoopableProp = loopProps.includes(prop) && isArrayValue;\n\n if (isLoopableProp) {\n loopValues[prop] = value;\n } else {\n regularValues[prop] = value;\n }\n });\n });\n return [regularValues, loopValues];\n};\n\nconst buildLoopPropsContent = (loopProps = [], propsToDisplay = [], limit = 0, data = {}) => {\n const loopPropsWithContent = [];\n const [regularValues, loopValues] = separateValues(propsToDisplay, loopProps, data);\n\n const loopLimit = getLoopPropsLimit(loopValues, limit);\n\n for (let i = 0; i < loopLimit; i += 1) {\n const propsArray = flatten(\n propsToDisplay.map(options => {\n const { propertiesToDisplay, label, modifier = '' } = options;\n\n return propertiesToDisplay.map(key => {\n const loopValue = loopValues[key];\n const propValue = loopValue ? getLoopValue(loopValue[i]) : regularValues[key];\n if (!propValue) return null;\n\n const processedValue = processDataSummaryValue(propValue, options);\n const linkToPublishedContent = getLinkToPublishedContent(key, data);\n return [upperFirst(label), processedValue, linkToPublishedContent, modifier];\n });\n })\n ).filter(Boolean);\n loopPropsWithContent.push(propsArray);\n }\n\n return flatten(loopPropsW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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import upperFirst from 'lodash.upperfirst';
|
|
2
2
|
import flatten from 'lodash.flatten';
|
|
3
|
-
import { isObject } from '../../../helpers';
|
|
3
|
+
import { isObject, processDataSummaryValue } from '../../../helpers';
|
|
4
4
|
import getLinkToPublishedContent from './get-link-to-published-content';
|
|
5
5
|
import getPropValue from './get-prop-value';
|
|
6
6
|
import getLinkBasedOnValue from './get-link-based-on-value';
|
|
@@ -25,8 +25,9 @@ const buildPropsToDisplayWithContent = (props, propsToDisplay = []) => {
|
|
|
25
25
|
if (!key) return null;
|
|
26
26
|
const objPropValue = getPropValue(key, props, options);
|
|
27
27
|
if (!objPropValue) return null;
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const processedValue = processDataSummaryValue(objPropValue, options);
|
|
29
|
+
const link = getLink(enableLink, key, props, processedValue);
|
|
30
|
+
return [upperFirst(label), processedValue, link, modifier];
|
|
30
31
|
});
|
|
31
32
|
})).filter(Boolean);
|
|
32
33
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-props-to-display-with-content.js","names":["upperFirst","flatten","isObject","getLinkToPublishedContent","getPropValue","getLinkBasedOnValue","buildPropsToDisplayWithContent","props","propsToDisplay","map","key","propValue","propName","split","join","filter","Boolean","options","propertiesToDisplay","label","modifier","enableLink","objPropValue","link","getLink"],"sources":["../../../../src/components/DataSummary/helpers/build-props-to-display-with-content.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport flatten from 'lodash.flatten';\nimport { isObject } from '../../../helpers';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport getPropValue from './get-prop-value';\nimport getLinkBasedOnValue from './get-link-based-on-value';\n\nconst buildPropsToDisplayWithContent = (props, propsToDisplay = []) => {\n if (!isObject(propsToDisplay[0])) {\n return propsToDisplay\n .map(key => {\n if (!key) return null;\n const propValue = getPropValue(key, props);\n if (!propValue) return null;\n const propName = key.split('.').join(' ');\n return [upperFirst(propName), propValue, '', ''];\n })\n .filter(Boolean);\n }\n\n return flatten(\n propsToDisplay.map(options => {\n const { propertiesToDisplay, label, modifier = '', enableLink } = options;\n return propertiesToDisplay.map(key => {\n if (!key) return null;\n\n const objPropValue = getPropValue(key, props, options);\n if (!objPropValue) return null;\n\n const link = getLink(enableLink, key, props,
|
|
1
|
+
{"version":3,"file":"build-props-to-display-with-content.js","names":["upperFirst","flatten","isObject","processDataSummaryValue","getLinkToPublishedContent","getPropValue","getLinkBasedOnValue","buildPropsToDisplayWithContent","props","propsToDisplay","map","key","propValue","propName","split","join","filter","Boolean","options","propertiesToDisplay","label","modifier","enableLink","objPropValue","processedValue","link","getLink"],"sources":["../../../../src/components/DataSummary/helpers/build-props-to-display-with-content.js"],"sourcesContent":["import upperFirst from 'lodash.upperfirst';\nimport flatten from 'lodash.flatten';\nimport { isObject, processDataSummaryValue } from '../../../helpers';\nimport getLinkToPublishedContent from './get-link-to-published-content';\nimport getPropValue from './get-prop-value';\nimport getLinkBasedOnValue from './get-link-based-on-value';\n\nconst buildPropsToDisplayWithContent = (props, propsToDisplay = []) => {\n if (!isObject(propsToDisplay[0])) {\n return propsToDisplay\n .map(key => {\n if (!key) return null;\n const propValue = getPropValue(key, props);\n if (!propValue) return null;\n const propName = key.split('.').join(' ');\n return [upperFirst(propName), propValue, '', ''];\n })\n .filter(Boolean);\n }\n\n return flatten(\n propsToDisplay.map(options => {\n const { propertiesToDisplay, label, modifier = '', enableLink } = options;\n return propertiesToDisplay.map(key => {\n if (!key) return null;\n\n const objPropValue = getPropValue(key, props, options);\n if (!objPropValue) return null;\n\n const processedValue = processDataSummaryValue(objPropValue, options);\n\n const link = getLink(enableLink, key, props, processedValue);\n\n return [upperFirst(label), processedValue, link, modifier];\n });\n })\n ).filter(Boolean);\n};\n\nexport default buildPropsToDisplayWithContent;\n\nfunction getLink(enableLink, key, props, objPropValue) {\n let link = '';\n if (enableLink) {\n link = getLinkToPublishedContent(key, props);\n if (!link) {\n link = getL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E9B,MAAMC,cAAc,GAAGrB,uBAAuB,CAACoB,YAAY,EAAEL,OAAO,CAAC;MAErE,MAAMO,IAAI,GAAGC,OAAO,CAACJ,UAAU,EAAEX,GAAG,EAAEH,KAAK,EAAEgB,cAAc,CAAC;MAE5D,OAAO,CAACxB,UAAU,CAACoB,KAAK,CAAC,EAAEI,cAAc,EAAEC,IAAI,EAAEJ,QAAQ,CAAC;IAC5D,CAAC,CAAC;EACJ,CAAC,CACH,CAAC,CAACL,MAAM,CAACC,OAAO,CAAC;AACnB,CAAC;AAED,eAAeV,8BAA8B;AAE7C,SAASmB,OAAOA,CAACJ,UAAU,EAAEX,GAAG,EAAEH,KAAK,EAAEe,YAAY,EAAE;EACrD,IAAIE,IAAI,GAAG,EAAE;EACb,IAAIH,UAAU,EAAE;IACdG,IAAI,GAAGrB,yBAAyB,CAACO,GAAG,EAAEH,KAAK,CAAC;IAC5C,IAAI,CAACiB,IAAI,EAAE;MACTA,IAAI,GAAGnB,mBAAmB,CAACiB,YAAY,CAAC;IAC1C;EACF;EACA,OAAOE,IAAI;AACb"}
|
|
@@ -10,7 +10,7 @@ import { MainContext } from '@blaze-cms/nextjs-components';
|
|
|
10
10
|
import { generateSingleItemQuery, getItemList } from '../../application/query';
|
|
11
11
|
import ListBuilder from './ListBuilder';
|
|
12
12
|
import { AZ_LIST_TYPE } from './constants';
|
|
13
|
-
import { getAzQueryFilter, getSortProps, hasRequiredItemListDetails } from './helpers';
|
|
13
|
+
import { getAzQueryFilter, getSortProps, hasRequiredItemListDetails, getListSpecificSearchFilter, getListQuery } from './helpers';
|
|
14
14
|
import { getGenericProps, getRequiredSchemas, checkForError, getUnpublishedEntityName, getPaginationIndex, getSearchFilterType, getElasticsearchOperator, buildSearchValuesText, getQueryFilters, getInheritedFilters, getQueryProps } from '../../helpers';
|
|
15
15
|
import { getItemListId, getItemListIds } from '../ItemList/helpers';
|
|
16
16
|
import { useGetEntitySchemasAsObj } from '../../hooks';
|
|
@@ -27,7 +27,7 @@ const ListFactory = props => {
|
|
|
27
27
|
type,
|
|
28
28
|
sortby: defaultSortBy,
|
|
29
29
|
sort: defaultSort,
|
|
30
|
-
|
|
30
|
+
allSearchFilters,
|
|
31
31
|
operator: filterOperator,
|
|
32
32
|
sortProperties,
|
|
33
33
|
itemListName
|
|
@@ -40,15 +40,19 @@ const ListFactory = props => {
|
|
|
40
40
|
asPath
|
|
41
41
|
} = router;
|
|
42
42
|
const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');
|
|
43
|
+
const [searchFilter, hasListSpecificFilters] = getListSpecificSearchFilter(allSearchFilters, name);
|
|
43
44
|
const {
|
|
44
45
|
query,
|
|
45
46
|
url,
|
|
46
47
|
query: {
|
|
47
|
-
sort: querySort,
|
|
48
|
-
sortby: querySortBy,
|
|
49
48
|
itemListId: queryItemListId
|
|
50
49
|
} = {}
|
|
51
50
|
} = parseUrl(parsedQuery);
|
|
51
|
+
const updatedQuery = getListQuery(query, hasListSpecificFilters, name);
|
|
52
|
+
const {
|
|
53
|
+
sort: querySort,
|
|
54
|
+
sortby: querySortBy
|
|
55
|
+
} = updatedQuery;
|
|
52
56
|
const {
|
|
53
57
|
sortbyFilters,
|
|
54
58
|
updatedSortProperties
|
|
@@ -65,8 +69,8 @@ const ListFactory = props => {
|
|
|
65
69
|
itemId: parentId
|
|
66
70
|
} = parent;
|
|
67
71
|
const updatedParentEntity = getUnpublishedEntityName(parentEntity);
|
|
68
|
-
const paginationIndex = getPaginationIndex(
|
|
69
|
-
const azFilter = getAzQueryFilter(
|
|
72
|
+
const paginationIndex = getPaginationIndex(updatedQuery, name);
|
|
73
|
+
const azFilter = getAzQueryFilter(updatedQuery, name);
|
|
70
74
|
const entitiesToUse = entities && entities.length ? entities : [legacyEntity];
|
|
71
75
|
const [filterEntity] = entitiesToUse;
|
|
72
76
|
const {
|
|
@@ -131,19 +135,19 @@ const ListFactory = props => {
|
|
|
131
135
|
const [textFilter] = getSearchFilterType(searchFilter, TEXT_SEARCH);
|
|
132
136
|
const shouldApplyTextFilter = textFilter && textFilter.propsToDisplay.length;
|
|
133
137
|
const operator = shouldApplyTextFilter ? getElasticsearchOperator(textFilter) : AND_OPERATOR;
|
|
134
|
-
const valuesText = shouldApplyTextFilter ? buildSearchValuesText(textFilter,
|
|
138
|
+
const valuesText = shouldApplyTextFilter ? buildSearchValuesText(textFilter, updatedQuery, name) : [];
|
|
135
139
|
const {
|
|
136
140
|
valuesAnd,
|
|
137
141
|
valuesOr
|
|
138
|
-
} = getQueryFilters(searchFilter,
|
|
139
|
-
const isTextSearchFilterApplied = !!(
|
|
142
|
+
} = getQueryFilters(searchFilter, updatedQuery, name);
|
|
143
|
+
const isTextSearchFilterApplied = !!(updatedQuery.search_term && searchFilter && getSearchFilterType(searchFilter, TEXT_SEARCH).length);
|
|
140
144
|
const searchValues = {
|
|
141
145
|
searchValuesText: valuesText,
|
|
142
146
|
searchValuesCheckboxSelectRange: valuesAnd,
|
|
143
147
|
searchValuesCheckboxOr: valuesOr
|
|
144
148
|
};
|
|
145
149
|
const listProps = _objectSpread(_objectSpread(_objectSpread({}, props), genericProps), {}, {
|
|
146
|
-
query,
|
|
150
|
+
query: updatedQuery,
|
|
147
151
|
url,
|
|
148
152
|
isCard,
|
|
149
153
|
isAZ,
|
|
@@ -181,7 +185,7 @@ ListFactory.propTypes = {
|
|
|
181
185
|
name: PropTypes.string,
|
|
182
186
|
sortby: PropTypes.array,
|
|
183
187
|
sort: PropTypes.string,
|
|
184
|
-
|
|
188
|
+
allSearchFilters: PropTypes.array,
|
|
185
189
|
sortProperties: PropTypes.array,
|
|
186
190
|
itemListName: PropTypes.string
|
|
187
191
|
};
|
|
@@ -196,7 +200,7 @@ ListFactory.defaultProps = {
|
|
|
196
200
|
sortProperties: [],
|
|
197
201
|
sort: '',
|
|
198
202
|
operator: AND,
|
|
199
|
-
|
|
203
|
+
allSearchFilters: [],
|
|
200
204
|
itemListName: ''
|
|
201
205
|
};
|
|
202
206
|
export default ListFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListFactory.js","names":["React","useContext","useQuery","parseUrl","PropTypes","useRouter","MainContext","generateSingleItemQuery","getItemList","ListBuilder","AZ_LIST_TYPE","getAzQueryFilter","getSortProps","hasRequiredItemListDetails","getGenericProps","getRequiredSchemas","checkForError","getUnpublishedEntityName","getPaginationIndex","getSearchFilterType","getElasticsearchOperator","buildSearchValuesText","getQueryFilters","getInheritedFilters","getQueryProps","getItemListId","getItemListIds","useGetEntitySchemasAsObj","AND_OPERATOR","TEXT_SEARCH","ID","AND","FULL","ListFactory","props","entity","legacyEntity","entities","parent","name","filterByProperty","filterBy","omitWrappers","type","sortby","defaultSortBy","sort","defaultSort","searchFilter","operator","filterOperator","sortProperties","itemListName","isPreview","router","asPath","parsedQuery","replace","query","url","querySort","querySortBy","itemListId","queryItemListId","sortbyFilters","updatedSortProperties","itemEntity","parentEntity","itemId","parentId","updatedParentEntity","paginationIndex","azFilter","entitiesToUse","length","filterEntity","data","mainSchemas","loading","schemasLoading","error","schemasError","currentSchema","filterEntitySchema","requiredSchema","requiredSchemaLoading","requiredSchemaError","inheritedFilters","queryProps","actions","getAction","get","getPublished","entityData","itemQueryError","itemQueryLoading","variables","id","skip","itemListData","itemListError","itemListLoading","errorsToCheck","hasErr","errMsg","itemListIds","isCard","includes","isAZ","genericProps","textFilter","shouldApplyTextFilter","propsToDisplay","valuesText","valuesAnd","valuesOr","isTextSearchFilterApplied","search_term","searchValues","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","listProps","_objectSpread","createElement","propTypes","object","isRequired","string","array","bool","defaultProps"],"sources":["../../../src/components/List/ListFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport { parseUrl } from 'query-string';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { generateSingleItemQuery, getItemList } from '../../application/query';\nimport ListBuilder from './ListBuilder';\nimport { AZ_LIST_TYPE } from './constants';\nimport { getAzQueryFilter, getSortProps, hasRequiredItemListDetails } from './helpers';\nimport {\n getGenericProps,\n getRequiredSchemas,\n checkForError,\n getUnpublishedEntityName,\n getPaginationIndex,\n getSearchFilterType,\n getElasticsearchOperator,\n buildSearchValuesText,\n getQueryFilters,\n getInheritedFilters,\n getQueryProps\n} from '../../helpers';\nimport { getItemListId, getItemListIds } from '../ItemList/helpers';\nimport { useGetEntitySchemasAsObj } from '../../hooks';\nimport { AND_OPERATOR, TEXT_SEARCH, ID, AND, FULL } from '../../constants';\n\nconst ListFactory = props => {\n const {\n entity: legacyEntity,\n entities,\n parent,\n name,\n filterByProperty,\n filterBy,\n omitWrappers,\n type,\n sortby: defaultSortBy,\n sort: defaultSort,\n searchFilter,\n operator: filterOperator,\n sortProperties,\n itemListName\n } = props;\n const { isPreview } = useContext(MainContext);\n const router = useRouter();\n const { asPath } = router;\n const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');\n const {\n query,\n url,\n query: { sort: querySort, sortby: querySortBy, itemListId: queryItemListId } = {}\n } = parseUrl(parsedQuery);\n const { sortbyFilters, updatedSortProperties } = getSortProps({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy\n });\n\n const itemListId = getItemListId(itemListName, queryItemListId);\n const { itemEntity: parentEntity, itemId: parentId } = parent;\n const updatedParentEntity = getUnpublishedEntityName(parentEntity);\n const paginationIndex = getPaginationIndex(query, name);\n const azFilter = getAzQueryFilter(query, name);\n\n const entitiesToUse = entities && entities.length ? entities : [legacyEntity];\n const [filterEntity] = entitiesToUse;\n const {\n data: mainSchemas = {},\n loading: schemasLoading,\n error: schemasError\n } = useGetEntitySchemasAsObj([updatedParentEntity, ...entitiesToUse]);\n\n const {\n [updatedParentEntity]: currentSchema = {},\n [filterEntity]: filterEntitySchema = {}\n } = mainSchemas;\n\n const {\n data: requiredSchema = {},\n loading: requiredSchemaLoading,\n error: requiredSchemaError\n } = useGetEntitySchemasAsObj(\n getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema),\n schemasLoading\n );\n const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);\n const queryProps = getQueryProps(inheritedFilters, currentSchema, filterEntitySchema);\n const { actions = {} } = currentSchema || {};\n const getAction = isPreview ? actions.get : actions.getPublished;\n\n const {\n data: { entityData = {} } = {},\n error: itemQueryError,\n loading: itemQueryLoading\n } = useQuery(generateSingleItemQuery(getAction, queryProps), {\n variables: { id: parentId },\n skip: schemasLoading || (!inheritedFilters.length && queryProps === ID)\n });\n\n const { data: itemListData = {}, error: itemListError, loading: itemListLoading } = useQuery(\n getItemList,\n {\n variables: { id: itemListId },\n skip: !itemListId\n }\n );\n\n if (!hasRequiredItemListDetails({ itemListName, router, itemListId, queryItemListId })) return '';\n\n const errorsToCheck = [schemasError, requiredSchemaError, itemQueryError, itemListError];\n const { hasErr, errMsg } = checkForError(errorsToCheck);\n\n if (requiredSchemaLoading || schemasLoading || itemQueryLoading || itemListLoading) return '';\n if (hasErr) return errMsg;\n\n const itemListIds = getItemListIds(itemListData);\n const isCard = !type.includes(FULL);\n const isAZ = type.includes(AZ_LIST_TYPE);\n const genericProps = getGenericProps(props);\n const [textFilter] = getSearchFilterType(searchFilter, TEXT_SEARCH);\n const shouldApplyTextFilter = textFilter && textFilter.propsToDisplay.length;\n const operator = shouldApplyTextFilter ? getElasticsearchOperator(textFilter) : AND_OPERATOR;\n const valuesText = shouldApplyTextFilter ? buildSearchValuesText(textFilter, query) : [];\n const { valuesAnd, valuesOr } = getQueryFilters(searchFilter, query);\n const isTextSearchFilterApplied = !!(\n query.search_term &&\n searchFilter &&\n getSearchFilterType(searchFilter, TEXT_SEARCH).length\n );\n\n const searchValues = {\n searchValuesText: valuesText,\n searchValuesCheckboxSelectRange: valuesAnd,\n searchValuesCheckboxOr: valuesOr\n };\n const listProps = {\n ...props,\n ...genericProps,\n query,\n url,\n isCard,\n isAZ,\n router,\n sort: null,\n sortby: null,\n sortProperties: updatedSortProperties,\n azFilter,\n searchValues,\n filterEntitySchema,\n requiredSchema,\n currentSchema,\n omitWrappers,\n operator,\n isTextSearchFilterApplied,\n paginationIndex,\n entityData,\n inheritedFilters,\n filterOperator,\n itemListIds,\n entities: entitiesToUse,\n mainSchemas\n };\n\n return <ListBuilder {...listProps} />;\n};\n\nListFactory.propTypes = {\n parent: PropTypes.object.isRequired,\n type: PropTypes.string.isRequired,\n entity: PropTypes.string,\n entities: PropTypes.array,\n filterBy: PropTypes.array,\n filterByProperty: PropTypes.array,\n omitWrappers: PropTypes.bool,\n operator: PropTypes.string,\n name: PropTypes.string,\n sortby: PropTypes.array,\n sort: PropTypes.string,\n searchFilter: PropTypes.object,\n sortProperties: PropTypes.array,\n itemListName: PropTypes.string\n};\n\nListFactory.defaultProps = {\n entity: '',\n entities: [],\n filterBy: [],\n filterByProperty: [],\n omitWrappers: false,\n name: '',\n sortby: [],\n sortProperties: [],\n sort: '',\n operator: AND,\n searchFilter: {},\n itemListName: ''\n};\n\nexport default ListFactory;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,uBAAuB,EAAEC,WAAW,QAAQ,yBAAyB;AAC9E,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,YAAY,QAAQ,aAAa;AAC1C,SAASC,gBAAgB,EAAEC,YAAY,EAAEC,0BAA0B,QAAQ,WAAW;AACtF,SACEC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,EACbC,wBAAwB,EACxBC,kBAAkB,EAClBC,mBAAmB,EACnBC,wBAAwB,EACxBC,qBAAqB,EACrBC,eAAe,EACfC,mBAAmB,EACnBC,aAAa,QACR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seUrl","PropTypes","useRouter","MainContext","generateSingleItemQuery","getItemList","ListBuilder","AZ_LIST_TYPE","getAzQueryFilter","getSortProps","hasRequiredItemListDetails","getListSpecificSearchFilter","getListQuery","getGenericProps","getRequiredSchemas","checkForError","getUnpublishedEntityName","getPaginationIndex","getSearchFilterType","getElasticsearchOperator","buildSearchValuesText","getQueryFilters","getInheritedFilters","getQueryProps","getItemListId","getItemListIds","useGetEntitySchemasAsObj","AND_OPERATOR","TEXT_SEARCH","ID","AND","FULL","ListFactory","props","entity","legacyEntity","entities","parent","name","filterByProperty","filterBy","omitWrappers","type","sortby","defaultSortBy","sort","defaultSort","allSearchFilters","operator","filterOperator","sortProperties","itemListName","isPreview","router","asPath","parsedQuery","replace","searchFilter","hasListSpecificFilters","query","url","itemListId","queryItemListId","updatedQuery","querySort","querySortBy","sortbyFilters","updatedSortProperties","itemEntity","parentEntity","itemId","parentId","updatedParentEntity","paginationIndex","azFilter","entitiesToUse","length","filterEntity","data","mainSchemas","loading","schemasLoading","error","schemasError","currentSchema","filterEntitySchema","requiredSchema","requiredSchemaLoading","requiredSchemaError","inheritedFilters","queryProps","actions","getAction","get","getPublished","entityData","itemQueryError","itemQueryLoading","variables","id","skip","itemListData","itemListError","itemListLoading","errorsToCheck","hasErr","errMsg","itemListIds","isCard","includes","isAZ","genericProps","textFilter","shouldApplyTextFilter","propsToDisplay","valuesText","valuesAnd","valuesOr","isTextSearchFilterApplied","search_term","searchValues","searchValuesText","searchValuesCheckboxSelectRange","searchValuesCheckboxOr","listProps","_objectSpread","createElement","propTypes","object","isRequired","string","array","bool","defaultProps"],"sources":["../../../src/components/List/ListFactory.js"],"sourcesContent":["import React, { useContext } from 'react';\nimport { useQuery } from '@apollo/client';\nimport { parseUrl } from 'query-string';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { MainContext } from '@blaze-cms/nextjs-components';\nimport { generateSingleItemQuery, getItemList } from '../../application/query';\nimport ListBuilder from './ListBuilder';\nimport { AZ_LIST_TYPE } from './constants';\nimport {\n getAzQueryFilter,\n getSortProps,\n hasRequiredItemListDetails,\n getListSpecificSearchFilter,\n getListQuery\n} from './helpers';\nimport {\n getGenericProps,\n getRequiredSchemas,\n checkForError,\n getUnpublishedEntityName,\n getPaginationIndex,\n getSearchFilterType,\n getElasticsearchOperator,\n buildSearchValuesText,\n getQueryFilters,\n getInheritedFilters,\n getQueryProps\n} from '../../helpers';\nimport { getItemListId, getItemListIds } from '../ItemList/helpers';\nimport { useGetEntitySchemasAsObj } from '../../hooks';\nimport { AND_OPERATOR, TEXT_SEARCH, ID, AND, FULL } from '../../constants';\n\nconst ListFactory = props => {\n const {\n entity: legacyEntity,\n entities,\n parent,\n name,\n filterByProperty,\n filterBy,\n omitWrappers,\n type,\n sortby: defaultSortBy,\n sort: defaultSort,\n allSearchFilters,\n operator: filterOperator,\n sortProperties,\n itemListName\n } = props;\n const { isPreview } = useContext(MainContext);\n const router = useRouter();\n const { asPath } = router;\n const parsedQuery = asPath.replace(/%5D/g, ']').replace(/%5B/g, '[');\n const [searchFilter, hasListSpecificFilters] = getListSpecificSearchFilter(\n allSearchFilters,\n name\n );\n const { query, url, query: { itemListId: queryItemListId } = {} } = parseUrl(parsedQuery);\n const updatedQuery = getListQuery(query, hasListSpecificFilters, name);\n const { sort: querySort, sortby: querySortBy } = updatedQuery;\n const { sortbyFilters, updatedSortProperties } = getSortProps({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy\n });\n\n const itemListId = getItemListId(itemListName, queryItemListId);\n const { itemEntity: parentEntity, itemId: parentId } = parent;\n const updatedParentEntity = getUnpublishedEntityName(parentEntity);\n const paginationIndex = getPaginationIndex(updatedQuery, name);\n const azFilter = getAzQueryFilter(updatedQuery, name);\n\n const entitiesToUse = entities && entities.length ? entities : [legacyEntity];\n const [filterEntity] = entitiesToUse;\n const {\n data: mainSchemas = {},\n loading: schemasLoading,\n error: schemasError\n } = useGetEntitySchemasAsObj([updatedParentEntity, ...entitiesToUse]);\n\n const {\n [updatedParentEntity]: currentSchema = {},\n [filterEntity]: filterEntitySchema = {}\n } = mainSchemas;\n\n const {\n data: requiredSchema = {},\n loading: requiredSchemaLoading,\n error: requiredSchemaError\n } = useGetEntitySchemasAsObj(\n getRequiredSchemas([...filterByProperty, ...sortbyFilters], filterEntitySchema),\n schemasLoading\n );\n const inheritedFilters = getInheritedFilters(filterBy, filterByProperty);\n const queryProps = getQueryProps(inheritedFilters, currentSchema, filterEntitySchema);\n const { actions = {} } = currentSchema || {};\n const getAction = isPreview ? actions.get : actions.getPublished;\n\n const {\n data: { entityData = {} } = {},\n error: itemQueryError,\n loading: itemQueryLoading\n } = useQuery(generateSingleItemQuery(getAction, queryProps), {\n variables: { id: parentId },\n skip: schemasLoading || (!inheritedFilters.length && queryProps === ID)\n });\n\n const { data: itemListData = {}, error: itemListError, loading: itemListLoading } = useQuery(\n getItemList,\n {\n variables: { id: itemListId },\n skip: !itemListId\n }\n );\n\n if (!hasRequiredItemListDetails({ itemListName, router, itemListId, queryItemListId })) return '';\n\n const errorsToCheck = [schemasError, requiredSchemaError, itemQueryError, itemListError];\n const { hasErr, errMsg } = checkForError(errorsToCheck);\n\n if (requiredSchemaLoading || schemasLoading || itemQueryLoading || itemListLoading) return '';\n if (hasErr) return errMsg;\n\n const itemListIds = getItemListIds(itemListData);\n const isCard = !type.includes(FULL);\n const isAZ = type.includes(AZ_LIST_TYPE);\n const genericProps = getGenericProps(props);\n const [textFilter] = getSearchFilterType(searchFilter, TEXT_SEARCH);\n const shouldApplyTextFilter = textFilter && textFilter.propsToDisplay.length;\n const operator = shouldApplyTextFilter ? getElasticsearchOperator(textFilter) : AND_OPERATOR;\n const valuesText = shouldApplyTextFilter\n ? buildSearchValuesText(textFilter, updatedQuery, name)\n : [];\n const { valuesAnd, valuesOr } = getQueryFilters(searchFilter, updatedQuery, name);\n const isTextSearchFilterApplied = !!(\n updatedQuery.search_term &&\n searchFilter &&\n getSearchFilterType(searchFilter, TEXT_SEARCH).length\n );\n\n const searchValues = {\n searchValuesText: valuesText,\n searchValuesCheckboxSelectRange: valuesAnd,\n searchValuesCheckboxOr: valuesOr\n };\n const listProps = {\n ...props,\n ...genericProps,\n query: updatedQuery,\n url,\n isCard,\n isAZ,\n router,\n sort: null,\n sortby: null,\n sortProperties: updatedSortProperties,\n azFilter,\n searchValues,\n filterEntitySchema,\n requiredSchema,\n currentSchema,\n omitWrappers,\n operator,\n isTextSearchFilterApplied,\n paginationIndex,\n entityData,\n inheritedFilters,\n filterOperator,\n itemListIds,\n entities: entitiesToUse,\n mainSchemas\n };\n\n return <ListBuilder {...listProps} />;\n};\n\nListFactory.propTypes = {\n parent: PropTypes.object.isRequired,\n type: PropTypes.string.isRequired,\n entity: PropTypes.string,\n entities: PropTypes.array,\n filterBy: PropTypes.array,\n filterByProperty: PropTypes.array,\n omitWrappers: PropTypes.bool,\n operator: PropTypes.string,\n name: PropTypes.string,\n sortby: PropTypes.array,\n sort: PropTypes.string,\n allSearchFilters: PropTypes.array,\n sortProperties: PropTypes.array,\n itemListName: PropTypes.string\n};\n\nListFactory.defaultProps = {\n entity: '',\n entities: [],\n filterBy: [],\n filterByProperty: [],\n omitWrappers: false,\n name: '',\n sortby: [],\n sortProperties: [],\n sort: '',\n operator: AND,\n allSearchFilters: [],\n itemListName: ''\n};\n\nexport default ListFactory;\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,SAASC,QAAQ,QAAQ,gBAAgB;AACzC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,WAAW,QAAQ,8BAA8B;AAC1D,SAASC,uBAAuB,EAAEC,WAAW,QAAQ,yBAAyB;AAC9E,OAAOC,WAAW,MAAM,eAAe;AACvC,SAASC,YAAY,QAAQ,aAAa;AAC1C,SACEC,gBAAgB,EAChBC,YAAY,EACZC,0BAA0B,EAC1BC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S,CAACiI;AAC1B,CAAC;AAEDlG,WAAW,CAACqG,YAAY,GAAG;EACzBnG,MAAM,EAAE,EAAE;EACVE,QAAQ,EAAE,EAAE;EACZI,QAAQ,EAAE,EAAE;EACZD,gBAAgB,EAAE,EAAE;EACpBE,YAAY,EAAE,KAAK;EACnBH,IAAI,EAAE,EAAE;EACRK,MAAM,EAAE,EAAE;EACVO,cAAc,EAAE,EAAE;EAClBL,IAAI,EAAE,EAAE;EACRG,QAAQ,EAAElB,GAAG;EACbiB,gBAAgB,EAAE,EAAE;EACpBI,YAAY,EAAE;AAChB,CAAC;AAED,eAAenB,WAAW"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import stripQueryKey from './strip-query-key';
|
|
2
|
+
const getListQuery = (query, hasListSpecificFilters, name) => {
|
|
3
|
+
const updatedQuery = {};
|
|
4
|
+
const listKey = `pb[${name}]`;
|
|
5
|
+
const paginationKey = `${listKey}[page]`;
|
|
6
|
+
const sortKey = `${listKey}[sort]`;
|
|
7
|
+
const sortByKey = `${listKey}[sortby]`;
|
|
8
|
+
Object.keys(query).forEach(queryKey => {
|
|
9
|
+
const isListKey = queryKey.indexOf(`${listKey}`) !== -1;
|
|
10
|
+
const decodedQueryValue = Array.isArray(query[queryKey]) ? query[queryKey].map(value => decodeURIComponent(value)) : decodeURIComponent(query[queryKey]);
|
|
11
|
+
if (hasListSpecificFilters) {
|
|
12
|
+
const strippedKey = stripQueryKey(queryKey, listKey, paginationKey);
|
|
13
|
+
if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;
|
|
14
|
+
} else {
|
|
15
|
+
if (queryKey.indexOf('pb[') === -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
16
|
+
if (queryKey.indexOf(paginationKey) !== -1) updatedQuery[queryKey] = decodedQueryValue;
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
updatedQuery.sort = query[sortKey] || query.sort;
|
|
20
|
+
updatedQuery.sortby = query[sortByKey] || query.sortby;
|
|
21
|
+
return updatedQuery;
|
|
22
|
+
};
|
|
23
|
+
export default getListQuery;
|
|
24
|
+
//# sourceMappingURL=get-list-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-list-query.js","names":["stripQueryKey","getListQuery","query","hasListSpecificFilters","name","updatedQuery","listKey","paginationKey","sortKey","sortByKey","Object","keys","forEach","queryKey","isListKey","indexOf","decodedQueryValue","Array","isArray","map","value","decodeURIComponent","strippedKey","sort","sortby"],"sources":["../../../../src/components/List/helpers/get-list-query.js"],"sourcesContent":["import stripQueryKey from './strip-query-key';\n\nconst getListQuery = (query, hasListSpecificFilters, name) => {\n const updatedQuery = {};\n const listKey = `pb[${name}]`;\n const paginationKey = `${listKey}[page]`;\n const sortKey = `${listKey}[sort]`;\n const sortByKey = `${listKey}[sortby]`;\n\n Object.keys(query).forEach(queryKey => {\n const isListKey = queryKey.indexOf(`${listKey}`) !== -1;\n const decodedQueryValue = Array.isArray(query[queryKey])\n ? query[queryKey].map(value => decodeURIComponent(value))\n : decodeURIComponent(query[queryKey]);\n if (hasListSpecificFilters) {\n const strippedKey = stripQueryKey(queryKey, listKey, paginationKey);\n if (isListKey) updatedQuery[strippedKey] = decodedQueryValue;\n } else {\n if (queryKey.indexOf('pb[') === -1) updatedQuery[queryKey] = decodedQueryValue;\n if (queryKey.indexOf(paginationKey) !== -1) updatedQuery[queryKey] = decodedQueryValue;\n }\n });\n updatedQuery.sort = query[sortKey] || query.sort;\n updatedQuery.sortby = query[sortByKey] || query.sortby;\n return updatedQuery;\n};\n\nexport default getListQuery;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,mBAAmB;AAE7C,MAAMC,YAAY,GAAGA,CAACC,KAAK,EAAEC,sBAAsB,EAAEC,IAAI,KAAK;EAC5D,MAAMC,YAAY,GAAG,CAAC,CAAC;EACvB,MAAMC,OAAO,GAAI,MAAKF,IAAK,GAAE;EAC7B,MAAMG,aAAa,GAAI,GAAED,OAAQ,QAAO;EACxC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ters, listName) => {
|
|
2
|
+
const searchFilterMatch = searchFilters.find(({
|
|
3
|
+
settings: {
|
|
4
|
+
listComponentName
|
|
5
|
+
}
|
|
6
|
+
}) => listComponentName === listName);
|
|
7
|
+
const hasListSpecificFilters = !!searchFilterMatch;
|
|
8
|
+
const searchFilterToUse = searchFilterMatch || searchFilters[0] || {};
|
|
9
|
+
return [searchFilterToUse, hasListSpecificFilters];
|
|
10
|
+
};
|
|
11
|
+
export default getListSpecificSearchFilter;
|
|
12
|
+
//# sourceMappingURL=get-list-specific-search-filter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-list-specific-search-filter.js","names":["getListSpecificSearchFilter","searchFilters","listName","searchFilterMatch","find","settings","listComponentName","hasListSpecificFilters","searchFilterToUse"],"sources":["../../../../src/components/List/helpers/get-list-specific-search-filter.js"],"sourcesContent":["const getListSpecificSearchFilter = (searchFilters, listName) => {\n const searchFilterMatch = searchFilters.find(\n ({ settings: { listComponentName } }) => listComponentName === listName\n );\n const hasListSpecificFilters = !!searchFilterMatch;\n const searchFilterToUse = searchFilterMatch || searchFilters[0] || {};\n return [searchFilterToUse, hasListSpecificFilters];\n};\n\nexport default getListSpecificSearchFilter;\n"],"mappings":"AAAA,MAAMA,2BAA2B,GAAGA,CAACC,aAAa,EAAEC,QAAQ,KAAK;EAC/D,MAAMC,iBAAiB,GAAGF,aAAa,CAACG,IAAI,CAC1C,CAAC;IAAEC,QAAQ,EAAE;MAAEC;IAAkB;EAAE,CAAC,KAAKA,iBAAiB,KAAKJ,QACjE,CAAC;EACD,MAAMK,sBAAsB,GAAG,CAAC,CAACJ,iBAAiB;EAClD,MAAMK,iBAAiB,GAAGL,iBAAiB,IAAIF,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;EACrE,OAAO,CAACO,iBAAiB,EAAED,sBAAsB,CAAC;AACpD,CAAC;AAED,eAAeP,2BAA2B"}
|
|
@@ -7,4 +7,6 @@ export { default as getItemsPerPageToUse } from './get-items-per-page-to-use';
|
|
|
7
7
|
export { default as getSortProps } from './get-sort-props';
|
|
8
8
|
export { default as hasRequiredItemListDetails } from './has-required-item-list-details';
|
|
9
9
|
export { default as getListComponent } from './get-list-component';
|
|
10
|
+
export { default as getListQuery } from './get-list-query';
|
|
11
|
+
export { default as getListSpecificSearchFilter } from './get-list-specific-search-filter';
|
|
10
12
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["default","buildPaginationItems","getAzQueryFilter","buildAzAggregations","buildAzUrl","sortAggs","getItemsPerPageToUse","getSortProps","hasRequiredItemListDetails","getListComponent"],"sources":["../../../../src/components/List/helpers/index.js"],"sourcesContent":["export { default as buildPaginationItems } from './build-pagination-items';\nexport { default as getAzQueryFilter } from './get-az-query-filter';\nexport { default as buildAzAggregations } from './build-az-aggregations';\nexport { default as buildAzUrl } from './build-az-url';\nexport { default as sortAggs } from './sort-aggs';\nexport { default as getItemsPerPageToUse } from './get-items-per-page-to-use';\nexport { default as getSortProps } from './get-sort-props';\nexport { default as hasRequiredItemListDetails } from './has-required-item-list-details';\nexport { default as getListComponent } from './get-list-component';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAAoB,QAAQ,0BAA0B;AAC1E,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,uBAAuB;AACnE,SAASF,OAAO,IAAIG,mBAAmB,QAAQ,yBAAyB;AACxE,SAASH,OAAO,IAAII,UAAU,QAAQ,gBAAgB;AACtD,SAASJ,OAAO,IAAIK,QAAQ,QAAQ,aAAa;AACjD,SAASL,OAAO,IAAIM,oBAAoB,QAAQ,6BAA6B;AAC7E,SAASN,OAAO,IAAIO,YAAY,QAAQ,kBAAkB;AAC1D,SAASP,OAAO,IAAIQ,0BAA0B,QAAQ,kCAAkC;AACxF,SAASR,OAAO,IAAIS,gBAAgB,QAAQ,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","buildPaginationItems","getAzQueryFilter","buildAzAggregations","buildAzUrl","sortAggs","getItemsPerPageToUse","getSortProps","hasRequiredItemListDetails","getListComponent","getListQuery","getListSpecificSearchFilter"],"sources":["../../../../src/components/List/helpers/index.js"],"sourcesContent":["export { default as buildPaginationItems } from './build-pagination-items';\nexport { default as getAzQueryFilter } from './get-az-query-filter';\nexport { default as buildAzAggregations } from './build-az-aggregations';\nexport { default as buildAzUrl } from './build-az-url';\nexport { default as sortAggs } from './sort-aggs';\nexport { default as getItemsPerPageToUse } from './get-items-per-page-to-use';\nexport { default as getSortProps } from './get-sort-props';\nexport { default as hasRequiredItemListDetails } from './has-required-item-list-details';\nexport { default as getListComponent } from './get-list-component';\nexport { default as getListQuery } from './get-list-query';\nexport { default as getListSpecificSearchFilter } from './get-list-specific-search-filter';\n"],"mappings":"AAAA,SAASA,OAAO,IAAIC,oBAAoB,QAAQ,0BAA0B;AAC1E,SAASD,OAAO,IAAIE,gBAAgB,QAAQ,uBAAuB;AACnE,SAASF,OAAO,IAAIG,mBAAmB,QAAQ,yBAAyB;AACxE,SAASH,OAAO,IAAII,UAAU,QAAQ,gBAAgB;AACtD,SAASJ,OAAO,IAAIK,QAAQ,QAAQ,aAAa;AACjD,SAASL,OAAO,IAAIM,oBAAoB,QAAQ,6BAA6B;AAC7E,SAASN,OAAO,IAAIO,YAAY,QAAQ,kBAAkB;AAC1D,SAASP,OAAO,IAAIQ,0BAA0B,QAAQ,kCAAkC;AACxF,SAASR,OAAO,IAAIS,gBAAgB,QAAQ,sBAAsB;AAClE,SAAST,OAAO,IAAIU,YAAY,QAAQ,kBAAkB;AAC1D,SAASV,OAAO,IAAIW,2BAA2B,QAAQ,mCAAmC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strip-query-key.js","names":["stripQueryKey","fullKey","listNameKey","paginationKey","substring","length"],"sources":["../../../../src/components/List/helpers/strip-query-key.js"],"sourcesContent":["const stripQueryKey = (fullKey, listNameKey, paginationKey) => {\n if (paginationKey === fullKey) return fullKey;\n return fullKey.substring(listNameKey.length + 1, fullKey.length - 1);\n};\n\nexport default stripQueryKey;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGA,CAACC,OAAO,EAAEC,WAAW,EAAEC,aAAa,KAAK;EAC7D,IAAIA,aAAa,KAAKF,OAAO,EAAE,OAAOA,OAAO;EAC7C,OAAOA,OAAO,CAACG,SAAS,CAACF,WAAW,CAACG,MAAM,GAAG,CAAC,EAAEJ,OAAO,CAACI,MAAM,GAAG,CAAC,CAAC;AACtE,CAAC;AAED,eAAeL,aAAa"}
|
|
@@ -9,12 +9,12 @@ const SearchContent = ({
|
|
|
9
9
|
searchInputAlignment,
|
|
10
10
|
searchInputWrapperMobile,
|
|
11
11
|
searchInputWrapperDesktop,
|
|
12
|
-
collapsible,
|
|
13
12
|
isMobile,
|
|
14
13
|
placeholder,
|
|
15
|
-
modifier
|
|
14
|
+
modifier,
|
|
15
|
+
collapsedSearch
|
|
16
16
|
}) => {
|
|
17
|
-
const [collapsed, setCollapsed] = useState(
|
|
17
|
+
const [collapsed, setCollapsed] = useState(collapsedSearch);
|
|
18
18
|
const router = useRouter();
|
|
19
19
|
const {
|
|
20
20
|
results,
|
|
@@ -44,7 +44,7 @@ const SearchContent = ({
|
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
const handleOnBlur = () => {
|
|
47
|
-
if (!
|
|
47
|
+
if (!collapsedSearch) return;
|
|
48
48
|
if (!debouncedSearchTerm || debouncedSearchTerm === '') setCollapsed(true);
|
|
49
49
|
};
|
|
50
50
|
const handleClearSearchResults = () => {
|
|
@@ -106,7 +106,8 @@ SearchContent.propTypes = {
|
|
|
106
106
|
isMobile: PropTypes.bool,
|
|
107
107
|
collapsible: PropTypes.bool,
|
|
108
108
|
entities: PropTypes.array.isRequired,
|
|
109
|
-
modifier: PropTypes.string
|
|
109
|
+
modifier: PropTypes.string,
|
|
110
|
+
collapsedSearch: PropTypes.bool
|
|
110
111
|
};
|
|
111
112
|
SearchContent.defaultProps = {
|
|
112
113
|
searchInputAlignment: '',
|
|
@@ -115,7 +116,8 @@ SearchContent.defaultProps = {
|
|
|
115
116
|
placeholder: '',
|
|
116
117
|
isMobile: false,
|
|
117
118
|
collapsible: false,
|
|
118
|
-
modifier: ''
|
|
119
|
+
modifier: '',
|
|
120
|
+
collapsedSearch: false
|
|
119
121
|
};
|
|
120
122
|
export default SearchContent;
|
|
121
123
|
//# sourceMappingURL=SearchContent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchContent.js","names":["React","useState","useEffect","PropTypes","useRouter","useDebounceSearch","SearchContentResults","SearchContentToggleIcon","SearchContent","entities","searchInputAlignment","searchInputWrapperMobile","searchInputWrapperDesktop","
|
|
1
|
+
{"version":3,"file":"SearchContent.js","names":["React","useState","useEffect","PropTypes","useRouter","useDebounceSearch","SearchContentResults","SearchContentToggleIcon","SearchContent","entities","searchInputAlignment","searchInputWrapperMobile","searchInputWrapperDesktop","isMobile","placeholder","modifier","collapsedSearch","collapsed","setCollapsed","router","results","searchTerm","setSearchTerm","debouncedSearchTerm","initialSearchTerm","resultKeys","handleRouteChange","events","on","off","responsiveClasses","handleClick","e","url","preventDefault","push","handleKeyPress","key","target","value","handleOnBlur","handleClearSearchResults","className","filter","Boolean","join","createElement","viewBox","fillRule","d","clipRule","onFocus","onChange","type","name","Fragment","onClear","onKeyPress","onBlur","propTypes","string","bool","collapsible","array","isRequired","defaultProps"],"sources":["../../../src/components/SearchContent/SearchContent.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport { useRouter } from 'next/router';\nimport { useDebounceSearch } from '@blaze-cms/plugin-search-ui';\nimport SearchContentResults from './SearchContentResults';\nimport SearchContentToggleIcon from './SearchContentToggleIcon';\n\nconst SearchContent = ({\n entities,\n searchInputAlignment,\n searchInputWrapperMobile,\n searchInputWrapperDesktop,\n isMobile,\n placeholder,\n modifier,\n collapsedSearch\n}) => {\n const [collapsed, setCollapsed] = useState(collapsedSearch);\n const router = useRouter();\n\n const { results, searchTerm, setSearchTerm, debouncedSearchTerm } = useDebounceSearch({\n entities,\n initialSearchTerm: '',\n resultKeys: 'id, name, image { url }, url'\n });\n\n useEffect(\n () => {\n const handleRouteChange = () => setSearchTerm('');\n router.events.on('routeChangeStart', handleRouteChange);\n\n return () => {\n router.events.off('routeChangeStart', handleRouteChange);\n };\n },\n [router.events, setSearchTerm]\n );\n\n const responsiveClasses = isMobile ? searchInputWrapperMobile : searchInputWrapperDesktop;\n\n const handleClick = (e, url) => {\n e.preventDefault();\n router.push(url);\n };\n\n const handleKeyPress = e => {\n if (e.key === 'Enter' && e.target.value !== '') {\n router.push(`/search?search_term=${e.target.value}`);\n }\n };\n\n const handleOnBlur = () => {\n if (!collapsedSearch) return;\n if (!debouncedSearchTerm || debouncedSearchTerm === '') setCollapsed(true);\n };\n\n const handleClearSearchResults = () => {\n setSearchTerm('');\n };\n\n const className = ['search-content', modifier, responsiveClasses].filter(Boolean).join(' ');\n return collapsed ? (\n <div className={className}>\n <div className=\"search-content--collapse__wrapper\">\n <label className=\"search-content--collapse__label\">\n <span className=\"search-content--collapse__icon_wrapper\">\n <svg className=\"search-content--collapse__icon\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </span>\n <input\n onFocus={() => setCollapsed(false)}\n onChange={e => setSearchTerm(e.target.value)}\n type=\"text\"\n name=\"search\"\n className=\"search-content--collapse__input\"\n />\n </label>\n </div>\n </div>\n ) : (\n <>\n <div className={className}>\n <div className=\"search-content--expanded__wrapper\">\n <label className=\"search-content--expanded__label\">\n <span className=\"search-content--expanded__icon_wrapper\">\n <SearchContentToggleIcon results={results} onClear={handleClearSearchResults} />\n </span>\n <input\n type=\"text\"\n name=\"search\"\n onChange={e => setSearchTerm(e.target.value)}\n onKeyPress={handleKeyPress}\n className=\"search-content--expanded__input\"\n placeholder={placeholder}\n value={searchTerm}\n onBlur={handleOnBlur}\n />\n </label>\n </div>\n <SearchContentResults\n results={results}\n debouncedSearchTerm={debouncedSearchTerm}\n handleClick={handleClick}\n />\n </div>\n </>\n );\n};\n\nSearchContent.propTypes = {\n searchInputAlignment: PropTypes.string,\n searchInputWrapperMobile: PropTypes.string,\n searchInputWrapperDesktop: PropTypes.string,\n placeholder: PropTypes.string,\n isMobile: PropTypes.bool,\n collapsible: PropTypes.bool,\n entities: PropTypes.array.isRequired,\n modifier: PropTypes.string,\n collapsedSearch: PropTypes.bool\n};\n\nSearchContent.defaultProps = {\n searchInputAlignment: '',\n searchInputWrapperMobile: '',\n searchInputWrapperDesktop: '',\n placeholder: '',\n isMobile: false,\n collapsible: false,\n modifier: '',\n collapsedSearch: false\n};\n\nexport default SearchContent;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,iBAAiB,QAAQ,6BAA6B;AAC/D,OAAOC,oBAAoB,MAAM,wBAAwB;AACzD,OAAOC,uBAAuB,MAAM,2BAA2B;AAE/D,MAAMC,aAAa,GAAGA,CAAC;EACrBC,QAAQ;EACRC,oBAAoB;EACpBC,wBAAwB;EACxBC,yBAAyB;EACzBC,QAAQ;EACRC,WAAW;EACXC,QAAQ;EACRC;AACF,CAAC,KAAK;EACJ,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGjB,QAAQ,CAACe,eAAe,CAAC;EAC3D,MAAMG,MAAM,GAAGf,SAAS,CAAC,CAAC;EAE1B,MAAM;IAAEgB,OAAO;IAAEC,UAAU;IAAEC,aAAa;IAAEC;EAAoB,CAAC,GAAGlB,iBAAiB,CAAC;IACpFI,QAAQ;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|
import debounce from 'lodash.debounce';
|
|
5
5
|
import FiltersList from './FiltersList';
|
|
6
|
-
import { isDeviceDesktop,
|
|
6
|
+
import { isDeviceDesktop, buildUrlQuery, getFilterValues, getResponsiveFilterClassnames } from '../helpers';
|
|
7
7
|
import CloseMobileForm from './CloseMobileForm';
|
|
8
8
|
import ResetDesktopForm from './ResetDesktopForm';
|
|
9
9
|
import MobileFormToolbar from './MobileFormToolbar';
|
|
10
10
|
import { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';
|
|
11
11
|
const SearchFilter = ({
|
|
12
12
|
searchFilterRef,
|
|
13
|
+
listComponentName,
|
|
13
14
|
data,
|
|
14
15
|
filters,
|
|
15
16
|
hasUrl,
|
|
@@ -22,12 +23,13 @@ const SearchFilter = ({
|
|
|
22
23
|
groupAfterDesktop,
|
|
23
24
|
groupAfterMobile,
|
|
24
25
|
filterValues,
|
|
25
|
-
setAppliedFilters
|
|
26
|
+
setAppliedFilters,
|
|
27
|
+
query
|
|
26
28
|
}) => {
|
|
27
29
|
const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);
|
|
28
30
|
const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);
|
|
29
|
-
const doSubmit =
|
|
30
|
-
const newQuery =
|
|
31
|
+
const doSubmit = newValues => {
|
|
32
|
+
const newQuery = buildUrlQuery(newValues, filters, listComponentName, query);
|
|
31
33
|
handleSearch(newQuery);
|
|
32
34
|
setMoreFiltersDesktopCollapsed(true);
|
|
33
35
|
setMoreFiltersMobileCollapsed(true);
|
|
@@ -55,7 +57,7 @@ const SearchFilter = ({
|
|
|
55
57
|
} = getResponsiveFilterClassnames(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed);
|
|
56
58
|
const formId = `filter-${name}-form`;
|
|
57
59
|
const handleReset = () => {
|
|
58
|
-
const newValues =
|
|
60
|
+
const newValues = getFilterValues(null, filters, {});
|
|
59
61
|
setAppliedFilters({
|
|
60
62
|
newValues,
|
|
61
63
|
type: 'reset'
|
|
@@ -70,7 +72,6 @@ const SearchFilter = ({
|
|
|
70
72
|
});
|
|
71
73
|
};
|
|
72
74
|
const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);
|
|
73
|
-
const shouldSearch = !hasUrl;
|
|
74
75
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("form", {
|
|
75
76
|
ref: searchFilterRef,
|
|
76
77
|
className: formClass,
|
|
@@ -78,7 +79,7 @@ const SearchFilter = ({
|
|
|
78
79
|
id: formId,
|
|
79
80
|
onSubmit: e => {
|
|
80
81
|
e.preventDefault();
|
|
81
|
-
doSubmit();
|
|
82
|
+
doSubmit(filterValues);
|
|
82
83
|
}
|
|
83
84
|
}, displaySearchFilter && /*#__PURE__*/React.createElement(CloseMobileForm, {
|
|
84
85
|
handleClose: () => setDisplaySearchFilter(false)
|
|
@@ -89,7 +90,7 @@ const SearchFilter = ({
|
|
|
89
90
|
}), /*#__PURE__*/React.createElement("div", {
|
|
90
91
|
className: "filter__wrapper filter__wrapper--search-refine"
|
|
91
92
|
}, !shouldGroup && /*#__PURE__*/React.createElement(FiltersList, {
|
|
92
|
-
shouldSearch:
|
|
93
|
+
shouldSearch: !hasUrl,
|
|
93
94
|
data: data,
|
|
94
95
|
filters: filters,
|
|
95
96
|
hasUrl: hasUrl,
|
|
@@ -97,7 +98,7 @@ const SearchFilter = ({
|
|
|
97
98
|
filterValues: filterValues,
|
|
98
99
|
updateFilterValues: updateFilterValues
|
|
99
100
|
}), shouldGroup && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(FiltersList, {
|
|
100
|
-
shouldSearch:
|
|
101
|
+
shouldSearch: !hasUrl,
|
|
101
102
|
data: data,
|
|
102
103
|
filters: filters.slice(0, groupAfterMobile),
|
|
103
104
|
hasUrl: hasUrl,
|
|
@@ -114,7 +115,7 @@ const SearchFilter = ({
|
|
|
114
115
|
}, /*#__PURE__*/React.createElement("div", {
|
|
115
116
|
className: MORE_FILTERS_CLASSES.MOBILE_CONTENT
|
|
116
117
|
}, /*#__PURE__*/React.createElement(FiltersList, {
|
|
117
|
-
shouldSearch:
|
|
118
|
+
shouldSearch: !hasUrl && isDeviceDesktop(),
|
|
118
119
|
data: data,
|
|
119
120
|
filters: filters.slice(groupAfterMobile, groupAfterDesktop ? groupAfterDesktop - 1 : 0),
|
|
120
121
|
hasUrl: hasUrl,
|
|
@@ -180,7 +181,13 @@ SearchFilter.propTypes = {
|
|
|
180
181
|
groupAfterDesktop: PropTypes.number.isRequired,
|
|
181
182
|
groupAfterMobile: PropTypes.number.isRequired,
|
|
182
183
|
filterValues: PropTypes.object.isRequired,
|
|
183
|
-
setAppliedFilters: PropTypes.func.isRequired
|
|
184
|
+
setAppliedFilters: PropTypes.func.isRequired,
|
|
185
|
+
listComponentName: PropTypes.string,
|
|
186
|
+
query: PropTypes.object
|
|
187
|
+
};
|
|
188
|
+
SearchFilter.defaultProps = {
|
|
189
|
+
listComponentName: '',
|
|
190
|
+
query: {}
|
|
184
191
|
};
|
|
185
192
|
export default SearchFilter;
|
|
186
193
|
//# sourceMappingURL=SearchFilter.js.map
|