@blaze-cms/react-page-builder 0.131.0 → 0.132.0-admin-updates.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (229) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/lib/components/Button.js +2 -1
  3. package/lib/components/Button.js.map +1 -1
  4. package/lib/components/Card/CardsRender.js +13 -6
  5. package/lib/components/Card/CardsRender.js.map +1 -1
  6. package/lib/components/Card/helpers/get-updated-items-to-display.js +55 -0
  7. package/lib/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
  8. package/lib/components/Card/helpers/index.js +7 -0
  9. package/lib/components/Card/helpers/index.js.map +1 -1
  10. package/lib/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
  11. package/lib/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -1
  12. package/lib/components/Code/Code.js +7 -3
  13. package/lib/components/Code/Code.js.map +1 -1
  14. package/lib/components/DataSummary/helpers/build-loop-props-content.js +6 -3
  15. package/lib/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  16. package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js +3 -2
  17. package/lib/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
  18. package/lib/components/DataSummary/helpers/get-link-to-published-content.js +2 -0
  19. package/lib/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  20. package/lib/components/List/ListFactory.js +16 -11
  21. package/lib/components/List/ListFactory.js.map +1 -1
  22. package/lib/components/List/helpers/get-list-query.js +43 -0
  23. package/lib/components/List/helpers/get-list-query.js.map +1 -0
  24. package/lib/components/List/helpers/get-list-specific-search-filter.js +21 -0
  25. package/lib/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
  26. package/lib/components/List/helpers/index.js +14 -0
  27. package/lib/components/List/helpers/index.js.map +1 -1
  28. package/lib/components/List/helpers/strip-query-key.js +14 -0
  29. package/lib/components/List/helpers/strip-query-key.js.map +1 -0
  30. package/lib/components/SearchContent/SearchContent.js +8 -8
  31. package/lib/components/SearchContent/SearchContent.js.map +1 -1
  32. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +17 -13
  33. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  34. package/lib/components/SearchFilter/SearchFilterContainer.js +64 -83
  35. package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  36. package/lib/components/SearchFilter/helpers/build-filters-query.js +3 -1
  37. package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  38. package/lib/components/SearchFilter/helpers/build-new-url.js +17 -0
  39. package/lib/components/SearchFilter/helpers/build-new-url.js.map +1 -0
  40. package/lib/components/SearchFilter/helpers/build-url-query.js +49 -0
  41. package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -0
  42. package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +32 -0
  43. package/lib/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
  44. package/lib/components/SearchFilter/helpers/get-filter-values.js +31 -0
  45. package/lib/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
  46. package/lib/components/SearchFilter/helpers/index.js +18 -11
  47. package/lib/components/SearchFilter/helpers/index.js.map +1 -1
  48. package/lib/components/SearchFilter/index.js.map +1 -1
  49. package/lib/components/SearchFilter/searchFilterReducer.js +43 -0
  50. package/lib/components/SearchFilter/searchFilterReducer.js.map +1 -0
  51. package/lib/components/SearchFilterSort/SearchFilterSort.js +31 -11
  52. package/lib/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
  53. package/lib/components/SearchFilterSort/helpers/handle-sort-update.js +19 -5
  54. package/lib/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
  55. package/lib/components/SearchFilterSort/helpers/update-sort.js +9 -5
  56. package/lib/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
  57. package/lib/helpers/build-inherited-filters.js +2 -0
  58. package/lib/helpers/build-inherited-filters.js.map +1 -1
  59. package/lib/helpers/build-props-query.js +5 -2
  60. package/lib/helpers/build-props-query.js.map +1 -1
  61. package/lib/helpers/build-query-key.js +16 -0
  62. package/lib/helpers/build-query-key.js.map +1 -0
  63. package/lib/helpers/build-set-filters.js +5 -1
  64. package/lib/helpers/build-set-filters.js.map +1 -1
  65. package/lib/helpers/get-entities-with-banner.js +8 -2
  66. package/lib/helpers/get-entities-with-banner.js.map +1 -1
  67. package/lib/helpers/get-query-filters.js +6 -8
  68. package/lib/helpers/get-query-filters.js.map +1 -1
  69. package/lib/helpers/get-query-props.js +13 -2
  70. package/lib/helpers/get-query-props.js.map +1 -1
  71. package/lib/helpers/get-wrapped-value-with-link.js +2 -3
  72. package/lib/helpers/get-wrapped-value-with-link.js.map +1 -1
  73. package/lib/helpers/index.js +14 -0
  74. package/lib/helpers/index.js.map +1 -1
  75. package/lib/helpers/parse-props-to-display.js +13 -8
  76. package/lib/helpers/parse-props-to-display.js.map +1 -1
  77. package/lib/helpers/process-data-summary-value.js +56 -0
  78. package/lib/helpers/process-data-summary-value.js.map +1 -0
  79. package/lib-es/components/Button.js +2 -1
  80. package/lib-es/components/Button.js.map +1 -1
  81. package/lib-es/components/Card/CardsRender.js +14 -7
  82. package/lib-es/components/Card/CardsRender.js.map +1 -1
  83. package/lib-es/components/Card/helpers/get-updated-items-to-display.js +32 -0
  84. package/lib-es/components/Card/helpers/get-updated-items-to-display.js.map +1 -0
  85. package/lib-es/components/Card/helpers/index.js +1 -0
  86. package/lib-es/components/Card/helpers/index.js.map +1 -1
  87. package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
  88. package/lib-es/components/CarouselWrapper/SmoothScrollCarousel.js.map +1 -1
  89. package/lib-es/components/Code/Code.js +8 -4
  90. package/lib-es/components/Code/Code.js.map +1 -1
  91. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js +6 -3
  92. package/lib-es/components/DataSummary/helpers/build-loop-props-content.js.map +1 -1
  93. package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js +4 -3
  94. package/lib-es/components/DataSummary/helpers/build-props-to-display-with-content.js.map +1 -1
  95. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js +2 -1
  96. package/lib-es/components/DataSummary/helpers/get-link-to-published-content.js.map +1 -1
  97. package/lib-es/components/List/ListFactory.js +16 -12
  98. package/lib-es/components/List/ListFactory.js.map +1 -1
  99. package/lib-es/components/List/helpers/get-list-query.js +24 -0
  100. package/lib-es/components/List/helpers/get-list-query.js.map +1 -0
  101. package/lib-es/components/List/helpers/get-list-specific-search-filter.js +12 -0
  102. package/lib-es/components/List/helpers/get-list-specific-search-filter.js.map +1 -0
  103. package/lib-es/components/List/helpers/index.js +2 -0
  104. package/lib-es/components/List/helpers/index.js.map +1 -1
  105. package/lib-es/components/List/helpers/strip-query-key.js +6 -0
  106. package/lib-es/components/List/helpers/strip-query-key.js.map +1 -0
  107. package/lib-es/components/SearchContent/SearchContent.js +8 -8
  108. package/lib-es/components/SearchContent/SearchContent.js.map +1 -1
  109. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +18 -13
  110. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  111. package/lib-es/components/SearchFilter/SearchFilterContainer.js +48 -70
  112. package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  113. package/lib-es/components/SearchFilter/helpers/build-filters-query.js +2 -0
  114. package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  115. package/lib-es/components/SearchFilter/helpers/build-new-url.js +8 -0
  116. package/lib-es/components/SearchFilter/helpers/build-new-url.js.map +1 -0
  117. package/lib-es/components/SearchFilter/helpers/build-url-query.js +31 -0
  118. package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -0
  119. package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +18 -0
  120. package/lib-es/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js.map +1 -0
  121. package/lib-es/components/SearchFilter/helpers/get-filter-values.js +19 -0
  122. package/lib-es/components/SearchFilter/helpers/get-filter-values.js.map +1 -0
  123. package/lib-es/components/SearchFilter/helpers/index.js +5 -4
  124. package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
  125. package/lib-es/components/SearchFilter/index.js +2 -2
  126. package/lib-es/components/SearchFilter/index.js.map +1 -1
  127. package/lib-es/components/SearchFilter/searchFilterReducer.js +26 -0
  128. package/lib-es/components/SearchFilter/searchFilterReducer.js.map +1 -0
  129. package/lib-es/components/SearchFilterSort/SearchFilterSort.js +26 -10
  130. package/lib-es/components/SearchFilterSort/SearchFilterSort.js.map +1 -1
  131. package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js +21 -4
  132. package/lib-es/components/SearchFilterSort/helpers/handle-sort-update.js.map +1 -1
  133. package/lib-es/components/SearchFilterSort/helpers/update-sort.js +8 -4
  134. package/lib-es/components/SearchFilterSort/helpers/update-sort.js.map +1 -1
  135. package/lib-es/helpers/build-inherited-filters.js +2 -0
  136. package/lib-es/helpers/build-inherited-filters.js.map +1 -1
  137. package/lib-es/helpers/build-props-query.js +4 -2
  138. package/lib-es/helpers/build-props-query.js.map +1 -1
  139. package/lib-es/helpers/build-query-key.js +7 -0
  140. package/lib-es/helpers/build-query-key.js.map +1 -0
  141. package/lib-es/helpers/build-set-filters.js +5 -1
  142. package/lib-es/helpers/build-set-filters.js.map +1 -1
  143. package/lib-es/helpers/get-entities-with-banner.js +9 -2
  144. package/lib-es/helpers/get-entities-with-banner.js.map +1 -1
  145. package/lib-es/helpers/get-query-filters.js +6 -8
  146. package/lib-es/helpers/get-query-filters.js.map +1 -1
  147. package/lib-es/helpers/get-query-props.js +10 -2
  148. package/lib-es/helpers/get-query-props.js.map +1 -1
  149. package/lib-es/helpers/get-wrapped-value-with-link.js +2 -2
  150. package/lib-es/helpers/get-wrapped-value-with-link.js.map +1 -1
  151. package/lib-es/helpers/index.js +2 -0
  152. package/lib-es/helpers/index.js.map +1 -1
  153. package/lib-es/helpers/parse-props-to-display.js +12 -9
  154. package/lib-es/helpers/parse-props-to-display.js.map +1 -1
  155. package/lib-es/helpers/process-data-summary-value.js +36 -0
  156. package/lib-es/helpers/process-data-summary-value.js.map +1 -0
  157. package/package.json +10 -10
  158. package/src/components/Button.js +2 -1
  159. package/src/components/Card/CardsRender.js +27 -7
  160. package/src/components/Card/helpers/get-updated-items-to-display.js +32 -0
  161. package/src/components/Card/helpers/index.js +1 -0
  162. package/src/components/CarouselWrapper/SmoothScrollCarousel.js +2 -2
  163. package/src/components/Code/Code.js +7 -3
  164. package/src/components/DataSummary/helpers/build-loop-props-content.js +7 -3
  165. package/src/components/DataSummary/helpers/build-props-to-display-with-content.js +6 -3
  166. package/src/components/DataSummary/helpers/get-link-to-published-content.js +4 -1
  167. package/src/components/List/ListFactory.js +25 -15
  168. package/src/components/List/helpers/get-list-query.js +28 -0
  169. package/src/components/List/helpers/get-list-specific-search-filter.js +10 -0
  170. package/src/components/List/helpers/index.js +2 -0
  171. package/src/components/List/helpers/strip-query-key.js +6 -0
  172. package/src/components/SearchContent/SearchContent.js +8 -8
  173. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +21 -18
  174. package/src/components/SearchFilter/SearchFilterContainer.js +59 -67
  175. package/src/components/SearchFilter/helpers/build-filters-query.js +9 -1
  176. package/src/components/SearchFilter/helpers/build-new-url.js +8 -0
  177. package/src/components/SearchFilter/helpers/build-url-query.js +33 -0
  178. package/src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js +17 -0
  179. package/src/components/SearchFilter/helpers/get-filter-values.js +21 -0
  180. package/src/components/SearchFilter/helpers/index.js +9 -7
  181. package/src/components/SearchFilter/index.js +2 -2
  182. package/src/components/SearchFilter/searchFilterReducer.js +15 -0
  183. package/src/components/SearchFilterSort/SearchFilterSort.js +18 -8
  184. package/src/components/SearchFilterSort/helpers/handle-sort-update.js +14 -5
  185. package/src/components/SearchFilterSort/helpers/update-sort.js +7 -3
  186. package/src/helpers/build-inherited-filters.js +3 -1
  187. package/src/helpers/build-props-query.js +4 -2
  188. package/src/helpers/build-query-key.js +7 -0
  189. package/src/helpers/build-set-filters.js +2 -1
  190. package/src/helpers/get-entities-with-banner.js +3 -2
  191. package/src/helpers/get-query-filters.js +4 -4
  192. package/src/helpers/get-query-props.js +12 -4
  193. package/src/helpers/get-wrapped-value-with-link.js +6 -3
  194. package/src/helpers/index.js +2 -0
  195. package/src/helpers/parse-props-to-display.js +25 -21
  196. package/src/helpers/process-data-summary-value.js +22 -0
  197. package/tests/helpers/mocks.js +3 -5
  198. package/tests/unit/src/components/Card/helpers/get-updated-items-to-display.test.js +72 -0
  199. package/tests/unit/src/components/Code/Code.test.js +5 -0
  200. package/tests/unit/src/components/Code/__snapshots__/Code.test.js.snap +8 -0
  201. package/tests/unit/src/components/DataSummary/helpers/build-loop-props-content.test.js +50 -0
  202. package/tests/unit/src/components/DataSummary/helpers/get-link-to-published-content.test.js +21 -0
  203. package/tests/unit/src/components/SearchFilter/__snapshots__/SearchFilterContainer.test.js.snap +1 -7
  204. package/tests/unit/src/components/SearchFilter/helpers/build-new-query.test.js +10 -10
  205. package/tests/unit/src/components/SearchFilter/helpers/build-query.test.js +24 -7
  206. package/tests/unit/src/components/SearchFilter/helpers/get-initial-filter-values.test.js +10 -10
  207. package/tests/unit/src/components/SearchFilterSort/SearchFilterSort.test.js +4 -1
  208. package/tests/unit/src/components/SearchFilterSort/helpers/handle-sort-update.test.js +26 -19
  209. package/tests/unit/src/components/SearchFilterSort/helpers/update-sort.test.js +10 -1
  210. package/tests/unit/src/helpers/__snapshots__/get-wrapped-value-with-link.test.js.snap +18 -0
  211. package/tests/unit/src/helpers/build-props-query.test.js +25 -0
  212. package/tests/unit/src/helpers/get-wrapped-value-with-link.test.js +2 -2
  213. package/tests/unit/src/helpers/parse-props-to-display.test.js +4 -0
  214. package/tests/unit/src/helpers/prcoess-data-summary-value.test.js +52 -0
  215. package/lib/components/SearchFilter/helpers/build-new-query.js +0 -15
  216. package/lib/components/SearchFilter/helpers/build-new-query.js.map +0 -1
  217. package/lib/components/SearchFilter/helpers/build-query.js +0 -37
  218. package/lib/components/SearchFilter/helpers/build-query.js.map +0 -1
  219. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +0 -43
  220. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
  221. package/lib-es/components/SearchFilter/helpers/build-new-query.js +0 -6
  222. package/lib-es/components/SearchFilter/helpers/build-new-query.js.map +0 -1
  223. package/lib-es/components/SearchFilter/helpers/build-query.js +0 -23
  224. package/lib-es/components/SearchFilter/helpers/build-query.js.map +0 -1
  225. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +0 -26
  226. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +0 -1
  227. package/src/components/SearchFilter/helpers/build-new-query.js +0 -6
  228. package/src/components/SearchFilter/helpers/build-query.js +0 -26
  229. package/src/components/SearchFilter/helpers/get-initial-filter-values.js +0 -30
