@alaarab/ogrid-react 2.0.9 → 2.0.12

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 (33) hide show
  1. package/dist/esm/components/BaseInlineCellEditor.js +2 -2
  2. package/dist/esm/components/CellErrorBoundary.js +1 -1
  3. package/dist/esm/components/ColumnChooserProps.js +6 -0
  4. package/dist/esm/components/ColumnHeaderFilterContent.js +35 -0
  5. package/dist/esm/components/ColumnHeaderFilterRenderers.js +67 -0
  6. package/dist/esm/components/MarchingAntsOverlay.js +25 -44
  7. package/dist/esm/components/PaginationControlsProps.js +6 -0
  8. package/dist/esm/constants/domHelpers.js +16 -0
  9. package/dist/esm/hooks/index.js +2 -0
  10. package/dist/esm/hooks/useColumnHeaderMenuState.js +52 -2
  11. package/dist/esm/hooks/useColumnResize.js +29 -0
  12. package/dist/esm/hooks/useDataGridState.js +77 -10
  13. package/dist/esm/hooks/useDataGridTableOrchestration.js +200 -0
  14. package/dist/esm/hooks/useDebounce.js +1 -1
  15. package/dist/esm/hooks/useOGrid.js +3 -6
  16. package/dist/esm/hooks/usePaginationControls.js +19 -0
  17. package/dist/esm/index.js +6 -1
  18. package/dist/esm/utils/index.js +1 -1
  19. package/dist/types/components/ColumnChooserProps.d.ts +12 -0
  20. package/dist/types/components/ColumnHeaderFilterContent.d.ts +62 -0
  21. package/dist/types/components/ColumnHeaderFilterRenderers.d.ts +71 -0
  22. package/dist/types/components/MarchingAntsOverlay.d.ts +11 -1
  23. package/dist/types/components/PaginationControlsProps.d.ts +15 -0
  24. package/dist/types/constants/domHelpers.d.ts +17 -0
  25. package/dist/types/hooks/index.d.ts +5 -1
  26. package/dist/types/hooks/useColumnHeaderMenuState.d.ts +23 -1
  27. package/dist/types/hooks/useDataGridState.d.ts +10 -6
  28. package/dist/types/hooks/useDataGridTableOrchestration.d.ts +131 -0
  29. package/dist/types/hooks/usePaginationControls.d.ts +20 -0
  30. package/dist/types/index.d.ts +9 -2
  31. package/dist/types/types/dataGridTypes.d.ts +1 -1
  32. package/dist/types/utils/index.d.ts +1 -1
  33. package/package.json +4 -4
