@cupra/ui-kit 0.2.0-canary.0 → 1.0.0-canary.2

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 CHANGED
@@ -1,861 +1,172 @@
1
1
  # UI Kit (Web Components)
2
2
 
3
3
  ## Overview
4
- Core Web Components for the DS-UI design system, built with Lit and TypeScript.
4
+ Core Web Components for the DS-UI design system, implemented with Lit and TypeScript.
5
+ This package is framework-agnostic and can be consumed from any modern frontend stack, either via npm or directly from the CDN.
5
6
 
6
7
  ## Audience
7
- Developers who want to use DS-UI as native Web Components in any web framework or plain HTML/JS.
8
+ Use `@cupra/ui-kit` if you want the **smallest, most portable** way to adopt DS-UI across frameworks:
8
9
 
9
- ## Installation
10
- - npm: `npm install @cupra/ui-kit`
11
- - pnpm: `pnpm add @cupra/ui-kit`
12
- - yarn: `yarn add @cupra/ui-kit`
13
-
14
- Access to the @cupra registry is required (see Requirements).
15
-
16
- ## Usage
17
- 1) Load the theme CSS for your chosen theme (e.g., cupra) or use the theme provider.
18
- 2) Wrap components with `<ds-theme-provider theme="cupra">`.
19
-
20
- Example (snippet):
21
- ```html
22
- <link rel="stylesheet" href="https://ds-assets.cupra.com/[version]/styles/cupra/theme.css">
23
- <ds-theme-provider theme="cupra">
24
- <ds-button variant="destructive">Hello</ds-button>
25
- </ds-theme-provider>
26
- ```
27
-
28
- ## Requirements
29
- - Node.js per .nvmrc
30
- - pnpm 9.4.0 or compatible
31
- - Access to GitHub Packages for @cupra (configure .npmrc or .yarnrc.yml with your token)
32
-
33
- ## Versioning
34
- This package follows semantic versioning. See repository releases for changes.
10
+ - Works with any environment (React, Vue, Svelte, Angular, plain JS, HTML).
11
+ - Provides encapsulation through Shadow DOM.
12
+ - Gives full control over when and how assets (CSS, fonts, icons) load.
35
13
 
36
- ## License
37
- License: SEAT S.A. Library EULA 1.0
38
- See LICENSE.md in this package for the full text. Third-party license attributions (if any) may be provided in THIRD_PARTY_LICENSES.md.
39
-
40
- ## Support
41
- Please open issues in the repository issue tracker.
14
+ If your application is **React-only**, and you prefer idiomatic React props & JSX, use `@cupra/ui-react` instead.
42
15
 
43
16
  ## Installation
44
17
 
45
- <details><summary>View installation instructions</summary>
46
-
47
- ### Using npm
48
-
49
- Run the following command to install the library:
50
-
51
- ```bash
52
- npm install @cupra/ui-kit
53
- ```
54
-
55
- ### Using pnpm
56
-
57
- If you're using **pnpm**, install the library with:
58
-
59
- ```bash
60
- pnpm add @cupra/ui-kit
61
- ```
18
+ ### Install the package
19
+ - npm: `npm install @cupra/ui-kit`
20
+ - pnpm: `pnpm add @cupra/ui-kit`
21
+ - yarn: `yarn add @cupra/ui-kit`
62
22
 
63
- ### Using yarn
23
+ ### Registry configuration (only if needed)
64
24
 
65
- To install the library with **yarn**, use:
25
+ **.npmrc**
66
26
 
67
- ```bash
68
- yarn add @cupra/ui-kit
27
+ ```ini
28
+ @cupra:registry=https://registry.npmjs.org
69
29
  ```
70
30
 
71
- ### .NPMRC
72
- >[!Important]
73
- >To be able to install the **ui-kit** library in your project you need access to the **@cupra**. To solve this, you need to have a **.npmrc** file if you are using **npm** or **pnpm** with a code similar to this:
74
- ```code
75
- @cupra:registry=https://npm.pkg.github.com
76
- //npm.pkg.github.com/:_authToken=<your_github_token>
77
- always-auth=true
78
- ```
31
+ **.yarnrc.yml**
79
32
 
80
- ### .YARNRC.YML
81
- >[!Important]
82
- >To be able to install the **ui-kit** library in your project you need access to the **@cupra**. To solve this, you need to have a **.yarnrc.yml** file if you are using **yarn** with a code similar to this:
83
- ```code
33
+ ```yaml
84
34
  npmScopes:
85
- seatcode:
86
- npmRegistryServer: "https://npm.pkg.github.com"
87
- npmAuthToken: "your_github_token"
35
+ cupra:
36
+ npmRegistryServer: "https://registry.npmjs.org"
88
37
  ```
89
- </details>
90
-
91
- ## Component usage
92
38
 
93
- <details><summary>View usage instructions</summary>
94
-
95
- ### Web Components
39
+ ---
96
40
 
97
- To use the components directly on an HTML page, ensure that the bundle and theme are loaded correctly as shown below. Wrap your components within the `<ds-theme-provider>` component to provide the necessary theme context.
41
+ ## Documentation & Live Playground
98
42
 
99
- #### Loading the Bundle
43
+ You can explore all `ui-kit` Web Components, their APIs, theming options and live examples in the online documentation and playground:
100
44
 
