-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathState.ts
More file actions
108 lines (96 loc) · 3.8 KB
/
State.ts
File metadata and controls
108 lines (96 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import { CellTemplates, Cell, ReactGridProps, Compatible, Highlight, CellChange, Id, SelectionMode, GridErrorEventHandler } from './PublicModel';
import { isBrowserIE } from '../Functions/internetExplorer';
import { isBrowserEdge } from '../Functions/microsoftEdge';
import { DefaultBehavior } from '../Behaviors/DefaultBehavior';
import { CellMatrix } from './CellMatrix';
import { Behavior } from './Behavior';
import { Location, Orientation, } from './InternalModel';
import { Range } from './Range';
import { defaultCellTemplates } from '../Functions/defaultCellTemplates';
export type StateModifier<TState extends State = State> = (state: TState) => TState;
export type StateUpdater = (modifier: StateModifier) => void;
export interface State<TCellMatrix extends CellMatrix = CellMatrix, TBehavior extends Behavior = Behavior> {
update: StateUpdater;
readonly props?: ReactGridProps;
readonly legacyBrowserMode: boolean;
readonly cellMatrix: TCellMatrix;
readonly currentBehavior: TBehavior;
readonly focusedLocation?: Location;
readonly cellTemplates: CellTemplates;
hiddenFocusElement?: HTMLDivElement; // updated without setState
readonly reactGridElement?: HTMLDivElement;
readonly scrollableElement?: HTMLElement | (Window & typeof globalThis);
readonly queuedCellChanges: CellChange[];
currentlyEditedCell?: Compatible<Cell>;
readonly highlightLocations: Highlight[];
// VISIBLE RANGE
readonly visibleRange?: Range;
// STICKY
readonly leftStickyColumns?: number;
readonly topStickyRows?: number;
// SCROLLS
readonly topScrollBoudary: number;
readonly bottomScrollBoudary: number;
readonly leftScrollBoudary: number;
readonly rightScrollBoudary: number;
readonly enableGroupIdRender: boolean;
readonly enableFillHandle: boolean;
readonly enableRangeSelection: boolean;
readonly enableColumnSelection: boolean;
readonly enableRowSelection: boolean;
readonly disableVirtualScrolling: boolean;
readonly contextMenuPosition: { top: number; left: number };
readonly lineOrientation: Orientation;
readonly linePosition: number;
readonly shadowSize: number;
readonly shadowPosition: number;
readonly shadowCursor: string;
readonly selectionMode: SelectionMode;
readonly selectedRanges: Range[];
readonly selectedIndexes: number[];
readonly selectedIds: Id[];
readonly activeSelectedRangeIdx: number;
readonly copyRange?: Range;
readonly rightStickyColumns: number | undefined;
readonly bottomStickyRows: number | undefined;
readonly onError?: GridErrorEventHandler;
}
export const defaultStateFields = {
legacyBrowserMode: isBrowserIE() || isBrowserEdge(),
focusedLocation: undefined,
currentBehavior: new DefaultBehavior(),
cellTemplates: defaultCellTemplates,
hiddenFocusElement: undefined,
reactGridElement: undefined,
scrollableElement: undefined,
queuedCellChanges: [],
currentlyEditedCell: undefined,
highlightLocations: [],
visibleRange: undefined,
topScrollBoudary: -1,
bottomScrollBoudary: -1,
leftScrollBoudary: -1,
rightScrollBoudary: -1,
enableGroupIdRender: false,
leftStickyColumns: undefined,
topStickyRows: undefined,
enableFillHandle: false,
enableRangeSelection: true,
enableColumnSelection: false,
enableRowSelection: false,
contextMenuPosition: { top: -1, left: -1 },
lineOrientation: "horizontal" as Orientation,
linePosition: -1,
shadowSize: 0,
shadowPosition: -1,
shadowCursor: "default",
selectionMode: "range" as SelectionMode,
selectedRanges: [],
selectedIndexes: [],
selectedIds: [],
activeSelectedRangeIdx: 0,
copyRange: undefined,
rightStickyColumns: undefined,
bottomStickyRows: undefined,
disableVirtualScrolling: false,
}