@eui/cli 22.0.0-alpha.9 → 22.0.0-alpha.90
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 +9 -13
- package/lib/skeletons/_angular/base/src/app/app-starter.service.ts +10 -2
- 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/src/config/global.ts +4 -1
- package/lib/skeletons/_angular/base/tsconfig.json +1 -2
- package/lib/skeletons/_angular/base-mobile/package.json +6 -19
- package/lib/skeletons/_angular/base-mobile/src/app/app-starter.service.ts +10 -1
- package/lib/skeletons/_angular/base-mobile/src/app/features/about/opensource-licences/opensource-licences.component.ts +0 -1
- package/lib/skeletons/_angular/base-mobile/src/config/global.ts +4 -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-ec/src/config/global.ts +4 -1
- 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/ecl-eu/src/config/global.ts +4 -1
- 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 +91 -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/skeletons/web-maven/pom.xml +2 -2
- package/lib/skeletons/web-spring-boot/myapp-web/pom.xml +4 -5
- package/lib/skeletons/web-spring-boot/myapp-web-rest/pom.xml +2 -4
- package/lib/skeletons/web-spring-boot/myapp-web-rest/src/main/java/myapp/security/FakeAuthenticationFilter.java +0 -2
- package/lib/skeletons/web-spring-boot/pom.xml +1 -1
- package/lib/utils/fs-extra.js +38 -0
- package/lib/utils/glob.js +144 -0
- package/lib/utils/rimraf.js +14 -0
- package/lib/utils.js +39 -15
- package/package.json +2 -7
- package/sonar-project.properties +0 -14
- /package/lib/skeletons/_angular/base/mock/app/models/{user.js → user.cjs} +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Component, viewChild } from '@angular/core';
|
|
2
|
+
import { RouterOutlet } from '@angular/router';
|
|
3
|
+
import { TranslatePipe } from '@ngx-translate/core';
|
|
4
|
+
import { EDS_SHELL, EdsShell, EdsMenuItem } from '@eui/eds/eds-shell';
|
|
5
|
+
import { EDS_ICON_BUTTON } from '@eui/eds/eds-icon-button';
|
|
6
|
+
import { EDS_USER_PROFILE } from '@eui/eds/eds-user-profile';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Desktop EDS application shell. Mirrors the default Angular desktop skeleton (same routes,
|
|
10
|
+
* features, config and interceptors) but composes the layout with the modern `@eui/eds`
|
|
11
|
+
* `eds-shell` and EDS components instead of the legacy `@eui/components` `eui-app`.
|
|
12
|
+
*
|
|
13
|
+
* The sidebar nav items carry a `url` that the `eds-menu` resolves through Angular's router
|
|
14
|
+
* (`[routerLink]`), so navigation is declarative — no manual `navigate()` call is needed.
|
|
15
|
+
*/
|
|
16
|
+
@Component({
|
|
17
|
+
selector: 'app-root',
|
|
18
|
+
templateUrl: './app.component.html',
|
|
19
|
+
imports: [
|
|
20
|
+
RouterOutlet,
|
|
21
|
+
TranslatePipe,
|
|
22
|
+
...EDS_SHELL,
|
|
23
|
+
...EDS_ICON_BUTTON,
|
|
24
|
+
...EDS_USER_PROFILE,
|
|
25
|
+
],
|
|
26
|
+
})
|
|
27
|
+
export class AppComponent {
|
|
28
|
+
private shell = viewChild.required(EdsShell);
|
|
29
|
+
|
|
30
|
+
sidebarItems: EdsMenuItem[] = [
|
|
31
|
+
{ label: 'Home', url: 'screen/home', icon: 'house' },
|
|
32
|
+
{
|
|
33
|
+
label: 'Module 1', url: 'screen/module1', icon: 'stack', children: [
|
|
34
|
+
{ label: 'page 1', url: 'screen/module1/page1' },
|
|
35
|
+
{ label: 'page 2', url: 'screen/module1/page2' },
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
{ label: 'Module 2', url: 'screen/module2', icon: 'folder' },
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
onToggleSidebar(): void {
|
|
42
|
+
this.shell().toggleSidebar();
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<title>Application name</title>
|
|
6
|
+
<base href="/">
|
|
7
|
+
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
9
|
+
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
|
10
|
+
</head>
|
|
11
|
+
|
|
12
|
+
<!-- The `eui-21` scope class is required by EDS styling (it provides the --eds-* tokens). -->
|
|
13
|
+
<body class="eui-21">
|
|
14
|
+
<app-root>
|
|
15
|
+
<div id="loader-wrapper">
|
|
16
|
+
<div id="loader"></div>
|
|
17
|
+
</div>
|
|
18
|
+
</app-root>
|
|
19
|
+
</body>
|
|
20
|
+
|
|
21
|
+
</html>
|
|
@@ -1,71 +1,114 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eui-angular-app",
|
|
3
|
-
"version": "22.0.0-alpha.
|
|
3
|
+
"version": "22.0.0-alpha.90",
|
|
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
|
-
"
|
|
33
|
-
"@angular-devkit/build-angular": "21.2.3",
|
|
23
|
+
"@angular/animations": "22.3.0",
|
|
24
|
+
"@angular/common": "22.3.0",
|
|
25
|
+
"@angular/compiler": "22.3.0",
|
|
26
|
+
"@angular/core": "22.3.0",
|
|
27
|
+
"@angular/forms": "22.3.0",
|
|
28
|
+
"@angular/platform-browser": "22.3.0",
|
|
29
|
+
"@angular/platform-browser-dynamic": "22.3.0",
|
|
30
|
+
"@angular/router": "22.3.0",
|
|
31
|
+
"@angular/elements": "22.3.0",
|
|
32
|
+
"@angular/service-worker": "22.3.0",
|
|
33
|
+
"@angular/cdk": "22.3.0",
|
|
34
|
+
"@angular/material": "22.3.0",
|
|
35
|
+
"@angular/material-luxon-adapter": "22.3.0",
|
|
36
|
+
"luxon": "3.7.2",
|
|
34
37
|
"rxjs": "7.8.2",
|
|
35
|
-
"tslib": "2.
|
|
36
|
-
"zone.js": "0.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"deepmerge-ts": "7.1.5",
|
|
40
|
-
"@ngx-translate/core": "15.0.0",
|
|
41
|
-
"@ngx-translate/http-loader": "8.0.0",
|
|
38
|
+
"tslib": "2.9.1",
|
|
39
|
+
"zone.js": "0.16.2",
|
|
40
|
+
"deepmerge-ts": "8.0.1",
|
|
41
|
+
"deepmerge": "4.3.1",
|
|
42
42
|
"reselect": "5.1.1",
|
|
43
43
|
"ngx-mask": "20.0.3",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"lodash-es": "4.
|
|
44
|
+
"@ngx-translate/core": "18.0.0",
|
|
45
|
+
"@ngx-translate/http-loader": "18.0.0",
|
|
46
|
+
"lodash-es": "4.18.1",
|
|
47
47
|
"localforage": "1.10.0",
|
|
48
|
-
"@
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
48
|
+
"@duetds/date-picker": "1.4.0",
|
|
49
|
+
"embla-carousel": "8.6.0",
|
|
50
|
+
"embla-carousel-reactive-utils": "8.6.0",
|
|
51
|
+
"embla-carousel-angular": "22.0.0",
|
|
52
|
+
"embla-carousel-auto-scroll": "8.6.0",
|
|
53
|
+
"quill": "2.0.3",
|
|
54
|
+
"quill-delta": "5.1.0",
|
|
55
|
+
"quill-better-table": "1.2.10",
|
|
56
|
+
"apexcharts": "5.16.0",
|
|
57
|
+
"marked": "18.0.5",
|
|
58
|
+
"ngx-markdown": "21.1.0",
|
|
59
|
+
"prismjs": "1.30.0",
|
|
60
|
+
"@stackblitz/sdk": "1.11.1",
|
|
61
|
+
"@eui/base": "22.0.0-alpha.90",
|
|
62
|
+
"@eui/core": "22.0.0-alpha.90",
|
|
63
|
+
"@eui/styles": "22.0.0-alpha.90",
|
|
64
|
+
"@eui/components": "22.0.0-alpha.90",
|
|
65
|
+
"@eui/showcase": "22.0.0-alpha.90",
|
|
66
|
+
"@eui/ecl": "22.0.0-alpha.90",
|
|
67
|
+
"@eui/eds": "22.0.0-alpha.90",
|
|
68
|
+
"@eui/eds-styles": "22.0.0-alpha.90",
|
|
69
|
+
"@eui/eds-wc": "22.0.0-alpha.88",
|
|
70
|
+
"@eui/eds-shared": "22.0.0-alpha.90"
|
|
55
71
|
},
|
|
56
72
|
"devDependencies": {
|
|
57
|
-
"@
|
|
58
|
-
"@angular/
|
|
59
|
-
"@angular/
|
|
60
|
-
"
|
|
61
|
-
"@
|
|
62
|
-
"
|
|
73
|
+
"@eui/cli": "22.0.0-alpha.90",
|
|
74
|
+
"@angular/compiler-cli": "22.3.0",
|
|
75
|
+
"@angular/language-service": "22.3.0",
|
|
76
|
+
"@angular/build": "22.3.0",
|
|
77
|
+
"@angular/cli": "22.3.0",
|
|
78
|
+
"ng-packagr": "22.3.0",
|
|
79
|
+
"typescript": "6.0.3",
|
|
80
|
+
"@types/node": "24.13.3",
|
|
81
|
+
"@types/lodash-es": "4.17.12",
|
|
82
|
+
"@types/quill": "2.0.14",
|
|
83
|
+
"ts-node": "10.9.2",
|
|
84
|
+
"eslint": "10.15.0",
|
|
85
|
+
"angular-eslint": "22.8.0",
|
|
86
|
+
"@angular-eslint/builder": "22.8.0",
|
|
87
|
+
"@angular-eslint/eslint-plugin": "22.8.0",
|
|
88
|
+
"@angular-eslint/eslint-plugin-template": "22.8.0",
|
|
89
|
+
"@angular-eslint/schematics": "22.8.0",
|
|
90
|
+
"@angular-eslint/template-parser": "22.8.0",
|
|
91
|
+
"eslint-plugin-prefer-arrow": "1.2.3",
|
|
92
|
+
"eslint-plugin-jsdoc": "65.5.6",
|
|
93
|
+
"eslint-plugin-import": "2.32.0",
|
|
94
|
+
"typescript-eslint": "8.74.0",
|
|
95
|
+
"@typescript-eslint/parser": "8.74.0",
|
|
96
|
+
"@typescript-eslint/eslint-plugin": "8.74.0",
|
|
97
|
+
"@eslint/js": "10.0.1",
|
|
98
|
+
"@eslint/eslintrc": "3.3.7",
|
|
99
|
+
"vitest": "4.1.12",
|
|
100
|
+
"@vitest/ui": "4.1.12",
|
|
101
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
102
|
+
"@vitest/coverage-istanbul": "4.1.12",
|
|
103
|
+
"jsdom": "31.0.1",
|
|
104
|
+
"xhr-mock": "2.5.1",
|
|
105
|
+
"@compodoc/compodoc": "2.0.0",
|
|
63
106
|
"npm-run-all": "4.1.5",
|
|
64
107
|
"json-server": "1.0.0-beta.3",
|
|
65
|
-
"nodemon": "3.1.
|
|
108
|
+
"nodemon": "3.1.11",
|
|
66
109
|
"lowdb": "1.0.0",
|
|
67
|
-
"body-parser": "
|
|
68
|
-
"express": "
|
|
69
|
-
|
|
70
|
-
}
|
|
110
|
+
"body-parser": "1.20.3",
|
|
111
|
+
"express": "4.21.2"
|
|
112
|
+
},
|
|
113
|
+
"resolutions": {}
|
|
71
114
|
}
|
|
@@ -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.90",
|
|
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.90"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@eui/cli": "22.0.0-alpha.90",
|
|
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
|
+
}
|