Command

Une liste et une palette de commandes avec recherche : champ combobox, options surlignées au clavier, groupes et filtrage intégré.

Disponible pour
  • Angular: disponible
  • Vue: disponible
  • React: disponible
  • React Native: pas encore disponible

Utilisation

Selected: nothing yet

Importation

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

Référence de l’API

SoneCommandComponentComposant

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

Sélecteur
sone-command
Inputs
NomType Par défaut
searchbidirectionnel

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
activebidirectionnel

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

string | nullnull

SoneCommandDialogComponentComposant

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

Sélecteur
sone-command-dialog
Inputs
NomType Par défaut
labelobligatoire

Names the dialog for assistive technology.

string—
sizeDialogSize"md"
Outputs
NomType
dismissvoid

SoneCommandEmptyDirectiveDirective

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

Sélecteur
[soneCommandEmpty]

SoneCommandGroupComponentComposant

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

Sélecteur
[soneCommandGroup]
Inputs
NomType Par défaut
headingstring | nullnull

SoneCommandInputDirectiveDirective

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

Sélecteur
input[soneCommandInput]

SoneCommandItemDirectiveDirective

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

Sélecteur
[soneCommandItem]
Inputs
NomType Par défaut
valuestring | nullnull
keywordsreadonly string[][]
disabledbooleanfalse
idstringsoneId("sone-command-item")
Outputs
NomType
select

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

string

SoneCommandListDirectiveDirective

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

Sélecteur
[soneCommandList]
Inputs
NomType Par défaut
idstringsoneId("sone-command-list")

SoneCommandSeparatorDirectiveDirective

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

Sélecteur
[soneCommandSeparator]