react-kd-grid 5.0.3 → 5.0.8
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/components/ui/CustomSelect.d.ts +14 -0
- package/dist/components/ui/Popover.d.ts +17 -0
- package/dist/grid/components/Filters/BooleanFilter.d.ts +7 -0
- package/dist/grid/components/Filters/DateFilter.d.ts +9 -0
- package/dist/grid/components/Filters/FilterContent.d.ts +9 -0
- package/dist/grid/components/Filters/FilterPopup.d.ts +2 -0
- package/dist/grid/components/Filters/MultiselectFilter.d.ts +10 -0
- package/dist/grid/components/Filters/NumberFilter.d.ts +9 -0
- package/dist/grid/components/Filters/TextFilter.d.ts +8 -0
- package/dist/grid/components/Filters/index.d.ts +6 -0
- package/dist/grid/components/Popovers/BulkActionPopover.d.ts +17 -0
- package/dist/grid/components/Popovers/ColumnVisibilityPopover.d.ts +35 -0
- package/dist/grid/components/Popovers/ExportPopover.d.ts +18 -0
- package/dist/grid/components/Popovers/FilterPopover.d.ts +29 -0
- package/dist/grid/components/Popovers/SettingsPopover.d.ts +17 -0
- package/dist/grid/components/Shared/CellEditor.d.ts +23 -0
- package/dist/grid/components/Shared/ColumnFilterSelector.d.ts +18 -0
- package/dist/grid/components/Shared/FooterAggregate.d.ts +16 -0
- package/dist/grid/components/Shared/GridHeader.d.ts +39 -0
- package/dist/grid/components/Shared/GridRows.d.ts +53 -0
- package/dist/grid/components/Shared/GroupBar.d.ts +12 -0
- package/dist/grid/components/Shared/GroupHeader.d.ts +29 -0
- package/dist/grid/components/Shared/LicenseError.d.ts +9 -0
- package/dist/grid/components/Shared/NoDataMessage.d.ts +11 -0
- package/dist/grid/components/Shared/PaginationControls.d.ts +18 -0
- package/dist/grid/components/Shared/RowContextMenu.d.ts +18 -0
- package/dist/grid/components/Toolbar/Toolbar.d.ts +70 -0
- package/dist/grid/constants/index.d.ts +1 -0
- package/dist/grid/constants/toolbar.d.ts +17 -0
- package/dist/grid/core/DataGrid.d.ts +3 -0
- package/dist/grid/core/GridBodyContainer.d.ts +83 -0
- package/dist/grid/core/GridFooterContainer.d.ts +23 -0
- package/dist/grid/core/GridToolbarContainer.d.ts +48 -0
- package/dist/grid/hooks/toolbar/useColumnDnD.d.ts +28 -0
- package/dist/grid/hooks/toolbar/useToolbarMenus.d.ts +29 -0
- package/dist/grid/hooks/useAdvancedFiltering.d.ts +18 -0
- package/dist/grid/hooks/useCellSelection.d.ts +67 -0
- package/dist/grid/hooks/useColumnState.d.ts +52 -0
- package/dist/grid/hooks/useDataWorker.d.ts +11 -0
- package/dist/grid/hooks/useEditingCell.d.ts +49 -0
- package/dist/grid/hooks/useExport.d.ts +14 -0
- package/dist/grid/hooks/useGridDataMaps.d.ts +17 -0
- package/dist/grid/hooks/useGridMethods.d.ts +20 -0
- package/dist/grid/hooks/useGrouping.d.ts +28 -0
- package/dist/grid/hooks/useHorizontalVirtualization.d.ts +18 -0
- package/dist/grid/hooks/useInfiniteScroll.d.ts +31 -0
- package/dist/grid/hooks/useLoadingBar.d.ts +21 -0
- package/dist/grid/hooks/usePagination.d.ts +28 -0
- package/dist/grid/hooks/useScrollSync.d.ts +29 -0
- package/dist/grid/hooks/useSelection.d.ts +13 -0
- package/dist/grid/hooks/useVirtualization.d.ts +17 -0
- package/dist/grid/types.d.ts +570 -0
- package/dist/grid/utils/dateUtils.d.ts +16 -0
- package/dist/grid/utils/highlightText.d.ts +15 -0
- package/dist/grid/utils/license.d.ts +3 -0
- package/dist/index.d.ts +21 -12
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { RefObject } from "react";
|
|
2
|
+
import type { GridColumn, GridRow, SortConfig, ColumnFilterValue } from "../types";
|
|
3
|
+
interface GridBodyContainerProps {
|
|
4
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
5
|
+
flatRows: any[];
|
|
6
|
+
columnsWithWidths: any[];
|
|
7
|
+
visibleColumns: any[];
|
|
8
|
+
totalWidth: number;
|
|
9
|
+
selectable: boolean;
|
|
10
|
+
dataToDisplay: any[];
|
|
11
|
+
pinnedAll: any[];
|
|
12
|
+
effectivePinnedColumns: Set<string>;
|
|
13
|
+
hvPadLeftMemo: number;
|
|
14
|
+
hvPadRightMemo: number;
|
|
15
|
+
resolvedHeaderHeight: number;
|
|
16
|
+
sortConfig: SortConfig;
|
|
17
|
+
columnFilters: Record<string, ColumnFilterValue | null>;
|
|
18
|
+
selectedRows: Set<string | number>;
|
|
19
|
+
data: any[];
|
|
20
|
+
handleSort: (key: string) => void;
|
|
21
|
+
setColumnFilter: (key: string, filter: ColumnFilterValue | null) => void;
|
|
22
|
+
handleSelectAll: (checked: boolean) => void;
|
|
23
|
+
handleColumnResize: (columnKey: string, width: number) => void;
|
|
24
|
+
handleColumnPin: (columnKey: string, pinned: boolean) => void;
|
|
25
|
+
addGroupKey: (key: string) => void;
|
|
26
|
+
removeGroupKey: (key: string) => void;
|
|
27
|
+
handleGroupBy: (columnKey: string) => void;
|
|
28
|
+
autosizeColumn: (columnKey: string) => void;
|
|
29
|
+
autosizeAllColumns: () => void;
|
|
30
|
+
resetColumns: () => void;
|
|
31
|
+
columnOrder: string[];
|
|
32
|
+
setColumnOrder: React.Dispatch<React.SetStateAction<string[]>>;
|
|
33
|
+
pagination: any;
|
|
34
|
+
minResizeWidth?: number;
|
|
35
|
+
effectiveVirtualized: boolean;
|
|
36
|
+
virtualizedRange: {
|
|
37
|
+
offsetY: number;
|
|
38
|
+
startIndex: number;
|
|
39
|
+
endIndex: number;
|
|
40
|
+
};
|
|
41
|
+
resolvedRowHeight: number;
|
|
42
|
+
visibleData: any[];
|
|
43
|
+
isRowSelectable?: (row: GridRow) => boolean;
|
|
44
|
+
handleRowSelect: (rowId: string | number, isSelected: boolean) => void;
|
|
45
|
+
rowStyle?: any;
|
|
46
|
+
globalFilter: string;
|
|
47
|
+
onContextMenu?: any;
|
|
48
|
+
onRowDoubleClick?: any;
|
|
49
|
+
onRowClick?: any;
|
|
50
|
+
onCellClick?: any;
|
|
51
|
+
onCellContextMenu?: any;
|
|
52
|
+
isCellFocused: (rowId: string | number, columnKey: string) => boolean;
|
|
53
|
+
isCellSelected: (rowId: string | number, columnKey: string) => boolean;
|
|
54
|
+
handleCellMouseDown: any;
|
|
55
|
+
handleCellMouseEnter: any;
|
|
56
|
+
contextMenuItems?: any;
|
|
57
|
+
getRowId?: any;
|
|
58
|
+
isEditing: (rowId: string | number, columnKey: string) => boolean;
|
|
59
|
+
startEdit: any;
|
|
60
|
+
commitEdit: any;
|
|
61
|
+
cancelEdit: any;
|
|
62
|
+
editingCell: any;
|
|
63
|
+
safeGetRowId: (r: any) => string | number;
|
|
64
|
+
toggleGroupExpansion: (groupKey: string) => void;
|
|
65
|
+
containerWidth: number;
|
|
66
|
+
groupConfig: any;
|
|
67
|
+
columns: GridColumn[];
|
|
68
|
+
renderGroupActions?: any;
|
|
69
|
+
groupFooterVariant: "chips" | "columns";
|
|
70
|
+
isValidLicense: boolean;
|
|
71
|
+
infiniteScroll: any;
|
|
72
|
+
sentinelRef: RefObject<HTMLDivElement>;
|
|
73
|
+
loading: boolean;
|
|
74
|
+
showLoader: boolean;
|
|
75
|
+
finishingLoader: boolean;
|
|
76
|
+
loaderTop: number;
|
|
77
|
+
noDataMessage?: string;
|
|
78
|
+
noDataRenderer?: any;
|
|
79
|
+
handleScroll: (e: React.UIEvent<HTMLDivElement>) => void;
|
|
80
|
+
cellSelectionEnabled: boolean;
|
|
81
|
+
}
|
|
82
|
+
export declare const GridBodyContainer: React.FC<GridBodyContainerProps>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { RefObject } from "react";
|
|
2
|
+
interface GridFooterContainerProps {
|
|
3
|
+
hasFooterAggregate: boolean;
|
|
4
|
+
footerScrollRef: RefObject<HTMLDivElement>;
|
|
5
|
+
forwardWheelToBody: (e: React.WheelEvent) => void;
|
|
6
|
+
totalWidth: number;
|
|
7
|
+
selectable: boolean;
|
|
8
|
+
resolvedRowHeight: number;
|
|
9
|
+
columnsWithWidths: any[];
|
|
10
|
+
flatRows: any[];
|
|
11
|
+
effectivePinnedColumns: Set<string>;
|
|
12
|
+
infiniteScroll: any;
|
|
13
|
+
paginationConfig: any;
|
|
14
|
+
isServerLoading: boolean;
|
|
15
|
+
selectedRowsCount: number;
|
|
16
|
+
data: any[];
|
|
17
|
+
filteredData: any[];
|
|
18
|
+
pagination: any;
|
|
19
|
+
handlePageChange: (page: number) => void;
|
|
20
|
+
handlePageSizeChange: (pageSize: number) => void;
|
|
21
|
+
}
|
|
22
|
+
export declare const GridFooterContainer: React.FC<GridFooterContainerProps>;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React, { ChangeEvent } from "react";
|
|
2
|
+
import type { GridColumn, ColumnFilterValue, Density } from "../types";
|
|
3
|
+
interface GridToolbarContainerProps {
|
|
4
|
+
showToolbar: boolean;
|
|
5
|
+
filterable: boolean;
|
|
6
|
+
globalFilter: string;
|
|
7
|
+
filteredDataLength: number;
|
|
8
|
+
totalDataLength: number;
|
|
9
|
+
paginationMode?: "client" | "server";
|
|
10
|
+
selectedRowsCount: number;
|
|
11
|
+
showExport: boolean;
|
|
12
|
+
columns: GridColumn[];
|
|
13
|
+
columnFilters: Record<string, ColumnFilterValue | null>;
|
|
14
|
+
columnVisibility: Record<string, boolean>;
|
|
15
|
+
onResetColumns: () => void;
|
|
16
|
+
exportOptions: {
|
|
17
|
+
enabled: boolean;
|
|
18
|
+
formats: any[];
|
|
19
|
+
filename: string;
|
|
20
|
+
onExport: (format: any, exportSelected: boolean) => void;
|
|
21
|
+
};
|
|
22
|
+
toolbarLeft?: React.ReactNode;
|
|
23
|
+
toolbarRight?: React.ReactNode;
|
|
24
|
+
onGlobalFilterChange: (e: ChangeEvent<HTMLInputElement>) => void;
|
|
25
|
+
onClearFilters: () => void;
|
|
26
|
+
onColumnFilter: (columnKey: string, filter: ColumnFilterValue | null) => void;
|
|
27
|
+
onColumnVisibilityChange: (columnKey: string, visible: boolean) => void;
|
|
28
|
+
columnOrder: string[];
|
|
29
|
+
onColumnOrderChange: (order: string[]) => void;
|
|
30
|
+
pinnedColumns: Set<string>;
|
|
31
|
+
onScrollToColumn: (columnKey: string) => void;
|
|
32
|
+
density: Density;
|
|
33
|
+
onDensityChange: (density: Density) => void;
|
|
34
|
+
showDensityControl: boolean;
|
|
35
|
+
groupable: boolean;
|
|
36
|
+
groupBarVisibility: "auto" | "visible" | "hidden";
|
|
37
|
+
groupConfig: {
|
|
38
|
+
columnKeys: string[];
|
|
39
|
+
expanded: Set<string>;
|
|
40
|
+
};
|
|
41
|
+
removeGroupKey: (key: string) => void;
|
|
42
|
+
setGroupKeys: (keys: string[]) => void;
|
|
43
|
+
addGroupKey: (key: string) => void;
|
|
44
|
+
collapseAllGroups: () => void;
|
|
45
|
+
expandAllGroups: () => void;
|
|
46
|
+
}
|
|
47
|
+
export declare const GridToolbarContainer: React.FC<GridToolbarContainerProps>;
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface Column {
|
|
2
|
+
key: string;
|
|
3
|
+
header: string;
|
|
4
|
+
}
|
|
5
|
+
interface UseColumnDnDProps {
|
|
6
|
+
columns: Column[];
|
|
7
|
+
columnOrder: string[];
|
|
8
|
+
pinnedColumns?: Set<string>;
|
|
9
|
+
onColumnOrderChange?: (order: string[]) => void;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* useColumnDnD
|
|
13
|
+
*
|
|
14
|
+
* Encapsulates the drag-and-drop logic for reordering columns within the toolbar menu.
|
|
15
|
+
* Previously, this logic was mixed with the rendering and menu state in SearchToolbar.tsx.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useColumnDnD({ columns, columnOrder, pinnedColumns, onColumnOrderChange, }: UseColumnDnDProps): {
|
|
18
|
+
draggingKey: string;
|
|
19
|
+
dragOver: {
|
|
20
|
+
key: string;
|
|
21
|
+
position: "before" | "after";
|
|
22
|
+
};
|
|
23
|
+
handleDragStart: (columnKey: string, e: React.DragEvent) => void;
|
|
24
|
+
handleDragOver: (targetKey: string, e: React.DragEvent) => void;
|
|
25
|
+
handleDrop: (targetKey: string) => void;
|
|
26
|
+
handleDragEnd: () => void;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useToolbarMenus
|
|
3
|
+
*
|
|
4
|
+
* Manages the visibility of various popover menus in the grid toolbar.
|
|
5
|
+
* Includes logic to close menus when clicking outside and handle specific cases like MUI DatePickers.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useToolbarMenus(): {
|
|
8
|
+
showExportMenu: boolean;
|
|
9
|
+
setShowExportMenu: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
10
|
+
showFilters: boolean;
|
|
11
|
+
setShowFilters: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
12
|
+
showBulkActionsMenu: boolean;
|
|
13
|
+
setShowBulkActionsMenu: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
14
|
+
showColumnMenu: boolean;
|
|
15
|
+
setShowColumnMenu: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
16
|
+
showSettingsMenu: boolean;
|
|
17
|
+
setShowSettingsMenu: import("react").Dispatch<import("react").SetStateAction<boolean>>;
|
|
18
|
+
exportMenuRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
19
|
+
bulkActionsRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
20
|
+
columnMenuRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
21
|
+
filtersMenuRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
22
|
+
settingsMenuRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
23
|
+
exportAnchorRef: import("react").MutableRefObject<HTMLButtonElement>;
|
|
24
|
+
bulkActionsAnchorRef: import("react").MutableRefObject<HTMLButtonElement>;
|
|
25
|
+
columnAnchorRef: import("react").MutableRefObject<HTMLButtonElement>;
|
|
26
|
+
filtersAnchorRef: import("react").MutableRefObject<HTMLButtonElement>;
|
|
27
|
+
settingsAnchorRef: import("react").MutableRefObject<HTMLButtonElement>;
|
|
28
|
+
closeAllMenus: () => void;
|
|
29
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { GridRow, GridColumn, ActiveFilters, ColumnFilterValue } from "../types";
|
|
2
|
+
interface UseAdvancedFilteringProps {
|
|
3
|
+
data: GridRow[];
|
|
4
|
+
columns: GridColumn[];
|
|
5
|
+
}
|
|
6
|
+
export declare const useAdvancedFiltering: ({ data, columns, }: UseAdvancedFilteringProps) => {
|
|
7
|
+
globalFilter: string;
|
|
8
|
+
setGlobalFilter: (value: string) => void;
|
|
9
|
+
columnFilters: ActiveFilters;
|
|
10
|
+
filteredData: GridRow[];
|
|
11
|
+
setColumnFilter: (columnKey: string, filter: ColumnFilterValue | null) => void;
|
|
12
|
+
clearColumnFilter: (columnKey: string) => void;
|
|
13
|
+
clearAllFilters: () => void;
|
|
14
|
+
getActiveFilterCount: () => number;
|
|
15
|
+
/** True while a filter transition is in-flight — use to show a loading indicator */
|
|
16
|
+
isFilterPending: boolean;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import type { CellFocusParams, CellSelectionPayload, CopyCellsPayload } from "../types";
|
|
3
|
+
interface CellCoord {
|
|
4
|
+
rowIndex: number;
|
|
5
|
+
colIndex: number;
|
|
6
|
+
}
|
|
7
|
+
interface FocusedCell {
|
|
8
|
+
rowId: string | number;
|
|
9
|
+
columnKey: string;
|
|
10
|
+
}
|
|
11
|
+
interface DragOverlay {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
rows: number;
|
|
15
|
+
cols: number;
|
|
16
|
+
}
|
|
17
|
+
interface UseCellSelectionProps {
|
|
18
|
+
cellFocusEnabled: boolean;
|
|
19
|
+
cellSelectionEnabled: boolean;
|
|
20
|
+
canSelectCell: (row: any, column: any) => boolean;
|
|
21
|
+
flatRows: any[];
|
|
22
|
+
columnsWithWidths: any[];
|
|
23
|
+
rowIndexById: Map<string | number, number>;
|
|
24
|
+
colIndexByKey: Map<string, number>;
|
|
25
|
+
rowById: Map<string | number, any>;
|
|
26
|
+
colByKey: Map<string, any>;
|
|
27
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
28
|
+
headerScrollRef: RefObject<HTMLDivElement>;
|
|
29
|
+
resolvedRowHeight: number;
|
|
30
|
+
selectable: boolean;
|
|
31
|
+
onCellFocusChange?: (params: CellFocusParams) => void;
|
|
32
|
+
onCellSelectionChange?: (payload: CellSelectionPayload) => void;
|
|
33
|
+
onCopyCells?: (payload: CopyCellsPayload) => void;
|
|
34
|
+
/** Stable column keys used to avoid dep on full column objects in effects */
|
|
35
|
+
columnKeys: string[];
|
|
36
|
+
/** Mirrors the grid-level getRowId — needed so focus/selection uses the correct key. */
|
|
37
|
+
getRowId?: (row: any) => string | number;
|
|
38
|
+
}
|
|
39
|
+
export interface UseCellSelectionReturn {
|
|
40
|
+
focusedCell: FocusedCell | null;
|
|
41
|
+
selectionAnchor: CellCoord | null;
|
|
42
|
+
selectionEnd: CellCoord | null;
|
|
43
|
+
dragOverlay: DragOverlay | null;
|
|
44
|
+
isCellSelected: (rowId: string | number, columnKey: string) => boolean;
|
|
45
|
+
isCellFocused: (rowId: string | number, columnKey: string) => boolean;
|
|
46
|
+
handleCellMouseDown: (params: {
|
|
47
|
+
row: any;
|
|
48
|
+
column: any;
|
|
49
|
+
event: any;
|
|
50
|
+
}) => void;
|
|
51
|
+
handleCellMouseEnter: (params: {
|
|
52
|
+
row: any;
|
|
53
|
+
column: any;
|
|
54
|
+
event: any;
|
|
55
|
+
}) => void;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Owns the entire cell focus + rectangular selection subsystem:
|
|
59
|
+
* - State: focusedCell, selectionAnchor, selectionEnd, dragOverlay
|
|
60
|
+
* - Mouse handlers: handleCellMouseDown, handleCellMouseEnter
|
|
61
|
+
* - Global effects: mouseup, mousemove, Shift+Arrow, keyboard focus nav
|
|
62
|
+
* - Auto-scroll RAF loop while dragging near scroll container edges
|
|
63
|
+
* - Ctrl/Cmd+C copy handler (Excel-compatible TSV output)
|
|
64
|
+
* - onCellSelectionChange callback (de-duped via signature ref)
|
|
65
|
+
*/
|
|
66
|
+
export declare const useCellSelection: ({ cellFocusEnabled, cellSelectionEnabled, canSelectCell, flatRows, columnsWithWidths, rowIndexById, colIndexByKey, rowById, colByKey, scrollRef, headerScrollRef, resolvedRowHeight, selectable, onCellFocusChange, onCellSelectionChange, onCopyCells, columnKeys, getRowId, }: UseCellSelectionProps) => UseCellSelectionReturn;
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { GridColumn, GridRow, ColumnConfig, ColumnFilterValue, Density, SortConfig } from "../types";
|
|
3
|
+
interface UseColumnStateProps {
|
|
4
|
+
columns: GridColumn[];
|
|
5
|
+
data: GridRow[];
|
|
6
|
+
initialColumnConfig?: Partial<ColumnConfig>;
|
|
7
|
+
onColumnConfigChange?: (config: ColumnConfig) => void;
|
|
8
|
+
setSortConfig: (config: SortConfig) => void;
|
|
9
|
+
setGroupKeys: (keys: string[]) => void;
|
|
10
|
+
setDensity: (density: Density) => void;
|
|
11
|
+
setGlobalFilter: (value: string) => void;
|
|
12
|
+
setColumnFilter: (key: string, filter: ColumnFilterValue) => void;
|
|
13
|
+
sortConfig: SortConfig;
|
|
14
|
+
groupConfig: {
|
|
15
|
+
columnKeys: string[];
|
|
16
|
+
};
|
|
17
|
+
globalFilter: string;
|
|
18
|
+
columnFilters: Record<string, ColumnFilterValue | null>;
|
|
19
|
+
density: Density;
|
|
20
|
+
containerWidth: number;
|
|
21
|
+
selectable: boolean;
|
|
22
|
+
}
|
|
23
|
+
export interface UseColumnStateReturn {
|
|
24
|
+
columnWidths: Record<string, number>;
|
|
25
|
+
columnOrder: string[];
|
|
26
|
+
pinnedColumns: Set<string>;
|
|
27
|
+
columnVisibility: Record<string, boolean>;
|
|
28
|
+
columnsWithWidths: any[];
|
|
29
|
+
pinnedAll: any[];
|
|
30
|
+
unpinnedAll: any[];
|
|
31
|
+
effectivePinnedColumns: Set<string>;
|
|
32
|
+
handleColumnResize: (columnKey: string, width: number) => void;
|
|
33
|
+
handleColumnPin: (columnKey: string, pinned: boolean) => void;
|
|
34
|
+
handleColumnVisibilityChange: (columnKey: string, visible: boolean) => void;
|
|
35
|
+
setColumnOrder: React.Dispatch<React.SetStateAction<string[]>>;
|
|
36
|
+
autosizeColumn: (columnKey: string) => void;
|
|
37
|
+
autosizeAllColumns: () => void;
|
|
38
|
+
resetColumns: () => void;
|
|
39
|
+
setColumnWidths: React.Dispatch<React.SetStateAction<Record<string, number>>>;
|
|
40
|
+
setPinnedColumns: React.Dispatch<React.SetStateAction<Set<string>>>;
|
|
41
|
+
setColumnVisibility: React.Dispatch<React.SetStateAction<Record<string, boolean>>>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Owns all column configuration state:
|
|
45
|
+
* - Column widths, order, pinning, visibility
|
|
46
|
+
* - Autosize (canvas-based measureText, with heuristic fallback)
|
|
47
|
+
* - Column config hydration from `initialColumnConfig` on mount
|
|
48
|
+
* - Debounced `onColumnConfigChange` emission
|
|
49
|
+
* - Calculation of resolved columnsWithWidths including flex-grow
|
|
50
|
+
*/
|
|
51
|
+
export declare const useColumnState: ({ columns, data, initialColumnConfig, onColumnConfigChange, setSortConfig, setGroupKeys, setDensity, setGlobalFilter, setColumnFilter, sortConfig, groupConfig, globalFilter, columnFilters, density, containerWidth, selectable, }: UseColumnStateProps) => UseColumnStateReturn;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
type SortCfg = {
|
|
2
|
+
key: string;
|
|
3
|
+
direction: "asc" | "desc";
|
|
4
|
+
} | null;
|
|
5
|
+
/** Lazily-created worker singleton per hook instance. */
|
|
6
|
+
export declare function useDataWorker(options?: {
|
|
7
|
+
enabled?: boolean;
|
|
8
|
+
}): {
|
|
9
|
+
process: (rows: any[], sort: SortCfg) => Promise<any[]>;
|
|
10
|
+
};
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useEditingCell
|
|
3
|
+
*
|
|
4
|
+
* Owns the lifecycle of an inline cell edit session:
|
|
5
|
+
* - Which cell is currently being edited (rowId + columnKey)
|
|
6
|
+
* - Starting an edit (triggered by double-click or F2)
|
|
7
|
+
* - Committing the edit and firing onCellEdit
|
|
8
|
+
* - Cancelling the edit
|
|
9
|
+
* - Keyboard F2 to open edit when a cell is focused (delegates from useCellSelection)
|
|
10
|
+
*
|
|
11
|
+
* Design: state is intentionally kept minimal. The *draft value* is owned by
|
|
12
|
+
* <CellEditor> because it needs to stay strictly local to the input DOM. This
|
|
13
|
+
* hook only needs to know *which* cell is open so GridRows can render the editor.
|
|
14
|
+
*/
|
|
15
|
+
import type { GridColumn, GridRow, CellEditParams } from "../types";
|
|
16
|
+
export interface EditingCell {
|
|
17
|
+
rowId: string | number;
|
|
18
|
+
columnKey: string;
|
|
19
|
+
/** Snapshot of the value at the moment editing started. */
|
|
20
|
+
initialValue: any;
|
|
21
|
+
row: GridRow;
|
|
22
|
+
column: GridColumn;
|
|
23
|
+
}
|
|
24
|
+
interface UseEditingCellProps {
|
|
25
|
+
getRowId: (row: GridRow) => string | number;
|
|
26
|
+
onCellEdit?: (params: CellEditParams) => void;
|
|
27
|
+
onCellEditStart?: (params: {
|
|
28
|
+
row: GridRow;
|
|
29
|
+
column: GridColumn;
|
|
30
|
+
value: any;
|
|
31
|
+
}) => boolean | void;
|
|
32
|
+
/** Currently focused cell (from useCellSelection) — used for F2 shortcut. */
|
|
33
|
+
focusedCell?: {
|
|
34
|
+
rowId: string | number;
|
|
35
|
+
columnKey: string;
|
|
36
|
+
} | null;
|
|
37
|
+
/** Full row-and-column lookup helpers for F2 shortcut. */
|
|
38
|
+
getRowById?: (rowId: string | number) => GridRow | undefined;
|
|
39
|
+
getColumnByKey?: (key: string) => GridColumn | undefined;
|
|
40
|
+
}
|
|
41
|
+
export interface UseEditingCellReturn {
|
|
42
|
+
editingCell: EditingCell | null;
|
|
43
|
+
startEdit: (row: GridRow, column: GridColumn) => void;
|
|
44
|
+
commitEdit: (newValue: any) => void;
|
|
45
|
+
cancelEdit: () => void;
|
|
46
|
+
isEditing: (rowId: string | number, columnKey: string) => boolean;
|
|
47
|
+
}
|
|
48
|
+
export declare const useEditingCell: ({ getRowId, onCellEdit, onCellEditStart, focusedCell, getRowById, getColumnByKey, }: UseEditingCellProps) => UseEditingCellReturn;
|
|
49
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GridRow, GridColumn, ExportFormat } from "../types";
|
|
2
|
+
interface UseExportProps {
|
|
3
|
+
data: GridRow[];
|
|
4
|
+
columns: GridColumn[];
|
|
5
|
+
selectedRows?: Set<string | number>;
|
|
6
|
+
filename?: string;
|
|
7
|
+
columnVisibility?: Record<string, boolean>;
|
|
8
|
+
}
|
|
9
|
+
export declare const useExport: ({ data, columns, selectedRows, filename, columnVisibility, }: UseExportProps) => {
|
|
10
|
+
exportData: (format: ExportFormat, exportSelected?: boolean) => void;
|
|
11
|
+
canExportSelected: boolean;
|
|
12
|
+
selectedCount: number;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { GridRow } from "../types";
|
|
2
|
+
interface UseGridDataMapsProps {
|
|
3
|
+
dataToDisplay: any[];
|
|
4
|
+
columnsWithWidths: any[];
|
|
5
|
+
getRowId?: (row: GridRow) => string | number;
|
|
6
|
+
}
|
|
7
|
+
export declare const useGridDataMaps: ({ dataToDisplay, columnsWithWidths, getRowId, }: UseGridDataMapsProps) => {
|
|
8
|
+
colIndexByKey: Map<string, number>;
|
|
9
|
+
colByKey: Map<string, any>;
|
|
10
|
+
flatRows: any[];
|
|
11
|
+
rowIndexById: Map<string | number, number>;
|
|
12
|
+
rowById: Map<string | number, any>;
|
|
13
|
+
totalWidth: any;
|
|
14
|
+
columnKeys: any[];
|
|
15
|
+
hasFooterAggregate: boolean;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
interface UseGridMethodsProps {
|
|
3
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
4
|
+
rowIndexById: Map<string | number, number>;
|
|
5
|
+
colIndexByKey: Map<string, number>;
|
|
6
|
+
columnsWithWidths: any[];
|
|
7
|
+
resolvedRowHeight: number;
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* useGridMethods
|
|
12
|
+
*
|
|
13
|
+
* Centralizes imperative grid operations like scrolling to specific rows or columns.
|
|
14
|
+
* This logic was previously duplicated in DataGrid.tsx and its sub-components.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useGridMethods({ scrollRef, rowIndexById, colIndexByKey, columnsWithWidths, resolvedRowHeight, selectable, }: UseGridMethodsProps): {
|
|
17
|
+
scrollToRow: (rowId: string | number) => void;
|
|
18
|
+
scrollToColumn: (columnKey: string) => void;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { GridRow, GroupConfig, GridColumn } from "../types";
|
|
2
|
+
interface UseGroupingProps {
|
|
3
|
+
data: GridRow[];
|
|
4
|
+
columns: GridColumn[];
|
|
5
|
+
}
|
|
6
|
+
export declare const useGrouping: ({ data, columns }: UseGroupingProps) => {
|
|
7
|
+
groupConfig: GroupConfig;
|
|
8
|
+
displayData: (GridRow & {
|
|
9
|
+
_isGroupHeader?: boolean;
|
|
10
|
+
_groupKey?: string;
|
|
11
|
+
_groupCount?: number;
|
|
12
|
+
_groupLevel?: number;
|
|
13
|
+
_groupColumnKey?: string;
|
|
14
|
+
_groupValue?: string;
|
|
15
|
+
_groupRows?: GridRow[];
|
|
16
|
+
_isGroupFooter?: boolean;
|
|
17
|
+
_groupAgg?: Record<string, any>;
|
|
18
|
+
})[];
|
|
19
|
+
handleGroupBy: (columnKey: string | null) => void;
|
|
20
|
+
addGroupKey: (columnKey: string) => void;
|
|
21
|
+
removeGroupKey: (columnKey: string) => void;
|
|
22
|
+
setGroupKeys: (columnKeys: string[]) => void;
|
|
23
|
+
toggleGroupExpansion: (groupPath: string) => void;
|
|
24
|
+
expandAllGroups: () => void;
|
|
25
|
+
collapseAllGroups: () => void;
|
|
26
|
+
isGrouped: boolean;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface UseHorizontalVirtualizationProps {
|
|
2
|
+
columnsWithWidths: any[];
|
|
3
|
+
pinnedAll: any[];
|
|
4
|
+
unpinnedAll: any[];
|
|
5
|
+
effectivePinnedColumns: Set<string>;
|
|
6
|
+
hScrollLeft: number;
|
|
7
|
+
viewportWidth: number;
|
|
8
|
+
selectable: boolean;
|
|
9
|
+
enableHorizontalVirtualization: boolean;
|
|
10
|
+
horizontalVirtualizationThreshold: number;
|
|
11
|
+
}
|
|
12
|
+
export declare const useHorizontalVirtualization: ({ columnsWithWidths, pinnedAll, unpinnedAll, effectivePinnedColumns, hScrollLeft, viewportWidth, selectable, enableHorizontalVirtualization, horizontalVirtualizationThreshold, }: UseHorizontalVirtualizationProps) => {
|
|
13
|
+
needsHorizontalVirtualization: boolean;
|
|
14
|
+
visibleColumns: any[];
|
|
15
|
+
hvPadLeftMemo: number;
|
|
16
|
+
hvPadRightMemo: number;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export interface UseInfiniteScrollOptions {
|
|
2
|
+
/** When false, the observer is disconnected entirely. */
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
/** Whether there are more rows to load. */
|
|
5
|
+
hasMore: boolean;
|
|
6
|
+
/** True while a fetch is in flight – prevents double-triggering. */
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
/** Called when the sentinel enters the viewport. */
|
|
9
|
+
onLoadMore: () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Pixels of extra root margin below the scroll viewport.
|
|
12
|
+
* A positive value means `onLoadMore` fires before the sentinel is
|
|
13
|
+
* fully visible (pre-fetch). Default: 200 px.
|
|
14
|
+
*/
|
|
15
|
+
threshold?: number;
|
|
16
|
+
/**
|
|
17
|
+
* The scrollable element that clips the sentinel.
|
|
18
|
+
* If not provided, defaults to the browser viewport.
|
|
19
|
+
*/
|
|
20
|
+
rootRef?: React.RefObject<Element | null>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Attaches an IntersectionObserver to a sentinel <div> placed at the
|
|
24
|
+
* bottom of the scrollable area. When the sentinel enters the viewport
|
|
25
|
+
* (plus the optional threshold), onLoadMore is called.
|
|
26
|
+
*
|
|
27
|
+
* @returns `sentinelRef` – attach this to a div at the bottom of the list.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useInfiniteScroll({ enabled, onLoadMore, threshold, rootRef, }: UseInfiniteScrollOptions): {
|
|
30
|
+
sentinelRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
31
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
interface UseLoadingBarProps {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
isServerLoading: boolean;
|
|
5
|
+
resolvedHeaderHeight: number;
|
|
6
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
7
|
+
containerRef: RefObject<HTMLElement>;
|
|
8
|
+
}
|
|
9
|
+
interface UseLoadingBarReturn {
|
|
10
|
+
showLoader: boolean;
|
|
11
|
+
finishingLoader: boolean;
|
|
12
|
+
loaderTop: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Manages the animated top loading bar state.
|
|
16
|
+
* - Tracks overall loading (prop + server)
|
|
17
|
+
* - Smooth 200 ms "finish" fade-out when loading completes
|
|
18
|
+
* - Positions the bar just below the sticky header via ResizeObserver
|
|
19
|
+
*/
|
|
20
|
+
export declare const useLoadingBar: ({ loading, isServerLoading, resolvedHeaderHeight, scrollRef, containerRef, }: UseLoadingBarProps) => UseLoadingBarReturn;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PaginationConfig, GridRow } from "../types";
|
|
2
|
+
interface UsePaginationProps {
|
|
3
|
+
data: GridRow[];
|
|
4
|
+
pagination?: {
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
mode?: "client" | "server";
|
|
7
|
+
pageSize?: number;
|
|
8
|
+
showPageSizeSelector?: boolean;
|
|
9
|
+
pageSizeOptions?: number[];
|
|
10
|
+
serverConfig?: {
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
onPageChange: (page: number, pageSize: number) => Promise<void> | void;
|
|
13
|
+
onPageSizeChange?: (pageSize: number) => Promise<void> | void;
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
totalRows: number;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export declare const usePagination: ({ data, pagination }: UsePaginationProps) => {
|
|
20
|
+
currentPage: number;
|
|
21
|
+
resetPage: () => void;
|
|
22
|
+
paginationConfig: PaginationConfig;
|
|
23
|
+
paginatedData: GridRow[];
|
|
24
|
+
isServerLoading: boolean;
|
|
25
|
+
handlePageChange: (page: number) => Promise<void>;
|
|
26
|
+
handlePageSizeChange: (newPageSize: number) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface UseScrollSyncProps {
|
|
4
|
+
scrollRef: RefObject<HTMLDivElement>;
|
|
5
|
+
footerScrollRef: RefObject<HTMLDivElement>;
|
|
6
|
+
hasFooterAggregate: boolean;
|
|
7
|
+
}
|
|
8
|
+
interface UseScrollSyncReturn {
|
|
9
|
+
/** Current horizontal scroll position of the body (RAF-throttled). */
|
|
10
|
+
hScrollLeft: number;
|
|
11
|
+
/** Current viewport width of the scroll container. */
|
|
12
|
+
viewportWidth: number;
|
|
13
|
+
/** Schedules a RAF-debounced update to hScrollLeft. */
|
|
14
|
+
scheduleHScrollUpdate: (value: number) => void;
|
|
15
|
+
/** Forwards horizontal wheel events from non-scrollable header/footer to the body. */
|
|
16
|
+
forwardWheelToBody: (e: React.WheelEvent<HTMLDivElement>) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Coordinates horizontal scroll state between the body scroll container,
|
|
20
|
+
* the sticky footer aggregate row, and the horizontal virtualisation system.
|
|
21
|
+
*
|
|
22
|
+
* Responsibilities:
|
|
23
|
+
* - RAF-throttled `hScrollLeft` state (used by horizontal virtualisation)
|
|
24
|
+
* - `viewportWidth` via ResizeObserver (used for visible column slicing)
|
|
25
|
+
* - Footer ↔ body scroll sync via an event listener
|
|
26
|
+
* - `forwardWheelToBody` for header/footer wheel events
|
|
27
|
+
*/
|
|
28
|
+
export declare const useScrollSync: ({ scrollRef, footerScrollRef, hasFooterAggregate, }: UseScrollSyncProps) => UseScrollSyncReturn;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GridRow } from "../types";
|
|
2
|
+
interface UseSelectionProps {
|
|
3
|
+
data: GridRow[];
|
|
4
|
+
selectedRowIds?: Iterable<string | number> | null;
|
|
5
|
+
onRowSelect?: (row: GridRow) => void;
|
|
6
|
+
getRowId?: (row: GridRow) => string | number;
|
|
7
|
+
}
|
|
8
|
+
export declare const useSelection: ({ data, selectedRowIds, onRowSelect, getRowId, }: UseSelectionProps) => {
|
|
9
|
+
selectedRows: Set<string | number>;
|
|
10
|
+
handleRowSelect: (rowId: string | number, isSelected: boolean) => void;
|
|
11
|
+
handleSelectAll: (isSelected: boolean) => void;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { UIEvent } from "react";
|
|
2
|
+
import { VirtualizedRange, GridRow } from "../types";
|
|
3
|
+
interface UseVirtualizationProps {
|
|
4
|
+
data: GridRow[];
|
|
5
|
+
virtualized?: boolean;
|
|
6
|
+
rowHeight?: number;
|
|
7
|
+
overscan?: number;
|
|
8
|
+
height: number;
|
|
9
|
+
}
|
|
10
|
+
export declare const useVirtualization: ({ data, virtualized, rowHeight, overscan, height, }: UseVirtualizationProps) => {
|
|
11
|
+
scrollRef: import("react").MutableRefObject<HTMLDivElement>;
|
|
12
|
+
virtualizedRange: VirtualizedRange;
|
|
13
|
+
visibleData: GridRow[];
|
|
14
|
+
totalHeight: number;
|
|
15
|
+
handleScroll: (e: UIEvent<HTMLDivElement>) => void;
|
|
16
|
+
};
|
|
17
|
+
export {};
|