Mixins / foldkit-mixins-ui

CheckboxGroup

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

export * as CheckboxGroup from './checkboxGroup.js'

In the guides

Members

CheckboxGroup.CheckboxGroupOption

interface · packages/mixins-ui/src/checkboxGroup.ts:49

interface CheckboxGroupOption<Value extends string> extends RowContent {
  readonly value: Value
}

One checkbox of the group: the row's words and marks, and the value it stands for.

CheckboxGroup.CheckboxGroupPreset

type · packages/mixins-ui/src/checkboxGroup.ts:246

type CheckboxGroupPreset = Pick<CheckboxGroupView<string, never>, 'style'> & {
  readonly mixins?: MixinList<never>
}

What a CheckboxGroup is given once: its look. The options, the checked values and the Messages are each use's.

CheckboxGroup.CheckboxGroupSelectAll

interface · packages/mixins-ui/src/checkboxGroup.ts:54

interface CheckboxGroupSelectAll<Value extends string, Message> {
  readonly label: string
  readonly onSet: (checked: ReadonlyArray<Value>) => NoInfer<Message>
}

A first row that checks every option or none, as shadcn's and Base UI's parent checkbox does.

CheckboxGroup.CheckboxGroupSlots

const · packages/mixins-ui/src/checkboxGroup.ts:18

const CheckboxGroupSlots: 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 legend: 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 option: 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 checkbox: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"aria-checked">, Attr.AttrToken<"aria-label">, Attr.AttrToken<"aria-controls">, Attr.AttrToken<"aria-disabled">, Attr.AttrToken<"aria-invalid">, Attr.AttrToken<"disabled">], 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 …;

A group of checkboxes for one question, as Zag's checkbox group: a fieldset named by its legend, and a row per option with the APG's checkbox (a button with role="checkbox" and aria-checked, which Space presses) named by a label for it, so a press on the words toggles it too. The checked values are the application's: the view draws checked and sends onToggle, and toggled is the transition update applies. checkbox and label take the same contract as the Checkbox's, so its recipe's pieces style them.

CheckboxGroup.CheckboxGroupView

interface · packages/mixins-ui/src/checkboxGroup.ts:60

interface CheckboxGroupView<Value extends string, Message> {
  readonly legend: string
  readonly options: ReadonlyArray<CheckboxGroupOption<Value>>
  readonly checked: ReadonlyArray<Value>
  readonly onToggle: (value: Value) => NoInfer<Message>
  readonly id: string
  readonly style?: NamedStyle<typeof CheckboxGroupSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
  readonly name?: string | undefined
  readonly error?: string | undefined
  readonly selectAll?: CheckboxGroupSelectAll<Value, Message> | undefined
}

CheckboxGroup.configure

function · packages/mixins-ui/src/checkboxGroup.ts:255

function configure<const Names extends string = never>(
  config: Presets<CheckboxGroupPreset, Names>,
): {
  readonly view: <const Value extends string, Outer>(
    options: CheckboxGroupView<Value, Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own CheckboxGroup: base for every use, presets chosen at a use with preset, and the call over both. mixins concatenate in that order; any other option given at the call replaces the preset's.

CheckboxGroup.coverage

function · packages/mixins-ui/src/checkboxGroup.ts:91

function coverage<Value extends string>(
  options: ReadonlyArray<CheckboxGroupOption<Value>>,
  checked: ReadonlyArray<Value>,
): 'none' | 'some' | 'all'

all when every option that can be checked is, none when none are, and some between. A disabled option counts for neither.

CheckboxGroup.setEnabled

function · packages/mixins-ui/src/checkboxGroup.ts:107

function setEnabled<Value extends string>(
  options: ReadonlyArray<CheckboxGroupOption<Value>>,
  checked: ReadonlyArray<Value>,
  on: boolean,
): ReadonlyArray<Value>

Every option that can be checked, or none of them, in the options' order: a disabled option keeps the state checked gives it either way, so a box locked on stays on.

CheckboxGroup.toggled

function · packages/mixins-ui/src/checkboxGroup.ts:119

function toggled<Value extends string>(
  checked: ReadonlyArray<Value>,
  value: Value,
): ReadonlyArray<Value>

The checked values after value is pressed: on if it was off, off if it was on.

CheckboxGroup.view

function · packages/mixins-ui/src/checkboxGroup.ts:126

function view<Value extends string, Message>(
  options: CheckboxGroupView<Value, Message>,
  h: HtmlBuilder<Message>,
): Html