@zhenliang/sheet 0.1.20 → 0.1.22
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/package.json +1 -1
- package/dist/core/config.d.ts +0 -13
- package/dist/core/config.js +0 -13
- package/dist/core/editor/cascaderEditor/index.d.ts +0 -5
- package/dist/core/editor/cascaderEditor/index.js +0 -54
- package/dist/core/editor/cascaderEditor/index.less +0 -28
- package/dist/core/editor/dateEditor/index.d.ts +0 -5
- package/dist/core/editor/dateEditor/index.js +0 -55
- package/dist/core/editor/dateEditor/index.less +0 -11
- package/dist/core/editor/index.d.ts +0 -4
- package/dist/core/editor/index.js +0 -4
- package/dist/core/editor/numberEditor/index.d.ts +0 -8
- package/dist/core/editor/numberEditor/index.js +0 -107
- package/dist/core/editor/numberEditor/index.less +0 -30
- package/dist/core/editor/selectEditor/index.d.ts +0 -6
- package/dist/core/editor/selectEditor/index.js +0 -96
- package/dist/core/editor/selectEditor/index.less +0 -43
- package/dist/core/reducers/index.d.ts +0 -9
- package/dist/core/reducers/index.js +0 -38
- package/dist/core/reducers/keyboardReducer.d.ts +0 -2
- package/dist/core/reducers/keyboardReducer.js +0 -93
- package/dist/core/reducers/mouseReducer.d.ts +0 -2
- package/dist/core/reducers/mouseReducer.js +0 -164
- package/dist/core/reducers/sideEffectReducer.d.ts +0 -4
- package/dist/core/reducers/sideEffectReducer.js +0 -378
- package/dist/core/reducers/stateReducer.d.ts +0 -2
- package/dist/core/reducers/stateReducer.js +0 -174
- package/dist/core/sheet/Cell.d.ts +0 -4
- package/dist/core/sheet/Cell.js +0 -181
- package/dist/core/sheet/DataEditor.d.ts +0 -3
- package/dist/core/sheet/DataEditor.js +0 -24
- package/dist/core/sheet/DefaultCell.d.ts +0 -11
- package/dist/core/sheet/DefaultCell.js +0 -31
- package/dist/core/sheet/DefaultRow.d.ts +0 -12
- package/dist/core/sheet/DefaultRow.js +0 -28
- package/dist/core/sheet/DefaultRowMapper.d.ts +0 -8
- package/dist/core/sheet/DefaultRowMapper.js +0 -15
- package/dist/core/sheet/DefaultShell.d.ts +0 -8
- package/dist/core/sheet/DefaultShell.js +0 -12
- package/dist/core/sheet/Event.d.ts +0 -5
- package/dist/core/sheet/Event.js +0 -17
- package/dist/core/sheet/ValueViewer.d.ts +0 -3
- package/dist/core/sheet/ValueViewer.js +0 -9
- package/dist/core/sheet/index.d.ts +0 -5
- package/dist/core/sheet/index.js +0 -265
- package/dist/core/sheet/index.less +0 -307
- package/dist/core/sheet/useCellEvent.d.ts +0 -3
- package/dist/core/sheet/useCellEvent.js +0 -22
- package/dist/core/sheet/useContextMenu.d.ts +0 -21
- package/dist/core/sheet/useContextMenu.js +0 -86
- package/dist/core/sheet/useKeyBoardEvent.d.ts +0 -3
- package/dist/core/sheet/useKeyBoardEvent.js +0 -66
- package/dist/core/sheet/useMouseEvent.d.ts +0 -3
- package/dist/core/sheet/useMouseEvent.js +0 -298
- package/dist/core/sheet/useSelectVisible.d.ts +0 -2
- package/dist/core/sheet/useSelectVisible.js +0 -57
- package/dist/core/sheet/useVirtualList.d.ts +0 -7
- package/dist/core/sheet/useVirtualList.js +0 -103
- package/dist/core/sheet/var.less +0 -41
- package/dist/core/shell/draggableShell/index.d.ts +0 -5
- package/dist/core/shell/draggableShell/index.js +0 -197
- package/dist/core/shell/draggableShell/index.less +0 -16
- package/dist/core/shell/tableShell.d.ts +0 -5
- package/dist/core/shell/tableShell.js +0 -109
- package/dist/core/table/events.d.ts +0 -15
- package/dist/core/table/events.js +0 -95
- package/dist/core/table/index.d.ts +0 -4
- package/dist/core/table/index.js +0 -313
- package/dist/core/table/useGroupConfig.d.ts +0 -2
- package/dist/core/table/useGroupConfig.js +0 -65
- package/dist/core/table/useRowSelection.d.ts +0 -2
- package/dist/core/table/useRowSelection.js +0 -24
- package/dist/core/table/util.d.ts +0 -8
- package/dist/core/table/util.js +0 -29
- package/dist/core/util.d.ts +0 -59
- package/dist/core/util.js +0 -490
- package/dist/core/viewer/btnViewer/index.d.ts +0 -2
- package/dist/core/viewer/btnViewer/index.js +0 -37
- package/dist/core/viewer/cascaderViewer/index.d.ts +0 -2
- package/dist/core/viewer/cascaderViewer/index.js +0 -11
- package/dist/core/viewer/checkViewer/index.d.ts +0 -2
- package/dist/core/viewer/checkViewer/index.js +0 -23
- package/dist/core/viewer/editViewer/index.d.ts +0 -2
- package/dist/core/viewer/editViewer/index.js +0 -31
- package/dist/core/viewer/groupViewer/index.d.ts +0 -2
- package/dist/core/viewer/groupViewer/index.js +0 -34
- package/dist/core/viewer/index.d.ts +0 -7
- package/dist/core/viewer/index.js +0 -7
- package/dist/core/viewer/selectorViewer/index.d.ts +0 -2
- package/dist/core/viewer/selectorViewer/index.js +0 -16
- package/dist/core/viewer/switchViewer/index.d.ts +0 -2
- package/dist/core/viewer/switchViewer/index.js +0 -22
- package/dist/example/antComponent.d.ts +0 -3
- package/dist/example/antComponent.js +0 -314
- package/dist/example/basic.d.ts +0 -4
- package/dist/example/basic.js +0 -121
- package/dist/example/ellipsis.d.ts +0 -3
- package/dist/example/ellipsis.js +0 -64
- package/dist/example/fixed.d.ts +0 -3
- package/dist/example/fixed.js +0 -89
- package/dist/example/group.d.ts +0 -3
- package/dist/example/group.js +0 -123
- package/dist/example/index.less +0 -5
- package/dist/example/selection.d.ts +0 -4
- package/dist/example/selection.js +0 -86
- package/dist/example/sheet.d.ts +0 -4
- package/dist/example/sheet.js +0 -393
- package/dist/example/valuationAnalyze.d.ts +0 -2
- package/dist/example/valuationAnalyze.js +0 -227
- package/dist/hooks/index.d.ts +0 -8
- package/dist/hooks/index.js +0 -7
- package/dist/hooks/useEventBus.d.ts +0 -4
- package/dist/hooks/useEventBus.js +0 -17
- package/dist/hooks/useKeyboard.d.ts +0 -18
- package/dist/hooks/useKeyboard.js +0 -108
- package/dist/hooks/useMiddlewareReducer.d.ts +0 -12
- package/dist/hooks/useMiddlewareReducer.js +0 -47
- package/dist/hooks/useMouse.d.ts +0 -11
- package/dist/hooks/useMouse.js +0 -68
- package/dist/hooks/useSetState.d.ts +0 -2
- package/dist/hooks/useSetState.js +0 -27
- package/dist/hooks/useSheetEvent.d.ts +0 -5
- package/dist/hooks/useSheetEvent.js +0 -5
- package/dist/hooks/useWidthConfig.d.ts +0 -4
- package/dist/hooks/useWidthConfig.js +0 -5
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -8
- package/dist/standardUtils/index.d.ts +0 -9
- package/dist/standardUtils/index.js +0 -32
- package/dist/type/index.d.ts +0 -2
- package/dist/type/index.js +0 -4
- package/dist/type/sheet.d.ts +0 -205
- package/dist/type/sheet.js +0 -9
- package/dist/type/sheetTable.d.ts +0 -89
- package/dist/type/sheetTable.js +0 -1
- package/dist/typings/index.d.ts +0 -1
package/changes.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
### 为什么要重写
|
|
2
|
+
|
|
3
|
+
#### 存在问题
|
|
4
|
+
|
|
5
|
+
1、表格选择逻辑与虚拟列表的冲突
|
|
6
|
+
2、表格的刷新机制: setRefresh(在多人开发的时候不便维护)
|
|
7
|
+
3、回调地狱
|
|
8
|
+
4、无法从 jll-portal 中剥离,有些地方与业务字段耦合
|
|
9
|
+
|
|
10
|
+
#### 后果
|
|
11
|
+
|
|
12
|
+
1、新增功能难度大
|
|
13
|
+
2、修改容易出 bug
|
|
14
|
+
3、不利于业务代码优化和重构
|
|
15
|
+
|
|
16
|
+
### 重写后的表格
|
|
17
|
+
|
|
18
|
+
#### 优点
|
|
19
|
+
|
|
20
|
+
1、维护性
|
|
21
|
+
2、扩展性
|
|
22
|
+
3、新的功能
|
|
23
|
+
|
|
24
|
+
#### 新的 API
|
|
25
|
+
|
|
26
|
+
1、TableProps
|
|
27
|
+
|
|
28
|
+
| 表头 | 表头 | 表头 |
|
|
29
|
+
| -------------------------------------------- | ----------------------- | ---- |
|
|
30
|
+
| className | container 类名 | 无 | |
|
|
31
|
+
| | sheetInstance | sheet 对外暴露的一些 API | 选中行,参与回滚等 | |
|
|
32
|
+
|
|
33
|
+
| columns | 表格列 | 无 ,必填 |
|
|
34
|
+
| dataSource | 数据源 | 无,必填 |
|
|
35
|
+
| virtualized |虚拟列表 | false |
|
|
36
|
+
| draggable | 列宽可调整 | false |
|
|
37
|
+
| rowClassName | 行类名 | 无 |
|
|
38
|
+
| rowKey | 唯一标识字段 | key , id |
|
|
39
|
+
| scroll | 同 antd table | {y:Math.min(400,row \* 40)} |
|
|
40
|
+
| rowSelection | 选中行的配置 | 尚未完全实现 |
|
|
41
|
+
| groupConfig | 表格分组 | 表格内部自动支持,对外配置尚未完全实现 |
|
|
42
|
+
| onChange | 表格 cell change handler | 无 |
|
|
43
|
+
| eventHandler | 自定义事件 handler | Record<string,(value:unknown)=>void> |
|
|
44
|
+
|
|
45
|
+
2、 ColumnProps
|
package/package.json
CHANGED
package/dist/core/config.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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;
|
package/dist/core/config.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export var TAB_KEY = 9;
|
|
2
|
-
export var ENTER_KEY = 13;
|
|
3
|
-
export var ESCAPE_KEY = 27;
|
|
4
|
-
export var LEFT_KEY = 37;
|
|
5
|
-
export var UP_KEY = 38;
|
|
6
|
-
export var RIGHT_KEY = 39;
|
|
7
|
-
export var DOWN_KEY = 40;
|
|
8
|
-
export var DELETE_KEY = 46;
|
|
9
|
-
export var BACKSPACE_KEY = 8;
|
|
10
|
-
export var Z_KEY = 90;
|
|
11
|
-
export var C_KEY = 67;
|
|
12
|
-
export var V_KEY = 86;
|
|
13
|
-
export var X_KEY = 88;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { SheetType } from "../../../type";
|
|
2
|
-
import 'antd/es/cascader/style/index.css';
|
|
3
|
-
import './index.less';
|
|
4
|
-
declare const getCascaderEditor: (options: SheetType.OptionsType[], getCustomOptions?: ((props: SheetType.CellEditorProps) => SheetType.OptionsType[]) | undefined) => SheetType.CellEditor;
|
|
5
|
-
export default getCascaderEditor;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { Cascader } from 'antd';
|
|
2
|
-
import 'antd/es/cascader/style/index.css';
|
|
3
|
-
import { isNil } from 'lodash';
|
|
4
|
-
import { useMemo } from 'react';
|
|
5
|
-
import { optionsToValuesFromLabelOrValue, valuesTransferToLabel } from "../../util";
|
|
6
|
-
import "./index.less";
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
var getCascaderEditor = function getCascaderEditor(options, getCustomOptions) {
|
|
9
|
-
var CascaderEditor = function CascaderEditor(props) {
|
|
10
|
-
var value = props.value,
|
|
11
|
-
onConfirm = props.onConfirm;
|
|
12
|
-
var val = useMemo(function () {
|
|
13
|
-
var res = optionsToValuesFromLabelOrValue(options, value);
|
|
14
|
-
console.log('cascader-editor', options, res, value);
|
|
15
|
-
return res;
|
|
16
|
-
}, [value, options]);
|
|
17
|
-
var handleChange = function handleChange(opt) {
|
|
18
|
-
onConfirm(opt ? opt[opt.length - 1] : null);
|
|
19
|
-
};
|
|
20
|
-
var customOptions = getCustomOptions ? getCustomOptions(props) : options;
|
|
21
|
-
return /*#__PURE__*/_jsx(Cascader, {
|
|
22
|
-
autoFocus: true,
|
|
23
|
-
open: true,
|
|
24
|
-
className: 'cascader-editor',
|
|
25
|
-
onMouseDown: function onMouseDown(event) {
|
|
26
|
-
event.stopPropagation();
|
|
27
|
-
},
|
|
28
|
-
value: val,
|
|
29
|
-
allowClear: true,
|
|
30
|
-
displayRender: function displayRender(label) {
|
|
31
|
-
return label[label.length - 1];
|
|
32
|
-
},
|
|
33
|
-
onChange: handleChange,
|
|
34
|
-
options: customOptions
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
CascaderEditor.formatter = function (value) {
|
|
38
|
-
var res = optionsToValuesFromLabelOrValue(options, value);
|
|
39
|
-
return !(res !== null && res !== void 0 && res.length) ? '' : valuesTransferToLabel(options, res[res.length - 1]);
|
|
40
|
-
};
|
|
41
|
-
CascaderEditor.parser = function (value) {
|
|
42
|
-
var res = optionsToValuesFromLabelOrValue(options, value);
|
|
43
|
-
return res.length ? res[res.length - 1] : null;
|
|
44
|
-
};
|
|
45
|
-
CascaderEditor.checker = function (value) {
|
|
46
|
-
if (isNil(value)) {
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
var res = optionsToValuesFromLabelOrValue(options, value);
|
|
50
|
-
return !!res.length;
|
|
51
|
-
};
|
|
52
|
-
return CascaderEditor;
|
|
53
|
-
};
|
|
54
|
-
export default getCascaderEditor;
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
.cascader-editor{
|
|
2
|
-
width: 100%;
|
|
3
|
-
padding: 0;
|
|
4
|
-
height: 20px !important;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
.ant-select-selector{
|
|
8
|
-
.ant-select-selection-search{
|
|
9
|
-
height: 16px !important;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
border: none !important;
|
|
13
|
-
background: transparent !important;
|
|
14
|
-
box-shadow: none !important;
|
|
15
|
-
color: #292c33;
|
|
16
|
-
height: 20px !important;
|
|
17
|
-
padding:0 !important;
|
|
18
|
-
|
|
19
|
-
input{
|
|
20
|
-
height: 18px !important;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.ant-cascader-menu {
|
|
25
|
-
font-size: 12px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { DatePickerProps } from 'antd';
|
|
2
|
-
import 'antd/es/date-picker/style/index.css';
|
|
3
|
-
import type { SheetType } from "../../../type";
|
|
4
|
-
import './index.less';
|
|
5
|
-
export declare const getDateEditor: (dateProps?: Pick<DatePickerProps, 'disabledDate' | 'disabled' | 'allowClear' | 'placeholder'>) => SheetType.CellEditor;
|
|
@@ -1,55 +0,0 @@
|
|
|
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); }
|
|
7
|
-
import { DatePicker } from 'antd';
|
|
8
|
-
import 'antd/es/date-picker/style/index.css';
|
|
9
|
-
import { isNil } from 'lodash';
|
|
10
|
-
import moment from 'moment';
|
|
11
|
-
import { useEffect, useMemo, useRef } from 'react';
|
|
12
|
-
import "./index.less";
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
export var getDateEditor = function getDateEditor(dateProps) {
|
|
15
|
-
var DateEditor = function DateEditor(props) {
|
|
16
|
-
var value = props.value,
|
|
17
|
-
onChange = props.onChange,
|
|
18
|
-
onConfirm = props.onConfirm;
|
|
19
|
-
var dateRef = useRef(null);
|
|
20
|
-
useEffect(function () {
|
|
21
|
-
var _dateRef$current;
|
|
22
|
-
dateRef === null || dateRef === void 0 ? void 0 : (_dateRef$current = dateRef.current) === null || _dateRef$current === void 0 ? void 0 : _dateRef$current.focus();
|
|
23
|
-
}, []);
|
|
24
|
-
var val = useMemo(function () {
|
|
25
|
-
return value && moment(value);
|
|
26
|
-
}, [value]);
|
|
27
|
-
var handleChange = function handleChange(value) {
|
|
28
|
-
onChange(value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD'));
|
|
29
|
-
onConfirm(value === null || value === void 0 ? void 0 : value.format('YYYY-MM-DD'));
|
|
30
|
-
};
|
|
31
|
-
return /*#__PURE__*/_jsx(DatePicker, _objectSpread({
|
|
32
|
-
open: true,
|
|
33
|
-
ref: dateRef,
|
|
34
|
-
className: "date-editor",
|
|
35
|
-
value: val,
|
|
36
|
-
onMouseDown: function onMouseDown(e) {
|
|
37
|
-
return e.stopPropagation();
|
|
38
|
-
},
|
|
39
|
-
onChange: handleChange
|
|
40
|
-
}, dateProps));
|
|
41
|
-
};
|
|
42
|
-
DateEditor.checker = function (value) {
|
|
43
|
-
if (isNil(value)) {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
var reg = /^[1-9]\d{3}(-|\/)(0[1-9]|1[0-2])(-|\/)(0[1-9]|[1-2][0-9]|3[0-1])$/;
|
|
47
|
-
return reg.test(value);
|
|
48
|
-
};
|
|
49
|
-
DateEditor.formatter = function (value) {
|
|
50
|
-
var _DateEditor$checker;
|
|
51
|
-
if (!(DateEditor !== null && DateEditor !== void 0 && (_DateEditor$checker = DateEditor.checker) !== null && _DateEditor$checker !== void 0 && _DateEditor$checker.call(DateEditor, value))) return null;
|
|
52
|
-
return value.replace('/', '-').replace('/', '-');
|
|
53
|
-
};
|
|
54
|
-
return DateEditor;
|
|
55
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
declare type inputProps = Partial<Pick<InputNumberProps, 'max' | 'min' | 'addonBefore' | 'addonAfter' | 'precision'>>;
|
|
6
|
-
export declare const NumberEditor: SheetType.CellEditor;
|
|
7
|
-
export declare const getNumberEditor: (extraProps?: inputProps, getExtraProps?: ((props: SheetType.CellEditorProps) => inputProps) | undefined) => SheetType.CellEditor;
|
|
8
|
-
export {};
|
|
@@ -1,107 +0,0 @@
|
|
|
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 = ["precision"];
|
|
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
|
-
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
|
-
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; }
|
|
6
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
7
|
-
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
|
-
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; }
|
|
9
|
-
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; }
|
|
10
|
-
import { formatPrecision } from "../../../standardUtils";
|
|
11
|
-
import { InputNumber as AntInputNumber } from 'antd';
|
|
12
|
-
import 'antd/es/input-number/style/index.css';
|
|
13
|
-
import { isNil } from 'lodash';
|
|
14
|
-
import { useCallback, useEffect, useRef } from 'react';
|
|
15
|
-
import "./index.less";
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
export var NumberEditor = function NumberEditor(props) {
|
|
18
|
-
var value = props.value,
|
|
19
|
-
onChange = props.onChange;
|
|
20
|
-
var inputNumberRef = useRef(null);
|
|
21
|
-
useEffect(function () {
|
|
22
|
-
var _inputNumberRef$curre;
|
|
23
|
-
inputNumberRef === null || inputNumberRef === void 0 ? void 0 : (_inputNumberRef$curre = inputNumberRef.current) === null || _inputNumberRef$curre === void 0 ? void 0 : _inputNumberRef$curre.focus();
|
|
24
|
-
}, []);
|
|
25
|
-
return /*#__PURE__*/_jsx(AntInputNumber, {
|
|
26
|
-
ref: inputNumberRef,
|
|
27
|
-
controls: false,
|
|
28
|
-
className: "number-editor",
|
|
29
|
-
onMouseDown: function onMouseDown(e) {
|
|
30
|
-
return e.stopPropagation();
|
|
31
|
-
},
|
|
32
|
-
value: value,
|
|
33
|
-
addonAfter: "%",
|
|
34
|
-
onChange: onChange
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
export var getNumberEditor = function getNumberEditor(extraProps, getExtraProps) {
|
|
38
|
-
var NumberEditor = function NumberEditor(props) {
|
|
39
|
-
var value = props.value,
|
|
40
|
-
onChange = props.onChange;
|
|
41
|
-
var inputNumberRef = useRef(null);
|
|
42
|
-
useEffect(function () {
|
|
43
|
-
var _inputNumberRef$curre2;
|
|
44
|
-
inputNumberRef === null || inputNumberRef === void 0 ? void 0 : (_inputNumberRef$curre2 = inputNumberRef.current) === null || _inputNumberRef$curre2 === void 0 ? void 0 : _inputNumberRef$curre2.focus();
|
|
45
|
-
}, []);
|
|
46
|
-
var _ref = getExtraProps ? getExtraProps(props) : extraProps !== null && extraProps !== void 0 ? extraProps : {},
|
|
47
|
-
precision = _ref.precision,
|
|
48
|
-
inputArgs = _objectWithoutProperties(_ref, _excluded);
|
|
49
|
-
var valueFormatter = useCallback(function (value) {
|
|
50
|
-
if (!value) {
|
|
51
|
-
return '';
|
|
52
|
-
}
|
|
53
|
-
if (typeof value === 'string') {
|
|
54
|
-
return value;
|
|
55
|
-
}
|
|
56
|
-
var hasDecimal = value - Math.floor(value) > 0;
|
|
57
|
-
if (hasDecimal) {
|
|
58
|
-
return formatPrecision(value, precision);
|
|
59
|
-
}
|
|
60
|
-
return String(value);
|
|
61
|
-
}, []);
|
|
62
|
-
var handleChange = useCallback(function (value) {
|
|
63
|
-
onChange && onChange(value ? value : null);
|
|
64
|
-
}, [onChange]);
|
|
65
|
-
return /*#__PURE__*/_jsx(AntInputNumber, _objectSpread(_objectSpread({
|
|
66
|
-
ref: inputNumberRef
|
|
67
|
-
}, inputArgs), {}, {
|
|
68
|
-
formatter: valueFormatter,
|
|
69
|
-
controls: false,
|
|
70
|
-
className: "number-editor",
|
|
71
|
-
onMouseDown: function onMouseDown(e) {
|
|
72
|
-
return e.stopPropagation();
|
|
73
|
-
},
|
|
74
|
-
value: value,
|
|
75
|
-
onChange: handleChange
|
|
76
|
-
}));
|
|
77
|
-
};
|
|
78
|
-
NumberEditor.formatter = function (value) {
|
|
79
|
-
var _String;
|
|
80
|
-
if (isNil(value) || isNaN(value)) {
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
var result = parseFloat((_String = String(value)) === null || _String === void 0 ? void 0 : _String.replace(/,/g, ''));
|
|
84
|
-
return result;
|
|
85
|
-
};
|
|
86
|
-
NumberEditor.parser = function (value) {
|
|
87
|
-
var _String2, _extraProps$precision;
|
|
88
|
-
var result = parseFloat((_String2 = String(value)) === null || _String2 === void 0 ? void 0 : _String2.replace(/,/g, ''));
|
|
89
|
-
if (isNil(result) || isNaN(result)) {
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
return Number(formatPrecision(result, (_extraProps$precision = extraProps === null || extraProps === void 0 ? void 0 : extraProps.precision) !== null && _extraProps$precision !== void 0 ? _extraProps$precision : 0));
|
|
93
|
-
};
|
|
94
|
-
NumberEditor.checker = function (value) {
|
|
95
|
-
var _String3;
|
|
96
|
-
if (isNil(value)) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
// parse number with thousands separator
|
|
100
|
-
var result = parseFloat((_String3 = String(value)) === null || _String3 === void 0 ? void 0 : _String3.replace(/,/g, ''));
|
|
101
|
-
if (isNaN(result)) {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
};
|
|
106
|
-
return NumberEditor;
|
|
107
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
.number-editor{
|
|
2
|
-
border: none !important;
|
|
3
|
-
background: transparent !important;
|
|
4
|
-
width:100%;
|
|
5
|
-
height: 38px;
|
|
6
|
-
height: 100%;
|
|
7
|
-
font-size: 12px;
|
|
8
|
-
box-shadow: none !important;
|
|
9
|
-
text-align: inherit !important;
|
|
10
|
-
|
|
11
|
-
.ant-input-number-wrapper{
|
|
12
|
-
text-align: inherit !important;
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.ant-input-number-input{
|
|
17
|
-
text-align: inherit !important;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.ant-input-number-input-wrap >input{
|
|
21
|
-
padding:0;
|
|
22
|
-
height: 38px;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.ant-input-number-group-addon{
|
|
26
|
-
background: transparent;
|
|
27
|
-
border: none;
|
|
28
|
-
padding:0
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { SheetType } from "../../../type";
|
|
2
|
-
import { SelectProps } from 'antd';
|
|
3
|
-
import 'antd/es/select/style/index.css';
|
|
4
|
-
import './index.less';
|
|
5
|
-
export declare const getSelectEditor: (options: SheetType.Options[], valueKey?: string, extra?: React.ReactNode, selectProps?: Partial<SelectProps>, getCustomOptions?: ((props: SheetType.CellEditorProps) => SheetType.Options[]) | undefined) => SheetType.CellEditor;
|
|
6
|
-
export default getSelectEditor;
|
|
@@ -1,96 +0,0 @@
|
|
|
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); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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
|
-
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
|
-
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(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
/* eslint-disable eqeqeq */
|
|
14
|
-
|
|
15
|
-
import { Select } from 'antd';
|
|
16
|
-
import 'antd/es/select/style/index.css';
|
|
17
|
-
import { isNil } from 'lodash';
|
|
18
|
-
import { useState } from 'react';
|
|
19
|
-
import "./index.less";
|
|
20
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
21
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
22
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
23
|
-
export var getSelectEditor = function getSelectEditor(options) {
|
|
24
|
-
var valueKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
|
|
25
|
-
var extra = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : /*#__PURE__*/_jsx(_Fragment, {});
|
|
26
|
-
var selectProps = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
27
|
-
var getCustomOptions = arguments.length > 4 ? arguments[4] : undefined;
|
|
28
|
-
var SelectEditor = function SelectEditor(props) {
|
|
29
|
-
var _useState = useState(true),
|
|
30
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
31
|
-
isOpen = _useState2[0],
|
|
32
|
-
setIsOpen = _useState2[1];
|
|
33
|
-
var value = props.value,
|
|
34
|
-
onConfirm = props.onConfirm;
|
|
35
|
-
var handleChange = function handleChange(opt) {
|
|
36
|
-
var updateValue = opt === undefined ? null : opt;
|
|
37
|
-
onConfirm(updateValue);
|
|
38
|
-
};
|
|
39
|
-
var handleKeyDown = function handleKeyDown(ev) {
|
|
40
|
-
// record last key pressed so we can handle enter
|
|
41
|
-
if (ev.which === 13 || ev.which === 9) {
|
|
42
|
-
ev.persist();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
var dropdown = function dropdown(menu) {
|
|
46
|
-
return /*#__PURE__*/_jsxs("div", {
|
|
47
|
-
onClick: function onClick() {
|
|
48
|
-
setIsOpen(false);
|
|
49
|
-
},
|
|
50
|
-
children: [menu, extra]
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
var customOptions = getCustomOptions ? getCustomOptions(props) : options;
|
|
54
|
-
return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, selectProps), {}, {
|
|
55
|
-
autoFocus: true,
|
|
56
|
-
className: "select-editor",
|
|
57
|
-
allowClear: true,
|
|
58
|
-
open: isOpen,
|
|
59
|
-
onMouseDown: function onMouseDown(e) {
|
|
60
|
-
e.stopPropagation();
|
|
61
|
-
},
|
|
62
|
-
value: SelectEditor.parser ? SelectEditor.parser(value) : value,
|
|
63
|
-
onChange: handleChange,
|
|
64
|
-
onKeyDown: handleKeyDown,
|
|
65
|
-
options: customOptions,
|
|
66
|
-
popupClassName: 'excelTablePopupClassName',
|
|
67
|
-
dropdownRender: dropdown
|
|
68
|
-
}));
|
|
69
|
-
};
|
|
70
|
-
SelectEditor.checker = function (value) {
|
|
71
|
-
if (isNil(value)) return true;
|
|
72
|
-
return options.some(function (item) {
|
|
73
|
-
return item.value == value;
|
|
74
|
-
}) || options.some(function (item) {
|
|
75
|
-
return item.label === value;
|
|
76
|
-
});
|
|
77
|
-
};
|
|
78
|
-
SelectEditor.parser = function (value) {
|
|
79
|
-
var _options$find, _options$find2;
|
|
80
|
-
return ((_options$find = options.find(function (item) {
|
|
81
|
-
return item.value == value;
|
|
82
|
-
})) === null || _options$find === void 0 ? void 0 : _options$find[valueKey]) || ((_options$find2 = options.find(function (item) {
|
|
83
|
-
return item.label === value;
|
|
84
|
-
})) === null || _options$find2 === void 0 ? void 0 : _options$find2[valueKey]);
|
|
85
|
-
};
|
|
86
|
-
SelectEditor.formatter = function (value) {
|
|
87
|
-
var _options$find3, _options$find4;
|
|
88
|
-
return ((_options$find3 = options.find(function (item) {
|
|
89
|
-
return item.value == value;
|
|
90
|
-
})) === null || _options$find3 === void 0 ? void 0 : _options$find3.label) || ((_options$find4 = options.find(function (item) {
|
|
91
|
-
return item.label === value;
|
|
92
|
-
})) === null || _options$find4 === void 0 ? void 0 : _options$find4.label);
|
|
93
|
-
};
|
|
94
|
-
return SelectEditor;
|
|
95
|
-
};
|
|
96
|
-
export default getSelectEditor;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
.select-editor {
|
|
2
|
-
// select style
|
|
3
|
-
width: 100%;
|
|
4
|
-
line-height: 20px;
|
|
5
|
-
height: 20px;
|
|
6
|
-
|
|
7
|
-
.ant-select-selector {
|
|
8
|
-
width: 100%;
|
|
9
|
-
border: none !important;
|
|
10
|
-
background: transparent !important;
|
|
11
|
-
box-shadow: none !important;
|
|
12
|
-
color: #292c33;
|
|
13
|
-
height: 20px !important;
|
|
14
|
-
padding:0 !important;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ant-select-selection-item {
|
|
18
|
-
color: #292c33;
|
|
19
|
-
font-size: 12px;
|
|
20
|
-
line-height: unset !important;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
.ant-select-arrow {
|
|
24
|
-
right: 0;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
.ant-select-clear {
|
|
28
|
-
right: 0;
|
|
29
|
-
box-shadow: inset 0 -100px 0 rgba(33,133,208,15%);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.ant-select-single:not(.ant-select-customize-input) .ant-select-selector {
|
|
33
|
-
padding: 0;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.ant-select-focused:not(.ant-select-disabled).ant-select:not(.ant-select-customize-input) .ant-select-selector {
|
|
37
|
-
box-shadow: inset 0 -100px 0 rgba(33,133,208,15%);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.ant-select-item {
|
|
41
|
-
font-size: 12px !important;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SheetType } from "../../type";
|
|
2
|
-
export declare type SheetAction = 'change' | 'changes' | 'rowMove' | 'colMove' | 'editFinish' | 'pushHistory' | 'popHistory' | 'selectRow' | 'select' | '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';
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { keyboardReducer } from "./keyboardReducer";
|
|
2
|
-
import { mouseReducer } from "./mouseReducer";
|
|
3
|
-
import { stateReducer } from "./stateReducer";
|
|
4
|
-
var sheetReducer = function sheetReducer(state, action) {
|
|
5
|
-
switch (action.type) {
|
|
6
|
-
case 'change':
|
|
7
|
-
case 'changes':
|
|
8
|
-
case 'rowMove':
|
|
9
|
-
case 'colMove':
|
|
10
|
-
case 'editFinish':
|
|
11
|
-
case 'pushHistory':
|
|
12
|
-
case 'popHistory':
|
|
13
|
-
case 'selectRow':
|
|
14
|
-
case 'select':
|
|
15
|
-
case 'clearSelect':
|
|
16
|
-
case 'clearSelectIfNotSingleRow':
|
|
17
|
-
case 'clearEdit':
|
|
18
|
-
return stateReducer[action.type](state, action.payload);
|
|
19
|
-
case 'mouseDown':
|
|
20
|
-
case 'mouseOver':
|
|
21
|
-
case 'mouseUp':
|
|
22
|
-
case 'loseFocus':
|
|
23
|
-
case 'doubleClick':
|
|
24
|
-
case 'mouseLeaveInterval':
|
|
25
|
-
return mouseReducer[action.type](state, action.payload);
|
|
26
|
-
case 'move':
|
|
27
|
-
case 'escape':
|
|
28
|
-
case 'reverse':
|
|
29
|
-
case 'delete':
|
|
30
|
-
case 'enter':
|
|
31
|
-
case 'otherInput':
|
|
32
|
-
return keyboardReducer[action.type](state, action.payload);
|
|
33
|
-
default:
|
|
34
|
-
throw new Error('Unexpected action');
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
export default sheetReducer;
|
|
38
|
-
export { sideEffectReducer } from "./sideEffectReducer";
|