@@ -0,0 +1,31 @@
1
+ import { SEARCH_TERM, TEXT_SEARCH } from '../constants';
2
+ import parseFilterValue from './parse-filter-value';
3
+ import { buildQueryKey } from '../../../helpers';
4
+ const buildUrlQuery = (filterValues, filters, listComponentName = '', query = {}) => {
5
+ if (!filterValues) return '';
6
+ const newQuery = [];
7
+ const queryKeys = [];
8
+ const searchValue = filterValues[SEARCH_TERM];
9
+ const searchKey = buildQueryKey(SEARCH_TERM, listComponentName);
10
+ queryKeys.push(searchKey);
11
+ if (searchValue) newQuery.push(`${searchKey}=${searchValue}`);
12
+ filters.forEach(({
13
+ propsToDisplay,
14
+ type
15
+ }) => {
16
+ if (type === TEXT_SEARCH) return;
17
+ propsToDisplay.forEach(prop => {
18
+ const value = filterValues[prop];
19
+ const filterKey = buildQueryKey(prop, listComponentName);
20
+ queryKeys.push(filterKey);
21
+ const parsedValue = parseFilterValue(filterKey, type, value, newQuery);
22
+ if (parsedValue && !newQuery.includes(parsedValue)) newQuery.push(parsedValue);
23
+ });
24
+ });
25
+ Object.keys(query).forEach(key => {
26
+ if (queryKeys.indexOf(key) === -1) newQuery.push(`${key}=${query[key]}`);
27
+ });
28
+ return newQuery.join('&');
29
+ };
30
+ export default buildUrlQuery;
31
+ //# sourceMappingURL=build-url-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-url-query.js","names":["SEARCH_TERM","TEXT_SEARCH","parseFilterValue","buildQueryKey","buildUrlQuery","filterValues","filters","listComponentName","query","newQuery","queryKeys","searchValue","searchKey","push","forEach","propsToDisplay","type","prop","value","filterKey","parsedValue","includes","Object","keys","key","indexOf","join"],"sources":["../../../../src/components/SearchFilter/helpers/build-url-query.js"],"sourcesContent":["import { SEARCH_TERM, TEXT_SEARCH } from '../constants';\nimport parseFilterValue from './parse-filter-value';\nimport { buildQueryKey } from '../../../helpers';\n\nconst buildUrlQuery = (filterValues, filters, listComponentName = '', query = {}) => {\n if (!filterValues) return '';\n\n const newQuery = [];\n const queryKeys = [];\n const searchValue = filterValues[SEARCH_TERM];\n const searchKey = buildQueryKey(SEARCH_TERM, listComponentName);\n queryKeys.push(searchKey);\n if (searchValue) newQuery.push(`${searchKey}=${searchValue}`);\n\n filters.forEach(({ propsToDisplay, type }) => {\n if (type === TEXT_SEARCH) return;\n propsToDisplay.forEach(prop => {\n const value = filterValues[prop];\n const filterKey = buildQueryKey(prop, listComponentName);\n queryKeys.push(filterKey);\n const parsedValue = parseFilterValue(filterKey, type, value, newQuery);\n if (parsedValue && !newQuery.includes(parsedValue)) newQuery.push(parsedValue);\n });\n });\n\n Object.keys(query).forEach(key => {\n if (queryKeys.indexOf(key) === -1) newQuery.push(`${key}=${query[key]}`);\n });\n\n return newQuery.join('&');\n};\n\nexport default buildUrlQuery;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,WAAW,QAAQ,cAAc;AACvD,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,SAASC,aAAa,QAAQ,kBAAkB;AAEhD,MAAMC,aAAa,GAAGA,CAACC,YAAY,EAAEC,OA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E,CAAC,CAAC;EAEF,OAAOf,QAAQ,CAACiB,IAAI,CAAC,GAAG,CAAC;AAC3B,CAAC;AAED,eAAetB,aAAa"}
@@ -0,0 +1,18 @@
1
+ import { RANGE, CHECKBOX_SELECT } from '../constants';
2
+ const getFilterRangesAndCheckboxesValues = filters => {
3
+ const checkboxSelectValues = [];
4
+ const rangeValues = [];
5
+ filters.forEach(({
6
+ type,
7
+ propsToDisplay
8
+ }) => {
9
+ if (CHECKBOX_SELECT.includes(type)) {
10
+ checkboxSelectValues.push(propsToDisplay[0]);
11
+ } else if (type === RANGE) {
12
+ rangeValues.push(...propsToDisplay);
13
+ }
14
+ });
15
+ return [checkboxSelectValues, rangeValues];
16
+ };
17
+ export default getFilterRangesAndCheckboxesValues;
18
+ //# sourceMappingURL=get-filter-ranges-and-checkboxes-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-filter-ranges-and-checkboxes-values.js","names":["RANGE","CHECKBOX_SELECT","getFilterRangesAndCheckboxesValues","filters","checkboxSelectValues","rangeValues","forEach","type","propsToDisplay","includes","push"],"sources":["../../../../src/components/SearchFilter/helpers/get-filter-ranges-and-checkboxes-values.js"],"sourcesContent":["import { RANGE, CHECKBOX_SELECT } from '../constants';\n\nconst getFilterRangesAndCheckboxesValues = filters => {\n const checkboxSelectValues = [];\n const rangeValues = [];\n\n filters.forEach(({ type, propsToDisplay }) => {\n if (CHECKBOX_SELECT.includes(type)) {\n checkboxSelectValues.push(propsToDisplay[0]);\n } else if (type === RANGE) {\n rangeValues.push(...propsToDisplay);\n }\n });\n return [checkboxSelectValues, rangeValues];\n};\n\nexport default getFilterRangesAndCheckboxesValues;\n"],"mappings":"AAAA,SAASA,KAAK,EAAEC,eAAe,QAAQ,cAAc;AAErD,MAAMC,kCAAkC,GAAGC,OAAO,IAAI;EACpD,MAAMC,oBAAoB,GAAG,EAAE;EAC/B,MAAMC,WAAW,GAAG,EAAE;EAEtBF,OAAO,CAACG,OAAO,CAAC,CAAC;IAAEC,IAAI;IAAEC;EAAe,CAAC,KAAK;IAC5C,IAAIP,eAAe,CAACQ,QAAQ,CAACF,IAAI,CAAC,EAAE;MAClCH,oBAAoB,CAACM,IAAI,CAACF,cAAc,CAAC,CAAC,CAAC,CAAC;IAC9C,CAAC,MAAM,IAAID,IAAI,KAAKP,KAAK,EAAE;MACzBK,WAAW,CAACK,IAAI,CAAC,GAAGF,cAAc,CAAC;IACrC;EACF,CAAC,CAAC;EACF,OAAO,CAACJ,oBAAoB,EAAEC,WAAW,CAAC;AAC5C,CAAC;AAED,eAAeH,kCAAkC"}
@@ -0,0 +1,19 @@
1
+ import { SEARCH_TERM, TEXT_SEARCH } from '../constants';
2
+ import getFilterValueFromQuery from './get-filter-value-from-query';
3
+ const getFilterValues = (filterData, filters, query) => {
4
+ const filterValues = {};
5
+ filterValues[SEARCH_TERM] = query[SEARCH_TERM] || '';
6
+ filters.forEach(filterProps => {
7
+ const {
8
+ propsToDisplay: [key],
9
+ type
10
+ } = filterProps;
11
+ if (type === TEXT_SEARCH) return;
12
+ const data = filterData && filterData[key] ? filterData[key] : {};
13
+ filterValues[key] = getFilterValueFromQuery(key, filterProps, data, query);
14
+ });
15
+ filterValues.dataNotSet = !filterData;
16
+ return filterValues;
17
+ };
18
+ export default getFilterValues;
19
+ //# sourceMappingURL=get-filter-values.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-filter-values.js","names":["SEARCH_TERM","TEXT_SEARCH","getFilterValueFromQuery","getFilterValues","filterData","filters","query","filterValues","forEach","filterProps","propsToDisplay","key","type","data","dataNotSet"],"sources":["../../../../src/components/SearchFilter/helpers/get-filter-values.js"],"sourcesContent":["import { SEARCH_TERM, TEXT_SEARCH } from '../constants';\nimport getFilterValueFromQuery from './get-filter-value-from-query';\n\nconst getFilterValues = (filterData, filters, query) => {\n const filterValues = {};\n filterValues[SEARCH_TERM] = query[SEARCH_TERM] || '';\n\n filters.forEach(filterProps => {\n const {\n propsToDisplay: [key],\n type\n } = filterProps;\n if (type === TEXT_SEARCH) return;\n const data = filterData && filterData[key] ? filterData[key] : {};\n filterValues[key] = getFilterValueFromQuery(key, filterProps, data, query);\n });\n filterValues.dataNotSet = !filterData;\n return filterValues;\n};\n\nexport default getFilterValues;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,WAAW,QAAQ,cAAc;AACvD,OAAOC,uBAAuB,MAAM,+BAA+B;AAEnE,MAAMC,eAAe,GAAGA,CAACC,UAAU,EAAEC,OAAO,EAAEC,KAAK,KAAK;EACtD,MAAMC,YAAY,GAAG,CAAC,CAAC;EACvBA,YAAY,CAACP,WAAW,CAAC,GAAGM,KAAK,CAACN,WAAW,CAAC,IAAI,EAAE;EAEpDK,OAAO,CAACG,OAAO,CAACC,WAAW,IAAI;IAC7B,MAAM;MACJC,cAAc,EAAE,CAACC,GAAG,CAAC;MACrBC;IACF,CAAC,GAAGH,WAAW;IACf,IAAIG,IAAI,KAAKX,WAAW,EAAE;IAC1B,MAAMY,IAAI,GAAGT,UAAU,IAAIA,UAAU,CAACO,GAAG,CAAC,GAAGP,UAAU,CAACO,GAAG,CAAC,GAAG,CAAC,CAAC;IACjEJ,YAAY,CAACI,GAAG,CAAC,GAAGT,uBAAuB,CAACS,GAAG,EAAEF,WAAW,EAAEI,IAAI,EAAEP,KAAK,CAAC;EAC5E,CAAC,CAAC;EACFC,YAAY,CAACO,UAAU,GAAG,CAACV,UAAU;EACrC,OAAOG,YAAY;AACrB,CAAC;AAED,eAAeJ,eAAe"}
@@ -1,4 +1,4 @@
1
- import buildNewQuery from './build-new-query';
1
+ import buildNewUrl from './build-new-url';
2
2
  import buildRawQueryStringified from './build-raw-query-stringified';
