@blaze-cms/react-page-builder 0.122.0 → 0.122.2

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 (22) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +5 -2
  3. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  4. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +15 -50
  5. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  6. package/lib/helpers/get-filter-props.js +3 -1
  7. package/lib/helpers/get-filter-props.js.map +1 -1
  8. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +3 -2
  9. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  10. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +10 -40
  11. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  12. package/lib-es/helpers/get-filter-props.js +2 -1
  13. package/lib-es/helpers/get-filter-props.js.map +1 -1
  14. package/package.json +2 -2
  15. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -2
  16. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +113 -148
  17. package/src/helpers/get-filter-props.js +4 -1
  18. package/tests/helpers/mocks.js +6 -0
  19. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +18 -4
  20. package/tests/unit/src/components/SearchFilter/SearchFilter/SearchFilter.test.js +64 -86
  21. package/tests/unit/src/components/SearchFilter/SearchFilter/__snapshots__/SearchFilter.test.js.snap +133 -61
  22. package/tests/unit/src/helpers/get-filter-props.test.js +10 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,40 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [0.122.2](https://github.com/thebyte9/blaze/compare/v0.122.1...v0.122.2) (2022-04-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add initial modifier to filter form ([be2254c](https://github.com/thebyte9/blaze/commit/be2254c967137b1c08e9989fcd1bf29d3675bb05))
12
+ * handle search filter with css ([872dc99](https://github.com/thebyte9/blaze/commit/872dc99b2ff26931bad9280f62b771d01a8c1c10))
13
+ * remove visibility ([7479231](https://github.com/thebyte9/blaze/commit/747923186c1c127dd82b4c4565b91b93e5812593))
14
+ * remove visibility ([32afbb4](https://github.com/thebyte9/blaze/commit/32afbb49f097a43e3e58a4938862a839beabe394))
15
+ * update to handle isCollapseOnMobile more consistently ([3123d99](https://github.com/thebyte9/blaze/commit/3123d9952f3d19391f91252bc1cfc716c787bed1))
16
+
17
+
18
+
19
+
20
+
21
+ ## [0.122.1](https://github.com/thebyte9/blaze/compare/v0.122.1-alpha.0...v0.122.1) (2022-03-21)
22
+
23
+ **Note:** Version bump only for package @blaze-cms/react-page-builder
24
+
25
+
26
+
27
+
28
+
29
+ ## [0.122.1-alpha.0](https://github.com/thebyte9/blaze/compare/v0.122.0...v0.122.1-alpha.0) (2022-03-16)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * handle non array data types when adding link to data summary ([#3382](https://github.com/thebyte9/blaze/issues/3382)) ([dd3ae87](https://github.com/thebyte9/blaze/commit/dd3ae8738d2ccc53909954b46b3f06d2cda93484))
35
+
36
+
37
+
38
+
39
+
6
40
  # [0.122.0](https://github.com/thebyte9/blaze/compare/v0.122.0-alpha.2...v0.122.0) (2022-03-15)
7
41
 
8
42
  **Note:** Version bump only for package @blaze-cms/react-page-builder
@@ -19,6 +19,8 @@ require("core-js/modules/es.regexp.exec.js");
19
19
 
20
20
  require("core-js/modules/es.string.split.js");
21
21
 
22
+ require("core-js/modules/es.array.is-array.js");
23
+
22
24
  var getLinkToPublishedContent = function getLinkToPublishedContent() {
23
25
  var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
24
26
  var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -28,8 +30,9 @@ var getLinkToPublishedContent = function getLinkToPublishedContent() {
28
30
  _key$split2 = (0, _slicedToArray2["default"])(_key$split, 1),
29
31
  baseKey = _key$split2[0];
30
32
 
31
- var content = props[baseKey] && props[baseKey][0];
32
- return content ? content.url : '';
33
+ if (!props[baseKey]) return '';
34
+ var content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
35
+ return content && content.url ? content.url : '';
33
36
  }
34
37
 
35
38
  return '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","split","baseKey","content","url"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,GAA0B;AAAA,MAAzBC,GAAyB,uEAAnB,EAAmB;AAAA,MAAfC,KAAe,uEAAP,EAAO;;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,qBAAkBF,GAAG,CAACG,KAAJ,CAAU,GAAV,CAAlB;AAAA;AAAA,QAAOC,OAAP;;AACA,QAAMC,OAAO,GAAGJ,KAAK,CAACG,OAAD,CAAL,IAAkBH,KAAK,CAACG,OAAD,CAAL,CAAe,CAAf,CAAlC;AACA,WAAOC,OAAO,GAAGA,OAAO,CAACC,GAAX,GAAiB,EAA/B;AACD;;AACD,SAAO,EAAP;AACD,CAPD;;eASeP,yB","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n const content = props[baseKey] && props[baseKey][0];\n return content ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
1
+ {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","split","baseKey","content","Array","isArray","url"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAMA,yBAAyB,GAAG,SAA5BA,yBAA4B,GAA0B;AAAA,MAAzBC,GAAyB,uEAAnB,EAAmB;AAAA,MAAfC,KAAe,uEAAP,EAAO;;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,qBAAkBF,GAAG,CAACG,KAAJ,CAAU,GAAV,CAAlB;AAAA;AAAA,QAAOC,OAAP;;AACA,QAAI,CAACH,KAAK,CAACG,OAAD,CAAV,EAAqB,OAAO,EAAP;AAErB,QAAMC,OAAO,GAAGC,KAAK,CAACC,OAAN,CAAcN,KAAK,CAACG,OAAD,CAAnB,IAAgCH,KAAK,CAACG,OAAD,CAAL,CAAe,CAAf,CAAhC,GAAoDH,KAAK,CAACG,OAAD,CAAzE;AACA,WAAOC,OAAO,IAAIA,OAAO,CAACG,GAAnB,GAAyBH,OAAO,CAACG,GAAjC,GAAuC,EAA9C;AACD;;AACD,SAAO,EAAP;AACD,CATD;;eAWeT,yB","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"],"file":"get-link-to-published-content.js"}
@@ -117,23 +117,13 @@ var SearchFilter = function SearchFilter(_ref) {
117
117
 
118
118
  var _useState = (0, _react.useState)(true),
119
119
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
120
- isDesktop = _useState2[0],
121
- setIsDesktop = _useState2[1];
120
+ moreFiltersMobileCollapsed = _useState2[0],
121
+ setMoreFiltersMobileCollapsed = _useState2[1];
122
122
 
123
- var _useState3 = (0, _react.useState)(null),
123
+ var _useState3 = (0, _react.useState)(true),
124
124
  _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
125
- pageWidth = _useState4[0],
126
- setPageWidth = _useState4[1];
127
-
128
- var _useState5 = (0, _react.useState)(true),
129
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
130
- moreFiltersMobileCollapsed = _useState6[0],
131
- setMoreFiltersMobileCollapsed = _useState6[1];
132
-
133
- var _useState7 = (0, _react.useState)(true),
134
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
135
- moreFiltersDesktopCollapsed = _useState8[0],
136
- setMoreFiltersDesktopCollapsed = _useState8[1];
125
+ moreFiltersDesktopCollapsed = _useState4[0],
126
+ setMoreFiltersDesktopCollapsed = _useState4[1];
137
127
 
138
128
  var _useReducer = (0, _react.useReducer)(reducer, initialFilterValues),
139
129
  _useReducer2 = (0, _slicedToArray2["default"])(_useReducer, 2),
@@ -144,24 +134,6 @@ var SearchFilter = function SearchFilter(_ref) {
144
134
  var newQuery = (0, _helpers.buildQuery)(newValues, filters);
145
135
  handleSearch(newQuery);
146
136
  }, 200);
147
- (0, _react.useEffect)(function () {
148
- if (window && !pageWidth) {
149
- setPageWidth(window.innerWidth);
150
- setIsDesktop((0, _helpers.isDeviceDesktop)());
151
- }
152
-
153
- var handleResize = function handleResize(_ref2) {
154
- var innerWidth = _ref2.target.innerWidth;
155
- setIsDesktop((0, _helpers.isDeviceDesktop)());
156
- setPageWidth(innerWidth);
157
- if (isDesktop) setDisplaySearchFilter(false);
158
- };
159
-
160
- window.addEventListener('resize', handleResize);
161
- return function () {
162
- window.removeEventListener('resize', handleResize);
163
- };
164
- }, [isDesktop, pageWidth, setDisplaySearchFilter]);
165
137
  (0, _react.useEffect)(function () {
166
138
  if (filterValues.shouldSearch) {
167
139
  handleSubmit(filterValues);
@@ -170,16 +142,9 @@ var SearchFilter = function SearchFilter(_ref) {
170
142
  });
171
143
  }
172
144
  }, [filterValues, handleSubmit]);
173
- var isDesktopFormDisplayed = true;
174
- var isMobileFormDisplayed = false;
175
-
176
- if (!isDesktop && isCollapsedOnResponsive) {
177
- isMobileFormDisplayed = displaySearchFilter;
178
- isDesktopFormDisplayed = false;
179
- }
180
-
181
- var formClass = (0, _classnames["default"])({
182
- 'filter__form filter__form--mobile': isMobileFormDisplayed
145
+ var formClass = (0, _classnames["default"])('filter__form filter__form--initial', {
146
+ 'filter__form--mobile': isCollapsedOnResponsive && displaySearchFilter,
147
+ 'filter__form--collapsible': isCollapsedOnResponsive
183
148
  });
184
149
 
185
150
  var _getResponsiveFilterC = (0, _helpers.getResponsiveFilterClassnames)(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed),
@@ -208,7 +173,7 @@ var SearchFilter = function SearchFilter(_ref) {
208
173
 
209
174
  var shouldGroup = !!(groupAfterDesktop || groupAfterMobile);
210
175
  var shouldSearch = !hasUrl;
211
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isDesktopFormDisplayed || isMobileFormDisplayed ? /*#__PURE__*/_react["default"].createElement("form", {
176
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("form", {
212
177
  ref: searchFilterRef,
213
178
  className: formClass,
214
179
  "data-testid": formId,
@@ -218,13 +183,13 @@ var SearchFilter = function SearchFilter(_ref) {
218
183
  var newQuery = (0, _helpers.buildQuery)(filterValues, filters);
219
184
  handleSearch(newQuery);
220
185
  }
221
- }, isMobileFormDisplayed && /*#__PURE__*/_react["default"].createElement(_CloseMobileForm["default"], {
186
+ }, displaySearchFilter && /*#__PURE__*/_react["default"].createElement(_CloseMobileForm["default"], {
222
187
  handleClose: function handleClose() {
223
188
  return setDisplaySearchFilter(false);
224
189
  }
225
190
  }), /*#__PURE__*/_react["default"].createElement("div", {
226
191
  className: "filter filter--search-refine"
227
- }, isDesktopFormDisplayed && /*#__PURE__*/_react["default"].createElement(_ResetDesktopForm["default"], {
192
+ }, /*#__PURE__*/_react["default"].createElement(_ResetDesktopForm["default"], {
228
193
  handleReset: handleReset
229
194
  }), /*#__PURE__*/_react["default"].createElement("div", {
230
195
  className: "filter__wrapper filter__wrapper--search-refine"
@@ -294,13 +259,13 @@ var SearchFilter = function SearchFilter(_ref) {
294
259
  }), /*#__PURE__*/_react["default"].createElement("button", {
295
260
  className: "button button--full-width",
296
261
  type: "submit"
297
- }, _constants.SEARCH)))), /*#__PURE__*/_react["default"].createElement("br", null), isDesktopFormDisplayed && /*#__PURE__*/_react["default"].createElement("button", {
262
+ }, _constants.SEARCH)))), /*#__PURE__*/_react["default"].createElement("br", null), !displaySearchFilter && /*#__PURE__*/_react["default"].createElement("button", {
298
263
  className: "button button--full-width",
299
264
  type: "submit"
300
- }, _constants.SEARCH))), isMobileFormDisplayed && /*#__PURE__*/_react["default"].createElement(_MobileFormToolbar["default"], {
265
+ }, _constants.SEARCH))), displaySearchFilter && /*#__PURE__*/_react["default"].createElement(_MobileFormToolbar["default"], {
301
266
  formId: formId,
302
267
  handleReset: handleReset
303
- })) : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, isCollapsedOnResponsive && /*#__PURE__*/_react["default"].createElement("div", {
268
+ })), isCollapsedOnResponsive && !displaySearchFilter && /*#__PURE__*/_react["default"].createElement("div", {
304
269
  className: "filter__refine filter__refine--mobile-close",
305
270
  "data-testid": "refine-mobile"
306
271
  }, /*#__PURE__*/_react["default"].createElement("div", {
@@ -308,7 +273,7 @@ var SearchFilter = function SearchFilter(_ref) {
308
273
  onClick: function onClick() {
309
274
  return setDisplaySearchFilter(true);
310
275
  }
311
- }, _constants.REFINE))));
276
+ }, _constants.REFINE)));
312
277
  };
