bolt-table 0.1.36 → 0.1.38

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
@@ -22,6 +22,9 @@ interface BoltTableIcons {
22
22
  search?: React$1.ReactNode;
23
23
  columns?: React$1.ReactNode;
24
24
  close?: React$1.ReactNode;
25
+ sparkles?: React$1.ReactNode;
26
+ send?: React$1.ReactNode;
27
+ loader?: React$1.ReactNode;
25
28
  }
26
29
 
27
30
  /** `'asc'` | `'desc'` | `null` — the direction of a column sort. */
@@ -208,6 +211,90 @@ interface ColumnPersistenceConfig {
208
211
  /** Persist column pinned state. Defaults to `true`. */
209
212
  persistPinned?: boolean;
210
213
  }
214
+ /** Supported comparison operators for AI-generated conditions. */
215
+ type AIOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "contains" | "notContains" | "startsWith" | "endsWith" | "in" | "notIn";
216
+ /** A single condition produced by the AI. */
217
+ interface AICondition {
218
+ column: string;
219
+ op: AIOperator;
220
+ value: unknown;
221
+ }
222
+ /** Filter rows matching conditions. */
223
+ interface AIFilterOperation {
224
+ type: "filter";
225
+ conditions: AICondition[];
226
+ logic?: "and" | "or";
227
+ }
228
+ /** Apply inline styles to rows matching conditions. */
229
+ interface AIStyleOperation {
230
+ type: "rowStyle";
231
+ conditions: AICondition[];
232
+ logic?: "and" | "or";
233
+ style: Record<string, string>;
234
+ }
235
+ /** Apply inline styles to specific cells matching conditions. */
236
+ interface AICellStyleOperation {
237
+ type: "cellStyle";
238
+ column: string;
239
+ conditions: AICondition[];
240
+ logic?: "and" | "or";
241
+ style: Record<string, string>;
242
+ }
243
+ /** Sort data by a column. */
244
+ interface AISortOperation {
245
+ type: "sort";
246
+ column: string;
247
+ direction: "asc" | "desc";
248
+ }
249
+ /** Hide or show specific columns. */
250
+ interface AIColumnVisibilityOperation {
251
+ type: "hideColumns" | "showColumns";
252
+ columns: string[];
253
+ }
254
+ /** Resize a column to a specific width. */
255
+ interface AIResizeColumnOperation {
256
+ type: "resizeColumn";
257
+ column: string;
258
+ width: number;
259
+ }
260
+ /** Reorder columns by moving a column to a new position. */
261
+ interface AIReorderColumnsOperation {
262
+ type: "reorderColumns";
263
+ order: string[];
264
+ }
265
+ /** Pin or unpin a column. */
266
+ interface AIPinColumnOperation {
267
+ type: "pinColumn";
268
+ column: string;
269
+ pinned: "left" | "right" | false;
270
+ }
271
+ /** Set the current page number. */
272
+ interface AISetPageOperation {
273
+ type: "setPage";
274
+ page: number;
275
+ }
276
+ /** Union of all possible AI operations. */
277
+ type AIOperation = AIFilterOperation | AIStyleOperation | AICellStyleOperation | AISortOperation | AIColumnVisibilityOperation | AIResizeColumnOperation | AIReorderColumnsOperation | AIPinColumnOperation | AISetPageOperation;
278
+ /** The structured response returned by the AI. */
279
+ interface AIResponse {
280
+ operations: AIOperation[];
281
+ message: string;
282
+ }
283
+ /** AI provider configuration. */
284
+ interface BoltTableAIConfig {
285
+ provider: "openai" | "anthropic" | "custom";
286
+ apiKey: string;
287
+ model?: string;
288
+ baseUrl?: string;
289
+ maxTokens?: number;
290
+ temperature?: number;
291
+ }
292
+ /** Top-level configuration for bolt-table.config.ts files. */
293
+ interface BoltTableConfig {
294
+ ai?: BoltTableAIConfig;
295
+ }
296
+ /** Helper for type-safe bolt-table.config.ts files. */
297
+ declare function defineConfig(config: BoltTableConfig): BoltTableConfig;
211
298
 
212
299
  interface BoltTableProps<T extends DataRecord = DataRecord> {
213
300
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -306,6 +393,21 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
306
393
  readonly toolbarContent?: React$1.ReactNode;
307
394
  /** Label for the column-settings button. Defaults to "Columns". */
308
395
  readonly columnSettingsLabel?: React$1.ReactNode;
396
+ /** Enable the AI assistant button in the toolbar. Requires `aiConfig` or `onAIQuery`. */
397
+ readonly aiMode?: boolean;
398
+ /** AI provider configuration (API key, model, etc.). Used by the built-in AI handler. */
399
+ readonly aiConfig?: BoltTableAIConfig;
400
+ /** Custom AI query handler. When provided, overrides the built-in AI call. Return an `AIResponse` with operations to apply. */
401
+ readonly onAIQuery?: (query: string, context: {
402
+ data: T[];
403
+ columns: ColumnType<T>[];
404
+ }) => Promise<AIResponse>;
405
+ /** Called after the AI applies operations. Receives the parsed response. */
406
+ readonly onAIResponse?: (response: AIResponse) => void;
407
+ /** Placeholder text for the AI search bar. */
408
+ readonly aiPlaceholder?: string;
409
+ /** Label for the AI button. Defaults to "Ask AI". */
410
+ readonly aiButtonLabel?: React$1.ReactNode;
309
411
  }