101
- The bundle for the components can be loaded directly from the CDN by using the following script:
45
+ [https://diagonal.cupra.com/ui-kit/index.html](https://diagonal.cupra.com/ui-kit/index.html)
102
46
 
103
- ```html
104
- <script src='https://ds-assets.cupra.com/[version]/dist/index.iife.js'></script>
105
- ```
47
+ ---
106
48
 
107
- - **[version]**: Specify the exact version of the library, such as `1.0`, `1.1.1`, or `2.0`. Wildcards like `1.x` or `1.*` are not supported.
49
+ ## Versioning and Release Channels
108
50
 
109
- Example:
51
+ This package is published to npm under **two channels**: `latest` (stable) and `canary` (early access).
110
52
 
111
- ```html
112
- <script src='https://ds-assets.cupra.com/1.0.3/dist/index.iife.js'></script>
113
- ```
53
+ ### Stable Releases (`latest`)
54
+ These versions represent production-ready builds:
114
55
 
115
- #### Loading the CSS
56
+ - Follow Semantic Versioning
57
+ - Include validated and approved changes
58
+ - Recommended for all production usage
116
59
 
117
- You can load the CSS directly with a `<link>`, which is the most performant option. Specify the theme and version in the URL:
60
+ Install latest stable:
118
61
 
119
- ```html
120
- <link rel='stylesheet' href='https://ds-assets.cupra.com/[version]/styles/[theme]/theme.css'>
62
+ ```bash
63
+ npm install @cupra/ui-kit
121
64
  ```
122
65
 
123
- - **[theme]**: Specify the theme name (e.g., `cupra`).
124
- - **[version]**: Use the fixed version, such as `1.0`, `1.1.1`, etc.
66
+ Specific stable version:
125
67
 
126
- > **Note**: Even when loading the CSS with a `<link>` for better performance, it is still necessary to use the `<ds-theme-provider>` component. This component provides a theme context with the `theme` attribute (e.g., `theme="cupra"`), which is required for certain components, such as `<ds-icon>`, to function correctly.
127
-
128
- Example:
129
-
130
- ```html
131
- <ds-theme-provider theme="cupra">
132
- <ds-button variant="destructive" icon-name="filters-background">Hello</ds-button>
133
- <ds-icon icon-name="filters-background"></ds-icon>
134
- <ds-modal open="false">
135
- <p slot="content">Hello</p>
136
- </ds-modal>
137
- <ds-tag icon-name="magnifying-glass">Hello</ds-tag>
138
- <ds-input type="date" label="Hello"></ds-input>
139
- </ds-theme-provider>
68
+ ```bash
69
+ npm install @cupra/ui-kit@0.1.3
140
70
  ```
141
- </details>
142
-
143
- ## Web Components
144
-
145
- <details><summary>View web components documentation</summary>
146
-
147
- Here is the documentation for the [Web Components](https://github.com/seatcode/ds-ui/blob/main/packages/ui-kit/web-components.md).
148
-
149
- >[!NOTE]
150
- >For more information you can access our [Storybook](https://65c4ab0114027d1f28fa89a1-uzhfdyxnjn.chromatic.com/), where you will find detailed documentation and interactive examples for each component, making it easier to use and understand them. Feel free to ask us for [Storybook](https://65c4ab0114027d1f28fa89a1-uzhfdyxnjn.chromatic.com/) **access permissions** or consult us any question about a component implementation.
151
- </details>
152
-
153
- ## Fonts
154
-
155
- <details><summary>View font information</summary>
156
-
157
- The font family is 'cupra-screen'. The following are the CSS tokens that should be used in your project:
158
-
159
- - `--ds-cp-type-display-[weight]`
160
- - `--ds-cp-type-headline-[weight]`
161
- - `--ds-cp-type-title1-[weight]`
162
- - `--ds-cp-type-title2-[weight]`
163
- - `--ds-cp-type-title3-[weight]`
164
- - `--ds-cp-type-title4-[weight]`
165
- - `--ds-cp-type-title5-[weight]`
166
- - `--ds-cp-type-title6-[weight]`
167
- - `--ds-cp-type-quote-[weight]`
168
- - `--ds-cp-type-lead-[weight]`
169
- - `--ds-cp-type-body-[weight]`
170
- - `--ds-cp-type-bodytight-[weight]`
171
- - `--ds-cp-type-small-[weight]`
172
- - `--ds-cp-type-smalltight-[weight]`
173
- - `--ds-cp-type-tiny-[weight]`
174
- - `--ds-cp-type-micro-[weight]`
175
-
176
- Where `[weight]` can be `book`, `regular`, or `medium`. The properties (size, line height, etc.) are automatically adapted based on the viewport.
177
- </details>
178
-
179
- ## Scroll
180
-
181
- <details><summary>View scroll customization</summary>
182
-
183
- ### `.ds-scroll` Class
184
- This class is used to customize the appearance of scrollbars in your web application. Applying `.ds-scroll` will give the scrollbar a modern and consistent look that aligns with the DS-UI.
185
-
186
- ### `.ds-scroll-global` Class
187
- This class extends the customization of scrollbars to **all** elements within the container. By using `.ds-scroll-global`, you ensure that every scrollable area within a specified section shares the same scrollbar styling for a unified user experience.
188
-
189
- ---
190
-
191
- ### Using Dark Mode with `.ds-mode-dark`
192
- > **Note:** This section only applies to themes that support dark mode.
193
-
194
- To activate dark mode for scrollbars, add the `.ds-mode-dark` class in combination with either `.ds-scroll` or `.ds-scroll-global`. This switches the scrollbar styling to a darker palette, suitable for dark-themed interfaces.
195
71
 
196
72
  ---
197
73
 
198
- ### Using Size with `.ds-scroll--size-[size]`
199
- > **Note:** This section only applies to themes that support size.
74
+ ### Canary Releases (`canary`)
75
+ Canary versions include the **most recent changes merged into `main`**.
200
76
 
201
- E.g. To activate 'S' forced size you must use `.ds-scroll--size-s` class in combination with either `.ds-scroll` or `.ds-scroll-global`.
77
+ Choose a canary version if you:
202
78
 
203
- ---
79
+ - Want early access to upcoming features
80
+ - Are testing the next stable release
81
+ - Accept small instability or rapid iteration
204
82
 
205
- ### Usage Example
206
- ```html
207
- <!-- For light mode -->
208
- <div class="ds-scroll">
209
- <!-- Content that requires scrolling -->
210
- </div>
211
-
212
- <!-- For dark mode (only if the theme supports it) -->
213
- <div class="ds-scroll ds-mode-dark">
214
- <!-- Content that requires scrolling -->
215
- </div>
216
-
217
- <!-- For size medium (only if the theme supports it) -->
218
- <div class="ds-scroll ds-scroll--size-m">
219
- <!-- Content that requires scrolling -->
220
- </div>
221
-
222
- <!-- Applying global scroll -->
223
- <div class="ds-scroll-global">
224
- <!-- Content (including children) that requires scrolling -->
225
- </div>
226
-
227
- <!-- Applying global scroll in dark mode (only if the theme supports it) -->
228
- <body class="ds-scroll-global ds-mode-dark">
229
- <!-- Content (including children) that requires scrolling -->
230
- </body>
231
-
232
- <!-- Applying global scroll and size medium (only if the theme supports it) -->
233
- <div class="ds-scroll-global ds-scroll--size-m">
234
- <!-- Content that requires scrolling -->
235
- </div>
83
+ Install latest canary:
236
84
 
85
+ ```bash
86
+ npm install @cupra/ui-kit@canary
237
87
  ```
238
- </details>
239
-
240
- ## Gradients
241
-
242
- <details><summary>View gradient classes</summary>
243
-
244
- ### `.ds-gradient-default` Class
245
- This class applies a subtle white-to-transparent gradient, ideal for sections requiring a light-themed overlay. It transitions from transparent at the top to solid white at the bottom, using the `--ds-color-white` variable.
246
88
 
247
- ### `.ds-gradient-inverted` Class
248
- This class creates a dark gradient transitioning from transparent to solid black at the bottom. It is suitable for dark-themed overlays, leveraging the `--ds-color-black` variable.
89
+ Specific canary version:
249
90
 
250
- ### `.ds-gradient-soft` Class
251
- The `.ds-gradient-soft` class provides a soft grey gradient that fades from transparent to `--ds-color-grey-15`. It is perfect for neutral or subtle styling.
252
-
253
- ### `.ds-gradient-grey` Class
254
- This class offers a slightly more pronounced grey gradient, transitioning from transparent to `--ds-color-grey-50`. Use it for elements requiring a moderate grey tone.
255
-
256
- ### `.ds-gradient-muffled` Class
257
- The `.ds-gradient-muffled` class applies a gradient that fades from transparent to `--ds-cp-color-back-muffled-default`. It is ideal for muted or desaturated color themes.
258
-
259
- ### `.ds-gradient-dark-inverted` Class
260
- This gradient transitions from transparent to a soft grey (`--ds-color-grey-15`), offering a light-grey inverted effect for darker themes.
261
-
262
- ### Usage Example
263
- ```html
264
- <!-- Default gradient -->
265
- <div class="ds-gradient-default">
266
- <!-- Content -->
267
- </div>
268
-
269
- <!-- Inverted gradient -->
270
- <div class="ds-gradient-inverted">
271
- <!-- Content -->
272
- </div>
273
-
274
- <!-- Soft grey gradient -->
275
- <div class="ds-gradient-soft">
276
- <!-- Content -->
277
- </div>
278
-
279
- <!-- Pronounced grey gradient -->
280
- <div class="ds-gradient-grey">
281
- <!-- Content -->
282
- </div>
283
-
284
- <!-- Muffled gradient -->
285
- <div class="ds-gradient-muffled">
286
- <!-- Content -->
287
- </div>
288
-
289
- <!-- Dark inverted gradient -->
290
- <div class="ds-gradient-dark-inverted">
291
- <!-- Content -->
292
- </div>
91
+ ```bash
92
+ npm install @cupra/ui-kit@0.1.4-canary.2
293
93
  ```
294
- </details>
295
94
 
296
- ## Slider component
95
+ ### Recommended usage
96
+ - **Production:** always use **stable (`latest`)**
97
+ - **Testing upcoming features:** use the **canary channel**
98
+ - **Deterministic builds:** pin exact versions (stable or canary)
297
99
 
298
- <details><summary>View slider component documentation</summary>
299
-
300
- This component provides a customizable slider for selecting values within a specified range. It supports single-value and range sliders with extensive formatting options.
301
-
302
- ### Attributes
303
-
304
- #### Basic Attributes
305
- | Attribute | Type | Default | Description |
306
- |-------------------------|--------------------|-----------|-----------------------------------------------|
307
- | `min` | `number` | `0` | Minimum value for the slider. |
308
- | `max` | `number` | `100` | Maximum value for the slider. |
309
- | `step` | `number` | `1` | Step size for the slider. |
310
- | `initial-value-min` | `number` | `0` | Initial value for the first thumb. |
311
- | `initial-value-max` | `number` | | Initial value for the second thumb (optional, for range sliders). |
312
-
313
- #### Internationalization (Intl) Attributes
314
-
315
- These attributes are directly tied to the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API and are used to format numbers according to locale and style.
316
-
317
- | Attribute | Type | Default | Description |
318
- |---------------------------|--------------------|-------------|--------------------------------------------------|
319
- | `locale` | `string` | `undefined` | Locale for formatting values (e.g., `en-US`, `es-ES`). |
320
- | `locale-matcher` | `"lookup"` \| `"best fit"` | `"lookup"` | Algorithm to match locales. |
321
- | `unit-style` | `"decimal"` \| `"currency"` \| `"percent"` \| `"unit"` | | Style for formatting the unit (e.g., percentages, currency). |
322
- | `currency` | `string` | | Currency for formatting values (e.g., `USD`, `EUR`). |
323
- | `unit` | `string` | | Unit of measurement for formatting values (e.g., `kilometer`). |
324
- | `minimum-integer-digits` | `number` | `1` | Minimum number of integer digits to display. |
325
- | `minimum-fraction-digits` | `number` | `0` | Minimum number of fractional digits to display. |
326
- | `maximum-fraction-digits` | `number` | `3` | Maximum number of fractional digits to display. |
327
-
328
- #### Component-Specific ("Manual") Attributes
329
-
330
- These attributes extend the functionality of the standard `Intl` API by introducing additional formatting or display options.
331
-
332
- | Attribute | Type | Default | Description |
333
- |---------------------------|--------------------|-----------------|--------------------------------------------------|
334
- | `unit-symbol` | `string` | | Custom symbol to display alongside values (e.g., "km", "°C"). |
335
- | `unit-symbol-position` | `"left"` \| `"right"` | `"right"` | Position of the custom unit symbol. |
336
- | `thousand-separator` | `string` | | Character used to separate thousands. Overrides Intl's formatting. |
337
- | `fraction-separator` | `string` | | Character used to separate fractional parts. Overrides Intl's formatting. |
338
-
339
- #### Styling Attributes
340
- | Attribute | Type | Default | Description |
341
- |------------|--------------|-----------|----------------------------------------------|
342
- | `mode` | `"dark"` \| `"light"` | `"light"` | Visual mode for the slider. |
343
-
344
- ---
345
-
346
- ### How It Works
347
-
348
- Internally, `<ds-slider>` uses the [Intl](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl) API to handle number formatting via a helper named `formatNumber`. Component attributes like `locale`, `currency`, `unit`, and `unit-style` are passed directly to `Intl.NumberFormat`.
349
-
350
- - Intl options drive the core formatting (grouping, decimals, symbol availability and position):
351
- - `unit-style="currency"` with `currency` uses the locale’s currency symbol and spacing.
352
- - `unit-style="percent"` uses the locale’s percent sign and placement.
353
- - `unit-style="unit"` with `unit` uses the locale’s unit label/symbol and placement.
354
- - `minimum-/maximum-fraction-digits` control decimal precision; `minimum-integer-digits` controls integer padding.
355
- - `formatNumber` also returns `unitSymbol` and `unitSymbolPosition` (left/right) when the chosen style implies a symbol (currency/percent/unit).
356
- - Component props `unit-symbol` and `unit-symbol-position` override the Intl‑provided symbol and position. If you don’t set them, the Intl-derived ones will be used when available.
357
- - `thousand-separator` and `fraction-separator` override the group and decimal separators in the final output string (they don’t affect rounding).
358
-
359
- #### Formatting guide (quick reference)
360
- - Currency (managed by Intl): set `unit-style="currency"` and a `currency` code; do not set `unit-symbol`.
361
- - Percent (managed by Intl): set `unit-style="percent"`; no custom symbol needed.
362
- - Unit (managed by Intl): set `unit-style="unit"` and `unit` (e.g., `kilometer`); optionally override with `unit-symbol` like `"km"` and your preferred `unit-symbol-position`.
363
- - Custom symbol (manual): leave `unit-style` unset or `decimal`, set `unit-symbol` (e.g., `"°C"`), and choose `unit-symbol-position`.
364
-
365
- ---
366
-
367
- ### Slots
368
- This component does not have slots.
100
+ ```bash
101
+ npm install @cupra/ui-kit@0.1.4-canary.2
102
+ ```
369
103
 
370
104
  ---
371
105
 
372
- ### Events
373
-
374
- | Event | Description | Detail |
375
- |----------|---------------------------------------|-----------------|
376
- | `change` | Fired when the slider value changes. | `{ targetId, value }` |
106
+ ## Usage
107
+ How to consume the package, either through the CDN or your application build.
377
108
 
378
109
  ---
379
110
 
380
- ### Examples
381
-
382
- #### Single Value Slider
111
+ ### Option A — CDN in plain HTML
112
+ 1) Load the DS-UI Web Components bundle:
383
113
 
384
114
  ```html
385
- <ds-slider
386
- min="0"
387
- max="100"
388
- step="1"
389
- initial-value-min="50"
390
- ></ds-slider>
115
+ <script src="https://ds-assets.cupra.com/[version]/dist/index.iife.js"></script>
391
116
  ```
392
117
 
393
- #### Range Slider
118
+ 2) Load the theme CSS (link preferred for performance):
394
119
 
395
120
  ```html
396
- <ds-slider
397
- min="0"
398
- max="1000"
399
- step="50"
400
- initial-value-min="100"
401
- initial-value-max="500"
402
- ></ds-slider>
121
+ <link rel="stylesheet" href="https://ds-assets.cupra.com/[version]/styles/[theme]/theme.css" />
403
122
  ```
404
123
 
405
- #### Currency Slider (Intl)
124
+ 3) Wrap your UI with the theme provider.
125
+ `load-fonts` and `load-styles` control whether the provider loads assets automatically.
406
126
 
