@plone/volto 18.0.0-alpha.21 → 18.0.0-alpha.22

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
@@ -17,6 +17,17 @@ myst:
17
17
 
18
18
  <!-- towncrier release notes start -->
19
19
 
20
+ ## 18.0.0-alpha.22 (2024-03-19)
21
+
22
+ ### Bugfix
23
+
24
+ - Correctly sort facet values if they are numbers @erral [#5864](https://github.com/plone/volto/issues/5864)
25
+ - Cross-package manager Volto path resolver in `webpack-relative-resolver` @sneridagh [#5893](https://github.com/plone/volto/issues/5893)
26
+
27
+ ### Documentation
28
+
29
+ - `Volto 18.0.0-alpha.21` and `volto-update-deps` documentation @sneridagh [#5892](https://github.com/plone/volto/issues/5892)
30
+
20
31
  ## 18.0.0-alpha.21 (2024-03-18)
21
32
 
22
33
  ### Breaking
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "license": "MIT",
12
- "version": "18.0.0-alpha.21",
12
+ "version": "18.0.0-alpha.22",
13
13
  "repository": {
14
14
  "type": "git",
15
15
  "url": "git@github.com:plone/volto.git"
@@ -57,6 +57,7 @@
57
57
  "@plone/volto-slate/(.*)$": "<rootDir>/../volto-slate/src/$1",
58
58
  "@plone/registry": "<rootDir>/../registry/src",
59
59
  "@plone/registry/(.*)$": "<rootDir>/../registry/src/$1",
60
+ "@plone/volto": "<rootDir>/src/index.js",
60
61
  "~/config": "<rootDir>/src/config",
61
62
  "~/../locales/${lang}.json": "<rootDir>/locales/en.json",
62
63
  "(.*)/locales/(.*)": "<rootDir>/locales/$2",
@@ -235,9 +236,9 @@
235
236
  "url": "^0.11.3",
236
237
  "use-deep-compare-effect": "1.8.1",
237
238
  "uuid": "^8.3.2",
238
- "@plone/registry": "1.5.2",
239
- "@plone/volto-slate": "18.0.0-alpha.10",
240
- "@plone/scripts": "3.6.0"
239
+ "@plone/registry": "1.5.3",
240
+ "@plone/scripts": "3.6.1",
241
+ "@plone/volto-slate": "18.0.0-alpha.10"
241
242
  },
242
243
  "devDependencies": {
243
244
  "@babel/core": "^7.0.0",
@@ -340,7 +341,7 @@
340
341
  "tmp": "0.2.1",
341
342
  "ts-jest": "^26.4.2",
342
343
  "ts-loader": "9.4.4",
343
- "typescript": "5.2.2",
344
+ "typescript": "^5.4.2",
344
345
  "use-trace-update": "1.3.2",
345
346
  "wait-on": "6.0.0",
346
347
  "webpack": "5.76.1",
@@ -22,6 +22,18 @@ const defaultShowFacet = (index) => {
22
22
  : values && Object.keys(values).length > 0;
23
23
  };
24
24
 
25
+ export const sortFacetChoices = (choices) => {
26
+ const sorted_choices = choices.sort((a, b) =>
27
+ typeof a.label === 'string' && typeof b.label === 'string'
28
+ ? a.label.localeCompare(b.label, 'en', { sensitivity: 'base' })
29
+ : typeof a.label === 'number' && typeof b.label == 'number'
30
+ ? a.label - b.label
31
+ : 0,
32
+ );
33
+
34
+ return sorted_choices;
35
+ };
36
+
25
37
  const Facets = (props) => {
26
38
  const [hidden, setHidden] = useState(true);
27
39
  const {
@@ -81,9 +93,7 @@ const Facets = (props) => {
81
93
  : true,
82
94
  );
83
95
 
84
- choices = choices.sort((a, b) =>
85
- a.label.localeCompare(b.label, 'en', { sensitivity: 'base' }),
86
- );
96
+ choices = sortFacetChoices(choices);
87
97
 
88
98
  const isMulti = facetSettings.multiple;
89
99
  const selectedValue = facets[facetSettings?.field?.value];
@@ -0,0 +1,76 @@
1
+ import { sortFacetChoices } from './Facets';
2
+
3
+ describe('sortFacetChoices', () => {
4
+ it('sort choices with string labels', () => {
5
+ const choices = [
6
+ { label: 'b' },
7
+ { label: 'd' },
8
+ { label: 'a' },
9
+ { label: 'c' },
10
+ ];
11
+ const sortedChoices = sortFacetChoices(choices);
12
+ expect(sortedChoices).toStrictEqual([
13
+ { label: 'a' },
14
+ { label: 'b' },
15
+ { label: 'c' },
16
+ { label: 'd' },
17
+ ]);
18
+ });
19
+ it('sort choices with string labels with accents (1)', () => {
20
+ const choices = [
21
+ { label: 'éventa' },
22
+ { label: 'portal' },
23
+ { label: 'newsitem' },
24
+ { label: 'eventb' },
25
+ ];
26
+ const sortedChoices = sortFacetChoices(choices);
27
+ expect(sortedChoices).toStrictEqual([
28
+ { label: 'éventa' },
29
+ { label: 'eventb' },
30
+ { label: 'newsitem' },
31
+ { label: 'portal' },
32
+ ]);
33
+ });
34
+
35
+ it('sort choices with string labels with accents (2)', () => {
36
+ const choices = [
37
+ { label: 'eventa' },
38
+ { label: 'portal' },
39
+ { label: 'newsitem' },
40
+ { label: 'éventb' },
41
+ ];
42
+ const sortedChoices = sortFacetChoices(choices);
43
+ expect(sortedChoices).toStrictEqual([
44
+ { label: 'eventa' },
45
+ { label: 'éventb' },
46
+ { label: 'newsitem' },
47
+ { label: 'portal' },
48
+ ]);
49
+ });
50
+
51
+ it('sort choices with int labels', () => {
52
+ const choices = [{ label: 7 }, { label: 3 }, { label: 1 }, { label: 4 }];
53
+ const sortedChoices = sortFacetChoices(choices);
54
+ expect(sortedChoices).toStrictEqual([
55
+ { label: 1 },
56
+ { label: 3 },
57
+ { label: 4 },
58
+ { label: 7 },
59
+ ]);
60
+ });
61
+ it('sort choices with labels of any kind', () => {
62
+ const choices = [
63
+ { label: 7 },
64
+ { label: '1' },
65
+ { label: 'b' },
66
+ { label: 5 },
67
+ ];
68
+ const sortedChoices = sortFacetChoices(choices);
69
+ expect(sortedChoices).toStrictEqual([
70
+ { label: 7 },
71
+ { label: '1' },
72
+ { label: 'b' },
73
+ { label: 5 },
74
+ ]);
75
+ });
76
+ });
@@ -1,2 +1,3 @@
1
+ export function sortFacetChoices(choices: any): any;
1
2
  export default Facets;
2
3
  declare function Facets(props: any): import("react/jsx-runtime").JSX.Element;
@@ -5,8 +5,11 @@ class RelativeResolverPlugin {
5
5
  this.source = source || 'resolve';
6
6
  this.target = target || 'resolve';
7
7
  this.registry = registry;
8
+ this.voltoModulePath = registry.isVoltoProject
9
+ ? require.resolve('@plone/volto').split('/').slice(0, -1).join('/')
10
+ : `${registry.voltoPath}/src`;
8
11
  this.voltoPaths = Object.assign(
9
- { '@plone/volto/': `${registry.voltoPath}/src` },
12
+ { '@plone/volto/': this.voltoModulePath },
10
13
  ...Object.keys(registry.packages).map((k) => ({
11
14
  [k]: registry.packages[k].modulePath,
12
15
  })),