3
3
  import { decodeValue, encodeValue } from './decode-encode';
4
4
  import checkIfRangeUpdated from './check-if-range-updated';
@@ -10,9 +10,10 @@ import getIntersectedProp from './get-intersected-prop';
10
10
  import getRangeValue from './get-range-value';
11
11
  import getSelectOptions from './get-select-options';
12
12
  import isDeviceDesktop from './is-device-desktop';
13
- import getInitialFilterValues from './get-initial-filter-values';
13
+ import getFilterValues from './get-filter-values';
14
14
  import getFilterValueFromQuery from './get-filter-value-from-query';
15
- import buildQuery from './build-query';
15
+ import buildUrlQuery from './build-url-query';
16
16
  import buildFiltersQuery from './build-filters-query';
17
- export { buildQuery, buildNewQuery, buildRawQueryStringified, decodeValue, encodeValue, checkIfRangeUpdated, getResponsiveFilterClassnames, getDisplayValue, calculateStep, calculateMinMax, getIntersectedProp, getRangeValue, getSelectOptions, isDeviceDesktop, getInitialFilterValues, getFilterValueFromQuery, buildFiltersQuery };
17
+ import getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';
18
+ export { buildUrlQuery, buildNewUrl, buildRawQueryStringified, decodeValue, encodeValue, checkIfRangeUpdated, getResponsiveFilterClassnames, getDisplayValue, calculateStep, calculateMinMax, getIntersectedProp, getRangeValue, getSelectOptions, isDeviceDesktop, getFilterValues, getFilterValueFromQuery, buildFiltersQuery, getFilterRangesAndCheckboxesValues };
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["buildNewQuery","buildRawQueryStringified","decodeValue","encodeValue","checkIfRangeUpdated","getResponsiveFilterClassnames","getDisplayValue","calculateStep","calculateMinMax","getIntersectedProp","getRangeValue","getSelectOptions","isDeviceDesktop","getInitialFilterValues","getFilterValueFromQuery","buildQuery","buildFiltersQuery"],"sources":["../../../../src/components/SearchFilter/helpers/index.js"],"sourcesContent":["import buildNewQuery from './build-new-query';\nimport buildRawQueryStringified from './build-raw-query-stringified';\nimport { decodeValue, encodeValue } from './decode-encode';\nimport checkIfRangeUpdated from './check-if-range-updated';\nimport getResponsiveFilterClassnames from './get-responsive-filter-classnames';\nimport getDisplayValue from './get-display-value';\nimport calculateStep from './calculate-step';\nimport calculateMinMax from './calculate-min-max';\nimport getIntersectedProp from './get-intersected-prop';\nimport getRangeValue from './get-range-value';\nimport getSelectOptions from './get-select-options';\nimport isDeviceDesktop from './is-device-desktop';\nimport getInitialFilterValues from './get-initial-filter-values';\nimport getFilterValueFromQuery from './get-filter-value-from-query';\nimport buildQuery from './build-query';\nimport buildFiltersQuery from './build-filters-query';\n\nexport {\n buildQuery,\n buildNewQuery,\n buildRawQueryStringified,\n decodeValue,\n encodeValue,\n checkIfRangeUpdated,\n getResponsiveFilterClassnames,\n getDisplayValue,\n calculateStep,\n calculateMinMax,\n getIntersectedProp,\n getRangeValue,\n getSelectOptions,\n isDeviceDesktop,\n getInitialFilterValues,\n getFilterValueFromQuery,\n buildFiltersQuery\n};\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,SAASC,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;AAC1D,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,6BAA6B,MAAM,oCAAoC;AAC9E,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,OAAOC,uBAAuB,MAAM,+BAA+B;AACnE,OAAOC,UAAU,MAAM,eAAe;AACtC,OAAOC,iBAAiB,MAAM,uBAAuB;AAErD,SACED,UAAU,EACVf,aAAa,EACbC,wBAAwB,EACxBC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,6BAA6B,EAC7BC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,EACfC,sBAAsB,EACtBC,uBAAuB,EACvBE,iBAAiB"}
1
+ {"version":3,"file":"index.js","names":["buildNewUrl","buildRawQueryStringified","decodeValue","encodeValue","checkIfRangeUpdated","getResponsiveFilterClassnames","getDisplayValue","calculateStep","calculateMinMax","getIntersectedProp","getRangeValue","getSelectOptions","isDeviceDesktop","getFilterValues","getFilterValueFromQuery","buildUrlQuery","buildFiltersQuery","getFilterRangesAndCheckboxesValues"],"sources":["../../../../src/components/SearchFilter/helpers/index.js"],"sourcesContent":["import buildNewUrl from './build-new-url';\nimport buildRawQueryStringified from './build-raw-query-stringified';\nimport { decodeValue, encodeValue } from './decode-encode';\nimport checkIfRangeUpdated from './check-if-range-updated';\nimport getResponsiveFilterClassnames from './get-responsive-filter-classnames';\nimport getDisplayValue from './get-display-value';\nimport calculateStep from './calculate-step';\nimport calculateMinMax from './calculate-min-max';\nimport getIntersectedProp from './get-intersected-prop';\nimport getRangeValue from './get-range-value';\nimport getSelectOptions from './get-select-options';\nimport isDeviceDesktop from './is-device-desktop';\nimport getFilterValues from './get-filter-values';\nimport getFilterValueFromQuery from './get-filter-value-from-query';\nimport buildUrlQuery from './build-url-query';\nimport buildFiltersQuery from './build-filters-query';\nimport getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';\n\nexport {\n buildUrlQuery,\n buildNewUrl,\n buildRawQueryStringified,\n decodeValue,\n encodeValue,\n checkIfRangeUpdated,\n getResponsiveFilterClassnames,\n getDisplayValue,\n calculateStep,\n calculateMinMax,\n getIntersectedProp,\n getRangeValue,\n getSelectOptions,\n isDeviceDesktop,\n getFilterValues,\n getFilterValueFromQuery,\n buildFiltersQuery,\n getFilterRangesAndCheckboxesValues\n};\n"],"mappings":"AAAA,OAAOA,WAAW,MAAM,iBAAiB;AACzC,OAAOC,wBAAwB,MAAM,+BAA+B;AACpE,SAASC,WAAW,EAAEC,WAAW,QAAQ,iBAAiB;AAC1D,OAAOC,mBAAmB,MAAM,0BAA0B;AAC1D,OAAOC,6BAA6B,MAAM,oCAAoC;AAC9E,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,kBAAkB,MAAM,wBAAwB;AACvD,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,gBAAgB,MAAM,sBAAsB;AACnD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,eAAe,MAAM,qBAAqB;AACjD,OAAOC,uBAAuB,MAAM,+BAA+B;AACnE,OAAOC,aAAa,MAAM,mBAAmB;AAC7C,OAAOC,iBAAiB,MAAM,uBAAuB;AACrD,OAAOC,kCAAkC,MAAM,2CAA2C;AAE1F,SACEF,aAAa,EACbf,WAAW,EACXC,wBAAwB,EACxBC,WAAW,EACXC,WAAW,EACXC,mBAAmB,EACnBC,6BAA6B,EAC7BC,eAAe,EACfC,aAAa,EACbC,eAAe,EACfC,kBAAkB,EAClBC,aAAa,EACbC,gBAAgB,EAChBC,eAAe,EACfC,eAAe,EACfC,uBAAuB,EACvBE,iBAAiB,EACjBC,kCAAkC"}
@@ -1,3 +1,3 @@
1
- import SearchFilterContainer from './SearchFilterContainer';
2
- export default SearchFilterContainer;
1
+ import SearchFilter from './SearchFilterContainer';
2
+ export default SearchFilter;
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["SearchFilterContainer"],"sources":["../../../src/components/SearchFilter/index.js"],"sourcesContent":["import SearchFilterContainer from './SearchFilterContainer';\n\nexport default SearchFilterContainer;\n"],"mappings":"AAAA,OAAOA,qBAAqB,MAAM,yBAAyB;AAE3D,eAAeA,qBAAqB"}
1
+ {"version":3,"file":"index.js","names":["SearchFilter"],"sources":["../../../src/components/SearchFilter/index.js"],"sourcesContent":["import SearchFilter from './SearchFilterContainer';\n\nexport default SearchFilter;\n"],"mappings":"AAAA,OAAOA,YAAY,MAAM,yBAAyB;AAElD,eAAeA,YAAY"}
@@ -0,0 +1,26 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ 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; }
3
+ 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; }
4
+ const searchFilterReducer = (state, action) => {
5
+ const {
6
+ newValues,
7
+ type,
8
+ shouldSearch = true
9
+ } = action;
10
+ switch (type) {
11
+ case 'update':
12
+ return _objectSpread(_objectSpread(_objectSpread({}, state), newValues), {}, {
13
+ shouldSearch
14
+ });
15
+ case 'resetSearch':
16
+ return _objectSpread(_objectSpread({}, state), {}, {
17
+ shouldSearch: false
18
+ });
19
+ case 'reset':
20
+ return null;
21
+ default:
22
+ throw new Error();
23
+ }
24
+ };
25
+ export default searchFilterReducer;
26
+ //# sourceMappingURL=searchFilterReducer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searchFilterReducer.js","names":["searchFilterReducer","state","action","newValues","type","shouldSearch","_objectSpread","Error"],"sources":["../../../src/components/SearchFilter/searchFilterReducer.js"],"sourcesContent":["const searchFilterReducer = (state, action) => {\n const { newValues, type, shouldSearch = true } = action;\n switch (type) {\n case 'update':\n return { ...state, ...newValues, shouldSearch };\n case 'resetSearch':\n return { ...state, shouldSearch: false };\n case 'reset':\n return null;\n default:\n throw new Error();\n }\n};\n\nexport default searchFilterReducer;\n"],"mappings":";;;AAAA,MAAMA,mBAAmB,GAAGA,CAACC,KAAK,EAAEC,MAAM,KAAK;EAC7C,MAAM;IAAEC,SAAS;IAAEC,IAAI;IAAEC,YAAY,GAAG;EAAK,CAAC,GAAGH,MAAM;EACvD,QAAQE,IAAI;IACV,KAAK,QAAQ;MACX,OAAAE,aAAA,CAAAA,aAAA,CAAAA,aAAA,KAAYL,KAAK,GAAKE,SAAS;QAAEE;MAAY;IAC/C,KAAK,aAAa;MAChB,OAAAC,aAAA,CAAAA,aAAA,KAAYL,KAAK;QAAEI,YAAY,EAAE;MAAK;IACxC,KAAK,OAAO;MACV,OAAO,IAAI;IACb;MACE,MAAM,IAAIE,KAAK,CAAC,CAAC;EACrB;AACF,CAAC;AAED,eAAeP,mBAAmB"}
@@ -1,27 +1,35 @@
1
1
  import React from 'react';