407
127
  ```html
408
- <ds-slider
409
- min="0"
410
- max="1000"
411
- step="100"
412
- initial-value-min="200"
413
- locale="en-US"
414
- unit-style="currency"
415
- currency="USD"
416
- ></ds-slider>
417
- ```
418
-
419
- #### Custom Symbol Slider
420
-
421
- ```html
422
- <ds-slider
423
- min="0"
424
- max="100"
425
- step="5"
426
- initial-value-min="20"
427
- unit-symbol="°C"
428
- unit-symbol-position="right"
429
- ></ds-slider>
430
- ```
431
-
432
- #### Percent Slider (Intl)
433
-
434
- ```html
435
- <ds-slider
436
- min="0"
437
- max="1"
438
- step="0.1"
439
- initial-value-min="0.25"
440
- locale="en-US"
441
- unit-style="percent"
442
- ></ds-slider>
443
- ```
444
-
445
- #### Unit Slider (Intl with optional override)
446
-
447
- ```html
448
- <ds-slider
449
- min="0"
450
- max="2000"
451
- step="100"
452
- initial-value-min="1200"
453
- locale="en-GB"
454
- unit-style="unit"
455
- unit="kilometer"
456
- >
457
- </ds-slider>
128
+ <ds-theme-provider theme="cupra" load-fonts="true" load-styles="true">
129
+ <ds-button variant="destructive" icon-name="filters-background">Hello</ds-button>
130
+ <ds-icon icon-name="filters-background"></ds-icon>
131
+ </ds-theme-provider>
458
132
  ```
