@blaze-cms/react-page-builder 0.133.0-alpha.2 → 0.133.0-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/lib/components/Button.js +3 -1
  3. package/lib/components/Button.js.map +1 -1
  4. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js +2 -2
  5. package/lib/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  6. package/lib/components/SearchFilter/SearchFilterContainer.js +58 -22
  7. package/lib/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  8. package/lib/components/SearchFilter/helpers/build-filters-query.js +18 -16
  9. package/lib/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  10. package/lib/components/SearchFilter/helpers/build-url-query.js +0 -1
  11. package/lib/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  12. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js +33 -0
  13. package/lib/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  14. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js +38 -0
  15. package/lib/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  16. package/lib/components/SearchFilter/helpers/index.js +8 -1
  17. package/lib/components/SearchFilter/helpers/index.js.map +1 -1
  18. package/lib/components/SocialFollow/sf.config.js +2 -1
  19. package/lib/components/SocialFollow/sf.config.js.map +1 -1
  20. package/lib/helpers/get-generic-render-variables.js +17 -12
  21. package/lib/helpers/get-generic-render-variables.js.map +1 -1
  22. package/lib-es/components/Button.js +2 -1
  23. package/lib-es/components/Button.js.map +1 -1
  24. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js +3 -3
  25. package/lib-es/components/SearchFilter/SearchFilter/SearchFilter.js.map +1 -1
  26. package/lib-es/components/SearchFilter/SearchFilterContainer.js +54 -13
  27. package/lib-es/components/SearchFilter/SearchFilterContainer.js.map +1 -1
  28. package/lib-es/components/SearchFilter/helpers/build-filters-query.js +18 -16
  29. package/lib-es/components/SearchFilter/helpers/build-filters-query.js.map +1 -1
  30. package/lib-es/components/SearchFilter/helpers/build-url-query.js +0 -1
  31. package/lib-es/components/SearchFilter/helpers/build-url-query.js.map +1 -1
  32. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js +21 -0
  33. package/lib-es/components/SearchFilter/helpers/get-initial-filter-values.js.map +1 -0
  34. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js +19 -0
  35. package/lib-es/components/SearchFilter/helpers/get-updated-filter-by.js.map +1 -0
  36. package/lib-es/components/SearchFilter/helpers/index.js +3 -2
  37. package/lib-es/components/SearchFilter/helpers/index.js.map +1 -1
  38. package/lib-es/components/SocialFollow/sf.config.js +3 -2
  39. package/lib-es/components/SocialFollow/sf.config.js.map +1 -1
  40. package/lib-es/helpers/get-generic-render-variables.js +2 -1
  41. package/lib-es/helpers/get-generic-render-variables.js.map +1 -1
  42. package/package.json +6 -6
  43. package/src/components/Button.js +6 -1
  44. package/src/components/SearchFilter/SearchFilter/SearchFilter.js +6 -3
  45. package/src/components/SearchFilter/SearchFilterContainer.js +42 -14
  46. package/src/components/SearchFilter/helpers/build-filters-query.js +23 -20
  47. package/src/components/SearchFilter/helpers/build-url-query.js +0 -2
  48. package/src/components/SearchFilter/helpers/get-initial-filter-values.js +24 -0
  49. package/src/components/SearchFilter/helpers/get-updated-filter-by.js +18 -0
  50. package/src/components/SearchFilter/helpers/index.js +5 -3
  51. package/src/components/SocialFollow/sf.config.js +2 -2
  52. package/src/helpers/get-generic-render-variables.js +2 -1
  53. package/tests/unit/src/components/SearchFilter/helpers/get-updated-filter-by.test.js +28 -0
  54. package/tests/unit/src/components/SocialFollow/__snapshots__/SocialFollow.test.js.snap +1 -1
  55. /package/tests/unit/src/components/SearchFilter/helpers/{build-new-query.test.js → build-new-url.test.js} +0 -0
@@ -29,38 +29,41 @@ const builFilterObject = ({ queryKey, value, filters, isRange, isInQuery }) => {
29
29
  filters.push({ match: { [key]: filterValue } });
30
30
  });
31
31
  };
