Form / foldkit-mixins-form

RenderContext

interface · packages/mixins-form/src/index.ts:448

interface RenderContext<Message> {
  readonly input: FieldInput
  readonly control: Control
  readonly draft: Draft
  readonly change: (value: Draft) => Message
  readonly toggled: (choice?: string) => Message
  readonly blurred: Message
  readonly bundle:
    | {
        readonly model: unknown
        readonly send: (message: unknown) => Message
        readonly viewInputs: unknown
      }
    | undefined
  readonly state: ReadonlyArray<
    Exclude<
      Attribute<Message>,
      {
        readonly _tag: 'InnerHTML'
      }
    >
  >
  readonly attrs: FieldAttrs
  readonly slots: SlotBuilders<typeof FieldSlots, Message>
  readonly h: HtmlBuilder<Message>
}

What a renderer draws one control from.

Members

RenderContext.input

property · packages/mixins-form/src/index.ts:449

readonly input: FieldInput

RenderContext.control

property · packages/mixins-form/src/index.ts:451

readonly control: Control

The control, whose data is its kind's: narrow it with the kind's is.

RenderContext.draft

property · packages/mixins-form/src/index.ts:452

readonly draft: Draft

RenderContext.change

property · packages/mixins-form/src/index.ts:453

readonly change: (value: Draft) => Message

RenderContext.toggled

property · packages/mixins-form/src/index.ts:460

readonly toggled: (choice?: string) => Message

A press on a flag (no choice) or on one choice of a list, applied to the draft as it stands when it lands: send it for a press, rather than a change built from the draft as drawn, which a second press before the next draw would undo.

RenderContext.blurred

property · packages/mixins-form/src/index.ts:461

readonly blurred: Message

RenderContext.bundle

property · packages/mixins-form/src/index.ts:466

readonly bundle:
  | {
      readonly model: unknown
      readonly send: (message: unknown) => Message
      readonly viewInputs: unknown
    }
  | undefined

For a control backed by a Bundle: its Model, and the Message carrying one of its own. Its draft is ''.

RenderContext.state

property · packages/mixins-form/src/index.ts:478

readonly state: ReadonlyArray<
  Exclude<
    Attribute<Message>,
    {
      readonly _tag: 'InnerHTML'
    }
  >
>

The control's id and its accessibility state. Put them on the element that holds the value: no InnerHTML, so a textarea takes them too.

RenderContext.attrs

property · packages/mixins-form/src/index.ts:480

readonly attrs: FieldAttrs

What the key's element takes beyond the base field view.

RenderContext.slots

property · packages/mixins-form/src/index.ts:481

readonly slots: SlotBuilders<typeof FieldSlots, Message>

RenderContext.h

property · packages/mixins-form/src/index.ts:482

readonly h: HtmlBuilder<Message>