Command

Uma lista e paleta de comandos com busca: campo combobox, opções destacadas pelo teclado, grupos e filtragem integrada.

Disponível em
  • Angular: disponível
  • Vue: disponível
  • React: disponível
  • React Native: ainda não disponível

Uso

Selected: nothing yet

Importação

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

Referência da API

SoneCommandComponentComponente

`<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.

Seletor
sone-command
Inputs
NomeTipo Padrão
searchbidirecional

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
activebidirecional

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

string | nullnull

SoneCommandDialogComponentComponente

`<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`.

Seletor
sone-command-dialog
Inputs
NomeTipo Padrão
labelobrigatório

Names the dialog for assistive technology.

string—
sizeDialogSize"md"
Outputs
NomeTipo
dismissvoid

SoneCommandEmptyDirectiveDiretiva

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

Seletor
[soneCommandEmpty]

SoneCommandGroupComponentComponente

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

Seletor
[soneCommandGroup]
Inputs
NomeTipo Padrão
headingstring | nullnull

SoneCommandInputDirectiveDiretiva

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

Seletor
input[soneCommandInput]

SoneCommandItemDirectiveDiretiva

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

Seletor
[soneCommandItem]
Inputs
NomeTipo Padrão
valuestring | nullnull
keywordsreadonly string[][]
disabledbooleanfalse
idstringsoneId("sone-command-item")
Outputs
NomeTipo
select

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

string

SoneCommandListDirectiveDiretiva

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

Seletor
[soneCommandList]
Inputs
NomeTipo Padrão
idstringsoneId("sone-command-list")

SoneCommandSeparatorDirectiveDiretiva

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

Seletor
[soneCommandSeparator]