react-kd-grid 5.0.2 → 5.0.4

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.
Files changed (82) hide show
  1. package/dist/components/SearchToolbar.d.ts +6 -2
  2. package/dist/components/toolbar/BulkActionPopover.d.ts +17 -0
  3. package/dist/components/toolbar/ColumnVisibilityPopover.d.ts +35 -0
  4. package/dist/components/toolbar/ExportPopover.d.ts +18 -0
  5. package/dist/components/toolbar/FilterPopover.d.ts +29 -0
  6. package/dist/components/toolbar/SettingsPopover.d.ts +17 -0
  7. package/dist/components/ui/Button.d.ts +11 -0
  8. package/dist/components/ui/Checkbox.d.ts +9 -0
  9. package/dist/components/ui/CustomSelect.d.ts +14 -0
  10. package/dist/components/ui/Popover.d.ts +17 -0
  11. package/dist/components/ui/TextField.d.ts +12 -0
  12. package/dist/constants/toolbar.d.ts +17 -0
  13. package/dist/core/GridBodyContainer.d.ts +83 -0
  14. package/dist/core/GridFooterContainer.d.ts +23 -0
  15. package/dist/core/GridToolbarContainer.d.ts +48 -0
  16. package/dist/grid/components/Filters/BooleanFilter.d.ts +7 -0
  17. package/dist/grid/components/Filters/DateFilter.d.ts +9 -0
  18. package/dist/grid/components/Filters/FilterContent.d.ts +9 -0
  19. package/dist/grid/components/Filters/FilterPopup.d.ts +2 -0
  20. package/dist/grid/components/Filters/MultiselectFilter.d.ts +10 -0
  21. package/dist/grid/components/Filters/NumberFilter.d.ts +9 -0
  22. package/dist/grid/components/Filters/TextFilter.d.ts +8 -0
  23. package/dist/grid/components/Filters/index.d.ts +6 -0
  24. package/dist/grid/components/Popovers/BulkActionPopover.d.ts +17 -0
  25. package/dist/grid/components/Popovers/ColumnVisibilityPopover.d.ts +35 -0
  26. package/dist/grid/components/Popovers/ExportPopover.d.ts +18 -0
  27. package/dist/grid/components/Popovers/FilterPopover.d.ts +29 -0
  28. package/dist/grid/components/Popovers/SettingsPopover.d.ts +17 -0
  29. package/dist/grid/components/Shared/CellEditor.d.ts +23 -0
  30. package/dist/grid/components/Shared/ColumnFilterSelector.d.ts +18 -0
  31. package/dist/grid/components/Shared/FooterAggregate.d.ts +16 -0
  32. package/dist/grid/components/Shared/GridHeader.d.ts +39 -0
  33. package/dist/grid/components/Shared/GridRows.d.ts +53 -0
  34. package/dist/grid/components/Shared/GroupBar.d.ts +12 -0
  35. package/dist/grid/components/Shared/GroupHeader.d.ts +29 -0
  36. package/dist/grid/components/Shared/LicenseError.d.ts +9 -0
  37. package/dist/grid/components/Shared/NoDataMessage.d.ts +11 -0
  38. package/dist/grid/components/Shared/PaginationControls.d.ts +18 -0
  39. package/dist/grid/components/Shared/RowContextMenu.d.ts +18 -0
  40. package/dist/grid/components/Toolbar/Toolbar.d.ts +70 -0
  41. package/dist/grid/constants/index.d.ts +1 -0
  42. package/dist/grid/constants/toolbar.d.ts +17 -0
  43. package/dist/grid/core/DataGrid.d.ts +3 -0
  44. package/dist/grid/core/GridBodyContainer.d.ts +83 -0
  45. package/dist/grid/core/GridFooterContainer.d.ts +23 -0
  46. package/dist/grid/core/GridToolbarContainer.d.ts +48 -0
  47. package/dist/grid/hooks/toolbar/useColumnDnD.d.ts +28 -0
  48. package/dist/grid/hooks/toolbar/useToolbarMenus.d.ts +29 -0
  49. package/dist/grid/hooks/useAdvancedFiltering.d.ts +18 -0
  50. package/dist/grid/hooks/useCellSelection.d.ts +67 -0
  51. package/dist/grid/hooks/useColumnState.d.ts +52 -0
  52. package/dist/grid/hooks/useDataWorker.d.ts +11 -0
  53. package/dist/grid/hooks/useEditingCell.d.ts +49 -0
  54. package/dist/grid/hooks/useExport.d.ts +14 -0
  55. package/dist/grid/hooks/useGridDataMaps.d.ts +17 -0
  56. package/dist/grid/hooks/useGridMethods.d.ts +20 -0
  57. package/dist/grid/hooks/useGrouping.d.ts +28 -0
  58. package/dist/grid/hooks/useHorizontalVirtualization.d.ts +18 -0
  59. package/dist/grid/hooks/useInfiniteScroll.d.ts +31 -0
  60. package/dist/grid/hooks/useLoadingBar.d.ts +21 -0
  61. package/dist/grid/hooks/usePagination.d.ts +28 -0
  62. package/dist/grid/hooks/useScrollSync.d.ts +29 -0
  63. package/dist/grid/hooks/useSelection.d.ts +13 -0
  64. package/dist/grid/hooks/useVirtualization.d.ts +17 -0
  65. package/dist/grid/types.d.ts +570 -0
  66. package/dist/grid/utils/dateUtils.d.ts +16 -0
  67. package/dist/grid/utils/highlightText.d.ts +15 -0
  68. package/dist/grid/utils/license.d.ts +3 -0
  69. package/dist/hooks/toolbar/useColumnDnD.d.ts +28 -0
  70. package/dist/hooks/toolbar/useToolbarMenus.d.ts +29 -0
  71. package/dist/hooks/useColumnState.d.ts +8 -1
  72. package/dist/hooks/useGridDataMaps.d.ts +17 -0
  73. package/dist/hooks/useGridMethods.d.ts +20 -0
  74. package/dist/hooks/useHorizontalVirtualization.d.ts +18 -0
  75. package/dist/icons/index.d.ts +1 -0
  76. package/dist/index.d.ts +21 -12
  77. package/dist/index.esm.js +1 -1
  78. package/dist/index.js +1 -1
  79. package/dist/styles.css +1 -0
  80. package/dist/types.d.ts +0 -22
  81. package/dist/utils/theme.d.ts +7 -0
  82. package/package.json +1 -1
@@ -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 {};