bolt-table 0.1.14 → 0.1.16
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 +1 -1478
- package/dist/index.d.mts +153 -1495
- package/dist/index.d.ts +153 -1495
- package/dist/index.js +383 -438
- package/dist/index.mjs +383 -438
- package/package.json +1 -1
- package/dist/index.js.map +0 -1
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,19 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React$1, { ReactNode, CSSProperties } from 'react';
|
|
3
3
|
import { Virtualizer } from '@tanstack/react-virtual';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Customizable icon overrides for BoltTable.
|
|
7
|
-
* Pass any of these to the `icons` prop on BoltTable to replace the default SVG icons.
|
|
8
|
-
* Each icon should be a pre-sized React node (e.g. an SVG at 12×12px).
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* <BoltTable
|
|
12
|
-
* icons={{
|
|
13
|
-
* gripVertical: <MyGripIcon size={12} />,
|
|
14
|
-
* sortAsc: <MySortUpIcon size={12} />,
|
|
15
|
-
* }}
|
|
16
|
-
* />
|
|
17
|
-
*/
|
|
5
|
+
/** Customizable icon overrides for BoltTable. */
|
|
18
6
|
interface BoltTableIcons {
|
|
19
7
|
gripVertical?: React$1.ReactNode;
|
|
20
8
|
sortAsc?: React$1.ReactNode;
|
|
@@ -32,1680 +20,350 @@ interface BoltTableIcons {
|
|
|
32
20
|
copy?: React$1.ReactNode;
|
|
33
21
|
}
|
|
34
22
|
|
|
35
|
-
/**
|
|
36
|
-
* The direction of a column sort.
|
|
37
|
-
*
|
|
38
|
-
* - `'asc'` — ascending order (A → Z, 0 → 9)
|
|
39
|
-
* - `'desc'` — descending order (Z → A, 9 → 0)
|
|
40
|
-
* - `null` — no sort applied
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* const [sortDir, setSortDir] = useState<SortDirection>(null);
|
|
44
|
-
*/
|
|
23
|
+
/** `'asc'` | `'desc'` | `null` — the direction of a column sort. */
|
|
45
24
|
type SortDirection = 'asc' | 'desc' | null;
|
|
46
|
-
/**
|
|
47
|
-
* Defines the shape of a single column in BoltTable.
|
|
48
|
-
*
|
|
49
|
-
* @typeParam T - The type of a single row record. Defaults to `unknown`.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* const columns: ColumnType<User>[] = [
|
|
53
|
-
* {
|
|
54
|
-
* key: 'name',
|
|
55
|
-
* dataIndex: 'name',
|
|
56
|
-
* title: 'Full Name',
|
|
57
|
-
* width: 200,
|
|
58
|
-
* sortable: true,
|
|
59
|
-
* render: (value, record) => <strong>{record.name}</strong>,
|
|
60
|
-
* },
|
|
61
|
-
* ];
|
|
62
|
-
*/
|
|
25
|
+
/** Defines the shape of a single column in BoltTable. */
|
|
63
26
|
interface ColumnType<T = unknown> {
|
|
64
|
-
/**
|
|
65
|
-
* The text or React node shown in the column header.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* title: 'Full Name'
|
|
69
|
-
* title: <span style={{ color: 'red' }}>Name</span>
|
|
70
|
-
*/
|
|
27
|
+
/** The text or React node shown in the column header. */
|
|
71
28
|
title: string | ReactNode;
|
|
72
|
-
/**
|
|
73
|
-
* The key in the row data object whose value this column displays.
|
|
74
|
-
* Must match a property name on your row record type `T`.
|
|
75
|
-
*
|
|
76
|
-
* @example
|
|
77
|
-
* // For a row { id: 1, firstName: 'John' }
|
|
78
|
-
* dataIndex: 'firstName'
|
|
79
|
-
*/
|
|
29
|
+
/** The key in the row data object whose value this column displays. */
|
|
80
30
|
dataIndex: string;
|
|
81
|
-
/**
|
|
82
|
-
* The fixed pixel width of this column.
|
|
83
|
-
* If omitted, defaults to `150px`.
|
|
84
|
-
* The last column always stretches to fill remaining space (minmax).
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* width: 200
|
|
88
|
-
*/
|
|
31
|
+
/** Fixed pixel width of this column. Defaults to `150px`; last column stretches to fill. */
|
|
89
32
|
width?: number;
|
|
90
|
-
/**
|
|
91
|
-
* A unique identifier for this column.
|
|
92
|
-
* Used internally for drag-and-drop ordering, pinning, hiding, and sorting.
|
|
93
|
-
* Should match `dataIndex` in most cases unless you have computed columns.
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* key: 'firstName'
|
|
97
|
-
*/
|
|
33
|
+
/** Unique identifier for this column, used for ordering, pinning, hiding, and sorting. */
|
|
98
34
|
key: string;
|
|
99
|
-
/**
|
|
100
|
-
* Custom render function for the cell content.
|
|
101
|
-
* If omitted, the raw value from `dataIndex` is rendered as-is.
|
|
102
|
-
*
|
|
103
|
-
* @param text - The raw cell value (`record[dataIndex]`)
|
|
104
|
-
* @param record - The full row data object
|
|
105
|
-
* @param index - The row index (0-based) in the current page/view
|
|
106
|
-
* @returns A React node to render inside the cell
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* render: (value, record) => (
|
|
110
|
-
* <span style={{ color: record.isActive ? 'green' : 'gray' }}>
|
|
111
|
-
* {String(value)}
|
|
112
|
-
* </span>
|
|
113
|
-
* )
|
|
114
|
-
*/
|
|
35
|
+
/** Custom render function for cell content. Receives `(value, record, index)`. */
|
|
115
36
|
render?: (text: unknown, record: T, index: number) => ReactNode;
|
|
116
|
-
/**
|
|
117
|
-
* Custom render function for the shimmer (loading skeleton) state.
|
|
118
|
-
* When the table is loading and has no data, this replaces the default
|
|
119
|
-
* animated pulse bar for this column.
|
|
120
|
-
*
|
|
121
|
-
* @returns A React node to render as the loading placeholder
|
|
122
|
-
*
|
|
123
|
-
* @example
|
|
124
|
-
* shimmerRender: () => (
|
|
125
|
-
* <div style={{ width: 40, height: 40, borderRadius: '50%', background: '#eee' }} />
|
|
126
|
-
* )
|
|
127
|
-
*/
|
|
37
|
+
/** Custom render for the shimmer/loading skeleton state of this column. */
|
|
128
38
|
shimmerRender?: () => ReactNode;
|
|
129
|
-
/**
|
|
130
|
-
* Whether this column shows sort controls (ascending/descending).
|
|
131
|
-
* Defaults to `true`. Set to `false` to hide sorting for this column entirely.
|
|
132
|
-
*
|
|
133
|
-
* @default true
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* sortable: false // disables sort UI for this column
|
|
137
|
-
*/
|
|
39
|
+
/** Whether this column shows sort controls. Defaults to `true`. */
|
|
138
40
|
sortable?: boolean;
|
|
139
41
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* (i.e. you are not doing server-side sorting).
|
|
143
|
-
*
|
|
144
|
-
* - Pass `true` to use the default comparator (string localeCompare / number subtraction).
|
|
145
|
-
* - Pass a function `(a, b) => number` for custom sort logic.
|
|
146
|
-
* Return negative if `a` should come first, positive if `b` should come first, 0 if equal.
|
|
147
|
-
*
|
|
148
|
-
* @example
|
|
149
|
-
* // Default comparator
|
|
150
|
-
* sorter: true
|
|
151
|
-
*
|
|
152
|
-
* // Custom comparator — sort by string length
|
|
153
|
-
* sorter: (a, b) => String(a.name).length - String(b.name).length
|
|
154
|
-
*
|
|
155
|
-
* // Custom comparator — sort by date
|
|
156
|
-
* sorter: (a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()
|
|
42
|
+
* Client-side sort comparator. `true` uses default comparator;
|
|
43
|
+
* pass `(a, b) => number` for custom logic.
|
|
157
44
|
*/
|
|
158
45
|
sorter?: boolean | ((a: T, b: T) => number);
|
|
159
|
-
/**
|
|
160
|
-
* Whether this column shows a filter control in the context menu.
|
|
161
|
-
* Defaults to `true`. Set to `false` to hide filtering for this column.
|
|
162
|
-
*
|
|
163
|
-
* @default true
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* filterable: false // disables filter UI for this column
|
|
167
|
-
*/
|
|
46
|
+
/** Whether this column shows a filter control. Defaults to `true`. */
|
|
168
47
|
filterable?: boolean;
|
|
169
48
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
* @param filterValue - The string the user typed into the filter input
|
|
174
|
-
* @param record - The full row data object being tested
|
|
175
|
-
* @param dataIndex - The column's `dataIndex` value
|
|
176
|
-
* @returns `true` to keep the row, `false` to exclude it
|
|
177
|
-
*
|
|
178
|
-
* Falls back to a case-insensitive substring match when not provided.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* // Only show rows where the status exactly matches the filter
|
|
182
|
-
* filterFn: (filterValue, record) =>
|
|
183
|
-
* record.status === filterValue
|
|
184
|
-
*
|
|
185
|
-
* // Numeric range filter — keep rows where age >= filterValue
|
|
186
|
-
* filterFn: (filterValue, record) =>
|
|
187
|
-
* Number(record.age) >= Number(filterValue)
|
|
49
|
+
* Client-side filter predicate. Return `true` to keep the row.
|
|
50
|
+
* Falls back to case-insensitive substring match when not provided.
|
|
188
51
|
*/
|
|
189
52
|
filterFn?: (filterValue: string, record: T, dataIndex: string) => boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Whether this column is hidden by default on first render.
|
|
192
|
-
* The user can still show it via column visibility controls if you expose them.
|
|
193
|
-
*
|
|
194
|
-
* @default false
|
|
195
|
-
*/
|
|
53
|
+
/** Whether this column is hidden by default on first render. */
|
|
196
54
|
defaultHidden?: boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Which side this column is pinned to by default on first render.
|
|
199
|
-
* - `'left'` — column sticks to the left edge while scrolling horizontally
|
|
200
|
-
* - `'right'` — column sticks to the right edge
|
|
201
|
-
* - `false` — column is not pinned (scrolls normally)
|
|
202
|
-
*
|
|
203
|
-
* @default false
|
|
204
|
-
*/
|
|
55
|
+
/** Which side this column is pinned to by default: `'left'`, `'right'`, or `false`. */
|
|
205
56
|
defaultPinned?: 'left' | 'right' | false;
|
|
206
|
-
/**
|
|
207
|
-
* Controls the current hidden state of the column.
|
|
208
|
-
* Use this for controlled visibility (managed by parent state).
|
|
209
|
-
* For uncontrolled, use `defaultHidden` instead.
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* hidden: hiddenColumns.includes('email')
|
|
213
|
-
*/
|
|
57
|
+
/** Controlled hidden state of the column. For uncontrolled, use `defaultHidden`. */
|
|
214
58
|
hidden?: boolean;
|
|
215
|
-
/**
|
|
216
|
-
* Controls the current pinned state of the column.
|
|
217
|
-
* Use this for controlled pinning (managed by parent state).
|
|
218
|
-
* For uncontrolled, use `defaultPinned` instead.
|
|
219
|
-
*
|
|
220
|
-
* - `'left'` — pinned to the left
|
|
221
|
-
* - `'right'` — pinned to the right
|
|
222
|
-
* - `false` — not pinned
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* pinned: 'left'
|
|
226
|
-
*/
|
|
59
|
+
/** Controlled pinned state: `'left'`, `'right'`, or `false`. For uncontrolled, use `defaultPinned`. */
|
|
227
60
|
pinned?: 'left' | 'right' | false;
|
|
228
|
-
/**
|
|
229
|
-
* Additional CSS class name(s) applied to every cell in this column,
|
|
230
|
-
* including both the header and body cells.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* className: 'text-right font-mono'
|
|
234
|
-
*/
|
|
61
|
+
/** Additional CSS class name(s) applied to every cell in this column. */
|
|
235
62
|
className?: string;
|
|
236
|
-
/**
|
|
237
|
-
* Inline CSS styles applied to every cell in this column,
|
|
238
|
-
* including both the header and body cells.
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* style: { textAlign: 'right', fontFamily: 'monospace' }
|
|
242
|
-
*/
|
|
63
|
+
/** Inline CSS styles applied to every cell in this column. */
|
|
243
64
|
style?: React.CSSProperties;
|
|
244
65
|
/**
|
|
245
|
-
* Enables the "Copy" action in the cell
|
|
246
|
-
*
|
|
247
|
-
* - `true` — copies the raw cell value as a string via `String(value)`
|
|
248
|
-
* - A function — called with `(value, record, index)` to produce the
|
|
249
|
-
* string that is copied to the clipboard. Similar to `sorter`.
|
|
250
|
-
*
|
|
251
|
-
* When omitted or `false`, no "Copy" option appears in the cell menu.
|
|
252
|
-
*
|
|
253
|
-
* @example
|
|
254
|
-
* // Default copy
|
|
255
|
-
* copy: true
|
|
256
|
-
*
|
|
257
|
-
* // Custom copy — combine fields
|
|
258
|
-
* copy: (value, record) => `${record.firstName} ${record.lastName}`
|
|
66
|
+
* Enables the "Copy" action in the cell context menu.
|
|
67
|
+
* `true` copies the raw value; pass a function for custom copy text.
|
|
259
68
|
*/
|
|
260
69
|
copy?: boolean | ((value: unknown, record: T, index: number) => string);
|
|
261
70
|
}
|
|
262
|
-
/**
|
|
263
|
-
* A single item in the column header context menu (right-click menu).
|
|
264
|
-
* Use `columnContextMenuItems` on BoltTable to inject custom actions
|
|
265
|
-
* alongside the built-in sort/filter/pin/hide options.
|
|
266
|
-
*
|
|
267
|
-
* @example
|
|
268
|
-
* const menuItems: ColumnContextMenuItem[] = [
|
|
269
|
-
* {
|
|
270
|
-
* key: 'copy',
|
|
271
|
-
* label: 'Copy column data',
|
|
272
|
-
* icon: <CopyIcon />,
|
|
273
|
-
* onClick: (columnKey) => copyColumnToClipboard(columnKey),
|
|
274
|
-
* },
|
|
275
|
-
* {
|
|
276
|
-
* key: 'delete',
|
|
277
|
-
* label: 'Remove column',
|
|
278
|
-
* danger: true,
|
|
279
|
-
* onClick: (columnKey) => removeColumn(columnKey),
|
|
280
|
-
* },
|
|
281
|
-
* ];
|
|
282
|
-
*/
|
|
71
|
+
/** A single item in the column header right-click context menu. */
|
|
283
72
|
interface ColumnContextMenuItem {
|
|
284
|
-
/**
|
|
285
|
-
* Unique identifier for this menu item.
|
|
286
|
-
* Used as the React `key` prop — must be unique among all custom items.
|
|
287
|
-
*/
|
|
73
|
+
/** Unique identifier for this menu item, used as the React `key`. */
|
|
288
74
|
key: string;
|
|
289
|
-
/**
|
|
290
|
-
* The label shown in the menu. Can be a string or any React node.
|
|
291
|
-
*
|
|
292
|
-
* @example
|
|
293
|
-
* label: 'Copy column'
|
|
294
|
-
* label: <span style={{ fontWeight: 'bold' }}>Copy column</span>
|
|
295
|
-
*/
|
|
75
|
+
/** The label shown in the menu. Can be a string or React node. */
|
|
296
76
|
label: React.ReactNode;
|
|
297
|
-
/**
|
|
298
|
-
* Optional icon shown to the left of the label.
|
|
299
|
-
* Recommended size: 12–14px .
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* icon: <CopyIcon className="h-3 w-3" />
|
|
303
|
-
*/
|
|
77
|
+
/** Optional icon shown to the left of the label. */
|
|
304
78
|
icon?: React.ReactNode;
|
|
305
|
-
/**
|
|
306
|
-
* When `true`, the label renders in red to indicate a destructive action.
|
|
307
|
-
*
|
|
308
|
-
* @default false
|
|
309
|
-
*/
|
|
79
|
+
/** When `true`, the label renders in red to indicate a destructive action. */
|
|
310
80
|
danger?: boolean;
|
|
311
|
-
/**
|
|
312
|
-
* When `true`, the item is grayed out and the click handler is not called.
|
|
313
|
-
*
|
|
314
|
-
* @default false
|
|
315
|
-
*/
|
|
81
|
+
/** When `true`, the item is grayed out and click handler is not called. */
|
|
316
82
|
disabled?: boolean;
|
|
317
|
-
/**
|
|
318
|
-
* Called when the user clicks this menu item.
|
|
319
|
-
*
|
|
320
|
-
* @param columnKey - The `key` of the column whose header was right-clicked
|
|
321
|
-
*
|
|
322
|
-
* @example
|
|
323
|
-
* onClick: (columnKey) => console.log('Clicked on column:', columnKey)
|
|
324
|
-
*/
|
|
83
|
+
/** Called when the user clicks this menu item. Receives the column `key`. */
|
|
325
84
|
onClick: (columnKey: string) => void;
|
|
326
85
|
}
|
|
327
|
-
/**
|
|
328
|
-
* How the row selection was triggered.
|
|
329
|
-
*
|
|
330
|
-
* - `'all'` — select/deselect all rows via the header checkbox
|
|
331
|
-
* - `'single'` — a single row was selected (radio or single click)
|
|
332
|
-
* - `'multiple'` — individual checkboxes toggled
|
|
333
|
-
*/
|
|
86
|
+
/** How the row selection was triggered: `'all'`, `'single'`, or `'multiple'`. */
|
|
334
87
|
type RowSelectMethod = 'all' | 'single' | 'multiple';
|
|
335
|
-
/**
|
|
336
|
-
* Configuration for expandable rows.
|
|
337
|
-
* When provided, each row gets an expand toggle button that reveals
|
|
338
|
-
* a custom rendered panel below the row.
|
|
339
|
-
*
|
|
340
|
-
* @typeParam T - The type of a single row record
|
|
341
|
-
*
|
|
342
|
-
* @example
|
|
343
|
-
* const expandable: ExpandableConfig<Order> = {
|
|
344
|
-
* rowExpandable: (record) => record.items.length > 0,
|
|
345
|
-
* expandedRowRender: (record) => (
|
|
346
|
-
* <div>
|
|
347
|
-
* {record.items.map(item => <div key={item.id}>{item.name}</div>)}
|
|
348
|
-
* </div>
|
|
349
|
-
* ),
|
|
350
|
-
* };
|
|
351
|
-
*/
|
|
88
|
+
/** Configuration for expandable rows with a custom rendered panel below each row. */
|
|
352
89
|
interface ExpandableConfig<T = unknown> {
|
|
353
|
-
/**
|
|
354
|
-
* When `true`, all rows are expanded on initial render.
|
|
355
|
-
* Takes priority over `defaultExpandedRowKeys`.
|
|
356
|
-
*
|
|
357
|
-
* @default false
|
|
358
|
-
*/
|
|
90
|
+
/** When `true`, all rows are expanded on initial render. */
|
|
359
91
|
defaultExpandAllRows?: boolean;
|
|
360
|
-
/**
|
|
361
|
-
* Controlled list of currently expanded row keys.
|
|
362
|
-
* When provided, BoltTable operates in **controlled mode** — you must
|
|
363
|
-
* update this list yourself in `onExpandedRowsChange`.
|
|
364
|
-
* When omitted, BoltTable manages expansion state internally.
|
|
365
|
-
*
|
|
366
|
-
* @example
|
|
367
|
-
* expandedRowKeys={expandedKeys}
|
|
368
|
-
*/
|
|
92
|
+
/** Controlled list of currently expanded row keys. Omit for uncontrolled mode. */
|
|
369
93
|
expandedRowKeys?: React.Key[];
|
|
370
|
-
/**
|
|
371
|
-
* Renders the expanded content panel for a row.
|
|
372
|
-
* This panel appears directly below the row when it is expanded.
|
|
373
|
-
* The panel auto-sizes to its content height.
|
|
374
|
-
*
|
|
375
|
-
* @param record - The row data object
|
|
376
|
-
* @param index - The row index (0-based)
|
|
377
|
-
* @param indent - The indent level (always 0 for flat tables)
|
|
378
|
-
* @param expanded - Whether the row is currently expanded (`true`)
|
|
379
|
-
* @returns The React content to render in the expanded panel
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* expandedRowRender: (record) => (
|
|
383
|
-
* <pre>{JSON.stringify(record, null, 2)}</pre>
|
|
384
|
-
* )
|
|
385
|
-
*/
|
|
94
|
+
/** Renders the expanded content panel for a row. */
|
|
386
95
|
expandedRowRender: (record: T, index: number, indent: number, expanded: boolean) => ReactNode;
|
|
387
|
-
/**
|
|
388
|
-
* Row keys that are expanded by default on first render (uncontrolled mode).
|
|
389
|
-
* Ignored when `expandedRowKeys` is provided.
|
|
390
|
-
*
|
|
391
|
-
* @example
|
|
392
|
-
* defaultExpandedRowKeys={['row-1', 'row-3']}
|
|
393
|
-
*/
|
|
96
|
+
/** Row keys expanded by default on first render (uncontrolled mode). */
|
|
394
97
|
defaultExpandedRowKeys?: React.Key[];
|
|
395
|
-
/**
|
|
396
|
-
* Called whenever the set of expanded rows changes.
|
|
397
|
-
* In controlled mode, use this to update your `expandedRowKeys` state.
|
|
398
|
-
*
|
|
399
|
-
* @param expandedKeys - The full list of currently expanded row keys
|
|
400
|
-
*
|
|
401
|
-
* @example
|
|
402
|
-
* onExpandedRowsChange={(keys) => setExpandedKeys(keys)}
|
|
403
|
-
*/
|
|
98
|
+
/** Called whenever the set of expanded rows changes. */
|
|
404
99
|
onExpandedRowsChange?: (expandedKeys: React.Key[]) => void;
|
|
405
|
-
/**
|
|
406
|
-
* Controls whether to show the expand icon for a specific row.
|
|
407
|
-
* Return `false` to hide the toggle for rows that cannot be expanded visually.
|
|
408
|
-
*
|
|
409
|
-
* @example
|
|
410
|
-
* showExpandIcon: (record) => record.hasChildren
|
|
411
|
-
*/
|
|
100
|
+
/** Controls whether the expand icon is shown for a specific row. */
|
|
412
101
|
showExpandIcon?: (record: T) => boolean;
|
|
413
|
-
/**
|
|
414
|
-
* Determines whether a specific row is expandable.
|
|
415
|
-
* When this returns `false` for a row, no expand button is rendered for it.
|
|
416
|
-
*
|
|
417
|
-
* @example
|
|
418
|
-
* rowExpandable: (record) => record.subRows.length > 0
|
|
419
|
-
*/
|
|
102
|
+
/** Determines whether a specific row is expandable. */
|
|
420
103
|
rowExpandable?: (record: T) => boolean;
|
|
421
104
|
}
|
|
422
|
-
/**
|
|
423
|
-
* Configuration for row selection (checkboxes or radio buttons).
|
|
424
|
-
* When provided, a selection column is prepended to the left of the table.
|
|
425
|
-
*
|
|
426
|
-
* @typeParam T - The type of a single row record
|
|
427
|
-
*
|
|
428
|
-
* @example
|
|
429
|
-
* // Checkbox selection
|
|
430
|
-
* const rowSelection: RowSelectionConfig<User> = {
|
|
431
|
-
* type: 'checkbox',
|
|
432
|
-
* selectedRowKeys,
|
|
433
|
-
* onChange: (keys, rows) => setSelectedRowKeys(keys),
|
|
434
|
-
* };
|
|
435
|
-
*
|
|
436
|
-
* // Radio selection (single row only)
|
|
437
|
-
* const rowSelection: RowSelectionConfig<User> = {
|
|
438
|
-
* type: 'radio',
|
|
439
|
-
* selectedRowKeys,
|
|
440
|
-
* onChange: (keys, rows) => setSelectedRowKeys(keys),
|
|
441
|
-
* };
|
|
442
|
-
*/
|
|
105
|
+
/** Configuration for row selection (checkboxes or radio buttons). */
|
|
443
106
|
interface RowSelectionConfig<T = unknown> {
|
|
444
|
-
/**
|
|
445
|
-
* The type of selection control.
|
|
446
|
-
* - `'checkbox'` — multiple rows can be selected (default)
|
|
447
|
-
* - `'radio'` — only one row can be selected at a time
|
|
448
|
-
*
|
|
449
|
-
* @default 'checkbox'
|
|
450
|
-
*/
|
|
107
|
+
/** `'checkbox'` for multi-select (default) or `'radio'` for single-select. */
|
|
451
108
|
type?: 'checkbox' | 'radio';
|
|
452
|
-
/**
|
|
453
|
-
* When `true`, hides the "select all" checkbox in the header.
|
|
454
|
-
* Useful when using radio mode or when you want to prevent bulk selection.
|
|
455
|
-
*
|
|
456
|
-
* @default false
|
|
457
|
-
*/
|
|
109
|
+
/** When `true`, hides the "select all" checkbox in the header. */
|
|
458
110
|
hideSelectAll?: boolean;
|
|
459
|
-
/**
|
|
460
|
-
* The currently selected row keys (controlled).
|
|
461
|
-
* This must always be provided — BoltTable does not manage selection state internally.
|
|
462
|
-
* Keys are matched against the value returned by the `rowKey` prop on BoltTable.
|
|
463
|
-
*
|
|
464
|
-
* @example
|
|
465
|
-
* selectedRowKeys={['row-1', 'row-5']}
|
|
466
|
-
*/
|
|
111
|
+
/** The currently selected row keys (controlled). */
|
|
467
112
|
selectedRowKeys: React.Key[];
|
|
468
|
-
/**
|
|
469
|
-
* Called when the header "select all" checkbox is toggled.
|
|
470
|
-
*
|
|
471
|
-
* @param selected - `true` if selecting all, `false` if deselecting all
|
|
472
|
-
* @param selectedRows - The rows that are now selected
|
|
473
|
-
* @param changeRows - The rows that changed in this action
|
|
474
|
-
*
|
|
475
|
-
* @example
|
|
476
|
-
* onSelectAll: (selected, rows) => {
|
|
477
|
-
* setSelectedKeys(selected ? rows.map(r => r.id) : []);
|
|
478
|
-
* }
|
|
479
|
-
*/
|
|
113
|
+
/** Called when the header "select all" checkbox is toggled. */
|
|
480
114
|
onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
|
|
481
|
-
/**
|
|
482
|
-
* Called when a single row's checkbox or radio is toggled.
|
|
483
|
-
*
|
|
484
|
-
* @param record - The row record that was toggled
|
|
485
|
-
* @param selected - `true` if the row is now selected
|
|
486
|
-
* @param selectedRows - All currently selected rows after this change
|
|
487
|
-
* @param nativeEvent - The original DOM event
|
|
488
|
-
*
|
|
489
|
-
* @example
|
|
490
|
-
* onSelect: (record, selected) => {
|
|
491
|
-
* console.log(`Row ${record.id} is now ${selected ? 'selected' : 'deselected'}`);
|
|
492
|
-
* }
|
|
493
|
-
*/
|
|
115
|
+
/** Called when a single row's checkbox or radio is toggled. */
|
|
494
116
|
onSelect?: (record: T, selected: boolean, selectedRows: T[], nativeEvent: Event) => void;
|
|
495
|
-
/**
|
|
496
|
-
* Called whenever the selection changes for any reason (single toggle or select all).
|
|
497
|
-
* This is the primary callback for keeping your state in sync.
|
|
498
|
-
*
|
|
499
|
-
* @param selectedRowKeys - The full list of currently selected row keys
|
|
500
|
-
* @param selectedRows - The full list of currently selected row records
|
|
501
|
-
* @param info - Metadata about how the change was triggered
|
|
502
|
-
*
|
|
503
|
-
* @example
|
|
504
|
-
* onChange: (keys, rows) => {
|
|
505
|
-
* setSelectedRowKeys(keys);
|
|
506
|
-
* setSelectedRows(rows);
|
|
507
|
-
* }
|
|
508
|
-
*/
|
|
117
|
+
/** Called whenever the selection changes for any reason. Primary state-sync callback. */
|
|
509
118
|
onChange?: (selectedRowKeys: React.Key[], selectedRows: T[], info: {
|
|
510
119
|
type: RowSelectMethod;
|
|
511
120
|
}) => void;
|
|
512
|
-
/**
|
|
513
|
-
* Returns additional props for the checkbox/radio of a specific row.
|
|
514
|
-
* Currently supports `disabled` to prevent a row from being selected.
|
|
515
|
-
*
|
|
516
|
-
* @param record - The row record
|
|
517
|
-
* @returns An object with optional `disabled` boolean
|
|
518
|
-
*
|
|
519
|
-
* @example
|
|
520
|
-
* getCheckboxProps: (record) => ({
|
|
521
|
-
* disabled: record.status === 'locked',
|
|
522
|
-
* })
|
|
523
|
-
*/
|
|
121
|
+
/** Returns additional props (e.g. `disabled`) for the checkbox/radio of a specific row. */
|
|
524
122
|
getCheckboxProps?: (record: T) => {
|
|
525
123
|
disabled?: boolean;
|
|
526
124
|
};
|
|
527
125
|
}
|
|
528
|
-
/**
|
|
529
|
-
* Configuration for the pagination footer.
|
|
530
|
-
* Pass `false` to the `pagination` prop on BoltTable to disable pagination entirely.
|
|
531
|
-
*
|
|
532
|
-
* BoltTable supports both **client-side** and **server-side** pagination:
|
|
533
|
-
* - **Client-side**: pass all your data at once; BoltTable slices it per page automatically.
|
|
534
|
-
* - **Server-side**: pass only the current page's data; set `total` to the full dataset size
|
|
535
|
-
* and handle `onPaginationChange` to fetch the next page from your API.
|
|
536
|
-
*
|
|
537
|
-
* @example
|
|
538
|
-
* // Client-side (pass all data)
|
|
539
|
-
* pagination={{ pageSize: 20 }}
|
|
540
|
-
*
|
|
541
|
-
* // Server-side
|
|
542
|
-
* pagination={{
|
|
543
|
-
* current: page,
|
|
544
|
-
* pageSize: 20,
|
|
545
|
-
* total: 500,
|
|
546
|
-
* showTotal: (total, range) => `${range[0]}-${range[1]} of ${total}`,
|
|
547
|
-
* }}
|
|
548
|
-
*/
|
|
126
|
+
/** Configuration for the pagination footer. Pass `false` to disable pagination. */
|
|
549
127
|
interface PaginationType {
|
|
550
|
-
/**
|
|
551
|
-
* The current active page number (1-based).
|
|
552
|
-
* Required for controlled / server-side pagination.
|
|
553
|
-
* Defaults to `1` if omitted.
|
|
554
|
-
*
|
|
555
|
-
* @example
|
|
556
|
-
* current: 3 // currently on page 3
|
|
557
|
-
*/
|
|
128
|
+
/** Current active page number (1-based). Defaults to `1`. */
|
|
558
129
|
current?: number;
|
|
559
|
-
/**
|
|
560
|
-
* Number of rows displayed per page.
|
|
561
|
-
* The user can also change this via the page-size selector in the footer.
|
|
562
|
-
*
|
|
563
|
-
* @default 10
|
|
564
|
-
*
|
|
565
|
-
* @example
|
|
566
|
-
* pageSize: 25
|
|
567
|
-
*/
|
|
130
|
+
/** Number of rows displayed per page. Defaults to `10`. */
|
|
568
131
|
pageSize?: number;
|
|
569
|
-
/**
|
|
570
|
-
* The total number of rows across **all pages**.
|
|
571
|
-
* Required for server-side pagination so BoltTable knows how many pages exist.
|
|
572
|
-
* For client-side pagination, omit this — BoltTable calculates it from `data.length`.
|
|
573
|
-
*
|
|
574
|
-
* @example
|
|
575
|
-
* total: 1234 // 1234 rows total on the server
|
|
576
|
-
*/
|
|
132
|
+
/** Total number of rows across all pages. Required for server-side pagination. */
|
|
577
133
|
total?: number;
|
|
578
|
-
/**
|
|
579
|
-
* Custom renderer for the "showing X-Y of Z" text in the pagination footer.
|
|
580
|
-
*
|
|
581
|
-
* @param total - The total number of rows
|
|
582
|
-
* @param range - A tuple `[start, end]` of the currently visible row range
|
|
583
|
-
* @returns A React node to render as the total label
|
|
584
|
-
*
|
|
585
|
-
* @example
|
|
586
|
-
* showTotal: (total, [start, end]) => `Showing ${start} to ${end} of ${total} results`
|
|
587
|
-
*/
|
|
134
|
+
/** Custom renderer for the "showing X–Y of Z" text in the pagination footer. */
|
|
588
135
|
showTotal?: (total: number, range: [number, number]) => ReactNode;
|
|
589
136
|
}
|
|
590
|
-
/**
|
|
591
|
-
* Configuration for row pinning.
|
|
592
|
-
* When provided, the specified rows are rendered as sticky rows at the top
|
|
593
|
-
* and/or bottom of the table body, remaining visible during vertical scroll.
|
|
594
|
-
*
|
|
595
|
-
* Pinned rows are excluded from pagination — they are always visible regardless
|
|
596
|
-
* of which page the user is on. Filtering still applies: if a pinned row's key
|
|
597
|
-
* doesn't exist in the (filtered) data, it simply won't appear.
|
|
598
|
-
*
|
|
599
|
-
* @example
|
|
600
|
-
* // Pin two rows to the top and one to the bottom
|
|
601
|
-
* rowPinning={{ top: ['row-1', 'row-3'], bottom: ['row-10'] }}
|
|
602
|
-
*
|
|
603
|
-
* @example
|
|
604
|
-
* // Controlled pinning — manage pinned keys in parent state
|
|
605
|
-
* const [pinning, setPinning] = useState<RowPinningConfig>({ top: ['header-row'] });
|
|
606
|
-
* <BoltTable rowPinning={pinning} ... />
|
|
607
|
-
*/
|
|
137
|
+
/** Configuration for row pinning. Pinned rows remain visible during vertical scroll. */
|
|
608
138
|
interface RowPinningConfig {
|
|
609
|
-
/**
|
|
610
|
-
* Row keys to pin at the top of the table.
|
|
611
|
-
* These rows stick below the column headers during vertical scroll.
|
|
612
|
-
* Order is preserved — rows are rendered in the order listed here.
|
|
613
|
-
*/
|
|
139
|
+
/** Row keys to pin at the top of the table. */
|
|
614
140
|
top?: React.Key[];
|
|
615
|
-
/**
|
|
616
|
-
* Row keys to pin at the bottom of the table.
|
|
617
|
-
* These rows stick to the bottom of the visible area during vertical scroll.
|
|
618
|
-
* Order is preserved — rows are rendered in the order listed here.
|
|
619
|
-
*/
|
|
141
|
+
/** Row keys to pin at the bottom of the table. */
|
|
620
142
|
bottom?: React.Key[];
|
|
621
143
|
}
|
|
622
|
-
/**
|
|
623
|
-
* The base type for a row record in BoltTable.
|
|
624
|
-
* All row data objects must be indexable by string keys.
|
|
625
|
-
*
|
|
626
|
-
* BoltTable is generic over `T extends DataRecord`, so you can pass your
|
|
627
|
-
* own strongly-typed row type for full type safety in `render`, `sorter`,
|
|
628
|
-
* `filterFn`, and selection callbacks.
|
|
629
|
-
*
|
|
630
|
-
* @example
|
|
631
|
-
* interface User extends DataRecord {
|
|
632
|
-
* id: string;
|
|
633
|
-
* name: string;
|
|
634
|
-
* email: string;
|
|
635
|
-
* age: number;
|
|
636
|
-
* }
|
|
637
|
-
*
|
|
638
|
-
* <BoltTable<User> columns={columns} data={users} />
|
|
639
|
-
*/
|
|
144
|
+
/** Base type for row records — all row objects must be indexable by string keys. */
|
|
640
145
|
type DataRecord = Record<string, unknown>;
|
|
641
146
|
|
|
642
|
-
/**
|
|
643
|
-
* Props for the BoltTable component.
|
|
644
|
-
*
|
|
645
|
-
* @typeParam T - The type of a single row record. Must extend `DataRecord`
|
|
646
|
-
* (i.e. `Record<string, unknown>`). Pass your own interface for
|
|
647
|
-
* full type safety in column `render`, `sorter`, and `filterFn`.
|
|
648
|
-
*
|
|
649
|
-
* @example
|
|
650
|
-
* interface User {
|
|
651
|
-
* id: string;
|
|
652
|
-
* name: string;
|
|
653
|
-
* email: string;
|
|
654
|
-
* age: number;
|
|
655
|
-
* }
|
|
656
|
-
*
|
|
657
|
-
* <BoltTable<User>
|
|
658
|
-
* columns={columns}
|
|
659
|
-
* data={users}
|
|
660
|
-
* rowKey="id"
|
|
661
|
-
* pagination={{ pageSize: 20 }}
|
|
662
|
-
* />
|
|
663
|
-
*/
|
|
664
147
|
interface BoltTableProps<T extends DataRecord = DataRecord> {
|
|
665
|
-
/**
|
|
666
|
-
* Column definitions array. Controls what columns are shown, their order,
|
|
667
|
-
* width, pinning, sort/filter behavior, and cell rendering.
|
|
668
|
-
*
|
|
669
|
-
* BoltTable watches this array for changes using a content fingerprint
|
|
670
|
-
* (key + hidden + pinned + width). The internal column state syncs whenever
|
|
671
|
-
* the fingerprint changes, but sub-pixel width jitter (e.g. percentage widths)
|
|
672
|
-
* is normalized to avoid unnecessary re-syncs.
|
|
673
|
-
*
|
|
674
|
-
* @example
|
|
675
|
-
* const columns: ColumnType<User>[] = [
|
|
676
|
-
* { key: 'name', dataIndex: 'name', title: 'Name', width: 200, sortable: true },
|
|
677
|
-
* { key: 'email', dataIndex: 'email', title: 'Email', width: 250 },
|
|
678
|
-
* { key: 'age', dataIndex: 'age', title: 'Age', width: 80, sortable: true },
|
|
679
|
-
* ];
|
|
680
|
-
*/
|
|
148
|
+
/** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
|
|
681
149
|
readonly columns: ColumnType<T>[];
|
|
682
|
-
/**
|
|
683
|
-
* The row data to display. Each element corresponds to one table row.
|
|
684
|
-
*
|
|
685
|
-
* For **client-side** pagination/sort/filter, pass the full dataset.
|
|
686
|
-
* BoltTable will slice, sort, and filter it internally.
|
|
687
|
-
*
|
|
688
|
-
* For **server-side** operations, pass only the current page's data and
|
|
689
|
-
* provide `onSortChange`, `onFilterChange`, and `onPaginationChange` callbacks
|
|
690
|
-
* to handle these operations on your server.
|
|
691
|
-
*
|
|
692
|
-
* @example
|
|
693
|
-
* data={users} // User[]
|
|
694
|
-
*/
|
|
150
|
+
/** The row data to display. Each element corresponds to one table row. */
|
|
695
151
|
readonly data: T[];
|
|
696
|
-
/**
|
|
697
|
-
* Height of each regular (non-expanded) row in pixels.
|
|
698
|
-
* All rows must have the same base height for virtualization to work correctly.
|
|
699
|
-
*
|
|
700
|
-
* @default 40
|
|
701
|
-
*
|
|
702
|
-
* @example
|
|
703
|
-
* rowHeight={48}
|
|
704
|
-
*/
|
|
152
|
+
/** Height of each row in pixels. All rows must have the same base height for virtualization. */
|
|
705
153
|
readonly rowHeight?: number;
|
|
706
|
-
/**
|
|
707
|
-
* The **estimated** height (in pixels) for expanded row content panels.
|
|
708
|
-
* Used as the initial size estimate when a row is first expanded, before
|
|
709
|
-
* the actual content height has been measured by ResizeObserver.
|
|
710
|
-
* Once measured, the virtualizer updates to the real height.
|
|
711
|
-
*
|
|
712
|
-
* Set this close to your typical expanded row height for the smoothest experience.
|
|
713
|
-
*
|
|
714
|
-
* @default 200
|
|
715
|
-
*
|
|
716
|
-
* @example
|
|
717
|
-
* expandedRowHeight={300}
|
|
718
|
-
*/
|
|
154
|
+
/** Estimated height (px) for expanded row content, used before actual measurement. */
|
|
719
155
|
readonly expandedRowHeight?: number;
|
|
720
|
-
/**
|
|
721
|
-
* Optional maximum height in pixels for expanded row panels.
|
|
722
|
-
* When the expanded content exceeds this height, the panel becomes scrollable.
|
|
723
|
-
* When omitted, panels grow to their full content height.
|
|
724
|
-
*
|
|
725
|
-
* @example
|
|
726
|
-
* maxExpandedRowHeight={400}
|
|
727
|
-
*/
|
|
156
|
+
/** Max height in pixels for expanded row panels. Scrolls when exceeded. */
|
|
728
157
|
readonly maxExpandedRowHeight?: number;
|
|
729
|
-
/**
|
|
730
|
-
* The primary color used for interactive elements throughout the table:
|
|
731
|
-
* - Sort direction indicators in column headers
|
|
732
|
-
* - Active filter icon in column headers
|
|
733
|
-
* - Column resize overlay line and label
|
|
734
|
-
* - Selected row background tint (as a transparent overlay)
|
|
735
|
-
* - Expand/collapse chevron buttons
|
|
736
|
-
* - Checkbox and radio button accent color
|
|
737
|
-
* - Highlighted sort/filter options in the context menu
|
|
738
|
-
* - Page number highlight in the pagination footer
|
|
739
|
-
*
|
|
740
|
-
* Accepts any valid CSS color string.
|
|
741
|
-
*
|
|
742
|
-
* @default '#1890ff'
|
|
743
|
-
*
|
|
744
|
-
* @example
|
|
745
|
-
* accentColor="#6366f1" // indigo
|
|
746
|
-
* accentColor="#10b981" // emerald
|
|
747
|
-
* accentColor="hsl(262, 80%, 50%)"
|
|
748
|
-
*/
|
|
158
|
+
/** Primary color for interactive elements (sort indicators, selected rows, checkboxes, etc.). */
|
|
749
159
|
readonly accentColor?: string;
|
|
750
|
-
/**
|
|
751
|
-
* Additional CSS class name applied to the outermost wrapper div of BoltTable.
|
|
752
|
-
* Use this to apply custom sizing, border, or shadow to the table container.
|
|
753
|
-
*
|
|
754
|
-
* @example
|
|
755
|
-
* className="rounded-lg border shadow-sm"
|
|
756
|
-
*/
|
|
160
|
+
/** Additional CSS class name applied to the outermost wrapper div. */
|
|
757
161
|
readonly className?: string;
|
|
758
|
-
/**
|
|
759
|
-
* Granular CSS class name overrides for specific parts of the table.
|
|
760
|
-
* Each key targets a different region of the table.
|
|
761
|
-
*
|
|
762
|
-
* @example
|
|
763
|
-
* classNames={{
|
|
764
|
-
* header: 'text-xs uppercase tracking-wider',
|
|
765
|
-
* cell: 'text-sm',
|
|
766
|
-
* row: 'border-b',
|
|
767
|
-
* pinnedHeader: 'bg-blue-50',
|
|
768
|
-
* pinnedCell: 'bg-blue-50/50',
|
|
769
|
-
* }}
|
|
770
|
-
*/
|
|
162
|
+
/** Granular CSS class name overrides for specific parts of the table. */
|
|
771
163
|
readonly classNames?: ClassNamesTypes;
|
|
772
|
-
/**
|
|
773
|
-
* Inline style overrides for specific parts of the table.
|
|
774
|
-
* Applied after all default and className-based styles, so these take
|
|
775
|
-
* the highest specificity.
|
|
776
|
-
*
|
|
777
|
-
* Note: `pinnedBg` is a special string property (not CSSProperties) that
|
|
778
|
-
* sets the background color of pinned column cells and headers directly.
|
|
779
|
-
*
|
|
780
|
-
* @example
|
|
781
|
-
* styles={{
|
|
782
|
-
* header: { fontSize: 12, fontWeight: 600 },
|
|
783
|
-
* pinnedBg: 'rgba(239, 246, 255, 0.9)',
|
|
784
|
-
* rowHover: { backgroundColor: '#f0f9ff' },
|
|
785
|
-
* rowSelected: { backgroundColor: '#dbeafe' },
|
|
786
|
-
* }}
|
|
787
|
-
*/
|
|
164
|
+
/** Inline style overrides for specific parts of the table. */
|
|
788
165
|
readonly styles?: StylesTypes;
|
|
789
|
-
/**
|
|
790
|
-
* A custom React node to use as the drag grip icon in column headers.
|
|
791
|
-
* When omitted, the default GripVertical SVG icon is used.
|
|
792
|
-
* Ignored when `hideGripIcon` is `true`.
|
|
793
|
-
*
|
|
794
|
-
* @deprecated Use `icons.gripVertical` instead. This prop is kept for backward compatibility.
|
|
795
|
-
*
|
|
796
|
-
* @example
|
|
797
|
-
* gripIcon={<DragHandleIcon style={{ width: 12, height: 12 }} />}
|
|
798
|
-
*/
|
|
166
|
+
/** @deprecated Use `icons.gripVertical` instead. Custom drag grip icon for column headers. */
|
|
799
167
|
readonly gripIcon?: React$1.ReactNode;
|
|
800
|
-
/**
|
|
801
|
-
* Custom icon overrides for the table's built-in icons.
|
|
802
|
-
* Pass any subset of icons to replace the defaults. Unspecified icons use
|
|
803
|
-
* the built-in SVG icons. Each icon should be a pre-sized React node.
|
|
804
|
-
*
|
|
805
|
-
* @example
|
|
806
|
-
* icons={{
|
|
807
|
-
* gripVertical: <MyGripIcon size={12} />,
|
|
808
|
-
* sortAsc: <MySortUpIcon size={12} />,
|
|
809
|
-
* chevronsLeft: <MyFirstPageIcon size={12} />,
|
|
810
|
-
* }}
|
|
811
|
-
*/
|
|
168
|
+
/** Custom icon overrides for the table's built-in icons. */
|
|
812
169
|
readonly icons?: BoltTableIcons;
|
|
813
|
-
/**
|
|
814
|
-
* When `true`, the drag grip icon is hidden from all column headers.
|
|
815
|
-
* Columns can still be dragged even without the grip icon.
|
|
816
|
-
*
|
|
817
|
-
* @default false
|
|
818
|
-
*
|
|
819
|
-
* @example
|
|
820
|
-
* hideGripIcon={true}
|
|
821
|
-
*/
|
|
170
|
+
/** When true, the drag grip icon is hidden from all column headers. */
|
|
822
171
|
readonly hideGripIcon?: boolean;
|
|
823
|
-
/**
|
|
824
|
-
* Pagination configuration for the footer, or `false` to disable pagination entirely.
|
|
825
|
-
*
|
|
826
|
-
* **Client-side pagination** (pass all data, BoltTable slices it):
|
|
827
|
-
* ```tsx
|
|
828
|
-
* pagination={{ pageSize: 20 }}
|
|
829
|
-
* ```
|
|
830
|
-
*
|
|
831
|
-
* **Server-side pagination** (pass only current page's data):
|
|
832
|
-
* ```tsx
|
|
833
|
-
* pagination={{ current: page, pageSize: 20, total: 500 }}
|
|
834
|
-
* onPaginationChange={(page, size) => fetchPage(page, size)}
|
|
835
|
-
* ```
|
|
836
|
-
*
|
|
837
|
-
* **Disable pagination:**
|
|
838
|
-
* ```tsx
|
|
839
|
-
* pagination={false}
|
|
840
|
-
* ```
|
|
841
|
-
*
|
|
842
|
-
* @default undefined (pagination footer shown with default settings)
|
|
843
|
-
*/
|
|
172
|
+
/** Pagination configuration for the footer, or false to disable pagination. */
|
|
844
173
|
readonly pagination?: PaginationType | false;
|
|
845
|
-
/**
|
|
846
|
-
* Called when the user changes the current page or page size via the pagination footer.
|
|
847
|
-
* Required for server-side pagination. For client-side pagination, this is optional
|
|
848
|
-
* (BoltTable handles page changes internally).
|
|
849
|
-
*
|
|
850
|
-
* @param page - The new page number (1-based)
|
|
851
|
-
* @param pageSize - The new page size
|
|
852
|
-
*
|
|
853
|
-
* @example
|
|
854
|
-
* onPaginationChange={(page, size) => {
|
|
855
|
-
* setCurrentPage(page);
|
|
856
|
-
* setPageSize(size);
|
|
857
|
-
* fetchData({ page, size });
|
|
858
|
-
* }}
|
|
859
|
-
*/
|
|
174
|
+
/** Called when the user changes the current page or page size via the pagination footer. */
|
|
860
175
|
readonly onPaginationChange?: (page: number, pageSize: number) => void;
|
|
861
|
-
/**
|
|
862
|
-
* Called when the user finishes resizing a column (on mouse up).
|
|
863
|
-
* Use this to persist the new width to your state or storage.
|
|
864
|
-
*
|
|
865
|
-
* @param columnKey - The `key` of the resized column
|
|
866
|
-
* @param newWidth - The new column width in pixels
|
|
867
|
-
*
|
|
868
|
-
* @example
|
|
869
|
-
* onColumnResize={(key, width) => {
|
|
870
|
-
* setColumnWidths(prev => ({ ...prev, [key]: width }));
|
|
871
|
-
* }}
|
|
872
|
-
*/
|
|
176
|
+
/** Called when the user finishes resizing a column (on mouse up). */
|
|
873
177
|
readonly onColumnResize?: (columnKey: string, newWidth: number) => void;
|
|
874
|
-
/**
|
|
875
|
-
* Called after the user drops a column header into a new position.
|
|
876
|
-
* Receives the full new column key order.
|
|
877
|
-
* Use this to persist the order to your state or storage.
|
|
878
|
-
*
|
|
879
|
-
* @param newOrder - Array of all column keys in their new order
|
|
880
|
-
*
|
|
881
|
-
* @example
|
|
882
|
-
* onColumnOrderChange={(order) => {
|
|
883
|
-
* setColumnOrder(order);
|
|
884
|
-
* }}
|
|
885
|
-
*/
|
|
178
|
+
/** Called after the user drops a column header into a new position. */
|
|
886
179
|
readonly onColumnOrderChange?: (newOrder: string[]) => void;
|
|
887
|
-
/**
|
|
888
|
-
* Called when the user pins or unpins a column via the context menu.
|
|
889
|
-
*
|
|
890
|
-
* @param columnKey - The `key` of the column whose pin state changed
|
|
891
|
-
* @param pinned - The new pin state: `'left'`, `'right'`, or `false`
|
|
892
|
-
*
|
|
893
|
-
* @example
|
|
894
|
-
* onColumnPin={(key, pinned) => {
|
|
895
|
-
* setColumns(prev => prev.map(col =>
|
|
896
|
-
* col.key === key ? { ...col, pinned } : col
|
|
897
|
-
* ));
|
|
898
|
-
* }}
|
|
899
|
-
*/
|
|
180
|
+
/** Called when the user pins or unpins a column via the context menu. */
|
|
900
181
|
readonly onColumnPin?: (columnKey: string, pinned: 'left' | 'right' | false) => void;
|
|
901
|
-
/**
|
|
902
|
-
* Called when the user hides or shows a column via the context menu.
|
|
903
|
-
* Note: pinned columns cannot be hidden.
|
|
904
|
-
*
|
|
905
|
-
* @param columnKey - The `key` of the column whose visibility changed
|
|
906
|
-
* @param hidden - `true` if the column is now hidden, `false` if now visible
|
|
907
|
-
*
|
|
908
|
-
* @example
|
|
909
|
-
* onColumnHide={(key, hidden) => {
|
|
910
|
-
* setColumns(prev => prev.map(col =>
|
|
911
|
-
* col.key === key ? { ...col, hidden } : col
|
|
912
|
-
* ));
|
|
913
|
-
* }}
|
|
914
|
-
*/
|
|
182
|
+
/** Called when the user hides or shows a column via the context menu. */
|
|
915
183
|
readonly onColumnHide?: (columnKey: string, hidden: boolean) => void;
|
|
916
|
-
/**
|
|
917
|
-
* Determines the unique key for each row. Used for selection, expansion,
|
|
918
|
-
* and stable virtualizer item keys.
|
|
919
|
-
*
|
|
920
|
-
* Can be:
|
|
921
|
-
* - A **string**: the name of a property on the row object (e.g. `'id'`)
|
|
922
|
-
* - A **function**: `(record) => string` for computed keys
|
|
923
|
-
* - A **number** or **symbol**: property access by index/symbol
|
|
924
|
-
*
|
|
925
|
-
* Always returns a string internally (numbers/symbols are coerced to string).
|
|
926
|
-
*
|
|
927
|
-
* @default 'id'
|
|
928
|
-
*
|
|
929
|
-
* @example
|
|
930
|
-
* rowKey="id"
|
|
931
|
-
* rowKey={(record) => `${record.type}-${record.id}`}
|
|
932
|
-
*/
|
|
184
|
+
/** Determines the unique key for each row. Can be a string property name, function, number, or symbol. */
|
|
933
185
|
readonly rowKey?: string | ((record: T) => string) | number | symbol;
|
|
934
|
-
/**
|
|
935
|
-
* Row selection configuration. When provided, prepends a checkbox (or radio)
|
|
936
|
-
* column to the left of the table.
|
|
937
|
-
*
|
|
938
|
-
* BoltTable does not manage selection state internally — you must track
|
|
939
|
-
* `selectedRowKeys` in your own state and update it in `onChange`.
|
|
940
|
-
*
|
|
941
|
-
* @example
|
|
942
|
-
* rowSelection={{
|
|
943
|
-
* type: 'checkbox',
|
|
944
|
-
* selectedRowKeys,
|
|
945
|
-
* onChange: (keys) => setSelectedRowKeys(keys),
|
|
946
|
-
* }}
|
|
947
|
-
*/
|
|
186
|
+
/** Row selection configuration. Prepends a checkbox/radio column when provided. */
|
|
948
187
|
expandable?: ExpandableConfig<T>;
|
|
949
|
-
/**
|
|
950
|
-
* Expandable row configuration. When provided, prepends an expand toggle
|
|
951
|
-
* column to the left of the table (to the right of the selection column
|
|
952
|
-
* if both are used).
|
|
953
|
-
*
|
|
954
|
-
* Supports both controlled (`expandedRowKeys`) and uncontrolled modes.
|
|
955
|
-
*
|
|
956
|
-
* @example
|
|
957
|
-
* expandable={{
|
|
958
|
-
* rowExpandable: (record) => record.hasDetails,
|
|
959
|
-
* expandedRowRender: (record) => <DetailPanel record={record} />,
|
|
960
|
-
* }}
|
|
961
|
-
*/
|
|
188
|
+
/** Expandable row configuration. Prepends an expand toggle column when provided. */
|
|
962
189
|
readonly rowSelection?: RowSelectionConfig<T>;
|
|
963
|
-
/**
|
|
964
|
-
* Row pinning configuration. When provided, the specified rows are rendered
|
|
965
|
-
* as sticky rows at the top and/or bottom of the table body.
|
|
966
|
-
*
|
|
967
|
-
* Pinned rows transcend pagination — they are always visible regardless of
|
|
968
|
-
* which page the user is on. Filtering still applies.
|
|
969
|
-
*
|
|
970
|
-
* @example
|
|
971
|
-
* rowPinning={{ top: ['row-1', 'row-3'], bottom: ['row-10'] }}
|
|
972
|
-
*/
|
|
190
|
+
/** Row pinning configuration. Specified rows render as sticky at top and/or bottom. */
|
|
973
191
|
readonly rowPinning?: RowPinningConfig;
|
|
974
|
-
/**
|
|
975
|
-
* Called when the user pins or unpins a row via the cell right-click context menu.
|
|
976
|
-
* Update your `rowPinning` state in this callback.
|
|
977
|
-
*
|
|
978
|
-
* @param rowKey - The key of the row whose pin state changed
|
|
979
|
-
* @param pinned - `'top'`, `'bottom'`, or `false` (unpinned)
|
|
980
|
-
*
|
|
981
|
-
* @example
|
|
982
|
-
* onRowPin={(key, pinned) => {
|
|
983
|
-
* setRowPinning(prev => {
|
|
984
|
-
* const top = (prev.top ?? []).filter(k => String(k) !== String(key));
|
|
985
|
-
* const bottom = (prev.bottom ?? []).filter(k => String(k) !== String(key));
|
|
986
|
-
* if (pinned === 'top') top.push(key);
|
|
987
|
-
* if (pinned === 'bottom') bottom.push(key);
|
|
988
|
-
* return { top, bottom };
|
|
989
|
-
* });
|
|
990
|
-
* }}
|
|
991
|
-
*/
|
|
192
|
+
/** Called when the user pins or unpins a row via the cell context menu. */
|
|
992
193
|
readonly onRowPin?: (rowKey: React$1.Key, pinned: 'top' | 'bottom' | false) => void;
|
|
993
|
-
/**
|
|
994
|
-
* Called when the user scrolls near the bottom of the table.
|
|
995
|
-
* Use this for infinite scroll / load-more behavior.
|
|
996
|
-
* Fires when the last visible row is within `onEndReachedThreshold` rows of the end.
|
|
997
|
-
*
|
|
998
|
-
* A debounce guard prevents this from firing repeatedly — it resets automatically
|
|
999
|
-
* when `data.length` changes or when `isLoading` flips back to `false`.
|
|
1000
|
-
*
|
|
1001
|
-
* @example
|
|
1002
|
-
* onEndReached={() => {
|
|
1003
|
-
* if (!isLoading) fetchNextPage();
|
|
1004
|
-
* }}
|
|
1005
|
-
*/
|
|
194
|
+
/** Called when the user scrolls near the bottom of the table. Use for infinite scroll. */
|
|
1006
195
|
readonly onEndReached?: () => void;
|
|
1007
|
-
/**
|
|
1008
|
-
* How many rows from the end of the list should trigger `onEndReached`.
|
|
1009
|
-
* A higher value triggers loading earlier (more buffer); lower means later.
|
|
1010
|
-
*
|
|
1011
|
-
* @default 5
|
|
1012
|
-
*
|
|
1013
|
-
* @example
|
|
1014
|
-
* onEndReachedThreshold={10}
|
|
1015
|
-
*/
|
|
196
|
+
/** How many rows from the end of the list should trigger onEndReached. */
|
|
1016
197
|
readonly onEndReachedThreshold?: number;
|
|
1017
|
-
/**
|
|
1018
|
-
* When `true` and `data` is empty, the table renders animated shimmer
|
|
1019
|
-
* skeleton rows instead of the empty state or real data.
|
|
1020
|
-
*
|
|
1021
|
-
* When `true` and `data` is non-empty (e.g. loading the next page in
|
|
1022
|
-
* infinite scroll), a small number of shimmer rows are appended at the
|
|
1023
|
-
* bottom below the real data.
|
|
1024
|
-
*
|
|
1025
|
-
* @default false
|
|
1026
|
-
*
|
|
1027
|
-
* @example
|
|
1028
|
-
* isLoading={isFetching}
|
|
1029
|
-
*/
|
|
198
|
+
/** When true and data is empty, shows shimmer skeleton rows. With data, appends shimmer rows at bottom. */
|
|
1030
199
|
readonly isLoading?: boolean;
|
|
1031
|
-
/**
|
|
1032
|
-
* Scroll indicator configuration (reserved for future use).
|
|
1033
|
-
* Currently unused but accepted to avoid prop-drilling issues in parent components.
|
|
1034
|
-
*/
|
|
200
|
+
/** Scroll indicator configuration (reserved for future use). */
|
|
1035
201
|
readonly scrollIndicators?: {
|
|
1036
202
|
vertical?: boolean;
|
|
1037
203
|
horizontal?: boolean;
|
|
1038
204
|
};
|
|
1039
|
-
/**
|
|
1040
|
-
* Called when the user changes the sort direction via the column header context menu.
|
|
1041
|
-
*
|
|
1042
|
-
* **Server-side sorting**: provide this callback. BoltTable will NOT sort the
|
|
1043
|
-
* data locally — it will pass the event to you and display the data as-is.
|
|
1044
|
-
*
|
|
1045
|
-
* **Client-side sorting** (default): omit this callback. BoltTable will sort
|
|
1046
|
-
* the data locally using `column.sorter` or a default comparator.
|
|
1047
|
-
*
|
|
1048
|
-
* @param columnKey - The `key` of the column being sorted
|
|
1049
|
-
* @param direction - The new sort direction, or `null` to clear the sort
|
|
1050
|
-
*
|
|
1051
|
-
* @example
|
|
1052
|
-
* // Server-side
|
|
1053
|
-
* onSortChange={(key, dir) => {
|
|
1054
|
-
* setSortKey(key);
|
|
1055
|
-
* setSortDir(dir);
|
|
1056
|
-
* refetch({ sortKey: key, sortDir: dir });
|
|
1057
|
-
* }}
|
|
1058
|
-
*/
|
|
205
|
+
/** Called when the user changes sort direction. Provide for server-side sorting. */
|
|
1059
206
|
readonly onSortChange?: (columnKey: string, direction: SortDirection) => void;
|
|
1060
|
-
/**
|
|
1061
|
-
* Called when the user applies or clears a column filter via the context menu.
|
|
1062
|
-
*
|
|
1063
|
-
* **Server-side filtering**: provide this callback. BoltTable will NOT filter
|
|
1064
|
-
* the data locally — it passes the full filters map to you.
|
|
1065
|
-
*
|
|
1066
|
-
* **Client-side filtering** (default): omit this callback. BoltTable will filter
|
|
1067
|
-
* locally using `column.filterFn` or a default case-insensitive substring match.
|
|
1068
|
-
*
|
|
1069
|
-
* @param filters - A map of `{ [columnKey]: filterValue }` for all active filters.
|
|
1070
|
-
* A column is removed from the map when its filter is cleared.
|
|
1071
|
-
*
|
|
1072
|
-
* @example
|
|
1073
|
-
* // Server-side
|
|
1074
|
-
* onFilterChange={(filters) => {
|
|
1075
|
-
* setActiveFilters(filters);
|
|
1076
|
-
* refetch({ filters });
|
|
1077
|
-
* }}
|
|
1078
|
-
*/
|
|
207
|
+
/** Called when the user applies or clears a column filter. Provide for server-side filtering. */
|
|
1079
208
|
readonly onFilterChange?: (filters: Record<string, string>) => void;
|
|
1080
|
-
/**
|
|
1081
|
-
* Custom items to append to the bottom of the right-click context menu
|
|
1082
|
-
* that appears on column headers. These appear after the built-in
|
|
1083
|
-
* sort / filter / pin / hide options.
|
|
1084
|
-
*
|
|
1085
|
-
* @example
|
|
1086
|
-
* columnContextMenuItems={[
|
|
1087
|
-
* {
|
|
1088
|
-
* key: 'copy-col',
|
|
1089
|
-
* label: 'Copy column data',
|
|
1090
|
-
* icon: <CopyIcon className="h-3 w-3" />,
|
|
1091
|
-
* onClick: (columnKey) => copyColumnToClipboard(columnKey),
|
|
1092
|
-
* },
|
|
1093
|
-
* ]}
|
|
1094
|
-
*/
|
|
209
|
+
/** Custom items to append to the column header right-click context menu. */
|
|
1095
210
|
readonly columnContextMenuItems?: ColumnContextMenuItem[];
|
|
1096
|
-
/**
|
|
1097
|
-
* Controls how the table's height is determined.
|
|
1098
|
-
*
|
|
1099
|
-
* - `true` (default): the table **auto-sizes** to its content, up to a maximum
|
|
1100
|
-
* of 10 rows. Shorter tables occupy less vertical space. The container uses
|
|
1101
|
-
* `maxHeight` so a smaller flex parent can still clip it.
|
|
1102
|
-
*
|
|
1103
|
-
* - `false`: the table fills its parent container (`height: 100%`). The parent
|
|
1104
|
-
* is fully responsible for providing a height. Use this when BoltTable is
|
|
1105
|
-
* placed inside a fixed-height container (e.g. a modal, a resizable panel).
|
|
1106
|
-
*
|
|
1107
|
-
* @default true
|
|
1108
|
-
*
|
|
1109
|
-
* @example
|
|
1110
|
-
* // Table inside a fixed-height panel
|
|
1111
|
-
* autoHeight={false}
|
|
1112
|
-
*/
|
|
211
|
+
/** Controls table height. True: auto-sizes to content (max 10 rows). False: fills parent container. */
|
|
1113
212
|
readonly autoHeight?: boolean;
|
|
1114
|
-
/**
|
|
1115
|
-
* When `true`, renders a full shimmer skeleton layout (including column headers)
|
|
1116
|
-
* before the table's column widths have been calculated from real data.
|
|
1117
|
-
*
|
|
1118
|
-
* Use this for the initial page load when you don't yet know the column widths
|
|
1119
|
-
* but want to show a realistic skeleton immediately.
|
|
1120
|
-
*
|
|
1121
|
-
* Differs from `isLoading`:
|
|
1122
|
-
* - `layoutLoading=true` → entire grid (headers + rows) is a skeleton
|
|
1123
|
-
* - `isLoading=true` → headers are real, only body rows are skeletons
|
|
1124
|
-
*
|
|
1125
|
-
* @default false
|
|
1126
|
-
*
|
|
1127
|
-
* @example
|
|
1128
|
-
* layoutLoading={!columnsResolved}
|
|
1129
|
-
*/
|
|
213
|
+
/** When true, renders a full shimmer skeleton layout before column widths are calculated. */
|
|
1130
214
|
readonly layoutLoading?: boolean;
|
|
1131
|
-
/**
|
|
1132
|
-
* Custom React node to render when the table has no data and is not loading.
|
|
1133
|
-
* Replaces the default "No data" message.
|
|
1134
|
-
* The empty state is centered in the visible viewport (sticky left + fixed width)
|
|
1135
|
-
* so it always appears centered even when the table is scrolled horizontally.
|
|
1136
|
-
*
|
|
1137
|
-
* @example
|
|
1138
|
-
* emptyRenderer={
|
|
1139
|
-
* <div className="flex flex-col items-center gap-2 py-12 text-muted-foreground">
|
|
1140
|
-
* <SearchX className="h-8 w-8" />
|
|
1141
|
-
* <p>No results found</p>
|
|
1142
|
-
* </div>
|
|
1143
|
-
* }
|
|
1144
|
-
*/
|
|
215
|
+
/** Custom React node to render when the table has no data and is not loading. */
|
|
1145
216
|
readonly emptyRenderer?: React$1.ReactNode;
|
|
1146
217
|
}
|
|
1147
|
-
/**
|
|
1148
|
-
* CSS class name overrides for specific regions of BoltTable.
|
|
1149
|
-
* All fields are optional — omit any you don't need to customize.
|
|
1150
|
-
*
|
|
1151
|
-
* @example
|
|
1152
|
-
* const classNames: ClassNamesTypes = {
|
|
1153
|
-
* header: 'text-xs font-semibold uppercase text-gray-500',
|
|
1154
|
-
* cell: 'text-sm text-gray-900',
|
|
1155
|
-
* pinnedHeader: 'bg-blue-50 border-r border-blue-200',
|
|
1156
|
-
* pinnedCell: 'bg-blue-50/50',
|
|
1157
|
-
* };
|
|
1158
|
-
*/
|
|
1159
218
|
interface ClassNamesTypes {
|
|
1160
|
-
/**
|
|
1161
|
-
* Applied to all non-pinned column header cells.
|
|
1162
|
-
* Pinned headers also receive `pinnedHeader` on top of this.
|
|
1163
|
-
*/
|
|
219
|
+
/** Applied to all non-pinned column header cells. */
|
|
1164
220
|
header?: string;
|
|
1165
|
-
/** Applied to all body cells (both pinned and non-pinned) */
|
|
221
|
+
/** Applied to all body cells (both pinned and non-pinned). */
|
|
1166
222
|
cell?: string;
|
|
1167
|
-
/** Applied to each row's wrapper element
|
|
223
|
+
/** Applied to each row's wrapper element. */
|
|
1168
224
|
row?: string;
|
|
1169
|
-
/**
|
|
1170
|
-
* Applied to the floating drag overlay header shown while dragging a column.
|
|
1171
|
-
* Use this to style the "ghost" column that follows the cursor.
|
|
1172
|
-
*/
|
|
225
|
+
/** Applied to the floating drag overlay header while dragging a column. */
|
|
1173
226
|
dragHeader?: string;
|
|
1174
|
-
/**
|
|
1175
|
-
* Applied additionally to pinned column header cells (on top of `header`).
|
|
1176
|
-
* Use this to add a border, background, or shadow to distinguish pinned headers.
|
|
1177
|
-
*/
|
|
227
|
+
/** Applied additionally to pinned column header cells. */
|
|
1178
228
|
pinnedHeader?: string;
|
|
1179
|
-
/**
|
|
1180
|
-
* Applied additionally to pinned column body cells.
|
|
1181
|
-
* Use this to add a border or separator between pinned and scrolling columns.
|
|
1182
|
-
*/
|
|
229
|
+
/** Applied additionally to pinned column body cells. */
|
|
1183
230
|
pinnedCell?: string;
|
|
1184
|
-
/**
|
|
1185
|
-
* Applied to the expanded row content panel (the div below an expanded row).
|
|
1186
|
-
* Does not affect the row itself, only the expanded panel.
|
|
1187
|
-
*/
|
|
231
|
+
/** Applied to the expanded row content panel. */
|
|
1188
232
|
expandedRow?: string;
|
|
1189
|
-
/**
|
|
1190
|
-
* Applied to each pinned row's wrapper div (the grid row containing all cells).
|
|
1191
|
-
* Use this to add a border, background, or separator for pinned rows.
|
|
1192
|
-
*/
|
|
233
|
+
/** Applied to each pinned row's wrapper div. */
|
|
1193
234
|
pinnedRow?: string;
|
|
1194
235
|
}
|
|
1195
|
-
/**
|
|
1196
|
-
* Inline style overrides for specific regions of BoltTable.
|
|
1197
|
-
* Applied after all default styles, so these take the highest specificity.
|
|
1198
|
-
*
|
|
1199
|
-
* All fields accept standard React `CSSProperties` except `pinnedBg`,
|
|
1200
|
-
* which accepts a CSS color string directly.
|
|
1201
|
-
*
|
|
1202
|
-
* @example
|
|
1203
|
-
* const styles: StylesTypes = {
|
|
1204
|
-
* header: { fontSize: 12, letterSpacing: '0.05em' },
|
|
1205
|
-
* rowHover: { backgroundColor: '#f8fafc' },
|
|
1206
|
-
* rowSelected: { backgroundColor: '#eff6ff' },
|
|
1207
|
-
* pinnedBg: 'rgba(239, 246, 255, 0.95)',
|
|
1208
|
-
* };
|
|
1209
|
-
*/
|
|
1210
236
|
interface StylesTypes {
|
|
1211
|
-
/** Inline styles for all non-pinned column header cells */
|
|
237
|
+
/** Inline styles for all non-pinned column header cells. */
|
|
1212
238
|
header?: CSSProperties;
|
|
1213
|
-
/** Inline styles for all body cells */
|
|
239
|
+
/** Inline styles for all body cells. */
|
|
1214
240
|
cell?: CSSProperties;
|
|
1215
|
-
/** Inline styles for each row wrapper
|
|
241
|
+
/** Inline styles for each row wrapper. */
|
|
1216
242
|
row?: CSSProperties;
|
|
1217
|
-
/**
|
|
1218
|
-
* Inline styles for the drag overlay header shown while dragging a column.
|
|
1219
|
-
* Applied on top of `header` styles.
|
|
1220
|
-
*/
|
|
243
|
+
/** Inline styles for the drag overlay header. */
|
|
1221
244
|
dragHeader?: CSSProperties;
|
|
1222
|
-
/**
|
|
1223
|
-
* Inline styles for pinned column header cells.
|
|
1224
|
-
* Applied on top of `header` styles.
|
|
1225
|
-
*/
|
|
245
|
+
/** Inline styles for pinned column header cells. */
|
|
1226
246
|
pinnedHeader?: CSSProperties;
|
|
1227
|
-
/**
|
|
1228
|
-
* Inline styles for pinned column body cells.
|
|
1229
|
-
* Applied on top of `cell` styles.
|
|
1230
|
-
*/
|
|
247
|
+
/** Inline styles for pinned column body cells. */
|
|
1231
248
|
pinnedCell?: CSSProperties;
|
|
1232
|
-
/** Inline styles for the expanded row content panel */
|
|
249
|
+
/** Inline styles for the expanded row content panel. */
|
|
1233
250
|
expandedRow?: CSSProperties;
|
|
1234
|
-
/** Inline styles for pinned row wrappers
|
|
251
|
+
/** Inline styles for pinned row wrappers. */
|
|
1235
252
|
pinnedRow?: CSSProperties;
|
|
1236
|
-
/**
|
|
1237
|
-
* CSS color string for the background of pinned row cells.
|
|
1238
|
-
* Should be opaque so that scrolling content behind pinned rows is hidden.
|
|
1239
|
-
* Falls back to `pinnedBg` if not set.
|
|
1240
|
-
*
|
|
1241
|
-
* @example
|
|
1242
|
-
* pinnedRowBg: 'rgba(255, 255, 255, 0.98)'
|
|
1243
|
-
*/
|
|
253
|
+
/** CSS color string for pinned row cell backgrounds. Falls back to pinnedBg. */
|
|
1244
254
|
pinnedRowBg?: string;
|
|
1245
|
-
/**
|
|
1246
|
-
* CSS color string applied as the background of hovered rows.
|
|
1247
|
-
* Defaults to `hsl(var(--muted) / 0.5)` if omitted.
|
|
1248
|
-
*
|
|
1249
|
-
* @example
|
|
1250
|
-
* rowHover: { backgroundColor: '#f8fafc' }
|
|
1251
|
-
*/
|
|
255
|
+
/** Styles applied to hovered rows. */
|
|
1252
256
|
rowHover?: CSSProperties;
|
|
1253
|
-
/**
|
|
1254
|
-
* CSS color string applied as the background tint of selected rows.
|
|
1255
|
-
* Defaults to `${accentColor}15` (accentColor at 8% opacity).
|
|
1256
|
-
*
|
|
1257
|
-
* @example
|
|
1258
|
-
* rowSelected: { backgroundColor: '#dbeafe' }
|
|
1259
|
-
*/
|
|
257
|
+
/** Styles applied to selected rows. */
|
|
1260
258
|
rowSelected?: CSSProperties;
|
|
1261
|
-
/**
|
|
1262
|
-
* CSS color string for the background of pinned column cells and headers.
|
|
1263
|
-
* Accepts any valid CSS color. Defaults to a semi-transparent white/dark
|
|
1264
|
-
* based on the current theme.
|
|
1265
|
-
*
|
|
1266
|
-
* @example
|
|
1267
|
-
* pinnedBg: 'rgba(239, 246, 255, 0.9)'
|
|
1268
|
-
*/
|
|
259
|
+
/** CSS color string for pinned column cells and headers background. */
|
|
1269
260
|
pinnedBg?: string;
|
|
1270
261
|
}
|
|
1271
|
-
/**
|
|
1272
|
-
* BoltTable — high-performance virtualized React table.
|
|
1273
|
-
*
|
|
1274
|
-
* Renders only the rows currently visible in the viewport using TanStack Virtual,
|
|
1275
|
-
* making it suitable for datasets of any size without performance degradation.
|
|
1276
|
-
*
|
|
1277
|
-
* @typeParam T - Your row data type. Must extend `DataRecord` (i.e. `Record<string, unknown>`).
|
|
1278
|
-
*
|
|
1279
|
-
* @example
|
|
1280
|
-
* // Minimal usage
|
|
1281
|
-
* <BoltTable
|
|
1282
|
-
* columns={[
|
|
1283
|
-
* { key: 'name', dataIndex: 'name', title: 'Name' },
|
|
1284
|
-
* { key: 'email', dataIndex: 'email', title: 'Email' },
|
|
1285
|
-
* ]}
|
|
1286
|
-
* data={users}
|
|
1287
|
-
* />
|
|
1288
|
-
*
|
|
1289
|
-
* @example
|
|
1290
|
-
* // Full-featured server-side example
|
|
1291
|
-
* <BoltTable<User>
|
|
1292
|
-
* columns={columns}
|
|
1293
|
-
* data={pageData}
|
|
1294
|
-
* rowKey="id"
|
|
1295
|
-
* isLoading={isFetching}
|
|
1296
|
-
* pagination={{ current: page, pageSize: 20, total: totalCount }}
|
|
1297
|
-
* onPaginationChange={(p, size) => fetchPage(p, size)}
|
|
1298
|
-
* onSortChange={(key, dir) => refetch({ sortKey: key, sortDir: dir })}
|
|
1299
|
-
* onFilterChange={(filters) => refetch({ filters })}
|
|
1300
|
-
* rowSelection={{ selectedRowKeys, onChange: (keys) => setSelectedRowKeys(keys) }}
|
|
1301
|
-
* expandable={{
|
|
1302
|
-
* rowExpandable: (r) => r.hasDetails,
|
|
1303
|
-
* expandedRowRender: (r) => <DetailPanel record={r} />,
|
|
1304
|
-
* }}
|
|
1305
|
-
* accentColor="#6366f1"
|
|
1306
|
-
* autoHeight={false}
|
|
1307
|
-
* />
|
|
1308
|
-
*/
|
|
1309
262
|
declare function BoltTable<T extends DataRecord = DataRecord>({ columns: initialColumns, data, rowHeight, expandedRowHeight, maxExpandedRowHeight, accentColor, className, classNames, styles, gripIcon, hideGripIcon, icons, pagination, onPaginationChange, onColumnResize, onColumnOrderChange, onColumnPin, onColumnHide, rowSelection, rowPinning, onRowPin, expandable, rowKey, onEndReached, onEndReachedThreshold, isLoading, onSortChange, onFilterChange, columnContextMenuItems, autoHeight, layoutLoading, emptyRenderer, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
|
|
1310
263
|
|
|
1311
|
-
/**
|
|
1312
|
-
* Props for the DraggableHeader component.
|
|
1313
|
-
* This is an internal component used by BoltTable — all props are passed
|
|
1314
|
-
* automatically and you do not need to use DraggableHeader directly.
|
|
1315
|
-
*/
|
|
1316
264
|
interface DraggableHeaderProps {
|
|
1317
|
-
/**
|
|
1318
|
-
* The column definition for this header cell.
|
|
1319
|
-
* Controls width, pinning, sort/filter capabilities, title, and styling.
|
|
1320
|
-
*/
|
|
265
|
+
/** Column definition for this header cell. */
|
|
1321
266
|
column: ColumnType<DataRecord>;
|
|
1322
|
-
/**
|
|
1323
|
-
* The visual position index of this column in the ordered column array.
|
|
1324
|
-
* Used to set the CSS `grid-column` placement so headers align with body cells.
|
|
1325
|
-
*/
|
|
267
|
+
/** Visual position index in the ordered column array. */
|
|
1326
268
|
visualIndex: number;
|
|
1327
|
-
/**
|
|
1328
|
-
* The accent color used for sort indicators, filter icons, the active sort
|
|
1329
|
-
* highlight in the context menu, and the resize handle hover line.
|
|
1330
|
-
*
|
|
1331
|
-
* @default '#1890ff'
|
|
1332
|
-
*/
|
|
269
|
+
/** Accent color for indicators and highlights. */
|
|
1333
270
|
accentColor?: string;
|
|
1334
|
-
/**
|
|
1335
|
-
* Called when the user presses down on the resize handle at the right edge
|
|
1336
|
-
* of this header cell. Starts the resize drag operation in BoltTable.
|
|
1337
|
-
*/
|
|
271
|
+
/** Called when the user starts resizing this column. */
|
|
1338
272
|
onResizeStart?: (columnKey: string, event: React$1.MouseEvent) => void;
|
|
1339
|
-
/**
|
|
1340
|
-
* Called when the user starts dragging this column header to reorder.
|
|
1341
|
-
* BoltTable handles the full drag lifecycle from this point.
|
|
1342
|
-
*/
|
|
273
|
+
/** Called when the user starts dragging this column header. */
|
|
1343
274
|
onColumnDragStart?: (columnKey: string, event: React$1.PointerEvent) => void;
|
|
1344
|
-
/**
|
|
1345
|
-
* Shared styling overrides for header cells.
|
|
1346
|
-
* `styles.header` applies to all headers; `styles.pinnedHeader` applies
|
|
1347
|
-
* additionally to pinned column headers.
|
|
1348
|
-
*/
|
|
275
|
+
/** Shared styling overrides for header cells. */
|
|
1349
276
|
styles?: StylesTypes;
|
|
1350
|
-
/**
|
|
1351
|
-
* Shared CSS class name overrides for header cells.
|
|
1352
|
-
* `classNames.header` applies to all headers; `classNames.pinnedHeader`
|
|
1353
|
-
* applies additionally to pinned column headers.
|
|
1354
|
-
*/
|
|
277
|
+
/** Shared CSS class name overrides for header cells. */
|
|
1355
278
|
classNames?: ClassNamesTypes;
|
|
1356
|
-
/**
|
|
1357
|
-
* When `true`, the drag grip icon on the left of the header label is hidden.
|
|
1358
|
-
* The column can still be dragged; only the visual indicator is removed.
|
|
1359
|
-
*
|
|
1360
|
-
* @default false
|
|
1361
|
-
*/
|
|
279
|
+
/** When true, the drag grip icon is hidden. */
|
|
1362
280
|
hideGripIcon?: boolean;
|
|
1363
|
-
/**
|
|
1364
|
-
* A custom React node to use as the drag grip icon.
|
|
1365
|
-
* When omitted, the default `GripVertical` icon is used.
|
|
1366
|
-
*
|
|
1367
|
-
* @example
|
|
1368
|
-
* gripIcon={<MyCustomDragIcon />}
|
|
1369
|
-
*/
|
|
281
|
+
/** Custom React node to use as the drag grip icon. */
|
|
1370
282
|
gripIcon?: React$1.ReactNode;
|
|
1371
|
-
/**
|
|
1372
|
-
* The pixel offset from the pinned edge (left or right) for this column.
|
|
1373
|
-
* Used to set `left` or `right` CSS on sticky-positioned pinned headers.
|
|
1374
|
-
* Calculated by BoltTable based on the total width of all preceding pinned columns.
|
|
1375
|
-
*/
|
|
283
|
+
/** Pixel offset from the pinned edge for sticky positioning. */
|
|
1376
284
|
stickyOffset?: number;
|
|
1377
|
-
/**
|
|
1378
|
-
* Called when the user pins or unpins this column via the context menu
|
|
1379
|
-
* or the unpin button shown on pinned headers.
|
|
1380
|
-
*
|
|
1381
|
-
* @param columnKey - The key of the column being toggled
|
|
1382
|
-
* @param pinned - The new pinned state: `'left'`, `'right'`, or `false` (unpinned)
|
|
1383
|
-
*/
|
|
285
|
+
/** Called when the user pins or unpins this column. */
|
|
1384
286
|
onTogglePin?: (columnKey: string, pinned: 'left' | 'right' | false) => void;
|
|
1385
|
-
/**
|
|
1386
|
-
* Called when the user clicks "Hide Column" in the context menu.
|
|
1387
|
-
* The column's `hidden` property will be toggled in BoltTable's state.
|
|
1388
|
-
* Pinned columns cannot be hidden and this will never be called for them.
|
|
1389
|
-
*
|
|
1390
|
-
* @param columnKey - The key of the column being hidden
|
|
1391
|
-
*/
|
|
287
|
+
/** Called when the user hides this column via the context menu. */
|
|
1392
288
|
onToggleHide?: (columnKey: string) => void;
|
|
1393
|
-
/**
|
|
1394
|
-
* Whether this is the rightmost visible column.
|
|
1395
|
-
* When `true`, the header cell uses `width: 100%` instead of a fixed pixel
|
|
1396
|
-
* width so it stretches to fill any remaining horizontal space.
|
|
1397
|
-
*
|
|
1398
|
-
* @default false
|
|
1399
|
-
*/
|
|
289
|
+
/** Whether this is the rightmost visible column. */
|
|
1400
290
|
isLastColumn?: boolean;
|
|
1401
|
-
/**
|
|
1402
|
-
* The current sort direction applied to this column.
|
|
1403
|
-
* - `'asc'` — column is sorted ascending (ArrowUpAZ icon shown)
|
|
1404
|
-
* - `'desc'` — column is sorted descending (ArrowDownAZ icon shown)
|
|
1405
|
-
* - `null` — column is not currently sorted (no icon shown)
|
|
1406
|
-
*
|
|
1407
|
-
* Passed from BoltTable's sort state; only set for the currently sorted column.
|
|
1408
|
-
*/
|
|
291
|
+
/** Current sort direction applied to this column. */
|
|
1409
292
|
sortDirection?: SortDirection;
|
|
1410
|
-
/**
|
|
1411
|
-
* Called when the user clicks a sort option in the context menu.
|
|
1412
|
-
*
|
|
1413
|
-
* @param columnKey - The key of the column to sort
|
|
1414
|
-
* @param direction - The requested sort direction (`'asc'`, `'desc'`, or `undefined` to toggle)
|
|
1415
|
-
*/
|
|
293
|
+
/** Called when the user clicks a sort option in the context menu. */
|
|
1416
294
|
onSort?: (columnKey: string, direction?: SortDirection) => void;
|
|
1417
|
-
/**
|
|
1418
|
-
* The current filter value active on this column.
|
|
1419
|
-
* When non-empty, a small Filter icon is shown in the header label.
|
|
1420
|
-
*
|
|
1421
|
-
* @default ''
|
|
1422
|
-
*/
|
|
295
|
+
/** Current filter value active on this column. */
|
|
1423
296
|
filterValue?: string;
|
|
1424
|
-
/**
|
|
1425
|
-
* Called when the user submits a new filter value via the context menu input.
|
|
1426
|
-
*
|
|
1427
|
-
* @param columnKey - The key of the column being filtered
|
|
1428
|
-
* @param value - The filter string entered by the user
|
|
1429
|
-
*/
|
|
297
|
+
/** Called when the user submits a filter value via the context menu. */
|
|
1430
298
|
onFilter?: (columnKey: string, value: string) => void;
|
|
1431
|
-
/**
|
|
1432
|
-
* Called when the user clicks "Clear Filter" in the context menu.
|
|
1433
|
-
*
|
|
1434
|
-
* @param columnKey - The key of the column whose filter should be cleared
|
|
1435
|
-
*/
|
|
299
|
+
/** Called when the user clears the filter via the context menu. */
|
|
1436
300
|
onClearFilter?: (columnKey: string) => void;
|
|
1437
|
-
/**
|
|
1438
|
-
* Additional custom items to append at the bottom of the right-click context menu.
|
|
1439
|
-
* These appear after the built-in sort/filter/pin/hide options.
|
|
1440
|
-
*
|
|
1441
|
-
* @example
|
|
1442
|
-
* customContextMenuItems={[
|
|
1443
|
-
* {
|
|
1444
|
-
* key: 'copy',
|
|
1445
|
-
* label: 'Copy column data',
|
|
1446
|
-
* icon: <CopyIcon />,
|
|
1447
|
-
* onClick: (columnKey) => copyColumn(columnKey),
|
|
1448
|
-
* }
|
|
1449
|
-
* ]}
|
|
1450
|
-
*/
|
|
301
|
+
/** Additional custom items for the right-click context menu. */
|
|
1451
302
|
customContextMenuItems?: ColumnContextMenuItem[];
|
|
1452
|
-
/**
|
|
1453
|
-
* Custom icon overrides from BoltTable's `icons` prop.
|
|
1454
|
-
* Passed through automatically — do not set manually.
|
|
1455
|
-
*/
|
|
303
|
+
/** Custom icon overrides from BoltTable's icons prop. */
|
|
1456
304
|
icons?: BoltTableIcons;
|
|
1457
305
|
}
|
|
1458
|
-
/**
|
|
1459
|
-
* DraggableHeader — a single column header cell for BoltTable.
|
|
1460
|
-
*
|
|
1461
|
-
* Features:
|
|
1462
|
-
* - **Drag to reorder**: grip icon on the left; dragging is disabled for pinned columns.
|
|
1463
|
-
* - **Resize handle**: a 12px wide invisible hit area on the right edge.
|
|
1464
|
-
* - **Sort indicators**: ArrowUpAZ / ArrowDownAZ shown when sorted.
|
|
1465
|
-
* - **Filter indicator**: small Filter icon when a filter is active.
|
|
1466
|
-
* - **Right-click context menu**: sort asc/desc, filter input, pin left/right, hide column,
|
|
1467
|
-
* plus any custom items passed via `customContextMenuItems`.
|
|
1468
|
-
* - **Unpin button**: replaces the resize handle on pinned columns.
|
|
1469
|
-
*
|
|
1470
|
-
* Wrapped in `React.memo` with a custom equality check — only re-renders when
|
|
1471
|
-
* its own column's data changes, preventing cascade re-renders across all headers
|
|
1472
|
-
* when a single column's sort/filter/width changes.
|
|
1473
|
-
*
|
|
1474
|
-
* @internal This is an internal BoltTable component. Use BoltTable directly.
|
|
1475
|
-
*/
|
|
1476
306
|
declare const DraggableHeader: React$1.MemoExoticComponent<({ column, visualIndex, accentColor, onResizeStart, styles, classNames, hideGripIcon, gripIcon, stickyOffset, onTogglePin, onToggleHide, isLastColumn, sortDirection, onSort, filterValue, onFilter, onClearFilter, customContextMenuItems, icons, onColumnDragStart, }: DraggableHeaderProps) => react_jsx_runtime.JSX.Element>;
|
|
1477
307
|
|
|
1478
|
-
/**
|
|
1479
|
-
* The imperative handle exposed by ResizeOverlay via `ref`.
|
|
1480
|
-
* All three methods must be called in sequence during a resize operation:
|
|
1481
|
-
* `show()` → `move()` (many times) → `hide()`.
|
|
1482
|
-
*/
|
|
1483
308
|
interface ResizeOverlayHandle {
|
|
1484
|
-
/**
|
|
1485
|
-
* Makes the overlay visible and positions it at the start of a resize.
|
|
1486
|
-
* Call this on `mousedown` of the resize handle.
|
|
1487
|
-
*
|
|
1488
|
-
* @param viewportX - The initial mouse X position in viewport coordinates (e.clientX)
|
|
1489
|
-
* @param columnName - The name/title of the column being resized (shown in the label)
|
|
1490
|
-
* @param areaRect - The bounding rect of the scroll container (from getBoundingClientRect)
|
|
1491
|
-
* @param headerLeftLocal - The left edge of the column header in scroll-content coordinates
|
|
1492
|
-
* @param minSize - The minimum allowed column width in pixels (used to clamp the line)
|
|
1493
|
-
* @param scrollTop - Current vertical scroll offset of the container (scrollTop)
|
|
1494
|
-
* @param scrollLeft - Current horizontal scroll offset of the container (scrollLeft)
|
|
1495
|
-
* @param initialLineX - The initial X position of the vertical line in content coordinates
|
|
1496
|
-
*/
|
|
1497
309
|
show: (viewportX: number, columnName: string, areaRect: DOMRect, headerLeftLocal: number, minSize: number, scrollTop: number, scrollLeft: number, initialLineX: number) => void;
|
|
1498
|
-
/**
|
|
1499
|
-
* Moves the vertical line to follow the mouse cursor during a resize drag.
|
|
1500
|
-
* Call this on every `mousemove` event while dragging.
|
|
1501
|
-
* The line is clamped to never go below the column's minimum width.
|
|
1502
|
-
*
|
|
1503
|
-
* @param viewportX - The current mouse X position in viewport coordinates (e.clientX)
|
|
1504
|
-
*/
|
|
1505
310
|
move: (viewportX: number) => void;
|
|
1506
|
-
/**
|
|
1507
|
-
* Hides the overlay completely.
|
|
1508
|
-
* Call this on `mouseup` when the resize operation ends.
|
|
1509
|
-
*/
|
|
1510
311
|
hide: () => void;
|
|
1511
312
|
}
|
|
1512
|
-
/**
|
|
1513
|
-
* Props for the ResizeOverlay component.
|
|
1514
|
-
*/
|
|
1515
313
|
interface ResizeOverlayProps {
|
|
1516
|
-
/**
|
|
1517
|
-
* The accent color used for the resize line and label background.
|
|
1518
|
-
* Should match the `accentColor` prop passed to BoltTable for visual consistency.
|
|
1519
|
-
*
|
|
1520
|
-
* @default '#1778ff'
|
|
1521
|
-
*
|
|
1522
|
-
* @example
|
|
1523
|
-
* accentColor="#6366f1"
|
|
1524
|
-
*/
|
|
314
|
+
/** @default '#1778ff' */
|
|
1525
315
|
accentColor?: string;
|
|
1526
316
|
}
|
|
1527
|
-
/**
|
|
1528
|
-
* ResizeOverlay — visual feedback component for column resize operations.
|
|
1529
|
-
*
|
|
1530
|
-
* Renders a colored vertical line and a floating column-name label that track
|
|
1531
|
-
* the user's cursor during a column resize drag. All DOM updates are direct
|
|
1532
|
-
* (bypassing React state) for zero-lag, 60fps movement.
|
|
1533
|
-
*
|
|
1534
|
-
* This component is an implementation detail of BoltTable and is not intended
|
|
1535
|
-
* to be used standalone. It is mounted once inside the scroll container and
|
|
1536
|
-
* controlled imperatively via the `ResizeOverlayHandle` ref.
|
|
1537
|
-
*
|
|
1538
|
-
* @example
|
|
1539
|
-
* // Inside BoltTable:
|
|
1540
|
-
* const resizeOverlayRef = useRef<ResizeOverlayHandle>(null);
|
|
1541
|
-
*
|
|
1542
|
-
* // On resize start:
|
|
1543
|
-
* resizeOverlayRef.current?.show(e.clientX, 'Name', areaRect, headerLeft, 40, scrollTop, scrollLeft, initX);
|
|
1544
|
-
*
|
|
1545
|
-
* // On mouse move:
|
|
1546
|
-
* resizeOverlayRef.current?.move(e.clientX);
|
|
1547
|
-
*
|
|
1548
|
-
* // On mouse up:
|
|
1549
|
-
* resizeOverlayRef.current?.hide();
|
|
1550
|
-
*
|
|
1551
|
-
* // In JSX:
|
|
1552
|
-
* <ResizeOverlay ref={resizeOverlayRef} accentColor={accentColor} />
|
|
1553
|
-
*/
|
|
1554
317
|
declare const ResizeOverlay: React$1.ForwardRefExoticComponent<ResizeOverlayProps & React$1.RefAttributes<ResizeOverlayHandle>>;
|
|
1555
318
|
|
|
1556
|
-
/**
|
|
1557
|
-
* Props for the TableBody component.
|
|
1558
|
-
* All props are passed automatically by BoltTable — this is an internal component.
|
|
1559
|
-
*/
|
|
1560
319
|
interface TableBodyProps {
|
|
1561
|
-
/**
|
|
320
|
+
/** Current page's row data */
|
|
1562
321
|
data: DataRecord[];
|
|
1563
|
-
/**
|
|
322
|
+
/** Ordered visible columns (left pinned → unpinned → right pinned) */
|
|
1564
323
|
orderedColumns: ColumnType<DataRecord>[];
|
|
1565
|
-
/**
|
|
1566
|
-
* The TanStack Virtual row virtualizer instance.
|
|
1567
|
-
* Provides `getVirtualItems()` and `getTotalSize()` for rendering.
|
|
1568
|
-
*/
|
|
324
|
+
/** TanStack Virtual row virtualizer instance */
|
|
1569
325
|
rowVirtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
1570
|
-
/**
|
|
1571
|
-
* Map of column key → sticky offset in pixels.
|
|
1572
|
-
* For left-pinned columns: distance from the left edge.
|
|
1573
|
-
* For right-pinned columns: distance from the right edge.
|
|
1574
|
-
*/
|
|
326
|
+
/** Map of column key → sticky offset in pixels */
|
|
1575
327
|
columnOffsets: Map<string, number>;
|
|
1576
|
-
/** Shared style overrides
|
|
328
|
+
/** Shared style overrides from BoltTable */
|
|
1577
329
|
styles?: StylesTypes;
|
|
1578
|
-
/** Shared class name overrides
|
|
330
|
+
/** Shared class name overrides from BoltTable */
|
|
1579
331
|
classNames?: ClassNamesTypes;
|
|
1580
|
-
/**
|
|
1581
|
-
* Row selection configuration.
|
|
1582
|
-
* When provided, the `__select__` column renders checkboxes or radio buttons.
|
|
1583
|
-
* `undefined` during shimmer loading to prevent selection UI on skeleton rows.
|
|
1584
|
-
*/
|
|
332
|
+
/** Row selection configuration */
|
|
1585
333
|
rowSelection?: RowSelectionConfig<DataRecord>;
|
|
1586
|
-
/**
|
|
1587
|
-
* Pre-normalized selected row keys (all converted to strings).
|
|
1588
|
-
* Normalized in BoltTable so Cell never has to deal with number/string mismatches.
|
|
1589
|
-
*
|
|
1590
|
-
* @default []
|
|
1591
|
-
*/
|
|
334
|
+
/** Pre-normalized selected row keys (all strings) */
|
|
1592
335
|
normalizedSelectedKeys?: string[];
|
|
1593
|
-
/**
|
|
1594
|
-
* Returns the string key for a given row record and index.
|
|
1595
|
-
* Derived from BoltTable's `rowKey` prop. Always returns a string.
|
|
1596
|
-
*
|
|
1597
|
-
* @param record - The row data object
|
|
1598
|
-
* @param index - The row's position in the data array
|
|
1599
|
-
*/
|
|
336
|
+
/** Returns the string key for a given row record and index */
|
|
1600
337
|
getRowKey?: (record: DataRecord, index: number) => string;
|
|
1601
|
-
/**
|
|
1602
|
-
* Expandable row configuration.
|
|
1603
|
-
* When provided, rows in `resolvedExpandedKeys` render an expanded content panel.
|
|
1604
|
-
* `undefined` during shimmer loading to prevent expand UI on skeleton rows.
|
|
1605
|
-
*/
|
|
338
|
+
/** Expandable row configuration */
|
|
1606
339
|
expandable?: ExpandableConfig<DataRecord>;
|
|
1607
|
-
/**
|
|
1608
|
-
* The set of currently expanded row keys.
|
|
1609
|
-
* Used to determine whether to render the expanded content panel for each row.
|
|
1610
|
-
*/
|
|
340
|
+
/** Set of currently expanded row keys */
|
|
1611
341
|
resolvedExpandedKeys?: Set<React$1.Key>;
|
|
1612
|
-
/**
|
|
1613
|
-
* Height of each regular (non-expanded) row in pixels.
|
|
1614
|
-
* Must match the `rowHeight` prop passed to BoltTable.
|
|
1615
|
-
*
|
|
1616
|
-
* @default 40
|
|
1617
|
-
*/
|
|
342
|
+
/** Height of each regular row in pixels */
|
|
1618
343
|
rowHeight?: number;
|
|
1619
|
-
/**
|
|
1620
|
-
* Total pixel width of all columns combined.
|
|
1621
|
-
* Used to set `minWidth` on the column spacer so the grid never collapses
|
|
1622
|
-
* below the sum of all column widths.
|
|
1623
|
-
*/
|
|
344
|
+
/** Total pixel width of all columns combined */
|
|
1624
345
|
totalTableWidth?: number;
|
|
1625
|
-
/**
|
|
1626
|
-
* The visible width of the scroll container in pixels.
|
|
1627
|
-
* Used to set the width of expanded row panels and the empty state div
|
|
1628
|
-
* so they fill exactly the visible viewport rather than the full content width.
|
|
1629
|
-
*/
|
|
346
|
+
/** Visible width of the scroll container in pixels */
|
|
1630
347
|
scrollAreaWidth?: number;
|
|
1631
|
-
/**
|
|
1632
|
-
* The accent color used for the expand toggle button chevron icon.
|
|
1633
|
-
* Should match the `accentColor` prop on BoltTable.
|
|
1634
|
-
*
|
|
1635
|
-
* @default '#1890ff'
|
|
1636
|
-
*/
|
|
348
|
+
/** Accent color for the expand toggle button */
|
|
1637
349
|
accentColor?: string;
|
|
1638
|
-
/**
|
|
1639
|
-
* Ref to the scroll container element.
|
|
1640
|
-
* Reserved for potential future use (e.g. programmatic scrolling from within TableBody).
|
|
1641
|
-
*/
|
|
350
|
+
/** Ref to the scroll container element */
|
|
1642
351
|
scrollContainerRef?: React$1.RefObject<HTMLDivElement | null>;
|
|
1643
|
-
/**
|
|
1644
|
-
* When `true`, all cells render as animated shimmer skeletons instead of
|
|
1645
|
-
* real data. Used during initial loading when `data` is empty.
|
|
1646
|
-
*
|
|
1647
|
-
* @default false
|
|
1648
|
-
*/
|
|
352
|
+
/** When true, cells render as shimmer skeletons */
|
|
1649
353
|
isLoading?: boolean;
|
|
1650
|
-
/**
|
|
1651
|
-
* Called by `MeasuredExpandedRow` when an expanded row's content height changes.
|
|
1652
|
-
* BoltTable uses this to update the virtualizer's size estimate for that row,
|
|
1653
|
-
* triggering a re-layout so the expanded content is never clipped.
|
|
1654
|
-
*
|
|
1655
|
-
* @param rowKey - The string key of the row whose expanded height changed
|
|
1656
|
-
* @param contentHeight - The new content height in pixels (border-box)
|
|
1657
|
-
*/
|
|
354
|
+
/** Called when an expanded row's content height changes */
|
|
1658
355
|
onExpandedRowResize?: (rowKey: string, contentHeight: number) => void;
|
|
1659
|
-
/**
|
|
1660
|
-
* Optional maximum height in pixels for expanded row panels.
|
|
1661
|
-
* When set, the panel becomes scrollable if its content exceeds this height.
|
|
1662
|
-
* When omitted, the panel grows to its full content height.
|
|
1663
|
-
*
|
|
1664
|
-
* @example
|
|
1665
|
-
* maxExpandedRowHeight={300}
|
|
1666
|
-
*/
|
|
356
|
+
/** Max height for expanded row panels (scrollable if exceeded) */
|
|
1667
357
|
maxExpandedRowHeight?: number;
|
|
1668
|
-
/**
|
|
1669
|
-
* Rows pinned to the top of the table body.
|
|
1670
|
-
* Rendered as non-virtualized sticky rows below the column headers.
|
|
1671
|
-
*/
|
|
358
|
+
/** Rows pinned to the top of the table body */
|
|
1672
359
|
pinnedTopData?: DataRecord[];
|
|
1673
|
-
/**
|
|
1674
|
-
* Rows pinned to the bottom of the table body.
|
|
1675
|
-
* Rendered as non-virtualized sticky rows at the bottom of the visible area.
|
|
1676
|
-
*/
|
|
360
|
+
/** Rows pinned to the bottom of the table body */
|
|
1677
361
|
pinnedBottomData?: DataRecord[];
|
|
1678
|
-
/**
|
|
1679
|
-
* The CSS `gridTemplateColumns` string matching the parent grid.
|
|
1680
|
-
* Needed for pinned row sub-grids to align with the main column layout.
|
|
1681
|
-
*/
|
|
362
|
+
/** CSS gridTemplateColumns string matching the parent grid */
|
|
1682
363
|
gridTemplateColumns?: string;
|
|
1683
|
-
/**
|
|
1684
|
-
* Height of the column header row in pixels.
|
|
1685
|
-
* Used to position the sticky top pinned rows below the headers.
|
|
1686
|
-
*
|
|
1687
|
-
* @default 36
|
|
1688
|
-
*/
|
|
364
|
+
/** Height of the column header row in pixels */
|
|
1689
365
|
headerHeight?: number;
|
|
1690
366
|
}
|
|
1691
|
-
/**
|
|
1692
|
-
* TableBody — the virtualized body renderer for BoltTable.
|
|
1693
|
-
*
|
|
1694
|
-
* Renders the visible rows using TanStack Virtual's window virtualization.
|
|
1695
|
-
* Only the rows currently in (or near) the viewport are in the DOM.
|
|
1696
|
-
*
|
|
1697
|
-
* Layout strategy:
|
|
1698
|
-
* - One `<div>` per column, spanning the full virtual height (`totalSize`px).
|
|
1699
|
-
* - Inside each column div, only the visible rows are rendered as
|
|
1700
|
-
* `position: absolute` cells stacked at their `virtualRow.start` offset.
|
|
1701
|
-
* - Pinned columns use `position: sticky` on the column div itself, backed
|
|
1702
|
-
* by a semi-transparent background to visually separate from scrolling content.
|
|
1703
|
-
* - Expanded rows are rendered in a separate full-width overlay div that sits
|
|
1704
|
-
* on top of all column divs (z-index: 15) and uses `position: sticky; left: 0`
|
|
1705
|
-
* to stay viewport-locked during horizontal scroll.
|
|
1706
|
-
*
|
|
1707
|
-
* @internal This is an internal BoltTable component. Use BoltTable directly.
|
|
1708
|
-
*/
|
|
1709
367
|
declare const TableBody: React$1.FC<TableBodyProps>;
|
|
1710
368
|
|
|
1711
369
|
export { BoltTable, type BoltTableIcons, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, TableBody };
|