Mixins / foldkit-mixins-ui

Field

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

export * as Field from './fieldShell.js'

In the guides

Members

Field.describedBy

function · packages/mixins-ui/src/fieldShell.ts:49

function describedBy<Message>(
  h: HtmlBuilder<Message>,
  id: string,
  drawn: {
    readonly description?: boolean | undefined
    readonly errors?: boolean | undefined
  },
): ReadonlyArray<Attribute<Message>>

The aria-describedby for the control id, given what the shell draws: its description, and its errors while there are any; none when it draws neither. A control drawn before the shell cannot know them, so it takes these attributes (Input.view's attributes: { input }, or h.input([...])).

Field.descriptionId

function · packages/mixins-ui/src/fieldShell.ts:38

function descriptionId(id: string): string

The id the shell gives the description of the control id.

Field.errorsId

function · packages/mixins-ui/src/fieldShell.ts:41

function errorsId(id: string): string

The id the shell gives the errors of the control id.

Field.FieldSlots

const · packages/mixins-ui/src/fieldShell.ts:13

const FieldSlots: 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 header: 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 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 marker: 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 labelAside: 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 control: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Inte …;

The shell around a control that is already drawn: its label (with the mark of a required or optional field, and anything beside it), a description and the errors under it. A shell owns no state and draws no control, so label, description, errors and orientation are one widget and not an option on each field.

Field.FieldView

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

type FieldView<Message> = FieldCommon<Message> &
  (
    | {
        readonly required?: boolean | undefined
        readonly optional?: undefined
      }
    | {
        readonly optional?: boolean | undefined
        readonly required?: undefined
      }
  )

A field is required or optional, never both.

Field.FieldWords

interface · packages/mixins-ui/src/fieldShell.ts:27

interface FieldWords {
  readonly required: string
  readonly optional: string
}

Field.view

function · packages/mixins-ui/src/fieldShell.ts:88

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

Field.words

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

const words = { required, optional }

The defaults, in English.