@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,13 @@
|
|
|
1
|
+
export declare const TAB_KEY = 9;
|
|
2
|
+
export declare const ENTER_KEY = 13;
|
|
3
|
+
export declare const ESCAPE_KEY = 27;
|
|
4
|
+
export declare const LEFT_KEY = 37;
|
|
5
|
+
export declare const UP_KEY = 38;
|
|
6
|
+
export declare const RIGHT_KEY = 39;
|
|
7
|
+
export declare const DOWN_KEY = 40;
|
|
8
|
+
export declare const DELETE_KEY = 46;
|
|
9
|
+
export declare const BACKSPACE_KEY = 8;
|
|
10
|
+
export declare const Z_KEY = 90;
|
|
11
|
+
export declare const C_KEY = 67;
|
|
12
|
+
export declare const V_KEY = 86;
|
|
13
|
+
export declare const X_KEY = 88;
|
|
@@ -4,60 +4,41 @@ import { useMemo } from 'react';
|
|
|
4
4
|
import { optionsTransferToValue } from "../../util";
|
|
5
5
|
import "./index.less";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
value:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
console.log(opt);
|
|
38
|
-
onConfirm(opt ? opt[opt.length - 1] : null);
|
|
7
|
+
var getCascaderEditor = function getCascaderEditor(options) {
|
|
8
|
+
var CascaderEditor = function CascaderEditor(props) {
|
|
9
|
+
var value = props.value,
|
|
10
|
+
onConfirm = props.onConfirm;
|
|
11
|
+
var val = useMemo(function () {
|
|
12
|
+
return optionsTransferToValue(options, value);
|
|
13
|
+
}, [value, options]);
|
|
14
|
+
var handleChange = function handleChange(opt) {
|
|
15
|
+
console.log(opt);
|
|
16
|
+
onConfirm(opt ? opt[opt.length - 1] : null);
|
|
17
|
+
};
|
|
18
|
+
return /*#__PURE__*/_jsx(Cascader, {
|
|
19
|
+
autoFocus: true,
|
|
20
|
+
open: true,
|
|
21
|
+
className: 'cascader-editor',
|
|
22
|
+
onMouseDown: function onMouseDown(event) {
|
|
23
|
+
event.stopPropagation();
|
|
24
|
+
},
|
|
25
|
+
value: val
|
|
26
|
+
// allowClear={false}
|
|
27
|
+
,
|
|
28
|
+
displayRender: function displayRender(label) {
|
|
29
|
+
return label[label.length - 1];
|
|
30
|
+
},
|
|
31
|
+
onChange: handleChange
|
|
32
|
+
// onBlur={handleBlur}
|
|
33
|
+
// onKeyDown={handleKeyDown}
|
|
34
|
+
,
|
|
35
|
+
options: options
|
|
36
|
+
});
|
|
39
37
|
};
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
event.stopPropagation();
|
|
46
|
-
},
|
|
47
|
-
value: val
|
|
48
|
-
// allowClear={false}
|
|
49
|
-
,
|
|
50
|
-
displayRender: function displayRender(label) {
|
|
51
|
-
return label[label.length - 1];
|
|
52
|
-
},
|
|
53
|
-
onChange: handleChange
|
|
54
|
-
// onBlur={handleBlur}
|
|
55
|
-
// onKeyDown={handleKeyDown}
|
|
56
|
-
,
|
|
57
|
-
options: options
|
|
58
|
-
});
|
|
38
|
+
CascaderEditor.checker = function (value) {
|
|
39
|
+
var res = optionsTransferToValue(options, value);
|
|
40
|
+
return res && res.length > 0;
|
|
41
|
+
};
|
|
42
|
+
return CascaderEditor;
|
|
59
43
|
};
|
|
60
|
-
|
|
61
|
-
var res = optionsTransferToValue(options, value);
|
|
62
|
-
return res && res.length > 0;
|
|
63
|
-
};
|
|
44
|
+
export default getCascaderEditor;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SheetType } from "../../../type";
|
|
2
|
+
import { InputNumberProps } from 'antd';
|
|
3
|
+
import 'antd/es/input-number/style/index.css';
|
|
4
|
+
import './index.less';
|
|
5
|
+
export declare const NumberEditor: SheetType.CellEditor;
|
|
6
|
+
export declare const getNumberEditor: (extraProps: Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>) => SheetType.CellEditor;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
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
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
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); }
|
|
1
7
|
import { InputNumber as AntInputNumber } from 'antd';
|
|
2
8
|
import 'antd/es/input-number/style/index.css';
|
|
3
9
|
import { useEffect, useRef } from 'react';
|
|
@@ -22,4 +28,27 @@ export var NumberEditor = function NumberEditor(props) {
|
|
|
22
28
|
addonAfter: "%",
|
|
23
29
|
onChange: onChange
|
|
24
30
|
});
|
|
31
|
+
};
|
|
32
|
+
export var getNumberEditor = function getNumberEditor(extraProps) {
|
|
33
|
+
var NumberEditor = function NumberEditor(props) {
|
|
34
|
+
var value = props.value,
|
|
35
|
+
onChange = props.onChange;
|
|
36
|
+
var inputNumberRef = useRef(null);
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
var _inputNumberRef$curre2;
|
|
39
|
+
inputNumberRef === null || inputNumberRef === void 0 ? void 0 : (_inputNumberRef$curre2 = inputNumberRef.current) === null || _inputNumberRef$curre2 === void 0 ? void 0 : _inputNumberRef$curre2.focus();
|
|
40
|
+
}, []);
|
|
41
|
+
return /*#__PURE__*/_jsx(AntInputNumber, _objectSpread(_objectSpread({
|
|
42
|
+
ref: inputNumberRef
|
|
43
|
+
}, extraProps), {}, {
|
|
44
|
+
controls: false,
|
|
45
|
+
className: "number-editor",
|
|
46
|
+
onMouseDown: function onMouseDown(e) {
|
|
47
|
+
return e.stopPropagation();
|
|
48
|
+
},
|
|
49
|
+
value: value,
|
|
50
|
+
onChange: onChange
|
|
51
|
+
}));
|
|
52
|
+
};
|
|
53
|
+
return NumberEditor;
|
|
25
54
|
};
|
|
@@ -2,7 +2,7 @@ import { Select } from 'antd';
|
|
|
2
2
|
import 'antd/es/select/style/index.css';
|
|
3
3
|
import "./index.less";
|
|
4
4
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
|
-
export var
|
|
5
|
+
export var getSelectEditor = function getSelectEditor(options) {
|
|
6
6
|
var SelectEditor = function SelectEditor(props) {
|
|
7
7
|
var value = props.value,
|
|
8
8
|
onConfirm = props.onConfirm;
|
|
@@ -41,4 +41,4 @@ export var GetSelectEditor = function GetSelectEditor(options) {
|
|
|
41
41
|
};
|
|
42
42
|
return SelectEditor;
|
|
43
43
|
};
|
|
44
|
-
export default
|
|
44
|
+
export default getSelectEditor;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SheetType } from "../../type";
|
|
2
|
+
export declare type SheetAction = 'change' | 'changes' | 'rowMove' | 'colMove' | 'editFinish' | 'pushHistory' | 'selectRow' | 'clearSelect' | 'clearSelectIfNotSingleRow' | 'clearEdit' | 'mouseDown' | 'mouseOver' | 'mouseUp' | 'loseFocus' | 'doubleClick' | 'mouseLeaveInterval' | 'move' | 'escape' | 'reverse' | 'delete' | 'enter' | 'otherInput' | 'none';
|
|
3
|
+
export declare type reducerAction = (type: Partial<SheetType.UpdateStateType>, payload?: unknown) => Partial<SheetType.UpdateStateType>;
|
|
4
|
+
declare const sheetReducer: (state: Partial<SheetType.UpdateStateType>, action: {
|
|
5
|
+
type: SheetAction;
|
|
6
|
+
payload?: unknown;
|
|
7
|
+
}) => Partial<SheetType.UpdateStateType>;
|
|
8
|
+
export default sheetReducer;
|
|
9
|
+
export { sideEffectReducer } from './sideEffectReducer';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SheetType } from "../../type";
|
|
2
|
+
import { FunctionAction, NormalAction } from '../../hooks';
|
|
3
|
+
export declare type asyncActionType = (dispatch: (action: NormalAction | FunctionAction) => void, getState: () => SheetType.UpdateStateType) => void;
|
|
4
|
+
export declare const sideEffectReducer: Record<string, asyncActionType>;
|
package/dist/core/sheet/Cell.js
CHANGED
|
@@ -13,10 +13,8 @@ import DefaultCell from "./DefaultCell";
|
|
|
13
13
|
import ValueViewer from "./ValueViewer";
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
function initialData(_ref) {
|
|
16
|
-
var cell = _ref.cell
|
|
17
|
-
|
|
18
|
-
col = _ref.col;
|
|
19
|
-
return renderValue(cell, row, col);
|
|
16
|
+
var cell = _ref.cell;
|
|
17
|
+
return renderValue(cell);
|
|
20
18
|
}
|
|
21
19
|
function widthStyle(cell) {
|
|
22
20
|
var width = typeof (cell === null || cell === void 0 ? void 0 : cell.width) === 'number' ? "".concat(cell.width, "px") : cell.width;
|
|
@@ -57,7 +55,7 @@ var Cell = function Cell(props) {
|
|
|
57
55
|
setValue = _useState2[1];
|
|
58
56
|
var valueRef = useRef(value);
|
|
59
57
|
useEffect(function () {
|
|
60
|
-
var newValue = renderValue(cell
|
|
58
|
+
var newValue = renderValue(cell);
|
|
61
59
|
setValue(newValue);
|
|
62
60
|
valueRef.current = newValue;
|
|
63
61
|
}, [cell, row, col]);
|
|
@@ -127,7 +125,7 @@ var Cell = function Cell(props) {
|
|
|
127
125
|
};
|
|
128
126
|
var renderViewer = function renderViewer(cel, r, col, valViewer) {
|
|
129
127
|
var Viewer = cell.valueViewer || valViewer || ValueViewer;
|
|
130
|
-
var val = renderValue(cell
|
|
128
|
+
var val = renderValue(cell);
|
|
131
129
|
return /*#__PURE__*/_jsx(Viewer, {
|
|
132
130
|
record: cell.record,
|
|
133
131
|
cell: cell,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SheetType } from "../../type";
|
|
2
|
+
declare const DefaultCell: (props: {
|
|
3
|
+
cell: SheetType.Cell;
|
|
4
|
+
row: number;
|
|
5
|
+
col: number;
|
|
6
|
+
attributesRenderer?: SheetType.AttributesRenderer | undefined;
|
|
7
|
+
className: string;
|
|
8
|
+
style: Record<string, string>;
|
|
9
|
+
children: React.ReactElement;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export default DefaultCell;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SheetType } from "../../type";
|
|
3
|
+
declare const DefaultRow: React.FC<{
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
row: number;
|
|
6
|
+
groupConfig?: {
|
|
7
|
+
groups: SheetType.RowGroup[];
|
|
8
|
+
groupOpen: boolean[];
|
|
9
|
+
};
|
|
10
|
+
}>;
|
|
11
|
+
export default DefaultRow;
|
package/dist/core/sheet/Event.js
CHANGED
|
@@ -41,7 +41,10 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
41
41
|
.harvest-sheet-container .harvest-sheet .cell {
|
|
42
42
|
height: 17px;
|
|
43
43
|
font-size: var(--cell-font-size);
|
|
44
|
-
padding:var(--cell-padding-
|
|
44
|
+
padding-left:var(--cell-padding-horizontal);
|
|
45
|
+
padding-right:var(--cell-padding-horizontal);
|
|
46
|
+
padding-top:var(--cell-padding-vertical);
|
|
47
|
+
padding-bottom:var(--cell-padding-vertical);
|
|
45
48
|
border: 1px solid var(--cell-border-color);
|
|
46
49
|
background-color: var(--cell-background-color);
|
|
47
50
|
cursor: cell;
|
|
@@ -143,6 +146,7 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
143
146
|
.harvest-sheet-container .harvest-sheet .cell.sheet-control{
|
|
144
147
|
border-right: 1px solid transparent;
|
|
145
148
|
background: var(--cell-background-color) ;
|
|
149
|
+
color:var(--read-color);
|
|
146
150
|
// position: relative !important;
|
|
147
151
|
}
|
|
148
152
|
|
|
@@ -176,6 +180,7 @@ span.harvest-sheet-container, span.harvest-sheet-container:focus {
|
|
|
176
180
|
.harvest-sheet-container .harvest-sheet .cell > input {
|
|
177
181
|
display: block;
|
|
178
182
|
width: calc(100% - 6px);
|
|
183
|
+
font-size: var(--cell-font-size);
|
|
179
184
|
height: 11px;
|
|
180
185
|
border: 2px solid rgb(33, 133, 208);
|
|
181
186
|
background: none;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Dispatch } from "../../hooks";
|
|
2
|
+
import type { SheetType } from "../../type";
|
|
3
|
+
export declare type MenuEvent = {
|
|
4
|
+
showMenu: boolean;
|
|
5
|
+
position: {
|
|
6
|
+
top: number;
|
|
7
|
+
left: number;
|
|
8
|
+
};
|
|
9
|
+
cellPosition: SheetType.CellPosition;
|
|
10
|
+
};
|
|
11
|
+
export declare const useContextMenu: (dispatch: Dispatch, elementRef: React.RefObject<SheetType.refAssertion>, enableContextMenu: boolean | undefined, contextMenuRef: React.RefObject<HTMLDivElement>) => {
|
|
12
|
+
showMenu: boolean;
|
|
13
|
+
position: {
|
|
14
|
+
top: number;
|
|
15
|
+
left: number;
|
|
16
|
+
};
|
|
17
|
+
cellPosition: {
|
|
18
|
+
row: number;
|
|
19
|
+
col: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetType } from "../../type";
|
|
2
|
+
export declare const useVirtualList: (elementRef: React.RefObject<SheetType.refAssertion>, data?: SheetType.Cell[][], virtualized?: boolean) => {
|
|
3
|
+
virtualStart: number;
|
|
4
|
+
virtualEnd: number;
|
|
5
|
+
paddingTop: number;
|
|
6
|
+
paddingBottom: number;
|
|
7
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SheetType } from "../../../type";
|
|
3
|
+
import './index.less';
|
|
4
|
+
export declare const DraggableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
}>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { SheetType } from "../../type";
|
|
3
|
+
import './draggableShell/index.less';
|
|
4
|
+
export declare const TableShell: ({ columns, className, showGroup, showSelect, controlProps, controlWidth, }: SheetType.SheetShell) => import("react").FC<{
|
|
5
|
+
children: React.ReactElement;
|
|
6
|
+
}>;
|
package/dist/core/table/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
2
|
-
var _excluded = ["columns", "dataSource", "rowKey", "rowSelection", "groupConfig", "onChange", "draggable"];
|
|
2
|
+
var _excluded = ["columns", "dataSource", "rowKey", "rowSelection", "groupConfig", "onChange", "draggable", "eventHandler"];
|
|
3
3
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
5
|
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; }
|
|
@@ -17,8 +17,8 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
17
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
18
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
19
19
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
20
|
+
import { Sheet } from "../..";
|
|
20
21
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
21
|
-
import Sheet from "../sheet";
|
|
22
22
|
import { SheetEvent } from "../sheet/Event";
|
|
23
23
|
import { DraggableShell } from "../shell/draggableShell";
|
|
24
24
|
import { TableShell } from "../shell/tableShell";
|
|
@@ -37,6 +37,7 @@ var Table = function Table(_ref) {
|
|
|
37
37
|
groupConfig = _ref.groupConfig,
|
|
38
38
|
onChange = _ref.onChange,
|
|
39
39
|
draggable = _ref.draggable,
|
|
40
|
+
eventHandler = _ref.eventHandler,
|
|
40
41
|
args = _objectWithoutProperties(_ref, _excluded);
|
|
41
42
|
var _useState = useState([[]]),
|
|
42
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -90,8 +91,8 @@ var Table = function Table(_ref) {
|
|
|
90
91
|
id: rowId,
|
|
91
92
|
row: currentIndex,
|
|
92
93
|
col: -1,
|
|
93
|
-
readonly: true,
|
|
94
94
|
editable: false,
|
|
95
|
+
align: 'center',
|
|
95
96
|
value: groupMap.get(currentIndex) && ((_groupMap$get = groupMap.get(currentIndex)) === null || _groupMap$get === void 0 ? void 0 : _groupMap$get.isStart),
|
|
96
97
|
record: {
|
|
97
98
|
open: groupMap.get(currentIndex) && ((_groupMap$get2 = groupMap.get(currentIndex)) === null || _groupMap$get2 === void 0 ? void 0 : _groupMap$get2.isOpen)
|
|
@@ -140,6 +141,7 @@ var Table = function Table(_ref) {
|
|
|
140
141
|
row: row,
|
|
141
142
|
col: -1,
|
|
142
143
|
readonly: true,
|
|
144
|
+
align: 'center',
|
|
143
145
|
value: checkedRow[row],
|
|
144
146
|
valueViewer: CheckViewer,
|
|
145
147
|
className: 'sheet-control'
|
|
@@ -305,6 +307,11 @@ var Table = function Table(_ref) {
|
|
|
305
307
|
}, "group-open-title")] : null, /*#__PURE__*/_jsx(SheetEvent, {
|
|
306
308
|
name: "reverse",
|
|
307
309
|
handler: handleReverse
|
|
310
|
+
}), Object.keys(eventHandler || {}).map(function (key) {
|
|
311
|
+
return /*#__PURE__*/_jsx(SheetEvent, {
|
|
312
|
+
name: key,
|
|
313
|
+
handler: eventHandler === null || eventHandler === void 0 ? void 0 : eventHandler[key]
|
|
314
|
+
}, key);
|
|
308
315
|
})]
|
|
309
316
|
}));
|
|
310
317
|
};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { SheetTableType, SheetType } from "../../type";
|
|
2
|
+
export declare const useGroupConfig: (dataSource: Record<string, unknown>[], tableGroupConfig?: SheetTableType.TableGroupConfig, hasChildren?: boolean) => [SheetType.RowGroupConfig, (value: SheetType.RowGroupConfig) => void];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useRowSelection: (dataSource: Record<string, unknown>[], rowSelection?: any, hasChildren?: boolean) => [boolean[], (value: boolean[]) => void];
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { SheetType } from "../type";
|
|
2
|
+
export declare function findParentTd(el: HTMLElement): HTMLElement | null;
|
|
3
|
+
export declare function extractDataRowAndCol(el: HTMLElement): {
|
|
4
|
+
row: number;
|
|
5
|
+
col: number;
|
|
6
|
+
};
|
|
7
|
+
export declare function getRowColConfig(start?: SheetType.CellPosition, end?: SheetType.CellPosition): {
|
|
8
|
+
startRow: number;
|
|
9
|
+
endRow: number;
|
|
10
|
+
startCol: number;
|
|
11
|
+
endCol: number;
|
|
12
|
+
};
|
|
13
|
+
export declare function flatRowColIndex(start?: SheetType.CellPosition, end?: SheetType.CellPosition): SheetType.CellPosition[];
|
|
14
|
+
export declare function flatRowCol(start?: SheetType.CellPosition, end?: SheetType.CellPosition): string[];
|
|
15
|
+
export declare function isInputKey(keyCode: number): boolean;
|
|
16
|
+
export declare function classNames(...args: (string | null | undefined)[]): string;
|
|
17
|
+
export declare function stringToClipboardData(str: string): void;
|
|
18
|
+
export declare const defaultParsePaste: (str: string) => string[][];
|
|
19
|
+
export declare function clipboardDataToString(): Promise<string[][]>;
|
|
20
|
+
export declare function formatDataToCell({ start, editing, end, data, pasteData, groupConfig, freePaste, }: Partial<SheetType.UpdateStateType> & {
|
|
21
|
+
pasteData: string[][];
|
|
22
|
+
freePaste: boolean;
|
|
23
|
+
}): {
|
|
24
|
+
changes: SheetType.CellData[];
|
|
25
|
+
extChanges?: undefined;
|
|
26
|
+
} | {
|
|
27
|
+
changes: SheetType.CellData[];
|
|
28
|
+
extChanges: SheetType.CellData[] | undefined;
|
|
29
|
+
} | undefined;
|
|
30
|
+
export declare const defaultValueRenderer: (cell: SheetType.Cell) => string | number | null | undefined;
|
|
31
|
+
export declare function renderValue(cell: SheetType.Cell): string | number;
|
|
32
|
+
export declare const optionsTransferToValue: (options: SheetType.OptionsType[], val: string) => string[];
|
|
33
|
+
export declare const groupConfigToGroupMap: (rowGroupConfig?: SheetType.RowGroupConfig) => Map<number, SheetType.RowGroup & {
|
|
34
|
+
isStart: boolean;
|
|
35
|
+
isOpen: boolean;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const changeGroupConfig: (rowGroupConfig: SheetType.RowGroupConfig, changeInfo: {
|
|
38
|
+
add?: number | undefined;
|
|
39
|
+
remove?: number | undefined;
|
|
40
|
+
}) => SheetType.RowGroupConfig;
|
|
41
|
+
export declare const rowToActualRow: (row: number, groupConfig?: SheetType.RowGroupConfig) => number;
|
|
42
|
+
export declare const getRowHeight: (container: HTMLSpanElement) => number;
|
|
43
|
+
export declare const getNextVisibleRow: (row: number, maxRow: number, groupMap?: Map<number, SheetType.RowGroup & {
|
|
44
|
+
isStart: boolean;
|
|
45
|
+
isOpen: boolean;
|
|
46
|
+
}>) => number | null;
|
|
47
|
+
export declare const calcMenuPosition: ({ tableElement, menuElement, x, y, }: {
|
|
48
|
+
tableElement: SheetType.refAssertion | null;
|
|
49
|
+
menuElement?: Element | null | undefined;
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
}) => {
|
|
53
|
+
top: number;
|
|
54
|
+
left: number;
|
|
55
|
+
};
|
package/dist/core/util.js
CHANGED
|
@@ -12,6 +12,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
12
12
|
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; }
|
|
13
13
|
/* eslint-disable no-param-reassign */
|
|
14
14
|
/* eslint-disable @typescript-eslint/no-use-before-define */
|
|
15
|
+
|
|
15
16
|
import { cloneDeep, isNil, range } from 'lodash';
|
|
16
17
|
export function findParentTd(el) {
|
|
17
18
|
if (!el) return null;
|