#Types
Generated by
website/scripts/generate-api.tsfrompackages/gridla/src. Do not edit by hand; runbun run generateinwebsite/.
State, action, and event types shared by the provider, composables, and components.
import { } from 'gridla/vue'
import type { GridActions, GridChangeDetail, GridChangeReason, GridInteraction, GridInteractionMode, GridItemView, GridPreview, GridProviderConfig, GridState } from 'gridla/vue'| Export | Kind | Summary |
|---|---|---|
GridActions | type | Imperative layout and selection API exposed by the controller. |
GridChangeDetail | type | Describes an accepted change: the reason, the affected item when there is one, and the solver strategy for solved operations. |
GridChangeReason | type | Why the layout changed, as reported in GridChangeDetail. |
GridInteraction | type | The gesture currently in progress. |
GridInteractionMode | type | Kind of gesture: dragging an item or resizing it. |
GridItemView | type | Everything needed to paint one item: its current and pre-gesture rectangles plus its active, selected, shifted, and transferring flags. |
GridPreview | type | The solver's latest answer for the gesture in progress. |
GridProviderConfig | type | Resolved provider configuration: every SolveOptions field plus the responsive, drag-threshold, and keyboard-step settings with defaults applied. |
GridState | type | Controller state held in the store. |
#Types
#GridActions
type · interaction/types.ts:99Imperative layout and selection API exposed by the controller. The object is stable for the controller's lifetime.
export type GridActions<TData = unknown> = {
/** Replace the whole layout. */
setLayout: (layout: GridLayout<TData>) => void
/** Move an item programmatically. Returns whether the solver accepted it. */
move: (itemId: string, position: GridPoint, options?: SolveOptions) => boolean
/** Resize an item programmatically. */
resize: (
itemId: string,
change: { edge: GridResizeEdge; delta: GridPoint } | { rect: Partial<GridRect> },
options?: SolveOptions,
) => boolean
/** Insert an item at a position or centered on a pointer. */
place: (
item: NewGridItem<TData>,
at: { position: GridPoint } | { pointer: GridPoint },
options?: SolveOptions,
) => boolean
remove: (itemId: string) => void
/** Patch an item's fields (constraints, policy, data). Geometry is re-clamped. */
update: (itemId: string, patch: Partial<GridItem<TData>>) => void
select: (itemId: string | null) => void
/** Cancel the gesture in progress without committing. */
cancel: () => void
/**
* Preview a new item (for example one dragged from a palette) centered on a
* pointer position in canvas pixels. Returns the preview, or `null` when it
* cannot be placed. Follow up with `commitIncoming` or `clearIncoming`.
*/
previewIncoming: (item: GridItem<TData>, pointer: GridPoint) => GridPreview<TData> | null
/** Commit the incoming preview into the layout. Returns whether one was committed. */
commitIncoming: () => boolean
/** Drop the incoming preview without committing. */
clearIncoming: () => void
}| Member | Type | Description |
|---|---|---|
setLayout | (layout: GridLayout\<TData\>) =\> void | Replace the whole layout. |
move | (itemId: string, position: GridPoint, options?: SolveOptions) =\> boolean | Move an item programmatically. Returns whether the solver accepted it. |
resize | `(itemId: string, change: { edge: GridResizeEdge; delta: GridPoint; } \ | { rect: Partial<GridRect>; }, options?: SolveOptions) => boolean` |
place | `(item: NewGridItem<TData>, at: { position: GridPoint; } \ | { pointer: GridPoint; }, options?: SolveOptions) => boolean` |
remove | (itemId: string) =\> void | |
update | (itemId: string, patch: Partial\<GridItem\<TData\>\>) =\> void | Patch an item's fields (constraints, policy, data). Geometry is re-clamped. |
select | `(itemId: string \ | null) => void` |
cancel | () =\> void | Cancel the gesture in progress without committing. |
previewIncoming | `(item: GridItem<TData>, pointer: GridPoint) => GridPreview<TData> \ | null` |
commitIncoming | () =\> boolean | Commit the incoming preview into the layout. Returns whether one was committed. |
clearIncoming | () =\> void | Drop the incoming preview without committing. |
#GridChangeDetail
type · interaction/types.ts:73Describes 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
}| Member | Type | Description |
|---|---|---|
reason | GridChangeReason | |
itemId? | string | |
strategy? | SolveStrategy |
#GridChangeReason
type · interaction/types.ts:60Why the layout changed, as reported in GridChangeDetail.
export type GridChangeReason =
| 'move'
| 'resize'
| 'place'
| 'remove'
| 'update'
| 'transfer'
| 'set'#GridInteraction
type · interaction/types.ts:17The 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
}| Member | Type | Description |
|---|---|---|
itemId | string | |
mode | GridInteractionMode | |
edge? | GridResizeEdge | |
pointerId | `number \ | null` |
grabOffset | GridPoint | Where the pointer grabbed the item, relative to its top-left. |
origin | GridRect | Item rect at gesture start, in rendered canvas pixels. |
start | GridPoint | Pointer position at gesture start, in rendered canvas pixels. |
#GridInteractionMode
type · interaction/types.ts:14Kind of gesture: dragging an item or resizing it.
export type GridInteractionMode = 'move' | 'resize'#GridItemView
type · vue/types.ts:26Everything needed to paint one item: its current and pre-gesture rectangles
plus its active, selected, shifted, and transferring flags. Returned by
useGridItemView and passed to the GridItem default slot.
export type GridItemView = {
/** Where the item is painted right now (preview-aware). */
rect: GridRect
/** Where the item was before the current gesture. */
baseRect: GridRect
/** Cursor-tracked rect while this item is active; `null` otherwise. */
activeRect: GridRect | null
isActive: boolean
isSelected: boolean
/** True when this item moved in the preview because another item pushed it. */
isShifted: boolean
/** True while the active item is being previewed in another canvas. */
isTransferring: boolean
interaction: GridInteraction | null
}| Member | Type | Description |
|---|---|---|
rect | GridRect | Where the item is painted right now (preview-aware). |
baseRect | GridRect | Where the item was before the current gesture. |
activeRect | `GridRect \ | null` |
isActive | boolean | |
isSelected | boolean | |
isShifted | boolean | True when this item moved in the preview because another item pushed it. |
isTransferring | boolean | True while the active item is being previewed in another canvas. |
interaction | `GridInteraction \ | null` |
#GridPreview
type · interaction/types.ts:31The 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
}| Member | Type | Description |
|---|---|---|
layout | GridLayout\<TData\> | |
item | GridItem\<TData\> | |
strategy | SolveStrategy | |
shiftedSiblings | boolean | |
accepted | boolean |
#GridProviderConfig
type · vue/types.ts:19Resolved provider configuration: every SolveOptions field plus the
responsive, drag-threshold, and keyboard-step settings with defaults applied.
Same shape as GridControllerConfig from gridla/interaction.
export type GridProviderConfig = GridControllerConfig| Member | Type | Description |
|---|---|---|
gap? | number | Minimum distance kept between neighbors. Default 0. |
snapDistance? | number | Distance within which edges attract. Default 24. |
snap? | boolean | When false, alignment snapping is skipped so the item tracks the requested position exactly. Bounds, gap, and constraint rules still apply. Default true. |
onTrace? | TraceCallback | Receives one event per solve describing which strategy produced the result. |
responsive | boolean | Project the layout onto the measured canvas size. When false, the canvas element is sized to the layout instead. Default true. |
dragThreshold | number | Minimum pointer travel before a press becomes a drag. Default 4. |
keyboardStep | number | Pixels moved per arrow key press. Default 8; Shift multiplies by 4. |
#GridState
type · interaction/types.ts:43Controller 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
}| Member | Type | Description |
|---|---|---|
source | GridLayout\<TData\> | The layout the controller was given (or owns). |
size | `GridSize \ | null` |
layout | GridLayout\<TData\> | source projected onto size. Interactions operate on this layout. |
interaction | `GridInteraction \ | null` |
activeRect | `GridRect \ | null` |
preview | `GridPreview<TData> \ | null` |
selectedId | `string \ | null` |
transferring | boolean | True while the active item is being previewed in another canvas. |