SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

paletteController

The browser half of the command palette.

tsx
import { paletteController } from "@sdxc/ui/app";

Usage

Wires the palette <dialog> the host sits in, for as long as the host stays mounted.

Signature

typescript
paletteController(options: PaletteController.Options): MixinDescriptor<HTMLElement>

Parameters

ParameterTypeRequiredDescription
optionsPaletteController.OptionsYesThe toggle key, the copy it announces with, and where recents come from.

Examples

tsx
<div hidden mix={[paletteController({ shortcut: "mod+k", open: "Open command menu", results: "{count} results", recent: [] })]} />

The events, constants and types its module publishes, each imported from @sdxc/ui/app too.

Constant

PALETTE_RECENT_LIMIT

How many recent commands the palette offers before anything is typed.

typescript
const PALETTE_RECENT_LIMIT = 5
Constant

PALETTE_ITEM_ATTRIBUTE

Marks each row with its command's id, which recent and the remembered list name.

typescript
const PALETTE_ITEM_ATTRIBUTE = "data-palette-item"
Constant

PALETTE_CONTROL_ATTRIBUTE

Marks the link or button a row presses.

typescript
const PALETTE_CONTROL_ATTRIBUTE = "data-palette-control"
Constant

PALETTE_GOTO_ATTRIBUTE

Names the page a row's control opens instead of acting.

typescript
const PALETTE_GOTO_ATTRIBUTE = "data-palette-goto"
Constant

PALETTE_PAGE_ATTRIBUTE

Marks a page of commands with its id.

typescript
const PALETTE_PAGE_ATTRIBUTE = "data-palette-page"
Constant

PALETTE_CLONE_ATTRIBUTE

Marks a row the island copied into the Recent group.

typescript
const PALETTE_CLONE_ATTRIBUTE = "data-palette-clone"
Constant

PALETTE_HINT_ATTRIBUTE

Marks a shortcut hint with the combo it prints, so the island reprints it per platform.

typescript
const PALETTE_HINT_ATTRIBUTE = "data-shortcut-hint"
Function

foldSearchText

Lower-cases text and strips its accents, so "cafe" finds "Café" and "Équipe" finds "equipe".

typescript
foldSearchText(value: string): string
ParameterTypeRequiredDescription
valuestringYesText to fold.
Type

PaletteController.Options

Plain data only, since the options cross into the browser with the palette's island.

typescript
type PaletteController.Options = {
		/** The combo that toggles the palette. */
		shortcut: string;
		/** The help-sheet label of that combo. */
		open: string;
		/** The announced result count, with `{count}` replaced. */
		results: string;
		/** Ids of commands the server offers under Recent. */
		recent: string[];
		/** The `localStorage` key commands run from the palette are remembered under. */
		remember?: string;
	}
@sdxc/ui

Can’t find it? Contact us