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