bolt-table 0.1.25 → 0.1.27

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/dist/index.d.mts CHANGED
@@ -19,10 +19,13 @@ interface BoltTableIcons {
19
19
  chevronsRight?: React$1.ReactNode;
20
20
  copy?: React$1.ReactNode;
21
21
  edit?: React$1.ReactNode;
22
+ search?: React$1.ReactNode;
23
+ columns?: React$1.ReactNode;
24
+ close?: React$1.ReactNode;
22
25
  }
23
26
 
24
27
  /** `'asc'` | `'desc'` | `null` — the direction of a column sort. */
25
- type SortDirection = 'asc' | 'desc' | null;
28
+ type SortDirection = "asc" | "desc" | null;
26
29
  /** Defines the shape of a single column in BoltTable. */
27
30
  interface ColumnType<T = unknown> {
28
31
  /** The text or React node shown in the column header. */
@@ -54,11 +57,11 @@ interface ColumnType<T = unknown> {
54
57
  /** Whether this column is hidden by default on first render. */
55
58
  defaultHidden?: boolean;
56
59
  /** Which side this column is pinned to by default: `'left'`, `'right'`, or `false`. */
57
- defaultPinned?: 'left' | 'right' | false;
60
+ defaultPinned?: "left" | "right" | false;
58
61
  /** Controlled hidden state of the column. For uncontrolled, use `defaultHidden`. */
59
62
  hidden?: boolean;
60
63
  /** Controlled pinned state: `'left'`, `'right'`, or `false`. For uncontrolled, use `defaultPinned`. */
61
- pinned?: 'left' | 'right' | false;
64
+ pinned?: "left" | "right" | false;
62
65
  /** Additional CSS class name(s) applied to every cell in this column. */
63
66
  className?: string;
64
67
  /** Inline CSS styles applied to every cell in this column. */
@@ -108,7 +111,7 @@ interface ColumnContextMenuItem {
108
111
  onClick: (columnKey: string) => void;
109
112
  }
110
113
  /** How the row selection was triggered: `'all'`, `'single'`, or `'multiple'`. */
111
- type RowSelectMethod = 'all' | 'single' | 'multiple';
114
+ type RowSelectMethod = "all" | "single" | "multiple";
112
115
  /** Configuration for expandable rows with a custom rendered panel below each row. */
113
116
  interface ExpandableConfig<T = unknown> {
114
117
  /** When `true`, all rows are expanded on initial render. */
@@ -129,7 +132,7 @@ interface ExpandableConfig<T = unknown> {
129
132
  /** Configuration for row selection (checkboxes or radio buttons). */
130
133
  interface RowSelectionConfig<T = unknown> {
131
134
  /** `'checkbox'` for multi-select (default) or `'radio'` for single-select. */
132
- type?: 'checkbox' | 'radio';
135
+ type?: "checkbox" | "radio";
133
136
  /** When `true`, hides the "select all" checkbox in the header. */
134
137
  hideSelectAll?: boolean;
135
138
  /** The currently selected row keys (controlled). */
@@ -171,6 +174,19 @@ interface RowPinningConfig {
171
174
  }
172
175
  /** Base type for row records — all row objects must be indexable by string keys. */
173
176
  type DataRecord = Record<string, unknown>;
177
+ /** Configuration for persisting column state to localStorage. */
178
+ interface ColumnPersistenceConfig {
179
+ /** Unique key used as the localStorage key prefix. Required. */
180
+ storageKey: string;
181
+ /** Persist column order. Defaults to `true`. */
182
+ persistOrder?: boolean;
183
+ /** Persist column widths. Defaults to `true`. */
184
+ persistWidths?: boolean;
185
+ /** Persist column visibility (hidden state). Defaults to `true`. */
186
+ persistVisibility?: boolean;
187
+ /** Persist column pinned state. Defaults to `true`. */
188
+ persistPinned?: boolean;
189
+ }
174
190
 
175
191
  interface BoltTableProps<T extends DataRecord = DataRecord> {
176
192
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -206,7 +222,7 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
206
222
  /** Called after the user drops a column header into a new position. */
207
223
  readonly onColumnOrderChange?: (newOrder: string[]) => void;
208
224
  /** Called when the user pins or unpins a column via the context menu. */
209
- readonly onColumnPin?: (columnKey: string, pinned: 'left' | 'right' | false) => void;
225
+ readonly onColumnPin?: (columnKey: string, pinned: "left" | "right" | false) => void;
210
226
  /** Called when the user hides or shows a column via the context menu. */
211
227
  readonly onColumnHide?: (columnKey: string, hidden: boolean) => void;
212
228
  /** Determines the unique key for each row. Can be a string property name, function, number, or symbol. */
@@ -218,7 +234,7 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
218
234
  /** Row pinning configuration. Pass `true` for internal state management, or an object for controlled mode. */
219
235
  readonly rowPinning?: RowPinningConfig | boolean;
220
236
  /** Called when the user pins or unpins a row via the cell context menu. */
221
- readonly onRowPin?: (rowKey: React$1.Key, pinned: 'top' | 'bottom' | false) => void;
237
+ readonly onRowPin?: (rowKey: React$1.Key, pinned: "top" | "bottom" | false) => void;
222
238
  /** Called when the user scrolls near the bottom of the table. Use for infinite scroll. */
223
239
  readonly onEndReached?: () => void;
224
240
  /** How many rows from the end of the list should trigger onEndReached. */
@@ -251,6 +267,20 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
251
267
  readonly onEdit?: (value: unknown, record: T, dataIndex: string, rowIndex: number) => void;
252
268
  /** Called when a row is clicked. When provided, all row cells show a pointer cursor on hover. */
253
269
  readonly onRowClick?: (record: T, index: number, event: React$1.MouseEvent) => void;
270
+ /** Enable horizontal virtualization for tables with many columns. Only visible columns are rendered. */
271
+ readonly enableColumnVirtualization?: boolean;
272
+ /** Enable dynamic row heights based on content. Uses ResizeObserver to measure actual row heights. */
273
+ readonly enableDynamicRowHeight?: boolean;
274
+ /** Configuration for persisting column state (order, widths, visibility, pinned) to localStorage. Defaults to `false` (disabled). */
275
+ readonly columnPersistence?: ColumnPersistenceConfig | false;
276
+ /** Show the column picker/settings button in the header area. Defaults to `true`. */
277
+ readonly showColumnSettings?: boolean;
278
+ /** Hide the global search input above the table. Defaults to `false`. */
279
+ readonly hideGlobalSearch?: boolean;
280
+ /** Controlled global search value. When provided, the table uses this instead of its own internal state. */
281
+ readonly globalSearchValue?: string;
282
+ /** Called when the global search value changes. */
283
+ readonly onGlobalSearchChange?: (value: string) => void;
254
284
  }
255
285
  interface ClassNamesTypes {
256
286
  /** Applied to all non-pinned column header cells. */
@@ -318,7 +348,7 @@ interface StylesTypes {
318
348
  /** Inline styles for the "X–Y of Z" info text. */
319
349
  paginationInfo?: CSSProperties;
320
350
  }
321
- declare function BoltTable<T extends DataRecord = DataRecord>({ columns: rawInitialColumns, data: rawData, 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, rowClassName, rowStyle, disabledFilters, onCopy, keepPinnedRowsAcrossPages, onEdit, onRowClick, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
351
+ declare function BoltTable<T extends DataRecord = DataRecord>({ columns: rawInitialColumns, data: rawData, 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, rowClassName, rowStyle, disabledFilters, onCopy, keepPinnedRowsAcrossPages, onEdit, onRowClick, enableColumnVirtualization, enableDynamicRowHeight, columnPersistence, showColumnSettings, hideGlobalSearch, globalSearchValue, onGlobalSearchChange, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
322
352
 
323
353
  interface DraggableHeaderProps {
324
354
  /** Column definition for this header cell. */
@@ -449,7 +479,11 @@ interface TableBodyProps {
449
479
  } | null;
450
480
  /** Called when the editing input commits or cancels — clears `editingCell`. */
451
481
  onEditComplete?: () => void;
482
+ /** When true, rows use content-based heights measured by ResizeObserver. */
483
+ enableDynamicRowHeight?: boolean;
484
+ /** Called when a row's measured height changes. Used by the parent to update the virtualizer. */
485
+ onRowHeightChange?: (index: number, height: number) => void;
452
486
  }
453
487
  declare const TableBody: React$1.FC<TableBodyProps>;
454
488
 
455
- export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };
489
+ export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnPersistenceConfig, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };
package/dist/index.d.ts CHANGED
@@ -19,10 +19,13 @@ interface BoltTableIcons {
19
19
  chevronsRight?: React$1.ReactNode;
20
20
  copy?: React$1.ReactNode;
21
21
  edit?: React$1.ReactNode;
22
+ search?: React$1.ReactNode;
23
+ columns?: React$1.ReactNode;
24
+ close?: React$1.ReactNode;
22
25
  }
23
26
 
24
27
  /** `'asc'` | `'desc'` | `null` — the direction of a column sort. */
25
- type SortDirection = 'asc' | 'desc' | null;
28
+ type SortDirection = "asc" | "desc" | null;
26
29
  /** Defines the shape of a single column in BoltTable. */
27
30
  interface ColumnType<T = unknown> {
28
31
  /** The text or React node shown in the column header. */
@@ -54,11 +57,11 @@ interface ColumnType<T = unknown> {
54
57
  /** Whether this column is hidden by default on first render. */
55
58
  defaultHidden?: boolean;
56
59
  /** Which side this column is pinned to by default: `'left'`, `'right'`, or `false`. */
57
- defaultPinned?: 'left' | 'right' | false;
60
+ defaultPinned?: "left" | "right" | false;
58
61
  /** Controlled hidden state of the column. For uncontrolled, use `defaultHidden`. */
59
62
  hidden?: boolean;
60
63
  /** Controlled pinned state: `'left'`, `'right'`, or `false`. For uncontrolled, use `defaultPinned`. */
61
- pinned?: 'left' | 'right' | false;
64
+ pinned?: "left" | "right" | false;
62
65
  /** Additional CSS class name(s) applied to every cell in this column. */
63
66
  className?: string;
64
67
  /** Inline CSS styles applied to every cell in this column. */
@@ -108,7 +111,7 @@ interface ColumnContextMenuItem {
108
111
  onClick: (columnKey: string) => void;
109
112
  }
110
113
  /** How the row selection was triggered: `'all'`, `'single'`, or `'multiple'`. */
111
- type RowSelectMethod = 'all' | 'single' | 'multiple';
114
+ type RowSelectMethod = "all" | "single" | "multiple";
112
115
  /** Configuration for expandable rows with a custom rendered panel below each row. */
113
116
  interface ExpandableConfig<T = unknown> {
114
117
  /** When `true`, all rows are expanded on initial render. */
@@ -129,7 +132,7 @@ interface ExpandableConfig<T = unknown> {
129
132
  /** Configuration for row selection (checkboxes or radio buttons). */
130
133
  interface RowSelectionConfig<T = unknown> {
131
134
  /** `'checkbox'` for multi-select (default) or `'radio'` for single-select. */
132
- type?: 'checkbox' | 'radio';
135
+ type?: "checkbox" | "radio";
133
136
  /** When `true`, hides the "select all" checkbox in the header. */
134
137
  hideSelectAll?: boolean;
135
138
  /** The currently selected row keys (controlled). */
@@ -171,6 +174,19 @@ interface RowPinningConfig {
171
174
  }
172
175
  /** Base type for row records — all row objects must be indexable by string keys. */
173
176
  type DataRecord = Record<string, unknown>;
177
+ /** Configuration for persisting column state to localStorage. */
178
+ interface ColumnPersistenceConfig {
179
+ /** Unique key used as the localStorage key prefix. Required. */
180
+ storageKey: string;
181
+ /** Persist column order. Defaults to `true`. */
182
+ persistOrder?: boolean;
183
+ /** Persist column widths. Defaults to `true`. */
184
+ persistWidths?: boolean;
185
+ /** Persist column visibility (hidden state). Defaults to `true`. */
186
+ persistVisibility?: boolean;
187
+ /** Persist column pinned state. Defaults to `true`. */
188
+ persistPinned?: boolean;
189
+ }
174
190
 
175
191
  interface BoltTableProps<T extends DataRecord = DataRecord> {
176
192
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -206,7 +222,7 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
206
222
  /** Called after the user drops a column header into a new position. */
207
223
  readonly onColumnOrderChange?: (newOrder: string[]) => void;
208
224
  /** Called when the user pins or unpins a column via the context menu. */
209
- readonly onColumnPin?: (columnKey: string, pinned: 'left' | 'right' | false) => void;
225
+ readonly onColumnPin?: (columnKey: string, pinned: "left" | "right" | false) => void;
210
226
  /** Called when the user hides or shows a column via the context menu. */
211
227
  readonly onColumnHide?: (columnKey: string, hidden: boolean) => void;
212
228
  /** Determines the unique key for each row. Can be a string property name, function, number, or symbol. */
@@ -218,7 +234,7 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
218
234
  /** Row pinning configuration. Pass `true` for internal state management, or an object for controlled mode. */
219
235
  readonly rowPinning?: RowPinningConfig | boolean;
220
236
  /** Called when the user pins or unpins a row via the cell context menu. */
221
- readonly onRowPin?: (rowKey: React$1.Key, pinned: 'top' | 'bottom' | false) => void;
237
+ readonly onRowPin?: (rowKey: React$1.Key, pinned: "top" | "bottom" | false) => void;
222
238
  /** Called when the user scrolls near the bottom of the table. Use for infinite scroll. */
223
239
  readonly onEndReached?: () => void;
224
240
  /** How many rows from the end of the list should trigger onEndReached. */
@@ -251,6 +267,20 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
251
267
  readonly onEdit?: (value: unknown, record: T, dataIndex: string, rowIndex: number) => void;
252
268
  /** Called when a row is clicked. When provided, all row cells show a pointer cursor on hover. */
253
269
  readonly onRowClick?: (record: T, index: number, event: React$1.MouseEvent) => void;
270
+ /** Enable horizontal virtualization for tables with many columns. Only visible columns are rendered. */
271
+ readonly enableColumnVirtualization?: boolean;
272
+ /** Enable dynamic row heights based on content. Uses ResizeObserver to measure actual row heights. */
273
+ readonly enableDynamicRowHeight?: boolean;
274
+ /** Configuration for persisting column state (order, widths, visibility, pinned) to localStorage. Defaults to `false` (disabled). */
275
+ readonly columnPersistence?: ColumnPersistenceConfig | false;
276
+ /** Show the column picker/settings button in the header area. Defaults to `true`. */
277
+ readonly showColumnSettings?: boolean;
278
+ /** Hide the global search input above the table. Defaults to `false`. */
279
+ readonly hideGlobalSearch?: boolean;
280
+ /** Controlled global search value. When provided, the table uses this instead of its own internal state. */
281
+ readonly globalSearchValue?: string;
282
+ /** Called when the global search value changes. */
283
+ readonly onGlobalSearchChange?: (value: string) => void;
254
284
  }
255
285
  interface ClassNamesTypes {
256
286
  /** Applied to all non-pinned column header cells. */
@@ -318,7 +348,7 @@ interface StylesTypes {
318
348
  /** Inline styles for the "X–Y of Z" info text. */
319
349
  paginationInfo?: CSSProperties;
320
350
  }
321
- declare function BoltTable<T extends DataRecord = DataRecord>({ columns: rawInitialColumns, data: rawData, 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, rowClassName, rowStyle, disabledFilters, onCopy, keepPinnedRowsAcrossPages, onEdit, onRowClick, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
351
+ declare function BoltTable<T extends DataRecord = DataRecord>({ columns: rawInitialColumns, data: rawData, 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, rowClassName, rowStyle, disabledFilters, onCopy, keepPinnedRowsAcrossPages, onEdit, onRowClick, enableColumnVirtualization, enableDynamicRowHeight, columnPersistence, showColumnSettings, hideGlobalSearch, globalSearchValue, onGlobalSearchChange, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
322
352
 
323
353
  interface DraggableHeaderProps {
324
354
  /** Column definition for this header cell. */
@@ -449,7 +479,11 @@ interface TableBodyProps {
449
479
  } | null;
450
480
  /** Called when the editing input commits or cancels — clears `editingCell`. */
451
481
  onEditComplete?: () => void;
482
+ /** When true, rows use content-based heights measured by ResizeObserver. */
483
+ enableDynamicRowHeight?: boolean;
484
+ /** Called when a row's measured height changes. Used by the parent to update the virtualizer. */
485
+ onRowHeightChange?: (index: number, height: number) => void;
452
486
  }
453
487
  declare const TableBody: React$1.FC<TableBodyProps>;
454
488
 
455
- export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };
489
+ export { BoltTable, type BoltTableIcons, type CellContextMenuItem, type ClassNamesTypes, type ColumnContextMenuItem, type ColumnPersistenceConfig, type ColumnType, type DataRecord, DraggableHeader, type ExpandableConfig, type PaginationType, ResizeOverlay, type RowPinningConfig, type RowSelectionConfig, type SortDirection, type StylesTypes, TableBody };