459
133
 
460
- To override the Intl-derived unit label with a shorter custom symbol:
134
+ **Performance note:**
135
+ For optimal behaviour, manually preload the CSS (and fonts if required) and set the provider to not load them:
461
136
 
462
137
  ```html
463
- <ds-slider
464
- min="0"
465
- max="2000"
466
- step="100"
467
- initial-value-min="1200"
468
- locale="en-GB"
469
- unit-style="unit"
470
- unit="kilometer"
471
- unit-symbol="km"
472
- unit-symbol-position="right"
473
- ></ds-slider>
474
- ```
138
+ <link rel="preload" as="style" href="https://ds-assets.cupra.com/[version]/styles/cupra/theme.css" />
139
+ <link rel="stylesheet" href="https://ds-assets.cupra.com/[version]/styles/cupra/theme.css" />
475
140
 
476
- #### Combined Intl and Manual Formatting
477
-
478
- ```html
479
- <ds-slider
480
- min="0"
481
- max="10000"
482
- step="500"
483
- initial-value-min="2000"
484
- locale="es-ES"
485
- currency="EUR"
486
- unit-symbol="approx."
487
- unit-symbol-position="left"
488
- thousand-separator="."
489
- fraction-separator=","
490
- ></ds-slider>
141
+ <ds-theme-provider theme="cupra" load-fonts="false" load-styles="false">
142
+ <!-- components -->
143
+ </ds-theme-provider>
491
144
  ```
