bolt-table 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # bolt-table
2
2
 
3
- A high-performance, fully-featured React table component built on [TanStack Virtual](https://tanstack.com/virtual) and [@dnd-kit](https://dndkit.com). Only the rows visible in the viewport are ever in the DOM — making it fast for datasets of any size.
3
+ A high-performance, zero-dependency\* React table component built on [TanStack Virtual](https://tanstack.com/virtual). Only the rows visible in the viewport are ever in the DOM — making it fast for datasets of any size.
4
+
5
+ \*Only peer dependency is `@tanstack/react-virtual` (+ React). No Tailwind, no CSS framework, no icon library required.
4
6
 
5
7
  [![npm version](https://img.shields.io/npm/v/bolt-table)](https://www.npmjs.com/package/bolt-table)
6
8
  [![license](https://img.shields.io/npm/l/bolt-table)](./LICENSE)
@@ -10,7 +12,7 @@ A high-performance, fully-featured React table component built on [TanStack Virt
10
12
  ## Features
11
13
 
12
14
  - **Row virtualization** — only visible rows are rendered, powered by TanStack Virtual
13
- - **Drag to reorder columns** — grab any header and drag it to a new position
15
+ - **Drag to reorder columns** — custom zero-dependency drag-and-drop (no @dnd-kit needed)
14
16
  - **Column pinning** — pin columns to the left or right edge via right-click
15
17
  - **Column resizing** — drag the right edge of any header to resize
16
18
  - **Column hiding** — hide/show columns via the right-click context menu
@@ -24,23 +26,18 @@ A high-performance, fully-featured React table component built on [TanStack Virt
24
26
  - **Empty state** — custom renderer or default "No data" message
25
27
  - **Auto height** — table shrinks/grows to fit rows, capped at 10 rows by default
26
28
  - **Right-click context menu** — sort, filter, pin, hide, plus custom items
27
- - **Dark mode** — works out of the box with CSS variables
29
+ - **Theme-agnostic** — works in light and dark mode out of the box, no CSS variables needed
30
+ - **Custom icons** — override any built-in icon via the `icons` prop
28
31
 
29
32
  ---
30
33
 
31
34
  ## Installation
32
35
 
33
36
  ```bash
34
- npm install bolt-table
37
+ npm install bolt-table @tanstack/react-virtual
35
38
  ```
36
39
 
37
- ### Peer dependencies
38
-
39
- These must be installed separately in your project:
40
-
41
- ```bash
42
- npm install @tanstack/react-virtual @dnd-kit/core @dnd-kit/sortable lucide-react
43
- ```
40
+ That's it. No other peer dependencies.
44
41
 
45
42
  ---
46
43
 
@@ -83,7 +80,7 @@ export default function App() {
83
80
 
84
81
  ## Next.js (App Router)
85
82
 
86
- BoltTable uses browser APIs and must be wrapped in a client boundary. Remove the `'use client'` directive from the component files and wrap usage instead:
83
+ BoltTable uses browser APIs and must be wrapped in a client boundary:
87
84
 
88
85
  ```tsx
89
86
  'use client';
@@ -94,9 +91,27 @@ import { BoltTable } from 'bolt-table';
94
91
 
95
92
  ## Styling
96
93
 
97
- BoltTable uses [Tailwind CSS](https://tailwindcss.com) utility classes and [Shadcn/ui](https://ui.shadcn.com) CSS variables (`--muted`, `--background`, `--border`, etc.).
94
+ BoltTable uses **inline CSS styles** for all defaults — no Tailwind, no CSS variables, no external stylesheets required. It works out of the box in any React project, light or dark mode.
95
+
96
+ You can customize everything via the `styles` and `classNames` props. If your project uses Tailwind, you can pass Tailwind classes through `classNames` and they'll be applied on top of the inline defaults.
97
+
98
+ ### Custom icons
99
+
100
+ All built-in icons are inline SVGs. Override any icon via the `icons` prop:
101
+
102
+ ```tsx
103
+ import type { BoltTableIcons } from 'bolt-table';
104
+
105
+ <BoltTable
106
+ icons={{
107
+ gripVertical: <MyGripIcon size={12} />,
108
+ sortAsc: <MySortUpIcon size={12} />,
109
+ chevronsLeft: <MyFirstPageIcon size={12} />,
110
+ }}
111
+ />
112
+ ```
98
113
 
99
- Make sure your project has Tailwind configured and the Shadcn CSS variables defined in your global stylesheet. If you use a different design system, you can override styles via the `styles` and `classNames` props.
114
+ Available icon keys: `gripVertical`, `sortAsc`, `sortDesc`, `filter`, `filterClear`, `pin`, `pinOff`, `eyeOff`, `chevronDown`, `chevronLeft`, `chevronRight`, `chevronsLeft`, `chevronsRight`.
100
115
 
101
116
  ---
102
117
 
@@ -116,7 +131,8 @@ Make sure your project has Tailwind configured and the Shadcn CSS variables defi
116
131
  | `className` | `string` | `''` | Class name for the outer wrapper |
117
132
  | `classNames` | `ClassNamesTypes` | `{}` | Granular class overrides per table region |
118
133
  | `styles` | `StylesTypes` | `{}` | Inline style overrides per table region |
119
- | `gripIcon` | `ReactNode` | — | Custom drag grip icon (defaults to `GripVertical`) |
134
+ | `icons` | `BoltTableIcons` | — | Custom icon overrides for built-in SVG icons |
135
+ | `gripIcon` | `ReactNode` | — | Custom drag grip icon (deprecated, use `icons.gripVertical`) |
120
136
  | `hideGripIcon` | `boolean` | `false` | Hide the drag grip icon from all headers |
121
137
  | `pagination` | `PaginationType \| false` | — | Pagination config, or `false` to disable |
122
138
  | `onPaginationChange` | `(page, pageSize) => void` | — | Called when page or page size changes |
@@ -172,7 +188,6 @@ const columns: ColumnType<User>[] = [
172
188
  dataIndex: 'name',
173
189
  title: 'Name',
174
190
  sortable: true,
175
- // Optional custom comparator:
176
191
  sorter: (a, b) => a.name.localeCompare(b.name),
177
192
  },
178
193
  {
@@ -180,7 +195,6 @@ const columns: ColumnType<User>[] = [
180
195
  dataIndex: 'age',
181
196
  title: 'Age',
182
197
  sortable: true,
183
- // Default numeric comparator used when sorter is omitted
184
198
  },
185
199
  ];
186
200
 
@@ -217,7 +231,6 @@ const columns: ColumnType<User>[] = [
217
231
  dataIndex: 'status',
218
232
  title: 'Status',
219
233
  filterable: true,
220
- // Exact match instead of default substring:
221
234
  filterFn: (value, record) => record.status === value,
222
235
  },
223
236
  ];
@@ -245,11 +258,9 @@ const columns: ColumnType<User>[] = [
245
258
  ```tsx
246
259
  <BoltTable
247
260
  columns={columns}
248
- data={allUsers} // all 500 rows
261
+ data={allUsers}
249
262
  pagination={{ pageSize: 20 }}
250
- onPaginationChange={(page, size) => {
251
- setPage(page);
252
- }}
263
+ onPaginationChange={(page, size) => setPage(page)}
253
264
  />
254
265
  ```
255
266
 
@@ -258,7 +269,7 @@ const columns: ColumnType<User>[] = [
258
269
  ```tsx
259
270
  <BoltTable
260
271
  columns={columns}
261
- data={currentPageData} // only 20 rows
272
+ data={currentPageData}
262
273
  pagination={{
263
274
  current: page,
264
275
  pageSize: 20,
@@ -287,10 +298,9 @@ const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
287
298
  data={data}
288
299
  rowKey="id"
289
300
  rowSelection={{
290
- type: 'checkbox', // or 'radio'
301
+ type: 'checkbox',
291
302
  selectedRowKeys,
292
303
  onChange: (keys, rows) => setSelectedRowKeys(keys),
293
- // Disable selection for specific rows:
294
304
  getCheckboxProps: (record) => ({
295
305
  disabled: record.status === 'locked',
296
306
  }),
@@ -315,12 +325,9 @@ const [selectedRowKeys, setSelectedRowKeys] = useState<React.Key[]>([]);
315
325
  <pre>{JSON.stringify(record.details, null, 2)}</pre>
316
326
  </div>
317
327
  ),
318
- // Optional: control expanded state yourself
319
- // expandedRowKeys={expandedKeys}
320
- // onExpandedRowsChange={(keys) => setExpandedKeys(keys)}
321
328
  }}
322
- expandedRowHeight={150} // initial estimate
323
- maxExpandedRowHeight={400} // makes panel scrollable if taller
329
+ expandedRowHeight={150}
330
+ maxExpandedRowHeight={400}
324
331
  />
325
332
  ```
326
333
 
@@ -353,8 +360,6 @@ const loadMore = async () => {
353
360
 
354
361
  ### Column pinning
355
362
 
356
- Pinning via column definition:
357
-
358
363
  ```tsx
359
364
  const columns: ColumnType<User>[] = [
360
365
  { key: 'name', dataIndex: 'name', title: 'Name', pinned: 'left', width: 200 },
@@ -367,58 +372,6 @@ Users can also pin/unpin columns at runtime via the right-click context menu.
367
372
 
368
373
  ---
369
374
 
370
- ### Custom cell rendering
371
-
372
- ```tsx
373
- const columns: ColumnType<User>[] = [
374
- {
375
- key: 'status',
376
- dataIndex: 'status',
377
- title: 'Status',
378
- width: 120,
379
- render: (value, record) => (
380
- <span
381
- style={{
382
- padding: '2px 8px',
383
- borderRadius: 4,
384
- fontSize: 12,
385
- backgroundColor: record.status === 'active' ? '#d1fae5' : '#fee2e2',
386
- color: record.status === 'active' ? '#065f46' : '#991b1b',
387
- }}
388
- >
389
- {String(value)}
390
- </span>
391
- ),
392
- },
393
- ];
394
- ```
395
-
396
- ---
397
-
398
- ### Custom context menu items
399
-
400
- ```tsx
401
- <BoltTable
402
- columns={columns}
403
- data={data}
404
- columnContextMenuItems={[
405
- {
406
- key: 'copy',
407
- label: 'Copy column data',
408
- icon: <CopyIcon className="h-3 w-3" />,
409
- onClick: (columnKey) => copyColumnToClipboard(columnKey),
410
- },
411
- {
412
- key: 'reset-width',
413
- label: 'Reset width',
414
- onClick: (columnKey) => resetColumnWidth(columnKey),
415
- },
416
- ]}
417
- />
418
- ```
419
-
420
- ---
421
-
422
375
  ### Styling overrides
423
376
 
424
377
  ```tsx
@@ -443,27 +396,6 @@ const columns: ColumnType<User>[] = [
443
396
 
444
397
  ---
445
398
 
446
- ### Loading skeleton
447
-
448
- ```tsx
449
- // Full skeleton on initial load (no data yet)
450
- <BoltTable
451
- columns={columns}
452
- data={[]}
453
- isLoading={true}
454
- pagination={{ pageSize: 20 }}
455
- />
456
-
457
- // Layout skeleton before column widths are known
458
- <BoltTable
459
- columns={columns}
460
- data={[]}
461
- layoutLoading={true}
462
- />
463
- ```
464
-
465
- ---
466
-
467
399
  ### Fixed height (fill parent)
468
400
 
469
401
  By default, BoltTable auto-sizes to its content. To fill a fixed-height container instead:
@@ -491,6 +423,7 @@ import type {
491
423
  PaginationType,
492
424
  SortDirection,
493
425
  DataRecord,
426
+ BoltTableIcons,
494
427
  } from 'bolt-table';
495
428
  ```
496
429
 
@@ -498,4 +431,4 @@ import type {
498
431
 
499
432
  ## License
500
433
 
501
- MIT © [Venkatesh Sirigineedi](https://github.com
434
+ MIT © [Venkatesh Sirigineedi](https://github.com/venkateshsirigineedi)
package/dist/index.d.mts CHANGED
@@ -278,7 +278,7 @@ interface ColumnContextMenuItem {
278
278
  label: React.ReactNode;
279
279
  /**
280
280
  * Optional icon shown to the left of the label.
281
- * Recommended size: 12–14px (e.g. a lucide-react icon at h-3 w-3).
281
+ * Recommended size: 12–14px .
282
282
  *
283
283
  * @example
284
284
  * icon: <CopyIcon className="h-3 w-3" />
@@ -1238,11 +1238,13 @@ interface DraggableHeaderProps {
1238
1238
  /**
1239
1239
  * Called when the user presses down on the resize handle at the right edge
1240
1240
  * of this header cell. Starts the resize drag operation in BoltTable.
1241
- *
1242
- * @param columnKey - The key of the column being resized
1243
- * @param event - The React mouse event from the resize handle mousedown
1244
1241
  */
1245
1242
  onResizeStart?: (columnKey: string, event: React$1.MouseEvent) => void;
1243
+ /**
1244
+ * Called when the user starts dragging this column header to reorder.
1245
+ * BoltTable handles the full drag lifecycle from this point.
1246
+ */
1247
+ onColumnDragStart?: (columnKey: string, event: React$1.PointerEvent) => void;
1246
1248
  /**
1247
1249
  * Shared styling overrides for header cells.
1248
1250
  * `styles.header` applies to all headers; `styles.pinnedHeader` applies
@@ -1264,7 +1266,7 @@ interface DraggableHeaderProps {
1264
1266
  hideGripIcon?: boolean;
1265
1267
  /**
1266
1268
  * A custom React node to use as the drag grip icon.
1267
- * When omitted, the default `GripVertical` icon from lucide-react is used.
1269
+ * When omitted, the default `GripVertical` icon is used.
1268
1270
  *
1269
1271
  * @example
1270
1272
  * gripIcon={<MyCustomDragIcon />}
@@ -1375,7 +1377,7 @@ interface DraggableHeaderProps {
1375
1377
  *
1376
1378
  * @internal This is an internal BoltTable component. Use BoltTable directly.
1377
1379
  */
1378
- 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, }: DraggableHeaderProps) => react_jsx_runtime.JSX.Element>;
1380
+ 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>;
1379
1381
 
1380
1382
  /**
1381
1383
  * The imperative handle exposed by ResizeOverlay via `ref`.
package/dist/index.d.ts CHANGED
@@ -278,7 +278,7 @@ interface ColumnContextMenuItem {
278
278
  label: React.ReactNode;
279
279
  /**
280
280
  * Optional icon shown to the left of the label.
281
- * Recommended size: 12–14px (e.g. a lucide-react icon at h-3 w-3).
281
+ * Recommended size: 12–14px .
282
282
  *
283
283
  * @example
284
284
  * icon: <CopyIcon className="h-3 w-3" />
@@ -1238,11 +1238,13 @@ interface DraggableHeaderProps {
1238
1238
  /**
1239
1239
  * Called when the user presses down on the resize handle at the right edge
1240
1240
  * of this header cell. Starts the resize drag operation in BoltTable.
1241
- *
1242
- * @param columnKey - The key of the column being resized
1243
- * @param event - The React mouse event from the resize handle mousedown
1244
1241
  */
1245
1242
  onResizeStart?: (columnKey: string, event: React$1.MouseEvent) => void;
1243
+ /**
1244
+ * Called when the user starts dragging this column header to reorder.
1245
+ * BoltTable handles the full drag lifecycle from this point.
1246
+ */
1247
+ onColumnDragStart?: (columnKey: string, event: React$1.PointerEvent) => void;
1246
1248
  /**
1247
1249
  * Shared styling overrides for header cells.
1248
1250
  * `styles.header` applies to all headers; `styles.pinnedHeader` applies
@@ -1264,7 +1266,7 @@ interface DraggableHeaderProps {
1264
1266
  hideGripIcon?: boolean;
1265
1267
  /**
1266
1268
  * A custom React node to use as the drag grip icon.
1267
- * When omitted, the default `GripVertical` icon from lucide-react is used.
1269
+ * When omitted, the default `GripVertical` icon is used.
1268
1270
  *
1269
1271
  * @example
1270
1272
  * gripIcon={<MyCustomDragIcon />}
@@ -1375,7 +1377,7 @@ interface DraggableHeaderProps {
1375
1377
  *
1376
1378
  * @internal This is an internal BoltTable component. Use BoltTable directly.
1377
1379
  */
1378
- 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, }: DraggableHeaderProps) => react_jsx_runtime.JSX.Element>;
1380
+ 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>;
1379
1381
 
1380
1382
  /**
1381
1383
  * The imperative handle exposed by ResizeOverlay via `ref`.