2
2
  import Select from '@blaze-react/select';
3
- import { withRouter } from 'next/router';
3
+ import { useRouter } from 'next/router';
4
4
  import { parseUrl } from 'query-string';
5
5
  import PropTypes from 'prop-types';
6
6
  import { DEFAULT_SORT } from './constants';
7
7
  import { handleSortUpdate } from './helpers';
8
8
  import { withTitle } from '../../HOC';
9
+ const getSortFromQuery = listComponentName => {
10
+ const listNameKey = listComponentName ? `pb[${listComponentName}]` : '';
11
+ const sortKey = `${listNameKey}${listNameKey ? '[sort]' : 'sort'}`;
12
+ const sortByKey = `${listNameKey}${listNameKey ? '[sortby]' : 'sortby'}`;
13
+ return [sortKey, sortByKey];
14
+ };
9
15
  const SearchFilterSort = ({
10
- router,
11
16
  filters,
12
17
  elementLabel,
13
18
  selectLabel,
14
- id
19
+ id,
20
+ listComponentName
15
21
  }) => {
22
+ const router = useRouter();
16
23
  const {
17
24
  asPath
18
25
  } = router;
26
+ const [sortKey, sortByKey] = getSortFromQuery(listComponentName);
19
27
  const {
20
28
  url,
21
29
  query,
22
30
  query: {
23
- sort,
24
- sortby
31
+ [sortKey]: sort,
32
+ [sortByKey]: sortby
25
33
  } = {}
26
34
  } = parseUrl(asPath);
27
35
  const selectedValue = `${sortby}:${sort}` || '';
@@ -33,7 +41,14 @@ const SearchFilterSort = ({
33
41
  }) => [`${propsToDisplay[0]}:${sortValue}`, optionLabel]);
