Command

Un elenco e una palette di comandi con ricerca: campo combobox, opzioni evidenziate da tastiera, gruppi e filtro integrato.

Disponibile in
  • Angular: disponibile
  • Vue: disponibile
  • React: disponibile
  • React Native: non ancora disponibile

Utilizzo

Selected: nothing yet

Importazione

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

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

Selettore
sone-command
Input
NomeTipo Predefinito
searchbidirezionale

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
activebidirezionale

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

Selettore
sone-command-dialog
Input
NomeTipo Predefinito
labelobbligatorio

Names the dialog for assistive technology.

string—
sizeDialogSize"md"
Output
NomeTipo
dismissvoid

SoneCommandEmptyDirectiveDirettiva

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

Selettore
[soneCommandEmpty]

SoneCommandGroupComponentComponente

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

Selettore
[soneCommandGroup]
Input
NomeTipo Predefinito
headingstring | nullnull

SoneCommandInputDirectiveDirettiva

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

Selettore
input[soneCommandInput]

SoneCommandItemDirectiveDirettiva

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

Selettore
[soneCommandItem]
Input
NomeTipo Predefinito
valuestring | nullnull
keywordsreadonly string[][]
disabledbooleanfalse
idstringsoneId("sone-command-item")
Output
NomeTipo
select

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

string

SoneCommandListDirectiveDirettiva

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

Selettore
[soneCommandList]
Input
NomeTipo Predefinito
idstringsoneId("sone-command-list")

SoneCommandSeparatorDirectiveDirettiva

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

Selettore
[soneCommandSeparator]