Mixins / foldkit-mixins-ui

Resizable

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

export * as Resizable from './resizable.js'

Members

Resizable.Bounds

interface · packages/mixins-ui/src/resizable.ts:85

interface Bounds {
  readonly min?: number | undefined
  readonly max?: number | undefined
  readonly step?: number | undefined
  readonly collapsible?: 'first' | 'second' | undefined
  readonly collapsedTo?: number | undefined
}

The bounds a share stays within, what a key moves it by, and which panel collapses.

Resizable.configure

function · packages/mixins-ui/src/resizable.ts:304

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

The application's own Resizable: 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. The bounds are the Model's (init), not a preset's.

Resizable.init

function · packages/mixins-ui/src/resizable.ts:105

function init(share?: number, bounds?: Bounds): Model

The first panel's share to start at, and the bounds it keeps; update and the view read the bounds from the Model.

Resizable.Message

const · packages/mixins-ui/src/resizable.ts:71

const Message: MessageUnion<{
  readonly Measured: { readonly size: Schema.Number }
  readonly DragStarted: {}
  readonly Dragged: { readonly delta: Schema.Number }
  readonly DragEnded: {}
  readonly Set: { readonly share: Schema.Number }
  readonly Toggled: {}
}>

Resizable.Model

const · packages/mixins-ui/src/resizable.ts:57

const Model: Schema.Struct<{
  readonly bounds: Schema.Struct<{
    readonly min: Schema.optionalKey<Schema.Number>
    readonly max: Schema.optionalKey<Schema.Number>
    readonly step: Schema.optionalKey<Schema.Number>
    readonly collapsible: Schema.optionalKey<
      Schema.Literals<readonly ['first', 'second']>
    >
    readonly collapsedTo: Schema.optionalKey<Schema.Number>
  }>
  readonly share: Schema.Number
  readonly from: Schema.Option<Schema.Number>
  readonly size: Schema.Number
  readonly restore: Schema.Option<Schema.Number>
}>

Resizable.ResizablePreset

type · packages/mixins-ui/src/resizable.ts:294

type ResizablePreset = Pick<
  ResizableView<never>,
  'orientation' | 'direction' | 'style'
> & {
  readonly mixins?: MixinList<never>
}

What a Resizable is given once: its look and the options that hold no Message.

Resizable.ResizableSlots

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

const ResizableSlots: 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 first: 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 handle: Slot.UnnamedSlot<
    Capability.Capability<
      'Interactive',
      readonly [Capability.Capability<'Base', readonly []>]
    >,
    readonly [Event.EventToken<'keydown'>],
    readonly [
      Attr.AttrToken<'role'>,
      Attr.AttrToken<'aria-label'>,
      Attr.AttrToken<'aria-controls'>,
      Attr.AttrToken<'aria-valuenow'>,
    ],
    readonly Slot.RequirementName[],
    boolean
  >
  readonly grip: 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 second: Slot.UnnamedSlot<
    Capability.Capability<
      'Container',
      readonly [
        Capability.Capability<
          'Interactive',
          readonly [Capability.Capability<'Base', readonly []>]
        >,
      ]
    >,
    readonly Slot.EventName[],
    readonly Slot.AttributeName[],
    readonly Slot.RequirementName[],
    boolean
  >
}>

Two panels with a handle between them, shadcn's Resizable and the APG's window splitter: the handle is a separator with its value, a tab stop the arrows step and Home and End send to the bounds, and a drag moves it. The split is a small Model of this module's (the first panel's share, where a drag began, and the share to go back to while a panel is collapsed), which the application keeps and folds with update; a drag measures the group with the Resize Mount and follows the Move Mount's deltas from where it began. A split whose bounds name a collapsible panel collapses it on Enter or a double-click, as the APG's splitter does, and the same again puts it back where it was. A panel may hold another split, either way.

Resizable.ResizableView

interface · packages/mixins-ui/src/resizable.ts:155

interface ResizableView<Message> extends Bounds {
  readonly model: Model
  readonly onMessage: (message: typeof Message.Type) => NoInfer<Message>
  readonly orientation?: 'horizontal' | 'vertical' | undefined
  readonly direction?: 'ltr' | 'rtl' | undefined
  readonly label: string
  readonly id?: string | undefined
  readonly first: Html
  readonly second: Html
  readonly style?: NamedStyle<typeof ResizableSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

Resizable.update

function · packages/mixins-ui/src/resizable.ts:127

function update(model: Model, message: Message, bounds?: Bounds): Model

The split after message; the same Model when nothing changes.

Resizable.view

function · packages/mixins-ui/src/resizable.ts:184

function view<Outer>(options: ResizableView<Outer>, h: HtmlBuilder<Outer>): Html