@zhenliang/sheet 0.0.1 → 0.0.3
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/core/config.d.ts +13 -0
- package/dist/core/editor/cascaderEditor/index.d.ts +5 -0
- package/dist/core/editor/cascaderEditor/index.js +36 -55
- package/dist/core/editor/dateEditor/index.d.ts +4 -0
- package/dist/core/editor/dateEditor/index.less +4 -0
- package/dist/core/editor/index.d.ts +4 -0
- package/dist/core/editor/index.js +4 -0
- package/dist/core/editor/numberEditor/index.d.ts +6 -0
- package/dist/core/editor/numberEditor/index.js +29 -0
- package/dist/core/editor/selectEditor/index.d.ts +5 -0
- package/dist/core/editor/selectEditor/index.js +2 -2
- package/dist/core/reducers/index.d.ts +9 -0
- package/dist/core/reducers/keyboardReducer.d.ts +2 -0
- package/dist/core/reducers/mouseReducer.d.ts +2 -0
- package/dist/core/reducers/sideEffectReducer.d.ts +4 -0
- package/dist/core/reducers/stateReducer.d.ts +2 -0
- package/dist/core/sheet/Cell.d.ts +4 -0
- package/dist/core/sheet/Cell.js +4 -6
- package/dist/core/sheet/DataEditor.d.ts +3 -0
- package/dist/core/sheet/DefaultCell.d.ts +11 -0
- package/dist/core/sheet/DefaultRow.d.ts +11 -0
- package/dist/core/sheet/DefaultRowMapper.d.ts +8 -0
- package/dist/core/sheet/DefaultShell.d.ts +8 -0
- package/dist/core/sheet/Event.d.ts +5 -0
- package/dist/core/sheet/Event.js +1 -1
- package/dist/core/sheet/ValueViewer.d.ts +3 -0
- package/dist/core/sheet/index.d.ts +5 -0
- package/dist/core/sheet/index.less +6 -1
- package/dist/core/sheet/useCellEvent.d.ts +3 -0
- package/dist/core/sheet/useContextMenu.d.ts +21 -0
- package/dist/core/sheet/useKeyBoardEvent.d.ts +3 -0
- package/dist/core/sheet/useMouseEvent.d.ts +3 -0
- package/dist/core/sheet/useVirtualList.d.ts +7 -0
- package/dist/core/shell/draggableShell/index.d.ts +6 -0
- package/dist/core/shell/tableShell.d.ts +6 -0
- package/dist/core/table/index.d.ts +4 -0
- package/dist/core/table/index.js +10 -3
- package/dist/core/table/useGroupConfig.d.ts +2 -0
- package/dist/core/table/useRowSelection.d.ts +1 -0
- package/dist/core/table/util.d.ts +8 -0
- package/dist/core/util.d.ts +55 -0
- package/dist/core/util.js +1 -0
- package/dist/core/viewer/btnViewer/index.d.ts +2 -0
- package/dist/core/viewer/btnViewer/index.js +37 -0
- package/dist/core/viewer/checkViewer/index.d.ts +2 -0
- package/dist/core/viewer/editViewer/index.d.ts +2 -0
- package/dist/core/viewer/editViewer/index.js +31 -0
- package/dist/core/viewer/groupViewer/index.d.ts +2 -0
- package/dist/core/viewer/index.d.ts +5 -0
- package/dist/core/viewer/index.js +5 -0
- package/dist/core/viewer/switchViewer/index.d.ts +2 -0
- package/dist/core/viewer/switchViewer/index.js +22 -0
- package/dist/example/antComponent.d.ts +3 -0
- package/dist/example/antComponent.js +216 -0
- package/dist/example/basic.d.ts +4 -0
- package/dist/example/ellipsis.d.ts +3 -0
- package/dist/example/fixed.d.ts +3 -0
- package/dist/example/group.d.ts +3 -0
- package/dist/example/selection.d.ts +4 -0
- package/dist/example/sheet.d.ts +4 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/useEventBus.d.ts +4 -0
- package/dist/hooks/useKeyboard.d.ts +18 -0
- package/dist/hooks/useMiddlewareReducer.d.ts +12 -0
- package/dist/hooks/useMouse.d.ts +11 -0
- package/dist/hooks/useSetState.d.ts +2 -0
- package/dist/hooks/useSheetEvent.d.ts +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -1
- package/dist/standardUtils/index.d.ts +9 -0
- package/dist/type/index.d.ts +2 -0
- package/dist/type/index.js +4 -0
- package/dist/type/sheet.d.ts +191 -0
- package/dist/type/sheet.js +8 -0
- package/dist/type/sheetTable.d.ts +55 -0
- package/dist/type/sheetTable.js +1 -0
- package/package.json +4 -4
- package/dist/core/shell/resizeShell.js +0 -57
- package/dist/example/draggable.js +0 -0
- package/dist/typings/sheet.d.ts +0 -209
- package/dist/typings/table.js +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { EventEmitter } from 'events';
|
|
4
|
+
import { SheetTableType } from '.';
|
|
5
|
+
export declare enum CellAlign {
|
|
6
|
+
left = "left",
|
|
7
|
+
center = "center",
|
|
8
|
+
right = "right"
|
|
9
|
+
}
|
|
10
|
+
export declare type Cell = {
|
|
11
|
+
id: string;
|
|
12
|
+
key?: string;
|
|
13
|
+
readonly?: boolean;
|
|
14
|
+
component?: CellViewer;
|
|
15
|
+
editable?: boolean;
|
|
16
|
+
colSpan?: number;
|
|
17
|
+
rowSpan?: number;
|
|
18
|
+
width?: number;
|
|
19
|
+
record?: Record<string, unknown>;
|
|
20
|
+
disableEvents?: boolean;
|
|
21
|
+
dataEditor?: CellEditor;
|
|
22
|
+
valueViewer?: CellViewer;
|
|
23
|
+
className?: string;
|
|
24
|
+
align?: CellAlign;
|
|
25
|
+
fixed?: Omit<CellAlign, 'center'>;
|
|
26
|
+
value?: string | number | null;
|
|
27
|
+
};
|
|
28
|
+
export declare type CellViewerProps = {
|
|
29
|
+
value: unknown;
|
|
30
|
+
record?: Record<string, unknown>;
|
|
31
|
+
row?: number;
|
|
32
|
+
col?: number;
|
|
33
|
+
cell?: Cell;
|
|
34
|
+
};
|
|
35
|
+
export declare type CellEditorProps = {
|
|
36
|
+
value: unknown;
|
|
37
|
+
cell?: Cell;
|
|
38
|
+
onChange: (value: unknown) => void;
|
|
39
|
+
onConfirm: (value: unknown) => void;
|
|
40
|
+
} & CellViewerProps;
|
|
41
|
+
export declare type CellEditor = React.FC<CellEditorProps> & {
|
|
42
|
+
checker?: (value: unknown) => boolean;
|
|
43
|
+
formatter?: (value: unknown) => unknown;
|
|
44
|
+
};
|
|
45
|
+
export declare type CellViewer = React.FC<CellViewerProps>;
|
|
46
|
+
export declare type CellPosition = {
|
|
47
|
+
row: number;
|
|
48
|
+
col: number;
|
|
49
|
+
};
|
|
50
|
+
export declare type CellData = {
|
|
51
|
+
id: string;
|
|
52
|
+
cell: Cell;
|
|
53
|
+
row: number;
|
|
54
|
+
col: number;
|
|
55
|
+
value?: string;
|
|
56
|
+
};
|
|
57
|
+
export declare type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
|
|
58
|
+
export declare type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
|
|
59
|
+
export declare type RowGroup = {
|
|
60
|
+
groupName: string;
|
|
61
|
+
groupStart: number;
|
|
62
|
+
groupEnd: number;
|
|
63
|
+
};
|
|
64
|
+
export declare type RowGroupConfig = {
|
|
65
|
+
groups: RowGroup[];
|
|
66
|
+
groupOpen: boolean[];
|
|
67
|
+
};
|
|
68
|
+
export declare type MenuRenderProps = {
|
|
69
|
+
position?: {
|
|
70
|
+
top: number;
|
|
71
|
+
left: number;
|
|
72
|
+
};
|
|
73
|
+
cell?: CellPosition;
|
|
74
|
+
onContextMenu?: (event: any) => void;
|
|
75
|
+
};
|
|
76
|
+
export declare type SheetInstance = {
|
|
77
|
+
zoomTo: (row?: number) => void;
|
|
78
|
+
pushToHistory: (value: OperateHistory) => void;
|
|
79
|
+
selectRow: (row?: number) => void;
|
|
80
|
+
popHistory: () => OperateHistory;
|
|
81
|
+
};
|
|
82
|
+
export declare type SheetProps = {
|
|
83
|
+
sheetInstance?: React.MutableRefObject<SheetInstance | null>;
|
|
84
|
+
sheetRenderer?: any;
|
|
85
|
+
rowRenderer?: any;
|
|
86
|
+
className?: string;
|
|
87
|
+
data: Cell[][];
|
|
88
|
+
freePaste?: boolean;
|
|
89
|
+
virtualized?: boolean;
|
|
90
|
+
groupConfig?: RowGroupConfig;
|
|
91
|
+
onCellsChanged?: CellChangeHandler;
|
|
92
|
+
menuRenderer?: React.FC<MenuRenderProps>;
|
|
93
|
+
onContextMenu?: (event: any) => void;
|
|
94
|
+
scroll?: {
|
|
95
|
+
x?: number | string;
|
|
96
|
+
y?: number | string;
|
|
97
|
+
};
|
|
98
|
+
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
99
|
+
children?: any[];
|
|
100
|
+
};
|
|
101
|
+
export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
|
|
102
|
+
className?: string;
|
|
103
|
+
showGroup?: boolean;
|
|
104
|
+
showSelect?: boolean;
|
|
105
|
+
controlWidth?: number;
|
|
106
|
+
controlProps?: {
|
|
107
|
+
check?: {
|
|
108
|
+
checked: boolean;
|
|
109
|
+
indeterminate?: boolean;
|
|
110
|
+
};
|
|
111
|
+
group?: {
|
|
112
|
+
open: boolean;
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
export declare type SheetRow = {
|
|
117
|
+
row: number;
|
|
118
|
+
cells: Cell[];
|
|
119
|
+
selected: boolean;
|
|
120
|
+
children: React.ElementType;
|
|
121
|
+
};
|
|
122
|
+
export declare type windowAssertion = {
|
|
123
|
+
clipboardData?: {
|
|
124
|
+
getData?: (type: string) => string;
|
|
125
|
+
setData?: (type: string, data: string) => string;
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
export declare type refAssertion = {
|
|
129
|
+
contains?: (target: EventTarget | null) => boolean;
|
|
130
|
+
focus?: () => boolean;
|
|
131
|
+
} & HTMLSpanElement;
|
|
132
|
+
export declare type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
|
|
133
|
+
export declare type CellProps = {
|
|
134
|
+
row: number;
|
|
135
|
+
col: number;
|
|
136
|
+
cell: Cell;
|
|
137
|
+
cellRenderer?: React.ElementType;
|
|
138
|
+
dataEditor?: React.ElementType;
|
|
139
|
+
valueViewer?: React.ElementType;
|
|
140
|
+
attributesRenderer?: AttributesRenderer;
|
|
141
|
+
};
|
|
142
|
+
export declare type UpdateStateType = {
|
|
143
|
+
eventBus: EventEmitter;
|
|
144
|
+
start: CellPosition;
|
|
145
|
+
end: CellPosition;
|
|
146
|
+
selecting: boolean;
|
|
147
|
+
forceEdit: boolean;
|
|
148
|
+
clear: CellPosition;
|
|
149
|
+
editing: CellPosition & {
|
|
150
|
+
value?: string;
|
|
151
|
+
};
|
|
152
|
+
history: OperateHistory[];
|
|
153
|
+
freePaste?: boolean;
|
|
154
|
+
data: Cell[][];
|
|
155
|
+
mouseDown: boolean;
|
|
156
|
+
lastSelected?: {
|
|
157
|
+
start?: CellPosition;
|
|
158
|
+
end?: CellPosition;
|
|
159
|
+
};
|
|
160
|
+
groupConfig?: {
|
|
161
|
+
groups: RowGroup[];
|
|
162
|
+
groupOpen: boolean[];
|
|
163
|
+
};
|
|
164
|
+
lastFocus: {
|
|
165
|
+
id: string;
|
|
166
|
+
col: number;
|
|
167
|
+
}[];
|
|
168
|
+
lastEditing: CellPosition & {
|
|
169
|
+
confirm?: boolean;
|
|
170
|
+
};
|
|
171
|
+
cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
|
|
172
|
+
};
|
|
173
|
+
export declare type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
|
|
174
|
+
export declare type Options<T = any> = {
|
|
175
|
+
value: string;
|
|
176
|
+
label: string;
|
|
177
|
+
} & T;
|
|
178
|
+
export declare type OptionsType = Options<{
|
|
179
|
+
disabled?: boolean;
|
|
180
|
+
children?: OptionsType[];
|
|
181
|
+
}>;
|
|
182
|
+
export declare type OperateHistory = {
|
|
183
|
+
changes: Partial<CellData>[];
|
|
184
|
+
type: OperateType;
|
|
185
|
+
rowInfo?: {
|
|
186
|
+
newRow?: number;
|
|
187
|
+
deleteRow?: number;
|
|
188
|
+
};
|
|
189
|
+
extraInfo?: Record<string, unknown>;
|
|
190
|
+
};
|
|
191
|
+
export declare type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { SheetType } from '.';
|
|
2
|
+
export declare type refAssertion = {
|
|
3
|
+
contains?: (target: EventTarget | null) => boolean;
|
|
4
|
+
focus?: () => boolean;
|
|
5
|
+
} & HTMLTableSectionElement;
|
|
6
|
+
export declare type CellAlign = 'left' | 'right' | 'center';
|
|
7
|
+
export declare type CellFixed = 'left' | 'right';
|
|
8
|
+
export declare type ColumnProps = {
|
|
9
|
+
align?: CellAlign;
|
|
10
|
+
fixed?: CellFixed;
|
|
11
|
+
width?: string | number;
|
|
12
|
+
dataIndex?: string;
|
|
13
|
+
title: string;
|
|
14
|
+
key?: string;
|
|
15
|
+
editable?: boolean;
|
|
16
|
+
readonly?: boolean | ((value: unknown, record: Record<string, unknown>, index: number) => boolean);
|
|
17
|
+
render?: SheetType.CellViewer;
|
|
18
|
+
editor?: SheetType.CellEditor;
|
|
19
|
+
};
|
|
20
|
+
export declare type TableChange = {
|
|
21
|
+
row: number;
|
|
22
|
+
id: string;
|
|
23
|
+
key: string;
|
|
24
|
+
value: unknown;
|
|
25
|
+
};
|
|
26
|
+
export declare type TableRowSelection = {
|
|
27
|
+
onChange: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
|
|
28
|
+
};
|
|
29
|
+
export declare type TableGroupConfig = {
|
|
30
|
+
defaultOpen: boolean;
|
|
31
|
+
};
|
|
32
|
+
export declare type TableProps = {
|
|
33
|
+
className?: string;
|
|
34
|
+
columns: ColumnProps[];
|
|
35
|
+
virtualized?: boolean;
|
|
36
|
+
dataSource: Record<string, unknown>[];
|
|
37
|
+
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
38
|
+
rowKey?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
39
|
+
scroll?: {
|
|
40
|
+
x?: number | string;
|
|
41
|
+
y?: number | string;
|
|
42
|
+
};
|
|
43
|
+
sticky?: boolean;
|
|
44
|
+
draggable?: boolean;
|
|
45
|
+
rowSelection?: {
|
|
46
|
+
rowSelected: string[];
|
|
47
|
+
onChange: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
|
|
48
|
+
};
|
|
49
|
+
groupConfig?: {
|
|
50
|
+
rowGroup: TableGroupConfig;
|
|
51
|
+
onChange: (value: TableGroupConfig) => void;
|
|
52
|
+
};
|
|
53
|
+
onChange: (changes: TableChange[]) => void;
|
|
54
|
+
eventHandler?: Record<'btn-click' | 'cell-edit' | 'cell-switch' | string, undefined | ((value: unknown) => void)>;
|
|
55
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhenliang/sheet",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@ant-design/icons": "^4.6.2",
|
|
48
|
+
"antd": "^4.24.0",
|
|
48
49
|
"events": "^3.3.0",
|
|
49
50
|
"lodash": "^4.17.21",
|
|
50
51
|
"moment": "^2.29.4",
|
|
@@ -71,9 +72,8 @@
|
|
|
71
72
|
"stylelint": "^14.9.1"
|
|
72
73
|
},
|
|
73
74
|
"peerDependencies": {
|
|
74
|
-
"
|
|
75
|
-
"react": "
|
|
76
|
-
"react-dom": ">=16.9.0"
|
|
75
|
+
"react": "17.x",
|
|
76
|
+
"react-dom": "17.x"
|
|
77
77
|
},
|
|
78
78
|
"publishConfig": {
|
|
79
79
|
"access": "public"
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { classNames } from "./util";
|
|
3
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
5
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
6
|
-
export var WrapperShell = function WrapperShell(_ref) {
|
|
7
|
-
var columns = _ref.columns,
|
|
8
|
-
className = _ref.className;
|
|
9
|
-
var TableShell = function TableShell(_ref2) {
|
|
10
|
-
var children = _ref2.children;
|
|
11
|
-
var _useMemo = useMemo(function () {
|
|
12
|
-
var thItems = columns.map(function (item) {
|
|
13
|
-
var _item$width;
|
|
14
|
-
return /*#__PURE__*/_jsx("th", {
|
|
15
|
-
className: "cell read-only",
|
|
16
|
-
style: {
|
|
17
|
-
width: (_item$width = item.width) !== null && _item$width !== void 0 ? _item$width : 'unset'
|
|
18
|
-
},
|
|
19
|
-
children: item.title
|
|
20
|
-
}, item.dataIndex);
|
|
21
|
-
});
|
|
22
|
-
var colItems = columns.map(function (item) {
|
|
23
|
-
var _item$width2;
|
|
24
|
-
return /*#__PURE__*/_jsx("col", {
|
|
25
|
-
className: "cell",
|
|
26
|
-
style: {
|
|
27
|
-
width: (_item$width2 = item.width) !== null && _item$width2 !== void 0 ? _item$width2 : 'unset'
|
|
28
|
-
}
|
|
29
|
-
}, item.dataIndex);
|
|
30
|
-
});
|
|
31
|
-
return {
|
|
32
|
-
thItems: thItems,
|
|
33
|
-
colItems: colItems
|
|
34
|
-
};
|
|
35
|
-
}, [columns]),
|
|
36
|
-
thItems = _useMemo.thItems,
|
|
37
|
-
colItems = _useMemo.colItems;
|
|
38
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
39
|
-
children: [/*#__PURE__*/_jsx("table", {
|
|
40
|
-
className: classNames('header', 'harvest-sheet', className),
|
|
41
|
-
children: /*#__PURE__*/_jsx("thead", {
|
|
42
|
-
children: /*#__PURE__*/_jsx("tr", {
|
|
43
|
-
children: thItems
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
}, "header"), /*#__PURE__*/_jsxs("table", {
|
|
47
|
-
className: classNames('body', 'harvest-sheet'),
|
|
48
|
-
children: [/*#__PURE__*/_jsx("colgroup", {
|
|
49
|
-
children: colItems
|
|
50
|
-
}), /*#__PURE__*/_jsx("tbody", {
|
|
51
|
-
children: children
|
|
52
|
-
}, "tbody")]
|
|
53
|
-
}, "body")]
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
return TableShell;
|
|
57
|
-
};
|
|
File without changes
|
package/dist/typings/sheet.d.ts
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
declare namespace Sheet {
|
|
2
|
-
type Cell = {
|
|
3
|
-
id: string;
|
|
4
|
-
key?: string;
|
|
5
|
-
readonly?: boolean;
|
|
6
|
-
component?: CellViewer;
|
|
7
|
-
editable?: boolean;
|
|
8
|
-
colSpan?: number;
|
|
9
|
-
rowSpan?: number;
|
|
10
|
-
width?: number;
|
|
11
|
-
record?: Record<string, unknown>;
|
|
12
|
-
disableEvents?: boolean;
|
|
13
|
-
dataEditor?: CellEditor;
|
|
14
|
-
valueViewer?: CellViewer;
|
|
15
|
-
className?: string;
|
|
16
|
-
align?: 'left' | 'center' | 'right';
|
|
17
|
-
fixed?: 'left' | 'right';
|
|
18
|
-
value?: string | number | null;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type CellEditorProps = {
|
|
22
|
-
value: unknown;
|
|
23
|
-
cell?: Cell;
|
|
24
|
-
onChange: (value) => void;
|
|
25
|
-
onConfirm: (value) => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type CellViewerProps = {
|
|
29
|
-
value: unknown;
|
|
30
|
-
record?: Record<string, unknown>;
|
|
31
|
-
row: number;
|
|
32
|
-
col: number;
|
|
33
|
-
cell?: Cell;
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
type CellEditor = React.FC<CellEditorProps> & {
|
|
37
|
-
checker?: (value: unknown) => boolean;
|
|
38
|
-
formatter?: (value: unknown) => unknown;
|
|
39
|
-
};
|
|
40
|
-
type CellViewer = React.FC<CellViewerProps>;
|
|
41
|
-
|
|
42
|
-
type CellPosition = {
|
|
43
|
-
row: number;
|
|
44
|
-
col: number;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
type CellData = {
|
|
48
|
-
id: string;
|
|
49
|
-
cell: Cell;
|
|
50
|
-
row: number;
|
|
51
|
-
col: number;
|
|
52
|
-
value?: string;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
|
|
56
|
-
type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
|
|
57
|
-
|
|
58
|
-
type RowGroup = {
|
|
59
|
-
groupName: string;
|
|
60
|
-
groupStart: number;
|
|
61
|
-
groupEnd: number;
|
|
62
|
-
};
|
|
63
|
-
type RowGroupConfig = {
|
|
64
|
-
groups: RowGroup[];
|
|
65
|
-
groupOpen: boolean[];
|
|
66
|
-
};
|
|
67
|
-
type MenuRenderProps = {
|
|
68
|
-
position?: { top: number; left: number };
|
|
69
|
-
cell?: Sheet.CellPosition;
|
|
70
|
-
onContextMenu?: (event: any) => void;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
type SheetInstance = {
|
|
74
|
-
zoomTo: (row?: number) => void;
|
|
75
|
-
pushToHistory: (value: OperateHistory) => void;
|
|
76
|
-
selectRow: (row?: number) => void;
|
|
77
|
-
popHistory: () => OperateHistory;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
type SheetProps = {
|
|
81
|
-
sheetInstance?: React.MutableRefObject<Sheet.SheetInstance | null>;
|
|
82
|
-
sheetRenderer?: any;
|
|
83
|
-
rowRenderer?: any;
|
|
84
|
-
className?: string;
|
|
85
|
-
data: Cell[][];
|
|
86
|
-
freePaste?: boolean;
|
|
87
|
-
virtualized?: boolean;
|
|
88
|
-
|
|
89
|
-
groupConfig?: RowGroupConfig;
|
|
90
|
-
|
|
91
|
-
onCellsChanged?: CellChangeHandler;
|
|
92
|
-
menuRenderer?: React.FC<MenuRenderProps>;
|
|
93
|
-
onContextMenu?: (event: any) => void;
|
|
94
|
-
|
|
95
|
-
scroll?: { x?: number | string; y?: number | string };
|
|
96
|
-
rowClassName?:
|
|
97
|
-
| string
|
|
98
|
-
| ((record: Record<string, unknown>, index: number) => string);
|
|
99
|
-
children?: (React.Element | null)[];
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
type SheetShell = Pick<SheetTable.TableProps, 'columns'> & {
|
|
103
|
-
className?: string;
|
|
104
|
-
showGroup?: boolean;
|
|
105
|
-
showSelect?: boolean;
|
|
106
|
-
controlWidth?: number;
|
|
107
|
-
controlProps?: {
|
|
108
|
-
check?: {
|
|
109
|
-
checked: boolean;
|
|
110
|
-
indeterminate?: boolean;
|
|
111
|
-
};
|
|
112
|
-
group?: {
|
|
113
|
-
open: boolean;
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
type SheetRow = {
|
|
119
|
-
row: number;
|
|
120
|
-
cells: Cell[];
|
|
121
|
-
selected: boolean;
|
|
122
|
-
children: React.ElementType;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// todo
|
|
126
|
-
type windowAssertion = {
|
|
127
|
-
clipboardData?: {
|
|
128
|
-
getData?: (type: string) => string;
|
|
129
|
-
setData?: (type: string, data: string) => string;
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
type refAssertion = {
|
|
134
|
-
contains?: (target: EventTarget | null) => boolean;
|
|
135
|
-
focus?: () => boolean;
|
|
136
|
-
} & HTMLSpanElement;
|
|
137
|
-
|
|
138
|
-
type AttributesRenderer = (
|
|
139
|
-
cell: Sheet.Cell,
|
|
140
|
-
row: number,
|
|
141
|
-
col: number,
|
|
142
|
-
) => Record<string, string>;
|
|
143
|
-
|
|
144
|
-
type CellProps = {
|
|
145
|
-
row: number;
|
|
146
|
-
col: number;
|
|
147
|
-
cell: Cell;
|
|
148
|
-
cellRenderer?: React.ElementType;
|
|
149
|
-
dataEditor?: React.ElementType;
|
|
150
|
-
valueViewer?: React.ElementType;
|
|
151
|
-
attributesRenderer?: AttributesRenderer;
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
type UpdateStateType = {
|
|
155
|
-
eventBus: EventEmitter;
|
|
156
|
-
start: Sheet.CellPosition;
|
|
157
|
-
end: Sheet.CellPosition;
|
|
158
|
-
selecting: boolean;
|
|
159
|
-
forceEdit: boolean;
|
|
160
|
-
clear: CellPosition;
|
|
161
|
-
editing: CellPosition & { value?: string };
|
|
162
|
-
history: OperateHistory[];
|
|
163
|
-
freePaste?: boolean;
|
|
164
|
-
data: Cell[][];
|
|
165
|
-
mouseDown: boolean;
|
|
166
|
-
lastSelected?: { start?: Sheet.CellPosition; end?: Sheet.CellPosition };
|
|
167
|
-
groupConfig?: {
|
|
168
|
-
groups: RowGroup[];
|
|
169
|
-
groupOpen: boolean[];
|
|
170
|
-
};
|
|
171
|
-
lastFocus: { id: string; col: number }[];
|
|
172
|
-
lastEditing: CellPosition & { confirm?: boolean };
|
|
173
|
-
cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
|
|
174
|
-
};
|
|
175
|
-
type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
|
|
176
|
-
|
|
177
|
-
type Options<T> = {
|
|
178
|
-
value: string;
|
|
179
|
-
label: string;
|
|
180
|
-
} & T;
|
|
181
|
-
|
|
182
|
-
type OptionsType = Options<{
|
|
183
|
-
disabled?: boolean;
|
|
184
|
-
children?: Common.Option<{
|
|
185
|
-
children?: Common.Options<Record<string, unknown>>;
|
|
186
|
-
}>;
|
|
187
|
-
}>;
|
|
188
|
-
|
|
189
|
-
type OperateHistory = {
|
|
190
|
-
changes: Partial<CellData>[];
|
|
191
|
-
type: OperateType;
|
|
192
|
-
|
|
193
|
-
rowInfo?: {
|
|
194
|
-
newRow?: number;
|
|
195
|
-
deleteRow?: number;
|
|
196
|
-
};
|
|
197
|
-
extraInfo?: Record<string, unknown>;
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
type OperateType =
|
|
201
|
-
// 前三个Type 直接调用 onCellChange
|
|
202
|
-
| 'Edit'
|
|
203
|
-
| 'Paste'
|
|
204
|
-
| 'Delete'
|
|
205
|
-
// 后三个单独Event 处理
|
|
206
|
-
| 'DeleteRow'
|
|
207
|
-
| 'NewRow'
|
|
208
|
-
| 'Custom';
|
|
209
|
-
}
|
package/dist/typings/table.js
DELETED
|
File without changes
|