linkmore-design 1.1.27-alpha.0 → 1.1.27
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 +3 -6
- package/dist/LmEditTable/EditTable.d.ts +5 -10
- package/dist/LmEditTable/sortableItem.d.ts +2 -3
- package/dist/LmEditTable/util.d.ts +0 -7
- package/dist/index.d.ts +2 -1
- package/dist/index.umd.js +527 -1133
- package/dist/index.umd.min.js +8 -8
- package/dist/variables.css +0 -65
- package/es/InputNumber/index.js +9 -7
- package/es/LmEditTable/DndContainer.d.ts +3 -6
- package/es/LmEditTable/DndContainer.js +10 -70
- package/es/LmEditTable/DragHandle.js +1 -1
- package/es/LmEditTable/EditTable.d.ts +5 -10
- package/es/LmEditTable/EditTable.js +360 -352
- package/es/LmEditTable/sortableItem.d.ts +2 -3
- package/es/LmEditTable/sortableItem.js +4 -16
- package/es/LmEditTable/sortableItemCol.js +10 -40
- package/es/LmEditTable/style/index.css +0 -65
- package/es/LmEditTable/style/variables.css +0 -65
- package/es/LmEditTable/util.d.ts +0 -7
- package/es/LmEditTable/util.js +7 -92
- package/es/LmTable/virTual/VirtualRow.js +14 -12
- package/es/hooks/useEvent/index.js +1 -1
- package/es/index.d.ts +2 -1
- package/es/styles/variables.css +0 -65
- package/lib/InputNumber/index.js +9 -9
- package/lib/LmEditTable/DndContainer.d.ts +3 -6
- package/lib/LmEditTable/DndContainer.js +9 -74
- package/lib/LmEditTable/DragHandle.js +1 -1
- package/lib/LmEditTable/EditTable.d.ts +5 -10
- package/lib/LmEditTable/EditTable.js +357 -349
- package/lib/LmEditTable/sortableItem.d.ts +2 -3
- package/lib/LmEditTable/sortableItem.js +5 -19
- package/lib/LmEditTable/sortableItemCol.js +8 -37
- package/lib/LmEditTable/style/index.css +0 -65
- package/lib/LmEditTable/style/variables.css +0 -65
- package/lib/LmEditTable/util.d.ts +0 -7
- package/lib/LmEditTable/util.js +6 -97
- package/lib/LmTable/virTual/VirtualRow.js +14 -12
- package/lib/hooks/useEvent/index.js +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/styles/variables.css +0 -65
- package/package.json +9 -7
- package/dist/LmEditTable/components/DraggableContainer.d.ts +0 -10
- package/dist/LmEditTable/components/QuickOpetate.d.ts +0 -12
- package/dist/LmEditTable/components/bottomOpetateComponent.d.ts +0 -13
- package/dist/LmEditTable/components/index.d.ts +0 -16
- package/dist/LmEditTable/hooks/useForkRef.d.ts +0 -2
- package/dist/LmEditTable/rowSort/DndContainerRow.d.ts +0 -10
- package/dist/LmEditTable/virtual/VirtualRow.d.ts +0 -7
- package/dist/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
- package/dist/LmEditTable/virtual/VirtualTable.d.ts +0 -3
- package/dist/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
- package/dist/LmEditTable/virtual/context.d.ts +0 -13
- package/dist/LmEditTable/virtual/index.d.ts +0 -4
- package/es/LmEditTable/components/DraggableContainer.d.ts +0 -10
- package/es/LmEditTable/components/DraggableContainer.js +0 -39
- package/es/LmEditTable/components/QuickOpetate.d.ts +0 -12
- package/es/LmEditTable/components/QuickOpetate.js +0 -82
- package/es/LmEditTable/components/bottomOpetateComponent.d.ts +0 -13
- package/es/LmEditTable/components/bottomOpetateComponent.js +0 -23
- package/es/LmEditTable/components/index.d.ts +0 -16
- package/es/LmEditTable/components/index.js +0 -7
- package/es/LmEditTable/hooks/useForkRef.d.ts +0 -2
- package/es/LmEditTable/hooks/useForkRef.js +0 -22
- package/es/LmEditTable/rowSort/DndContainerRow.d.ts +0 -10
- package/es/LmEditTable/rowSort/DndContainerRow.js +0 -81
- package/es/LmEditTable/virtual/VirtualRow.d.ts +0 -7
- package/es/LmEditTable/virtual/VirtualRow.js +0 -62
- package/es/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
- package/es/LmEditTable/virtual/VirtualRowBack.js +0 -100
- package/es/LmEditTable/virtual/VirtualTable.d.ts +0 -3
- package/es/LmEditTable/virtual/VirtualTable.js +0 -54
- package/es/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
- package/es/LmEditTable/virtual/VirtualWrapper.js +0 -60
- package/es/LmEditTable/virtual/context.d.ts +0 -13
- package/es/LmEditTable/virtual/context.js +0 -54
- package/es/LmEditTable/virtual/index.d.ts +0 -4
- package/es/LmEditTable/virtual/index.js +0 -4
- package/lib/LmEditTable/components/DraggableContainer.d.ts +0 -10
- package/lib/LmEditTable/components/DraggableContainer.js +0 -52
- package/lib/LmEditTable/components/QuickOpetate.d.ts +0 -12
- package/lib/LmEditTable/components/QuickOpetate.js +0 -96
- package/lib/LmEditTable/components/bottomOpetateComponent.d.ts +0 -13
- package/lib/LmEditTable/components/bottomOpetateComponent.js +0 -34
- package/lib/LmEditTable/components/index.d.ts +0 -16
- package/lib/LmEditTable/components/index.js +0 -37
- package/lib/LmEditTable/hooks/useForkRef.d.ts +0 -2
- package/lib/LmEditTable/hooks/useForkRef.js +0 -29
- package/lib/LmEditTable/rowSort/DndContainerRow.d.ts +0 -10
- package/lib/LmEditTable/rowSort/DndContainerRow.js +0 -99
- package/lib/LmEditTable/virtual/VirtualRow.d.ts +0 -7
- package/lib/LmEditTable/virtual/VirtualRow.js +0 -78
- package/lib/LmEditTable/virtual/VirtualRowBack.d.ts +0 -6
- package/lib/LmEditTable/virtual/VirtualRowBack.js +0 -113
- package/lib/LmEditTable/virtual/VirtualTable.d.ts +0 -3
- package/lib/LmEditTable/virtual/VirtualTable.js +0 -71
- package/lib/LmEditTable/virtual/VirtualWrapper.d.ts +0 -3
- package/lib/LmEditTable/virtual/VirtualWrapper.js +0 -73
- package/lib/LmEditTable/virtual/context.d.ts +0 -13
- package/lib/LmEditTable/virtual/context.js +0 -64
- package/lib/LmEditTable/virtual/index.d.ts +0 -4
- package/lib/LmEditTable/virtual/index.js +0 -31
|
@@ -1,99 +0,0 @@
|
|
|
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 _core = require("@dnd-kit/core");
|
|
17
|
-
|
|
18
|
-
var _modifiers = require("@dnd-kit/modifiers");
|
|
19
|
-
|
|
20
|
-
var _sortable = require("@dnd-kit/sortable");
|
|
21
|
-
|
|
22
|
-
// 可拖拽容器
|
|
23
|
-
var DndContainer = function DndContainer(_ref) {
|
|
24
|
-
var children = _ref.children,
|
|
25
|
-
options = _ref.options,
|
|
26
|
-
move = _ref.move,
|
|
27
|
-
rowKey = _ref.rowKey,
|
|
28
|
-
items = _ref.items,
|
|
29
|
-
tableWidth = _ref.tableWidth;
|
|
30
|
-
|
|
31
|
-
var _React$useState = _react.default.useState(false),
|
|
32
|
-
_React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
|
|
33
|
-
isDragging = _React$useState2[0],
|
|
34
|
-
setIsDragging = _React$useState2[1]; // 是否拖拽中
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
var _React$useState3 = _react.default.useState(null),
|
|
38
|
-
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
|
|
39
|
-
activeId = _React$useState4[0],
|
|
40
|
-
setActiveId = _React$useState4[1]; // 是否拖拽中
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var sensors = (0, _core.useSensors)((0, _core.useSensor)(_core.PointerSensor), (0, _core.useSensor)(_core.KeyboardSensor, {
|
|
44
|
-
coordinateGetter: _sortable.sortableKeyboardCoordinates
|
|
45
|
-
})); // 开始拖拽
|
|
46
|
-
|
|
47
|
-
var handleDragStart = function handleDragStart(_ref2) {
|
|
48
|
-
var active = _ref2.active;
|
|
49
|
-
setIsDragging(true);
|
|
50
|
-
|
|
51
|
-
if (!active) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
setActiveId(active.id);
|
|
56
|
-
}; // 拖拽结束
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var handleDragEnd = function handleDragEnd(event) {
|
|
60
|
-
var active = event.active,
|
|
61
|
-
over = event.over;
|
|
62
|
-
setActiveId(null); // 未移入时触发
|
|
63
|
-
|
|
64
|
-
if (!(over === null || over === void 0 ? void 0 : over.id)) {
|
|
65
|
-
return;
|
|
66
|
-
} // 移入时触发更新数据
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (active.id !== over.id) {
|
|
70
|
-
move(active.id, over.id);
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
var instance = {
|
|
75
|
-
isDragging: isDragging,
|
|
76
|
-
activeId: activeId,
|
|
77
|
-
options: options,
|
|
78
|
-
rowKey: rowKey,
|
|
79
|
-
children: children,
|
|
80
|
-
move: move,
|
|
81
|
-
items: items,
|
|
82
|
-
tableWidth: tableWidth
|
|
83
|
-
};
|
|
84
|
-
console.log('instance', instance);
|
|
85
|
-
return /*#__PURE__*/_react.default.createElement(_core.DndContext, {
|
|
86
|
-
sensors: sensors,
|
|
87
|
-
onDragStart: handleDragStart,
|
|
88
|
-
onDragCancel: function onDragCancel() {
|
|
89
|
-
return setActiveId(null);
|
|
90
|
-
},
|
|
91
|
-
collisionDetection: _core.closestCenter,
|
|
92
|
-
onDragEnd: handleDragEnd,
|
|
93
|
-
modifiers: [_modifiers.restrictToParentElement, _modifiers.restrictToVerticalAxis]
|
|
94
|
-
}, children);
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
var _default = /*#__PURE__*/(0, _react.memo)(DndContainer);
|
|
98
|
-
|
|
99
|
-
exports.default = _default;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.default = void 0;
|
|
11
|
-
|
|
12
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
13
|
-
|
|
14
|
-
var _context = require("./context");
|
|
15
|
-
|
|
16
|
-
var _useForkRef = _interopRequireDefault(require("../hooks/useForkRef"));
|
|
17
|
-
|
|
18
|
-
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
19
|
-
var t = {};
|
|
20
|
-
|
|
21
|
-
for (var p in s) {
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
27
|
-
}
|
|
28
|
-
return t;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
|
|
32
|
-
var children = _a.children,
|
|
33
|
-
pref = _a.pref,
|
|
34
|
-
resetProps = __rest(_a, ["children", "pref"]);
|
|
35
|
-
|
|
36
|
-
var _useStore = (0, _context.useStore)(),
|
|
37
|
-
state = _useStore.state,
|
|
38
|
-
dispatch = _useStore.dispatch;
|
|
39
|
-
|
|
40
|
-
var rowHeight = state.rowHeight,
|
|
41
|
-
totalLen = state.totalLen;
|
|
42
|
-
var trRef = (0, _react.useRef)(null); // 列长度
|
|
43
|
-
|
|
44
|
-
var columnsLen = (0, _react.useMemo)(function () {
|
|
45
|
-
var _a;
|
|
46
|
-
|
|
47
|
-
return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
|
|
48
|
-
}, [children]);
|
|
49
|
-
(0, _react.useEffect)(function () {
|
|
50
|
-
if (state.columnsLen !== columnsLen) {
|
|
51
|
-
dispatch({
|
|
52
|
-
type: 'changeColumnsLen',
|
|
53
|
-
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
}, [columnsLen, dispatch, state.columnsLen]);
|
|
57
|
-
(0, _react.useEffect)(function () {
|
|
58
|
-
var initHeight = function initHeight(tempRef) {
|
|
59
|
-
var _a, _b, _c;
|
|
60
|
-
|
|
61
|
-
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
62
|
-
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;
|
|
63
|
-
dispatch({
|
|
64
|
-
type: 'initHeight',
|
|
65
|
-
rowHeight: tempRowHeight
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
initHeight(trRef);
|
|
71
|
-
}, [trRef, dispatch, rowHeight, totalLen, ref]);
|
|
72
|
-
return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
|
|
73
|
-
ref: (0, _useForkRef.default)(pref, trRef)
|
|
74
|
-
}), children);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
var _default = VirtualRow;
|
|
78
|
-
exports.default = _default;
|
|
@@ -1,113 +0,0 @@
|
|
|
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.filter(function (v) {
|
|
45
|
-
var _a, _b;
|
|
46
|
-
|
|
47
|
-
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';
|
|
48
|
-
}).length) !== null && _a !== void 0 ? _a : 0;
|
|
49
|
-
}, [children]);
|
|
50
|
-
(0, _react.useEffect)(function () {
|
|
51
|
-
if (state.columnsLen !== columnsLen) {
|
|
52
|
-
dispatch({
|
|
53
|
-
type: 'changeColumnsLen',
|
|
54
|
-
columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
}, [columnsLen, dispatch, state.columnsLen]);
|
|
58
|
-
(0, _react.useEffect)(function () {
|
|
59
|
-
var initHeight = function initHeight(tempRef) {
|
|
60
|
-
var _a, _b, _c;
|
|
61
|
-
|
|
62
|
-
if (((_a = tempRef === null || tempRef === void 0 ? void 0 : tempRef.current) === null || _a === void 0 ? void 0 : _a.offsetHeight) && !rowHeight && totalLen) {
|
|
63
|
-
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;
|
|
64
|
-
dispatch({
|
|
65
|
-
type: 'initHeight',
|
|
66
|
-
rowHeight: tempRowHeight
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
initHeight(Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef);
|
|
72
|
-
}, [trRef, dispatch, rowHeight, totalLen, ref]); // return {fixedLeft: [], fixedRight: [], columns: []}
|
|
73
|
-
|
|
74
|
-
var fixedColumns = (0, _react.useMemo)(function () {
|
|
75
|
-
return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
|
|
76
|
-
var _a, _b;
|
|
77
|
-
|
|
78
|
-
if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
|
|
79
|
-
pre.fixedLeft.push(cur);
|
|
80
|
-
return pre;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
|
|
84
|
-
pre.fixedRight.push(cur);
|
|
85
|
-
return pre;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
pre.columns.push(cur);
|
|
89
|
-
return pre;
|
|
90
|
-
}, {
|
|
91
|
-
fixedLeft: [],
|
|
92
|
-
fixedRight: [],
|
|
93
|
-
columns: []
|
|
94
|
-
});
|
|
95
|
-
}, [children]); // 横向单元格合并
|
|
96
|
-
|
|
97
|
-
var colSpan = (0, _react.useMemo)(function () {
|
|
98
|
-
var _a;
|
|
99
|
-
|
|
100
|
-
return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
|
|
101
|
-
}, [virtualItems]);
|
|
102
|
-
console.log('virtualItems', virtualItems);
|
|
103
|
-
return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
|
|
104
|
-
ref: Object.prototype.hasOwnProperty.call(ref, 'current') ? ref : trRef
|
|
105
|
-
}), fixedColumns.fixedLeft, !!colSpan && /*#__PURE__*/_react.default.createElement("td", {
|
|
106
|
-
colSpan: colSpan
|
|
107
|
-
}), virtualItems.map(function (virtualCol) {
|
|
108
|
-
return fixedColumns.columns[virtualCol.index];
|
|
109
|
-
}), fixedColumns.fixedRight);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
var _default = VirtualRow;
|
|
113
|
-
exports.default = _default;
|
|
@@ -1,71 +0,0 @@
|
|
|
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;
|
|
@@ -1,73 +0,0 @@
|
|
|
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;
|
|
@@ -1,13 +0,0 @@
|
|
|
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 };
|
|
@@ -1,64 +0,0 @@
|
|
|
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;
|
|
@@ -1,31 +0,0 @@
|
|
|
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"));
|