Provider
Generated by website/scripts/generate-api.ts from packages/gridla/src. Do not edit by hand; run bun run generate in website/.
GridProvider owns layout and gesture state for one canvas. It accepts every SolveOptions field as a prop, works controlled or uncontrolled, reads its props reactively, and exposes the controller through context.
import { GridProvider, useGridContext, useTransferScope } from 'gridla/solid'
import type { GridContextValue, GridProviderProps } from 'gridla/solid'
Components
GridProvider
component · solid/provider.ts:61
Owns layout and gesture state for one canvas. Place a GridCanvas inside
it. Props are read reactively: changing layout, a callback, or a solver
option forwards to the controller without remounting. A binding over
createGridController from gridla/interaction.
export function GridProvider<TData = unknown>(props: GridProviderProps<TData>): JSX.Element
Hooks
useGridContext
hook · solid/context.ts:34
Read the nearest GridProvider context. Throws when called outside a provider.
export function useGridContext<TData = unknown>(): GridContextValue<TData>
useTransferScope
hook · solid/context.ts:45
The nearest GridTransferScope, or null when there is none.
export function useTransferScope(): TransferScope | null
Types
GridContextValue
type · solid/context.ts:18
Value provided by GridProvider: its id, the state store, the imperative
actions, the resolved config as an accessor, the gesture API, and the
underlying GridController from gridla/interaction.
export type GridContextValue<TData = unknown> = {
/** Unique id of this provider. Used by transfer scopes. */
id: string
store: GridStore<GridState<TData>>
actions: GridActions<TData>
/** The resolved configuration; tracks the provider's props. */
config: Accessor<GridControllerConfig>
/** Low-level gesture API used by `GridCanvas`. */
gesture: GridGestureApi<TData>
/** The controller the provider is built on. */
controller: GridController<TData>
}
GridProviderProps
type · solid/provider.ts:25
Props for GridProvider: every SolveOptions field, a controlled or
uncontrolled layout, change and transfer callbacks, and the settings that
make up GridProviderConfig.
export type GridProviderProps<TData = unknown> = SolveOptions & {
/** Controlled layout. Pair with `onLayoutChange`. */
layout?: GridLayout<TData>
/** Initial layout for uncontrolled use. */
defaultLayout?: GridLayout<TData>
/**
* Called with the next layout after every accepted change. The layout is
* expressed in the canvas size it was rendered at.
*/
onLayoutChange?: (layout: GridLayout<TData>, detail: GridChangeDetail) => void
/** Fires with the solver strategy on every accepted interactive commit. */
onCommit?: (detail: GridChangeDetail) => void
/** Called when an item moves to another canvas inside a `GridTransferScope`. */
onTransferOut?: (itemId: string, targetId: string) => void
/** Called when an item arrives from another canvas. */
onTransferIn?: (item: GridItem<TData>, sourceId: string) => void
/** Whether items from other canvases may be dropped here. Default `true`. */
acceptTransfers?: boolean | ((item: GridItem<TData>, sourceId: string) => boolean)
/** Project the layout onto the measured canvas size. Default `true`. */
responsive?: boolean
/** Minimum pointer travel before a press becomes a drag. Default `4`. */
dragThreshold?: number
/** Pixels moved per arrow key press. Default `8`. */
keyboardStep?: number
/** Controlled selection. */
selectedId?: string | null
onSelectedIdChange?: (itemId: string | null) => void
children?: JSX.Element
}