313
278
 
314
279
  SearchFilter.propTypes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/SearchFilter/SearchFilter/SearchFilter.js"],"names":["reducer","state","action","newValues","type","shouldSearch","Error","SearchFilter","searchFilterRef","data","filters","hasUrl","entity","handleSearch","name","isCollapsedOnResponsive","displaySearchFilter","setDisplaySearchFilter","initialFilterValues","groupAfterDesktop","groupAfterMobile","isDesktop","setIsDesktop","pageWidth","setPageWidth","moreFiltersMobileCollapsed","setMoreFiltersMobileCollapsed","moreFiltersDesktopCollapsed","setMoreFiltersDesktopCollapsed","filterValues","dispatch","handleSubmit","newQuery","window","innerWidth","handleResize","target","addEventListener","removeEventListener","isDesktopFormDisplayed","isMobileFormDisplayed","formClass","moreFiltersMobileWrapperClass","moreFiltersMobileTogglerClass","moreFiltersDesktopWrapperClass","moreFiltersDesktopTogglerClass","formId","handleReset","updateFilterValues","shouldSubmit","shouldGroup","e","preventDefault","slice","MORE_FILTERS_CLASSES","MOBILE_CONTENT","DESKTOP_CONTENT","DESKTOP_BUTTONS","SEARCH","MOBILE_BUTTONS","REFINE","propTypes","PropTypes","object","isRequired","array","bool","string","func","number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,MAAR,EAAmB;AACjC,MAAQC,SAAR,GAAiDD,MAAjD,CAAQC,SAAR;AAAA,MAAmBC,IAAnB,GAAiDF,MAAjD,CAAmBE,IAAnB;AAAA,6BAAiDF,MAAjD,CAAyBG,YAAzB;AAAA,MAAyBA,YAAzB,qCAAwC,IAAxC;;AAEA,UAAQD,IAAR;AACE,SAAK,QAAL;AACE,2DAAYH,KAAZ,GAAsBE,SAAtB;AAAiCE,QAAAA,YAAY,EAAZA;AAAjC;;AACF,SAAK,aAAL;AACE,6CAAYJ,KAAZ;AAAmBI,QAAAA,YAAY,EAAE;AAAjC;;AACF,SAAK,OAAL;AACE,6CAAYF,SAAZ;AAAuBE,QAAAA,YAAY,EAAZA;AAAvB;;AACF;AACE,YAAM,IAAIC,KAAJ,EAAN;AARJ;AAUD,CAbD;;AAeA,IAAMC,YAAY,GAAG,SAAfA,YAAe,OAcf;AAAA,MAbJC,eAaI,QAbJA,eAaI;AAAA,MAZJC,IAYI,QAZJA,IAYI;AAAA,MAXJC,OAWI,QAXJA,OAWI;AAAA,MAVJC,MAUI,QA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,CAA5B;AAAA;AAA5B,KACG2C,iBADH,CAHF,CAFJ,CA9HJ,CADF;AA6ID,CAxOD;;AA0OArD,YAAY,CAACsD,SAAb,GAAyB;AACvBpD,EAAAA,IAAI,EAAEqD,sBAAUC,MAAV,CAAiBC,UADA;AAEvBtD,EAAAA,OAAO,EAAEoD,sBAAUG,KAAV,CAAgBD,UAFF;AAGvBxD,EAAAA,eAAe,EAAEsD,sBAAUC,MAAV,CAAiBC,UAHX;AAIvBrD,EAAAA,MAAM,EAAEmD,sBAAUI,IAAV,CAAeF,UAJA;AAKvBpD,EAAAA,MAAM,EAAEkD,sBAAUK,MAAV,CAAiBH,UALF;AAMvBnD,EAAAA,YAAY,EAAEiD,sBAAUM,IAAV,CAAeJ,UANN;AAOvBlD,EAAAA,IAAI,EAAEgD,sBAAUK,MAAV,CAAiBH,UAPA;AAQvBhD,EAAAA,mBAAmB,EAAE8C,sBAAUI,IAAV,CAAeF,UARb;AASvB/C,EAAAA,sBAAsB,EAAE6C,sBAAUM,IAAV,CAAeJ,UAThB;AAUvBjD,EAAAA,uBAAuB,EAAE+C,sBAAUI,IAAV,CAAeF,UAVjB;AAWvB7C,EAAAA,iBAAiB,EAAE2C,sBAAUO,MAAV,CAAiBL,UAXb;AAYvB5C,EAAAA,gBAAgB,EAAE0C,sBAAUO,MAAV,CAAiBL,UAZZ;AAavB9C,EAAAA,mBAAmB,EAAE4C,sBAAUC,MAAV,CAAiBC;AAbf,CAAzB;eAgBezD,Y","sourcesContent":["import React, { useState, useEffect, useReducer } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport FiltersList from './FiltersList';\nimport {\n isDeviceDesktop,\n buildQuery,\n getInitialFilterValues,\n getResponsiveFilterClassnames\n} from '../helpers';\nimport CloseMobileForm from './CloseMobileForm';\nimport ResetDesktopForm from './ResetDesktopForm';\nimport MobileFormToolbar from './MobileFormToolbar';\nimport { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';\n\nconst reducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return { ...newValues, shouldSearch };\n default:\n throw new Error();\n }\n};\n\nconst SearchFilter = ({\n searchFilterRef,\n data,\n filters,\n hasUrl,\n entity,\n handleSearch,\n name,\n isCollapsedOnResponsive,\n displaySearchFilter,\n setDisplaySearchFilter,\n initialFilterValues,\n groupAfterDesktop,\n groupAfterMobile\n}) => {\n const [isDesktop, setIsDesktop] = useState(true);\n const [pageWidth, setPageWidth] = useState(null);\n const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);\n const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);\n const [filterValues, dispatch] = useReducer(reducer, initialFilterValues);\n\n const handleSubmit = debounce(newValues => {\n const newQuery = buildQuery(newValues, filters);\n handleSearch(newQuery);\n }, 200);\n\n useEffect(\n () => {\n if (window && !pageWidth) {\n setPageWidth(window.innerWidth);\n setIsDesktop(isDeviceDesktop());\n }\n\n const handleResize = ({ target: { innerWidth } }) => {\n setIsDesktop(isDeviceDesktop());\n setPageWidth(innerWidth);\n if (isDesktop) setDisplaySearchFilter(false);\n };\n\n window.addEventListener('resize', handleResize);\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n },\n [isDesktop, pageWidth, setDisplaySearchFilter]\n );\n\n useEffect(\n () => {\n if (filterValues.shouldSearch) {\n handleSubmit(filterValues);\n dispatch({ type: 'resetSearch' });\n }\n },\n [filterValues, handleSubmit]\n );\n\n let isDesktopFormDisplayed = true;\n let isMobileFormDisplayed = false;\n\n if (!isDesktop && isCollapsedOnResponsive) {\n isMobileFormDisplayed = displaySearchFilter;\n isDesktopFormDisplayed = false;\n }\n\n const formClass = classnames({\n 'filter__form filter__form--mobile': isMobileFormDisplayed\n });\n\n const {\n moreFiltersMobileWrapperClass,\n moreFiltersMobileTogglerClass,\n moreFiltersDesktopWrapperClass,\n moreFiltersDesktopTogglerClass\n } = getResponsiveFilterClassnames(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed);\n\n const formId = `filter-${name}-form`;\n\n const handleReset = () => {\n const newValues = getInitialFilterValues(data, filters, {});\n\n dispatch({ newValues, type: 'reset' });\n };\n\n const updateFilterValues = (newValues, shouldSubmit) => {\n dispatch({ newValues, shouldSearch: shouldSubmit, type: 'update' });\n };\n\n const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);\n const shouldSearch = !hasUrl;\n\n return (\n <>\n {isDesktopFormDisplayed || isMobileFormDisplayed ? (\n <form\n ref={searchFilterRef}\n className={formClass}\n data-testid={formId}\n id={formId}\n onSubmit={e => {\n e.preventDefault();\n const newQuery = buildQuery(filterValues, filters);\n handleSearch(newQuery);\n }}>\n {isMobileFormDisplayed && (\n <CloseMobileForm handleClose={() => setDisplaySearchFilter(false)} />\n )}\n\n <div className=\"filter filter--search-refine\">\n {isDesktopFormDisplayed && <ResetDesktopForm handleReset={handleReset} />}\n\n <div className=\"filter__wrapper filter__wrapper--search-refine\">\n {!shouldGroup && (\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n )}\n\n {shouldGroup && (\n <>\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters.slice(0, groupAfterMobile)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterMobile && (\n <button\n className={moreFiltersMobileTogglerClass}\n type=\"button\"\n onClick={() => setMoreFiltersMobileCollapsed(!moreFiltersMobileCollapsed)}>\n Filters\n </button>\n )}\n\n <div className={moreFiltersMobileWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.MOBILE_CONTENT}>\n <FiltersList\n shouldSearch={shouldSearch && isDeviceDesktop()}\n data={data}\n filters={filters.slice(\n groupAfterMobile,\n groupAfterDesktop ? groupAfterDesktop - 1 : 0\n )}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterDesktop && (\n <button\n className={moreFiltersDesktopTogglerClass}\n type=\"button\"\n onClick={() =>\n setMoreFiltersDesktopCollapsed(!moreFiltersDesktopCollapsed)\n }>\n More filters\n </button>\n )}\n\n <div className={moreFiltersDesktopWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.DESKTOP_CONTENT}>\n <FiltersList\n shouldSearch={false}\n data={data}\n filters={filters.slice(groupAfterDesktop)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n </div>\n\n <div className={MORE_FILTERS_CLASSES.DESKTOP_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </div>\n\n <div className={MORE_FILTERS_CLASSES.MOBILE_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </>\n )}\n\n <br />\n\n {isDesktopFormDisplayed && (\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n )}\n </div>\n </div>\n\n {isMobileFormDisplayed && <MobileFormToolbar formId={formId} handleReset={handleReset} />}\n </form>\n ) : (\n <>\n {isCollapsedOnResponsive && (\n <div\n className=\"filter__refine filter__refine--mobile-close\"\n data-testid=\"refine-mobile\">\n <div role=\"button\" onClick={() => setDisplaySearchFilter(true)}>\n {REFINE}\n </div>\n </div>\n )}\n </>\n )}\n </>\n );\n};\n\nSearchFilter.propTypes = {\n data: PropTypes.object.isRequired,\n filters: PropTypes.array.isRequired,\n searchFilterRef: PropTypes.object.isRequired,\n hasUrl: PropTypes.bool.isRequired,\n entity: PropTypes.string.isRequired,\n handleSearch: PropTypes.func.isRequired,\n name: PropTypes.string.isRequired,\n displaySearchFilter: PropTypes.bool.isRequired,\n setDisplaySearchFilter: PropTypes.func.isRequired,\n isCollapsedOnResponsive: PropTypes.bool.isRequired,\n groupAfterDesktop: PropTypes.number.isRequired,\n groupAfterMobile: PropTypes.number.isRequired,\n initialFilterValues: PropTypes.object.isRequired\n};\n\nexport default SearchFilter;\n"],"file":"SearchFilter.js"}
1
+ {"version":3,"sources":["../../../../src/components/SearchFilter/SearchFilter/SearchFilter.js"],"names":["reducer","state","action","newValues","type","shouldSearch","Error","SearchFilter","searchFilterRef","data","filters","hasUrl","entity","handleSearch","name","isCollapsedOnResponsive","displaySearchFilter","setDisplaySearchFilter","initialFilterValues","groupAfterDesktop","groupAfterMobile","moreFiltersMobileCollapsed","setMoreFiltersMobileCollapsed","moreFiltersDesktopCollapsed","setMoreFiltersDesktopCollapsed","filterValues","dispatch","handleSubmit","newQuery","formClass","moreFiltersMobileWrapperClass","moreFiltersMobileTogglerClass","moreFiltersDesktopWrapperClass","moreFiltersDesktopTogglerClass","formId","handleReset","updateFilterValues","shouldSubmit","shouldGroup","e","preventDefault","slice","MORE_FILTERS_CLASSES","MOBILE_CONTENT","DESKTOP_CONTENT","DESKTOP_BUTTONS","SEARCH","MOBILE_BUTTONS","REFINE","propTypes","PropTypes","object","isRequired","array","bool","string","func","number"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAQC,MAAR,EAAmB;AACjC,MAAQC,SAAR,GAAiDD,MAAjD,CAAQC,SAAR;AAAA,MAAmBC,IAAnB,GAAiDF,MAAjD,CAAmBE,IAAnB;AAAA,6BAAiDF,MAAjD,CAAyBG,YAAzB;AAAA,MAAyBA,YAAzB,qCAAwC,IAAxC;;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AA,mBAAmB,EAAEkC,sBAAUI,IAAV,CAAeF,UARb;AASvBnC,EAAAA,sBAAsB,EAAEiC,sBAAUM,IAAV,CAAeJ,UAThB;AAUvBrC,EAAAA,uBAAuB,EAAEmC,sBAAUI,IAAV,CAAeF,UAVjB;AAWvBjC,EAAAA,iBAAiB,EAAE+B,sBAAUO,MAAV,CAAiBL,UAXb;AAYvBhC,EAAAA,gBAAgB,EAAE8B,sBAAUO,MAAV,CAAiBL,UAZZ;AAavBlC,EAAAA,mBAAmB,EAAEgC,sBAAUC,MAAV,CAAiBC;AAbf,CAAzB;eAgBe7C,Y","sourcesContent":["import React, { useState, useEffect, useReducer } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport FiltersList from './FiltersList';\nimport {\n isDeviceDesktop,\n buildQuery,\n getInitialFilterValues,\n getResponsiveFilterClassnames\n} from '../helpers';\nimport CloseMobileForm from './CloseMobileForm';\nimport ResetDesktopForm from './ResetDesktopForm';\nimport MobileFormToolbar from './MobileFormToolbar';\nimport { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';\n\nconst reducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return { ...newValues, shouldSearch };\n default:\n throw new Error();\n }\n};\n\nconst SearchFilter = ({\n searchFilterRef,\n data,\n filters,\n hasUrl,\n entity,\n handleSearch,\n name,\n isCollapsedOnResponsive,\n displaySearchFilter,\n setDisplaySearchFilter,\n initialFilterValues,\n groupAfterDesktop,\n groupAfterMobile\n}) => {\n const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);\n const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);\n const [filterValues, dispatch] = useReducer(reducer, initialFilterValues);\n\n const handleSubmit = debounce(newValues => {\n const newQuery = buildQuery(newValues, filters);\n handleSearch(newQuery);\n }, 200);\n\n useEffect(\n () => {\n if (filterValues.shouldSearch) {\n handleSubmit(filterValues);\n dispatch({ type: 'resetSearch' });\n }\n },\n [filterValues, handleSubmit]\n );\n\n const formClass = classnames('filter__form filter__form--initial', {\n 'filter__form--mobile': isCollapsedOnResponsive && displaySearchFilter,\n 'filter__form--collapsible': isCollapsedOnResponsive\n });\n\n const {\n moreFiltersMobileWrapperClass,\n moreFiltersMobileTogglerClass,\n moreFiltersDesktopWrapperClass,\n moreFiltersDesktopTogglerClass\n } = getResponsiveFilterClassnames(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed);\n\n const formId = `filter-${name}-form`;\n\n const handleReset = () => {\n const newValues = getInitialFilterValues(data, filters, {});\n\n dispatch({ newValues, type: 'reset' });\n };\n\n const updateFilterValues = (newValues, shouldSubmit) => {\n dispatch({ newValues, shouldSearch: shouldSubmit, type: 'update' });\n };\n\n const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);\n const shouldSearch = !hasUrl;\n\n return (\n <>\n <form\n ref={searchFilterRef}\n className={formClass}\n data-testid={formId}\n id={formId}\n onSubmit={e => {\n e.preventDefault();\n const newQuery = buildQuery(filterValues, filters);\n handleSearch(newQuery);\n }}>\n {displaySearchFilter && (\n <CloseMobileForm handleClose={() => setDisplaySearchFilter(false)} />\n )}\n\n <div className=\"filter filter--search-refine\">\n <ResetDesktopForm handleReset={handleReset} />\n\n <div className=\"filter__wrapper filter__wrapper--search-refine\">\n {!shouldGroup && (\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n )}\n\n {shouldGroup && (\n <>\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters.slice(0, groupAfterMobile)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterMobile && (\n <button\n className={moreFiltersMobileTogglerClass}\n type=\"button\"\n onClick={() => setMoreFiltersMobileCollapsed(!moreFiltersMobileCollapsed)}>\n Filters\n </button>\n )}\n\n <div className={moreFiltersMobileWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.MOBILE_CONTENT}>\n <FiltersList\n shouldSearch={shouldSearch && isDeviceDesktop()}\n data={data}\n filters={filters.slice(\n groupAfterMobile,\n groupAfterDesktop ? groupAfterDesktop - 1 : 0\n )}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterDesktop && (\n <button\n className={moreFiltersDesktopTogglerClass}\n type=\"button\"\n onClick={() =>\n setMoreFiltersDesktopCollapsed(!moreFiltersDesktopCollapsed)\n }>\n More filters\n </button>\n )}\n\n <div className={moreFiltersDesktopWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.DESKTOP_CONTENT}>\n <FiltersList\n shouldSearch={false}\n data={data}\n filters={filters.slice(groupAfterDesktop)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n </div>\n\n <div className={MORE_FILTERS_CLASSES.DESKTOP_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </div>\n\n <div className={MORE_FILTERS_CLASSES.MOBILE_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </>\n )}\n\n <br />\n\n {!displaySearchFilter && (\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n )}\n </div>\n </div>\n\n {displaySearchFilter && <MobileFormToolbar formId={formId} handleReset={handleReset} />}\n </form>\n\n {isCollapsedOnResponsive &&\n !displaySearchFilter && (\n <div className=\"filter__refine filter__refine--mobile-close\" data-testid=\"refine-mobile\">\n <div role=\"button\" onClick={() => setDisplaySearchFilter(true)}>\n {REFINE}\n </div>\n </div>\n )}\n </>\n );\n};\n\nSearchFilter.propTypes = {\n data: PropTypes.object.isRequired,\n filters: PropTypes.array.isRequired,\n searchFilterRef: PropTypes.object.isRequired,\n hasUrl: PropTypes.bool.isRequired,\n entity: PropTypes.string.isRequired,\n handleSearch: PropTypes.func.isRequired,\n name: PropTypes.string.isRequired,\n displaySearchFilter: PropTypes.bool.isRequired,\n setDisplaySearchFilter: PropTypes.func.isRequired,\n isCollapsedOnResponsive: PropTypes.bool.isRequired,\n groupAfterDesktop: PropTypes.number.isRequired,\n groupAfterMobile: PropTypes.number.isRequired,\n initialFilterValues: PropTypes.object.isRequired\n};\n\nexport default SearchFilter;\n"],"file":"SearchFilter.js"}
@@ -47,6 +47,8 @@ var getFilterProps = function getFilterProps(filter) {
47
47
  currentEntityRelations = _ref5$relations === void 0 ? [] : _ref5$relations,
48
48
  _ref5$properties = _ref5.properties,
49
49
  currentEntityProperties = _ref5$properties === void 0 ? {} : _ref5$properties,
50
+ _ref5$dynamicProperti = _ref5.dynamicProperties,
51
+ currentEntityDynamicProperties = _ref5$dynamicProperti === void 0 ? {} : _ref5$dynamicProperti,
50
52
  currentEntityId = _ref5.identifier;
51
53
 
52
54
  var _ref6 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {},
@@ -63,7 +65,7 @@ var getFilterProps = function getFilterProps(filter) {
63
65
  relationName = _filterName$split2[0],
64
66
  relationProp = _filterName$split2[1];
65
67
 
66
- var hasProperty = !!currentEntityProperties[filterName];
68
+ var hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
67
69
  var relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
68
70
  var filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
69
71
  var propertyEntityName = relationEntityName || filterNameEntity;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterLocalKeys","relationName","relations","find","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","currentEntityId","identifier","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,YAAD,EAAeC,SAAf,EAA6B;AACtD,aACEA,SAAS,CAACC,IAAV,CAAe;AAAA,QAAGC,UAAH,SAAGA,UAAH;AAAA,WAAoBA,UAAU,KAAKH,YAAnC;AAAA,GAAf,KAAmE,EADrE;AAAA,MAAQI,gBAAR,QAAQA,gBAAR;;AAEA,SAAOA,gBAAP;AACD,CAJD;;AAMA,IAAMC,iBAAiB,GAAG,SAApBA,iBAAoB,CAACC,UAAD,EAAaC,qBAAb,EAAuC;AAC/D,cACEA,qBAAqB,CAACL,IAAtB,CAA2B;AAAA,QAAGM,UAAH,SAAGA,UAAH;AAAA,WAAoBA,UAAU,KAAKF,UAAnC;AAAA,GAA3B,KAA6E,EAD/E;AAAA,MAAQF,gBAAR,SAAQA,gBAAR;;AAEA,SAAOA,gBAAP;AACD,CAJD;;AAMA,IAAMK,cAAc,GAAG,SAAjBA,cAAiB,CACrBC,MADqB,EAQlB;AAAA,kFAFC,EAED;AAAA,8BALDT,SAKC;AAAA,MALUU,sBAKV,gCALmC,EAKnC;AAAA,+BAJDC,UAIC;AAAA,MAJWC,uBAIX,iCAJqC,EAIrC;AAAA,MAHWC,eAGX,SAHDC,UAGC;;AAAA,kFADsE,EACtE;AAAA,8BADDd,SACC;AAAA,MADUM,qBACV,gCADkC,EAClC;AAAA,MADkDS,eAClD,SADsCD,UACtC;;AACH,sBAAqBL,MAAM,CAACO,KAAP,CAAa,GAAb,CAArB;AAAA;AAAA,MAAOX,UAAP;;AACA,0BAAqCA,UAAU,CAACW,KAAX,CAAiB,GAAjB,CAArC;AAAA;AAAA,MAAOjB,YAAP;AAAA,MAAqBkB,YAArB;;AACA,MAAMC,WAAW,GAAG,CAAC,CAACN,uBAAuB,CAACP,UAAD,CAA7C;AACA,MAAMc,kBAAkB,GAAGF,YAAY,GACnCnB,kBAAkB,CAACC,YAAD,EAAeW,sBAAf,CADiB,GAEnC,IAFJ;AAGA,MAAMU,gBAAgB,GAAGhB,iBAAiB,CAACC,UAAD,EAAaC,qBAAb,CAA1C;AAEA,MAAMe,kBAAkB,GAAGF,kBAAkB,IAAIC,gBAAjD;AACA,MAAME,UAAU,GAAGF,gBAAgB,GAAGL,eAAH,GAAqBI,kBAAxD;AACA,MAAMI,cAAc,GAAGV,eAAe,KAAKQ,kBAA3C;AACA,MAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,MAAMM,mBAAmB,GAAGD,wBAAwB,GAChD,uCAAsBH,kBAAtB,EAA0CX,sBAA1C,EAAkEE,uBAAlE,CADgD,GAEhD,EAFJ;AAGA,MAAMc,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLtB,IAAAA,UAAU,EAAVA,UADK;AAELiB,IAAAA,UAAU,EAAVA,UAFK;AAGLvB,IAAAA,YAAY,EAAZA,YAHK;AAILkB,IAAAA,YAAY,EAAZA,YAJK;AAKLC,IAAAA,WAAW,EAAXA,WALK;AAMLC,IAAAA,kBAAkB,EAAlBA,kBANK;AAOLI,IAAAA,cAAc,EAAdA,cAPK;AAQLE,IAAAA,mBAAmB,EAAnBA,mBARK;AASLC,IAAAA,kBAAkB,EAAlBA;AATK,GAAP;AAWD,CArCD;;eAuCelB,c","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!currentEntityProperties[filterName];\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
1
+ {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterLocalKeys","relationName","relations","find","localField","entityIdentifier","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","dynamicProperties","currentEntityDynamicProperties","currentEntityId","identifier","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;AAEA,IAAMA,kBAAkB,GAAG,SAArBA,kBAAqB,CAACC,YAAD,EAAeC,SAAf,EAA6B;AACtD,aACEA,SAAS,CAACC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MY,gBAAgB,GAAGlB,iBAAiB,CAACC,UAAD,EAAaC,qBAAb,CAA1C;AAEA,MAAMiB,kBAAkB,GAAGF,kBAAkB,IAAIC,gBAAjD;AACA,MAAME,UAAU,GAAGF,gBAAgB,GAAGL,eAAH,GAAqBI,kBAAxD;AACA,MAAMI,cAAc,GAAGV,eAAe,KAAKQ,kBAA3C;AACA,MAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,MAAMM,mBAAmB,GAAGD,wBAAwB,GAChD,uCAAsBH,kBAAtB,EAA0Cb,sBAA1C,EAAkEE,uBAAlE,CADgD,GAEhD,EAFJ;AAGA,MAAMgB,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLxB,IAAAA,UAAU,EAAVA,UADK;AAELmB,IAAAA,UAAU,EAAVA,UAFK;AAGLzB,IAAAA,YAAY,EAAZA,YAHK;AAILoB,IAAAA,YAAY,EAAZA,YAJK;AAKLC,IAAAA,WAAW,EAAXA,WALK;AAMLC,IAAAA,kBAAkB,EAAlBA,kBANK;AAOLI,IAAAA,cAAc,EAAdA,cAPK;AAQLE,IAAAA,mBAAmB,EAAnBA,mBARK;AASLC,IAAAA,kBAAkB,EAAlBA;AATK,GAAP;AAWD,CAxCD;;eA0CepB,c","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n dynamicProperties: currentEntityDynamicProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!(\n currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]\n );\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
@@ -1,8 +1,9 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
2
  if (key.includes('published')) {
3
3
  const [baseKey] = key.split('.');
4
- const content = props[baseKey] && props[baseKey][0];
5
- return content ? content.url : '';
4
+ if (!props[baseKey]) return '';
5
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
6
+ return content && content.url ? content.url : '';
6
7
  }
7
8
 
8
9
  return '';
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","baseKey","split","content","url"],"mappings":"AAAA,MAAMA,yBAAyB,GAAG,CAACC,GAAG,GAAG,EAAP,EAAWC,KAAK,GAAG,EAAnB,KAA0B;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,UAAM,CAACC,OAAD,IAAYH,GAAG,CAACI,KAAJ,CAAU,GAAV,CAAlB;AACA,UAAMC,OAAO,GAAGJ,KAAK,CAACE,OAAD,CAAL,IAAkBF,KAAK,CAACE,OAAD,CAAL,CAAe,CAAf,CAAlC;AACA,WAAOE,OAAO,GAAGA,OAAO,CAACC,GAAX,GAAiB,EAA/B;AACD;;AACD,SAAO,EAAP;AACD,CAPD;;AASA,eAAeP,yBAAf","sourcesContent":["const getLinkToPublishedContent = (key = '', props = {}) => {\n if (key.includes('published')) {\n const [baseKey] = key.split('.');\n const content = props[baseKey] && props[baseKey][0];\n return content ? content.url : '';\n }\n return '';\n};\n\nexport default getLinkToPublishedContent;\n"],"file":"get-link-to-published-content.js"}
1
+ {"version":3,"sources":["../../../../src/components/DataSummary/helpers/get-link-to-published-content.js"],"names":["getLinkToPublishedContent","key","props","includes","baseKey","split","content","Array","isArray","url"],"mappings":"AAAA,MAAMA,yBAAyB,GAAG,CAACC,GAAG,GAAG,EAAP,EAAWC,KAAK,GAAG,EAAnB,KAA0B;AAC1D,MAAID,GAAG,CAACE,QAAJ,CAAa,WAAb,CAAJ,EAA+B;AAC7B,UAAM,CAACC,OAAD,IAAYH,GAAG,CAACI,KAAJ,CAAU,GAAV,CAAlB;AACA,QAAI,CAACH,KAAK,CAACE,OAAD,CAAV,EAAqB,OAAO,EAAP;AAErB,UAAME,OAAO,GAAGC,KAAK,CAACC,OAAN,CAAcN,KAAK,CAACE,OAAD,CAAnB,IAAgCF,KAAK,CAACE,OAAD,CAAL,CAAe,CAAf,CAAhC,GAAoDF,KAAK,CAACE,OAAD,CAAzE;AACA,WAAOE,OAAO,IAAIA,OAAO,CAACG,GAAnB,GAAyBH,OAAO,CAACG,GAAjC,GAAuC,EAA9C;AACD;;AACD,SAAO,EAAP;AACD,CATD;;AAWA,eAAeT,yBAAf","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"],"file":"get-link-to-published-content.js"}
@@ -58,8 +58,6 @@ const SearchFilter = ({
58
58
  groupAfterDesktop,
59
59
  groupAfterMobile
60
60
  }) => {
61
- const [isDesktop, setIsDesktop] = useState(true);
62
- const [pageWidth, setPageWidth] = useState(null);
63
61
  const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);
64
62
  const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);
65
63
  const [filterValues, dispatch] = useReducer(reducer, initialFilterValues);
@@ -67,27 +65,6 @@ const SearchFilter = ({
67
65
  const newQuery = buildQuery(newValues, filters);
68
66
  handleSearch(newQuery);
69
67
  }, 200);
70
- useEffect(() => {
71
- if (window && !pageWidth) {
72
- setPageWidth(window.innerWidth);
73
- setIsDesktop(isDeviceDesktop());
74
- }
75
-
76
- const handleResize = ({
77
- target: {
78
- innerWidth
79
- }
80
- }) => {
81
- setIsDesktop(isDeviceDesktop());
82
- setPageWidth(innerWidth);
83
- if (isDesktop) setDisplaySearchFilter(false);
84
- };
85
-
86
- window.addEventListener('resize', handleResize);
87
- return () => {
88
- window.removeEventListener('resize', handleResize);
89
- };
90
- }, [isDesktop, pageWidth, setDisplaySearchFilter]);
91
68
  useEffect(() => {
92
69
  if (filterValues.shouldSearch) {
93
70
  handleSubmit(filterValues);
@@ -96,16 +73,9 @@ const SearchFilter = ({
96
73
  });
97
74
  }
98
75
  }, [filterValues, handleSubmit]);
99
- let isDesktopFormDisplayed = true;
100
- let isMobileFormDisplayed = false;
101
-
102
- if (!isDesktop && isCollapsedOnResponsive) {
103
- isMobileFormDisplayed = displaySearchFilter;
104
- isDesktopFormDisplayed = false;
105
- }
106
-
107
- const formClass = classnames({
108
- 'filter__form filter__form--mobile': isMobileFormDisplayed
76
+ const formClass = classnames('filter__form filter__form--initial', {
77
+ 'filter__form--mobile': isCollapsedOnResponsive && displaySearchFilter,
78
+ 'filter__form--collapsible': isCollapsedOnResponsive
109
79
  });
110
80
  const {
111
81
  moreFiltersMobileWrapperClass,
@@ -133,7 +103,7 @@ const SearchFilter = ({
133
103
 
134
104
  const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);
135
105
  const shouldSearch = !hasUrl;
136
- return /*#__PURE__*/React.createElement(React.Fragment, null, isDesktopFormDisplayed || isMobileFormDisplayed ? /*#__PURE__*/React.createElement("form", {
106
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("form", {
137
107
  ref: searchFilterRef,
138
108
  className: formClass,
139
109
  "data-testid": formId,
@@ -143,11 +113,11 @@ const SearchFilter = ({
143
113
  const newQuery = buildQuery(filterValues, filters);
144
114
  handleSearch(newQuery);
145
115
  }
146
- }, isMobileFormDisplayed && /*#__PURE__*/React.createElement(CloseMobileForm, {
116
+ }, displaySearchFilter && /*#__PURE__*/React.createElement(CloseMobileForm, {
147
117
  handleClose: () => setDisplaySearchFilter(false)
148
118
  }), /*#__PURE__*/React.createElement("div", {
149
119
  className: "filter filter--search-refine"
150
- }, isDesktopFormDisplayed && /*#__PURE__*/React.createElement(ResetDesktopForm, {
120
+ }, /*#__PURE__*/React.createElement(ResetDesktopForm, {
151
121
  handleReset: handleReset
152
122
  }), /*#__PURE__*/React.createElement("div", {
153
123
  className: "filter__wrapper filter__wrapper--search-refine"
@@ -213,19 +183,19 @@ const SearchFilter = ({
213
183
  }), /*#__PURE__*/React.createElement("button", {
214
184
  className: "button button--full-width",
215
185
  type: "submit"
216
- }, SEARCH)))), /*#__PURE__*/React.createElement("br", null), isDesktopFormDisplayed && /*#__PURE__*/React.createElement("button", {
186
+ }, SEARCH)))), /*#__PURE__*/React.createElement("br", null), !displaySearchFilter && /*#__PURE__*/React.createElement("button", {
217
187
  className: "button button--full-width",
218
188
  type: "submit"
219
- }, SEARCH))), isMobileFormDisplayed && /*#__PURE__*/React.createElement(MobileFormToolbar, {
189
+ }, SEARCH))), displaySearchFilter && /*#__PURE__*/React.createElement(MobileFormToolbar, {
220
190
  formId: formId,
221
191
  handleReset: handleReset
222
- })) : /*#__PURE__*/React.createElement(React.Fragment, null, isCollapsedOnResponsive && /*#__PURE__*/React.createElement("div", {
192
+ })), isCollapsedOnResponsive && !displaySearchFilter && /*#__PURE__*/React.createElement("div", {
223
193
  className: "filter__refine filter__refine--mobile-close",
224
194
  "data-testid": "refine-mobile"
225
195
  }, /*#__PURE__*/React.createElement("div", {
226
196
  role: "button",
227
197
  onClick: () => setDisplaySearchFilter(true)
228
- }, REFINE))));
198
+ }, REFINE)));
229
199
  };
