Command

Lista poleceń i paleta z wyszukiwaniem — pole combobox, opcje podświetlane z klawiatury, grupy i wbudowane filtrowanie.

Dostępny w
  • Angular: dostępny
  • Vue: dostępny
  • React: dostępny
  • React Native: jeszcze niedostępny

Użycie

Selected: nothing yet

Import

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

Dokumentacja API

SoneCommandComponentKomponent

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

Selektor
sone-command
Wejścia
NazwaTyp Domyślnie
searchdwukierunkowe

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
activedwukierunkowe

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

string | nullnull

SoneCommandDialogComponentKomponent

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

Selektor
sone-command-dialog
Wejścia
NazwaTyp Domyślnie
labelwymagane

Names the dialog for assistive technology.

string—
sizeDialogSize"md"
Wyjścia
NazwaTyp
dismissvoid

SoneCommandEmptyDirectiveDyrektywa

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

Selektor
[soneCommandEmpty]

SoneCommandGroupComponentKomponent

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

Selektor
[soneCommandGroup]
Wejścia
NazwaTyp Domyślnie
headingstring | nullnull

SoneCommandInputDirectiveDyrektywa

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

Selektor
input[soneCommandInput]

SoneCommandItemDirectiveDyrektywa

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

Selektor
[soneCommandItem]
Wejścia
NazwaTyp Domyślnie
valuestring | nullnull
keywordsreadonly string[][]
disabledbooleanfalse
idstringsoneId("sone-command-item")
Wyjścia
NazwaTyp
select

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

string

SoneCommandListDirectiveDyrektywa

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

Selektor
[soneCommandList]
Wejścia
NazwaTyp Domyślnie
idstringsoneId("sone-command-list")

SoneCommandSeparatorDirectiveDyrektywa

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

Selektor
[soneCommandSeparator]