310
412
  interface ClassNamesTypes {
311
413
  /** Applied to all non-pinned column header cells. */
@@ -373,7 +475,7 @@ interface StylesTypes {
373
475
  /** Inline styles for the "X–Y of Z" info text. */
374
476
  paginationInfo?: CSSProperties;
375
477
  }
376
- 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, toolbarContent, columnSettingsLabel, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
478
+ 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, toolbarContent, columnSettingsLabel, aiMode, aiConfig, onAIQuery, onAIResponse, aiPlaceholder, aiButtonLabel, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
377
479
 
378
480
  interface DraggableHeaderProps {
379
481
  /** Column definition for this header cell. */
@@ -510,7 +612,9 @@ interface TableBodyProps {
510
612
  onRowHeightChange?: (index: number, height: number) => void;
511
613
  /** Maps column key → 1-based CSS grid column index in the full (non-virtualized) grid. Required for correct placement when column virtualization is enabled. */
512
614
  columnGridIndexMap?: Map<string, number>;
615
+ /** Optional AI cell style function. Returns extra styles for a specific cell. */
616
+ cellStyleFn?: (record: DataRecord, columnKey: string) => React$1.CSSProperties | undefined;
513
617
  }
514
618
  declare const TableBody: React$1.FC<TableBodyProps>;
515
619
 
516
- 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 };
620
+ export { type AICellStyleOperation, type AIColumnVisibilityOperation, type AICondition, type AIFilterOperation, type AIOperation, type AIOperator, type AIPinColumnOperation, type AIReorderColumnsOperation, type AIResizeColumnOperation, type AIResponse, type AISetPageOperation, type AISortOperation, type AIStyleOperation, BoltTable, type BoltTableAIConfig, type BoltTableConfig, 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, defineConfig };
package/dist/index.d.ts CHANGED
@@ -22,6 +22,9 @@ interface BoltTableIcons {
22
22
  search?: React$1.ReactNode;
23
23
  columns?: React$1.ReactNode;
24
24
  close?: React$1.ReactNode;
25
+ sparkles?: React$1.ReactNode;
26
+ send?: React$1.ReactNode;
27
+ loader?: React$1.ReactNode;
25
28
  }
26
29
 
27
30
  /** `'asc'` | `'desc'` | `null` — the direction of a column sort. */
@@ -208,6 +211,90 @@ interface ColumnPersistenceConfig {
208
211
  /** Persist column pinned state. Defaults to `true`. */
209
212
  persistPinned?: boolean;
210
213
  }
214
+ /** Supported comparison operators for AI-generated conditions. */
215
+ type AIOperator = "eq" | "neq" | "gt" | "gte" | "lt" | "lte" | "contains" | "notContains" | "startsWith" | "endsWith" | "in" | "notIn";
216
+ /** A single condition produced by the AI. */
217
+ interface AICondition {
218
+ column: string;
219
+ op: AIOperator;
220
+ value: unknown;
221
+ }
222
+ /** Filter rows matching conditions. */
223
+ interface AIFilterOperation {
224
+ type: "filter";
225
+ conditions: AICondition[];
226
+ logic?: "and" | "or";
227
+ }
228
+ /** Apply inline styles to rows matching conditions. */
229
+ interface AIStyleOperation {
230
+ type: "rowStyle";
231
+ conditions: AICondition[];
232
+ logic?: "and" | "or";
233
+ style: Record<string, string>;
234
+ }
235
+ /** Apply inline styles to specific cells matching conditions. */
236
+ interface AICellStyleOperation {
237
+ type: "cellStyle";
238
+ column: string;
239
+ conditions: AICondition[];
240
+ logic?: "and" | "or";
241
+ style: Record<string, string>;
242
+ }
243
+ /** Sort data by a column. */
244
+ interface AISortOperation {
245
+ type: "sort";
246
+ column: string;
247
+ direction: "asc" | "desc";
248
+ }
249
+ /** Hide or show specific columns. */
250
+ interface AIColumnVisibilityOperation {
251
+ type: "hideColumns" | "showColumns";
252
+ columns: string[];
253
+ }
254
+ /** Resize a column to a specific width. */
255
+ interface AIResizeColumnOperation {
256
+ type: "resizeColumn";
257
+ column: string;
258
+ width: number;
259
+ }
260
+ /** Reorder columns by moving a column to a new position. */
261
+ interface AIReorderColumnsOperation {
262
+ type: "reorderColumns";
263
+ order: string[];
264
+ }
265
+ /** Pin or unpin a column. */
266
+ interface AIPinColumnOperation {
267
+ type: "pinColumn";
268
+ column: string;
269
+ pinned: "left" | "right" | false;
270
+ }
271
+ /** Set the current page number. */
272
+ interface AISetPageOperation {
273
+ type: "setPage";
274
+ page: number;
275
+ }
276
+ /** Union of all possible AI operations. */
277
+ type AIOperation = AIFilterOperation | AIStyleOperation | AICellStyleOperation | AISortOperation | AIColumnVisibilityOperation | AIResizeColumnOperation | AIReorderColumnsOperation | AIPinColumnOperation | AISetPageOperation;
278
+ /** The structured response returned by the AI. */
279
+ interface AIResponse {
280
+ operations: AIOperation[];
281
+ message: string;
282
+ }
283
+ /** AI provider configuration. */
284
+ interface BoltTableAIConfig {
285
+ provider: "openai" | "anthropic" | "custom";
286
+ apiKey: string;
287
+ model?: string;
288
+ baseUrl?: string;
289
+ maxTokens?: number;
290
+ temperature?: number;
291
+ }
292
+ /** Top-level configuration for bolt-table.config.ts files. */
293
+ interface BoltTableConfig {
294
+ ai?: BoltTableAIConfig;
295
+ }
296
+ /** Helper for type-safe bolt-table.config.ts files. */
297
+ declare function defineConfig(config: BoltTableConfig): BoltTableConfig;
211
298
 
212
299
  interface BoltTableProps<T extends DataRecord = DataRecord> {
213
300
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -306,6 +393,21 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
306
393
  readonly toolbarContent?: React$1.ReactNode;
307
394
  /** Label for the column-settings button. Defaults to "Columns". */
308
395
  readonly columnSettingsLabel?: React$1.ReactNode;
396
+ /** Enable the AI assistant button in the toolbar. Requires `aiConfig` or `onAIQuery`. */
397
+ readonly aiMode?: boolean;
398
+ /** AI provider configuration (API key, model, etc.). Used by the built-in AI handler. */
399
+ readonly aiConfig?: BoltTableAIConfig;
400
+ /** Custom AI query handler. When provided, overrides the built-in AI call. Return an `AIResponse` with operations to apply. */
401
+ readonly onAIQuery?: (query: string, context: {
402
+ data: T[];
403
+ columns: ColumnType<T>[];
404
+ }) => Promise<AIResponse>;
405
+ /** Called after the AI applies operations. Receives the parsed response. */
406
+ readonly onAIResponse?: (response: AIResponse) => void;
407
+ /** Placeholder text for the AI search bar. */
408
+ readonly aiPlaceholder?: string;
409
+ /** Label for the AI button. Defaults to "Ask AI". */
410
+ readonly aiButtonLabel?: React$1.ReactNode;
309
411
  }
310
412
  interface ClassNamesTypes {
311
413
  /** Applied to all non-pinned column header cells. */
@@ -373,7 +475,7 @@ interface StylesTypes {
373
475
  /** Inline styles for the "X–Y of Z" info text. */
374
476
  paginationInfo?: CSSProperties;
375
477
  }
376
- 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, toolbarContent, columnSettingsLabel, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
478
+ 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, toolbarContent, columnSettingsLabel, aiMode, aiConfig, onAIQuery, onAIResponse, aiPlaceholder, aiButtonLabel, }: BoltTableProps<T>): react_jsx_runtime.JSX.Element;
377
479
 
378
480
  interface DraggableHeaderProps {
379
481
  /** Column definition for this header cell. */
@@ -510,7 +612,9 @@ interface TableBodyProps {
510
612
  onRowHeightChange?: (index: number, height: number) => void;
511
613
  /** Maps column key → 1-based CSS grid column index in the full (non-virtualized) grid. Required for correct placement when column virtualization is enabled. */
512
614
  columnGridIndexMap?: Map<string, number>;
615
+ /** Optional AI cell style function. Returns extra styles for a specific cell. */
616
+ cellStyleFn?: (record: DataRecord, columnKey: string) => React$1.CSSProperties | undefined;
513
617
  }
514
618
  declare const TableBody: React$1.FC<TableBodyProps>;
515
619
 
516
- 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 };
620
+ export { type AICellStyleOperation, type AIColumnVisibilityOperation, type AICondition, type AIFilterOperation, type AIOperation, type AIOperator, type AIPinColumnOperation, type AIReorderColumnsOperation, type AIResizeColumnOperation, type AIResponse, type AISetPageOperation, type AISortOperation, type AIStyleOperation, BoltTable, type BoltTableAIConfig, type BoltTableConfig, 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, defineConfig };