230
200
 
231
201
  SearchFilter.propTypes = {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/SearchFilter/SearchFilter/SearchFilter.js"],"names":["React","useState","useEffect","useReducer","PropTypes","classnames","debounce","FiltersList","isDeviceDesktop","buildQuery","getInitialFilterValues","getResponsiveFilterClassnames","CloseMobileForm","ResetDesktopForm","MobileFormToolbar","SEARCH","REFINE","MORE_FILTERS_CLASSES","reducer","state","action","newValues","type","shouldSearch","Error","SearchFilter","searchFilterRef","data","filters","hasUrl","entity","handleSearch","name","isCollapsedOnResponsive","displaySearchFilter","setDisplaySearchFilter","initialFilterValues","groupAfterDesktop","groupAfterMobile","isDesktop","setIsDesktop","pageWidth","setPageWidth","moreFiltersMobileCollapsed","setMoreFiltersMobileCollapsed","moreFiltersDesktopCollapsed","setMoreFiltersDesktopCollapsed","filterValues","dispatch","handleSubmit","newQuery","window","innerWidth","handleResize","target","addEventListener","removeEventListener","isDesktopFormDisplayed","isMobileFormDisplayed","formClass","moreFiltersMobileWrapperClass","moreFiltersMobileTogglerClass","moreFiltersDesktopWrapperClass","moreFiltersDesktopTogglerClass","formId","handleReset","updateFilterValues","shouldSubmit","shouldGroup","e","preventDefault","slice","MOBILE_CONTENT","DESKTOP_CONTENT","DESKTOP_BUTTONS","MOBILE_BUTTONS","propTypes","object","isRequired","array","bool","string","func","number"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAA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AMvB/C,EAAAA,YAAY,EAAE3B,SAAS,CAAC8E,IAAV,CAAeJ,UANN;AAOvB9C,EAAAA,IAAI,EAAE5B,SAAS,CAAC6E,MAAV,CAAiBH,UAPA;AAQvB5C,EAAAA,mBAAmB,EAAE9B,SAAS,CAAC4E,IAAV,CAAeF,UARb;AASvB3C,EAAAA,sBAAsB,EAAE/B,SAAS,CAAC8E,IAAV,CAAeJ,UAThB;AAUvB7C,EAAAA,uBAAuB,EAAE7B,SAAS,CAAC4E,IAAV,CAAeF,UAVjB;AAWvBzC,EAAAA,iBAAiB,EAAEjC,SAAS,CAAC+E,MAAV,CAAiBL,UAXb;AAYvBxC,EAAAA,gBAAgB,EAAElC,SAAS,CAAC+E,MAAV,CAAiBL,UAZZ;AAavB1C,EAAAA,mBAAmB,EAAEhC,SAAS,CAACyE,MAAV,CAAiBC;AAbf,CAAzB;AAgBA,eAAerD,YAAf","sourcesContent":["import React, { useState, useEffect, useReducer } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport FiltersList from './FiltersList';\nimport {\n isDeviceDesktop,\n buildQuery,\n getInitialFilterValues,\n getResponsiveFilterClassnames\n} from '../helpers';\nimport CloseMobileForm from './CloseMobileForm';\nimport ResetDesktopForm from './ResetDesktopForm';\nimport MobileFormToolbar from './MobileFormToolbar';\nimport { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';\n\nconst reducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return { ...newValues, shouldSearch };\n default:\n throw new Error();\n }\n};\n\nconst SearchFilter = ({\n searchFilterRef,\n data,\n filters,\n hasUrl,\n entity,\n handleSearch,\n name,\n isCollapsedOnResponsive,\n displaySearchFilter,\n setDisplaySearchFilter,\n initialFilterValues,\n groupAfterDesktop,\n groupAfterMobile\n}) => {\n const [isDesktop, setIsDesktop] = useState(true);\n const [pageWidth, setPageWidth] = useState(null);\n const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);\n const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);\n const [filterValues, dispatch] = useReducer(reducer, initialFilterValues);\n\n const handleSubmit = debounce(newValues => {\n const newQuery = buildQuery(newValues, filters);\n handleSearch(newQuery);\n }, 200);\n\n useEffect(\n () => {\n if (window && !pageWidth) {\n setPageWidth(window.innerWidth);\n setIsDesktop(isDeviceDesktop());\n }\n\n const handleResize = ({ target: { innerWidth } }) => {\n setIsDesktop(isDeviceDesktop());\n setPageWidth(innerWidth);\n if (isDesktop) setDisplaySearchFilter(false);\n };\n\n window.addEventListener('resize', handleResize);\n return () => {\n window.removeEventListener('resize', handleResize);\n };\n },\n [isDesktop, pageWidth, setDisplaySearchFilter]\n );\n\n useEffect(\n () => {\n if (filterValues.shouldSearch) {\n handleSubmit(filterValues);\n dispatch({ type: 'resetSearch' });\n }\n },\n [filterValues, handleSubmit]\n );\n\n let isDesktopFormDisplayed = true;\n let isMobileFormDisplayed = false;\n\n if (!isDesktop && isCollapsedOnResponsive) {\n isMobileFormDisplayed = displaySearchFilter;\n isDesktopFormDisplayed = false;\n }\n\n const formClass = classnames({\n 'filter__form filter__form--mobile': isMobileFormDisplayed\n });\n\n const {\n moreFiltersMobileWrapperClass,\n moreFiltersMobileTogglerClass,\n moreFiltersDesktopWrapperClass,\n moreFiltersDesktopTogglerClass\n } = getResponsiveFilterClassnames(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed);\n\n const formId = `filter-${name}-form`;\n\n const handleReset = () => {\n const newValues = getInitialFilterValues(data, filters, {});\n\n dispatch({ newValues, type: 'reset' });\n };\n\n const updateFilterValues = (newValues, shouldSubmit) => {\n dispatch({ newValues, shouldSearch: shouldSubmit, type: 'update' });\n };\n\n const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);\n const shouldSearch = !hasUrl;\n\n return (\n <>\n {isDesktopFormDisplayed || isMobileFormDisplayed ? (\n <form\n ref={searchFilterRef}\n className={formClass}\n data-testid={formId}\n id={formId}\n onSubmit={e => {\n e.preventDefault();\n const newQuery = buildQuery(filterValues, filters);\n handleSearch(newQuery);\n }}>\n {isMobileFormDisplayed && (\n <CloseMobileForm handleClose={() => setDisplaySearchFilter(false)} />\n )}\n\n <div className=\"filter filter--search-refine\">\n {isDesktopFormDisplayed && <ResetDesktopForm handleReset={handleReset} />}\n\n <div className=\"filter__wrapper filter__wrapper--search-refine\">\n {!shouldGroup && (\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n )}\n\n {shouldGroup && (\n <>\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters.slice(0, groupAfterMobile)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterMobile && (\n <button\n className={moreFiltersMobileTogglerClass}\n type=\"button\"\n onClick={() => setMoreFiltersMobileCollapsed(!moreFiltersMobileCollapsed)}>\n Filters\n </button>\n )}\n\n <div className={moreFiltersMobileWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.MOBILE_CONTENT}>\n <FiltersList\n shouldSearch={shouldSearch && isDeviceDesktop()}\n data={data}\n filters={filters.slice(\n groupAfterMobile,\n groupAfterDesktop ? groupAfterDesktop - 1 : 0\n )}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterDesktop && (\n <button\n className={moreFiltersDesktopTogglerClass}\n type=\"button\"\n onClick={() =>\n setMoreFiltersDesktopCollapsed(!moreFiltersDesktopCollapsed)\n }>\n More filters\n </button>\n )}\n\n <div className={moreFiltersDesktopWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.DESKTOP_CONTENT}>\n <FiltersList\n shouldSearch={false}\n data={data}\n filters={filters.slice(groupAfterDesktop)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n </div>\n\n <div className={MORE_FILTERS_CLASSES.DESKTOP_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </div>\n\n <div className={MORE_FILTERS_CLASSES.MOBILE_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </>\n )}\n\n <br />\n\n {isDesktopFormDisplayed && (\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n )}\n </div>\n </div>\n\n {isMobileFormDisplayed && <MobileFormToolbar formId={formId} handleReset={handleReset} />}\n </form>\n ) : (\n <>\n {isCollapsedOnResponsive && (\n <div\n className=\"filter__refine filter__refine--mobile-close\"\n data-testid=\"refine-mobile\">\n <div role=\"button\" onClick={() => setDisplaySearchFilter(true)}>\n {REFINE}\n </div>\n </div>\n )}\n </>\n )}\n </>\n );\n};\n\nSearchFilter.propTypes = {\n data: PropTypes.object.isRequired,\n filters: PropTypes.array.isRequired,\n searchFilterRef: PropTypes.object.isRequired,\n hasUrl: PropTypes.bool.isRequired,\n entity: PropTypes.string.isRequired,\n handleSearch: PropTypes.func.isRequired,\n name: PropTypes.string.isRequired,\n displaySearchFilter: PropTypes.bool.isRequired,\n setDisplaySearchFilter: PropTypes.func.isRequired,\n isCollapsedOnResponsive: PropTypes.bool.isRequired,\n groupAfterDesktop: PropTypes.number.isRequired,\n groupAfterMobile: PropTypes.number.isRequired,\n initialFilterValues: PropTypes.object.isRequired\n};\n\nexport default SearchFilter;\n"],"file":"SearchFilter.js"}
