@eeacms/volto-eea-design-system 1.39.0 → 1.40.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.
- package/CHANGELOG.md +16 -0
- package/README.md +4 -1
- package/jest-addon.config.js +436 -6
- package/package.json +3 -2
- package/src/ui/Footer/Footer.stories.js +4 -0
- package/src/ui/Footer/SubFooter.jsx +3 -0
- package/src/ui/Header/Header.jsx +15 -4
- package/src/ui/Header/Header.test.jsx +362 -2
- package/src/ui/Header/HeaderMenuPopUp.js +10 -8
- package/src/ui/Header/HeaderMenuPopUp.test.js +581 -0
- package/src/ui/Header/HeaderSearchPopUp.test.js +118 -0
- package/src/ui/Header/utils.js +79 -0
- package/src/ui/Header/utils.test.js +225 -0
- package/src/ui/Logo/Logo.jsx +14 -2
- package/src/ui/Logo/Logo.stories.js +2 -0
- package/src/ui/Tag/Tag.jsx +1 -1
- package/src/ui/Tag/Tag.stories.jsx +15 -3
- package/src/ui/TagList/TagList.stories.jsx +24 -12
- package/theme/themes/eea/collections/breadcrumb.overrides +6 -5
- package/theme/themes/eea/extras/contextNavigation.less +2 -2
- package/theme/themes/eea/extras/contextNavigation.variables +3 -2
- package/theme/themes/eea/extras/footer.less +4 -0
- package/theme/themes/eea/extras/header.less +9 -0
- package/theme/themes/eea/extras/header.variables +5 -0
- package/theme/themes/eea/globals/site.overrides +99 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
+
### [1.40.0](https://github.com/eea/volto-eea-design-system/compare/1.39.1...1.40.0) - 4 November 2025
|
|
8
|
+
|
|
9
|
+
#### :rocket: New Features
|
|
10
|
+
|
|
11
|
+
- feat(print): improve PDF printing - refs #291995 [David Ichim - [`ea10d80`](https://github.com/eea/volto-eea-design-system/commit/ea10d806beacac455d922e335336fffd57688b78)]
|
|
12
|
+
|
|
13
|
+
#### :hammer_and_wrench: Others
|
|
14
|
+
|
|
15
|
+
- Bump version to 1.40.0 [David Ichim - [`281bd44`](https://github.com/eea/volto-eea-design-system/commit/281bd44e8d022c286f0cb9b1dc38564f88a006bc)]
|
|
16
|
+
### [1.39.1](https://github.com/eea/volto-eea-design-system/compare/1.39.0...1.39.1) - 22 September 2025
|
|
17
|
+
|
|
18
|
+
#### :boom: Breaking Change
|
|
19
|
+
|
|
20
|
+
- breaking(figma): removed mockups folder, moved to figma_mockups branch [David Ichim - [`1d37f0a`](https://github.com/eea/volto-eea-design-system/commit/1d37f0a5a22048243030811a7feef51413f4303a)]
|
|
21
|
+
- breaking(docs): update mockup references and add details in README files [David Ichim - [`6c58a46`](https://github.com/eea/volto-eea-design-system/commit/6c58a468006a1580589f4e2c5e66a8f0ff17cd0d)]
|
|
22
|
+
|
|
7
23
|
### [1.39.0](https://github.com/eea/volto-eea-design-system/compare/1.38.3...1.39.0) - 20 August 2025
|
|
8
24
|
|
|
9
25
|
#### :rocket: New Features
|
package/README.md
CHANGED
|
@@ -31,7 +31,10 @@ Checkout the docs found within the [website](https://github.com/eea/volto-eea-de
|
|
|
31
31
|
|
|
32
32
|
### Try the design system mockups
|
|
33
33
|
|
|
34
|
-
Checkout the docs found within the [mockups](https://github.com/eea/volto-eea-design-system/blob/
|
|
34
|
+
Checkout the docs found within the [mockups](https://github.com/eea/volto-eea-design-system/blob/figma_mockups/mockups/README.md) folder from the `figma_mockups` branch.
|
|
35
|
+
|
|
36
|
+
> [!NOTE]
|
|
37
|
+
We moved the mockups to a separate branch to avoid bloating the main branch with large files.
|
|
35
38
|
|
|
36
39
|
## Docusaurus and Storybook
|
|
37
40
|
|
package/jest-addon.config.js
CHANGED
|
@@ -1,26 +1,441 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic Jest configuration for Volto addons
|
|
3
|
+
*
|
|
4
|
+
* This configuration automatically:
|
|
5
|
+
* - Detects the addon name from the config file path
|
|
6
|
+
* - Configures test coverage to focus on the specific test path
|
|
7
|
+
* - Handles different ways of specifying test paths:
|
|
8
|
+
* - Full paths like src/addons/addon-name/src/components
|
|
9
|
+
* - Just filenames like Component.test.jsx
|
|
10
|
+
* - Just directory names like components
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* RAZZLE_JEST_CONFIG=src/addons/addon-name/jest-addon.config.js CI=true yarn test [test-path] --collectCoverage
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
require('dotenv').config({ path: __dirname + '/.env' });
|
|
17
|
+
|
|
18
|
+
const path = require('path');
|
|
19
|
+
const fs = require('fs');
|
|
20
|
+
const fg = require('fast-glob');
|
|
21
|
+
|
|
22
|
+
// Get the addon name from the current file path
|
|
23
|
+
const pathParts = __filename.split(path.sep);
|
|
24
|
+
const addonsIdx = pathParts.lastIndexOf('addons');
|
|
25
|
+
const addonName =
|
|
26
|
+
addonsIdx !== -1 && addonsIdx < pathParts.length - 1
|
|
27
|
+
? pathParts[addonsIdx + 1]
|
|
28
|
+
: path.basename(path.dirname(__filename)); // Fallback to folder name
|
|
29
|
+
const addonBasePath = `src/addons/${addonName}/src`;
|
|
30
|
+
|
|
31
|
+
// --- Performance caches ---
|
|
32
|
+
const fileSearchCache = new Map();
|
|
33
|
+
const dirSearchCache = new Map();
|
|
34
|
+
const dirListingCache = new Map();
|
|
35
|
+
const statCache = new Map();
|
|
36
|
+
const implementationCache = new Map();
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Cached fs.statSync wrapper to avoid redundant filesystem calls
|
|
40
|
+
* @param {string} p
|
|
41
|
+
* @returns {fs.Stats|null}
|
|
42
|
+
*/
|
|
43
|
+
const getStatSync = (p) => {
|
|
44
|
+
if (statCache.has(p)) return statCache.get(p);
|
|
45
|
+
try {
|
|
46
|
+
const s = fs.statSync(p);
|
|
47
|
+
statCache.set(p, s);
|
|
48
|
+
return s;
|
|
49
|
+
} catch {
|
|
50
|
+
statCache.set(p, null);
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Find files that match a specific pattern using fast-glob
|
|
57
|
+
* @param {string} baseDir - The base directory to search in
|
|
58
|
+
* @param {string} fileName - The name of the file to find
|
|
59
|
+
* @param {string} [pathPattern=''] - Optional path pattern to filter results
|
|
60
|
+
* @returns {string[]} - Array of matching file paths
|
|
61
|
+
*/
|
|
62
|
+
const findFilesWithPattern = (baseDir, fileName, pathPattern = '') => {
|
|
63
|
+
const cacheKey = `${baseDir}|${fileName}|${pathPattern}`;
|
|
64
|
+
if (fileSearchCache.has(cacheKey)) {
|
|
65
|
+
return fileSearchCache.get(cacheKey);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
let files = [];
|
|
69
|
+
try {
|
|
70
|
+
const patterns = fileName
|
|
71
|
+
? [`${baseDir}/**/${fileName}`]
|
|
72
|
+
: [`${baseDir}/**/*.{js,jsx,ts,tsx}`];
|
|
73
|
+
|
|
74
|
+
files = fg.sync(patterns, { onlyFiles: true });
|
|
75
|
+
|
|
76
|
+
if (pathPattern) {
|
|
77
|
+
files = files.filter((file) => file.includes(pathPattern));
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
files = [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
fileSearchCache.set(cacheKey, files);
|
|
84
|
+
return files;
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Find directories that match a specific pattern using fast-glob
|
|
89
|
+
* @param {string} baseDir - The base directory to search in
|
|
90
|
+
* @param {string} dirName - The name of the directory to find
|
|
91
|
+
* @param {string} [pathPattern=''] - Optional path pattern to filter results
|
|
92
|
+
* @returns {string[]} - Array of matching directory paths
|
|
93
|
+
*/
|
|
94
|
+
const findDirsWithPattern = (baseDir, dirName, pathPattern = '') => {
|
|
95
|
+
const cacheKey = `${baseDir}|${dirName}|${pathPattern}`;
|
|
96
|
+
if (dirSearchCache.has(cacheKey)) {
|
|
97
|
+
return dirSearchCache.get(cacheKey);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
let dirs = [];
|
|
101
|
+
try {
|
|
102
|
+
const patterns = dirName
|
|
103
|
+
? [`${baseDir}/**/${dirName}`]
|
|
104
|
+
: [`${baseDir}/**/`];
|
|
105
|
+
|
|
106
|
+
dirs = fg.sync(patterns, { onlyDirectories: true });
|
|
107
|
+
|
|
108
|
+
if (pathPattern) {
|
|
109
|
+
dirs = dirs.filter((dir) => dir.includes(pathPattern));
|
|
110
|
+
}
|
|
111
|
+
} catch {
|
|
112
|
+
dirs = [];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
dirSearchCache.set(cacheKey, dirs);
|
|
116
|
+
return dirs;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Find files or directories in the addon using fast-glob
|
|
121
|
+
* @param {string} name - The name to search for
|
|
122
|
+
* @param {string} type - The type of item to find ('f' for files, 'd' for directories)
|
|
123
|
+
* @param {string} [additionalOptions=''] - Additional options for flexible path matching
|
|
124
|
+
* @returns {string|null} - The path of the found item or null if not found
|
|
125
|
+
*/
|
|
126
|
+
const findInAddon = (name, type, additionalOptions = '') => {
|
|
127
|
+
const isFile = type === 'f';
|
|
128
|
+
const isDirectory = type === 'd';
|
|
129
|
+
const isFlexiblePathMatch = additionalOptions.includes('-path');
|
|
130
|
+
|
|
131
|
+
let pathPattern = '';
|
|
132
|
+
if (isFlexiblePathMatch) {
|
|
133
|
+
const match = additionalOptions.match(/-path "([^"]+)"/);
|
|
134
|
+
if (match && match[1]) {
|
|
135
|
+
pathPattern = match[1].replace(/\*/g, '');
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
let results = [];
|
|
141
|
+
if (isFile) {
|
|
142
|
+
results = findFilesWithPattern(addonBasePath, name, pathPattern);
|
|
143
|
+
} else if (isDirectory) {
|
|
144
|
+
results = findDirsWithPattern(addonBasePath, name, pathPattern);
|
|
145
|
+
}
|
|
146
|
+
return results.length > 0 ? results[0] : null;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Find the implementation file for a test file
|
|
154
|
+
* @param {string} testPath - Path to the test file
|
|
155
|
+
* @returns {string|null} - Path to the implementation file or null if not found
|
|
156
|
+
*/
|
|
157
|
+
const findImplementationFile = (testPath) => {
|
|
158
|
+
if (implementationCache.has(testPath)) {
|
|
159
|
+
return implementationCache.get(testPath);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (!fs.existsSync(testPath)) {
|
|
163
|
+
implementationCache.set(testPath, null);
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const dirPath = path.dirname(testPath);
|
|
168
|
+
const fileName = path.basename(testPath);
|
|
169
|
+
|
|
170
|
+
// Regex for common test file patterns (e.g., .test.js, .spec.ts)
|
|
171
|
+
const TEST_OR_SPEC_FILE_REGEX = /\.(test|spec)\.[jt]sx?$/;
|
|
172
|
+
|
|
173
|
+
if (!TEST_OR_SPEC_FILE_REGEX.test(fileName)) {
|
|
174
|
+
implementationCache.set(testPath, null);
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const baseFileName = path
|
|
179
|
+
.basename(fileName, path.extname(fileName))
|
|
180
|
+
.replace(/\.(test|spec)$/, ''); // Remove .test or .spec
|
|
181
|
+
|
|
182
|
+
let dirFiles = dirListingCache.get(dirPath);
|
|
183
|
+
if (!dirFiles) {
|
|
184
|
+
dirFiles = fs.readdirSync(dirPath);
|
|
185
|
+
dirListingCache.set(dirPath, dirFiles);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const exactMatch = dirFiles.find((file) => {
|
|
189
|
+
const fileBaseName = path.basename(file, path.extname(file));
|
|
190
|
+
return (
|
|
191
|
+
fileBaseName === baseFileName && !TEST_OR_SPEC_FILE_REGEX.test(file) // Ensure it's not another test/spec file
|
|
192
|
+
);
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
if (exactMatch) {
|
|
196
|
+
const result = `${dirPath}/${exactMatch}`;
|
|
197
|
+
implementationCache.set(testPath, result);
|
|
198
|
+
return result;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const similarMatch = dirFiles.find((file) => {
|
|
202
|
+
if (
|
|
203
|
+
TEST_OR_SPEC_FILE_REGEX.test(file) ||
|
|
204
|
+
(getStatSync(`${dirPath}/${file}`)?.isDirectory() ?? false)
|
|
205
|
+
) {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const fileBaseName = path.basename(file, path.extname(file));
|
|
209
|
+
return (
|
|
210
|
+
fileBaseName.toLowerCase().includes(baseFileName.toLowerCase()) ||
|
|
211
|
+
baseFileName.toLowerCase().includes(fileBaseName.toLowerCase())
|
|
212
|
+
);
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
if (similarMatch) {
|
|
216
|
+
const result = `${dirPath}/${similarMatch}`;
|
|
217
|
+
implementationCache.set(testPath, result);
|
|
218
|
+
return result;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
implementationCache.set(testPath, null);
|
|
222
|
+
return null;
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Get the test path from command line arguments
|
|
227
|
+
* @returns {string|null} - The resolved test path or null if not found
|
|
228
|
+
*/
|
|
229
|
+
const getTestPath = () => {
|
|
230
|
+
const args = process.argv;
|
|
231
|
+
let testPath = null;
|
|
232
|
+
const TEST_FILE_REGEX = /\.test\.[jt]sx?$/; // Matches .test.js, .test.jsx, .test.ts, .test.tsx
|
|
233
|
+
|
|
234
|
+
testPath = args.find(
|
|
235
|
+
(arg) =>
|
|
236
|
+
arg.includes(addonName) &&
|
|
237
|
+
!arg.startsWith('--') &&
|
|
238
|
+
arg !== 'test' &&
|
|
239
|
+
arg !== 'node',
|
|
240
|
+
);
|
|
241
|
+
|
|
242
|
+
if (!testPath) {
|
|
243
|
+
const testIndex = args.findIndex((arg) => arg === 'test');
|
|
244
|
+
if (testIndex !== -1 && testIndex < args.length - 1) {
|
|
245
|
+
const nextArg = args[testIndex + 1];
|
|
246
|
+
if (!nextArg.startsWith('--')) {
|
|
247
|
+
testPath = nextArg;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (!testPath) {
|
|
253
|
+
testPath = args.find((arg) => TEST_FILE_REGEX.test(arg));
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (!testPath) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
if (!testPath.includes(path.sep)) {
|
|
261
|
+
if (TEST_FILE_REGEX.test(testPath)) {
|
|
262
|
+
const foundTestFile = findInAddon(testPath, 'f');
|
|
263
|
+
if (foundTestFile) {
|
|
264
|
+
return foundTestFile;
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
const foundDir = findInAddon(testPath, 'd');
|
|
268
|
+
if (foundDir) {
|
|
269
|
+
return foundDir;
|
|
270
|
+
}
|
|
271
|
+
const flexibleDir = findInAddon(testPath, 'd', `-path "*${testPath}*"`);
|
|
272
|
+
if (flexibleDir) {
|
|
273
|
+
return flexibleDir;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
} else if (
|
|
277
|
+
TEST_FILE_REGEX.test(testPath) && // Check if it looks like a test file path
|
|
278
|
+
!testPath.startsWith('src/addons/')
|
|
279
|
+
) {
|
|
280
|
+
const testFileName = path.basename(testPath);
|
|
281
|
+
const foundTestFile = findInAddon(testFileName, 'f');
|
|
282
|
+
if (foundTestFile) {
|
|
283
|
+
const relativePath = path.dirname(testPath);
|
|
284
|
+
if (foundTestFile.includes(relativePath)) {
|
|
285
|
+
return foundTestFile;
|
|
286
|
+
}
|
|
287
|
+
const similarFiles = findFilesWithPattern(
|
|
288
|
+
addonBasePath,
|
|
289
|
+
testFileName,
|
|
290
|
+
relativePath,
|
|
291
|
+
);
|
|
292
|
+
if (similarFiles && similarFiles.length > 0) {
|
|
293
|
+
return similarFiles[0];
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (
|
|
299
|
+
!path
|
|
300
|
+
.normalize(testPath)
|
|
301
|
+
.startsWith(path.join('src', 'addons', addonName, 'src')) &&
|
|
302
|
+
!path.isAbsolute(testPath) // Use path.isAbsolute for robust check
|
|
303
|
+
) {
|
|
304
|
+
testPath = path.join(addonBasePath, testPath); // Use path.join for OS-agnostic paths
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (fs.existsSync(testPath)) {
|
|
308
|
+
return testPath;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const pathWithoutTrailingSlash = testPath.endsWith(path.sep)
|
|
312
|
+
? testPath.slice(0, -1)
|
|
313
|
+
: null;
|
|
314
|
+
if (pathWithoutTrailingSlash && fs.existsSync(pathWithoutTrailingSlash)) {
|
|
315
|
+
return pathWithoutTrailingSlash;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const pathWithTrailingSlash = !testPath.endsWith(path.sep)
|
|
319
|
+
? testPath + path.sep
|
|
320
|
+
: null;
|
|
321
|
+
if (pathWithTrailingSlash && fs.existsSync(pathWithTrailingSlash)) {
|
|
322
|
+
// Generally, return paths without trailing slashes for consistency,
|
|
323
|
+
// unless it's specifically needed for a directory that only exists with it (rare).
|
|
324
|
+
return testPath;
|
|
325
|
+
}
|
|
326
|
+
return testPath; // Return the original path if no variations exist
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Determine collectCoverageFrom patterns based on test path
|
|
331
|
+
* @returns {string[]} - Array of coverage patterns
|
|
332
|
+
*/
|
|
333
|
+
const getCoveragePatterns = () => {
|
|
334
|
+
const excludePatterns = [
|
|
335
|
+
'!src/**/*.d.ts',
|
|
336
|
+
'!**/*.test.{js,jsx,ts,tsx}',
|
|
337
|
+
'!**/*.stories.{js,jsx,ts,tsx}',
|
|
338
|
+
'!**/*.spec.{js,jsx,ts,tsx}',
|
|
339
|
+
];
|
|
340
|
+
|
|
341
|
+
const defaultPatterns = [
|
|
342
|
+
`${addonBasePath}/**/*.{js,jsx,ts,tsx}`,
|
|
343
|
+
...excludePatterns,
|
|
344
|
+
];
|
|
345
|
+
|
|
346
|
+
const ANY_SCRIPT_FILE_REGEX = /\.[jt]sx?$/;
|
|
347
|
+
|
|
348
|
+
const directoryArg = process.argv.find(
|
|
349
|
+
(arg) =>
|
|
350
|
+
!arg.includes(path.sep) &&
|
|
351
|
+
!arg.startsWith('--') &&
|
|
352
|
+
arg !== 'test' &&
|
|
353
|
+
arg !== 'node' &&
|
|
354
|
+
!ANY_SCRIPT_FILE_REGEX.test(arg) &&
|
|
355
|
+
![
|
|
356
|
+
'yarn',
|
|
357
|
+
'npm',
|
|
358
|
+
'npx',
|
|
359
|
+
'collectCoverage',
|
|
360
|
+
'CI',
|
|
361
|
+
'RAZZLE_JEST_CONFIG',
|
|
362
|
+
].some(
|
|
363
|
+
(reserved) =>
|
|
364
|
+
arg === reserved || arg.startsWith(reserved.split('=')[0] + '='),
|
|
365
|
+
) &&
|
|
366
|
+
process.argv.indexOf(arg) >
|
|
367
|
+
process.argv.findIndex((item) => item === 'test'),
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
if (directoryArg) {
|
|
371
|
+
const foundDir = findInAddon(directoryArg, 'd');
|
|
372
|
+
if (foundDir) {
|
|
373
|
+
return [`${foundDir}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
let testPath = getTestPath();
|
|
378
|
+
|
|
379
|
+
if (!testPath) {
|
|
380
|
+
return defaultPatterns;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
if (testPath.endsWith(path.sep)) {
|
|
384
|
+
testPath = testPath.slice(0, -1);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
const stats = getStatSync(testPath);
|
|
388
|
+
|
|
389
|
+
if (stats && stats.isFile()) {
|
|
390
|
+
const implFile = findImplementationFile(testPath);
|
|
391
|
+
if (implFile) {
|
|
392
|
+
return [implFile, '!src/**/*.d.ts'];
|
|
393
|
+
}
|
|
394
|
+
const dirPath = path.dirname(testPath);
|
|
395
|
+
return [`${dirPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
396
|
+
} else if (stats && stats.isDirectory()) {
|
|
397
|
+
return [`${testPath}/**/*.{js,jsx,ts,tsx}`, ...excludePatterns];
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return defaultPatterns;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const coverageConfig = getCoveragePatterns();
|
|
404
|
+
|
|
1
405
|
module.exports = {
|
|
2
406
|
testMatch: ['**/src/addons/**/?(*.)+(spec|test).[jt]s?(x)'],
|
|
3
|
-
collectCoverageFrom:
|
|
4
|
-
|
|
5
|
-
'
|
|
407
|
+
collectCoverageFrom: coverageConfig,
|
|
408
|
+
coveragePathIgnorePatterns: [
|
|
409
|
+
'/node_modules/',
|
|
410
|
+
'schema\\.[jt]s?$',
|
|
411
|
+
'index\\.[jt]s?$',
|
|
412
|
+
'config\\.[jt]sx?$',
|
|
6
413
|
],
|
|
7
414
|
moduleNameMapper: {
|
|
8
415
|
'\\.(css|less|scss|sass)$': 'identity-obj-proxy',
|
|
9
416
|
'@plone/volto/cypress': '<rootDir>/node_modules/@plone/volto/cypress',
|
|
10
417
|
'@plone/volto/babel': '<rootDir>/node_modules/@plone/volto/babel',
|
|
11
418
|
'@plone/volto/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
12
|
-
'@package/(.*)$': '<rootDir>/src/$1',
|
|
13
|
-
'@root/(.*)$': '<rootDir>/src/$1',
|
|
419
|
+
'@package/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
420
|
+
'@root/(.*)$': '<rootDir>/node_modules/@plone/volto/src/$1',
|
|
14
421
|
'@plone/volto-quanta/(.*)$': '<rootDir>/src/addons/volto-quanta/src/$1',
|
|
422
|
+
'@eeacms/search/(.*)$': '<rootDir>/src/addons/volto-searchlib/searchlib/$1',
|
|
423
|
+
'@eeacms/search': '<rootDir>/src/addons/volto-searchlib/searchlib',
|
|
15
424
|
'@eeacms/(.*?)/(.*)$': '<rootDir>/node_modules/@eeacms/$1/src/$2',
|
|
16
|
-
'@plone/volto-slate':
|
|
425
|
+
'@plone/volto-slate$':
|
|
17
426
|
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src',
|
|
427
|
+
'@plone/volto-slate/(.*)$':
|
|
428
|
+
'<rootDir>/node_modules/@plone/volto/packages/volto-slate/src/$1',
|
|
18
429
|
'~/(.*)$': '<rootDir>/src/$1',
|
|
19
430
|
'load-volto-addons':
|
|
20
431
|
'<rootDir>/node_modules/@plone/volto/jest-addons-loader.js',
|
|
21
432
|
},
|
|
433
|
+
transformIgnorePatterns: [
|
|
434
|
+
'/node_modules/(?!(@plone|@root|@package|@eeacms)/).*/',
|
|
435
|
+
],
|
|
22
436
|
transform: {
|
|
23
437
|
'^.+\\.js(x)?$': 'babel-jest',
|
|
438
|
+
'^.+\\.ts(x)?$': 'babel-jest',
|
|
24
439
|
'^.+\\.(png)$': 'jest-file',
|
|
25
440
|
'^.+\\.(jpg)$': 'jest-file',
|
|
26
441
|
'^.+\\.(svg)$': './node_modules/@plone/volto/jest-svgsystem-transform.js',
|
|
@@ -33,4 +448,19 @@ module.exports = {
|
|
|
33
448
|
statements: 5,
|
|
34
449
|
},
|
|
35
450
|
},
|
|
451
|
+
...(process.env.JEST_USE_SETUP === 'ON' && {
|
|
452
|
+
setupFilesAfterEnv: [
|
|
453
|
+
fs.existsSync(
|
|
454
|
+
path.join(
|
|
455
|
+
__dirname,
|
|
456
|
+
'node_modules',
|
|
457
|
+
'@eeacms',
|
|
458
|
+
addonName,
|
|
459
|
+
'jest.setup.js',
|
|
460
|
+
),
|
|
461
|
+
)
|
|
462
|
+
? `<rootDir>/node_modules/@eeacms/${addonName}/jest.setup.js`
|
|
463
|
+
: `<rootDir>/src/addons/${addonName}/jest.setup.js`,
|
|
464
|
+
],
|
|
465
|
+
}),
|
|
36
466
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eeacms/volto-eea-design-system",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.40.0",
|
|
4
4
|
"description": "@eeacms/volto-eea-design-system: Volto add-on",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "European Environment Agency: IDM2 A-Team",
|
|
@@ -36,7 +36,8 @@
|
|
|
36
36
|
"husky": "^8.0.3",
|
|
37
37
|
"lint-staged": "^14.0.1",
|
|
38
38
|
"md5": "^2.3.0",
|
|
39
|
-
"postcss-less": "6.0.0"
|
|
39
|
+
"postcss-less": "6.0.0",
|
|
40
|
+
"ts-jest": "^26.4.2"
|
|
40
41
|
},
|
|
41
42
|
"lint-staged": {
|
|
42
43
|
"src/**/*.{js,jsx,ts,tsx,json}": [
|
|
@@ -131,6 +131,8 @@ Default.args = {
|
|
|
131
131
|
tablet: 4,
|
|
132
132
|
computer: 4,
|
|
133
133
|
},
|
|
134
|
+
width: 270,
|
|
135
|
+
height: 100,
|
|
134
136
|
},
|
|
135
137
|
{
|
|
136
138
|
url: 'https://www.eionet.europa.eu/',
|
|
@@ -142,6 +144,8 @@ Default.args = {
|
|
|
142
144
|
tablet: 4,
|
|
143
145
|
computer: 4,
|
|
144
146
|
},
|
|
147
|
+
width: 330,
|
|
148
|
+
height: 100,
|
|
145
149
|
},
|
|
146
150
|
],
|
|
147
151
|
social: [
|
package/src/ui/Header/Header.jsx
CHANGED
|
@@ -14,6 +14,7 @@ import burgerIcon from '@eeacms/volto-eea-design-system/../theme/themes/eea/asse
|
|
|
14
14
|
|
|
15
15
|
import HeaderSearchPopUp from './HeaderSearchPopUp';
|
|
16
16
|
import HeaderMenuPopUp from './HeaderMenuPopUp';
|
|
17
|
+
import { findBestMatchingMenuItem, isMenuItemActive } from './utils';
|
|
17
18
|
import PropTypes from 'prop-types';
|
|
18
19
|
import _ from 'lodash';
|
|
19
20
|
import { isInternalURL } from '@plone/volto/helpers';
|
|
@@ -275,6 +276,12 @@ const Main = ({
|
|
|
275
276
|
const mobileMenuBurgerRef = React.useRef();
|
|
276
277
|
const desktopMenuRef = React.useRef();
|
|
277
278
|
|
|
279
|
+
// Memoize the best-matching menu item calculation to avoid re-computation on every render
|
|
280
|
+
const { bestMatchUrl, bestScore } = React.useMemo(() => {
|
|
281
|
+
const result = findBestMatchingMenuItem(menuItems, activeItem);
|
|
282
|
+
return result;
|
|
283
|
+
}, [menuItems, activeItem]);
|
|
284
|
+
|
|
278
285
|
// disable sticky setting until feature is more stable
|
|
279
286
|
// const isScrollingUp = useScrollingUp();
|
|
280
287
|
// <div
|
|
@@ -303,10 +310,11 @@ const Main = ({
|
|
|
303
310
|
>
|
|
304
311
|
{menuItems.map((item, index) => {
|
|
305
312
|
const url = item['@id'] || item.url;
|
|
306
|
-
const
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
313
|
+
const active = isMenuItemActive(
|
|
314
|
+
item,
|
|
315
|
+
bestMatchUrl,
|
|
316
|
+
bestScore,
|
|
317
|
+
);
|
|
310
318
|
return (
|
|
311
319
|
<Menu.Item
|
|
312
320
|
name={url}
|
|
@@ -335,6 +343,9 @@ const Main = ({
|
|
|
335
343
|
<Image
|
|
336
344
|
src={!searchIsActive ? `${searchIcon}` : `${closeIcon}`}
|
|
337
345
|
alt="Global search"
|
|
346
|
+
height={45}
|
|
347
|
+
width={45}
|
|
348
|
+
className="header-search-icon"
|
|
338
349
|
/>
|
|
339
350
|
</button>
|
|
340
351
|
)}
|