Typeahead.Args
const · packages/primitives/src/interaction/typeahead.ts:33
const Args: Schema.Struct<{ readonly timeoutMs: Schema.Number }>Primitives / foldkit-primitives/interaction
namespace · packages/primitives/src/interaction/typeahead.ts:7
export * as Typeahead from './typeahead.js'Typeahead over a set of items: printable keys build a query that a timer clears, and the query picks the item to move to. The query lives in the Model so a replay sees the same picks; the timer runs on Effect's clock so TestClock drives it. Which item matches is a pure function.
Typeahead.Argsconst · packages/primitives/src/interaction/typeahead.ts:33
const Args: Schema.Struct<{ readonly timeoutMs: Schema.Number }>Typeahead.behaviorfunction · packages/primitives/src/interaction/typeahead.ts:159
function behavior<Field extends string>(
declared: Declared<typeof bundle, Field>,
): {
<Slots, Input extends { readonly [K in Field]: Model }, ParentMessage>(
bound: SlotView.Bound<Slots, Input, ParentMessage>,
): (
options: BehaviorOptions<Input, Slots>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
<Slots>(
slots: SlotView.Unbound<Slots>,
): <Input extends { readonly [K in Field]: Model }, ParentMessage>(
options: BehaviorOptions<Input, Slots>,
) => Behavior.NamedBehavior<Slots, Input, ParentMessage>
}Wires a placed Typeahead to the host slot with the keys route.
Typeahead.BehaviorOptionsinterface · packages/primitives/src/interaction/typeahead.ts:117
interface BehaviorOptions<Input, Slots> extends KeyOptions<Input> {
readonly host: keyof Slots & string
}Typeahead.bundleconst · packages/primitives/src/interaction/typeahead.ts:61
const bundle: Bundle.Bundle<
'Typeahead',
{ readonly timeoutMs: number },
{ readonly query: string; readonly generation: number },
| { readonly _tag: 'Cleared' }
| { readonly _tag: 'Typed'; readonly char: string }
| { readonly _tag: 'Expired'; readonly generation: number },
never,
never,
never,
NoView,
{},
{
clear: (
model: Model,
) => Readonly<{
model: { readonly query: string; readonly generation: number }
commands?: Update.Commands<
| { readonly _tag: 'Cleared' }
| { readonly _tag: 'Typed'; readonly char: string }
| { readonly _tag: 'Expired'; readonly generation: number },
never
>
outMessage?: never
}>
},
undefined
>Typeahead.isPrintablefunction · packages/primitives/src/interaction/typeahead.ts:105
function isPrintable(key: string, modifiers: KeyboardModifiers): booleanOne character (a code point, not a UTF-16 unit) with no ctrl, alt or meta: a typeahead key.
Typeahead.KeyOptionsinterface · packages/primitives/src/interaction/typeahead.ts:108
interface KeyOptions<Input> {
readonly items: (input: Input) => Behaviors.Collection.Items<unknown>
readonly text: (input: Input, index: number) => string
readonly current: (input: Input) => string | null
}Typeahead.keysfunction · packages/primitives/src/interaction/typeahead.ts:129
function keys<Field extends string>(
declared: Declared<typeof bundle, Field>,
): <Input extends { readonly [K in Field]: Model }, ParentMessage>(
options: KeyOptions<Input>,
) => Behaviors.Keys.Route<Input, ParentMessage>The route a Typeahead installs on its host: every printable key extends
the query, focuses the matching item by its id (which then reports itself
current, through RovingTabindex's OnFocus), and answers Typed. With no
match the key still extends the query, so the next one can match; a space
with an empty query is left to the host (it activates).
Typeahead.matchfunction · packages/primitives/src/interaction/typeahead.ts:86
function match(
texts: ReadonlyArray<string>,
enabled: ReadonlyArray<number>,
query: string,
current: number,
): number | undefinedThe enabled index whose text starts with query, searching forward from
current and wrapping, or undefined. A query of one character, or one
character repeated (aaa), starts after the current item so repeated
presses cycle through the items that begin with it; a longer query starts
at the current item, since the user is refining a match. Case and leading
whitespace are ignored.
Typeahead.Messageconst · packages/primitives/src/interaction/typeahead.ts:23
const Message: MessageUnion<{
readonly Typed: { readonly char: Schema.String }
readonly Expired: { readonly generation: Schema.Number }
readonly Cleared: {}
}>Typeahead.Modelconst · packages/primitives/src/interaction/typeahead.ts:15
const Model: Schema.Struct<{
readonly query: Schema.String
readonly generation: Schema.Number
}>