1
+ {"version":3,"sources":["../../../../src/components/SearchFilter/SearchFilter/SearchFilter.js"],"names":["React","useState","useEffect","useReducer","PropTypes","classnames","debounce","FiltersList","isDeviceDesktop","buildQuery","getInitialFilterValues","getResponsiveFilterClassnames","CloseMobileForm","ResetDesktopForm","MobileFormToolbar","SEARCH","REFINE","MORE_FILTERS_CLASSES","reducer","state","action","newValues","type","shouldSearch","Error","SearchFilter","searchFilterRef","data","filters","hasUrl","entity","handleSearch","name","isCollapsedOnResponsive","displaySearchFilter","setDisplaySearchFilter","initialFilterValues","groupAfterDesktop","groupAfterMobile","moreFiltersMobileCollapsed","setMoreFiltersMobileCollapsed","moreFiltersDesktopCollapsed","setMoreFiltersDesktopCollapsed","filterValues","dispatch","handleSubmit","newQuery","formClass","moreFiltersMobileWrapperClass","moreFiltersMobileTogglerClass","moreFiltersDesktopWrapperClass","moreFiltersDesktopTogglerClass","formId","handleReset","updateFilterValues","shouldSubmit","shouldGroup","e","preventDefault","slice","MOBILE_CONTENT","DESKTOP_CONTENT","DESKTOP_BUTTONS","MOBILE_BUTTONS","propTypes","object","isRequired","array","bool","string","func","number"],"mappings":";;;;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,EAAqCC,UAArC,QAAuD,OAAvD;AACA,OAAOC,SAAP,MAAsB,YAAtB;AACA,OAAOC,UAAP,MAAuB,YAAvB;AACA,OAAOC,QAAP,MAAqB,iBAArB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AACA,SACEC,eADF,EAEEC,UAFF,EAGEC,sBAHF,EAIEC,6BAJF,QAKO,YALP;AAMA,OAAOC,eAAP,MAA4B,mBAA5B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,iBAAP,MAA8B,qBAA9B;AACA,SAASC,MAAT,EAAiBC,MAAjB,EAAyBC,oBAAzB,QAAqD,cAArD;;AAEA,MAAMC,OAAO,GAAG,CAACC,KAAD,EAAQC,MAAR,KAAmB;AACjC,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,IAAb;AAAmBC,IAAAA,YAAY,GAAG;AAAlC,MAA2CH,MAAjD;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Xb;AAYvB5B,EAAAA,gBAAgB,EAAElC,SAAS,CAACmE,MAAV,CAAiBL,UAZZ;AAavB9B,EAAAA,mBAAmB,EAAEhC,SAAS,CAAC6D,MAAV,CAAiBC;AAbf,CAAzB;AAgBA,eAAezC,YAAf","sourcesContent":["import React, { useState, useEffect, useReducer } from 'react';\nimport PropTypes from 'prop-types';\nimport classnames from 'classnames';\nimport debounce from 'lodash.debounce';\nimport FiltersList from './FiltersList';\nimport {\n isDeviceDesktop,\n buildQuery,\n getInitialFilterValues,\n getResponsiveFilterClassnames\n} from '../helpers';\nimport CloseMobileForm from './CloseMobileForm';\nimport ResetDesktopForm from './ResetDesktopForm';\nimport MobileFormToolbar from './MobileFormToolbar';\nimport { SEARCH, REFINE, MORE_FILTERS_CLASSES } from '../constants';\n\nconst reducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return { ...newValues, shouldSearch };\n default:\n throw new Error();\n }\n};\n\nconst SearchFilter = ({\n searchFilterRef,\n data,\n filters,\n hasUrl,\n entity,\n handleSearch,\n name,\n isCollapsedOnResponsive,\n displaySearchFilter,\n setDisplaySearchFilter,\n initialFilterValues,\n groupAfterDesktop,\n groupAfterMobile\n}) => {\n const [moreFiltersMobileCollapsed, setMoreFiltersMobileCollapsed] = useState(true);\n const [moreFiltersDesktopCollapsed, setMoreFiltersDesktopCollapsed] = useState(true);\n const [filterValues, dispatch] = useReducer(reducer, initialFilterValues);\n\n const handleSubmit = debounce(newValues => {\n const newQuery = buildQuery(newValues, filters);\n handleSearch(newQuery);\n }, 200);\n\n useEffect(\n () => {\n if (filterValues.shouldSearch) {\n handleSubmit(filterValues);\n dispatch({ type: 'resetSearch' });\n }\n },\n [filterValues, handleSubmit]\n );\n\n const formClass = classnames('filter__form filter__form--initial', {\n 'filter__form--mobile': isCollapsedOnResponsive && displaySearchFilter,\n 'filter__form--collapsible': isCollapsedOnResponsive\n });\n\n const {\n moreFiltersMobileWrapperClass,\n moreFiltersMobileTogglerClass,\n moreFiltersDesktopWrapperClass,\n moreFiltersDesktopTogglerClass\n } = getResponsiveFilterClassnames(moreFiltersDesktopCollapsed, moreFiltersMobileCollapsed);\n\n const formId = `filter-${name}-form`;\n\n const handleReset = () => {\n const newValues = getInitialFilterValues(data, filters, {});\n\n dispatch({ newValues, type: 'reset' });\n };\n\n const updateFilterValues = (newValues, shouldSubmit) => {\n dispatch({ newValues, shouldSearch: shouldSubmit, type: 'update' });\n };\n\n const shouldGroup = !!(groupAfterDesktop || groupAfterMobile);\n const shouldSearch = !hasUrl;\n\n return (\n <>\n <form\n ref={searchFilterRef}\n className={formClass}\n data-testid={formId}\n id={formId}\n onSubmit={e => {\n e.preventDefault();\n const newQuery = buildQuery(filterValues, filters);\n handleSearch(newQuery);\n }}>\n {displaySearchFilter && (\n <CloseMobileForm handleClose={() => setDisplaySearchFilter(false)} />\n )}\n\n <div className=\"filter filter--search-refine\">\n <ResetDesktopForm handleReset={handleReset} />\n\n <div className=\"filter__wrapper filter__wrapper--search-refine\">\n {!shouldGroup && (\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n )}\n\n {shouldGroup && (\n <>\n <FiltersList\n shouldSearch={shouldSearch}\n data={data}\n filters={filters.slice(0, groupAfterMobile)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterMobile && (\n <button\n className={moreFiltersMobileTogglerClass}\n type=\"button\"\n onClick={() => setMoreFiltersMobileCollapsed(!moreFiltersMobileCollapsed)}>\n Filters\n </button>\n )}\n\n <div className={moreFiltersMobileWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.MOBILE_CONTENT}>\n <FiltersList\n shouldSearch={shouldSearch && isDeviceDesktop()}\n data={data}\n filters={filters.slice(\n groupAfterMobile,\n groupAfterDesktop ? groupAfterDesktop - 1 : 0\n )}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n\n {!!groupAfterDesktop && (\n <button\n className={moreFiltersDesktopTogglerClass}\n type=\"button\"\n onClick={() =>\n setMoreFiltersDesktopCollapsed(!moreFiltersDesktopCollapsed)\n }>\n More filters\n </button>\n )}\n\n <div className={moreFiltersDesktopWrapperClass}>\n <div className={MORE_FILTERS_CLASSES.DESKTOP_CONTENT}>\n <FiltersList\n shouldSearch={false}\n data={data}\n filters={filters.slice(groupAfterDesktop)}\n hasUrl={hasUrl}\n entity={entity}\n filterValues={filterValues}\n updateFilterValues={updateFilterValues}\n />\n </div>\n\n <div className={MORE_FILTERS_CLASSES.DESKTOP_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </div>\n\n <div className={MORE_FILTERS_CLASSES.MOBILE_BUTTONS}>\n <ResetDesktopForm handleReset={handleReset} />\n\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n </div>\n </div>\n </>\n )}\n\n <br />\n\n {!displaySearchFilter && (\n <button className=\"button button--full-width\" type=\"submit\">\n {SEARCH}\n </button>\n )}\n </div>\n </div>\n\n {displaySearchFilter && <MobileFormToolbar formId={formId} handleReset={handleReset} />}\n </form>\n\n {isCollapsedOnResponsive &&\n !displaySearchFilter && (\n <div className=\"filter__refine filter__refine--mobile-close\" data-testid=\"refine-mobile\">\n <div role=\"button\" onClick={() => setDisplaySearchFilter(true)}>\n {REFINE}\n </div>\n </div>\n )}\n </>\n );\n};\n\nSearchFilter.propTypes = {\n data: PropTypes.object.isRequired,\n filters: PropTypes.array.isRequired,\n searchFilterRef: PropTypes.object.isRequired,\n hasUrl: PropTypes.bool.isRequired,\n entity: PropTypes.string.isRequired,\n handleSearch: PropTypes.func.isRequired,\n name: PropTypes.string.isRequired,\n displaySearchFilter: PropTypes.bool.isRequired,\n setDisplaySearchFilter: PropTypes.func.isRequired,\n isCollapsedOnResponsive: PropTypes.bool.isRequired,\n groupAfterDesktop: PropTypes.number.isRequired,\n groupAfterMobile: PropTypes.number.isRequired,\n initialFilterValues: PropTypes.object.isRequired\n};\n\nexport default SearchFilter;\n"],"file":"SearchFilter.js"}
@@ -21,6 +21,7 @@ const getRelationEntity = (filterName, filterEntityRelations) => {
21
21
  const getFilterProps = (filter, {
22
22
  relations: currentEntityRelations = [],
23
23
  properties: currentEntityProperties = {},
24
+ dynamicProperties: currentEntityDynamicProperties = {},
24
25
  identifier: currentEntityId
25
26
  } = {}, {
26
27
  relations: filterEntityRelations = [],
@@ -28,7 +29,7 @@ const getFilterProps = (filter, {
28
29
  } = {}) => {
29
30
  const [filterName] = filter.split('/');
30
31
  const [relationName, relationProp] = filterName.split('.');
31
- const hasProperty = !!currentEntityProperties[filterName];
32
+ const hasProperty = !!(currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]);
32
33
  const relationEntityName = relationProp ? getFilterLocalKeys(relationName, currentEntityRelations) : null;
33
34
  const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);
34
35
  const propertyEntityName = relationEntityName || filterNameEntity;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterRelationKeys","getFilterLocalKeys","relationName","relations","entityIdentifier","find","localField","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","identifier","currentEntityId","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":"AAAA,OAAOA,qBAAP,MAAkC,4BAAlC;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,YAAD,EAAeC,SAAf,KAA6B;AACtD,QAAM;AAAEC,IAA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ACA,QAAMG,wBAAwB,GAAG,CAACN,WAAD,IAAgB,CAACC,kBAAlD;AACA,QAAMM,mBAAmB,GAAGD,wBAAwB,GAChD3B,qBAAqB,CAACwB,kBAAD,EAAqBX,sBAArB,EAA6CE,uBAA7C,CAD2B,GAEhD,EAFJ;AAGA,QAAMc,kBAAkB,GAAGF,wBAAwB,IAAI,CAACC,mBAAmB,CAACE,MAA5E;AAEA,SAAO;AACLtB,IAAAA,UADK;AAELiB,IAAAA,UAFK;AAGLvB,IAAAA,YAHK;AAILkB,IAAAA,YAJK;AAKLC,IAAAA,WALK;AAMLC,IAAAA,kBANK;AAOLI,IAAAA,cAPK;AAQLE,IAAAA,mBARK;AASLC,IAAAA;AATK,GAAP;AAWD,CArCD;;AAuCA,eAAelB,cAAf","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!currentEntityProperties[filterName];\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
1
+ {"version":3,"sources":["../../src/helpers/get-filter-props.js"],"names":["getFilterRelationKeys","getFilterLocalKeys","relationName","relations","entityIdentifier","find","localField","getRelationEntity","filterName","filterEntityRelations","foreignKey","getFilterProps","filter","currentEntityRelations","properties","currentEntityProperties","dynamicProperties","currentEntityDynamicProperties","identifier","currentEntityId","filteryEntityId","split","relationProp","hasProperty","relationEntityName","filterNameEntity","propertyEntityName","entityName","isEntityItself","shouldCheckRelationNames","relationForeignKeys","shouldIgnoreFilter","length"],"mappings":"AAAA,OAAOA,qBAAP,MAAkC,4BAAlC;;AAEA,MAAMC,kBAAkB,GAAG,CAACC,YAAD,EAAeC,SAAf,KAA6B;AACtD,QAAM;AAAEC,IAAAA;AAAF,MACJD,SAAS,CAACE,IAAV,CAAe,CAAC;AAAEC,IAAAA;AAAF,GAAD,KAAoBA,UAAU,KAAKJ,YAAlD,KAAmE,EADrE;AAEA,SAAOE,gBAAP;AACD,CAJD;;AAMA,MAAMG,iBAAiB,GAAG,CAACC,UAAD,EAAaC,qBAAb,KAAuC;AAC/D,QAAM;AAAEL,IAAAA;AAAF,MACJK,qBAAqB,CAACJ,IAAtB,CAA2B,CAAC;AAAEK,IAAAA;AAAF,GAAD,KAAoBA,UAAU,KAAKF,UAA9D,KAA6E,EAD/E;AAEA,SAAOJ,gBAAP;AACD,CAJD;;AAMA,MAAMO,cAAc,GAAG,CACrBC,MADqB,EAErB;AACET,EAAAA,SAAS,EAAEU,sBAAsB,GAAG,EADtC;AAEEC,EAAAA,UAAU,EAAEC,uBAAuB,GAAG,EAFxC;AAGEC,EAAAA,iBAAiB,EAAEC,8BAA8B,GAAG,EAHtD;AAI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AAf","sourcesContent":["import getFilterRelationKeys from './get-filter-relation-keys';\n\nconst getFilterLocalKeys = (relationName, relations) => {\n const { entityIdentifier } =\n relations.find(({ localField }) => localField === relationName) || {};\n return entityIdentifier;\n};\n\nconst getRelationEntity = (filterName, filterEntityRelations) => {\n const { entityIdentifier } =\n filterEntityRelations.find(({ foreignKey }) => foreignKey === filterName) || {};\n return entityIdentifier;\n};\n\nconst getFilterProps = (\n filter,\n {\n relations: currentEntityRelations = [],\n properties: currentEntityProperties = {},\n dynamicProperties: currentEntityDynamicProperties = {},\n identifier: currentEntityId\n } = {},\n { relations: filterEntityRelations = [], identifier: filteryEntityId } = {}\n) => {\n const [filterName] = filter.split('/');\n const [relationName, relationProp] = filterName.split('.');\n const hasProperty = !!(\n currentEntityProperties[filterName] || currentEntityDynamicProperties[filterName]\n );\n const relationEntityName = relationProp\n ? getFilterLocalKeys(relationName, currentEntityRelations)\n : null;\n const filterNameEntity = getRelationEntity(filterName, filterEntityRelations);\n\n const propertyEntityName = relationEntityName || filterNameEntity;\n const entityName = filterNameEntity ? filteryEntityId : relationEntityName;\n const isEntityItself = currentEntityId === propertyEntityName;\n const shouldCheckRelationNames = !hasProperty && !relationEntityName;\n const relationForeignKeys = shouldCheckRelationNames\n ? getFilterRelationKeys(propertyEntityName, currentEntityRelations, currentEntityProperties)\n : [];\n const shouldIgnoreFilter = shouldCheckRelationNames && !relationForeignKeys.length;\n\n return {\n filterName,\n entityName,\n relationName,\n relationProp,\n hasProperty,\n relationEntityName,\n isEntityItself,\n relationForeignKeys,\n shouldIgnoreFilter\n };\n};\n\nexport default getFilterProps;\n"],"file":"get-filter-props.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.122.0",
3
+ "version": "0.122.2",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -84,5 +84,5 @@
84
84
  "lib/*",
85
85
  "lib-es/*"
86
86
  ],
87
- "gitHead": "6b11475b1ebacbfc1435fe85b2c82fdf342568fd"
87
+ "gitHead": "902fe9c63427c77430763c9fc6312e6f9e3cac6d"
88
88
  }
@@ -1,8 +1,10 @@
1
1
  const getLinkToPublishedContent = (key = '', props = {}) => {
2
2
  if (key.includes('published')) {
3
3
  const [baseKey] = key.split('.');
4
- const content = props[baseKey] && props[baseKey][0];
5
- return content ? content.url : '';
4
+ if (!props[baseKey]) return '';
5
+
6
+ const content = Array.isArray(props[baseKey]) ? props[baseKey][0] : props[baseKey];
7
+ return content && content.url ? content.url : '';
6
8
  }
7
9
  return '';
8
10
  };