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]