@db-ux/react-core-components 4.9.1 → 4.10.0-esm-f121fc3
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 +9 -2
- package/README.md +97 -35
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/accordion.js +102 -86
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/model.d.ts +1 -1
- package/dist/components/accordion/model.js +4 -2
- package/dist/components/accordion-item/accordion-item.d.ts +3 -2
- package/dist/components/accordion-item/accordion-item.js +89 -56
- package/dist/components/accordion-item/index.d.ts +1 -1
- package/dist/components/accordion-item/model.d.ts +5 -1
- package/dist/components/badge/badge.d.ts +1 -1
- package/dist/components/badge/badge.js +72 -32
- package/dist/components/badge/index.d.ts +1 -1
- package/dist/components/badge/model.d.ts +1 -1
- package/dist/components/badge/model.js +12 -1
- package/dist/components/brand/brand.d.ts +1 -1
- package/dist/components/brand/brand.js +60 -13
- package/dist/components/brand/index.d.ts +1 -1
- package/dist/components/brand/model.d.ts +1 -1
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.js +75 -21
- package/dist/components/button/index.d.ts +1 -1
- package/dist/components/button/model.d.ts +1 -1
- package/dist/components/button/model.js +13 -2
- package/dist/components/card/card.d.ts +1 -1
- package/dist/components/card/card.js +65 -15
- package/dist/components/card/index.d.ts +1 -1
- package/dist/components/card/model.d.ts +1 -1
- package/dist/components/card/model.js +8 -2
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/checkbox/checkbox.js +163 -157
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/model.d.ts +1 -1
- package/dist/components/custom-button/custom-button.d.ts +1 -1
- package/dist/components/custom-button/custom-button.js +65 -10
- package/dist/components/custom-button/index.d.ts +1 -1
- package/dist/components/custom-button/model.d.ts +2 -2
- package/dist/components/custom-select/custom-select.d.ts +1 -1
- package/dist/components/custom-select/custom-select.js +509 -727
- package/dist/components/custom-select/index.d.ts +1 -1
- package/dist/components/custom-select/model.d.ts +3 -3
- package/dist/components/custom-select/model.js +8 -1
- package/dist/components/custom-select-dropdown/custom-select-dropdown.d.ts +1 -1
- package/dist/components/custom-select-dropdown/custom-select-dropdown.js +62 -11
- package/dist/components/custom-select-dropdown/index.d.ts +1 -1
- package/dist/components/custom-select-dropdown/model.d.ts +1 -1
- package/dist/components/custom-select-dropdown/model.js +8 -1
- package/dist/components/custom-select-form-field/custom-select-form-field.d.ts +1 -1
- package/dist/components/custom-select-form-field/custom-select-form-field.js +57 -10
- package/dist/components/custom-select-form-field/index.d.ts +1 -1
- package/dist/components/custom-select-form-field/model.d.ts +1 -1
- package/dist/components/custom-select-list/custom-select-list.d.ts +1 -1
- package/dist/components/custom-select-list/custom-select-list.js +60 -11
- package/dist/components/custom-select-list/index.d.ts +1 -1
- package/dist/components/custom-select-list/model.d.ts +1 -1
- package/dist/components/custom-select-list-item/custom-select-list-item.d.ts +2 -2
- package/dist/components/custom-select-list-item/custom-select-list-item.js +89 -32
- package/dist/components/custom-select-list-item/index.d.ts +1 -1
- package/dist/components/custom-select-list-item/model.d.ts +1 -1
- package/dist/components/custom-select-list-item/model.js +4 -1
- package/dist/components/divider/divider.d.ts +1 -1
- package/dist/components/divider/divider.js +60 -10
- package/dist/components/divider/index.d.ts +1 -1
- package/dist/components/divider/model.d.ts +1 -1
- package/dist/components/divider/model.js +4 -2
- package/dist/components/drawer/drawer.d.ts +2 -2
- package/dist/components/drawer/drawer.js +118 -97
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/model.d.ts +1 -1
- package/dist/components/drawer/model.js +14 -4
- package/dist/components/header/header.d.ts +1 -1
- package/dist/components/header/header.js +143 -65
- package/dist/components/header/index.d.ts +1 -1
- package/dist/components/header/model.d.ts +1 -1
- package/dist/components/icon/icon.d.ts +1 -1
- package/dist/components/icon/icon.js +61 -12
- package/dist/components/icon/index.d.ts +1 -1
- package/dist/components/icon/model.d.ts +1 -1
- package/dist/components/icon/model.js +11 -1
- package/dist/components/infotext/index.d.ts +1 -1
- package/dist/components/infotext/infotext.d.ts +1 -1
- package/dist/components/infotext/infotext.js +62 -12
- package/dist/components/infotext/model.d.ts +1 -1
- package/dist/components/input/index.d.ts +1 -1
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/input.js +198 -167
- package/dist/components/input/model.d.ts +1 -1
- package/dist/components/input/model.js +21 -5
- package/dist/components/link/index.d.ts +1 -1
- package/dist/components/link/link.d.ts +1 -1
- package/dist/components/link/link.js +70 -12
- package/dist/components/link/model.d.ts +1 -1
- package/dist/components/link/model.js +8 -3
- package/dist/components/navigation/index.d.ts +1 -1
- package/dist/components/navigation/model.d.ts +1 -1
- package/dist/components/navigation/navigation.d.ts +1 -1
- package/dist/components/navigation/navigation.js +57 -11
- package/dist/components/navigation-item/index.d.ts +1 -1
- package/dist/components/navigation-item/model.d.ts +6 -2
- package/dist/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/components/navigation-item/navigation-item.js +117 -81
- package/dist/components/notification/index.d.ts +1 -1
- package/dist/components/notification/model.d.ts +1 -1
- package/dist/components/notification/model.js +12 -3
- package/dist/components/notification/notification.d.ts +2 -2
- package/dist/components/notification/notification.js +100 -32
- package/dist/components/page/index.d.ts +1 -1
- package/dist/components/page/model.d.ts +1 -1
- package/dist/components/page/model.js +4 -2
- package/dist/components/page/page.d.ts +1 -1
- package/dist/components/page/page.js +74 -46
- package/dist/components/popover/index.d.ts +1 -1
- package/dist/components/popover/model.d.ts +1 -1
- package/dist/components/popover/popover.d.ts +1 -1
- package/dist/components/popover/popover.js +126 -125
- package/dist/components/radio/index.d.ts +1 -1
- package/dist/components/radio/model.d.ts +1 -1
- package/dist/components/radio/radio.d.ts +1 -1
- package/dist/components/radio/radio.js +124 -85
- package/dist/components/section/index.d.ts +1 -1
- package/dist/components/section/model.d.ts +1 -1
- package/dist/components/section/section.d.ts +1 -1
- package/dist/components/section/section.js +59 -10
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/model.d.ts +1 -1
- package/dist/components/select/select.d.ts +1 -1
- package/dist/components/select/select.js +188 -191
- package/dist/components/stack/index.d.ts +1 -1
- package/dist/components/stack/model.d.ts +1 -1
- package/dist/components/stack/model.js +14 -4
- package/dist/components/stack/stack.d.ts +1 -1
- package/dist/components/stack/stack.js +63 -10
- package/dist/components/switch/index.d.ts +1 -1
- package/dist/components/switch/model.d.ts +1 -1
- package/dist/components/switch/switch.d.ts +1 -1
- package/dist/components/switch/switch.js +182 -150
- package/dist/components/tab-item/index.d.ts +1 -1
- package/dist/components/tab-item/model.d.ts +1 -1
- package/dist/components/tab-item/tab-item.d.ts +1 -1
- package/dist/components/tab-item/tab-item.js +105 -76
- package/dist/components/tab-list/index.d.ts +1 -1
- package/dist/components/tab-list/model.d.ts +1 -1
- package/dist/components/tab-list/tab-list.d.ts +1 -1
- package/dist/components/tab-list/tab-list.js +60 -11
- package/dist/components/tab-panel/index.d.ts +1 -1
- package/dist/components/tab-panel/model.d.ts +1 -1
- package/dist/components/tab-panel/tab-panel.d.ts +1 -1
- package/dist/components/tab-panel/tab-panel.js +59 -13
- package/dist/components/tabs/index.d.ts +1 -1
- package/dist/components/tabs/model.d.ts +1 -1
- package/dist/components/tabs/model.js +4 -2
- package/dist/components/tabs/tabs.d.ts +1 -1
- package/dist/components/tabs/tabs.js +191 -178
- package/dist/components/tag/index.d.ts +1 -1
- package/dist/components/tag/model.d.ts +1 -1
- package/dist/components/tag/model.js +4 -1
- package/dist/components/tag/tag.d.ts +1 -1
- package/dist/components/tag/tag.js +91 -32
- package/dist/components/textarea/index.d.ts +1 -1
- package/dist/components/textarea/model.d.ts +1 -1
- package/dist/components/textarea/model.js +13 -2
- package/dist/components/textarea/textarea.d.ts +1 -1
- package/dist/components/textarea/textarea.js +165 -150
- package/dist/components/tooltip/index.d.ts +1 -1
- package/dist/components/tooltip/model.d.ts +1 -1
- package/dist/components/tooltip/model.js +4 -1
- package/dist/components/tooltip/tooltip.d.ts +1 -1
- package/dist/components/tooltip/tooltip.js +119 -115
- package/dist/index.d.ts +26 -26
- package/dist/index.js +64 -81
- package/dist/shared/constants.js +32 -94
- package/dist/shared/figma.d.ts +12 -6
- package/dist/shared/model.js +73 -22
- package/dist/utils/document-click-listener.js +26 -29
- package/dist/utils/document-scroll-listener.js +30 -38
- package/dist/utils/floating-components.js +107 -358
- package/dist/utils/form-components.js +34 -60
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +49 -167
- package/dist/utils/navigation.js +68 -135
- package/dist/utils/react.js +10 -15
- package/package.json +13 -8
- package/dist/components/accordion/index.js +0 -1
- package/dist/components/accordion-item/index.js +0 -1
- package/dist/components/accordion-item/model.js +0 -1
- package/dist/components/badge/index.js +0 -1
- package/dist/components/brand/index.js +0 -1
- package/dist/components/brand/model.js +0 -1
- package/dist/components/button/index.js +0 -1
- package/dist/components/card/index.js +0 -1
- package/dist/components/checkbox/index.js +0 -1
- package/dist/components/checkbox/model.js +0 -1
- package/dist/components/custom-button/index.js +0 -1
- package/dist/components/custom-button/model.js +0 -1
- package/dist/components/custom-select/index.js +0 -1
- package/dist/components/custom-select-dropdown/index.js +0 -1
- package/dist/components/custom-select-form-field/index.js +0 -1
- package/dist/components/custom-select-form-field/model.js +0 -1
- package/dist/components/custom-select-list/index.js +0 -1
- package/dist/components/custom-select-list/model.js +0 -1
- package/dist/components/custom-select-list-item/index.js +0 -1
- package/dist/components/divider/index.js +0 -1
- package/dist/components/drawer/index.js +0 -1
- package/dist/components/header/index.js +0 -1
- package/dist/components/header/model.js +0 -1
- package/dist/components/icon/index.js +0 -1
- package/dist/components/infotext/index.js +0 -1
- package/dist/components/infotext/model.js +0 -1
- package/dist/components/input/index.js +0 -1
- package/dist/components/link/index.js +0 -1
- package/dist/components/navigation/index.js +0 -1
- package/dist/components/navigation/model.js +0 -1
- package/dist/components/navigation-item/index.js +0 -1
- package/dist/components/navigation-item/model.js +0 -1
- package/dist/components/notification/index.js +0 -1
- package/dist/components/page/index.js +0 -1
- package/dist/components/popover/index.js +0 -1
- package/dist/components/popover/model.js +0 -1
- package/dist/components/radio/index.js +0 -1
- package/dist/components/radio/model.js +0 -1
- package/dist/components/section/index.js +0 -1
- package/dist/components/section/model.js +0 -1
- package/dist/components/select/index.js +0 -1
- package/dist/components/select/model.js +0 -1
- package/dist/components/stack/index.js +0 -1
- package/dist/components/switch/index.js +0 -1
- package/dist/components/switch/model.js +0 -1
- package/dist/components/tab-item/index.js +0 -1
- package/dist/components/tab-item/model.js +0 -1
- package/dist/components/tab-list/index.js +0 -1
- package/dist/components/tab-list/model.js +0 -1
- package/dist/components/tab-panel/index.js +0 -1
- package/dist/components/tab-panel/model.js +0 -1
- package/dist/components/tabs/index.js +0 -1
- package/dist/components/tag/index.js +0 -1
- package/dist/components/textarea/index.js +0 -1
- package/dist/components/tooltip/index.js +0 -1
- package/dist/shared/examples/index.js +0 -4
- package/dist/shared/figma.js +0 -1
- package/dist/shared/showcase/show-code-link.js +0 -51
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @db-ux/react-core-components
|
|
2
2
|
|
|
3
|
+
## 4.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- feat(`DBAccordionItem`): add `open` prop to control the expanded state of an accordion item programmatically. - [see commit 8e7c85d](https://github.com/db-ux-design-system/core-web/commit/8e7c85dfba9e0b013fce9db2151545b8f336a29a)
|
|
8
|
+
|
|
9
|
+
- refactor(form components): replace hard 25ch label width limit with customizable CSS variable `--db-label-max-size` (defaults to `100%`). To restore the previous behavior, set `--db-label-max-size: 25ch;` in your project styles. - [see commit 08b1234](https://github.com/db-ux-design-system/core-web/commit/08b1234342e3c0d622116d528a979ff53d7e2356)
|
|
10
|
+
|
|
3
11
|
## 4.9.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
|
@@ -206,8 +214,7 @@ _version bump_
|
|
|
206
214
|
- fix(form elements): `valid` background- and border-colors - [see commit 8f07e55](https://github.com/db-ux-design-system/core-web/commit/8f07e55f2155fcb619198857397ce354f90c4803)
|
|
207
215
|
|
|
208
216
|
- fix: set DBTabItem internal state `_selected` correctly - [see commit f7625cb](https://github.com/db-ux-design-system/core-web/commit/f7625cbd9d64513527e826c9d2c1ef42b2734a4b):
|
|
209
|
-
|
|
210
|
-
- Now also sets aria-selected=true|false correctly which improves screen reader behaviour
|
|
217
|
+
- Now also sets aria-selected=true|false correctly which improves screen reader behaviour
|
|
211
218
|
|
|
212
219
|
## 4.2.1
|
|
213
220
|
|
package/README.md
CHANGED
|
@@ -6,49 +6,83 @@
|
|
|
6
6
|
[](https://makeapullrequest.com)
|
|
7
7
|
|
|
8
8
|
A React library containing all styles & components of [DB UX Design System (technical components)](https://github.com/db-ux-design-system/core-web).
|
|
9
|
-
|
|
10
|
-
> **Note:** Find more information about specific components [here](https://design-system.deutschebahn.com/core-web/review/main)
|
|
9
|
+
We also provide more information about specific components. This information is in our [Design System documentation](https://design-system.deutschebahn.com/documentation/get-started/).
|
|
11
10
|
|
|
12
11
|
## Install
|
|
13
12
|
|
|
14
13
|
```shell
|
|
15
|
-
|
|
14
|
+
pnpm add @db-ux/react-core-components @db-ux/core-components @db-ux/core-foundations --save-dev
|
|
16
15
|
```
|
|
17
16
|
|
|
18
|
-
> **Note:** This will install [`@db-ux/core-foundations`](https://www.npmjs.com/package/@db-ux/core-foundations) and [`@db-ux/core-components`](https://www.npmjs.com/package/@db-ux/core-components) as well which contains the `css`/`scss` files
|
|
19
|
-
|
|
20
17
|
## Styling Dependencies
|
|
21
18
|
|
|
22
|
-
|
|
19
|
+
### Vite Plugin
|
|
20
|
+
|
|
21
|
+
If you're using Vite, you can use the [`@db-ux/core-vite-plugin`](https://www.npmjs.com/package/@db-ux/core-vite-plugin) which simplifies the CSS setup to a single import.
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
pnpm add @db-ux/core-vite-plugin --save-dev
|
|
25
|
+
```
|
|
23
26
|
|
|
24
|
-
|
|
25
|
-
- Rollup (rollup): points to `@db-ux/core-foundations/assets`
|
|
26
|
-
- Webpack (webpack): points to `~@db-ux/core-foundations/assets`
|
|
27
|
+
Add the plugin to your `vite.config.ts`:
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
29
|
+
```ts
|
|
30
|
+
import { defineConfig } from "vite";
|
|
31
|
+
import dbUxPlugin from "@db-ux/core-vite-plugin";
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
@forward "@db-ux/core-foundations/build/styles/bundle"; // Semantic tokens
|
|
35
|
-
@forward "@db-ux/core-foundations/build/styles/icons/rollup"; // Icon fonts
|
|
36
|
-
@forward "@db-ux/core-components/build/styles/rollup"; // Component styling
|
|
33
|
+
export default defineConfig({
|
|
34
|
+
plugins: [dbUxPlugin()]
|
|
35
|
+
});
|
|
37
36
|
```
|
|
38
37
|
|
|
39
|
-
|
|
40
|
-
<details>
|
|
41
|
-
<summary><strong>CSS</strong></summary>
|
|
38
|
+
Then import the plugin in your CSS file:
|
|
42
39
|
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
import "@db-ux/core-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
40
|
+
```css
|
|
41
|
+
/* index.css */
|
|
42
|
+
@import "@db-ux/core-vite-plugin/index.css";
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
📖 **[Learn more about `@db-ux/core-vite-plugin` node package](https://www.npmjs.com/package/@db-ux/core-vite-plugin)**
|
|
46
|
+
|
|
47
|
+
### PostCSS Plugin (recommended)
|
|
48
|
+
|
|
49
|
+
We recommend using the [`@db-ux/core-postcss-plugin`](https://www.npmjs.com/package/@db-ux/core-postcss-plugin) to reduce your bundle size. It flattens CSS custom properties by resolving `var()`, `calc()`, `color-mix()`, and `light-dark()` at build time, removing unused declarations.
|
|
50
|
+
|
|
51
|
+
```shell
|
|
52
|
+
pnpm add @db-ux/core-postcss-plugin --save-dev
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Configure it in `vite.config.ts`:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { defineConfig } from "vite";
|
|
59
|
+
import { dbUxFlatten } from "@db-ux/core-postcss-plugin";
|
|
60
|
+
|
|
61
|
+
export default defineConfig({
|
|
62
|
+
css: {
|
|
63
|
+
transformer: "postcss", // required for Vite 8+ (default: 'lightningcss')
|
|
64
|
+
postcss: {
|
|
65
|
+
plugins: [dbUxFlatten()]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
});
|
|
49
69
|
```
|
|
50
70
|
|
|
51
|
-
|
|
71
|
+
📖 **[Learn more about `@db-ux/core-postcss-plugin` node package](https://www.npmjs.com/package/@db-ux/core-postcss-plugin)**
|
|
72
|
+
|
|
73
|
+
### Manual CSS Setup
|
|
74
|
+
|
|
75
|
+
If you're not using Vite or prefer manual setup, import the styles in your main CSS file:
|
|
76
|
+
|
|
77
|
+
```css
|
|
78
|
+
/* index.css */
|
|
79
|
+
@layer whitelabel-theme, db-ux;
|
|
80
|
+
/* You may want to include another theme here, this is a whitelabel theme! So instead of including the following line of code, please have a look at the DB Theme section */
|
|
81
|
+
@import "@db-ux/core-foundations/build/styles/theme/rollup.css"
|
|
82
|
+
layer(whitelabel-theme);
|
|
83
|
+
|
|
84
|
+
@import "@db-ux/core-components/build/styles/bundle.css" layer(db-ux);
|
|
85
|
+
```
|
|
52
86
|
|
|
53
87
|
### Vite 8
|
|
54
88
|
|
|
@@ -86,8 +120,6 @@ export default defineConfig({
|
|
|
86
120
|
});
|
|
87
121
|
```
|
|
88
122
|
|
|
89
|
-
> **Note:** The `@db-ux/core-components/build/styles/relative` file contains optional and all components styles. If you consider performance issues see [@db-ux/core-components](https://www.npmjs.com/package/@db-ux/core-components) for more information.
|
|
90
|
-
|
|
91
123
|
### Next 16
|
|
92
124
|
|
|
93
125
|
Starting with Next 16, the default CSS minifier was changed to [LightningCSS](https://lightningcss.dev/), which provides buggy transformations for modern CSS features used by the DB UX Design System (e.g. `light-dark()` CSS function). We might provide a specific configuration necessary to mitigate those problems in the near future. To keep CSS output stable in the meantime, configure `next.config.ts` like this:
|
|
@@ -116,10 +148,11 @@ In case that you're building a website or application for Deutsche Bahn, you'll
|
|
|
116
148
|
## Usage
|
|
117
149
|
|
|
118
150
|
```tsx
|
|
119
|
-
import { DBButton } from
|
|
120
|
-
|
|
121
|
-
<DBButton
|
|
122
|
-
|
|
151
|
+
import { DBButton } from "@db-ux/react-core-components";
|
|
152
|
+
|
|
153
|
+
<DBButton variant="brand" onClick={() => console.log("clicked")}>
|
|
154
|
+
Add item to cart
|
|
155
|
+
</DBButton>;
|
|
123
156
|
```
|
|
124
157
|
|
|
125
158
|
## AI Agent Support
|
|
@@ -136,7 +169,7 @@ npx @db-ux/agent-cli
|
|
|
136
169
|
|
|
137
170
|
This will create or update `.github/copilot-instructions.md` with component documentation based on your installed `@db-ux` packages, helping AI agents provide better suggestions.
|
|
138
171
|
|
|
139
|
-
📖 **[Learn more about `@db-ux/agent-cli` node package](
|
|
172
|
+
📖 **[Learn more about `@db-ux/agent-cli` node package](https://www.npmjs.com/package/@db-ux/agent-cli)**
|
|
140
173
|
|
|
141
174
|
## Code Quality
|
|
142
175
|
|
|
@@ -145,7 +178,7 @@ To enforce correct usage of DB UX Design System components in your React project
|
|
|
145
178
|
### Installation
|
|
146
179
|
|
|
147
180
|
```shell
|
|
148
|
-
|
|
181
|
+
pnpm add eslint @db-ux/core-eslint-plugin @typescript-eslint/parser --save-dev
|
|
149
182
|
```
|
|
150
183
|
|
|
151
184
|
### Setup
|
|
@@ -176,6 +209,35 @@ export default [
|
|
|
176
209
|
|
|
177
210
|
📖 **[Learn more about `@db-ux/core-eslint-plugin` node package](https://www.npmjs.com/package/@db-ux/core-eslint-plugin)**
|
|
178
211
|
|
|
212
|
+
## Stylelint
|
|
213
|
+
|
|
214
|
+
To validate correct usage of DB UX Design System tokens in your CSS/SCSS, use the [`@db-ux/core-stylelint`](https://www.npmjs.com/package/@db-ux/core-stylelint) plugin.
|
|
215
|
+
|
|
216
|
+
### Installation
|
|
217
|
+
|
|
218
|
+
```shell
|
|
219
|
+
pnpm add stylelint @db-ux/core-stylelint --save-dev
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Setup
|
|
223
|
+
|
|
224
|
+
Add to your `.stylelintrc.json`:
|
|
225
|
+
|
|
226
|
+
```json
|
|
227
|
+
{
|
|
228
|
+
"plugins": ["@db-ux/core-stylelint"],
|
|
229
|
+
"rules": {
|
|
230
|
+
"db-ux/use-spacings": [true],
|
|
231
|
+
"db-ux/use-sizing": [true],
|
|
232
|
+
"db-ux/use-border-width": [true],
|
|
233
|
+
"db-ux/use-border-radius": [true],
|
|
234
|
+
"db-ux/use-border-color": [true]
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
📖 **[Learn more about `@db-ux/core-stylelint` node package](https://www.npmjs.com/package/@db-ux/core-stylelint)**
|
|
240
|
+
|
|
179
241
|
## Deutsche Bahn brand
|
|
180
242
|
|
|
181
243
|
As we'd like to perfectly support our users and customers on their digital journey, the usage of Deutsche Bahn brand and trademarks are bound of clear guidelines and restrictions even if being used with the code that we're providing with this product; Deutsche Bahn fully reserves all rights regarding the Deutsche Bahn brand, even though that we're providing the code of DB UX Design System products free to use and release it under the Apache 2.0 license.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBAccordion: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("
|
|
2
|
+
declare const DBAccordion: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../index.js").GlobalProps | keyof import("./model.js").DBAccordionDefaultProps> & import("./model.js").DBAccordionDefaultProps & import("../../index.js").GlobalProps & React.RefAttributes<any>>;
|
|
3
3
|
export default DBAccordion;
|
|
@@ -1,88 +1,104 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
2
|
+
import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
|
|
3
|
+
import { cls as n } from "../../utils/index.js";
|
|
4
|
+
import r from "../accordion-item/accordion-item.js";
|
|
5
|
+
import { forwardRef as i, useEffect as a, useId as o, useRef as s, useState as c } from "react";
|
|
6
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
7
|
+
//#region src/components/accordion/accordion.tsx
|
|
8
|
+
function f(i, f) {
|
|
9
|
+
let p = o(), m = f || s(f), [h, g] = c(() => ""), [_, v] = c(() => !1), [y, b] = c(() => !1);
|
|
10
|
+
function x() {
|
|
11
|
+
try {
|
|
12
|
+
return typeof i.items == "string" ? JSON.parse(i.items) : i.items;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
console.error(e);
|
|
15
|
+
}
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
return a(() => {
|
|
19
|
+
v(!0), b(!0);
|
|
20
|
+
}, []), a(() => {
|
|
21
|
+
_ && m.current && (i.behavior === "single" ? i.name ? h !== i.name && g(i.name) : g(`accordion-${p}`) : g(""));
|
|
22
|
+
}, [
|
|
23
|
+
_,
|
|
24
|
+
i.name,
|
|
25
|
+
i.behavior
|
|
26
|
+
]), a(() => {
|
|
27
|
+
if (m.current) {
|
|
28
|
+
let e = m.current.getElementsByTagName("details");
|
|
29
|
+
if (e) for (let t of Array.from(e)) h === "" ? t.removeAttribute("name") : t.name = h ?? "";
|
|
30
|
+
}
|
|
31
|
+
}, [m.current, h]), a(() => {
|
|
32
|
+
if (m.current && y) {
|
|
33
|
+
if (i?.initOpenIndex && i.initOpenIndex.length > 0) {
|
|
34
|
+
let e = m.current.getElementsByTagName("details");
|
|
35
|
+
if (e) {
|
|
36
|
+
let t = i.behavior === "single" && i.initOpenIndex.length > 1 ? [i.initOpenIndex[0]] : i.initOpenIndex;
|
|
37
|
+
Array.from(e).forEach((e, n) => {
|
|
38
|
+
t?.includes(n) && (e.open = !0);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
b(!1);
|
|
43
|
+
}
|
|
44
|
+
}, [
|
|
45
|
+
m.current,
|
|
46
|
+
y,
|
|
47
|
+
i.initOpenIndex
|
|
48
|
+
]), /* @__PURE__ */ d("ul", {
|
|
49
|
+
ref: m,
|
|
50
|
+
...e(i, [
|
|
51
|
+
"data-icon-variant",
|
|
52
|
+
"data-icon-variant-before",
|
|
53
|
+
"data-icon-variant-after",
|
|
54
|
+
"data-icon-weight",
|
|
55
|
+
"data-icon-weight-before",
|
|
56
|
+
"data-icon-weight-after",
|
|
57
|
+
"data-interactive",
|
|
58
|
+
"data-force-mobile",
|
|
59
|
+
"data-color",
|
|
60
|
+
"data-container-color",
|
|
61
|
+
"data-bg-color",
|
|
62
|
+
"data-on-bg-color",
|
|
63
|
+
"data-color-scheme",
|
|
64
|
+
"data-font-size",
|
|
65
|
+
"data-headline-size",
|
|
66
|
+
"data-divider",
|
|
67
|
+
"data-focus",
|
|
68
|
+
"data-font",
|
|
69
|
+
"data-density"
|
|
70
|
+
]),
|
|
71
|
+
id: i.id ?? i.propOverrides?.id,
|
|
72
|
+
...t(i, [
|
|
73
|
+
"data-icon-variant",
|
|
74
|
+
"data-icon-variant-before",
|
|
75
|
+
"data-icon-variant-after",
|
|
76
|
+
"data-icon-weight",
|
|
77
|
+
"data-icon-weight-before",
|
|
78
|
+
"data-icon-weight-after",
|
|
79
|
+
"data-interactive",
|
|
80
|
+
"data-force-mobile",
|
|
81
|
+
"data-color",
|
|
82
|
+
"data-container-color",
|
|
83
|
+
"data-bg-color",
|
|
84
|
+
"data-on-bg-color",
|
|
85
|
+
"data-color-scheme",
|
|
86
|
+
"data-font-size",
|
|
87
|
+
"data-headline-size",
|
|
88
|
+
"data-divider",
|
|
89
|
+
"data-focus",
|
|
90
|
+
"data-font",
|
|
91
|
+
"data-density"
|
|
92
|
+
]),
|
|
93
|
+
className: n("db-accordion", i.className),
|
|
94
|
+
"data-variant": i.variant,
|
|
95
|
+
children: [i.items ? null : /* @__PURE__ */ u(l, { children: i.children }), i.items ? /* @__PURE__ */ u(l, { children: x()?.map((e, t) => /* @__PURE__ */ u(r, {
|
|
96
|
+
headlinePlain: e.headlinePlain,
|
|
97
|
+
disabled: e.disabled,
|
|
98
|
+
text: e.text
|
|
99
|
+
}, `accordion-item-${t}`)) }) : null]
|
|
100
|
+
});
|
|
86
101
|
}
|
|
87
|
-
|
|
88
|
-
|
|
102
|
+
var p = i(f);
|
|
103
|
+
//#endregion
|
|
104
|
+
export { p as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as DBAccordion } from './accordion';
|
|
1
|
+
export { default as DBAccordion } from './accordion.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GlobalProps, InitializedState } from '../../shared/model';
|
|
1
|
+
import type { GlobalProps, InitializedState } from '../../shared/model.js';
|
|
2
2
|
import type { DBAccordionItemDefaultProps } from '../accordion-item/model';
|
|
3
3
|
export declare const AccordionVariantList: readonly ["divider", "card"];
|
|
4
4
|
export type AccordionVariantType = (typeof AccordionVariantList)[number];
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/components/accordion/model.ts
|
|
2
|
+
var e = ["divider", "card"], t = ["multiple", "single"];
|
|
3
|
+
//#endregion
|
|
4
|
+
export { t as AccordionBehaviorList, e as AccordionVariantList };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBAccordionItem: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model").GlobalProps | "name" | "text" | "defaultOpen" | "disabled" | "headline" | "headlinePlain" | keyof import("../../shared/model").ToggleEventProps> & {
|
|
2
|
+
declare const DBAccordionItem: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../shared/model.js").GlobalProps | "name" | "text" | "defaultOpen" | "open" | "disabled" | "headline" | "headlinePlain" | keyof import("../../shared/model.js").ToggleEventProps> & {
|
|
3
3
|
defaultOpen?: boolean;
|
|
4
|
+
open?: boolean | string;
|
|
4
5
|
disabled?: boolean | string;
|
|
5
6
|
headline?: any;
|
|
6
7
|
headlinePlain?: string;
|
|
7
|
-
} & import("../../shared/model").TextProps & import("../../shared/model").GlobalProps & import("../../shared/model").ToggleEventProps & import("../../shared/model").NameProps & React.RefAttributes<any>>;
|
|
8
|
+
} & import("../../shared/model.js").TextProps & import("../../shared/model.js").GlobalProps & import("../../shared/model.js").ToggleEventProps & import("../../shared/model.js").NameProps & React.RefAttributes<any>>;
|
|
8
9
|
export default DBAccordionItem;
|
|
@@ -1,58 +1,91 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
2
|
+
import { filterPassingProps as e, getRootProps as t } from "../../utils/react.js";
|
|
3
|
+
import { cls as n, getBoolean as r, getBooleanAsString as i } from "../../utils/index.js";
|
|
4
|
+
import { forwardRef as a, useEffect as o, useRef as s, useState as c } from "react";
|
|
5
|
+
import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
|
+
//#region src/components/accordion-item/accordion-item.tsx
|
|
7
|
+
function f(a, f) {
|
|
8
|
+
let p = f || s(f), [m, h] = c(() => !1), [g, _] = c(() => void 0), [v, y] = c(() => !1);
|
|
9
|
+
function b() {
|
|
10
|
+
if (p.current) {
|
|
11
|
+
let e = p.current.setAttribute;
|
|
12
|
+
p.current.setAttribute = (t, n) => {
|
|
13
|
+
e.call(p.current, t, n), t === "name" && _(n);
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function x(e) {
|
|
18
|
+
e?.preventDefault();
|
|
19
|
+
let t = !m;
|
|
20
|
+
a.onToggle && a.onToggle(t), a.open === void 0 && h(t);
|
|
21
|
+
}
|
|
22
|
+
return o(() => {
|
|
23
|
+
a.defaultOpen && h(a.defaultOpen), y(!0);
|
|
24
|
+
}, []), o(() => {
|
|
25
|
+
p.current && v && b();
|
|
26
|
+
}, [p.current, v]), o(() => {
|
|
27
|
+
a.name && _(a.name);
|
|
28
|
+
}, [a.name]), o(() => {
|
|
29
|
+
let e = r(a.open, "open");
|
|
30
|
+
e !== void 0 && h(e);
|
|
31
|
+
}, [a.open]), /* @__PURE__ */ u("li", {
|
|
32
|
+
id: a.id ?? a.propOverrides?.id,
|
|
33
|
+
...t(a, [
|
|
34
|
+
"data-icon-variant",
|
|
35
|
+
"data-icon-variant-before",
|
|
36
|
+
"data-icon-variant-after",
|
|
37
|
+
"data-icon-weight",
|
|
38
|
+
"data-icon-weight-before",
|
|
39
|
+
"data-icon-weight-after",
|
|
40
|
+
"data-interactive",
|
|
41
|
+
"data-force-mobile",
|
|
42
|
+
"data-color",
|
|
43
|
+
"data-container-color",
|
|
44
|
+
"data-bg-color",
|
|
45
|
+
"data-on-bg-color",
|
|
46
|
+
"data-color-scheme",
|
|
47
|
+
"data-font-size",
|
|
48
|
+
"data-headline-size",
|
|
49
|
+
"data-divider",
|
|
50
|
+
"data-focus",
|
|
51
|
+
"data-font",
|
|
52
|
+
"data-density"
|
|
53
|
+
]),
|
|
54
|
+
className: n("db-accordion-item", a.className),
|
|
55
|
+
children: /* @__PURE__ */ d("details", {
|
|
56
|
+
"aria-disabled": i(a.disabled),
|
|
57
|
+
ref: p,
|
|
58
|
+
...e(a, [
|
|
59
|
+
"data-icon-variant",
|
|
60
|
+
"data-icon-variant-before",
|
|
61
|
+
"data-icon-variant-after",
|
|
62
|
+
"data-icon-weight",
|
|
63
|
+
"data-icon-weight-before",
|
|
64
|
+
"data-icon-weight-after",
|
|
65
|
+
"data-interactive",
|
|
66
|
+
"data-force-mobile",
|
|
67
|
+
"data-color",
|
|
68
|
+
"data-container-color",
|
|
69
|
+
"data-bg-color",
|
|
70
|
+
"data-on-bg-color",
|
|
71
|
+
"data-color-scheme",
|
|
72
|
+
"data-font-size",
|
|
73
|
+
"data-headline-size",
|
|
74
|
+
"data-divider",
|
|
75
|
+
"data-focus",
|
|
76
|
+
"data-font",
|
|
77
|
+
"data-density",
|
|
78
|
+
"onToggle"
|
|
79
|
+
]),
|
|
80
|
+
name: g,
|
|
81
|
+
open: m,
|
|
82
|
+
children: [/* @__PURE__ */ d("summary", {
|
|
83
|
+
onClick: (e) => x(e),
|
|
84
|
+
children: [a.headlinePlain ? /* @__PURE__ */ u(l, { children: a.headlinePlain }) : null, a.headlinePlain ? null : /* @__PURE__ */ u(l, { children: a.headline })]
|
|
85
|
+
}), /* @__PURE__ */ d("div", { children: [a.text ? /* @__PURE__ */ u(l, { children: a.text }) : null, a.children] })]
|
|
86
|
+
})
|
|
87
|
+
});
|
|
56
88
|
}
|
|
57
|
-
|
|
58
|
-
|
|
89
|
+
var p = a(f);
|
|
90
|
+
//#endregion
|
|
91
|
+
export { p as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as DBAccordionItem } from './accordion-item';
|
|
1
|
+
export { default as DBAccordionItem } from './accordion-item.js';
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { GlobalProps, InitializedState, NameProps, NameState, TextProps, ToggleEventProps, ToggleEventState } from '../../shared/model';
|
|
1
|
+
import type { GlobalProps, InitializedState, NameProps, NameState, TextProps, ToggleEventProps, ToggleEventState } from '../../shared/model.js';
|
|
2
2
|
export type DBAccordionItemDefaultProps = {
|
|
3
3
|
/**
|
|
4
4
|
* Initial state for the accordion item
|
|
5
5
|
*/
|
|
6
6
|
defaultOpen?: boolean;
|
|
7
|
+
/**
|
|
8
|
+
* State for the accordion item
|
|
9
|
+
*/
|
|
10
|
+
open?: boolean | string;
|
|
7
11
|
/**
|
|
8
12
|
* The disabled attribute can be set to keep a user from clicking on the element.
|
|
9
13
|
*/
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
declare const DBBadge: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("
|
|
2
|
+
declare const DBBadge: React.ForwardRefExoticComponent<Omit<React.HTMLAttributes<any>, keyof import("../../index.js").GlobalProps | "semantic" | "text" | keyof import("./model.js").DBBadgeDefaultProps | "size" | "emphasis" | "wrap"> & import("./model.js").DBBadgeDefaultProps & import("../../index.js").GlobalProps & import("../../index.js").SemanticProps & import("../../index.js").SizeProps & import("../../index.js").EmphasisProps & import("../../index.js").TextProps & import("../../index.js").WrapProps & React.RefAttributes<any>>;
|
|
3
3
|
export default DBBadge;
|