@@ -0,0 +1,131 @@
1
+ import type { RefObject } from 'react';
2
+ import type { IOGridDataGridProps, IColumnDef } from '../types';
3
+ import type { UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, DataGridPinningState } from './useDataGridState';
4
+ import type { UseColumnResizeResult } from './useColumnResize';
5
+ import type { UseColumnReorderResult } from './useColumnReorder';
6
+ import type { UseVirtualScrollResult } from './useVirtualScroll';
7
+ import type { HeaderFilterConfigInput, CellRenderDescriptorInput } from '../utils';
8
+ import type { IStatusBarProps, RowId, HeaderRow } from '../types';
9
+ /** Parameters for the orchestration hook. */
10
+ export interface UseDataGridTableOrchestrationParams<T> {
11
+ props: IOGridDataGridProps<T>;
12
+ }
13
+ /** Everything the framework-specific view layer needs to render. */
14
+ export interface UseDataGridTableOrchestrationResult<T> {
15
+ wrapperRef: RefObject<HTMLDivElement | null>;
16
+ tableContainerRef: RefObject<HTMLDivElement | null>;
17
+ lastMouseShiftRef: React.MutableRefObject<boolean>;
18
+ state: UseDataGridStateResult<T>;
19
+ layout: DataGridLayoutState<T>;
20
+ rowSel: DataGridRowSelectionState;
21
+ editing: DataGridEditingState<T>;
22
+ interaction: DataGridCellInteractionState;
23
+ ctxMenu: DataGridContextMenuState;
24
+ viewModels: DataGridViewModelState<T>;
25
+ pinning: DataGridPinningState;
26
+ handleResizeStart: UseColumnResizeResult<T>['handleResizeStart'];
27
+ getColumnWidth: UseColumnResizeResult<T>['getColumnWidth'];
28
+ isReorderDragging: UseColumnReorderResult['isDragging'];
29
+ dropIndicatorX: UseColumnReorderResult['dropIndicatorX'];
30
+ handleHeaderMouseDown: UseColumnReorderResult['handleHeaderMouseDown'];
31
+ virtualScrollEnabled: boolean;
32
+ virtualRowHeight: number;
33
+ visibleRange: UseVirtualScrollResult['visibleRange'];
34
+ items: T[];
35
+ columns: IOGridDataGridProps<T>['columns'];
36
+ getRowId: IOGridDataGridProps<T>['getRowId'];
37
+ emptyState: IOGridDataGridProps<T>['emptyState'];
38
+ layoutMode: 'fill' | 'content';
39
+ rowSelection: IOGridDataGridProps<T>['rowSelection'];
40
+ freezeRows: IOGridDataGridProps<T>['freezeRows'];
41
+ freezeCols: IOGridDataGridProps<T>['freezeCols'];
42
+ suppressHorizontalScroll: IOGridDataGridProps<T>['suppressHorizontalScroll'];
43
+ isLoading: boolean;
44
+ loadingMessage: string;
45
+ ariaLabel: string | undefined;
46
+ ariaLabelledBy: string | undefined;
47
+ visibleColumns: IOGridDataGridProps<T>['visibleColumns'];
48
+ columnOrder: IOGridDataGridProps<T>['columnOrder'];
49
+ columnReorder: IOGridDataGridProps<T>['columnReorder'];
50
+ density: 'compact' | 'normal' | 'comfortable';
51
+ pinnedColumns: IOGridDataGridProps<T>['pinnedColumns'];
52
+ currentPage: number;
53
+ propPageSize: number;
54
+ rowNumberOffset: number;
55
+ headerRows: HeaderRow<T>[];
56
+ allowOverflowX: boolean;
57
+ fitToContent: boolean;
58
+ editCallbacks: {
59
+ commitCellEdit: DataGridEditingState<T>['commitCellEdit'];
60
+ setEditingCell: DataGridEditingState<T>['setEditingCell'];
61
+ setPendingEditorValue: DataGridEditingState<T>['setPendingEditorValue'];
62
+ cancelPopoverEdit: DataGridEditingState<T>['cancelPopoverEdit'];
63
+ };
64
+ interactionHandlers: {
65
+ handleCellMouseDown: DataGridCellInteractionState['handleCellMouseDown'];
66
+ setActiveCell: DataGridCellInteractionState['setActiveCell'];
67
+ setEditingCell: DataGridEditingState<T>['setEditingCell'];
68
+ handleCellContextMenu: DataGridContextMenuState['handleCellContextMenu'];
69
+ };
70
+ cellDescriptorInputRef: React.MutableRefObject<CellRenderDescriptorInput<T>>;
71
+ pendingEditorValueRef: React.MutableRefObject<unknown>;
72
+ popoverAnchorElRef: React.MutableRefObject<HTMLElement | null>;
73
+ selectedRowIdsRef: React.MutableRefObject<Set<RowId>>;
74
+ handleSingleRowClick: (e: React.MouseEvent<HTMLTableRowElement>) => void;
75
+ handlePasteVoid: () => void;
76
+ visibleCols: IColumnDef<T>[];
77
+ totalColCount: number;
78
+ hasCheckboxCol: boolean;
79
+ hasRowNumbersCol: boolean;
80
+ colOffset: number;
81
+ containerWidth: number;
82
+ minTableWidth: number;
83
+ desiredTableWidth: number;
84
+ columnSizingOverrides: Record<string, {
85
+ widthPx: number;
86
+ }>;
87
+ setColumnSizingOverrides: React.Dispatch<React.SetStateAction<Record<string, {
88
+ widthPx: number;
89
+ }>>>;
90
+ selectedRowIds: Set<RowId>;
91
+ updateSelection: DataGridRowSelectionState['updateSelection'];
92
+ handleRowCheckboxChange: DataGridRowSelectionState['handleRowCheckboxChange'];
93
+ handleSelectAll: DataGridRowSelectionState['handleSelectAll'];
94
+ allSelected: boolean;
95
+ someSelected: boolean;
96
+ editingCell: DataGridEditingState<T>['editingCell'];
97
+ setPopoverAnchorEl: DataGridEditingState<T>['setPopoverAnchorEl'];
98
+ cancelPopoverEdit: DataGridEditingState<T>['cancelPopoverEdit'];
99
+ setActiveCell: DataGridCellInteractionState['setActiveCell'];
100
+ selectionRange: DataGridCellInteractionState['selectionRange'];
101
+ hasCellSelection: boolean;
102
+ handleGridKeyDown: DataGridCellInteractionState['handleGridKeyDown'];
103
+ handleFillHandleMouseDown: DataGridCellInteractionState['handleFillHandleMouseDown'];
104
+ handleCopy: DataGridCellInteractionState['handleCopy'];
105
+ handleCut: DataGridCellInteractionState['handleCut'];
106
+ cutRange: DataGridCellInteractionState['cutRange'];
107
+ copyRange: DataGridCellInteractionState['copyRange'];
108
+ canUndo: boolean;
109
+ canRedo: boolean;
110
+ onUndo: DataGridCellInteractionState['onUndo'];
111
+ onRedo: DataGridCellInteractionState['onRedo'];
112
+ isDragging: boolean;
113
+ menuPosition: DataGridContextMenuState['menuPosition'];
114
+ handleCellContextMenu: DataGridContextMenuState['handleCellContextMenu'];
115
+ closeContextMenu: DataGridContextMenuState['closeContextMenu'];
116
+ headerFilterInput: HeaderFilterConfigInput;
117
+ cellDescriptorInput: CellRenderDescriptorInput<T>;
118
+ statusBarConfig: IStatusBarProps | null;
119
+ showEmptyInGrid: boolean;
120
+ onCellError: DataGridViewModelState<T>['onCellError'];
121
+ headerMenu: DataGridPinningState['headerMenu'];
122
+ }
123
+ /**
124
+ * Shared orchestration hook for DataGridTable.
125
+ *
126
+ * Encapsulates all state management and computation that is identical across
127
+ * Radix, Fluent, and Material DataGridTable implementations. Each UI package
128
+ * calls this hook, then renders its own framework-specific JSX using the
129
+ * returned values.
130
+ */
131
+ export declare function useDataGridTableOrchestration<T>(params: UseDataGridTableOrchestrationParams<T>): UseDataGridTableOrchestrationResult<T>;
@@ -0,0 +1,20 @@
1
+ import { getPaginationViewModel } from '../utils';
2
+ export interface UsePaginationControlsProps {
3
+ currentPage: number;
4
+ pageSize: number;
5
+ totalCount: number;
6
+ onPageChange: (page: number) => void;
7
+ onPageSizeChange: (pageSize: number) => void;
8
+ pageSizeOptions?: number[];
9
+ entityLabelPlural?: string;
10
+ }
11
+ export interface UsePaginationControlsResult {
12
+ labelPlural: string;
13
+ vm: ReturnType<typeof getPaginationViewModel>;
14
+ handlePageSizeChange: (value: number) => void;
15
+ }
16
+ /**
17
+ * Shared pagination controls logic for React UI packages.
18
+ * Computes pagination view model and provides standardized handlers.
19
+ */
20
+ export declare function usePaginationControls(props: UsePaginationControlsProps): UsePaginationControlsResult;
@@ -1,8 +1,9 @@
1
1
  export { CHECKBOX_COLUMN_WIDTH, ROW_NUMBER_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from '@alaarab/ogrid-core';
2
2
  export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnDef, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IValueParserParams, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridDataGridProps, RowSelectionMode, RowId, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, HeaderCell, HeaderRow, SideBarPanelId, ISideBarDef, IDateFilterValue, IVirtualScrollConfig, IColumnReorderConfig, } from './types';
