linkmore-design 1.1.11 → 1.1.13-alpha.0
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/CHANGELOG.md +34 -0
- package/dist/Cascader/demos/formItem.d.ts +2 -0
- package/dist/LmEditTable/DndContainer.d.ts +4 -3
- package/dist/LmEditTable/EditTable.d.ts +2 -0
- package/dist/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/dist/LmEditTable/components/index.d.ts +11 -0
- package/dist/LmEditTable/sortableItem.d.ts +3 -2
- package/dist/LmEditTable/util.d.ts +2 -0
- package/dist/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/dist/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/dist/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/dist/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/dist/LmEditTable/virtual/context.d.ts +13 -0
- package/dist/LmEditTable/virtual/index.d.ts +4 -0
- package/dist/Select/demos/formItem.d.ts +2 -0
- package/dist/Select/index.d.ts +1 -0
- package/dist/TreeSelect/demos/formItem.d.ts +2 -0
- package/dist/TreeSelect/index.d.ts +8 -3
- package/dist/index.umd.js +629 -226
- package/dist/index.umd.min.js +5 -5
- package/dist/variables.css +47 -0
- package/es/IconFont/index.js +1 -1
- package/es/LmEditTable/DndContainer.d.ts +4 -3
- package/es/LmEditTable/DndContainer.js +2 -2
- package/es/LmEditTable/EditTable.d.ts +2 -0
- package/es/LmEditTable/EditTable.js +200 -158
- package/es/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/es/LmEditTable/components/DraggableContainer.js +32 -0
- package/es/LmEditTable/components/index.d.ts +11 -0
- package/es/LmEditTable/components/index.js +5 -0
- package/es/LmEditTable/sortableItem.d.ts +3 -2
- package/es/LmEditTable/sortableItem.js +15 -4
- package/es/LmEditTable/style/index.css +47 -0
- package/es/LmEditTable/style/variables.css +47 -0
- package/es/LmEditTable/util.d.ts +2 -0
- package/es/LmEditTable/util.js +37 -1
- package/es/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/es/LmEditTable/virtual/VirtualRow.js +60 -0
- package/es/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/es/LmEditTable/virtual/VirtualRowBack.js +102 -0
- package/es/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/es/LmEditTable/virtual/VirtualTable.js +54 -0
- package/es/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/es/LmEditTable/virtual/VirtualWrapper.js +60 -0
- package/es/LmEditTable/virtual/context.d.ts +13 -0
- package/es/LmEditTable/virtual/context.js +54 -0
- package/es/LmEditTable/virtual/index.d.ts +4 -0
- package/es/LmEditTable/virtual/index.js +4 -0
- package/es/Select/index.d.ts +1 -0
- package/es/Select/index.js +38 -4
- package/es/TreeSelect/index.d.ts +8 -3
- package/es/TreeSelect/index.js +74 -1
- package/es/hooks/useEvent/index.js +1 -1
- package/es/styles/variables.css +47 -0
- package/lib/IconFont/index.js +1 -1
- package/lib/LmEditTable/DndContainer.d.ts +4 -3
- package/lib/LmEditTable/DndContainer.js +4 -3
- package/lib/LmEditTable/EditTable.d.ts +2 -0
- package/lib/LmEditTable/EditTable.js +195 -153
- package/lib/LmEditTable/components/DraggableContainer.d.ts +7 -0
- package/lib/LmEditTable/components/DraggableContainer.js +45 -0
- package/lib/LmEditTable/components/index.d.ts +11 -0
- package/lib/LmEditTable/components/index.js +21 -0
- package/lib/LmEditTable/sortableItem.d.ts +3 -2
- package/lib/LmEditTable/sortableItem.js +18 -5
- package/lib/LmEditTable/style/index.css +47 -0
- package/lib/LmEditTable/style/variables.css +47 -0
- package/lib/LmEditTable/util.d.ts +2 -0
- package/lib/LmEditTable/util.js +40 -0
- package/lib/LmEditTable/virtual/VirtualRow.d.ts +6 -0
- package/lib/LmEditTable/virtual/VirtualRow.js +73 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.js +115 -0
- package/lib/LmEditTable/virtual/VirtualTable.d.ts +3 -0
- package/lib/LmEditTable/virtual/VirtualTable.js +71 -0
- package/lib/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
- package/lib/LmEditTable/virtual/VirtualWrapper.js +73 -0
- package/lib/LmEditTable/virtual/context.d.ts +13 -0
- package/lib/LmEditTable/virtual/context.js +64 -0
- package/lib/LmEditTable/virtual/index.d.ts +4 -0
- package/lib/LmEditTable/virtual/index.js +31 -0
- package/lib/Select/index.d.ts +1 -0
- package/lib/Select/index.js +37 -3
- package/lib/TreeSelect/index.d.ts +8 -3
- package/lib/TreeSelect/index.js +78 -1
- package/lib/hooks/useEvent/index.js +1 -1
- package/lib/styles/variables.css +47 -0
- package/package.json +1 -1
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.default = void 0;
|
|
9
9
|
|
|
10
|
-
var _react =
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
|
12
12
|
var _sortable = require("@dnd-kit/sortable");
|
|
13
13
|
|
|
14
14
|
var _utilities = require("@dnd-kit/utilities");
|
|
15
15
|
|
|
16
|
+
var _virtual = require("./virtual");
|
|
17
|
+
|
|
16
18
|
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
17
19
|
var t = {};
|
|
18
20
|
|
|
@@ -30,7 +32,8 @@ var SortableItem = function SortableItem(props) {
|
|
|
30
32
|
var key = props['data-row-key'],
|
|
31
33
|
children = props.children,
|
|
32
34
|
className = props.className,
|
|
33
|
-
|
|
35
|
+
virtual = props.virtual,
|
|
36
|
+
resetField = __rest(props, ['data-row-key', "children", "className", "virtual"]);
|
|
34
37
|
|
|
35
38
|
var _useSortable = (0, _sortable.useSortable)({
|
|
36
39
|
id: key
|
|
@@ -44,12 +47,22 @@ var SortableItem = function SortableItem(props) {
|
|
|
44
47
|
transform: _utilities.CSS.Transform.toString(transform),
|
|
45
48
|
transition: transition
|
|
46
49
|
};
|
|
47
|
-
|
|
50
|
+
|
|
51
|
+
if (!virtual) {
|
|
52
|
+
return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetField, {
|
|
53
|
+
ref: setNodeRef,
|
|
54
|
+
key: key,
|
|
55
|
+
style: style
|
|
56
|
+
}, attributes), children);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_virtual.VirtualRow, Object.assign({}, resetField, {
|
|
48
60
|
ref: setNodeRef,
|
|
49
61
|
key: key,
|
|
50
62
|
style: style
|
|
51
63
|
}, attributes), children);
|
|
52
64
|
};
|
|
53
65
|
|
|
54
|
-
var _default = SortableItem;
|
|
66
|
+
var _default = /*#__PURE__*/(0, _react.memo)(SortableItem);
|
|
67
|
+
|
|
55
68
|
exports.default = _default;
|
|
@@ -549,6 +549,9 @@ p {
|
|
|
549
549
|
letter-spacing: 0px;
|
|
550
550
|
color: var(--color-85);
|
|
551
551
|
}
|
|
552
|
+
.lm_editTable_warpper .lm_custom_cell_td {
|
|
553
|
+
position: relative;
|
|
554
|
+
}
|
|
552
555
|
.lm_editTable_warpper .lm_custom_cell_td .ant-form-item-control-input-content {
|
|
553
556
|
display: flex;
|
|
554
557
|
flex-direction: row;
|
|
@@ -560,6 +563,32 @@ p {
|
|
|
560
563
|
.lm_editTable_warpper .lm_custom_cell_td .ant-table-row-expand-icon {
|
|
561
564
|
margin-top: 6px;
|
|
562
565
|
}
|
|
566
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp {
|
|
567
|
+
font-size: 8px;
|
|
568
|
+
position: absolute;
|
|
569
|
+
left: calc(50% - 10px);
|
|
570
|
+
z-index: 100;
|
|
571
|
+
width: 20px;
|
|
572
|
+
height: 10px;
|
|
573
|
+
background-color: var(--color-6);
|
|
574
|
+
display: flex;
|
|
575
|
+
align-items: center;
|
|
576
|
+
justify-content: center;
|
|
577
|
+
color: #D8D8D8;
|
|
578
|
+
}
|
|
579
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp:hover {
|
|
580
|
+
cursor: pointer;
|
|
581
|
+
background-color: var(--primary-color);
|
|
582
|
+
color: #fff;
|
|
583
|
+
}
|
|
584
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_up {
|
|
585
|
+
top: -4px;
|
|
586
|
+
left: calc(50% - 10px);
|
|
587
|
+
}
|
|
588
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_down {
|
|
589
|
+
bottom: -6px;
|
|
590
|
+
left: calc(50% - 10px);
|
|
591
|
+
}
|
|
563
592
|
.lm_editTable_warpper .lm_editTable_cell_edit {
|
|
564
593
|
height: 40px;
|
|
565
594
|
padding: 8px 8px !important;
|
|
@@ -609,3 +638,21 @@ p {
|
|
|
609
638
|
color: var(--color-85);
|
|
610
639
|
margin-left: 0 !important;
|
|
611
640
|
}
|
|
641
|
+
.lm_table_append_add_popover .ant-popover-inner-content {
|
|
642
|
+
padding: 0px;
|
|
643
|
+
}
|
|
644
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul {
|
|
645
|
+
margin: 0;
|
|
646
|
+
}
|
|
647
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul li {
|
|
648
|
+
font-size: 12px;
|
|
649
|
+
padding: 4px 8px;
|
|
650
|
+
height: 24px;
|
|
651
|
+
display: flex;
|
|
652
|
+
align-items: center;
|
|
653
|
+
justify-content: center;
|
|
654
|
+
cursor: pointer;
|
|
655
|
+
}
|
|
656
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul li:hover {
|
|
657
|
+
background-color: var(--color-15);
|
|
658
|
+
}
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
letter-spacing: 0px;
|
|
38
38
|
color: var(--color-85);
|
|
39
39
|
}
|
|
40
|
+
.lm_editTable_warpper .lm_custom_cell_td {
|
|
41
|
+
position: relative;
|
|
42
|
+
}
|
|
40
43
|
.lm_editTable_warpper .lm_custom_cell_td .ant-form-item-control-input-content {
|
|
41
44
|
display: flex;
|
|
42
45
|
flex-direction: row;
|
|
@@ -48,6 +51,32 @@
|
|
|
48
51
|
.lm_editTable_warpper .lm_custom_cell_td .ant-table-row-expand-icon {
|
|
49
52
|
margin-top: 6px;
|
|
50
53
|
}
|
|
54
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp {
|
|
55
|
+
font-size: 8px;
|
|
56
|
+
position: absolute;
|
|
57
|
+
left: calc(50% - 10px);
|
|
58
|
+
z-index: 100;
|
|
59
|
+
width: 20px;
|
|
60
|
+
height: 10px;
|
|
61
|
+
background-color: var(--color-6);
|
|
62
|
+
display: flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
justify-content: center;
|
|
65
|
+
color: #D8D8D8;
|
|
66
|
+
}
|
|
67
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp:hover {
|
|
68
|
+
cursor: pointer;
|
|
69
|
+
background-color: var(--primary-color);
|
|
70
|
+
color: #fff;
|
|
71
|
+
}
|
|
72
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_up {
|
|
73
|
+
top: -4px;
|
|
74
|
+
left: calc(50% - 10px);
|
|
75
|
+
}
|
|
76
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_down {
|
|
77
|
+
bottom: -6px;
|
|
78
|
+
left: calc(50% - 10px);
|
|
79
|
+
}
|
|
51
80
|
.lm_editTable_warpper .lm_editTable_cell_edit {
|
|
52
81
|
height: 40px;
|
|
53
82
|
padding: 8px 8px !important;
|
|
@@ -97,3 +126,21 @@
|
|
|
97
126
|
color: var(--color-85);
|
|
98
127
|
margin-left: 0 !important;
|
|
99
128
|
}
|
|
129
|
+
.lm_table_append_add_popover .ant-popover-inner-content {
|
|
130
|
+
padding: 0px;
|
|
131
|
+
}
|
|
132
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul {
|
|
133
|
+
margin: 0;
|
|
134
|
+
}
|
|
135
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul li {
|
|
136
|
+
font-size: 12px;
|
|
137
|
+
padding: 4px 8px;
|
|
138
|
+
height: 24px;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
cursor: pointer;
|
|
143
|
+
}
|
|
144
|
+
.lm_table_append_add_popover .ant-popover-inner-content ul li:hover {
|
|
145
|
+
background-color: var(--color-15);
|
|
146
|
+
}
|
|
@@ -2,6 +2,8 @@ export declare function isObjEmpty(obj: Record<string, any>): boolean;
|
|
|
2
2
|
export declare function deepDataSourcePreKeys(dataSource: any[], rowKey: string): any;
|
|
3
3
|
export declare function isExpandRow(children: any): boolean;
|
|
4
4
|
export declare function checkRowKeyByDataSource(dataSource: any, rowKey: any): any;
|
|
5
|
+
export declare function getExpandStatus(children: any): any;
|
|
6
|
+
export declare function checkMemoShouldUploadSpecialFun(prev: any, next: any): any;
|
|
5
7
|
declare const _default: {
|
|
6
8
|
isObjEmpty: typeof isObjEmpty;
|
|
7
9
|
};
|
package/lib/LmEditTable/util.js
CHANGED
|
@@ -5,9 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
exports.checkMemoShouldUploadSpecialFun = checkMemoShouldUploadSpecialFun;
|
|
8
9
|
exports.checkRowKeyByDataSource = checkRowKeyByDataSource;
|
|
9
10
|
exports.deepDataSourcePreKeys = deepDataSourcePreKeys;
|
|
10
11
|
exports.default = void 0;
|
|
12
|
+
exports.getExpandStatus = getExpandStatus;
|
|
11
13
|
exports.isExpandRow = isExpandRow;
|
|
12
14
|
exports.isObjEmpty = isObjEmpty;
|
|
13
15
|
|
|
@@ -75,6 +77,44 @@ function checkRowKeyByDataSource(dataSource, rowKey) {
|
|
|
75
77
|
return res;
|
|
76
78
|
}
|
|
77
79
|
|
|
80
|
+
function getExpandStatus(children) {
|
|
81
|
+
var _a, _b, _c, _d, _e;
|
|
82
|
+
|
|
83
|
+
return isExpandRow(children) ? (_e = (_d = (_c = (_b = (_a = children === null || children === void 0 ? void 0 : children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.children) === null || _c === void 0 ? void 0 : _c[1]) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e['aria-label'] : '';
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
87
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
88
|
+
|
|
89
|
+
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
90
|
+
|
|
91
|
+
if (!checkExpandStatus) {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
var prevCol = prev === null || prev === void 0 ? void 0 : prev.col;
|
|
96
|
+
var nextCol = next === null || next === void 0 ? void 0 : next.col;
|
|
97
|
+
|
|
98
|
+
if (((_a = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _a === void 0 ? void 0 : _a.optionOnly) || ((_b = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _b === void 0 ? void 0 : _b.optionOnly)) {
|
|
99
|
+
return (0, _lodash.isEqual)((_c = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _c === void 0 ? void 0 : _c.options, (_d = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _d === void 0 ? void 0 : _d.options);
|
|
100
|
+
}
|
|
101
|
+
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
if (((_e = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _e === void 0 ? void 0 : _e.quickcopy) || ((_f = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _f === void 0 ? void 0 : _f.quickcopy)) {
|
|
105
|
+
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
106
|
+
var p = (0, _lodash.pick)(prev, pickProps);
|
|
107
|
+
var n = (0, _lodash.pick)(next, pickProps);
|
|
108
|
+
return (0, _lodash.isEqual)(p, n);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
112
|
+
return (0, _lodash.isEqual)((_h = (_g = prev.children) === null || _g === void 0 ? void 0 : _g[1]) === null || _h === void 0 ? void 0 : _h.props, (_k = (_j = next.children) === null || _j === void 0 ? void 0 : _j[1]) === null || _k === void 0 ? void 0 : _k.props);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
|
|
78
118
|
var _default = {
|
|
79
119
|
isObjEmpty: isObjEmpty
|
|
80
120
|
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
|
|
14
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
|
|
17
|
+
for (var p in s) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
|
|
28
|
+
var children = _a.children,
|
|
29
|
+
resetProps = __rest(_a, ["children"]);
|
|
30
|
+
|
|
31
|
+
var _useStore = (0, _context.useStore)(),
|
|
32
|
+
state = _useStore.state,
|
|
33
|
+
dispatch = _useStore.dispatch;
|
|
34
|
+
|
|
35
|
+
var rowHeight = state.rowHeight,
|
|
36
|
+
totalLen = state.totalLen;
|
|
37
|
+
var trRef = (0, _react.useRef)(null); // 列长度
|
|
38
|
+
|
|
39
|
+
var columnsLen = (0, _react.useMemo)(function () {
|
|
40
|
+
var _a;
|
|
41
|
+
|
|
42
|
+
return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
|
|
43
|
+
}, [children]);
|
|
44
|
+
(0, _react.useEffect)(function () {
|
|
45
|
+
if (state.columnsLen !== columnsLen) {
|
|
46
|
+
dispatch({
|
|
47
|
+
type: 'changeColumnsLen',
|
|
48
|
+
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}, [columnsLen, dispatch, state.columnsLen]);
|
|
52
|
+
(0, _react.useEffect)(function () {
|
|
53
|
+
var initHeight = function initHeight(tempRef) {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
|
|
56
|
+
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
57
|
+
var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
|
|
58
|
+
dispatch({
|
|
59
|
+
type: 'initHeight',
|
|
60
|
+
rowHeight: tempRowHeight
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
|
|
66
|
+
}, [trRef, dispatch, rowHeight, totalLen, ref]);
|
|
67
|
+
return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
|
|
68
|
+
ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
|
|
69
|
+
}), children);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _default = VirtualRow;
|
|
73
|
+
exports.default = _default;
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
|
|
14
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
|
|
17
|
+
for (var p in s) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
|
|
28
|
+
var children = _a.children,
|
|
29
|
+
resetProps = __rest(_a, ["children"]);
|
|
30
|
+
|
|
31
|
+
var _useStore = (0, _context.useStore)(),
|
|
32
|
+
state = _useStore.state,
|
|
33
|
+
dispatch = _useStore.dispatch,
|
|
34
|
+
instance = _useStore.instance;
|
|
35
|
+
|
|
36
|
+
var rowHeight = state.rowHeight,
|
|
37
|
+
totalLen = state.totalLen;
|
|
38
|
+
var virtualItems = instance.columnVirtual.virtualItems;
|
|
39
|
+
var trRef = (0, _react.useRef)(null); // 列长度
|
|
40
|
+
|
|
41
|
+
var columnsLen = (0, _react.useMemo)(function () {
|
|
42
|
+
var _a;
|
|
43
|
+
|
|
44
|
+
return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
|
|
45
|
+
}, [children]);
|
|
46
|
+
(0, _react.useEffect)(function () {
|
|
47
|
+
if (state.columnsLen !== columnsLen) {
|
|
48
|
+
dispatch({
|
|
49
|
+
type: 'changeColumnsLen',
|
|
50
|
+
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [columnsLen, dispatch, state.columnsLen]);
|
|
54
|
+
(0, _react.useEffect)(function () {
|
|
55
|
+
var initHeight = function initHeight(tempRef) {
|
|
56
|
+
var _a, _b, _c;
|
|
57
|
+
|
|
58
|
+
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
59
|
+
var tempRowHeight = (_c = (_b = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _b === void 0 ? void 0 : _b.offsetHeight) !== null && _c !== void 0 ? _c : 0;
|
|
60
|
+
dispatch({
|
|
61
|
+
type: 'initHeight',
|
|
62
|
+
rowHeight: tempRowHeight
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
|
|
68
|
+
}, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
|
|
69
|
+
|
|
70
|
+
var fixedColumns = (0, _react.useMemo)(function () {
|
|
71
|
+
return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
|
|
74
|
+
if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
|
|
75
|
+
pre.fixedLeft.push(cur);
|
|
76
|
+
return pre;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
|
|
80
|
+
pre.fixedRight.push(cur);
|
|
81
|
+
return pre;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
pre.columns.push(cur);
|
|
85
|
+
return pre;
|
|
86
|
+
}, {
|
|
87
|
+
fixedLeft: [],
|
|
88
|
+
fixedRight: [],
|
|
89
|
+
columns: []
|
|
90
|
+
});
|
|
91
|
+
}, [children]); // 截取非固定列
|
|
92
|
+
|
|
93
|
+
var resetVirtualItems = (0, _react.useMemo)(function () {
|
|
94
|
+
var fixedLeft = fixedColumns.fixedLeft,
|
|
95
|
+
columns = fixedColumns.columns;
|
|
96
|
+
return virtualItems.slice(fixedLeft.length, fixedLeft.length + columns.length);
|
|
97
|
+
}, [fixedColumns, virtualItems]); // 横向单元格合并
|
|
98
|
+
|
|
99
|
+
var colSpan = (0, _react.useMemo)(function () {
|
|
100
|
+
var _a;
|
|
101
|
+
|
|
102
|
+
var startIndex = ((_a = resetVirtualItems === null || resetVirtualItems === void 0 ? void 0 : resetVirtualItems[0]) === null || _a === void 0 ? void 0 : _a.index) || 0;
|
|
103
|
+
return startIndex ? startIndex - fixedColumns.fixedLeft.length : startIndex;
|
|
104
|
+
}, [fixedColumns, resetVirtualItems]);
|
|
105
|
+
return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
|
|
106
|
+
ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
|
|
107
|
+
}), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/_react.default.createElement("td", {
|
|
108
|
+
colSpan: colSpan
|
|
109
|
+
}), resetVirtualItems.map(function (virtualCol) {
|
|
110
|
+
return children[virtualCol.index];
|
|
111
|
+
}), fixedColumns.fixedRight);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
var _default = VirtualRow;
|
|
115
|
+
exports.default = _default;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
|
|
12
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
+
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
15
|
+
|
|
16
|
+
var _reactVirtual = require("react-virtual");
|
|
17
|
+
|
|
18
|
+
var _context = require("./context");
|
|
19
|
+
|
|
20
|
+
var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
|
|
21
|
+
var _a, _b, _c, _d;
|
|
22
|
+
|
|
23
|
+
var bodyRef = (0, _react.useRef)(null);
|
|
24
|
+
|
|
25
|
+
var _useRealive = (0, _context.useRealive)(),
|
|
26
|
+
_useRealive2 = (0, _slicedToArray2.default)(_useRealive, 2),
|
|
27
|
+
state = _useRealive2[0],
|
|
28
|
+
dispatch = _useRealive2[1]; // { totalSize, virtualItems }
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
var rowVirtual = (0, _reactVirtual.useVirtual)({
|
|
32
|
+
size: state.totalLen,
|
|
33
|
+
// 绑定父节点
|
|
34
|
+
parentRef: {
|
|
35
|
+
current: (_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _a === void 0 ? void 0 : _a.parentNode
|
|
36
|
+
},
|
|
37
|
+
estimateSize: _react.default.useCallback(function () {
|
|
38
|
+
return state.rowHeight;
|
|
39
|
+
}, [state.rowHeight]),
|
|
40
|
+
overscan: 5
|
|
41
|
+
});
|
|
42
|
+
var columnVirtual = (0, _reactVirtual.useVirtual)({
|
|
43
|
+
horizontal: true,
|
|
44
|
+
size: state.columnsLen,
|
|
45
|
+
parentRef: {
|
|
46
|
+
current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
|
|
47
|
+
},
|
|
48
|
+
estimateSize: _react.default.useCallback(function (i) {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
|
|
51
|
+
return (_b = (_a = tableProps === null || tableProps === void 0 ? void 0 : tableProps.children[0]) === null || _a === void 0 ? void 0 : _a.props) === null || _b === void 0 ? void 0 : _b.colWidths[i];
|
|
52
|
+
}, [(_d = (_c = tableProps.children[0]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.colWidths]),
|
|
53
|
+
overscan: 5
|
|
54
|
+
});
|
|
55
|
+
var instance = {
|
|
56
|
+
rowVirtual: rowVirtual,
|
|
57
|
+
columnVirtual: columnVirtual
|
|
58
|
+
};
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement(_context.TableContext.Provider, {
|
|
60
|
+
value: {
|
|
61
|
+
state: state,
|
|
62
|
+
dispatch: dispatch,
|
|
63
|
+
instance: instance
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/_react.default.createElement("table", Object.assign({
|
|
66
|
+
ref: bodyRef
|
|
67
|
+
}, tableProps)));
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
var _default = VirtualTable;
|
|
71
|
+
exports.default = _default;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _context = require("./context");
|
|
13
|
+
|
|
14
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
15
|
+
var t = {};
|
|
16
|
+
|
|
17
|
+
for (var p in s) {
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
var VirtualWrapper = /*#__PURE__*/_react.default.memo(function (wrapperProps) {
|
|
28
|
+
var _a, _b;
|
|
29
|
+
|
|
30
|
+
var children = wrapperProps.children,
|
|
31
|
+
resetProps = __rest(wrapperProps, ["children"]);
|
|
32
|
+
|
|
33
|
+
var _useStore = (0, _context.useStore)(),
|
|
34
|
+
state = _useStore.state,
|
|
35
|
+
dispatch = _useStore.dispatch,
|
|
36
|
+
instance = _useStore.instance;
|
|
37
|
+
|
|
38
|
+
var _instance$rowVirtual = instance.rowVirtual,
|
|
39
|
+
virtualItems = _instance$rowVirtual.virtualItems,
|
|
40
|
+
totalSize = _instance$rowVirtual.totalSize;
|
|
41
|
+
var contents = (0, _react.useMemo)(function () {
|
|
42
|
+
return children[1];
|
|
43
|
+
}, [children]);
|
|
44
|
+
var contentsLen = (0, _react.useMemo)(function () {
|
|
45
|
+
var _a;
|
|
46
|
+
|
|
47
|
+
return (_a = contents === null || contents === void 0 ? void 0 : contents.length) !== null && _a !== void 0 ? _a : 0;
|
|
48
|
+
}, [contents]);
|
|
49
|
+
(0, _react.useEffect)(function () {
|
|
50
|
+
if (state.totalLen !== contentsLen) {
|
|
51
|
+
dispatch({
|
|
52
|
+
type: 'changeTotalLen',
|
|
53
|
+
totalLen: contentsLen !== null && contentsLen !== void 0 ? contentsLen : 0
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}, [contentsLen, dispatch, state.totalLen]);
|
|
57
|
+
var paddingTop = virtualItems.length > 0 ? ((_a = virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems[0]) === null || _a === void 0 ? void 0 : _a.start) || 0 : 0;
|
|
58
|
+
var paddingBottom = virtualItems.length > 0 ? totalSize - (((_b = virtualItems === null || virtualItems === void 0 ? void 0 : virtualItems[virtualItems.length - 1]) === null || _b === void 0 ? void 0 : _b.end) || 0) : 0;
|
|
59
|
+
return /*#__PURE__*/_react.default.createElement("tbody", Object.assign({}, resetProps), paddingTop > 0 && /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
|
|
60
|
+
style: {
|
|
61
|
+
height: "".concat(paddingTop, "px")
|
|
62
|
+
}
|
|
63
|
+
})), children[0], virtualItems.map(function (virtualRow) {
|
|
64
|
+
return contents[virtualRow.index];
|
|
65
|
+
}), paddingBottom > 0 && /*#__PURE__*/_react.default.createElement("tr", null, /*#__PURE__*/_react.default.createElement("td", {
|
|
66
|
+
style: {
|
|
67
|
+
height: "".concat(paddingBottom, "px")
|
|
68
|
+
}
|
|
69
|
+
})));
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
var _default = VirtualWrapper;
|
|
73
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const TableContext: import("react").Context<{
|
|
3
|
+
state: any;
|
|
4
|
+
dispatch: any;
|
|
5
|
+
instance: any;
|
|
6
|
+
}>;
|
|
7
|
+
declare const useStore: () => {
|
|
8
|
+
state: any;
|
|
9
|
+
dispatch: any;
|
|
10
|
+
instance: any;
|
|
11
|
+
};
|
|
12
|
+
declare const useRealive: () => [any, import("react").Dispatch<any>];
|
|
13
|
+
export { TableContext, useStore, useRealive };
|