@eui/cli 22.0.0-alpha.8 → 22.0.0-alpha.80
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/README.md +357 -88
- package/bin/eui-cli.js +26 -0
- package/bin/scripts/migrate.js +5 -0
- package/lib/app-utils/build.js +26 -0
- package/lib/app-utils/migrate.js +610 -0
- package/lib/app-utils/serve.js +32 -0
- package/lib/build.js +28 -7
- package/lib/cli.js +16 -2
- package/lib/config.js +10 -1
- package/lib/skeletons/_angular/base/mock/app/routes/{index.js → index.cjs} +1 -1
- package/lib/skeletons/_angular/base/mock/app/routes/{user_routes.js → user_routes.cjs} +1 -1
- package/lib/skeletons/_angular/base/mock/{server.js → server.cjs} +1 -1
- package/lib/skeletons/_angular/base/package.json +4 -3
- package/lib/skeletons/_angular/base/src/app/app-starter.service.ts +0 -1
- package/lib/skeletons/_angular/base/src/app/app.component.spec.ts +1 -1
- package/lib/skeletons/_angular/base/src/app/features/home/home.component.ts +0 -4
- package/lib/skeletons/_angular/base/tsconfig.json +1 -2
- package/lib/skeletons/_angular/base-mobile/package.json +5 -4
- package/lib/skeletons/_angular/base-mobile/src/app/features/about/opensource-licences/opensource-licences.component.ts +0 -1
- package/lib/skeletons/_angular/options/ecl-ec/angular.json +2 -2
- package/lib/skeletons/_angular/options/ecl-ec/src/app/app.component.html +2 -2
- package/lib/skeletons/_angular/options/ecl-ec/src/app/app.component.ts +4 -6
- package/lib/skeletons/_angular/options/ecl-ec/src/app/features/home/home.component.ts +0 -4
- package/lib/skeletons/_angular/options/ecl-eu/angular.json +2 -2
- package/lib/skeletons/_angular/options/ecl-eu/src/app/app.component.html +2 -2
- package/lib/skeletons/_angular/options/ecl-eu/src/app/app.component.ts +4 -6
- package/lib/skeletons/_angular/options/ecl-eu/src/app/features/home/home.component.ts +0 -4
- package/lib/skeletons/_angular/options/eds/src/app/app.component.html +35 -0
- package/lib/skeletons/_angular/options/eds/src/app/app.component.spec.ts +56 -0
- package/lib/skeletons/_angular/options/eds/src/app/app.component.ts +44 -0
- package/lib/skeletons/_angular/options/eds/src/index.html +21 -0
- package/lib/skeletons/_angular/options/pnpm/package.json +98 -48
- package/lib/skeletons/_react/base/README.md +65 -0
- package/lib/skeletons/_react/base/eslint.config.mjs +17 -0
- package/lib/skeletons/_react/base/gitignore_TO_REPLACE +34 -0
- package/lib/skeletons/_react/base/index.html +13 -0
- package/lib/skeletons/_react/base/mock/app/models/user.cjs +6 -0
- package/lib/skeletons/_react/base/mock/app/routes/index.cjs +5 -0
- package/lib/skeletons/_react/base/mock/app/routes/user_routes.cjs +44 -0
- package/lib/skeletons/_react/base/mock/db/db.json +10 -0
- package/lib/skeletons/_react/base/mock/server.cjs +23 -0
- package/lib/skeletons/_react/base/package.json +29 -0
- package/lib/skeletons/_react/base/public/.gitkeep +0 -0
- package/lib/skeletons/_react/base/src/App.tsx +73 -0
- package/lib/skeletons/_react/base/src/main.tsx +30 -0
- package/lib/skeletons/_react/base/src/pages/about.tsx +27 -0
- package/lib/skeletons/_react/base/src/pages/home.tsx +50 -0
- package/lib/skeletons/_react/base/src/routes.ts +18 -0
- package/lib/skeletons/_react/base/src/styles.css +37 -0
- package/lib/skeletons/_react/base/src/vite-env.d.ts +1 -0
- package/lib/skeletons/_react/base/tsconfig.app.json +18 -0
- package/lib/skeletons/_react/base/tsconfig.json +7 -0
- package/lib/skeletons/_react/base/tsconfig.node.json +15 -0
- package/lib/skeletons/_react/base/vite.config.ts +77 -0
- package/lib/skeletons/_react/options/pnpm/package.json +46 -0
- package/lib/utils.js +26 -2
- package/package.json +1 -1
- package/sonar-project.properties +0 -14
- /package/lib/skeletons/_angular/base/mock/app/models/{user.js → user.cjs} +0 -0
|
@@ -1,71 +1,121 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eui-angular-app",
|
|
3
|
-
"version": "22.0.0-alpha.
|
|
3
|
+
"version": "22.0.0-alpha.80",
|
|
4
4
|
"license": "EUPL-1.1",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"ng": "ng",
|
|
7
|
-
"start-mock-server": "nodemon --watch ./mock ./mock/server.
|
|
8
|
-
"start-serve": "eui-cli serve-app --configuration=proxy-mock",
|
|
7
|
+
"start-mock-server": "nodemon --watch ./mock ./mock/server.cjs",
|
|
8
|
+
"start-serve": "eui-cli serve-app --configuration=proxy-mock --configEnvTarget=mock",
|
|
9
9
|
"start": "npm-run-all --parallel start-mock-server start-serve",
|
|
10
10
|
"start-proxy": "eui-cli serve-app --configuration=proxy",
|
|
11
11
|
"start-local": "eui-cli serve-app",
|
|
12
12
|
"build": "eui-cli build-app",
|
|
13
13
|
"build-dev": "eui-cli build-app --configuration=development --configEnvTarget=dev",
|
|
14
|
-
"build-prod": "eui-cli build-app --configuration=production-optimized --configEnvTarget=prod
|
|
15
|
-
"
|
|
14
|
+
"build-prod": "eui-cli build-app --configuration=production-optimized --configEnvTarget=prod",
|
|
15
|
+
"build-prod-skip-test": "eui-cli build-app --configuration=production-optimized --configEnvTarget=prod --skipTest",
|
|
16
|
+
"build-prod-stats": "eui-cli build-app --configuration=production-optimized --configEnvTarget=prod",
|
|
17
|
+
"app:build": "eui-cli build-app",
|
|
18
|
+
"app:inject-config": "eui-cli inject-config-app",
|
|
19
|
+
"generate-sprite": "eui-cli generate-sprite"
|
|
16
20
|
},
|
|
17
21
|
"private": true,
|
|
18
22
|
"dependencies": {
|
|
19
|
-
"@angular/animations": "
|
|
20
|
-
"@angular/common": "
|
|
21
|
-
"@angular/compiler": "
|
|
22
|
-
"@angular/core": "
|
|
23
|
-
"@angular/forms": "
|
|
24
|
-
"@angular/platform-browser": "
|
|
25
|
-
"@angular/platform-browser-dynamic": "
|
|
26
|
-
"@angular/router": "
|
|
27
|
-
"@angular/elements": "
|
|
28
|
-
"@angular/
|
|
29
|
-
"@angular/
|
|
30
|
-
"@angular/
|
|
31
|
-
"@angular/material": "
|
|
32
|
-
"@angular/material-
|
|
33
|
-
"
|
|
23
|
+
"@angular/animations": "22.2.0",
|
|
24
|
+
"@angular/common": "22.2.0",
|
|
25
|
+
"@angular/compiler": "22.2.0",
|
|
26
|
+
"@angular/core": "22.2.0",
|
|
27
|
+
"@angular/forms": "22.2.0",
|
|
28
|
+
"@angular/platform-browser": "22.2.0",
|
|
29
|
+
"@angular/platform-browser-dynamic": "22.2.0",
|
|
30
|
+
"@angular/router": "22.2.0",
|
|
31
|
+
"@angular/elements": "22.2.0",
|
|
32
|
+
"@angular/service-worker": "22.2.0",
|
|
33
|
+
"@angular/cdk": "22.2.0",
|
|
34
|
+
"@angular/material": "22.2.0",
|
|
35
|
+
"@angular/material-moment-adapter": "22.2.0",
|
|
36
|
+
"@angular/material-luxon-adapter": "22.2.0",
|
|
37
|
+
"luxon": "3.7.2",
|
|
34
38
|
"rxjs": "7.8.2",
|
|
35
39
|
"tslib": "2.8.1",
|
|
36
|
-
"zone.js": "0.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"@ngx-translate/
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"hammerjs": "2.0.8",
|
|
45
|
-
"pikaday": "1.8.2",
|
|
46
|
-
"lodash-es": "4.17.23",
|
|
40
|
+
"zone.js": "0.16.2",
|
|
41
|
+
"deepmerge-ts": "8.0.1",
|
|
42
|
+
"deepmerge": "4.3.1",
|
|
43
|
+
"reselect": "5.2.0",
|
|
44
|
+
"ngx-mask": "22.0.1",
|
|
45
|
+
"@ngx-translate/core": "18.0.0",
|
|
46
|
+
"@ngx-translate/http-loader": "18.0.0",
|
|
47
|
+
"lodash-es": "4.18.1",
|
|
47
48
|
"localforage": "1.10.0",
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
49
|
+
"@duetds/date-picker": "1.4.0",
|
|
50
|
+
"embla-carousel": "8.6.0",
|
|
51
|
+
"embla-carousel-reactive-utils": "8.6.0",
|
|
52
|
+
"embla-carousel-angular": "22.0.0",
|
|
53
|
+
"embla-carousel-auto-scroll": "8.6.0",
|
|
54
|
+
"moment": "2.31.0",
|
|
55
|
+
"quill": "2.0.3",
|
|
56
|
+
"quill-delta": "5.1.0",
|
|
57
|
+
"quill-better-table": "1.2.10",
|
|
58
|
+
"apexcharts": "5.16.0",
|
|
59
|
+
"marked": "18.0.5",
|
|
60
|
+
"ngx-markdown": "22.0.0",
|
|
61
|
+
"prismjs": "1.30.0",
|
|
62
|
+
"@stackblitz/sdk": "1.11.1",
|
|
63
|
+
"@eui/base": "22.0.0-alpha.80",
|
|
64
|
+
"@eui/core": "22.0.0-alpha.80",
|
|
65
|
+
"@eui/styles": "22.0.0-alpha.80",
|
|
66
|
+
"@eui/components": "22.0.0-alpha.80",
|
|
67
|
+
"@eui/showcase": "22.0.0-alpha.80",
|
|
68
|
+
"@eui/ecl": "22.0.0-alpha.80",
|
|
69
|
+
"@eui/eds": "22.0.0-alpha.80",
|
|
70
|
+
"@eui/eds-styles": "22.0.0-alpha.80",
|
|
71
|
+
"@eui/eds-wc": "22.0.0-alpha.25",
|
|
72
|
+
"@eui/eds-shared": "22.0.0-alpha.80"
|
|
55
73
|
},
|
|
56
74
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@angular/
|
|
59
|
-
"@angular/
|
|
60
|
-
"
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
75
|
+
"@eui/cli": "22.0.0-alpha.80",
|
|
76
|
+
"@angular/compiler-cli": "22.2.0",
|
|
77
|
+
"@angular/language-service": "22.2.0",
|
|
78
|
+
"@angular/build": "22.2.0",
|
|
79
|
+
"@angular/cli": "22.2.0",
|
|
80
|
+
"ng-packagr": "22.2.2",
|
|
81
|
+
"typescript": "6.0.3",
|
|
82
|
+
"@types/node": "24.13.3",
|
|
83
|
+
"@types/lodash-es": "4.17.12",
|
|
84
|
+
"@types/quill": "2.0.14",
|
|
85
|
+
"ts-node": "10.9.2",
|
|
86
|
+
"eslint": "10.11.0",
|
|
87
|
+
"angular-eslint": "22.5.0",
|
|
88
|
+
"@angular-eslint/builder": "22.5.0",
|
|
89
|
+
"@angular-eslint/eslint-plugin": "22.5.0",
|
|
90
|
+
"@angular-eslint/eslint-plugin-template": "22.5.0",
|
|
91
|
+
"@angular-eslint/schematics": "22.5.0",
|
|
92
|
+
"@angular-eslint/template-parser": "22.5.0",
|
|
93
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
94
|
+
"eslint-plugin-jsdoc": "63.0.12",
|
|
95
|
+
"eslint-plugin-import": "2.32.0",
|
|
96
|
+
"typescript-eslint": "8.63.0",
|
|
97
|
+
"@typescript-eslint/parser": "8.63.0",
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "8.63.0",
|
|
99
|
+
"@eslint/js": "9.39.1",
|
|
100
|
+
"@eslint/eslintrc": "3.3.5",
|
|
101
|
+
"vitest": "4.1.11",
|
|
102
|
+
"@vitest/ui": "4.1.11",
|
|
103
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
104
|
+
"@vitest/coverage-istanbul": "4.1.11",
|
|
105
|
+
"jsdom": "30.0.1",
|
|
106
|
+
"xhr-mock": "2.5.1",
|
|
107
|
+
"@compodoc/compodoc": "2.0.0",
|
|
63
108
|
"npm-run-all": "4.1.5",
|
|
64
109
|
"json-server": "1.0.0-beta.3",
|
|
65
|
-
"nodemon": "3.1.
|
|
110
|
+
"nodemon": "3.1.11",
|
|
66
111
|
"lowdb": "1.0.0",
|
|
67
|
-
"body-parser": "
|
|
68
|
-
"express": "
|
|
69
|
-
|
|
112
|
+
"body-parser": "1.20.3",
|
|
113
|
+
"express": "4.21.2"
|
|
114
|
+
},
|
|
115
|
+
"resolutions": {
|
|
116
|
+
"semver": ">=7.5.2",
|
|
117
|
+
"dompurify": ">=3.2.4",
|
|
118
|
+
"tmp": ">0.2.4",
|
|
119
|
+
"tablesort": "5.6.0"
|
|
70
120
|
}
|
|
71
121
|
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# eUI React App
|
|
2
|
+
|
|
3
|
+
A React + Vite starter application built with [`@eui/eds-react`](https://eui.ecdevops.eu) — the
|
|
4
|
+
pure-React port of the EU Design System (EDS) components — and React Router.
|
|
5
|
+
|
|
6
|
+
## Prerequisites
|
|
7
|
+
|
|
8
|
+
- Node.js `^20.19.0 || ^22.12.0 || >=24.15.0`
|
|
9
|
+
- Yarn 1.x (or pnpm)
|
|
10
|
+
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
Install dependencies (done automatically by the eUI CLI when you opt in):
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
yarn
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Start the dev server (opens on http://localhost:4200):
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm start
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Available scripts
|
|
26
|
+
|
|
27
|
+
| Script | Description |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `npm start` | Start the Vite dev server with HMR |
|
|
30
|
+
| `npm run build` | Type-check and build the production bundle into `dist/` |
|
|
31
|
+
| `npm run preview` | Preview the production build locally |
|
|
32
|
+
| `npm run lint` | Lint the `src` folder with ESLint |
|
|
33
|
+
| `npm run test` | Run unit tests with Vitest |
|
|
34
|
+
|
|
35
|
+
## Project structure
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
├── index.html # App entry; <body class="eui-21"> provides the EDS token scope
|
|
39
|
+
├── vite.config.ts # Vite config; serves EDS icon sprites under /assets/eds
|
|
40
|
+
├── tsconfig*.json # TypeScript project references
|
|
41
|
+
├── eslint.config.mjs # Flat ESLint config (single quotes, TS recommended)
|
|
42
|
+
└── src/
|
|
43
|
+
├── main.tsx # Mounts <App/> in a HashRouter; loads EDS + component styles
|
|
44
|
+
├── App.tsx # The EdsShell (toolbar + sidebar + routed content)
|
|
45
|
+
├── routes.ts # Navigation table (sidebar items)
|
|
46
|
+
├── styles.css # App-level styles
|
|
47
|
+
└── pages/ # Route pages (home, about)
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Adding a page
|
|
51
|
+
|
|
52
|
+
1. Create `src/pages/my-page.tsx` exporting a component.
|
|
53
|
+
2. Add an entry to `NAV_ITEMS` in `src/routes.ts` (path, label, EDS icon name).
|
|
54
|
+
3. Add a `<Route>` for it in `src/App.tsx`.
|
|
55
|
+
|
|
56
|
+
## Styling
|
|
57
|
+
|
|
58
|
+
The EDS design tokens (`--eds-*`) are provided by `@eui/eds-styles` and are available anywhere
|
|
59
|
+
under the `eui-21` scope (set on `<body>`). Prefer the `eds-u-*` utility classes for layout. All
|
|
60
|
+
`@eui/eds-react` component styles are loaded via the combined `@eui/eds-react/styles.css` barrel
|
|
61
|
+
in `main.tsx`; to reduce bundle size you can instead import only the per-component CSS you use.
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
EUPL-1.1
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import js from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
|
+
|
|
4
|
+
export default tseslint.config(
|
|
5
|
+
{ ignores: ['dist', 'node_modules'] },
|
|
6
|
+
{
|
|
7
|
+
files: ['src/**/*.{ts,tsx}'],
|
|
8
|
+
extends: [js.configs.recommended, ...tseslint.configs.recommended],
|
|
9
|
+
rules: {
|
|
10
|
+
quotes: ['error', 'single', { avoidEscape: true }],
|
|
11
|
+
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
|
|
12
|
+
'@typescript-eslint/no-explicit-any': 'warn',
|
|
13
|
+
'prefer-const': 'error',
|
|
14
|
+
'no-var': 'error',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# compiled output
|
|
4
|
+
**/node_modules
|
|
5
|
+
**/dist
|
|
6
|
+
**/out-tsc
|
|
7
|
+
**/tmp
|
|
8
|
+
**/coverage
|
|
9
|
+
|
|
10
|
+
# IDEs and editors
|
|
11
|
+
/.idea
|
|
12
|
+
.project
|
|
13
|
+
.classpath
|
|
14
|
+
*.launch
|
|
15
|
+
.settings/
|
|
16
|
+
|
|
17
|
+
# IDE - VSCode
|
|
18
|
+
.vscode/*
|
|
19
|
+
!.vscode/settings.json
|
|
20
|
+
!.vscode/tasks.json
|
|
21
|
+
!.vscode/launch.json
|
|
22
|
+
!.vscode/extensions.json
|
|
23
|
+
|
|
24
|
+
# misc
|
|
25
|
+
npm-debug.log
|
|
26
|
+
yarn-error.log
|
|
27
|
+
*.local
|
|
28
|
+
|
|
29
|
+
# Vite
|
|
30
|
+
.vite
|
|
31
|
+
|
|
32
|
+
# System Files
|
|
33
|
+
.DS_Store
|
|
34
|
+
Thumbs.db
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>eUI React App</title>
|
|
7
|
+
</head>
|
|
8
|
+
<!-- The `eui-21` scope class is required by EDS styling (it provides the --eds-* tokens). -->
|
|
9
|
+
<body class="eui-21">
|
|
10
|
+
<div id="root"></div>
|
|
11
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
12
|
+
</body>
|
|
13
|
+
</html>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
const User = require('../models/user.cjs');
|
|
3
|
+
|
|
4
|
+
module.exports = function (app, db) {
|
|
5
|
+
db.then(db => {
|
|
6
|
+
app.get('/api/user-details', (req, res) => {
|
|
7
|
+
res.send(db.get('user-details'))
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
app.get('/api/users', (req, res) => {
|
|
11
|
+
res.send(db.get('users'))
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
app.get('/api/users/:userId', (req, res) => {
|
|
15
|
+
res.send(
|
|
16
|
+
db.get('users')
|
|
17
|
+
.find({ userId: req.params.userId })
|
|
18
|
+
);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
app.put('/api/users/:userId', (req, res) => {
|
|
22
|
+
db.get('users')
|
|
23
|
+
.find({ userId: req.params.userId })
|
|
24
|
+
.assign( { ...req.body } )
|
|
25
|
+
.write()
|
|
26
|
+
.then(user => res.send(user))
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
app.delete('/api/users/:userId', (req, res) => {
|
|
30
|
+
db.get('users')
|
|
31
|
+
.remove({ userId: req.params.userId })
|
|
32
|
+
.write()
|
|
33
|
+
.then(res.send())
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
app.post('/api/users', (req, res) => {
|
|
37
|
+
db.get('users')
|
|
38
|
+
.push({ ...User, ...req.body, ...{ userId: crypto.randomUUID() } })
|
|
39
|
+
.last()
|
|
40
|
+
.write()
|
|
41
|
+
.then(user => res.send(user))
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const express = require('express');
|
|
2
|
+
const bodyParser = require('body-parser');
|
|
3
|
+
const app = express();
|
|
4
|
+
const low = require('lowdb');
|
|
5
|
+
const FileAsync = require('lowdb/adapters/FileAsync');
|
|
6
|
+
const adapter = new FileAsync('mock/db/db.json');
|
|
7
|
+
const db = low(adapter);
|
|
8
|
+
const port = 3000;
|
|
9
|
+
|
|
10
|
+
app.use(express.json());
|
|
11
|
+
app.use(bodyParser.urlencoded({ extended: true }));
|
|
12
|
+
// const cors = require('cors');
|
|
13
|
+
// if needed to be reached from another localhost server for local testing a distributed app f.e.
|
|
14
|
+
// app.use(cors({
|
|
15
|
+
// origin: 'http://127.0.0.1:8080',
|
|
16
|
+
// credentials: true,
|
|
17
|
+
// }));
|
|
18
|
+
|
|
19
|
+
require('./app/routes/index.cjs')(app, db);
|
|
20
|
+
|
|
21
|
+
app.listen(port, () => {
|
|
22
|
+
console.log('We are live on ' + port);
|
|
23
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "eui-react-app",
|
|
3
|
+
"version": "22.0.0-alpha.80",
|
|
4
|
+
"license": "EUPL-1.1",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start-mock-server": "nodemon --watch ./mock ./mock/server.cjs",
|
|
9
|
+
"start-serve": "eui-cli serve-app",
|
|
10
|
+
"start": "npm-run-all --parallel start-mock-server start-serve",
|
|
11
|
+
"start-local": "eui-cli serve-app",
|
|
12
|
+
"build": "tsc -b && eui-cli build-app",
|
|
13
|
+
"preview": "vite preview",
|
|
14
|
+
"lint": "eslint src --ext .ts,.tsx",
|
|
15
|
+
"test": "vitest run"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"@eui/deps-base-react": "22.0.0-alpha.80"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eui/cli": "22.0.0-alpha.80",
|
|
22
|
+
"npm-run-all": "4.1.5",
|
|
23
|
+
"json-server": "1.0.0-beta.3",
|
|
24
|
+
"nodemon": "3.1.11",
|
|
25
|
+
"lowdb": "1.0.0",
|
|
26
|
+
"body-parser": "1.20.3",
|
|
27
|
+
"express": "4.21.2"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Routes, Route, Navigate, useNavigate, useLocation } from 'react-router-dom';
|
|
2
|
+
import {
|
|
3
|
+
EdsShell,
|
|
4
|
+
EdsShellToolbar,
|
|
5
|
+
EdsShellToolbarApp,
|
|
6
|
+
EdsShellMenuToggle,
|
|
7
|
+
EdsShellSidebar,
|
|
8
|
+
EdsShellSidebarNav,
|
|
9
|
+
EdsShellSidebarFooter,
|
|
10
|
+
EdsShellContent,
|
|
11
|
+
EdsShellFooter,
|
|
12
|
+
type EdsMenuItem,
|
|
13
|
+
} from '@eui/eds-react/eds-shell';
|
|
14
|
+
|
|
15
|
+
import { NAV_ITEMS } from './routes.js';
|
|
16
|
+
import { HomePage } from './pages/home.js';
|
|
17
|
+
import { AboutPage } from './pages/about.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The application shell — an `EdsShell` with a toolbar, a collapsible sidebar navigation, and a
|
|
21
|
+
* routed content area. Routing is owned by the app (React Router `HashRouter`, set up in
|
|
22
|
+
* `main.tsx`): the sidebar's `onItemClick` navigates, and `<Routes>` renders the matching page.
|
|
23
|
+
* The `EdsShell` component is router-agnostic — nav items only carry a `url` and fire
|
|
24
|
+
* `onItemClick`; the app decides what to do with it.
|
|
25
|
+
*/
|
|
26
|
+
export function App() {
|
|
27
|
+
const navigate = useNavigate();
|
|
28
|
+
const location = useLocation();
|
|
29
|
+
const currentPath = location.pathname === '/' ? '/home' : location.pathname;
|
|
30
|
+
|
|
31
|
+
// Build the sidebar items from the shared route table, flagging the active one.
|
|
32
|
+
const navItems: EdsMenuItem[] = NAV_ITEMS.map((item) => ({
|
|
33
|
+
label: item.label,
|
|
34
|
+
icon: item.icon,
|
|
35
|
+
url: `#${item.path}`,
|
|
36
|
+
active: item.path === currentPath,
|
|
37
|
+
}));
|
|
38
|
+
|
|
39
|
+
const onNavClick = (item: EdsMenuItem): void => {
|
|
40
|
+
if (!item.url) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
navigate(item.url.replace(/^#/, '') || '/');
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<EdsShell
|
|
48
|
+
toolbar={
|
|
49
|
+
<EdsShellToolbar
|
|
50
|
+
menuToggle={<EdsShellMenuToggle />}
|
|
51
|
+
app={<EdsShellToolbarApp appName="eUI React App" appSubTitle="@eui/eds-react" />}
|
|
52
|
+
/>
|
|
53
|
+
}
|
|
54
|
+
sidebar={
|
|
55
|
+
<EdsShellSidebar
|
|
56
|
+
collapseMode="icons"
|
|
57
|
+
nav={<EdsShellSidebarNav items={navItems} hasIcons onItemClick={onNavClick} />}
|
|
58
|
+
footer={<EdsShellSidebarFooter>Powered by @eui/eds-react</EdsShellSidebarFooter>}
|
|
59
|
+
/>
|
|
60
|
+
}
|
|
61
|
+
footer={<EdsShellFooter copyright="© European Union" />}
|
|
62
|
+
>
|
|
63
|
+
<EdsShellContent>
|
|
64
|
+
<Routes>
|
|
65
|
+
<Route path="/home" element={<HomePage />} />
|
|
66
|
+
<Route path="/about" element={<AboutPage />} />
|
|
67
|
+
<Route path="/" element={<Navigate to="/home" replace />} />
|
|
68
|
+
<Route path="*" element={<Navigate to="/home" replace />} />
|
|
69
|
+
</Routes>
|
|
70
|
+
</EdsShellContent>
|
|
71
|
+
</EdsShell>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StrictMode } from 'react';
|
|
2
|
+
import { createRoot } from 'react-dom/client';
|
|
3
|
+
import { HashRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
// EdsIcon resolves sprites from `${assetsBase}/eds/icons/sprites/{set}.svg`. Derive an absolute
|
|
6
|
+
// base from Vite's deploy base (`import.meta.env.BASE_URL`) so sprites load regardless of the
|
|
7
|
+
// page URL's trailing slash. The eds-assets Vite plugin serves the sprites under `/assets/eds`.
|
|
8
|
+
(globalThis as { __EDS_ASSETS_BASE__?: string }).__EDS_ASSETS_BASE__ =
|
|
9
|
+
`${import.meta.env.BASE_URL.replace(/\/$/, '')}/assets`;
|
|
10
|
+
|
|
11
|
+
// EDS design tokens + base styles (provide the --eds-* custom properties the components read)
|
|
12
|
+
// and the eds-u-* layout utilities.
|
|
13
|
+
import '@eui/eds-styles/dist/eds.css';
|
|
14
|
+
import '@eui/eds-styles/dist/eds-utilities.css';
|
|
15
|
+
// All pure-React @eui/eds-react component styles via the combined barrel. Bundle-conscious apps
|
|
16
|
+
// can instead import only the per-component CSS they use (e.g. '@eui/eds-react/eds-button/eds-button.css').
|
|
17
|
+
import '@eui/eds-react/styles.css';
|
|
18
|
+
|
|
19
|
+
// App-specific styles.
|
|
20
|
+
import './styles.css';
|
|
21
|
+
|
|
22
|
+
import { App } from './App.js';
|
|
23
|
+
|
|
24
|
+
createRoot(document.getElementById('root')!).render(
|
|
25
|
+
<StrictMode>
|
|
26
|
+
<HashRouter>
|
|
27
|
+
<App />
|
|
28
|
+
</HashRouter>
|
|
29
|
+
</StrictMode>,
|
|
30
|
+
);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { EdsCard, EdsCardHeader, EdsCardLabel, EdsCardBody } from '@eui/eds-react/eds-card';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A second example page, reachable from the sidebar, to demonstrate client-side routing.
|
|
5
|
+
*/
|
|
6
|
+
export function AboutPage() {
|
|
7
|
+
return (
|
|
8
|
+
<div className="app-page">
|
|
9
|
+
<h1 className="app-page__title">About</h1>
|
|
10
|
+
<p className="app-page__intro">
|
|
11
|
+
This page is served by React Router. Navigation between it and the home page happens
|
|
12
|
+
entirely client-side via the sidebar, with no full-page reload.
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
<EdsCard>
|
|
16
|
+
<EdsCardHeader>
|
|
17
|
+
<EdsCardLabel>How routing works</EdsCardLabel>
|
|
18
|
+
</EdsCardHeader>
|
|
19
|
+
<EdsCardBody>
|
|
20
|
+
The sidebar items in <code>src/App.tsx</code> carry a <code>url</code> and the
|
|
21
|
+
shell calls <code>onItemClick</code>; the app then navigates with React Router.
|
|
22
|
+
The <code>EdsShell</code> itself stays router-agnostic.
|
|
23
|
+
</EdsCardBody>
|
|
24
|
+
</EdsCard>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { EdsCard, EdsCardHeader, EdsCardLabel, EdsCardBody } from '@eui/eds-react/eds-card';
|
|
2
|
+
import { EdsButton } from '@eui/eds-react/eds-button';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The default landing page. A simple example composing a couple of `@eui/eds-react` components
|
|
6
|
+
* (`EdsCard`, `EdsButton`) inside the shell content area. Replace this with your own home page.
|
|
7
|
+
*/
|
|
8
|
+
export function HomePage() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="app-page">
|
|
11
|
+
<h1 className="app-page__title">Welcome to your eUI React app</h1>
|
|
12
|
+
<p className="app-page__intro">
|
|
13
|
+
This starter is powered by <strong>@eui/eds-react</strong> — the pure-React port of the
|
|
14
|
+
EU Design System components — with routing handled by React Router.
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
<div className="eds-u-d-flex eds-u-flex-wrap eds-u-flex-gap-l">
|
|
18
|
+
<EdsCard>
|
|
19
|
+
<EdsCardHeader>
|
|
20
|
+
<EdsCardLabel>Get started</EdsCardLabel>
|
|
21
|
+
</EdsCardHeader>
|
|
22
|
+
<EdsCardBody>
|
|
23
|
+
Edit <code>src/pages/home.tsx</code> to build your first page, then add routes in
|
|
24
|
+
<code> src/routes.ts</code> and <code>src/App.tsx</code>.
|
|
25
|
+
</EdsCardBody>
|
|
26
|
+
</EdsCard>
|
|
27
|
+
|
|
28
|
+
<EdsCard>
|
|
29
|
+
<EdsCardHeader>
|
|
30
|
+
<EdsCardLabel>Components</EdsCardLabel>
|
|
31
|
+
</EdsCardHeader>
|
|
32
|
+
<EdsCardBody>
|
|
33
|
+
Import any component from <code>@eui/eds-react</code> and its styles are already
|
|
34
|
+
loaded via the combined <code>styles.css</code> barrel in <code>main.tsx</code>.
|
|
35
|
+
</EdsCardBody>
|
|
36
|
+
</EdsCard>
|
|
37
|
+
</div>
|
|
38
|
+
|
|
39
|
+
<div className="eds-u-mt-l eds-u-d-flex eds-u-flex-gap-s">
|
|
40
|
+
<EdsButton
|
|
41
|
+
type="primary"
|
|
42
|
+
onClick={() => window.open('https://eui.ecdevops.eu', '_blank', 'noopener')}
|
|
43
|
+
>
|
|
44
|
+
eUI documentation
|
|
45
|
+
</EdsButton>
|
|
46
|
+
<EdsButton type="secondary">Secondary action</EdsButton>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The app's navigation routes. The sidebar (in `App.tsx`) and the routed pages both derive from
|
|
3
|
+
* this single table, so adding a page is a one-line change here plus a `<Route>` in `App.tsx`.
|
|
4
|
+
* `icon` values are EDS icon names (see the sprite catalog in `@eui/eds-styles`).
|
|
5
|
+
*/
|
|
6
|
+
export interface NavItem {
|
|
7
|
+
/** Router path (also the hash route). */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Sidebar label. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** EDS icon name shown in the sidebar. */
|
|
12
|
+
icon: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const NAV_ITEMS: NavItem[] = [
|
|
16
|
+
{ path: '/home', label: 'Home', icon: 'house' },
|
|
17
|
+
{ path: '/about', label: 'About', icon: 'circle-info' },
|
|
18
|
+
];
|