32
+
32
33
  const buildFiltersQuery = ({
33
34
  shouldAddFilters,
34
- query,
35
+
35
36
  filterBy,
36
37
  filterByProperty,
37
38
  rangeValues,
38
- queryKeys
39
+ queryKeys,
40
+ query
39
41
  }) => {
40
42
  if (!shouldAddFilters) return [];
41
43
  const mustFilters = [];
42
- Object.keys(query).forEach(queryKey => {
43
- if (QUERY_KEYS_TO_IGNORE.includes(queryKey)) return;
44
- if (!queryKey || !query[queryKey]) return;
45
- const queryValue = query[queryKey];
44
+ if (query) {
45
+ Object.keys(query).forEach(queryKey => {
46
+ if (QUERY_KEYS_TO_IGNORE.includes(queryKey)) return;
47
+ if (!queryKey || !query[queryKey]) return;
48
+ const queryValue = query[queryKey];
46
49
 
47
- const isRange = rangeValues.includes(queryKey);
48
- const isInQuery = queryKeys.includes(queryKey);
49
- builFilterObject({ queryKey, value: queryValue, filters: mustFilters, isRange, isInQuery });
50
- });
50
+ const isRange = rangeValues.includes(queryKey);
51
+ const isInQuery = queryKeys.includes(queryKey);
52
+ builFilterObject({ queryKey, value: queryValue, filters: mustFilters, isRange, isInQuery });
53
+ });
54
+ }
51
55
 
52
56
  if (filterByProperty && filterByProperty.length) {
53
- filterByProperty &&
54
- filterByProperty.forEach(filterByPropOption => {
55
- const [filterByPropKey] = filterByPropOption.split('/');
56
- filterBy.forEach(filterByOption => {
57
- if (filterByOption.indexOf(filterByPropKey) === -1) return;
58
- const [, filteryByValue] = filterByOption.split('/');
59
- const filterByKeyword = `${filterByPropKey}.keyword`;
60
- if (!filteryByValue) return;
61
- mustFilters.push({ match: { [filterByKeyword]: filteryByValue } });
62
- });
57
+ filterByProperty.forEach(filterByPropOption => {
58
+ const [filterByPropKey] = filterByPropOption.split('/');
59
+ filterBy.forEach(filterByOption => {
60
+ if (filterByOption.indexOf(filterByPropKey) === -1) return;
61
+ const [, filteryByValue] = filterByOption.split('/');
62
+ const filterByKeyword = `${filterByPropKey}.keyword`;
63
+ if (!filteryByValue) return;
64
+ mustFilters.push({ match: { [filterByKeyword]: filteryByValue } });
63
65
  });
66
+ });
64
67
  }
65
68
 
66
69
  return mustFilters;
@@ -3,8 +3,6 @@ import parseFilterValue from './parse-filter-value';
3
3
  import { buildQueryKey } from '../../../helpers';
4
4
 
5
5
  const buildUrlQuery = (filterValues, filters, listComponentName = '', query = {}) => {
6
- if (!filterValues) return '';
7
-
8
6
  const newQuery = [];
9
7
  const queryKeys = [];
10
8
  const searchValue = filterValues[SEARCH_TERM];
@@ -0,0 +1,24 @@
1
+ import { SEARCH_TERM, TEXT_SEARCH } from '../constants';
2
+ import getFilterValueFromQuery from './get-filter-value-from-query';
3
+ import { buildQueryKey } from '../../../helpers';
4
+
5
+ const getInitialFilterValues = (filterData, filters, query, listComponentName) => {
6
+ const filterValues = {};
7
+ const searchQueryKey = buildQueryKey(SEARCH_TERM, listComponentName);
8
+ filterValues[SEARCH_TERM] = query[searchQueryKey] || '';
9
+
10
+ filters.forEach(filterProps => {
11
+ const {
12
+ propsToDisplay: [key],
13
+ type
14
+ } = filterProps;
15
+ if (type === TEXT_SEARCH) return;
16
+ const data = filterData && filterData[key] ? filterData[key] : {};
17
+ const queryKey = buildQueryKey(key, listComponentName);
18
+ filterValues[key] = getFilterValueFromQuery(queryKey, filterProps, data, query);
19
+ });
20
+
21
+ return filterValues;
22
+ };
23
+
24
+ export default getInitialFilterValues;
@@ -0,0 +1,18 @@
1
+ const getUpdatedFilterBy = (filterBy, filterByProperty, parentData) => {
2
+ if (!parentData || (filterBy && filterBy.length))
3
+ return { updatedFilterBy: filterBy, updatedFilterByProperty: filterByProperty };
4
+
5
+ const updatedFilterBy = [];
6
+ filterByProperty.forEach(property => {
7
+ const [key] = property.split('/');
8
+ const filterData = parentData[key];
9
+
10
+ if (!filterData) return;
11
+ if (Array.isArray(filterData)) filterData.forEach(dat => updatedFilterBy.push(`${key}/${dat}`));
12
+ else updatedFilterBy.push(`${key}/${filterData}`);
13
+ });
14
+
15
+ return { updatedFilterBy, updatedFilterByProperty: filterByProperty };
16
+ };
17
+
18
+ export default getUpdatedFilterBy;
@@ -12,12 +12,12 @@ import getSelectOptions from './get-select-options';
12
12
  import isDeviceDesktop from './is-device-desktop';
13
13
  import getFilterValues from './get-filter-values';
14
14
  import getFilterValueFromQuery from './get-filter-value-from-query';
15
- import buildUrlQuery from './build-url-query';
16
15
  import buildFiltersQuery from './build-filters-query';
17
16
  import getFilterRangesAndCheckboxesValues from './get-filter-ranges-and-checkboxes-values';
17
+ import getUpdatedFilterBy from './get-updated-filter-by';
18
+ import buildUrlQuery from './build-url-query';
18
19
 
19
20
  export {
20
- buildUrlQuery,
21
21
  buildNewUrl,
22
22
  buildRawQueryStringified,
23
23
  decodeValue,
@@ -34,5 +34,7 @@ export {
34
34
  getFilterValues,
35
35
  getFilterValueFromQuery,
36
36
  buildFiltersQuery,
37
- getFilterRangesAndCheckboxesValues
37
+ getFilterRangesAndCheckboxesValues,
38
+ getUpdatedFilterBy,
39
+ buildUrlQuery
38
40
  };
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  FaFacebookF,
3
- FaTwitter,
4
3
  FaPinterestP,
5
4
  FaInstagram,
6
5
  FaLinkedinIn,
7
6
  FaYoutube,
8
7
  FaTiktok
9
8
  } from 'react-icons/fa';
9
+ import { FaXTwitter } from 'react-icons/fa6';
10
10
 
11
11
  export const BASE_CLASS_NAME_FOLLOW = 'social__list-item social__list-item--follow';
12
12
  export const PORTRAIT = 'portrait';
@@ -22,7 +22,7 @@ export const SOCIAL_NETWORKS = {
22
22
  twitter: {
23
23
  name: 'Twitter',
24
24
  className: 'twitter',
25
- Icon: FaTwitter,
25
+ Icon: FaXTwitter,
26
26
  spanClassName: 'hidden'
27
27
  },
28
28
  pinterest: {
@@ -3,9 +3,10 @@ import buildSortValues from './build-sort-values';
3
3
 
4
4
  const getCorrectSort = (relations, filterProps, stringProps, useSortObject) => {
5
5
  const { sort, sortby, sortProperties = [] } = filterProps;
6
+ const [sortProperty = []] = sortProperties || [];
6
7
 
7
8
  return buildSortValues(
8
- [{ sort, propsToDisplay: sortby }, ...sortProperties],
9
+ [{ sort, propsToDisplay: sortby }, ...[sortProperty]],
9
10
  relations,
10
11
  stringProps,
11
12
  useSortObject
@@ -0,0 +1,28 @@
1
+ import getUpdatedFilterBy from '../../../../../../src/components/SearchFilter/helpers/get-updated-filter-by';
2
+
3
+ const mockedFilterByProperty = ['categoryId/product', 'subjectIds/product'];
4
+
5
+ const mockedParentData = {
6
+ id: 'abc123d',
7
+ categoryId: null,
8
+ subjectIds: ['subjectid123s']
9
+ };
10
+
11
+ describe('getUpdatedFilterBy helper', () => {
12
+ const mockedFilterBy = [1, 2, 3];
13
+ const noParentData = getUpdatedFilterBy(mockedFilterBy, [], {});
14
+ const withFilterBy = getUpdatedFilterBy(mockedFilterBy, [], { id: '123' });
15
+ const withUpdatedFilterBy = getUpdatedFilterBy([], mockedFilterByProperty, mockedParentData);
16
+
17
+ it('should return current filterBy and filterByProperty if no parentData or if filterBy values exist', () => {
18
+ expect(noParentData).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
19
+ expect(withFilterBy).toEqual({ updatedFilterBy: mockedFilterBy, updatedFilterByProperty: [] });
20
+ });
21
+
22
+ it('should return updated filterBy based on parent data matchess', () => {
23
+ expect(withUpdatedFilterBy).toEqual({
24
+ updatedFilterBy: ['subjectIds/subjectid123s'],
25
+ updatedFilterByProperty: mockedFilterByProperty
26
+ });
27
+ });
28
+ });
@@ -61,7 +61,7 @@ exports[`SocialFollow component should render without throwing an error and matc
61
61
  xmlns="http://www.w3.org/2000/svg"
62
62
  >
63
63
  <path
64
- d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"
64
+ d="M389.2 48h70.6L305.6 224.2 487 464H345L233.7 318.6 106.5 464H35.8L200.7 275.5 26.8 48H172.4L272.9 180.9 389.2 48zM364.4 421.8h39.1L151.1 88h-42L364.4 421.8z"
65
65
  />
66
66
  </svg>
67
67
  </i>