linkmore-design 1.1.12 → 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/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/index.umd.js +471 -217
- package/dist/index.umd.min.js +5 -5
- package/dist/variables.css +29 -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 +139 -150
- 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 +29 -0
- package/es/LmEditTable/style/variables.css +29 -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/hooks/useEvent/index.js +1 -1
- package/es/styles/variables.css +29 -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 +135 -146
- 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 +29 -0
- package/lib/LmEditTable/style/variables.css +29 -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/hooks/useEvent/index.js +1 -1
- package/lib/styles/variables.css +29 -0
- package/package.json +1 -1
|
@@ -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;
|
|
@@ -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 };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useStore = exports.useRealive = exports.TableContext = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
|
|
10
|
+
// =============== context ============== //
|
|
11
|
+
var TableContext = /*#__PURE__*/(0, _react.createContext)({
|
|
12
|
+
state: null,
|
|
13
|
+
dispatch: null,
|
|
14
|
+
instance: {}
|
|
15
|
+
});
|
|
16
|
+
exports.TableContext = TableContext;
|
|
17
|
+
|
|
18
|
+
var useStore = function useStore() {
|
|
19
|
+
return (0, _react.useContext)(TableContext);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.useStore = useStore;
|
|
23
|
+
var initialState = {
|
|
24
|
+
// 行高度
|
|
25
|
+
rowHeight: 0,
|
|
26
|
+
columnsLen: 0,
|
|
27
|
+
// 总行数
|
|
28
|
+
totalLen: 0
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
var reducer = function reducer(state, action) {
|
|
32
|
+
var totalLen = action.totalLen,
|
|
33
|
+
columnsLen = action.columnsLen,
|
|
34
|
+
rowHeight = action.rowHeight;
|
|
35
|
+
|
|
36
|
+
switch (action.type) {
|
|
37
|
+
// 数据数量
|
|
38
|
+
case 'changeTotalLen':
|
|
39
|
+
return Object.assign(Object.assign({}, state), {
|
|
40
|
+
totalLen: totalLen
|
|
41
|
+
});
|
|
42
|
+
// 列数量
|
|
43
|
+
|
|
44
|
+
case 'changeColumnsLen':
|
|
45
|
+
return Object.assign(Object.assign({}, state), {
|
|
46
|
+
columnsLen: columnsLen
|
|
47
|
+
});
|
|
48
|
+
// 初始化行高度
|
|
49
|
+
|
|
50
|
+
case 'initHeight':
|
|
51
|
+
return Object.assign(Object.assign({}, state), {
|
|
52
|
+
rowHeight: rowHeight
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
default:
|
|
56
|
+
throw new Error();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var useRealive = function useRealive() {
|
|
61
|
+
return (0, _react.useReducer)(reducer, initialState);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.useRealive = useRealive;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "VirtualRow", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _VirtualRow.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "VirtualTable", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _VirtualTable.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "VirtualWrapper", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _VirtualWrapper.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
var _VirtualTable = _interopRequireDefault(require("./VirtualTable"));
|
|
28
|
+
|
|
29
|
+
var _VirtualWrapper = _interopRequireDefault(require("./VirtualWrapper"));
|
|
30
|
+
|
|
31
|
+
var _VirtualRow = _interopRequireDefault(require("./VirtualRow"));
|
package/lib/styles/variables.css
CHANGED
|
@@ -9742,6 +9742,9 @@ p {
|
|
|
9742
9742
|
letter-spacing: 0px;
|
|
9743
9743
|
color: var(--color-85);
|
|
9744
9744
|
}
|
|
9745
|
+
.lm_editTable_warpper .lm_custom_cell_td {
|
|
9746
|
+
position: relative;
|
|
9747
|
+
}
|
|
9745
9748
|
.lm_editTable_warpper .lm_custom_cell_td .ant-form-item-control-input-content {
|
|
9746
9749
|
display: flex;
|
|
9747
9750
|
flex-direction: row;
|
|
@@ -9753,6 +9756,32 @@ p {
|
|
|
9753
9756
|
.lm_editTable_warpper .lm_custom_cell_td .ant-table-row-expand-icon {
|
|
9754
9757
|
margin-top: 6px;
|
|
9755
9758
|
}
|
|
9759
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp {
|
|
9760
|
+
font-size: 8px;
|
|
9761
|
+
position: absolute;
|
|
9762
|
+
left: calc(50% - 10px);
|
|
9763
|
+
z-index: 100;
|
|
9764
|
+
width: 20px;
|
|
9765
|
+
height: 10px;
|
|
9766
|
+
background-color: var(--color-6);
|
|
9767
|
+
display: flex;
|
|
9768
|
+
align-items: center;
|
|
9769
|
+
justify-content: center;
|
|
9770
|
+
color: #D8D8D8;
|
|
9771
|
+
}
|
|
9772
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_warp:hover {
|
|
9773
|
+
cursor: pointer;
|
|
9774
|
+
background-color: var(--primary-color);
|
|
9775
|
+
color: #fff;
|
|
9776
|
+
}
|
|
9777
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_up {
|
|
9778
|
+
top: -4px;
|
|
9779
|
+
left: calc(50% - 10px);
|
|
9780
|
+
}
|
|
9781
|
+
.lm_editTable_warpper .lm_custom_cell_td .quick_copy_down {
|
|
9782
|
+
bottom: -6px;
|
|
9783
|
+
left: calc(50% - 10px);
|
|
9784
|
+
}
|
|
9756
9785
|
.lm_editTable_warpper .lm_editTable_cell_edit {
|
|
9757
9786
|
height: 40px;
|
|
9758
9787
|
padding: 8px 8px !important;
|