3
3
  export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './types';
4
- export { useFilterOptions, useOGrid, useActiveCell, useCellEditing, useContextMenu, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useUndoRedo, useDebounce, useFillHandle, useDataGridState, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useColumnResize, useRichSelectState, useSideBarState, useTableLayout, useColumnReorder, useVirtualScroll, useLatestRef, } from './hooks';
5
- export type { UseFilterOptionsResult, UseOGridResult, UseOGridPagination, UseOGridColumnChooser, UseOGridLayout, UseOGridFilters, ColumnChooserPlacement, UseActiveCellResult, UseCellEditingResult, EditingCell, UseContextMenuResult, ContextMenuPosition, UseCellSelectionResult, UseCellSelectionParams, UseClipboardResult, UseClipboardParams, UseRowSelectionResult, UseRowSelectionParams, UseKeyboardNavigationResult, UseKeyboardNavigationParams, UseUndoRedoResult, UseUndoRedoParams, UseFillHandleResult, UseFillHandleParams, UseDataGridStateParams, UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, UseColumnHeaderFilterStateParams, UseColumnHeaderFilterStateResult, UseTextFilterStateParams, UseTextFilterStateResult, UseMultiSelectFilterStateParams, UseMultiSelectFilterStateResult, UsePeopleFilterStateParams, UsePeopleFilterStateResult, UseDateFilterStateParams, UseDateFilterStateResult, UseColumnChooserStateParams, UseColumnChooserStateResult, UseInlineCellEditorStateParams, UseInlineCellEditorStateResult, InlineCellEditorType, UseColumnResizeParams, UseColumnResizeResult, UseRichSelectStateParams, UseRichSelectStateResult, UseSideBarStateParams, UseSideBarStateResult, UseTableLayoutParams, UseTableLayoutResult, UseColumnReorderParams, UseColumnReorderResult, UseVirtualScrollParams, UseVirtualScrollResult, } from './hooks';
4
+ export { useFilterOptions, useOGrid, useActiveCell, useCellEditing, useContextMenu, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useUndoRedo, useDebounce, useFillHandle, useDataGridState, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useColumnResize, useRichSelectState, useSideBarState, useTableLayout, useColumnReorder, useVirtualScroll, useLatestRef, usePaginationControls, useDataGridTableOrchestration, } from './hooks';
5
+ export type { UseFilterOptionsResult, UseOGridResult, UseOGridPagination, UseOGridColumnChooser, UseOGridLayout, UseOGridFilters, ColumnChooserPlacement, UseActiveCellResult, UseCellEditingResult, EditingCell, UseContextMenuResult, ContextMenuPosition, UseCellSelectionResult, UseCellSelectionParams, UseClipboardResult, UseClipboardParams, UseRowSelectionResult, UseRowSelectionParams, UseKeyboardNavigationResult, UseKeyboardNavigationParams, UseUndoRedoResult, UseUndoRedoParams, UseFillHandleResult, UseFillHandleParams, UseDataGridStateParams, UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, DataGridPinningState, UseColumnHeaderFilterStateParams, UseColumnHeaderFilterStateResult, UseTextFilterStateParams, UseTextFilterStateResult, UseMultiSelectFilterStateParams, UseMultiSelectFilterStateResult, UsePeopleFilterStateParams, UsePeopleFilterStateResult, UseDateFilterStateParams, UseDateFilterStateResult, UseColumnChooserStateParams, UseColumnChooserStateResult, UseInlineCellEditorStateParams, UseInlineCellEditorStateResult, InlineCellEditorType, UseColumnResizeParams, UseColumnResizeResult, UseRichSelectStateParams, UseRichSelectStateResult, UseSideBarStateParams, UseSideBarStateResult, UseTableLayoutParams, UseTableLayoutResult, UseColumnReorderParams, UseColumnReorderResult, UseVirtualScrollParams, UseVirtualScrollResult, UsePaginationControlsProps, UsePaginationControlsResult, UseDataGridTableOrchestrationParams, UseDataGridTableOrchestrationResult, } from './hooks';
6
+ export { GRID_ROOT_STYLE, CURSOR_CELL_STYLE, POPOVER_ANCHOR_STYLE, PREVENT_DEFAULT, NOOP, STOP_PROPAGATION, } from './constants/domHelpers';
6
7
  export { OGridLayout } from './components/OGridLayout';
