@smallwebco/tinypivot-react 1.0.0
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/LICENSE.md +78 -0
- package/dist/index.cjs +2773 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +269 -0
- package/dist/index.d.ts +269 -0
- package/dist/index.js +2755 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +70 -0
- package/dist/style.d.cts +2 -0
- package/dist/style.d.ts +2 -0
- package/package.json +51 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ColumnStats, FieldStats, PivotValueField, AggregationFunction, PivotResult, LicenseInfo, ExportOptions, PivotExportData, SelectionBounds, PaginationOptions } from '@smallwebco/tinypivot-core';
|
|
3
|
+
export { AggregationFunction, CellClickEvent, ColumnStats, CopyEvent, DataGridProps, ExportEvent, ExportOptions, FieldStats, FilterEvent, GridOptions, LicenseInfo, LicenseType, PaginationOptions, PivotCell, PivotConfig as PivotConfigType, PivotField, PivotResult, PivotTableProps, PivotValueField, RowSelectionChangeEvent, SelectionBounds, SelectionChangeEvent, SortEvent, formatCellValue, getAggregationLabel, getColumnUniqueValues } from '@smallwebco/tinypivot-core';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import react__default from 'react';
|
|
6
|
+
import * as _tanstack_react_table from '@tanstack/react-table';
|
|
7
|
+
import { SortingState, ColumnFiltersState, VisibilityState } from '@tanstack/react-table';
|
|
8
|
+
|
|
9
|
+
interface DataGridProps {
|
|
10
|
+
data: Record<string, unknown>[];
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
rowHeight?: number;
|
|
13
|
+
headerHeight?: number;
|
|
14
|
+
fontSize?: 'xs' | 'sm' | 'base';
|
|
15
|
+
showPivot?: boolean;
|
|
16
|
+
enableExport?: boolean;
|
|
17
|
+
enableSearch?: boolean;
|
|
18
|
+
enablePagination?: boolean;
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
enableColumnResize?: boolean;
|
|
21
|
+
enableClipboard?: boolean;
|
|
22
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
23
|
+
stripedRows?: boolean;
|
|
24
|
+
exportFilename?: string;
|
|
25
|
+
enableVerticalResize?: boolean;
|
|
26
|
+
initialHeight?: number;
|
|
27
|
+
minHeight?: number;
|
|
28
|
+
maxHeight?: number;
|
|
29
|
+
onCellClick?: (payload: {
|
|
30
|
+
row: number;
|
|
31
|
+
col: number;
|
|
32
|
+
value: unknown;
|
|
33
|
+
rowData: Record<string, unknown>;
|
|
34
|
+
}) => void;
|
|
35
|
+
onSelectionChange?: (payload: {
|
|
36
|
+
cells: Array<{
|
|
37
|
+
row: number;
|
|
38
|
+
col: number;
|
|
39
|
+
}>;
|
|
40
|
+
values: unknown[];
|
|
41
|
+
}) => void;
|
|
42
|
+
onExport?: (payload: {
|
|
43
|
+
rowCount: number;
|
|
44
|
+
filename: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
onCopy?: (payload: {
|
|
47
|
+
text: string;
|
|
48
|
+
cellCount: number;
|
|
49
|
+
}) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function DataGrid({ data, loading, fontSize: initialFontSize, showPivot, enableExport, enableSearch, enablePagination, pageSize, enableColumnResize, enableClipboard, theme, stripedRows, exportFilename, enableVerticalResize, initialHeight, minHeight, maxHeight, onCellClick, onExport, onCopy, }: DataGridProps): react_jsx_runtime.JSX.Element;
|
|
52
|
+
|
|
53
|
+
interface ColumnFilterProps {
|
|
54
|
+
columnId: string;
|
|
55
|
+
columnName: string;
|
|
56
|
+
stats: ColumnStats;
|
|
57
|
+
selectedValues: string[];
|
|
58
|
+
sortDirection: 'asc' | 'desc' | null;
|
|
59
|
+
onFilter: (values: string[]) => void;
|
|
60
|
+
onSort: (direction: 'asc' | 'desc' | null) => void;
|
|
61
|
+
onClose: () => void;
|
|
62
|
+
}
|
|
63
|
+
declare function ColumnFilter({ columnName, stats, selectedValues, sortDirection, onFilter, onSort, onClose, }: ColumnFilterProps): react_jsx_runtime.JSX.Element;
|
|
64
|
+
|
|
65
|
+
interface PivotConfigProps {
|
|
66
|
+
availableFields: FieldStats[];
|
|
67
|
+
rowFields: string[];
|
|
68
|
+
columnFields: string[];
|
|
69
|
+
valueFields: PivotValueField[];
|
|
70
|
+
showRowTotals: boolean;
|
|
71
|
+
showColumnTotals: boolean;
|
|
72
|
+
onShowRowTotalsChange: (value: boolean) => void;
|
|
73
|
+
onShowColumnTotalsChange: (value: boolean) => void;
|
|
74
|
+
onClearConfig: () => void;
|
|
75
|
+
onAutoSuggest: () => void;
|
|
76
|
+
onDragStart: (field: string, event: react__default.DragEvent) => void;
|
|
77
|
+
onDragEnd: () => void;
|
|
78
|
+
onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
79
|
+
onAddRowField: (field: string) => void;
|
|
80
|
+
onRemoveRowField: (field: string) => void;
|
|
81
|
+
onAddColumnField: (field: string) => void;
|
|
82
|
+
onRemoveColumnField: (field: string) => void;
|
|
83
|
+
onAddValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
84
|
+
onRemoveValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
85
|
+
}
|
|
86
|
+
declare function PivotConfig({ availableFields, rowFields, columnFields, valueFields, showRowTotals, onShowRowTotalsChange, onClearConfig, onAutoSuggest, onDragStart, onDragEnd, onUpdateAggregation, onRemoveRowField, onRemoveColumnField, onRemoveValueField, onAddRowField, onAddColumnField, }: PivotConfigProps): react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
88
|
+
interface ActiveFilter {
|
|
89
|
+
column: string;
|
|
90
|
+
valueCount: number;
|
|
91
|
+
values: string[];
|
|
92
|
+
}
|
|
93
|
+
interface PivotSkeletonProps {
|
|
94
|
+
rowFields: string[];
|
|
95
|
+
columnFields: string[];
|
|
96
|
+
valueFields: PivotValueField[];
|
|
97
|
+
isConfigured: boolean;
|
|
98
|
+
draggingField: string | null;
|
|
99
|
+
pivotResult: PivotResult | null;
|
|
100
|
+
fontSize?: 'xs' | 'sm' | 'base';
|
|
101
|
+
activeFilters?: ActiveFilter[] | null;
|
|
102
|
+
totalRowCount?: number;
|
|
103
|
+
filteredRowCount?: number;
|
|
104
|
+
onAddRowField: (field: string) => void;
|
|
105
|
+
onRemoveRowField: (field: string) => void;
|
|
106
|
+
onAddColumnField: (field: string) => void;
|
|
107
|
+
onRemoveColumnField: (field: string) => void;
|
|
108
|
+
onAddValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
109
|
+
onRemoveValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
110
|
+
onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
111
|
+
onReorderRowFields: (fields: string[]) => void;
|
|
112
|
+
onReorderColumnFields: (fields: string[]) => void;
|
|
113
|
+
}
|
|
114
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
interface ExcelGridOptions<T> {
|
|
117
|
+
data: T[];
|
|
118
|
+
columns?: string[];
|
|
119
|
+
enableSorting?: boolean;
|
|
120
|
+
enableFiltering?: boolean;
|
|
121
|
+
pageSize?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Excel-like grid hook
|
|
125
|
+
*/
|
|
126
|
+
declare function useExcelGrid<T extends Record<string, unknown>>(options: ExcelGridOptions<T>): {
|
|
127
|
+
table: _tanstack_react_table.Table<T>;
|
|
128
|
+
sorting: SortingState;
|
|
129
|
+
columnFilters: ColumnFiltersState;
|
|
130
|
+
columnVisibility: VisibilityState;
|
|
131
|
+
globalFilter: string;
|
|
132
|
+
columnKeys: string[];
|
|
133
|
+
setSorting: react.Dispatch<react.SetStateAction<SortingState>>;
|
|
134
|
+
setColumnFilters: react.Dispatch<react.SetStateAction<ColumnFiltersState>>;
|
|
135
|
+
setGlobalFilter: react.Dispatch<react.SetStateAction<string>>;
|
|
136
|
+
filteredRowCount: number;
|
|
137
|
+
totalRowCount: number;
|
|
138
|
+
activeFilters: {
|
|
139
|
+
column: string;
|
|
140
|
+
values: string[];
|
|
141
|
+
}[];
|
|
142
|
+
getColumnStats: (columnKey: string) => ColumnStats;
|
|
143
|
+
clearStatsCache: () => void;
|
|
144
|
+
hasActiveFilter: (columnId: string) => boolean;
|
|
145
|
+
setColumnFilter: (columnId: string, values: string[]) => void;
|
|
146
|
+
getColumnFilterValues: (columnId: string) => string[];
|
|
147
|
+
clearAllFilters: () => void;
|
|
148
|
+
toggleSort: (columnId: string) => void;
|
|
149
|
+
getSortDirection: (columnId: string) => 'asc' | 'desc' | null;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
interface UsePivotTableReturn {
|
|
153
|
+
rowFields: string[];
|
|
154
|
+
columnFields: string[];
|
|
155
|
+
valueFields: PivotValueField[];
|
|
156
|
+
showRowTotals: boolean;
|
|
157
|
+
showColumnTotals: boolean;
|
|
158
|
+
availableFields: FieldStats[];
|
|
159
|
+
unassignedFields: FieldStats[];
|
|
160
|
+
isConfigured: boolean;
|
|
161
|
+
pivotResult: PivotResult | null;
|
|
162
|
+
addRowField: (field: string) => void;
|
|
163
|
+
removeRowField: (field: string) => void;
|
|
164
|
+
addColumnField: (field: string) => void;
|
|
165
|
+
removeColumnField: (field: string) => void;
|
|
166
|
+
addValueField: (field: string, aggregation?: AggregationFunction) => void;
|
|
167
|
+
removeValueField: (field: string, aggregation?: AggregationFunction) => void;
|
|
168
|
+
updateValueFieldAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
169
|
+
clearConfig: () => void;
|
|
170
|
+
setShowRowTotals: (value: boolean) => void;
|
|
171
|
+
setShowColumnTotals: (value: boolean) => void;
|
|
172
|
+
autoSuggestConfig: () => void;
|
|
173
|
+
setRowFields: (fields: string[]) => void;
|
|
174
|
+
setColumnFields: (fields: string[]) => void;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Main pivot table hook
|
|
178
|
+
*/
|
|
179
|
+
declare function usePivotTable(data: Record<string, unknown>[]): UsePivotTableReturn;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set the license key for the library
|
|
183
|
+
*/
|
|
184
|
+
declare function setLicenseKey(key: string): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Enable demo mode
|
|
187
|
+
*/
|
|
188
|
+
declare function enableDemoMode(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Configure the license secret
|
|
191
|
+
*/
|
|
192
|
+
declare function configureLicenseSecret(secret: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Hook for accessing license information
|
|
195
|
+
*/
|
|
196
|
+
declare function useLicense(): {
|
|
197
|
+
licenseInfo: LicenseInfo;
|
|
198
|
+
isDemo: boolean;
|
|
199
|
+
isPro: boolean;
|
|
200
|
+
canUsePivot: boolean;
|
|
201
|
+
canUseAdvancedAggregations: boolean;
|
|
202
|
+
canUsePercentageMode: boolean;
|
|
203
|
+
showWatermark: boolean;
|
|
204
|
+
requirePro: (feature: string) => boolean;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
declare function exportToCSV<T extends Record<string, unknown>>(data: T[], columns: string[], options?: ExportOptions): void;
|
|
208
|
+
declare function exportPivotToCSV(pivotData: PivotExportData, rowFields: string[], columnFields: string[], valueFields: PivotValueField[], options?: ExportOptions): void;
|
|
209
|
+
declare function copyToClipboard(text: string, onSuccess?: () => void, onError?: (err: Error) => void): void;
|
|
210
|
+
declare function formatSelectionForClipboard<T extends Record<string, unknown>>(rows: T[], columns: string[], selectionBounds: SelectionBounds): string;
|
|
211
|
+
/**
|
|
212
|
+
* Pagination hook
|
|
213
|
+
*/
|
|
214
|
+
declare function usePagination<T>(data: T[], options?: PaginationOptions): {
|
|
215
|
+
pageSize: number;
|
|
216
|
+
currentPage: number;
|
|
217
|
+
totalPages: number;
|
|
218
|
+
paginatedData: T[];
|
|
219
|
+
startIndex: number;
|
|
220
|
+
endIndex: number;
|
|
221
|
+
goToPage: (page: number) => void;
|
|
222
|
+
nextPage: () => void;
|
|
223
|
+
prevPage: () => void;
|
|
224
|
+
firstPage: () => void;
|
|
225
|
+
lastPage: () => void;
|
|
226
|
+
setPageSize: (size: number) => void;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Global search/filter hook
|
|
230
|
+
*/
|
|
231
|
+
declare function useGlobalSearch<T extends Record<string, unknown>>(data: T[], columns: string[]): {
|
|
232
|
+
searchTerm: string;
|
|
233
|
+
setSearchTerm: react.Dispatch<react.SetStateAction<string>>;
|
|
234
|
+
caseSensitive: boolean;
|
|
235
|
+
setCaseSensitive: react.Dispatch<react.SetStateAction<boolean>>;
|
|
236
|
+
filteredData: T[];
|
|
237
|
+
clearSearch: () => void;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Row selection hook
|
|
241
|
+
*/
|
|
242
|
+
declare function useRowSelection<T>(data: T[]): {
|
|
243
|
+
selectedRowIndices: Set<number>;
|
|
244
|
+
selectedRows: T[];
|
|
245
|
+
allSelected: boolean;
|
|
246
|
+
someSelected: boolean;
|
|
247
|
+
toggleRow: (index: number) => void;
|
|
248
|
+
selectRow: (index: number) => void;
|
|
249
|
+
deselectRow: (index: number) => void;
|
|
250
|
+
selectAll: () => void;
|
|
251
|
+
deselectAll: () => void;
|
|
252
|
+
toggleAll: () => void;
|
|
253
|
+
isSelected: (index: number) => boolean;
|
|
254
|
+
selectRange: (startIndex: number, endIndex: number) => void;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Column resizing hook
|
|
258
|
+
*/
|
|
259
|
+
declare function useColumnResize(initialWidths: Record<string, number>, minWidth?: number, maxWidth?: number): {
|
|
260
|
+
columnWidths: Record<string, number>;
|
|
261
|
+
setColumnWidths: react.Dispatch<react.SetStateAction<Record<string, number>>>;
|
|
262
|
+
isResizing: boolean;
|
|
263
|
+
resizingColumn: string | null;
|
|
264
|
+
startResize: (columnId: string, event: React.MouseEvent) => void;
|
|
265
|
+
resetColumnWidth: (columnId: string) => void;
|
|
266
|
+
resetAllWidths: () => void;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { ColumnFilter, DataGrid, PivotConfig, PivotSkeleton, configureLicenseSecret, copyToClipboard, enableDemoMode, exportPivotToCSV, exportToCSV, formatSelectionForClipboard, setLicenseKey, useColumnResize, useExcelGrid, useGlobalSearch, useLicense, usePagination, usePivotTable, useRowSelection };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ColumnStats, FieldStats, PivotValueField, AggregationFunction, PivotResult, LicenseInfo, ExportOptions, PivotExportData, SelectionBounds, PaginationOptions } from '@smallwebco/tinypivot-core';
|
|
3
|
+
export { AggregationFunction, CellClickEvent, ColumnStats, CopyEvent, DataGridProps, ExportEvent, ExportOptions, FieldStats, FilterEvent, GridOptions, LicenseInfo, LicenseType, PaginationOptions, PivotCell, PivotConfig as PivotConfigType, PivotField, PivotResult, PivotTableProps, PivotValueField, RowSelectionChangeEvent, SelectionBounds, SelectionChangeEvent, SortEvent, formatCellValue, getAggregationLabel, getColumnUniqueValues } from '@smallwebco/tinypivot-core';
|
|
4
|
+
import * as react from 'react';
|
|
5
|
+
import react__default from 'react';
|
|
6
|
+
import * as _tanstack_react_table from '@tanstack/react-table';
|
|
7
|
+
import { SortingState, ColumnFiltersState, VisibilityState } from '@tanstack/react-table';
|
|
8
|
+
|
|
9
|
+
interface DataGridProps {
|
|
10
|
+
data: Record<string, unknown>[];
|
|
11
|
+
loading?: boolean;
|
|
12
|
+
rowHeight?: number;
|
|
13
|
+
headerHeight?: number;
|
|
14
|
+
fontSize?: 'xs' | 'sm' | 'base';
|
|
15
|
+
showPivot?: boolean;
|
|
16
|
+
enableExport?: boolean;
|
|
17
|
+
enableSearch?: boolean;
|
|
18
|
+
enablePagination?: boolean;
|
|
19
|
+
pageSize?: number;
|
|
20
|
+
enableColumnResize?: boolean;
|
|
21
|
+
enableClipboard?: boolean;
|
|
22
|
+
theme?: 'light' | 'dark' | 'auto';
|
|
23
|
+
stripedRows?: boolean;
|
|
24
|
+
exportFilename?: string;
|
|
25
|
+
enableVerticalResize?: boolean;
|
|
26
|
+
initialHeight?: number;
|
|
27
|
+
minHeight?: number;
|
|
28
|
+
maxHeight?: number;
|
|
29
|
+
onCellClick?: (payload: {
|
|
30
|
+
row: number;
|
|
31
|
+
col: number;
|
|
32
|
+
value: unknown;
|
|
33
|
+
rowData: Record<string, unknown>;
|
|
34
|
+
}) => void;
|
|
35
|
+
onSelectionChange?: (payload: {
|
|
36
|
+
cells: Array<{
|
|
37
|
+
row: number;
|
|
38
|
+
col: number;
|
|
39
|
+
}>;
|
|
40
|
+
values: unknown[];
|
|
41
|
+
}) => void;
|
|
42
|
+
onExport?: (payload: {
|
|
43
|
+
rowCount: number;
|
|
44
|
+
filename: string;
|
|
45
|
+
}) => void;
|
|
46
|
+
onCopy?: (payload: {
|
|
47
|
+
text: string;
|
|
48
|
+
cellCount: number;
|
|
49
|
+
}) => void;
|
|
50
|
+
}
|
|
51
|
+
declare function DataGrid({ data, loading, fontSize: initialFontSize, showPivot, enableExport, enableSearch, enablePagination, pageSize, enableColumnResize, enableClipboard, theme, stripedRows, exportFilename, enableVerticalResize, initialHeight, minHeight, maxHeight, onCellClick, onExport, onCopy, }: DataGridProps): react_jsx_runtime.JSX.Element;
|
|
52
|
+
|
|
53
|
+
interface ColumnFilterProps {
|
|
54
|
+
columnId: string;
|
|
55
|
+
columnName: string;
|
|
56
|
+
stats: ColumnStats;
|
|
57
|
+
selectedValues: string[];
|
|
58
|
+
sortDirection: 'asc' | 'desc' | null;
|
|
59
|
+
onFilter: (values: string[]) => void;
|
|
60
|
+
onSort: (direction: 'asc' | 'desc' | null) => void;
|
|
61
|
+
onClose: () => void;
|
|
62
|
+
}
|
|
63
|
+
declare function ColumnFilter({ columnName, stats, selectedValues, sortDirection, onFilter, onSort, onClose, }: ColumnFilterProps): react_jsx_runtime.JSX.Element;
|
|
64
|
+
|
|
65
|
+
interface PivotConfigProps {
|
|
66
|
+
availableFields: FieldStats[];
|
|
67
|
+
rowFields: string[];
|
|
68
|
+
columnFields: string[];
|
|
69
|
+
valueFields: PivotValueField[];
|
|
70
|
+
showRowTotals: boolean;
|
|
71
|
+
showColumnTotals: boolean;
|
|
72
|
+
onShowRowTotalsChange: (value: boolean) => void;
|
|
73
|
+
onShowColumnTotalsChange: (value: boolean) => void;
|
|
74
|
+
onClearConfig: () => void;
|
|
75
|
+
onAutoSuggest: () => void;
|
|
76
|
+
onDragStart: (field: string, event: react__default.DragEvent) => void;
|
|
77
|
+
onDragEnd: () => void;
|
|
78
|
+
onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
79
|
+
onAddRowField: (field: string) => void;
|
|
80
|
+
onRemoveRowField: (field: string) => void;
|
|
81
|
+
onAddColumnField: (field: string) => void;
|
|
82
|
+
onRemoveColumnField: (field: string) => void;
|
|
83
|
+
onAddValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
84
|
+
onRemoveValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
85
|
+
}
|
|
86
|
+
declare function PivotConfig({ availableFields, rowFields, columnFields, valueFields, showRowTotals, onShowRowTotalsChange, onClearConfig, onAutoSuggest, onDragStart, onDragEnd, onUpdateAggregation, onRemoveRowField, onRemoveColumnField, onRemoveValueField, onAddRowField, onAddColumnField, }: PivotConfigProps): react_jsx_runtime.JSX.Element;
|
|
87
|
+
|
|
88
|
+
interface ActiveFilter {
|
|
89
|
+
column: string;
|
|
90
|
+
valueCount: number;
|
|
91
|
+
values: string[];
|
|
92
|
+
}
|
|
93
|
+
interface PivotSkeletonProps {
|
|
94
|
+
rowFields: string[];
|
|
95
|
+
columnFields: string[];
|
|
96
|
+
valueFields: PivotValueField[];
|
|
97
|
+
isConfigured: boolean;
|
|
98
|
+
draggingField: string | null;
|
|
99
|
+
pivotResult: PivotResult | null;
|
|
100
|
+
fontSize?: 'xs' | 'sm' | 'base';
|
|
101
|
+
activeFilters?: ActiveFilter[] | null;
|
|
102
|
+
totalRowCount?: number;
|
|
103
|
+
filteredRowCount?: number;
|
|
104
|
+
onAddRowField: (field: string) => void;
|
|
105
|
+
onRemoveRowField: (field: string) => void;
|
|
106
|
+
onAddColumnField: (field: string) => void;
|
|
107
|
+
onRemoveColumnField: (field: string) => void;
|
|
108
|
+
onAddValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
109
|
+
onRemoveValueField: (field: string, aggregation: AggregationFunction) => void;
|
|
110
|
+
onUpdateAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
111
|
+
onReorderRowFields: (fields: string[]) => void;
|
|
112
|
+
onReorderColumnFields: (fields: string[]) => void;
|
|
113
|
+
}
|
|
114
|
+
declare function PivotSkeleton({ rowFields, columnFields, valueFields, isConfigured, draggingField, pivotResult, fontSize, activeFilters, totalRowCount, filteredRowCount, onAddRowField, onRemoveRowField, onAddColumnField, onRemoveColumnField, onAddValueField, onRemoveValueField, }: PivotSkeletonProps): react_jsx_runtime.JSX.Element;
|
|
115
|
+
|
|
116
|
+
interface ExcelGridOptions<T> {
|
|
117
|
+
data: T[];
|
|
118
|
+
columns?: string[];
|
|
119
|
+
enableSorting?: boolean;
|
|
120
|
+
enableFiltering?: boolean;
|
|
121
|
+
pageSize?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Excel-like grid hook
|
|
125
|
+
*/
|
|
126
|
+
declare function useExcelGrid<T extends Record<string, unknown>>(options: ExcelGridOptions<T>): {
|
|
127
|
+
table: _tanstack_react_table.Table<T>;
|
|
128
|
+
sorting: SortingState;
|
|
129
|
+
columnFilters: ColumnFiltersState;
|
|
130
|
+
columnVisibility: VisibilityState;
|
|
131
|
+
globalFilter: string;
|
|
132
|
+
columnKeys: string[];
|
|
133
|
+
setSorting: react.Dispatch<react.SetStateAction<SortingState>>;
|
|
134
|
+
setColumnFilters: react.Dispatch<react.SetStateAction<ColumnFiltersState>>;
|
|
135
|
+
setGlobalFilter: react.Dispatch<react.SetStateAction<string>>;
|
|
136
|
+
filteredRowCount: number;
|
|
137
|
+
totalRowCount: number;
|
|
138
|
+
activeFilters: {
|
|
139
|
+
column: string;
|
|
140
|
+
values: string[];
|
|
141
|
+
}[];
|
|
142
|
+
getColumnStats: (columnKey: string) => ColumnStats;
|
|
143
|
+
clearStatsCache: () => void;
|
|
144
|
+
hasActiveFilter: (columnId: string) => boolean;
|
|
145
|
+
setColumnFilter: (columnId: string, values: string[]) => void;
|
|
146
|
+
getColumnFilterValues: (columnId: string) => string[];
|
|
147
|
+
clearAllFilters: () => void;
|
|
148
|
+
toggleSort: (columnId: string) => void;
|
|
149
|
+
getSortDirection: (columnId: string) => 'asc' | 'desc' | null;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
interface UsePivotTableReturn {
|
|
153
|
+
rowFields: string[];
|
|
154
|
+
columnFields: string[];
|
|
155
|
+
valueFields: PivotValueField[];
|
|
156
|
+
showRowTotals: boolean;
|
|
157
|
+
showColumnTotals: boolean;
|
|
158
|
+
availableFields: FieldStats[];
|
|
159
|
+
unassignedFields: FieldStats[];
|
|
160
|
+
isConfigured: boolean;
|
|
161
|
+
pivotResult: PivotResult | null;
|
|
162
|
+
addRowField: (field: string) => void;
|
|
163
|
+
removeRowField: (field: string) => void;
|
|
164
|
+
addColumnField: (field: string) => void;
|
|
165
|
+
removeColumnField: (field: string) => void;
|
|
166
|
+
addValueField: (field: string, aggregation?: AggregationFunction) => void;
|
|
167
|
+
removeValueField: (field: string, aggregation?: AggregationFunction) => void;
|
|
168
|
+
updateValueFieldAggregation: (field: string, oldAgg: AggregationFunction, newAgg: AggregationFunction) => void;
|
|
169
|
+
clearConfig: () => void;
|
|
170
|
+
setShowRowTotals: (value: boolean) => void;
|
|
171
|
+
setShowColumnTotals: (value: boolean) => void;
|
|
172
|
+
autoSuggestConfig: () => void;
|
|
173
|
+
setRowFields: (fields: string[]) => void;
|
|
174
|
+
setColumnFields: (fields: string[]) => void;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Main pivot table hook
|
|
178
|
+
*/
|
|
179
|
+
declare function usePivotTable(data: Record<string, unknown>[]): UsePivotTableReturn;
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Set the license key for the library
|
|
183
|
+
*/
|
|
184
|
+
declare function setLicenseKey(key: string): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Enable demo mode
|
|
187
|
+
*/
|
|
188
|
+
declare function enableDemoMode(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Configure the license secret
|
|
191
|
+
*/
|
|
192
|
+
declare function configureLicenseSecret(secret: string): void;
|
|
193
|
+
/**
|
|
194
|
+
* Hook for accessing license information
|
|
195
|
+
*/
|
|
196
|
+
declare function useLicense(): {
|
|
197
|
+
licenseInfo: LicenseInfo;
|
|
198
|
+
isDemo: boolean;
|
|
199
|
+
isPro: boolean;
|
|
200
|
+
canUsePivot: boolean;
|
|
201
|
+
canUseAdvancedAggregations: boolean;
|
|
202
|
+
canUsePercentageMode: boolean;
|
|
203
|
+
showWatermark: boolean;
|
|
204
|
+
requirePro: (feature: string) => boolean;
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
declare function exportToCSV<T extends Record<string, unknown>>(data: T[], columns: string[], options?: ExportOptions): void;
|
|
208
|
+
declare function exportPivotToCSV(pivotData: PivotExportData, rowFields: string[], columnFields: string[], valueFields: PivotValueField[], options?: ExportOptions): void;
|
|
209
|
+
declare function copyToClipboard(text: string, onSuccess?: () => void, onError?: (err: Error) => void): void;
|
|
210
|
+
declare function formatSelectionForClipboard<T extends Record<string, unknown>>(rows: T[], columns: string[], selectionBounds: SelectionBounds): string;
|
|
211
|
+
/**
|
|
212
|
+
* Pagination hook
|
|
213
|
+
*/
|
|
214
|
+
declare function usePagination<T>(data: T[], options?: PaginationOptions): {
|
|
215
|
+
pageSize: number;
|
|
216
|
+
currentPage: number;
|
|
217
|
+
totalPages: number;
|
|
218
|
+
paginatedData: T[];
|
|
219
|
+
startIndex: number;
|
|
220
|
+
endIndex: number;
|
|
221
|
+
goToPage: (page: number) => void;
|
|
222
|
+
nextPage: () => void;
|
|
223
|
+
prevPage: () => void;
|
|
224
|
+
firstPage: () => void;
|
|
225
|
+
lastPage: () => void;
|
|
226
|
+
setPageSize: (size: number) => void;
|
|
227
|
+
};
|
|
228
|
+
/**
|
|
229
|
+
* Global search/filter hook
|
|
230
|
+
*/
|
|
231
|
+
declare function useGlobalSearch<T extends Record<string, unknown>>(data: T[], columns: string[]): {
|
|
232
|
+
searchTerm: string;
|
|
233
|
+
setSearchTerm: react.Dispatch<react.SetStateAction<string>>;
|
|
234
|
+
caseSensitive: boolean;
|
|
235
|
+
setCaseSensitive: react.Dispatch<react.SetStateAction<boolean>>;
|
|
236
|
+
filteredData: T[];
|
|
237
|
+
clearSearch: () => void;
|
|
238
|
+
};
|
|
239
|
+
/**
|
|
240
|
+
* Row selection hook
|
|
241
|
+
*/
|
|
242
|
+
declare function useRowSelection<T>(data: T[]): {
|
|
243
|
+
selectedRowIndices: Set<number>;
|
|
244
|
+
selectedRows: T[];
|
|
245
|
+
allSelected: boolean;
|
|
246
|
+
someSelected: boolean;
|
|
247
|
+
toggleRow: (index: number) => void;
|
|
248
|
+
selectRow: (index: number) => void;
|
|
249
|
+
deselectRow: (index: number) => void;
|
|
250
|
+
selectAll: () => void;
|
|
251
|
+
deselectAll: () => void;
|
|
252
|
+
toggleAll: () => void;
|
|
253
|
+
isSelected: (index: number) => boolean;
|
|
254
|
+
selectRange: (startIndex: number, endIndex: number) => void;
|
|
255
|
+
};
|
|
256
|
+
/**
|
|
257
|
+
* Column resizing hook
|
|
258
|
+
*/
|
|
259
|
+
declare function useColumnResize(initialWidths: Record<string, number>, minWidth?: number, maxWidth?: number): {
|
|
260
|
+
columnWidths: Record<string, number>;
|
|
261
|
+
setColumnWidths: react.Dispatch<react.SetStateAction<Record<string, number>>>;
|
|
262
|
+
isResizing: boolean;
|
|
263
|
+
resizingColumn: string | null;
|
|
264
|
+
startResize: (columnId: string, event: React.MouseEvent) => void;
|
|
265
|
+
resetColumnWidth: (columnId: string) => void;
|
|
266
|
+
resetAllWidths: () => void;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
export { ColumnFilter, DataGrid, PivotConfig, PivotSkeleton, configureLicenseSecret, copyToClipboard, enableDemoMode, exportPivotToCSV, exportToCSV, formatSelectionForClipboard, setLicenseKey, useColumnResize, useExcelGrid, useGlobalSearch, useLicense, usePagination, usePivotTable, useRowSelection };
|