react-glide-table 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # react-glide-table
2
2
 
3
- Headless React table primitives built on [@tanstack/react-table](https://tanstack.com/table) and [@tanstack/react-virtual](https://tanstack.com/virtual).
3
+ Headless React table built on [@tanstack/react-table](https://tanstack.com/table) and [@tanstack/react-virtual](https://tanstack.com/virtual).
4
4
 
5
- You own the markup and styles. This package exposes state, handlers, and pure helpers for selection, editing, fill, row spanning, tree expand, and virtualization.
5
+ Primary DX is a **compound API** (`createTable` / `Table.Column`) with an unstyled semantic HTML shell. Customize with `className` hooks, `slots`, and column `render`. `useGlideTable` remains the lower-level escape hatch when you need full control of markup.
6
+
7
+ The package ships **no CSS** — class names like `DataTableJSX` / `data-table` are opt-in hooks for your own styles.
6
8
 
7
9
  ## Installation
8
10
 
@@ -14,12 +16,66 @@ pnpm add react-glide-table
14
16
 
15
17
  Peer dependencies: `react` and `react-dom` (`^18` or `^19`).
16
18
 
17
- ## Quick start
19
+ The package is marked `"sideEffects": false` for tree-shaking. Prefer subpath imports when you only need one surface:
20
+
21
+ | Import | Contents |
22
+ | --- | --- |
23
+ | `react-glide-table` | Full barrel (compound + core) |
24
+ | `react-glide-table/compound` | `createTable` / `Table` / `DataTable` + related types |
25
+ | `react-glide-table/core` | `useGlideTable` + feature hooks/helpers (no compound UI) |
26
+
27
+ ## Quick start (compound)
28
+
29
+ ```tsx
30
+ import { createTable } from "react-glide-table/compound"
31
+ import { useState } from "react"
32
+
33
+ type Product = { id: string; name: string; qty: number }
34
+
35
+ const ProductTable = createTable<Product>()
36
+
37
+ export function Products({ data }: { data: Product[] }) {
38
+ const [page, setPage] = useState(1)
39
+
40
+ return (
41
+ <ProductTable
42
+ data={data}
43
+ getRowId={(row) => row.id}
44
+ className="my-table"
45
+ // Optional: replace Toolbar / Row / Pending / Empty
46
+ // slots={{ Toolbar: MyToolbar, Row: MyRow, Empty: MyEmpty }}
47
+ >
48
+ <ProductTable.Header>
49
+ <ProductTable.Column field="name">Name</ProductTable.Column>
50
+ <ProductTable.Column field="qty" editable>
51
+ Qty
52
+ </ProductTable.Column>
53
+ </ProductTable.Header>
54
+ <ProductTable.Pagination page={page} pageSize={10} onChange={setPage} />
55
+ </ProductTable>
56
+ )
57
+ }
58
+ ```
59
+
60
+ ### Customization surface
61
+
62
+ | Slot / prop | Role |
63
+ | --- | --- |
64
+ | `slots.Toolbar` | Top summary / actions region |
65
+ | `slots.Row` | Full row replacement (cells, selection, edit UI) |
66
+ | `slots.Pending` / `slots.Empty` | Loading and empty states |
67
+ | `className` / column `className` / `headerClassName` | Class hooks (style yourself) |
68
+ | `labels` / `summary` / `toolbar` | Copy and slot nodes |
69
+ | `Column.render` | Cell content custom render |
70
+
71
+ Row-level UI → `slots.Row`. Cell content → `Column.render`. Header/Cell are not separate slots.
72
+
73
+ ## Escape hatch (`useGlideTable`)
18
74
 
19
75
  ```tsx
20
76
  import { flexRender } from "@tanstack/react-table"
21
- import { useGlideTable } from "react-glide-table"
22
- import type { ColumnDef } from "react-glide-table"
77
+ import { useGlideTable } from "react-glide-table/core"
78
+ import type { ColumnDef } from "react-glide-table/core"
23
79
 
24
80
  type Product = { id: string; name: string; qty: number }
25
81
 
@@ -69,22 +125,26 @@ export function ProductTable({ data }: { data: Product[] }) {
69
125
  }
70
126
  ```
71
127
 
72
- Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior. See the `playground/` app for a full reference UI built on top of `useGlideTable`.
128
+ Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior.
73
129
 
74
130
  ## Public API
75
131
 
76
- | Export | Role |
77
- | --- | --- |
78
- | `useGlideTable` | Headless table engine (TanStack instance, virtualization, selection/edit/expand state) |
79
- | `useCellEdit` / `useCellSelection` / `useConvertTreeData` | Feature hooks |
80
- | `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, | Pure helpers |
81
- | `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | Optional English UI copy helpers |
82
- | Tree field defaults | `id` / `parentId` / `children` / `qty` |
132
+ | Export | Path | Role |
133
+ | --- | --- | --- |
134
+ | `createTable` / `Table` | `/compound` | Compound column DSL (`Header` / `Column` / `Body` / `Pagination`) |
135
+ | `DataTable` | `/compound` | Unstyled default renderer (semantic HTML + slots/props) |
136
+ | `useGlideTable` | `/core` | Headless engine escape hatch |
137
+ | `useCellEdit` / `useCellSelection` / `useConvertTreeData` | `/core` | Feature hooks |
138
+ | `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, | `/core` | Pure helpers |
139
+ | `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | `/core` | Optional English UI copy helpers |
140
+ | Tree field defaults | `/core` | `id` / `parentId` / `children` / `qty` |
141
+
142
+ Root `react-glide-table` re-exports both surfaces. Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, …
83
143
 
84
144
  ## Notable constraints
85
145
 
86
146
  - **Row span + virtualization**: when `enableRowSpan` is on, virtualization is forced off (HTML `<table>` + `rowspan` cannot safely share a virtual window).
87
- - **No shipped CSS / opinionated components**: bring your own DOM. The published package does not export the reference UI components under `src/components/ui` (but some feature helpers are re-exported and shipped).
147
+ - **No shipped CSS**: the default renderer emits class hooks only. Bring your own styles (see playground for a CSS-skinned example).
88
148
 
89
149
  ## Local playground
90
150
 
@@ -93,7 +153,7 @@ pnpm install
93
153
  pnpm dev
94
154
  ```
95
155
 
96
- The playground imports a reference `createTable` / `DataTable` UI from the repo source to exercise the headless core.
156
+ The playground uses `createTable` with a local CSS skin (`src/styles/index.css`) to exercise the compound API and headless core.
97
157
 
98
158
  ## License
99
159