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'
ExportKindSummary
GridContextValuetypeValue 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.
GridProvidercomponentOwns layout and gesture state for one canvas.
GridProviderPropstypeProps for GridProvider: every SolveOptions field, a controlled or uncontrolled layout, change and transfer callbacks, and the settings that make up GridProviderConfig.
useGridContexthookRead the nearest GridProvider context.
useTransferScopehookThe nearest GridTransferScope, or null when there is none.

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>
}
MemberTypeDescription
idstringUnique id of this provider. Used by transfer scopes.
storeGridStore\<GridState\<TData\>\>
actionsGridActions\<TData\>
configAccessor\<GridControllerConfig\>The resolved configuration; tracks the provider's props.
gestureGridGestureApi\<TData\>Low-level gesture API used by GridCanvas.
controllerGridController\<TData\>The controller the provider is built on.

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
}
MemberTypeDescription
layout?GridLayout\<TData\>Controlled layout. Pair with onLayoutChange.
defaultLayout?GridLayout\<TData\>Initial layout for uncontrolled use.
onLayoutChange?((layout: GridLayout\<TData\>, detail: GridChangeDetail) =\> void)Called with the next layout after every accepted change. The layout is expressed in the canvas size it was rendered at.
onCommit?((detail: GridChangeDetail) =\> void)Fires with the solver strategy on every accepted interactive commit.
onTransferOut?((itemId: string, targetId: string) =\> void)Called when an item moves to another canvas inside a GridTransferScope.
onTransferIn?((item: GridItem\<TData\>, sourceId: string) =\> void)Called when an item arrives from another canvas.
acceptTransfers?`boolean \((item: GridItem<TData>, sourceId: string) => boolean)`
responsive?booleanProject the layout onto the measured canvas size. Default true.
dragThreshold?numberMinimum pointer travel before a press becomes a drag. Default 4.
keyboardStep?numberPixels moved per arrow key press. Default 8.
selectedId?`string \null`
onSelectedIdChange?`((itemId: string \null) => void)`
children?JSX.Element