Command

可搜索的命令列表与命令面板——组合框输入、键盘高亮选项、分组和内置筛选。

可用框架
  • Angular: 可用
  • Vue: 可用
  • React: 可用
  • React Native: 暂不可用

用法

Selected: nothing yet

导入

ts
import {
  SoneCommandComponent,
  SoneCommandDialogComponent,
  SoneCommandEmptyDirective,
  SoneCommandGroupComponent,
  SoneCommandInputDirective,
  SoneCommandItemDirective,
  SoneCommandListDirective,
  SoneCommandSeparatorDirective,
} from "@surface-one/angular/command";

API 参考

SoneCommandComponent组件

`<sone-command>` — a filterable command list (shadcn/ui Command, spartan/ui brn-command): a combobox input over a listbox. The input keeps focus; the highlighted option is announced through `aria-activedescendant`. Arrow keys, Home / End and PageUp / PageDown move the highlight, Enter selects it. Filtering is built in (case- and accent-insensitive, item `value` + `keywords`); set `shouldFilter` to `false` when the list already comes filtered from a server.

选择器
sone-command
输入
名称类型 默认值
search双向

The search text — `[(search)]`; the `soneCommandInput` writes it.

string""
shouldFilter

Filter the items by `search`. Turn off for server-side search.

booleantrue
filter

A custom match function (default `soneCommandFilter`).

SoneCommandFiltersoneCommandFilter
loop

Arrow keys wrap from the last option to the first.

booleanfalse
active双向

The highlighted option's value — `[(active)]`.

string | nullnull

SoneCommandDialogComponent组件

`<sone-command-dialog>` — a `sone-dialog` sized and padded for a command palette (shadcn/ui CommandDialog). Project a `<sone-command>` into it; render it with `@if` and close it on `(dismiss)`, like any dialog. Escape, the scrim and focus return come from `sone-dialog`.

选择器
sone-command-dialog
输入
名称类型 默认值
label必填

Names the dialog for assistive technology.

string—
sizeDialogSize"md"
输出
名称类型
dismissvoid

SoneCommandEmptyDirective指令

`[soneCommandEmpty]` — shown only when no option matches.

选择器
[soneCommandEmpty]

SoneCommandGroupComponent组件

`[soneCommandGroup]` — a labelled group of options; it hides when none of them match.

选择器
[soneCommandGroup]
输入
名称类型 默认值
headingstring | nullnull

SoneCommandInputDirective指令

`input[soneCommandInput]` — the combobox that searches the command list and keeps focus.

选择器
input[soneCommandInput]

SoneCommandItemDirective指令

`[soneCommandItem]` — one option. `value` is what the search matches (default: the text content) and what `select` emits; `keywords` match too.

选择器
[soneCommandItem]
输入
名称类型 默认值
valuestring | nullnull
keywordsreadonly string[][]
disabledbooleanfalse
idstringsoneId("sone-command-item")
输出
名称类型
select

Chosen with a click or Enter; emits the item's value.

string

SoneCommandListDirective指令

`[soneCommandList]` — the listbox; it scrolls when the options overflow.

选择器
[soneCommandList]
输入
名称类型 默认值
idstringsoneId("sone-command-list")

SoneCommandSeparatorDirective指令

`[soneCommandSeparator]` — a divider between groups; hidden while searching.

选择器
[soneCommandSeparator]