@alaarab/ogrid-vue 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/components/SideBar.js +1 -0
- package/dist/esm/composables/index.js +27 -0
- package/dist/esm/composables/useActiveCell.js +58 -0
- package/dist/esm/composables/useCellEditing.js +20 -0
- package/dist/esm/composables/useCellSelection.js +281 -0
- package/dist/esm/composables/useClipboard.js +147 -0
- package/dist/esm/composables/useColumnChooserState.js +77 -0
- package/dist/esm/composables/useColumnHeaderFilterState.js +186 -0
- package/dist/esm/composables/useColumnResize.js +73 -0
- package/dist/esm/composables/useContextMenu.js +23 -0
- package/dist/esm/composables/useDataGridState.js +308 -0
- package/dist/esm/composables/useDateFilterState.js +36 -0
- package/dist/esm/composables/useDebounce.js +42 -0
- package/dist/esm/composables/useFillHandle.js +175 -0
- package/dist/esm/composables/useFilterOptions.js +39 -0
- package/dist/esm/composables/useInlineCellEditorState.js +42 -0
- package/dist/esm/composables/useKeyboardNavigation.js +353 -0
- package/dist/esm/composables/useMultiSelectFilterState.js +59 -0
- package/dist/esm/composables/useOGrid.js +406 -0
- package/dist/esm/composables/usePeopleFilterState.js +66 -0
- package/dist/esm/composables/useRichSelectState.js +59 -0
- package/dist/esm/composables/useRowSelection.js +75 -0
- package/dist/esm/composables/useSideBarState.js +41 -0
- package/dist/esm/composables/useTableLayout.js +85 -0
- package/dist/esm/composables/useTextFilterState.js +26 -0
- package/dist/esm/composables/useUndoRedo.js +75 -0
- package/dist/esm/index.js +7 -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 +195 -0
- package/dist/esm/utils/index.js +1 -0
- package/dist/types/components/SideBar.d.ts +26 -0
- package/dist/types/composables/index.d.ts +47 -0
- package/dist/types/composables/useActiveCell.d.ts +14 -0
- package/dist/types/composables/useCellEditing.d.ts +16 -0
- package/dist/types/composables/useCellSelection.d.ts +20 -0
- package/dist/types/composables/useClipboard.d.ts +25 -0
- package/dist/types/composables/useColumnChooserState.d.ts +22 -0
- package/dist/types/composables/useColumnHeaderFilterState.d.ts +68 -0
- package/dist/types/composables/useColumnResize.d.ts +21 -0
- package/dist/types/composables/useContextMenu.d.ts +19 -0
- package/dist/types/composables/useDataGridState.d.ts +129 -0
- package/dist/types/composables/useDateFilterState.d.ts +16 -0
- package/dist/types/composables/useDebounce.d.ts +10 -0
- package/dist/types/composables/useFillHandle.d.ts +30 -0
- package/dist/types/composables/useFilterOptions.d.ts +15 -0
- package/dist/types/composables/useInlineCellEditorState.d.ts +20 -0
- package/dist/types/composables/useKeyboardNavigation.d.ts +46 -0
- package/dist/types/composables/useMultiSelectFilterState.d.ts +20 -0
- package/dist/types/composables/useOGrid.d.ts +52 -0
- package/dist/types/composables/usePeopleFilterState.d.ts +20 -0
- package/dist/types/composables/useRichSelectState.d.ts +21 -0
- package/dist/types/composables/useRowSelection.d.ts +21 -0
- package/dist/types/composables/useSideBarState.d.ts +19 -0
- package/dist/types/composables/useTableLayout.d.ts +27 -0
- package/dist/types/composables/useTextFilterState.d.ts +13 -0
- package/dist/types/composables/useUndoRedo.d.ts +21 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/types/columnTypes.d.ts +25 -0
- package/dist/types/types/dataGridTypes.d.ts +151 -0
- package/dist/types/types/index.d.ts +3 -0
- package/dist/types/utils/dataGridViewModel.d.ts +137 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/package.json +38 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { IColumnDef } from '../types';
|
|
3
|
+
export interface UseColumnResizeParams {
|
|
4
|
+
columnSizingOverrides: Ref<Record<string, {
|
|
5
|
+
widthPx: number;
|
|
6
|
+
}>>;
|
|
7
|
+
setColumnSizingOverrides: (value: Record<string, {
|
|
8
|
+
widthPx: number;
|
|
9
|
+
}>) => void;
|
|
10
|
+
minWidth?: number;
|
|
11
|
+
defaultWidth?: number;
|
|
12
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
13
|
+
}
|
|
14
|
+
export interface UseColumnResizeResult<T> {
|
|
15
|
+
handleResizeStart: (e: MouseEvent, col: IColumnDef<T>) => void;
|
|
16
|
+
getColumnWidth: (col: IColumnDef<T>) => number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Manages column resize drag interactions with RAF-throttled state updates.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useColumnResize<T>(params: UseColumnResizeParams): UseColumnResizeResult<T>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface ContextMenuPosition {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
}
|
|
6
|
+
export interface UseContextMenuResult {
|
|
7
|
+
contextMenuPosition: Ref<ContextMenuPosition | null>;
|
|
8
|
+
setContextMenuPosition: (pos: ContextMenuPosition | null) => void;
|
|
9
|
+
handleCellContextMenu: (e: {
|
|
10
|
+
clientX: number;
|
|
11
|
+
clientY: number;
|
|
12
|
+
preventDefault?: () => void;
|
|
13
|
+
}) => void;
|
|
14
|
+
closeContextMenu: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Manages context menu position state for right-click menus.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useContextMenu(): UseContextMenuResult;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type { RowId, IOGridDataGridProps, IStatusBarProps, IColumnDef } from '../types';
|
|
3
|
+
import type { HeaderFilterConfigInput, CellRenderDescriptorInput } from '../utils';
|
|
4
|
+
export interface UseDataGridStateParams<T> {
|
|
5
|
+
props: Ref<IOGridDataGridProps<T>>;
|
|
6
|
+
wrapperRef: Ref<HTMLDivElement | null> | ShallowRef<HTMLDivElement | null>;
|
|
7
|
+
}
|
|
8
|
+
export interface DataGridLayoutState<T> {
|
|
9
|
+
flatColumns: IColumnDef<T>[];
|
|
10
|
+
visibleCols: IColumnDef<T>[];
|
|
11
|
+
visibleColumnCount: number;
|
|
12
|
+
totalColCount: number;
|
|
13
|
+
colOffset: number;
|
|
14
|
+
hasCheckboxCol: boolean;
|
|
15
|
+
rowIndexByRowId: Map<RowId, number>;
|
|
16
|
+
containerWidth: number;
|
|
17
|
+
minTableWidth: number;
|
|
18
|
+
desiredTableWidth: number;
|
|
19
|
+
columnSizingOverrides: Record<string, {
|
|
20
|
+
widthPx: number;
|
|
21
|
+
}>;
|
|
22
|
+
setColumnSizingOverrides: (value: Record<string, {
|
|
23
|
+
widthPx: number;
|
|
24
|
+
}>) => void;
|
|
25
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
26
|
+
}
|
|
27
|
+
export interface DataGridRowSelectionState {
|
|
28
|
+
selectedRowIds: Set<RowId>;
|
|
29
|
+
updateSelection: (newSelectedIds: Set<RowId>) => void;
|
|
30
|
+
handleRowCheckboxChange: (rowId: RowId, checked: boolean, rowIndex: number, shiftKey: boolean) => void;
|
|
31
|
+
handleSelectAll: (checked: boolean) => void;
|
|
32
|
+
allSelected: boolean;
|
|
33
|
+
someSelected: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface DataGridEditingState<T> {
|
|
36
|
+
editingCell: {
|
|
37
|
+
rowId: RowId;
|
|
38
|
+
columnId: string;
|
|
39
|
+
} | null;
|
|
40
|
+
setEditingCell: (cell: {
|
|
41
|
+
rowId: RowId;
|
|
42
|
+
columnId: string;
|
|
43
|
+
} | null) => void;
|
|
44
|
+
pendingEditorValue: unknown;
|
|
45
|
+
setPendingEditorValue: (value: unknown) => void;
|
|
46
|
+
commitCellEdit: (item: T, columnId: string, oldValue: unknown, newValue: unknown, rowIndex: number, globalColIndex: number) => void;
|
|
47
|
+
cancelPopoverEdit: () => void;
|
|
48
|
+
popoverAnchorEl: HTMLElement | null;
|
|
49
|
+
setPopoverAnchorEl: (el: HTMLElement | null) => void;
|
|
50
|
+
}
|
|
51
|
+
export interface DataGridCellInteractionState {
|
|
52
|
+
activeCell: {
|
|
53
|
+
rowIndex: number;
|
|
54
|
+
columnIndex: number;
|
|
55
|
+
} | null;
|
|
56
|
+
setActiveCell: (cell: {
|
|
57
|
+
rowIndex: number;
|
|
58
|
+
columnIndex: number;
|
|
59
|
+
} | null) => void;
|
|
60
|
+
selectionRange: {
|
|
61
|
+
startRow: number;
|
|
62
|
+
startCol: number;
|
|
63
|
+
endRow: number;
|
|
64
|
+
endCol: number;
|
|
65
|
+
} | null;
|
|
66
|
+
setSelectionRange: (range: DataGridCellInteractionState['selectionRange']) => void;
|
|
67
|
+
handleCellMouseDown: (e: MouseEvent, rowIndex: number, globalColIndex: number) => void;
|
|
68
|
+
handleSelectAllCells: () => void;
|
|
69
|
+
hasCellSelection: boolean;
|
|
70
|
+
handleGridKeyDown: (e: KeyboardEvent) => void;
|
|
71
|
+
handleFillHandleMouseDown: (e: MouseEvent) => void;
|
|
72
|
+
handleCopy: () => void;
|
|
73
|
+
handleCut: () => void;
|
|
74
|
+
handlePaste: () => Promise<void>;
|
|
75
|
+
cutRange: {
|
|
76
|
+
startRow: number;
|
|
77
|
+
startCol: number;
|
|
78
|
+
endRow: number;
|
|
79
|
+
endCol: number;
|
|
80
|
+
} | null;
|
|
81
|
+
copyRange: {
|
|
82
|
+
startRow: number;
|
|
83
|
+
startCol: number;
|
|
84
|
+
endRow: number;
|
|
85
|
+
endCol: number;
|
|
86
|
+
} | null;
|
|
87
|
+
clearClipboardRanges: () => void;
|
|
88
|
+
canUndo: boolean;
|
|
89
|
+
canRedo: boolean;
|
|
90
|
+
onUndo?: () => void;
|
|
91
|
+
onRedo?: () => void;
|
|
92
|
+
isDragging: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface DataGridContextMenuState {
|
|
95
|
+
menuPosition: {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
} | null;
|
|
99
|
+
setMenuPosition: (pos: {
|
|
100
|
+
x: number;
|
|
101
|
+
y: number;
|
|
102
|
+
} | null) => void;
|
|
103
|
+
handleCellContextMenu: (e: {
|
|
104
|
+
clientX: number;
|
|
105
|
+
clientY: number;
|
|
106
|
+
preventDefault?: () => void;
|
|
107
|
+
}) => void;
|
|
108
|
+
closeContextMenu: () => void;
|
|
109
|
+
}
|
|
110
|
+
export interface DataGridViewModelState<T> {
|
|
111
|
+
headerFilterInput: HeaderFilterConfigInput;
|
|
112
|
+
cellDescriptorInput: CellRenderDescriptorInput<T>;
|
|
113
|
+
statusBarConfig: IStatusBarProps | null;
|
|
114
|
+
showEmptyInGrid: boolean;
|
|
115
|
+
onCellError?: (error: Error, info: unknown) => void;
|
|
116
|
+
}
|
|
117
|
+
export interface UseDataGridStateResult<T> {
|
|
118
|
+
layout: Ref<DataGridLayoutState<T>>;
|
|
119
|
+
rowSelection: Ref<DataGridRowSelectionState>;
|
|
120
|
+
editing: Ref<DataGridEditingState<T>>;
|
|
121
|
+
interaction: Ref<DataGridCellInteractionState>;
|
|
122
|
+
contextMenu: Ref<DataGridContextMenuState>;
|
|
123
|
+
viewModels: Ref<DataGridViewModelState<T>>;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Single orchestration composable for DataGridTable. Takes grid props and wrapper ref,
|
|
127
|
+
* returns all derived state and handlers so UI packages can be thin view layers.
|
|
128
|
+
*/
|
|
129
|
+
export declare function useDataGridState<T>(params: UseDataGridStateParams<T>): UseDataGridStateResult<T>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
import type { IDateFilterValue } from '../types';
|
|
3
|
+
export interface UseDateFilterStateParams {
|
|
4
|
+
dateValue?: IDateFilterValue;
|
|
5
|
+
onDateChange?: (value: IDateFilterValue | undefined) => void;
|
|
6
|
+
isFilterOpen: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseDateFilterStateResult {
|
|
9
|
+
tempDateFrom: ReturnType<typeof ref<string>>;
|
|
10
|
+
setTempDateFrom: (v: string) => void;
|
|
11
|
+
tempDateTo: ReturnType<typeof ref<string>>;
|
|
12
|
+
setTempDateTo: (v: string) => void;
|
|
13
|
+
handleDateApply: () => void;
|
|
14
|
+
handleDateClear: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function useDateFilterState(params: UseDateFilterStateParams): UseDateFilterStateResult;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Returns a debounced ref that updates after the specified delay when the source value changes.
|
|
4
|
+
*/
|
|
5
|
+
export declare function useDebounce<T>(value: Ref<T>, delayMs: number): Ref<T>;
|
|
6
|
+
/**
|
|
7
|
+
* Returns a stable callback that invokes the given function after the specified delay.
|
|
8
|
+
* Each new call resets the timer.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useDebouncedCallback<T extends (...args: unknown[]) => void>(fn: T, delayMs: number): T;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type { ISelectionRange, IActiveCell, IColumnDef, ICellValueChangedEvent } from '../types';
|
|
3
|
+
export interface UseFillHandleParams<T> {
|
|
4
|
+
items: Ref<T[]>;
|
|
5
|
+
visibleCols: Ref<IColumnDef<T>[]>;
|
|
6
|
+
editable: Ref<boolean | undefined>;
|
|
7
|
+
onCellValueChanged: Ref<((event: ICellValueChangedEvent<T>) => void) | undefined>;
|
|
8
|
+
selectionRange: Ref<ISelectionRange | null>;
|
|
9
|
+
setSelectionRange: (range: ISelectionRange | null) => void;
|
|
10
|
+
setActiveCell: (cell: IActiveCell | null) => void;
|
|
11
|
+
colOffset: number;
|
|
12
|
+
wrapperRef: Ref<HTMLElement | null> | ShallowRef<HTMLElement | null>;
|
|
13
|
+
beginBatch?: () => void;
|
|
14
|
+
endBatch?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export interface UseFillHandleResult {
|
|
17
|
+
fillDrag: Ref<{
|
|
18
|
+
startRow: number;
|
|
19
|
+
startCol: number;
|
|
20
|
+
} | null>;
|
|
21
|
+
setFillDrag: (value: {
|
|
22
|
+
startRow: number;
|
|
23
|
+
startCol: number;
|
|
24
|
+
} | null) => void;
|
|
25
|
+
handleFillHandleMouseDown: (e: MouseEvent) => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Manages Excel-style fill handle drag-to-fill for cell ranges.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useFillHandle<T>(params: UseFillHandleParams<T>): UseFillHandleResult;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { IDataSource } from '../types';
|
|
3
|
+
export interface UseFilterOptionsResult {
|
|
4
|
+
filterOptions: Ref<Record<string, string[]>>;
|
|
5
|
+
loadingOptions: Ref<Record<string, boolean>>;
|
|
6
|
+
}
|
|
7
|
+
/** Accepted data source shapes for useFilterOptions. */
|
|
8
|
+
type FilterOptionsSource = IDataSource<unknown> | {
|
|
9
|
+
fetchFilterOptions?: (field: string) => Promise<string[]>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Load filter options for the given fields from a data source.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useFilterOptions(dataSource: Ref<FilterOptionsSource>, fields: Ref<string[]>): UseFilterOptionsResult;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
export type InlineCellEditorType = 'text' | 'select' | 'checkbox' | 'richSelect' | 'date';
|
|
3
|
+
export interface UseInlineCellEditorStateParams {
|
|
4
|
+
value: unknown;
|
|
5
|
+
editorType: InlineCellEditorType;
|
|
6
|
+
onCommit: (value: unknown) => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseInlineCellEditorStateResult {
|
|
10
|
+
localValue: ReturnType<typeof ref<string>>;
|
|
11
|
+
setLocalValue: (value: string) => void;
|
|
12
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
13
|
+
handleBlur: () => void;
|
|
14
|
+
commit: (value: unknown) => void;
|
|
15
|
+
cancel: () => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Returns localValue/setLocalValue, handleKeyDown, handleBlur, commit, cancel.
|
|
19
|
+
*/
|
|
20
|
+
export declare function useInlineCellEditorState(params: UseInlineCellEditorStateParams): UseInlineCellEditorStateResult;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type { RowId, IActiveCell, ISelectionRange, IColumnDef, ICellValueChangedEvent, RowSelectionMode } from '../types';
|
|
3
|
+
import type { EditingCell } from './useCellEditing';
|
|
4
|
+
import type { ContextMenuPosition } from './useContextMenu';
|
|
5
|
+
export interface UseKeyboardNavigationParams<T> {
|
|
6
|
+
data: {
|
|
7
|
+
items: Ref<T[]>;
|
|
8
|
+
visibleCols: Ref<IColumnDef<T>[]>;
|
|
9
|
+
colOffset: number;
|
|
10
|
+
hasCheckboxCol: Ref<boolean>;
|
|
11
|
+
visibleColumnCount: Ref<number>;
|
|
12
|
+
getRowId: (item: T) => RowId;
|
|
13
|
+
};
|
|
14
|
+
state: {
|
|
15
|
+
activeCell: Ref<IActiveCell | null>;
|
|
16
|
+
selectionRange: Ref<ISelectionRange | null>;
|
|
17
|
+
editingCell: Ref<EditingCell | null>;
|
|
18
|
+
selectedRowIds: Ref<Set<RowId>>;
|
|
19
|
+
};
|
|
20
|
+
handlers: {
|
|
21
|
+
setActiveCell: (cell: IActiveCell | null) => void;
|
|
22
|
+
setSelectionRange: (range: ISelectionRange | null) => void;
|
|
23
|
+
setEditingCell: (cell: EditingCell | null) => void;
|
|
24
|
+
handleRowCheckboxChange: (rowId: RowId, checked: boolean, rowIndex: number, shiftKey: boolean) => void;
|
|
25
|
+
handleCopy: () => void;
|
|
26
|
+
handleCut: () => void;
|
|
27
|
+
handlePaste: () => Promise<void>;
|
|
28
|
+
setContextMenu: (pos: ContextMenuPosition | null) => void;
|
|
29
|
+
onUndo?: () => void;
|
|
30
|
+
onRedo?: () => void;
|
|
31
|
+
clearClipboardRanges?: () => void;
|
|
32
|
+
};
|
|
33
|
+
features: {
|
|
34
|
+
editable: Ref<boolean | undefined>;
|
|
35
|
+
onCellValueChanged: Ref<((event: ICellValueChangedEvent<T>) => void) | undefined>;
|
|
36
|
+
rowSelection: Ref<RowSelectionMode>;
|
|
37
|
+
wrapperRef: Ref<HTMLElement | null> | ShallowRef<HTMLElement | null>;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export interface UseKeyboardNavigationResult {
|
|
41
|
+
handleGridKeyDown: (e: KeyboardEvent) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Handles all keyboard navigation, shortcuts, and cell editing triggers for the grid.
|
|
45
|
+
*/
|
|
46
|
+
export declare function useKeyboardNavigation<T>(params: UseKeyboardNavigationParams<T>): UseKeyboardNavigationResult;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseMultiSelectFilterStateParams {
|
|
3
|
+
selectedValues?: string[];
|
|
4
|
+
onFilterChange?: (values: string[]) => void;
|
|
5
|
+
options?: string[];
|
|
6
|
+
isFilterOpen: () => boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface UseMultiSelectFilterStateResult {
|
|
9
|
+
tempSelected: Ref<Set<string>>;
|
|
10
|
+
setTempSelected: (v: Set<string>) => void;
|
|
11
|
+
searchText: Ref<string>;
|
|
12
|
+
setSearchText: (v: string) => void;
|
|
13
|
+
debouncedSearchText: Ref<string>;
|
|
14
|
+
filteredOptions: Ref<string[]>;
|
|
15
|
+
handleCheckboxChange: (option: string, checked: boolean) => void;
|
|
16
|
+
handleSelectAll: () => void;
|
|
17
|
+
handleClearSelection: () => void;
|
|
18
|
+
handleApplyMultiSelect: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function useMultiSelectFilterState(params: UseMultiSelectFilterStateParams): UseMultiSelectFilterStateResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
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: unknown;
|
|
26
|
+
toolbarBelow: unknown;
|
|
27
|
+
className?: string;
|
|
28
|
+
emptyState?: {
|
|
29
|
+
message?: unknown;
|
|
30
|
+
render?: () => unknown;
|
|
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: Ref<IOGridDataGridProps<T>>;
|
|
41
|
+
pagination: Ref<UseOGridPagination>;
|
|
42
|
+
columnChooser: Ref<UseOGridColumnChooser>;
|
|
43
|
+
layout: Ref<UseOGridLayout>;
|
|
44
|
+
filters: Ref<UseOGridFilters>;
|
|
45
|
+
/** Imperative API object for programmatic grid control. */
|
|
46
|
+
api: Ref<IOGridApi<T>>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Top-level orchestration composable for OGrid: manages pagination, sorting, filtering,
|
|
50
|
+
* column visibility, and sidebar.
|
|
51
|
+
*/
|
|
52
|
+
export declare function useOGrid<T>(props: Ref<IOGridProps<T>>): UseOGridResult<T>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { UserLike } from '../types';
|
|
3
|
+
import type { ColumnFilterType } from '../types';
|
|
4
|
+
export interface UsePeopleFilterStateParams {
|
|
5
|
+
selectedUser?: UserLike;
|
|
6
|
+
onUserChange?: (user: UserLike | undefined) => void;
|
|
7
|
+
peopleSearch?: (query: string) => Promise<UserLike[]>;
|
|
8
|
+
isFilterOpen: () => boolean;
|
|
9
|
+
filterType: ColumnFilterType;
|
|
10
|
+
}
|
|
11
|
+
export interface UsePeopleFilterStateResult {
|
|
12
|
+
peopleSuggestions: Ref<UserLike[]>;
|
|
13
|
+
isPeopleLoading: Ref<boolean>;
|
|
14
|
+
peopleSearchText: Ref<string>;
|
|
15
|
+
setPeopleSearchText: (v: string) => void;
|
|
16
|
+
peopleInputRef: Ref<HTMLInputElement | null>;
|
|
17
|
+
handleUserSelect: (user: UserLike) => void;
|
|
18
|
+
handleClearUser: () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function usePeopleFilterState(params: UsePeopleFilterStateParams): UsePeopleFilterStateResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
export interface UseRichSelectStateParams {
|
|
3
|
+
values: unknown[];
|
|
4
|
+
formatValue?: (value: unknown) => string;
|
|
5
|
+
initialValue: unknown;
|
|
6
|
+
onCommit: (value: unknown) => void;
|
|
7
|
+
onCancel: () => void;
|
|
8
|
+
}
|
|
9
|
+
export interface UseRichSelectStateResult {
|
|
10
|
+
searchText: Ref<string>;
|
|
11
|
+
setSearchText: (text: string) => void;
|
|
12
|
+
filteredValues: Ref<unknown[]>;
|
|
13
|
+
highlightedIndex: Ref<number>;
|
|
14
|
+
handleKeyDown: (e: KeyboardEvent) => void;
|
|
15
|
+
selectValue: (value: unknown) => void;
|
|
16
|
+
getDisplayText: (value: unknown) => string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Manages searchable rich select editor state with keyboard navigation.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useRichSelectState(params: UseRichSelectStateParams): UseRichSelectStateResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { RowId, RowSelectionMode, IRowSelectionChangeEvent } from '../types';
|
|
3
|
+
export interface UseRowSelectionParams<T> {
|
|
4
|
+
items: Ref<T[]>;
|
|
5
|
+
getRowId: (item: T) => RowId;
|
|
6
|
+
rowSelection: Ref<RowSelectionMode>;
|
|
7
|
+
controlledSelectedRows: Ref<Set<RowId> | undefined>;
|
|
8
|
+
onSelectionChange: ((event: IRowSelectionChangeEvent<T>) => void) | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface UseRowSelectionResult {
|
|
11
|
+
selectedRowIds: Ref<Set<RowId>>;
|
|
12
|
+
updateSelection: (newSelectedIds: Set<RowId>) => void;
|
|
13
|
+
handleRowCheckboxChange: (rowId: RowId, checked: boolean, rowIndex: number, shiftKey: boolean) => void;
|
|
14
|
+
handleSelectAll: (checked: boolean) => void;
|
|
15
|
+
allSelected: Ref<boolean>;
|
|
16
|
+
someSelected: Ref<boolean>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Manages row selection state for single or multiple selection modes with shift-click range support.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useRowSelection<T>(params: UseRowSelectionParams<T>): UseRowSelectionResult;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { SideBarPanelId, ISideBarDef } from '../types';
|
|
3
|
+
export interface UseSideBarStateParams {
|
|
4
|
+
config: boolean | ISideBarDef | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface UseSideBarStateResult {
|
|
7
|
+
isEnabled: boolean;
|
|
8
|
+
activePanel: Ref<SideBarPanelId | null>;
|
|
9
|
+
setActivePanel: (panel: SideBarPanelId | null) => void;
|
|
10
|
+
panels: SideBarPanelId[];
|
|
11
|
+
position: 'left' | 'right';
|
|
12
|
+
isOpen: Ref<boolean>;
|
|
13
|
+
toggle: (panel: SideBarPanelId) => void;
|
|
14
|
+
close: () => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Manages side bar panel state: enabled panels, active panel, position, and toggle/close handlers.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useSideBarState(params: UseSideBarStateParams): UseSideBarStateResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Ref, type ShallowRef } from 'vue';
|
|
2
|
+
import type { IColumnDef } from '../types';
|
|
3
|
+
export interface UseTableLayoutParams<T> {
|
|
4
|
+
wrapperRef: Ref<HTMLElement | null> | ShallowRef<HTMLElement | null>;
|
|
5
|
+
visibleCols: Ref<IColumnDef<T>[]>;
|
|
6
|
+
flatColumns: Ref<IColumnDef<T>[]>;
|
|
7
|
+
hasCheckboxCol: Ref<boolean>;
|
|
8
|
+
initialColumnWidths?: Record<string, number>;
|
|
9
|
+
onColumnResized?: (columnId: string, width: number) => void;
|
|
10
|
+
}
|
|
11
|
+
export interface UseTableLayoutResult {
|
|
12
|
+
containerWidth: Ref<number>;
|
|
13
|
+
minTableWidth: Ref<number>;
|
|
14
|
+
desiredTableWidth: Ref<number>;
|
|
15
|
+
columnSizingOverrides: Ref<Record<string, {
|
|
16
|
+
widthPx: number;
|
|
17
|
+
}>>;
|
|
18
|
+
setColumnSizingOverrides: (value: Record<string, {
|
|
19
|
+
widthPx: number;
|
|
20
|
+
}>) => void;
|
|
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,13 @@
|
|
|
1
|
+
import { ref } from 'vue';
|
|
2
|
+
export interface UseTextFilterStateParams {
|
|
3
|
+
textValue?: string;
|
|
4
|
+
onTextChange?: (value: string) => void;
|
|
5
|
+
isFilterOpen: () => boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface UseTextFilterStateResult {
|
|
8
|
+
tempTextValue: ReturnType<typeof ref<string>>;
|
|
9
|
+
setTempTextValue: (v: string) => void;
|
|
10
|
+
handleTextApply: () => void;
|
|
11
|
+
handleTextClear: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare function useTextFilterState(params: UseTextFilterStateParams): UseTextFilterStateResult;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref } from 'vue';
|
|
2
|
+
import type { ICellValueChangedEvent } from '../types';
|
|
3
|
+
export interface UseUndoRedoParams<T> {
|
|
4
|
+
onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
|
|
5
|
+
maxUndoDepth?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface UseUndoRedoResult<T> {
|
|
8
|
+
onCellValueChanged: ((event: ICellValueChangedEvent<T>) => void) | undefined;
|
|
9
|
+
undo: () => void;
|
|
10
|
+
redo: () => void;
|
|
11
|
+
canUndo: Ref<boolean>;
|
|
12
|
+
canRedo: Ref<boolean>;
|
|
13
|
+
beginBatch: () => void;
|
|
14
|
+
endBatch: () => void;
|
|
15
|
+
maxUndoDepth: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wraps onCellValueChanged with an undo/redo history stack.
|
|
19
|
+
* Supports batch operations: changes between beginBatch/endBatch are one undo step.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useUndoRedo<T>(params: UseUndoRedoParams<T>): UseUndoRedoResult<T>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from '@alaarab/ogrid-core';
|
|
2
|
+
export type { IColumnDef, ICellEditorProps, IOGridProps, IOGridClientProps, IOGridServerProps, IOGridDataGridProps, } from './types';
|
|
3
|
+
export type { ColumnFilterType, IColumnFilterDef, IColumnMeta, IColumnGroupDef, IColumnDefinition, ICellValueChangedEvent, CellEditorParams, IValueParserParams, IDateFilterValue, HeaderCell, HeaderRow, RowId, UserLike, UserLikeInput, FilterValue, IFilters, IFetchParams, IPageResult, IDataSource, IGridColumnState, IOGridApi, RowSelectionMode, IRowSelectionChangeEvent, StatusBarPanel, IStatusBarProps, IActiveCell, ISelectionRange, SideBarPanelId, ISideBarDef, } from './types';
|
|
4
|
+
export { toUserLike, isInSelectionRange, normalizeSelectionRange } from './types';
|
|
5
|
+
export { useOGrid, useDataGridState, useActiveCell, useCellEditing, useCellSelection, useClipboard, useRowSelection, useKeyboardNavigation, useFillHandle, useUndoRedo, useContextMenu, useColumnResize, useFilterOptions, useDebounce, useDebouncedCallback, useTableLayout, useColumnHeaderFilterState, useTextFilterState, useMultiSelectFilterState, usePeopleFilterState, useDateFilterState, useColumnChooserState, useInlineCellEditorState, useRichSelectState, useSideBarState, } from './composables';
|
|
6
|
+
export type { UseOGridResult, UseOGridPagination, UseOGridColumnChooser, UseOGridLayout, UseOGridFilters, ColumnChooserPlacement, UseDataGridStateParams, UseDataGridStateResult, DataGridLayoutState, DataGridRowSelectionState, DataGridEditingState, DataGridCellInteractionState, DataGridContextMenuState, DataGridViewModelState, UseActiveCellResult, EditingCell, UseCellEditingResult, UseCellSelectionParams, UseCellSelectionResult, UseClipboardParams, UseClipboardResult, UseRowSelectionParams, UseRowSelectionResult, UseKeyboardNavigationParams, UseKeyboardNavigationResult, UseFillHandleParams, UseFillHandleResult, UseUndoRedoParams, UseUndoRedoResult, ContextMenuPosition, UseContextMenuResult, UseColumnResizeParams, UseColumnResizeResult, UseFilterOptionsResult, UseTableLayoutParams, UseTableLayoutResult, UseColumnHeaderFilterStateParams, UseColumnHeaderFilterStateResult, UseTextFilterStateParams, UseTextFilterStateResult, UseMultiSelectFilterStateParams, UseMultiSelectFilterStateResult, UsePeopleFilterStateParams, UsePeopleFilterStateResult, UseDateFilterStateParams, UseDateFilterStateResult, UseColumnChooserStateParams, UseColumnChooserStateResult, InlineCellEditorType, UseInlineCellEditorStateParams, UseInlineCellEditorStateResult, UseRichSelectStateParams, UseRichSelectStateResult, UseSideBarStateParams, UseSideBarStateResult, } from './composables';
|
|
7
|
+
export { getHeaderFilterConfig, getCellRenderDescriptor, resolveCellDisplayContent, resolveCellStyle, buildInlineEditorProps, buildPopoverEditorProps, getCellInteractionProps, } from './utils';
|
|
8
|
+
export type { HeaderFilterConfigInput, HeaderFilterConfig, CellRenderDescriptorInput, CellRenderDescriptor, CellRenderMode, CellInteractionHandlers, CellInteractionProps, } from './utils';
|
|
9
|
+
export type { SideBarProps, SideBarFilterColumn } from './components/SideBar';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
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
|
+
* Vue-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 (Vue-specific). Returns any renderable content. */
|
|
20
|
+
renderCell?: (item: T) => unknown;
|
|
21
|
+
/** Static or per-row cell inline styles (Vue-specific). */
|
|
22
|
+
cellStyle?: Record<string, string> | ((item: T) => Record<string, string>);
|
|
23
|
+
/** Built-in editor type or custom Vue component. */
|
|
24
|
+
cellEditor?: 'text' | 'select' | 'checkbox' | 'richSelect' | 'date' | Component;
|
|
25
|
+
}
|