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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [0.133.0-alpha.2](https://github.com/thebyte9/blaze/compare/v0.133.0-alpha.1...v0.133.0-alpha.2) (2023-09-06)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * handle sort order when user sort not applied ([#4040](https://github.com/thebyte9/blaze/issues/4040)) ([7e674ef](https://github.com/thebyte9/blaze/commit/7e674ef7798d3032351dd4ef50c88d81f2130be4))
12
+
13
+
14
+
15
+
16
+
6
17
  # [0.133.0-alpha.1](https://github.com/thebyte9/blaze/compare/v0.133.0-alpha.0...v0.133.0-alpha.1) (2023-09-05)
7
18
 
8
19
 
@@ -19,16 +19,19 @@ var getSortProps = function getSortProps(_ref) {
19
19
  querySortBy = _ref.querySortBy,
20
20
  defaultSortBy = _ref.defaultSortBy,
21
21
  isTextSearchFilterApplied = _ref.isTextSearchFilterApplied;
22
- var sort = querySort || (sortProperties.length ? null : defaultSort);
23
- var sortby = null;
24
- if (querySortBy) sortby = [querySortBy];else if (!sortProperties.length) sortby = defaultSortBy;
25
22
  var updatedSortProperties = (0, _toConsumableArray2["default"])(sortProperties);
23
+ if (!querySort && !sortProperties.length) {
24
+ updatedSortProperties.unshift({
25
+ sort: defaultSort,
26
+ propsToDisplay: defaultSortBy
27
+ });
28
+ }
26
29
  if (isTextSearchFilterApplied) updatedSortProperties.unshift({
27
30
  isScore: true
28
31
  });
29
- if (sort) updatedSortProperties.unshift({
30
- sort: sort,
31
- propsToDisplay: sortby
32
+ if (querySort) updatedSortProperties.unshift({
33
+ sort: querySort,
34
+ propsToDisplay: [querySortBy]
32
35
  });
33
36
  var sortbyFilters = updatedSortProperties.map(function (_ref2) {
34
37
  var filterProps = _ref2.propsToDisplay;
@@ -1 +1 @@
1
- {"version":3,"file":"get-sort-props.js","names":["getSortProps","_ref","querySort","sortProperties","defaultSort","querySortBy","defaultSortBy","isTextSearchFilterApplied","sort","length","sortby","updatedSortProperties","_toConsumableArray2","unshift","isScore","propsToDisplay","sortbyFilters","map","_ref2","filterProps","filter","Boolean","flat","_default","exports"],"sources":["../../../../src/components/List/helpers/get-sort-props.js"],"sourcesContent":["const getSortProps = ({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy,\n isTextSearchFilterApplied\n}) => {\n const sort = querySort || (sortProperties.length ? null : defaultSort);\n let sortby = null;\n if (querySortBy) sortby = [querySortBy];\n else if (!sortProperties.length) sortby = defaultSortBy;\n\n const updatedSortProperties = [...sortProperties];\n if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });\n if (sort) updatedSortProperties.unshift({ sort, propsToDisplay: sortby });\n\n const sortbyFilters = updatedSortProperties\n .map(({ propsToDisplay: filterProps }) => filterProps)\n .filter(Boolean)\n .flat();\n return { sortbyFilters, updatedSortProperties };\n};\n\nexport default getSortProps;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAOZ;EAAA,IANJC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,cAAc,GAAAF,IAAA,CAAdE,cAAc;IACdC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IACXC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,yBAAyB,GAAAN,IAAA,CAAzBM,yBAAyB;EAEzB,IAAMC,IAAI,GAAGN,SAAS,KAAKC,cAAc,CAACM,MAAM,GAAG,IAAI,GAAGL,WAAW,CAAC;EACtE,IAAIM,MAAM,GAAG,IAAI;EACjB,IAAIL,WAAW,EAAEK,MAAM,GAAG,CAACL,WAAW,CAAC,CAAC,KACnC,IAAI,CAACF,cAAc,CAACM,MAAM,EAAEC,MAAM,GAAGJ,aAAa;EAEvD,IAAMK,qBAAqB,OAAAC,mBAAA,aAAOT,cAAc,CAAC;EACjD,IAAII,yBAAyB,EAAEI,qBAAqB,CAACE,OAAO,CAAC;IAAEC,OAAO,EAAE;EAAK,CAAC,CAAC;EAC/E,IAAIN,IAAI,EAAEG,qBAAqB,CAACE,OAAO,CAAC;IAAEL,IAAI,EAAJA,IAAI;IAAEO,cAAc,EAAEL;EAAO,CAAC,CAAC;EAEzE,IAAMM,aAAa,GAAGL,qBAAqB,CACxCM,GAAG,CAAC,UAAAC,KAAA;IAAA,IAAmBC,WAAW,GAAAD,KAAA,CAA3BH,cAAc;IAAA,OAAoBI,WAAW;EAAA,EAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,CAAC;EACT,OAAO;IAAEN,aAAa,EAAbA,aAAa;IAAEL,qBAAqB,EAArBA;EAAsB,CAAC;AACjD,CAAC;AAAC,IAAAY,QAAA,GAEavB,YAAY;AAAAwB,OAAA,cAAAD,QAAA"}
1
+ {"version":3,"file":"get-sort-props.js","names":["getSortProps","_ref","querySort","sortProperties","defaultSort","querySortBy","defaultSortBy","isTextSearchFilterApplied","updatedSortProperties","_toConsumableArray2","length","unshift","sort","propsToDisplay","isScore","sortbyFilters","map","_ref2","filterProps","filter","Boolean","flat","_default","exports"],"sources":["../../../../src/components/List/helpers/get-sort-props.js"],"sourcesContent":["const getSortProps = ({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy,\n isTextSearchFilterApplied\n}) => {\n const updatedSortProperties = [...sortProperties];\n if (!querySort && !sortProperties.length) {\n updatedSortProperties.unshift({ sort: defaultSort, propsToDisplay: defaultSortBy });\n }\n if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });\n if (querySort) updatedSortProperties.unshift({ sort: querySort, propsToDisplay: [querySortBy] });\n\n const sortbyFilters = updatedSortProperties\n .map(({ propsToDisplay: filterProps }) => filterProps)\n .filter(Boolean)\n .flat();\n return { sortbyFilters, updatedSortProperties };\n};\n\nexport default getSortProps;\n"],"mappings":";;;;;;;;;;;;;;AAAA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAOZ;EAAA,IANJC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,cAAc,GAAAF,IAAA,CAAdE,cAAc;IACdC,WAAW,GAAAH,IAAA,CAAXG,WAAW;IACXC,WAAW,GAAAJ,IAAA,CAAXI,WAAW;IACXC,aAAa,GAAAL,IAAA,CAAbK,aAAa;IACbC,yBAAyB,GAAAN,IAAA,CAAzBM,yBAAyB;EAEzB,IAAMC,qBAAqB,OAAAC,mBAAA,aAAON,cAAc,CAAC;EACjD,IAAI,CAACD,SAAS,IAAI,CAACC,cAAc,CAACO,MAAM,EAAE;IACxCF,qBAAqB,CAACG,OAAO,CAAC;MAAEC,IAAI,EAAER,WAAW;MAAES,cAAc,EAAEP;IAAc,CAAC,CAAC;EACrF;EACA,IAAIC,yBAAyB,EAAEC,qBAAqB,CAACG,OAAO,CAAC;IAAEG,OAAO,EAAE;EAAK,CAAC,CAAC;EAC/E,IAAIZ,SAAS,EAAEM,qBAAqB,CAACG,OAAO,CAAC;IAAEC,IAAI,EAAEV,SAAS;IAAEW,cAAc,EAAE,CAACR,WAAW;EAAE,CAAC,CAAC;EAEhG,IAAMU,aAAa,GAAGP,qBAAqB,CACxCQ,GAAG,CAAC,UAAAC,KAAA;IAAA,IAAmBC,WAAW,GAAAD,KAAA,CAA3BJ,cAAc;IAAA,OAAoBK,WAAW;EAAA,EAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,CAAC;EACT,OAAO;IAAEN,aAAa,EAAbA,aAAa;IAAEP,qBAAqB,EAArBA;EAAsB,CAAC;AACjD,CAAC;AAAC,IAAAc,QAAA,GAEatB,YAAY;AAAAuB,OAAA,cAAAD,QAAA"}
@@ -6,16 +6,19 @@ const getSortProps = ({
6
6
  defaultSortBy,
7
7
  isTextSearchFilterApplied
8
8
  }) => {
9
- const sort = querySort || (sortProperties.length ? null : defaultSort);
10
- let sortby = null;
11
- if (querySortBy) sortby = [querySortBy];else if (!sortProperties.length) sortby = defaultSortBy;
12
9
  const updatedSortProperties = [...sortProperties];
10
+ if (!querySort && !sortProperties.length) {
11
+ updatedSortProperties.unshift({
12
+ sort: defaultSort,
13
+ propsToDisplay: defaultSortBy
14
+ });
15
+ }
13
16
  if (isTextSearchFilterApplied) updatedSortProperties.unshift({
14
17
  isScore: true
15
18
  });
16
- if (sort) updatedSortProperties.unshift({
17
- sort,
18
- propsToDisplay: sortby
19
+ if (querySort) updatedSortProperties.unshift({
20
+ sort: querySort,
21
+ propsToDisplay: [querySortBy]
19
22
  });
20
23
  const sortbyFilters = updatedSortProperties.map(({
21
24
  propsToDisplay: filterProps
@@ -1 +1 @@
1
- {"version":3,"file":"get-sort-props.js","names":["getSortProps","querySort","sortProperties","defaultSort","querySortBy","defaultSortBy","isTextSearchFilterApplied","sort","length","sortby","updatedSortProperties","unshift","isScore","propsToDisplay","sortbyFilters","map","filterProps","filter","Boolean","flat"],"sources":["../../../../src/components/List/helpers/get-sort-props.js"],"sourcesContent":["const getSortProps = ({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy,\n isTextSearchFilterApplied\n}) => {\n const sort = querySort || (sortProperties.length ? null : defaultSort);\n let sortby = null;\n if (querySortBy) sortby = [querySortBy];\n else if (!sortProperties.length) sortby = defaultSortBy;\n\n const updatedSortProperties = [...sortProperties];\n if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });\n if (sort) updatedSortProperties.unshift({ sort, propsToDisplay: sortby });\n\n const sortbyFilters = updatedSortProperties\n .map(({ propsToDisplay: filterProps }) => filterProps)\n .filter(Boolean)\n .flat();\n return { sortbyFilters, updatedSortProperties };\n};\n\nexport default getSortProps;\n"],"mappings":"AAAA,MAAMA,YAAY,GAAGA,CAAC;EACpBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC,WAAW;EACXC,aAAa;EACbC;AACF,CAAC,KAAK;EACJ,MAAMC,IAAI,GAAGN,SAAS,KAAKC,cAAc,CAACM,MAAM,GAAG,IAAI,GAAGL,WAAW,CAAC;EACtE,IAAIM,MAAM,GAAG,IAAI;EACjB,IAAIL,WAAW,EAAEK,MAAM,GAAG,CAACL,WAAW,CAAC,CAAC,KACnC,IAAI,CAACF,cAAc,CAACM,MAAM,EAAEC,MAAM,GAAGJ,aAAa;EAEvD,MAAMK,qBAAqB,GAAG,CAAC,GAAGR,cAAc,CAAC;EACjD,IAAII,yBAAyB,EAAEI,qBAAqB,CAACC,OAAO,CAAC;IAAEC,OAAO,EAAE;EAAK,CAAC,CAAC;EAC/E,IAAIL,IAAI,EAAEG,qBAAqB,CAACC,OAAO,CAAC;IAAEJ,IAAI;IAAEM,cAAc,EAAEJ;EAAO,CAAC,CAAC;EAEzE,MAAMK,aAAa,GAAGJ,qBAAqB,CACxCK,GAAG,CAAC,CAAC;IAAEF,cAAc,EAAEG;EAAY,CAAC,KAAKA,WAAW,CAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,CAAC;EACT,OAAO;IAAEL,aAAa;IAAEJ;EAAsB,CAAC;AACjD,CAAC;AAED,eAAeV,YAAY"}
1
+ {"version":3,"file":"get-sort-props.js","names":["getSortProps","querySort","sortProperties","defaultSort","querySortBy","defaultSortBy","isTextSearchFilterApplied","updatedSortProperties","length","unshift","sort","propsToDisplay","isScore","sortbyFilters","map","filterProps","filter","Boolean","flat"],"sources":["../../../../src/components/List/helpers/get-sort-props.js"],"sourcesContent":["const getSortProps = ({\n querySort,\n sortProperties,\n defaultSort,\n querySortBy,\n defaultSortBy,\n isTextSearchFilterApplied\n}) => {\n const updatedSortProperties = [...sortProperties];\n if (!querySort && !sortProperties.length) {\n updatedSortProperties.unshift({ sort: defaultSort, propsToDisplay: defaultSortBy });\n }\n if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });\n if (querySort) updatedSortProperties.unshift({ sort: querySort, propsToDisplay: [querySortBy] });\n\n const sortbyFilters = updatedSortProperties\n .map(({ propsToDisplay: filterProps }) => filterProps)\n .filter(Boolean)\n .flat();\n return { sortbyFilters, updatedSortProperties };\n};\n\nexport default getSortProps;\n"],"mappings":"AAAA,MAAMA,YAAY,GAAGA,CAAC;EACpBC,SAAS;EACTC,cAAc;EACdC,WAAW;EACXC,WAAW;EACXC,aAAa;EACbC;AACF,CAAC,KAAK;EACJ,MAAMC,qBAAqB,GAAG,CAAC,GAAGL,cAAc,CAAC;EACjD,IAAI,CAACD,SAAS,IAAI,CAACC,cAAc,CAACM,MAAM,EAAE;IACxCD,qBAAqB,CAACE,OAAO,CAAC;MAAEC,IAAI,EAAEP,WAAW;MAAEQ,cAAc,EAAEN;IAAc,CAAC,CAAC;EACrF;EACA,IAAIC,yBAAyB,EAAEC,qBAAqB,CAACE,OAAO,CAAC;IAAEG,OAAO,EAAE;EAAK,CAAC,CAAC;EAC/E,IAAIX,SAAS,EAAEM,qBAAqB,CAACE,OAAO,CAAC;IAAEC,IAAI,EAAET,SAAS;IAAEU,cAAc,EAAE,CAACP,WAAW;EAAE,CAAC,CAAC;EAEhG,MAAMS,aAAa,GAAGN,qBAAqB,CACxCO,GAAG,CAAC,CAAC;IAAEH,cAAc,EAAEI;EAAY,CAAC,KAAKA,WAAW,CAAC,CACrDC,MAAM,CAACC,OAAO,CAAC,CACfC,IAAI,CAAC,CAAC;EACT,OAAO;IAAEL,aAAa;IAAEN;EAAsB,CAAC;AACjD,CAAC;AAED,eAAeP,YAAY"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/react-page-builder",
3
- "version": "0.133.0-alpha.1",
3
+ "version": "0.133.0-alpha.2",
4
4
  "description": "Blaze react page builder",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -89,5 +89,5 @@
89
89
  "lib/*",
90
90
  "lib-es/*"
91
91
  ],
92
- "gitHead": "7f1bd742f23bd8cd5a22930c7e8574bc4a772867"
92
+ "gitHead": "39cd6858ba7996fe86b54eedba2c958952e63e40"
93
93
  }
@@ -6,14 +6,12 @@ const getSortProps = ({
6
6
  defaultSortBy,
7
7
  isTextSearchFilterApplied
8
8
  }) => {
9
- const sort = querySort || (sortProperties.length ? null : defaultSort);
10
- let sortby = null;
11
- if (querySortBy) sortby = [querySortBy];
12
- else if (!sortProperties.length) sortby = defaultSortBy;
13
-
14
9
  const updatedSortProperties = [...sortProperties];
10
+ if (!querySort && !sortProperties.length) {
11
+ updatedSortProperties.unshift({ sort: defaultSort, propsToDisplay: defaultSortBy });
12
+ }
15
13
  if (isTextSearchFilterApplied) updatedSortProperties.unshift({ isScore: true });
16
- if (sort) updatedSortProperties.unshift({ sort, propsToDisplay: sortby });
14
+ if (querySort) updatedSortProperties.unshift({ sort: querySort, propsToDisplay: [querySortBy] });
17
15
 
18
16
  const sortbyFilters = updatedSortProperties
19
17
  .map(({ propsToDisplay: filterProps }) => filterProps)
@@ -60,6 +60,29 @@ describe('getSortProps helper function', () => {
60
60
  ]);
61
61
  });
62
62
 
63
+ it('should add score sort as first value if has textSearch but no sort applied', () => {
64
+ const { updatedSortProperties } = getSortProps({
65
+ ...props,
66
+ isTextSearchFilterApplied: true
67
+ });
68
+ expect(updatedSortProperties).toEqual([{ isScore: true }, ...sortProperties]);
69
+ });
70
+
71
+ it('should add default sort and score sort as first value if has textSearch and no other sort', () => {
72
+ const { updatedSortProperties } = getSortProps({
73
+ ...props,
74
+ sortProperties: [],
75
+ isTextSearchFilterApplied: true
76
+ });
77
+ expect(updatedSortProperties).toEqual([
78
+ { isScore: true },
79
+ {
80
+ propsToDisplay: props.defaultSortBy,
81
+ sort: props.defaultSort
82
+ }
83
+ ]);
84
+ });
85
+
63
86
  it('should use old style sort', () => {
64
87
  const { sortbyFilters, updatedSortProperties } = getSortProps({
65
88
  ...props,