Mixins / foldkit-mixins-ui

Item

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

export * as Item from './item.js'

In the guides

Members

Item.configure

function · packages/mixins-ui/src/item.ts:195

function configure<const Names extends string = never>(
  config: Presets<ItemPreset, Names>,
): {
  readonly view: <Outer>(
    options: ItemView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
  readonly group: <Outer>(
    options: ItemGroupView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own Item: base for every use, presets chosen at a use with preset, and the call over both. A preset's style reaches a group's rows too; its groupStyle is the group's own.

Item.group

function · packages/mixins-ui/src/item.ts:154

function group<Message = never>(
  options: ItemGroupView<Message>,
  h: HtmlBuilder<Message>,
): Html

Item.ItemGroupSlots

const · packages/mixins-ui/src/item.ts:128

const ItemGroupSlots: 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 row: Slot.UnnamedSlot<
    Capability.Capability<
      'Container',
      readonly [
        Capability.Capability<
          'Interactive',
          readonly [Capability.Capability<'Base', readonly []>]
        >,
      ]
    >,
    readonly Slot.EventName[],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
}>

A group publishes the list and each row's place in it; each row is an ItemSlots item. A list of settings, notifications or files.

Item.ItemGroupView

interface · packages/mixins-ui/src/item.ts:139

interface ItemGroupView<Message = never> {
  readonly items: ReadonlyArray<ItemOfGroup<Message>>
  readonly label?: string | undefined
  readonly wrap?:
    ((row: Html, source: ItemOfGroup<Message>) => Html) | undefined
  readonly style?: NamedStyle<typeof ItemGroupSlots> | undefined
  readonly itemStyle?: NamedStyle<typeof ItemSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

Rows as one list, divided by hairlines or apart.

Item.ItemOfGroup

type · packages/mixins-ui/src/item.ts:134

type ItemOfGroup<Message> = Omit<ItemView<Message>, 'style' | 'mixins'> & {
  readonly key: string
}

One row of a group: an item with the key that keeps its DOM when it moves.

Item.ItemPreset

type · packages/mixins-ui/src/item.ts:179

type ItemPreset = Pick<ItemView<never>, 'style' | 'words'> & {
  readonly groupStyle?: NamedStyle<typeof ItemGroupSlots> | undefined
  readonly mixins?: MixinList<never>
}

What an Item is given once: its look and words, and the look of a group of them.

Item.ItemSlots

const · packages/mixins-ui/src/item.ts:21

const ItemSlots: 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 media: 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 content: 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 title: 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<Capability.Capability<"Container", readonly [Capability.Capability<"Inte …;

An item is the row primitive: the common shape of a row of anything (a setting, a notification, a file, a contact, a search result) as media at the start, a title over a description, and actions at the end. It owns no state, messages, or bundles; draw the parts the row has and skip the rest. Reach for a Field instead when the row is a form control.

A pressable row is one control, as a pressable card is: overlay is a link or a button stretched over the row and named by its title, so the row is one tab stop, while its actions sit above it and stay pressable on their own. The root carries data-pressable, data-selected and data-disabled for a style to read.

Item.ItemView

interface · packages/mixins-ui/src/item.ts:46

interface ItemView<Message = never> {
  readonly header?: Html | undefined
  readonly footer?: Html | undefined
  readonly content?: Html | undefined
  readonly media?: Html | undefined
  readonly title?: string | undefined
  readonly description?: string | undefined
  readonly actions?: Html | undefined
  readonly press?: Press<Message> | undefined
  readonly label?: string | undefined
  readonly selected?: boolean | undefined
  readonly disabled?: boolean | undefined
  readonly words?: Partial<ItemWords> | undefined
  readonly style?: NamedStyle<typeof ItemSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

A row in one call: the regions it earns, what pressing it does, its state, a style for its slots, and mixins beside the style. content follows the title and description in the content region. No upstream component stands behind it.

Item.ItemWords

interface · packages/mixins-ui/src/item.ts:34

interface ItemWords {
  readonly newTab: string
}

The fixed text an item draws: what a link opening a new tab says.

Item.view

function · packages/mixins-ui/src/item.ts:75

function view<Message = never>(
  options: ItemView<Message>,
  h: HtmlBuilder<Message>,
): Html

Item.words

const · packages/mixins-ui/src/item.ts:38

const words = { newTab }