CommandPalette
Description
A command palette utility
CommandPalette provides a fast and efficient way for users to navigate an application and trigger commands using only their keyboard. Inspired by modern editors and tools, it allows users to search through a list of actions and execute them with a single keystroke.
API reference
public sealed class CommandPalette : Layer<CommandPalette>A keyboard-driven full-screen command launcher (Ctrl/Cmd-K style) that lets users search and invoke application commands.
- Namespace
- Tesserae
- Inheritance
- Layer<CommandPalette> → CommandPalette
Constructors
| Name | Description |
|---|---|
| CommandPalette | Creates a CommandPalette whose global Ctrl/Cmd keyboard listener is bound to the lifetime of host: the listener is attached when host first mounts to the DOM and detached when it is removed. This prevents the palette from leaking listeners (and continuing to respond to its shortcut) after the owning view has been navigated away. |
public CommandPalette(IComponent host, IEnumerable<CommandPaletteAction> actions = null)Creates a CommandPalette whose global Ctrl/Cmd keyboard listener is bound to the lifetime of host: the listener is attached when host first mounts to the DOM and detached when it is removed. This prevents the palette from leaking listeners (and continuing to respond to its shortcut) after the owning view has been navigated away.
Properties
| Name | Description |
|---|---|
| EnableGlobalShortcut | Enables the global shortcut on the component. |
| EnableGlobalActionShortcuts | Enables the global action shortcuts on the component. |
| HideOnAction | Hides the on action. |
| GlobalShortcutKey | Key (combined with Ctrl/Cmd) that toggles the palette globally. Case-insensitive. Defaults to "k". |
| Placeholder | Gets or sets the placeholder text shown when the component is empty. |
public bool EnableGlobalShortcut { get; set; }Enables the global shortcut on the component.
public bool EnableGlobalActionShortcuts { get; set; }Enables the global action shortcuts on the component.
public string GlobalShortcutKey { get; set; }Key (combined with Ctrl/Cmd) that toggles the palette globally. Case-insensitive. Defaults to "k".
Methods
| Name | Description |
|---|---|
| SetActions | Sets the actions of the component. |
| AddAction | Adds the given action to the component. |
| Open | Opens the component. |
| Close | Closes the component. |
| Toggle | Toggles the component's state. |
| Show | Shows the component. |
| Hide | Hides the component. |
public CommandPalette SetActions(IEnumerable<CommandPaletteAction> actions)Sets the actions of the component.
public CommandPalette AddAction(CommandPaletteAction action)Adds the given action to the component.
Events
| Name | Description |
|---|---|
| ActionExecuted | Raised when action executed occurs. |
public sealed class CommandPaletteAction- Namespace
- Tesserae
Constructors
| Name | Description |
|---|---|
| CommandPaletteAction | Initializes a new instance of this class. |
Properties
| Name | Description |
|---|---|
| Id | Sets the DOM id of the component. |
| Name | Gets or sets the name of the component. |
| Subtitle | Gets or sets the subtitle. |
| Keywords | Gets or sets the keywords. |
| Section | Gets or sets the section. |
| ParentId | Gets or sets the parent id. |
| Icon | Gets or sets the icon shown by the component. |
| Shortcut | Gets or sets the shortcut. |
| IsEnabled | Gets or sets a value indicating whether the component is interactive (enabled). |
| IsVisible | Gets a value indicating whether the component is currently visible. |
| Perform | Gets or sets the perform. |
public string Name { get; set; }Gets or sets the name of the component.
public string ParentId { get; set; }Gets or sets the parent id.
public UIcons? Icon { get; set; }Gets or sets the icon shown by the component.
public string[] Shortcut { get; set; }Gets or sets the shortcut.
public bool IsEnabled { get; set; }Gets or sets a value indicating whether the component is interactive (enabled).
public bool IsVisible { get; set; }Gets a value indicating whether the component is currently visible.