外观
Command 命令面板
让用户输入名称筛选命令,并用鼠标或键盘执行匹配项。
import { SCommand } from '@icecreamqaq/shadcn/command'使用示例
常用 API
| 成员 | 类型 | 用法 |
|---|---|---|
SCommandDialog.open | boolean | 通过 v-model:open 控制面板的打开状态。 |
SCommandDialog.title / description | string | 为对话框提供读屏名称和使用说明。 |
SCommandItem.value | AcceptableValue | 为选项提供稳定的值,显示文本用于搜索匹配。 |
SCommandItem.@select | 事件 | 在确认选项时执行命令,可在回调中关闭命令面板。 |
SCommandEmpty | 默认插槽 | 输入查询且没有匹配项时显示。 |
内嵌列表使用 SCommand 作为根节点。SCommandDialog 已包含这个根节点,可直接放入 SCommandInput 和 SCommandList。
完整 API
Command30 个成员
属性
| 名称 | 类型 |
|---|---|
modelValue | AcceptableValue | AcceptableValue[] |
defaultValue | AcceptableValue | AcceptableValue[] |
multiple | boolean |
max | number |
orientation | DataOrientation |
dir | Direction |
disabled | boolean |
selectionBehavior | "replace" | "toggle" |
highlightOnHover | boolean |
loop | boolean |
by | string | ((a: AcceptableValue, b: AcceptableValue) => boolean) |
keepFocusOnValueChange | boolean |
asChild | boolean |
as | AsTag | Component |
name | string |
required | boolean |
class | ClassValue |
search | string |
defaultSearch | string |
options | readonly SelectEntry[] |
placeholder | string |
renderOption | RenderContent<{ option: SelectOption; }> |
事件
| 名称 | 类型 |
|---|---|
invalid | ((payload: AcceptableValue) => any) |
update:modelValue | ((value: AcceptableValue) => any) |
highlight | ((payload: { ref: HTMLElement; value: AcceptableValue; } | undefined) => any) |
update:search | ((value: string) => any) |
entryFocus | ((event: CustomEvent<any>) => any) |
leave | ((event: Event) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
empty | ((props: {}) => any) |
CommandDialog8 个成员
属性
| 名称 | 类型 |
|---|---|
open | boolean |
defaultOpen | boolean |
modal | boolean |
unmountOnHide | boolean |
title | string |
description | string |
事件
| 名称 | 类型 |
|---|---|
update:open | ((value: boolean) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: { open: boolean; close: () => void; }) => any) |
CommandEmpty4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CommandGroup5 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
heading | string |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CommandInput8 个成员
属性
| 名称 | 类型 |
|---|---|
modelValue | string |
autoFocus | boolean |
disabled | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
defaultValue | string |
事件
| 名称 | 类型 |
|---|---|
update:modelValue | ((value: string) => any) |
CommandItem8 个成员
属性
| 名称 | 类型 |
|---|---|
value 必填 | AcceptableValue |
disabled | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
textValue | string |
事件
| 名称 | 类型 |
|---|---|
select | ((event: CustomEvent<{ originalEvent: PointerEvent; value?: AcceptableValue | undefined; }>) => any) |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CommandList4 个成员
属性
| 名称 | 类型 |
|---|---|
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CommandSeparator6 个成员
属性
| 名称 | 类型 |
|---|---|
orientation | DataOrientation |
decorative | boolean |
asChild | boolean |
as | AsTag | Component |
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
CommandShortcut2 个成员
属性
| 名称 | 类型 |
|---|---|
class | ClassValue |
插槽
| 名称 | 类型 |
|---|---|
default | ((props: {}) => any) |
分组导出
模板标签为 <s-command>。
组件 SCommand、SCommandDialog、SCommandEmpty、SCommandGroup、SCommandInput、SCommandItem、SCommandList、SCommandSeparator、SCommandShortcut
函数与常量 provideCommandContext、provideCommandGroupContext、useCommand、useCommandGroup
类型 CommandSearchInput