@voicenter-team/voicenter-ui-plus 4.0.0 → 4.0.1
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/MIGRATION_v3.md +196 -196
- package/README.md +1051 -1051
- package/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcFileUploader/VcFileUploaderSimple.css +1 -1
- package/library/assets/components/VcJsonSchema/Components/JsonSchemaEditor.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Circles.css +1 -1
- package/library/assets/components/VcLoading/Loaders/DotSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LdsSpinner.css +1 -1
- package/library/assets/components/VcLoading/Loaders/LoadIcon.css +1 -1
- package/library/assets/components/VcLoading/Loaders/Stretch.css +1 -1
- package/library/assets/components/VcLoading/VcLoading.css +1 -1
- package/library/assets/components/VcMdEditor/ParameterNode.css +1 -1
- package/library/assets/components/VcSegmented/VcSegmented.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Card.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Circle.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Row.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Square.css +1 -1
- package/library/assets/components/VcSkeletonLoader/Loaders/Text.css +1 -1
- package/library/components/VcCheckbox/VcCheckbox.vue.mjs +1 -1
- package/library/components/VcCheckbox/VcCheckboxButton.vue.mjs +1 -1
- package/library/components/VcDatePicker/VcDatePicker.vue.mjs +1 -1
- package/library/components/VcDropdown/VcDropdownItem.vue.mjs +1 -1
- package/library/components/VcFileUploader/VcFileUploaderSimple.vue.mjs +1 -1
- package/library/components/VcForm/VcForm.vue.mjs +1 -1
- package/library/components/VcForm/VcFormItem.vue.mjs +1 -1
- package/library/components/VcHtmlEditor/VcHtmlEditorToolbar.vue.mjs +1 -1
- package/library/components/VcInput/VcInput.vue.mjs +1 -1
- package/library/components/VcJsonSchema/Components/JsonSchemaEditor.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Circles.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/DotSpinner.vue2.mjs +2 -2
- package/library/components/VcLoading/Loaders/LdsSpinner.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/LoadIcon.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue.mjs +1 -1
- package/library/components/VcLoading/Loaders/Stretch.vue2.mjs +1 -1
- package/library/components/VcLoading/VcLoading.vue.mjs +1 -1
- package/library/components/VcMdEditor/ParameterNode.vue.mjs +1 -1
- package/library/components/VcMdEditor/VcMdEditor.vue.mjs +1 -1
- package/library/components/VcMdEditor/VcMdEditorToolbar.vue.mjs +1 -1
- package/library/components/VcMessage/reactions/VcMessageReactionBar.vue.mjs +1 -1
- package/library/components/VcRadio/VcRadio.vue.mjs +1 -1
- package/library/components/VcSegmented/VcSegmented.vue.mjs +1 -1
- package/library/components/VcSelect/VcSelect.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Card.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Circle.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Row.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Square.vue.mjs +1 -1
- package/library/components/VcSkeletonLoader/Loaders/Text.vue.mjs +1 -1
- package/library/components/VcSlider/VcSlider.vue.mjs +1 -1
- package/library/components/VcTable/VcTable.vue.mjs +4 -1
- package/library/entity/components/Table/VcEntityListTable.vue.mjs +8 -3
- package/library/index.mjs.gz +0 -0
- package/library/localization/index.mjs.gz +0 -0
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +16 -16
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/theme/index.mjs.gz +0 -0
- package/library/types/localization/locales/en.json.d.ts +415 -415
- package/library/types/theme/themes.json.d.ts +72 -72
- package/library/utils/jsonSchema/index.mjs.gz +0 -0
- package/package.json +311 -311
- package/src/theme/index.ts +101 -101
- package/src/theme/tailwindScheme.js +78 -78
- package/src/theme/theme.types.ts +31 -31
- package/src/theme/themeMerge.ts +63 -63
- package/src/theme/themes.json +72 -72
- package/tailwind.config.d.ts +5 -5
- package/tailwind.config.js +178 -178
- /package/library/assets/node_modules/element-plus/theme-chalk/src/{tooltip.css → dropdown-item.css} +0 -0
package/README.md
CHANGED
|
@@ -1,1051 +1,1051 @@
|
|
|
1
|
-
# Voicenter UI library for Vue
|
|
2
|
-
This is Vue 3.x + Typescript component library made for Voicenter systems.
|
|
3
|
-
|
|
4
|
-
> **4.x renames the colour tokens, draws Lucide icons and changes some component defaults.** An application on 3.x follows [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x); one on 2.x first follows [`MIGRATION_v3.md`](./MIGRATION_v3.md); one already on a 4.0 beta follows [Upgrading from a 4.0 beta](#upgrading-from-a-40-beta).
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
npm i @voicenter-team/voicenter-ui-plus
|
|
10
|
-
npm i vue@^3.5 element-plus @vueuse/core @lucide/vue dayjs lodash-es libphonenumber-js maska
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Optional peers
|
|
14
|
-
|
|
15
|
-
The packages that only some components need are optional peer dependencies, and npm does not install them. An application installs into its own `dependencies` the packages of the components it renders: each component's page in the [live documentation](https://voicenter-ui-plus.pages.dev/) gives them as one `npm i` line under its heading.
|
|
16
|
-
|
|
17
|
-
A component loads its packages with `import()` the first time it needs them: when it renders, or when the part that needs the package is used. The packages behind such a part load only then: `VcMessage` loads the editor packages for a markdown block and `wavesurfer.js` for an audio block, `VcChatComposer` loads `emojibase-data` when its emoji picker opens, `VcExcelFileUploader` loads `xlsx` when a file is picked, the PDF components load `pdfjs-dist` when a document loads. In a Vite application a missing package fails only that component, at that moment, with an error naming the package (`<pkg> is not installed` from the library, or `Could not resolve "<pkg>" imported by "@voicenter-team/voicenter-ui-plus"` from Vite); the application builds and the rest of it works. A Vite application's build needs no configuration for the packages it leaves out: no `external` list (an application that listed them in `build.rollupOptions.external` on 3.x removes those entries, or a package it later installs is never bundled). webpack fails a build on an `import()` it cannot resolve, so a webpack application installs the packages of every component it renders.
|
|
18
|
-
|
|
19
|
-
The library's type declarations import the types of these packages. An application that type-checks with `skipLibCheck: false` and leaves a package out gets a `TS2307` for it; with `skipLibCheck: true` (the default of Vite's templates) those types are `any`.
|
|
20
|
-
|
|
21
|
-
The stylesheets of these packages that a component needs are in the library's CSS, except KaTeX's, which brings 60 font files. Markdown renders math (`$…$`, or the math block of the `VcMdEditor` toolbar) with KaTeX, in `VcMdEditor` and in the markdown of `VcMessage`, `VcAiReasoning`, `VcAgentRunCard` and `VcSystemUserPrompt`: an application that shows math installs `katex` and adds `import 'katex/dist/katex.min.css'` itself.
|
|
22
|
-
|
|
23
|
-
### Sass compiler (build-time)
|
|
24
|
-
|
|
25
|
-
This library customizes element-plus theming via SCSS variable injection at build time. Your bundler needs to be able to compile SCSS. If your project doesn't already use Sass, add it as a dev dependency:
|
|
26
|
-
|
|
27
|
-
```bash
|
|
28
|
-
npm i -D sass-embedded
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
This is a **build-time only** requirement — it doesn't add anything to your runtime bundle. Most Vue 3 / Vite projects already have it.
|
|
32
|
-
|
|
33
|
-
## Usage
|
|
34
|
-
|
|
35
|
-
### Tree-shake mode (recommended)
|
|
36
|
-
```ts
|
|
37
|
-
import { VcButton, VcInput } from '@voicenter-team/voicenter-ui-plus'
|
|
38
|
-
// Use as local components — no app.use() needed.
|
|
39
|
-
```
|
|
40
|
-
Bundlers drop unused components and their CSS. A consumer importing only `VcButton` ships ~50–150 KB JS + ~10–30 KB CSS.
|
|
41
|
-
|
|
42
|
-
The stylesheet sets the default theme (voicenter) on `:root`. Another theme and the text font are two calls, the ones the plugin makes itself:
|
|
43
|
-
|
|
44
|
-
```ts
|
|
45
|
-
import Theme from '@voicenter-team/voicenter-ui-plus/theme'
|
|
46
|
-
import { loadTextFont } from '@voicenter-team/voicenter-ui-plus/font'
|
|
47
|
-
|
|
48
|
-
Theme({ type: 'local', themeName: 'voicenter' }) // any themeConfig, see "Theming specification"
|
|
49
|
-
loadTextFont() // Rubik and DM Mono from Google Fonts
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
If you use `useConfirmModal`, `useConfirmPopup`, or `NotifyService`, mount global overlays in `App.vue`:
|
|
53
|
-
|
|
54
|
-
```vue
|
|
55
|
-
<script setup lang="ts">
|
|
56
|
-
import { VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus'
|
|
57
|
-
</script>
|
|
58
|
-
|
|
59
|
-
<template>
|
|
60
|
-
<RouterView />
|
|
61
|
-
<VcPluginOverlays />
|
|
62
|
-
</template>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
### Plugin mode (global registration)
|
|
66
|
-
```ts
|
|
67
|
-
import VoicenterUI from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
68
|
-
import '@voicenter-team/voicenter-ui-plus/style.css'
|
|
69
|
-
|
|
70
|
-
// Overlay composables can be imported from the same entry:
|
|
71
|
-
// import { useConfirmModal, useConfirmPopup, VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
72
|
-
|
|
73
|
-
app.use(VoicenterUI, {
|
|
74
|
-
themeConfig, // theme config (see below)
|
|
75
|
-
lang: 'en' // localization
|
|
76
|
-
})
|
|
77
|
-
// Confirm modals/popovers/notifications: auto-mounted via VcPluginOverlays
|
|
78
|
-
// (mountOverlays: true by default). Opt out with mountOverlays: false and
|
|
79
|
-
// add <VcPluginOverlays /> to App.vue — also registered globally by the plugin.
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
`style.css` loads the `vc-icon-*` icon font and its classes. The plugin option `injectIconFont: true` adds the font's `@font-face` to the document head as well: an application needs it only when the stylesheet is inside a shadow root (a custom element, a browser extension's content script), where a `@font-face` does not apply.
|
|
83
|
-
|
|
84
|
-
### Global overlays
|
|
85
|
-
|
|
86
|
-
Several APIs are **state-only** — they update global reactive singletons but do not render UI by themselves:
|
|
87
|
-
|
|
88
|
-
| API | Overlay component |
|
|
89
|
-
|---|---|
|
|
90
|
-
| `useConfirmModal` | `VcConfirmModal` |
|
|
91
|
-
| `useConfirmPopup` | `VcConfirmPopover` |
|
|
92
|
-
| `NotifyService` / `$notify` | `VcNotification` |
|
|
93
|
-
|
|
94
|
-
**Plugin mode:** mounted automatically on `app.use()` (default). Pass `mountOverlays: false` to mount manually.
|
|
95
|
-
|
|
96
|
-
**Notifications:** one top-right host by default. For multiple positions, use `overlayNotifications` in plugin config or mount your own:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
app.use(VoicenterUI, {
|
|
100
|
-
overlayNotifications: [
|
|
101
|
-
{ group: 'top-right', position: 'top-right' },
|
|
102
|
-
{ group: 'bottom-right', position: 'bottom-right' },
|
|
103
|
-
],
|
|
104
|
-
})
|
|
105
|
-
// NotifyService.add({ group: 'bottom-right', ... })
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
Or `overlayNotifications: 'none'` and put `<VcNotification />` in App.vue (confirms still auto-mount).
|
|
109
|
-
|
|
110
|
-
**Tree-shake mode:** add `<VcPluginOverlays />` to `App.vue` (bundles confirm hosts; configure via `notifications` prop).
|
|
111
|
-
|
|
112
|
-
Entity components such as `VcEntityListTable` call `useConfirmModal` internally — delete confirmations require overlays to be mounted.
|
|
113
|
-
|
|
114
|
-
### Tailwind
|
|
115
|
-
|
|
116
|
-
The scheme and the shipped `tailwind.config.js` are Tailwind 3 configurations: an application installs `tailwindcss@3`, `postcss` and `autoprefixer` (`npx tailwindcss init -p` creates its configuration).
|
|
117
|
-
|
|
118
|
-
Tailwind's colours come from the library scheme, so the utility classes and the theme are one set of tokens. `theme.colors` replaces Tailwind's own palette on purpose: only the library's colours exist as classes.
|
|
119
|
-
|
|
120
|
-
```js
|
|
121
|
-
// tailwind.config.js
|
|
122
|
-
const voiceTailwindScheme = require('@voicenter-team/voicenter-ui-plus/src/theme/tailwindScheme')
|
|
123
|
-
|
|
124
|
-
module.exports = {
|
|
125
|
-
...yourConfiguration,
|
|
126
|
-
theme: {
|
|
127
|
-
colors: { ...voiceTailwindScheme },
|
|
128
|
-
borderColor: { ...voiceTailwindScheme },
|
|
129
|
-
fill: voiceTailwindScheme
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
The library's own `tailwind.config.js` (shipped as `@voicenter-team/voicenter-ui-plus/tailwind.config`) also has keys for the radii, shadows, font family and font weights of the components; [Corners](#corners), [Shadows](#shadows) and [Text](#text) say what each class is for. Their values are the CSS variables the library stylesheet sets on `:root` in both modes, so a class drawn with them changes together with the library. An application takes these keys from the shipped configuration:
|
|
135
|
-
|
|
136
|
-
```js
|
|
137
|
-
// tailwind.config.js
|
|
138
|
-
const uiPlusTheme = require('@voicenter-team/voicenter-ui-plus/tailwind.config').theme
|
|
139
|
-
|
|
140
|
-
module.exports = {
|
|
141
|
-
...yourConfiguration,
|
|
142
|
-
theme: {
|
|
143
|
-
// colours as above
|
|
144
|
-
extend: {
|
|
145
|
-
borderRadius: uiPlusTheme.borderRadius,
|
|
146
|
-
boxShadow: uiPlusTheme.boxShadow,
|
|
147
|
-
transitionProperty: uiPlusTheme.extend.transitionProperty,
|
|
148
|
-
fontFamily: uiPlusTheme.fontFamily,
|
|
149
|
-
fontWeight: uiPlusTheme.extend.fontWeight
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
Import the application's own stylesheet after the library, so the application's utilities win ties of equal specificity with the library's CSS (`.hidden` is the usual one).
|
|
156
|
-
|
|
157
|
-
Tailwind's preflight (`@tailwind base`) in that stylesheet sets `font-family` on `html` again, Tailwind's sans font, after the library set Rubik there. `html { @apply font-main; }` in the application's `@layer base` keeps the library font on the page.
|
|
158
|
-
|
|
159
|
-
The 3.x colour names are not in the scheme; [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) lists their 4.x names.
|
|
160
|
-
|
|
161
|
-
### Theming specification
|
|
162
|
-
The `themeConfig` passed to `app.use(VoicenterUI, { themeConfig })`, or to `Theme()` in tree-shake mode, could have the following specifications.
|
|
163
|
-
|
|
164
|
-
A theme is a flat object of colour tokens. Each key is set on the document element as a CSS variable with `--` in front of it: `vc-action-primary` becomes `--vc-action-primary`. The keys are grouped by role:
|
|
165
|
-
|
|
166
|
-
- `vc-content-*`: text and icons (`primary`, `secondary`, `tertiary`, `disabled`, `success`, `warning`, `danger`, `info`); `warning` colours warning text and icons alike; `vc-content-brand` is brand-coloured text and icons (links, active tabs, the text of `primary` outline and borderless buttons), a deeper red than the brand fill (set by voicenter and voicenterDark; a theme that does not set it takes its `vc-action-primary`);
|
|
167
|
-
- `vc-bg-*`: backgrounds (`page`, `surface`, `inset`, `inset-strong`, `field`, `muted`, `overlay`);
|
|
168
|
-
- `vc-action-*`: fills of interactive elements (`primary`, `secondary`, `info`, `success`, `warning`, `danger`);
|
|
169
|
-
- `vc-onfill` and `vc-onfill-{fill}`: text on a solid fill. Every built-in theme sets `vc-onfill-primary` and `vc-onfill-warning`; `vc-onfill-secondary`, `vc-onfill-info`, `vc-onfill-success` and `vc-onfill-danger` are optional, and a fill whose key is not set takes `vc-onfill`;
|
|
170
|
-
- `vc-border`, `vc-border-strong`, `vc-input` (field borders), `vc-ring` (focus ring), `vc-shadow-color`;
|
|
171
|
-
- `vc-mix-anchor` and `vc-mix-anchor-{fill}`: the colour the hover and pressed states of a fill are mixed toward (black darkens, white lightens). Any fill can have its own anchor: a fill whose `vc-mix-anchor-{fill}` key is not set mixes toward `vc-mix-anchor`. Every built-in theme sets `vc-mix-anchor-primary` and `vc-mix-anchor-warning`, the two fills with their own text colour. Coloured text (links, outline and borderless buttons) has no anchor key: its hover and pressed states mix toward `vc-content-primary`, so they darken on a light theme and lighten on a dark one.
|
|
172
|
-
|
|
173
|
-
Hover, pressed, disabled and tinted states (`--vc-action-primary--hover`, `--vc-action-primary--subtle-hover`, …) are mixed from these values by the library, so a theme sets only the base colours. The Element Plus colour variables (`--el-color-primary`, `--el-bg-color`, `--el-border-color`, …) are filled from the same tokens; a theme can still set an `el-*` key to override one. A theme that does not set `vc-content-success`, `vc-content-warning`, `vc-content-danger` or `vc-content-info` takes its `vc-action-*` of the same status for it.
|
|
174
|
-
|
|
175
|
-
The full list of keys and the values of every built-in theme are in [`src/theme/themes.json`](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json). The library's stylesheet sets the keys of the default theme (voicenter) on `:root`. Any other key a theme leaves out takes the default theme's value; after a theme switch at run time, a key the new theme leaves out keeps the previous theme's value. Theme keys of 3.x (`primary`, `default-text`, `ui-lines`, …) are not read, and nothing warns about them: a `customJson` or remote theme with 3.x keys draws the default theme. A theme passes the `vc-*` keys ([Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) maps them).
|
|
176
|
-
|
|
177
|
-
### Local
|
|
178
|
-
**Config:**
|
|
179
|
-
```js
|
|
180
|
-
{
|
|
181
|
-
type: 'local'
|
|
182
|
-
themeName: 'voicenter' | 'voicenterDark'
|
|
183
|
-
onSetupCallback: () => {
|
|
184
|
-
console.log('Loaded!')
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
```
|
|
188
|
-
**Description:**
|
|
189
|
-
|
|
190
|
-
Such configuration will append to the document element the CSS variables from one of the configuration passed in `themeName` parameter which it will get from theme specification delivered alongside with library
|
|
191
|
-
|
|
192
|
-
**Params:**
|
|
193
|
-
- **themeName**
|
|
194
|
-
- The name of the theme to be injected. `voicenter` is the default (it is also used when no `themeConfig` is passed); `voicenterDark` is the dark theme. An unknown name logs a warning and keeps the default.
|
|
195
|
-
- `voicenterDark` is the dark counterpart of `voicenter`. Its fills are deep enough for white text on every one of them (`vc-onfill`, `vc-onfill-primary` and `vc-onfill-warning` are white), and their hover and pressed states darken (`vc-mix-anchor` is black). Coloured text never reads a fill: it takes the `content-*` keys and `vc-content-brand`, which are lighter than the fills, and gets lighter still on hover and press.
|
|
196
|
-
- **onSetupCallback**
|
|
197
|
-
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
198
|
-
|
|
199
|
-
### Remote
|
|
200
|
-
**Config:**
|
|
201
|
-
```js
|
|
202
|
-
{
|
|
203
|
-
type: 'remote'
|
|
204
|
-
brandingSectionName: 'someName'
|
|
205
|
-
apiUrl: 'someUrl'
|
|
206
|
-
brandingSectionName: {
|
|
207
|
-
property: 'data'
|
|
208
|
-
}
|
|
209
|
-
onSetupCallback: () => {
|
|
210
|
-
console.log('Loaded!')
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
```
|
|
214
|
-
**Description:**
|
|
215
|
-
|
|
216
|
-
Such configuration will initiate the call to the specified apiUrl in order to retrieve the JSON object with key-value properties of the CSS variables to inject to document element
|
|
217
|
-
|
|
218
|
-
**Params:**
|
|
219
|
-
- **brandingSectionName**
|
|
220
|
-
- [Optional] The name of the section (tagSection) in the database configuration which will be passed to the API in payload and on response retrieved replaced from resulted values
|
|
221
|
-
- **apiUrl**
|
|
222
|
-
- The API url to which the POST request will be initiated
|
|
223
|
-
- **onSetupCallback**
|
|
224
|
-
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
225
|
-
- **brandingSectionName**
|
|
226
|
-
- [Optional] The payload data that will be sent to the request
|
|
227
|
-
|
|
228
|
-
### Custom JSON
|
|
229
|
-
**Config:**
|
|
230
|
-
```js
|
|
231
|
-
{
|
|
232
|
-
type: 'customJson'
|
|
233
|
-
config: {
|
|
234
|
-
'vc-action-primary': '#E80130',
|
|
235
|
-
'vc-content-primary': '#1F2937'
|
|
236
|
-
}
|
|
237
|
-
onSetupCallback: () => {
|
|
238
|
-
console.log('Loaded!')
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
**Description:**
|
|
243
|
-
|
|
244
|
-
Such configuration will initiate the styling with custom provided theme
|
|
245
|
-
|
|
246
|
-
**Params:**
|
|
247
|
-
- **config**
|
|
248
|
-
- The object where the key is the variable to be set and the value is the variable value. The keys are the theme keys described above; check the [themes object](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json) for the full list.
|
|
249
|
-
- **onSetupCallback**
|
|
250
|
-
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
251
|
-
|
|
252
|
-
### None
|
|
253
|
-
`{ type: 'none', onSetupCallback?: (theme) => void }` injects no theme variables; the application sets them itself.
|
|
254
|
-
|
|
255
|
-
## Migrating from 3.x to 4.x
|
|
256
|
-
|
|
257
|
-
### What changed and why
|
|
258
|
-
|
|
259
|
-
- **Colours** are named by their role, and a theme sets only the base colours: the hover, pressed, disabled and tinted states are mixed from them by the library, with one formula for every colour. The 3.x colour names are gone. Details: [Colour names](#colour-names), [CSS variables](#css-variables), [Tailwind colour classes](#tailwind-colour-classes), [Theme keys](#theme-keys) and [Finding the 3.x names](#finding-the-3x-names).
|
|
260
|
-
- **Icons** are Lucide (`@lucide/vue`), the icons of the 4.0 design, where 3.x drew the `vc-icon-*` font. An icon prop still takes a `vc-icon-*` class. Details: [Icons](#icons).
|
|
261
|
-
- **Corners** take one of six radius roles, `control`, `control-sm`, `popup`, `card`, `tag` and `inner`, each a CSS variable (`--vc-radius-control`) and a class of the shipped Tailwind configuration (`rounded-control`). They replace the 3.x radius scale and `--base-border-radius`. The classes read the variables the library stylesheet sets, so a corner drawn with them changes together with the library. Details: [Corners](#corners) and [Styles and component defaults](#styles-and-component-defaults).
|
|
262
|
-
- **Text** has one font key, `main`, which names the role rather than the font, so a font change keeps the class; `font-inter`, `font-heebo` and `font-rubik`, which all drew Rubik, are gone. It takes three weights, `font-normal`, `font-medium` and `font-semibold` (`--vc-font-weight-*`): Rubik is a variable font whose stock weights read heavy, so the first two are lighter than in 3.x. Details: [Text](#text) and [Styles and component defaults](#styles-and-component-defaults).
|
|
263
|
-
- **Focus** is one ring, `shadow-focus` (`shadow-focus-inner` draws it inside), in the theme's `vc-ring` colour. The colour-named focus classes are gone: they all drew that one ring, whatever colour the name gave. Details: [Shadows](#shadows) and [Styles and component defaults](#styles-and-component-defaults).
|
|
264
|
-
- **Component defaults**: the fields default to `primary`, and the colours `primary-alternative` and `active` are gone, since both drew the brand colour, as `primary` does. VcTagInput and VcTreeSelect show their values as the muted chips of a multiple VcSelect, a field's prefix icon follows the size of the field, and the close and copy controls of modals, notifications and code blocks are a VcButtonIcon, with the size, radius and hover of the library's controls. Details: [Styles and component defaults](#styles-and-component-defaults).
|
|
265
|
-
- **Themes**: 4.x has two built-in themes, the light `voicenter` (the default) and the dark `voicenterDark`, so the `themeName` of the application's `themeConfig` changes:
|
|
266
|
-
|
|
267
|
-
| `themeName` in 3.x | 4.x |
|
|
268
|
-
| --- | --- |
|
|
269
|
-
| `voicenterRed` | `voicenter`: the same theme under its 4.x name |
|
|
270
|
-
| `redGreen` (the 3.x default), `red`, `blue` | `voicenter`; an application that has to keep those colours passes them as a `customJson` theme ([Theming specification](#theming-specification)) |
|
|
271
|
-
| `black` | `voicenterDark` |
|
|
272
|
-
| no `themeConfig` | nothing to change: the application is drawn in `voicenter`, where 3.x drew `redGreen` |
|
|
273
|
-
|
|
274
|
-
A 3.x name left in `themeName` does not fail: it logs `No such theme` in the console and the application is drawn in `voicenter`. Search for it (`grep -rnE "themeName|voicenterRed|redGreen" src`), and for code that switches themes by name, such as a dark-mode toggle. The stylesheet sets the default theme on `:root`.
|
|
275
|
-
- **Optional peers**: 3.x installed every peer dependency together with the library. 4.x marks the packages that only some components need optional, and npm does not install them. An application adds to its `dependencies` the packages the documentation page of each component it renders lists ([Optional peers](#optional-peers)), then runs the application: a component whose package is missing fails when it needs it, with the message given there. Also: an application that listed uninstalled peers in `build.rollupOptions.external` removes those entries; a component now renders before its package arrives (plain code, an empty editor area, an empty composer line), so an application test that asserts right after `mount` awaits `flushPromises()` first; an application whose markdown shows math adds KaTeX's stylesheet itself (see there).
|
|
276
|
-
- **Removed**: besides the names above, the theme `blue`, which no application on 3.x selects (only applications still on 0.x do), and the classes of the native close controls. The sections below give what replaces each removed name.
|
|
277
|
-
|
|
278
|
-
### Colour names
|
|
279
|
-
|
|
280
|
-
In 4.x the colours are named by their role: `content` for text and icons, `bg` for backgrounds, `action` for the fills of interactive elements, `onfill` for text on a fill, and `border`, `input` and `ring` for lines. The 3.x colour names are gone: a 3.x CSS variable is not set, a 3.x Tailwind colour class is not generated and a 3.x theme key is not read. An application moves every colour it takes from ui-plus to the 4.x name in the tables below. Where a 3.x name has two 4.x names, the token follows what the value finally draws, also when it sits in a custom property, a JS object or a prop: `content-*` where it colours text or an icon, `action-*` where it fills or outlines.
|
|
281
|
-
|
|
282
|
-
Hover, pressed and tinted states keep one pattern. In CSS variables, `--focus` (hover) becomes `--hover`, `--pressed` stays `--pressed`, and `-bg--focus` and `-bg--pressed` (the 10% and 20% washes) become `--subtle-hover` and `--subtle-pressed`: `--primary-actions-bg--focus` is `--vc-action-primary--subtle-hover`. Tailwind names use one dash: `bg-action-primary-hover`, `bg-action-primary-subtle-hover`. `destructive` and `error` are both `danger`; `primary-alternative` and `active-elements` are both `primary`.
|
|
283
|
-
|
|
284
|
-
What keeps its name:
|
|
285
|
-
|
|
286
|
-
- the `color` prop values of the components: `primary`, `secondary`, `destructive`, `success` and `warning`; `info` is new, and `active` and `primary-alternative` are removed (see "Styles and component defaults");
|
|
287
|
-
- the shadow classes (`shadow-card`, `shadow-table`, `shadow-hover-outer-primary`, …) apart from the focus classes, `shadow-hover`, `shadow-hover-{colour}` and `shadow-hover-outer-destructive` (see "Styles and component defaults"): they read the 4.x tokens;
|
|
288
|
-
- the Element Plus variables (`--el-color-primary`, `--el-border-color`, …): the library fills them from the 4.x tokens.
|
|
289
|
-
|
|
290
|
-
Props that take a Tailwind colour name take the 4.x name: `VcCollapseItem` `color-icon="action-primary"` and `color-border="border"` (the defaults). The `color` of `VcLoading` takes a component colour (`primary`, `destructive`, …) or a 4.x Tailwind colour name (`content-secondary`).
|
|
291
|
-
|
|
292
|
-
Some 3.x names had a value of their own in the built-in themes and now share a token, so they draw differently:
|
|
293
|
-
|
|
294
|
-
- `icons` and `table-headings` were an accent colour of their own in red and black and the brand colour in redGreen, and `headers` an accent colour in black; they are `content-primary`, the body text colour.
|
|
295
|
-
- `default-text` (red, voicenterRed) and `heading-text` (red) differed from `primary-text`; all three are `content-primary`.
|
|
296
|
-
- `primary-alternative` had a colour of its own in every theme; it is `action-primary`.
|
|
297
|
-
- `active-elements` had a colour of its own in red; it is `action-primary`.
|
|
298
|
-
- `inactive-elements` was the secondary colour in red, redGreen and black; it is `content-disabled`.
|
|
299
|
-
- `progress-line-done` was a neutral grey in red, redGreen and black; it is `action-success`. `progress-line-not-done` was the secondary colour in red and redGreen and a dark grey in black; it is `border`.
|
|
300
|
-
- `scrollbar-track`, `scrollbar-thumb` and `scrollbar-thumb-hover` were fixed greys in red, redGreen and black; they are `bg-surface`, `border` and `content-disabled`, so the scrollbar follows the theme.
|
|
301
|
-
- `destructive` and `error` were two colours in redGreen and black; both are `action-danger`.
|
|
302
|
-
|
|
303
|
-
Some names keep their meaning but have a new value in voicenter (3.x `voicenterRed`): `destructive`, `error`, `success`, `warning` and `actions-mix-color`, and the `secondary` fill (#4A607A, a darker grey; `secondary` text is `content-secondary`); the `primary` text in voicenter is #C20027 (`content-brand`), a deeper red than the #E80130 fill.
|
|
304
|
-
|
|
305
|
-
For the brand colour, use `action-primary` for fills and `content-brand` for text and icons.
|
|
306
|
-
|
|
307
|
-
### CSS variables
|
|
308
|
-
|
|
309
|
-
| 3.x variable | 4.x |
|
|
310
|
-
| --- | --- |
|
|
311
|
-
| `--main-bg` | `var(--vc-bg-page)` |
|
|
312
|
-
| `--light-bg` | `var(--vc-bg-surface)` |
|
|
313
|
-
| `--card-bg-color` | `var(--vc-bg-surface)` |
|
|
314
|
-
| `--dark-bg` | `var(--vc-bg-inset-strong)` |
|
|
315
|
-
| `--field-bg` | `var(--vc-bg-field)` |
|
|
316
|
-
| `--overlay-bg` | `var(--vc-bg-overlay)`: it carries its own transparency (3.x components mixed `--overlay-bg` to 40%, so a 3.x value `X` becomes `color-mix(in srgb, X 40%, transparent)`) |
|
|
317
|
-
| `--skeleton-loader` | `var(--vc-bg-muted)` |
|
|
318
|
-
| `--skeleton-loader-animation` | `var(--vc-bg-skeleton-shine)` |
|
|
319
|
-
| `--scrollbar-track` | `var(--vc-bg-surface)` |
|
|
320
|
-
| `--primary-text` | `var(--vc-content-primary)` |
|
|
321
|
-
| `--heading-text` | `var(--vc-content-primary)` |
|
|
322
|
-
| `--headers` | `var(--vc-content-primary)` |
|
|
323
|
-
| `--icons` | `var(--vc-content-primary)` |
|
|
324
|
-
| `--table-headings` | `var(--vc-content-primary)` |
|
|
325
|
-
| `--default-text` | `var(--vc-content-primary)` |
|
|
326
|
-
| `--secondary-text` | `var(--vc-content-secondary)` |
|
|
327
|
-
| `--placeholders` | `var(--vc-content-tertiary)` |
|
|
328
|
-
| `--inactive-text` | `var(--vc-content-disabled)` |
|
|
329
|
-
| `--inactive-elements` | `var(--vc-content-disabled)` |
|
|
330
|
-
| `--btn-filled-text` | `var(--vc-onfill-primary, var(--vc-onfill))` |
|
|
331
|
-
| `--default-loader` | `var(--vc-onfill-primary, var(--vc-onfill))` |
|
|
332
|
-
| `--ui-lines` | `var(--vc-border)` |
|
|
333
|
-
| `--major-ui-lines` | `var(--vc-border-strong)` |
|
|
334
|
-
| `--field-borders` | `var(--vc-input)` |
|
|
335
|
-
| `--scrollbar-thumb` | `var(--vc-border)` |
|
|
336
|
-
| `--scrollbar-thumb-hover` | `var(--vc-content-disabled)` |
|
|
337
|
-
| `--progress-line-done` | `var(--vc-action-success)` |
|
|
338
|
-
| `--progress-line-not-done` | `var(--vc-border)` |
|
|
339
|
-
| `--card-shadow-color` | `color-mix(in srgb, var(--vc-shadow-color) 12%, transparent)` |
|
|
340
|
-
| `--table-shadow-color` | `color-mix(in srgb, var(--vc-shadow-color) 7%, transparent)` |
|
|
341
|
-
| `--actions-mix-color` | `var(--vc-mix-anchor)` |
|
|
342
|
-
| `--primary` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
343
|
-
| `--primary-actions` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
344
|
-
| `--primary-actions--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
345
|
-
| `--primary-actions--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
346
|
-
| `--primary-actions-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
347
|
-
| `--primary-actions-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
348
|
-
| `--primary-alternative` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
349
|
-
| `--primary-alternative-actions` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
350
|
-
| `--primary-alternative-actions--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
351
|
-
| `--primary-alternative-actions--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
352
|
-
| `--primary-alternative-actions-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
353
|
-
| `--primary-alternative-actions-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
354
|
-
| `--secondary` | `var(--vc-action-secondary)` (fills, borders); `var(--vc-content-secondary)` (text) |
|
|
355
|
-
| `--secondary-actions` | `var(--vc-action-secondary)` (fills, borders); `var(--vc-content-secondary)` (text) |
|
|
356
|
-
| `--secondary-actions--focus` | `var(--vc-action-secondary--hover)` (fills); `var(--vc-content-secondary--hover)` (text) |
|
|
357
|
-
| `--secondary-actions--pressed` | `var(--vc-action-secondary--pressed)` (fills); `var(--vc-content-secondary--pressed)` (text) |
|
|
358
|
-
| `--secondary-actions-bg--focus` | `var(--vc-action-secondary--subtle-hover)` |
|
|
359
|
-
| `--secondary-actions-bg--pressed` | `var(--vc-action-secondary--subtle-pressed)` |
|
|
360
|
-
| `--destructive` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
361
|
-
| `--destructive-actions` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
362
|
-
| `--destructive-actions--focus` | `var(--vc-action-danger--hover)` |
|
|
363
|
-
| `--destructive-actions--pressed` | `var(--vc-action-danger--pressed)` |
|
|
364
|
-
| `--destructive-actions-bg--focus` | `var(--vc-action-danger--subtle-hover)` |
|
|
365
|
-
| `--destructive-actions-bg--pressed` | `var(--vc-action-danger--subtle-pressed)` |
|
|
366
|
-
| `--error` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
367
|
-
| `--error-actions` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
368
|
-
| `--error-actions--focus` | `var(--vc-action-danger--hover)` |
|
|
369
|
-
| `--error-actions--pressed` | `var(--vc-action-danger--pressed)` |
|
|
370
|
-
| `--error-actions-bg--focus` | `var(--vc-action-danger--subtle-hover)` |
|
|
371
|
-
| `--error-actions-bg--pressed` | `var(--vc-action-danger--subtle-pressed)` |
|
|
372
|
-
| `--success` | `var(--vc-action-success)` (fills); `var(--vc-content-success)` (text) |
|
|
373
|
-
| `--success-actions` | `var(--vc-action-success)` (fills); `var(--vc-content-success)` (text) |
|
|
374
|
-
| `--success-actions--focus` | `var(--vc-action-success--hover)` |
|
|
375
|
-
| `--success-actions--pressed` | `var(--vc-action-success--pressed)` |
|
|
376
|
-
| `--success-actions-bg--focus` | `var(--vc-action-success--subtle-hover)` |
|
|
377
|
-
| `--success-actions-bg--pressed` | `var(--vc-action-success--subtle-pressed)` |
|
|
378
|
-
| `--warning` | `var(--vc-action-warning)` (fills); `var(--vc-content-warning)` (text) |
|
|
379
|
-
| `--warning-actions` | `var(--vc-action-warning)` (fills); `var(--vc-content-warning)` (text) |
|
|
380
|
-
| `--warning-actions--focus` | `var(--vc-action-warning--hover)` |
|
|
381
|
-
| `--warning-actions--pressed` | `var(--vc-action-warning--pressed)` |
|
|
382
|
-
| `--warning-actions-bg--focus` | `var(--vc-action-warning--subtle-hover)` |
|
|
383
|
-
| `--warning-actions-bg--pressed` | `var(--vc-action-warning--subtle-pressed)` |
|
|
384
|
-
| `--active-elements` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
385
|
-
| `--active-elements--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
386
|
-
| `--active-elements--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
387
|
-
| `--active-elements-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
388
|
-
| `--active-elements-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
389
|
-
| `--inactive-elements--focus` | `color-mix(in srgb, var(--vc-content-disabled) 80%, var(--vc-mix-anchor))` |
|
|
390
|
-
| `--inactive-elements--pressed` | `color-mix(in srgb, var(--vc-content-disabled) 65%, var(--vc-mix-anchor))` |
|
|
391
|
-
| `--inactive-elements-bg--focus` | `color-mix(in srgb, var(--vc-content-disabled) 10%, transparent)` |
|
|
392
|
-
| `--inactive-elements-bg--pressed` | `color-mix(in srgb, var(--vc-content-disabled) 20%, transparent)` |
|
|
393
|
-
| `--input-font-weight` (the weight of field text, `500`) | `--input-font-weight`, now the normal weight step `var(--vc-font-weight-normal)` |
|
|
394
|
-
|
|
395
|
-
### Tailwind colour classes
|
|
396
|
-
|
|
397
|
-
A colour name works the same after every colour prefix (`text-`, `bg-`, `border-`, `ring-`, `fill-`, `stroke-`, `divide-`, `outline-`, `placeholder-`, …) and with every variant: `text-default-text` becomes `text-content-primary`, `hover:bg-primary-actions-bg--focus` becomes `hover:bg-action-primary-subtle-hover`, `border-ui-lines` becomes `border-border`.
|
|
398
|
-
|
|
399
|
-
Text and icons in a status colour take the `content` name (`text-content-danger`, `text-content-success`). In most themes it is the same colour as the fill (`bg-action-danger`); voicenter draws success and warning text and icons darker than the fill.
|
|
400
|
-
|
|
401
|
-
`primary` and `secondary` are not status colours. Text and icons in `primary` (links, active tabs, outline and borderless buttons) take `var(--vc-content-brand)`, a deeper red than the `bg-action-primary` fill, with `var(--vc-content-brand--hover)` and `var(--vc-content-brand--pressed)`. Text and icons in `secondary` take `var(--vc-content-secondary)`, with `var(--vc-content-secondary--hover)` and `var(--vc-content-secondary--pressed)`; the border of an outline button is its text colour. The shipped Tailwind scheme has them as classes: `text-content-brand` with `-hover` and `-pressed`, and `text-content-secondary` with `-hover`. `content-secondary` is the 3.x `secondary-text`, a grey.
|
|
402
|
-
|
|
403
|
-
| 3.x colour name | 4.x colour name |
|
|
404
|
-
| --- | --- |
|
|
405
|
-
| `main-bg` | `page` |
|
|
406
|
-
| `light-bg` | `surface` |
|
|
407
|
-
| `card-bg-color` | `surface` |
|
|
408
|
-
| `dark-bg` | `inset-strong` |
|
|
409
|
-
| `field-bg` | `field` |
|
|
410
|
-
| `overlay-bg` | `overlay` (it carries its own transparency, as above) |
|
|
411
|
-
| `skeleton-loader` | `muted` |
|
|
412
|
-
| `skeleton-loader-animation` | no class |
|
|
413
|
-
| `scrollbar-track` | `surface` |
|
|
414
|
-
| `primary-text` | `content-primary` |
|
|
415
|
-
| `heading-text` | `content-primary` |
|
|
416
|
-
| `headers` | `content-primary` |
|
|
417
|
-
| `icons` | `content-primary` |
|
|
418
|
-
| `table-headings` | `content-primary` |
|
|
419
|
-
| `default-text` | `content-primary` |
|
|
420
|
-
| `secondary-text` | `content-secondary` |
|
|
421
|
-
| `placeholders` | `content-tertiary` |
|
|
422
|
-
| `inactive-text` | `content-disabled` |
|
|
423
|
-
| `inactive-elements` | `content-disabled` |
|
|
424
|
-
| `btn-filled-text` | `onfill-primary` |
|
|
425
|
-
| `default-loader` | `onfill-primary` |
|
|
426
|
-
| `ui-lines` | `border` |
|
|
427
|
-
| `major-ui-lines` | `border-strong` |
|
|
428
|
-
| `field-borders` | `input` |
|
|
429
|
-
| `scrollbar-thumb` | `border` |
|
|
430
|
-
| `scrollbar-thumb-hover` | `content-disabled` |
|
|
431
|
-
| `progress-line-done` | `action-success` |
|
|
432
|
-
| `progress-line-not-done` | `border` |
|
|
433
|
-
| `card-shadow-color` | no class; the `shadow-card` and `shadow-table` classes carry it |
|
|
434
|
-
| `table-shadow-color` | no class; the `shadow-table-row` and `shadow-table-header` classes carry it |
|
|
435
|
-
| `actions-mix-color` | no class |
|
|
436
|
-
| `primary` | `action-primary` (fills); `content-brand` (text) |
|
|
437
|
-
| `primary-actions` | `action-primary` (fills); `content-brand` (text) |
|
|
438
|
-
| `primary-actions--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
439
|
-
| `primary-actions--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
440
|
-
| `primary-actions-bg--focus` | `action-primary-subtle-hover` |
|
|
441
|
-
| `primary-actions-bg--pressed` | `action-primary-subtle-pressed` |
|
|
442
|
-
| `primary-alternative` | `action-primary` (fills); `content-brand` (text) |
|
|
443
|
-
| `primary-alternative-actions` | `action-primary` (fills); `content-brand` (text) |
|
|
444
|
-
| `primary-alternative-actions--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
445
|
-
| `primary-alternative-actions--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
446
|
-
| `primary-alternative-actions-bg--focus` | `action-primary-subtle-hover` |
|
|
447
|
-
| `primary-alternative-actions-bg--pressed` | `action-primary-subtle-pressed` |
|
|
448
|
-
| `secondary` | `action-secondary` (fills, borders); `content-secondary` (text) |
|
|
449
|
-
| `secondary-actions` | `action-secondary` (fills, borders); `content-secondary` (text) |
|
|
450
|
-
| `secondary-actions--focus` | `action-secondary-hover` (fills); `content-secondary-hover` (text) |
|
|
451
|
-
| `secondary-actions--pressed` | `action-secondary-pressed` (fills); `var(--vc-content-secondary--pressed)` in a style (text) |
|
|
452
|
-
| `secondary-actions-bg--focus` | `action-secondary-subtle-hover` |
|
|
453
|
-
| `secondary-actions-bg--pressed` | `action-secondary-subtle-pressed` |
|
|
454
|
-
| `destructive` | `action-danger` (fills); `content-danger` (text) |
|
|
455
|
-
| `destructive-actions` | `action-danger` (fills); `content-danger` (text) |
|
|
456
|
-
| `destructive-actions--focus` | `action-danger-hover` |
|
|
457
|
-
| `destructive-actions--pressed` | `action-danger-pressed` |
|
|
458
|
-
| `destructive-actions-bg--focus` | `action-danger-subtle-hover` |
|
|
459
|
-
| `destructive-actions-bg--pressed` | `action-danger-subtle-pressed` |
|
|
460
|
-
| `error` | `action-danger` (fills); `content-danger` (text) |
|
|
461
|
-
| `error-actions` | `action-danger` (fills); `content-danger` (text) |
|
|
462
|
-
| `error-actions--focus` | `action-danger-hover` |
|
|
463
|
-
| `error-actions--pressed` | `action-danger-pressed` |
|
|
464
|
-
| `error-actions-bg--focus` | `action-danger-subtle-hover` |
|
|
465
|
-
| `error-actions-bg--pressed` | `action-danger-subtle-pressed` |
|
|
466
|
-
| `success` | `action-success` (fills); `content-success` (text) |
|
|
467
|
-
| `success-actions` | `action-success` (fills); `content-success` (text) |
|
|
468
|
-
| `success-actions--focus` | `action-success-hover` |
|
|
469
|
-
| `success-actions--pressed` | `action-success-pressed` |
|
|
470
|
-
| `success-actions-bg--focus` | `action-success-subtle-hover` |
|
|
471
|
-
| `success-actions-bg--pressed` | `action-success-subtle-pressed` |
|
|
472
|
-
| `warning` | `action-warning` (fills); `content-warning` (text) |
|
|
473
|
-
| `warning-actions` | `action-warning` (fills); `content-warning` (text) |
|
|
474
|
-
| `warning-actions--focus` | `action-warning-hover` |
|
|
475
|
-
| `warning-actions--pressed` | `action-warning-pressed` |
|
|
476
|
-
| `warning-actions-bg--focus` | `action-warning-subtle-hover` |
|
|
477
|
-
| `warning-actions-bg--pressed` | `action-warning-subtle-pressed` |
|
|
478
|
-
| `active-elements` | `action-primary` (fills); `content-brand` (text) |
|
|
479
|
-
| `active-elements--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
480
|
-
| `active-elements--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
481
|
-
| `active-elements-bg--focus` | `action-primary-subtle-hover` |
|
|
482
|
-
| `active-elements-bg--pressed` | `action-primary-subtle-pressed` |
|
|
483
|
-
| `inactive-elements--focus` | no class |
|
|
484
|
-
| `inactive-elements--pressed` | no class |
|
|
485
|
-
| `inactive-elements-bg--focus` | no class; disabled fields use `bg-inset` |
|
|
486
|
-
| `inactive-elements-bg--pressed` | no class |
|
|
487
|
-
|
|
488
|
-
### Theme keys
|
|
489
|
-
|
|
490
|
-
A `customJson` or `remote` theme passes the 4.x keys ([Theming specification](#theming-specification)). Where several 3.x keys become one 4.x key, the theme sets it once. When those keys had different values, this is a choice of one colour for all of them, made by whoever owns the theme, not a rename: `default-text`, `primary-text` and `heading-text` are one `vc-content-primary`, `primary` and `primary-alternative` one `vc-action-primary`. An application can also leave its own theme for a built-in one (`type: 'local'`). A 4.x theme sets only base colours: the hover, pressed and tinted states are mixed by the library. A key the theme leaves out takes the default theme's value, as the Theming specification describes.
|
|
491
|
-
|
|
492
|
-
Keys with no 3.x key of their own: `vc-bg-inset`, `vc-ring`, `vc-onfill-warning`, the anchors of single fills `vc-mix-anchor-{fill}` (the built-in themes set `vc-mix-anchor-primary` and `vc-mix-anchor-warning`; set them as `actions-mix-color` was set), `vc-action-info`, `vc-content-info` and `vc-content-brand` (the text of the 3.x `primary`, where 4.x draws the text deeper than the fill).
|
|
493
|
-
|
|
494
|
-
A remote branding section gets the `vc-*` keys before the application is upgraded: a 3.x application ignores them, and a 4.x application ignores the 3.x keys, so every key it does not receive takes the default theme's value.
|
|
495
|
-
|
|
496
|
-
| 3.x theme key | 4.x theme key |
|
|
497
|
-
| --- | --- |
|
|
498
|
-
| `main-bg` | `vc-bg-page` |
|
|
499
|
-
| `light-bg` | `vc-bg-surface` |
|
|
500
|
-
| `card-bg-color` | `vc-bg-surface` |
|
|
501
|
-
| `dark-bg` | `vc-bg-inset-strong` |
|
|
502
|
-
| `field-bg` | `vc-bg-field` |
|
|
503
|
-
| `overlay-bg` | `vc-bg-overlay`: it carries its own transparency (3.x components mixed `--overlay-bg` to 40%, so a 3.x value `X` becomes `color-mix(in srgb, X 40%, transparent)`) |
|
|
504
|
-
| `skeleton-loader` | `vc-bg-muted` |
|
|
505
|
-
| `skeleton-loader-animation` | none: mixed from `vc-bg-surface` |
|
|
506
|
-
| `scrollbar-track` | `vc-bg-surface` |
|
|
507
|
-
| `default-text` | `vc-content-primary` |
|
|
508
|
-
| `primary-text` | `vc-content-primary` |
|
|
509
|
-
| `heading-text` | `vc-content-primary` |
|
|
510
|
-
| `headers` | `vc-content-primary` |
|
|
511
|
-
| `icons` | `vc-content-primary` |
|
|
512
|
-
| `table-headings` | `vc-content-primary` |
|
|
513
|
-
| `secondary-text` | `vc-content-secondary` |
|
|
514
|
-
| `placeholders` | `vc-content-tertiary` |
|
|
515
|
-
| `inactive-text` | `vc-content-disabled` |
|
|
516
|
-
| `inactive-elements` | `vc-content-disabled` |
|
|
517
|
-
| `scrollbar-thumb-hover` | `vc-content-disabled` |
|
|
518
|
-
| `btn-filled-text` | `vc-onfill-primary` (text on the primary fill); `vc-onfill` for the other fills |
|
|
519
|
-
| `default-loader` | `vc-onfill-primary` |
|
|
520
|
-
| `ui-lines` | `vc-border` |
|
|
521
|
-
| `scrollbar-thumb` | `vc-border` |
|
|
522
|
-
| `major-ui-lines` | `vc-border-strong` |
|
|
523
|
-
| `progress-line-not-done` | `vc-border` |
|
|
524
|
-
| `field-borders` | `vc-input` |
|
|
525
|
-
| `card-shadow-color` | `vc-shadow-color`: a dark base colour the library mixes down (12% for cards here); the 3.x light-grey value is not reused |
|
|
526
|
-
| `table-shadow-color` | `vc-shadow-color`: a dark base colour the library mixes down (7% for tables here); the 3.x light-grey value is not reused |
|
|
527
|
-
| `actions-mix-color` | `vc-mix-anchor`, and `vc-mix-anchor-{fill}` for a fill with its own anchor (the built-in themes set `vc-mix-anchor-primary` and `vc-mix-anchor-warning`) |
|
|
528
|
-
| `primary` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
529
|
-
| `primary-alternative` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
530
|
-
| `active-elements` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
531
|
-
| `secondary` | `vc-action-secondary` (fills, borders); `vc-content-secondary` (text) |
|
|
532
|
-
| `destructive` | `vc-action-danger` (fills); `vc-content-danger` (text) |
|
|
533
|
-
| `error` | `vc-action-danger` (fills); `vc-content-danger` (text) |
|
|
534
|
-
| `success` | `vc-action-success` (fills); `vc-content-success` (text) |
|
|
535
|
-
| `progress-line-done` | `vc-action-success` |
|
|
536
|
-
| `warning` | `vc-action-warning` (fills); `vc-content-warning` (text and icons) |
|
|
537
|
-
| `transparent` | none: not a theme key |
|
|
538
|
-
| `current` | none: not a theme key |
|
|
539
|
-
| `white` | none: not a theme key |
|
|
540
|
-
| `black` | none: not a theme key |
|
|
541
|
-
|
|
542
|
-
### Finding the 3.x names
|
|
543
|
-
|
|
544
|
-
A 3.x name in `@apply` or in `theme('colors.…')` fails the Tailwind build. In a template class or in `var(--…)` it fails silently: the class is not generated and the variable is not set. This finds them in an application (any hit is a 3.x name; the 4.x names do not match):
|
|
545
|
-
|
|
546
|
-
```bash
|
|
547
|
-
n='(main|light|dark|field|overlay)-bg|card-bg-color|skeleton-loader(-animation)?|scrollbar-(track|thumb(-hover)?)|(primary|heading|default|secondary|inactive|btn-filled)-text|headers|icons|table-headings|placeholders|default-loader|(major-)?ui-lines|field-borders|progress-line-(not-)?done|(card|table)-shadow-color|actions-mix-color|(primary(-alternative)?|secondary|destructive|error|success|warning)(-actions)?|(active|inactive)-elements'
|
|
548
|
-
s='(-bg)?(--(focus|pressed))?'
|
|
549
|
-
grep -rnE "(var\(|['\"])--($n)$s[,)'\"]|(^|[^a-zA-Z0-9_-])(text|bg|border(-[xytrblse])?|ring(-offset)?|fill|stroke|divide|outline|placeholder|shadow|from|via|to|caret|accent|decoration)-($n)$s([^a-zA-Z0-9_-]|$)" src index.html tailwind.config.*
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
Add every other folder of the application with templates or styles. The Tailwind configuration counts too: a 3.x variable in its `boxShadow` or `colors` draws nothing, with no error. A class name composed in SCSS (`bg-#{$color}`) or in a JS string (`` `bg-${color}` ``) does not match the pattern either: search the parts that make such names (`#{`, `-actions`, `-elements`, `-text`) as well, and the lists those variables take their values from.
|
|
553
|
-
|
|
554
|
-
Colour prop values that name a Tailwind colour (`VcCollapseItem` `color-icon` and `color-border`, `VcLoading` `color`) do not match this pattern; check them separately.
|
|
555
|
-
|
|
556
|
-
The theme keys of a `customJson` configuration (`colors.json`) and of a remote branding section move to the `vc-*` keys of the table above. An application with `type: 'none'` sets the 4.x variables itself. `onSetupCallback(theme)` receives the theme with its `vc-*` keys.
|
|
557
|
-
|
|
558
|
-
### Icons
|
|
559
|
-
|
|
560
|
-
The components draw Lucide icons (`@lucide/vue`) where 3.x drew the `vc-icon-*` font, and the default icon of an icon prop is a Lucide component. A style that targets a `vc-icon-*` class inside a component no longer matches. An icon prop still takes a `vc-icon-*` class, drawn by the icon font that `style.css` loads (`injectIconFont` only inside a shadow root, see "Installation").
|
|
561
|
-
|
|
562
|
-
### Styles and component defaults
|
|
563
|
-
|
|
564
|
-
| What | 3.x | 4.x |
|
|
565
|
-
| --- | --- | --- |
|
|
566
|
-
| Close and maximize controls of VcModal, the close control of a notification, the copy control of VcCodeBlock | native buttons with the classes `vc-dialog-header-icon`, `vc-link`, `vc-dialog-header-maximize-icon`, `vc-dialog-header-close-icon` and `vc-toast-close-icon`; the copy control read `--code-block-muted` and `--code-block-selection` | a small secondary VcButtonIcon; those classes are gone (`vc-dialog-header-close`, `vc-dialog-header-maximize`, `vc-toast-icon-close` and `vc-code-block__copy` stay), and the copy control takes the colours of VcButtonIcon instead of `--code-block-muted` and `--code-block-selection` |
|
|
567
|
-
| `--base-border-radius` | set on `<html>` by the theme setup | removed; corners read the component radii `--vc-radius-*` (`--vc-radius-control` for controls) |
|
|
568
|
-
| The radius keys of the shipped `tailwind.config.js` | `xs`, `sm` (0.25rem), `md`, `lg`, `xl`, `xxl`, `tag`, `DEFAULT` (`rounded`) and `horizontal-tab-*` | the radius roles (see "Corners"), `none` and `full`. An application keeps Tailwind's own scale, and its `extend.borderRadius` from the shipped configuration adds the roles: `rounded-sm` is Tailwind's, and `rounded-xs`, `rounded-xxl` and `rounded-horizontal-tab-*` are not generated. A configuration that takes the whole shipped file instead of the keys "Tailwind" lists, such as `merge(require('@voicenter-team/voicenter-ui-plus/tailwind.config'), ownConfig)` with lodash `merge`, has only the roles, `none` and `full`. `borderRadius: require('tailwindcss/defaultTheme').borderRadius` in its own `theme` brings Tailwind's scale back beside the roles, since `merge` joins the two objects. With it `rounded-sm` is 0.125rem (3.x: 0.25rem; `rounded` is the 0.25rem one), and `rounded-2xl` and `rounded-3xl` are generated, which 3.x did not generate. An application with a `theme.borderRadius` of its own (a copy of the 3.x scale) removes it, takes the roles through `extend.borderRadius` and moves its `rounded-*` classes to the roles, by what each element is and not by its 3.x size ([Corners](#corners)) |
|
|
569
|
-
| The font keys of the shipped `tailwind.config.js` and the font classes of the library stylesheet | `main`, `rubik`, `inter` and `heebo`, all four Rubik | `main` only: `font-inter`, `font-heebo` and `font-rubik` are removed; replace them with `font-main`. `@apply font-inter` (or `font-heebo`, `font-rubik`) and `theme('fontFamily.inter')` fail the build. In a template the class is not generated, and text without it inherits whatever font its container sets, so the class is replaced rather than dropped |
|
|
570
|
-
| The component colours `primary-alternative` and `active`: the value of `color` and of any prop that takes a component colour (`prefixIconColor`, `tagColor`, `buttonColor`, `filledColor`, `confirmActionColor`, the `colorKey` of an option) | `primary-alternative` drew a colour of its own, `active` drew `active-elements` | removed: `componentColors` and `COMPONENT_COLOR_TYPE` no longer list them, and no class is generated for them. A project replaces every `primary-alternative` with `primary`, and every `active` given as a colour (`color="active"`, `prefix-icon-color="active"`) with `primary`: both draw the brand colour, and 4.x has no second accent colour. A style that targets their colour classes (`vc-button-color--primary-alternative`, `vc-input--active`, `vc-switch-color-active`, …) targets the `primary` class |
|
|
571
|
-
| The default `color` of VcInput, VcAutocomplete, VcPhoneInput, VcOtpInput, VcTimeInput, VcTagInput, VcSwitch and VcExtendedDatetimeRangePicker; `DEFAULT_COLOR` | `'active'` | `'primary'` |
|
|
572
|
-
| `shadow-hover-outer-active`, `shadow-hover-outer-primary-alternative` | the hover glow of the `active` and `primary-alternative` colours | removed; `shadow-hover-outer-primary` |
|
|
573
|
-
| `shadow-hover-outer-destructive` | the hover glow of the `destructive` colour | `shadow-hover-outer-danger`: a glow class is named by its fill, as `bg-action-danger` |
|
|
574
|
-
| The hover outline of VcCard with `hovered` | replaces the card shadow | fades in over the card shadow, which stays |
|
|
575
|
-
| `shadow-focus-outer`, `shadow-focus-outer-{primary,secondary,destructive,success,warning,info}`, `shadow-focus-{primary,secondary,destructive,success,warning}` | a focus glow in the colour the class names | removed; `shadow-focus`, the one focus ring, which has no colour of its own. A project whose Tailwind configuration defines these keys itself keeps them |
|
|
576
|
-
| `shadow-hover`, `shadow-hover-{primary,secondary,destructive,success,warning}` | a hover glow, outside and inside, in the colour the class names | removed: no component used them. `shadow-hover-inner`, `shadow-hover-outer`, `shadow-hover-outer-{colour}` and `shadow-hover-outer-off` stay. A project whose Tailwind configuration defines these keys itself keeps them |
|
|
577
|
-
| `tagBorderless` and `tagColor` of VcTagInput and VcTreeSelect | `false`, `'primary'` | `true`, `''`: a value is a borderless chip with no colour, neutral like a VcSelect multiple value (label and close icon `content-secondary`); set them for bordered, coloured tags. `tag-color="secondary"` draws the secondary colour, `action-secondary`, as on any other tag. A 3.x `tag-color` alone now gives a borderless chip in that colour; `:tag-borderless="false"` brings back the 3.x bordered tag |
|
|
578
|
-
| `DEFAULT_ICON_SIZE`, the default `prefixIconSize` of VcInput, VcAutocomplete, VcPhoneInput and VcExtendedDatetimeRangePicker | `'sm'` | `''`: no size class, so the prefix icon follows the size of the field and is larger at the default size; `prefix-icon-size="sm"` keeps the 3.x size |
|
|
579
|
-
| `iconClass` of VcSoundPlayerMarker | `'icon-md'` | `'icon-xs'`: the icon sits on a filled circle of the marker colour |
|
|
580
|
-
| The code font of VcCodeBlock, VcJsonViewer, VcToolCall, VcApprovalCard, the code in VcMdEditor and the labels of VcSipFlow | each its own list of system monospace fonts (VcMdEditor `JetBrains Mono` first, VcSipFlow `monospace` and `serif`) | DM Mono (`var(--vc-font-mono)`), loaded with Rubik, the system monospace fonts as fallback; `--vc-json-viewer-mono-font`, `--vc-tool-call-mono-font` and `--vc-approval-card-mono-font` still override it |
|
|
581
|
-
| Icon sizes inside the components: the default `iconClass` of VcPlayerPlayStopButton, the default `iconClasses` of VcPlayerPlaybackRate and VcPlayerPlaybackRatePopup, the `size` icons of VcSoundPlayer, the `large` icon of VcDatePicker, and the icons of VcPdfDocument's footer, VcTree, VcTreeSelect, VcImageUploader, VcIconPicker, VcSummaryStep, VcFileImportErrorsCard and VcExtendedDatetimeRangePicker | `icon-lg` (22px), `icon-2xl` (30px) | `icon-xl` (24px), `icon-2r` (32px): the icon sizes of the design (12 / 14 / 16 / 20 / 24 / 32). The classes themselves keep their sizes; pass the old class to keep the 3.x size |
|
|
582
|
-
| `borderRadius` of VcMeterGroup | `'6px'` | `'var(--vc-radius-inner)'`, the inner radius role |
|
|
583
|
-
| `StatusProgressConfig`, the type of the `statusColorMap` prop of VcProgressCircular | `Record<string, string>` | `Partial<Record<StatusProgress, string>>`: its keys are the `StatusProgress` values, each optional, so an object literal with another key, or code that reads another key, fails the type check |
|
|
584
|
-
| `VcTagInputColor`, exported from the package root | `'active' \| 'primary' \| 'secondary' \| 'destructive'` | removed: no prop took it. The `color` of VcTagInput is `COMPONENT_COLOR_TYPE` and its `tagColor` is `VcTagColorType` |
|
|
585
|
-
| `VcDatetimeRangePicker` and the types `VcPresetRangesType` and `VcDatetimeRangePickerModelType` | the component drew only a notice that it is deprecated | removed. `<VcDatetimeRangePicker>` becomes `<VcDatePicker type="datetimerange">` (or another `type`), or `VcExtendedDatetimeRangePicker` where the field has quick ranges; an import of the component or of the two types is deleted |
|
|
586
|
-
| `beforeStepFn` and `onEnterStepFn` of a `VcWizard` step (`VcWizardStepType`) | read as `validateStepFn` and `initStepFn`, with a console warning | removed, and a step that still sets them is neither validated nor initialised, with no error: rename `beforeStepFn` to `validateStepFn` and `onEnterStepFn` to `initStepFn` |
|
|
587
|
-
| `BindResultObjectType<T>`, exported from the package root | an alias of `BindingRowItemType<T>` | removed; replace it with `BindingRowItemType<T>` |
|
|
588
|
-
| The `columns` prop of VcTable | `ColumnType`: columns of `Record<string, unknown>` rows, whatever the rows of the table | `ColumnType<Row>`, `Row` being the type of the table's `options`: `format` and `sortableFunction` receive the row with its type. Columns declared for another row type than the table's fail the type check; declare them as `ColumnType<Row>` |
|
|
589
|
-
| `TEXT_COLORS`, exported from the package root | the Tailwind text class of each component colour (`text-primary`, `text-secondary-actions`, …) | removed; `textColorClass(color)` returns the text class of a component colour, `vc-text-color--<colour>` from the library stylesheet, and `text-<key>` for a Tailwind colour key |
|
|
590
|
-
| The default slot of VcButton and the value of VcBadgeTag | direct children of `.vc-button--content` and of the badge | inside `span.vc-button__label` and `span.vc-badge-tag__value`, which trim the label box to its capitals so the control centres them; a selector that reaches the slot content as a direct child (`.vc-button--content > span`) no longer matches it |
|
|
591
|
-
| `font-normal`, `font-medium`, `font-semibold` | `400`, `500`, `600` | `380`, `480`, `600` (`--vc-font-weight-*`): the three weights of the components' text, in an application too once it takes `extend.fontWeight` (see "Tailwind") |
|
|
592
|
-
| Page text, `b` and `strong`, table headers (`th`) | `400`, `bolder`, the browser's bold | `font-normal`, `font-semibold`, `font-medium` |
|
|
593
|
-
| `font-bold`, `font-extrabold`, `font-black`; `font-thin`, `font-extralight`, `font-light` in an application | Tailwind's weights | unchanged; the 4.x text has the three weights above, so replace the first three with `font-semibold` and the other three with `font-normal` |
|
|
594
|
-
| The colour of an `info` or `warning` notification (`NotifyService`, `$notify`) | `info`: `primary-actions`, the brand colour; `warning`: `warning` | `content-info` and `content-warning`: a notification takes the text colour of the component colour of its type, as `success` takes `content-success` and `error` takes `content-danger` |
|
|
595
|
-
| The border and clear icon of VcTagInput with a `color` | a glow on hover; when focused, the border of the colour | no glow: for every colour, `info` included, the border warms toward the colour on hover and takes the colour's hover shade when focused; the clear icon is the colour's text colour and darkens from it on hover |
|
|
596
|
-
| `color` and `prefixIconColor` of VcTreeSelect | the field drew the same colour whatever its `color` (the colour class did not reach it); a `prefixIconColor` other than `active`, `primary` and `destructive` drew `active-elements` | the field takes its `color` as VcTagInput does: the border warms toward the colour on hover and takes the colour's hover shade while the tree is open; the prefix icon takes the text colour of its `prefixIconColor`, for every colour |
|
|
597
|
-
| The rings of the `circles` loader of VcLoading with a `color` other than `primary`, `secondary` and `destructive` | three rings of the one colour | the outer ring is the colour, the second and third its hover and pressed shades, as for `primary`, `secondary` and `destructive` |
|
|
598
|
-
| The text of an unchecked VcRadioButtonsGroup button on hover | `primary`: the brand colour itself; the other colours: the hover shade of the fill | the hover shade of the colour's text colour, `primary` included: `primary` darkens on hover (lightens in `black`) as the others do, and `success` and `warning` mix from their text colour, which in voicenter is darker than the fill |
|
|
599
|
-
| The tick of a checked VcCheckbox, the text of a checked VcCheckboxButton and the text inside a VcProgress bar, for a fill other than `primary` | `btn-filled-text`, on every fill | the on-fill colour of that fill, as on a filled button: on the `warning` fill it is `onfill-warning`, dark in voicenter |
|
|
600
|
-
| A status that the `statusColorMap` of VcProgressCircular leaves out, when the map has no `default` key | `primary-alternative-actions`, the library's default | the fill of that status |
|
|
601
|
-
| The text and underline of a `success` or `warning` VcHyperLink | the fill colour (`success-actions`, `warning-actions`) | the text colour, `content-success` or `content-warning`, for the text and the underline alike: every colour's underline is the colour of its text. In voicenter these are darker than the fill |
|
|
602
|
-
| The clear icon of a VcInput or VcAutocomplete with a `color`, on hover | the hover shade of the fill | the hover shade of the colour's text colour, the colour the icon has at rest: unchanged for `primary`, `secondary`, `destructive` and `info`; for `success` and `warning` in voicenter, whose text is darker than the fill, darker than before |
|
|
603
|
-
| Slot content of a VcRadio with a `color` that reads `active-elements` (4.x: `action-primary`) | the radio's colour: the radio redefined `--active-elements` | the brand colour: the radio sets its own `--vc-radio-color` and redefines no theme variable |
|
|
604
|
-
| Slot content of VcFileUploaderArea that reads `icons` (4.x: `content-primary`) | `secondary-text`: the area redefined `--icons` | `content-primary`: the area colours its own label, drop text and file names `content-secondary` and redefines no theme variable |
|
|
605
|
-
|
|
606
|
-
### AI chat components
|
|
607
|
-
|
|
608
|
-
4.x adds the components `VcAiReasoning`, `VcToolCall`, `VcApprovalCard`, `VcAskUserCard`, `VcAgentRunCard`, `VcAgentRunGroup`, `VcJsonViewer`, `VcLightbox` and `VcPdfViewer` (their packages: [Optional peers](#optional-peers)). `VcMessage`, `VcMessagesWrapper`, `VcChatComposer` and `VcFileItem` gained props, slots and events for AI chats; existing usages render as before. What can need a change in an application:
|
|
609
|
-
|
|
610
|
-
- **`@milkdown/*` must be `^7.22.0`** (was `^7.15.5`). With the `prosemirror-model` that npm resolves today (1.25.12), milkdown before 7.22.0 fails to parse lists (`RangeError: Expected value of type boolean for attribute spread`), and every list of a `VcMdEditor` disappears. A lockfile that still holds an older `prosemirror-model` hides the problem until the next fresh install.
|
|
611
|
-
- **`VcMdEditor` in `readonly` lays out its text by the text's own direction and treats it as untrusted.** Every paragraph, heading, list, quote, table and cell takes its direction from its own text instead of the page's (`<html dir>` at mount, or the direction button): English text in an RTL page now reads left to right, a Hebrew paragraph in an LTR page right to left, a block without letters follows the text around it, and code reads left to right. A link with a protocol other than http(s), mailto and tel loses its `href`, web links open in a new tab (`target="_blank" rel="noopener noreferrer"`), and the table handles are hidden. An editable editor is unchanged. New in `VcMdEditor`: `streaming` (throttled updates and a caret while an AI answer arrives) and `plain` (no field around the text, for bubbles and cards); `minHeight` takes the number `0` (it fell back to 400px, so callers passed the string `'0'`).
|
|
612
|
-
- **`VcMessagesWrapper` is generic** over the message type: extend `VcChatMessage` with your own fields and the slots and events keep your type. `InstanceType<typeof VcMessagesWrapper>` no longer type-checks for a template ref; use the exported interface:
|
|
613
|
-
|
|
614
|
-
```diff
|
|
615
|
-
- const wrapper = ref<InstanceType<typeof VcMessagesWrapper>>()
|
|
616
|
-
+ import type { VcMessagesWrapperExposed } from '@voicenter-team/voicenter-ui-plus'
|
|
617
|
-
+ const wrapper = ref<VcMessagesWrapperExposed>()
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
- **`VcChatMessage.createdAt` is optional.** A message without it starts no date divider and shows no time (AI SDK messages have no timestamp). Code that passes `message.createdAt` on to something that does not accept `undefined` needs a guard, or a message type of your own with a required `createdAt`.
|
|
621
|
-
- **`VcMessageContent` has a `markdown` block** (`{ type: 'markdown', text, streaming? }`). An exhaustive `switch` or a `Record<VcMessageContentType, …>` over the content types needs the new case.
|
|
622
|
-
- **`VcMessage`'s `content` also accepts an array** of blocks, rendered in order in one bubble. `VcChatMessage.content` stays a single block; several blocks in a wrapper go through its `message` slot.
|
|
623
|
-
- **`VcMessage` colours changed.** In 3.x own messages used `--dark-bg` / `--btn-filled-text`, a contrast of 1.13–1.42:1 in every light theme, and the quote of an incoming message used the same pair. In 4.x others' bubbles are `--vc-bg-muted` and own ones (`align="end"`) the blue tint `--vc-action-info--subtle-hover`, both with `--vc-content-primary` text, so a bubble shows on a white card; the quote inside is `--vc-bg-surface`. The variables keep their 3.x names (`--vc-message-bg`, `--vc-message-text`, `--vc-message-reply-bg`, `--vc-message-reply-text`): a project that sets them keeps working, with any 3.x theme variable in their values replaced by its 4.x token. Markdown links in bubbles take the text colour. A project that styled around the old dark own bubble (e.g. white icons in a custom `footer`) should check its contrast.
|
|
624
|
-
- **Disabled tabs are no longer faded.** In `VcVerticalTabs` a disabled tab was drawn at 50% opacity; now, as in `VcTabs` and `VcRadioTabs`, its label and icon are `--vc-content-disabled`, with a not-allowed cursor, and hover or focus does not recolour it. A project that adds its own opacity to disabled tabs should remove it.
|
|
625
|
-
- **`VcTour`'s mask is `--vc-bg-overlay`.** `VcModal` already used it; `VcTour`'s mask (black at 50%) now takes it too. A `color` set in `VcTour`'s `mask` prop still wins.
|
|
626
|
-
- **`VcSkeletonLoader` stops its sweep under reduced motion.** When the system asks for reduced motion (`prefers-reduced-motion: reduce`) the shine no longer moves; the grey shapes stay as they were.
|
|
627
|
-
- **`VcViewSwitcher` is removed; `VcSegmented` takes its place.** `<VcViewSwitcher>` becomes `<VcSegmented variant="surface">` with the same `v-model`, `options`, `config` and `disabled`: `variant="surface"` draws the selected segment as the raised pill the switcher had, and `config` takes the same keys (`labelKey`, `valueKey`, `iconKey`, `disabledKey`, `disabledHintKey`). What changes in the template:
|
|
628
|
-
- the slot `tab-item` is `default`; its props are `item` (the option as passed), `option` (the mapped option, as before) and `isActive`;
|
|
629
|
-
- `@change` receives `(value, option)`, where the switcher passed the option alone;
|
|
630
|
-
- `data-test-name="x"` becomes the attribute `data-test="x"`;
|
|
631
|
-
- a style on `.vc-view-switcher`, `.vc-view-switcher-item` and `.vc-view-switcher-item--active` moves to `.vc-segmented`, `.el-segmented__item` and `.el-segmented__item.is-selected`;
|
|
632
|
-
- a segment is as high as a control of its `size`, lower than the switcher was; a row of options too wide for its container goes into a container that scrolls.
|
|
633
|
-
|
|
634
|
-
An application that already used `VcSegmented` checks its `@change`: the second argument is the picked option, where it was the earlier value. `VcSegmented` has no `color` prop: the selected segment is the primary fill (`variant="solid"`) or the surface pill (`variant="surface"`), so `color="…"` is removed from the tag. The selected segment is drawn on the segment itself, and `.el-segmented__item-selected` is shown only while the selection slides to another segment: a style on `.el-segmented__item-selected` moves to `.el-segmented__item.is-selected`, and a colour of the selected segment is set with `--el-segmented-item-selected-bg-color`, which both read.
|
|
635
|
-
- **`VcDatePicker` fills its container.** Date, date-time and range fields had the fixed Element Plus widths (220px a date, 350px a range, 400px a date-time range); a field is now as wide as its container, like `VcInput` and `VcSelect`. In a toolbar or filter bar it takes its width from a class (`class="w-44"`) or from its container.
|
|
636
|
-
- **`VcTable` has three densities, and `compact` is gone.** The `density` prop takes `'compact' | 'default' | 'large'`. A table with no props has the look `compact` gave in 3.x (14px text, rows about 36px), so `compact` is removed from the template. `density="large"` is the 3.x default look (16px text, rows about 43px); `density="compact"` is denser than 3.x had (12px text, rows about 28px, for small buttons and tags in its cells). The class `vc-table--small` is gone: a style written for it moves to `.vc-table--density-default`.
|
|
637
|
-
- **`VcTable` stacks into cards only on phones.** The stacked-card layout (header row hidden, each cell labelled) now starts at 440px of screen width instead of 780px, so a tablet or a narrow window keeps the table. A project that relied on the cards between 441 and 780px should check its tables there.
|
|
638
|
-
- **The `actions` slot of `VcChatComposer` (3.4.8) is `toolbar-start`**, with the slot props `{ disabled, streaming }`; `toolbar-end` (new) sits right before Send / Stop.
|
|
639
|
-
- **`VcMessagesWrapper`'s `scrollToMessage` takes options**, as in 3.4.8: `scrollToMessage(id, 'auto')` of 3.4.7 and earlier becomes `scrollToMessage(id, { behavior: 'auto' })`, and `block` and `offset` place the message. It scrolls only the wrapper, not the page, and the view stays on the message while the list grows below it.
|
|
640
|
-
- **Exported types**: `VcFileItemProps` (with the new `errorText`), `VcChatComposerEmits`, and props / emits / slot-props / exposed interfaces of every new component.
|
|
641
|
-
- **Localization**: the library ships only `en`. An application with another locale adds the keys new since 3.4.8 with `tVUManage.updateLocaleMessages`: `voicenterUi.jsonViewer.*`, `voicenterUi.aiChat.*`, `voicenterUi.lightbox.*`, `voicenterUi.aiReasoning.*`, `voicenterUi.toolCall.*`, `voicenterUi.approvalCard.*`, `voicenterUi.askUserCard.*`, `voicenterUi.agentRun.*`, `voicenterUi.agentRunGroup.*`, `voicenterUi.pdfViewer.*`, `voicenterUi.filterBar.*`, `voicenterUi.messagesWrapper.jumpToBottom`, `voicenterUi.message.download`, `voicenterUi.chatComposer.stop`, `voicenterUi.chatComposer.stopGenerating`, `voicenterUi.chatComposer.unsupportedFile`, `voicenterUi.fileItem.preview`, `voicenterUi.fileItem.remove` (English texts in `src/localization/locales/en.json`). An application on 3.4.7 or earlier also adds the keys of 3.4.8: `voicenterUi.message.video`, `voicenterUi.message.status.*`, `voicenterUi.messagesWrapper.newMessages`.
|
|
642
|
-
|
|
643
|
-
Fixes in the components 3.x had:
|
|
644
|
-
|
|
645
|
-
- **PDFs open without `eval` (CVE-2024-4367).** pdf.js before 4.2.67 compiles font glyphs with `eval`, so a crafted PDF could run JavaScript in the page. `VcPdfDocument` and `VcPdfViewer` now pass `isEvalSupported: false` to `getDocument` (no caller can turn it back on); pdf.js draws the glyphs through its slower interpreted path, the text looks the same. The lasting fix is `pdfjs-dist` 4.2.67 or newer, a separate upgrade of the peer (the library still declares `^2.16.105`).
|
|
646
|
-
- **Lists in `VcMdEditor`** render again with `@milkdown/*` `^7.22.0` (see above).
|
|
647
|
-
- **Code blocks in `VcMdEditor`** take the theme's colours. Copy is a secondary text action (`--vc-content-secondary` text and icon, the `--vc-action-secondary--subtle-hover` hover, a focus ring, visible while it has keyboard focus) instead of Crepe's grey pill without hover or focus states; the line numbers, fold markers, folded-code placeholder, cursor and selection use the theme variables instead of One Dark's colours. The syntax colours are unchanged. Read-only, a code block is framed (`--vc-border`, on `--vc-bg-surface` in `--vc-content-primary`) with no line numbers, active line or language button, Copy floats in its corner on hover or focus, a long line scrolls with a visible scrollbar, and inline code wraps instead of running past the column.
|
|
648
|
-
|
|
649
|
-
## Upgrading from a 4.0 beta
|
|
650
|
-
|
|
651
|
-
An application on a 4.0 beta has moved from 3.x with [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) as its beta shipped it. That section describes the current release; the table below lists what such an application changes or checks on the way there. A row names the last release without the change, so the application takes every row whose release is the one it has installed (the `version` its `package.json` or lock file gives for the library before the upgrade) or a later one: an application on `4.0.0-beta.3` takes the rows of `4.0.0-beta.3`, `4.0.0-beta.4` and `4.0.0-beta.5`.
|
|
652
|
-
|
|
653
|
-
Additions that ask nothing of an application (new components, props, theme keys and classes) are not rows: they are in the sections above and in the [live documentation](https://voicenter-ui-plus.pages.dev/).
|
|
654
|
-
|
|
655
|
-
| Changed after | What changed | What the application does |
|
|
656
|
-
| --- | --- | --- |
|
|
657
|
-
| `4.0.0-beta.1` | The packages that only some components need are optional peers, and npm no longer installs them with the library | The **Optional peers** item of [What changed and why](#what-changed-and-why): the packages of the components it renders go into its own `dependencies` ([Optional peers](#optional-peers)), with the `external` list, the tests and the KaTeX stylesheet that item names |
|
|
658
|
-
| `4.0.0-beta.5` | The default theme is `voicenter`, where the earlier betas had `redGreen` | An application that passes no `themeConfig`, or a tree-shake one that does not call `Theme()`, is drawn in `voicenter` ([Theming specification](#theming-specification)) |
|
|
659
|
-
| `4.0.0-beta.5` | The built-in themes are the light `voicenter` and the dark `voicenterDark`, which is new: `red`, `redGreen`, `black` and `voicenterRed` are removed | An application that passes one of the removed names is drawn in `voicenter` and logs a warning: it passes `voicenter` (light; the colours `voicenterRed` had) or `voicenterDark` (dark), or its own colours as a `customJson` theme ([Theming specification](#theming-specification)) |
|
|
660
|
-
| `4.0.0-beta.5` | The built-in themes no longer set `vc-content-warning-icon` | `var(--vc-content-warning-icon)` and the class `text-content-warning-icon` draw no colour: they become `var(--vc-content-warning)` and `text-content-warning`, the one warning colour of text and icons. A `customJson` or remote theme drops the key |
|
|
661
|
-
| `4.0.0-beta.5` | Brand and grey text have their own tokens: `content-brand` for text and icons in `primary`, `content-secondary` for text and icons in `secondary`; `action-primary` and `action-secondary` draw fills | Text and icons the application colours with `text-action-primary`, `text-action-secondary` or `var(--vc-action-primary)` / `var(--vc-action-secondary)` move to `text-content-brand`, `text-content-secondary` and their variables; fills and borders keep the `action-*` names ([Tailwind colour classes](#tailwind-colour-classes)) |
|
|
662
|
-
| `4.0.0-beta.5` | Disabled controls and disabled tabs are no longer faded: they draw the disabled colours at full opacity | A style of the application that fades a disabled ui-plus control or tab, or reads its opacity, is removed ([AI chat components](#ai-chat-components), the note on disabled tabs) |
|
|
663
|
-
| `4.0.0-beta.5` | `VcMessage` bubbles: others' are `bg-muted`, own ones the blue tint | An application that sets `--vc-message-bg` and the variables beside it keeps its colours; one that styled around the earlier bubble colours checks its contrast ([AI chat components](#ai-chat-components)) |
|
|
664
|
-
| `4.0.0-beta.5` | The default icon classes inside the components are `icon-xl` (24px) and `icon-2r` (32px), where the earlier betas had `icon-lg` (22px) and `icon-2xl` (30px) | Nothing, or the earlier class passed in the component's icon class prop to keep that size ([Styles and component defaults](#styles-and-component-defaults)) |
|
|
665
|
-
| `4.0.0-beta.5` | `VcTable` stacks into cards up to 440px of screen width, where the earlier betas stacked up to 780px | The application checks its tables between 441 and 780px ([AI chat components](#ai-chat-components)) |
|
|
666
|
-
| `4.0.0-beta.5` | The step buttons of `VcTour` are `VcButton` | A style that targets Element Plus's buttons inside the tour (`.el-tour-buttons .el-button`) no longer matches; the buttons take the VcButton classes |
|
|
667
|
-
| `4.0.0-beta.5` | Code in the components is DM Mono, through one variable, `--vc-font-mono`; the plugin and `loadTextFont()` load it with Rubik from Google Fonts | Nothing where the fonts come from the plugin or `loadTextFont()`. An application that loads the fonts itself also loads DM Mono (400 and 500), or sets `--vc-font-mono` on `:root` to its own code font ([Text](#text)) |
|
|
668
|
-
| `4.0.0-beta.5` | `VcTable` takes `density` (`'compact' \| 'default' \| 'large'`) and has no `compact` prop; a table with no props has the look `compact` gave | `compact` is removed from every `VcTable`; a table that had no `compact` takes `density="large"` to keep its look; a style on `.vc-table--small` moves to `.vc-table--density-default` ([AI chat components](#ai-chat-components)) |
|
|
669
|
-
| `4.0.0-beta.5` | `VcDatePicker` is as wide as its container, where the earlier betas had the fixed Element Plus widths | A date picker in a toolbar, a filter bar or any row that relied on the fixed width takes a width class or a sized container ([AI chat components](#ai-chat-components)) |
|
|
670
|
-
| `4.0.0-beta.5` | `VcViewSwitcher` is removed; `VcSegmented` takes icons, disabled hints and the `surface` variant, its `change` passes `(value, option)`, and its `color` prop is removed | Every `<VcViewSwitcher>` becomes `<VcSegmented variant="surface">` by the list under **`VcViewSwitcher` is removed** ([AI chat components](#ai-chat-components)); a `@change` handler of an existing `VcSegmented` that read the earlier value as its second argument is updated, `color` is removed from every `<VcSegmented>`, and a style on `.el-segmented__item-selected` moves to `.el-segmented__item.is-selected` |
|
|
671
|
-
| `4.0.0-beta.5` | `VcDatetimeRangePicker`, the step keys `beforeStepFn` and `onEnterStepFn` of `VcWizard`, and the types `BindResultObjectType`, `VcPresetRangesType` and `VcDatetimeRangePickerModelType` are removed | The application searches for these names (`grep -rnE "VcDatetimeRangePicker|vc-datetime-range-picker|beforeStepFn|onEnterStepFn|BindResultObjectType|VcPresetRangesType" src`) and replaces each hit by its row in **Styles and component defaults** ([Styles and component defaults](#styles-and-component-defaults)); a wizard step with the old keys otherwise skips its validation silently |
|
|
672
|
-
| `4.0.0-beta.5` | The `columns` of `VcTable` are typed by the table's row: `ColumnType<Row>` | Nothing at runtime. Where `vue-tsc` reports the `columns` of a `<VcTable>`, the columns are declared as `ColumnType<Row>` with the type of the table's `options` ([Styles and component defaults](#styles-and-component-defaults)) |
|
|
673
|
-
| `4.0.0-beta.6` | `VcTimeInput` mounted with a value above `maxValue` sends `maxValue`, where the earlier betas showed `maxValue` and sent `minValue`; with `maxValue` 0 (no upper limit) its + button adds a step, where the earlier betas set the value to 0; on an RTL page its digits stay left to right (01:30, where the earlier betas showed 30:01) | An application with a time input whose starting value can be above its `maxValue`, or with `max-value="0"`, checks the value it receives; one that styled around the reversed RTL digits removes that style |
|
|
674
|
-
| `4.0.0-beta.9` | `clearable` does nothing on `VcTimeInput`, where `4.0.0-beta.8` alone drew a clear control: the field always holds a number, `update:modelValue` passes `number`, and the `seconds` of `input` is a `number` | `clearable` is removed from every `<VcTimeInput>` (`grep -rnE "<VcTimeInput[^>]*clearable" src`), and a handler written for `number \| undefined` can take `number`; a field that must be able to hold no value is shown or hidden by the form around it |
|
|
675
|
-
|
|
676
|
-
After its rows the application runs the search of [Finding the 3.x names](#finding-the-3x-names) again: it finds a 3.x name that the guide of an earlier beta did not list.
|
|
677
|
-
|
|
678
|
-
## Using ui-plus in an application
|
|
679
|
-
|
|
680
|
-
How an application builds its UI with ui-plus. Agents working in a consuming project read this section before any UI work; it describes the version installed next to it.
|
|
681
|
-
|
|
682
|
-
### Where the facts are
|
|
683
|
-
|
|
684
|
-
The installed package is the truth. Read it before saying what ui-plus has or how a component behaves.
|
|
685
|
-
|
|
686
|
-
- **Every component**: `library/types/components/exports.d.ts`. One component's props, events and slots: `library/types/components/<VcName>/<VcName>.vue.d.ts`.
|
|
687
|
-
- **Composables, services, directives, the entity base**: `library/types/composables/`, `library/types/services/`, `library/types/directives/`, `library/types/entity/`.
|
|
688
|
-
- **Types**: prop, event and configuration types are exported from the package root (`import type { UIConfig } from '@voicenter-team/voicenter-ui-plus'`). Generic components take type parameters in the template: `<VcSelect<User, 'id', 'name'> v-model="selected" :options="users" value-key="id" label-key="name" />`.
|
|
689
|
-
- **Colour tokens**: `src/theme/themes.json` (each key is the CSS variable `--<key>`) and `src/theme/tailwindScheme.js` (the Tailwind colour names).
|
|
690
|
-
- **Examples**: the [live documentation](https://voicenter-ui-plus.pages.dev/).
|
|
691
|
-
|
|
692
|
-
### Choosing a component
|
|
693
|
-
|
|
694
|
-
- Interaction components come from ui-plus: buttons, inputs, selects, date pickers, checkboxes, tabs, tables, modals, drawers, tooltips, popovers, uploaders, notifications, confirmations. Search `exports.d.ts` by what the user is shown (a picker of people, an on/off switch, a list with a search) before concluding a component is missing.
|
|
695
|
-
- A component is used **as the library draws it**: through its props, slots and variants. Fitting it into the layout is free: width, spacing, wrapping, alignment.
|
|
696
|
-
- A **custom control** needs the project owner's explicit yes, asked before it is written: which element is needed, what was searched in ui-plus, why nothing fits. Custom means any of:
|
|
697
|
-
- a new interaction component;
|
|
698
|
-
- a ui-plus component whose own CSS variables (`--el-*`, the ones ui-plus sets on `.vc-*`) or internal classes are overridden to change how it looks or behaves as a control: its track, rows, selected, hover or active state, shape or indicator;
|
|
699
|
-
- a ui-plus component used for a role it is not built for, such as a segmented switcher drawn as a searchable list.
|
|
700
|
-
- Until that yes, the closest ui-plus component is used as drawn, and the difference from the design is the first open point of the report: what the design draws, which component was used, how they differ. No agent or orchestrator gives this approval in the owner's place.
|
|
701
|
-
- A report names a control by what is on screen: a restyled ui-plus component is reported as custom.
|
|
702
|
-
- A design hand-off (Figma, mock-up, screenshot, a specification) says what the user should see. It never justifies a restyle or a custom control.
|
|
703
|
-
|
|
704
|
-
### Colours
|
|
705
|
-
|
|
706
|
-
- Every colour is a ui-plus token: a Tailwind class from the library scheme (`text-content-primary`, `text-content-secondary`, `bg-action-primary`, `text-content-brand` for brand-coloured text, `bg-page`, `bg-surface`, `border-border`, `text-content-success`, `text-content-danger`) or a theme variable in a style (`color: var(--vc-content-primary)`). Status colours, tags, icons and chart series included.
|
|
707
|
-
- Hex values, `rgb()`/`rgba()`, arbitrary classes such as `bg-[#…]` and new colour variables stay out of application code. Such colours already in a project are not a precedent.
|
|
708
|
-
- The theme configuration (`themeConfig`, usually a `colors.json`) sets the library theme. It is not a palette to add colours to.
|
|
709
|
-
|
|
710
|
-
### Corners
|
|
711
|
-
|
|
712
|
-
- A corner takes the radius role of what it draws: `rounded-<role>`, a class of the shipped configuration ([Tailwind](#tailwind)), or `var(--vc-radius-<role>)` in a style:
|
|
713
|
-
- `rounded-control`: buttons, icon, toggle and split buttons, inputs, selects, pickers, at the default and large sizes;
|
|
714
|
-
- `rounded-control-sm`: the same controls at the small size (`--vc-size-control-sm`, 24px), and any other control of that height;
|
|
715
|
-
- `rounded-popup`: floating panels (popovers, dropdowns, select panels, tooltips, date-picker panels, notifications);
|
|
716
|
-
- `rounded-card`: cards, the outer frame of a table, modals;
|
|
717
|
-
- `rounded-tag`: tags and chips, drawn as a pill;
|
|
718
|
-
- `rounded-inner`: a part inside a control, popup or card (menu and list items, thumbnails and file icons, inline chips and labels, boxes inside editors and modals, checkbox boxes, colour-picker sliders, tree nodes, skeleton blocks, square tags).
|
|
719
|
-
- Besides the roles the shipped configuration has only `rounded-none` and `rounded-full` (a circle). A role takes Tailwind's side and corner prefixes like any radius: `rounded-t-card`, `rounded-s-control`.
|
|
720
|
-
- Pixel radii and arbitrary classes such as `rounded-[6px]` stay out of application code. Such radii already in a project are not a precedent.
|
|
721
|
-
|
|
722
|
-
### Shadows
|
|
723
|
-
|
|
724
|
-
- A shadow is a class of the shipped configuration ([Tailwind](#tailwind)):
|
|
725
|
-
- elevation: `shadow-raised` for an element lifted on hover or drag and `shadow-overlay` for a floating panel, read from `--vc-shadow-raised` and `--vc-shadow-overlay`; `shadow-card` for a card;
|
|
726
|
-
- focus: `shadow-focus` draws the one focus ring `--vc-focus-ring`, the theme's `--vc-ring` colour at `--vc-focus-ring-width`, and `shadow-focus-inner` draws it inside.
|
|
727
|
-
- `shadow-vertical-tab-item-hover` is the raised elevation; `shadow-focus-outer-off` is not a focus ring and keeps its own glow.
|
|
728
|
-
- A hand-written `box-shadow` and arbitrary classes such as `shadow-[…]` stay out of application code. Such shadows already in a project are not a precedent.
|
|
729
|
-
|
|
730
|
-
### Text
|
|
731
|
-
|
|
732
|
-
- Text keeps the library font, Rubik, which covers Latin and Hebrew: `font-main`, the one font key of the shipped configuration, set on `<html>`. The plugin (`app.use(VoicenterUI)`) loads it from Google Fonts. The tree-shake entry does not load it, the stylesheet only names it: `loadTextFont()` loads it ([Tree-shake mode](#tree-shake-mode-recommended)). An application's own Tailwind preflight sets another font on `<html>` ([Tailwind](#tailwind)).
|
|
733
|
-
- Text takes three weights, classes of the shipped configuration ([Tailwind](#tailwind)) read from `--vc-font-weight-*`: `font-normal` (the page text), `font-medium` (table headers, `th`) and `font-semibold` (`b` and `strong`). The other weight classes keep their Tailwind values.
|
|
734
|
-
- `transition-weight` is for text whose weight changes with its state.
|
|
735
|
-
- Code (JSON, code blocks, identifiers) takes `var(--vc-font-mono)` in a stylesheet: DM Mono, loaded with Rubik by the plugin and by `loadTextFont()`, with the system monospace fonts as fallback. An application with a code font of its own sets the variable on `:root`.
|
|
736
|
-
- Other font families and the weights `font-bold` and heavier stay out of application code. Such fonts and weights already in a project are not a precedent.
|
|
737
|
-
|
|
738
|
-
### Icons
|
|
739
|
-
|
|
740
|
-
- Icons are Lucide (`@lucide/vue`). An icon the application passes to a component or draws itself is a Lucide component imported by name: `import { Search } from '@lucide/vue'`, then `<VcButton :icon="Search">` or `<VcIcon :icon="Search" />`.
|
|
741
|
-
- The type of an icon prop is `TIcon`, exported from the package root.
|
|
742
|
-
|
|
743
|
-
### Notifications and confirmations
|
|
744
|
-
|
|
745
|
-
`NotifyService`, `useConfirmModal` and `useConfirmPopup` render only through the hosts described in [Global overlays](#global-overlays), mounted once in the application. A `VcNotification` host shows only the messages of its own `group`, so where the application mounts one host per group, every notification names one of those groups.
|
|
746
|
-
|
|
747
|
-
### Text direction
|
|
748
|
-
|
|
749
|
-
ui-plus follows the `dir` attribute of `<html>`: `useRTL()` reads it and updates when it changes. The application sets the direction there, once.
|
|
750
|
-
|
|
751
|
-
### AI chat
|
|
752
|
-
|
|
753
|
-
An AI chat is built from the chat components; their props, events and slots are in the installed types, and the [live documentation](https://voicenter-ui-plus.pages.dev/) has an example of each.
|
|
754
|
-
|
|
755
|
-
- The conversation: `VcMessagesWrapper` (its `message` slot renders one AI message from several parts, `hideHeader`, `busy`, the jump-to-latest button) with `VcMessage` (`variant="plain"` for the assistant, several content blocks, the `footer` slot for model / tokens / copy).
|
|
756
|
-
- Assistant text: `VcMdEditor` with `readonly hide-toolbar plain`, and `streaming` while it streams (the renderer of the `markdown` block of `VcMessage`). Reasoning: `VcAiReasoning`. Tool calls: `VcToolCall`. Human approval of a tool: `VcApprovalCard`. Questions the agent asks the user: `VcAskUserCard`. Sub-agents: `VcAgentRunCard` / `VcAgentRunGroup`.
|
|
757
|
-
- Input: `VcChatComposer` with `streaming` (Stop instead of Send). Attachments open in `VcLightbox` (images) or `VcPdfViewer` (an inline PDF viewer for a tab or a panel).
|
|
758
|
-
- The library ships only English texts: an application in another language adds the keys of these components with `tVUManage.updateLocaleMessages` (the list is in [AI chat components](#ai-chat-components)).
|
|
759
|
-
|
|
760
|
-
### Server-side rendering
|
|
761
|
-
|
|
762
|
-
ui-plus is built and tested for client-rendered Vue applications. Its composables read `document` and `window` when they are called (`useRTL` among them), and the package ships no Nuxt module. An application with server-side rendering proves one page that uses ui-plus in development and in a production build before relying on it, and reports what fails.
|
|
763
|
-
|
|
764
|
-
### Troubleshooting
|
|
765
|
-
|
|
766
|
-
- **Component not found or a blank page**: in tree-shake mode a component is a local import, never a globally registered tag. In plugin mode both `app.use(VoicenterUI, …)` and `import '@voicenter-team/voicenter-ui-plus/style.css'` are present.
|
|
767
|
-
- **A component fails with `<pkg> is not installed` or `Could not resolve "<pkg>" imported by "@voicenter-team/voicenter-ui-plus"`**: the application does not have that optional peer. Install the packages the component's documentation page lists ([Optional peers](#optional-peers)).
|
|
768
|
-
- **Duplicate styles, a huge CSS payload**: the two modes are mixed (named imports plus the global `style.css`). Pick one (`MIGRATION_v3.md`, §1).
|
|
769
|
-
- **`InstanceType<typeof VcMessagesWrapper>` does not type-check**: a generic component (`VcMessagesWrapper` since 4.0) has no constructor type. Type its template ref with the exported interface: `ref<VcMessagesWrapperExposed>()`. The other chat components with exposed methods export the same kind of interface (`VcChatComposerExposed`, `VcLightboxExposed`, `VcPdfViewerExposed`, …).
|
|
770
|
-
- **Lists missing from `VcMdEditor` or an AI answer** (`RangeError: Expected value of type boolean for attribute spread` in the console): `@milkdown/*` is older than 7.22.0. Install `^7.22.0` ([AI chat components](#ai-chat-components)).
|
|
771
|
-
- **PDF.js worker not loading, or Symbol / ZapfDingbats glyphs (✓, ✗, ★, Greek letters) drawn with another font or as boxes**: the worker and the standard font data of those two fonts are sibling assets resolved with `new URL('./pdf.worker.min.js', import.meta.url)` and `new URL('./standard_fonts/FoxitDingbats.pfb', import.meta.url)` (and `FoxitSymbol.pfb`); the bundler must support that pattern (Vite, webpack 5+, Rollup and esbuild do) and emits them as assets of the application.
|
|
772
|
-
|
|
773
|
-
## Date Handling
|
|
774
|
-
|
|
775
|
-
This library uses **dayjs** for all date operations and formatting. When working with date-related components, use dayjs format tokens (NOT date-fns format tokens).
|
|
776
|
-
|
|
777
|
-
### Format Tokens
|
|
778
|
-
|
|
779
|
-
**Important**: Use dayjs format tokens:
|
|
780
|
-
- `DD` - Day of month (2 digits) - **NOT** `dd`
|
|
781
|
-
- `YYYY` - 4-digit year - **NOT** `yyyy`
|
|
782
|
-
- `MM` - Month (2 digits)
|
|
783
|
-
- `HH` - 24-hour format
|
|
784
|
-
- `mm` - Minutes
|
|
785
|
-
- `ss` - Seconds
|
|
786
|
-
|
|
787
|
-
### Common Formats
|
|
788
|
-
|
|
789
|
-
```typescript
|
|
790
|
-
'DD/MM/YYYY' // 31/12/2024
|
|
791
|
-
'DD-MM-YYYY' // 31-12-2024
|
|
792
|
-
'YYYY-MM-DD' // 2024-12-31
|
|
793
|
-
'DD/MM/YYYY, HH:mm' // 31/12/2024, 14:30
|
|
794
|
-
'DD/MM/YYYY HH:mm:ss' // 31/12/2024 14:30:45
|
|
795
|
-
```
|
|
796
|
-
|
|
797
|
-
### Usage Example
|
|
798
|
-
|
|
799
|
-
```vue
|
|
800
|
-
<VcDatePicker
|
|
801
|
-
v-model="date"
|
|
802
|
-
format="DD/MM/YYYY"
|
|
803
|
-
input-date-format="DD/MM/YYYY"
|
|
804
|
-
input-time-format="HH:mm"
|
|
805
|
-
/>
|
|
806
|
-
```
|
|
807
|
-
|
|
808
|
-
## Date Utility Functions
|
|
809
|
-
|
|
810
|
-
The library provides a comprehensive set of date utility functions built on dayjs. These utilities are available for use in external projects.
|
|
811
|
-
|
|
812
|
-
### Import Date Utilities
|
|
813
|
-
|
|
814
|
-
```typescript
|
|
815
|
-
import {
|
|
816
|
-
formatDate,
|
|
817
|
-
parseDate,
|
|
818
|
-
addDays,
|
|
819
|
-
subtractDays,
|
|
820
|
-
getHours,
|
|
821
|
-
getMinutes,
|
|
822
|
-
getSeconds,
|
|
823
|
-
setTime,
|
|
824
|
-
isAfter,
|
|
825
|
-
isSameAfter,
|
|
826
|
-
isBefore,
|
|
827
|
-
isSameBefore,
|
|
828
|
-
format,
|
|
829
|
-
add,
|
|
830
|
-
sub,
|
|
831
|
-
addFp,
|
|
832
|
-
subFp
|
|
833
|
-
} from '@voicenter-team/voicenter-ui-plus'
|
|
834
|
-
```
|
|
835
|
-
|
|
836
|
-
### Basic Date Operations
|
|
837
|
-
|
|
838
|
-
#### Formatting Dates
|
|
839
|
-
|
|
840
|
-
```typescript
|
|
841
|
-
// Format a date with default format (YYYY-MM-DD)
|
|
842
|
-
const formatted = formatDate(new Date())
|
|
843
|
-
// Result: "2024-12-31"
|
|
844
|
-
|
|
845
|
-
// Format with custom format
|
|
846
|
-
const custom = formatDate(new Date(), 'DD/MM/YYYY')
|
|
847
|
-
// Result: "31/12/2024"
|
|
848
|
-
|
|
849
|
-
// Using format function (alias)
|
|
850
|
-
const formatted2 = format(new Date(), 'DD/MM/YYYY HH:mm')
|
|
851
|
-
// Result: "31/12/2024 14:30"
|
|
852
|
-
```
|
|
853
|
-
|
|
854
|
-
#### Parsing Dates
|
|
855
|
-
|
|
856
|
-
```typescript
|
|
857
|
-
// Parse a date string with format
|
|
858
|
-
const date = parseDate('31/12/2024', 'DD/MM/YYYY')
|
|
859
|
-
// Returns: Date object
|
|
860
|
-
```
|
|
861
|
-
|
|
862
|
-
### Date Arithmetic
|
|
863
|
-
|
|
864
|
-
#### Adding/Subtracting Days
|
|
865
|
-
|
|
866
|
-
```typescript
|
|
867
|
-
// Add days
|
|
868
|
-
const futureDate = addDays(new Date(), 7)
|
|
869
|
-
// Returns: Date 7 days from now
|
|
870
|
-
|
|
871
|
-
// Subtract days
|
|
872
|
-
const pastDate = subtractDays(new Date(), 5)
|
|
873
|
-
// Returns: Date 5 days ago
|
|
874
|
-
```
|
|
875
|
-
|
|
876
|
-
#### Adding/Subtracting Time Units
|
|
877
|
-
|
|
878
|
-
```typescript
|
|
879
|
-
// Add multiple time units
|
|
880
|
-
const newDate = add(new Date(), {
|
|
881
|
-
years: 1,
|
|
882
|
-
months: 2,
|
|
883
|
-
days: 5,
|
|
884
|
-
hours: 3,
|
|
885
|
-
minutes: 30
|
|
886
|
-
})
|
|
887
|
-
|
|
888
|
-
// Subtract multiple time units
|
|
889
|
-
const earlierDate = sub(new Date(), {
|
|
890
|
-
weeks: 2,
|
|
891
|
-
days: 3,
|
|
892
|
-
hours: 12
|
|
893
|
-
})
|
|
894
|
-
|
|
895
|
-
// Functional programming style (reversed arguments)
|
|
896
|
-
const fpDate = addFp({ days: 7 }, new Date())
|
|
897
|
-
const fpDate2 = subFp({ hours: 5 }, new Date())
|
|
898
|
-
```
|
|
899
|
-
|
|
900
|
-
### Time Operations
|
|
901
|
-
|
|
902
|
-
#### Getting Time Components
|
|
903
|
-
|
|
904
|
-
```typescript
|
|
905
|
-
const date = new Date('2024-12-31T14:30:45')
|
|
906
|
-
|
|
907
|
-
const hours = getHours(date) // 14
|
|
908
|
-
const minutes = getMinutes(date) // 30
|
|
909
|
-
const seconds = getSeconds(date) // 45
|
|
910
|
-
```
|
|
911
|
-
|
|
912
|
-
#### Setting Time
|
|
913
|
-
|
|
914
|
-
```typescript
|
|
915
|
-
// Set time on a date (returns new Date object)
|
|
916
|
-
const newDate = setTime(new Date(), {
|
|
917
|
-
hours: 14,
|
|
918
|
-
minutes: 30,
|
|
919
|
-
seconds: 0
|
|
920
|
-
})
|
|
921
|
-
```
|
|
922
|
-
|
|
923
|
-
### Date Comparisons
|
|
924
|
-
|
|
925
|
-
```typescript
|
|
926
|
-
const date1 = new Date('2024-12-31')
|
|
927
|
-
const date2 = new Date('2025-01-01')
|
|
928
|
-
|
|
929
|
-
// Check if date1 is after date2
|
|
930
|
-
const isLater = isAfter(date1, date2, 'day')
|
|
931
|
-
// Returns: false
|
|
932
|
-
|
|
933
|
-
// Check if date1 is same or after date2
|
|
934
|
-
const isSameOrLater = isSameAfter(date1, date2, 'day')
|
|
935
|
-
// Returns: false
|
|
936
|
-
|
|
937
|
-
// Check if date1 is before date2
|
|
938
|
-
const isEarlier = isBefore(date1, date2, 'day')
|
|
939
|
-
// Returns: true
|
|
940
|
-
|
|
941
|
-
// Check if date1 is same or before date2
|
|
942
|
-
const isSameOrEarlier = isSameBefore(date1, date2, 'day')
|
|
943
|
-
// Returns: true
|
|
944
|
-
```
|
|
945
|
-
|
|
946
|
-
**Comparison Units**: The comparison functions accept a `units` parameter (default: `'minute'`). Valid units:
|
|
947
|
-
- `'year'`, `'month'`, `'week'`, `'day'`
|
|
948
|
-
- `'hour'`, `'minute'`, `'second'`
|
|
949
|
-
|
|
950
|
-
### Complete Usage Example
|
|
951
|
-
|
|
952
|
-
```typescript
|
|
953
|
-
import {
|
|
954
|
-
formatDate,
|
|
955
|
-
addDays,
|
|
956
|
-
isAfter,
|
|
957
|
-
format,
|
|
958
|
-
add,
|
|
959
|
-
getHours,
|
|
960
|
-
setTime
|
|
961
|
-
} from '@voicenter-team/voicenter-ui-plus'
|
|
962
|
-
|
|
963
|
-
// Format today's date
|
|
964
|
-
const today = formatDate(new Date(), 'DD/MM/YYYY')
|
|
965
|
-
|
|
966
|
-
// Get date 30 days from now
|
|
967
|
-
const futureDate = addDays(new Date(), 30)
|
|
968
|
-
|
|
969
|
-
// Check if a date is in the future
|
|
970
|
-
const isFuture = isAfter(futureDate, new Date(), 'day')
|
|
971
|
-
|
|
972
|
-
// Add 2 weeks and 3 days
|
|
973
|
-
const deadline = add(new Date(), {
|
|
974
|
-
weeks: 2,
|
|
975
|
-
days: 3
|
|
976
|
-
})
|
|
977
|
-
|
|
978
|
-
// Get current hour
|
|
979
|
-
const currentHour = getHours(new Date())
|
|
980
|
-
|
|
981
|
-
// Set specific time
|
|
982
|
-
const meetingTime = setTime(new Date(), {
|
|
983
|
-
hours: 14,
|
|
984
|
-
minutes: 30
|
|
985
|
-
})
|
|
986
|
-
|
|
987
|
-
// Format the result
|
|
988
|
-
const formattedDeadline = format(deadline, 'DD/MM/YYYY HH:mm')
|
|
989
|
-
```
|
|
990
|
-
|
|
991
|
-
### Notes
|
|
992
|
-
|
|
993
|
-
- All functions accept `Date`, `string`, or `number` as date input
|
|
994
|
-
- All date manipulation functions return new `Date` objects (immutable)
|
|
995
|
-
- Format strings use dayjs format tokens (see Format Tokens section above)
|
|
996
|
-
- These utilities are built on dayjs and maintain compatibility with dayjs format patterns
|
|
997
|
-
|
|
998
|
-
## Contributing: adding a new component
|
|
999
|
-
|
|
1000
|
-
The public component surface is defined in **one place**: [`script/components-manifest.mjs`](./script/components-manifest.mjs) — one line per component.
|
|
1001
|
-
|
|
1002
|
-
```js
|
|
1003
|
-
{ name: 'VcMyThing', path: 'components/VcMyThing/VcMyThing.vue' },
|
|
1004
|
-
```
|
|
1005
|
-
|
|
1006
|
-
`npm run generate:entries` materializes the manifest into three fully
|
|
1007
|
-
generated files (never edit them by hand — the next generator run
|
|
1008
|
-
overwrites them, and the verifier fails the build until they match):
|
|
1009
|
-
|
|
1010
|
-
- `src/components.gen.ts` — named exports, re-exported by `src/index.ts`
|
|
1011
|
-
(tree-shake mode);
|
|
1012
|
-
- `src/plugin-components.gen.ts` — `registerComponents(app)`, called by
|
|
1013
|
-
the plugin's install (global registration mode);
|
|
1014
|
-
- `src/components/exports.ts` — the `GlobalComponents` template typing.
|
|
1015
|
-
|
|
1016
|
-
`src/index.ts` and `src/plugin.ts` themselves stay hand-written and small.
|
|
1017
|
-
The `.gen` modules are safe to route through only because
|
|
1018
|
-
`rewriteCssImports()` in `vite.config.ts` strips the CSS imports that
|
|
1019
|
-
`vite-plugin-lib-inject-css` aggregates onto them — each component's CSS
|
|
1020
|
-
stays in its own chunk, so per-component CSS tree-shaking survives. Don't
|
|
1021
|
-
rename the `.gen` files without updating that strip list (the verifier
|
|
1022
|
-
guards this wiring too).
|
|
1023
|
-
|
|
1024
|
-
Typical flows:
|
|
1025
|
-
|
|
1026
|
-
- **New component**: `node script/create-component.mjs` — scaffolds the
|
|
1027
|
-
component folder, adds the manifest line, and regenerates all entries.
|
|
1028
|
-
- **Existing .vue file**: add one line to the manifest, then
|
|
1029
|
-
`npm run generate:entries`.
|
|
1030
|
-
|
|
1031
|
-
Every manifest entry is exported from the package root AND registered
|
|
1032
|
-
globally in plugin mode — there are no partial modes.
|
|
1033
|
-
|
|
1034
|
-
`npm run verify:entries` is the safety net: it independently cross-checks
|
|
1035
|
-
the manifest, the three generated files and the filesystem (a component
|
|
1036
|
-
file that exists but is missing from the manifest fails too). It runs in
|
|
1037
|
-
the pre-commit hook (together with `lint-staged` and `ts-check`; hooks are
|
|
1038
|
-
installed automatically by `npm install` via husky) and in CI, so an
|
|
1039
|
-
inconsistent component surface cannot reach `master`.
|
|
1040
|
-
|
|
1041
|
-
## Documentation
|
|
1042
|
-
|
|
1043
|
-
### Live Documentation
|
|
1044
|
-
Visit [documentation](https://voicenter-ui-plus.pages.dev/) for interactive component examples and demos.
|
|
1045
|
-
|
|
1046
|
-
## Project Documentation
|
|
1047
|
-
For detailed technical documentation, see the [`docs/`](./docs/) directory:
|
|
1048
|
-
|
|
1049
|
-
- **[Quick Start Guide](./docs/AGENTS_QUICK_START.md)** - For developers working on the library
|
|
1050
|
-
- **[Architecture Overview](./docs/ARCHITECTURE.md)** - Project structure and technical details
|
|
1051
|
-
- **[Documentation Guide](./docs/DOCUMENTATION_GUIDE.md)** - Working with the documentation system
|
|
1
|
+
# Voicenter UI library for Vue
|
|
2
|
+
This is Vue 3.x + Typescript component library made for Voicenter systems.
|
|
3
|
+
|
|
4
|
+
> **4.x renames the colour tokens, draws Lucide icons and changes some component defaults.** An application on 3.x follows [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x); one on 2.x first follows [`MIGRATION_v3.md`](./MIGRATION_v3.md); one already on a 4.0 beta follows [Upgrading from a 4.0 beta](#upgrading-from-a-40-beta).
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @voicenter-team/voicenter-ui-plus
|
|
10
|
+
npm i vue@^3.5 element-plus @vueuse/core @lucide/vue dayjs lodash-es libphonenumber-js maska
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Optional peers
|
|
14
|
+
|
|
15
|
+
The packages that only some components need are optional peer dependencies, and npm does not install them. An application installs into its own `dependencies` the packages of the components it renders: each component's page in the [live documentation](https://voicenter-ui-plus.pages.dev/) gives them as one `npm i` line under its heading.
|
|
16
|
+
|
|
17
|
+
A component loads its packages with `import()` the first time it needs them: when it renders, or when the part that needs the package is used. The packages behind such a part load only then: `VcMessage` loads the editor packages for a markdown block and `wavesurfer.js` for an audio block, `VcChatComposer` loads `emojibase-data` when its emoji picker opens, `VcExcelFileUploader` loads `xlsx` when a file is picked, the PDF components load `pdfjs-dist` when a document loads. In a Vite application a missing package fails only that component, at that moment, with an error naming the package (`<pkg> is not installed` from the library, or `Could not resolve "<pkg>" imported by "@voicenter-team/voicenter-ui-plus"` from Vite); the application builds and the rest of it works. A Vite application's build needs no configuration for the packages it leaves out: no `external` list (an application that listed them in `build.rollupOptions.external` on 3.x removes those entries, or a package it later installs is never bundled). webpack fails a build on an `import()` it cannot resolve, so a webpack application installs the packages of every component it renders.
|
|
18
|
+
|
|
19
|
+
The library's type declarations import the types of these packages. An application that type-checks with `skipLibCheck: false` and leaves a package out gets a `TS2307` for it; with `skipLibCheck: true` (the default of Vite's templates) those types are `any`.
|
|
20
|
+
|
|
21
|
+
The stylesheets of these packages that a component needs are in the library's CSS, except KaTeX's, which brings 60 font files. Markdown renders math (`$…$`, or the math block of the `VcMdEditor` toolbar) with KaTeX, in `VcMdEditor` and in the markdown of `VcMessage`, `VcAiReasoning`, `VcAgentRunCard` and `VcSystemUserPrompt`: an application that shows math installs `katex` and adds `import 'katex/dist/katex.min.css'` itself.
|
|
22
|
+
|
|
23
|
+
### Sass compiler (build-time)
|
|
24
|
+
|
|
25
|
+
This library customizes element-plus theming via SCSS variable injection at build time. Your bundler needs to be able to compile SCSS. If your project doesn't already use Sass, add it as a dev dependency:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm i -D sass-embedded
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This is a **build-time only** requirement — it doesn't add anything to your runtime bundle. Most Vue 3 / Vite projects already have it.
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
### Tree-shake mode (recommended)
|
|
36
|
+
```ts
|
|
37
|
+
import { VcButton, VcInput } from '@voicenter-team/voicenter-ui-plus'
|
|
38
|
+
// Use as local components — no app.use() needed.
|
|
39
|
+
```
|
|
40
|
+
Bundlers drop unused components and their CSS. A consumer importing only `VcButton` ships ~50–150 KB JS + ~10–30 KB CSS.
|
|
41
|
+
|
|
42
|
+
The stylesheet sets the default theme (voicenter) on `:root`. Another theme and the text font are two calls, the ones the plugin makes itself:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import Theme from '@voicenter-team/voicenter-ui-plus/theme'
|
|
46
|
+
import { loadTextFont } from '@voicenter-team/voicenter-ui-plus/font'
|
|
47
|
+
|
|
48
|
+
Theme({ type: 'local', themeName: 'voicenter' }) // any themeConfig, see "Theming specification"
|
|
49
|
+
loadTextFont() // Rubik and DM Mono from Google Fonts
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
If you use `useConfirmModal`, `useConfirmPopup`, or `NotifyService`, mount global overlays in `App.vue`:
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<script setup lang="ts">
|
|
56
|
+
import { VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus'
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<RouterView />
|
|
61
|
+
<VcPluginOverlays />
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Plugin mode (global registration)
|
|
66
|
+
```ts
|
|
67
|
+
import VoicenterUI from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
68
|
+
import '@voicenter-team/voicenter-ui-plus/style.css'
|
|
69
|
+
|
|
70
|
+
// Overlay composables can be imported from the same entry:
|
|
71
|
+
// import { useConfirmModal, useConfirmPopup, VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
72
|
+
|
|
73
|
+
app.use(VoicenterUI, {
|
|
74
|
+
themeConfig, // theme config (see below)
|
|
75
|
+
lang: 'en' // localization
|
|
76
|
+
})
|
|
77
|
+
// Confirm modals/popovers/notifications: auto-mounted via VcPluginOverlays
|
|
78
|
+
// (mountOverlays: true by default). Opt out with mountOverlays: false and
|
|
79
|
+
// add <VcPluginOverlays /> to App.vue — also registered globally by the plugin.
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`style.css` loads the `vc-icon-*` icon font and its classes. The plugin option `injectIconFont: true` adds the font's `@font-face` to the document head as well: an application needs it only when the stylesheet is inside a shadow root (a custom element, a browser extension's content script), where a `@font-face` does not apply.
|
|
83
|
+
|
|
84
|
+
### Global overlays
|
|
85
|
+
|
|
86
|
+
Several APIs are **state-only** — they update global reactive singletons but do not render UI by themselves:
|
|
87
|
+
|
|
88
|
+
| API | Overlay component |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `useConfirmModal` | `VcConfirmModal` |
|
|
91
|
+
| `useConfirmPopup` | `VcConfirmPopover` |
|
|
92
|
+
| `NotifyService` / `$notify` | `VcNotification` |
|
|
93
|
+
|
|
94
|
+
**Plugin mode:** mounted automatically on `app.use()` (default). Pass `mountOverlays: false` to mount manually.
|
|
95
|
+
|
|
96
|
+
**Notifications:** one top-right host by default. For multiple positions, use `overlayNotifications` in plugin config or mount your own:
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
app.use(VoicenterUI, {
|
|
100
|
+
overlayNotifications: [
|
|
101
|
+
{ group: 'top-right', position: 'top-right' },
|
|
102
|
+
{ group: 'bottom-right', position: 'bottom-right' },
|
|
103
|
+
],
|
|
104
|
+
})
|
|
105
|
+
// NotifyService.add({ group: 'bottom-right', ... })
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Or `overlayNotifications: 'none'` and put `<VcNotification />` in App.vue (confirms still auto-mount).
|
|
109
|
+
|
|
110
|
+
**Tree-shake mode:** add `<VcPluginOverlays />` to `App.vue` (bundles confirm hosts; configure via `notifications` prop).
|
|
111
|
+
|
|
112
|
+
Entity components such as `VcEntityListTable` call `useConfirmModal` internally — delete confirmations require overlays to be mounted.
|
|
113
|
+
|
|
114
|
+
### Tailwind
|
|
115
|
+
|
|
116
|
+
The scheme and the shipped `tailwind.config.js` are Tailwind 3 configurations: an application installs `tailwindcss@3`, `postcss` and `autoprefixer` (`npx tailwindcss init -p` creates its configuration).
|
|
117
|
+
|
|
118
|
+
Tailwind's colours come from the library scheme, so the utility classes and the theme are one set of tokens. `theme.colors` replaces Tailwind's own palette on purpose: only the library's colours exist as classes.
|
|
119
|
+
|
|
120
|
+
```js
|
|
121
|
+
// tailwind.config.js
|
|
122
|
+
const voiceTailwindScheme = require('@voicenter-team/voicenter-ui-plus/src/theme/tailwindScheme')
|
|
123
|
+
|
|
124
|
+
module.exports = {
|
|
125
|
+
...yourConfiguration,
|
|
126
|
+
theme: {
|
|
127
|
+
colors: { ...voiceTailwindScheme },
|
|
128
|
+
borderColor: { ...voiceTailwindScheme },
|
|
129
|
+
fill: voiceTailwindScheme
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
The library's own `tailwind.config.js` (shipped as `@voicenter-team/voicenter-ui-plus/tailwind.config`) also has keys for the radii, shadows, font family and font weights of the components; [Corners](#corners), [Shadows](#shadows) and [Text](#text) say what each class is for. Their values are the CSS variables the library stylesheet sets on `:root` in both modes, so a class drawn with them changes together with the library. An application takes these keys from the shipped configuration:
|
|
135
|
+
|
|
136
|
+
```js
|
|
137
|
+
// tailwind.config.js
|
|
138
|
+
const uiPlusTheme = require('@voicenter-team/voicenter-ui-plus/tailwind.config').theme
|
|
139
|
+
|
|
140
|
+
module.exports = {
|
|
141
|
+
...yourConfiguration,
|
|
142
|
+
theme: {
|
|
143
|
+
// colours as above
|
|
144
|
+
extend: {
|
|
145
|
+
borderRadius: uiPlusTheme.borderRadius,
|
|
146
|
+
boxShadow: uiPlusTheme.boxShadow,
|
|
147
|
+
transitionProperty: uiPlusTheme.extend.transitionProperty,
|
|
148
|
+
fontFamily: uiPlusTheme.fontFamily,
|
|
149
|
+
fontWeight: uiPlusTheme.extend.fontWeight
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Import the application's own stylesheet after the library, so the application's utilities win ties of equal specificity with the library's CSS (`.hidden` is the usual one).
|
|
156
|
+
|
|
157
|
+
Tailwind's preflight (`@tailwind base`) in that stylesheet sets `font-family` on `html` again, Tailwind's sans font, after the library set Rubik there. `html { @apply font-main; }` in the application's `@layer base` keeps the library font on the page.
|
|
158
|
+
|
|
159
|
+
The 3.x colour names are not in the scheme; [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) lists their 4.x names.
|
|
160
|
+
|
|
161
|
+
### Theming specification
|
|
162
|
+
The `themeConfig` passed to `app.use(VoicenterUI, { themeConfig })`, or to `Theme()` in tree-shake mode, could have the following specifications.
|
|
163
|
+
|
|
164
|
+
A theme is a flat object of colour tokens. Each key is set on the document element as a CSS variable with `--` in front of it: `vc-action-primary` becomes `--vc-action-primary`. The keys are grouped by role:
|
|
165
|
+
|
|
166
|
+
- `vc-content-*`: text and icons (`primary`, `secondary`, `tertiary`, `disabled`, `success`, `warning`, `danger`, `info`); `warning` colours warning text and icons alike; `vc-content-brand` is brand-coloured text and icons (links, active tabs, the text of `primary` outline and borderless buttons), a deeper red than the brand fill (set by voicenter and voicenterDark; a theme that does not set it takes its `vc-action-primary`);
|
|
167
|
+
- `vc-bg-*`: backgrounds (`page`, `surface`, `inset`, `inset-strong`, `field`, `muted`, `overlay`);
|
|
168
|
+
- `vc-action-*`: fills of interactive elements (`primary`, `secondary`, `info`, `success`, `warning`, `danger`);
|
|
169
|
+
- `vc-onfill` and `vc-onfill-{fill}`: text on a solid fill. Every built-in theme sets `vc-onfill-primary` and `vc-onfill-warning`; `vc-onfill-secondary`, `vc-onfill-info`, `vc-onfill-success` and `vc-onfill-danger` are optional, and a fill whose key is not set takes `vc-onfill`;
|
|
170
|
+
- `vc-border`, `vc-border-strong`, `vc-input` (field borders), `vc-ring` (focus ring), `vc-shadow-color`;
|
|
171
|
+
- `vc-mix-anchor` and `vc-mix-anchor-{fill}`: the colour the hover and pressed states of a fill are mixed toward (black darkens, white lightens). Any fill can have its own anchor: a fill whose `vc-mix-anchor-{fill}` key is not set mixes toward `vc-mix-anchor`. Every built-in theme sets `vc-mix-anchor-primary` and `vc-mix-anchor-warning`, the two fills with their own text colour. Coloured text (links, outline and borderless buttons) has no anchor key: its hover and pressed states mix toward `vc-content-primary`, so they darken on a light theme and lighten on a dark one.
|
|
172
|
+
|
|
173
|
+
Hover, pressed, disabled and tinted states (`--vc-action-primary--hover`, `--vc-action-primary--subtle-hover`, …) are mixed from these values by the library, so a theme sets only the base colours. The Element Plus colour variables (`--el-color-primary`, `--el-bg-color`, `--el-border-color`, …) are filled from the same tokens; a theme can still set an `el-*` key to override one. A theme that does not set `vc-content-success`, `vc-content-warning`, `vc-content-danger` or `vc-content-info` takes its `vc-action-*` of the same status for it.
|
|
174
|
+
|
|
175
|
+
The full list of keys and the values of every built-in theme are in [`src/theme/themes.json`](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json). The library's stylesheet sets the keys of the default theme (voicenter) on `:root`. Any other key a theme leaves out takes the default theme's value; after a theme switch at run time, a key the new theme leaves out keeps the previous theme's value. Theme keys of 3.x (`primary`, `default-text`, `ui-lines`, …) are not read, and nothing warns about them: a `customJson` or remote theme with 3.x keys draws the default theme. A theme passes the `vc-*` keys ([Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) maps them).
|
|
176
|
+
|
|
177
|
+
### Local
|
|
178
|
+
**Config:**
|
|
179
|
+
```js
|
|
180
|
+
{
|
|
181
|
+
type: 'local'
|
|
182
|
+
themeName: 'voicenter' | 'voicenterDark'
|
|
183
|
+
onSetupCallback: () => {
|
|
184
|
+
console.log('Loaded!')
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
**Description:**
|
|
189
|
+
|
|
190
|
+
Such configuration will append to the document element the CSS variables from one of the configuration passed in `themeName` parameter which it will get from theme specification delivered alongside with library
|
|
191
|
+
|
|
192
|
+
**Params:**
|
|
193
|
+
- **themeName**
|
|
194
|
+
- The name of the theme to be injected. `voicenter` is the default (it is also used when no `themeConfig` is passed); `voicenterDark` is the dark theme. An unknown name logs a warning and keeps the default.
|
|
195
|
+
- `voicenterDark` is the dark counterpart of `voicenter`. Its fills are deep enough for white text on every one of them (`vc-onfill`, `vc-onfill-primary` and `vc-onfill-warning` are white), and their hover and pressed states darken (`vc-mix-anchor` is black). Coloured text never reads a fill: it takes the `content-*` keys and `vc-content-brand`, which are lighter than the fills, and gets lighter still on hover and press.
|
|
196
|
+
- **onSetupCallback**
|
|
197
|
+
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
198
|
+
|
|
199
|
+
### Remote
|
|
200
|
+
**Config:**
|
|
201
|
+
```js
|
|
202
|
+
{
|
|
203
|
+
type: 'remote'
|
|
204
|
+
brandingSectionName: 'someName'
|
|
205
|
+
apiUrl: 'someUrl'
|
|
206
|
+
brandingSectionName: {
|
|
207
|
+
property: 'data'
|
|
208
|
+
}
|
|
209
|
+
onSetupCallback: () => {
|
|
210
|
+
console.log('Loaded!')
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
**Description:**
|
|
215
|
+
|
|
216
|
+
Such configuration will initiate the call to the specified apiUrl in order to retrieve the JSON object with key-value properties of the CSS variables to inject to document element
|
|
217
|
+
|
|
218
|
+
**Params:**
|
|
219
|
+
- **brandingSectionName**
|
|
220
|
+
- [Optional] The name of the section (tagSection) in the database configuration which will be passed to the API in payload and on response retrieved replaced from resulted values
|
|
221
|
+
- **apiUrl**
|
|
222
|
+
- The API url to which the POST request will be initiated
|
|
223
|
+
- **onSetupCallback**
|
|
224
|
+
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
225
|
+
- **brandingSectionName**
|
|
226
|
+
- [Optional] The payload data that will be sent to the request
|
|
227
|
+
|
|
228
|
+
### Custom JSON
|
|
229
|
+
**Config:**
|
|
230
|
+
```js
|
|
231
|
+
{
|
|
232
|
+
type: 'customJson'
|
|
233
|
+
config: {
|
|
234
|
+
'vc-action-primary': '#E80130',
|
|
235
|
+
'vc-content-primary': '#1F2937'
|
|
236
|
+
}
|
|
237
|
+
onSetupCallback: () => {
|
|
238
|
+
console.log('Loaded!')
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
**Description:**
|
|
243
|
+
|
|
244
|
+
Such configuration will initiate the styling with custom provided theme
|
|
245
|
+
|
|
246
|
+
**Params:**
|
|
247
|
+
- **config**
|
|
248
|
+
- The object where the key is the variable to be set and the value is the variable value. The keys are the theme keys described above; check the [themes object](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json) for the full list.
|
|
249
|
+
- **onSetupCallback**
|
|
250
|
+
- The function which will be called right after the variables will be injected into the document element. First parameter of which is the theme object which was set up
|
|
251
|
+
|
|
252
|
+
### None
|
|
253
|
+
`{ type: 'none', onSetupCallback?: (theme) => void }` injects no theme variables; the application sets them itself.
|
|
254
|
+
|
|
255
|
+
## Migrating from 3.x to 4.x
|
|
256
|
+
|
|
257
|
+
### What changed and why
|
|
258
|
+
|
|
259
|
+
- **Colours** are named by their role, and a theme sets only the base colours: the hover, pressed, disabled and tinted states are mixed from them by the library, with one formula for every colour. The 3.x colour names are gone. Details: [Colour names](#colour-names), [CSS variables](#css-variables), [Tailwind colour classes](#tailwind-colour-classes), [Theme keys](#theme-keys) and [Finding the 3.x names](#finding-the-3x-names).
|
|
260
|
+
- **Icons** are Lucide (`@lucide/vue`), the icons of the 4.0 design, where 3.x drew the `vc-icon-*` font. An icon prop still takes a `vc-icon-*` class. Details: [Icons](#icons).
|
|
261
|
+
- **Corners** take one of six radius roles, `control`, `control-sm`, `popup`, `card`, `tag` and `inner`, each a CSS variable (`--vc-radius-control`) and a class of the shipped Tailwind configuration (`rounded-control`). They replace the 3.x radius scale and `--base-border-radius`. The classes read the variables the library stylesheet sets, so a corner drawn with them changes together with the library. Details: [Corners](#corners) and [Styles and component defaults](#styles-and-component-defaults).
|
|
262
|
+
- **Text** has one font key, `main`, which names the role rather than the font, so a font change keeps the class; `font-inter`, `font-heebo` and `font-rubik`, which all drew Rubik, are gone. It takes three weights, `font-normal`, `font-medium` and `font-semibold` (`--vc-font-weight-*`): Rubik is a variable font whose stock weights read heavy, so the first two are lighter than in 3.x. Details: [Text](#text) and [Styles and component defaults](#styles-and-component-defaults).
|
|
263
|
+
- **Focus** is one ring, `shadow-focus` (`shadow-focus-inner` draws it inside), in the theme's `vc-ring` colour. The colour-named focus classes are gone: they all drew that one ring, whatever colour the name gave. Details: [Shadows](#shadows) and [Styles and component defaults](#styles-and-component-defaults).
|
|
264
|
+
- **Component defaults**: the fields default to `primary`, and the colours `primary-alternative` and `active` are gone, since both drew the brand colour, as `primary` does. VcTagInput and VcTreeSelect show their values as the muted chips of a multiple VcSelect, a field's prefix icon follows the size of the field, and the close and copy controls of modals, notifications and code blocks are a VcButtonIcon, with the size, radius and hover of the library's controls. Details: [Styles and component defaults](#styles-and-component-defaults).
|
|
265
|
+
- **Themes**: 4.x has two built-in themes, the light `voicenter` (the default) and the dark `voicenterDark`, so the `themeName` of the application's `themeConfig` changes:
|
|
266
|
+
|
|
267
|
+
| `themeName` in 3.x | 4.x |
|
|
268
|
+
| --- | --- |
|
|
269
|
+
| `voicenterRed` | `voicenter`: the same theme under its 4.x name |
|
|
270
|
+
| `redGreen` (the 3.x default), `red`, `blue` | `voicenter`; an application that has to keep those colours passes them as a `customJson` theme ([Theming specification](#theming-specification)) |
|
|
271
|
+
| `black` | `voicenterDark` |
|
|
272
|
+
| no `themeConfig` | nothing to change: the application is drawn in `voicenter`, where 3.x drew `redGreen` |
|
|
273
|
+
|
|
274
|
+
A 3.x name left in `themeName` does not fail: it logs `No such theme` in the console and the application is drawn in `voicenter`. Search for it (`grep -rnE "themeName|voicenterRed|redGreen" src`), and for code that switches themes by name, such as a dark-mode toggle. The stylesheet sets the default theme on `:root`.
|
|
275
|
+
- **Optional peers**: 3.x installed every peer dependency together with the library. 4.x marks the packages that only some components need optional, and npm does not install them. An application adds to its `dependencies` the packages the documentation page of each component it renders lists ([Optional peers](#optional-peers)), then runs the application: a component whose package is missing fails when it needs it, with the message given there. Also: an application that listed uninstalled peers in `build.rollupOptions.external` removes those entries; a component now renders before its package arrives (plain code, an empty editor area, an empty composer line), so an application test that asserts right after `mount` awaits `flushPromises()` first; an application whose markdown shows math adds KaTeX's stylesheet itself (see there).
|
|
276
|
+
- **Removed**: besides the names above, the theme `blue`, which no application on 3.x selects (only applications still on 0.x do), and the classes of the native close controls. The sections below give what replaces each removed name.
|
|
277
|
+
|
|
278
|
+
### Colour names
|
|
279
|
+
|
|
280
|
+
In 4.x the colours are named by their role: `content` for text and icons, `bg` for backgrounds, `action` for the fills of interactive elements, `onfill` for text on a fill, and `border`, `input` and `ring` for lines. The 3.x colour names are gone: a 3.x CSS variable is not set, a 3.x Tailwind colour class is not generated and a 3.x theme key is not read. An application moves every colour it takes from ui-plus to the 4.x name in the tables below. Where a 3.x name has two 4.x names, the token follows what the value finally draws, also when it sits in a custom property, a JS object or a prop: `content-*` where it colours text or an icon, `action-*` where it fills or outlines.
|
|
281
|
+
|
|
282
|
+
Hover, pressed and tinted states keep one pattern. In CSS variables, `--focus` (hover) becomes `--hover`, `--pressed` stays `--pressed`, and `-bg--focus` and `-bg--pressed` (the 10% and 20% washes) become `--subtle-hover` and `--subtle-pressed`: `--primary-actions-bg--focus` is `--vc-action-primary--subtle-hover`. Tailwind names use one dash: `bg-action-primary-hover`, `bg-action-primary-subtle-hover`. `destructive` and `error` are both `danger`; `primary-alternative` and `active-elements` are both `primary`.
|
|
283
|
+
|
|
284
|
+
What keeps its name:
|
|
285
|
+
|
|
286
|
+
- the `color` prop values of the components: `primary`, `secondary`, `destructive`, `success` and `warning`; `info` is new, and `active` and `primary-alternative` are removed (see "Styles and component defaults");
|
|
287
|
+
- the shadow classes (`shadow-card`, `shadow-table`, `shadow-hover-outer-primary`, …) apart from the focus classes, `shadow-hover`, `shadow-hover-{colour}` and `shadow-hover-outer-destructive` (see "Styles and component defaults"): they read the 4.x tokens;
|
|
288
|
+
- the Element Plus variables (`--el-color-primary`, `--el-border-color`, …): the library fills them from the 4.x tokens.
|
|
289
|
+
|
|
290
|
+
Props that take a Tailwind colour name take the 4.x name: `VcCollapseItem` `color-icon="action-primary"` and `color-border="border"` (the defaults). The `color` of `VcLoading` takes a component colour (`primary`, `destructive`, …) or a 4.x Tailwind colour name (`content-secondary`).
|
|
291
|
+
|
|
292
|
+
Some 3.x names had a value of their own in the built-in themes and now share a token, so they draw differently:
|
|
293
|
+
|
|
294
|
+
- `icons` and `table-headings` were an accent colour of their own in red and black and the brand colour in redGreen, and `headers` an accent colour in black; they are `content-primary`, the body text colour.
|
|
295
|
+
- `default-text` (red, voicenterRed) and `heading-text` (red) differed from `primary-text`; all three are `content-primary`.
|
|
296
|
+
- `primary-alternative` had a colour of its own in every theme; it is `action-primary`.
|
|
297
|
+
- `active-elements` had a colour of its own in red; it is `action-primary`.
|
|
298
|
+
- `inactive-elements` was the secondary colour in red, redGreen and black; it is `content-disabled`.
|
|
299
|
+
- `progress-line-done` was a neutral grey in red, redGreen and black; it is `action-success`. `progress-line-not-done` was the secondary colour in red and redGreen and a dark grey in black; it is `border`.
|
|
300
|
+
- `scrollbar-track`, `scrollbar-thumb` and `scrollbar-thumb-hover` were fixed greys in red, redGreen and black; they are `bg-surface`, `border` and `content-disabled`, so the scrollbar follows the theme.
|
|
301
|
+
- `destructive` and `error` were two colours in redGreen and black; both are `action-danger`.
|
|
302
|
+
|
|
303
|
+
Some names keep their meaning but have a new value in voicenter (3.x `voicenterRed`): `destructive`, `error`, `success`, `warning` and `actions-mix-color`, and the `secondary` fill (#4A607A, a darker grey; `secondary` text is `content-secondary`); the `primary` text in voicenter is #C20027 (`content-brand`), a deeper red than the #E80130 fill.
|
|
304
|
+
|
|
305
|
+
For the brand colour, use `action-primary` for fills and `content-brand` for text and icons.
|
|
306
|
+
|
|
307
|
+
### CSS variables
|
|
308
|
+
|
|
309
|
+
| 3.x variable | 4.x |
|
|
310
|
+
| --- | --- |
|
|
311
|
+
| `--main-bg` | `var(--vc-bg-page)` |
|
|
312
|
+
| `--light-bg` | `var(--vc-bg-surface)` |
|
|
313
|
+
| `--card-bg-color` | `var(--vc-bg-surface)` |
|
|
314
|
+
| `--dark-bg` | `var(--vc-bg-inset-strong)` |
|
|
315
|
+
| `--field-bg` | `var(--vc-bg-field)` |
|
|
316
|
+
| `--overlay-bg` | `var(--vc-bg-overlay)`: it carries its own transparency (3.x components mixed `--overlay-bg` to 40%, so a 3.x value `X` becomes `color-mix(in srgb, X 40%, transparent)`) |
|
|
317
|
+
| `--skeleton-loader` | `var(--vc-bg-muted)` |
|
|
318
|
+
| `--skeleton-loader-animation` | `var(--vc-bg-skeleton-shine)` |
|
|
319
|
+
| `--scrollbar-track` | `var(--vc-bg-surface)` |
|
|
320
|
+
| `--primary-text` | `var(--vc-content-primary)` |
|
|
321
|
+
| `--heading-text` | `var(--vc-content-primary)` |
|
|
322
|
+
| `--headers` | `var(--vc-content-primary)` |
|
|
323
|
+
| `--icons` | `var(--vc-content-primary)` |
|
|
324
|
+
| `--table-headings` | `var(--vc-content-primary)` |
|
|
325
|
+
| `--default-text` | `var(--vc-content-primary)` |
|
|
326
|
+
| `--secondary-text` | `var(--vc-content-secondary)` |
|
|
327
|
+
| `--placeholders` | `var(--vc-content-tertiary)` |
|
|
328
|
+
| `--inactive-text` | `var(--vc-content-disabled)` |
|
|
329
|
+
| `--inactive-elements` | `var(--vc-content-disabled)` |
|
|
330
|
+
| `--btn-filled-text` | `var(--vc-onfill-primary, var(--vc-onfill))` |
|
|
331
|
+
| `--default-loader` | `var(--vc-onfill-primary, var(--vc-onfill))` |
|
|
332
|
+
| `--ui-lines` | `var(--vc-border)` |
|
|
333
|
+
| `--major-ui-lines` | `var(--vc-border-strong)` |
|
|
334
|
+
| `--field-borders` | `var(--vc-input)` |
|
|
335
|
+
| `--scrollbar-thumb` | `var(--vc-border)` |
|
|
336
|
+
| `--scrollbar-thumb-hover` | `var(--vc-content-disabled)` |
|
|
337
|
+
| `--progress-line-done` | `var(--vc-action-success)` |
|
|
338
|
+
| `--progress-line-not-done` | `var(--vc-border)` |
|
|
339
|
+
| `--card-shadow-color` | `color-mix(in srgb, var(--vc-shadow-color) 12%, transparent)` |
|
|
340
|
+
| `--table-shadow-color` | `color-mix(in srgb, var(--vc-shadow-color) 7%, transparent)` |
|
|
341
|
+
| `--actions-mix-color` | `var(--vc-mix-anchor)` |
|
|
342
|
+
| `--primary` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
343
|
+
| `--primary-actions` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
344
|
+
| `--primary-actions--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
345
|
+
| `--primary-actions--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
346
|
+
| `--primary-actions-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
347
|
+
| `--primary-actions-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
348
|
+
| `--primary-alternative` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
349
|
+
| `--primary-alternative-actions` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
350
|
+
| `--primary-alternative-actions--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
351
|
+
| `--primary-alternative-actions--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
352
|
+
| `--primary-alternative-actions-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
353
|
+
| `--primary-alternative-actions-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
354
|
+
| `--secondary` | `var(--vc-action-secondary)` (fills, borders); `var(--vc-content-secondary)` (text) |
|
|
355
|
+
| `--secondary-actions` | `var(--vc-action-secondary)` (fills, borders); `var(--vc-content-secondary)` (text) |
|
|
356
|
+
| `--secondary-actions--focus` | `var(--vc-action-secondary--hover)` (fills); `var(--vc-content-secondary--hover)` (text) |
|
|
357
|
+
| `--secondary-actions--pressed` | `var(--vc-action-secondary--pressed)` (fills); `var(--vc-content-secondary--pressed)` (text) |
|
|
358
|
+
| `--secondary-actions-bg--focus` | `var(--vc-action-secondary--subtle-hover)` |
|
|
359
|
+
| `--secondary-actions-bg--pressed` | `var(--vc-action-secondary--subtle-pressed)` |
|
|
360
|
+
| `--destructive` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
361
|
+
| `--destructive-actions` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
362
|
+
| `--destructive-actions--focus` | `var(--vc-action-danger--hover)` |
|
|
363
|
+
| `--destructive-actions--pressed` | `var(--vc-action-danger--pressed)` |
|
|
364
|
+
| `--destructive-actions-bg--focus` | `var(--vc-action-danger--subtle-hover)` |
|
|
365
|
+
| `--destructive-actions-bg--pressed` | `var(--vc-action-danger--subtle-pressed)` |
|
|
366
|
+
| `--error` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
367
|
+
| `--error-actions` | `var(--vc-action-danger)` (fills); `var(--vc-content-danger)` (text) |
|
|
368
|
+
| `--error-actions--focus` | `var(--vc-action-danger--hover)` |
|
|
369
|
+
| `--error-actions--pressed` | `var(--vc-action-danger--pressed)` |
|
|
370
|
+
| `--error-actions-bg--focus` | `var(--vc-action-danger--subtle-hover)` |
|
|
371
|
+
| `--error-actions-bg--pressed` | `var(--vc-action-danger--subtle-pressed)` |
|
|
372
|
+
| `--success` | `var(--vc-action-success)` (fills); `var(--vc-content-success)` (text) |
|
|
373
|
+
| `--success-actions` | `var(--vc-action-success)` (fills); `var(--vc-content-success)` (text) |
|
|
374
|
+
| `--success-actions--focus` | `var(--vc-action-success--hover)` |
|
|
375
|
+
| `--success-actions--pressed` | `var(--vc-action-success--pressed)` |
|
|
376
|
+
| `--success-actions-bg--focus` | `var(--vc-action-success--subtle-hover)` |
|
|
377
|
+
| `--success-actions-bg--pressed` | `var(--vc-action-success--subtle-pressed)` |
|
|
378
|
+
| `--warning` | `var(--vc-action-warning)` (fills); `var(--vc-content-warning)` (text) |
|
|
379
|
+
| `--warning-actions` | `var(--vc-action-warning)` (fills); `var(--vc-content-warning)` (text) |
|
|
380
|
+
| `--warning-actions--focus` | `var(--vc-action-warning--hover)` |
|
|
381
|
+
| `--warning-actions--pressed` | `var(--vc-action-warning--pressed)` |
|
|
382
|
+
| `--warning-actions-bg--focus` | `var(--vc-action-warning--subtle-hover)` |
|
|
383
|
+
| `--warning-actions-bg--pressed` | `var(--vc-action-warning--subtle-pressed)` |
|
|
384
|
+
| `--active-elements` | `var(--vc-action-primary)` (fills); `var(--vc-content-brand)` (text) |
|
|
385
|
+
| `--active-elements--focus` | `var(--vc-action-primary--hover)` (fills); `var(--vc-content-brand--hover)` (text) |
|
|
386
|
+
| `--active-elements--pressed` | `var(--vc-action-primary--pressed)` (fills); `var(--vc-content-brand--pressed)` (text) |
|
|
387
|
+
| `--active-elements-bg--focus` | `var(--vc-action-primary--subtle-hover)` |
|
|
388
|
+
| `--active-elements-bg--pressed` | `var(--vc-action-primary--subtle-pressed)` |
|
|
389
|
+
| `--inactive-elements--focus` | `color-mix(in srgb, var(--vc-content-disabled) 80%, var(--vc-mix-anchor))` |
|
|
390
|
+
| `--inactive-elements--pressed` | `color-mix(in srgb, var(--vc-content-disabled) 65%, var(--vc-mix-anchor))` |
|
|
391
|
+
| `--inactive-elements-bg--focus` | `color-mix(in srgb, var(--vc-content-disabled) 10%, transparent)` |
|
|
392
|
+
| `--inactive-elements-bg--pressed` | `color-mix(in srgb, var(--vc-content-disabled) 20%, transparent)` |
|
|
393
|
+
| `--input-font-weight` (the weight of field text, `500`) | `--input-font-weight`, now the normal weight step `var(--vc-font-weight-normal)` |
|
|
394
|
+
|
|
395
|
+
### Tailwind colour classes
|
|
396
|
+
|
|
397
|
+
A colour name works the same after every colour prefix (`text-`, `bg-`, `border-`, `ring-`, `fill-`, `stroke-`, `divide-`, `outline-`, `placeholder-`, …) and with every variant: `text-default-text` becomes `text-content-primary`, `hover:bg-primary-actions-bg--focus` becomes `hover:bg-action-primary-subtle-hover`, `border-ui-lines` becomes `border-border`.
|
|
398
|
+
|
|
399
|
+
Text and icons in a status colour take the `content` name (`text-content-danger`, `text-content-success`). In most themes it is the same colour as the fill (`bg-action-danger`); voicenter draws success and warning text and icons darker than the fill.
|
|
400
|
+
|
|
401
|
+
`primary` and `secondary` are not status colours. Text and icons in `primary` (links, active tabs, outline and borderless buttons) take `var(--vc-content-brand)`, a deeper red than the `bg-action-primary` fill, with `var(--vc-content-brand--hover)` and `var(--vc-content-brand--pressed)`. Text and icons in `secondary` take `var(--vc-content-secondary)`, with `var(--vc-content-secondary--hover)` and `var(--vc-content-secondary--pressed)`; the border of an outline button is its text colour. The shipped Tailwind scheme has them as classes: `text-content-brand` with `-hover` and `-pressed`, and `text-content-secondary` with `-hover`. `content-secondary` is the 3.x `secondary-text`, a grey.
|
|
402
|
+
|
|
403
|
+
| 3.x colour name | 4.x colour name |
|
|
404
|
+
| --- | --- |
|
|
405
|
+
| `main-bg` | `page` |
|
|
406
|
+
| `light-bg` | `surface` |
|
|
407
|
+
| `card-bg-color` | `surface` |
|
|
408
|
+
| `dark-bg` | `inset-strong` |
|
|
409
|
+
| `field-bg` | `field` |
|
|
410
|
+
| `overlay-bg` | `overlay` (it carries its own transparency, as above) |
|
|
411
|
+
| `skeleton-loader` | `muted` |
|
|
412
|
+
| `skeleton-loader-animation` | no class |
|
|
413
|
+
| `scrollbar-track` | `surface` |
|
|
414
|
+
| `primary-text` | `content-primary` |
|
|
415
|
+
| `heading-text` | `content-primary` |
|
|
416
|
+
| `headers` | `content-primary` |
|
|
417
|
+
| `icons` | `content-primary` |
|
|
418
|
+
| `table-headings` | `content-primary` |
|
|
419
|
+
| `default-text` | `content-primary` |
|
|
420
|
+
| `secondary-text` | `content-secondary` |
|
|
421
|
+
| `placeholders` | `content-tertiary` |
|
|
422
|
+
| `inactive-text` | `content-disabled` |
|
|
423
|
+
| `inactive-elements` | `content-disabled` |
|
|
424
|
+
| `btn-filled-text` | `onfill-primary` |
|
|
425
|
+
| `default-loader` | `onfill-primary` |
|
|
426
|
+
| `ui-lines` | `border` |
|
|
427
|
+
| `major-ui-lines` | `border-strong` |
|
|
428
|
+
| `field-borders` | `input` |
|
|
429
|
+
| `scrollbar-thumb` | `border` |
|
|
430
|
+
| `scrollbar-thumb-hover` | `content-disabled` |
|
|
431
|
+
| `progress-line-done` | `action-success` |
|
|
432
|
+
| `progress-line-not-done` | `border` |
|
|
433
|
+
| `card-shadow-color` | no class; the `shadow-card` and `shadow-table` classes carry it |
|
|
434
|
+
| `table-shadow-color` | no class; the `shadow-table-row` and `shadow-table-header` classes carry it |
|
|
435
|
+
| `actions-mix-color` | no class |
|
|
436
|
+
| `primary` | `action-primary` (fills); `content-brand` (text) |
|
|
437
|
+
| `primary-actions` | `action-primary` (fills); `content-brand` (text) |
|
|
438
|
+
| `primary-actions--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
439
|
+
| `primary-actions--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
440
|
+
| `primary-actions-bg--focus` | `action-primary-subtle-hover` |
|
|
441
|
+
| `primary-actions-bg--pressed` | `action-primary-subtle-pressed` |
|
|
442
|
+
| `primary-alternative` | `action-primary` (fills); `content-brand` (text) |
|
|
443
|
+
| `primary-alternative-actions` | `action-primary` (fills); `content-brand` (text) |
|
|
444
|
+
| `primary-alternative-actions--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
445
|
+
| `primary-alternative-actions--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
446
|
+
| `primary-alternative-actions-bg--focus` | `action-primary-subtle-hover` |
|
|
447
|
+
| `primary-alternative-actions-bg--pressed` | `action-primary-subtle-pressed` |
|
|
448
|
+
| `secondary` | `action-secondary` (fills, borders); `content-secondary` (text) |
|
|
449
|
+
| `secondary-actions` | `action-secondary` (fills, borders); `content-secondary` (text) |
|
|
450
|
+
| `secondary-actions--focus` | `action-secondary-hover` (fills); `content-secondary-hover` (text) |
|
|
451
|
+
| `secondary-actions--pressed` | `action-secondary-pressed` (fills); `var(--vc-content-secondary--pressed)` in a style (text) |
|
|
452
|
+
| `secondary-actions-bg--focus` | `action-secondary-subtle-hover` |
|
|
453
|
+
| `secondary-actions-bg--pressed` | `action-secondary-subtle-pressed` |
|
|
454
|
+
| `destructive` | `action-danger` (fills); `content-danger` (text) |
|
|
455
|
+
| `destructive-actions` | `action-danger` (fills); `content-danger` (text) |
|
|
456
|
+
| `destructive-actions--focus` | `action-danger-hover` |
|
|
457
|
+
| `destructive-actions--pressed` | `action-danger-pressed` |
|
|
458
|
+
| `destructive-actions-bg--focus` | `action-danger-subtle-hover` |
|
|
459
|
+
| `destructive-actions-bg--pressed` | `action-danger-subtle-pressed` |
|
|
460
|
+
| `error` | `action-danger` (fills); `content-danger` (text) |
|
|
461
|
+
| `error-actions` | `action-danger` (fills); `content-danger` (text) |
|
|
462
|
+
| `error-actions--focus` | `action-danger-hover` |
|
|
463
|
+
| `error-actions--pressed` | `action-danger-pressed` |
|
|
464
|
+
| `error-actions-bg--focus` | `action-danger-subtle-hover` |
|
|
465
|
+
| `error-actions-bg--pressed` | `action-danger-subtle-pressed` |
|
|
466
|
+
| `success` | `action-success` (fills); `content-success` (text) |
|
|
467
|
+
| `success-actions` | `action-success` (fills); `content-success` (text) |
|
|
468
|
+
| `success-actions--focus` | `action-success-hover` |
|
|
469
|
+
| `success-actions--pressed` | `action-success-pressed` |
|
|
470
|
+
| `success-actions-bg--focus` | `action-success-subtle-hover` |
|
|
471
|
+
| `success-actions-bg--pressed` | `action-success-subtle-pressed` |
|
|
472
|
+
| `warning` | `action-warning` (fills); `content-warning` (text) |
|
|
473
|
+
| `warning-actions` | `action-warning` (fills); `content-warning` (text) |
|
|
474
|
+
| `warning-actions--focus` | `action-warning-hover` |
|
|
475
|
+
| `warning-actions--pressed` | `action-warning-pressed` |
|
|
476
|
+
| `warning-actions-bg--focus` | `action-warning-subtle-hover` |
|
|
477
|
+
| `warning-actions-bg--pressed` | `action-warning-subtle-pressed` |
|
|
478
|
+
| `active-elements` | `action-primary` (fills); `content-brand` (text) |
|
|
479
|
+
| `active-elements--focus` | `action-primary-hover` (fills); `content-brand-hover` (text) |
|
|
480
|
+
| `active-elements--pressed` | `action-primary-pressed` (fills); `content-brand-pressed` (text) |
|
|
481
|
+
| `active-elements-bg--focus` | `action-primary-subtle-hover` |
|
|
482
|
+
| `active-elements-bg--pressed` | `action-primary-subtle-pressed` |
|
|
483
|
+
| `inactive-elements--focus` | no class |
|
|
484
|
+
| `inactive-elements--pressed` | no class |
|
|
485
|
+
| `inactive-elements-bg--focus` | no class; disabled fields use `bg-inset` |
|
|
486
|
+
| `inactive-elements-bg--pressed` | no class |
|
|
487
|
+
|
|
488
|
+
### Theme keys
|
|
489
|
+
|
|
490
|
+
A `customJson` or `remote` theme passes the 4.x keys ([Theming specification](#theming-specification)). Where several 3.x keys become one 4.x key, the theme sets it once. When those keys had different values, this is a choice of one colour for all of them, made by whoever owns the theme, not a rename: `default-text`, `primary-text` and `heading-text` are one `vc-content-primary`, `primary` and `primary-alternative` one `vc-action-primary`. An application can also leave its own theme for a built-in one (`type: 'local'`). A 4.x theme sets only base colours: the hover, pressed and tinted states are mixed by the library. A key the theme leaves out takes the default theme's value, as the Theming specification describes.
|
|
491
|
+
|
|
492
|
+
Keys with no 3.x key of their own: `vc-bg-inset`, `vc-ring`, `vc-onfill-warning`, the anchors of single fills `vc-mix-anchor-{fill}` (the built-in themes set `vc-mix-anchor-primary` and `vc-mix-anchor-warning`; set them as `actions-mix-color` was set), `vc-action-info`, `vc-content-info` and `vc-content-brand` (the text of the 3.x `primary`, where 4.x draws the text deeper than the fill).
|
|
493
|
+
|
|
494
|
+
A remote branding section gets the `vc-*` keys before the application is upgraded: a 3.x application ignores them, and a 4.x application ignores the 3.x keys, so every key it does not receive takes the default theme's value.
|
|
495
|
+
|
|
496
|
+
| 3.x theme key | 4.x theme key |
|
|
497
|
+
| --- | --- |
|
|
498
|
+
| `main-bg` | `vc-bg-page` |
|
|
499
|
+
| `light-bg` | `vc-bg-surface` |
|
|
500
|
+
| `card-bg-color` | `vc-bg-surface` |
|
|
501
|
+
| `dark-bg` | `vc-bg-inset-strong` |
|
|
502
|
+
| `field-bg` | `vc-bg-field` |
|
|
503
|
+
| `overlay-bg` | `vc-bg-overlay`: it carries its own transparency (3.x components mixed `--overlay-bg` to 40%, so a 3.x value `X` becomes `color-mix(in srgb, X 40%, transparent)`) |
|
|
504
|
+
| `skeleton-loader` | `vc-bg-muted` |
|
|
505
|
+
| `skeleton-loader-animation` | none: mixed from `vc-bg-surface` |
|
|
506
|
+
| `scrollbar-track` | `vc-bg-surface` |
|
|
507
|
+
| `default-text` | `vc-content-primary` |
|
|
508
|
+
| `primary-text` | `vc-content-primary` |
|
|
509
|
+
| `heading-text` | `vc-content-primary` |
|
|
510
|
+
| `headers` | `vc-content-primary` |
|
|
511
|
+
| `icons` | `vc-content-primary` |
|
|
512
|
+
| `table-headings` | `vc-content-primary` |
|
|
513
|
+
| `secondary-text` | `vc-content-secondary` |
|
|
514
|
+
| `placeholders` | `vc-content-tertiary` |
|
|
515
|
+
| `inactive-text` | `vc-content-disabled` |
|
|
516
|
+
| `inactive-elements` | `vc-content-disabled` |
|
|
517
|
+
| `scrollbar-thumb-hover` | `vc-content-disabled` |
|
|
518
|
+
| `btn-filled-text` | `vc-onfill-primary` (text on the primary fill); `vc-onfill` for the other fills |
|
|
519
|
+
| `default-loader` | `vc-onfill-primary` |
|
|
520
|
+
| `ui-lines` | `vc-border` |
|
|
521
|
+
| `scrollbar-thumb` | `vc-border` |
|
|
522
|
+
| `major-ui-lines` | `vc-border-strong` |
|
|
523
|
+
| `progress-line-not-done` | `vc-border` |
|
|
524
|
+
| `field-borders` | `vc-input` |
|
|
525
|
+
| `card-shadow-color` | `vc-shadow-color`: a dark base colour the library mixes down (12% for cards here); the 3.x light-grey value is not reused |
|
|
526
|
+
| `table-shadow-color` | `vc-shadow-color`: a dark base colour the library mixes down (7% for tables here); the 3.x light-grey value is not reused |
|
|
527
|
+
| `actions-mix-color` | `vc-mix-anchor`, and `vc-mix-anchor-{fill}` for a fill with its own anchor (the built-in themes set `vc-mix-anchor-primary` and `vc-mix-anchor-warning`) |
|
|
528
|
+
| `primary` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
529
|
+
| `primary-alternative` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
530
|
+
| `active-elements` | `vc-action-primary` (fills); `vc-content-brand` (text) |
|
|
531
|
+
| `secondary` | `vc-action-secondary` (fills, borders); `vc-content-secondary` (text) |
|
|
532
|
+
| `destructive` | `vc-action-danger` (fills); `vc-content-danger` (text) |
|
|
533
|
+
| `error` | `vc-action-danger` (fills); `vc-content-danger` (text) |
|
|
534
|
+
| `success` | `vc-action-success` (fills); `vc-content-success` (text) |
|
|
535
|
+
| `progress-line-done` | `vc-action-success` |
|
|
536
|
+
| `warning` | `vc-action-warning` (fills); `vc-content-warning` (text and icons) |
|
|
537
|
+
| `transparent` | none: not a theme key |
|
|
538
|
+
| `current` | none: not a theme key |
|
|
539
|
+
| `white` | none: not a theme key |
|
|
540
|
+
| `black` | none: not a theme key |
|
|
541
|
+
|
|
542
|
+
### Finding the 3.x names
|
|
543
|
+
|
|
544
|
+
A 3.x name in `@apply` or in `theme('colors.…')` fails the Tailwind build. In a template class or in `var(--…)` it fails silently: the class is not generated and the variable is not set. This finds them in an application (any hit is a 3.x name; the 4.x names do not match):
|
|
545
|
+
|
|
546
|
+
```bash
|
|
547
|
+
n='(main|light|dark|field|overlay)-bg|card-bg-color|skeleton-loader(-animation)?|scrollbar-(track|thumb(-hover)?)|(primary|heading|default|secondary|inactive|btn-filled)-text|headers|icons|table-headings|placeholders|default-loader|(major-)?ui-lines|field-borders|progress-line-(not-)?done|(card|table)-shadow-color|actions-mix-color|(primary(-alternative)?|secondary|destructive|error|success|warning)(-actions)?|(active|inactive)-elements'
|
|
548
|
+
s='(-bg)?(--(focus|pressed))?'
|
|
549
|
+
grep -rnE "(var\(|['\"])--($n)$s[,)'\"]|(^|[^a-zA-Z0-9_-])(text|bg|border(-[xytrblse])?|ring(-offset)?|fill|stroke|divide|outline|placeholder|shadow|from|via|to|caret|accent|decoration)-($n)$s([^a-zA-Z0-9_-]|$)" src index.html tailwind.config.*
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
Add every other folder of the application with templates or styles. The Tailwind configuration counts too: a 3.x variable in its `boxShadow` or `colors` draws nothing, with no error. A class name composed in SCSS (`bg-#{$color}`) or in a JS string (`` `bg-${color}` ``) does not match the pattern either: search the parts that make such names (`#{`, `-actions`, `-elements`, `-text`) as well, and the lists those variables take their values from.
|
|
553
|
+
|
|
554
|
+
Colour prop values that name a Tailwind colour (`VcCollapseItem` `color-icon` and `color-border`, `VcLoading` `color`) do not match this pattern; check them separately.
|
|
555
|
+
|
|
556
|
+
The theme keys of a `customJson` configuration (`colors.json`) and of a remote branding section move to the `vc-*` keys of the table above. An application with `type: 'none'` sets the 4.x variables itself. `onSetupCallback(theme)` receives the theme with its `vc-*` keys.
|
|
557
|
+
|
|
558
|
+
### Icons
|
|
559
|
+
|
|
560
|
+
The components draw Lucide icons (`@lucide/vue`) where 3.x drew the `vc-icon-*` font, and the default icon of an icon prop is a Lucide component. A style that targets a `vc-icon-*` class inside a component no longer matches. An icon prop still takes a `vc-icon-*` class, drawn by the icon font that `style.css` loads (`injectIconFont` only inside a shadow root, see "Installation").
|
|
561
|
+
|
|
562
|
+
### Styles and component defaults
|
|
563
|
+
|
|
564
|
+
| What | 3.x | 4.x |
|
|
565
|
+
| --- | --- | --- |
|
|
566
|
+
| Close and maximize controls of VcModal, the close control of a notification, the copy control of VcCodeBlock | native buttons with the classes `vc-dialog-header-icon`, `vc-link`, `vc-dialog-header-maximize-icon`, `vc-dialog-header-close-icon` and `vc-toast-close-icon`; the copy control read `--code-block-muted` and `--code-block-selection` | a small secondary VcButtonIcon; those classes are gone (`vc-dialog-header-close`, `vc-dialog-header-maximize`, `vc-toast-icon-close` and `vc-code-block__copy` stay), and the copy control takes the colours of VcButtonIcon instead of `--code-block-muted` and `--code-block-selection` |
|
|
567
|
+
| `--base-border-radius` | set on `<html>` by the theme setup | removed; corners read the component radii `--vc-radius-*` (`--vc-radius-control` for controls) |
|
|
568
|
+
| The radius keys of the shipped `tailwind.config.js` | `xs`, `sm` (0.25rem), `md`, `lg`, `xl`, `xxl`, `tag`, `DEFAULT` (`rounded`) and `horizontal-tab-*` | the radius roles (see "Corners"), `none` and `full`. An application keeps Tailwind's own scale, and its `extend.borderRadius` from the shipped configuration adds the roles: `rounded-sm` is Tailwind's, and `rounded-xs`, `rounded-xxl` and `rounded-horizontal-tab-*` are not generated. A configuration that takes the whole shipped file instead of the keys "Tailwind" lists, such as `merge(require('@voicenter-team/voicenter-ui-plus/tailwind.config'), ownConfig)` with lodash `merge`, has only the roles, `none` and `full`. `borderRadius: require('tailwindcss/defaultTheme').borderRadius` in its own `theme` brings Tailwind's scale back beside the roles, since `merge` joins the two objects. With it `rounded-sm` is 0.125rem (3.x: 0.25rem; `rounded` is the 0.25rem one), and `rounded-2xl` and `rounded-3xl` are generated, which 3.x did not generate. An application with a `theme.borderRadius` of its own (a copy of the 3.x scale) removes it, takes the roles through `extend.borderRadius` and moves its `rounded-*` classes to the roles, by what each element is and not by its 3.x size ([Corners](#corners)) |
|
|
569
|
+
| The font keys of the shipped `tailwind.config.js` and the font classes of the library stylesheet | `main`, `rubik`, `inter` and `heebo`, all four Rubik | `main` only: `font-inter`, `font-heebo` and `font-rubik` are removed; replace them with `font-main`. `@apply font-inter` (or `font-heebo`, `font-rubik`) and `theme('fontFamily.inter')` fail the build. In a template the class is not generated, and text without it inherits whatever font its container sets, so the class is replaced rather than dropped |
|
|
570
|
+
| The component colours `primary-alternative` and `active`: the value of `color` and of any prop that takes a component colour (`prefixIconColor`, `tagColor`, `buttonColor`, `filledColor`, `confirmActionColor`, the `colorKey` of an option) | `primary-alternative` drew a colour of its own, `active` drew `active-elements` | removed: `componentColors` and `COMPONENT_COLOR_TYPE` no longer list them, and no class is generated for them. A project replaces every `primary-alternative` with `primary`, and every `active` given as a colour (`color="active"`, `prefix-icon-color="active"`) with `primary`: both draw the brand colour, and 4.x has no second accent colour. A style that targets their colour classes (`vc-button-color--primary-alternative`, `vc-input--active`, `vc-switch-color-active`, …) targets the `primary` class |
|
|
571
|
+
| The default `color` of VcInput, VcAutocomplete, VcPhoneInput, VcOtpInput, VcTimeInput, VcTagInput, VcSwitch and VcExtendedDatetimeRangePicker; `DEFAULT_COLOR` | `'active'` | `'primary'` |
|
|
572
|
+
| `shadow-hover-outer-active`, `shadow-hover-outer-primary-alternative` | the hover glow of the `active` and `primary-alternative` colours | removed; `shadow-hover-outer-primary` |
|
|
573
|
+
| `shadow-hover-outer-destructive` | the hover glow of the `destructive` colour | `shadow-hover-outer-danger`: a glow class is named by its fill, as `bg-action-danger` |
|
|
574
|
+
| The hover outline of VcCard with `hovered` | replaces the card shadow | fades in over the card shadow, which stays |
|
|
575
|
+
| `shadow-focus-outer`, `shadow-focus-outer-{primary,secondary,destructive,success,warning,info}`, `shadow-focus-{primary,secondary,destructive,success,warning}` | a focus glow in the colour the class names | removed; `shadow-focus`, the one focus ring, which has no colour of its own. A project whose Tailwind configuration defines these keys itself keeps them |
|
|
576
|
+
| `shadow-hover`, `shadow-hover-{primary,secondary,destructive,success,warning}` | a hover glow, outside and inside, in the colour the class names | removed: no component used them. `shadow-hover-inner`, `shadow-hover-outer`, `shadow-hover-outer-{colour}` and `shadow-hover-outer-off` stay. A project whose Tailwind configuration defines these keys itself keeps them |
|
|
577
|
+
| `tagBorderless` and `tagColor` of VcTagInput and VcTreeSelect | `false`, `'primary'` | `true`, `''`: a value is a borderless chip with no colour, neutral like a VcSelect multiple value (label and close icon `content-secondary`); set them for bordered, coloured tags. `tag-color="secondary"` draws the secondary colour, `action-secondary`, as on any other tag. A 3.x `tag-color` alone now gives a borderless chip in that colour; `:tag-borderless="false"` brings back the 3.x bordered tag |
|
|
578
|
+
| `DEFAULT_ICON_SIZE`, the default `prefixIconSize` of VcInput, VcAutocomplete, VcPhoneInput and VcExtendedDatetimeRangePicker | `'sm'` | `''`: no size class, so the prefix icon follows the size of the field and is larger at the default size; `prefix-icon-size="sm"` keeps the 3.x size |
|
|
579
|
+
| `iconClass` of VcSoundPlayerMarker | `'icon-md'` | `'icon-xs'`: the icon sits on a filled circle of the marker colour |
|
|
580
|
+
| The code font of VcCodeBlock, VcJsonViewer, VcToolCall, VcApprovalCard, the code in VcMdEditor and the labels of VcSipFlow | each its own list of system monospace fonts (VcMdEditor `JetBrains Mono` first, VcSipFlow `monospace` and `serif`) | DM Mono (`var(--vc-font-mono)`), loaded with Rubik, the system monospace fonts as fallback; `--vc-json-viewer-mono-font`, `--vc-tool-call-mono-font` and `--vc-approval-card-mono-font` still override it |
|
|
581
|
+
| Icon sizes inside the components: the default `iconClass` of VcPlayerPlayStopButton, the default `iconClasses` of VcPlayerPlaybackRate and VcPlayerPlaybackRatePopup, the `size` icons of VcSoundPlayer, the `large` icon of VcDatePicker, and the icons of VcPdfDocument's footer, VcTree, VcTreeSelect, VcImageUploader, VcIconPicker, VcSummaryStep, VcFileImportErrorsCard and VcExtendedDatetimeRangePicker | `icon-lg` (22px), `icon-2xl` (30px) | `icon-xl` (24px), `icon-2r` (32px): the icon sizes of the design (12 / 14 / 16 / 20 / 24 / 32). The classes themselves keep their sizes; pass the old class to keep the 3.x size |
|
|
582
|
+
| `borderRadius` of VcMeterGroup | `'6px'` | `'var(--vc-radius-inner)'`, the inner radius role |
|
|
583
|
+
| `StatusProgressConfig`, the type of the `statusColorMap` prop of VcProgressCircular | `Record<string, string>` | `Partial<Record<StatusProgress, string>>`: its keys are the `StatusProgress` values, each optional, so an object literal with another key, or code that reads another key, fails the type check |
|
|
584
|
+
| `VcTagInputColor`, exported from the package root | `'active' \| 'primary' \| 'secondary' \| 'destructive'` | removed: no prop took it. The `color` of VcTagInput is `COMPONENT_COLOR_TYPE` and its `tagColor` is `VcTagColorType` |
|
|
585
|
+
| `VcDatetimeRangePicker` and the types `VcPresetRangesType` and `VcDatetimeRangePickerModelType` | the component drew only a notice that it is deprecated | removed. `<VcDatetimeRangePicker>` becomes `<VcDatePicker type="datetimerange">` (or another `type`), or `VcExtendedDatetimeRangePicker` where the field has quick ranges; an import of the component or of the two types is deleted |
|
|
586
|
+
| `beforeStepFn` and `onEnterStepFn` of a `VcWizard` step (`VcWizardStepType`) | read as `validateStepFn` and `initStepFn`, with a console warning | removed, and a step that still sets them is neither validated nor initialised, with no error: rename `beforeStepFn` to `validateStepFn` and `onEnterStepFn` to `initStepFn` |
|
|
587
|
+
| `BindResultObjectType<T>`, exported from the package root | an alias of `BindingRowItemType<T>` | removed; replace it with `BindingRowItemType<T>` |
|
|
588
|
+
| The `columns` prop of VcTable | `ColumnType`: columns of `Record<string, unknown>` rows, whatever the rows of the table | `ColumnType<Row>`, `Row` being the type of the table's `options`: `format` and `sortableFunction` receive the row with its type. Columns declared for another row type than the table's fail the type check; declare them as `ColumnType<Row>` |
|
|
589
|
+
| `TEXT_COLORS`, exported from the package root | the Tailwind text class of each component colour (`text-primary`, `text-secondary-actions`, …) | removed; `textColorClass(color)` returns the text class of a component colour, `vc-text-color--<colour>` from the library stylesheet, and `text-<key>` for a Tailwind colour key |
|
|
590
|
+
| The default slot of VcButton and the value of VcBadgeTag | direct children of `.vc-button--content` and of the badge | inside `span.vc-button__label` and `span.vc-badge-tag__value`, which trim the label box to its capitals so the control centres them; a selector that reaches the slot content as a direct child (`.vc-button--content > span`) no longer matches it |
|
|
591
|
+
| `font-normal`, `font-medium`, `font-semibold` | `400`, `500`, `600` | `380`, `480`, `600` (`--vc-font-weight-*`): the three weights of the components' text, in an application too once it takes `extend.fontWeight` (see "Tailwind") |
|
|
592
|
+
| Page text, `b` and `strong`, table headers (`th`) | `400`, `bolder`, the browser's bold | `font-normal`, `font-semibold`, `font-medium` |
|
|
593
|
+
| `font-bold`, `font-extrabold`, `font-black`; `font-thin`, `font-extralight`, `font-light` in an application | Tailwind's weights | unchanged; the 4.x text has the three weights above, so replace the first three with `font-semibold` and the other three with `font-normal` |
|
|
594
|
+
| The colour of an `info` or `warning` notification (`NotifyService`, `$notify`) | `info`: `primary-actions`, the brand colour; `warning`: `warning` | `content-info` and `content-warning`: a notification takes the text colour of the component colour of its type, as `success` takes `content-success` and `error` takes `content-danger` |
|
|
595
|
+
| The border and clear icon of VcTagInput with a `color` | a glow on hover; when focused, the border of the colour | no glow: for every colour, `info` included, the border warms toward the colour on hover and takes the colour's hover shade when focused; the clear icon is the colour's text colour and darkens from it on hover |
|
|
596
|
+
| `color` and `prefixIconColor` of VcTreeSelect | the field drew the same colour whatever its `color` (the colour class did not reach it); a `prefixIconColor` other than `active`, `primary` and `destructive` drew `active-elements` | the field takes its `color` as VcTagInput does: the border warms toward the colour on hover and takes the colour's hover shade while the tree is open; the prefix icon takes the text colour of its `prefixIconColor`, for every colour |
|
|
597
|
+
| The rings of the `circles` loader of VcLoading with a `color` other than `primary`, `secondary` and `destructive` | three rings of the one colour | the outer ring is the colour, the second and third its hover and pressed shades, as for `primary`, `secondary` and `destructive` |
|
|
598
|
+
| The text of an unchecked VcRadioButtonsGroup button on hover | `primary`: the brand colour itself; the other colours: the hover shade of the fill | the hover shade of the colour's text colour, `primary` included: `primary` darkens on hover (lightens in `black`) as the others do, and `success` and `warning` mix from their text colour, which in voicenter is darker than the fill |
|
|
599
|
+
| The tick of a checked VcCheckbox, the text of a checked VcCheckboxButton and the text inside a VcProgress bar, for a fill other than `primary` | `btn-filled-text`, on every fill | the on-fill colour of that fill, as on a filled button: on the `warning` fill it is `onfill-warning`, dark in voicenter |
|
|
600
|
+
| A status that the `statusColorMap` of VcProgressCircular leaves out, when the map has no `default` key | `primary-alternative-actions`, the library's default | the fill of that status |
|
|
601
|
+
| The text and underline of a `success` or `warning` VcHyperLink | the fill colour (`success-actions`, `warning-actions`) | the text colour, `content-success` or `content-warning`, for the text and the underline alike: every colour's underline is the colour of its text. In voicenter these are darker than the fill |
|
|
602
|
+
| The clear icon of a VcInput or VcAutocomplete with a `color`, on hover | the hover shade of the fill | the hover shade of the colour's text colour, the colour the icon has at rest: unchanged for `primary`, `secondary`, `destructive` and `info`; for `success` and `warning` in voicenter, whose text is darker than the fill, darker than before |
|
|
603
|
+
| Slot content of a VcRadio with a `color` that reads `active-elements` (4.x: `action-primary`) | the radio's colour: the radio redefined `--active-elements` | the brand colour: the radio sets its own `--vc-radio-color` and redefines no theme variable |
|
|
604
|
+
| Slot content of VcFileUploaderArea that reads `icons` (4.x: `content-primary`) | `secondary-text`: the area redefined `--icons` | `content-primary`: the area colours its own label, drop text and file names `content-secondary` and redefines no theme variable |
|
|
605
|
+
|
|
606
|
+
### AI chat components
|
|
607
|
+
|
|
608
|
+
4.x adds the components `VcAiReasoning`, `VcToolCall`, `VcApprovalCard`, `VcAskUserCard`, `VcAgentRunCard`, `VcAgentRunGroup`, `VcJsonViewer`, `VcLightbox` and `VcPdfViewer` (their packages: [Optional peers](#optional-peers)). `VcMessage`, `VcMessagesWrapper`, `VcChatComposer` and `VcFileItem` gained props, slots and events for AI chats; existing usages render as before. What can need a change in an application:
|
|
609
|
+
|
|
610
|
+
- **`@milkdown/*` must be `^7.22.0`** (was `^7.15.5`). With the `prosemirror-model` that npm resolves today (1.25.12), milkdown before 7.22.0 fails to parse lists (`RangeError: Expected value of type boolean for attribute spread`), and every list of a `VcMdEditor` disappears. A lockfile that still holds an older `prosemirror-model` hides the problem until the next fresh install.
|
|
611
|
+
- **`VcMdEditor` in `readonly` lays out its text by the text's own direction and treats it as untrusted.** Every paragraph, heading, list, quote, table and cell takes its direction from its own text instead of the page's (`<html dir>` at mount, or the direction button): English text in an RTL page now reads left to right, a Hebrew paragraph in an LTR page right to left, a block without letters follows the text around it, and code reads left to right. A link with a protocol other than http(s), mailto and tel loses its `href`, web links open in a new tab (`target="_blank" rel="noopener noreferrer"`), and the table handles are hidden. An editable editor is unchanged. New in `VcMdEditor`: `streaming` (throttled updates and a caret while an AI answer arrives) and `plain` (no field around the text, for bubbles and cards); `minHeight` takes the number `0` (it fell back to 400px, so callers passed the string `'0'`).
|
|
612
|
+
- **`VcMessagesWrapper` is generic** over the message type: extend `VcChatMessage` with your own fields and the slots and events keep your type. `InstanceType<typeof VcMessagesWrapper>` no longer type-checks for a template ref; use the exported interface:
|
|
613
|
+
|
|
614
|
+
```diff
|
|
615
|
+
- const wrapper = ref<InstanceType<typeof VcMessagesWrapper>>()
|
|
616
|
+
+ import type { VcMessagesWrapperExposed } from '@voicenter-team/voicenter-ui-plus'
|
|
617
|
+
+ const wrapper = ref<VcMessagesWrapperExposed>()
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
- **`VcChatMessage.createdAt` is optional.** A message without it starts no date divider and shows no time (AI SDK messages have no timestamp). Code that passes `message.createdAt` on to something that does not accept `undefined` needs a guard, or a message type of your own with a required `createdAt`.
|
|
621
|
+
- **`VcMessageContent` has a `markdown` block** (`{ type: 'markdown', text, streaming? }`). An exhaustive `switch` or a `Record<VcMessageContentType, …>` over the content types needs the new case.
|
|
622
|
+
- **`VcMessage`'s `content` also accepts an array** of blocks, rendered in order in one bubble. `VcChatMessage.content` stays a single block; several blocks in a wrapper go through its `message` slot.
|
|
623
|
+
- **`VcMessage` colours changed.** In 3.x own messages used `--dark-bg` / `--btn-filled-text`, a contrast of 1.13–1.42:1 in every light theme, and the quote of an incoming message used the same pair. In 4.x others' bubbles are `--vc-bg-muted` and own ones (`align="end"`) the blue tint `--vc-action-info--subtle-hover`, both with `--vc-content-primary` text, so a bubble shows on a white card; the quote inside is `--vc-bg-surface`. The variables keep their 3.x names (`--vc-message-bg`, `--vc-message-text`, `--vc-message-reply-bg`, `--vc-message-reply-text`): a project that sets them keeps working, with any 3.x theme variable in their values replaced by its 4.x token. Markdown links in bubbles take the text colour. A project that styled around the old dark own bubble (e.g. white icons in a custom `footer`) should check its contrast.
|
|
624
|
+
- **Disabled tabs are no longer faded.** In `VcVerticalTabs` a disabled tab was drawn at 50% opacity; now, as in `VcTabs` and `VcRadioTabs`, its label and icon are `--vc-content-disabled`, with a not-allowed cursor, and hover or focus does not recolour it. A project that adds its own opacity to disabled tabs should remove it.
|
|
625
|
+
- **`VcTour`'s mask is `--vc-bg-overlay`.** `VcModal` already used it; `VcTour`'s mask (black at 50%) now takes it too. A `color` set in `VcTour`'s `mask` prop still wins.
|
|
626
|
+
- **`VcSkeletonLoader` stops its sweep under reduced motion.** When the system asks for reduced motion (`prefers-reduced-motion: reduce`) the shine no longer moves; the grey shapes stay as they were.
|
|
627
|
+
- **`VcViewSwitcher` is removed; `VcSegmented` takes its place.** `<VcViewSwitcher>` becomes `<VcSegmented variant="surface">` with the same `v-model`, `options`, `config` and `disabled`: `variant="surface"` draws the selected segment as the raised pill the switcher had, and `config` takes the same keys (`labelKey`, `valueKey`, `iconKey`, `disabledKey`, `disabledHintKey`). What changes in the template:
|
|
628
|
+
- the slot `tab-item` is `default`; its props are `item` (the option as passed), `option` (the mapped option, as before) and `isActive`;
|
|
629
|
+
- `@change` receives `(value, option)`, where the switcher passed the option alone;
|
|
630
|
+
- `data-test-name="x"` becomes the attribute `data-test="x"`;
|
|
631
|
+
- a style on `.vc-view-switcher`, `.vc-view-switcher-item` and `.vc-view-switcher-item--active` moves to `.vc-segmented`, `.el-segmented__item` and `.el-segmented__item.is-selected`;
|
|
632
|
+
- a segment is as high as a control of its `size`, lower than the switcher was; a row of options too wide for its container goes into a container that scrolls.
|
|
633
|
+
|
|
634
|
+
An application that already used `VcSegmented` checks its `@change`: the second argument is the picked option, where it was the earlier value. `VcSegmented` has no `color` prop: the selected segment is the primary fill (`variant="solid"`) or the surface pill (`variant="surface"`), so `color="…"` is removed from the tag. The selected segment is drawn on the segment itself, and `.el-segmented__item-selected` is shown only while the selection slides to another segment: a style on `.el-segmented__item-selected` moves to `.el-segmented__item.is-selected`, and a colour of the selected segment is set with `--el-segmented-item-selected-bg-color`, which both read.
|
|
635
|
+
- **`VcDatePicker` fills its container.** Date, date-time and range fields had the fixed Element Plus widths (220px a date, 350px a range, 400px a date-time range); a field is now as wide as its container, like `VcInput` and `VcSelect`. In a toolbar or filter bar it takes its width from a class (`class="w-44"`) or from its container.
|
|
636
|
+
- **`VcTable` has three densities, and `compact` is gone.** The `density` prop takes `'compact' | 'default' | 'large'`. A table with no props has the look `compact` gave in 3.x (14px text, rows about 36px), so `compact` is removed from the template. `density="large"` is the 3.x default look (16px text, rows about 43px); `density="compact"` is denser than 3.x had (12px text, rows about 28px, for small buttons and tags in its cells). The class `vc-table--small` is gone: a style written for it moves to `.vc-table--density-default`.
|
|
637
|
+
- **`VcTable` stacks into cards only on phones.** The stacked-card layout (header row hidden, each cell labelled) now starts at 440px of screen width instead of 780px, so a tablet or a narrow window keeps the table. A project that relied on the cards between 441 and 780px should check its tables there.
|
|
638
|
+
- **The `actions` slot of `VcChatComposer` (3.4.8) is `toolbar-start`**, with the slot props `{ disabled, streaming }`; `toolbar-end` (new) sits right before Send / Stop.
|
|
639
|
+
- **`VcMessagesWrapper`'s `scrollToMessage` takes options**, as in 3.4.8: `scrollToMessage(id, 'auto')` of 3.4.7 and earlier becomes `scrollToMessage(id, { behavior: 'auto' })`, and `block` and `offset` place the message. It scrolls only the wrapper, not the page, and the view stays on the message while the list grows below it.
|
|
640
|
+
- **Exported types**: `VcFileItemProps` (with the new `errorText`), `VcChatComposerEmits`, and props / emits / slot-props / exposed interfaces of every new component.
|
|
641
|
+
- **Localization**: the library ships only `en`. An application with another locale adds the keys new since 3.4.8 with `tVUManage.updateLocaleMessages`: `voicenterUi.jsonViewer.*`, `voicenterUi.aiChat.*`, `voicenterUi.lightbox.*`, `voicenterUi.aiReasoning.*`, `voicenterUi.toolCall.*`, `voicenterUi.approvalCard.*`, `voicenterUi.askUserCard.*`, `voicenterUi.agentRun.*`, `voicenterUi.agentRunGroup.*`, `voicenterUi.pdfViewer.*`, `voicenterUi.filterBar.*`, `voicenterUi.messagesWrapper.jumpToBottom`, `voicenterUi.message.download`, `voicenterUi.chatComposer.stop`, `voicenterUi.chatComposer.stopGenerating`, `voicenterUi.chatComposer.unsupportedFile`, `voicenterUi.fileItem.preview`, `voicenterUi.fileItem.remove` (English texts in `src/localization/locales/en.json`). An application on 3.4.7 or earlier also adds the keys of 3.4.8: `voicenterUi.message.video`, `voicenterUi.message.status.*`, `voicenterUi.messagesWrapper.newMessages`.
|
|
642
|
+
|
|
643
|
+
Fixes in the components 3.x had:
|
|
644
|
+
|
|
645
|
+
- **PDFs open without `eval` (CVE-2024-4367).** pdf.js before 4.2.67 compiles font glyphs with `eval`, so a crafted PDF could run JavaScript in the page. `VcPdfDocument` and `VcPdfViewer` now pass `isEvalSupported: false` to `getDocument` (no caller can turn it back on); pdf.js draws the glyphs through its slower interpreted path, the text looks the same. The lasting fix is `pdfjs-dist` 4.2.67 or newer, a separate upgrade of the peer (the library still declares `^2.16.105`).
|
|
646
|
+
- **Lists in `VcMdEditor`** render again with `@milkdown/*` `^7.22.0` (see above).
|
|
647
|
+
- **Code blocks in `VcMdEditor`** take the theme's colours. Copy is a secondary text action (`--vc-content-secondary` text and icon, the `--vc-action-secondary--subtle-hover` hover, a focus ring, visible while it has keyboard focus) instead of Crepe's grey pill without hover or focus states; the line numbers, fold markers, folded-code placeholder, cursor and selection use the theme variables instead of One Dark's colours. The syntax colours are unchanged. Read-only, a code block is framed (`--vc-border`, on `--vc-bg-surface` in `--vc-content-primary`) with no line numbers, active line or language button, Copy floats in its corner on hover or focus, a long line scrolls with a visible scrollbar, and inline code wraps instead of running past the column.
|
|
648
|
+
|
|
649
|
+
## Upgrading from a 4.0 beta
|
|
650
|
+
|
|
651
|
+
An application on a 4.0 beta has moved from 3.x with [Migrating from 3.x to 4.x](#migrating-from-3x-to-4x) as its beta shipped it. That section describes the current release; the table below lists what such an application changes or checks on the way there. A row names the last release without the change, so the application takes every row whose release is the one it has installed (the `version` its `package.json` or lock file gives for the library before the upgrade) or a later one: an application on `4.0.0-beta.3` takes the rows of `4.0.0-beta.3`, `4.0.0-beta.4` and `4.0.0-beta.5`.
|
|
652
|
+
|
|
653
|
+
Additions that ask nothing of an application (new components, props, theme keys and classes) are not rows: they are in the sections above and in the [live documentation](https://voicenter-ui-plus.pages.dev/).
|
|
654
|
+
|
|
655
|
+
| Changed after | What changed | What the application does |
|
|
656
|
+
| --- | --- | --- |
|
|
657
|
+
| `4.0.0-beta.1` | The packages that only some components need are optional peers, and npm no longer installs them with the library | The **Optional peers** item of [What changed and why](#what-changed-and-why): the packages of the components it renders go into its own `dependencies` ([Optional peers](#optional-peers)), with the `external` list, the tests and the KaTeX stylesheet that item names |
|
|
658
|
+
| `4.0.0-beta.5` | The default theme is `voicenter`, where the earlier betas had `redGreen` | An application that passes no `themeConfig`, or a tree-shake one that does not call `Theme()`, is drawn in `voicenter` ([Theming specification](#theming-specification)) |
|
|
659
|
+
| `4.0.0-beta.5` | The built-in themes are the light `voicenter` and the dark `voicenterDark`, which is new: `red`, `redGreen`, `black` and `voicenterRed` are removed | An application that passes one of the removed names is drawn in `voicenter` and logs a warning: it passes `voicenter` (light; the colours `voicenterRed` had) or `voicenterDark` (dark), or its own colours as a `customJson` theme ([Theming specification](#theming-specification)) |
|
|
660
|
+
| `4.0.0-beta.5` | The built-in themes no longer set `vc-content-warning-icon` | `var(--vc-content-warning-icon)` and the class `text-content-warning-icon` draw no colour: they become `var(--vc-content-warning)` and `text-content-warning`, the one warning colour of text and icons. A `customJson` or remote theme drops the key |
|
|
661
|
+
| `4.0.0-beta.5` | Brand and grey text have their own tokens: `content-brand` for text and icons in `primary`, `content-secondary` for text and icons in `secondary`; `action-primary` and `action-secondary` draw fills | Text and icons the application colours with `text-action-primary`, `text-action-secondary` or `var(--vc-action-primary)` / `var(--vc-action-secondary)` move to `text-content-brand`, `text-content-secondary` and their variables; fills and borders keep the `action-*` names ([Tailwind colour classes](#tailwind-colour-classes)) |
|
|
662
|
+
| `4.0.0-beta.5` | Disabled controls and disabled tabs are no longer faded: they draw the disabled colours at full opacity | A style of the application that fades a disabled ui-plus control or tab, or reads its opacity, is removed ([AI chat components](#ai-chat-components), the note on disabled tabs) |
|
|
663
|
+
| `4.0.0-beta.5` | `VcMessage` bubbles: others' are `bg-muted`, own ones the blue tint | An application that sets `--vc-message-bg` and the variables beside it keeps its colours; one that styled around the earlier bubble colours checks its contrast ([AI chat components](#ai-chat-components)) |
|
|
664
|
+
| `4.0.0-beta.5` | The default icon classes inside the components are `icon-xl` (24px) and `icon-2r` (32px), where the earlier betas had `icon-lg` (22px) and `icon-2xl` (30px) | Nothing, or the earlier class passed in the component's icon class prop to keep that size ([Styles and component defaults](#styles-and-component-defaults)) |
|
|
665
|
+
| `4.0.0-beta.5` | `VcTable` stacks into cards up to 440px of screen width, where the earlier betas stacked up to 780px | The application checks its tables between 441 and 780px ([AI chat components](#ai-chat-components)) |
|
|
666
|
+
| `4.0.0-beta.5` | The step buttons of `VcTour` are `VcButton` | A style that targets Element Plus's buttons inside the tour (`.el-tour-buttons .el-button`) no longer matches; the buttons take the VcButton classes |
|
|
667
|
+
| `4.0.0-beta.5` | Code in the components is DM Mono, through one variable, `--vc-font-mono`; the plugin and `loadTextFont()` load it with Rubik from Google Fonts | Nothing where the fonts come from the plugin or `loadTextFont()`. An application that loads the fonts itself also loads DM Mono (400 and 500), or sets `--vc-font-mono` on `:root` to its own code font ([Text](#text)) |
|
|
668
|
+
| `4.0.0-beta.5` | `VcTable` takes `density` (`'compact' \| 'default' \| 'large'`) and has no `compact` prop; a table with no props has the look `compact` gave | `compact` is removed from every `VcTable`; a table that had no `compact` takes `density="large"` to keep its look; a style on `.vc-table--small` moves to `.vc-table--density-default` ([AI chat components](#ai-chat-components)) |
|
|
669
|
+
| `4.0.0-beta.5` | `VcDatePicker` is as wide as its container, where the earlier betas had the fixed Element Plus widths | A date picker in a toolbar, a filter bar or any row that relied on the fixed width takes a width class or a sized container ([AI chat components](#ai-chat-components)) |
|
|
670
|
+
| `4.0.0-beta.5` | `VcViewSwitcher` is removed; `VcSegmented` takes icons, disabled hints and the `surface` variant, its `change` passes `(value, option)`, and its `color` prop is removed | Every `<VcViewSwitcher>` becomes `<VcSegmented variant="surface">` by the list under **`VcViewSwitcher` is removed** ([AI chat components](#ai-chat-components)); a `@change` handler of an existing `VcSegmented` that read the earlier value as its second argument is updated, `color` is removed from every `<VcSegmented>`, and a style on `.el-segmented__item-selected` moves to `.el-segmented__item.is-selected` |
|
|
671
|
+
| `4.0.0-beta.5` | `VcDatetimeRangePicker`, the step keys `beforeStepFn` and `onEnterStepFn` of `VcWizard`, and the types `BindResultObjectType`, `VcPresetRangesType` and `VcDatetimeRangePickerModelType` are removed | The application searches for these names (`grep -rnE "VcDatetimeRangePicker|vc-datetime-range-picker|beforeStepFn|onEnterStepFn|BindResultObjectType|VcPresetRangesType" src`) and replaces each hit by its row in **Styles and component defaults** ([Styles and component defaults](#styles-and-component-defaults)); a wizard step with the old keys otherwise skips its validation silently |
|
|
672
|
+
| `4.0.0-beta.5` | The `columns` of `VcTable` are typed by the table's row: `ColumnType<Row>` | Nothing at runtime. Where `vue-tsc` reports the `columns` of a `<VcTable>`, the columns are declared as `ColumnType<Row>` with the type of the table's `options` ([Styles and component defaults](#styles-and-component-defaults)) |
|
|
673
|
+
| `4.0.0-beta.6` | `VcTimeInput` mounted with a value above `maxValue` sends `maxValue`, where the earlier betas showed `maxValue` and sent `minValue`; with `maxValue` 0 (no upper limit) its + button adds a step, where the earlier betas set the value to 0; on an RTL page its digits stay left to right (01:30, where the earlier betas showed 30:01) | An application with a time input whose starting value can be above its `maxValue`, or with `max-value="0"`, checks the value it receives; one that styled around the reversed RTL digits removes that style |
|
|
674
|
+
| `4.0.0-beta.9` | `clearable` does nothing on `VcTimeInput`, where `4.0.0-beta.8` alone drew a clear control: the field always holds a number, `update:modelValue` passes `number`, and the `seconds` of `input` is a `number` | `clearable` is removed from every `<VcTimeInput>` (`grep -rnE "<VcTimeInput[^>]*clearable" src`), and a handler written for `number \| undefined` can take `number`; a field that must be able to hold no value is shown or hidden by the form around it |
|
|
675
|
+
|
|
676
|
+
After its rows the application runs the search of [Finding the 3.x names](#finding-the-3x-names) again: it finds a 3.x name that the guide of an earlier beta did not list.
|
|
677
|
+
|
|
678
|
+
## Using ui-plus in an application
|
|
679
|
+
|
|
680
|
+
How an application builds its UI with ui-plus. Agents working in a consuming project read this section before any UI work; it describes the version installed next to it.
|
|
681
|
+
|
|
682
|
+
### Where the facts are
|
|
683
|
+
|
|
684
|
+
The installed package is the truth. Read it before saying what ui-plus has or how a component behaves.
|
|
685
|
+
|
|
686
|
+
- **Every component**: `library/types/components/exports.d.ts`. One component's props, events and slots: `library/types/components/<VcName>/<VcName>.vue.d.ts`.
|
|
687
|
+
- **Composables, services, directives, the entity base**: `library/types/composables/`, `library/types/services/`, `library/types/directives/`, `library/types/entity/`.
|
|
688
|
+
- **Types**: prop, event and configuration types are exported from the package root (`import type { UIConfig } from '@voicenter-team/voicenter-ui-plus'`). Generic components take type parameters in the template: `<VcSelect<User, 'id', 'name'> v-model="selected" :options="users" value-key="id" label-key="name" />`.
|
|
689
|
+
- **Colour tokens**: `src/theme/themes.json` (each key is the CSS variable `--<key>`) and `src/theme/tailwindScheme.js` (the Tailwind colour names).
|
|
690
|
+
- **Examples**: the [live documentation](https://voicenter-ui-plus.pages.dev/).
|
|
691
|
+
|
|
692
|
+
### Choosing a component
|
|
693
|
+
|
|
694
|
+
- Interaction components come from ui-plus: buttons, inputs, selects, date pickers, checkboxes, tabs, tables, modals, drawers, tooltips, popovers, uploaders, notifications, confirmations. Search `exports.d.ts` by what the user is shown (a picker of people, an on/off switch, a list with a search) before concluding a component is missing.
|
|
695
|
+
- A component is used **as the library draws it**: through its props, slots and variants. Fitting it into the layout is free: width, spacing, wrapping, alignment.
|
|
696
|
+
- A **custom control** needs the project owner's explicit yes, asked before it is written: which element is needed, what was searched in ui-plus, why nothing fits. Custom means any of:
|
|
697
|
+
- a new interaction component;
|
|
698
|
+
- a ui-plus component whose own CSS variables (`--el-*`, the ones ui-plus sets on `.vc-*`) or internal classes are overridden to change how it looks or behaves as a control: its track, rows, selected, hover or active state, shape or indicator;
|
|
699
|
+
- a ui-plus component used for a role it is not built for, such as a segmented switcher drawn as a searchable list.
|
|
700
|
+
- Until that yes, the closest ui-plus component is used as drawn, and the difference from the design is the first open point of the report: what the design draws, which component was used, how they differ. No agent or orchestrator gives this approval in the owner's place.
|
|
701
|
+
- A report names a control by what is on screen: a restyled ui-plus component is reported as custom.
|
|
702
|
+
- A design hand-off (Figma, mock-up, screenshot, a specification) says what the user should see. It never justifies a restyle or a custom control.
|
|
703
|
+
|
|
704
|
+
### Colours
|
|
705
|
+
|
|
706
|
+
- Every colour is a ui-plus token: a Tailwind class from the library scheme (`text-content-primary`, `text-content-secondary`, `bg-action-primary`, `text-content-brand` for brand-coloured text, `bg-page`, `bg-surface`, `border-border`, `text-content-success`, `text-content-danger`) or a theme variable in a style (`color: var(--vc-content-primary)`). Status colours, tags, icons and chart series included.
|
|
707
|
+
- Hex values, `rgb()`/`rgba()`, arbitrary classes such as `bg-[#…]` and new colour variables stay out of application code. Such colours already in a project are not a precedent.
|
|
708
|
+
- The theme configuration (`themeConfig`, usually a `colors.json`) sets the library theme. It is not a palette to add colours to.
|
|
709
|
+
|
|
710
|
+
### Corners
|
|
711
|
+
|
|
712
|
+
- A corner takes the radius role of what it draws: `rounded-<role>`, a class of the shipped configuration ([Tailwind](#tailwind)), or `var(--vc-radius-<role>)` in a style:
|
|
713
|
+
- `rounded-control`: buttons, icon, toggle and split buttons, inputs, selects, pickers, at the default and large sizes;
|
|
714
|
+
- `rounded-control-sm`: the same controls at the small size (`--vc-size-control-sm`, 24px), and any other control of that height;
|
|
715
|
+
- `rounded-popup`: floating panels (popovers, dropdowns, select panels, tooltips, date-picker panels, notifications);
|
|
716
|
+
- `rounded-card`: cards, the outer frame of a table, modals;
|
|
717
|
+
- `rounded-tag`: tags and chips, drawn as a pill;
|
|
718
|
+
- `rounded-inner`: a part inside a control, popup or card (menu and list items, thumbnails and file icons, inline chips and labels, boxes inside editors and modals, checkbox boxes, colour-picker sliders, tree nodes, skeleton blocks, square tags).
|
|
719
|
+
- Besides the roles the shipped configuration has only `rounded-none` and `rounded-full` (a circle). A role takes Tailwind's side and corner prefixes like any radius: `rounded-t-card`, `rounded-s-control`.
|
|
720
|
+
- Pixel radii and arbitrary classes such as `rounded-[6px]` stay out of application code. Such radii already in a project are not a precedent.
|
|
721
|
+
|
|
722
|
+
### Shadows
|
|
723
|
+
|
|
724
|
+
- A shadow is a class of the shipped configuration ([Tailwind](#tailwind)):
|
|
725
|
+
- elevation: `shadow-raised` for an element lifted on hover or drag and `shadow-overlay` for a floating panel, read from `--vc-shadow-raised` and `--vc-shadow-overlay`; `shadow-card` for a card;
|
|
726
|
+
- focus: `shadow-focus` draws the one focus ring `--vc-focus-ring`, the theme's `--vc-ring` colour at `--vc-focus-ring-width`, and `shadow-focus-inner` draws it inside.
|
|
727
|
+
- `shadow-vertical-tab-item-hover` is the raised elevation; `shadow-focus-outer-off` is not a focus ring and keeps its own glow.
|
|
728
|
+
- A hand-written `box-shadow` and arbitrary classes such as `shadow-[…]` stay out of application code. Such shadows already in a project are not a precedent.
|
|
729
|
+
|
|
730
|
+
### Text
|
|
731
|
+
|
|
732
|
+
- Text keeps the library font, Rubik, which covers Latin and Hebrew: `font-main`, the one font key of the shipped configuration, set on `<html>`. The plugin (`app.use(VoicenterUI)`) loads it from Google Fonts. The tree-shake entry does not load it, the stylesheet only names it: `loadTextFont()` loads it ([Tree-shake mode](#tree-shake-mode-recommended)). An application's own Tailwind preflight sets another font on `<html>` ([Tailwind](#tailwind)).
|
|
733
|
+
- Text takes three weights, classes of the shipped configuration ([Tailwind](#tailwind)) read from `--vc-font-weight-*`: `font-normal` (the page text), `font-medium` (table headers, `th`) and `font-semibold` (`b` and `strong`). The other weight classes keep their Tailwind values.
|
|
734
|
+
- `transition-weight` is for text whose weight changes with its state.
|
|
735
|
+
- Code (JSON, code blocks, identifiers) takes `var(--vc-font-mono)` in a stylesheet: DM Mono, loaded with Rubik by the plugin and by `loadTextFont()`, with the system monospace fonts as fallback. An application with a code font of its own sets the variable on `:root`.
|
|
736
|
+
- Other font families and the weights `font-bold` and heavier stay out of application code. Such fonts and weights already in a project are not a precedent.
|
|
737
|
+
|
|
738
|
+
### Icons
|
|
739
|
+
|
|
740
|
+
- Icons are Lucide (`@lucide/vue`). An icon the application passes to a component or draws itself is a Lucide component imported by name: `import { Search } from '@lucide/vue'`, then `<VcButton :icon="Search">` or `<VcIcon :icon="Search" />`.
|
|
741
|
+
- The type of an icon prop is `TIcon`, exported from the package root.
|
|
742
|
+
|
|
743
|
+
### Notifications and confirmations
|
|
744
|
+
|
|
745
|
+
`NotifyService`, `useConfirmModal` and `useConfirmPopup` render only through the hosts described in [Global overlays](#global-overlays), mounted once in the application. A `VcNotification` host shows only the messages of its own `group`, so where the application mounts one host per group, every notification names one of those groups.
|
|
746
|
+
|
|
747
|
+
### Text direction
|
|
748
|
+
|
|
749
|
+
ui-plus follows the `dir` attribute of `<html>`: `useRTL()` reads it and updates when it changes. The application sets the direction there, once.
|
|
750
|
+
|
|
751
|
+
### AI chat
|
|
752
|
+
|
|
753
|
+
An AI chat is built from the chat components; their props, events and slots are in the installed types, and the [live documentation](https://voicenter-ui-plus.pages.dev/) has an example of each.
|
|
754
|
+
|
|
755
|
+
- The conversation: `VcMessagesWrapper` (its `message` slot renders one AI message from several parts, `hideHeader`, `busy`, the jump-to-latest button) with `VcMessage` (`variant="plain"` for the assistant, several content blocks, the `footer` slot for model / tokens / copy).
|
|
756
|
+
- Assistant text: `VcMdEditor` with `readonly hide-toolbar plain`, and `streaming` while it streams (the renderer of the `markdown` block of `VcMessage`). Reasoning: `VcAiReasoning`. Tool calls: `VcToolCall`. Human approval of a tool: `VcApprovalCard`. Questions the agent asks the user: `VcAskUserCard`. Sub-agents: `VcAgentRunCard` / `VcAgentRunGroup`.
|
|
757
|
+
- Input: `VcChatComposer` with `streaming` (Stop instead of Send). Attachments open in `VcLightbox` (images) or `VcPdfViewer` (an inline PDF viewer for a tab or a panel).
|
|
758
|
+
- The library ships only English texts: an application in another language adds the keys of these components with `tVUManage.updateLocaleMessages` (the list is in [AI chat components](#ai-chat-components)).
|
|
759
|
+
|
|
760
|
+
### Server-side rendering
|
|
761
|
+
|
|
762
|
+
ui-plus is built and tested for client-rendered Vue applications. Its composables read `document` and `window` when they are called (`useRTL` among them), and the package ships no Nuxt module. An application with server-side rendering proves one page that uses ui-plus in development and in a production build before relying on it, and reports what fails.
|
|
763
|
+
|
|
764
|
+
### Troubleshooting
|
|
765
|
+
|
|
766
|
+
- **Component not found or a blank page**: in tree-shake mode a component is a local import, never a globally registered tag. In plugin mode both `app.use(VoicenterUI, …)` and `import '@voicenter-team/voicenter-ui-plus/style.css'` are present.
|
|
767
|
+
- **A component fails with `<pkg> is not installed` or `Could not resolve "<pkg>" imported by "@voicenter-team/voicenter-ui-plus"`**: the application does not have that optional peer. Install the packages the component's documentation page lists ([Optional peers](#optional-peers)).
|
|
768
|
+
- **Duplicate styles, a huge CSS payload**: the two modes are mixed (named imports plus the global `style.css`). Pick one (`MIGRATION_v3.md`, §1).
|
|
769
|
+
- **`InstanceType<typeof VcMessagesWrapper>` does not type-check**: a generic component (`VcMessagesWrapper` since 4.0) has no constructor type. Type its template ref with the exported interface: `ref<VcMessagesWrapperExposed>()`. The other chat components with exposed methods export the same kind of interface (`VcChatComposerExposed`, `VcLightboxExposed`, `VcPdfViewerExposed`, …).
|
|
770
|
+
- **Lists missing from `VcMdEditor` or an AI answer** (`RangeError: Expected value of type boolean for attribute spread` in the console): `@milkdown/*` is older than 7.22.0. Install `^7.22.0` ([AI chat components](#ai-chat-components)).
|
|
771
|
+
- **PDF.js worker not loading, or Symbol / ZapfDingbats glyphs (✓, ✗, ★, Greek letters) drawn with another font or as boxes**: the worker and the standard font data of those two fonts are sibling assets resolved with `new URL('./pdf.worker.min.js', import.meta.url)` and `new URL('./standard_fonts/FoxitDingbats.pfb', import.meta.url)` (and `FoxitSymbol.pfb`); the bundler must support that pattern (Vite, webpack 5+, Rollup and esbuild do) and emits them as assets of the application.
|
|
772
|
+
|
|
773
|
+
## Date Handling
|
|
774
|
+
|
|
775
|
+
This library uses **dayjs** for all date operations and formatting. When working with date-related components, use dayjs format tokens (NOT date-fns format tokens).
|
|
776
|
+
|
|
777
|
+
### Format Tokens
|
|
778
|
+
|
|
779
|
+
**Important**: Use dayjs format tokens:
|
|
780
|
+
- `DD` - Day of month (2 digits) - **NOT** `dd`
|
|
781
|
+
- `YYYY` - 4-digit year - **NOT** `yyyy`
|
|
782
|
+
- `MM` - Month (2 digits)
|
|
783
|
+
- `HH` - 24-hour format
|
|
784
|
+
- `mm` - Minutes
|
|
785
|
+
- `ss` - Seconds
|
|
786
|
+
|
|
787
|
+
### Common Formats
|
|
788
|
+
|
|
789
|
+
```typescript
|
|
790
|
+
'DD/MM/YYYY' // 31/12/2024
|
|
791
|
+
'DD-MM-YYYY' // 31-12-2024
|
|
792
|
+
'YYYY-MM-DD' // 2024-12-31
|
|
793
|
+
'DD/MM/YYYY, HH:mm' // 31/12/2024, 14:30
|
|
794
|
+
'DD/MM/YYYY HH:mm:ss' // 31/12/2024 14:30:45
|
|
795
|
+
```
|
|
796
|
+
|
|
797
|
+
### Usage Example
|
|
798
|
+
|
|
799
|
+
```vue
|
|
800
|
+
<VcDatePicker
|
|
801
|
+
v-model="date"
|
|
802
|
+
format="DD/MM/YYYY"
|
|
803
|
+
input-date-format="DD/MM/YYYY"
|
|
804
|
+
input-time-format="HH:mm"
|
|
805
|
+
/>
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
## Date Utility Functions
|
|
809
|
+
|
|
810
|
+
The library provides a comprehensive set of date utility functions built on dayjs. These utilities are available for use in external projects.
|
|
811
|
+
|
|
812
|
+
### Import Date Utilities
|
|
813
|
+
|
|
814
|
+
```typescript
|
|
815
|
+
import {
|
|
816
|
+
formatDate,
|
|
817
|
+
parseDate,
|
|
818
|
+
addDays,
|
|
819
|
+
subtractDays,
|
|
820
|
+
getHours,
|
|
821
|
+
getMinutes,
|
|
822
|
+
getSeconds,
|
|
823
|
+
setTime,
|
|
824
|
+
isAfter,
|
|
825
|
+
isSameAfter,
|
|
826
|
+
isBefore,
|
|
827
|
+
isSameBefore,
|
|
828
|
+
format,
|
|
829
|
+
add,
|
|
830
|
+
sub,
|
|
831
|
+
addFp,
|
|
832
|
+
subFp
|
|
833
|
+
} from '@voicenter-team/voicenter-ui-plus'
|
|
834
|
+
```
|
|
835
|
+
|
|
836
|
+
### Basic Date Operations
|
|
837
|
+
|
|
838
|
+
#### Formatting Dates
|
|
839
|
+
|
|
840
|
+
```typescript
|
|
841
|
+
// Format a date with default format (YYYY-MM-DD)
|
|
842
|
+
const formatted = formatDate(new Date())
|
|
843
|
+
// Result: "2024-12-31"
|
|
844
|
+
|
|
845
|
+
// Format with custom format
|
|
846
|
+
const custom = formatDate(new Date(), 'DD/MM/YYYY')
|
|
847
|
+
// Result: "31/12/2024"
|
|
848
|
+
|
|
849
|
+
// Using format function (alias)
|
|
850
|
+
const formatted2 = format(new Date(), 'DD/MM/YYYY HH:mm')
|
|
851
|
+
// Result: "31/12/2024 14:30"
|
|
852
|
+
```
|
|
853
|
+
|
|
854
|
+
#### Parsing Dates
|
|
855
|
+
|
|
856
|
+
```typescript
|
|
857
|
+
// Parse a date string with format
|
|
858
|
+
const date = parseDate('31/12/2024', 'DD/MM/YYYY')
|
|
859
|
+
// Returns: Date object
|
|
860
|
+
```
|
|
861
|
+
|
|
862
|
+
### Date Arithmetic
|
|
863
|
+
|
|
864
|
+
#### Adding/Subtracting Days
|
|
865
|
+
|
|
866
|
+
```typescript
|
|
867
|
+
// Add days
|
|
868
|
+
const futureDate = addDays(new Date(), 7)
|
|
869
|
+
// Returns: Date 7 days from now
|
|
870
|
+
|
|
871
|
+
// Subtract days
|
|
872
|
+
const pastDate = subtractDays(new Date(), 5)
|
|
873
|
+
// Returns: Date 5 days ago
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
#### Adding/Subtracting Time Units
|
|
877
|
+
|
|
878
|
+
```typescript
|
|
879
|
+
// Add multiple time units
|
|
880
|
+
const newDate = add(new Date(), {
|
|
881
|
+
years: 1,
|
|
882
|
+
months: 2,
|
|
883
|
+
days: 5,
|
|
884
|
+
hours: 3,
|
|
885
|
+
minutes: 30
|
|
886
|
+
})
|
|
887
|
+
|
|
888
|
+
// Subtract multiple time units
|
|
889
|
+
const earlierDate = sub(new Date(), {
|
|
890
|
+
weeks: 2,
|
|
891
|
+
days: 3,
|
|
892
|
+
hours: 12
|
|
893
|
+
})
|
|
894
|
+
|
|
895
|
+
// Functional programming style (reversed arguments)
|
|
896
|
+
const fpDate = addFp({ days: 7 }, new Date())
|
|
897
|
+
const fpDate2 = subFp({ hours: 5 }, new Date())
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
### Time Operations
|
|
901
|
+
|
|
902
|
+
#### Getting Time Components
|
|
903
|
+
|
|
904
|
+
```typescript
|
|
905
|
+
const date = new Date('2024-12-31T14:30:45')
|
|
906
|
+
|
|
907
|
+
const hours = getHours(date) // 14
|
|
908
|
+
const minutes = getMinutes(date) // 30
|
|
909
|
+
const seconds = getSeconds(date) // 45
|
|
910
|
+
```
|
|
911
|
+
|
|
912
|
+
#### Setting Time
|
|
913
|
+
|
|
914
|
+
```typescript
|
|
915
|
+
// Set time on a date (returns new Date object)
|
|
916
|
+
const newDate = setTime(new Date(), {
|
|
917
|
+
hours: 14,
|
|
918
|
+
minutes: 30,
|
|
919
|
+
seconds: 0
|
|
920
|
+
})
|
|
921
|
+
```
|
|
922
|
+
|
|
923
|
+
### Date Comparisons
|
|
924
|
+
|
|
925
|
+
```typescript
|
|
926
|
+
const date1 = new Date('2024-12-31')
|
|
927
|
+
const date2 = new Date('2025-01-01')
|
|
928
|
+
|
|
929
|
+
// Check if date1 is after date2
|
|
930
|
+
const isLater = isAfter(date1, date2, 'day')
|
|
931
|
+
// Returns: false
|
|
932
|
+
|
|
933
|
+
// Check if date1 is same or after date2
|
|
934
|
+
const isSameOrLater = isSameAfter(date1, date2, 'day')
|
|
935
|
+
// Returns: false
|
|
936
|
+
|
|
937
|
+
// Check if date1 is before date2
|
|
938
|
+
const isEarlier = isBefore(date1, date2, 'day')
|
|
939
|
+
// Returns: true
|
|
940
|
+
|
|
941
|
+
// Check if date1 is same or before date2
|
|
942
|
+
const isSameOrEarlier = isSameBefore(date1, date2, 'day')
|
|
943
|
+
// Returns: true
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
**Comparison Units**: The comparison functions accept a `units` parameter (default: `'minute'`). Valid units:
|
|
947
|
+
- `'year'`, `'month'`, `'week'`, `'day'`
|
|
948
|
+
- `'hour'`, `'minute'`, `'second'`
|
|
949
|
+
|
|
950
|
+
### Complete Usage Example
|
|
951
|
+
|
|
952
|
+
```typescript
|
|
953
|
+
import {
|
|
954
|
+
formatDate,
|
|
955
|
+
addDays,
|
|
956
|
+
isAfter,
|
|
957
|
+
format,
|
|
958
|
+
add,
|
|
959
|
+
getHours,
|
|
960
|
+
setTime
|
|
961
|
+
} from '@voicenter-team/voicenter-ui-plus'
|
|
962
|
+
|
|
963
|
+
// Format today's date
|
|
964
|
+
const today = formatDate(new Date(), 'DD/MM/YYYY')
|
|
965
|
+
|
|
966
|
+
// Get date 30 days from now
|
|
967
|
+
const futureDate = addDays(new Date(), 30)
|
|
968
|
+
|
|
969
|
+
// Check if a date is in the future
|
|
970
|
+
const isFuture = isAfter(futureDate, new Date(), 'day')
|
|
971
|
+
|
|
972
|
+
// Add 2 weeks and 3 days
|
|
973
|
+
const deadline = add(new Date(), {
|
|
974
|
+
weeks: 2,
|
|
975
|
+
days: 3
|
|
976
|
+
})
|
|
977
|
+
|
|
978
|
+
// Get current hour
|
|
979
|
+
const currentHour = getHours(new Date())
|
|
980
|
+
|
|
981
|
+
// Set specific time
|
|
982
|
+
const meetingTime = setTime(new Date(), {
|
|
983
|
+
hours: 14,
|
|
984
|
+
minutes: 30
|
|
985
|
+
})
|
|
986
|
+
|
|
987
|
+
// Format the result
|
|
988
|
+
const formattedDeadline = format(deadline, 'DD/MM/YYYY HH:mm')
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
### Notes
|
|
992
|
+
|
|
993
|
+
- All functions accept `Date`, `string`, or `number` as date input
|
|
994
|
+
- All date manipulation functions return new `Date` objects (immutable)
|
|
995
|
+
- Format strings use dayjs format tokens (see Format Tokens section above)
|
|
996
|
+
- These utilities are built on dayjs and maintain compatibility with dayjs format patterns
|
|
997
|
+
|
|
998
|
+
## Contributing: adding a new component
|
|
999
|
+
|
|
1000
|
+
The public component surface is defined in **one place**: [`script/components-manifest.mjs`](./script/components-manifest.mjs) — one line per component.
|
|
1001
|
+
|
|
1002
|
+
```js
|
|
1003
|
+
{ name: 'VcMyThing', path: 'components/VcMyThing/VcMyThing.vue' },
|
|
1004
|
+
```
|
|
1005
|
+
|
|
1006
|
+
`npm run generate:entries` materializes the manifest into three fully
|
|
1007
|
+
generated files (never edit them by hand — the next generator run
|
|
1008
|
+
overwrites them, and the verifier fails the build until they match):
|
|
1009
|
+
|
|
1010
|
+
- `src/components.gen.ts` — named exports, re-exported by `src/index.ts`
|
|
1011
|
+
(tree-shake mode);
|
|
1012
|
+
- `src/plugin-components.gen.ts` — `registerComponents(app)`, called by
|
|
1013
|
+
the plugin's install (global registration mode);
|
|
1014
|
+
- `src/components/exports.ts` — the `GlobalComponents` template typing.
|
|
1015
|
+
|
|
1016
|
+
`src/index.ts` and `src/plugin.ts` themselves stay hand-written and small.
|
|
1017
|
+
The `.gen` modules are safe to route through only because
|
|
1018
|
+
`rewriteCssImports()` in `vite.config.ts` strips the CSS imports that
|
|
1019
|
+
`vite-plugin-lib-inject-css` aggregates onto them — each component's CSS
|
|
1020
|
+
stays in its own chunk, so per-component CSS tree-shaking survives. Don't
|
|
1021
|
+
rename the `.gen` files without updating that strip list (the verifier
|
|
1022
|
+
guards this wiring too).
|
|
1023
|
+
|
|
1024
|
+
Typical flows:
|
|
1025
|
+
|
|
1026
|
+
- **New component**: `node script/create-component.mjs` — scaffolds the
|
|
1027
|
+
component folder, adds the manifest line, and regenerates all entries.
|
|
1028
|
+
- **Existing .vue file**: add one line to the manifest, then
|
|
1029
|
+
`npm run generate:entries`.
|
|
1030
|
+
|
|
1031
|
+
Every manifest entry is exported from the package root AND registered
|
|
1032
|
+
globally in plugin mode — there are no partial modes.
|
|
1033
|
+
|
|
1034
|
+
`npm run verify:entries` is the safety net: it independently cross-checks
|
|
1035
|
+
the manifest, the three generated files and the filesystem (a component
|
|
1036
|
+
file that exists but is missing from the manifest fails too). It runs in
|
|
1037
|
+
the pre-commit hook (together with `lint-staged` and `ts-check`; hooks are
|
|
1038
|
+
installed automatically by `npm install` via husky) and in CI, so an
|
|
1039
|
+
inconsistent component surface cannot reach `master`.
|
|
1040
|
+
|
|
1041
|
+
## Documentation
|
|
1042
|
+
|
|
1043
|
+
### Live Documentation
|
|
1044
|
+
Visit [documentation](https://voicenter-ui-plus.pages.dev/) for interactive component examples and demos.
|
|
1045
|
+
|
|
1046
|
+
## Project Documentation
|
|
1047
|
+
For detailed technical documentation, see the [`docs/`](./docs/) directory:
|
|
1048
|
+
|
|
1049
|
+
- **[Quick Start Guide](./docs/AGENTS_QUICK_START.md)** - For developers working on the library
|
|
1050
|
+
- **[Architecture Overview](./docs/ARCHITECTURE.md)** - Project structure and technical details
|
|
1051
|
+
- **[Documentation Guide](./docs/DOCUMENTATION_GUIDE.md)** - Working with the documentation system
|