Data Grid (editable)
niko-table/data-table-gridFreeBlock
Composable editable spreadsheet grid: a headless engine (focus, selection, edit lifecycle, undo/redo, clipboard — all rowId-addressed so sort/filter work while editing) + a skin composed with DataTableRoot and the virtualized body. Keyboard cell nav, drag range-select with edge auto-scroll, quote-aware TSV copy/cut/paste with one-to-many tiling, fill handle, drag-move, dynamic columns, row drag-to-reorder, selection status bar, cross-highlight, and text/number/checkbox/date/select/combobox cells. Virtualized to 100k+ rows.
Install it
npx shadcn@latest add https://niko-table.com/r/data-table-grid.jsonSource
1"use client"23/**4 * niko-table — created by Semir N. (Semkoo, https://github.com/Semkoo) with AI assistance.5 *6 * Before reporting anything: please check the changelog first.7 * - In-repo: ./CHANGELOG.md8 * - Docs site: https://niko-table.com/changelog9 *10 * Found a bug or have a fix? Open an issue or PR on GitHub so other11 * users (and future LLMs reading this code) benefit:12 * https://github.com/Semkoo/niko-table-registry13 */14import * as React from "react"1516import { TooltipProvider } from "@/components/ui/tooltip"1718import { useDataTable } from "../../core/data-table-context"19import { useDataTableScroll } from "../../hooks/use-data-table-scroll"20import type { UseDataGrid } from "../hooks/use-data-grid"21import { useGridKeyboard } from "../hooks/use-grid-keyboard"22import { useGridNavigation } from "../hooks/use-grid-navigation"23import {24 emptyCell,25 type CellPosition,26 type CellState,27 type GridRow,28 type SelectionBounds,29} from "../types/grid-cell"30import { DataGridContextProvider } from "./data-grid-context"31import {32 DataGridFeaturesProvider,33 DataGridInternalsProvider,34 GRID_EDGE_SPEED,35 GRID_EDGE_ZONE,36 type DataGridInternals,37 type GridEnv,38 type GridFeatures,39 type RegisterGridFeature,40} from "./data-grid-features"4142export interface DataGridProps<TRow extends GridRow> {43 grid: UseDataGrid<TRow>44 children: React.ReactNode45 className?: string46 /**47 * Called when the user presses `?` (with a focused cell, not editing) — wire48 * it to open a keyboard-shortcuts help dialog. When unset, `?` types normally.49 */50 onRequestShortcuts?: () => void51}5253/**54 * The DataGrid container — the irreducible core. Place INSIDE `DataTableRoot`,55 * wrapping the `DataTable`. It reads the table's DISPLAY order (post56 * filter/sort) and owns the selection rectangle, keyboard navigation, drag57 * range-select, and the scroll-into-view seam. Cells (addressed by row id)58 * read their state from `DataGridContext`.59 *60 * Everything else is opt-in, composable children (mix and match — an unmounted61 * feature attaches no listeners and tree-shakes out of the bundle):62 *63 * @example64 * <DataGrid grid={grid}>65 * <DataGridClipboard resolveCell={resolveCell} /> // copy/cut/paste66 * <DataGridFillHandle /> // corner-drag fill67 * <DataGridMove /> // border-drag move/copy68 * <DataGridCrossHighlight /> // header/gutter highlight69 * <DataTable>…</DataTable>70// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from niko-table
All 31 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Data Tabledata-table | niko-table | Blocks | Free | 2 deps · 37 files |