492
145
 
493
146
  ---
494
147
 
495
- ### When to Use
496
-
497
- - **Single Value Sliders**: Use for selecting a single value within a range, e.g., volume control or brightness.
498
- - **Range Sliders**: Use for selecting a range of values, e.g., price filters.
499
- - **Intl Formatting**: Use `locale`, `currency`, and `unit-style` to format values for international users.
500
- - **Custom Symbols**: Combine `unit-symbol` and Intl formatting for tailored user interfaces.
501
-
502
- ---
503
-
504
- ### Notes
505
- - Ensure `min`, `max`, and `step` values are consistent to avoid unexpected behavior.
506
- - `unit-symbol` can complement `Intl` settings to provide additional context (e.g., "approx.").
507
- - Custom separators (e.g., `thousand-separator`) override Intl formatting behavior.
508
- </details>
509
-
510
- ## Z-Index Variables
511
-
512
- <details><summary>View z-index variables documentation</summary>
513
-
514
- These CSS variables help you manage the stacking order of the components.
515
-
516
- ### Introduction
517
-
518
- These predefined z-index variables provide a predictable and consistent layering strategy
519
- for elements such as headers, footers, modals, tooltips, and alerts. By using these variables,
520
- you can avoid arbitrary or conflicting z-index values across different parts of your application.
521
-
522
- ### Provided Variables
523
-
524
- | Variable | Default | Description |
525
- |--------------------------------|---------|------------------------------------------------------------------------------------------------------|
526
- | `--ds-z-index-negative` | -1 | Used for layers placed intentionally behind the base layer (e.g., background images). |
527
- | `--ds-z-index-base` | 0 | The default stacking context; typically used by elements without a specific z-index. |
528
- | `--ds-z-index-default` | 1 | Slightly above base elements, often used for general interactive UI components. |
529
- | `--ds-z-index-app-footer` | 1000 | Used for a main application footer if it needs to overlap default content. |
530
- | `--ds-z-index-app-header` | 1100 | Used for a main application header if it needs to overlap default content. |
531
- | `--ds-z-index-overlay` | 1200 | For overlays (e.g., dimmed backgrounds) that should appear above standard content. |
532
- | `--ds-z-index-tooltip` | 1300 | Ensures tooltips appear above overlays but below modals. |
533
- | `--ds-z-index-modal` | 1400 | Used for modal dialogs, above tooltips but potentially below certain dropdowns. |
534
- | `--ds-z-index-context-menu` | 1500 | For context menus or dropdowns that should appear above most overlays and modals. |
535
- | `--ds-z-index-popover` | 1600 | For popovers that need to appear above context menus or modals. |
536
- | `--ds-z-index-toast` | 1700 | For toast or notification messages, typically over main interactions but under loaders. |
537
- | `--ds-z-index-loader` | 1800 | For loading indicators or progress bars that must overlay standard UI elements. |
538
- | `--ds-z-index-alert-info` | 1900 | For informational alerts that need to appear above loaders. |
539
- | `--ds-z-index-alert-success` | 2000 | For success alerts, higher than info alerts. |
540
- | `--ds-z-index-alert-warning` | 2100 | For warning alerts, stacked above success alerts. |
541
- | `--ds-z-index-alert-error` | 2200 | For error alerts, stacked above warning alerts. |
542
- | `--ds-z-index-top` | 9999 | A very high stacking level for elements that must appear above all other layers. |
543
-
544
- ### Usage
545
-
546
- To apply one of these z-index values, reference the variable in your CSS.
547
- For example, a modal:
548
-
549
- ```css
550
- .my-modal {
551
- position: fixed;
552
- top: 50%;
553
- left: 50%;
554
- transform: translate(-50%, -50%);
555
- z-index: var(--ds-z-index-modal);
556
- }
557
- ```
558
-
559
- Or a context menu:
560
-
561
- ```css
562
- .my-context-menu {
563
- position: absolute;
564
- z-index: var(--ds-z-index-context-menu);
565
- /* Additional styling here */
566
- }
567
- ```
148
+ ### Option B — Installed via npm in an app build
149
+ Install the package:
568
150
 
