linkmore-design 1.1.25 → 1.1.27-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/dist/LmEditTable/DndContainer.d.ts +6 -3
- package/dist/LmEditTable/EditTable.d.ts +10 -5
- package/dist/LmEditTable/components/DraggableContainer.d.ts +10 -0
- package/dist/LmEditTable/components/QuickOpetate.d.ts +12 -0
- package/dist/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
- package/dist/LmEditTable/components/index.d.ts +16 -0
- package/dist/LmEditTable/hooks/useForkRef.d.ts +2 -0
- package/dist/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
- package/dist/LmEditTable/sortableItem.d.ts +3 -2
- package/dist/LmEditTable/util.d.ts +7 -0
- package/dist/LmEditTable/virtual/VirtualRow.d.ts +7 -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.d.ts +1 -2
- package/dist/index.umd.js +1173 -537
- package/dist/index.umd.min.js +8 -8
- package/dist/variables.css +65 -0
- package/es/Input/index.js +27 -2
- package/es/InputNumber/index.js +7 -9
- package/es/LmEditTable/DndContainer.d.ts +6 -3
- package/es/LmEditTable/DndContainer.js +70 -10
- package/es/LmEditTable/DragHandle.js +1 -1
- package/es/LmEditTable/EditTable.d.ts +10 -5
- package/es/LmEditTable/EditTable.js +352 -360
- package/es/LmEditTable/components/DraggableContainer.d.ts +10 -0
- package/es/LmEditTable/components/DraggableContainer.js +39 -0
- package/es/LmEditTable/components/QuickOpetate.d.ts +12 -0
- package/es/LmEditTable/components/QuickOpetate.js +82 -0
- package/es/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
- package/es/LmEditTable/components/bottomOpetateComponent.js +23 -0
- package/es/LmEditTable/components/index.d.ts +16 -0
- package/es/LmEditTable/components/index.js +7 -0
- package/es/LmEditTable/hooks/useForkRef.d.ts +2 -0
- package/es/LmEditTable/hooks/useForkRef.js +22 -0
- package/es/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
- package/es/LmEditTable/rowSort/DndContainerRow.js +81 -0
- package/es/LmEditTable/sortableItem.d.ts +3 -2
- package/es/LmEditTable/sortableItem.js +16 -4
- package/es/LmEditTable/sortableItemCol.js +40 -10
- package/es/LmEditTable/style/index.css +65 -0
- package/es/LmEditTable/style/variables.css +65 -0
- package/es/LmEditTable/util.d.ts +7 -0
- package/es/LmEditTable/util.js +92 -7
- package/es/LmEditTable/virtual/VirtualRow.d.ts +7 -0
- package/es/LmEditTable/virtual/VirtualRow.js +62 -0
- package/es/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/es/LmEditTable/virtual/VirtualRowBack.js +100 -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/LmFilter/filterFns/index.js +7 -2
- package/es/LmTable/virTual/VirtualRow.js +12 -14
- package/es/LmUpload/LmUpload.js +4 -2
- package/es/hooks/useEvent/index.js +1 -1
- package/es/index.d.ts +1 -2
- package/es/styles/variables.css +65 -0
- package/lib/Input/index.js +29 -2
- package/lib/InputNumber/index.js +9 -9
- package/lib/LmEditTable/DndContainer.d.ts +6 -3
- package/lib/LmEditTable/DndContainer.js +74 -9
- package/lib/LmEditTable/DragHandle.js +1 -1
- package/lib/LmEditTable/EditTable.d.ts +10 -5
- package/lib/LmEditTable/EditTable.js +349 -357
- package/lib/LmEditTable/components/DraggableContainer.d.ts +10 -0
- package/lib/LmEditTable/components/DraggableContainer.js +52 -0
- package/lib/LmEditTable/components/QuickOpetate.d.ts +12 -0
- package/lib/LmEditTable/components/QuickOpetate.js +96 -0
- package/lib/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
- package/lib/LmEditTable/components/bottomOpetateComponent.js +34 -0
- package/lib/LmEditTable/components/index.d.ts +16 -0
- package/lib/LmEditTable/components/index.js +37 -0
- package/lib/LmEditTable/hooks/useForkRef.d.ts +2 -0
- package/lib/LmEditTable/hooks/useForkRef.js +29 -0
- package/lib/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
- package/lib/LmEditTable/rowSort/DndContainerRow.js +99 -0
- package/lib/LmEditTable/sortableItem.d.ts +3 -2
- package/lib/LmEditTable/sortableItem.js +19 -5
- package/lib/LmEditTable/sortableItemCol.js +37 -8
- package/lib/LmEditTable/style/index.css +65 -0
- package/lib/LmEditTable/style/variables.css +65 -0
- package/lib/LmEditTable/util.d.ts +7 -0
- package/lib/LmEditTable/util.js +97 -6
- package/lib/LmEditTable/virtual/VirtualRow.d.ts +7 -0
- package/lib/LmEditTable/virtual/VirtualRow.js +78 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.d.ts +6 -0
- package/lib/LmEditTable/virtual/VirtualRowBack.js +113 -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/LmFilter/filterFns/index.js +7 -2
- package/lib/LmTable/virTual/VirtualRow.js +12 -14
- package/lib/LmUpload/LmUpload.js +7 -2
- package/lib/hooks/useEvent/index.js +1 -1
- package/lib/index.d.ts +1 -2
- package/lib/styles/variables.css +65 -0
- package/package.json +11 -9
package/es/LmEditTable/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
3
|
-
import { keyBy } from 'lodash';
|
|
3
|
+
import { keyBy, isEqual, pick, isFunction, omit } from 'lodash';
|
|
4
4
|
export function isObjEmpty(obj) {
|
|
5
5
|
var _a;
|
|
6
6
|
|
|
@@ -9,19 +9,20 @@ export function isObjEmpty(obj) {
|
|
|
9
9
|
export function deepDataSourcePreKeys(dataSource, rowKey) {
|
|
10
10
|
var deepDataSource = [];
|
|
11
11
|
|
|
12
|
-
var eachChildren = function eachChildren(children, preKeys) {
|
|
13
|
-
children === null || children === void 0 ? void 0 : children.forEach(function (item) {
|
|
12
|
+
var eachChildren = function eachChildren(children, preKeys, deepIds) {
|
|
13
|
+
children === null || children === void 0 ? void 0 : children.forEach(function (item, index) {
|
|
14
14
|
deepDataSource.push(Object.assign(Object.assign({}, item), {
|
|
15
|
-
preKeys: [].concat(_toConsumableArray(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]])
|
|
15
|
+
preKeys: [].concat(_toConsumableArray(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]]),
|
|
16
|
+
_deepIds: [].concat(_toConsumableArray(deepIds), [index + 1])
|
|
16
17
|
}));
|
|
17
18
|
|
|
18
19
|
if (item === null || item === void 0 ? void 0 : item.children) {
|
|
19
|
-
eachChildren(item === null || item === void 0 ? void 0 : item.children, [].concat(_toConsumableArray(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]])); // deepDataSource.push({ ...item, preKeys: [...preKeys, item[rowKey]] })
|
|
20
|
+
eachChildren(item === null || item === void 0 ? void 0 : item.children, [].concat(_toConsumableArray(preKeys), [item === null || item === void 0 ? void 0 : item[rowKey]]), [].concat(_toConsumableArray(deepIds), [index + 1])); // deepDataSource.push({ ...item, preKeys: [...preKeys, item[rowKey]] })
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
23
|
};
|
|
23
24
|
|
|
24
|
-
eachChildren(dataSource, []);
|
|
25
|
+
eachChildren(dataSource, [], []);
|
|
25
26
|
return keyBy(deepDataSource, rowKey);
|
|
26
27
|
}
|
|
27
28
|
export function isExpandRow(children) {
|
|
@@ -53,7 +54,91 @@ export function checkRowKeyByDataSource(dataSource, rowKey) {
|
|
|
53
54
|
|
|
54
55
|
return Object.assign(Object.assign({}, v), _defineProperty({}, rowKey, v[rowKey] || "v".concat(idx + 1)));
|
|
55
56
|
});
|
|
56
|
-
return res;
|
|
57
|
+
return res || [];
|
|
58
|
+
}
|
|
59
|
+
export function getExpandStatus(children) {
|
|
60
|
+
var _a, _b, _c, _d, _e;
|
|
61
|
+
|
|
62
|
+
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'] : '';
|
|
63
|
+
}
|
|
64
|
+
export function checkMemoShouldUploadSpecialFun(prev, next) {
|
|
65
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
66
|
+
|
|
67
|
+
var checkExpandStatus = getExpandStatus(prev.children) === getExpandStatus(next.children);
|
|
68
|
+
|
|
69
|
+
if (!checkExpandStatus) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
var prevCol = prev === null || prev === void 0 ? void 0 : prev.col;
|
|
74
|
+
var nextCol = next === null || next === void 0 ? void 0 : next.col;
|
|
75
|
+
/** TODO: 使用了自定义render, 是否要判断rowIndex? 这样排序之后,渲染的性能就会变差 */
|
|
76
|
+
|
|
77
|
+
if (((prevCol === null || prevCol === void 0 ? void 0 : prevCol.render) || (nextCol === null || nextCol === void 0 ? void 0 : nextCol.render)) && !isEqual(pick(prev, ['colIndex', 'record', 'children']), pick(next, ['colIndex', 'record', 'children']))) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (!(next === null || next === void 0 ? void 0 : next.quickOpetateClearAll) && ((next === null || next === void 0 ? void 0 : next.getLength) < 2 || (prev === null || prev === void 0 ? void 0 : prev.getLength) === 1) && (next === null || next === void 0 ? void 0 : next.dataIndex) === 'lm_edit_opetate') {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (prev.isEdit !== next.isEdit) {
|
|
86
|
+
return false;
|
|
87
|
+
} // console.log(22, prevCol?.editable === 'render', nextCol?.editable === 'render', prevCol?.componentProps, prevCol?.componentProps)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
if (((prevCol === null || prevCol === void 0 ? void 0 : prevCol.editable) === 'render' || (nextCol === null || nextCol === void 0 ? void 0 : nextCol.editable) === 'render') && (((_a = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _a === void 0 ? void 0 : _a.render) || ((_b = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _b === void 0 ? void 0 : _b.render)) && (!isEqual(omit(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps, ['render']), omit(nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps, ['render'])) || !isEqual(pick(prev, ['colIndex', 'record', 'rowIndex']), pick(next, ['colIndex', 'record', 'rowIndex'])))) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (((prevCol === null || prevCol === void 0 ? void 0 : prevCol.fixed) || (nextCol === null || nextCol === void 0 ? void 0 : nextCol.fixed)) && !isEqual(prev === null || prev === void 0 ? void 0 : prev.style, next === null || next === void 0 ? void 0 : next.style)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if ((((_c = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _c === void 0 ? void 0 : _c.optionOnly) || ((_d = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _d === void 0 ? void 0 : _d.optionOnly)) && !isEqual((_e = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _e === void 0 ? void 0 : _e.options, (_f = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _f === void 0 ? void 0 : _f.options)) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if ((((_g = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _g === void 0 ? void 0 : _g.options) || ((_h = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _h === void 0 ? void 0 : _h.options)) && !isEqual((_j = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _j === void 0 ? void 0 : _j.options, (_k = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _k === void 0 ? void 0 : _k.options)) {
|
|
103
|
+
return false;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
if ((isFunction(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) || isFunction(nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) && !isEqual(prevCol.newOptions, nextCol.newOptions) && !isEqual(prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps, nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps)) {
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (((prevCol === null || prevCol === void 0 ? void 0 : prevCol.order) || (nextCol === null || nextCol === void 0 ? void 0 : nextCol.order)) && !isEqual(prevCol === null || prevCol === void 0 ? void 0 : prevCol.order, nextCol === null || nextCol === void 0 ? void 0 : nextCol.order)) {
|
|
111
|
+
// return isEqual(prevCol?.order, nextCol?.fixed)
|
|
112
|
+
return false;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (next.className.indexOf('drag-visible') > -1) {
|
|
116
|
+
return isEqual(prev.style, next.style);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (next.className.indexOf('ant-table-selection-column') > -1) {
|
|
120
|
+
return isEqual((_m = (_l = prev.children) === null || _l === void 0 ? void 0 : _l[1]) === null || _m === void 0 ? void 0 : _m.props, (_p = (_o = next.children) === null || _o === void 0 ? void 0 : _o[1]) === null || _p === void 0 ? void 0 : _p.props);
|
|
121
|
+
}
|
|
122
|
+
/** 如果启用了快速复制功能,需要实时判断rowIndex与getLength */
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
if (((_q = prevCol === null || prevCol === void 0 ? void 0 : prevCol.componentProps) === null || _q === void 0 ? void 0 : _q.quickcopy) || ((_r = nextCol === null || nextCol === void 0 ? void 0 : nextCol.componentProps) === null || _r === void 0 ? void 0 : _r.quickcopy)) {
|
|
126
|
+
var pickProps = ['record', 'colIndex', 'rowIndex', 'getLength'];
|
|
127
|
+
var p = pick(prev, pickProps);
|
|
128
|
+
var n = pick(next, pickProps);
|
|
129
|
+
return isEqual(p, n);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
export function checkExpandIconColumnIndex(_ref) {
|
|
135
|
+
var rowSelection = _ref.rowSelection,
|
|
136
|
+
sortOpen = _ref.sortOpen,
|
|
137
|
+
indexCol = _ref.indexCol;
|
|
138
|
+
var arr = [rowSelection, sortOpen, indexCol].filter(function (item) {
|
|
139
|
+
return !!item;
|
|
140
|
+
});
|
|
141
|
+
return arr.length;
|
|
57
142
|
}
|
|
58
143
|
export default {
|
|
59
144
|
isObjEmpty: isObjEmpty
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
import React, { useRef, useMemo, useEffect } from 'react';
|
|
15
|
+
import { useStore } from './context';
|
|
16
|
+
import useForkRef from '../hooks/useForkRef';
|
|
17
|
+
var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
|
|
18
|
+
var children = _a.children,
|
|
19
|
+
pref = _a.pref,
|
|
20
|
+
resetProps = __rest(_a, ["children", "pref"]);
|
|
21
|
+
|
|
22
|
+
var _useStore = useStore(),
|
|
23
|
+
state = _useStore.state,
|
|
24
|
+
dispatch = _useStore.dispatch;
|
|
25
|
+
|
|
26
|
+
var rowHeight = state.rowHeight,
|
|
27
|
+
totalLen = state.totalLen;
|
|
28
|
+
var trRef = useRef(null); // 列长度
|
|
29
|
+
|
|
30
|
+
var columnsLen = useMemo(function () {
|
|
31
|
+
var _a;
|
|
32
|
+
|
|
33
|
+
return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
|
|
34
|
+
}, [children]);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
if (state.columnsLen !== columnsLen) {
|
|
37
|
+
dispatch({
|
|
38
|
+
type: 'changeColumnsLen',
|
|
39
|
+
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}, [columnsLen, dispatch, state.columnsLen]);
|
|
43
|
+
useEffect(function () {
|
|
44
|
+
var initHeight = function initHeight(tempRef) {
|
|
45
|
+
var _a, _b, _c;
|
|
46
|
+
|
|
47
|
+
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
48
|
+
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;
|
|
49
|
+
dispatch({
|
|
50
|
+
type: 'initHeight',
|
|
51
|
+
rowHeight: tempRowHeight
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
initHeight(trRef);
|
|
57
|
+
}, [trRef, dispatch, rowHeight, totalLen, ref]);
|
|
58
|
+
return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
|
|
59
|
+
ref: useForkRef(pref, trRef)
|
|
60
|
+
}), children);
|
|
61
|
+
});
|
|
62
|
+
export default VirtualRow;
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
import React, { useRef, useMemo, useEffect } from 'react';
|
|
15
|
+
import { useStore } from './context';
|
|
16
|
+
var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
|
|
17
|
+
var children = _a.children,
|
|
18
|
+
resetProps = __rest(_a, ["children"]);
|
|
19
|
+
|
|
20
|
+
var _useStore = useStore(),
|
|
21
|
+
state = _useStore.state,
|
|
22
|
+
dispatch = _useStore.dispatch,
|
|
23
|
+
instance = _useStore.instance;
|
|
24
|
+
|
|
25
|
+
var rowHeight = state.rowHeight,
|
|
26
|
+
totalLen = state.totalLen;
|
|
27
|
+
var virtualItems = instance.columnVirtual.virtualItems;
|
|
28
|
+
var trRef = useRef(null); // 非固定列长度
|
|
29
|
+
|
|
30
|
+
var columnsLen = useMemo(function () {
|
|
31
|
+
var _a;
|
|
32
|
+
|
|
33
|
+
return (_a = children === null || children === void 0 ? void 0 : children.filter(function (v) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
|
|
36
|
+
return typeof ((_a = v.props) === null || _a === void 0 ? void 0 : _a.fixLeft) !== 'number' && typeof ((_b = v.props) === null || _b === void 0 ? void 0 : _b.fixRight) !== 'number';
|
|
37
|
+
}).length) !== null && _a !== void 0 ? _a : 0;
|
|
38
|
+
}, [children]);
|
|
39
|
+
useEffect(function () {
|
|
40
|
+
if (state.columnsLen !== columnsLen) {
|
|
41
|
+
dispatch({
|
|
42
|
+
type: 'changeColumnsLen',
|
|
43
|
+
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}, [columnsLen, dispatch, state.columnsLen]);
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
var initHeight = function initHeight(tempRef) {
|
|
49
|
+
var _a, _b, _c;
|
|
50
|
+
|
|
51
|
+
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
52
|
+
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;
|
|
53
|
+
dispatch({
|
|
54
|
+
type: 'initHeight',
|
|
55
|
+
rowHeight: tempRowHeight
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
|
|
61
|
+
}, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
|
|
62
|
+
|
|
63
|
+
var fixedColumns = useMemo(function () {
|
|
64
|
+
return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
|
|
65
|
+
var _a, _b;
|
|
66
|
+
|
|
67
|
+
if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
|
|
68
|
+
pre.fixedLeft.push(cur);
|
|
69
|
+
return pre;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
|
|
73
|
+
pre.fixedRight.push(cur);
|
|
74
|
+
return pre;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
pre.columns.push(cur);
|
|
78
|
+
return pre;
|
|
79
|
+
}, {
|
|
80
|
+
fixedLeft: [],
|
|
81
|
+
fixedRight: [],
|
|
82
|
+
columns: []
|
|
83
|
+
});
|
|
84
|
+
}, [children]); // 横向单元格合并
|
|
85
|
+
|
|
86
|
+
var colSpan = useMemo(function () {
|
|
87
|
+
var _a;
|
|
88
|
+
|
|
89
|
+
return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
|
|
90
|
+
}, [virtualItems]);
|
|
91
|
+
console.log('virtualItems', virtualItems);
|
|
92
|
+
return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
|
|
93
|
+
ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
|
|
94
|
+
}), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/React.createElement("td", {
|
|
95
|
+
colSpan: colSpan
|
|
96
|
+
}), virtualItems.map(function (virtualCol) {
|
|
97
|
+
return fixedColumns.columns[virtualCol.index];
|
|
98
|
+
}), fixedColumns.fixedRight);
|
|
99
|
+
});
|
|
100
|
+
export default VirtualRow;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import React, { useRef } from 'react';
|
|
3
|
+
import { useVirtual } from 'react-virtual';
|
|
4
|
+
import { TableContext, useRealive } from './context';
|
|
5
|
+
var VirtualTable = /*#__PURE__*/React.memo(function (tableProps) {
|
|
6
|
+
var _a, _b, _c, _d;
|
|
7
|
+
|
|
8
|
+
var bodyRef = useRef(null);
|
|
9
|
+
|
|
10
|
+
var _useRealive = useRealive(),
|
|
11
|
+
_useRealive2 = _slicedToArray(_useRealive, 2),
|
|
12
|
+
state = _useRealive2[0],
|
|
13
|
+
dispatch = _useRealive2[1]; // { totalSize, virtualItems }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
var rowVirtual = useVirtual({
|
|
17
|
+
size: state.totalLen,
|
|
18
|
+
// 绑定父节点
|
|
19
|
+
parentRef: {
|
|
20
|
+
current: (_a = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _a === void 0 ? void 0 : _a.parentNode
|
|
21
|
+
},
|
|
22
|
+
estimateSize: React.useCallback(function () {
|
|
23
|
+
return state.rowHeight;
|
|
24
|
+
}, [state.rowHeight]),
|
|
25
|
+
overscan: 5
|
|
26
|
+
});
|
|
27
|
+
var columnVirtual = useVirtual({
|
|
28
|
+
horizontal: true,
|
|
29
|
+
size: state.columnsLen,
|
|
30
|
+
parentRef: {
|
|
31
|
+
current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
|
|
32
|
+
},
|
|
33
|
+
estimateSize: React.useCallback(function (i) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
|
|
36
|
+
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];
|
|
37
|
+
}, [(_d = (_c = tableProps.children[0]) === null || _c === void 0 ? void 0 : _c.props) === null || _d === void 0 ? void 0 : _d.colWidths]),
|
|
38
|
+
overscan: 5
|
|
39
|
+
});
|
|
40
|
+
var instance = {
|
|
41
|
+
rowVirtual: rowVirtual,
|
|
42
|
+
columnVirtual: columnVirtual
|
|
43
|
+
};
|
|
44
|
+
return /*#__PURE__*/React.createElement(TableContext.Provider, {
|
|
45
|
+
value: {
|
|
46
|
+
state: state,
|
|
47
|
+
dispatch: dispatch,
|
|
48
|
+
instance: instance
|
|
49
|
+
}
|
|
50
|
+
}, /*#__PURE__*/React.createElement("table", Object.assign({
|
|
51
|
+
ref: bodyRef
|
|
52
|
+
}, tableProps)));
|
|
53
|
+
});
|
|
54
|
+
export default VirtualTable;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
var __rest = this && this.__rest || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
|
|
4
|
+
for (var p in s) {
|
|
5
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
9
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
import React, { useEffect, useMemo } from 'react';
|
|
15
|
+
import { useStore } from './context';
|
|
16
|
+
var VirtualWrapper = /*#__PURE__*/React.memo(function (wrapperProps) {
|
|
17
|
+
var _a, _b;
|
|
18
|
+
|
|
19
|
+
var children = wrapperProps.children,
|
|
20
|
+
resetProps = __rest(wrapperProps, ["children"]);
|
|
21
|
+
|
|
22
|
+
var _useStore = useStore(),
|
|
23
|
+
state = _useStore.state,
|
|
24
|
+
dispatch = _useStore.dispatch,
|
|
25
|
+
instance = _useStore.instance;
|
|
26
|
+
|
|
27
|
+
var _instance$rowVirtual = instance.rowVirtual,
|
|
28
|
+
virtualItems = _instance$rowVirtual.virtualItems,
|
|
29
|
+
totalSize = _instance$rowVirtual.totalSize;
|
|
30
|
+
var contents = useMemo(function () {
|
|
31
|
+
return children[1];
|
|
32
|
+
}, [children]);
|
|
33
|
+
var contentsLen = useMemo(function () {
|
|
34
|
+
var _a;
|
|
35
|
+
|
|
36
|
+
return (_a = contents === null || contents === void 0 ? void 0 : contents.length) !== null && _a !== void 0 ? _a : 0;
|
|
37
|
+
}, [contents]);
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (state.totalLen !== contentsLen) {
|
|
40
|
+
dispatch({
|
|
41
|
+
type: 'changeTotalLen',
|
|
42
|
+
totalLen: contentsLen !== null && contentsLen !== void 0 ? contentsLen : 0
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}, [contentsLen, dispatch, state.totalLen]);
|
|
46
|
+
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;
|
|
47
|
+
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;
|
|
48
|
+
return /*#__PURE__*/React.createElement("tbody", Object.assign({}, resetProps), paddingTop > 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
49
|
+
style: {
|
|
50
|
+
height: "".concat(paddingTop, "px")
|
|
51
|
+
}
|
|
52
|
+
})), children[0], virtualItems.map(function (virtualRow) {
|
|
53
|
+
return contents[virtualRow.index];
|
|
54
|
+
}), paddingBottom > 0 && /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", {
|
|
55
|
+
style: {
|
|
56
|
+
height: "".concat(paddingBottom, "px")
|
|
57
|
+
}
|
|
58
|
+
})));
|
|
59
|
+
});
|
|
60
|
+
export default VirtualWrapper;
|
|
@@ -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,54 @@
|
|
|
1
|
+
import { createContext, useContext, useReducer } from 'react'; // =============== context ============== //
|
|
2
|
+
|
|
3
|
+
var TableContext = /*#__PURE__*/createContext({
|
|
4
|
+
state: null,
|
|
5
|
+
dispatch: null,
|
|
6
|
+
instance: {}
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
var useStore = function useStore() {
|
|
10
|
+
return useContext(TableContext);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
var initialState = {
|
|
14
|
+
// 行高度
|
|
15
|
+
rowHeight: 0,
|
|
16
|
+
columnsLen: 0,
|
|
17
|
+
// 总行数
|
|
18
|
+
totalLen: 0
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
var reducer = function reducer(state, action) {
|
|
22
|
+
var totalLen = action.totalLen,
|
|
23
|
+
columnsLen = action.columnsLen,
|
|
24
|
+
rowHeight = action.rowHeight;
|
|
25
|
+
|
|
26
|
+
switch (action.type) {
|
|
27
|
+
// 数据数量
|
|
28
|
+
case 'changeTotalLen':
|
|
29
|
+
return Object.assign(Object.assign({}, state), {
|
|
30
|
+
totalLen: totalLen
|
|
31
|
+
});
|
|
32
|
+
// 列数量
|
|
33
|
+
|
|
34
|
+
case 'changeColumnsLen':
|
|
35
|
+
return Object.assign(Object.assign({}, state), {
|
|
36
|
+
columnsLen: columnsLen
|
|
37
|
+
});
|
|
38
|
+
// 初始化行高度
|
|
39
|
+
|
|
40
|
+
case 'initHeight':
|
|
41
|
+
return Object.assign(Object.assign({}, state), {
|
|
42
|
+
rowHeight: rowHeight
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
default:
|
|
46
|
+
throw new Error();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
var useRealive = function useRealive() {
|
|
51
|
+
return useReducer(reducer, initialState);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { TableContext, useStore, useRealive };
|
|
@@ -172,7 +172,12 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
172
172
|
fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
|
|
173
173
|
type: item.type,
|
|
174
174
|
value: Array.isArray(itemValue) ? itemValue : [itemValue],
|
|
175
|
-
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* and 等同于逻辑关系contains: 选中的值包含所有值
|
|
178
|
+
* or 等同于逻辑关系in: 选中的值存在于所有值之中
|
|
179
|
+
*/
|
|
180
|
+
operator: obj[cur].mode === 'and' ? 'contains' : 'in'
|
|
176
181
|
}]);
|
|
177
182
|
}
|
|
178
183
|
|
|
@@ -343,7 +348,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
|
|
|
343
348
|
fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
|
|
344
349
|
type: item.type,
|
|
345
350
|
value: Array.isArray(itemValue) ? itemValue : [itemValue],
|
|
346
|
-
operator: complexFilter[cur].mode === 'and' ? '
|
|
351
|
+
operator: complexFilter[cur].mode === 'and' ? 'contains' : 'in'
|
|
347
352
|
};
|
|
348
353
|
}
|
|
349
354
|
|
|
@@ -25,12 +25,16 @@ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
|
|
|
25
25
|
var rowHeight = state.rowHeight,
|
|
26
26
|
totalLen = state.totalLen;
|
|
27
27
|
var virtualItems = instance.columnVirtual.virtualItems;
|
|
28
|
-
var trRef = useRef(null); //
|
|
28
|
+
var trRef = useRef(null); // 非固定列长度
|
|
29
29
|
|
|
30
30
|
var columnsLen = useMemo(function () {
|
|
31
31
|
var _a;
|
|
32
32
|
|
|
33
|
-
return (_a = children === null || children === void 0 ? void 0 : children.
|
|
33
|
+
return (_a = children === null || children === void 0 ? void 0 : children.filter(function (v) {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
|
|
36
|
+
return typeof ((_a = v.props) === null || _a === void 0 ? void 0 : _a.fixLeft) !== 'number' && typeof ((_b = v.props) === null || _b === void 0 ? void 0 : _b.fixRight) !== 'number';
|
|
37
|
+
}).length) !== null && _a !== void 0 ? _a : 0; // return children?.length ?? 0
|
|
34
38
|
}, [children]);
|
|
35
39
|
useEffect(function () {
|
|
36
40
|
if (state.columnsLen !== columnsLen) {
|
|
@@ -77,26 +81,20 @@ var VirtualRow = /*#__PURE__*/React.memo(function (_a, ref) {
|
|
|
77
81
|
fixedRight: [],
|
|
78
82
|
columns: []
|
|
79
83
|
});
|
|
80
|
-
}, [children]); //
|
|
81
|
-
|
|
82
|
-
var resetVirtualItems = useMemo(function () {
|
|
83
|
-
var fixedLeft = fixedColumns.fixedLeft,
|
|
84
|
-
columns = fixedColumns.columns;
|
|
85
|
-
return virtualItems.slice(fixedLeft.length, fixedLeft.length + columns.length);
|
|
86
|
-
}, [fixedColumns, virtualItems]); // 横线单元格合并
|
|
84
|
+
}, [children]); // 横线单元格合并
|
|
87
85
|
|
|
88
86
|
var colSpan = useMemo(function () {
|
|
89
87
|
var _a;
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
|
|
90
|
+
}, [virtualItems]);
|
|
91
|
+
console.log('virtualItems', virtualItems);
|
|
94
92
|
return /*#__PURE__*/React.createElement("tr", Object.assign({}, resetProps, {
|
|
95
93
|
ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
|
|
96
94
|
}), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/React.createElement("td", {
|
|
97
95
|
colSpan: colSpan
|
|
98
|
-
}),
|
|
99
|
-
return
|
|
96
|
+
}), virtualItems.map(function (virtualCol) {
|
|
97
|
+
return fixedColumns.columns[virtualCol.index];
|
|
100
98
|
}), fixedColumns.fixedRight);
|
|
101
99
|
});
|
|
102
100
|
export default VirtualRow;
|
package/es/LmUpload/LmUpload.js
CHANGED
|
@@ -13,6 +13,7 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
13
13
|
|
|
14
14
|
import React, { useRef, useMemo, forwardRef } from 'react';
|
|
15
15
|
import LmFilterRoot from './wrapper/UploadRoot';
|
|
16
|
+
import DisabledContext from '../ConfigProvider/DisabledContext';
|
|
16
17
|
|
|
17
18
|
var LmUpload = function LmUpload(_a, ref) {
|
|
18
19
|
var _fileConfig = _a.fileConfig,
|
|
@@ -21,7 +22,8 @@ var LmUpload = function LmUpload(_a, ref) {
|
|
|
21
22
|
_ossConfig = _a.ossConfig,
|
|
22
23
|
resetProps = __rest(_a, ["fileConfig", "fileNames", "components", "ossConfig"]);
|
|
23
24
|
|
|
24
|
-
var defaultRef = useRef(null);
|
|
25
|
+
var defaultRef = useRef(null);
|
|
26
|
+
var disabled = React.useContext(DisabledContext); // 仅在初始化触发一次
|
|
25
27
|
|
|
26
28
|
var initConfig = useMemo(function () {
|
|
27
29
|
return {
|
|
@@ -78,7 +80,7 @@ var LmUpload = function LmUpload(_a, ref) {
|
|
|
78
80
|
type: ['jpg', 'jpeg', 'png'],
|
|
79
81
|
listType: 'card',
|
|
80
82
|
readOnly: false,
|
|
81
|
-
disabled: false,
|
|
83
|
+
disabled: disabled || false,
|
|
82
84
|
showUploadList: true,
|
|
83
85
|
fileList: null,
|
|
84
86
|
defaultFileList: [],
|
package/es/index.d.ts
CHANGED
|
@@ -51,10 +51,9 @@ export type { TooltipProps } from './Tooltip';
|
|
|
51
51
|
export { default as Form } from './Form';
|
|
52
52
|
export { default as Spin } from './Spin';
|
|
53
53
|
export { default as LmEditTable } from './LmEditTable';
|
|
54
|
-
export type {
|
|
54
|
+
export type { TLmEditTable, CountdownHandle } from './LmEditTable/EditTable';
|
|
55
55
|
export { default as List } from './List';
|
|
56
56
|
export { default as LMQuickMenu } from './QuickMenu';
|
|
57
|
-
export type { IMenuData, IQuickMenuProps } from './QuickMenu';
|
|
58
57
|
export { default as DatePicker } from './DatePicker';
|
|
59
58
|
export type { DatePickerProps, MonthPickerProps, WeekPickerProps, RangePickerProps } from './DatePicker';
|
|
60
59
|
export { default as Popover } from './Popover';
|