Mixins / foldkit-mixins-ui

Command

namespace · packages/mixins-ui/src/command.ts:1

export * as Command from './command.js'

Members

Command.CommandGroup

interface · packages/mixins-ui/src/command.ts:46

interface CommandGroup<Value extends string> {
  readonly heading?: string | undefined
  readonly items: ReadonlyArray<CommandItem<Value>>
}

Command.CommandHint

interface · packages/mixins-ui/src/command.ts:52

interface CommandHint {
  readonly keys: Keys
  readonly label: string
}

A key named in the footer: what pressing it does.

Command.CommandItem

interface · packages/mixins-ui/src/command.ts:30

interface CommandItem<Value extends string> {
  readonly value: Value
  readonly label: string
  readonly description?: string | undefined
  readonly keywords?: ReadonlyArray<string> | undefined
  readonly shortcut?: Keys | undefined
  readonly icon?: Html | undefined
  readonly opensPage?: boolean | undefined
  readonly disabled?: boolean | undefined
}

Command.CommandKeyInput

interface · packages/mixins-ui/src/command.ts:65

interface CommandKeyInput<Value extends string> {
  readonly query: string
  readonly current: Option.Option<Value>
  readonly rows: ReadonlyArray<Value>
}

What a key route reads: the field's words, the highlighted row and the rows ↑↓ can reach.

Command.CommandPage

interface · packages/mixins-ui/src/command.ts:57

interface CommandPage<Message> {
  readonly trail: ReadonlyArray<string>
  readonly onBack: NoInfer<Message>
}

Command.CommandPreset

type · packages/mixins-ui/src/command.ts:420

type CommandPreset = Pick<
  CommandView<string, never>,
  'placeholder' | 'words' | 'hints' | 'style' | 'kbd'
> & {
  readonly mixins?: MixinList<never>
}

What a Command is given once: its wording, hints, look and mixins. The query, rows and Messages are each use's.

Command.CommandRoute

type · packages/mixins-ui/src/command.ts:74

type CommandRoute<Value extends string, Message> = Behaviors.Keys.Route<
  CommandKeyInput<Value>,
  Message
>

A key the menu answers beside its own; see CommandView.routes.

Command.CommandSlots

const · packages/mixins-ui/src/command/slots.ts:23

const CommandSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly search: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly crumbs: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly crumb: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly input: Slot.UnnamedSlot<Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [Event.EventToken<"input">, Event.EventToken<"keydown">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-expanded">], readonly Slot.RequirementName[], boolean>; readonly list: Slot.UnnamedSlot<Cap …;

A command menu, shadcn's Command and Fluid Functionalism's CommandMenu: a search field that keeps focus while the keys move through the rows and points at the highlighted one through aria-activedescendant, over a list of grouped rows. (A press on a row runs it; foldkit has no default-preventing mousedown to keep the field focused through the press, so a menu that stays open after a pressed row refocuses its field in the Command onRun starts.) ↑ and ↓ wrap through the enabled rows, Enter runs the highlighted one, a press runs the one pressed, and the pointer moves the highlight. Rows never re-sort as the query grows, so nothing moves under the pointer; whenever the highlighted row is filtered away, the first enabled row takes it, so Enter always has a target. The query, the highlighted value and the page are the application's; filtered is what the view shows for a query.

Nested pages are the application's too: a row that opensPage steps in when run (the application pushes the page and clears the query), and Backspace in an empty field sends page.onBack. In a dialog, hotkey opens it on ⌘K or Ctrl+K, and the Dialog component draws it: the field, the first thing in the panel that takes focus, has it when it opens.

Command.CommandView

interface · packages/mixins-ui/src/command.ts:82

interface CommandView<Value extends string, Message> {
  readonly id: string
  readonly label: string
  readonly placeholder?: string | undefined
  readonly groups: ReadonlyArray<CommandGroup<Value>>
  readonly query: string
  readonly onQuery: (query: string) => NoInfer<Message>
  readonly active: Option.Option<Value>
  readonly onActive: (value: Value) => NoInfer<Message>
  readonly onRun: (value: Value) => NoInfer<Message>
  readonly loading?: boolean | undefined
  readonly words?: Partial<CommandWords> | undefined
  readonly page?: CommandPage<Message> | undefined
  readonly routes?:
    ReadonlyArray<CommandRoute<Value, NoInfer<Message>>> | undefined
  readonly hints?: ReadonlyArray<CommandHint> | undefined
  readonly style?: NamedStyle<typeof CommandSlots> | undefined
  readonly kbd?: NamedStyle<typeof KbdSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

Command.CommandWords

interface · packages/mixins-ui/src/command/words.ts:2

interface CommandWords {
  readonly empty: string
  readonly loading: string
}

The fixed text a Command says.

Command.configure

function · packages/mixins-ui/src/command.ts:429

function configure<const Names extends string = never>(
  config: Presets<CommandPreset, Names>,
): {
  readonly view: <Value extends string, Outer>(
    options: CommandView<Value, Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own Command: base for every use, presets chosen at a use with preset, and the call over both.

Command.conflict

function · packages/mixins-ui/src/command.ts:175

function conflict<Value extends string, Message>(
  routes: ReadonlyArray<CommandRoute<Value, Message>>,
): Option.Option<Diagnostic>

The mixins:key-conflict that drawing the menu with routes would throw, or none: the application's routes against the menu's own (the arrows, PageUp, PageDown, Enter and Backspace) and against each other.

Command.filtered

function · packages/mixins-ui/src/command.ts:128

function filtered<Value extends string>(
  groups: ReadonlyArray<CommandGroup<Value>>,
  query: string,
): ReadonlyArray<CommandGroup<Value>>

The groups as a query leaves them: a row stays when every word of the query is in its label, description or keywords, whatever their case, in its place; a group left with no rows goes.

Command.hotkey

function · packages/mixins-ui/src/command.ts:393

function hotkey<Message>(message: Message): Stream.Stream<Message>

The keys that open a command menu in a dialog, ⌘K or Ctrl+K, anywhere on the page, as message: the browser's own use of them is kept from it. Lift it with Subscription.persistentEntry; the application opens its Dialog on the Message.

Command.keepActiveInView

const · packages/mixins-ui/src/command.ts:412

const keepActiveInView: readonly [Mixin<never>]

Scrolls the highlighted row into view as the keys move it, the least that shows it, in a list taller than its panel. Pass it beside the style. Not a default, for the reason overlayBars is not: its Mount sends no Message.

Command.Keys

type · packages/mixins-ui/src/command.ts:28

type Keys = readonly [string, ...ReadonlyArray<string>]

Keys pressed together, as drawn: ['⌘', 'N'].

Command.overlayBars

const · packages/mixins-ui/src/command/overlayBars.ts:11

const overlayBars: readonly [Mixin<never>]

What draws the bar over the list (ScrollBars), in place of the browser's, on a pointer that can hover; pass it beside the style. Not a default: its Mount sends no Message, yet a Scene test of every page that drew one would have to resolve it.

Command.view

function · packages/mixins-ui/src/command.ts:183

function view<Value extends string, Message>(
  options: CommandView<Value, Message>,
  h: HtmlBuilder<Message>,
): Html

Command.words

const · packages/mixins-ui/src/command/words.ts:10

const words = { empty, loading }

The words a Command uses when none are given.