Overview
The store module provides centralized state management using Zustand. It manages bins, grid configuration, view modes, selection state, drag interactions, and undo/redo history.Import
Types
Bin
Represents a single Gridfinity bin with all its properties.string
required
UUID generated automatically on creation
number
required
Grid column position (0-indexed)
number
required
Grid row position (0-indexed)
number
required
Width in grid units (1 unit = 42mm)
number
required
Depth in grid units (1 unit = 42mm)
number
required
Height in grid units (1 unit = 7mm)
ViewMode
RenderMode
DragState
Tracks drag-and-drop interactions for placing and moving bins.State Properties
Grid Configuration
number
default:"6"
Number of grid columns
number
default:"6"
Number of grid rows
Bin Management
Bin[]
default:"[]"
Array of all bins in the grid
string | null
default:"null"
ID of the primary selected bin
string[]
default:"[]"
Array of all selected bin IDs (supports multi-select)
View Settings
ViewMode
default:"'split'"
Current viewport layout mode
RenderMode
default:"'standard'"
Current 3D rendering style
boolean
default:"true"
Whether to render the baseplate
boolean
default:"false"
Whether to show dimension annotations
boolean
default:"false"
Whether to enable section view (cut-through)
Interaction State
DragState
Current drag-and-drop state
History
Bin[][]
default:"[[]]"
Undo/redo history stack of bin states
number
default:"0"
Current position in history stack
Actions
addBin
Adds a new bin to the grid.Omit<Bin, 'id'>
required
Bin configuration without ID (generated automatically)
removeBin
Removes a bin by ID.string
required
ID of the bin to remove
updateBin
Updates properties of an existing bin.string
required
ID of the bin to update
Partial<Bin>
required
Properties to update (partial update)
moveBin
Moves a bin to a new grid position.string
required
ID of the bin to move
number
required
New X grid position
number
required
New Y grid position
selectBin
Selects a bin, with optional multi-select support.string | null
required
ID of bin to select, or null to clear selection
boolean
default:"false"
Whether to add to selection (multi-select mode)
- If
idisnull, clears all selections - If
multiisfalse, replaces current selection - If
multiistrue, toggles the bin in the selection set
setGridSize
Updates the grid dimensions.number
required
Number of columns
number
required
Number of rows
setViewMode
Changes the viewport layout.ViewMode
required
New view mode: ‘2d’, ‘3d’, or ‘split’
setRenderMode
Changes the 3D rendering style.RenderMode
required
New render mode: ‘standard’, ‘technical’, or ‘blueprint’
setShowDimensions
Toggles dimension annotations.boolean
required
Whether to show dimensions
setSectionView
Toggles section view (cut-through).boolean
required
Whether to enable section view
clearAll
Removes all bins and clears selection.setDragState
Updates the drag state (used internally by drag handlers).Partial<DragState>
required
Partial drag state to merge
startPlacing
Enters bin placement mode with a configuration template.Omit<Bin, 'id' | 'x' | 'y'>
required
Bin configuration for placement (position determined by user click)
cancelPlacing
Exits placement mode without creating a bin.undo
Reverts to the previous state in history.redo
Reapplies the next state in history.Usage Example
History Management
The store automatically tracks bin changes for undo/redo:- Recorded operations:
addBin,removeBin,updateBin,moveBin,clearAll - History stack: Maintains a snapshot of
binsarray after each operation - Max history: Limited only by browser memory
- Implementation: Uses deep cloning via
JSON.parse(JSON.stringify())
