@cupra/ui-react 2.0.0-canary.6 → 2.0.0-canary.7
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 +121 -76
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
# UI React (React Components)
|
|
2
2
|
|
|
3
3
|
## Overview
|
|
4
|
+
|
|
4
5
|
React components and wrappers built on top of the DS-UI Web Components, providing a seamless and idiomatic developer experience for React.
|
|
5
6
|
This package exposes React-friendly APIs (props, JSX, typed events) while preserving the DS-UI theming, styling, and asset resolution model.
|
|
6
7
|
|
|
8
|
+
---
|
|
9
|
+
|
|
7
10
|
## Audience
|
|
11
|
+
|
|
8
12
|
Use `@cupra/ui-react` if your application is built with **React** and you want:
|
|
9
13
|
|
|
10
14
|
- First-class React ergonomics with DS-UI components
|
|
@@ -14,6 +18,8 @@ Use `@cupra/ui-react` if your application is built with **React** and you want:
|
|
|
14
18
|
|
|
15
19
|
If you need a **framework-agnostic** solution, consider `@cupra/ui-kit` (Web Components).
|
|
16
20
|
|
|
21
|
+
---
|
|
22
|
+
|
|
17
23
|
## Requirements & Compatibility
|
|
18
24
|
|
|
19
25
|
This library currently provides **official support for React 18**.
|
|
@@ -22,11 +28,13 @@ This library currently provides **official support for React 18**.
|
|
|
22
28
|
|
|
23
29
|
Projects using other React versions may still install and use the library, but behaviour is not guaranteed until official support is released.
|
|
24
30
|
|
|
25
|
-
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
## TypeScript and module resolution
|
|
26
34
|
|
|
27
35
|
This library is **bundler-first**.
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
### Subpath imports (recommended)
|
|
30
38
|
|
|
31
39
|
Importing components via subpaths (for example `@cupra/ui-react/Accordion`) requires
|
|
32
40
|
TypeScript to use **bundler-based module resolution**:
|
|
@@ -34,7 +42,7 @@ TypeScript to use **bundler-based module resolution**:
|
|
|
34
42
|
- **TypeScript ≥ 5**
|
|
35
43
|
- `"moduleResolution": "bundler"`
|
|
36
44
|
|
|
37
|
-
This matches how modern bundlers resolve modules and enables the best
|
|
45
|
+
This matches how modern bundlers resolve modules and enables the best developer experience,
|
|
38
46
|
including proper tree-shaking and code-splitting.
|
|
39
47
|
|
|
40
48
|
Minimal required `tsconfig.json` setting:
|
|
@@ -47,64 +55,89 @@ Minimal required `tsconfig.json` setting:
|
|
|
47
55
|
}
|
|
48
56
|
```
|
|
49
57
|
|
|
58
|
+
Other compiler options (`target`, `module`, `lib`, etc.) are project-specific and can be configured as needed.
|
|
59
|
+
|
|
50
60
|
---
|
|
51
61
|
|
|
52
|
-
|
|
62
|
+
### Root imports (compatibility mode)
|
|
53
63
|
|
|
54
|
-
If your project cannot use `moduleResolution: "bundler"`, you can still consume
|
|
55
|
-
the library using **root imports**:
|
|
64
|
+
If your project cannot use `moduleResolution: "bundler"`, you can still consume the library using **root imports**:
|
|
56
65
|
|
|
57
66
|
```
|
|
58
67
|
import { Accordion, IconButton } from "@cupra/ui-react";
|
|
59
68
|
```
|
|
60
69
|
|
|
61
|
-
This mode works with legacy or constrained TypeScript setups, but has the
|
|
62
|
-
following trade-offs:
|
|
70
|
+
This mode works with legacy or constrained TypeScript setups, but has the following trade-offs:
|
|
63
71
|
|
|
64
72
|
- Subpath imports are not available
|
|
65
73
|
- Reduced tree-shaking and chunking opportunities
|
|
66
74
|
- All components are imported from the package entry point
|
|
67
75
|
|
|
68
|
-
Root imports are supported as a fallback, but **subpath imports are recommended
|
|
69
|
-
whenever possible**.
|
|
76
|
+
Root imports are supported as a fallback, but **subpath imports are recommended whenever possible**.
|
|
70
77
|
|
|
71
78
|
---
|
|
72
79
|
|
|
73
|
-
|
|
80
|
+
### Notes
|
|
74
81
|
|
|
75
82
|
- Subpath imports are intentionally designed for bundler-based environments.
|
|
76
83
|
- The library does not attempt to enforce Node-style module resolution.
|
|
77
84
|
- No additional runtime configuration is required when using a modern bundler.
|
|
78
|
-
## Installation
|
|
79
85
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Getting started
|
|
89
|
+
|
|
90
|
+
### Installation
|
|
91
|
+
|
|
92
|
+
`@cupra/ui-react` is a React wrapper around the Web Components provided by
|
|
93
|
+
`@cupra/ui-kit`.
|
|
84
94
|
|
|
85
|
-
|
|
95
|
+
For this reason, **both packages must be installed** in your project.
|
|
86
96
|
|
|
87
|
-
|
|
97
|
+
Using npm:
|
|
88
98
|
|
|
89
|
-
```
|
|
90
|
-
@cupra
|
|
99
|
+
```
|
|
100
|
+
npm install @cupra/ui-react @cupra/ui-kit
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Using pnpm:
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
pnpm add @cupra/ui-react @cupra/ui-kit
|
|
91
107
|
```
|
|
92
108
|
|
|
93
|
-
|
|
109
|
+
Using yarn:
|
|
94
110
|
|
|
95
|
-
```yaml
|
|
96
|
-
npmScopes:
|
|
97
|
-
cupra:
|
|
98
|
-
npmRegistryServer: "https://registry.npmjs.org"
|
|
99
111
|
```
|
|
112
|
+
yarn add @cupra/ui-react @cupra/ui-kit
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
### About peer dependencies
|
|
118
|
+
|
|
119
|
+
`@cupra/ui-kit` is declared as a **peer dependency** of `@cupra/ui-react`.
|
|
120
|
+
|
|
121
|
+
This means:
|
|
122
|
+
|
|
123
|
+
- `@cupra/ui-react` does not bundle or ship the Web Components itself
|
|
124
|
+
- the consuming project must provide a compatible version of `@cupra/ui-kit`
|
|
125
|
+
- only a single instance of the design system is expected at runtime
|
|
126
|
+
|
|
127
|
+
Some package managers (such as npm ≥ 7 or pnpm with compatible settings) may install
|
|
128
|
+
peer dependencies automatically. Others (such as Yarn) require installing them explicitly.
|
|
129
|
+
|
|
130
|
+
If you encounter missing-module or runtime errors after installing `@cupra/ui-react`,
|
|
131
|
+
make sure that `@cupra/ui-kit` is also installed in your project.
|
|
100
132
|
|
|
101
133
|
---
|
|
102
134
|
|
|
103
135
|
## Documentation & Live Playground
|
|
104
136
|
|
|
105
|
-
You can explore all `ui-react`
|
|
137
|
+
You can explore all `ui-react` components, their APIs, theming options and live examples
|
|
138
|
+
in the online documentation and playground:
|
|
106
139
|
|
|
107
|
-
|
|
140
|
+
https://diagonal.cupra.com/ui-react/index.html
|
|
108
141
|
|
|
109
142
|
---
|
|
110
143
|
|
|
@@ -112,7 +145,8 @@ You can explore all `ui-react` Components, their APIs, theming options and live
|
|
|
112
145
|
|
|
113
146
|
This package is distributed through npm using **two release channels**.
|
|
114
147
|
|
|
115
|
-
### Stable
|
|
148
|
+
### Stable releases (`latest`)
|
|
149
|
+
|
|
116
150
|
Production-ready versions:
|
|
117
151
|
|
|
118
152
|
- Follow Semantic Versioning
|
|
@@ -121,19 +155,20 @@ Production-ready versions:
|
|
|
121
155
|
|
|
122
156
|
Install:
|
|
123
157
|
|
|
124
|
-
```
|
|
125
|
-
npm install @cupra/ui-react
|
|
158
|
+
```
|
|
159
|
+
npm install @cupra/ui-react
|
|
126
160
|
```
|
|
127
161
|
|
|
128
162
|
Specific version:
|
|
129
163
|
|
|
130
|
-
```
|
|
131
|
-
npm install @cupra/ui-react@0.1.3
|
|
164
|
+
```
|
|
165
|
+
npm install @cupra/ui-react@0.1.3
|
|
132
166
|
```
|
|
133
167
|
|
|
134
168
|
---
|
|
135
169
|
|
|
136
|
-
### Canary
|
|
170
|
+
### Canary releases (`canary`)
|
|
171
|
+
|
|
137
172
|
Early-access versions published after each merge into `main`.
|
|
138
173
|
|
|
139
174
|
Use canary releases if you:
|
|
@@ -144,89 +179,99 @@ Use canary releases if you:
|
|
|
144
179
|
|
|
145
180
|
Latest canary:
|
|
146
181
|
|
|
147
|
-
```
|
|
148
|
-
npm install @cupra/ui-react@canary
|
|
182
|
+
```
|
|
183
|
+
npm install @cupra/ui-react@canary
|
|
149
184
|
```
|
|
150
185
|
|
|
151
186
|
Specific canary version:
|
|
152
187
|
|
|
153
|
-
```
|
|
154
|
-
npm install @cupra/ui-react@0.1.4-canary.2
|
|
188
|
+
```
|
|
189
|
+
npm install @cupra/ui-react@0.1.4-canary.2
|
|
155
190
|
```
|
|
156
191
|
|
|
157
192
|
---
|
|
158
193
|
|
|
159
194
|
## Recommended usage
|
|
160
195
|
|
|
161
|
-
- **Production:** use **stable versions (
|
|
162
|
-
- **Internal testing / preview:** use
|
|
163
|
-
|
|
164
|
-
```bash
|
|
165
|
-
npm install @cupra/ui-react@0.1.4-canary.2
|
|
166
|
-
```
|
|
196
|
+
- **Production:** use **stable versions** (for example `@cupra/ui-react@1.1.3`)
|
|
197
|
+
- **Internal testing / preview:** use **canary** versions
|
|
167
198
|
|
|
168
199
|
---
|
|
169
200
|
|
|
170
201
|
## Usage
|
|
171
202
|
|
|
172
|
-
|
|
173
|
-
|
|
203
|
+
When possible, import components via subpaths:
|
|
204
|
+
|
|
205
|
+
```
|
|
206
|
+
import { Button } from "@cupra/ui-react/Button";
|
|
207
|
+
```
|
|
174
208
|
|
|
175
|
-
If
|
|
209
|
+
If your TypeScript setup does not support bundler-based module resolution, use root imports instead:
|
|
210
|
+
|
|
211
|
+
```
|
|
212
|
+
import { Button } from "@cupra/ui-react";
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
Wrap your React application with `ThemeProvider`.
|
|
176
216
|
|
|
177
|
-
Wrap your React app with `ThemeProvider`.
|
|
178
217
|
The provider requires **three props**:
|
|
179
218
|
|
|
180
|
-
| Prop
|
|
181
|
-
|
|
182
|
-
| `theme`
|
|
183
|
-
| `loadFonts` | boolean | Yes
|
|
184
|
-
| `loadStyles
|
|
219
|
+
| Prop | Type | Required | Description |
|
|
220
|
+
|-------------|---------|----------|-----------------------------------------------|
|
|
221
|
+
| `theme` | string | Yes | Visual theme identifier (e.g. cupra-diagonal) |
|
|
222
|
+
| `loadFonts` | boolean | Yes | Auto-load DS-UI font files |
|
|
223
|
+
| `loadStyles`| boolean | Yes | Auto-load DS-UI CSS |
|
|
185
224
|
|
|
186
|
-
If `loadFonts` or `loadStyles` are `false`, you must manually include `<link>` tags
|
|
225
|
+
If `loadFonts` or `loadStyles` are `false`, you must manually include the corresponding `<link>` tags.
|
|
187
226
|
|
|
188
227
|
### Option A — Manual CSS and font links
|
|
189
228
|
|
|
190
|
-
```
|
|
191
|
-
import { ThemeProvider } from
|
|
192
|
-
import { Button } from
|
|
193
|
-
import { Icon } from
|
|
229
|
+
```
|
|
230
|
+
import { ThemeProvider } from "@cupra/ui-react/ThemeProvider";
|
|
231
|
+
import { Button } from "@cupra/ui-react/Button";
|
|
232
|
+
import { Icon } from "@cupra/ui-react/Icon";
|
|
194
233
|
|
|
195
|
-
export function App() {
|
|
196
|
-
|
|
234
|
+
export function App() {
|
|
235
|
+
return (
|
|
197
236
|
<>
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
</
|
|
237
|
+
<link rel="preload" as="style" href="https://ds-assets.cupra.com/[version]/styles/cupra/theme.css" />
|
|
238
|
+
<link rel="stylesheet" href="https://ds-assets.cupra.com/[version]/styles/cupra/theme.css" />
|
|
239
|
+
<ThemeProvider theme="cupra-diagonal" loadFonts={false} loadStyles={false}>
|
|
240
|
+
<Button variant="destructive" icon-name="filters-background">
|
|
241
|
+
Click me
|
|
242
|
+
</Button>
|
|
243
|
+
<Icon icon-name="filters-background" />
|
|
244
|
+
</ThemeProvider>
|
|
204
245
|
</>
|
|
205
|
-
|
|
206
|
-
}
|
|
246
|
+
);
|
|
247
|
+
}
|
|
207
248
|
```
|
|
208
249
|
|
|
209
250
|
### Option B — Provider loads assets automatically
|
|
210
251
|
|
|
211
|
-
```
|
|
212
|
-
import { ThemeProvider } from
|
|
213
|
-
import { Button } from
|
|
252
|
+
```
|
|
253
|
+
import { ThemeProvider } from "@cupra/ui-react/ThemeProvider";
|
|
254
|
+
import { Button } from "@cupra/ui-react/Button";
|
|
214
255
|
|
|
215
|
-
export function App() {
|
|
216
|
-
|
|
256
|
+
export function App() {
|
|
257
|
+
return (
|
|
217
258
|
<ThemeProvider theme="cupra-diagonal" loadFonts={true} loadStyles={true}>
|
|
218
|
-
|
|
259
|
+
<Button variant="primary">Button</Button>
|
|
219
260
|
</ThemeProvider>
|
|
220
|
-
|
|
221
|
-
}
|
|
261
|
+
);
|
|
262
|
+
}
|
|
222
263
|
```
|
|
223
264
|
|
|
224
265
|
---
|
|
225
266
|
|
|
226
267
|
## License
|
|
227
|
-
|
|
268
|
+
|
|
269
|
+
SEAT S.A. Library EULA 1.0
|
|
228
270
|
See `LICENSE.md` in this package for the full text.
|
|
229
271
|
Third-party attributions may appear in `THIRD_PARTY_LICENSES.md`.
|
|
230
272
|
|
|
273
|
+
---
|
|
274
|
+
|
|
231
275
|
## Support
|
|
276
|
+
|
|
232
277
|
For help and support, contact: **ds.support@seat.es**
|