@zhenliang/sheet 0.1.23 → 0.1.25
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/changes.md +45 -0
- package/dist/core/editor/cascaderEditor/index.js +0 -1
- package/dist/core/editor/cascaderEditor/index.less +9 -5
- package/dist/core/editor/dateEditor/index.js +10 -4
- package/dist/core/editor/dateEditor/index.less +8 -1
- package/dist/core/editor/numberEditor/index.d.ts +1 -1
- package/dist/core/editor/numberEditor/index.js +5 -5
- package/dist/core/editor/numberEditor/index.less +2 -2
- package/dist/core/editor/selectEditor/index.js +4 -4
- package/dist/core/editor/selectEditor/index.less +8 -3
- package/dist/core/reducers/index.d.ts +2 -2
- package/dist/core/reducers/keyboardReducer.js +3 -3
- package/dist/core/reducers/mouseReducer.js +5 -5
- package/dist/core/reducers/sideEffectReducer.d.ts +1 -1
- package/dist/core/reducers/sideEffectReducer.js +10 -10
- package/dist/core/reducers/stateReducer.js +10 -10
- package/dist/core/sheet/Cell.js +2 -2
- package/dist/core/sheet/DataEditor.js +1 -1
- package/dist/core/sheet/DefaultCell.d.ts +1 -0
- package/dist/core/sheet/DefaultCell.js +3 -3
- package/dist/core/sheet/DefaultRowMapper.js +4 -1
- package/dist/core/sheet/index.js +31 -23
- package/dist/core/sheet/index.less +6 -3
- package/dist/core/sheet/useContextMenu.d.ts +1 -1
- package/dist/core/sheet/useContextMenu.js +6 -6
- package/dist/core/sheet/useKeyBoardEvent.js +1 -1
- package/dist/core/sheet/useMouseEvent.js +6 -6
- package/dist/core/sheet/useSelectVisible.js +3 -3
- package/dist/core/sheet/useVirtualList.js +3 -3
- package/dist/core/shell/draggableShell/index.d.ts +1 -0
- package/dist/core/shell/draggableShell/index.js +6 -6
- package/dist/core/shell/tableShell.d.ts +1 -0
- package/dist/core/shell/tableShell.js +4 -4
- package/dist/core/table/events.js +5 -5
- package/dist/core/table/index.js +7 -7
- package/dist/core/table/useGroupConfig.js +1 -1
- package/dist/core/table/useRowSelection.js +1 -1
- package/dist/core/util.d.ts +0 -1
- package/dist/core/util.js +19 -52
- package/dist/core/viewer/cascaderViewer/index.js +6 -1
- package/dist/core/viewer/editViewer/index.js +2 -1
- package/dist/core/viewer/groupViewer/index.js +5 -1
- package/dist/example/antComponent.js +7 -8
- package/dist/example/basic.js +4 -4
- package/dist/example/group.js +3 -3
- package/dist/example/selection.js +4 -4
- package/dist/example/sheet.js +21 -17
- package/dist/example/valuationAnalyze.d.ts +1 -0
- package/dist/example/valuationAnalyze.js +1 -1
- package/dist/hooks/useEventBus.js +1 -1
- package/dist/hooks/useKeyboard.d.ts +2 -2
- package/dist/hooks/useMiddlewareReducer.d.ts +5 -5
- package/dist/hooks/useMiddlewareReducer.js +2 -2
- package/dist/hooks/useMouse.d.ts +1 -1
- package/dist/hooks/useMouse.js +6 -6
- package/dist/hooks/useSetState.js +4 -4
- package/dist/standardUtils/index.d.ts +1 -1
- package/dist/standardUtils/index.js +1 -1
- package/dist/type/sheet.d.ts +28 -27
- package/dist/type/sheetTable.d.ts +10 -9
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function _typeof(
|
|
2
|
-
function ownKeys(
|
|
3
|
-
function _objectSpread(
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
5
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
6
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
@@ -8,7 +8,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
8
8
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
9
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
13
|
import { useCallback, useState } from 'react';
|
|
14
14
|
var useSetState = function useSetState() {
|
|
@@ -2,7 +2,7 @@ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArra
|
|
|
2
2
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
3
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
-
function _iterableToArrayLimit(
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
7
|
export var formatPrecision = function formatPrecision(value) {
|
|
8
8
|
var precision = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
|
package/dist/type/sheet.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare enum CellAlign {
|
|
|
8
8
|
right = "right",
|
|
9
9
|
unset = "unset"
|
|
10
10
|
}
|
|
11
|
-
export
|
|
11
|
+
export type Cell = {
|
|
12
12
|
id: string;
|
|
13
13
|
key?: string;
|
|
14
14
|
readonly?: boolean;
|
|
@@ -26,49 +26,49 @@ export declare type Cell = {
|
|
|
26
26
|
fixed?: Omit<CellAlign, 'center'>;
|
|
27
27
|
value?: string | number | null;
|
|
28
28
|
};
|
|
29
|
-
export
|
|
29
|
+
export type CellViewerProps = {
|
|
30
30
|
value: unknown;
|
|
31
31
|
record?: Record<string, unknown>;
|
|
32
32
|
row?: number;
|
|
33
33
|
col?: number;
|
|
34
34
|
cell?: Cell;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type CellEditorProps = {
|
|
37
37
|
value: unknown;
|
|
38
38
|
cell?: Cell;
|
|
39
39
|
onChange: (value: unknown) => void;
|
|
40
40
|
onConfirm: (value: unknown) => void;
|
|
41
41
|
} & CellViewerProps;
|
|
42
|
-
export
|
|
42
|
+
export type CellEditor = React.FC<CellEditorProps> & {
|
|
43
43
|
checker?: (value: unknown, record?: Record<string, unknown>) => boolean;
|
|
44
44
|
formatter?: (value: unknown, record?: Record<string, unknown>) => unknown;
|
|
45
45
|
parser?: (value: unknown, record?: Record<string, unknown>) => unknown;
|
|
46
46
|
};
|
|
47
|
-
export
|
|
48
|
-
export
|
|
47
|
+
export type CellViewer = React.FC<CellViewerProps>;
|
|
48
|
+
export type CellPosition = {
|
|
49
49
|
row: number;
|
|
50
50
|
col: number;
|
|
51
51
|
};
|
|
52
|
-
export
|
|
52
|
+
export type CellData = {
|
|
53
53
|
id: string;
|
|
54
54
|
cell: Cell;
|
|
55
55
|
row: number;
|
|
56
56
|
col: number;
|
|
57
57
|
value?: string;
|
|
58
58
|
};
|
|
59
|
-
export
|
|
60
|
-
export
|
|
61
|
-
export
|
|
59
|
+
export type CellNavigable = (cell?: Cell, row?: number, col?: number) => boolean;
|
|
60
|
+
export type CellChangeHandler = (cells: CellData[], additions?: CellData[]) => void;
|
|
61
|
+
export type RowGroup = {
|
|
62
62
|
groupName: string;
|
|
63
63
|
groupStart: number;
|
|
64
64
|
groupEnd: number;
|
|
65
65
|
};
|
|
66
|
-
export
|
|
66
|
+
export type RowGroupConfig = {
|
|
67
67
|
defaultOpen?: boolean;
|
|
68
68
|
groups: RowGroup[];
|
|
69
69
|
groupOpen: boolean[];
|
|
70
70
|
};
|
|
71
|
-
export
|
|
71
|
+
export type MenuRenderProps = {
|
|
72
72
|
position?: {
|
|
73
73
|
top: number;
|
|
74
74
|
left: number;
|
|
@@ -76,7 +76,7 @@ export declare type MenuRenderProps = {
|
|
|
76
76
|
cell?: CellPosition;
|
|
77
77
|
onContextMenu?: (event: any) => void;
|
|
78
78
|
};
|
|
79
|
-
export
|
|
79
|
+
export type SheetInstance = {
|
|
80
80
|
zoomTo: (row?: number) => void;
|
|
81
81
|
pushToHistory: (value: OperateHistory) => void;
|
|
82
82
|
selectRow: (row?: number) => void;
|
|
@@ -86,10 +86,11 @@ export declare type SheetInstance = {
|
|
|
86
86
|
}) => void;
|
|
87
87
|
popHistory: () => OperateHistory;
|
|
88
88
|
};
|
|
89
|
-
export
|
|
89
|
+
export type SheetProps = {
|
|
90
90
|
sheetInstance?: React.MutableRefObject<SheetInstance | null>;
|
|
91
91
|
sheetRenderer?: any;
|
|
92
92
|
rowRenderer?: any;
|
|
93
|
+
emptyRenderer?: any;
|
|
93
94
|
className?: string;
|
|
94
95
|
data: Cell[][];
|
|
95
96
|
freePaste?: boolean;
|
|
@@ -108,11 +109,11 @@ export declare type SheetProps = {
|
|
|
108
109
|
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
109
110
|
children?: any[];
|
|
110
111
|
};
|
|
111
|
-
export
|
|
112
|
+
export type WidthConfig = {
|
|
112
113
|
onChange?: (value: Record<number | string, number>) => void;
|
|
113
114
|
widths?: Record<number | string, number>;
|
|
114
115
|
};
|
|
115
|
-
export
|
|
116
|
+
export type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
|
|
116
117
|
className?: string;
|
|
117
118
|
showGroup?: boolean;
|
|
118
119
|
showSelect?: boolean;
|
|
@@ -127,24 +128,24 @@ export declare type SheetShell = Pick<SheetTableType.TableProps, 'columns'> & {
|
|
|
127
128
|
};
|
|
128
129
|
};
|
|
129
130
|
};
|
|
130
|
-
export
|
|
131
|
+
export type SheetRow = {
|
|
131
132
|
row: number;
|
|
132
133
|
cells: Cell[];
|
|
133
134
|
selected: boolean;
|
|
134
135
|
children: React.ElementType;
|
|
135
136
|
};
|
|
136
|
-
export
|
|
137
|
+
export type windowAssertion = {
|
|
137
138
|
clipboardData?: {
|
|
138
139
|
getData?: (type: string) => string;
|
|
139
140
|
setData?: (type: string, data: string) => string;
|
|
140
141
|
};
|
|
141
142
|
};
|
|
142
|
-
export
|
|
143
|
+
export type refAssertion = {
|
|
143
144
|
contains?: (target: EventTarget | null) => boolean;
|
|
144
145
|
focus?: () => boolean;
|
|
145
146
|
} & HTMLSpanElement;
|
|
146
|
-
export
|
|
147
|
-
export
|
|
147
|
+
export type AttributesRenderer = (cell: Cell, row: number, col: number) => Record<string, string>;
|
|
148
|
+
export type CellProps = {
|
|
148
149
|
row: number;
|
|
149
150
|
col: number;
|
|
150
151
|
cell: Cell;
|
|
@@ -153,7 +154,7 @@ export declare type CellProps = {
|
|
|
153
154
|
valueViewer?: React.ElementType;
|
|
154
155
|
attributesRenderer?: AttributesRenderer;
|
|
155
156
|
};
|
|
156
|
-
export
|
|
157
|
+
export type UpdateStateType = {
|
|
157
158
|
eventBus: EventEmitter;
|
|
158
159
|
start: CellPosition;
|
|
159
160
|
end: CellPosition;
|
|
@@ -184,16 +185,16 @@ export declare type UpdateStateType = {
|
|
|
184
185
|
};
|
|
185
186
|
cellChangeHandler: (cells: CellData[], additions?: CellData[]) => void;
|
|
186
187
|
};
|
|
187
|
-
export
|
|
188
|
-
export
|
|
188
|
+
export type UpdateFocus = (start: CellPosition, end: CellPosition) => void;
|
|
189
|
+
export type Options<T = any> = {
|
|
189
190
|
value: string | number;
|
|
190
191
|
label: string;
|
|
191
192
|
} & T;
|
|
192
|
-
export
|
|
193
|
+
export type OptionsType = Options<{
|
|
193
194
|
disabled?: boolean;
|
|
194
195
|
children?: OptionsType[];
|
|
195
196
|
}>;
|
|
196
|
-
export
|
|
197
|
+
export type OperateHistory = {
|
|
197
198
|
changes: Partial<CellData>[];
|
|
198
199
|
type: OperateType;
|
|
199
200
|
rowInfo?: {
|
|
@@ -202,4 +203,4 @@ export declare type OperateHistory = {
|
|
|
202
203
|
};
|
|
203
204
|
extraInfo?: Record<string, unknown>;
|
|
204
205
|
};
|
|
205
|
-
export
|
|
206
|
+
export type OperateType = 'Edit' | 'Paste' | 'Delete' | 'DeleteRow' | 'NewRow' | 'Custom';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { SheetType } from '.';
|
|
3
|
-
export
|
|
3
|
+
export type refAssertion = {
|
|
4
4
|
contains?: (target: EventTarget | null) => boolean;
|
|
5
5
|
focus?: () => boolean;
|
|
6
6
|
} & HTMLTableSectionElement;
|
|
7
|
-
export
|
|
8
|
-
export
|
|
9
|
-
export
|
|
7
|
+
export type CellFixed = SheetType.CellAlign;
|
|
8
|
+
export type RecordRowMap<T> = (value: unknown, record: Record<string, unknown>, index: number, colIndex?: number) => T;
|
|
9
|
+
export type ColumnProps = {
|
|
10
10
|
/**
|
|
11
11
|
* @description 对齐
|
|
12
12
|
* @default "left"
|
|
@@ -37,24 +37,24 @@ export declare type ColumnProps = {
|
|
|
37
37
|
render?: SheetType.CellViewer;
|
|
38
38
|
editor?: SheetType.CellEditor;
|
|
39
39
|
};
|
|
40
|
-
export
|
|
40
|
+
export type TableChange = {
|
|
41
41
|
col?: number;
|
|
42
42
|
row: number;
|
|
43
43
|
id: string;
|
|
44
44
|
key: string;
|
|
45
45
|
value: unknown;
|
|
46
46
|
};
|
|
47
|
-
export
|
|
47
|
+
export type TableRowSelection = {
|
|
48
48
|
rowSelected?: string[];
|
|
49
49
|
onChange?: (selectedRowKeys: string[], selectedRows: Record<string, unknown>[]) => void;
|
|
50
50
|
};
|
|
51
|
-
export
|
|
51
|
+
export type TableGroupConfig = {
|
|
52
52
|
defaultOpen?: boolean;
|
|
53
53
|
rowGroup?: SheetType.RowGroupConfig;
|
|
54
54
|
onChange?: (value: SheetType.RowGroupConfig) => void;
|
|
55
55
|
};
|
|
56
|
-
export
|
|
57
|
-
export
|
|
56
|
+
export type EventHandler = (value: any) => void;
|
|
57
|
+
export type TableProps = {
|
|
58
58
|
/**
|
|
59
59
|
* @description 表格类名
|
|
60
60
|
* @default "undefined"
|
|
@@ -68,6 +68,7 @@ export declare type TableProps = {
|
|
|
68
68
|
columns: ColumnProps[];
|
|
69
69
|
virtualized?: boolean;
|
|
70
70
|
dataSource: Record<string, unknown>[];
|
|
71
|
+
emptyRenderer?: any;
|
|
71
72
|
rowClassName?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
72
73
|
rowKey?: string | ((record: Record<string, unknown>, index: number) => string);
|
|
73
74
|
scroll?: {
|