@alaarab/ogrid-react 2.0.0-beta
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/README.md +55 -0
- package/dist/esm/components/BaseInlineCellEditor.js +112 -0
- package/dist/esm/components/CellErrorBoundary.js +43 -0
- package/dist/esm/components/EmptyState.js +19 -0
- package/dist/esm/components/GridContextMenu.js +35 -0
- package/dist/esm/components/MarchingAntsOverlay.js +110 -0
- package/dist/esm/components/OGridLayout.js +91 -0
- package/dist/esm/components/SideBar.js +122 -0
- package/dist/esm/components/StatusBar.js +6 -0
- package/dist/esm/hooks/index.js +25 -0
- package/dist/esm/hooks/useActiveCell.js +62 -0
- package/dist/esm/hooks/useCellEditing.js +15 -0
- package/dist/esm/hooks/useCellSelection.js +327 -0
- package/dist/esm/hooks/useClipboard.js +161 -0
- package/dist/esm/hooks/useColumnChooserState.js +62 -0
- package/dist/esm/hooks/useColumnHeaderFilterState.js +180 -0
- package/dist/esm/hooks/useColumnResize.js +92 -0
- package/dist/esm/hooks/useContextMenu.js +21 -0
- package/dist/esm/hooks/useDataGridState.js +313 -0
- package/dist/esm/hooks/useDateFilterState.js +34 -0
- package/dist/esm/hooks/useDebounce.js +35 -0
- package/dist/esm/hooks/useFillHandle.js +195 -0
- package/dist/esm/hooks/useFilterOptions.js +40 -0
- package/dist/esm/hooks/useInlineCellEditorState.js +44 -0
- package/dist/esm/hooks/useKeyboardNavigation.js +419 -0
- package/dist/esm/hooks/useLatestRef.js +11 -0
- package/dist/esm/hooks/useMultiSelectFilterState.js +59 -0
- package/dist/esm/hooks/useOGrid.js +465 -0
- package/dist/esm/hooks/usePeopleFilterState.js +68 -0
- package/dist/esm/hooks/useRichSelectState.js +58 -0
- package/dist/esm/hooks/useRowSelection.js +80 -0
- package/dist/esm/hooks/useSideBarState.js +39 -0
- package/dist/esm/hooks/useTableLayout.js +77 -0
- package/dist/esm/hooks/useTextFilterState.js +25 -0
- package/dist/esm/hooks/useUndoRedo.js +83 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/storybook/index.js +1 -0
- package/dist/esm/storybook/mockData.js +73 -0
- package/dist/esm/types/columnTypes.js +1 -0
- package/dist/esm/types/dataGridTypes.js +1 -0
- package/dist/esm/types/index.js +1 -0
- package/dist/esm/utils/dataGridViewModel.js +220 -0
- package/dist/esm/utils/gridRowComparator.js +2 -0
- package/dist/esm/utils/index.js +5 -0
- package/dist/types/components/BaseInlineCellEditor.d.ts +33 -0
- package/dist/types/components/CellErrorBoundary.d.ts +25 -0
- package/dist/types/components/EmptyState.d.ts +26 -0
- package/dist/types/components/GridContextMenu.d.ts +18 -0
- package/dist/types/components/MarchingAntsOverlay.d.ts +15 -0
- package/dist/types/components/OGridLayout.d.ts +37 -0
- package/dist/types/components/SideBar.d.ts +30 -0
- package/dist/types/components/StatusBar.d.ts +24 -0
- package/dist/types/hooks/index.d.ts +48 -0
- package/dist/types/hooks/useActiveCell.d.ts +13 -0
- package/dist/types/hooks/useCellEditing.d.ts +16 -0
- package/dist/types/hooks/useCellSelection.d.ts +22 -0
- package/dist/types/hooks/useClipboard.d.ts +30 -0
- package/dist/types/hooks/useColumnChooserState.d.ts +27 -0
- package/dist/types/hooks/useColumnHeaderFilterState.d.ts +73 -0
- package/dist/types/hooks/useColumnResize.d.ts +23 -0
- package/dist/types/hooks/useContextMenu.d.ts +19 -0
- package/dist/types/hooks/useDataGridState.d.ts +137 -0
- package/dist/types/hooks/useDateFilterState.d.ts +19 -0
- package/dist/types/hooks/useDebounce.d.ts +9 -0
- package/dist/types/hooks/useFillHandle.d.ts +33 -0
- package/dist/types/hooks/useFilterOptions.d.ts +16 -0
- package/dist/types/hooks/useInlineCellEditorState.d.ts +24 -0
- package/dist/types/hooks/useKeyboardNavigation.d.ts +47 -0
- package/dist/types/hooks/useLatestRef.d.ts +6 -0
- package/dist/types/hooks/useMultiSelectFilterState.d.ts +24 -0
- package/dist/types/hooks/useOGrid.d.ts +52 -0
- package/dist/types/hooks/usePeopleFilterState.d.ts +25 -0
- package/dist/types/hooks/useRichSelectState.d.ts +22 -0
- package/dist/types/hooks/useRowSelection.d.ts +22 -0
- package/dist/types/hooks/useSideBarState.d.ts +20 -0
- package/dist/types/hooks/useTableLayout.d.ts +27 -0
- package/dist/types/hooks/useTextFilterState.d.ts +16 -0
- package/dist/types/hooks/useUndoRedo.d.ts +23 -0
- package/dist/types/index.d.ts +23 -0
- package/dist/types/storybook/index.d.ts +2 -0
- package/dist/types/storybook/mockData.d.ts +37 -0
- package/dist/types/types/columnTypes.d.ts +25 -0
- package/dist/types/types/dataGridTypes.d.ts +152 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/utils/dataGridViewModel.d.ts +161 -0
- package/dist/types/utils/gridRowComparator.d.ts +2 -0
- package/dist/types/utils/index.d.ts +6 -0
- package/package.json +46 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { RowId, IActiveCell, ISelectionRange, IColumnDef, ICellValueChangedEvent, RowSelectionMode } from '../types';
|
|
2
|
+
import type { EditingCell } from './useCellEditing';
|
|
3
|
+
import type { ContextMenuPosition } from './useContextMenu';
|
|
4
|
+
export interface UseKeyboardNavigationParams<T> {
|
|
5
|
+
data: {
|
|
6
|
+
items: T[];
|
|
7
|
+
visibleCols: IColumnDef<T>[];
|
|
8
|
+
colOffset: number;
|
|
9
|
+
hasCheckboxCol: boolean;
|
|
10
|
+
visibleColumnCount: number;
|
|
11
|
+
getRowId: (item: T) => RowId;
|
|
12
|
+
};
|
|
13
|
+
state: {
|
|
14
|
+
activeCell: IActiveCell | null;
|
|
15
|
+
selectionRange: ISelectionRange | null;
|
|
16
|
+
editingCell: EditingCell | null;
|
|
17
|
+
selectedRowIds: Set<RowId>;
|
|
18
|
+
};
|
|
19
|
+
handlers: {
|
|
20
|
+
setActiveCell: (cell: IActiveCell | null) => void;
|
|
21
|
+
setSelectionRange: (range: ISelectionRange | null) => void;
|
|
22
|
+
setEditingCell: (cell: EditingCell | null) => void;
|
|
23
|
+
handleRowCheckboxChange: (rowId: RowId, checked: boolean, rowIndex: number, shiftKey: boolean) => void;
|
|
24
|
+
handleCopy: () => void;
|
|
25
|
+
handleCut: () => void;
|
|
26
|
+
handlePaste: () => Promise<void>;
|
|
27
|
+
setContextMenu: (pos: ContextMenuPosition | null) => void;
|
|
28
|
+
onUndo?: () => void;
|
|
29
|
+
onRedo?: () => void;
|
|
30
|
+
clearClipboardRanges?: () => void;
|
|
31
|
+
};
|
|
32
|
+
features: {
|
|
33
|
+
editable?: boolean;
|
|
34
|
+
onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
|
|
35
|
+
rowSelection: RowSelectionMode;
|
|
36
|
+
wrapperRef: React.RefObject<HTMLElement | null>;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export interface UseKeyboardNavigationResult {
|
|
40
|
+
handleGridKeyDown: (e: React.KeyboardEvent) => void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Handles all keyboard navigation, shortcuts, and cell editing triggers for the grid.
|
|
44
|
+
* @param params - Grouped data, state, handlers, and feature flags for keyboard interactions.
|
|
45
|
+
* @returns Keyboard event handler for the grid wrapper.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useKeyboardNavigation<T>(params: UseKeyboardNavigationParams<T>): UseKeyboardNavigationResult;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multi-select filter state sub-hook for column header filters.
|
|
3
|
+
* Manages temporary selection set, search text, debounced search, filtered options, and select/clear handlers.
|
|
4
|
+
*/
|
|
5
|
+
import { type Dispatch, type SetStateAction } from 'react';
|
|
6
|
+
export interface UseMultiSelectFilterStateParams {
|
|
7
|
+
selectedValues?: string[];
|
|
8
|
+
onFilterChange?: (values: string[]) => void;
|
|
9
|
+
options?: string[];
|
|
10
|
+
isFilterOpen: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface UseMultiSelectFilterStateResult {
|
|
13
|
+
tempSelected: Set<string>;
|
|
14
|
+
setTempSelected: Dispatch<SetStateAction<Set<string>>>;
|
|
15
|
+
searchText: string;
|
|
16
|
+
setSearchText: (v: string) => void;
|
|
17
|
+
debouncedSearchText: string;
|
|
18
|
+
filteredOptions: string[];
|
|
19
|
+
handleCheckboxChange: (option: string, checked: boolean) => void;
|
|
20
|
+
handleSelectAll: () => void;
|
|
21
|
+
handleClearSelection: () => void;
|
|
22
|
+
handleApplyMultiSelect: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function useMultiSelectFilterState(params: UseMultiSelectFilterStateParams): UseMultiSelectFilterStateResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { SideBarProps } from '../components/SideBar';
|
|
3
|
+
import type { IOGridProps, IOGridDataGridProps, IOGridApi, IFilters, IColumnDefinition } from '../types';
|
|
4
|
+
/** Resolved column chooser placement. */
|
|
5
|
+
export type ColumnChooserPlacement = 'toolbar' | 'sidebar' | 'none';
|
|
6
|
+
/** Pagination state and handlers. */
|
|
7
|
+
export interface UseOGridPagination {
|
|
8
|
+
page: number;
|
|
9
|
+
pageSize: number;
|
|
10
|
+
displayTotalCount: number;
|
|
11
|
+
setPage: (p: number) => void;
|
|
12
|
+
setPageSize: (size: number) => void;
|
|
13
|
+
pageSizeOptions?: number[];
|
|
14
|
+
entityLabelPlural: string;
|
|
15
|
+
}
|
|
16
|
+
/** Column chooser state and handlers. */
|
|
17
|
+
export interface UseOGridColumnChooser {
|
|
18
|
+
columns: IColumnDefinition[];
|
|
19
|
+
visibleColumns: Set<string>;
|
|
20
|
+
onVisibilityChange: (columnKey: string, isVisible: boolean) => void;
|
|
21
|
+
placement: ColumnChooserPlacement;
|
|
22
|
+
}
|
|
23
|
+
/** Layout / chrome configuration. */
|
|
24
|
+
export interface UseOGridLayout {
|
|
25
|
+
toolbar: React.ReactNode;
|
|
26
|
+
toolbarBelow: React.ReactNode;
|
|
27
|
+
className?: string;
|
|
28
|
+
emptyState?: {
|
|
29
|
+
message?: React.ReactNode;
|
|
30
|
+
render?: () => React.ReactNode;
|
|
31
|
+
};
|
|
32
|
+
sideBarProps: SideBarProps | null;
|
|
33
|
+
}
|
|
34
|
+
/** Filter state. */
|
|
35
|
+
export interface UseOGridFilters {
|
|
36
|
+
hasActiveFilters: boolean;
|
|
37
|
+
setFilters: (f: IFilters) => void;
|
|
38
|
+
}
|
|
39
|
+
export interface UseOGridResult<T> {
|
|
40
|
+
dataGridProps: IOGridDataGridProps<T>;
|
|
41
|
+
pagination: UseOGridPagination;
|
|
42
|
+
columnChooser: UseOGridColumnChooser;
|
|
43
|
+
layout: UseOGridLayout;
|
|
44
|
+
filters: UseOGridFilters;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Top-level orchestration hook for OGrid: manages pagination, sorting, filtering, column visibility, and sidebar.
|
|
48
|
+
* @param props - All OGrid props (columns, data, callbacks, feature flags).
|
|
49
|
+
* @param ref - Forwarded ref for imperative API (refresh, export, applyColumnState).
|
|
50
|
+
* @returns Grouped props for DataGridTable, pagination controls, column chooser, layout, and filters.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useOGrid<T>(props: IOGridProps<T>, ref: React.Ref<IOGridApi<T>>): UseOGridResult<T>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* People filter state sub-hook for column header filters.
|
|
3
|
+
* Manages people search text, suggestions, loading state, input ref, and user select/clear handlers.
|
|
4
|
+
* Includes debounced people search effect.
|
|
5
|
+
*/
|
|
6
|
+
import { type RefObject } from 'react';
|
|
7
|
+
import type { UserLike } from '../types/dataGridTypes';
|
|
8
|
+
import type { ColumnFilterType } from '../types/columnTypes';
|
|
9
|
+
export interface UsePeopleFilterStateParams {
|
|
10
|
+
selectedUser?: UserLike;
|
|
11
|
+
onUserChange?: (user: UserLike | undefined) => void;
|
|
12
|
+
peopleSearch?: (query: string) => Promise<UserLike[]>;
|
|
13
|
+
isFilterOpen: boolean;
|
|
14
|
+
filterType: ColumnFilterType;
|
|
15
|
+
}
|
|
16
|
+
export interface UsePeopleFilterStateResult {
|
|
17
|
+
peopleSuggestions: UserLike[];
|
|
18
|
+
isPeopleLoading: boolean;
|
|
19
|
+
peopleSearchText: string;
|
|
20
|
+
setPeopleSearchText: (v: string) => void;
|
|
21
|
+
peopleInputRef: RefObject<HTMLInputElement | null>;
|
|
22
|
+
handleUserSelect: (user: UserLike) => void;
|
|
23
|
+
handleClearUser: () => void;
|
|
24
|
+
}
|
|
25
|
+
export declare function usePeopleFilterState(params: UsePeopleFilterStateParams): UsePeopleFilterStateResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface UseRichSelectStateParams {
|
|
2
|
+
values: unknown[];
|
|
3
|
+
formatValue?: (value: unknown) => string;
|
|
4
|
+
initialValue: unknown;
|
|
5
|
+
onCommit: (value: unknown) => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
}
|
|
8
|
+
export interface UseRichSelectStateResult {
|
|
9
|
+
searchText: string;
|
|
10
|
+
setSearchText: (text: string) => void;
|
|
11
|
+
filteredValues: unknown[];
|
|
12
|
+
highlightedIndex: number;
|
|
13
|
+
handleKeyDown: (e: React.KeyboardEvent) => void;
|
|
14
|
+
selectValue: (value: unknown) => void;
|
|
15
|
+
getDisplayText: (value: unknown) => string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Manages searchable rich select editor state with keyboard navigation (arrow keys, enter, escape).
|
|
19
|
+
* @param params - Values, format function, initial value, and commit/cancel callbacks.
|
|
20
|
+
* @returns Search text, filtered values, highlighted index, keyboard handler, and select function.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRichSelectState(params: UseRichSelectStateParams): UseRichSelectStateResult;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { RowId, RowSelectionMode, IRowSelectionChangeEvent } from '../types';
|
|
2
|
+
export interface UseRowSelectionParams<T> {
|
|
3
|
+
items: T[];
|
|
4
|
+
getRowId: (item: T) => RowId;
|
|
5
|
+
rowSelection: RowSelectionMode;
|
|
6
|
+
controlledSelectedRows: Set<RowId> | undefined;
|
|
7
|
+
onSelectionChange: ((event: IRowSelectionChangeEvent<T>) => void) | undefined;
|
|
8
|
+
}
|
|
9
|
+
export interface UseRowSelectionResult {
|
|
10
|
+
selectedRowIds: Set<RowId>;
|
|
11
|
+
updateSelection: (newSelectedIds: Set<RowId>) => void;
|
|
12
|
+
handleRowCheckboxChange: (rowId: RowId, checked: boolean, rowIndex: number, shiftKey: boolean) => void;
|
|
13
|
+
handleSelectAll: (checked: boolean) => void;
|
|
14
|
+
allSelected: boolean;
|
|
15
|
+
someSelected: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Manages row selection state for single or multiple selection modes with shift-click range support.
|
|
19
|
+
* @param params - Items, getRowId, selection mode, controlled state, and selection change callback.
|
|
20
|
+
* @returns Selected row IDs, update function, checkbox handlers, and selection state booleans.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useRowSelection<T>(params: UseRowSelectionParams<T>): UseRowSelectionResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { SideBarPanelId, ISideBarDef } from '../types';
|
|
2
|
+
export interface UseSideBarStateParams {
|
|
3
|
+
config: boolean | ISideBarDef | undefined;
|
|
4
|
+
}
|
|
5
|
+
export interface UseSideBarStateResult {
|
|
6
|
+
isEnabled: boolean;
|
|
7
|
+
activePanel: SideBarPanelId | null;
|
|
8
|
+
setActivePanel: (panel: SideBarPanelId | null) => void;
|
|
9
|
+
panels: SideBarPanelId[];
|
|
10
|
+
position: 'left' | 'right';
|
|
11
|
+
isOpen: boolean;
|
|
12
|
+
toggle: (panel: SideBarPanelId) => void;
|
|
13
|
+
close: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Manages side bar panel state: enabled panels, active panel, position, and toggle/close handlers.
|
|
17
|
+
* @param params - Side bar config (boolean, ISideBarDef, or undefined).
|
|
18
|
+
* @returns Enabled flag, active panel, setters, panel list, position, open state, toggle, and close.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useSideBarState(params: UseSideBarStateParams): UseSideBarStateResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
import type { IColumnDef } from '../types';
|
|
3
|
+
export interface UseTableLayoutParams<T> {
|
|
4
|
+
wrapperRef: RefObject<HTMLDivElement | null>;
|
|
5
|
+
visibleCols: IColumnDef<T>[];
|
|
6
|
+
flatColumns: IColumnDef<T>[];
|
|
7
|
+
hasCheckboxCol: boolean;
|
|
8
|
+
initialColumnWidths?: Record<string, number>;
|
|
9
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface UseTableLayoutResult {
|
|
12
|
+
containerWidth: number;
|
|
13
|
+
minTableWidth: number;
|
|
14
|
+
desiredTableWidth: number;
|
|
15
|
+
columnSizingOverrides: Record<string, {
|
|
16
|
+
widthPx: number;
|
|
17
|
+
}>;
|
|
18
|
+
setColumnSizingOverrides: React.Dispatch<React.SetStateAction<Record<string, {
|
|
19
|
+
widthPx: number;
|
|
20
|
+
}>>>;
|
|
21
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Manages table layout: container width measurement, column sizing overrides,
|
|
25
|
+
* min/desired table width calculations.
|
|
26
|
+
*/
|
|
27
|
+
export declare function useTableLayout<T>(params: UseTableLayoutParams<T>): UseTableLayoutResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Text filter state sub-hook for column header filters.
|
|
3
|
+
* Manages temporary text value and apply/clear handlers.
|
|
4
|
+
*/
|
|
5
|
+
export interface UseTextFilterStateParams {
|
|
6
|
+
textValue?: string;
|
|
7
|
+
onTextChange?: (value: string) => void;
|
|
8
|
+
isFilterOpen: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface UseTextFilterStateResult {
|
|
11
|
+
tempTextValue: string;
|
|
12
|
+
setTempTextValue: (v: string) => void;
|
|
13
|
+
handleTextApply: () => void;
|
|
14
|
+
handleTextClear: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useTextFilterState(params: UseTextFilterStateParams): UseTextFilterStateResult;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ICellValueChangedEvent } from '../types';
|
|
2
|
+
export interface UseUndoRedoParams<T> {
|
|
3
|
+
onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
|
|
4
|
+
maxUndoDepth?: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseUndoRedoResult<T> {
|
|
7
|
+
onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
|
|
8
|
+
undo: () => void;
|
|
9
|
+
redo: () => void;
|
|
10
|
+
canUndo: boolean;
|
|
11
|
+
canRedo: boolean;
|
|
12
|
+
/** Start a batch — all changes until endBatch() are grouped as one undo step. */
|
|
13
|
+
beginBatch: () => void;
|
|
14
|
+
/** End a batch — commits the accumulated changes as a single undo entry. */
|
|
15
|
+
endBatch: () => void;
|
|
16
|
+
/** The configured maximum undo stack depth. */
|
|
17
|
+
maxUndoDepth: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Wraps onCellValueChanged with an undo/redo history stack.
|
|
21
|
+
* Supports batch operations: changes between beginBatch/endBatch are one undo step.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useUndoRedo<T>(params: UseUndoRedoParams<T>): UseUndoRedoResult<T>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { CHECKBOX_COLUMN_WIDTH, DEFAULT_MIN_COLUMN_WIDTH, CELL_PADDING, GRID_BORDER_RADIUS, } from '@alaarab/ogrid-core';
|
|
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, } from './types';
|
|
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, 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, } from './hooks';
|
|
6
|
+
export { OGridLayout } from './components/OGridLayout';
|
|
7
|
+
export type { OGridLayoutProps } from './components/OGridLayout';
|
|
8
|
+
export { StatusBar } from './components/StatusBar';
|
|
9
|
+
export type { StatusBarProps, StatusBarClassNames } from './components/StatusBar';
|
|
10
|
+
export { BaseInlineCellEditor, editorWrapperStyle, editorInputStyle, richSelectWrapperStyle, richSelectDropdownStyle, richSelectOptionStyle, richSelectOptionHighlightedStyle, richSelectNoMatchesStyle, selectEditorStyle, } from './components/BaseInlineCellEditor';
|
|
11
|
+
export type { BaseInlineCellEditorProps } from './components/BaseInlineCellEditor';
|
|
12
|
+
export { GridContextMenu } from './components/GridContextMenu';
|
|
13
|
+
export type { GridContextMenuProps, GridContextMenuClassNames } from './components/GridContextMenu';
|
|
14
|
+
export { MarchingAntsOverlay } from './components/MarchingAntsOverlay';
|
|
15
|
+
export type { MarchingAntsOverlayProps } from './components/MarchingAntsOverlay';
|
|
16
|
+
export { SideBar } from './components/SideBar';
|
|
17
|
+
export type { SideBarProps, SideBarFilterColumn } from './components/SideBar';
|
|
18
|
+
export { CellErrorBoundary } from './components/CellErrorBoundary';
|
|
19
|
+
export type { CellErrorBoundaryProps } from './components/CellErrorBoundary';
|
|
20
|
+
export { EmptyState } from './components/EmptyState';
|
|
21
|
+
export type { EmptyStateProps } from './components/EmptyState';
|
|
22
|
+
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
|
+
export type { CsvColumn, StatusBarPart, StatusBarPartsInput, GridContextMenuItem, GridContextMenuHandlerProps, PaginationViewModel, HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, ParseValueResult, AggregationResult, GridRowComparatorProps, } from './utils';
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { storyRows, storyGetRowId, noop, editableInitialRows, editableColumns, NotesPopupEditor, spreadsheetRows, spreadsheetColumns, departmentFilterOptions, statusFilterOptions, } from './mockData';
|
|
2
|
+
export type { StoryRow, EditableRow, RowWithNotes, SpreadsheetRow, } from './mockData';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IColumnDef, ICellEditorProps } from '../types';
|
|
3
|
+
export interface StoryRow {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
status: string;
|
|
7
|
+
owner: string;
|
|
8
|
+
approved?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare const storyRows: StoryRow[];
|
|
11
|
+
export declare const storyGetRowId: (r: StoryRow) => string;
|
|
12
|
+
export declare const noop: () => void;
|
|
13
|
+
export interface EditableRow {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
status: string;
|
|
17
|
+
approved: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare const editableInitialRows: EditableRow[];
|
|
20
|
+
export declare const editableColumns: IColumnDef<EditableRow>[];
|
|
21
|
+
export interface RowWithNotes extends EditableRow {
|
|
22
|
+
notes?: string;
|
|
23
|
+
}
|
|
24
|
+
export declare function NotesPopupEditor<T>({ value, onValueChange, onCommit, onCancel }: ICellEditorProps<T>): React.ReactElement;
|
|
25
|
+
export interface SpreadsheetRow {
|
|
26
|
+
id: string;
|
|
27
|
+
name: string;
|
|
28
|
+
department: string;
|
|
29
|
+
salary: number;
|
|
30
|
+
startDate: string;
|
|
31
|
+
status: string;
|
|
32
|
+
email: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const spreadsheetRows: SpreadsheetRow[];
|
|
35
|
+
export declare const spreadsheetColumns: IColumnDef<SpreadsheetRow>[];
|
|
36
|
+
export declare const departmentFilterOptions: string[];
|
|
37
|
+
export declare const statusFilterOptions: string[];
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { IColumnDef as ICoreColumnDef, CellEditorParams } from '@alaarab/ogrid-core';
|
|
3
|
+
export type { ColumnFilterType, IDateFilterValue, IColumnFilterDef, IColumnMeta, IValueParserParams, ICellValueChangedEvent, CellEditorParams, IColumnGroupDef, HeaderCell, HeaderRow, IColumnDefinition, } from '@alaarab/ogrid-core';
|
|
4
|
+
/** Props passed to custom cell editor components. */
|
|
5
|
+
export interface ICellEditorProps<T = unknown> {
|
|
6
|
+
value: unknown;
|
|
7
|
+
onValueChange: (value: unknown) => void;
|
|
8
|
+
onCommit: () => void;
|
|
9
|
+
onCancel: () => void;
|
|
10
|
+
item: T;
|
|
11
|
+
column: IColumnDef<T>;
|
|
12
|
+
cellEditorParams?: CellEditorParams;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* React-specific column definition. Extends core's framework-agnostic IColumnDef
|
|
16
|
+
* with renderCell, cellStyle, and a narrowed cellEditor type.
|
|
17
|
+
*/
|
|
18
|
+
export interface IColumnDef<T = unknown> extends ICoreColumnDef<T> {
|
|
19
|
+
/** Custom cell renderer (React-specific). */
|
|
20
|
+
renderCell?: (item: T) => React.ReactNode;
|
|
21
|
+
/** Static or per-row cell inline styles (React-specific). */
|
|
22
|
+
cellStyle?: React.CSSProperties | ((item: T) => React.CSSProperties);
|
|
23
|
+
/** Built-in editor type or custom React component. */
|
|
24
|
+
cellEditor?: 'text' | 'select' | 'checkbox' | 'richSelect' | 'date' | React.ComponentType<ICellEditorProps<T>>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { IColumnDef, IColumnGroupDef, ICellValueChangedEvent } from './columnTypes';
|
|
3
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, IOGridApi, } from '@alaarab/ogrid-core';
|
|
4
|
+
export { toUserLike, isInSelectionRange, normalizeSelectionRange } from '@alaarab/ogrid-core';
|
|
5
|
+
import type { RowId, UserLike, IFilters, FilterValue, RowSelectionMode, IRowSelectionChangeEvent, IStatusBarProps, IDataSource, ISideBarDef } from '@alaarab/ogrid-core';
|
|
6
|
+
/** Base props shared by both client-side and server-side OGrid modes. */
|
|
7
|
+
interface IOGridBaseProps<T> {
|
|
8
|
+
columns: (IColumnDef<T> | IColumnGroupDef<T>)[];
|
|
9
|
+
getRowId: (item: T) => RowId;
|
|
10
|
+
page?: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
sort?: {
|
|
13
|
+
field: string;
|
|
14
|
+
direction: 'asc' | 'desc';
|
|
15
|
+
};
|
|
16
|
+
filters?: IFilters;
|
|
17
|
+
visibleColumns?: Set<string>;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
onPageChange?: (page: number) => void;
|
|
20
|
+
onPageSizeChange?: (size: number) => void;
|
|
21
|
+
onSortChange?: (sort: {
|
|
22
|
+
field: string;
|
|
23
|
+
direction: 'asc' | 'desc';
|
|
24
|
+
}) => void;
|
|
25
|
+
onFiltersChange?: (filters: IFilters) => void;
|
|
26
|
+
onVisibleColumnsChange?: (cols: Set<string>) => void;
|
|
27
|
+
columnOrder?: string[];
|
|
28
|
+
onColumnOrderChange?: (order: string[]) => void;
|
|
29
|
+
/** Called when a column is resized by the user. */
|
|
30
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
31
|
+
/** Called when a column is pinned or unpinned. */
|
|
32
|
+
onColumnPinned?: (columnId: string, pinned: 'left' | 'right' | null) => void;
|
|
33
|
+
freezeRows?: number;
|
|
34
|
+
freezeCols?: number;
|
|
35
|
+
editable?: boolean;
|
|
36
|
+
/** Enable spreadsheet-like cell selection (active cell, range, fill handle, clipboard, context menu). Default: true. */
|
|
37
|
+
cellSelection?: boolean;
|
|
38
|
+
onCellValueChanged?: (event: ICellValueChangedEvent<T>) => void;
|
|
39
|
+
onUndo?: () => void;
|
|
40
|
+
onRedo?: () => void;
|
|
41
|
+
canUndo?: boolean;
|
|
42
|
+
canRedo?: boolean;
|
|
43
|
+
rowSelection?: RowSelectionMode;
|
|
44
|
+
selectedRows?: Set<RowId>;
|
|
45
|
+
onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
|
|
46
|
+
statusBar?: boolean | IStatusBarProps;
|
|
47
|
+
defaultPageSize?: number;
|
|
48
|
+
defaultSortBy?: string;
|
|
49
|
+
defaultSortDirection?: 'asc' | 'desc';
|
|
50
|
+
toolbar?: ReactNode;
|
|
51
|
+
/** Secondary toolbar row rendered below the primary toolbar (e.g. active filter chips). */
|
|
52
|
+
toolbarBelow?: ReactNode;
|
|
53
|
+
emptyState?: {
|
|
54
|
+
message?: ReactNode;
|
|
55
|
+
render?: () => ReactNode;
|
|
56
|
+
};
|
|
57
|
+
entityLabelPlural?: string;
|
|
58
|
+
className?: string;
|
|
59
|
+
/** Where the column chooser renders.
|
|
60
|
+
* - `true` or `'toolbar'` (default): column chooser button in the toolbar strip.
|
|
61
|
+
* - `'sidebar'`: column chooser only available via the sidebar columns panel.
|
|
62
|
+
* - `false`: column chooser hidden entirely. */
|
|
63
|
+
columnChooser?: boolean | 'toolbar' | 'sidebar';
|
|
64
|
+
layoutMode?: 'content' | 'fill';
|
|
65
|
+
/** When true, horizontal scrolling is suppressed (overflow-x hidden). */
|
|
66
|
+
suppressHorizontalScroll?: boolean;
|
|
67
|
+
/** Side bar configuration. `true` shows default panels (columns + filters). Pass ISideBarDef for options. */
|
|
68
|
+
sideBar?: boolean | ISideBarDef;
|
|
69
|
+
/** Page size options shown in the pagination dropdown. Default: [10, 20, 50, 100]. */
|
|
70
|
+
pageSizeOptions?: number[];
|
|
71
|
+
/** Fires once when the grid first renders with data (useful for restoring column state). */
|
|
72
|
+
onFirstDataRendered?: () => void;
|
|
73
|
+
/** Called when server-side fetchPage fails. */
|
|
74
|
+
onError?: (error: unknown) => void;
|
|
75
|
+
/** Called when a cell renderer or custom editor throws an error. */
|
|
76
|
+
onCellError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
77
|
+
'aria-label'?: string;
|
|
78
|
+
'aria-labelledby'?: string;
|
|
79
|
+
}
|
|
80
|
+
/** Client-side mode: pass a data array. */
|
|
81
|
+
export interface IOGridClientProps<T> extends IOGridBaseProps<T> {
|
|
82
|
+
data: T[];
|
|
83
|
+
dataSource?: never;
|
|
84
|
+
}
|
|
85
|
+
/** Server-side mode: pass a dataSource. */
|
|
86
|
+
export interface IOGridServerProps<T> extends IOGridBaseProps<T> {
|
|
87
|
+
data?: never;
|
|
88
|
+
dataSource: IDataSource<T>;
|
|
89
|
+
}
|
|
90
|
+
/** Props for the OGrid wrapper component (shared across Fluent, Material, Radix).
|
|
91
|
+
* Must provide either `data` (client-side) or `dataSource` (server-side), not both. */
|
|
92
|
+
export type IOGridProps<T> = IOGridClientProps<T> | IOGridServerProps<T>;
|
|
93
|
+
/** Props passed from useOGrid to the framework-specific DataGridTable. */
|
|
94
|
+
export interface IOGridDataGridProps<T> {
|
|
95
|
+
items: T[];
|
|
96
|
+
columns: (IColumnDef<T> | IColumnGroupDef<T>)[];
|
|
97
|
+
getRowId: (item: T) => RowId;
|
|
98
|
+
sortBy?: string;
|
|
99
|
+
sortDirection: 'asc' | 'desc';
|
|
100
|
+
onColumnSort: (columnKey: string) => void;
|
|
101
|
+
visibleColumns: Set<string>;
|
|
102
|
+
/** Optional column display order (column ids). When set, visible columns are ordered by this array. */
|
|
103
|
+
columnOrder?: string[];
|
|
104
|
+
onColumnOrderChange?: (order: string[]) => void;
|
|
105
|
+
/** Called when a column is resized by the user. */
|
|
106
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
107
|
+
/** Called when a column is pinned or unpinned. */
|
|
108
|
+
onColumnPinned?: (columnId: string, pinned: 'left' | 'right' | null) => void;
|
|
109
|
+
/** Runtime pin overrides (from restored state or programmatic changes). */
|
|
110
|
+
pinnedColumns?: Record<string, 'left' | 'right'>;
|
|
111
|
+
/** Initial column width overrides (from restored state). */
|
|
112
|
+
initialColumnWidths?: Record<string, number>;
|
|
113
|
+
/** Number of rows to freeze (sticky), e.g. 1 = header row. */
|
|
114
|
+
freezeRows?: number;
|
|
115
|
+
/** Number of data columns to freeze (sticky left). */
|
|
116
|
+
freezeCols?: number;
|
|
117
|
+
layoutMode?: 'content' | 'fill';
|
|
118
|
+
/** When true, horizontal scrolling is suppressed (overflow-x hidden). */
|
|
119
|
+
suppressHorizontalScroll?: boolean;
|
|
120
|
+
isLoading?: boolean;
|
|
121
|
+
loadingMessage?: string;
|
|
122
|
+
editable?: boolean;
|
|
123
|
+
/** Enable spreadsheet-like cell selection. Default: true. */
|
|
124
|
+
cellSelection?: boolean;
|
|
125
|
+
onCellValueChanged?: (event: ICellValueChangedEvent<T>) => void;
|
|
126
|
+
onUndo?: () => void;
|
|
127
|
+
onRedo?: () => void;
|
|
128
|
+
canUndo?: boolean;
|
|
129
|
+
canRedo?: boolean;
|
|
130
|
+
rowSelection?: RowSelectionMode;
|
|
131
|
+
selectedRows?: Set<RowId>;
|
|
132
|
+
onSelectionChange?: (event: IRowSelectionChangeEvent<T>) => void;
|
|
133
|
+
statusBar?: IStatusBarProps;
|
|
134
|
+
/** Unified filter model (discriminated union values). */
|
|
135
|
+
filters: IFilters;
|
|
136
|
+
/** Single callback for all filter changes. Pass undefined to clear. */
|
|
137
|
+
onFilterChange: (key: string, value: FilterValue | undefined) => void;
|
|
138
|
+
filterOptions: Record<string, string[]>;
|
|
139
|
+
loadingFilterOptions: Record<string, boolean>;
|
|
140
|
+
peopleSearch?: (query: string) => Promise<UserLike[]>;
|
|
141
|
+
getUserByEmail?: (email: string) => Promise<UserLike | undefined>;
|
|
142
|
+
emptyState?: {
|
|
143
|
+
onClearAll: () => void;
|
|
144
|
+
hasActiveFilters: boolean;
|
|
145
|
+
message?: ReactNode;
|
|
146
|
+
render?: () => ReactNode;
|
|
147
|
+
};
|
|
148
|
+
/** Called when a cell renderer or custom editor throws an error. */
|
|
149
|
+
onCellError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
150
|
+
'aria-label'?: string;
|
|
151
|
+
'aria-labelledby'?: string;
|
|
152
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnDef, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, ICellEditorProps, CellEditorParams, IValueParserParams, IDateFilterValue, HeaderCell, HeaderRow, } from './columnTypes';
|
|
2
|
+
export type { RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, IOGridProps, IOGridClientProps, IOGridServerProps, IOGridDataGridProps, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, } from './dataGridTypes';
|
|
3
|
+
export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './dataGridTypes';
|