@voicenter-team/voicenter-ui-plus 3.4.7 → 3.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +558 -558
- package/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcChatComposer/VcChatComposer.css +1 -1
- package/library/assets/components/VcFileUploader/VcFileUploaderSimple.css +1 -1
- package/library/assets/components/VcMessage/VcMessage.css +1 -1
- package/library/assets/components/VcMessage/VcMessageMeta.css +1 -0
- package/library/assets/components/VcMessage/content/VcMessageVideoBlock.css +1 -0
- package/library/assets/components/VcMessagesWrapper/VcMessagesWrapper.css +1 -1
- package/library/components/VcChatComposer/VcChatComposer.vue.mjs +38 -27
- package/library/components/VcChatComposer/richText.mjs +8 -0
- 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/VcExcelUploader/VcExcelFileUploader.vue.mjs +1 -0
- package/library/components/VcExcelUploader/VcFileImportResultBindData.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/VcMdEditor/VcMdEditor.vue.mjs +1 -1
- package/library/components/VcMdEditor/VcMdEditorToolbar.vue.mjs +1 -1
- package/library/components/VcMessage/VcMessage.vue.mjs +65 -40
- package/library/components/VcMessage/VcMessageMeta.vue.mjs +49 -0
- package/library/components/VcMessage/VcMessageMeta.vue3.mjs +5 -0
- package/library/components/VcMessage/content/VcMessageAudioBlock.vue.mjs +3 -9
- package/library/components/VcMessage/content/VcMessageImageBlock.vue.mjs +1 -1
- package/library/components/VcMessage/content/VcMessageVideoBlock.vue.mjs +60 -0
- package/library/components/VcMessage/content/VcMessageVideoBlock.vue3.mjs +5 -0
- package/library/components/VcMessage/content/formatDuration.mjs +10 -0
- package/library/components/VcMessage/content/messageContentComponents.mjs +8 -5
- package/library/components/VcMessage/reactions/VcMessageReactionBar.vue.mjs +1 -1
- package/library/components/VcMessagesWrapper/VcMessagesWrapper.vue.mjs +167 -63
- package/library/components/VcMessagesWrapper/VcMessagesWrapperRow.vue.mjs +83 -0
- package/library/components/VcMessagesWrapper/VcMessagesWrapperRow.vue2.mjs +4 -0
- package/library/components/VcRadio/VcRadio.vue.mjs +1 -1
- package/library/components/VcSelect/VcSelect.vue.mjs +1 -1
- package/library/components/VcSlider/VcSlider.vue.mjs +1 -1
- package/library/index.mjs.gz +0 -0
- package/library/localization/index.mjs.gz +0 -0
- package/library/localization/locales/en.json.mjs +8 -1
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +9 -5
- 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/components/VcChatComposer/VcChatComposer.vue.d.ts +29 -2
- package/library/types/components/VcExcelUploader/VcExcelFileUploader.vue.d.ts +1 -2
- package/library/types/components/VcMessage/VcMessage.vue.d.ts +20 -2
- package/library/types/components/VcMessage/VcMessageMeta.vue.d.ts +24 -0
- package/library/types/components/VcMessage/content/VcMessageVideoBlock.vue.d.ts +24 -0
- package/library/types/components/VcMessage/content/formatDuration.d.ts +4 -0
- package/library/types/components/VcMessagesWrapper/VcMessagesWrapper.vue.d.ts +20 -2
- package/library/types/components/VcMessagesWrapper/VcMessagesWrapperRow.vue.d.ts +49 -0
- package/library/types/components/VcModal/VcConfirmModal.vue.d.ts +1 -1
- package/library/types/localization/locales/en.json.d.ts +194 -187
- package/library/types/types/VcChatComposer.types.d.ts +3 -2
- package/library/types/types/VcMessage.types.d.ts +48 -3
- package/library/types/types/VcMessagesWrapper.types.d.ts +30 -1
- package/library/utils/jsonSchema/index.mjs.gz +0 -0
- package/package.json +215 -215
- package/tailwind.config.js +192 -192
- /package/library/assets/node_modules/element-plus/theme-chalk/src/{date-picker.css → tooltip.css} +0 -0
package/README.md
CHANGED
|
@@ -1,558 +1,558 @@
|
|
|
1
|
-
# Voicenter UI library for Vue
|
|
2
|
-
This is Vue 3.x + Typescript component library made for Voicenter systems.
|
|
3
|
-
|
|
4
|
-
> **v3.0.0 is a tree-shaking release with breaking changes.** See [`MIGRATION_v3.md`](./MIGRATION_v3.md). The separate `*-extended` package is gone — every component lives in this package now.
|
|
5
|
-
|
|
6
|
-
## Installation
|
|
7
|
-
|
|
8
|
-
```bash
|
|
9
|
-
npm i @voicenter-team/voicenter-ui-plus
|
|
10
|
-
npm i vue@^3.5 element-plus @vueuse/core dayjs lodash-es libphonenumber-js maska
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
### Sass compiler (build-time)
|
|
14
|
-
|
|
15
|
-
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:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm i -D sass-embedded
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
This is a **build-time only** requirement — it doesn't add anything to your runtime bundle. Most Vue 3 / Vite projects already have it.
|
|
22
|
-
|
|
23
|
-
Optional peer deps — install only for the heavy components you use:
|
|
24
|
-
|
|
25
|
-
| Component | Peer deps |
|
|
26
|
-
|---|---|
|
|
27
|
-
| `VcPdfDocument` | `pdfjs-dist@^2.16.105` |
|
|
28
|
-
| `VcSoundPlayer` | `wavesurfer.js` |
|
|
29
|
-
| `VcExcelFileUploader` | `xlsx` |
|
|
30
|
-
| `VcImageUploader` | `vue-advanced-cropper` |
|
|
31
|
-
| `VcHtmlEditor` / `VcJsonSchema` | `codemirror @codemirror/lang-html @codemirror/lang-json @codemirror/lang-markdown vue-codemirror6` |
|
|
32
|
-
| `VcMdEditor` | `@milkdown/crepe @milkdown/kit @milkdown/vue @prosemirror-adapter/vue` |
|
|
33
|
-
|
|
34
|
-
### If you're on Vite 8 / rolldown (and skipping some optional peers)
|
|
35
|
-
|
|
36
|
-
Vite 8's rolldown-based bundler validates named imports against optional-peer-dep stubs and fails the build with `MISSING_EXPORT` errors when a heavy component's peer is uninstalled — even when you don't use that component. Add the unused optional peers to `build.rollupOptions.external` in your `vite.config.ts`:
|
|
37
|
-
|
|
38
|
-
```ts
|
|
39
|
-
// vite.config.ts
|
|
40
|
-
import { defineConfig } from 'vite'
|
|
41
|
-
import vue from '@vitejs/plugin-vue'
|
|
42
|
-
|
|
43
|
-
export default defineConfig({
|
|
44
|
-
plugins: [ vue() ],
|
|
45
|
-
build: {
|
|
46
|
-
rollupOptions: {
|
|
47
|
-
external: [
|
|
48
|
-
// List only the heavy peers you DON'T install
|
|
49
|
-
/^@milkdown\//, /^@prosemirror/, /^@codemirror\//, /^codemirror/,
|
|
50
|
-
/^vue-codemirror6/, /^vue-advanced-cropper/,
|
|
51
|
-
'wavesurfer.js', 'xlsx', 'pdfjs-dist', /^pdfjs-dist\//
|
|
52
|
-
]
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Earlier Vite versions (5, 6, 7 with rollup) and webpack 5+ don't require this — the older rollup variant warns but doesn't error on optional-peer named imports.
|
|
59
|
-
|
|
60
|
-
## Usage
|
|
61
|
-
|
|
62
|
-
### Tree-shake mode (recommended)
|
|
63
|
-
```ts
|
|
64
|
-
import { VcButton, VcInput } from '@voicenter-team/voicenter-ui-plus'
|
|
65
|
-
// Use as local components — no app.use() needed.
|
|
66
|
-
```
|
|
67
|
-
Bundlers drop unused components and their CSS. A consumer importing only `VcButton` ships ~50–150 KB JS + ~10–30 KB CSS.
|
|
68
|
-
|
|
69
|
-
If you use `useConfirmModal`, `useConfirmPopup`, or `NotifyService`, mount global overlays in `App.vue`:
|
|
70
|
-
|
|
71
|
-
```vue
|
|
72
|
-
<script setup lang="ts">
|
|
73
|
-
import { VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus'
|
|
74
|
-
</script>
|
|
75
|
-
|
|
76
|
-
<template>
|
|
77
|
-
<RouterView />
|
|
78
|
-
<VcPluginOverlays />
|
|
79
|
-
</template>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Plugin mode (global registration)
|
|
83
|
-
```ts
|
|
84
|
-
import VoicenterUI from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
85
|
-
import '@voicenter-team/voicenter-ui-plus/style.css'
|
|
86
|
-
|
|
87
|
-
// Overlay composables can be imported from the same entry:
|
|
88
|
-
// import { useConfirmModal, useConfirmPopup, VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
89
|
-
|
|
90
|
-
app.use(VoicenterUI, {
|
|
91
|
-
themeConfig, // theme config (see below)
|
|
92
|
-
lang: 'en', // localization
|
|
93
|
-
injectIconFont: true // inject icon-font <link> tags into <head>
|
|
94
|
-
})
|
|
95
|
-
// Confirm modals/popovers/notifications: auto-mounted via VcPluginOverlays
|
|
96
|
-
// (mountOverlays: true by default). Opt out with mountOverlays: false and
|
|
97
|
-
// add <VcPluginOverlays /> to App.vue — also registered globally by the plugin.
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
### Global overlays
|
|
101
|
-
|
|
102
|
-
Several APIs are **state-only** — they update global reactive singletons but do not render UI by themselves:
|
|
103
|
-
|
|
104
|
-
| API | Overlay component |
|
|
105
|
-
|---|---|
|
|
106
|
-
| `useConfirmModal` | `VcConfirmModal` |
|
|
107
|
-
| `useConfirmPopup` | `VcConfirmPopover` |
|
|
108
|
-
| `NotifyService` / `$notify` | `VcNotification` |
|
|
109
|
-
|
|
110
|
-
**Plugin mode:** mounted automatically on `app.use()` (default). Pass `mountOverlays: false` to mount manually.
|
|
111
|
-
|
|
112
|
-
**Notifications:** one top-right host by default. For multiple positions, use `overlayNotifications` in plugin config or mount your own:
|
|
113
|
-
|
|
114
|
-
```ts
|
|
115
|
-
app.use(VoicenterUI, {
|
|
116
|
-
overlayNotifications: [
|
|
117
|
-
{ group: 'top-right', position: 'top-right' },
|
|
118
|
-
{ group: 'bottom-right', position: 'bottom-right' },
|
|
119
|
-
],
|
|
120
|
-
})
|
|
121
|
-
// NotifyService.add({ group: 'bottom-right', ... })
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
Or `overlayNotifications: 'none'` and put `<VcNotification />` in App.vue (confirms still auto-mount).
|
|
125
|
-
|
|
126
|
-
**Tree-shake mode:** add `<VcPluginOverlays />` to `App.vue` (bundles confirm hosts; configure via `notifications` prop).
|
|
127
|
-
|
|
128
|
-
Entity components such as `VcEntityListTable` call `useConfirmModal` internally — delete confirmations require overlays to be mounted.
|
|
129
|
-
|
|
130
|
-
### Tailwind
|
|
131
|
-
|
|
132
|
-
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.
|
|
133
|
-
|
|
134
|
-
```js
|
|
135
|
-
// tailwind.config.js
|
|
136
|
-
const voiceTailwindScheme = require('@voicenter-team/voicenter-ui-plus/src/theme/tailwindScheme')
|
|
137
|
-
|
|
138
|
-
module.exports = {
|
|
139
|
-
...yourConfiguration,
|
|
140
|
-
theme: {
|
|
141
|
-
colors: { ...voiceTailwindScheme },
|
|
142
|
-
borderColor: { ...voiceTailwindScheme },
|
|
143
|
-
fill: voiceTailwindScheme
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
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).
|
|
149
|
-
|
|
150
|
-
### Theming specification
|
|
151
|
-
The `themeConfig` which is passed as options to the VoicenterUI `vue.use` data could have the following specifications:
|
|
152
|
-
|
|
153
|
-
### Local
|
|
154
|
-
**Config:**
|
|
155
|
-
```js
|
|
156
|
-
{
|
|
157
|
-
type: 'local'
|
|
158
|
-
themeName: 'red' | 'blue' | '...'
|
|
159
|
-
onSetupCallback: () => {
|
|
160
|
-
console.log('Loaded!')
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
**Description:**
|
|
165
|
-
|
|
166
|
-
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
|
|
167
|
-
|
|
168
|
-
**Params:**
|
|
169
|
-
- **themeName**
|
|
170
|
-
- The name of the theme to be injected
|
|
171
|
-
- **onSetupCallback**
|
|
172
|
-
- 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
|
|
173
|
-
|
|
174
|
-
### Remote
|
|
175
|
-
**Config:**
|
|
176
|
-
```js
|
|
177
|
-
{
|
|
178
|
-
type: 'remote'
|
|
179
|
-
brandingSectionName: 'someName'
|
|
180
|
-
apiUrl: 'someUrl'
|
|
181
|
-
brandingSectionName: {
|
|
182
|
-
property: 'data'
|
|
183
|
-
}
|
|
184
|
-
onSetupCallback: () => {
|
|
185
|
-
console.log('Loaded!')
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
```
|
|
189
|
-
**Description:**
|
|
190
|
-
|
|
191
|
-
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
|
|
192
|
-
|
|
193
|
-
**Params:**
|
|
194
|
-
- **brandingSectionName**
|
|
195
|
-
- [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
|
|
196
|
-
- **apiUrl**
|
|
197
|
-
- The API url to which the POST request will be initiated
|
|
198
|
-
- **onSetupCallback**
|
|
199
|
-
- 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
|
|
200
|
-
- **brandingSectionName**
|
|
201
|
-
- [Optional] The payload data that will be sent to the request
|
|
202
|
-
|
|
203
|
-
### Custom JSON
|
|
204
|
-
**Config:**
|
|
205
|
-
```js
|
|
206
|
-
{
|
|
207
|
-
type: 'customJson'
|
|
208
|
-
config: {
|
|
209
|
-
black: '#000000'
|
|
210
|
-
}
|
|
211
|
-
onSetupCallback: () => {
|
|
212
|
-
console.log('Loaded!')
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
```
|
|
216
|
-
**Description:**
|
|
217
|
-
|
|
218
|
-
Such configuration will initiate the styling with custom provided theme
|
|
219
|
-
|
|
220
|
-
**Params:**
|
|
221
|
-
- **config**
|
|
222
|
-
- The object where the key is the variable to be set and the value is the variable value. Check the [themes object](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json) to check existing variables
|
|
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
|
-
|
|
226
|
-
### None
|
|
227
|
-
`{ type: 'none', onSetupCallback?: (theme) => void }` injects no theme variables; the application sets them itself.
|
|
228
|
-
|
|
229
|
-
## Using ui-plus in an application
|
|
230
|
-
|
|
231
|
-
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.
|
|
232
|
-
|
|
233
|
-
### Where the facts are
|
|
234
|
-
|
|
235
|
-
The installed package is the truth. Read it before saying what ui-plus has or how a component behaves.
|
|
236
|
-
|
|
237
|
-
- **Every component**: `library/types/components/exports.d.ts`. One component's props, events and slots: `library/types/components/<VcName>/<VcName>.vue.d.ts`.
|
|
238
|
-
- **Composables, services, directives, the entity base**: `library/types/composables/`, `library/types/services/`, `library/types/directives/`, `library/types/entity/`.
|
|
239
|
-
- **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" />`.
|
|
240
|
-
- **Colour tokens**: `src/theme/themes.json` (each key is the CSS variable `--<key>`) and `src/theme/tailwindScheme.js` (the Tailwind colour names).
|
|
241
|
-
- **Examples**: the [live documentation](https://voicenter-ui.netlify.app/).
|
|
242
|
-
|
|
243
|
-
### Choosing a component
|
|
244
|
-
|
|
245
|
-
- 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.
|
|
246
|
-
- 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.
|
|
247
|
-
- 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:
|
|
248
|
-
- a new interaction component;
|
|
249
|
-
- 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;
|
|
250
|
-
- a ui-plus component used for a role it is not built for, such as a segmented switcher drawn as a searchable list.
|
|
251
|
-
- 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.
|
|
252
|
-
- A report names a control by what is on screen: a restyled ui-plus component is reported as custom.
|
|
253
|
-
- 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.
|
|
254
|
-
|
|
255
|
-
### Colours
|
|
256
|
-
|
|
257
|
-
- Every colour is a ui-plus token: a Tailwind class from the library scheme (`text-default-text`, `text-secondary-text`, `text-primary`, `bg-main-bg`, `bg-light-bg`, `border-ui-lines`, `text-success`, `text-error`) or a theme variable in a style (`color: var(--default-text)`). Status colours, tags, icons and chart series included.
|
|
258
|
-
- 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.
|
|
259
|
-
- The theme configuration (`themeConfig`, usually a `colors.json`) sets the library theme. It is not a palette to add colours to.
|
|
260
|
-
|
|
261
|
-
### Notifications and confirmations
|
|
262
|
-
|
|
263
|
-
`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.
|
|
264
|
-
|
|
265
|
-
### Text direction
|
|
266
|
-
|
|
267
|
-
ui-plus follows the `dir` attribute of `<html>`: `useRTL()` reads it and updates when it changes. The application sets the direction there, once.
|
|
268
|
-
|
|
269
|
-
### Server-side rendering
|
|
270
|
-
|
|
271
|
-
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.
|
|
272
|
-
|
|
273
|
-
### Troubleshooting
|
|
274
|
-
|
|
275
|
-
- **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.
|
|
276
|
-
- **`Cannot find module 'pdfjs-dist'` (or another optional peer) at build time**: install the peer, or stop importing its component.
|
|
277
|
-
- **Duplicate styles, a huge CSS payload**: the two modes are mixed (named imports plus the global `style.css`). Pick one (`MIGRATION_v3.md`, §1).
|
|
278
|
-
- **PDF.js worker not loading**: the worker is a sibling asset resolved with `new URL('./pdf.worker.min.js', import.meta.url)`; the bundler must support that pattern (Vite, webpack 5+, Rollup and esbuild do).
|
|
279
|
-
|
|
280
|
-
## Date Handling
|
|
281
|
-
|
|
282
|
-
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).
|
|
283
|
-
|
|
284
|
-
### Format Tokens
|
|
285
|
-
|
|
286
|
-
**Important**: Use dayjs format tokens:
|
|
287
|
-
- `DD` - Day of month (2 digits) - **NOT** `dd`
|
|
288
|
-
- `YYYY` - 4-digit year - **NOT** `yyyy`
|
|
289
|
-
- `MM` - Month (2 digits)
|
|
290
|
-
- `HH` - 24-hour format
|
|
291
|
-
- `mm` - Minutes
|
|
292
|
-
- `ss` - Seconds
|
|
293
|
-
|
|
294
|
-
### Common Formats
|
|
295
|
-
|
|
296
|
-
```typescript
|
|
297
|
-
'DD/MM/YYYY' // 31/12/2024
|
|
298
|
-
'DD-MM-YYYY' // 31-12-2024
|
|
299
|
-
'YYYY-MM-DD' // 2024-12-31
|
|
300
|
-
'DD/MM/YYYY, HH:mm' // 31/12/2024, 14:30
|
|
301
|
-
'DD/MM/YYYY HH:mm:ss' // 31/12/2024 14:30:45
|
|
302
|
-
```
|
|
303
|
-
|
|
304
|
-
### Usage Example
|
|
305
|
-
|
|
306
|
-
```vue
|
|
307
|
-
<VcDatePicker
|
|
308
|
-
v-model="date"
|
|
309
|
-
format="DD/MM/YYYY"
|
|
310
|
-
input-date-format="DD/MM/YYYY"
|
|
311
|
-
input-time-format="HH:mm"
|
|
312
|
-
/>
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
## Date Utility Functions
|
|
316
|
-
|
|
317
|
-
The library provides a comprehensive set of date utility functions built on dayjs. These utilities are available for use in external projects.
|
|
318
|
-
|
|
319
|
-
### Import Date Utilities
|
|
320
|
-
|
|
321
|
-
```typescript
|
|
322
|
-
import {
|
|
323
|
-
formatDate,
|
|
324
|
-
parseDate,
|
|
325
|
-
addDays,
|
|
326
|
-
subtractDays,
|
|
327
|
-
getHours,
|
|
328
|
-
getMinutes,
|
|
329
|
-
getSeconds,
|
|
330
|
-
setTime,
|
|
331
|
-
isAfter,
|
|
332
|
-
isSameAfter,
|
|
333
|
-
isBefore,
|
|
334
|
-
isSameBefore,
|
|
335
|
-
format,
|
|
336
|
-
add,
|
|
337
|
-
sub,
|
|
338
|
-
addFp,
|
|
339
|
-
subFp
|
|
340
|
-
} from '@voicenter-team/voicenter-ui-plus'
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
### Basic Date Operations
|
|
344
|
-
|
|
345
|
-
#### Formatting Dates
|
|
346
|
-
|
|
347
|
-
```typescript
|
|
348
|
-
// Format a date with default format (YYYY-MM-DD)
|
|
349
|
-
const formatted = formatDate(new Date())
|
|
350
|
-
// Result: "2024-12-31"
|
|
351
|
-
|
|
352
|
-
// Format with custom format
|
|
353
|
-
const custom = formatDate(new Date(), 'DD/MM/YYYY')
|
|
354
|
-
// Result: "31/12/2024"
|
|
355
|
-
|
|
356
|
-
// Using format function (alias)
|
|
357
|
-
const formatted2 = format(new Date(), 'DD/MM/YYYY HH:mm')
|
|
358
|
-
// Result: "31/12/2024 14:30"
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
#### Parsing Dates
|
|
362
|
-
|
|
363
|
-
```typescript
|
|
364
|
-
// Parse a date string with format
|
|
365
|
-
const date = parseDate('31/12/2024', 'DD/MM/YYYY')
|
|
366
|
-
// Returns: Date object
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
### Date Arithmetic
|
|
370
|
-
|
|
371
|
-
#### Adding/Subtracting Days
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
// Add days
|
|
375
|
-
const futureDate = addDays(new Date(), 7)
|
|
376
|
-
// Returns: Date 7 days from now
|
|
377
|
-
|
|
378
|
-
// Subtract days
|
|
379
|
-
const pastDate = subtractDays(new Date(), 5)
|
|
380
|
-
// Returns: Date 5 days ago
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
#### Adding/Subtracting Time Units
|
|
384
|
-
|
|
385
|
-
```typescript
|
|
386
|
-
// Add multiple time units
|
|
387
|
-
const newDate = add(new Date(), {
|
|
388
|
-
years: 1,
|
|
389
|
-
months: 2,
|
|
390
|
-
days: 5,
|
|
391
|
-
hours: 3,
|
|
392
|
-
minutes: 30
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
// Subtract multiple time units
|
|
396
|
-
const earlierDate = sub(new Date(), {
|
|
397
|
-
weeks: 2,
|
|
398
|
-
days: 3,
|
|
399
|
-
hours: 12
|
|
400
|
-
})
|
|
401
|
-
|
|
402
|
-
// Functional programming style (reversed arguments)
|
|
403
|
-
const fpDate = addFp({ days: 7 }, new Date())
|
|
404
|
-
const fpDate2 = subFp({ hours: 5 }, new Date())
|
|
405
|
-
```
|
|
406
|
-
|
|
407
|
-
### Time Operations
|
|
408
|
-
|
|
409
|
-
#### Getting Time Components
|
|
410
|
-
|
|
411
|
-
```typescript
|
|
412
|
-
const date = new Date('2024-12-31T14:30:45')
|
|
413
|
-
|
|
414
|
-
const hours = getHours(date) // 14
|
|
415
|
-
const minutes = getMinutes(date) // 30
|
|
416
|
-
const seconds = getSeconds(date) // 45
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
#### Setting Time
|
|
420
|
-
|
|
421
|
-
```typescript
|
|
422
|
-
// Set time on a date (returns new Date object)
|
|
423
|
-
const newDate = setTime(new Date(), {
|
|
424
|
-
hours: 14,
|
|
425
|
-
minutes: 30,
|
|
426
|
-
seconds: 0
|
|
427
|
-
})
|
|
428
|
-
```
|
|
429
|
-
|
|
430
|
-
### Date Comparisons
|
|
431
|
-
|
|
432
|
-
```typescript
|
|
433
|
-
const date1 = new Date('2024-12-31')
|
|
434
|
-
const date2 = new Date('2025-01-01')
|
|
435
|
-
|
|
436
|
-
// Check if date1 is after date2
|
|
437
|
-
const isLater = isAfter(date1, date2, 'day')
|
|
438
|
-
// Returns: false
|
|
439
|
-
|
|
440
|
-
// Check if date1 is same or after date2
|
|
441
|
-
const isSameOrLater = isSameAfter(date1, date2, 'day')
|
|
442
|
-
// Returns: false
|
|
443
|
-
|
|
444
|
-
// Check if date1 is before date2
|
|
445
|
-
const isEarlier = isBefore(date1, date2, 'day')
|
|
446
|
-
// Returns: true
|
|
447
|
-
|
|
448
|
-
// Check if date1 is same or before date2
|
|
449
|
-
const isSameOrEarlier = isSameBefore(date1, date2, 'day')
|
|
450
|
-
// Returns: true
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
**Comparison Units**: The comparison functions accept a `units` parameter (default: `'minute'`). Valid units:
|
|
454
|
-
- `'year'`, `'month'`, `'week'`, `'day'`
|
|
455
|
-
- `'hour'`, `'minute'`, `'second'`
|
|
456
|
-
|
|
457
|
-
### Complete Usage Example
|
|
458
|
-
|
|
459
|
-
```typescript
|
|
460
|
-
import {
|
|
461
|
-
formatDate,
|
|
462
|
-
addDays,
|
|
463
|
-
isAfter,
|
|
464
|
-
format,
|
|
465
|
-
add,
|
|
466
|
-
getHours,
|
|
467
|
-
setTime
|
|
468
|
-
} from '@voicenter-team/voicenter-ui-plus'
|
|
469
|
-
|
|
470
|
-
// Format today's date
|
|
471
|
-
const today = formatDate(new Date(), 'DD/MM/YYYY')
|
|
472
|
-
|
|
473
|
-
// Get date 30 days from now
|
|
474
|
-
const futureDate = addDays(new Date(), 30)
|
|
475
|
-
|
|
476
|
-
// Check if a date is in the future
|
|
477
|
-
const isFuture = isAfter(futureDate, new Date(), 'day')
|
|
478
|
-
|
|
479
|
-
// Add 2 weeks and 3 days
|
|
480
|
-
const deadline = add(new Date(), {
|
|
481
|
-
weeks: 2,
|
|
482
|
-
days: 3
|
|
483
|
-
})
|
|
484
|
-
|
|
485
|
-
// Get current hour
|
|
486
|
-
const currentHour = getHours(new Date())
|
|
487
|
-
|
|
488
|
-
// Set specific time
|
|
489
|
-
const meetingTime = setTime(new Date(), {
|
|
490
|
-
hours: 14,
|
|
491
|
-
minutes: 30
|
|
492
|
-
})
|
|
493
|
-
|
|
494
|
-
// Format the result
|
|
495
|
-
const formattedDeadline = format(deadline, 'DD/MM/YYYY HH:mm')
|
|
496
|
-
```
|
|
497
|
-
|
|
498
|
-
### Notes
|
|
499
|
-
|
|
500
|
-
- All functions accept `Date`, `string`, or `number` as date input
|
|
501
|
-
- All date manipulation functions return new `Date` objects (immutable)
|
|
502
|
-
- Format strings use dayjs format tokens (see Format Tokens section above)
|
|
503
|
-
- These utilities are built on dayjs and maintain compatibility with dayjs format patterns
|
|
504
|
-
|
|
505
|
-
## Contributing: adding a new component
|
|
506
|
-
|
|
507
|
-
The public component surface is defined in **one place**: [`script/components-manifest.mjs`](./script/components-manifest.mjs) — one line per component.
|
|
508
|
-
|
|
509
|
-
```js
|
|
510
|
-
{ name: 'VcMyThing', path: 'components/VcMyThing/VcMyThing.vue' },
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
`npm run generate:entries` materializes the manifest into three fully
|
|
514
|
-
generated files (never edit them by hand — the next generator run
|
|
515
|
-
overwrites them, and the verifier fails the build until they match):
|
|
516
|
-
|
|
517
|
-
- `src/components.gen.ts` — named exports, re-exported by `src/index.ts`
|
|
518
|
-
(tree-shake mode);
|
|
519
|
-
- `src/plugin-components.gen.ts` — `registerComponents(app)`, called by
|
|
520
|
-
the plugin's install (global registration mode);
|
|
521
|
-
- `src/components/exports.ts` — the `GlobalComponents` template typing.
|
|
522
|
-
|
|
523
|
-
`src/index.ts` and `src/plugin.ts` themselves stay hand-written and small.
|
|
524
|
-
The `.gen` modules are safe to route through only because
|
|
525
|
-
`rewriteCssImports()` in `vite.config.ts` strips the CSS imports that
|
|
526
|
-
`vite-plugin-lib-inject-css` aggregates onto them — each component's CSS
|
|
527
|
-
stays in its own chunk, so per-component CSS tree-shaking survives. Don't
|
|
528
|
-
rename the `.gen` files without updating that strip list (the verifier
|
|
529
|
-
guards this wiring too).
|
|
530
|
-
|
|
531
|
-
Typical flows:
|
|
532
|
-
|
|
533
|
-
- **New component**: `node script/create-component.mjs` — scaffolds the
|
|
534
|
-
component folder, adds the manifest line, and regenerates all entries.
|
|
535
|
-
- **Existing .vue file**: add one line to the manifest, then
|
|
536
|
-
`npm run generate:entries`.
|
|
537
|
-
|
|
538
|
-
Every manifest entry is exported from the package root AND registered
|
|
539
|
-
globally in plugin mode — there are no partial modes.
|
|
540
|
-
|
|
541
|
-
`npm run verify:entries` is the safety net: it independently cross-checks
|
|
542
|
-
the manifest, the three generated files and the filesystem (a component
|
|
543
|
-
file that exists but is missing from the manifest fails too). It runs in
|
|
544
|
-
the pre-commit hook (together with `lint-staged` and `ts-check`; hooks are
|
|
545
|
-
installed automatically by `npm install` via husky) and in CI, so an
|
|
546
|
-
inconsistent component surface cannot reach `master`.
|
|
547
|
-
|
|
548
|
-
## Documentation
|
|
549
|
-
|
|
550
|
-
### Live Documentation
|
|
551
|
-
Visit [documentation](https://voicenter-ui.netlify.app/) for interactive component examples and demos.
|
|
552
|
-
|
|
553
|
-
## Project Documentation
|
|
554
|
-
For detailed technical documentation, see the [`docs/`](./docs/) directory:
|
|
555
|
-
|
|
556
|
-
- **[Quick Start Guide](./docs/AGENTS_QUICK_START.md)** - For developers working on the library
|
|
557
|
-
- **[Architecture Overview](./docs/ARCHITECTURE.md)** - Project structure and technical details
|
|
558
|
-
- **[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
|
+
> **v3.0.0 is a tree-shaking release with breaking changes.** See [`MIGRATION_v3.md`](./MIGRATION_v3.md). The separate `*-extended` package is gone — every component lives in this package now.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
npm i @voicenter-team/voicenter-ui-plus
|
|
10
|
+
npm i vue@^3.5 element-plus @vueuse/core dayjs lodash-es libphonenumber-js maska
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Sass compiler (build-time)
|
|
14
|
+
|
|
15
|
+
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:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm i -D sass-embedded
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This is a **build-time only** requirement — it doesn't add anything to your runtime bundle. Most Vue 3 / Vite projects already have it.
|
|
22
|
+
|
|
23
|
+
Optional peer deps — install only for the heavy components you use:
|
|
24
|
+
|
|
25
|
+
| Component | Peer deps |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `VcPdfDocument` | `pdfjs-dist@^2.16.105` |
|
|
28
|
+
| `VcSoundPlayer` | `wavesurfer.js` |
|
|
29
|
+
| `VcExcelFileUploader` | `xlsx` |
|
|
30
|
+
| `VcImageUploader` | `vue-advanced-cropper` |
|
|
31
|
+
| `VcHtmlEditor` / `VcJsonSchema` | `codemirror @codemirror/lang-html @codemirror/lang-json @codemirror/lang-markdown vue-codemirror6` |
|
|
32
|
+
| `VcMdEditor` | `@milkdown/crepe @milkdown/kit @milkdown/vue @prosemirror-adapter/vue` |
|
|
33
|
+
|
|
34
|
+
### If you're on Vite 8 / rolldown (and skipping some optional peers)
|
|
35
|
+
|
|
36
|
+
Vite 8's rolldown-based bundler validates named imports against optional-peer-dep stubs and fails the build with `MISSING_EXPORT` errors when a heavy component's peer is uninstalled — even when you don't use that component. Add the unused optional peers to `build.rollupOptions.external` in your `vite.config.ts`:
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
// vite.config.ts
|
|
40
|
+
import { defineConfig } from 'vite'
|
|
41
|
+
import vue from '@vitejs/plugin-vue'
|
|
42
|
+
|
|
43
|
+
export default defineConfig({
|
|
44
|
+
plugins: [ vue() ],
|
|
45
|
+
build: {
|
|
46
|
+
rollupOptions: {
|
|
47
|
+
external: [
|
|
48
|
+
// List only the heavy peers you DON'T install
|
|
49
|
+
/^@milkdown\//, /^@prosemirror/, /^@codemirror\//, /^codemirror/,
|
|
50
|
+
/^vue-codemirror6/, /^vue-advanced-cropper/,
|
|
51
|
+
'wavesurfer.js', 'xlsx', 'pdfjs-dist', /^pdfjs-dist\//
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
})
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Earlier Vite versions (5, 6, 7 with rollup) and webpack 5+ don't require this — the older rollup variant warns but doesn't error on optional-peer named imports.
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### Tree-shake mode (recommended)
|
|
63
|
+
```ts
|
|
64
|
+
import { VcButton, VcInput } from '@voicenter-team/voicenter-ui-plus'
|
|
65
|
+
// Use as local components — no app.use() needed.
|
|
66
|
+
```
|
|
67
|
+
Bundlers drop unused components and their CSS. A consumer importing only `VcButton` ships ~50–150 KB JS + ~10–30 KB CSS.
|
|
68
|
+
|
|
69
|
+
If you use `useConfirmModal`, `useConfirmPopup`, or `NotifyService`, mount global overlays in `App.vue`:
|
|
70
|
+
|
|
71
|
+
```vue
|
|
72
|
+
<script setup lang="ts">
|
|
73
|
+
import { VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus'
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<RouterView />
|
|
78
|
+
<VcPluginOverlays />
|
|
79
|
+
</template>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Plugin mode (global registration)
|
|
83
|
+
```ts
|
|
84
|
+
import VoicenterUI from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
85
|
+
import '@voicenter-team/voicenter-ui-plus/style.css'
|
|
86
|
+
|
|
87
|
+
// Overlay composables can be imported from the same entry:
|
|
88
|
+
// import { useConfirmModal, useConfirmPopup, VcPluginOverlays } from '@voicenter-team/voicenter-ui-plus/plugin'
|
|
89
|
+
|
|
90
|
+
app.use(VoicenterUI, {
|
|
91
|
+
themeConfig, // theme config (see below)
|
|
92
|
+
lang: 'en', // localization
|
|
93
|
+
injectIconFont: true // inject icon-font <link> tags into <head>
|
|
94
|
+
})
|
|
95
|
+
// Confirm modals/popovers/notifications: auto-mounted via VcPluginOverlays
|
|
96
|
+
// (mountOverlays: true by default). Opt out with mountOverlays: false and
|
|
97
|
+
// add <VcPluginOverlays /> to App.vue — also registered globally by the plugin.
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Global overlays
|
|
101
|
+
|
|
102
|
+
Several APIs are **state-only** — they update global reactive singletons but do not render UI by themselves:
|
|
103
|
+
|
|
104
|
+
| API | Overlay component |
|
|
105
|
+
|---|---|
|
|
106
|
+
| `useConfirmModal` | `VcConfirmModal` |
|
|
107
|
+
| `useConfirmPopup` | `VcConfirmPopover` |
|
|
108
|
+
| `NotifyService` / `$notify` | `VcNotification` |
|
|
109
|
+
|
|
110
|
+
**Plugin mode:** mounted automatically on `app.use()` (default). Pass `mountOverlays: false` to mount manually.
|
|
111
|
+
|
|
112
|
+
**Notifications:** one top-right host by default. For multiple positions, use `overlayNotifications` in plugin config or mount your own:
|
|
113
|
+
|
|
114
|
+
```ts
|
|
115
|
+
app.use(VoicenterUI, {
|
|
116
|
+
overlayNotifications: [
|
|
117
|
+
{ group: 'top-right', position: 'top-right' },
|
|
118
|
+
{ group: 'bottom-right', position: 'bottom-right' },
|
|
119
|
+
],
|
|
120
|
+
})
|
|
121
|
+
// NotifyService.add({ group: 'bottom-right', ... })
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Or `overlayNotifications: 'none'` and put `<VcNotification />` in App.vue (confirms still auto-mount).
|
|
125
|
+
|
|
126
|
+
**Tree-shake mode:** add `<VcPluginOverlays />` to `App.vue` (bundles confirm hosts; configure via `notifications` prop).
|
|
127
|
+
|
|
128
|
+
Entity components such as `VcEntityListTable` call `useConfirmModal` internally — delete confirmations require overlays to be mounted.
|
|
129
|
+
|
|
130
|
+
### Tailwind
|
|
131
|
+
|
|
132
|
+
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.
|
|
133
|
+
|
|
134
|
+
```js
|
|
135
|
+
// tailwind.config.js
|
|
136
|
+
const voiceTailwindScheme = require('@voicenter-team/voicenter-ui-plus/src/theme/tailwindScheme')
|
|
137
|
+
|
|
138
|
+
module.exports = {
|
|
139
|
+
...yourConfiguration,
|
|
140
|
+
theme: {
|
|
141
|
+
colors: { ...voiceTailwindScheme },
|
|
142
|
+
borderColor: { ...voiceTailwindScheme },
|
|
143
|
+
fill: voiceTailwindScheme
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
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).
|
|
149
|
+
|
|
150
|
+
### Theming specification
|
|
151
|
+
The `themeConfig` which is passed as options to the VoicenterUI `vue.use` data could have the following specifications:
|
|
152
|
+
|
|
153
|
+
### Local
|
|
154
|
+
**Config:**
|
|
155
|
+
```js
|
|
156
|
+
{
|
|
157
|
+
type: 'local'
|
|
158
|
+
themeName: 'red' | 'blue' | '...'
|
|
159
|
+
onSetupCallback: () => {
|
|
160
|
+
console.log('Loaded!')
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
**Description:**
|
|
165
|
+
|
|
166
|
+
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
|
|
167
|
+
|
|
168
|
+
**Params:**
|
|
169
|
+
- **themeName**
|
|
170
|
+
- The name of the theme to be injected
|
|
171
|
+
- **onSetupCallback**
|
|
172
|
+
- 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
|
|
173
|
+
|
|
174
|
+
### Remote
|
|
175
|
+
**Config:**
|
|
176
|
+
```js
|
|
177
|
+
{
|
|
178
|
+
type: 'remote'
|
|
179
|
+
brandingSectionName: 'someName'
|
|
180
|
+
apiUrl: 'someUrl'
|
|
181
|
+
brandingSectionName: {
|
|
182
|
+
property: 'data'
|
|
183
|
+
}
|
|
184
|
+
onSetupCallback: () => {
|
|
185
|
+
console.log('Loaded!')
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
**Description:**
|
|
190
|
+
|
|
191
|
+
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
|
|
192
|
+
|
|
193
|
+
**Params:**
|
|
194
|
+
- **brandingSectionName**
|
|
195
|
+
- [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
|
|
196
|
+
- **apiUrl**
|
|
197
|
+
- The API url to which the POST request will be initiated
|
|
198
|
+
- **onSetupCallback**
|
|
199
|
+
- 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
|
|
200
|
+
- **brandingSectionName**
|
|
201
|
+
- [Optional] The payload data that will be sent to the request
|
|
202
|
+
|
|
203
|
+
### Custom JSON
|
|
204
|
+
**Config:**
|
|
205
|
+
```js
|
|
206
|
+
{
|
|
207
|
+
type: 'customJson'
|
|
208
|
+
config: {
|
|
209
|
+
black: '#000000'
|
|
210
|
+
}
|
|
211
|
+
onSetupCallback: () => {
|
|
212
|
+
console.log('Loaded!')
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
**Description:**
|
|
217
|
+
|
|
218
|
+
Such configuration will initiate the styling with custom provided theme
|
|
219
|
+
|
|
220
|
+
**Params:**
|
|
221
|
+
- **config**
|
|
222
|
+
- The object where the key is the variable to be set and the value is the variable value. Check the [themes object](https://github.com/VoicenterTeam/voicenter-ui-plus/blob/master/src/theme/themes.json) to check existing variables
|
|
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
|
+
|
|
226
|
+
### None
|
|
227
|
+
`{ type: 'none', onSetupCallback?: (theme) => void }` injects no theme variables; the application sets them itself.
|
|
228
|
+
|
|
229
|
+
## Using ui-plus in an application
|
|
230
|
+
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
### Where the facts are
|
|
234
|
+
|
|
235
|
+
The installed package is the truth. Read it before saying what ui-plus has or how a component behaves.
|
|
236
|
+
|
|
237
|
+
- **Every component**: `library/types/components/exports.d.ts`. One component's props, events and slots: `library/types/components/<VcName>/<VcName>.vue.d.ts`.
|
|
238
|
+
- **Composables, services, directives, the entity base**: `library/types/composables/`, `library/types/services/`, `library/types/directives/`, `library/types/entity/`.
|
|
239
|
+
- **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" />`.
|
|
240
|
+
- **Colour tokens**: `src/theme/themes.json` (each key is the CSS variable `--<key>`) and `src/theme/tailwindScheme.js` (the Tailwind colour names).
|
|
241
|
+
- **Examples**: the [live documentation](https://voicenter-ui.netlify.app/).
|
|
242
|
+
|
|
243
|
+
### Choosing a component
|
|
244
|
+
|
|
245
|
+
- 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.
|
|
246
|
+
- 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.
|
|
247
|
+
- 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:
|
|
248
|
+
- a new interaction component;
|
|
249
|
+
- 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;
|
|
250
|
+
- a ui-plus component used for a role it is not built for, such as a segmented switcher drawn as a searchable list.
|
|
251
|
+
- 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.
|
|
252
|
+
- A report names a control by what is on screen: a restyled ui-plus component is reported as custom.
|
|
253
|
+
- 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.
|
|
254
|
+
|
|
255
|
+
### Colours
|
|
256
|
+
|
|
257
|
+
- Every colour is a ui-plus token: a Tailwind class from the library scheme (`text-default-text`, `text-secondary-text`, `text-primary`, `bg-main-bg`, `bg-light-bg`, `border-ui-lines`, `text-success`, `text-error`) or a theme variable in a style (`color: var(--default-text)`). Status colours, tags, icons and chart series included.
|
|
258
|
+
- 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.
|
|
259
|
+
- The theme configuration (`themeConfig`, usually a `colors.json`) sets the library theme. It is not a palette to add colours to.
|
|
260
|
+
|
|
261
|
+
### Notifications and confirmations
|
|
262
|
+
|
|
263
|
+
`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.
|
|
264
|
+
|
|
265
|
+
### Text direction
|
|
266
|
+
|
|
267
|
+
ui-plus follows the `dir` attribute of `<html>`: `useRTL()` reads it and updates when it changes. The application sets the direction there, once.
|
|
268
|
+
|
|
269
|
+
### Server-side rendering
|
|
270
|
+
|
|
271
|
+
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.
|
|
272
|
+
|
|
273
|
+
### Troubleshooting
|
|
274
|
+
|
|
275
|
+
- **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.
|
|
276
|
+
- **`Cannot find module 'pdfjs-dist'` (or another optional peer) at build time**: install the peer, or stop importing its component.
|
|
277
|
+
- **Duplicate styles, a huge CSS payload**: the two modes are mixed (named imports plus the global `style.css`). Pick one (`MIGRATION_v3.md`, §1).
|
|
278
|
+
- **PDF.js worker not loading**: the worker is a sibling asset resolved with `new URL('./pdf.worker.min.js', import.meta.url)`; the bundler must support that pattern (Vite, webpack 5+, Rollup and esbuild do).
|
|
279
|
+
|
|
280
|
+
## Date Handling
|
|
281
|
+
|
|
282
|
+
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).
|
|
283
|
+
|
|
284
|
+
### Format Tokens
|
|
285
|
+
|
|
286
|
+
**Important**: Use dayjs format tokens:
|
|
287
|
+
- `DD` - Day of month (2 digits) - **NOT** `dd`
|
|
288
|
+
- `YYYY` - 4-digit year - **NOT** `yyyy`
|
|
289
|
+
- `MM` - Month (2 digits)
|
|
290
|
+
- `HH` - 24-hour format
|
|
291
|
+
- `mm` - Minutes
|
|
292
|
+
- `ss` - Seconds
|
|
293
|
+
|
|
294
|
+
### Common Formats
|
|
295
|
+
|
|
296
|
+
```typescript
|
|
297
|
+
'DD/MM/YYYY' // 31/12/2024
|
|
298
|
+
'DD-MM-YYYY' // 31-12-2024
|
|
299
|
+
'YYYY-MM-DD' // 2024-12-31
|
|
300
|
+
'DD/MM/YYYY, HH:mm' // 31/12/2024, 14:30
|
|
301
|
+
'DD/MM/YYYY HH:mm:ss' // 31/12/2024 14:30:45
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Usage Example
|
|
305
|
+
|
|
306
|
+
```vue
|
|
307
|
+
<VcDatePicker
|
|
308
|
+
v-model="date"
|
|
309
|
+
format="DD/MM/YYYY"
|
|
310
|
+
input-date-format="DD/MM/YYYY"
|
|
311
|
+
input-time-format="HH:mm"
|
|
312
|
+
/>
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Date Utility Functions
|
|
316
|
+
|
|
317
|
+
The library provides a comprehensive set of date utility functions built on dayjs. These utilities are available for use in external projects.
|
|
318
|
+
|
|
319
|
+
### Import Date Utilities
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import {
|
|
323
|
+
formatDate,
|
|
324
|
+
parseDate,
|
|
325
|
+
addDays,
|
|
326
|
+
subtractDays,
|
|
327
|
+
getHours,
|
|
328
|
+
getMinutes,
|
|
329
|
+
getSeconds,
|
|
330
|
+
setTime,
|
|
331
|
+
isAfter,
|
|
332
|
+
isSameAfter,
|
|
333
|
+
isBefore,
|
|
334
|
+
isSameBefore,
|
|
335
|
+
format,
|
|
336
|
+
add,
|
|
337
|
+
sub,
|
|
338
|
+
addFp,
|
|
339
|
+
subFp
|
|
340
|
+
} from '@voicenter-team/voicenter-ui-plus'
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Basic Date Operations
|
|
344
|
+
|
|
345
|
+
#### Formatting Dates
|
|
346
|
+
|
|
347
|
+
```typescript
|
|
348
|
+
// Format a date with default format (YYYY-MM-DD)
|
|
349
|
+
const formatted = formatDate(new Date())
|
|
350
|
+
// Result: "2024-12-31"
|
|
351
|
+
|
|
352
|
+
// Format with custom format
|
|
353
|
+
const custom = formatDate(new Date(), 'DD/MM/YYYY')
|
|
354
|
+
// Result: "31/12/2024"
|
|
355
|
+
|
|
356
|
+
// Using format function (alias)
|
|
357
|
+
const formatted2 = format(new Date(), 'DD/MM/YYYY HH:mm')
|
|
358
|
+
// Result: "31/12/2024 14:30"
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
#### Parsing Dates
|
|
362
|
+
|
|
363
|
+
```typescript
|
|
364
|
+
// Parse a date string with format
|
|
365
|
+
const date = parseDate('31/12/2024', 'DD/MM/YYYY')
|
|
366
|
+
// Returns: Date object
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
### Date Arithmetic
|
|
370
|
+
|
|
371
|
+
#### Adding/Subtracting Days
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// Add days
|
|
375
|
+
const futureDate = addDays(new Date(), 7)
|
|
376
|
+
// Returns: Date 7 days from now
|
|
377
|
+
|
|
378
|
+
// Subtract days
|
|
379
|
+
const pastDate = subtractDays(new Date(), 5)
|
|
380
|
+
// Returns: Date 5 days ago
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
#### Adding/Subtracting Time Units
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
// Add multiple time units
|
|
387
|
+
const newDate = add(new Date(), {
|
|
388
|
+
years: 1,
|
|
389
|
+
months: 2,
|
|
390
|
+
days: 5,
|
|
391
|
+
hours: 3,
|
|
392
|
+
minutes: 30
|
|
393
|
+
})
|
|
394
|
+
|
|
395
|
+
// Subtract multiple time units
|
|
396
|
+
const earlierDate = sub(new Date(), {
|
|
397
|
+
weeks: 2,
|
|
398
|
+
days: 3,
|
|
399
|
+
hours: 12
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
// Functional programming style (reversed arguments)
|
|
403
|
+
const fpDate = addFp({ days: 7 }, new Date())
|
|
404
|
+
const fpDate2 = subFp({ hours: 5 }, new Date())
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Time Operations
|
|
408
|
+
|
|
409
|
+
#### Getting Time Components
|
|
410
|
+
|
|
411
|
+
```typescript
|
|
412
|
+
const date = new Date('2024-12-31T14:30:45')
|
|
413
|
+
|
|
414
|
+
const hours = getHours(date) // 14
|
|
415
|
+
const minutes = getMinutes(date) // 30
|
|
416
|
+
const seconds = getSeconds(date) // 45
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
#### Setting Time
|
|
420
|
+
|
|
421
|
+
```typescript
|
|
422
|
+
// Set time on a date (returns new Date object)
|
|
423
|
+
const newDate = setTime(new Date(), {
|
|
424
|
+
hours: 14,
|
|
425
|
+
minutes: 30,
|
|
426
|
+
seconds: 0
|
|
427
|
+
})
|
|
428
|
+
```
|
|
429
|
+
|
|
430
|
+
### Date Comparisons
|
|
431
|
+
|
|
432
|
+
```typescript
|
|
433
|
+
const date1 = new Date('2024-12-31')
|
|
434
|
+
const date2 = new Date('2025-01-01')
|
|
435
|
+
|
|
436
|
+
// Check if date1 is after date2
|
|
437
|
+
const isLater = isAfter(date1, date2, 'day')
|
|
438
|
+
// Returns: false
|
|
439
|
+
|
|
440
|
+
// Check if date1 is same or after date2
|
|
441
|
+
const isSameOrLater = isSameAfter(date1, date2, 'day')
|
|
442
|
+
// Returns: false
|
|
443
|
+
|
|
444
|
+
// Check if date1 is before date2
|
|
445
|
+
const isEarlier = isBefore(date1, date2, 'day')
|
|
446
|
+
// Returns: true
|
|
447
|
+
|
|
448
|
+
// Check if date1 is same or before date2
|
|
449
|
+
const isSameOrEarlier = isSameBefore(date1, date2, 'day')
|
|
450
|
+
// Returns: true
|
|
451
|
+
```
|
|
452
|
+
|
|
453
|
+
**Comparison Units**: The comparison functions accept a `units` parameter (default: `'minute'`). Valid units:
|
|
454
|
+
- `'year'`, `'month'`, `'week'`, `'day'`
|
|
455
|
+
- `'hour'`, `'minute'`, `'second'`
|
|
456
|
+
|
|
457
|
+
### Complete Usage Example
|
|
458
|
+
|
|
459
|
+
```typescript
|
|
460
|
+
import {
|
|
461
|
+
formatDate,
|
|
462
|
+
addDays,
|
|
463
|
+
isAfter,
|
|
464
|
+
format,
|
|
465
|
+
add,
|
|
466
|
+
getHours,
|
|
467
|
+
setTime
|
|
468
|
+
} from '@voicenter-team/voicenter-ui-plus'
|
|
469
|
+
|
|
470
|
+
// Format today's date
|
|
471
|
+
const today = formatDate(new Date(), 'DD/MM/YYYY')
|
|
472
|
+
|
|
473
|
+
// Get date 30 days from now
|
|
474
|
+
const futureDate = addDays(new Date(), 30)
|
|
475
|
+
|
|
476
|
+
// Check if a date is in the future
|
|
477
|
+
const isFuture = isAfter(futureDate, new Date(), 'day')
|
|
478
|
+
|
|
479
|
+
// Add 2 weeks and 3 days
|
|
480
|
+
const deadline = add(new Date(), {
|
|
481
|
+
weeks: 2,
|
|
482
|
+
days: 3
|
|
483
|
+
})
|
|
484
|
+
|
|
485
|
+
// Get current hour
|
|
486
|
+
const currentHour = getHours(new Date())
|
|
487
|
+
|
|
488
|
+
// Set specific time
|
|
489
|
+
const meetingTime = setTime(new Date(), {
|
|
490
|
+
hours: 14,
|
|
491
|
+
minutes: 30
|
|
492
|
+
})
|
|
493
|
+
|
|
494
|
+
// Format the result
|
|
495
|
+
const formattedDeadline = format(deadline, 'DD/MM/YYYY HH:mm')
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
### Notes
|
|
499
|
+
|
|
500
|
+
- All functions accept `Date`, `string`, or `number` as date input
|
|
501
|
+
- All date manipulation functions return new `Date` objects (immutable)
|
|
502
|
+
- Format strings use dayjs format tokens (see Format Tokens section above)
|
|
503
|
+
- These utilities are built on dayjs and maintain compatibility with dayjs format patterns
|
|
504
|
+
|
|
505
|
+
## Contributing: adding a new component
|
|
506
|
+
|
|
507
|
+
The public component surface is defined in **one place**: [`script/components-manifest.mjs`](./script/components-manifest.mjs) — one line per component.
|
|
508
|
+
|
|
509
|
+
```js
|
|
510
|
+
{ name: 'VcMyThing', path: 'components/VcMyThing/VcMyThing.vue' },
|
|
511
|
+
```
|
|
512
|
+
|
|
513
|
+
`npm run generate:entries` materializes the manifest into three fully
|
|
514
|
+
generated files (never edit them by hand — the next generator run
|
|
515
|
+
overwrites them, and the verifier fails the build until they match):
|
|
516
|
+
|
|
517
|
+
- `src/components.gen.ts` — named exports, re-exported by `src/index.ts`
|
|
518
|
+
(tree-shake mode);
|
|
519
|
+
- `src/plugin-components.gen.ts` — `registerComponents(app)`, called by
|
|
520
|
+
the plugin's install (global registration mode);
|
|
521
|
+
- `src/components/exports.ts` — the `GlobalComponents` template typing.
|
|
522
|
+
|
|
523
|
+
`src/index.ts` and `src/plugin.ts` themselves stay hand-written and small.
|
|
524
|
+
The `.gen` modules are safe to route through only because
|
|
525
|
+
`rewriteCssImports()` in `vite.config.ts` strips the CSS imports that
|
|
526
|
+
`vite-plugin-lib-inject-css` aggregates onto them — each component's CSS
|
|
527
|
+
stays in its own chunk, so per-component CSS tree-shaking survives. Don't
|
|
528
|
+
rename the `.gen` files without updating that strip list (the verifier
|
|
529
|
+
guards this wiring too).
|
|
530
|
+
|
|
531
|
+
Typical flows:
|
|
532
|
+
|
|
533
|
+
- **New component**: `node script/create-component.mjs` — scaffolds the
|
|
534
|
+
component folder, adds the manifest line, and regenerates all entries.
|
|
535
|
+
- **Existing .vue file**: add one line to the manifest, then
|
|
536
|
+
`npm run generate:entries`.
|
|
537
|
+
|
|
538
|
+
Every manifest entry is exported from the package root AND registered
|
|
539
|
+
globally in plugin mode — there are no partial modes.
|
|
540
|
+
|
|
541
|
+
`npm run verify:entries` is the safety net: it independently cross-checks
|
|
542
|
+
the manifest, the three generated files and the filesystem (a component
|
|
543
|
+
file that exists but is missing from the manifest fails too). It runs in
|
|
544
|
+
the pre-commit hook (together with `lint-staged` and `ts-check`; hooks are
|
|
545
|
+
installed automatically by `npm install` via husky) and in CI, so an
|
|
546
|
+
inconsistent component surface cannot reach `master`.
|
|
547
|
+
|
|
548
|
+
## Documentation
|
|
549
|
+
|
|
550
|
+
### Live Documentation
|
|
551
|
+
Visit [documentation](https://voicenter-ui.netlify.app/) for interactive component examples and demos.
|
|
552
|
+
|
|
553
|
+
## Project Documentation
|
|
554
|
+
For detailed technical documentation, see the [`docs/`](./docs/) directory:
|
|
555
|
+
|
|
556
|
+
- **[Quick Start Guide](./docs/AGENTS_QUICK_START.md)** - For developers working on the library
|
|
557
|
+
- **[Architecture Overview](./docs/ARCHITECTURE.md)** - Project structure and technical details
|
|
558
|
+
- **[Documentation Guide](./docs/DOCUMENTATION_GUIDE.md)** - Working with the documentation system
|