import * as _smallwebco_tinypivot_core from '@smallwebco/tinypivot-core'; import { AIAnalystConfig, ResolvedTheme, AIDataLoadedEvent, AIConversationUpdateEvent, AIQueryExecutedEvent, AIErrorEvent, ColumnStats, NumericRange, DateRange, NumberFormat, DateFormat, Theme, PivotLayout, DrillThroughResult, FieldStats, PivotValueField, CalculatedField, AggregationFunction, PivotResult, AIConversation, AITableSchema, AIDataSource, PivotExportData, ExportOptions, XlsxExportOptions, SourceData, SelectionBounds, PaginationOptions, LicenseInfo } from '@smallwebco/tinypivot-core'; export { AIAnalystConfig, AIColumnSchema, AIConversation, AIConversationUpdateEvent, AIDataLoadedEvent, AIDataSource, AIErrorEvent, AIMessage, AIMessageMetadata, AIQueryExecutedEvent, AITableSchema, AggregationFunction, CellClickEvent, ColumnStats, CopyEvent, DataGridProps, DrillThroughDescriptor, DrillThroughResult, ExportEvent, ExportOptions, FieldRoleOverrides, FieldStats, FilterEvent, GridOptions, LicenseInfo, LicenseType, PaginationOptions, PivotCell, PivotConfig as PivotConfigType, PivotField, PivotGroupStart, PivotLayout, PivotResult, PivotRowMeta, PivotTableProps, PivotValueField, RowSelectionChangeEvent, SelectionBounds, SelectionChangeEvent, SortEvent, XlsxExportOptions, formatCellValue, getAggregationLabel, getColumnUniqueValues } from '@smallwebco/tinypivot-core'; import * as react from 'react'; import react__default from 'react'; import * as react_jsx_runtime from 'react/jsx-runtime'; import * as _tanstack_react_table from '@tanstack/react-table'; import { SortingState, ColumnFiltersState, VisibilityState } from '@tanstack/react-table'; /** * TinyPivot React - AI Data Analyst Component * Split-panel layout: 1/4 chat, 3/4 data preview * Each query step shows data visually with expandable SQL */ interface AIAnalystProps { config: AIAnalystConfig; theme?: ResolvedTheme; onDataLoaded?: (payload: AIDataLoadedEvent) => void; onConversationUpdate?: (payload: AIConversationUpdateEvent) => void; onQueryExecuted?: (payload: AIQueryExecutedEvent) => void; onError?: (payload: AIErrorEvent) => void; onViewResults?: (payload: { data: Record[]; query: string; }) => void; } interface AIAnalystHandle { loadFullData: () => Promise[] | null>; selectedDataSource: string | undefined; } declare const AIAnalyst: react__default.ForwardRefExoticComponent>; interface ColumnFilterProps { columnId: string; columnName: string; stats: ColumnStats; selectedValues: string[]; sortDirection: 'asc' | 'desc' | null; /** Current numeric range filter (if any) */ numericRange?: NumericRange | null; /** Current date range filter (if any) */ dateRange?: DateRange | null; /** Number display format */ numberFormat?: NumberFormat; /** Date display format */ dateFormat?: DateFormat; onFilter: (values: string[]) => void; onSort: (direction: 'asc' | 'desc' | null) => void; onClose: () => void; /** Called when a numeric range filter is applied */ onRangeFilter?: (range: NumericRange | null) => void; /** Called when a date range filter is applied */ onDateRangeFilter?: (range: DateRange | null) => void; } declare function ColumnFilter({ columnName, stats, selectedValues, sortDirection, numericRange, dateRange, numberFormat, dateFormat, onFilter, onSort, onClose, onRangeFilter, onDateRangeFilter, }: ColumnFilterProps): react_jsx_runtime.JSX.Element; interface DataGridProps { data: Record[]; loading?: boolean; rowHeight?: number; headerHeight?: number; fontSize?: 'xs' | 'sm' | 'base'; showPivot?: boolean; enableExport?: boolean; enableSearch?: boolean; enablePagination?: boolean; pageSize?: number; enableColumnResize?: boolean; enableClipboard?: boolean; theme?: Theme; stripedRows?: boolean; exportFilename?: string; enableVerticalResize?: boolean; initialHeight?: number; minHeight?: number; maxHeight?: number; /** Number display format */ numberFormat?: NumberFormat; /** Date display format */ dateFormat?: DateFormat; /** Override auto-detected chart field roles per column name */ fieldRoleOverrides?: Record; /** AI Data Analyst configuration (Pro feature, disabled by default) */ aiAnalyst?: AIAnalystConfig; /** Enable row group collapse/expand (default true) */ enableDrillDown?: boolean; /** Enable drill-through on double-click (Pro feature, default true) */ enableDrillThrough?: boolean; /** Pivot row layout: 'grouped' merges repeated parent cells, 'tabular' repeats every value */ pivotLayout?: PivotLayout; onCellClick?: (payload: { row: number; col: number; value: unknown; rowData: Record; }) => void; onSelectionChange?: (payload: { cells: Array<{ row: number; col: number; }>; values: unknown[]; }) => void; onExport?: (payload: { rowCount: number; filename: string; }) => void; onCopy?: (payload: { text: string; cellCount: number; }) => void; onAIDataLoaded?: (payload: AIDataLoadedEvent) => void; onAIConversationUpdate?: (payload: AIConversationUpdateEvent) => void; onAIQueryExecuted?: (payload: AIQueryExecutedEvent) => void; onAIError?: (payload: AIErrorEvent) => void; onCollapseChange?: (collapsedPaths: string[]) => void; onDrillThrough?: (result: DrillThroughResult) => void; } declare function DataGrid({ data, loading, fontSize: initialFontSize, showPivot, enableExport, enableSearch, enablePagination, pageSize, enableColumnResize, enableClipboard, theme, stripedRows, exportFilename, enableVerticalResize, initialHeight, minHeight, maxHeight, numberFormat, dateFormat, fieldRoleOverrides, aiAnalyst, enableDrillDown, enableDrillThrough, pivotLayout, onCellClick, onExport, onCopy, onAIDataLoaded, onAIConversationUpdate, onAIQueryExecuted, onAIError, onCollapseChange, onDrillThrough, }: DataGridProps): react_jsx_runtime.JSX.Element; interface PivotConfigProps { availableFields: FieldStats[]; rowFields: string[]; columnFields: string[]; valueFields: PivotValueField[]; showRowTotals: boolean; showColumnTotals: boolean; calculatedFields?: CalculatedField[]; onShowRowTotalsChange: (value: boolean) => void; onShowColumnTotalsChange: (value: boolean) => void; onClearConfig: () => void; onAutoSuggest: () => void; onDragStart: (field: string, event: react__default.DragEvent) => void; onDragEnd: () => void; onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void; onAddRowField: (field: string) => void; onRemoveRowField: (field: string) => void; onAddColumnField: (field: string) => void; onRemoveColumnField: (field: string) => void; onAddValueField: (field: string, aggregation: AggregationFunction) => void; onRemoveValueField: (field: string, aggregation: AggregationFunction) => void; onAddCalculatedField?: (field: CalculatedField) => void; onRemoveCalculatedField?: (id: string) => void; onUpdateCalculatedField?: (field: CalculatedField) => void; theme?: string; /** Axis value filters: field → excluded values */ fieldFilters?: Record; /** Returns the unique values of a field — enables the axis filter UI */ getFieldValues?: (field: string) => string[]; onUpdateFieldFilter?: (field: string, excludedValues: string[]) => void; } declare function PivotConfig({ availableFields, rowFields, columnFields, valueFields, showRowTotals, calculatedFields, onShowRowTotalsChange, onShowColumnTotalsChange, onClearConfig, onAutoSuggest, onDragStart, onDragEnd, onUpdateAggregation, onRemoveRowField, onRemoveColumnField, onRemoveValueField, onAddRowField, onAddColumnField, onAddCalculatedField, onRemoveCalculatedField, onUpdateCalculatedField, theme, fieldFilters, getFieldValues, onUpdateFieldFilter, }: PivotConfigProps): react_jsx_runtime.JSX.Element; interface ActiveFilter { column: string; valueCount: number; values?: string[]; displayText?: string; isRange?: boolean; } interface PivotSkeletonProps { rowFields: string[]; columnFields: string[]; valueFields: PivotValueField[]; calculatedFields?: CalculatedField[]; isConfigured: boolean; draggingField: string | null; pivotResult: PivotResult | null; hasActiveFieldFilters?: boolean; fontSize?: 'xs' | 'sm' | 'base'; activeFilters?: ActiveFilter[] | null; totalRowCount?: number; filteredRowCount?: number; enableDrillDown?: boolean; enableDrillThrough?: boolean; onAddRowField: (field: string) => void; onRemoveRowField: (field: string) => void; onAddColumnField: (field: string) => void; onRemoveColumnField: (field: string) => void; onAddValueField: (field: string, aggregation: AggregationFunction) => void; onRemoveValueField: (field: string, aggregation: AggregationFunction) => void; onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void; onReorderRowFields: (fields: string[]) => void; onReorderColumnFields: (fields: string[]) => void; onToggleCollapse?: (key: string, altKey: boolean) => void; onDrillThroughCell?: (payload: { rowPath: string[]; columnPath: string[]; valueFieldIndex: number; }) => void; theme?: string; pivotLayout?: PivotLayout; } declare function PivotSkeleton({ rowFields, columnFields, valueFields, calculatedFields, isConfigured, draggingField, pivotResult, hasActiveFieldFilters, fontSize, activeFilters, totalRowCount, filteredRowCount, enableDrillDown, enableDrillThrough, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, onReorderRowFields, onReorderColumnFields, onToggleCollapse, onDrillThroughCell, theme, pivotLayout, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element; interface UseAIAnalystOptions { config: AIAnalystConfig; onDataLoaded?: (event: AIDataLoadedEvent) => void; onConversationUpdate?: (event: AIConversationUpdateEvent) => void; onQueryExecuted?: (event: AIQueryExecutedEvent) => void; onError?: (event: AIErrorEvent) => void; } declare function useAIAnalyst(options: UseAIAnalystOptions): { conversation: AIConversation; messages: _smallwebco_tinypivot_core.AIMessage[]; hasMessages: boolean; schemas: Map; isLoading: boolean; isLoadingTables: boolean; error: string | null; lastLoadedData: Record[] | null; selectedDataSource: string | undefined; selectedDataSourceInfo: AIDataSource | undefined; /** Available data sources (either from config or auto-discovered) */ dataSources: AIDataSource[]; selectDataSource: (dataSourceId: string) => Promise; sendMessage: (content: string) => Promise; clearConversation: () => void; exportConversation: () => AIConversation; importConversation: (conv: AIConversation) => void; /** Refresh table list from endpoint */ fetchTables: () => Promise; /** Load full data for the currently selected data source */ loadFullData: () => Promise[] | null>; }; interface ExcelGridOptions { data: T[]; columns?: string[]; enableSorting?: boolean; enableFiltering?: boolean; pageSize?: number; } /** * Excel-like grid hook */ declare function useExcelGrid>(options: ExcelGridOptions): { table: _tanstack_react_table.Table; sorting: SortingState; columnFilters: ColumnFiltersState; columnVisibility: VisibilityState; globalFilter: string; columnKeys: string[]; setSorting: react.Dispatch>; setColumnFilters: react.Dispatch>; setGlobalFilter: react.Dispatch>; filteredRowCount: number; totalRowCount: number; activeFilters: ({ column: string; type: "range"; range: NumericRange; dateRange: DateRange | null; values: string[]; } | { column: string; type: "dateRange"; range: NumericRange | null; dateRange: DateRange; values: string[]; } | { column: string; type: "values"; values: string[]; range: NumericRange | null; dateRange: DateRange | null; })[]; getColumnStats: (columnKey: string) => ColumnStats; clearStatsCache: () => void; hasActiveFilter: (columnId: string) => boolean; setColumnFilter: (columnId: string, values: string[]) => void; getColumnFilterValues: (columnId: string) => string[]; clearAllFilters: () => void; toggleSort: (columnId: string) => void; getSortDirection: (columnId: string) => 'asc' | 'desc' | null; setNumericRangeFilter: (columnId: string, range: NumericRange | null) => void; getNumericRangeFilter: (columnId: string) => NumericRange | null; setDateRangeFilter: (columnId: string, range: DateRange | null) => void; getDateRangeFilter: (columnId: string) => DateRange | null; }; declare function exportToCSV>(data: T[], columns: string[], options?: ExportOptions): void; declare function exportPivotToCSV(pivotData: PivotExportData, rowFields: string[], columnFields: string[], valueFields: PivotValueField[], options?: ExportOptions): void; declare function exportToXLSX>(data: T[], columns: string[], options?: XlsxExportOptions): Promise; declare function exportPivotToXLSX(pivotData: PivotExportData, rowFields: string[], columnFields: string[], valueFields: PivotValueField[], options?: XlsxExportOptions, sourceData?: SourceData): Promise; declare function copyToClipboard(text: string, onSuccess?: () => void, onError?: (err: Error) => void): void; declare function formatSelectionForClipboard>(rows: T[], columns: string[], selectionBounds: SelectionBounds): string; /** * Pagination hook */ declare function usePagination(data: T[], options?: PaginationOptions): { pageSize: number; currentPage: number; totalPages: number; paginatedData: T[]; startIndex: number; endIndex: number; goToPage: (page: number) => void; nextPage: () => void; prevPage: () => void; firstPage: () => void; lastPage: () => void; setPageSize: (size: number) => void; }; /** * Global search/filter hook */ declare function useGlobalSearch>(data: T[], columns: string[]): { searchTerm: string; setSearchTerm: react.Dispatch>; caseSensitive: boolean; setCaseSensitive: react.Dispatch>; filteredData: T[]; clearSearch: () => void; }; /** * Row selection hook */ declare function useRowSelection(data: T[]): { selectedRowIndices: Set; selectedRows: T[]; allSelected: boolean; someSelected: boolean; toggleRow: (index: number) => void; selectRow: (index: number) => void; deselectRow: (index: number) => void; selectAll: () => void; deselectAll: () => void; toggleAll: () => void; isSelected: (index: number) => boolean; selectRange: (startIndex: number, endIndex: number) => void; }; /** * Column resizing hook */ declare function useColumnResize(initialWidths: Record, minWidth?: number, maxWidth?: number): { columnWidths: Record; setColumnWidths: react.Dispatch>>; isResizing: boolean; resizingColumn: string | null; startResize: (columnId: string, event: React.MouseEvent) => void; resetColumnWidth: (columnId: string) => void; resetAllWidths: () => void; }; /** * Set the license key for the library */ declare function setLicenseKey(key: string): Promise; /** * Enable demo mode - requires the correct demo secret * Returns true if activation succeeded, false if secret was invalid */ declare function enableDemoMode(secret: string): Promise; /** * Configure the license secret */ declare function configureLicenseSecret(secret: string): void; /** * Hook for accessing license information */ declare function useLicense(): { licenseInfo: LicenseInfo; isDemo: boolean; isPro: boolean; canUsePivot: boolean; canUseAdvancedAggregations: boolean; canUsePercentageMode: boolean; canUseCharts: boolean; canUseAIAnalyst: boolean; canUseXlsxExport: boolean; showWatermark: boolean; requirePro: (feature: string) => boolean; }; interface UsePivotTableReturn { rowFields: string[]; columnFields: string[]; valueFields: PivotValueField[]; showRowTotals: boolean; showColumnTotals: boolean; calculatedFields: CalculatedField[]; collapsedPaths: Set; fieldFilters: Record; availableFields: FieldStats[]; unassignedFields: FieldStats[]; isConfigured: boolean; activeFieldFilters: Record; pivotResult: PivotResult | null; addRowField: (field: string) => void; removeRowField: (field: string) => void; addColumnField: (field: string) => void; removeColumnField: (field: string) => void; addValueField: (field: string, aggregation?: AggregationFunction) => void; removeValueField: (field: string, aggregation?: AggregationFunction) => void; updateValueFieldAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void; clearConfig: () => void; setShowRowTotals: (value: boolean) => void; setShowColumnTotals: (value: boolean) => void; autoSuggestConfig: () => void; setRowFields: (fields: string[]) => void; setColumnFields: (fields: string[]) => void; addCalculatedField: (field: CalculatedField) => void; removeCalculatedField: (id: string) => void; toggleCollapsedPath: (key: string, altKey: boolean, rowFields: string[], currentPivotResult: PivotResult | null) => Set; setFieldFilter: (field: string, excludedValues: string[]) => void; clearFieldFilter: (field: string) => void; } /** * Main pivot table hook */ declare function usePivotTable(data: Record[], enableDrillDown?: boolean): UsePivotTableReturn; export { AIAnalyst, ColumnFilter, DataGrid, PivotConfig, PivotSkeleton, type UseAIAnalystOptions, configureLicenseSecret, copyToClipboard, enableDemoMode, exportPivotToCSV, exportPivotToXLSX, exportToCSV, exportToXLSX, formatSelectionForClipboard, setLicenseKey, useAIAnalyst, useColumnResize, useExcelGrid, useGlobalSearch, useLicense, usePagination, usePivotTable, useRowSelection };