@zhenliang/sheet 0.1.60 → 0.1.62
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/sheet/Control.js +1 -2
- package/dist/core/sheet/index.js +8 -5
- package/dist/core/sheet/index.less +1 -3
- package/dist/core/table/addButton.js +3 -2
- package/dist/core/table/index.js +1 -0
- package/dist/example/antComponent.js +1 -0
- package/dist/example/basic.js +7 -3
- package/dist/type/sheet.d.ts +1 -0
- package/package.json +2 -2
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
|
|
@@ -41,7 +41,7 @@ export var Control = function Control(props) {
|
|
|
41
41
|
}, {
|
|
42
42
|
title: '返回编辑行',
|
|
43
43
|
disabled: startRowVisible,
|
|
44
|
-
event:
|
|
44
|
+
event: backToEditRow,
|
|
45
45
|
icon: /*#__PURE__*/_jsx(EditOutlined, {
|
|
46
46
|
style: itemStyle
|
|
47
47
|
}),
|
|
@@ -57,7 +57,6 @@ export var Control = function Control(props) {
|
|
|
57
57
|
}
|
|
58
58
|
return /*#__PURE__*/_jsx("div", {
|
|
59
59
|
className: "control",
|
|
60
|
-
onClick: backToEditRow,
|
|
61
60
|
style: backEditStyle,
|
|
62
61
|
children: btns.map(function (item) {
|
|
63
62
|
return /*#__PURE__*/_jsx("div", {
|
package/dist/core/sheet/index.js
CHANGED
|
@@ -19,14 +19,14 @@ import { Control } from "./Control";
|
|
|
19
19
|
import { DefaultRowMapper } from "./DefaultRowMapper";
|
|
20
20
|
import { Menu } from "./Menu";
|
|
21
21
|
import "./index.less";
|
|
22
|
+
import { SearchInput } from "./searchInput";
|
|
22
23
|
import { useCellEvent } from "./useCellEvent";
|
|
23
24
|
import { useContextMenu } from "./useContextMenu";
|
|
24
25
|
import { useKeyBoardEvent } from "./useKeyBoardEvent";
|
|
25
26
|
import { useMouseEvent } from "./useMouseEvent";
|
|
27
|
+
import { useSearchInput } from "./useSearchInput";
|
|
26
28
|
import { useSelectVisible } from "./useSelectVisible";
|
|
27
29
|
import { VirtualizeEnd, VirtualizeStart, useVirtualList } from "./useVirtualList";
|
|
28
|
-
import { SearchInput } from "./searchInput";
|
|
29
|
-
import { useSearchInput } from "./useSearchInput";
|
|
30
30
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
31
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
32
32
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -246,7 +246,7 @@ var Sheet = function Sheet(props) {
|
|
|
246
246
|
firstRowVisible = _useSelectVisible4[0];
|
|
247
247
|
var _useSelectVisible5 = useSelectVisible(sheetWrapperRef, {
|
|
248
248
|
col: 0,
|
|
249
|
-
row: ((
|
|
249
|
+
row: ((data === null || data === void 0 ? void 0 : data.length) || 1) - 1
|
|
250
250
|
}),
|
|
251
251
|
_useSelectVisible6 = _slicedToArray(_useSelectVisible5, 1),
|
|
252
252
|
lastRowVisible = _useSelectVisible6[0];
|
|
@@ -268,6 +268,9 @@ var Sheet = function Sheet(props) {
|
|
|
268
268
|
value: eventBus,
|
|
269
269
|
children: /*#__PURE__*/_jsxs(_Fragment, {
|
|
270
270
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
271
|
+
style: {
|
|
272
|
+
position: 'relative'
|
|
273
|
+
},
|
|
271
274
|
children: [/*#__PURE__*/_jsxs("span", {
|
|
272
275
|
ref: sheetWrapperRef,
|
|
273
276
|
tabIndex: 0,
|
|
@@ -310,8 +313,8 @@ var Sheet = function Sheet(props) {
|
|
|
310
313
|
return sheetInstance === null || sheetInstance === void 0 || (_sheetInstance$curren2 = sheetInstance.current) === null || _sheetInstance$curren2 === void 0 ? void 0 : _sheetInstance$curren2.zoomTo(0);
|
|
311
314
|
},
|
|
312
315
|
toBottom: function toBottom() {
|
|
313
|
-
var _sheetInstance$curren3,
|
|
314
|
-
return sheetInstance === null || sheetInstance === void 0 || (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 ? void 0 : _sheetInstance$curren3.zoomTo(((
|
|
316
|
+
var _sheetInstance$curren3, _data$length;
|
|
317
|
+
return sheetInstance === null || sheetInstance === void 0 || (_sheetInstance$curren3 = sheetInstance.current) === null || _sheetInstance$curren3 === void 0 ? void 0 : _sheetInstance$curren3.zoomTo(((_data$length = data === null || data === void 0 ? void 0 : data.length) !== null && _data$length !== void 0 ? _data$length : 1) - 1);
|
|
315
318
|
},
|
|
316
319
|
showQuickLocationBtn: showQuickLocationBtn,
|
|
317
320
|
ControlContainer: ControlContainer
|
|
@@ -292,11 +292,8 @@ span.harvest-sheet-container:focus {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
.harvest-sheet-control {
|
|
295
|
-
position: relative;
|
|
296
295
|
z-index: 3;
|
|
297
|
-
bottom: 0;
|
|
298
296
|
left: 0;
|
|
299
|
-
background-color: white;
|
|
300
297
|
}
|
|
301
298
|
|
|
302
299
|
.harvest-sheet-control .control {
|
|
@@ -306,6 +303,7 @@ span.harvest-sheet-container:focus {
|
|
|
306
303
|
flex-direction: row;
|
|
307
304
|
justify-content: flex-end;
|
|
308
305
|
border-radius: 2px;
|
|
306
|
+
height: 24px;
|
|
309
307
|
.control-item {
|
|
310
308
|
margin-right: 4px;
|
|
311
309
|
&:last-child {
|
|
@@ -66,9 +66,10 @@ export var AddButton = function AddButton(props) {
|
|
|
66
66
|
type: "dashed",
|
|
67
67
|
style: {
|
|
68
68
|
width: '100%',
|
|
69
|
-
height: 32
|
|
69
|
+
height: 32,
|
|
70
|
+
backgroundColor: '#fff'
|
|
70
71
|
},
|
|
71
|
-
onClick: function onClick(
|
|
72
|
+
onClick: function onClick() {
|
|
72
73
|
handleAdd && handleAdd();
|
|
73
74
|
},
|
|
74
75
|
children: ["+ \u6DFB\u52A0", _handleBatchAdd && /*#__PURE__*/_jsx(Popover, {
|
package/dist/core/table/index.js
CHANGED
|
@@ -187,6 +187,7 @@ var Table = function Table(_ref) {
|
|
|
187
187
|
sheetRenderer: WrappedTableShell,
|
|
188
188
|
data: data,
|
|
189
189
|
onCellsChanged: handleChanges,
|
|
190
|
+
handleAdd: handleAdd,
|
|
190
191
|
children: [/*#__PURE__*/_jsx(SelectionEvent, {
|
|
191
192
|
hasChildren: hasChildren,
|
|
192
193
|
rowSelection: rowSelection,
|
package/dist/example/basic.js
CHANGED
|
@@ -31,20 +31,24 @@ var columns = [{
|
|
|
31
31
|
return /*#__PURE__*/_jsx("a", {
|
|
32
32
|
children: value
|
|
33
33
|
});
|
|
34
|
-
}
|
|
34
|
+
},
|
|
35
|
+
width: 100
|
|
35
36
|
}, {
|
|
36
37
|
title: 'Age',
|
|
37
38
|
dataIndex: 'age',
|
|
38
|
-
key: 'age'
|
|
39
|
+
key: 'age',
|
|
40
|
+
width: 100
|
|
39
41
|
}, {
|
|
40
42
|
title: 'Address',
|
|
41
43
|
editable: false,
|
|
42
44
|
dataIndex: 'address',
|
|
43
|
-
key: 'address'
|
|
45
|
+
key: 'address',
|
|
46
|
+
width: 100
|
|
44
47
|
}, {
|
|
45
48
|
title: 'Tags',
|
|
46
49
|
key: 'tags',
|
|
47
50
|
dataIndex: 'tags',
|
|
51
|
+
width: 100,
|
|
48
52
|
render: function render(_ref2) {
|
|
49
53
|
var tags = _ref2.record.tags;
|
|
50
54
|
return /*#__PURE__*/_jsx(_Fragment, {
|
package/dist/type/sheet.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhenliang/sheet",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.62",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -80,4 +80,4 @@
|
|
|
80
80
|
"authors": [
|
|
81
81
|
"fizz.zhou@ap.jll.com"
|
|
82
82
|
]
|
|
83
|
-
}
|
|
83
|
+
}
|