bolt-table 0.1.36 → 0.1.37

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,68 @@ 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
+ /** Union of all possible AI operations. */
255
+ type AIOperation = AIFilterOperation | AIStyleOperation | AICellStyleOperation | AISortOperation | AIColumnVisibilityOperation;
256
+ /** The structured response returned by the AI. */
257
+ interface AIResponse {
258
+ operations: AIOperation[];
259
+ message: string;
260
+ }
261
+ /** AI provider configuration. */
262
+ interface BoltTableAIConfig {
263
+ provider: "openai" | "anthropic" | "custom";
264
+ apiKey: string;
265
+ model?: string;
266
+ baseUrl?: string;
267
+ maxTokens?: number;
268
+ temperature?: number;
269
+ }
270
+ /** Top-level configuration for bolt-table.config.ts files. */
271
+ interface BoltTableConfig {
272
+ ai?: BoltTableAIConfig;
273
+ }
274
+ /** Helper for type-safe bolt-table.config.ts files. */
275
+ declare function defineConfig(config: BoltTableConfig): BoltTableConfig;
211
276
 
212
277
  interface BoltTableProps<T extends DataRecord = DataRecord> {
213
278
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -306,6 +371,21 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
306
371
  readonly toolbarContent?: React$1.ReactNode;
307
372
  /** Label for the column-settings button. Defaults to "Columns". */
308
373
  readonly columnSettingsLabel?: React$1.ReactNode;
374
+ /** Enable the AI assistant button in the toolbar. Requires `aiConfig` or `onAIQuery`. */
375
+ readonly aiMode?: boolean;
376
+ /** AI provider configuration (API key, model, etc.). Used by the built-in AI handler. */
377
+ readonly aiConfig?: BoltTableAIConfig;
378
+ /** Custom AI query handler. When provided, overrides the built-in AI call. Return an `AIResponse` with operations to apply. */
379
+ readonly onAIQuery?: (query: string, context: {
380
+ data: T[];
381
+ columns: ColumnType<T>[];
382
+ }) => Promise<AIResponse>;
383
+ /** Called after the AI applies operations. Receives the parsed response. */
384
+ readonly onAIResponse?: (response: AIResponse) => void;
385
+ /** Placeholder text for the AI search bar. */
386
+ readonly aiPlaceholder?: string;
387
+ /** Label for the AI button. Defaults to "Ask AI". */
388
+ readonly aiButtonLabel?: React$1.ReactNode;
309
389
  }
310
390
  interface ClassNamesTypes {
311
391
  /** Applied to all non-pinned column header cells. */
@@ -373,7 +453,7 @@ interface StylesTypes {
373
453
  /** Inline styles for the "X–Y of Z" info text. */
374
454
  paginationInfo?: CSSProperties;
375
455
  }
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;
456
+ 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
457
 
378
458
  interface DraggableHeaderProps {
379
459
  /** Column definition for this header cell. */
@@ -510,7 +590,9 @@ interface TableBodyProps {
510
590
  onRowHeightChange?: (index: number, height: number) => void;
511
591
  /** 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
592
  columnGridIndexMap?: Map<string, number>;
593
+ /** Optional AI cell style function. Returns extra styles for a specific cell. */
594
+ cellStyleFn?: (record: DataRecord, columnKey: string) => React$1.CSSProperties | undefined;
513
595
  }
514
596
  declare const TableBody: React$1.FC<TableBodyProps>;
515
597
 
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 };
598
+ export { type AICellStyleOperation, type AIColumnVisibilityOperation, type AICondition, type AIFilterOperation, type AIOperation, type AIOperator, type AIResponse, 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,68 @@ 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
+ /** Union of all possible AI operations. */
255
+ type AIOperation = AIFilterOperation | AIStyleOperation | AICellStyleOperation | AISortOperation | AIColumnVisibilityOperation;
256
+ /** The structured response returned by the AI. */
257
+ interface AIResponse {
258
+ operations: AIOperation[];
259
+ message: string;
260
+ }
261
+ /** AI provider configuration. */
262
+ interface BoltTableAIConfig {
263
+ provider: "openai" | "anthropic" | "custom";
264
+ apiKey: string;
265
+ model?: string;
266
+ baseUrl?: string;
267
+ maxTokens?: number;
268
+ temperature?: number;
269
+ }
270
+ /** Top-level configuration for bolt-table.config.ts files. */
271
+ interface BoltTableConfig {
272
+ ai?: BoltTableAIConfig;
273
+ }
274
+ /** Helper for type-safe bolt-table.config.ts files. */
275
+ declare function defineConfig(config: BoltTableConfig): BoltTableConfig;
211
276
 
212
277
  interface BoltTableProps<T extends DataRecord = DataRecord> {
213
278
  /** Column definitions controlling what columns are shown, their order, width, pinning, sort/filter, and rendering. */
@@ -306,6 +371,21 @@ interface BoltTableProps<T extends DataRecord = DataRecord> {
306
371
  readonly toolbarContent?: React$1.ReactNode;
307
372
  /** Label for the column-settings button. Defaults to "Columns". */
308
373
  readonly columnSettingsLabel?: React$1.ReactNode;
374
+ /** Enable the AI assistant button in the toolbar. Requires `aiConfig` or `onAIQuery`. */
375
+ readonly aiMode?: boolean;
376
+ /** AI provider configuration (API key, model, etc.). Used by the built-in AI handler. */
377
+ readonly aiConfig?: BoltTableAIConfig;
378
+ /** Custom AI query handler. When provided, overrides the built-in AI call. Return an `AIResponse` with operations to apply. */
379
+ readonly onAIQuery?: (query: string, context: {
380
+ data: T[];
381
+ columns: ColumnType<T>[];
382
+ }) => Promise<AIResponse>;
383
+ /** Called after the AI applies operations. Receives the parsed response. */
384
+ readonly onAIResponse?: (response: AIResponse) => void;
385
+ /** Placeholder text for the AI search bar. */
386
+ readonly aiPlaceholder?: string;
387
+ /** Label for the AI button. Defaults to "Ask AI". */
388
+ readonly aiButtonLabel?: React$1.ReactNode;
309
389
  }
310
390
  interface ClassNamesTypes {
311
391
  /** Applied to all non-pinned column header cells. */
@@ -373,7 +453,7 @@ interface StylesTypes {
373
453
  /** Inline styles for the "X–Y of Z" info text. */
374
454
  paginationInfo?: CSSProperties;
375
455
  }
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;
456
+ 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
457
 
378
458
  interface DraggableHeaderProps {
379
459
  /** Column definition for this header cell. */
@@ -510,7 +590,9 @@ interface TableBodyProps {
510
590
  onRowHeightChange?: (index: number, height: number) => void;
511
591
  /** 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
592
  columnGridIndexMap?: Map<string, number>;
593
+ /** Optional AI cell style function. Returns extra styles for a specific cell. */
594
+ cellStyleFn?: (record: DataRecord, columnKey: string) => React$1.CSSProperties | undefined;
513
595
  }
514
596
  declare const TableBody: React$1.FC<TableBodyProps>;
515
597
 
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 };
598
+ export { type AICellStyleOperation, type AIColumnVisibilityOperation, type AICondition, type AIFilterOperation, type AIOperation, type AIOperator, type AIResponse, 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 };