@alaarab/ogrid-core 1.9.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -20
- package/dist/esm/index.js +5 -15
- package/dist/esm/types/index.js +2 -1
- package/dist/esm/utils/clientSideData.js +1 -1
- package/dist/esm/utils/gridRowComparator.js +11 -1
- package/dist/esm/utils/index.js +1 -2
- package/dist/types/index.d.ts +3 -23
- package/dist/types/types/columnTypes.d.ts +3 -6
- package/dist/types/types/dataGridTypes.d.ts +1 -150
- package/dist/types/types/index.d.ts +3 -3
- package/dist/types/utils/gridRowComparator.d.ts +8 -0
- package/dist/types/utils/index.d.ts +1 -3
- package/package.json +6 -24
- package/dist/esm/components/BaseInlineCellEditor.js +0 -112
- package/dist/esm/components/CellErrorBoundary.js +0 -43
- package/dist/esm/components/EmptyState.js +0 -19
- package/dist/esm/components/GridContextMenu.js +0 -35
- package/dist/esm/components/MarchingAntsOverlay.js +0 -110
- package/dist/esm/components/OGridLayout.js +0 -91
- package/dist/esm/components/SideBar.js +0 -122
- package/dist/esm/components/StatusBar.js +0 -6
- package/dist/esm/hooks/index.js +0 -25
- package/dist/esm/hooks/useActiveCell.js +0 -62
- package/dist/esm/hooks/useCellEditing.js +0 -15
- package/dist/esm/hooks/useCellSelection.js +0 -324
- package/dist/esm/hooks/useClipboard.js +0 -162
- package/dist/esm/hooks/useColumnChooserState.js +0 -62
- package/dist/esm/hooks/useColumnHeaderFilterState.js +0 -180
- package/dist/esm/hooks/useColumnResize.js +0 -92
- package/dist/esm/hooks/useContextMenu.js +0 -21
- package/dist/esm/hooks/useDataGridState.js +0 -314
- package/dist/esm/hooks/useDateFilterState.js +0 -34
- package/dist/esm/hooks/useDebounce.js +0 -35
- package/dist/esm/hooks/useFillHandle.js +0 -196
- package/dist/esm/hooks/useFilterOptions.js +0 -40
- package/dist/esm/hooks/useInlineCellEditorState.js +0 -44
- package/dist/esm/hooks/useKeyboardNavigation.js +0 -420
- package/dist/esm/hooks/useLatestRef.js +0 -11
- package/dist/esm/hooks/useMultiSelectFilterState.js +0 -59
- package/dist/esm/hooks/useOGrid.js +0 -467
- package/dist/esm/hooks/usePeopleFilterState.js +0 -68
- package/dist/esm/hooks/useRichSelectState.js +0 -58
- package/dist/esm/hooks/useRowSelection.js +0 -78
- package/dist/esm/hooks/useSideBarState.js +0 -39
- package/dist/esm/hooks/useTableLayout.js +0 -77
- package/dist/esm/hooks/useTextFilterState.js +0 -25
- package/dist/esm/hooks/useUndoRedo.js +0 -83
- package/dist/esm/storybook/index.js +0 -1
- package/dist/esm/storybook/mockData.js +0 -73
- package/dist/esm/utils/dataGridViewModel.js +0 -233
- package/dist/types/components/BaseInlineCellEditor.d.ts +0 -33
- package/dist/types/components/CellErrorBoundary.d.ts +0 -25
- package/dist/types/components/EmptyState.d.ts +0 -26
- package/dist/types/components/GridContextMenu.d.ts +0 -18
- package/dist/types/components/MarchingAntsOverlay.d.ts +0 -15
- package/dist/types/components/OGridLayout.d.ts +0 -37
- package/dist/types/components/SideBar.d.ts +0 -30
- package/dist/types/components/StatusBar.d.ts +0 -24
- package/dist/types/hooks/index.d.ts +0 -48
- package/dist/types/hooks/useActiveCell.d.ts +0 -13
- package/dist/types/hooks/useCellEditing.d.ts +0 -16
- package/dist/types/hooks/useCellSelection.d.ts +0 -22
- package/dist/types/hooks/useClipboard.d.ts +0 -30
- package/dist/types/hooks/useColumnChooserState.d.ts +0 -27
- package/dist/types/hooks/useColumnHeaderFilterState.d.ts +0 -73
- package/dist/types/hooks/useColumnResize.d.ts +0 -23
- package/dist/types/hooks/useContextMenu.d.ts +0 -19
- package/dist/types/hooks/useDataGridState.d.ts +0 -137
- package/dist/types/hooks/useDateFilterState.d.ts +0 -19
- package/dist/types/hooks/useDebounce.d.ts +0 -9
- package/dist/types/hooks/useFillHandle.d.ts +0 -33
- package/dist/types/hooks/useFilterOptions.d.ts +0 -16
- package/dist/types/hooks/useInlineCellEditorState.d.ts +0 -24
- package/dist/types/hooks/useKeyboardNavigation.d.ts +0 -47
- package/dist/types/hooks/useLatestRef.d.ts +0 -6
- package/dist/types/hooks/useMultiSelectFilterState.d.ts +0 -24
- package/dist/types/hooks/useOGrid.d.ts +0 -52
- package/dist/types/hooks/usePeopleFilterState.d.ts +0 -25
- package/dist/types/hooks/useRichSelectState.d.ts +0 -22
- package/dist/types/hooks/useRowSelection.d.ts +0 -22
- package/dist/types/hooks/useSideBarState.d.ts +0 -20
- package/dist/types/hooks/useTableLayout.d.ts +0 -27
- package/dist/types/hooks/useTextFilterState.d.ts +0 -16
- package/dist/types/hooks/useUndoRedo.d.ts +0 -23
- package/dist/types/storybook/index.d.ts +0 -2
- package/dist/types/storybook/mockData.d.ts +0 -37
- package/dist/types/utils/dataGridViewModel.d.ts +0 -169
|
@@ -1,47 +0,0 @@
|
|
|
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;
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
@@ -1,52 +0,0 @@
|
|
|
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>;
|
|
@@ -1,25 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,22 +0,0 @@
|
|
|
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;
|
|
@@ -1,20 +0,0 @@
|
|
|
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;
|
|
@@ -1,27 +0,0 @@
|
|
|
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;
|
|
@@ -1,16 +0,0 @@
|
|
|
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;
|
|
@@ -1,23 +0,0 @@
|
|
|
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>;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { storyRows, storyGetRowId, noop, editableInitialRows, editableColumns, NotesPopupEditor, spreadsheetRows, spreadsheetColumns, departmentFilterOptions, statusFilterOptions, } from './mockData';
|
|
2
|
-
export type { StoryRow, EditableRow, RowWithNotes, SpreadsheetRow, } from './mockData';
|
|
@@ -1,37 +0,0 @@
|
|
|
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[];
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* View model helpers for DataGridTable. Core owns the logic; UI packages only render.
|
|
3
|
-
*/
|
|
4
|
-
import type * as React from 'react';
|
|
5
|
-
import type { ColumnFilterType, ICellEditorProps, IDateFilterValue } from '../types/columnTypes';
|
|
6
|
-
import type { IColumnDef } from '../types/columnTypes';
|
|
7
|
-
import type { RowId, UserLike, IFilters, FilterValue } from '../types/dataGridTypes';
|
|
8
|
-
export interface HeaderFilterConfigInput {
|
|
9
|
-
sortBy?: string;
|
|
10
|
-
sortDirection: 'asc' | 'desc';
|
|
11
|
-
onColumnSort: (columnKey: string) => void;
|
|
12
|
-
filters: IFilters;
|
|
13
|
-
onFilterChange: (key: string, value: FilterValue | undefined) => void;
|
|
14
|
-
filterOptions: Record<string, string[]>;
|
|
15
|
-
loadingFilterOptions: Record<string, boolean>;
|
|
16
|
-
peopleSearch?: (query: string) => Promise<UserLike[]>;
|
|
17
|
-
}
|
|
18
|
-
/** Props to pass to ColumnHeaderFilter. Matches IColumnHeaderFilterProps. */
|
|
19
|
-
export interface HeaderFilterConfig {
|
|
20
|
-
columnKey: string;
|
|
21
|
-
columnName: string;
|
|
22
|
-
filterType: ColumnFilterType;
|
|
23
|
-
isSorted?: boolean;
|
|
24
|
-
isSortedDescending?: boolean;
|
|
25
|
-
onSort?: () => void;
|
|
26
|
-
selectedValues?: string[];
|
|
27
|
-
onFilterChange?: (values: string[]) => void;
|
|
28
|
-
options?: string[];
|
|
29
|
-
isLoadingOptions?: boolean;
|
|
30
|
-
textValue?: string;
|
|
31
|
-
onTextChange?: (value: string) => void;
|
|
32
|
-
selectedUser?: UserLike;
|
|
33
|
-
onUserChange?: (user: UserLike | undefined) => void;
|
|
34
|
-
peopleSearch?: (query: string) => Promise<UserLike[]>;
|
|
35
|
-
dateValue?: IDateFilterValue;
|
|
36
|
-
onDateChange?: (value: IDateFilterValue | undefined) => void;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns ColumnHeaderFilter props from column def and grid filter/sort state.
|
|
40
|
-
* Use in Fluent/Material/Radix DataGridTable instead of createHeaderWithFilter.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getHeaderFilterConfig<T>(col: IColumnDef<T>, input: HeaderFilterConfigInput): HeaderFilterConfig;
|
|
43
|
-
/**
|
|
44
|
-
* Checks whether a given row index falls within a selection range.
|
|
45
|
-
* O(1) — used by React.memo comparators to skip unchanged rows.
|
|
46
|
-
*/
|
|
47
|
-
export declare function isRowInRange(range: {
|
|
48
|
-
startRow: number;
|
|
49
|
-
endRow: number;
|
|
50
|
-
} | null, rowIndex: number): boolean;
|
|
51
|
-
export type CellRenderMode = 'editing-inline' | 'editing-popover' | 'display';
|
|
52
|
-
export interface CellRenderDescriptorInput<T> {
|
|
53
|
-
editingCell: {
|
|
54
|
-
rowId: RowId;
|
|
55
|
-
columnId: string;
|
|
56
|
-
} | null;
|
|
57
|
-
activeCell: {
|
|
58
|
-
rowIndex: number;
|
|
59
|
-
columnIndex: number;
|
|
60
|
-
} | null;
|
|
61
|
-
selectionRange: {
|
|
62
|
-
startRow: number;
|
|
63
|
-
startCol: number;
|
|
64
|
-
endRow: number;
|
|
65
|
-
endCol: number;
|
|
66
|
-
} | null;
|
|
67
|
-
cutRange: {
|
|
68
|
-
startRow: number;
|
|
69
|
-
startCol: number;
|
|
70
|
-
endRow: number;
|
|
71
|
-
endCol: number;
|
|
72
|
-
} | null;
|
|
73
|
-
copyRange: {
|
|
74
|
-
startRow: number;
|
|
75
|
-
startCol: number;
|
|
76
|
-
endRow: number;
|
|
77
|
-
endCol: number;
|
|
78
|
-
} | null;
|
|
79
|
-
colOffset: number;
|
|
80
|
-
itemsLength: number;
|
|
81
|
-
getRowId: (item: T) => RowId;
|
|
82
|
-
editable?: boolean;
|
|
83
|
-
onCellValueChanged?: (event: import('../types/columnTypes').ICellValueChangedEvent<T>) => void;
|
|
84
|
-
/** True while user is drag-selecting cells — hides fill handle during drag. */
|
|
85
|
-
isDragging?: boolean;
|
|
86
|
-
}
|
|
87
|
-
export interface CellRenderDescriptor {
|
|
88
|
-
mode: CellRenderMode;
|
|
89
|
-
editorType?: 'text' | 'select' | 'checkbox' | 'richSelect' | 'date';
|
|
90
|
-
value?: unknown;
|
|
91
|
-
isActive: boolean;
|
|
92
|
-
isInRange: boolean;
|
|
93
|
-
isInCutRange: boolean;
|
|
94
|
-
isInCopyRange: boolean;
|
|
95
|
-
isSelectionEndCell: boolean;
|
|
96
|
-
canEditAny: boolean;
|
|
97
|
-
isPinned: boolean;
|
|
98
|
-
pinnedSide?: 'left' | 'right';
|
|
99
|
-
globalColIndex: number;
|
|
100
|
-
rowId: RowId;
|
|
101
|
-
rowIndex: number;
|
|
102
|
-
/** Raw value for display (when mode === 'display'). UI uses col.renderCell or col.valueFormatter. */
|
|
103
|
-
displayValue?: unknown;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Returns a descriptor for rendering a cell. UI uses this to decide editing-inline vs editing-popover vs display
|
|
107
|
-
* and to apply isActive, isInRange, etc. without duplicating the boolean logic.
|
|
108
|
-
*/
|
|
109
|
-
export declare function getCellRenderDescriptor<T>(item: T, col: IColumnDef<T>, rowIndex: number, colIdx: number, input: CellRenderDescriptorInput<T>): CellRenderDescriptor;
|
|
110
|
-
/**
|
|
111
|
-
* Resolves display content for a cell in display mode.
|
|
112
|
-
* Handles the renderCell → valueFormatter → String() fallback chain.
|
|
113
|
-
*/
|
|
114
|
-
export declare function resolveCellDisplayContent<T>(col: IColumnDef<T>, item: T, displayValue: unknown): React.ReactNode;
|
|
115
|
-
/**
|
|
116
|
-
* Resolves the cellStyle from a column def, handling both function and static values.
|
|
117
|
-
*/
|
|
118
|
-
export declare function resolveCellStyle<T>(col: IColumnDef<T>, item: T): React.CSSProperties | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* Builds props for InlineCellEditor. Shared across all UI packages.
|
|
121
|
-
*/
|
|
122
|
-
export declare function buildInlineEditorProps<T>(item: T, col: IColumnDef<T>, descriptor: CellRenderDescriptor, callbacks: {
|
|
123
|
-
commitCellEdit: (item: T, columnId: string, oldValue: unknown, newValue: unknown, rowIndex: number, globalColIndex: number) => void;
|
|
124
|
-
setEditingCell: (cell: null) => void;
|
|
125
|
-
}): {
|
|
126
|
-
value: unknown;
|
|
127
|
-
item: T;
|
|
128
|
-
column: IColumnDef<T>;
|
|
129
|
-
rowIndex: number;
|
|
130
|
-
editorType: "text" | "select" | "checkbox" | "richSelect" | "date";
|
|
131
|
-
onCommit: (newValue: unknown) => void;
|
|
132
|
-
onCancel: () => void;
|
|
133
|
-
};
|
|
134
|
-
/**
|
|
135
|
-
* Builds ICellEditorProps for custom popover editors. Shared across all UI packages.
|
|
136
|
-
*/
|
|
137
|
-
export declare function buildPopoverEditorProps<T>(item: T, col: IColumnDef<T>, descriptor: CellRenderDescriptor, pendingEditorValue: unknown, callbacks: {
|
|
138
|
-
setPendingEditorValue: (value: unknown) => void;
|
|
139
|
-
commitCellEdit: (item: T, columnId: string, oldValue: unknown, newValue: unknown, rowIndex: number, globalColIndex: number) => void;
|
|
140
|
-
cancelPopoverEdit: () => void;
|
|
141
|
-
}): ICellEditorProps<T>;
|
|
142
|
-
/**
|
|
143
|
-
* Common interaction props for cell wrapper elements.
|
|
144
|
-
* Includes data attributes, event handlers, and accessibility props.
|
|
145
|
-
* Spread onto the cell wrapper div/Box in each UI package.
|
|
146
|
-
*/
|
|
147
|
-
export interface CellInteractionHandlers {
|
|
148
|
-
handleCellMouseDown: (e: React.MouseEvent, rowIndex: number, colIndex: number) => void;
|
|
149
|
-
setActiveCell: (cell: {
|
|
150
|
-
rowIndex: number;
|
|
151
|
-
columnIndex: number;
|
|
152
|
-
}) => void;
|
|
153
|
-
setEditingCell: (cell: {
|
|
154
|
-
rowId: RowId;
|
|
155
|
-
columnId: string;
|
|
156
|
-
} | null) => void;
|
|
157
|
-
handleCellContextMenu: (e: React.MouseEvent) => void;
|
|
158
|
-
}
|
|
159
|
-
export declare function getCellInteractionProps(descriptor: CellRenderDescriptor, columnId: string, handlers: CellInteractionHandlers): {
|
|
160
|
-
role?: "button" | undefined;
|
|
161
|
-
onDoubleClick?: (() => void) | undefined;
|
|
162
|
-
tabIndex: number;
|
|
163
|
-
onMouseDown: (e: React.MouseEvent) => void;
|
|
164
|
-
onClick: () => void;
|
|
165
|
-
onContextMenu: (e: React.MouseEvent) => void;
|
|
166
|
-
'data-in-range'?: "true" | undefined;
|
|
167
|
-
'data-row-index': number;
|
|
168
|
-
'data-col-index': number;
|
|
169
|
-
};
|