react-glide-table 1.1.0 → 1.1.1

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,7 +16,53 @@ pnpm add react-glide-table
14
16
 
15
17
  Peer dependencies: `react` and `react-dom` (`^18` or `^19`).
16
18
 
17
- ## Quick start
19
+ ## Quick start (compound)
20
+
21
+ ```tsx
22
+ import { createTable } from "react-glide-table"
23
+ import { useState } from "react"
24
+
25
+ type Product = { id: string; name: string; qty: number }
26
+
27
+ const ProductTable = createTable<Product>()
28
+
29
+ export function Products({ data }: { data: Product[] }) {
30
+ const [page, setPage] = useState(1)
31
+
32
+ return (
33
+ <ProductTable
34
+ data={data}
35
+ getRowId={(row) => row.id}
36
+ className="my-table"
37
+ // Optional: replace Toolbar / Row / Pending / Empty
38
+ // slots={{ Toolbar: MyToolbar, Row: MyRow, Empty: MyEmpty }}
39
+ >
40
+ <ProductTable.Header>
41
+ <ProductTable.Column field="name">Name</ProductTable.Column>
42
+ <ProductTable.Column field="qty" editable>
43
+ Qty
44
+ </ProductTable.Column>
45
+ </ProductTable.Header>
46
+ <ProductTable.Pagination page={page} pageSize={10} onChange={setPage} />
47
+ </ProductTable>
48
+ )
49
+ }
50
+ ```
51
+
52
+ ### Customization surface
53
+
54
+ | Slot / prop | Role |
55
+ | --- | --- |
56
+ | `slots.Toolbar` | Top summary / actions region |
57
+ | `slots.Row` | Full row replacement (cells, selection, edit UI) |
58
+ | `slots.Pending` / `slots.Empty` | Loading and empty states |
59
+ | `className` / column `className` / `headerClassName` | Class hooks (style yourself) |
60
+ | `labels` / `summary` / `toolbar` | Copy and slot nodes |
61
+ | `Column.render` | Cell content custom render |
62
+
63
+ Row-level UI → `slots.Row`. Cell content → `Column.render`. Header/Cell are not separate slots.
64
+
65
+ ## Escape hatch (`useGlideTable`)
18
66
 
19
67
  ```tsx
20
68
  import { flexRender } from "@tanstack/react-table"
@@ -69,22 +117,26 @@ export function ProductTable({ data }: { data: Product[] }) {
69
117
  }
70
118
  ```
71
119
 
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`.
120
+ Wire `rowContextValue` into your own row/cell components for edit, selection, expand, and row-span behavior.
73
121
 
74
122
  ## Public API
75
123
 
76
124
  | Export | Role |
77
125
  | --- | --- |
78
- | `useGlideTable` | Headless table engine (TanStack instance, virtualization, selection/edit/expand state) |
126
+ | `createTable` / `Table` | Compound column DSL (`Header` / `Column` / `Body` / `Pagination`) |
127
+ | `DataTable` | Unstyled default renderer (semantic HTML + slots/props) |
128
+ | `useGlideTable` | Headless engine escape hatch |
79
129
  | `useCellEdit` / `useCellSelection` / `useConvertTreeData` | Feature hooks |
80
130
  | `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, … | Pure helpers |
81
131
  | `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | Optional English UI copy helpers |
82
132
  | Tree field defaults | `id` / `parentId` / `children` / `qty` |
83
133
 
134
+ Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, …
135
+
84
136
  ## Notable constraints
85
137
 
86
138
  - **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).
139
+ - **No shipped CSS**: the default renderer emits class hooks only. Bring your own styles (see playground for a CSS-skinned example).
88
140
 
89
141
  ## Local playground
90
142
 
@@ -93,7 +145,7 @@ pnpm install
93
145
  pnpm dev
94
146
  ```
95
147
 
96
- The playground imports a reference `createTable` / `DataTable` UI from the repo source to exercise the headless core.
148
+ The playground uses `createTable` with a local CSS skin (`src/styles/index.css`) to exercise the compound API and headless core.
97
149
 
98
150
  ## License
99
151