vlite3 1.5.12 → 1.5.14
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 +20 -8
- package/components/Accordion/AccordionContent.vue.js +2 -2
- package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
- package/components/Form/AccordionView2.vue.js +1 -1
- package/components/Form/Form.vue.js +2 -2
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/PanZoomViewport/PanZoomViewport.vue.d.ts +7 -7
- package/components/PanZoomViewport/PanZoomViewport.vue.js +1 -1
- package/components/Tabes/Tabes.vue.js +2 -2
- package/docs/README.md +16 -0
- package/docs/component-index.md +313 -0
- package/docs/components/accordion.md +52 -0
- package/docs/components/alert.md +34 -0
- package/docs/components/app-shell.md +371 -0
- package/docs/components/async-select.md +264 -0
- package/docs/components/attachments-list.md +231 -0
- package/docs/components/avatar-group.md +74 -0
- package/docs/components/avatar-uploader.md +61 -0
- package/docs/components/avatar.md +28 -0
- package/docs/components/badge.md +81 -0
- package/docs/components/barcode.md +42 -0
- package/docs/components/beacon.md +29 -0
- package/docs/components/breadcrumb.md +317 -0
- package/docs/components/button-group.md +35 -0
- package/docs/components/button.md +86 -0
- package/docs/components/calendar.md +95 -0
- package/docs/components/carousel.md +122 -0
- package/docs/components/cart.md +533 -0
- package/docs/components/category-manager.md +269 -0
- package/docs/components/category-menu.md +251 -0
- package/docs/components/charts.md +1456 -0
- package/docs/components/chat.md +330 -0
- package/docs/components/checkbox.md +31 -0
- package/docs/components/chip.md +137 -0
- package/docs/components/choice-box.md +40 -0
- package/docs/components/clipboard.md +105 -0
- package/docs/components/clock.md +70 -0
- package/docs/components/color-picker.md +82 -0
- package/docs/components/command-palette.md +214 -0
- package/docs/components/comment-thread.md +171 -0
- package/docs/components/confirmation-modal.md +50 -0
- package/docs/components/custom-fields-display.md +94 -0
- package/docs/components/custom-fields.md +97 -0
- package/docs/components/data-list.md +93 -0
- package/docs/components/data-table.md +922 -0
- package/docs/components/date-picker.md +58 -0
- package/docs/components/date-range-picker.md +24 -0
- package/docs/components/date-time.md +104 -0
- package/docs/components/dropdown.md +740 -0
- package/docs/components/empty.md +100 -0
- package/docs/components/export-data.md +320 -0
- package/docs/components/file-picker.md +83 -0
- package/docs/components/file-preview.md +42 -0
- package/docs/components/file-tree.md +144 -0
- package/docs/components/footer.md +251 -0
- package/docs/components/forms.md +776 -0
- package/docs/components/gantt-chart.md +767 -0
- package/docs/components/google-login.md +67 -0
- package/docs/components/google-map.md +128 -0
- package/docs/components/heatmap.md +80 -0
- package/docs/components/icon-picker.md +58 -0
- package/docs/components/icon.md +176 -0
- package/docs/components/image-comparison.md +51 -0
- package/docs/components/image-magnifier.md +26 -0
- package/docs/components/import-data.md +521 -0
- package/docs/components/input.md +58 -0
- package/docs/components/invoice.md +339 -0
- package/docs/components/kanban.md +302 -0
- package/docs/components/label.md +25 -0
- package/docs/components/list.md +419 -0
- package/docs/components/masonry.md +55 -0
- package/docs/components/modal.md +133 -0
- package/docs/components/multi-select.md +54 -0
- package/docs/components/navbar.md +403 -0
- package/docs/components/number-input.md +41 -0
- package/docs/components/otp-input.md +68 -0
- package/docs/components/pagination.md +83 -0
- package/docs/components/pan-zoom-viewport.md +245 -0
- package/docs/components/permission-editor.md +322 -0
- package/docs/components/persona.md +56 -0
- package/docs/components/price.md +106 -0
- package/docs/components/pricing-plan.md +68 -0
- package/docs/components/progress-bar.md +53 -0
- package/docs/components/qr-code.md +59 -0
- package/docs/components/rating.md +59 -0
- package/docs/components/rich-text-editor.md +210 -0
- package/docs/components/scale-generator.md +101 -0
- package/docs/components/screen.md +208 -0
- package/docs/components/seo-provider.md +189 -0
- package/docs/components/side-panel.md +94 -0
- package/docs/components/sidebar-menu.md +422 -0
- package/docs/components/skeleton.md +115 -0
- package/docs/components/slider.md +48 -0
- package/docs/components/spinner.md +27 -0
- package/docs/components/splitter.md +97 -0
- package/docs/components/stats.md +234 -0
- package/docs/components/status-chip.md +232 -0
- package/docs/components/switch.md +23 -0
- package/docs/components/tabs.md +335 -0
- package/docs/components/tag-input.md +55 -0
- package/docs/components/textarea.md +31 -0
- package/docs/components/theme-provider.md +130 -0
- package/docs/components/theme-toggle.md +36 -0
- package/docs/components/thumbnail-selector.md +186 -0
- package/docs/components/timeline.md +225 -0
- package/docs/components/toast-notification.md +89 -0
- package/docs/components/tooltip.md +31 -0
- package/docs/components/workbook.md +102 -0
- package/docs/composables/use-theme.md +59 -0
- package/docs/getting-started/setup.md +176 -0
- package/docs/guides/draggable.md +211 -0
- package/docs/guides/internationalization.md +281 -0
- package/docs/guides/performance.md +118 -0
- package/docs/guides/testing-forms.md +154 -0
- package/docs/guides/testing-overlays.md +131 -0
- package/docs/guides/theming.md +124 -0
- package/docs/utilities/search.md +580 -0
- package/docs/utilities/utilities.md +371 -0
- package/docs-manifest.json +336 -0
- package/package.json +5 -13
- package/scripts/generate-docs-manifest.js +207 -0
- package/scripts/sync-docs.js +754 -0
- package/style.css +1 -1
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
# Chat
|
|
2
|
+
|
|
3
|
+
**Import:** `import { ChatInterface } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
A fully-featured, enterprise-grade chat component supporting reverse infinite scroll, message editing, message deletion with optional double-confirm, file attachments with inline preview, and a responsive auto-growing textarea input.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Props
|
|
10
|
+
|
|
11
|
+
| Prop | Type | Default | Description |
|
|
12
|
+
| :-------------- | :-------------------- | :------------------- | :--------------------------------------------------------------------------------------------------------------- |
|
|
13
|
+
| `data` | `ChatMessage[]` | **required** | Array of messages to display. |
|
|
14
|
+
| `currentUserId` | `string \| number` | **required** | The ID of the currently authenticated user. Used to distinguish sender vs. receiver bubbles. |
|
|
15
|
+
| `showAvatar` | `boolean` | `true` | Toggles avatar visibility next to each message. |
|
|
16
|
+
| `showUserInfo` | `boolean` | `true` | Toggles the sender name label above receiver messages. |
|
|
17
|
+
| `showTimestamp` | `boolean` | `true` | Toggles the formatted timestamp below each message. |
|
|
18
|
+
| `placeholder` | `string` | `'Type a message...'`| Placeholder text for the message input textarea. |
|
|
19
|
+
| `isLoadingMore` | `boolean` | `false` | When `true`, shows a spinner at the top of the message list (used during reverse-scroll pagination). |
|
|
20
|
+
| `allowDeleteAll`| `boolean` | `false` | When `true`, allows the current user to delete messages sent by others (admin mode). |
|
|
21
|
+
| `allowEditAll` | `boolean` | `false` | When `true`, allows the current user to edit messages sent by others (admin mode). |
|
|
22
|
+
| `allowFileUpload`| `boolean` | `true` | When `true` (default), shows the file attachment picker button. |
|
|
23
|
+
| `confirmDelete` | `boolean` | `true` | When `true`, the delete button requires a second click to confirm. Set to `false` to delete on first click. |
|
|
24
|
+
| `folderId` | `string` | `undefined` | The storage folder ID passed to the file upload handler when attaching files. |
|
|
25
|
+
| `maxFileSize` | `number` | `undefined` | Maximum allowed file size in bytes for attachments (e.g. `10 * 1024 * 1024` for 10 MB). |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Events
|
|
30
|
+
|
|
31
|
+
| Event | Payload | Description |
|
|
32
|
+
| :-------- | :----------------------------------- | :-------------------------------------------------------------------------------------------------- |
|
|
33
|
+
| `add` | `(text: string, attachments?: ChatAttachment[])` | Emitted when the user sends a new message. `attachments` is `undefined` if no files were selected. |
|
|
34
|
+
| `delete` | `(id: string \| number)` | Emitted when a message is confirmed for deletion. |
|
|
35
|
+
| `edit` | `(message: ChatMessage)` | Emitted when the user saves an edited message. The payload is the full updated message object. |
|
|
36
|
+
| `refetch` | `()` | Emitted when the user scrolls to the top, signaling that older messages should be loaded. |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## Types
|
|
41
|
+
```ts
|
|
42
|
+
export interface ChatMessage {
|
|
43
|
+
id: string | number
|
|
44
|
+
text: string
|
|
45
|
+
senderId: string | number
|
|
46
|
+
senderName?: string
|
|
47
|
+
avatar?: string
|
|
48
|
+
timestamp?: string | Date
|
|
49
|
+
isEdited?: boolean
|
|
50
|
+
attachments?: ChatAttachment[]
|
|
51
|
+
[key: string]: any
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ChatAttachment {
|
|
55
|
+
fileUrl: string
|
|
56
|
+
fileName?: string
|
|
57
|
+
fileType?: string
|
|
58
|
+
fileSize?: number
|
|
59
|
+
[key: string]: any
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
### Basic Chat
|
|
68
|
+
```vue
|
|
69
|
+
<script setup lang="ts">
|
|
70
|
+
import { ref } from 'vue'
|
|
71
|
+
import { ChatInterface, type ChatMessage, type ChatAttachment } from 'vlite3'
|
|
72
|
+
|
|
73
|
+
const currentUserId = 'user_1'
|
|
74
|
+
|
|
75
|
+
const messages = ref<ChatMessage[]>([
|
|
76
|
+
{
|
|
77
|
+
id: 1,
|
|
78
|
+
text: 'Hey! How are you doing?',
|
|
79
|
+
senderId: 'user_2',
|
|
80
|
+
senderName: 'Alice',
|
|
81
|
+
avatar: 'https://i.pravatar.cc/150?img=5',
|
|
82
|
+
timestamp: new Date(),
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
id: 2,
|
|
86
|
+
text: 'I am good! Just working on something cool.',
|
|
87
|
+
senderId: 'user_1',
|
|
88
|
+
senderName: 'Me',
|
|
89
|
+
timestamp: new Date(),
|
|
90
|
+
},
|
|
91
|
+
])
|
|
92
|
+
|
|
93
|
+
const handleAdd = (text: string, attachments?: ChatAttachment[]) => {
|
|
94
|
+
messages.value.push({
|
|
95
|
+
id: Date.now(),
|
|
96
|
+
text,
|
|
97
|
+
senderId: currentUserId,
|
|
98
|
+
senderName: 'Me',
|
|
99
|
+
timestamp: new Date(),
|
|
100
|
+
attachments,
|
|
101
|
+
})
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const handleDelete = (id: string | number) => {
|
|
105
|
+
messages.value = messages.value.filter(m => m.id !== id)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const handleEdit = (updated: ChatMessage) => {
|
|
109
|
+
const i = messages.value.findIndex(m => m.id === updated.id)
|
|
110
|
+
if (i !== -1) messages.value[i] = { ...updated }
|
|
111
|
+
}
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<template>
|
|
115
|
+
<div class="h-[600px] border border-border rounded-xl overflow-hidden flex flex-col">
|
|
116
|
+
<ChatInterface
|
|
117
|
+
:data="messages"
|
|
118
|
+
:current-user-id="currentUserId"
|
|
119
|
+
@add="handleAdd"
|
|
120
|
+
@delete="handleDelete"
|
|
121
|
+
@edit="handleEdit" />
|
|
122
|
+
</div>
|
|
123
|
+
</template>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
### With Reverse Infinite Scroll
|
|
129
|
+
|
|
130
|
+
The component uses an `IntersectionObserver` internally. When the user scrolls to the top of the message list, the `refetch` event fires. Prepend older messages to `data` and set `isLoadingMore` accordingly. The component automatically preserves the scroll position after prepending so the view does not jump.
|
|
131
|
+
```vue
|
|
132
|
+
<script setup lang="ts">
|
|
133
|
+
import { ref } from 'vue'
|
|
134
|
+
import { ChatInterface, type ChatMessage } from 'vlite3'
|
|
135
|
+
|
|
136
|
+
const messages = ref<ChatMessage[]>([/* initial page */])
|
|
137
|
+
const isLoadingMore = ref(false)
|
|
138
|
+
const page = ref(1)
|
|
139
|
+
|
|
140
|
+
const handleRefetch = async () => {
|
|
141
|
+
if (isLoadingMore.value) return
|
|
142
|
+
isLoadingMore.value = true
|
|
143
|
+
|
|
144
|
+
const older = await fetchOlderMessages(page.value)
|
|
145
|
+
messages.value = [...older, ...messages.value]
|
|
146
|
+
|
|
147
|
+
page.value++
|
|
148
|
+
isLoadingMore.value = false
|
|
149
|
+
}
|
|
150
|
+
</script>
|
|
151
|
+
|
|
152
|
+
<template>
|
|
153
|
+
<div class="h-[600px] flex flex-col border border-border rounded-xl overflow-hidden">
|
|
154
|
+
<ChatInterface
|
|
155
|
+
:data="messages"
|
|
156
|
+
current-user-id="user_1"
|
|
157
|
+
:is-loading-more="isLoadingMore"
|
|
158
|
+
@refetch="handleRefetch"
|
|
159
|
+
@add="handleAdd"
|
|
160
|
+
@delete="handleDelete"
|
|
161
|
+
@edit="handleEdit" />
|
|
162
|
+
</div>
|
|
163
|
+
</template>
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
### With File Attachments
|
|
169
|
+
|
|
170
|
+
Pass a `folderId` to route uploads to a specific storage folder. Optionally cap file size via `maxFileSize`. Attachments are uploaded before the message is emitted — the `add` event always receives already-uploaded `ChatAttachment[]` objects with resolved `fileUrl` values.
|
|
171
|
+
```vue
|
|
172
|
+
<template>
|
|
173
|
+
<ChatInterface
|
|
174
|
+
:data="messages"
|
|
175
|
+
current-user-id="user_1"
|
|
176
|
+
folder-id="chat-uploads"
|
|
177
|
+
:max-file-size="10 * 1024 * 1024"
|
|
178
|
+
@add="handleAdd"
|
|
179
|
+
@delete="handleDelete"
|
|
180
|
+
@edit="handleEdit" />
|
|
181
|
+
</template>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
---
|
|
185
|
+
|
|
186
|
+
### Delete Confirmation
|
|
187
|
+
|
|
188
|
+
By default (`confirmDelete: true`), the delete button turns into a **check icon** on first click, requiring a second click to confirm. A small **×** badge appears on the button to cancel the pending delete. If the user does not confirm within **3 seconds**, the state resets automatically.
|
|
189
|
+
```vue
|
|
190
|
+
<!-- Default: requires double-click to confirm (recommended) -->
|
|
191
|
+
<ChatInterface :data="messages" current-user-id="user_1" :confirm-delete="true" ... />
|
|
192
|
+
|
|
193
|
+
<!-- Instant delete on first click -->
|
|
194
|
+
<ChatInterface :data="messages" current-user-id="user_1" :confirm-delete="false" ... />
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
**Delete flow with `confirmDelete: true`:**
|
|
198
|
+
|
|
199
|
+
1. User hovers the message → action buttons appear.
|
|
200
|
+
2. User clicks 🗑️ → button switches to ✓ (red tint) + a tiny × cancel badge.
|
|
201
|
+
3. User clicks ✓ → `delete` event emits with the message `id`.
|
|
202
|
+
4. If user clicks × or waits 3 s → state resets back to 🗑️.
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
### Admin Mode
|
|
207
|
+
|
|
208
|
+
Use `allowDeleteAll` and `allowEditAll` to grant the current user the ability to act on messages sent by others (e.g. a moderator or support agent).
|
|
209
|
+
```vue
|
|
210
|
+
<ChatInterface
|
|
211
|
+
:data="messages"
|
|
212
|
+
current-user-id="admin_1"
|
|
213
|
+
:allow-delete-all="true"
|
|
214
|
+
:allow-edit-all="true"
|
|
215
|
+
@add="handleAdd"
|
|
216
|
+
@delete="handleDelete"
|
|
217
|
+
@edit="handleEdit" />
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
---
|
|
221
|
+
|
|
222
|
+
### Minimal (No Avatars, No Timestamps)
|
|
223
|
+
```vue
|
|
224
|
+
<ChatInterface
|
|
225
|
+
:data="messages"
|
|
226
|
+
current-user-id="user_1"
|
|
227
|
+
:show-avatar="false"
|
|
228
|
+
:show-user-info="false"
|
|
229
|
+
:show-timestamp="false"
|
|
230
|
+
@add="handleAdd"
|
|
231
|
+
@delete="handleDelete"
|
|
232
|
+
@edit="handleEdit" />
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
## Keyboard Shortcuts
|
|
238
|
+
|
|
239
|
+
| Key | Action |
|
|
240
|
+
| :--------------- | :------------------------------------------ |
|
|
241
|
+
| `Enter` | Send the message (when input is focused). |
|
|
242
|
+
| `Shift + Enter` | Insert a newline in the message input. |
|
|
243
|
+
| `Escape` | Cancel an active edit and restore input. |
|
|
244
|
+
|
|
245
|
+
---
|
|
246
|
+
|
|
247
|
+
## Attachment Display — `AttachmentsList`
|
|
248
|
+
|
|
249
|
+
Attachments are rendered inline inside the chat bubble using the `AttachmentsList` component in `variant="inline"` mode. This variant:
|
|
250
|
+
|
|
251
|
+
- Inherits the current text color (`currentColor`) of the bubble so icons are always visible against both the sender's primary-colored bubble and the receiver's muted bubble.
|
|
252
|
+
- Uses a semi-transparent background (`bg-black/10` / `dark:bg-white/10`) for each attachment row instead of a hard-coded card color.
|
|
253
|
+
- Provides **Eye** (preview) and **Download** buttons that open a `FilePreview` modal or trigger a secure blob-based download respectively.
|
|
254
|
+
|
|
255
|
+
The `AttachmentsList` component can also be used standalone with `variant="default"` (the default) for rendering attachment lists outside of a chat context.
|
|
256
|
+
```vue
|
|
257
|
+
<script setup lang="ts">
|
|
258
|
+
import { AttachmentsList } from 'vlite3'
|
|
259
|
+
|
|
260
|
+
const files = [
|
|
261
|
+
{
|
|
262
|
+
fileName: 'invoice-2023.pdf',
|
|
263
|
+
fileSize: 1048576,
|
|
264
|
+
fileUrl: 'https://example.com/invoice.pdf',
|
|
265
|
+
},
|
|
266
|
+
]
|
|
267
|
+
</script>
|
|
268
|
+
|
|
269
|
+
<template>
|
|
270
|
+
<!-- Standalone default card style -->
|
|
271
|
+
<AttachmentsList :attachments="files" />
|
|
272
|
+
|
|
273
|
+
<!-- Inline style for embedding inside colored containers -->
|
|
274
|
+
<AttachmentsList :attachments="files" variant="inline" />
|
|
275
|
+
|
|
276
|
+
<!-- Without download -->
|
|
277
|
+
<AttachmentsList :attachments="files" :can-download="false" />
|
|
278
|
+
|
|
279
|
+
<!-- Without preview -->
|
|
280
|
+
<AttachmentsList :attachments="files" :can-view="false" />
|
|
281
|
+
</template>
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### `AttachmentsList` Props
|
|
285
|
+
|
|
286
|
+
| Prop | Type | Default | Description |
|
|
287
|
+
| :------------ | :----------------------------------- | :---------- | :--------------------------------------------------------------------------------------- |
|
|
288
|
+
| `attachments` | `AttachmentItem \| AttachmentItem[]` | `[]` | A single file or array of files to display. |
|
|
289
|
+
| `canView` | `boolean` | `true` | Toggles the preview (Eye) button. |
|
|
290
|
+
| `canDownload` | `boolean` | `true` | Toggles the download button. |
|
|
291
|
+
| `variant` | `'default' \| 'inline'` | `'default'` | `'inline'` uses `currentColor` for icons to blend seamlessly into any colored container. |
|
|
292
|
+
|
|
293
|
+
### `AttachmentItem` Type
|
|
294
|
+
```ts
|
|
295
|
+
export interface AttachmentItem {
|
|
296
|
+
fileName?: string
|
|
297
|
+
fileSize?: number
|
|
298
|
+
fileUrl: string
|
|
299
|
+
[key: string]: any
|
|
300
|
+
}
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## Layout Requirement
|
|
306
|
+
|
|
307
|
+
`ChatInterface` uses `flex-1` and `min-h-0` to fill its parent. Always wrap it in a container with a **fixed height** and `flex flex-col`:
|
|
308
|
+
```vue
|
|
309
|
+
<template>
|
|
310
|
+
<!-- Required: fixed height + flex col wrapper -->
|
|
311
|
+
<div class="h-[600px] flex flex-col border border-border rounded-xl overflow-hidden">
|
|
312
|
+
<ChatInterface ... />
|
|
313
|
+
</div>
|
|
314
|
+
</template>
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
Without a fixed height, the message list will not scroll correctly and the input will not anchor to the bottom.
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
## Internal Architecture
|
|
322
|
+
|
|
323
|
+
| Concern | Implementation |
|
|
324
|
+
| :------------------------ | :------------------------------------------------------------------------------------------------- |
|
|
325
|
+
| Reverse infinite scroll | `IntersectionObserver` watching a 1px sentinel `div` at the top of the message list. |
|
|
326
|
+
| Scroll preservation | Compares `scrollHeight` before and after prepend; offsets `scrollTop` by the difference. |
|
|
327
|
+
| Textarea auto-grow | Resets `height: auto` then sets `height` to `scrollHeight`, capped at `120px` (≈5 lines). |
|
|
328
|
+
| File upload | Delegates to `useFileUpload` composable; uploads complete before `add` event fires. |
|
|
329
|
+
| Delete confirmation | Local `pendingDelete` ref per bubble; auto-resets via `setTimeout` after 3 seconds. |
|
|
330
|
+
| Attachment inline styling | `variant="inline"` on `AttachmentsList` uses raw `<button>` elements inheriting `currentColor`. |
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# CheckBox
|
|
2
|
+
|
|
3
|
+
**Import:** `import { CheckBox } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
### Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
| --------------- | ----------------- | ------- | -------------------------------------- |
|
|
9
|
+
| `modelValue` | `boolean` | `false` | Binding (`v-model`) |
|
|
10
|
+
| `checked` | `boolean` | `false` | Binding (`v-model:checked`) |
|
|
11
|
+
| `label` | `string` | — | Side label text |
|
|
12
|
+
| `labelI18n` | `string` | — | I18n translation key for label |
|
|
13
|
+
| `indeterminate` | `boolean` | `false` | Mixed state visually |
|
|
14
|
+
| `disabled` | `boolean` | `false` | Disable input |
|
|
15
|
+
| `size` | `CheckboxSize` | `md` | Dimensions |
|
|
16
|
+
| `rounded` | `CheckboxRounded` | — | Corner radius (defaults to size style) |
|
|
17
|
+
| `id` | `string` | — | ID for the checkbox element |
|
|
18
|
+
| `class` | `string` | — | Custom CSS classes |
|
|
19
|
+
|
|
20
|
+
### Types
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
type CheckboxSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
24
|
+
type CheckboxRounded = 'none' | 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'full'
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Usage
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<CheckBox v-model:checked="isAgreed" label="I accept terms" />
|
|
31
|
+
```
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Chip
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Chip } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
Label text always stays on a single line. Width sizes to content (`w-max`) and does not shrink or truncate in tables, flex columns, or other constrained containers.
|
|
6
|
+
|
|
7
|
+
### Props
|
|
8
|
+
|
|
9
|
+
| Prop | Type | Default | Description |
|
|
10
|
+
| :------------ | :------------------------------- | :------- | :----------------------------------------------- |
|
|
11
|
+
| `variant` | `ChipVariant \| string` | `subtle` | Color / semantic style of the chip |
|
|
12
|
+
| `appearance` | `'filled' \| 'transparent'` | `filled` | Surface treatment — see [Appearance](#appearance)|
|
|
13
|
+
| `size` | `'xsmall' \| 'small' \| 'medium' \| 'large'` | `medium` | Dimensions of the chip |
|
|
14
|
+
| `text` | `string` | `''` | Label text rendered inside the chip |
|
|
15
|
+
| `textI18n` | `string` | — | i18n translation key for the label text |
|
|
16
|
+
| `icon` | `string` | — | Leading icon (Iconify icon ID or image URL) |
|
|
17
|
+
| `clickable` | `boolean` | `false` | Enable click interaction styles and click event |
|
|
18
|
+
| `deletable` | `boolean` | `false` | Show a delete (×) button and emit delete event |
|
|
19
|
+
| `disabled` | `boolean` | `false` | Disable all interactions and apply muted styling |
|
|
20
|
+
| `class` | `string` | `''` | Additional CSS classes applied to the root |
|
|
21
|
+
|
|
22
|
+
### Slots
|
|
23
|
+
|
|
24
|
+
| Slot | Description |
|
|
25
|
+
| :----- | :---------------------------------------------------------------------------------- |
|
|
26
|
+
| `icon` | Override the default icon area (rendered before the text) |
|
|
27
|
+
| `default` | Override the label content (rendered inside the text `<span>`) |
|
|
28
|
+
|
|
29
|
+
### Events
|
|
30
|
+
|
|
31
|
+
| Event | Payload | Condition | Description |
|
|
32
|
+
| :-------- | :----------- | :----------------------- | :-------------------------------------- |
|
|
33
|
+
| `click` | `MouseEvent` | Requires `clickable` | Fired when the chip is clicked |
|
|
34
|
+
| `delete` | `MouseEvent` | Requires `deletable` | Fired when the delete button is clicked |
|
|
35
|
+
|
|
36
|
+
### Keyboard Support
|
|
37
|
+
|
|
38
|
+
| Key | Action |
|
|
39
|
+
| :-------------------- | :------------------------------------------------ |
|
|
40
|
+
| `Enter` / `Space` | Triggers `click` event when `clickable` is `true` |
|
|
41
|
+
| `Backspace` / `Delete`| Triggers `delete` event when `deletable` is `true`|
|
|
42
|
+
|
|
43
|
+
### Types
|
|
44
|
+
```ts
|
|
45
|
+
type ChipVariant =
|
|
46
|
+
| 'solid'
|
|
47
|
+
| 'outline'
|
|
48
|
+
| 'ghost'
|
|
49
|
+
| 'subtle'
|
|
50
|
+
| 'secondary'
|
|
51
|
+
| 'success'
|
|
52
|
+
| 'warning'
|
|
53
|
+
| 'danger'
|
|
54
|
+
| 'info'
|
|
55
|
+
| 'purple'
|
|
56
|
+
| 'teal'
|
|
57
|
+
| 'indigo'
|
|
58
|
+
| 'orange'
|
|
59
|
+
| 'pink'
|
|
60
|
+
| 'cyan'
|
|
61
|
+
|
|
62
|
+
type ChipAppearance = 'filled' | 'transparent'
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Appearance
|
|
66
|
+
|
|
67
|
+
| Value | Description |
|
|
68
|
+
| :------------ | :-------------------------------------------------------------------------- |
|
|
69
|
+
| `filled` | Default. Applies the variant’s background, border, and text colors |
|
|
70
|
+
| `transparent` | Keeps the variant’s semantic text/icon color with no background or border |
|
|
71
|
+
|
|
72
|
+
`appearance="transparent"` works with every `variant` (standard, semantic, and extended). Hover / disabled / focus states stay clear without restoring a filled surface. Text, icons, and the delete control inherit the semantic foreground color.
|
|
73
|
+
|
|
74
|
+
### Variants
|
|
75
|
+
|
|
76
|
+
| Value | Description |
|
|
77
|
+
| :---------- | :----------------------------------------------------------------- |
|
|
78
|
+
| `solid` | Filled primary background with primary foreground text |
|
|
79
|
+
| `outline` | Transparent background with visible border |
|
|
80
|
+
| `ghost` | No border, no background — muted foreground text |
|
|
81
|
+
| `subtle` | Light accent background, no border (default) |
|
|
82
|
+
| `secondary` | Secondary semantic color (subtle background + border) |
|
|
83
|
+
| `success` | Green semantic color |
|
|
84
|
+
| `warning` | Amber/yellow semantic color |
|
|
85
|
+
| `danger` | Red semantic color |
|
|
86
|
+
| `info` | Blue semantic color |
|
|
87
|
+
| `purple` | Purple extended semantic color |
|
|
88
|
+
| `teal` | Teal extended semantic color |
|
|
89
|
+
| `indigo` | Indigo extended semantic color |
|
|
90
|
+
| `orange` | Orange extended semantic color |
|
|
91
|
+
| `pink` | Pink extended semantic color |
|
|
92
|
+
| `cyan` | Cyan extended semantic color |
|
|
93
|
+
|
|
94
|
+
> The `variant` prop also accepts any `string` to support dynamic or custom extended themes.
|
|
95
|
+
|
|
96
|
+
### Usage
|
|
97
|
+
```vue
|
|
98
|
+
<!-- Basic -->
|
|
99
|
+
<Chip text="Vue" variant="subtle" />
|
|
100
|
+
|
|
101
|
+
<!-- Semantic colors (filled — default) -->
|
|
102
|
+
<Chip text="Active" variant="success" icon="lucide:check" />
|
|
103
|
+
<Chip text="Failed" variant="danger" icon="lucide:x-circle" />
|
|
104
|
+
|
|
105
|
+
<!-- Transparent — semantic color on text/icon only -->
|
|
106
|
+
<Chip text="Active" variant="success" appearance="transparent" icon="lucide:check" />
|
|
107
|
+
<Chip text="Failed" variant="danger" appearance="transparent" icon="lucide:x-circle" />
|
|
108
|
+
|
|
109
|
+
<!-- Sizes -->
|
|
110
|
+
<Chip text="Extra Small" size="xsmall" />
|
|
111
|
+
<Chip text="Small" size="small" />
|
|
112
|
+
<Chip text="Large" size="large" />
|
|
113
|
+
|
|
114
|
+
<!-- Clickable -->
|
|
115
|
+
<Chip text="Filter" variant="outline" clickable @click="onSelect" />
|
|
116
|
+
|
|
117
|
+
<!-- Deletable -->
|
|
118
|
+
<Chip text="Tag" variant="secondary" deletable @delete="onRemove" />
|
|
119
|
+
|
|
120
|
+
<!-- Clickable + Deletable -->
|
|
121
|
+
<Chip text="Mixed" clickable deletable @click="onSelect" @delete="onRemove" />
|
|
122
|
+
|
|
123
|
+
<!-- Disabled -->
|
|
124
|
+
<Chip text="Inactive" disabled />
|
|
125
|
+
|
|
126
|
+
<!-- Icon only -->
|
|
127
|
+
<Chip icon="lucide:bell" variant="outline" />
|
|
128
|
+
|
|
129
|
+
<!-- Custom slot content -->
|
|
130
|
+
<Chip variant="subtle">
|
|
131
|
+
<template #icon>
|
|
132
|
+
<img src="/avatar.png" class="w-3.5 h-3.5 rounded-full" />
|
|
133
|
+
</template>
|
|
134
|
+
Jane Doe
|
|
135
|
+
</Chip>
|
|
136
|
+
```
|
|
137
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# ChoiceBox
|
|
2
|
+
|
|
3
|
+
**Import:** `import { ChoiceBox, type ChoiceBoxOption } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
### Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
| :---------------- | :------------------------------------------------- | :------ | :------------------------ |
|
|
9
|
+
| `modelValue` | `string \| number \| (string \| number)[] \| null` | — | Selection binding |
|
|
10
|
+
| `options` | `ChoiceBoxOption[]` | — | Data source |
|
|
11
|
+
| `multiple` | `boolean` | `false` | Allow multiple selections |
|
|
12
|
+
| `title` | `string` | — | Group title |
|
|
13
|
+
| `titleI18n` | `string` | — | I18n key for group title |
|
|
14
|
+
| `description` | `string` | — | Group description |
|
|
15
|
+
| `descriptionI18n` | `string` | — | I18n key for description |
|
|
16
|
+
| `grid` | `number` | `1` | Grid columns (1-4) |
|
|
17
|
+
| `gap` | `number` | `4` | Gap size (2, 3, 4, 6, 8) |
|
|
18
|
+
| `disabled` | `boolean` | `false` | Disable all options |
|
|
19
|
+
|
|
20
|
+
### Types
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
export interface ChoiceBoxOption {
|
|
24
|
+
id: string | number
|
|
25
|
+
title: string
|
|
26
|
+
titleI18n?: string
|
|
27
|
+
description?: string
|
|
28
|
+
descriptionI18n?: string
|
|
29
|
+
icon?: string
|
|
30
|
+
disabled?: boolean
|
|
31
|
+
badge?: string
|
|
32
|
+
badgeI18n?: string
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Usage
|
|
37
|
+
|
|
38
|
+
```vue
|
|
39
|
+
<ChoiceBox v-model="selectedPlan" :options="plans" title="Choose Plan" :grid="3" />
|
|
40
|
+
```
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Clipboard
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Clipboard } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
The `Clipboard` component standardizes copy-button presentation and feedback. Use direct text mode for static values the component can write itself, or external action mode when the consuming project owns content generation, redaction, loading, clipboard writing, notifications, or other copy orchestration.
|
|
6
|
+
|
|
7
|
+
### Success contract
|
|
8
|
+
|
|
9
|
+
- A resolved `void` or `true` action result is successful.
|
|
10
|
+
- A resolved `false` result is unsuccessful and does not show copied feedback.
|
|
11
|
+
- A synchronous throw or rejected promise emits `error` and does not show copied feedback.
|
|
12
|
+
- While an action is pending, the button shows its loading state and ignores duplicate clicks.
|
|
13
|
+
|
|
14
|
+
If both `action` and `textToCopy` are supplied, `action` takes precedence.
|
|
15
|
+
|
|
16
|
+
### Props
|
|
17
|
+
|
|
18
|
+
| Prop | Type | Default | Description |
|
|
19
|
+
| :--- | :--- | :--- | :--- |
|
|
20
|
+
| `textToCopy` | `string` | — | Direct mode: exact content written by the component |
|
|
21
|
+
| `action` | `() => boolean \| void \| Promise<boolean \| void>` | — | External mode: project-owned copy action |
|
|
22
|
+
| `variant` | `ButtonVariant` | `outline` | Visual style of the button |
|
|
23
|
+
| `size` | `ButtonSize` | `md` | Dimensions |
|
|
24
|
+
| `rounded` | `ButtonRounded` | `full` | Border radius |
|
|
25
|
+
| `defaultIcon` | `string` | `lucide:copy` | Icon shown in the default state |
|
|
26
|
+
| `copiedIcon` | `string` | `lucide:check` | Icon shown after confirmed success |
|
|
27
|
+
| `defaultText` | `string` | — | Custom default label |
|
|
28
|
+
| `copiedText` | `string` | — | Custom successful label |
|
|
29
|
+
| `defaultTextI18n` | `string` | `vlite.clipboard.copy` | I18n key for the default label |
|
|
30
|
+
| `copiedTextI18n` | `string` | `vlite.clipboard.copied` | I18n key for the successful label |
|
|
31
|
+
| `confirmationDuration` | `number` | `1500` | Successful-feedback duration in milliseconds |
|
|
32
|
+
| `asIcon` | `boolean` | `false` | Render an icon-only button |
|
|
33
|
+
| `dir` | `'ltr' \| 'rtl' \| 'auto'` | `auto` | Text/icon direction passed to Button |
|
|
34
|
+
| `disabled` | `boolean` | `false` | Disable interaction |
|
|
35
|
+
| `class` | `any` | — | Custom CSS classes |
|
|
36
|
+
|
|
37
|
+
At least one of `textToCopy` or `action` is required for an interactive button.
|
|
38
|
+
|
|
39
|
+
### Events
|
|
40
|
+
|
|
41
|
+
| Event | Payload | Description |
|
|
42
|
+
| :--- | :--- | :--- |
|
|
43
|
+
| `copy` | `string \| undefined` | Emitted after confirmed success; direct mode includes the copied text |
|
|
44
|
+
| `error` | `Error` | Emitted when direct copying fails or an external action throws/rejects |
|
|
45
|
+
|
|
46
|
+
### Default slot
|
|
47
|
+
|
|
48
|
+
The default slot receives `{ copied, loading }`. When supplied, it replaces the component's text label while keeping the standard icon, loading, and confirmation behavior.
|
|
49
|
+
|
|
50
|
+
### Usage
|
|
51
|
+
|
|
52
|
+
#### Direct text mode
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<Clipboard text-to-copy="npm install vlite3" />
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### External action mode
|
|
59
|
+
|
|
60
|
+
Keep project-specific generation and clipboard behavior in the project action:
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<script setup lang="ts">
|
|
64
|
+
async function copySelected(): Promise<boolean> {
|
|
65
|
+
const output = await generateAndRedactSelection()
|
|
66
|
+
return writeProjectClipboard(output)
|
|
67
|
+
}
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<template>
|
|
71
|
+
<Clipboard :action="copySelected" default-text="Copy output" />
|
|
72
|
+
</template>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### Row-specific action
|
|
76
|
+
|
|
77
|
+
```vue
|
|
78
|
+
<Clipboard :action="() => copyUrl(request)" as-icon />
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### Icon only
|
|
82
|
+
|
|
83
|
+
Icon-only buttons use the copy icon by default, the check icon after success, and an accessible label derived from the current state.
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<Clipboard text-to-copy="Secret API Key" as-icon rounded="full" />
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
#### Custom text, icons, and duration
|
|
90
|
+
|
|
91
|
+
```vue
|
|
92
|
+
<Clipboard
|
|
93
|
+
text-to-copy="https://example.com/share/123"
|
|
94
|
+
default-text="Copy Link"
|
|
95
|
+
copied-text="Link Copied!"
|
|
96
|
+
default-icon="lucide:link"
|
|
97
|
+
copied-icon="lucide:check-circle"
|
|
98
|
+
:confirmation-duration="2500"
|
|
99
|
+
variant="secondary"
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### RTL
|
|
104
|
+
|
|
105
|
+
Clipboard is built on `Button`, so labeled controls inherit the page or nearest ancestor `dir`. Under `html[dir=rtl]`, the icon sits at inline-start. Inside a `dir="ltr"` island, the control remains LTR with the surrounding strip.
|