Mixins / foldkit-mixins-ui

SearchField

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

export * as SearchField from './searchField.js'

In the guides

Members

SearchField.conflict

function · packages/mixins-ui/src/searchField.ts:138

function conflict<Message>(
  routes: ReadonlyArray<Route<Message>>,
): Option.Option<Diagnostic>

The mixins:key-conflict that drawing the field with routes would throw, or none: the application's routes against Escape and against each other.

SearchField.Focus

const · packages/mixins-ui/src/searchField.ts:74

const Focus: Command.CommandDefinitionWithArgs<
  'SearchField.Focus',
  { id: Schema.String },
  Effect.Effect<{ readonly _tag: 'CompletedFocus' }, never, never>
>

Focuses the input of the field with id; a missing input is not an error.

SearchField.inputId

function · packages/mixins-ui/src/searchField.ts:71

function inputId(id: string): string

The id of the field's input, for id given to view.

SearchField.Message

const · packages/mixins-ui/src/searchField.ts:64

const Message: MessageUnion<{ readonly CompletedFocus: {} }>

SearchField.Route

type · packages/mixins-ui/src/searchField.ts:82

type Route<Message> = Behaviors.Keys.Route<string, Message>

A key the field answers beside Escape; its input is the text.

SearchField.SearchFieldPattern

const · packages/mixins-ui/src/searchField.ts:51

const SearchFieldPattern: A11y.Pattern<{
  readonly input: {
    readonly capability: Capability.Capability<
      'TextInput',
      readonly [
        Capability.Capability<
          'Focusable',
          readonly [
            Capability.Capability<
              'Interactive',
              readonly [Capability.Capability<'Base', readonly []>]
            >,
          ]
        >,
      ]
    >
    readonly events: readonly [
      Event.EventToken<'input'>,
      Event.EventToken<'keydown'>,
    ]
    readonly attributes: readonly [Attr.AttrToken<'aria-label'>]
  }
  readonly clear: {
    readonly capability: Capability.Capability<
      'Interactive',
      readonly [Capability.Capability<'Base', readonly []>]
    >
    readonly events: readonly [Event.EventToken<'click'>]
    readonly attributes: readonly [Attr.AttrToken<'aria-label'>]
  }
}>

The input's role is native searchbox; the name has to be given, and clearing must be a control.

SearchField.SearchFieldSlots

const · packages/mixins-ui/src/searchField.ts:35

const SearchFieldSlots: Slots.Contract<{ readonly input: Slot.UnnamedSlot<Capability.Capability<"TextInput", readonly [Capability.Capability<"Focusable", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>]>, readonly [Event.EventToken<"input">, Event.EventToken<"keydown">], readonly [Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-invalid">, Attr.AttrToken<"disabled">, Attr.AttrToken<"value">], readonly Slot.RequirementName[], boolean>; readonly clear: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"aria-label">], readonly Slot.RequirementName[], boolean>; readonly group: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [], readonly [], readonly [], false>; readonly start: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [], readonly [], readonly [], false>; readonly end: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly [], readonly [], readonly [], false>; readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonl …;

A text field for searching: a native type="search" input (role searchbox) in one box with a magnifier at its start (or your own start) and a button that clears it, drawn only while there is text. The view holds no state: the application owns the text, onInput reports typing and clear.onClear is what the button and Escape send. Escape clears only a field with text, so on an empty one it reaches an enclosing dialog.

Pressing the button removes it, and the focus it held with it. Answer onClear with Focus, which puts focus back on the input; a Mount could do it without the application, but one that sends no Message cannot be resolved by a Scene test of every page drawing the field.

SearchField.SearchFieldView

interface · packages/mixins-ui/src/searchField.ts:89

interface SearchFieldView<Message> extends Adornments {
  readonly id: string
  readonly label: string
  readonly value: string
  readonly onInput: OnInput<NoInfer<Message>>
  readonly clear?:
    | {
        readonly onClear: NoInfer<Message>
        readonly content?: Html | undefined
      }
    | undefined
  readonly busy?: boolean | undefined
  readonly placeholder?: string | undefined
  readonly invalid?: boolean | undefined
  readonly disabled?: boolean | undefined
  readonly words?: SearchFieldWords | undefined
  readonly routes?: ReadonlyArray<Route<NoInfer<Message>>> | undefined
  readonly style?: NamedStyle<typeof SearchFieldSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

SearchField.SearchFieldWords

interface · packages/mixins-ui/src/searchField.ts:84

interface SearchFieldWords {
  readonly clear?: string | undefined
}

SearchField.view

function · packages/mixins-ui/src/searchField.ts:146

function view<Message>(
  options: SearchFieldView<Message>,
  h: HtmlBuilder<Message>,
): Html