vue-command-kit 0.1.1 โ 0.1.2
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 +118 -143
- package/dist/__tests__/CommandDialog.test.d.ts +1 -0
- package/dist/__tests__/CommandInput.test.d.ts +1 -0
- package/dist/__tests__/CommandItem.test.d.ts +1 -0
- package/dist/__tests__/CommandList.test.d.ts +1 -0
- package/dist/__tests__/injectStrict.test.d.ts +1 -0
- package/dist/__tests__/parseShortcut.test.d.ts +1 -0
- package/dist/__tests__/useCommandMenu.test.d.ts +1 -0
- package/dist/__tests__/useCommandRoot.test.d.ts +1 -0
- package/dist/types.d.ts +9 -0
- package/dist/useCommandMenu.d.ts +10 -1
- package/dist/useCommandRoot.d.ts +3 -0
- package/dist/vue-cmdk.js +378 -336
- package/dist/vue-cmdk.umd.cjs +1 -1
- package/package.json +28 -1
package/README.md
CHANGED
|
@@ -15,87 +15,19 @@
|
|
|
15
15
|
<img src="./demo.gif" alt="vue-cmdk demo" width="720">
|
|
16
16
|
</p>
|
|
17
17
|
|
|
18
|
-
## ๐ง Inspiration
|
|
19
|
-
|
|
20
|
-
This project is heavily inspired by two great projects:
|
|
21
|
-
|
|
22
|
-
| Project | Author | Description |
|
|
23
|
-
| --- | --- | --- |
|
|
24
|
-
| [`vue-command-palette`](https://github.com/xiaoluoboding/vue-command-palette) | [@xiaoluoboding](https://github.com/xiaoluoboding) | The first composable command palette for Vue, with 590 โ
|
|
|
25
|
-
| [`cmdk`](https://github.com/pacocoursey/cmdk) | [@pacocoursey](https://github.com/pacocoursey) | Fast, unstyled command menu React component (10k+ โ
) |
|
|
26
|
-
|
|
27
|
-
### Why another one?
|
|
28
|
-
|
|
29
|
-
[`vue-command-palette`](https://github.com/xiaoluoboding/vue-command-palette) pioneered the โK experience for Vue. Big thanks to [@xiaoluoboding](https://github.com/xiaoluoboding) for the original idea and work ๐
|
|
30
|
-
|
|
31
|
-
However, the project has been **inactive since September 2023** โ 9 issues remain unanswered, no dependencies have been updated in years, and the bundle size is 28 kB. The Vue ecosystem deserves a **well-maintained, lightweight alternative** that keeps up with modern standards.
|
|
32
|
-
|
|
33
|
-
**vue-cmdk** is built to fill that gap: same compound component API, zero dependencies, half the size, with full TypeScript support and a commitment to ongoing maintenance.
|
|
34
|
-
|
|
35
|
-
### vs vue-command-palette (legacy reference)
|
|
36
|
-
|
|
37
|
-
| Feature | `vue-command-palette` | `vue-cmdk` |
|
|
38
|
-
| ---------------- | :----------------------: | :-----------: |
|
|
39
|
-
| ๐ฆ Bundle (min) | 28.2 kB | **11.8 kB** |
|
|
40
|
-
| ๐ฆ Bundle (gzip) | 9.6 kB | **3.4 kB** |
|
|
41
|
-
| ๐ Search | fuse.js (extra dep) | **Built-in** |
|
|
42
|
-
| ๐ TypeScript | Partial | **Full** |
|
|
43
|
-
| ๐ Async items | โ | โ
|
|
|
44
|
-
| ๐งฉ Custom filter | โ | โ
|
|
|
45
|
-
| ๐ Focus trap | โ | โ
|
|
|
46
|
-
| ๐งน Dependencies | 3 (fuse.js, nanoid, ...) | **0** |
|
|
47
|
-
| ๐ง Maintenance | โ Inactive since 2023 | โ
**Active** |
|
|
48
|
-
|
|
49
|
-
---
|
|
50
|
-
|
|
51
18
|
## โจ Features
|
|
52
19
|
|
|
53
|
-
- **๐งฉ Compound component API** โ `<Command.Dialog>`, `<Command.
|
|
20
|
+
- **๐งฉ Compound component API** โ `<Command.Dialog>`, `<Command.Input>`, `<Command.Item>`, etc.
|
|
54
21
|
- **๐ Unstyled** โ Bring your own CSS, zero opinions, full design control
|
|
55
22
|
- **๐ Built-in search** โ Fast case-insensitive filtering with keyword matching
|
|
56
23
|
- **โจ๏ธ Keyboard-first** โ Arrow keys, Enter, Escape โ all built-in, no config needed
|
|
24
|
+
- **๐ Global shortcut** โ Register shortcuts on items (e.g. `โS`) and they work globally
|
|
57
25
|
- **๐ฆ Tiny** โ 3.4 kB gzipped, **zero runtime dependencies** (peer: `vue` only)
|
|
58
26
|
- **๐ฏ TypeScript** โ Full type inference and declaration files
|
|
59
27
|
- **๐ Dynamic items** โ Pass items as a reactive array, swap anytime
|
|
60
28
|
- **๐ Custom filter** โ Provide your own filter function
|
|
61
29
|
- **โฟ Accessible** โ ARIA attributes, focus trap, `aria-live` region
|
|
62
30
|
|
|
63
|
-
## ๐ Comparison with React cmdk
|
|
64
|
-
|
|
65
|
-
`vue-cmdk` is a Vue 3 port inspired by the excellent [`cmdk`](https://github.com/pacocoursey/cmdk) (React). Below is the current feature parity status:
|
|
66
|
-
|
|
67
|
-
| # | Feature | React `cmdk` | `vue-cmdk` | Status |
|
|
68
|
-
| --- | -------------------------------------------- | :-------------: | :--------------: | :--------: |
|
|
69
|
-
| 1 | `Command` root `value` / `onValueChange` | โ
| โ | ๐ Planned |
|
|
70
|
-
| 2 | `Command` root `shouldFilter` | โ
| โ | ๐ Planned |
|
|
71
|
-
| 3 | `Command` root `loop` | โ
| โ | ๐ Planned |
|
|
72
|
-
| 4 | `Command` root `label` (aria-label) | โ
| โ | ๐ Planned |
|
|
73
|
-
| 5 | `Command.Dialog` `open` / `onOpenChange` | โ
`open` | โ
`visible` | โ
|
|
|
74
|
-
| 6 | `Command.Dialog` `container` (portal target) | โ
| โ | ๐ก Future |
|
|
75
|
-
| 7 | `Command.Input` `value` / `onValueChange` | โ
| โ
`searchQuery` | โ
|
|
|
76
|
-
| 8 | `Command.Item` `forceMount` | โ
| โ | ๐ Planned |
|
|
77
|
-
| 9 | `Command.Item` `keywords` | โ
| โ
| โ
|
|
|
78
|
-
| 10 | `Command.Item` `onSelect` | โ
| โ
| โ
|
|
|
79
|
-
| 11 | `Command.Item` auto value from textContent | โ
| โ | ๐ Planned |
|
|
80
|
-
| 12 | `Command.Group` `forceMount` | โ
| โ | ๐ Planned |
|
|
81
|
-
| 13 | `Command.Group` `heading` | โ
| โ
| โ
|
|
|
82
|
-
| 14 | `Command.Separator` `alwaysRender` | โ
| โ | ๐ก Future |
|
|
83
|
-
| 15 | `Command.Empty` | โ
| โ
| โ
|
|
|
84
|
-
| 16 | `Command.Loading` | โ
| โ
| โ
|
|
|
85
|
-
| 17 | `useCommandState()` state selector | โ
| โ | ๐ Planned |
|
|
86
|
-
| 18 | **Nested items / Pages** | โ
(pattern) | โ | ๐ Planned |
|
|
87
|
-
| 19 | **Built-in search / filtering** | โ
| โ
| โ
|
|
|
88
|
-
| 20 | **Custom filter function** | โ
(rank-based) | โ
(item-based) | โ
|
|
|
89
|
-
| 21 | **Global shortcut listener** | โ (manual) | โ
(built-in) | โ
Bonus |
|
|
90
|
-
| 22 | **Keyboard navigation** | โ
| โ
| โ
|
|
|
91
|
-
| 23 | **Focus trap** | โ
(Radix) | โ
(custom) | โ
|
|
|
92
|
-
| 24 | **Zero dependencies** | โ (Radix UI) | โ
(0 deps) | โ
Better |
|
|
93
|
-
| 25 | **TypeScript** | โ
| โ
| โ
|
|
|
94
|
-
| 26 | **Unstyled** | โ
| โ
| โ
|
|
|
95
|
-
| 27 | **Bundle size (gzip)** | ~7 kB | **3.4 kB** | โ
Smaller |
|
|
96
|
-
|
|
97
|
-
> **Legend** โ โ
Done ยท ๐ High/Medium priority ยท ๐ก Low priority / Nice to have
|
|
98
|
-
|
|
99
31
|
## ๐ Install
|
|
100
32
|
|
|
101
33
|
```bash
|
|
@@ -108,20 +40,20 @@ npm install vue-command-kit
|
|
|
108
40
|
|
|
109
41
|
```vue
|
|
110
42
|
<script setup lang="ts">
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
43
|
+
import { ref } from 'vue'
|
|
44
|
+
import { Command } from 'vue-command-kit'
|
|
45
|
+
import type { CommandItemData } from 'vue-command-kit'
|
|
114
46
|
|
|
115
|
-
|
|
47
|
+
const visible = ref(false)
|
|
116
48
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
49
|
+
const items: CommandItemData[] = [
|
|
50
|
+
{ value: 'settings', label: 'Open settings', shortcut: 'โ,' },
|
|
51
|
+
{ value: 'home', label: 'Go to home', shortcut: 'โH' },
|
|
52
|
+
]
|
|
121
53
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
54
|
+
function onSelect(item: CommandItemData) {
|
|
55
|
+
console.log('selected:', item.value)
|
|
56
|
+
}
|
|
125
57
|
</script>
|
|
126
58
|
|
|
127
59
|
<template>
|
|
@@ -157,19 +89,15 @@ npm install vue-command-kit
|
|
|
157
89
|
|
|
158
90
|
```vue
|
|
159
91
|
<script setup lang="ts">
|
|
160
|
-
|
|
92
|
+
import { Command } from 'vue-command-kit'
|
|
161
93
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
94
|
+
function myFilter(items: CommandItemData[], query: string) {
|
|
95
|
+
return items.filter((item) => item.label?.includes(query))
|
|
96
|
+
}
|
|
166
97
|
</script>
|
|
167
98
|
|
|
168
99
|
<template>
|
|
169
|
-
<Command.Dialog
|
|
170
|
-
:filter="myFilter"
|
|
171
|
-
...
|
|
172
|
-
/>
|
|
100
|
+
<Command.Dialog :filter="myFilter" ... />
|
|
173
101
|
</template>
|
|
174
102
|
```
|
|
175
103
|
|
|
@@ -177,17 +105,17 @@ npm install vue-command-kit
|
|
|
177
105
|
|
|
178
106
|
```vue
|
|
179
107
|
<script setup lang="ts">
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
108
|
+
import { ref } from 'vue'
|
|
109
|
+
import { Command } from 'vue-command-kit'
|
|
110
|
+
import type { CommandItemData } from 'vue-command-kit'
|
|
183
111
|
|
|
184
|
-
|
|
185
|
-
|
|
112
|
+
const visible = ref(false)
|
|
113
|
+
const query = ref('')
|
|
186
114
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
115
|
+
const items: CommandItemData[] = [
|
|
116
|
+
{ value: 'home', label: 'Home', keywords: ['dashboard'] },
|
|
117
|
+
{ value: 'settings', label: 'Settings' },
|
|
118
|
+
]
|
|
191
119
|
</script>
|
|
192
120
|
|
|
193
121
|
<template>
|
|
@@ -204,26 +132,26 @@ npm install vue-command-kit
|
|
|
204
132
|
|
|
205
133
|
```vue
|
|
206
134
|
<script setup lang="ts">
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
135
|
+
import { ref, watch } from 'vue'
|
|
136
|
+
import { Command } from 'vue-command-kit'
|
|
137
|
+
import type { CommandItemData } from 'vue-command-kit'
|
|
138
|
+
|
|
139
|
+
const visible = ref(false)
|
|
140
|
+
const loading = ref(false)
|
|
141
|
+
const items = ref<CommandItemData[]>([])
|
|
142
|
+
|
|
143
|
+
watch(visible, async (v) => {
|
|
144
|
+
if (v) {
|
|
145
|
+
loading.value = true
|
|
146
|
+
const data = await fetch('/api/commands').then((r) => r.json())
|
|
147
|
+
items.value = data.map((d: any) => ({
|
|
148
|
+
value: d.id,
|
|
149
|
+
label: d.name,
|
|
150
|
+
group: d.category,
|
|
151
|
+
}))
|
|
152
|
+
loading.value = false
|
|
153
|
+
}
|
|
154
|
+
})
|
|
227
155
|
</script>
|
|
228
156
|
|
|
229
157
|
<template>
|
|
@@ -239,58 +167,73 @@ npm install vue-command-kit
|
|
|
239
167
|
|
|
240
168
|
## ๐ API
|
|
241
169
|
|
|
242
|
-
### `<Command.Dialog>` Props
|
|
243
|
-
|
|
244
|
-
| Prop | Type | Default | Description |
|
|
245
|
-
| --------------- | ------------------- | --------------------- | ------------------------------------ |
|
|
246
|
-
| `visible` | `boolean` | `false` | Controlled open state |
|
|
247
|
-
| `items` | `CommandItemData[]` | `[]` | Items to display |
|
|
248
|
-
| `searchQuery` | `string` | `''` | Search query (`v-model:searchQuery`) |
|
|
249
|
-
| `placeholder` | `string` | `'Type a command...'` | Input placeholder |
|
|
250
|
-
| `filter` | `FilterFn` | โ | Custom filter function |
|
|
251
|
-
| `loading` | `boolean` | `false` | Show loading state |
|
|
252
|
-
| `autoFocus` | `boolean` | `true` | Auto-focus input on open |
|
|
253
|
-
| `closeOnSelect` | `boolean` | `true` | Close dialog after selection |
|
|
254
|
-
|
|
255
|
-
### `<Command.Dialog>` Events
|
|
256
|
-
|
|
257
|
-
| Event | Payload | Description |
|
|
258
|
-
| -------------------- | ----------------- | --------------------------------- |
|
|
259
|
-
| `update:visible` | `boolean` | Emitted when visibility changes |
|
|
260
|
-
| `update:searchQuery` | `string` | Emitted when search query changes |
|
|
261
|
-
| `select` | `CommandItemData` | Emitted when an item is selected |
|
|
262
|
-
|
|
263
170
|
### Components
|
|
264
171
|
|
|
265
172
|
| Component | Description |
|
|
266
173
|
| --------------------- | ---------------------------------------------- |
|
|
267
174
|
| `<Command.Dialog>` | Modal dialog with mask, transition, focus trap |
|
|
268
|
-
| `<Command.Menu>` | Inline command menu (non-modal)
|
|
175
|
+
| `<Command.Menu>` | Inline command menu (non-modal) with slots |
|
|
269
176
|
| `<Command.Input>` | Search input with keyboard navigation |
|
|
270
|
-
| `<Command.List>` | Scrollable list rendering
|
|
177
|
+
| `<Command.List>` | Scrollable list rendering grouped items |
|
|
271
178
|
| `<Command.Group>` | Group of items with heading |
|
|
272
179
|
| `<Command.Item>` | Single selectable command item |
|
|
273
180
|
| `<Command.Empty>` | Shown when no results match |
|
|
274
181
|
| `<Command.Separator>` | Visual separator |
|
|
275
182
|
| `<Command.Loading>` | Loading indicator |
|
|
276
183
|
|
|
184
|
+
### `<Command.Dialog>` Props
|
|
185
|
+
|
|
186
|
+
| Prop | Type | Default | Description |
|
|
187
|
+
| --------------- | ------------------- | ------------------------------- | ---------------------------------------------- |
|
|
188
|
+
| `visible` | `boolean` | `false` | Controlled open state |
|
|
189
|
+
| `items` | `CommandItemData[]` | `[]` | Items to display |
|
|
190
|
+
| `searchQuery` | `string` | `''` | Search query (`v-model:searchQuery`) |
|
|
191
|
+
| `value` | `string` | โ | Selected item value (`v-model:value`) |
|
|
192
|
+
| `placeholder` | `string` | `'Type a command or search...'` | Input placeholder |
|
|
193
|
+
| `filter` | `FilterFn` | โ | Custom filter function |
|
|
194
|
+
| `loading` | `boolean` | `false` | Show loading state |
|
|
195
|
+
| `autoFocus` | `boolean` | `true` | Auto-focus input on open |
|
|
196
|
+
| `closeOnSelect` | `boolean` | `true` | Close dialog after selection |
|
|
197
|
+
| `shouldFilter` | `boolean` | `true` | When `false`, skip built-in filtering |
|
|
198
|
+
| `loop` | `boolean` | `true` | When `false`, keyboard nav stops at boundaries |
|
|
199
|
+
| `label` | `string` | `'Command menu'` | `aria-label` for the dialog |
|
|
200
|
+
|
|
201
|
+
### `<Command.Dialog>` Events
|
|
202
|
+
|
|
203
|
+
| Event | Payload | Description |
|
|
204
|
+
| -------------------- | ----------------- | --------------------------------- |
|
|
205
|
+
| `update:visible` | `boolean` | Emitted when visibility changes |
|
|
206
|
+
| `update:searchQuery` | `string` | Emitted when search query changes |
|
|
207
|
+
| `update:value` | `string` | Emitted when an item is selected |
|
|
208
|
+
| `select` | `CommandItemData` | Emitted when an item is selected |
|
|
209
|
+
|
|
277
210
|
### `CommandItemData`
|
|
278
211
|
|
|
279
212
|
```ts
|
|
280
213
|
interface CommandItemData {
|
|
214
|
+
/** Unique value for this item */
|
|
281
215
|
value: string
|
|
216
|
+
/** Display label (falls back to value) */
|
|
282
217
|
label?: string
|
|
218
|
+
/** Optional keywords for search matching */
|
|
283
219
|
keywords?: string[]
|
|
220
|
+
/** Optional shortcut display (e.g. "โS") */
|
|
284
221
|
shortcut?: string
|
|
222
|
+
/** Group this item belongs to */
|
|
285
223
|
group?: string
|
|
224
|
+
/** Disabled state */
|
|
286
225
|
disabled?: boolean
|
|
287
|
-
icon
|
|
226
|
+
/** Custom render icon or prefix */
|
|
227
|
+
icon?: Component | VNode | (() => VNode)
|
|
228
|
+
/** Callback when item is selected */
|
|
288
229
|
onSelect?: (item: CommandItemData) => void
|
|
289
230
|
}
|
|
290
231
|
```
|
|
291
232
|
|
|
292
233
|
### `useCommandMenu()` Composable
|
|
293
234
|
|
|
235
|
+
Use the composable for programmatic control outside of `Command.Dialog` / `Command.Menu`.
|
|
236
|
+
|
|
294
237
|
```ts
|
|
295
238
|
import { useCommandMenu } from 'vue-command-kit'
|
|
296
239
|
import type { UseCommandMenuReturn, FilterFn } from 'vue-command-kit'
|
|
@@ -302,6 +245,38 @@ menu.close()
|
|
|
302
245
|
menu.toggle()
|
|
303
246
|
```
|
|
304
247
|
|
|
248
|
+
Returns:
|
|
249
|
+
|
|
250
|
+
| Return | Type | Description |
|
|
251
|
+
| ----------------- | ------------------------- | ------------------------------------------------ |
|
|
252
|
+
| `visible` | `Ref<boolean>` | Open state |
|
|
253
|
+
| `searchQuery` | `Ref<string>` | Current search query |
|
|
254
|
+
| `activeIndex` | `Ref<number>` | Currently highlighted item index |
|
|
255
|
+
| `items` | `Ref<CommandItemData[]>` | Raw item list |
|
|
256
|
+
| `filteredItems` | `ComputedRef<...>` | Items after filtering |
|
|
257
|
+
| `groupedItems` | `ComputedRef<...>` | Filtered items grouped by `group` field |
|
|
258
|
+
| `open()` | `() => void` | Open the menu |
|
|
259
|
+
| `close()` | `() => void` | Close and reset search |
|
|
260
|
+
| `toggle()` | `() => void` | Toggle open state |
|
|
261
|
+
| `selectNext()` | `() => void` | Move active index down |
|
|
262
|
+
| `selectPrev()` | `() => void` | Move active index up |
|
|
263
|
+
| `selectCurrent()` | `() => void` | Select currently active item |
|
|
264
|
+
| `defaultFilter()` | `(items, query) => items` | Default filter implementation (case-insensitive) |
|
|
265
|
+
|
|
266
|
+
## ๐ฆ Bundle Size
|
|
267
|
+
|
|
268
|
+
| Format | Size |
|
|
269
|
+
| ------- | ---------- |
|
|
270
|
+
| ESM | 11.8 kB |
|
|
271
|
+
| UMD | 11.8 kB |
|
|
272
|
+
| Gzipped | **3.4 kB** |
|
|
273
|
+
|
|
274
|
+
Zero runtime dependencies. Peer dependency only on `vue ^3.4.0`.
|
|
275
|
+
|
|
276
|
+
## ๐ค Acknowledgements
|
|
277
|
+
|
|
278
|
+
vue-cmdk is inspired by [`cmdk`](https://github.com/pacocoursey/cmdk) by [@pacocoursey](https://github.com/pacocoursey) โ a fast, unstyled command menu for React.
|
|
279
|
+
|
|
305
280
|
### Keyboard
|
|
306
281
|
|
|
307
282
|
| Key | Action |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types.d.ts
CHANGED
|
@@ -34,11 +34,20 @@ export interface CommandRootProps {
|
|
|
34
34
|
closeOnSelect?: boolean;
|
|
35
35
|
/** Whether the menu is loading */
|
|
36
36
|
loading?: boolean;
|
|
37
|
+
/** aria-label for the dialog/menu */
|
|
38
|
+
label?: string;
|
|
39
|
+
/** When false, skip built-in filtering and show all items (custom filter still applies) */
|
|
40
|
+
shouldFilter?: boolean;
|
|
41
|
+
/** When false, keyboard navigation stops at boundaries instead of wrapping around */
|
|
42
|
+
loop?: boolean;
|
|
43
|
+
/** Controlled selected item value (v-model) */
|
|
44
|
+
value?: string;
|
|
37
45
|
}
|
|
38
46
|
/** Emitted events */
|
|
39
47
|
export interface CommandRootEmits {
|
|
40
48
|
(e: 'update:visible', value: boolean): void;
|
|
41
49
|
(e: 'update:searchQuery', value: string): void;
|
|
50
|
+
(e: 'update:value', value: string): void;
|
|
42
51
|
(e: 'select', item: CommandItemData): void;
|
|
43
52
|
}
|
|
44
53
|
/** Props for CommandDialog โ extends shared root props with items array */
|
package/dist/useCommandMenu.d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { Ref, ComputedRef } from 'vue';
|
|
2
2
|
import { CommandItemData, CommandGroupData } from './types';
|
|
3
3
|
export type FilterFn = (items: CommandItemData[], query: string) => CommandItemData[] | null;
|
|
4
|
+
export interface UseCommandMenuOptions {
|
|
5
|
+
/** Custom filter function */
|
|
6
|
+
filter?: FilterFn;
|
|
7
|
+
/** When false, skip built-in filtering */
|
|
8
|
+
shouldFilter?: boolean;
|
|
9
|
+
/** When false, keyboard navigation stops at boundaries */
|
|
10
|
+
loop?: boolean;
|
|
11
|
+
}
|
|
4
12
|
export interface UseCommandMenuReturn {
|
|
5
13
|
visible: Ref<boolean>;
|
|
6
14
|
searchQuery: Ref<string>;
|
|
7
15
|
activeIndex: Ref<number>;
|
|
16
|
+
selectedValue: Ref<string | undefined>;
|
|
8
17
|
items: Ref<CommandItemData[]>;
|
|
9
18
|
toggle: () => void;
|
|
10
19
|
open: () => void;
|
|
@@ -17,4 +26,4 @@ export interface UseCommandMenuReturn {
|
|
|
17
26
|
selectPrev: () => void;
|
|
18
27
|
selectCurrent: () => void;
|
|
19
28
|
}
|
|
20
|
-
export declare function useCommandMenu(
|
|
29
|
+
export declare function useCommandMenu(optionsOrFilter?: UseCommandMenuOptions | FilterFn, onItemSelect?: (item: CommandItemData) => void): UseCommandMenuReturn;
|
package/dist/useCommandRoot.d.ts
CHANGED