569
- By consistently using these shared variables, you can maintain uniform layering logic
570
- across your application.
571
-
572
- ### When to Use
573
-
574
- - **Overlays and Dialogs**: Assign `--ds-z-index-overlay` for modal backgrounds or overlays,
575
- and `--ds-z-index-modal` for dialogs that appear on top of them.
576
- - **Context Menus**: Utilize `--ds-z-index-context-menu` for right-click or dropdown menus,
577
- ensuring they appear above standard overlays and modals.
578
- - **Tooltips and Popovers**: Use `--ds-z-index-tooltip` for tooltips and `--ds-z-index-popover`
579
- for popovers, maintaining a proper stacking order.
580
- - **Notifications**: Use `--ds-z-index-toast` for toast messages, ensuring they're visible
581
- but do not overshadow modals or popovers.
582
- - **Critical Alerts**: For error or critical alerts, consider the highest relevant index
583
- (`--ds-z-index-alert-error`) to ensure they appear above other elements.
584
- - **Custom Needs**: If you need a layer above or below existing tiers, consider defining
585
- a new variable. However, we recommend using these provided values for clarity and consistency.
586
- </details>
587
-
588
- ## Background Classes (.ds-bg)
589
-
590
- <details><summary>View background classes</summary>
591
-
592
- ### Introduction
593
-
594
- These CSS classes are designed to apply responsive backgrounds to HTML elements. The background image is loaded from a CDN using the base URL defined by the `$cdnBaseUrl` variable, and it adapts automatically to different screen sizes through media queries. The system uses a base class (`.ds-bg`) along with several variant classes to determine which background image to display.
595
-
596
- ### Available Classes
597
-
598
- | **Class** | **Description** |
599
- |----------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
600
- | **ds-bg** | The base background class. It applies:<br>- Vertical background repeat (`repeat-y`).<br>- Base background color using `--dg-color-bg-base`.<br>- Background size set to 100% width (auto height). |
601
- | **ds-bg--leon** | Variant that applies the "leon" background image when used together with `ds-bg`. |
602
- | **ds-bg--terramar** | Variant that applies the "terramar" background image when used together with `ds-bg`. |
603
- | **ds-bg--ateca** | Variant that applies the "ateca" background image when used together with `ds-bg`. |
604
- | **ds-bg--born** | Variant that applies the "born" background image when used together with `ds-bg`. |
605
- | **ds-bg--tavascan** | Variant that applies the "tavascan" background image when used together with `ds-bg`. |
606
- | **ds-bg--formentor** | Variant that applies the "formentor" background image when used together with `ds-bg`. |
607
-
608
- ### Responsive Behavior and Breakpoints
609
-
610
- Background images and their positions change automatically based on the screen width. Below is an overview of the breakpoints and how the background is adjusted:
611
-
612
- | **Breakpoint** | **Media Query** | **Image Suffix** | **Background Position** |
613
- |----------------|-----------------------|-----------|----------------|
614
- | **XS** | min-width: 0px | `-xs.svg` | `left top` |
615
- | **S** | min-width: 480px | `-s.svg` | `left top` |
616
- | **M** | min-width: 768px | `-m.svg` | `left -338px` |
617
- | **L** | min-width: 1024px | `-l.svg` | `left -338px` |
618
- | **XL** | min-width: 1440px | `-xl.svg` | `left -595px` |
619
- | **XXL** | min-width: 1920px | `-xxl.svg` | `left -595px` |
620
-
621
- ### Usage Examples
622
-
623
- **Default Background:**
624
-
625
- ```html
626
- <div class="ds-bg"></div>
151
+ ```bash
152
+ npm install @cupra/ui-kit
627
153
  ```
628
154
 
629
- **Using a Variant (e.g., "ds-bg--leon"):**
155
+ Then include the theme provider as in the CDN example.
156
+ CSS may be loaded manually (recommended) or automatically via the provider:
630
157
 
631
158
  ```html