7
8
  export type { OGridLayoutProps } from './components/OGridLayout';
8
9
  export { StatusBar } from './components/StatusBar';
@@ -19,5 +20,11 @@ export { CellErrorBoundary } from './components/CellErrorBoundary';
19
20
  export type { CellErrorBoundaryProps } from './components/CellErrorBoundary';
20
21
  export { EmptyState } from './components/EmptyState';
21
22
  export type { EmptyStateProps } from './components/EmptyState';
23
+ export { DateFilterContent, getColumnHeaderFilterStateParams, getDateFilterContentProps, } from './components/ColumnHeaderFilterContent';
24
+ export type { IColumnHeaderFilterProps, DateFilterContentProps, DateFilterClassNames, } from './components/ColumnHeaderFilterContent';
22
25
  export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, GRID_CONTEXT_MENU_ITEMS, getContextMenuHandlers, formatShortcut, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, getHeaderFilterConfig, getCellRenderDescriptor, isRowInRange, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, areGridRowPropsEqual, } from './utils';
23
26
  export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, ParseValueResult, AggregationResult, GridRowComparatorProps, } from './utils';
27
+ export { renderFilterContent } from './components/ColumnHeaderFilterRenderers';
28
+ export type { FilterContentRenderers, MultiSelectRendererProps, TextRendererProps, PeopleRendererProps, DateRendererProps, } from './components/ColumnHeaderFilterRenderers';
29
+ export type { IColumnChooserProps } from './components/ColumnChooserProps';
30
+ export type { IPaginationControlsProps } from './components/PaginationControlsProps';
@@ -105,7 +105,7 @@ export interface IOGridDataGridProps<T> {
105
105
  getRowId: (item: T) => RowId;
106
106
  sortBy?: string;
107
107
  sortDirection: 'asc' | 'desc';
108
- onColumnSort: (columnKey: string) => void;
108
+ onColumnSort: (columnKey: string, direction?: 'asc' | 'desc' | null) => void;
109
109
  visibleColumns: Set<string>;
110
110
  /** Optional column display order (column ids). When set, visible columns are ordered by this array. */
111
111
  columnOrder?: string[];
@@ -1,4 +1,4 @@
1
- export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, getContextMenuHandlers, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, } from '@alaarab/ogrid-core';
1
+ export { escapeCsvValue, buildCsvHeader, buildCsvRows, exportToCsv, triggerCsvDownload, getCellValue, flattenColumns, buildHeaderRows, getFilterField, mergeFilter, deriveFilterOptionsFromData, getMultiSelectFilterFields, getStatusBarParts, getDataGridStatusBarConfig, getPaginationViewModel, PAGE_SIZE_OPTIONS, MAX_PAGE_BUTTONS, GRID_CONTEXT_MENU_ITEMS, getContextMenuHandlers, formatShortcut, parseValue, numberParser, currencyParser, dateParser, emailParser, booleanParser, computeAggregations, processClientSideData, computeNextSortState, measureColumnContentWidth, AUTOSIZE_EXTRA_PX, AUTOSIZE_MAX_PX, } from '@alaarab/ogrid-core';
2
2
  export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, ParseValueResult, AggregationResult, } from '@alaarab/ogrid-core';
3
3
  export { getHeaderFilterConfig, getCellRenderDescriptor, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, } from './dataGridViewModel';
4
4
  export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, } from './dataGridViewModel';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alaarab/ogrid-react",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "description": "OGrid React – React hooks, headless components, and utilities for OGrid data grids.",
5
5
  "main": "dist/esm/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -36,7 +36,7 @@
36
36
  "node": ">=18"
37
37
  },
38
38
  "dependencies": {
39
- "@alaarab/ogrid-core": "2.0.9"
39
+ "@alaarab/ogrid-core": "2.0.12"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@tanstack/react-virtual": "^3.0.0",
@@ -51,8 +51,8 @@
51
51
  "@testing-library/jest-dom": "^6.9.1",
52
52
  "@testing-library/react": "^16.3.2",
53
53
  "@testing-library/user-event": "^14.6.1",
54
- "@types/react": "^18.3.18",
55
- "@types/react-dom": "^18.3.5",
54
+ "@types/react": "^19.0.0",
55
+ "@types/react-dom": "^19.0.0",
56
56
  "react": "^18.3.1",
57
57
  "react-dom": "^18.3.1"
58
58
  },