34
42
  const setSortValue = ({
35
43
  value
36
- }) => handleSortUpdate(router, value, query, url, selectLabel);
44
+ }) => handleSortUpdate({
45
+ router,
46
+ value,
47
+ query,
48
+ url,
49
+ selectLabel,
50
+ listComponentName
51
+ });
37
52
  return /*#__PURE__*/React.createElement("div", {
38
53
  className: "sort-by"
39
54
  }, /*#__PURE__*/React.createElement(Select, {
@@ -46,17 +61,18 @@ const SearchFilterSort = ({
46
61
  }));
47
62
  };
48
63
  SearchFilterSort.propTypes = {
49
- router: PropTypes.object.isRequired,
50
64
  filters: PropTypes.array,
51
65
  elementLabel: PropTypes.string,
52
66
  selectLabel: PropTypes.string,
53
- id: PropTypes.string
67
+ id: PropTypes.string,
68
+ listComponentName: PropTypes.string
54
69
  };
55
70
  SearchFilterSort.defaultProps = {
56
71
  filters: [],
57
72
  elementLabel: '',
58
73
  selectLabel: '',
59
- id: ''
74
+ id: '',
75
+ listComponentName: ''
60
76
  };
61
- export default withRouter(withTitle(SearchFilterSort));
77
+ export default withTitle(SearchFilterSort);
62
78
  //# sourceMappingURL=SearchFilterSort.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchFilterSort.js","names":["React","Select","withRouter","parseUrl","PropTypes","DEFAULT_SORT","handleSortUpdate","withTitle","SearchFilterSort","router","filters","elementLabel","selectLabel","id","asPath","url","query","sort","sortby","selectedValue","defaultTextValue","options","map","label","optionLabel","propsToDisplay","sortValue","setSortValue","value","createElement","className","onChange","propTypes","object","isRequired","array","string","defaultProps"],"sources":["../../../src/components/SearchFilterSort/SearchFilterSort.js"],"sourcesContent":["import React from 'react';\nimport Select from '@blaze-react/select';\nimport { withRouter } from 'next/router';\nimport { parseUrl } from 'query-string';\nimport PropTypes from 'prop-types';\nimport { DEFAULT_SORT } from './constants';\nimport { handleSortUpdate } from './helpers';\nimport { withTitle } from '../../HOC';\n\nconst SearchFilterSort = ({ router, filters, elementLabel, selectLabel, id }) => {\n const { asPath } = router;\n const { url, query, query: { sort, sortby } = {} } = parseUrl(asPath);\n const selectedValue = `${sortby}:${sort}` || '';\n const defaultTextValue = selectLabel || DEFAULT_SORT;\n const options = filters.map(({ label: optionLabel, propsToDisplay, sort: sortValue }) => [\n `${propsToDisplay[0]}:${sortValue}`,\n optionLabel\n ]);\n\n const setSortValue = ({ value }) => handleSortUpdate(router, value, query, url, selectLabel);\n\n return (\n <div className=\"sort-by\">\n <Select\n label={elementLabel}\n defaultTextValue={defaultTextValue}\n value={selectedValue}\n id={id}\n options={options}\n onChange={setSortValue}\n />\n </div>\n );\n};\n\nSearchFilterSort.propTypes = {\n router: PropTypes.object.isRequired,\n filters: PropTypes.array,\n elementLabel: PropTypes.string,\n selectLabel: PropTypes.string,\n id: PropTypes.string\n};\n\nSearchFilterSort.defaultProps = {\n filters: [],\n elementLabel: '',\n selectLabel: '',\n id: ''\n};\n\nexport default withRouter(withTitle(SearchFilterSort));\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,MAAM,MAAM,qBAAqB;AACxC,SAASC,UAAU,QAAQ,aAAa;AACxC,SAASC,QAAQ,QAAQ,cAAc;AACvC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,YAAY,QAAQ,aAAa;AAC1C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,SAAS,QAAQ,WAAW;AAErC,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,MAAM;EAAEC,OAAO;EAAEC,YAAY;EAAEC,WAAW;EAAEC;AAAG,CAAC,KAAK;EAC/E,MAAM;IAAEC;EAAO,CAAC,GAAGL,MAAM;EACzB,MAAM;IAAEM,GAAG;IAAEC,KAAK;IAAEA,KAAK,EAAE;MAAEC,IAAI;MAAEC;IAAO,CAAC,GAAG,CAAC;EAAE,CAAC,GAAGf,QAAQ,CAACW,MAAM,CAAC;EACrE,MAAMK,aAAa,GAAI,GAAED,MAAO,IAAGD,IAAK,EAAC,IAAI,EAAE;EAC/C,MAAMG,gBAAgB,GAAGR,WAAW,IAAIP,YAAY;EACpD,MAAMgB,OAAO,GAAGX,OAAO,CAACY,GAAG,CAAC,CAAC;IAAEC,KAAK,EAAEC,WAAW;IAAEC,cAAc;IAAER,IAAI,EAAES;EAAU,CAAC,KAAK,CACtF,GAAED,cAAc,CAAC,CAAC,CAAE,IAAGC,SAAU,EAAC,EACnCF,WAAW,CACZ,CAAC;EAEF,MAAMG,YAAY,GAAGA,CAAC;IAAEC;EAAM,CAAC,KAAKtB,gBAAgB,CAACG,MAAM,EAAEmB,KAAK,EAAEZ,KAAK,EAAED,GAAG,EAAEH,WAAW,CAAC;EAE5F,oBACEZ,KAAA,CAAA6B,aAAA;IAAKC,SAAS,EAAC;EAAS,gBACtB9B,KAAA,CAAA6B,aAAA,CAAC5B,MAAM;IACLsB,KAAK,EAAEZ,YAAa;IACpBS,gBAAgB,EAAEA,gBAAiB;IACnCQ,KAAK,EAAET,aAAc;IACrBN,EAAE,EAAEA,EAAG;IACPQ,OAAO,EAAEA,OAAQ;IACjBU,QAAQ,EAAEJ;EAAa,CACxB,CACE,CAAC;AAEV,CAAC;AAEDnB,gBAAgB,CAACwB,SAAS,GAAG;EAC3BvB,MAAM,EAAEL,SAAS,CAAC6B,MAAM,CAACC,UAAU;EACnCxB,OAAO,EAAEN,SAAS,CAAC+B,KAAK;EACxBxB,YAAY,EAAEP,SAAS,CAACgC,MAAM;EAC9BxB,WAAW,EAAER,SAAS,CAACgC,MAAM;EAC7BvB,EAAE,EAAET,SAAS,CAACgC;AAChB,CAAC;AAED5B,gBAAgB,CAAC6B,YAAY,GAAG;EAC9B3B,OAAO,EAAE,EAAE;EACXC,YAAY,EAAE,EAAE;EAChBC,WAAW,EAAE,EAAE;EACfC,EAAE,EAAE;AACN,CAAC;AAED,eAAeX,UAAU,CAACK,SAAS,CAACC,gBAAgB,CAAC,CAAC"}
1
+ {"version":3,"file":"SearchFilterSort.js","names":["React","Select","useRouter","parseUrl","PropTypes","DEFAULT_SORT","handleSortUpdate","withTitle","getSortFromQuery","listComponentName","listNameKey","sortKey","sortByKey","SearchFilterSort","filters","elementLabel","selectLabel","id","router","asPath","url","query","sort","sortby","selectedValue","defaultTextValue","options","map","label","optionLabel","propsToDisplay","sortValue","setSortValue","value","createElement","className","onChange","propTypes","array","string","defaultProps"],"sources":["../../../src/components/SearchFilterSort/SearchFilterSort.js"],"sourcesContent":["import React from 'react';\nimport Select from '@blaze-react/select';\nimport { useRouter } from 'next/router';\nimport { parseUrl } from 'query-string';\nimport PropTypes from 'prop-types';\nimport { DEFAULT_SORT } from './constants';\nimport { handleSortUpdate } from './helpers';\nimport { withTitle } from '../../HOC';\n\nconst getSortFromQuery = listComponentName => {\n const listNameKey = listComponentName ? `pb[${listComponentName}]` : '';\n const sortKey = `${listNameKey}${listNameKey ? '[sort]' : 'sort'}`;\n const sortByKey = `${listNameKey}${listNameKey ? '[sortby]' : 'sortby'}`;\n return [sortKey, sortByKey];\n};\nconst SearchFilterSort = ({ filters, elementLabel, selectLabel, id, listComponentName }) => {\n const router = useRouter();\n const { asPath } = router;\n const [sortKey, sortByKey] = getSortFromQuery(listComponentName);\n const { url, query, query: { [sortKey]: sort, [sortByKey]: sortby } = {} } = parseUrl(asPath);\n const selectedValue = `${sortby}:${sort}` || '';\n const defaultTextValue = selectLabel || DEFAULT_SORT;\n const options = filters.map(({ label: optionLabel, propsToDisplay, sort: sortValue }) => [\n `${propsToDisplay[0]}:${sortValue}`,\n optionLabel\n ]);\n\n const setSortValue = ({ value }) =>\n handleSortUpdate({ router, value, query, url, selectLabel, listComponentName });\n\n return (\n <div className=\"sort-by\">\n <Select\n label={elementLabel}\n defaultTextValue={defaultTextValue}\n value={selectedValue}\n id={id}\n options={options}\n onChange={setSortValue}\n />\n </div>\n );\n};\n\nSearchFilterSort.propTypes = {\n filters: PropTypes.array,\n elementLabel: PropTypes.string,\n selectLabel: PropTypes.string,\n id: PropTypes.string,\n listComponentName: PropTypes.string\n};\n\nSearchFilterSort.defaultProps = {\n filters: [],\n elementLabel: '',\n selectLabel: '',\n id: '',\n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INATION_QUERY } from '../constants';
3
3
  import updateSort from './update-sort';
4
- const handleSortUpdate = (router, value, query, url, selectLabel) => {
4
+ const handleSortUpdate = ({
5
+ router,
6
+ value,
7
+ query,
8
+ url,
9
+ selectLabel,
10
+ listComponentName
11
+ }) => {
5
12
  const queryWithoutSort = {};
6
13
  const routerOptions = {
7
14
  shallow: true,
8
15
  scroll: false
9
16
  };
17
+ const {
18
+ asPath
19
+ } = router;
20
+ const hashBit = asPath.split('#')[1];
21
+ const parsedHash = hashBit ? `#${hashBit}` : '';
22
+ const listNameKey = listComponentName ? `pb[${listComponentName}]` : '';
23
+ const sortString = listNameKey ? `[${SORT}]` : SORT;
24
+ const sortByString = listNameKey ? `[${SORTBY}]` : SORTBY;
25
+ const sortKey = `${listNameKey}${sortString}`;
26
+ const sortByKey = `${listNameKey}${sortByString}`;
10
27
  Object.keys(query).forEach(key => {
11
28
  if (key.indexOf(PAGINATION_QUERY) !== -1) return;
12
- if (key !== SORTBY && key !== SORT) queryWithoutSort[key] = query[key];
29
+ if (key !== sortByKey && key !== sortKey) queryWithoutSort[key] = query[key];
13
30
  });
14
31
  if (value === DEFAULT_SORT || value === selectLabel) {
15
32
  const stringifiedQuery = stringify(queryWithoutSort);
16
- return stringifiedQuery ? router.push(`/Resolver`, `${url}?${stringifiedQuery}`, routerOptions) : router.push(`/Resolver`, url, routerOptions);
33
+ return stringifiedQuery ? router.push(`/Resolver`, `${url}?${stringifiedQuery}${parsedHash}`, routerOptions) : router.push(`/Resolver`, `${url}${parsedHash}`, routerOptions);
17
34
  }
18
- const updatedSortUrl = updateSort(value, queryWithoutSort, url);
35
+ const updatedSortUrl = updateSort(value, queryWithoutSort, url, parsedHash, listComponentName);
19
36
  return router.push('/Resolver', updatedSortUrl, routerOptions);
20
37
  };
21
38
  export default handleSortUpdate;
@@ -1 +1 @@
1
- {"version":3,"file":"handle-sort-update.js","names":["stringify","DEFAULT_SORT","SORT","SORTBY","PAGINATION_QUERY","updateSort","handleSortUpdate","router","value","query","url","selectLabel","queryWithoutSort","routerOptions","shallow","scroll","Object","keys","forEach","key","indexOf","stringifiedQuery","push","updatedSortUrl"],"sources":["../../../../src/components/SearchFilterSort/helpers/handle-sort-update.js"],"sourcesContent":["import { stringify } from 'query-string';\nimport { DEFAULT_SORT, SORT, SORTBY, PAGINATION_QUERY } from '../constants';\nimport updateSort from './update-sort';\n\nconst handleSortUpdate = (router, value, query, url, selectLabel) => {\n const queryWithoutSort = {};\n const routerOptions = { shallow: true, scroll: false };\n Object.keys(query).forEach(key => {\n if (key.indexOf(PAGINATION_QUERY) !== -1) return;\n if (key !== SORTBY && key !== SORT) queryWithoutSort[key] = query[key];\n });\n if (value === DEFAULT_SORT || value === selectLabel) {\n const stringifiedQuery = stringify(queryWithoutSort);\n\n return stringifiedQuery\n ? router.push(`/Resolver`, `${url}?${stringifiedQuery}`, routerOptions)\n : router.push(`/Resolver`, url, routerOptions);\n }\n const updatedSortUrl = updateSort(value, queryWithoutSort, url);\n return router.push('/Resolver', updatedSortUrl, routerOptions);\n};\n\nexport default handleSortUpdate;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAEC,gBAAgB,QAAQ,cAAc;AAC3E,OAAOC,UAAU,MAAM,eAAe;AAEtC,MAAMC,gBAAgB,GAAGA,CAACC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,GAAG,EAAEC,WAAW,KAAK;EACnE,MAAMC,gBAAgB,GAAG,CAAC,CAAC;EAC3B,MAAMC,aAAa,GAAG;IAAEC,OAAO,EAAE,IAAI;IAAEC,MAAM,EAAE;EAAM,CAAC;EACtDC,MAAM,CAACC,IAAI,CAACR,KAAK,CAAC,CAACS,OAAO,CAACC,GAAG,IAAI;IAChC,IAAIA,GAAG,CAACC,OAAO,CAAChB,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE;IAC1C,IAAIe,GAAG,KAAKhB,MAAM,IAAIgB,GAAG,KAAKjB,IAAI,EAAEU,gBAAgB,CAACO,GAAG,CAAC,GAAGV,KAAK,CAACU,GAAG,CAAC;EACxE,CAAC,CAAC;EACF,IAAIX,KAAK,KAAKP,YAAY,IAAIO,KAAK,KAAKG,WAAW,EAAE;IACnD,MAAMU,gBAAgB,GAAGrB,SAAS,CAACY,gBAAgB,CAAC;IAEpD,OAAOS,gBAAgB,GACnBd,MAAM,CAACe,IAAI,CAAE,WAAU,EAAG,GAAEZ,GAAI,IAAGW,gBAAiB,EAAC,EAAER,aAAa,CAAC,GACrEN,MAAM,CAACe,IAAI,CAAE,WAAU,EAAEZ,GAAG,EAAEG,aAAa,CAAC;EAClD;EACA,MAAMU,cAAc,GAAGlB,UAAU,CAACG,KAAK,EAAEI,gBAAgB,EAAEF,GAAG,CAAC;EAC/D,OAAOH,MAAM,CAACe,IAAI,CAAC,WAAW,EAAEC,cAAc,EAAEV,aAAa,CAAC;AAChE,CAAC;AAED,eAAeP,gBAAgB"}
1
+ {"version":3,"file":"handle-sort-update.js","names":["stringify","DEFAULT_SORT","SORT","SORTBY","PAGINATION_QUERY","updateSort","handleSortUpdate","router","value","query","url","selectLabel","listComponentName","queryWithoutSort","routerOptions","shallow","scroll","asPath","hashBit","split","parsedHash","listNameKey","sortString","sortByString","sortKey","sortByKey","Object","keys","forEach","key","indexOf","stringifiedQuery","push","updatedSortUrl"],"sources":["../../../../src/components/SearchFilterSort/helpers/handle-sort-update.js"],"sourcesContent":["import { stringify } from 'query-string';\nimport { DEFAULT_SORT, SORT, SORTBY, PAGINATION_QUERY } from '../constants';\nimport updateSort from './update-sort';\n\nconst handleSortUpdate = ({ router, value, query, url, selectLabel, listComponentName }) => {\n const queryWithoutSort = {};\n const routerOptions = { shallow: true, scroll: false };\n const { asPath } = router;\n const hashBit = asPath.split('#')[1];\n const parsedHash = hashBit ? `#${hashBit}` : '';\n const listNameKey = listComponentName ? `pb[${listComponentName}]` : '';\n const sortString = listNameKey ? `[${SORT}]` : SORT;\n const sortByString = listNameKey ? `[${SORTBY}]` : SORTBY;\n const sortKey = `${listNameKey}${sortString}`;\n const sortByKey = `${listNameKey}${sortByString}`;\n Object.keys(query).forEach(key => {\n if (key.indexOf(PAGINATION_QUERY) !== -1) return;\n if (key !== sortByKey && key !== sortKey) queryWithoutSort[key] = query[key];\n });\n if (value === DEFAULT_SORT || value === selectLabel) {\n const stringifiedQuery = stringify(queryWithoutSort);\n\n return stringifiedQuery\n ? router.push(`/Resolver`, `${url}?${stringifiedQuery}${parsedHash}`, routerOptions)\n : router.push(`/Resolver`, `${url}${parsedHash}`, routerOptions);\n }\n\n const updatedSortUrl = updateSort(value, queryWithoutSort, url, parsedHash, listComponentName);\n return router.push('/Resolver', updatedSortUrl, routerOptions);\n};\n\nexport default handleSortUpdate;\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,YAAY,EAAEC,IAAI,EAAEC,MAAM,EAAEC,gBAAgB,QAAQ,cAAc;AAC3E,OAAOC,UAAU,MAAM,eAAe;AAEtC,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,MAAM;EAAEC,KAAK;EAAEC,KAAK;EAAEC,GAAG;EAAEC,WAAW;EAAEC;AAAkB,CAAC,KAAK;EAC1F,MAAMC,gBAAgB,GAAG,CAAC,CAAC;EAC3B,MAAMC,aAAa,GAAG;IAAEC,OAAO,EAAE,IAAI;IAAEC,MAAM,EAAE;EAAM,CAAC;EACtD,MAAM;IAAEC;EAAO,CAAC,GAAGV,MAAM;EACzB,MAAMW,OAAO,GAAGD,MAAM,CAACE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;EACpC,MAAMC,UAAU,GAAGF,OAAO,GAAI,IAAGA,OAAQ,EAAC,GAAG,EAAE;EAC/C,MAAMG,WAAW,GAAGT,iBAAiB,GAAI,MAAKA,iBAAkB,GAAE,GAAG,EAAE;EACvE,MAAMU,UAAU,GAAGD,WAAW,GAAI,IAAGnB,IAAK,GAAE,GAAGA,IAAI;EACnD,MAAMqB,YAAY,GAAGF,WAAW,GAAI,IAAGlB,MAAO,GAAE,GAAGA,MAAM;EACzD,MAAMqB,OAAO,GAAI,GAAEH,WAAY,GAAEC,UAAW,EAAC;EAC7C,MAAMG,SAAS,GAAI,GAAEJ,WAAY,GAAEE,YAAa,EAAC;EACjDG,MAAM,CAACC,IAAI,CAAClB,KAAK,CAAC,CAACmB,OAAO,CAACC,GAAG,IAAI;IAChC,IAAIA,GAAG,CAACC,OAAO,CAAC1B,gBAAgB,CAAC,KAAK,CAAC,CAAC,EAAE;IAC1C,IAAIyB,GAAG,KAAKJ,SAAS,IAAII,GAAG,KAAKL,OAAO,EAAEX,gBAAgB,CAACgB,GAAG,CAAC,GAAGpB,KAAK,CAACoB,GAAG,CAAC;EAC9E,CAAC,CAAC;EACF,IAAIrB,KAAK,KAAKP,YAAY,IAAIO,KAAK,KAAKG,WAAW,EAAE;IACnD,MAAMoB,gBAAgB,GAAG/B,SAAS,CAACa,gBAAgB,CAAC;IAEpD,OAAOkB,gBAAgB,GACnBxB,MAAM,CAACyB,IAAI,CAAE,WAAU,EAAG,GAAEtB,GAAI,IAAGqB,gBAAiB,GAAEX,UAAW,EAAC,EAAEN,aAAa,CAAC,GAClFP,MAAM,CAACyB,IAAI,CAAE,WAAU,EAAG,GAAEtB,GAAI,GAAEU,UAAW,EAAC,EAAEN,aAAa,CAAC;EACpE;EAEA,MAAMmB,cAAc,GAAG5B,UAAU,CAACG,KAAK,EAAEK,gBAAgB,EAAEH,GAAG,EAAEU,UAAU,EAAER,iBAAiB,CAAC;EAC9F,OAAOL,MAAM,CAACyB,IAAI,CAAC,WAAW,EAAEC,cAAc,EAAEnB,aAAa,CAAC;AAChE,CAAC;AAED,eAAeR,gBAAgB"}
@@ -2,14 +2,18 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
4
  import { stringify } from 'query-string';
5
- const updateSort = (value, query, url) => {
5
+ import { buildQueryKey } from '../../../helpers';
6
+ import { SORT, SORTBY } from '../constants';
7
+ const updateSort = (value, query, url, hashBit = '', listComponentName = '') => {
8
+ const sortKey = buildQueryKey(SORT, listComponentName);
9
+ const sortByKey = buildQueryKey(SORTBY, listComponentName);
6
10
  const [newSortBy, newSort] = value.split(':');
7
11
  const updatedQuery = _objectSpread(_objectSpread({}, query), {}, {
8
- sortby: newSortBy,
9
- sort: newSort
12
+ [sortByKey]: newSortBy,
13
+ [sortKey]: newSort
10
14
  });
11
15
  const parsedQuery = stringify(updatedQuery);
12
- return `${url}?${parsedQuery}`;
16
+ return `${url}?${parsedQuery}${hashBit}`;
13
17
  };
14
18
  export default updateSort;
15
19
  //# sourceMappingURL=update-sort.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"update-sort.js","names":["stringify","updateSort","value","query","url","newSortBy","newSort","split","updatedQuery","_objectSpread","sortby","sort","parsedQuery"],"sources":["../../../../src/components/SearchFilterSort/helpers/update-sort.js"],"sourcesContent":["import { stringify } from 'query-string';\n\nconst updateSort = (value, query, url) => {\n const [newSortBy, newSort] = value.split(':');\n const updatedQuery = { ...query, sortby: newSortBy, sort: newSort };\n const parsedQuery = stringify(updatedQuery);\n return `${url}?${parsedQuery}`;\n};\n\nexport default updateSort;\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,cAAc;AAExC,MAAMC,UAAU,GAAGA,CAACC,KAAK,EAAEC,KAAK,EAAEC,GAAG,KAAK;EACxC,MAAM,CAACC,SAAS,EAAEC,OAAO,CAAC,GAAGJ,KAAK,CAACK,KAAK,CAAC,GAAG,CAAC;EAC7C,MAAMC,YAAY,GAAAC,aAAA,CAAAA,aAAA,KAAQN,KAAK;IAAEO,MAAM,EAAEL,SAAS;IAAEM,IAAI,EAAEL;EAAO,EAAE;EACnE,MAAMM,WAAW,GAAGZ,SAAS,CAACQ,YAAY,CAAC;EAC3C,OAAQ,GAAEJ,GAAI,IAAGQ,WAAY,EAAC;AAChC,CAAC;AAED,eAAeX,UAAU"}
1
+ {"version":3,"file":"update-sort.js","names":["stringify","buildQueryKey","SORT","SORTBY","updateSort","value","query","url","hashBit","listComponentName","sortKey","sortByKey","newSortBy","newSort","split","updatedQuery","_objectSpread","parsedQuery"],"sources":["../../../../src/components/SearchFilterSort/helpers/update-sort.js"],"sourcesContent":["import { stringify } from 'query-string';\nimport { buildQueryKey } from '../../../helpers';\nimport { SORT, SORTBY } from '../constants';\n\nconst updateSort = (value, query, url, hashBit = '', listComponentName = '') => {\n const sortKey = buildQueryKey(SORT, listComponentName);\n const sortByKey = buildQueryKey(SORTBY, listComponentName);\n const [newSortBy, newSort] = value.split(':');\n const updatedQuery = { ...query, [sortByKey]: newSortBy, [sortKey]: newSort };\n const parsedQuery = stringify(updatedQuery);\n return `${url}?${parsedQuery}${hashBit}`;\n};\n\nexport default updateSort;\n"],"mappings":";;;AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,IAAI,EAAEC,MAAM,QAAQ,cAAc;AAE3C,MAAMC,UAAU,GAAGA,CAACC,KAAK,EAAEC,KAAK,EAAEC,GAAG,EAAEC,OAAO,GAAG,EAAE,EAAEC,iBAAiB,GAAG,EAAE,KAAK;EAC9E,MAAMC,OAAO,GAAGT,aAAa,CAACC,IAAI,EAAEO,iBAAiB,CAAC;EACtD,MAAME,SAAS,GAAGV,aAAa,CAACE,MAAM,EAAEM,iBAAiB,CAAC;EAC1D,MAAM,CAACG,SAAS,EAAEC,OAAO,CAAC,GAAGR,KAAK,CAACS,KAAK,CAAC,GAAG,CAAC;EAC7C,MAAMC,YAAY,GAAAC,aAAA,CAAAA,aAAA,KAAQV,KAAK;IAAE,CAACK,SAAS,GAAGC,SAAS;IAAE,CAACF,OAAO,GAAGG;EAAO,EAAE;EAC7E,MAAMI,WAAW,GAAGjB,SAAS,CAACe,YAAY,CAAC;EAC3C,OAAQ,GAAER,GAAI,IAAGU,WAAY,GAAET,OAAQ,EAAC;AAC1C,CAAC;AAED,eAAeJ,UAAU"}
@@ -1,6 +1,7 @@
1
1
  import flatten from 'lodash.flatten';
2
2
  import isFilterEntitysId from './is-filter-entitys-id';
3
3
  import getFilterProps from './get-filter-props';
4
+ import { ID } from '../constants';
4
5
  const getRelationData = (entityData, relationName, currentRelationNames) => {
5
6
  if (!entityData) return null;
6
7
  if (currentRelationNames && currentRelationNames.length) {
@@ -38,6 +39,7 @@ const buildInheritedFilters = (entityData, inheritedFilters, currentSchema, filt
38
39
  relationForeignKeys,
39
40
  shouldIgnoreFilter
40
41
  } = getFilterProps(filter, currentSchema, filterEntitySchema);
42
+ if (filterName === ID) return;
41
43
  const relationData = getRelationData(entityData, relationName, relationForeignKeys);
42
44
  if (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId) || shouldIgnoreFilter) {
43
45
  relationFilters.push(`${filterName}/${itemId}`);
@@ -1 +1 @@
1
- {"version":3,"file":"build-inherited-filters.js","names":["flatten","isFilterEntitysId","getFilterProps","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","push","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","identifier","currentEntityId","forEach","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","Array","isArray","filtersNoRelation"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n return relationFilters;\n};\n\nexport default buildInheritedFilters;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,gBAAgB;AACpC,OAAOC,iBAAiB,MAAM,wBAAwB;AACtD,OAAOC,cAAc,MAAM,oBAAoB;AAE/C,MAAMC,eAAe,GAAGA,CAACC,UAAU,EAAEC,YAAY,EAAEC,oBAAoB,KAAK;EAC1E,IAAI,CAACF,UAAU,EAAE,OAAO,IAAI;EAC5B,IAAIE,oBAAoB,IAAIA,oBAAoB,CAACC,MAAM,EAAE;IACvD,MAAMC,gBAAgB,GAAGF,oBAAoB,CAACG,GAAG,CAACC,IAAI,IAAIN,UAAU,CAACM,IAAI,CAAC,CAAC,CAACC,MAAM,CAACC,OAAO,CAAC;IAC3F,OAAOJ,gBAAgB,CAACD,MAAM,GAAGP,OAAO,CAACQ,gBAAgB,CAAC,GAAG,IAAI;EACnE;EACA,OAAOJ,UAAU,CAACC,YAAY,CAAC;AACjC,CAAC;AAED,MAAMQ,mBAAmB,GAAGA,CAACC,WAAW,EAAEC,YAAY,KAAKD,WAAW,IAAI,CAAC,CAACC,YAAY,CAACR,MAAM;AAE/F,MAAMS,oBAAoB,GAAGA,CAACF,WAAW,EAAEG,YAAY,EAAEF,YAAY,EAAEV,YAAY,KAAK;EACtF,MAAMa,OAAO,GAAG,EAAE;EAClB,IAAID,YAAY,EAAE;IAChB,MAAME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,CAACC,GAAG,EAAEC,aAAa,KAAK;MAC/D,IAAIA,aAAa,IAAI,OAAOA,aAAa,KAAK,QAAQ,EACpDD,GAAG,CAACE,IAAI,CAAE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,oBAAoB,CAC5CF,WAAW,EACXG,YAAY,EACZF,YAAY,EACZV,YACF,CAAC;MACDwB,eAAe,CAACN,IAAI,CAAC,GAAGkB,iBAAiB,CAAC;IAC5C;IAEA,IAAIxB,YAAY,EAAE;MAChB,MAAME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,CAACC,GAAG,EAAEC,aAAa,KAAK;QAC/D,IAAIA,aAAa,CAACa,YAAY,CAAC,EAAEd,GAAG,CAACE,IAAI,CAAE,GAAEU,UAAW,IAAGX,aAAa,CAACa,YAAY,CAAE,EAAC,CAAC;QACzF,OAAOd,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNQ,eAAe,CAACN,IAAI,CAAC,GAAGJ,YAAY,CAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAACoB,YAAY,CAAC,EAAE;MACrDN,eAAe,CAACN,IAAI,CAAE,GAAEU,UAAW,IAAGlB,YAAY,CAACoB,YAAY,CAAE,EAAC,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAON,eAAe;AACxB,CAAC;AAED,eAAeL,qBAAqB"}
1
+ {"version":3,"file":"build-inherited-filters.js","names":["flatten","isFilterEntitysId","getFilterProps","ID","getRelationData","entityData","relationName","currentRelationNames","length","arrayOfRelations","map","name","filter","Boolean","checkIfArrayHasData","isDataArray","relationData","setFiltersNoRelation","arrayHasData","filters","filterValues","reduce","acc","relationValue","push","buildInheritedFilters","inheritedFilters","currentSchema","filterEntitySchema","itemId","relationFilters","identifier","currentEntityId","forEach","filterName","entityName","relationProp","relationEntityName","relationForeignKeys","shouldIgnoreFilter","Array","isArray","filtersNoRelation"],"sources":["../../src/helpers/build-inherited-filters.js"],"sourcesContent":["import flatten from 'lodash.flatten';\nimport isFilterEntitysId from './is-filter-entitys-id';\nimport getFilterProps from './get-filter-props';\nimport { ID } from '../constants';\n\nconst getRelationData = (entityData, relationName, currentRelationNames) => {\n if (!entityData) return null;\n if (currentRelationNames && currentRelationNames.length) {\n const arrayOfRelations = currentRelationNames.map(name => entityData[name]).filter(Boolean);\n return arrayOfRelations.length ? flatten(arrayOfRelations) : null;\n }\n return entityData[relationName];\n};\n\nconst checkIfArrayHasData = (isDataArray, relationData) => isDataArray && !!relationData.length;\n\nconst setFiltersNoRelation = (isDataArray, arrayHasData, relationData, relationName) => {\n const filters = [];\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue && typeof relationValue !== 'object')\n acc.push(`${relationName}/${relationValue}`);\n return acc;\n }, []);\n filters.push(...filterValues);\n } else if (!isDataArray && typeof relationData !== 'object') {\n filters.push(`${relationName}/${relationData}`);\n }\n\n return filters;\n};\nconst buildInheritedFilters = (\n entityData,\n inheritedFilters,\n currentSchema,\n filterEntitySchema,\n itemId\n) => {\n const relationFilters = [];\n const { identifier: currentEntityId } = currentSchema;\n\n inheritedFilters.forEach(filter => {\n const {\n filterName,\n entityName,\n relationName,\n relationProp,\n relationEntityName,\n relationForeignKeys,\n shouldIgnoreFilter\n } = getFilterProps(filter, currentSchema, filterEntitySchema);\n\n if (filterName === ID) return;\n\n const relationData = getRelationData(entityData, relationName, relationForeignKeys);\n if (\n (currentEntityId === entityName && isFilterEntitysId(filterName, currentEntityId)) ||\n shouldIgnoreFilter\n ) {\n relationFilters.push(`${filterName}/${itemId}`);\n }\n\n if (!relationData) return;\n\n const isDataArray = Array.isArray(relationData);\n const arrayHasData = checkIfArrayHasData(isDataArray, relationData);\n\n if (!relationEntityName) {\n const filtersNoRelation = setFiltersNoRelation(\n isDataArray,\n arrayHasData,\n relationData,\n relationName\n );\n relationFilters.push(...filtersNoRelation);\n }\n\n if (arrayHasData) {\n const filterValues = relationData.reduce((acc, relationValue) => {\n if (relationValue[relationProp]) acc.push(`${filterName}/${relationValue[relationProp]}`);\n return acc;\n }, []);\n relationFilters.push(...filterValues);\n } else if (!isDataArray && relationData[relationProp]) {\n relationFilters.push(`${filterName}/${relationData[relationProp]}`);\n }\n });\n\n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AME,YAAY,GAAGJ,YAAY,CAACK,MAAM,CAAC,CAACC,GAAG,EAAEC,aAAa,KAAK;QAC/D,IAAIA,aAAa,CAACa,YAAY,CAAC,EAAEd,GAAG,CAACE,IAAI,CAAE,GAAEU,UAAW,IAAGX,aAAa,CAACa,YAAY,CAAE,EAAC,CAAC;QACzF,OAAOd,GAAG;MACZ,CAAC,EAAE,EAAE,CAAC;MACNQ,eAAe,CAACN,IAAI,CAAC,GAAGJ,YAAY,CAAC;IACvC,CAAC,MAAM,IAAI,CAACL,WAAW,IAAIC,YAAY,CAACoB,YAAY,CAAC,EAAE;MACrDN,eAAe,CAACN,IAAI,CAAE,GAAEU,UAAW,IAAGlB,YAAY,CAACoB,YAAY,CAAE,EAAC,CAAC;IACrE;EACF,CAAC,CAAC;EAEF,OAAON,eAAe;AACxB,CAAC;AAED,eAAeL,qBAAqB"}
@@ -28,16 +28,18 @@ const buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, link
28
28
  };
29
29
  const buildComplexProps = (shouldAddCategoryProps, props, {
30
30
  relations = [],
31
- dynamicProperties = {}
31
+ dynamicProperties = {},
32
+ properties = {}
32
33
  }, linkProps) => Object.keys(props).map(base => {
33
34
  const nestedProps = props[base];
34
35
  const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));
36
+ const matchingProperty = !!properties[base];
35
37
  const matchingRelation = relations.find(({
36
38
  localField
37
39
  }) => localField === base);
38
40
  const matchingDynamicProp = Object.keys(dynamicProperties).find(dynamicKey => dynamicKey === base);
39
41
  if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');
40
- if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
42
+ if (hasLink && (!!matchingProperty || !!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');
41
43
  const jointNestedProps = nestedProps.join(',');
42
44
  if (base === 'category' && shouldAddCategoryProps) return `${base}{${jointNestedProps}, ${categoryProps}}`;
43
45
  if (base.includes('published')) {
@@ -1 +1 @@
1
- {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","map","hasLink","find","linkProp","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","properties","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingRelation || !!matchingDynamicProp)) nestedProps.push('url');\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AACjC,MAAMI,aAAa,GAAG,kCAAkC;AAExD,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKX,WAAW,CAAC,CAACY,MAAM,CAAC;AAE7E,MAAMC,eAAe,GAAGA,CAACC,YAAY,EAAEC,UAAU,GAAG,EAAE,EAAEC,WAAW,GAAG,IAAI,EAAEC,SAAS,GAAG,EAAE,KAAK;EAC7F,MAAMC,YAAY,GAAGJ,YAAY,CAACK,eAAe,GAAGL,YAAY,CAACK,eAAe,GAAGL,YAAY;EAC/F,MAAMM,sBAAsB,GAAG,CAAC,CAACL,UAAU,CAACL,MAAM,CAACC,IAAI,IAAIA,IAAI,CAACU,QAAQ,CAAC,WAAW,CAAC,CAAC,CAACT,MAAM;EAC7F,MAAM;IAAEU,cAAc;IAAEC;EAAuB,CAAC,GAAGC,gBAAgB,CACjEN,YAAY,EACZF,WAAW,EACXI,sBACF,CAAC;EAED,MAAMK,QAAQ,GAAG,CAAC,GAAGH,cAAc,EAAE,GAAGP,UAAU,CAAC;EACnD,MAAMW,WAAW,GAAG,CAAC,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAGF,QAAQ,CAAC,CAAC,CAAC;EAC/C,MAAMG,UAAU,GAAG,EAAE;EACrB,MAAMC,WAAW,GAAG,CAAC,CAAC;EACtBH,WAAW,CAACI,OAAO,CAACnB,IAAI,IAAI;IAC1B,IAAIA,IAAI,EAAE;M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 {"version":3,"file":"build-props-query.js","names":["CATEGORY_ID","ID","PREHEADER_PROP","HEADLINE_PROP","defaultProps","categoryProps","checkProps","props","Object","keys","filter","prop","length","buildPropsQuery","entitySchema","extraProps","cardOptions","linkProps","parsedSchema","getEntitySchema","extraPropsHaveCategory","includes","typeBasedProps","shouldAddCategoryProps","getTypeBaseProps","allProps","uniqueProps","Set","basicProps","nestedProps","forEach","push","base","nested","split","complexProps","buildComplexProps","join","relations","dynamicProperties","properties","map","hasLink","find","linkProp","matchingProperty","matchingRelation","localField","matchingDynamicProp","dynamicKey","jointNestedProps","isCard","displayCategory","displayThumbnail","interfaces","isContent","hasCategory","hasPreheader","getCategoyProps","getContentProps","url"],"sources":["../../src/helpers/build-props-query.js"],"sourcesContent":["import { CATEGORY_ID, ID, PREHEADER_PROP, HEADLINE_PROP } from '../constants';\n\nconst defaultProps = [ID, 'name'];\nconst categoryProps = 'id publishedListingPage{id, url}';\n\nconst checkProps = props =>\n !!(props && Object.keys(props).filter(prop => prop === CATEGORY_ID).length);\n\nconst buildPropsQuery = (entitySchema, extraProps = [], cardOptions = null, linkProps = []) => {\n const parsedSchema = entitySchema.getEntitySchema ? entitySchema.getEntitySchema : entitySchema;\n const extraPropsHaveCategory = !!extraProps.filter(prop => prop.includes('category.')).length;\n const { typeBasedProps, shouldAddCategoryProps } = getTypeBaseProps(\n parsedSchema,\n cardOptions,\n extraPropsHaveCategory\n );\n\n const allProps = [...typeBasedProps, ...extraProps];\n const uniqueProps = [...new Set([...allProps])];\n const basicProps = [];\n const nestedProps = {};\n uniqueProps.forEach(prop => {\n if (prop) {\n if (!prop.includes('.')) {\n basicProps.push(prop);\n return;\n }\n const [base, nested] = prop.split('.');\n if (!nestedProps[base]) nestedProps[base] = [nested];\n else nestedProps[base].push(nested);\n }\n });\n\n const complexProps = buildComplexProps(\n shouldAddCategoryProps,\n nestedProps,\n parsedSchema,\n linkProps\n );\n\n return [...basicProps, ...complexProps].join(',');\n};\n\nconst buildComplexProps = (\n shouldAddCategoryProps,\n props,\n { relations = [], dynamicProperties = {}, properties = {} },\n linkProps\n) =>\n Object.keys(props).map(base => {\n const nestedProps = props[base];\n const hasLink = !!linkProps.find(linkProp => linkProp.includes(base));\n const matchingProperty = !!properties[base];\n const matchingRelation = relations.find(({ localField }) => localField === base);\n const matchingDynamicProp = Object.keys(dynamicProperties).find(\n dynamicKey => dynamicKey === base\n );\n\n if (matchingRelation && !nestedProps.includes('id')) nestedProps.push('id');\n if (hasLink && (!!matchingProperty || !!matchingRelation || !!matchingDynamicProp))\n nestedProps.push('url');\n const jointNestedProps = nestedProps.join(',');\n if (base === 'category' && shouldAddCategoryProps)\n return `${base}{${jointNestedProps}, ${categoryProps}}`;\n if (base.includes('published')) {\n return `${base}{${jointNestedProps},url}`;\n }\n return `${base}{${jointNestedProps}}`;\n });\n\nconst getTypeBaseProps = (entitySchema, cardOptions, extraPropsHaveCategory) => {\n const isCard = !!cardOptions;\n const { displayCategory = true, displayThumbnail = true } = cardOptions || {};\n\n const shouldAddCategoryProps =\n (isCard && displayCategory) || (!isCard && !extraPropsHaveCategory);\n\n if (!isCard) return { typeBasedProps: [ID], shouldAddCategoryProps };\n\n const { interfaces, properties, dynamicProperties, relations } = entitySchema;\n\n const isContent = !!interfaces.includes('content/content');\n const hasCategory = checkProps(properties) || checkProps(dynamicProperties);\n const hasPreheader = properties[PREHEADER_PROP];\n\n const typeBasedProps = [...defaultProps];\n\n typeBasedProps.push(...getCategoyProps(shouldAddCategoryProps, hasCategory, hasPreheader));\n typeBasedProps.push(...getContentProps(isContent));\n\n if (properties.url || dynamicProperties.url) typeBasedProps.push('url');\n\n if (displayThumbnail && relations.find(({ localField }) => localField === 'image')) {\n typeBasedProps.push('image.id', 'image.url', 'image.data');\n }\n\n return { typeBasedProps, shouldAddCategoryProps };\n};\n\nconst getContentProps = isContent => (isContent ? ['url', 'sponsored', 'featured'] : []);\n\nconst getCategoyProps = (shouldAddCategoryProps, hasCategory, hasPreheader) => {\n if (!shouldAddCategoryProps) return [];\n const props = [];\n if (hasCategory)\n props.push('category.name', 'category.listingPageId', 'category.listingPageEntity');\n\n if (hasPreheader) {\n props.push(`${PREHEADER_PROP}{name}`);\n props.push(HEADLINE_PROP);\n }\n\n return props;\n};\n\nexport default buildPropsQuery;\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,EAAE,EAAEC,cAAc,EAAEC,aAAa,QAAQ,cAAc;AAE7E,MAAMC,YAAY,GAAG,CAACH,EAAE,EAAE,MAAM,CAAC;AACjC,MAAMI,aAAa,GAAG,kCAAkC;AAExD,MAAMC,UAAU,GAAGC,KAAK,IACtB,CAAC,EAAEA,KAAK,IAAIC,MAAM,CAACC,IAAI,CAACF,KAAK,CAAC,CAACG,MAAM,CAACC,IAAI,IAAIA,IAAI,KAAKX,WAAW,CAAC,CAACY,MAAM,CAAC;AAE7E,MAAMC,eAAe,GAAGA,CAACC,YAAY,EAAEC,UAAU,GAAG,EAAE,EAAEC,WAAW,GAAG,IAAI,EAAEC,SAAS,GAAG,EAAE,KAAK;EAC7F,MAAMC,YAAY,GAAGJ,YAAY,CAACK,eAAe,GAAGL,YAAY,CAACK,eAAe,GAAGL,YAAY;EAC/F,MAAMM,sBAAsB,GAAG,CAAC,CAACL,UAAU,CAACL,MAAM,CAACC,IAAI,IAAIA,IAAI,CAACU,QAAQ,CAAC,WAAW,CAAC,CAAC,CAACT,MAAM;EAC7F,MAAM;IAAEU,cAAc;IAAEC;EAAuB,CAAC,GAAGC,gBAAgB,CACjEN,YAAY,EACZF,WAAW,EACXI,sBACF,CAAC;EAED,MAAMK,QAAQ,GAAG,CAAC,GAAGH,cAAc,EAAE,GAAGP,UAAU,CAAC;EACnD,MAAMW,WAAW,GAAG,CAAC,GAAG,IAAIC,GAAG,CAAC,CAAC,GAAGF,QAAQ,CAAC,CAAC,CAAC;EAC/C,MAAMG,UAAU,GAAG,EAAE;EACrB,MAAMC,WAAW,GAAG,CAAC,CAAC;EACtBH,WAAW,CAACI,OAAO,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EAAE;IAChBlD,KAAK,CAACwB,IAAI,CAAE,GAAE7B,cAAe,QAAO,CAAC;IACrCK,KAAK,CAACwB,IAAI,CAAC5B,aAAa,CAAC;EAC3B;EAEA,OAAOI,KAAK;AACd,CAAC;AAED,eAAeM,eAAe"}
@@ -0,0 +1,7 @@
1
+ const buildQueryKey = (key, listName) => {
2
+ const listNameKey = listName ? `pb[${listName}]` : '';
3
+ const wrappedSearchKey = listNameKey ? `[${key}]` : key;
4
+ return `${listNameKey}${wrappedSearchKey}`;
5
+ };
6
+ export default buildQueryKey;
7
+ //# sourceMappingURL=build-query-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-query-key.js","names":["buildQueryKey","key","listName","listNameKey","wrappedSearchKey"],"sources":["../../src/helpers/build-query-key.js"],"sourcesContent":["const buildQueryKey = (key, listName) => {\n const listNameKey = listName ? `pb[${listName}]` : '';\n const wrappedSearchKey = listNameKey ? `[${key}]` : key;\n return `${listNameKey}${wrappedSearchKey}`;\n};\n\nexport default buildQueryKey;\n"],"mappings":"AAAA,MAAMA,aAAa,GAAGA,CAACC,GAAG,EAAEC,QAAQ,KAAK;EACvC,MAAMC,WAAW,GAAGD,QAAQ,GAAI,MAAKA,QAAS,GAAE,GAAG,EAAE;EACrD,MAAME,gBAAgB,GAAGD,WAAW,GAAI,IAAGF,GAAI,GAAE,GAAGA,GAAG;EACvD,OAAQ,GAAEE,WAAY,GAAEC,gBAAiB,EAAC;AAC5C,CAAC;AAED,eAAeJ,aAAa"}
@@ -24,7 +24,11 @@ const buildSetFilters = ({
24
24
  getCheckboxFilters(checkboxFilters, SPONSORED);
25
25
  }
26
26
  const shouldApplyFilterValues = filterBy.length && filterByProperty.length;
27
- const listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};
27
+ if (!shouldApplyFilterValues) return {
28
+ checkboxFilters,
29
+ listFilterValues: {}
30
+ };
31
+ const listFilterValues = getFilterValues(filterBy);
28
32
  return {
29
33
  checkboxFilters,
30
34
  listFilterValues
@@ -1 +1 @@
1
- {"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\n\nconst getCheckboxFilters = (checkboxFilters, name) => {\n checkboxFilters.push(name);\n};\n\nconst getFilterValues = filterBy =>\n filterBy.reduce((acc, filter) => {\n const [fieldName, ...values] = filter.split('/');\n const value = values.join('/');\n const previousValue = acc[fieldName];\n const finalValue = previousValue ? [...previousValue, value] : [value];\n\n acc[fieldName] = finalValue;\n return acc;\n }, {});\n\nconst buildSetFilters = ({\n filterBy = [],\n filterByProperty = [],\n filterByFeatured,\n filterBySponsored\n}) => {\n const checkboxFilters = [];\n\n if (filterByFeatured) {\n getCheckboxFilters(checkboxFilters, FEATURED);\n }\n if (filterBySponsored) {\n getCheckboxFilters(checkboxFilters, SPONSORED);\n }\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n const listFilterValues = shouldApplyFilterValues ? getFilterValues(filterBy) : {};\n\n return { checkboxFilters, listFilterValues };\n};\n\nexport default buildSetFilters;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,cAAc;AAElD,MAAMC,kBAAkB,GAAGA,CAACC,eAAe,EAAEC,IAAI,KAAK;EACpDD,eAAe,CAACE,IAAI,CAACD,IAAI,CAAC;AAC5B,CAAC;AAED,MAAME,eAAe,GAAGC,QAAQ,IAC9BA,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EAC/B,MAAM,CAACC,SAAS,EAAE,GAAGC,MAAM,CAAC,GAAGF,MAAM,CAACG,KAAK,CAAC,GAAG,CAAC;EAChD,MAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC;EAC9B,MAAMC,aAAa,GAAGP,GAAG,CAACE,SAAS,CAAC;EACpC,MAAMM,UAAU,GAAGD,aAAa,GAAG,CAAC,GAAGA,aAAa,EAAEF,KAAK,CAAC,GAAG,CAACA,KAAK,CAAC;EAEtEL,GAAG,CAACE,SAAS,CAAC,GAAGM,UAAU;EAC3B,OAAOR,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAER,MAAMS,eAAe,GAAGA,CAAC;EACvBX,QAAQ,GAAG,EAAE;EACbY,gBAAgB,GAAG,EAAE;EACrBC,gBAAgB;EAChBC;AACF,CAAC,KAAK;EACJ,MAAMlB,eAAe,GAAG,EAAE;EAE1B,IAAIiB,gBAAgB,EAAE;IACpBlB,kBAAkB,CAACC,eAAe,EAAEH,QAAQ,CAAC;EAC/C;EACA,IAAIqB,iBAAiB,EAAE;IACrBnB,kBAAkB,CAACC,eAAe,EAAEF,SAAS,CAAC;EAChD;EAEA,MAAMqB,uBAAuB,GAAGf,QAAQ,CAACgB,MAAM,IAAIJ,gBAAgB,CAACI,MAAM;EAC1E,MAAMC,gBAAgB,GAAGF,uBAAuB,GAAGhB,eAAe,CAACC,QAAQ,CAAC,GAAG,CAAC,CAAC;EAEjF,OAAO;IAAEJ,eAAe;IAAEqB;EAAiB,CAAC;AAC9C,CAAC;AAED,eAAeN,eAAe"}
1
+ {"version":3,"file":"build-set-filters.js","names":["FEATURED","SPONSORED","getCheckboxFilters","checkboxFilters","name","push","getFilterValues","filterBy","reduce","acc","filter","fieldName","values","split","value","join","previousValue","finalValue","buildSetFilters","filterByProperty","filterByFeatured","filterBySponsored","shouldApplyFilterValues","length","listFilterValues"],"sources":["../../src/helpers/build-set-filters.js"],"sourcesContent":["import { FEATURED, SPONSORED } from '../constants';\n\nconst getCheckboxFilters = (checkboxFilters, name) => {\n checkboxFilters.push(name);\n};\n\nconst getFilterValues = filterBy =>\n filterBy.reduce((acc, filter) => {\n const [fieldName, ...values] = filter.split('/');\n const value = values.join('/');\n const previousValue = acc[fieldName];\n const finalValue = previousValue ? [...previousValue, value] : [value];\n\n acc[fieldName] = finalValue;\n return acc;\n }, {});\n\nconst buildSetFilters = ({\n filterBy = [],\n filterByProperty = [],\n filterByFeatured,\n filterBySponsored\n}) => {\n const checkboxFilters = [];\n\n if (filterByFeatured) {\n getCheckboxFilters(checkboxFilters, FEATURED);\n }\n if (filterBySponsored) {\n getCheckboxFilters(checkboxFilters, SPONSORED);\n }\n\n const shouldApplyFilterValues = filterBy.length && filterByProperty.length;\n if (!shouldApplyFilterValues) return { checkboxFilters, listFilterValues: {} };\n\n const listFilterValues = getFilterValues(filterBy);\n return { checkboxFilters, listFilterValues };\n};\n\nexport default buildSetFilters;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,SAAS,QAAQ,cAAc;AAElD,MAAMC,kBAAkB,GAAGA,CAACC,eAAe,EAAEC,IAAI,KAAK;EACpDD,eAAe,CAACE,IAAI,CAACD,IAAI,CAAC;AAC5B,CAAC;AAED,MAAME,eAAe,GAAGC,QAAQ,IAC9BA,QAAQ,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EAC/B,MAAM,CAACC,SAAS,EAAE,GAAGC,MAAM,CAAC,GAAGF,MAAM,CAACG,KAAK,CAAC,GAAG,CAAC;EAChD,MAAMC,KAAK,GAAGF,MAAM,CAACG,IAAI,CAAC,GAAG,CAAC;EAC9B,MAAMC,aAAa,GAAGP,GAAG,CAACE,SAAS,CAAC;EACpC,MAAMM,UAAU,GAAGD,aAAa,GAAG,CAAC,GAAGA,aAAa,EAAEF,KAAK,CAAC,GAAG,CAACA,KAAK,CAAC;EAEtEL,GAAG,CAACE,SAAS,CAAC,GAAGM,UAAU;EAC3B,OAAOR,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AAER,MAAMS,eAAe,GAAGA,CAAC;EACvBX,QAAQ,GAAG,EAAE;EACbY,gBAAgB,GAAG,EAAE;EACrBC,gBAAgB;EAChBC;AACF,CAAC,KAAK;EACJ,MAAMlB,eAAe,GAAG,EAAE;EAE1B,IAAIiB,gBAAgB,EAAE;IACpBlB,kBAAkB,CAACC,eAAe,EAAEH,QAAQ,CAAC;EAC/C;EACA,IAAIqB,iBAAiB,EAAE;IACrBnB,kBAAkB,CAACC,eAAe,EAAEF,SAAS,CAAC;EAChD;EAEA,MAAMqB,uBAAuB,GAAGf,QAAQ,CAACgB,MAAM,IAAIJ,gBAAgB,CAACI,MAAM;EAC1E,IAAI,CAACD,uBAAuB,EAAE,OAAO;IAAEnB,eAAe;IAAEqB,gBAAgB,EAAE,CAAC;EAAE,CAAC;EAE9E,MAAMA,gBAAgB,GAAGlB,eAAe,CAACC,QAAQ,CAAC;EAClD,OAAO;IAAEJ,eAAe;IAAEqB;EAAiB,CAAC;AAC9C,CAAC;AAED,eAAeN,eAAe"}
@@ -11,12 +11,19 @@ export default function getEntitiesWithBanner(entities, options, hasNewBannerSet
11
11
  const {
12
12
  parent,
13
13
  transform,
14
- limit
14
+ limit,
15
+ banner
15
16
  } = options;
17
+ const {
18
+ adunit,
19
+ baseAdunit
20
+ } = banner || {};
16
21
  return _objectSpread(_objectSpread({}, currentEntity), {}, {
17
22
  parent,
18
23
  limit,
19
- transform
24
+ transform,
25
+ adunit,
26
+ baseAdunit
20
27
  });
21
28
  });
22
29
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-entities-with-banner.js","names":["injectBannersToEntities","getEntitiesWithBanner","entities","options","hasNewBannerSettings","hasBanner","map","currentEntity","parent","transform","limit","_objectSpread"],"sources":["../../src/helpers/get-entities-with-banner.js"],"sourcesContent":["import injectBannersToEntities from './inject-banners-to-entities';\n\nexport default function getEntitiesWithBanner(entities, options, hasNewBannerSettings) {\n const { hasBanner } = options;\n if (hasNewBannerSettings) {\n return entities.map(currentEntity => {\n const { parent, transform, limit } = options;\n return { ...currentEntity, parent, limit, transform };\n });\n }\n if (!hasBanner) return entities;\n\n return injectBannersToEntities(entities, options);\n}\n"],"mappings":";;;AAAA,OAAOA,uBAAuB,MAAM,8BAA8B;AAElE,eAAe,SAASC,qBAAqBA,CAACC,QAAQ,EAAEC,OAAO,EAAEC,oBAAoB,EAAE;EACrF,MAAM;IAAEC;EAAU,CAAC,GAAGF,OAAO;EAC7B,IAAIC,oBAAoB,EAAE;IACxB,OAAOF,QAAQ,CAACI,GAAG,CAACC,aAAa,IAAI;MACnC,MAAM;QAAEC,MAAM;QAAEC,SAAS;QAAEC;MAAM,CAAC,GAAGP,OAAO;MAC5C,OAAAQ,aAAA,CAAAA,aAAA,KAAYJ,aAAa;QAAEC,MAAM;QAAEE,KAAK;QAAED;MAAS;IACrD,CAAC,CAAC;EACJ;EACA,IAAI,CAACJ,SAAS,EAAE,OAAOH,QAAQ;EAE/B,OAAOF,uBAAuB,CAACE,QAAQ,EAAEC,OAAO,CAAC;AACnD"}
1
+ {"version":3,"file":"get-entities-with-banner.js","names":["injectBannersToEntities","getEntitiesWithBanner","entities","options","hasNewBannerSettings","hasBanner","map","currentEntity","parent","transform","limit","banner","adunit","baseAdunit","_objectSpread"],"sources":["../../src/helpers/get-entities-with-banner.js"],"sourcesContent":["import injectBannersToEntities from './inject-banners-to-entities';\n\nexport default function getEntitiesWithBanner(entities, options, hasNewBannerSettings) {\n const { hasBanner } = options;\n if (hasNewBannerSettings) {\n return entities.map(currentEntity => {\n const { parent, transform, limit, banner } = options;\n const { adunit, baseAdunit } = banner || {};\n return { ...currentEntity, parent, limit, transform, adunit, baseAdunit };\n });\n }\n if (!hasBanner) return entities;\n\n return injectBannersToEntities(entities, options);\n}\n"],"mappings":";;;AAAA,OAAOA,uBAAuB,MAAM,8BAA8B;AAElE,eAAe,SAASC,qBAAqBA,CAACC,QAAQ,EAAEC,OAAO,EAAEC,oBAAoB,EAAE;EACrF,MAAM;IAAEC;EAAU,CAAC,GAAGF,OAAO;EAC7B,IAAIC,oBAAoB,EAAE;IACxB,OAAOF,QAAQ,CAACI,GAAG,CAACC,aAAa,IAAI;MACnC,MAAM;QAAEC,MAAM;QAAEC,SAAS;QAAEC,KAAK;QAAEC;MAAO,CAAC,GAAGR,OAAO;MACpD,MAAM;QAAES,MAAM;QAAEC;MAAW,CAAC,GAAGF,MAAM,IAAI,CAAC,CAAC;MAC3C,OAAAG,aAAA,CAAAA,aAAA,KAAYP,aAAa;QAAEC,MAAM;QAAEE,KAAK;QAAED,SAAS;QAAEG,MAAM;QAAEC;MAAU;IACzE,CAAC,CAAC;EACJ;EACA,IAAI,CAACR,SAAS,EAAE,OAAOH,QAAQ;EAE/B,OAAOF,uBAAuB,CAACE,QAAQ,EAAEC,OAAO,CAAC;AACnD"}