#Types
Generated by
website/scripts/generate-api.tsfrompackages/gridla/src. Do not edit by hand; runbun run generateinwebsite/.
State and change types re-exported from the interaction layer for Qwik consumers.
import { } from 'gridla/qwik'
import type { GridActions, GridChangeDetail, GridChangeReason, GridInteraction, GridInteractionMode, GridPreview, GridState } from 'gridla/qwik'| 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. |
GridPreview | type | The solver's latest answer for the gesture in progress. |
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'#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 |
#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. |