Types

Generated by website/scripts/generate-api.ts from packages/gridla/src. Do not edit by hand; run bun run generate in website/.

State and change types re-exported from the interaction layer for DOM consumers.

import {  } from 'gridla/dom'
import type { GridChangeDetail, GridChangeReason, GridInteraction, GridPreview, GridState } from 'gridla/dom'
ExportKindSummary
GridChangeDetailtypeDescribes an accepted change: the reason, the affected item when there is one, and the solver strategy for solved operations.
GridChangeReasontypeWhy the layout changed, as reported in GridChangeDetail.
GridInteractiontypeThe gesture currently in progress.
GridPreviewtypeThe solver's latest answer for the gesture in progress.
GridStatetypeController state held in the store.

Types

GridChangeDetail

type · interaction/types.ts:73

Describes an accepted change: the reason, the affected item when there is one, and the solver strategy for solved operations.

export type GridChangeDetail = {
  reason: GridChangeReason
  itemId?: string
  strategy?: SolveStrategy
}
MemberTypeDescription
reasonGridChangeReason
itemId?string
strategy?SolveStrategy

GridChangeReason

type · interaction/types.ts:60

Why the layout changed, as reported in GridChangeDetail.

export type GridChangeReason =
  | 'move'
  | 'resize'
  | 'place'
  | 'remove'
  | 'update'
  | 'transfer'
  | 'set'

GridInteraction

type · interaction/types.ts:17

The gesture currently in progress.

export type GridInteraction = {
  itemId: string
  mode: GridInteractionMode
  edge?: GridResizeEdge
  pointerId: number | null
  /** Where the pointer grabbed the item, relative to its top-left. */
  grabOffset: GridPoint
  /** Item rect at gesture start, in rendered canvas pixels. */
  origin: GridRect
  /** Pointer position at gesture start, in rendered canvas pixels. */
  start: GridPoint
}
MemberTypeDescription
itemIdstring
modeGridInteractionMode
edge?GridResizeEdge
pointerId`number \null`
grabOffsetGridPointWhere the pointer grabbed the item, relative to its top-left.
originGridRectItem rect at gesture start, in rendered canvas pixels.
startGridPointPointer position at gesture start, in rendered canvas pixels.

GridPreview

type · interaction/types.ts:31

The solver's latest answer for the gesture in progress.

export type GridPreview<TData = unknown> = {
  layout: GridLayout<TData>
  item: GridItem<TData>
  strategy: SolveStrategy
  shiftedSiblings: boolean
  accepted: boolean
}
MemberTypeDescription
layoutGridLayout\<TData\>
itemGridItem\<TData\>
strategySolveStrategy
shiftedSiblingsboolean
acceptedboolean

GridState

type · interaction/types.ts:43

Controller state held in the store. layout is what interactions operate on; source is what the caller owns.

export type GridState<TData = unknown> = {
  /** The layout the controller was given (or owns). */
  source: GridLayout<TData>
  /** Measured canvas element size, or `null` until measured. */
  size: GridSize | null
  /** `source` projected onto `size`. Interactions operate on this layout. */
  layout: GridLayout<TData>
  interaction: GridInteraction | null
  /** Rect that tracks the pointer during a gesture, in rendered pixels. */
  activeRect: GridRect | null
  preview: GridPreview<TData> | null
  selectedId: string | null
  /** True while the active item is being previewed in another canvas. */
  transferring: boolean
}
MemberTypeDescription
sourceGridLayout\<TData\>The layout the controller was given (or owns).
size`GridSize \null`
layoutGridLayout\<TData\>source projected onto size. Interactions operate on this layout.
interaction`GridInteraction \null`
activeRect`GridRect \null`
preview`GridPreview<TData> \null`
selectedId`string \null`
transferringbooleanTrue while the active item is being previewed in another canvas.