vlite3 1.5.12 → 1.5.13
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/Dropdown/DropdownMenu.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 +17 -0
- package/docs/all-components.md +89 -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 +339 -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
- /package/components/Dropdown/{DropdownMenu2.vue.js → DropdownMenu3.vue.js} +0 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
# SidebarMenu
|
|
2
|
+
|
|
3
|
+
**Import:** `import { SidebarMenu } from 'vlite3'`
|
|
4
|
+
**Types:** `import type { SidebarMenuItemSchema } from 'vlite3'`
|
|
5
|
+
|
|
6
|
+
`SidebarMenu` is a recursive, fully accessible navigation menu that renders a tree of items. It supports nested children (unlimited depth), popovers, compact icon-only mode, horizontal layout, responsive breakpoints, badges, disabled states, custom actions, and deep integration with the `Navbar` component's `renderNestedTabs` feature.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Props
|
|
11
|
+
|
|
12
|
+
| Prop | Type | Default | Description |
|
|
13
|
+
| :-------------------- | :----------------------------------------- | :--------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
14
|
+
| `items` | `SidebarMenuItemSchema[]` | `[]` | The full menu data structure. Supports unlimited nesting via the `children` field. |
|
|
15
|
+
| `allowMultiple` | `boolean` | `true` | When `true`, multiple submenu groups can be open simultaneously. When `false`, opening one group collapses all others. |
|
|
16
|
+
| `defaultExpanded` | `string[]` | `[]` | Array of item IDs (or label strings if no `id` is set) that are expanded by default on mount. |
|
|
17
|
+
| `indentSize` | `number` | `12` | Pixel amount of left indentation added per nesting level. |
|
|
18
|
+
| `variant` | `'default' \| 'ghost'` | `'default'` | Visual theme. `default` shows a vertical line connector between parent and children. `ghost` renders without the connector. |
|
|
19
|
+
| `compact` | `boolean` | `false` | Collapses the menu to icon-only mode. Labels are hidden; icons are centered. Popover mode is forced for all items with children. |
|
|
20
|
+
| `showCompactLabels` | `boolean` | `false` | When `compact` is `true`, renders small labels beneath each icon. |
|
|
21
|
+
| `renderMode` | `'tree' \| 'popover'` | `'tree'` | Global submenu rendering strategy. `tree` expands children inline. `popover` renders children in a floating `Dropdown`. Overridable per item via `SidebarMenuItemSchema.renderMode`. |
|
|
22
|
+
| `orientation` | `'vertical' \| 'horizontal'` | `'vertical'` | Layout direction. `horizontal` places top-level items in a row and forces `popover` mode for items with children. |
|
|
23
|
+
| `mobileBreakpoint` | `'sm' \| 'md' \| 'lg' \| 'xl' \| 'none'` | `'none'` | When set (not `'none'`), the menu switches from `orientation` to `'vertical'` on screens smaller than the specified breakpoint. |
|
|
24
|
+
| `showTooltip` | `boolean` | `true` | Enables a tooltip showing the item label in `compact` or `horizontal` modes. |
|
|
25
|
+
| `iconSize` | `string` | `'16px'` | CSS size string applied to icon width/height in normal mode. |
|
|
26
|
+
| `compactIconSize` | `string` | `'20px'` | CSS size string for icons when `compact` is `true`. |
|
|
27
|
+
| `labelClass` | `string` | `'text-sm'` | Tailwind class(es) applied to item labels in normal mode. |
|
|
28
|
+
| `compactLabelClass` | `string` | `'text-[11.5px] mt-1'` | Tailwind class(es) applied to labels when `compact` and `showCompactLabels` are both `true`. |
|
|
29
|
+
| `itemPadding` | `string` | `'py-2 px-2'` | Tailwind padding classes applied to each item in normal mode. |
|
|
30
|
+
| `compactItemPadding` | `string` | `'py-2 px-1'` | Tailwind padding classes applied to each item in compact mode. |
|
|
31
|
+
| `nestedMenuWidth` | `string` | `'220px'` | CSS width of the floating popover menu for children. |
|
|
32
|
+
| `nestedMenuMaxHeight` | `string` | `'300px'` | CSS max-height of the floating popover menu. Content scrolls beyond this height. |
|
|
33
|
+
| `itemClass` | `string` | `''` | Additional CSS class(es) appended to every menu item element. |
|
|
34
|
+
| `menuOffset` | `[number, number]` | `[0, 10]` | `[x, y]` pixel offset for the popover menu position relative to its trigger. |
|
|
35
|
+
|
|
36
|
+
---
|
|
37
|
+
|
|
38
|
+
## Type Definition
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
interface SidebarMenuItemSchema {
|
|
42
|
+
id?: string
|
|
43
|
+
// Unique identifier for expand/active tracking. Falls back to `to` then `label`.
|
|
44
|
+
|
|
45
|
+
label: string
|
|
46
|
+
// Display text shown in the menu.
|
|
47
|
+
|
|
48
|
+
labelI18n?: string
|
|
49
|
+
// i18n translation key. Overrides `label` if provided.
|
|
50
|
+
|
|
51
|
+
icon?: string
|
|
52
|
+
// Icon identifier string (e.g. 'lucide:home'). Rendered via <Icon>.
|
|
53
|
+
|
|
54
|
+
to?: string | { path: string; [key: string]: any }
|
|
55
|
+
// Vue Router navigation target. Renders as <router-link>.
|
|
56
|
+
|
|
57
|
+
href?: string
|
|
58
|
+
// External URL. Renders as <a target="_blank" rel="noopener noreferrer">.
|
|
59
|
+
|
|
60
|
+
children?: SidebarMenuItemSchema[]
|
|
61
|
+
// Nested submenu items (unlimited depth).
|
|
62
|
+
|
|
63
|
+
badge?: string | number
|
|
64
|
+
// Badge content shown to the right of the label (e.g. 'New', 3).
|
|
65
|
+
|
|
66
|
+
badgeClass?: string
|
|
67
|
+
// Tailwind classes applied to the badge element.
|
|
68
|
+
// Default: 'bg-muted text-muted-foreground'
|
|
69
|
+
|
|
70
|
+
disabled?: boolean
|
|
71
|
+
// Disables the item. Applies opacity-50 and pointer-events-none.
|
|
72
|
+
|
|
73
|
+
renderMode?: 'tree' | 'popover'
|
|
74
|
+
// Per-item override of the global renderMode prop.
|
|
75
|
+
|
|
76
|
+
action?: (item: SidebarMenuItemSchema) => void
|
|
77
|
+
// Custom click handler called in addition to routing/navigation.
|
|
78
|
+
// If the item has no `to` or `href`, this is the sole click behavior.
|
|
79
|
+
|
|
80
|
+
class?: string
|
|
81
|
+
// Additional CSS class(es) applied to this specific item's container.
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Internal Architecture
|
|
88
|
+
|
|
89
|
+
### Context (provide/inject)
|
|
90
|
+
|
|
91
|
+
`SidebarMenu` provides `sidebar-menu-ctx` to all `SidebarMenuItem` descendants:
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
interface SidebarMenuContext {
|
|
95
|
+
activeItem: string | null
|
|
96
|
+
expandedItems: string[]
|
|
97
|
+
toggleExpand: (id: string) => void
|
|
98
|
+
setActive: (id: string | null) => void
|
|
99
|
+
indentSize: number
|
|
100
|
+
variant: 'default' | 'ghost'
|
|
101
|
+
renderMode: 'tree' | 'popover'
|
|
102
|
+
renderNestedTabs: boolean // From injected Navbar context
|
|
103
|
+
compact: boolean
|
|
104
|
+
showCompactLabels: boolean
|
|
105
|
+
iconSize: string
|
|
106
|
+
compactIconSize: string
|
|
107
|
+
labelClass: string
|
|
108
|
+
compactLabelClass: string
|
|
109
|
+
itemPadding: string
|
|
110
|
+
compactItemPadding: string
|
|
111
|
+
nestedMenuWidth: string
|
|
112
|
+
nestedMenuMaxHeight: string
|
|
113
|
+
currentOrientation: 'vertical' | 'horizontal'
|
|
114
|
+
showTooltip: boolean
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Route Synchronization
|
|
119
|
+
|
|
120
|
+
`SidebarMenu` watches `useRoute().path` and calls `syncWithRoute()` on every path change:
|
|
121
|
+
|
|
122
|
+
1. Recursively traverses the `items` tree.
|
|
123
|
+
2. Sets `activeItem` to the matching item's ID.
|
|
124
|
+
3. Pushes all ancestor IDs into `expandedItems` so parent groups auto-expand to reveal the active child.
|
|
125
|
+
|
|
126
|
+
Matching logic: exact path match OR prefix match (non-root, boundary-aware).
|
|
127
|
+
|
|
128
|
+
### `renderNestedTabs` Integration
|
|
129
|
+
|
|
130
|
+
When the parent `Navbar` has `renderNestedTabs="true"`:
|
|
131
|
+
|
|
132
|
+
- Clicking a top-level item calls `navbarCtx.setNestedTabs()` with its children mapped to `NavbarTabItem[]`.
|
|
133
|
+
- The `Navbar` renders these as a `NavbarTabs` bar at the top of `#main`.
|
|
134
|
+
- The inline chevron expand behavior is suppressed for depth-0 items.
|
|
135
|
+
|
|
136
|
+
### Render Mode Decision (per item, priority order)
|
|
137
|
+
|
|
138
|
+
1. If `isHorizontal` (depth 0) AND has children → **popover**
|
|
139
|
+
2. If `compact` AND has children → **popover**
|
|
140
|
+
3. If `renderNestedTabs` AND depth 0 → **tree** (chevron suppressed)
|
|
141
|
+
4. Item's own `renderMode` field (if set)
|
|
142
|
+
5. Global `renderMode` prop
|
|
143
|
+
|
|
144
|
+
### Smooth Expand/Collapse Animation
|
|
145
|
+
|
|
146
|
+
Tree-mode child groups use Vue `<Transition>` with JS hooks (`before-enter`, `enter`, `after-enter`, `before-leave`, `leave`) for smooth `height` + `opacity` animation — works for any content size.
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Usage
|
|
151
|
+
|
|
152
|
+
### Basic Vertical Menu
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<script setup>
|
|
156
|
+
import { SidebarMenu } from 'vlite3'
|
|
157
|
+
import type { SidebarMenuItemSchema } from 'vlite3'
|
|
158
|
+
|
|
159
|
+
const items: SidebarMenuItemSchema[] = [
|
|
160
|
+
{ label: 'Dashboard', icon: 'lucide:layout-dashboard', to: '/dashboard' },
|
|
161
|
+
{
|
|
162
|
+
label: 'Projects',
|
|
163
|
+
icon: 'lucide:folder',
|
|
164
|
+
children: [
|
|
165
|
+
{ label: 'Active', to: '/projects/active' },
|
|
166
|
+
{ label: 'Archived', to: '/projects/archived' },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
{ label: 'Settings', icon: 'lucide:settings', to: '/settings' },
|
|
170
|
+
]
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<template>
|
|
174
|
+
<SidebarMenu :items="items" />
|
|
175
|
+
</template>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### With Badges, Disabled Items, and Custom Actions
|
|
179
|
+
|
|
180
|
+
```vue
|
|
181
|
+
<SidebarMenu
|
|
182
|
+
:items="[
|
|
183
|
+
{
|
|
184
|
+
label: 'Inbox',
|
|
185
|
+
icon: 'lucide:inbox',
|
|
186
|
+
to: '/inbox',
|
|
187
|
+
badge: 12,
|
|
188
|
+
badgeClass: 'bg-primary/10 text-primary',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
label: 'Reports',
|
|
192
|
+
icon: 'lucide:bar-chart',
|
|
193
|
+
to: '/reports',
|
|
194
|
+
badge: 'New',
|
|
195
|
+
badgeClass: 'bg-green-100 text-green-700',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
label: 'Admin Panel',
|
|
199
|
+
icon: 'lucide:shield',
|
|
200
|
+
to: '/admin',
|
|
201
|
+
disabled: true,
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
label: 'Help & Support',
|
|
205
|
+
icon: 'lucide:life-buoy',
|
|
206
|
+
action: (item) => openHelpDrawer(),
|
|
207
|
+
},
|
|
208
|
+
]" />
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Popover Mode for Nested Items
|
|
212
|
+
|
|
213
|
+
```vue
|
|
214
|
+
<SidebarMenu
|
|
215
|
+
:items="[
|
|
216
|
+
{
|
|
217
|
+
label: 'Analytics',
|
|
218
|
+
icon: 'lucide:bar-chart-3',
|
|
219
|
+
renderMode: 'popover',
|
|
220
|
+
children: [
|
|
221
|
+
{ label: 'Overview', to: '/analytics/overview' },
|
|
222
|
+
{ label: 'Performance', to: '/analytics/performance' },
|
|
223
|
+
{ label: 'Real-time', to: '/analytics/realtime' },
|
|
224
|
+
],
|
|
225
|
+
},
|
|
226
|
+
]" />
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Compact (Icon-Only) Mode
|
|
230
|
+
|
|
231
|
+
```vue
|
|
232
|
+
<!-- Icons only — no labels -->
|
|
233
|
+
<SidebarMenu :items="items" :compact="true" compact-icon-size="22px" />
|
|
234
|
+
|
|
235
|
+
<!-- Icons + small labels below -->
|
|
236
|
+
<SidebarMenu
|
|
237
|
+
:items="items"
|
|
238
|
+
:compact="true"
|
|
239
|
+
:show-compact-labels="true"
|
|
240
|
+
compact-icon-size="20px"
|
|
241
|
+
compact-label-class="text-[10px] mt-1" />
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Horizontal Navigation (Responsive)
|
|
245
|
+
|
|
246
|
+
```vue
|
|
247
|
+
<!-- Horizontal on md+ screens, collapses to vertical on smaller screens -->
|
|
248
|
+
<SidebarMenu
|
|
249
|
+
:items="items"
|
|
250
|
+
orientation="horizontal"
|
|
251
|
+
mobile-breakpoint="md"
|
|
252
|
+
icon-size="16px"
|
|
253
|
+
:show-tooltip="false" />
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Default Expanded Groups
|
|
257
|
+
|
|
258
|
+
```vue
|
|
259
|
+
<!-- Open by label string -->
|
|
260
|
+
<SidebarMenu :items="items" :default-expanded="['Projects', 'Settings']" />
|
|
261
|
+
|
|
262
|
+
<!-- Open by item ID (preferred) -->
|
|
263
|
+
<SidebarMenu
|
|
264
|
+
:items="[
|
|
265
|
+
{ id: 'proj', label: 'Projects', children: [...] },
|
|
266
|
+
{ id: 'cfg', label: 'Config', children: [...] },
|
|
267
|
+
]"
|
|
268
|
+
:default-expanded="['proj']" />
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Prevent Multiple Open Groups
|
|
272
|
+
|
|
273
|
+
```vue
|
|
274
|
+
<SidebarMenu :items="items" :allow-multiple="false" />
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Mixed Render Modes
|
|
278
|
+
|
|
279
|
+
```vue
|
|
280
|
+
<SidebarMenu
|
|
281
|
+
:items="[
|
|
282
|
+
{
|
|
283
|
+
label: 'Products',
|
|
284
|
+
icon: 'lucide:package',
|
|
285
|
+
renderMode: 'popover',
|
|
286
|
+
children: [
|
|
287
|
+
{ label: 'All Products', to: '/products' },
|
|
288
|
+
{ label: 'Categories', to: '/products/categories' },
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
label: 'Settings',
|
|
293
|
+
icon: 'lucide:settings',
|
|
294
|
+
children: [
|
|
295
|
+
{ label: 'Account', to: '/settings/account' },
|
|
296
|
+
{ label: 'Billing', to: '/settings/billing' },
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
]"
|
|
300
|
+
render-mode="tree" />
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
### Custom Sizing and Padding
|
|
304
|
+
|
|
305
|
+
```vue
|
|
306
|
+
<SidebarMenu
|
|
307
|
+
:items="items"
|
|
308
|
+
icon-size="20px"
|
|
309
|
+
compact-icon-size="26px"
|
|
310
|
+
label-class="text-base font-medium"
|
|
311
|
+
compact-label-class="text-[11px] mt-1.5"
|
|
312
|
+
item-padding="py-2.5 px-3"
|
|
313
|
+
compact-item-padding="py-3 px-1.5"
|
|
314
|
+
:indent-size="16" />
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Inside Navbar (Full App Shell)
|
|
318
|
+
|
|
319
|
+
```vue
|
|
320
|
+
<Navbar variant="sidebar">
|
|
321
|
+
<template #header="{ toggle }">
|
|
322
|
+
<div class="h-16 border-b flex items-center px-6">
|
|
323
|
+
<button class="md:hidden" @click="toggle">
|
|
324
|
+
<Icon icon="lucide:menu" />
|
|
325
|
+
</button>
|
|
326
|
+
<span class="font-bold">MyApp</span>
|
|
327
|
+
</div>
|
|
328
|
+
</template>
|
|
329
|
+
|
|
330
|
+
<template #default>
|
|
331
|
+
<!-- SidebarMenu automatically receives compact and renderNestedTabs
|
|
332
|
+
context from Navbar via provide/inject -->
|
|
333
|
+
<SidebarMenu
|
|
334
|
+
:items="menuItems"
|
|
335
|
+
:default-expanded="['Dashboard']"
|
|
336
|
+
icon-size="18px" />
|
|
337
|
+
</template>
|
|
338
|
+
|
|
339
|
+
<template #main>
|
|
340
|
+
<RouterView />
|
|
341
|
+
</template>
|
|
342
|
+
</Navbar>
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
### External Links
|
|
346
|
+
|
|
347
|
+
```vue
|
|
348
|
+
<SidebarMenu
|
|
349
|
+
:items="[
|
|
350
|
+
{ label: 'GitHub', icon: 'lucide:github', href: 'https://github.com/my-org/my-repo' },
|
|
351
|
+
{ label: 'Status Page', icon: 'lucide:activity', href: 'https://status.example.com' },
|
|
352
|
+
]" />
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
### i18n Labels
|
|
356
|
+
|
|
357
|
+
```vue
|
|
358
|
+
<SidebarMenu
|
|
359
|
+
:items="[
|
|
360
|
+
{
|
|
361
|
+
label: 'Dashboard',
|
|
362
|
+
labelI18n: 'nav.dashboard',
|
|
363
|
+
icon: 'lucide:layout-dashboard',
|
|
364
|
+
to: '/dashboard',
|
|
365
|
+
},
|
|
366
|
+
{
|
|
367
|
+
label: 'Settings',
|
|
368
|
+
labelI18n: 'nav.settings',
|
|
369
|
+
icon: 'lucide:settings',
|
|
370
|
+
to: '/settings',
|
|
371
|
+
},
|
|
372
|
+
]" />
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## SidebarMenuItem (Internal)
|
|
378
|
+
|
|
379
|
+
**Import:** `import { SidebarMenuItem } from 'vlite3'`
|
|
380
|
+
|
|
381
|
+
The recursive building block used internally. Reads all configuration from `sidebar-menu-ctx` injected by `SidebarMenu`. Direct use outside a `SidebarMenu` wrapper will throw a runtime error.
|
|
382
|
+
|
|
383
|
+
### SidebarMenuItem Props
|
|
384
|
+
|
|
385
|
+
| Prop | Type | Default | Description |
|
|
386
|
+
| :----------- | :---------------------- | :-------- | :------------------------------------------------------------------------------------------------------ |
|
|
387
|
+
| `item` | `SidebarMenuItemSchema` | required | The menu item data object to render. |
|
|
388
|
+
| `depth` | `number` | `0` | Current nesting depth, used for indent calculation. Incremented automatically for each recursive child. |
|
|
389
|
+
| `menuOffset` | `[number, number]` | `[0, 10]` | Popover offset, forwarded from `SidebarMenu`. |
|
|
390
|
+
| `itemClass` | `string` | `''` | Additional class(es) appended to the item element. |
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
## Accessibility
|
|
395
|
+
|
|
396
|
+
- Root `<nav>` has `role="tree"` and `aria-label="Sidebar Menu"`.
|
|
397
|
+
- `<router-link>` / `<a>` items carry `aria-current="page"` when active.
|
|
398
|
+
- Expandable items carry `aria-expanded` reflecting open/closed state.
|
|
399
|
+
- Popover triggers carry `aria-haspopup="true"` and `aria-expanded`.
|
|
400
|
+
- Disabled items receive `tabindex="-1"` via `pointer-events-none`.
|
|
401
|
+
- Chevron expand buttons are independently focusable with `tabindex="0"` and respond to `Enter`/`Space`.
|
|
402
|
+
- `focus-visible:ring-1 focus-visible:ring-primary/50` on all interactive elements.
|
|
403
|
+
|
|
404
|
+
---
|
|
405
|
+
|
|
406
|
+
## RTL
|
|
407
|
+
|
|
408
|
+
Under `html[dir=rtl]`:
|
|
409
|
+
|
|
410
|
+
- Nested indent and tree connectors use `margin-inline-start` / `inset-inline-start`
|
|
411
|
+
- Expand / drilldown chevrons point toward inline-end (`chevron-left` in RTL)
|
|
412
|
+
- Drilldown back control and slide transitions mirror with direction
|
|
413
|
+
- Side popovers / tooltips open toward the content (`left-start` / `left` in RTL)
|
|
414
|
+
|
|
415
|
+
## Notes & Best Practices
|
|
416
|
+
|
|
417
|
+
- **Prefer `id` over relying on `label` for `defaultExpanded`** — labels can change; IDs are stable.
|
|
418
|
+
- In `horizontal` mode, items with children always use `popover` regardless of `renderMode`.
|
|
419
|
+
- `compact` mode is best combined with a parent container having a fixed narrow width (e.g. `w-20`). `Navbar` does this automatically.
|
|
420
|
+
- The `action` callback fires on every click (before routing). Use it for side effects — not as a replacement for `to`/`href` navigation.
|
|
421
|
+
- `mobileBreakpoint` is independent of the parent `Navbar`'s `mobileBreakpoint`. They should typically match to avoid layout inconsistencies.
|
|
422
|
+
- When `renderMode="popover"` is used globally, deep nesting beyond 2 levels can be confusing. Consider flattening data or using `tree` mode for deeply nested structures.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Skeleton
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Skeleton } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
Pixel-perfect skeleton loading screens generated directly from your real UI layout. Instead of manually configuring heights, widths, and border radii, the `Skeleton` component derives them automatically from the actual elements.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## ⚠️ Performance & Best Practices (CRITICAL)
|
|
10
|
+
|
|
11
|
+
To maintain 60fps and prevent CPU spikes in large applications, you **must** choose the correct rendering strategy based on your use case.
|
|
12
|
+
|
|
13
|
+
### 1. Lists and `v-for` Loops (The 20+ Component Scenario)
|
|
14
|
+
|
|
15
|
+
**🛑 NEVER use `auto` inside a loop.** If you render 20 items with `<Skeleton auto>`, the system will simultaneously perform 20 deep DOM traversals (`getBoundingClientRect`, `getComputedStyle`), causing severe layout thrashing and locking the main thread.
|
|
16
|
+
|
|
17
|
+
**✅ ALWAYS use `name` (Global Registry) for lists.**
|
|
18
|
+
Extract the skeleton once, register it, and pass the `name` prop. The component will skip DOM traversal entirely and stamp out the 20 VDOM nodes in milliseconds using a shared, cached memory reference.
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<Skeleton v-for="user in users" :key="user.id" :loading="isLoading" auto>
|
|
22
|
+
<UserCard :data="user" />
|
|
23
|
+
</Skeleton>
|
|
24
|
+
|
|
25
|
+
<Skeleton v-for="user in users" :key="user.id" :loading="isLoading" name="user-card">
|
|
26
|
+
<UserCard :data="user" />
|
|
27
|
+
</Skeleton>
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### 2. API Re-fetching & Reactivity
|
|
31
|
+
|
|
32
|
+
- **When using `name`:** Toggling `loading` from `false -> true` is instantaneous. It simply unhides the cached DOM nodes and resumes the CSS animation.
|
|
33
|
+
- **When using `auto`:** Toggling `loading` from `false -> true` forces a **brand new DOM snapshot**. It will capture the exact current state of the `#fixture`. Use this only for singular, complex layouts (like dynamic forms) that change shape over time.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### Props
|
|
38
|
+
|
|
39
|
+
| Prop | Type | Default | Description |
|
|
40
|
+
| :--------------- | :---------------------------------- | :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------- |
|
|
41
|
+
| `loading` | `boolean` | `false` | When true, displays the skeleton overlay. |
|
|
42
|
+
| `auto` | `boolean` | `false` | When true, automatically captures bones from the `#fixture` slot at runtime. Use ONLY for singular elements, NEVER in loops. |
|
|
43
|
+
| `name` | `string` | — | Unique identifier to resolve pre-generated bones from the global registry. MANDATORY for lists/loops. |
|
|
44
|
+
| `initialBones` | `SkeletonResult \| ResponsiveBones` | — | Pass pre-generated bone data directly, bypassing the registry. |
|
|
45
|
+
| `color` | `string` | `rgba(0, 0, 0, 0.03)` | Base color of the bones in light mode. |
|
|
46
|
+
| `darkColor` | `string` | `rgba(255, 255, 255, 0.05)` | Base color of the bones in dark mode. |
|
|
47
|
+
| `animate` | `AnimationStyle` | `'pulse'` | Visual animation style. Accepts `'pulse'`, `'shimmer'`, `'solid'`, or boolean. |
|
|
48
|
+
| `stagger` | `number \| boolean` | `false` | Stagger delay in milliseconds between bone animations (`true` = 80ms). |
|
|
49
|
+
| `transition` | `number \| boolean` | `false` | Fade-out duration in milliseconds when loading finishes (`true` = 300ms). |
|
|
50
|
+
| `snapshotConfig` | `SnapshotConfig` | — | Fine-grained configuration for how bones are extracted from the DOM. |
|
|
51
|
+
| `class` | `string` | — | Custom CSS classes applied to the root container. |
|
|
52
|
+
|
|
53
|
+
### Slots
|
|
54
|
+
|
|
55
|
+
| Slot | Description |
|
|
56
|
+
| :--------- | :----------------------------------------------------------------------------------------------------------- |
|
|
57
|
+
| `default` | Your actual component content. Rendered and visible when `loading` is false. |
|
|
58
|
+
| `fixture` | Mock content used to auto-generate bones when the `auto` prop is true. Rendered invisibly in the background. |
|
|
59
|
+
| `fallback` | Content shown when `loading` is true but no bone data is available (and `auto` is false). |
|
|
60
|
+
|
|
61
|
+
### Types
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
export type AnimationStyle = 'pulse' | 'shimmer' | 'solid' | boolean
|
|
65
|
+
|
|
66
|
+
export interface SnapshotConfig {
|
|
67
|
+
/** HTML tags always captured as a single atomic bone. */
|
|
68
|
+
leafTags?: string[]
|
|
69
|
+
/** Capture containers with visible borders + border-radius. */
|
|
70
|
+
captureRoundedBorders?: boolean
|
|
71
|
+
/** HTML tags to skip entirely. */
|
|
72
|
+
excludeTags?: string[]
|
|
73
|
+
/** CSS selectors to skip entirely. */
|
|
74
|
+
excludeSelectors?: string[]
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Usage
|
|
79
|
+
|
|
80
|
+
**1. Auto-Generated (Runtime Snapshotting)**
|
|
81
|
+
Best for single instances or complex dynamic forms. Do not use in lists.
|
|
82
|
+
|
|
83
|
+
```vue
|
|
84
|
+
<template>
|
|
85
|
+
<Skeleton :loading="isLoading" auto animate="shimmer" transition>
|
|
86
|
+
<ProfileCard :user="userData" />
|
|
87
|
+
</Skeleton>
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
**2. Pre-Generated (Using the Registry)**
|
|
92
|
+
MANDATORY for lists, data tables, and high-performance repeated cards.
|
|
93
|
+
|
|
94
|
+
```vue
|
|
95
|
+
<template>
|
|
96
|
+
<Skeleton name="profile-card" :loading="isLoading" stagger>
|
|
97
|
+
<ProfileCard :user="userData" />
|
|
98
|
+
</Skeleton>
|
|
99
|
+
</template>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
# 3. The Skeleton Loop Trap
|
|
103
|
+
|
|
104
|
+
**NEVER** use `<Skeleton auto>` inside a `v-for` loop.
|
|
105
|
+
|
|
106
|
+
- **Why:** The `auto` prop forces the browser to calculate `getBoundingClientRect` and `getComputedStyle` for every single nested element. Doing this synchronously across 20+ list items will cause severe layout thrashing and lock the main thread.
|
|
107
|
+
- **REQUIRED FIX:** Always pre-register the skeleton layout and use the `name` prop so the DOM nodes are stamped out from a cached memory reference.
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<Skeleton v-for="item in list" :key="item.id" auto>...</Skeleton>
|
|
111
|
+
|
|
112
|
+
<Skeleton v-for="item in list" :key="item.id" name="my-card">...</Skeleton>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
For data tables, lists, and repeated cards, ALWAYS use pre-generated bones via the name prop. This extracts the layout exactly once, caches it as a VDOM object, and reuses it for every item instantly (O(1) calculation complexity).
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Slider
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Slider } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
### Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
| :------------- | :----------------------------- | :------ | :------------------- |
|
|
9
|
+
| `modelValue` | `number` | `0` | Value binding |
|
|
10
|
+
| `min` | `number` | `0` | Minimum value |
|
|
11
|
+
| `max` | `number` | `100` | Maximum value |
|
|
12
|
+
| `step` | `number` | `1` | Step interval |
|
|
13
|
+
| `label` | `string` | — | Label text |
|
|
14
|
+
| `labelI18n` | `string` | — | I18n key for label |
|
|
15
|
+
| `labelClass` | `string` | — | CSS class for label |
|
|
16
|
+
| `valueClass` | `string` | — | CSS class for value |
|
|
17
|
+
| `icon` | `string` | — | Icon next to label |
|
|
18
|
+
| `showValue` | `boolean` | `true` | Show numerical value |
|
|
19
|
+
| `size` | `'xs' \| 'sm' \| 'md' \| 'lg'` | `md` | Dimensions |
|
|
20
|
+
| `variant` | `'one' \| 'two'` | `one` | Layout variant |
|
|
21
|
+
| `thumbVariant` | `'default' \| 'solid'` | `default`| Thumb style variant |
|
|
22
|
+
| `centerOrigin` | `boolean` | — | Force bipolar mode |
|
|
23
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `horizontal` | Slider orientation |
|
|
24
|
+
| `disabled` | `boolean` | `false` | Disable interaction |
|
|
25
|
+
|
|
26
|
+
### Events
|
|
27
|
+
|
|
28
|
+
- `@update:modelValue`: Emitted as value changes (v-model)
|
|
29
|
+
- `@change`: Emitted when change completes (drag end)
|
|
30
|
+
- `@iconClick`: Emitted when the label or icon wrapper is clicked
|
|
31
|
+
|
|
32
|
+
### Usage
|
|
33
|
+
|
|
34
|
+
```vue
|
|
35
|
+
<Slider label="Volume" v-model="volume" :max="100" />
|
|
36
|
+
<Slider label="Balance" v-model="balance" :min="-50" :max="50" icon="lucide:scale" />
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
#### RTL
|
|
40
|
+
|
|
41
|
+
Under `html[dir=rtl]` (horizontal orientation):
|
|
42
|
+
|
|
43
|
+
- Label sits on **inline-start** (right), value on **inline-end** (left)
|
|
44
|
+
- Track fill grows from the **right**; the thumb position mirrors with the value
|
|
45
|
+
- The native `<input type="range">` uses matching `dir="rtl"` so drag/click stay in sync with the painted thumb (moving left increases value)
|
|
46
|
+
- Bipolar origin tick and fill rounding use logical edges so they stay correct in both directions
|
|
47
|
+
|
|
48
|
+
Vertical orientation is unchanged by page direction.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
|
|
3
|
+
**Import:** `import { Spinner } from 'vlite3'`
|
|
4
|
+
|
|
5
|
+
### Props
|
|
6
|
+
|
|
7
|
+
| Prop | Type | Default | Description |
|
|
8
|
+
| :-------- | :--------------- | :-------- | :----------------- |
|
|
9
|
+
| `size` | `SpinnerSize` | `md` | Dimensions |
|
|
10
|
+
| `color` | `SpinnerColor` | `current` | Color theme |
|
|
11
|
+
| `variant` | `SpinnerVariant` | `border` | Visual style |
|
|
12
|
+
| `class` | `string` | — | Custom CSS classes |
|
|
13
|
+
|
|
14
|
+
### Types
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
type SpinnerSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl'
|
|
18
|
+
type SpinnerColor = 'current' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'white'
|
|
19
|
+
type SpinnerVariant = 'border' | 'dots' | 'bars' | 'ping'
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Usage
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<Spinner />
|
|
26
|
+
<Spinner variant="dots" size="lg" color="primary" />
|
|
27
|
+
```
|