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.
Files changed (127) hide show
  1. package/README.md +20 -8
  2. package/components/Accordion/AccordionContent.vue.js +2 -2
  3. package/components/CommandPalette/CommandPaletteContent2.vue.js +1 -1
  4. package/components/CommandPalette/{CommandPaletteItem2.vue.js → CommandPaletteItem.vue.js} +1 -1
  5. package/components/Dropdown/DropdownMenu.vue.js +1 -1
  6. package/components/Form/AccordionView2.vue.js +1 -1
  7. package/components/Form/Form.vue.js +2 -2
  8. package/components/NavbarCommandPalette.vue.js +1 -1
  9. package/components/PanZoomViewport/PanZoomViewport.vue.d.ts +7 -7
  10. package/components/PanZoomViewport/PanZoomViewport.vue.js +1 -1
  11. package/components/Tabes/Tabes.vue.js +2 -2
  12. package/docs/README.md +17 -0
  13. package/docs/all-components.md +89 -0
  14. package/docs/component-index.md +313 -0
  15. package/docs/components/accordion.md +52 -0
  16. package/docs/components/alert.md +34 -0
  17. package/docs/components/app-shell.md +371 -0
  18. package/docs/components/async-select.md +264 -0
  19. package/docs/components/attachments-list.md +231 -0
  20. package/docs/components/avatar-group.md +74 -0
  21. package/docs/components/avatar-uploader.md +61 -0
  22. package/docs/components/avatar.md +28 -0
  23. package/docs/components/badge.md +81 -0
  24. package/docs/components/barcode.md +42 -0
  25. package/docs/components/beacon.md +29 -0
  26. package/docs/components/breadcrumb.md +317 -0
  27. package/docs/components/button-group.md +35 -0
  28. package/docs/components/button.md +86 -0
  29. package/docs/components/calendar.md +95 -0
  30. package/docs/components/carousel.md +122 -0
  31. package/docs/components/cart.md +533 -0
  32. package/docs/components/category-manager.md +269 -0
  33. package/docs/components/category-menu.md +251 -0
  34. package/docs/components/charts.md +1456 -0
  35. package/docs/components/chat.md +330 -0
  36. package/docs/components/checkbox.md +31 -0
  37. package/docs/components/chip.md +137 -0
  38. package/docs/components/choice-box.md +40 -0
  39. package/docs/components/clipboard.md +105 -0
  40. package/docs/components/clock.md +70 -0
  41. package/docs/components/color-picker.md +82 -0
  42. package/docs/components/command-palette.md +214 -0
  43. package/docs/components/comment-thread.md +171 -0
  44. package/docs/components/confirmation-modal.md +50 -0
  45. package/docs/components/custom-fields-display.md +94 -0
  46. package/docs/components/custom-fields.md +97 -0
  47. package/docs/components/data-list.md +93 -0
  48. package/docs/components/data-table.md +922 -0
  49. package/docs/components/date-picker.md +58 -0
  50. package/docs/components/date-range-picker.md +24 -0
  51. package/docs/components/date-time.md +104 -0
  52. package/docs/components/dropdown.md +740 -0
  53. package/docs/components/empty.md +100 -0
  54. package/docs/components/export-data.md +320 -0
  55. package/docs/components/file-picker.md +83 -0
  56. package/docs/components/file-preview.md +42 -0
  57. package/docs/components/file-tree.md +144 -0
  58. package/docs/components/footer.md +251 -0
  59. package/docs/components/forms.md +776 -0
  60. package/docs/components/gantt-chart.md +767 -0
  61. package/docs/components/google-login.md +67 -0
  62. package/docs/components/google-map.md +128 -0
  63. package/docs/components/heatmap.md +80 -0
  64. package/docs/components/icon-picker.md +58 -0
  65. package/docs/components/icon.md +176 -0
  66. package/docs/components/image-comparison.md +51 -0
  67. package/docs/components/image-magnifier.md +26 -0
  68. package/docs/components/import-data.md +521 -0
  69. package/docs/components/input.md +58 -0
  70. package/docs/components/invoice.md +339 -0
  71. package/docs/components/kanban.md +302 -0
  72. package/docs/components/label.md +25 -0
  73. package/docs/components/list.md +419 -0
  74. package/docs/components/masonry.md +55 -0
  75. package/docs/components/modal.md +133 -0
  76. package/docs/components/multi-select.md +54 -0
  77. package/docs/components/navbar.md +403 -0
  78. package/docs/components/number-input.md +41 -0
  79. package/docs/components/otp-input.md +68 -0
  80. package/docs/components/pagination.md +83 -0
  81. package/docs/components/pan-zoom-viewport.md +245 -0
  82. package/docs/components/permission-editor.md +322 -0
  83. package/docs/components/persona.md +56 -0
  84. package/docs/components/price.md +106 -0
  85. package/docs/components/pricing-plan.md +68 -0
  86. package/docs/components/progress-bar.md +53 -0
  87. package/docs/components/qr-code.md +59 -0
  88. package/docs/components/rating.md +59 -0
  89. package/docs/components/rich-text-editor.md +210 -0
  90. package/docs/components/scale-generator.md +101 -0
  91. package/docs/components/screen.md +208 -0
  92. package/docs/components/seo-provider.md +189 -0
  93. package/docs/components/side-panel.md +94 -0
  94. package/docs/components/sidebar-menu.md +422 -0
  95. package/docs/components/skeleton.md +115 -0
  96. package/docs/components/slider.md +48 -0
  97. package/docs/components/spinner.md +27 -0
  98. package/docs/components/splitter.md +97 -0
  99. package/docs/components/stats.md +234 -0
  100. package/docs/components/status-chip.md +232 -0
  101. package/docs/components/switch.md +23 -0
  102. package/docs/components/tabs.md +335 -0
  103. package/docs/components/tag-input.md +55 -0
  104. package/docs/components/textarea.md +31 -0
  105. package/docs/components/theme-provider.md +130 -0
  106. package/docs/components/theme-toggle.md +36 -0
  107. package/docs/components/thumbnail-selector.md +186 -0
  108. package/docs/components/timeline.md +225 -0
  109. package/docs/components/toast-notification.md +89 -0
  110. package/docs/components/tooltip.md +31 -0
  111. package/docs/components/workbook.md +102 -0
  112. package/docs/composables/use-theme.md +59 -0
  113. package/docs/getting-started/setup.md +176 -0
  114. package/docs/guides/draggable.md +211 -0
  115. package/docs/guides/internationalization.md +281 -0
  116. package/docs/guides/performance.md +118 -0
  117. package/docs/guides/testing-forms.md +154 -0
  118. package/docs/guides/testing-overlays.md +131 -0
  119. package/docs/guides/theming.md +124 -0
  120. package/docs/utilities/search.md +580 -0
  121. package/docs/utilities/utilities.md +371 -0
  122. package/docs-manifest.json +339 -0
  123. package/package.json +5 -13
  124. package/scripts/generate-docs-manifest.js +207 -0
  125. package/scripts/sync-docs.js +754 -0
  126. package/style.css +1 -1
  127. /package/components/Dropdown/{DropdownMenu2.vue.js → DropdownMenu3.vue.js} +0 -0