632
- <div class="ds-bg ds-bg--leon"></div>
159
+ <ds-theme-provider theme="cupra" load-fonts="true" load-styles="true">
160
+ <ds-button variant="primary">Button</ds-button>
161
+ </ds-theme-provider>
633
162
  ```
634
163
 
635
- Simply add the base class `ds-bg` to your element. To display a specific background image, combine it with one of the variant classes such as `ds-bg--leon`, `ds-bg--terramar`, `ds-bg--ateca`, `ds-bg--born`, or `ds-bg--tavascan`.
636
- </details>
637
-
638
- ## ds-currency
639
-
640
- <details><summary>View currency component documentation</summary>
641
-
642
- `ds-currency` is a new component designed to display a currency value formatted according to your settings. It handles symbol placement, decimal and thousand separators, and optional period/note.
643
-
644
- ### 🎯 Attributes
645
-
646
- - **currency-code**
647
- ISO 4217 currency code (e.g. `EUR`, `USD`).
648
-
649
- - **locale**
650
- BCP 47 locale tag (ISO 639-1 language + ISO 3166-1 alpha-2 region), e.g. `es-ES`, `en-US`.
651
-
652
- - **amount-number**
653
- Numeric value to format as currency.
654
-
655
- - **amount-text**
656
- Literal text to display instead of the formatted value.
657
-
658
- - **minimum-fraction-digits**
659
- Minimum decimals (default `0`).
660
-
661
- - **maximum-fraction-digits**
662
- Maximum decimals (default `20`).
663
-
664
- - **thousand-separator**
665
- Override default thousands separator.
666
-
667
- - **fraction-separator**
668
- Override default decimal separator.
669
-
670
- - **period**
671
- Field to display after the amount (e.g. `month`, `year`, etc.). Acceptable values: `era`, `year`, `month`, `quarter`, `weekOfYear`, `weekday`, `dayPeriod`, `day`, `hour`, `minute`, `second`. These correspond to the standard ECMA-402 `Intl.DisplayNames` `dateTimeField` values (Unicode CLDR UTS #35) and are transformed according to the locale.
672
-
673
- - **note**
674
- Used to render a superscript number (e.g. "¹", "²") that links to footnotes or explanatory text in the UI.
675
-
676
- ---
677
-
678
- ### 💻 Example
679
-
680
- <ds-currency
681
- locale="es-ES"
682
- currency-code="EUR"
683
- amount-number="1234.56"
684
- period="month"
685
- note="1">
686
- </ds-currency>
687
-
688
- _Renders:_ **1.234,56€¹/month**
689
-
690
164
  ---
691
165
 
692
- ### 🌐 ISO & Standards + Functionality
693
-
694
- - **currency-code** follows **ISO 4217** for currency identifiers
695
- - **locale** uses **BCP 47** (ISO 639-1 + ISO 3166-1 alpha-2) to drive `Intl.NumberFormat` and `Intl.DisplayNames`
696
- - **period** uses **ECMA-402 Intl.DisplayNames** `dateTimeField` values (Unicode CLDR UTS #35) `era`, `year`, `month`… and localizes accordingly
697
- - Formats numbers with proper decimal and thousand separators
698
- - Positions currency symbol automatically (left/right) based on locale
699
- - Supports custom separators, fraction digit limits, plus optional period (`/month`, `/year`) and note text
700
- </details>
701
-
702
- ## Toast System
703
-
704
- <details><summary>Toast</summary>
705
-
706
- The toast system provides a way to display non-intrusive notifications to users. It consists of two components:
707
-
708
- - `<ds-toast>`: The container that manages and displays toast messages
709
- - `<ds-toast-message>`: Individual toast message components
710
-
711
- ### Basic Usage
712
-
713
- 1. Add the toast container to your application:
714
-
715
- ```html
716
- <ds-toast position="top-right"></ds-toast>
717
- ```
718
-
719
- 2. Trigger a toast from anywhere in your JavaScript:
720
-
721
- ```javascript
722
- window.dispatchEvent(
723
- new CustomEvent('toast:add', {
724
- detail: {
725
- title: 'Success',
726
- text: 'Operation completed successfully',
727
- status: 'success',
728
- duration: 5000 // Optional: time in milliseconds before auto-dismissing (default: 10000ms)
729
- }
730
- })
731
- );
732
- ```
733
-
734
- ### Toast Statuses
735
-
736
- There are five possible statuses for a toast message:
737
-
738
- - `success`: Used for successful operations
739
- - `error`: Used for error messages
740
- - `warning`: Used for warning messages
741
- - `info`: Used for informational messages
742
- - `default`: Used when no specific status is needed
743
-
744
- ### Custom Toast Templates
745
-
746
- You can create custom toast templates using the `<ds-toast-message>` component:
747
-
748
- ```html
749
- <ds-toast-message
750
- data-id="custom-toast-template"
751
- data-template="true"
752
- status="default"
753
- title="Custom Toast"
754
- text="This is a custom toast message"
755
- >
756
- <ds-link-button>Action Link</ds-link-button>
757
- </ds-toast-message>
758
- ```
759
-
760
- Then trigger it using:
761
-
762
- ```javascript
763
- window.dispatchEvent(
764
- new CustomEvent('toast:add', {
765
- detail: {
766
- referenceId: 'custom-toast-template',
767
- duration: 10000 // Optional: custom duration
768
- }
769
- })
770
- );
771
- ```
772
-
773
- ### Toast Positioning
774
-
775
- The `<ds-toast>` component supports four positions:
776
-
777
- - `top-right` (default)
778
- - `top-left`
779
- - `bottom-right`
780
- - `bottom-left`
781
-
782
- ```html
783
- <ds-toast position="bottom-left"></ds-toast>
784
- ```
785
-
786
- ### Toast Options
787
-
788
- The `'toast:add'` event `detail` accepts the following options:
789
-
790
- | Option | Type | Description |
791
- |-------------|------|---------------------------------------------------------------------------|
792
- | id | string | Optional custom identifier for the toast. If not provided, the system automatically generates one. Useful when you need to reference or remove a specific toast programmatically.|
793
- | title | string | The title of the toast |
794
- | text | string | The message content of the toast |
795
- | status | string | One of: 'success', 'error', 'warning', 'info', 'default' |
796
- | duration | number | Time in milliseconds before auto-dismissing (default: 10000ms) |
797
- | referenceId | string | ID of a custom toast template to use (will ignore title, text and status) |
798
-
799
- ### React Usage
800
-
801
- If you're using React, you can use the provided React components:
802
-
803
- ```jsx
804
- import { Toast, ToastMessage } from '@cupra/ui-react';
805
-
806
- // In your component:
807
- return (
808
- <>
809
- <Toast position="top-right" />
810
-
811
- {/* Custom template (optional) */}
812
- <ToastMessage
813
- data-id="custom-template"
814
- data-template={true}
815
- title="Custom Toast"
816
- text="This is a custom toast message"
817
- >
818
- <button>Action Button</button>
819
- </ToastMessage>
820
- </>
821
- );
822
-
823
- // Trigger a toast from anywhere:
824
- window.dispatchEvent(
825
- new CustomEvent('toast:add', {
826
- detail: {
827
- title: 'Hello',
828
- text: 'This is a toast message',
829
- status: 'info'
830
- }
831
- })
832
- );
833
- ```
834
-
835
- ### Removing a Toast
836
-
837
- To manually close or remove a toast, dispatch the `'toast:remove'` event.
838
- It accepts either the `id` of a specific toast or the `referenceId` of a custom template.
839
-
840
- ```javascript
841
- // Remove a specific toast by ID
842
- window.dispatchEvent(
843
- new CustomEvent('toast:remove', { detail: { id: 'my-toast-id' } })
844
- );
845
-
846
- // Or remove a toast created from a template
847
- window.dispatchEvent(
848
- new CustomEvent('toast:remove', { detail: { referenceId: 'custom-toast-template' } })
849
- );
850
- ```
851
-
852
- > **Note:**
853
- > This is **not the recommended approach**.
854
- > Toasts are designed to close automatically after their duration expires, or manually by user interaction (for example, clicking a close button).
855
- > The `'toast:remove'` event should only be used in specific cases when programmatic control is required.
856
- >
857
- > When removing by `id`, each toast has a unique identifier (automatically generated unless manually provided).
858
- > When removing by `referenceId`, it refers to a template identifier.
859
- > If multiple toasts have been created using the same `referenceId`, only one instance —the oldest— will be removed.
166
+ ## License
167
+ License: SEAT S.A. Library EULA 1.0
168
+ See `LICENSE.md` for the full license text.
169
+ Third-party license attributions may be listed in `THIRD_PARTY_LICENSES.md`.
860
170
 
861
- </details>
171
+ ## Support
172
+ For any questions or assistance, contact: **ds.support@seat.es**