Mixins / foldkit-mixins-ui

Input

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

export * as Input from './input.js'

In the guides

Members

Input.field

function · packages/mixins-ui/src/input.ts:234

function field<Message>(
  options: InputField<Message>,
  h: HtmlBuilder<Message>,
): Html

Input.InputCommon

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

interface InputCommon<Message> {
  readonly id: string
  readonly value?: string | undefined
  readonly onInput?: OnInput<Message> | undefined
  readonly disabled?: boolean | undefined
  readonly invalid?: boolean | undefined
  readonly type?: string | undefined
  readonly placeholder?: string | undefined
  readonly name?: string | undefined
  readonly readOnly?: boolean | undefined
  readonly required?: boolean | undefined
  readonly autocomplete?: string | undefined
  readonly inputMode?:
    | 'none'
    | 'text'
    | 'decimal'
    | 'numeric'
    | 'tel'
    | 'search'
    | 'email'
    | 'url'
    | undefined
  readonly maxLength?: number | undefined
  readonly attributes?:
    | {
        readonly [K in keyof typeof InputSlots]?: ReadonlyArray<
          Attribute<NoInfer<Message>>
        >
      }
    | undefined
  readonly style?: NamedStyle<typeof InputSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
  readonly input?: unknown
}

Input.InputDrawn

type · packages/mixins-ui/src/input.ts:100

type InputDrawn = {
  readonly label: string
  readonly description?: string | undefined
  readonly labelAside?: Html | undefined
  readonly draw?: undefined
  readonly described?: undefined
} & Adornments

The options of an input drawn by the view itself, from a label.

Input.InputField

interface · packages/mixins-ui/src/input.ts:220

interface InputField<Message> {
  readonly id: string
  readonly label: string
  readonly field: FieldValidation.Field<unknown>
  readonly changed: (value: string) => Message
  readonly type?: string | undefined
  readonly placeholder?: string | undefined
  readonly style?: NamedStyle<typeof InputSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
  readonly draw?:
    ((parts: FieldParts, h: HtmlBuilder<Message>) => Html) | undefined
}

A text field in one call: a field's state drawn through view with its label, control, and description placed. The value is drawn with String(), as the base field view draws any draft. draw places the parts; the default stacks them. type and placeholder ride through only where given. Custom drawers stay for controls with no shipped renderer.

Input.InputSlots

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

const InputSlots: Slots.Contract<{ 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 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<"focus">, Event.EventToken<"blur">, Event.EventToken<"keydown">], readonly [Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-invalid">, Attr.AttrToken<"disabled">, Attr.AttrToken<"value">], readonly Slot.RequirementName[], boolean>; readonly label: 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 description: Slot.UnnamedSlot<Cap …;

Input.InputView

type · packages/mixins-ui/src/input.ts:120

type InputView<Message> = InputCommon<Message> &
  (
    | InputDrawn
    | {
        readonly draw: (
          resolved: ResolvedInput<Message>,
          h: HtmlBuilder<Message>,
        ) => Html
        readonly described?: boolean | undefined
        readonly label?: undefined
        readonly description?: undefined
        readonly labelAside?: undefined
        readonly start?: undefined
        readonly end?: undefined
      }
  )

An input in one call: its value and Messages, a style for its slots, and the rest of @foldkit/ui's own config. Given a label, it draws the field itself: the label (with labelAside beside it), the control with start and end around it inside one box, and the description under it. Given a draw, it places the resolved input, label and description bundles (and root, header, labelAside, group, start and end) as the application wants, and toView stays for one drawn as something else.

Input.resolve

function · packages/mixins-ui/src/input.ts:30

function resolve<Input, Message>(
  attributes: InputAttributes<Message> &
    Partial<
      Record<
        'root' | 'header' | 'labelAside' | 'group' | 'start' | 'end',
        ReadonlyArray<Attribute<Message>>
      >
    >,
  mixins: MixinList<Message>,
  context: ResolveContext<Input, Message>,
): ResolvedInput<Message>

Applies mixins to the input's bundles: upstream's, and any of this package's own slots given.

Input.ResolvedInput

type · packages/mixins-ui/src/input.ts:27

type ResolvedInput<Message> = Resolved<
  InputAttributes<Message>,
  typeof InputSlots,
  Message
>

The input's bundles with the attached Mixins applied.

Input.toView

function · packages/mixins-ui/src/input.ts:43

function toView<Message>(
  mixins: MixinList<Message>,
  context: ResolveContext<unknown, Message>,
  draw: (resolved: ResolvedInput<Message>) => Html,
): (attributes: InputAttributes<Message>) => Html

The input's toView: draw receives its bundles with mixins applied.

Input.view

function · packages/mixins-ui/src/input.ts:152

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