@@ -0,0 +1,269 @@
1
+ # Category Manager
2
+
3
+ **Import:** `import { CategoryManager, type CategoryItem } from 'vlite3'`
4
+
5
+ ### Description
6
+
7
+ A production-ready, fully interactive tree manager for Vue 3. It allows users to create, edit, delete, and reorder hierarchical category structures with unlimited depth. It supports two distinct editing modes: **inline creation** (click-to-type, keyboard-confirmable) for speed, and a **modal form** for richer structured input via a fully customizable schema.
8
+
9
+ Built-in features include drag-and-drop reordering at every tree level, accordion expand/collapse, icon pickers, and a clean empty state.
10
+
11
+ ---
12
+
13
+ ### Props
14
+
15
+ | Prop | Type | Default | Description |
16
+ | :----------------- | :-------------- | :----------------------------------------- | :-------------------------------------------------------------------------------------- |
17
+ | `modelValue` | `CategoryItem[]`| `[]` | The nested category tree. Bind with `v-model`. |
18
+ | `formSchema` | `IForm[]?` | Default schema (icon, title, description) | Custom Form schema used in the Add/Edit modal. Overrides the default 3-field form. |
19
+ | `readonly` | `boolean` | `false` | Disables all mutations (add, edit, delete, drag). Renders the tree as a read-only view. |
20
+ | `loading` | `boolean` | `false` | Shows a translucent overlay without destroying the component. **Use this instead of `v-if`** to preserve expanded/inline state across data refetches. |
21
+ | `defaultExpanded` | `(string \| number)[]` | `undefined` | Array of category IDs to auto-expand on initial mount. |
22
+ | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Size modifier applied to each tree node row. |
23
+ | `emptyTitle` | `string` | `'No Categories Found'` | Heading shown in the empty state. |
24
+ | `emptyDescription` | `string` | `'Get started by creating your first category.'` | Body text shown in the empty state. |
25
+ | `*I18n` | `string` | `undefined` | Every text element in the component can be customized or localized. See **Customization & i18n** section. |
26
+
27
+ ---
28
+
29
+ ### Customization & i18n
30
+
31
+ Every string in the `CategoryManager` is customizable via props. You can pass raw strings (e.g. `addCategoryText="New Category"`) or i18n keys if you are using an i18n solution (e.g. `addCategoryTextI18n="myApp.newCategory"`).
32
+
33
+ | Property Type | Available Props (Append `I18n` for i18n keys) |
34
+ | :------------------ | :---------------------------------------------------------------------------------------------------------------------------------------------------- |
35
+ | **Empty State** | `emptyTitle`, `emptyDescription` |
36
+ | **Header** | `headerTitle`, `headerDescription`, `addCategoryText`, `createCategoryText` |
37
+ | **Placeholders** | `newRootPlaceholder`, `newSubcategoryPlaceholder`, `categoryTitlePlaceholder` |
38
+ | **Modal** | `modalTitleAdd`, `modalTitleAddChild`, `modalTitleEdit`, `modalSaveText` |
39
+ | **Tooltips** | `quickAddTooltip`, `advancedDetailsTooltip`, `deleteTooltip`, `saveTooltip`, `cancelTooltip` |
40
+
41
+ By default, the component looks for internal global keys using the `$t` utility (e.g., `vlite.categoryManager.emptyTitle`).
42
+
43
+ ---
44
+
45
+ ### Emits
46
+
47
+ | Event | Payload | Description |
48
+ | :--------------- | :--------------- | :----------------------------------------------------------------------- |
49
+ | `update:modelValue` | `CategoryItem[]` | Emitted on every mutation (add, edit, delete, reorder). Use with `v-model`. |
50
+ | `@onAdd` | `CategoryItem` | Emitted when a new category or sub-category is created. |
51
+ | `@onEdit` | `CategoryItem` | Emitted when an existing category is edited. |
52
+ | `@onDelete` | `CategoryItem` | Emitted when a category is deleted (the deleted item is passed). |
53
+ | `@onReorder` | `{ id, parentId, position }` | Emitted once after a drag-and-drop completes, providing the moved node's new placement details. |
54
+
55
+ ---
56
+
57
+ ### Data Model
58
+
59
+ #### `CategoryItem` Shape
60
+
61
+ | Field | Type | Description |
62
+ | :------------ | :-------------------- | :--------------------------------------------------------------------- |
63
+ | `id` | `string \| number` | **Required.** Unique identifier. Auto-generated for inline creates. |
64
+ | `title` | `string` | **Required.** Display name of the category. |
65
+ | `icon` | `string?` | Icon key (e.g., `'lucide:folder'`). Rendered as a visual prefix. |
66
+ | `description` | `string?` | Optional descriptor shown in the advanced modal form. |
67
+ | `children` | `CategoryItem[]?` | Nested sub-categories. The component auto-normalizes `undefined` to `[]`. |
68
+ | `[key]` | `any` | Any additional fields are preserved on your data and passed through emits. |
69
+
70
+ ---
71
+
72
+ ### Slots
73
+
74
+ | Slot Name | Description |
75
+ | :--- | :--- |
76
+ | `header` | Replaces the entire header area (title + "Add Category" button). |
77
+
78
+ ---
79
+
80
+ ### Implementation Examples
81
+
82
+ #### 1. Basic Tree with v-model
83
+
84
+ ```vue
85
+ <script setup>
86
+ import { ref } from 'vue'
87
+ import { CategoryManager, type CategoryItem } from 'vlite3'
88
+
89
+ const categories = ref<CategoryItem[]>([
90
+ {
91
+ id: 'cat-1',
92
+ title: 'Electronics',
93
+ icon: 'lucide:cpu',
94
+ children: [
95
+ { id: 'cat-1-1', title: 'Laptops', icon: 'lucide:laptop', children: [] },
96
+ ],
97
+ },
98
+ ])
99
+ </script>
100
+
101
+ <template>
102
+ <CategoryManager v-model="categories" />
103
+ </template>
104
+ ```
105
+
106
+ #### 2. Full Event Handling
107
+
108
+ ```vue
109
+ <template>
110
+ <CategoryManager
111
+ v-model="categories"
112
+ @onAdd="(item) => console.log('Added:', item)"
113
+ @onEdit="(item) => console.log('Edited:', item)"
114
+ @onDelete="(item) => console.log('Deleted:', item)"
115
+ @onReorder="(payload) => console.log('Reordered:', payload)"
116
+ />
117
+ </template>
118
+ ```
119
+
120
+ #### 3. Custom Form Schema for the Edit Modal
121
+
122
+ The modal that opens for "Add" and "Edit" actions is powered by the `<Form>` component. Pass any valid `IForm[]` schema to replace the default fields.
123
+
124
+ ```vue
125
+ <script setup>
126
+ const customFormSchema = [
127
+ { name: 'title', label: 'Name', type: 'text', required: true },
128
+ { name: 'icon', label: 'Icon', type: 'iconPicker' },
129
+ { name: 'color', label: 'Label Color', type: 'color', value: '#6366f1' },
130
+ { name: 'isActive', label: 'Is Active', type: 'switch', value: true },
131
+ ]
132
+ </script>
133
+
134
+ <template>
135
+ <CategoryManager v-model="categories" :form-schema="customFormSchema" />
136
+ </template>
137
+ ```
138
+
139
+ #### 4. Read-only Tree Display
140
+
141
+ ```vue
142
+ <template>
143
+ <CategoryManager :model-value="categories" readonly />
144
+ </template>
145
+ ```
146
+
147
+ #### 5. Custom Header Slot
148
+
149
+ ```vue
150
+ <template>
151
+ <CategoryManager v-model="categories">
152
+ <template #header>
153
+ <h2 class="text-xl font-bold">Product Taxonomy</h2>
154
+ </template>
155
+ </CategoryManager>
156
+ </template>
157
+ ```
158
+
159
+ #### 6. Production Pattern with API Refetching (Recommended)
160
+
161
+ When performing CRUD operations that trigger a data refetch, use the `:loading` prop **instead of `v-if`**. This keeps the component mounted and preserves all expanded/inline state across refetches.
162
+
163
+ ```vue
164
+ <script setup>
165
+ import { computed } from 'vue'
166
+ import { CategoryManager, type CategoryManagerExpose } from 'vlite3'
167
+ import { useGetCategoriesQuery, useCreateCategoryMutation } from '@/graphql'
168
+
169
+ const { result, loading, refetch } = useGetCategoriesQuery(/* ... */)
170
+ const { mutate: create } = useCreateCategoryMutation()
171
+
172
+ const categories = computed(() => result.value?.getCategories?.items || [])
173
+ const categoryManagerRef = ref<CategoryManagerExpose | null>(null)
174
+
175
+ const handleAdd = async (item) => {
176
+ await create({ data: { name: item.title, icon: item.icon } })
177
+ refetch() // Component stays mounted, expanded sections preserved
178
+ }
179
+ </script>
180
+
181
+ <template>
182
+ <!-- ✅ DO: Use :loading prop — component survives refetch -->
183
+ <CategoryManager
184
+ ref="categoryManagerRef"
185
+ :loading="loading"
186
+ :raw-data="categories"
187
+ :default-expanded="['cat-1', 'cat-2']"
188
+ @onAdd="handleAdd" />
189
+
190
+ <!-- ❌ DON'T: v-if destroys the component and all internal state -->
191
+ <!-- <CategoryManager v-if="!loading" :raw-data="categories" /> -->
192
+ </template>
193
+ ```
194
+
195
+ #### 7. Programmatic Expand/Collapse (via ref)
196
+
197
+ ```vue
198
+ <script setup>
199
+ const cmRef = ref()
200
+
201
+ // Expand all nodes
202
+ cmRef.value?.expandAll()
203
+ // Collapse all
204
+ cmRef.value?.collapseAll()
205
+ // Expand specific IDs
206
+ cmRef.value?.expand('cat-1', 'cat-2')
207
+ // Collapse specific IDs
208
+ cmRef.value?.collapse('cat-1')
209
+ // Read current expanded set
210
+ console.log(cmRef.value?.expandedIds)
211
+ </script>
212
+
213
+ <template>
214
+ <CategoryManager ref="cmRef" v-model="categories" />
215
+ </template>
216
+ ```
217
+
218
+ ---
219
+
220
+ ### Data Contract for AI Agents (JSON Template)
221
+
222
+ ```json
223
+ [
224
+ {
225
+ "id": "cat-1",
226
+ "title": "Electronics",
227
+ "icon": "lucide:cpu",
228
+ "children": [
229
+ {
230
+ "id": "cat-1-1",
231
+ "title": "Computers",
232
+ "icon": "lucide:monitor",
233
+ "children": [
234
+ { "id": "cat-1-1-1", "title": "Laptops", "icon": "lucide:laptop", "children": [] },
235
+ { "id": "cat-1-1-2", "title": "Desktops", "icon": "lucide:pc-case", "children": [] }
236
+ ]
237
+ },
238
+ { "id": "cat-1-2", "title": "Smartphones", "icon": "lucide:smartphone", "children": [] }
239
+ ]
240
+ }
241
+ ]
242
+ ```
243
+
244
+ ---
245
+
246
+ ### Exposed API (via `ref`)
247
+
248
+ Access these by setting a template ref on the component:
249
+
250
+ | Method / Property | Type | Description |
251
+ | :--- | :--- | :--- |
252
+ | `expandedIds` | `Ref<Set<string \| number>>` | Reactive set of currently expanded node IDs. |
253
+ | `expandAll()` | `() => void` | Expands every node in the tree. |
254
+ | `collapseAll()` | `() => void` | Collapses all nodes. |
255
+ | `expand(...ids)` | `(...ids: (string \| number)[]) => void` | Expands specific node(s) by ID. |
256
+ | `collapse(...ids)` | `(...ids: (string \| number)[]) => void` | Collapses specific node(s) by ID. |
257
+
258
+ ---
259
+
260
+ ### Senior Engineer's Notes
261
+
262
+ 1. **Two edit modes**: Each node has a **quick-add inline** mode (click ➕, type, press Enter to confirm or Esc to cancel) and a **modal form** mode (click the settings icon ⚙️). The inline mode is fast for 90% of cases; the modal is for structured data.
263
+ 2. **Unlimited depth**: The tree is rendered recursively via an internal `CategoryNode` component. There is no hard depth limit, though deep nesting (~5+) should be carefully considered from a UX perspective.
264
+ 3. **`children` auto-normalization**: If your API returns nodes without a `children` key, the component silently initializes it to `[]` during the deep clone on `watch`. This prevents undefined references in the recursive renderer and reorder logic.
265
+ 4. **Extra data fields are safe**: The `CategoryItem` interface uses `[key: string]: any` — your backend-specific fields (`slug`, `meta`, etc.) pass through undisturbed on all emit payloads.
266
+ 5. **Optimized Drag-and-Drop Syncing**: Items can be freely reordered within their parent group or extracted seamlessly to the root. Upon releasing a dragged node, the component emits the completely updated tree via `update:modelValue`. Simultaneously, `@onReorder` triggers exactly once per drop with a minimal payload (`id`, `parentId`, `position`), eliminating continuous mid-drag emissions and allowing for extremely efficient network updates to your API.
267
+ 6. **Self-contained state**: The component deep-clones your `modelValue` internally on initialization. All edits operate on this internal clone and emit the final state up. This prevents accidental mutation of your parent state.
268
+ 7. **State preservation on refetch**: When using the `:loading` prop instead of `v-if`, the component stays mounted through data refetches. The `rawData` watcher intelligently prunes stale IDs from the expanded set while preserving valid ones, so users never lose their place in the tree.
269
+ 8. **Empty data handling**: Deleting the last category via API (resulting in an empty `rawData` array) is handled correctly — the component clears its internal state and shows the empty state.
@@ -0,0 +1,251 @@
1
+ # CategoryMenu
2
+
3
+ **Import:** `import { CategoryMenu, type CategoryMenuProps, type CategoryMenuItem } from 'vlite3'`
4
+
5
+ A read-only, presentation-focused counterpart to [`CategoryManager`](./category-manager.md). The data shape is the same — `CategoryManager`'s `CategoryItem[]` can be passed straight in, or you can leverage the built-in `rawData` prop to feed it flat datasets direct from an API. Four built-in variants cover the most common e-commerce presentation needs: tabs, mega menu, sidebar accordion, and inline pills.
6
+
7
+ ---
8
+
9
+ ## Variants
10
+
11
+ ### `tabs` (default)
12
+
13
+ A horizontal scrollable row of top-level categories, featuring overflow gradients and left/right hidden-scroll controls identical to standard tabs (`NavbarTabs` or `Tabes`). Hovering a top-level item on desktop opens a popover listing its immediate children — and **the popover is fully recursive**: any child with its own `children` opens a nested popover to the right, and so on. The cascading popovers, positioning, overflow handling, keyboard nav, and click-outside are all inherited from the existing `<Dropdown>` component. On mobile, the popover is replaced with an inline expanded list.
14
+
15
+ ```
16
+
17
+ [ All ] < [ Electronics ] [ Clothing ] [ Sale ] >
18
+ │
19
+ └─ popover:
20
+ · Computers ▶
21
+ · Smartphones ▶
22
+ · Cameras
23
+ · Audio
24
+ │
25
+ └─ (nested popover to the right)
26
+ · Laptops
27
+ · Desktops
28
+ · Tablets
29
+
30
+ ```
31
+
32
+ ### `mega`
33
+
34
+ A wide panel that drops below the top row. **Active-only**: hovering a top-level button displays only that top-level's children — one column, populated with the active top-level's children. Nested children (up to 3 levels deep) render inline as smaller in-column sub-items, so the panel is flat — no nested side-popovers. Implemented via `<Dropdown layout="grouped">` with the active top-level passed as a single-element options array.
35
+
36
+ ```
37
+
38
+ [ Electronics ] [ Clothing ] [ Sale ]
39
+ ↓ hovering Clothing
40
+ ─────────────────────────────────────────────────────────────
41
+ │ Clothing │
42
+ │ Men │
43
+ │ · Shirts │
44
+ │ · Pants │
45
+ │ · Suits │
46
+ │ Women │
47
+ │ · Dresses │
48
+ │ · Tops │
49
+ │ · Skirts │
50
+ │ Kids │
51
+ │ · Boys │
52
+ │ · Girls │
53
+ │ · Baby │
54
+ ─────────────────────────────────────────────────────────────
55
+
56
+ ```
57
+
58
+ The active top-level is the _trigger_ — it never appears as a nested item the user has to click. Click a child to select; click a top-level button in the row above the panel to navigate to that category directly.
59
+
60
+ ### `sidebar`
61
+
62
+ A vertical accordion. Each parent expands to show its children. By default only one parent can be open at a time; pass `multi-expand` to allow several. Honors `active-id` by auto-expanding the path to the active node.
63
+
64
+ ```
65
+
66
+ > Electronics
67
+ > Laptops
68
+ > Smartphones
69
+ > v Clothing
70
+ > Men
71
+ > Women
72
+ > Kids
73
+ > Sale
74
+
75
+ ```
76
+
77
+ ### `inline`
78
+
79
+ A compact pill list. Each parent shows a "Children A · Children B" hint beside its name. Designed for tight horizontal spaces — e.g. just under a search bar, or inside a card.
80
+
81
+ ```
82
+
83
+ [ Electronics · Laptops · Cameras ] [ Clothing ] [ Sale ]
84
+
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Props
90
+
91
+ | Prop | Type | Default | Description |
92
+ | :----------------- | :------------------------------------------ | :---------- | :----------------------------------------------------------------------------------------------------------------------------------------------------- |
93
+ | `items` | `CategoryMenuItem[]` | `[]` | Hierarchical category tree. Accepts the same shape as `CategoryManager`. |
94
+ | `rawData` | `RawCategoryItem[]` | `undefined` | Alternative to `items`: Flat array of category items. Converts flat relational objects into a nested hierarchy locally. |
95
+ | `variant` | `'tabs' \| 'mega' \| 'sidebar' \| 'inline'` | `'tabs'` | Layout variant — see [Variants](#variants). |
96
+ | `maxDepth` | `number` | `2` | Max depth to render. `1` = top-level only. The `mega` and `sidebar` variants render grandchildren inline when `maxDepth >= 3`. |
97
+ | `showIcons` | `boolean` | `true` | Whether to render the icon prefix on each item. |
98
+ | `showAllItem` | `boolean` | `false` | Show an "All" pseudo-item at the start. (`tabs` variant only.) |
99
+ | `allItemLabel` | `string` | `'All'` | Label for the "All" item. |
100
+ | `multiExpand` | `boolean` | `false` | `sidebar` variant: allow multiple parents to be open at once. |
101
+ | `activeId` | `string \| number \| null` | `null` | The currently active category. Highlights the matching node; in `sidebar` mode, auto-expands its ancestors. |
102
+ | `routePrefix` | `string` | `''` | Optional Vue Router path prefix used to auto-generate category links. Nested categories join their slug path with hyphens, e.g. `/products/cloth-men`. |
103
+ | `megaColumns` | `number` | `4` | `mega` variant: number of columns in the panel. Clamped to `[1, 6]`. |
104
+ | `showImages` | `boolean` | `true` | `mega` variant: whether to render the hero image for the active top-level. |
105
+ | `showDescriptions` | `boolean` | `true` | `mega` variant: whether to render the description text under the hero. |
106
+ | `class` | `string` | `''` | Pass-through classes for the root container. |
107
+
108
+ ---
109
+
110
+ ## Events
111
+
112
+ | Event | Payload | Description |
113
+ | :------- | :----------------- | :--------------------------------------------------------------------------------- |
114
+ | `select` | `CategoryMenuItem` | Emitted when any leaf, child, or parent is clicked. The clicked item is passed in. |
115
+
116
+ ---
117
+
118
+ ## Slots
119
+
120
+ The component currently exposes no public slots. The built-in variants cover the 95% case; if you need a fully custom render, fork the variant you need or wrap `CategoryMenu` in a Vue component of your own.
121
+
122
+ ---
123
+
124
+ ## Usage Examples
125
+
126
+ ### Using raw API Data directly
127
+
128
+ You don't need to manually compute the nested tree. Like `CategoryManager`, you can simply bind `rawData` directly inside the template. The component handles the recursion and nesting locally.
129
+
130
+ ```vue
131
+ <script setup>
132
+ const flatCategoriesFromApi = [
133
+ { id: '1', name: 'Electronics' },
134
+ { id: '2', name: 'Laptops', parentId: '1' },
135
+ ]
136
+ </script>
137
+
138
+ <template>
139
+ <CategoryMenu :raw-data="flatCategoriesFromApi" variant="tabs" />
140
+ </template>
141
+ ```
142
+
143
+ ### Basic tabs
144
+
145
+ ```vue
146
+ <script setup>
147
+ import { ref } from 'vue'
148
+ import { CategoryMenu } from 'vlite3'
149
+
150
+ const categories = ref([
151
+ {
152
+ id: 1,
153
+ title: 'Electronics',
154
+ icon: 'lucide:cpu',
155
+ children: [
156
+ { id: 11, title: 'Laptops' },
157
+ { id: 12, title: 'Smartphones' },
158
+ ],
159
+ },
160
+ { id: 2, title: 'Clothing', icon: 'lucide:shirt' },
161
+ { id: 3, title: 'Sale', icon: 'lucide:tag' },
162
+ ])
163
+
164
+ const onSelect = (cat) => console.log('Selected:', cat)
165
+ </script>
166
+
167
+ <template>
168
+ <CategoryMenu
169
+ :items="categories"
170
+ variant="tabs"
171
+ route-prefix="/products"
172
+ show-all-item
173
+ all-item-label="Shop all"
174
+ @select="onSelect" />
175
+ </template>
176
+ ```
177
+
178
+ ### Mega menu for a brand-led store
179
+
180
+ ```vue
181
+ <template>
182
+ <CategoryMenu
183
+ :items="categoryTree"
184
+ variant="mega"
185
+ route-prefix="/collections"
186
+ :mega-columns="4"
187
+ :max-depth="2"
188
+ :show-images="true" />
189
+ </template>
190
+ ```
191
+
192
+ With `route-prefix="/collections"`, a nested item like `Men -> Bags` is rendered as a Vue Router link to `/collections/men-bags`.
193
+
194
+ ### Sidebar in a category-browser page
195
+
196
+ ```vue
197
+ <aside class="w-64 border-r border-border p-4">
198
+ <CategoryMenu
199
+ :items="categoryTree"
200
+ variant="sidebar"
201
+ route-prefix="/products"
202
+ :active-id="route.params.categoryId"
203
+ :max-depth="3"
204
+ multi-expand />
205
+ </aside>
206
+ ```
207
+
208
+ ### Inline pills under a hero
209
+
210
+ ```vue
211
+ <header>
212
+ <h1>What's trending</h1>
213
+ <CategoryMenu
214
+ :items="trendingCategories"
215
+ variant="inline"
216
+ route-prefix="/trending"
217
+ :show-icons="false"
218
+ @select="onSelect" />
219
+ </header>
220
+ ```
221
+
222
+ ### Using a `CategoryManager`-managed tree
223
+
224
+ The data shape is identical, so any tree you've built with `CategoryManager` can be passed straight in. The `loading` and `rawData` props of `CategoryManager` continue to work in tandem — feed the result into `CategoryMenu`:
225
+
226
+ ```vue
227
+ <script setup>
228
+ import { CategoryManager, CategoryMenu } from 'vlite3'
229
+
230
+ const { result, loading } = useGetCategoriesQuery()
231
+ </script>
232
+
233
+ <template>
234
+ <CategoryManager :loading="loading" :raw-data="result?.getCategories?.items" readonly />
235
+
236
+ <CategoryMenu :raw-data="result?.getCategories?.items" variant="mega" route-prefix="/products" />
237
+ </template>
238
+ ```
239
+
240
+ ---
241
+
242
+ ## Senior Engineer's Notes
243
+
244
+ 1. **Read-only by design.** `CategoryMenu` deliberately does not emit anything that would mutate the tree. It only emits `@select`. If you need CRUD, use [`CategoryManager`](https://www.google.com/search?q=./CategoryManager.md) instead.
245
+ 2. **Compatible data shape.** The `CategoryMenuItem` type is structurally identical to `CategoryManager`'s `CategoryItem`, which means swapping between the two is a one-line change. The same data drives both the admin editor and the storefront menu.
246
+ 3. **Automatic router links.** Pass `routePrefix` once and the component derives clean slugs from `slug`, `title`, `name`, `label`, or `id`. Nested category names are joined with hyphens at any depth, so `Cloth -> Men -> Shirts` becomes `/products/cloth-men-shirts`.
247
+ 4. **Powered by `<Dropdown>` for the floating variants.** The `tabs` and `mega` variants don't reinvent popper logic — they delegate to the existing `<Dropdown>` component (which is built on `v-tooltip-lite` + Popper.js). A small adapter in `./utils` (`categoryToDropdownOption`) bridges the field names. The cascade-style nested popovers, the multi-column grouped mega panel, keyboard navigation, click-outside, scroll/resize handling, and RTL behavior are all inherited for free. `sidebar` and `inline` are pure-render and don't need it.
248
+ 5. **Cascading depth in `tabs`.** The `tabs` popover is fully recursive — hover a sub-category with its own `children` and another popover opens to the right. The depth is unlimited; the visible depth is limited only by the data you feed in. (`sidebar` shows the same data flat; `mega` flattens to 3 levels inline and cascades beyond that.)
249
+ 6. **`maxDepth` is a UX hint, not a hard cap.** Setting it to `1` hides all children; setting it to `3` exposes grandchildren inline in `mega` and `sidebar`. Going past `3` is supported but rarely useful — deep trees should usually be paginated, not inlined.
250
+ 7. **Active-node tracking.** Pass `activeId` to highlight the current category. The `sidebar` variant auto-expands the path to that node, which is exactly what you want for a category browser page.
251
+ 8. **Empty / loading states.** When `items` is empty, the component renders a single muted "No categories to display." line. For a richer skeleton, wrap it in a `<Skeleton>` or use `v-if` at the call site.