react-glide-table 1.1.1 → 1.1.3

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Headless React table built on [@tanstack/react-table](https://tanstack.com/table) and [@tanstack/react-virtual](https://tanstack.com/virtual).
4
4
 
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.
5
+ Primary DX is a **compound API** (`createTable` / `Table.Column`) with an unstyled semantic HTML shell. Customize with `className`, **`classNames` (Tailwind-friendly part map)**, `slots`, and column `render`. `useGlideTable` remains the lower-level escape hatch when you need full control of markup.
6
6
 
7
7
  The package ships **no CSS** — class names like `DataTableJSX` / `data-table` are opt-in hooks for your own styles.
8
8
 
@@ -16,10 +16,18 @@ pnpm add react-glide-table
16
16
 
17
17
  Peer dependencies: `react` and `react-dom` (`^18` or `^19`).
18
18
 
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
+
19
27
  ## Quick start (compound)
20
28
 
21
29
  ```tsx
22
- import { createTable } from "react-glide-table"
30
+ import { createTable } from "react-glide-table/compound"
23
31
  import { useState } from "react"
24
32
 
25
33
  type Product = { id: string; name: string; qty: number }
@@ -33,9 +41,15 @@ export function Products({ data }: { data: Product[] }) {
33
41
  <ProductTable
34
42
  data={data}
35
43
  getRowId={(row) => row.id}
36
- className="my-table"
37
- // Optional: replace Toolbar / Row / Pending / Empty
38
- // slots={{ Toolbar: MyToolbar, Row: MyRow, Empty: MyEmpty }}
44
+ className="rounded-lg border"
45
+ classNames={{
46
+ scroll: "max-h-[480px] overflow-auto",
47
+ head: "sticky top-0 z-10 bg-neutral-50",
48
+ headCell: "px-3 text-xs font-semibold text-neutral-500",
49
+ row: "hover:bg-neutral-100 data-[selected]:bg-blue-600 data-[selected]:text-white",
50
+ cell: "border-b border-neutral-200 px-3 text-sm",
51
+ toolbar: "flex items-center justify-between gap-2 p-2",
52
+ }}
39
53
  >
40
54
  <ProductTable.Header>
41
55
  <ProductTable.Column field="name">Name</ProductTable.Column>
@@ -53,21 +67,29 @@ export function Products({ data }: { data: Product[] }) {
53
67
 
54
68
  | Slot / prop | Role |
55
69
  | --- | --- |
70
+ | `classNames` | Per-part Tailwind/utility classes (`root`, `scroll`, `row`, `cell`, `toolbar`, …) |
56
71
  | `slots.Toolbar` | Top summary / actions region |
57
72
  | `slots.Row` | Full row replacement (cells, selection, edit UI) |
58
73
  | `slots.Pending` / `slots.Empty` | Loading and empty states |
59
- | `className` / column `className` / `headerClassName` | Class hooks (style yourself) |
74
+ | `className` / column `className` / `headerClassName` | Extra class hooks |
60
75
  | `labels` / `summary` / `toolbar` | Copy and slot nodes |
61
76
  | `Column.render` | Cell content custom render |
62
77
 
78
+ Row/cell **state** is exposed as `data-*` attributes for Tailwind variants:
79
+
80
+ - row: `data-selected`, `data-hovered`, `data-expandable`, `data-expanded`
81
+ - cell: `data-merged`, `data-selection-fill`, `data-editable`, `data-editing`, …
82
+
83
+ Example: `row: "data-[selected]:bg-blue-600"`.
84
+
63
85
  Row-level UI → `slots.Row`. Cell content → `Column.render`. Header/Cell are not separate slots.
64
86
 
65
87
  ## Escape hatch (`useGlideTable`)
66
88
 
67
89
  ```tsx
68
90
  import { flexRender } from "@tanstack/react-table"
69
- import { useGlideTable } from "react-glide-table"
70
- import type { ColumnDef } from "react-glide-table"
91
+ import { useGlideTable } from "react-glide-table/core"
92
+ import type { ColumnDef } from "react-glide-table/core"
71
93
 
72
94
  type Product = { id: string; name: string; qty: number }
73
95
 
@@ -121,17 +143,17 @@ Wire `rowContextValue` into your own row/cell components for edit, selection, ex
121
143
 
122
144
  ## Public API
123
145
 
124
- | Export | Role |
125
- | --- | --- |
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 |
129
- | `useCellEdit` / `useCellSelection` / `useConvertTreeData` | Feature hooks |
130
- | `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, … | Pure helpers |
131
- | `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | Optional English UI copy helpers |
132
- | Tree field defaults | `id` / `parentId` / `children` / `qty` |
133
-
134
- Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, …
146
+ | Export | Path | Role |
147
+ | --- | --- | --- |
148
+ | `createTable` / `Table` | `/compound` | Compound column DSL (`Header` / `Column` / `Body` / `Pagination`) |
149
+ | `DataTable` | `/compound` | Unstyled default renderer (semantic HTML + slots/props) |
150
+ | `useGlideTable` | `/core` | Headless engine escape hatch |
151
+ | `useCellEdit` / `useCellSelection` / `useConvertTreeData` | `/core` | Feature hooks |
152
+ | `applyCellEdit`, `applyFillData`, `buildColumnRowSpanMap`, … | `/core` | Pure helpers |
153
+ | `DEFAULT_DATA_TABLE_LABELS` / `resolveDataTableLabels` | `/core` | Optional English UI copy helpers |
154
+ | Tree field defaults | `/core` | `id` / `parentId` / `children` / `qty` |
155
+
156
+ Root `react-glide-table` re-exports both surfaces. Related types: `TableProps`, `TableColumnProps`, `DataTableProps`, `DataTableSlots`, `TableCompoundComponent`, `ColumnDef`, …
135
157
 
136
158
  ## Notable constraints
137
159