linkmore-design 1.1.26 → 1.1.27-alpha.1

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.
Files changed (117) hide show
  1. package/dist/LmEditTable/DndContainer.d.ts +6 -3
  2. package/dist/LmEditTable/EditTable.d.ts +10 -5
  3. package/dist/LmEditTable/components/DraggableContainer.d.ts +10 -0
  4. package/dist/LmEditTable/components/QuickOpetate.d.ts +12 -0
  5. package/dist/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
  6. package/dist/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  7. package/dist/LmEditTable/components/index.d.ts +17 -0
  8. package/dist/LmEditTable/hooks/useForkRef.d.ts +2 -0
  9. package/dist/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
  10. package/dist/LmEditTable/sortableItem.d.ts +3 -2
  11. package/dist/LmEditTable/util.d.ts +8 -0
  12. package/dist/LmEditTable/virtual/VirtualRow.d.ts +7 -0
  13. package/dist/LmEditTable/virtual/VirtualRow2.d.ts +7 -0
  14. package/dist/LmEditTable/virtual/VirtualTable.d.ts +3 -0
  15. package/dist/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
  16. package/dist/LmEditTable/virtual/context.d.ts +13 -0
  17. package/dist/LmEditTable/virtual/index.d.ts +4 -0
  18. package/dist/LmTable/virTual/VirtualRow.d.ts +1 -1
  19. package/dist/index.d.ts +1 -2
  20. package/dist/index.umd.js +1380 -576
  21. package/dist/index.umd.min.js +21 -21
  22. package/dist/variables.css +92 -0
  23. package/es/InputNumber/index.js +7 -9
  24. package/es/LmEditTable/DndContainer.d.ts +6 -3
  25. package/es/LmEditTable/DndContainer.js +70 -10
  26. package/es/LmEditTable/DragHandle.js +1 -1
  27. package/es/LmEditTable/EditTable.d.ts +10 -5
  28. package/es/LmEditTable/EditTable.js +364 -360
  29. package/es/LmEditTable/components/DraggableContainer.d.ts +10 -0
  30. package/es/LmEditTable/components/DraggableContainer.js +39 -0
  31. package/es/LmEditTable/components/QuickOpetate.d.ts +12 -0
  32. package/es/LmEditTable/components/QuickOpetate.js +82 -0
  33. package/es/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
  34. package/es/LmEditTable/components/bottomOpetateComponent.js +23 -0
  35. package/es/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  36. package/es/LmEditTable/components/customRenderEmpty.js +20 -0
  37. package/es/LmEditTable/components/index.d.ts +17 -0
  38. package/es/LmEditTable/components/index.js +8 -0
  39. package/es/LmEditTable/hooks/useForkRef.d.ts +2 -0
  40. package/es/LmEditTable/hooks/useForkRef.js +22 -0
  41. package/es/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
  42. package/es/LmEditTable/rowSort/DndContainerRow.js +81 -0
  43. package/es/LmEditTable/sortableItem.d.ts +3 -2
  44. package/es/LmEditTable/sortableItem.js +16 -4
  45. package/es/LmEditTable/sortableItemCol.js +40 -10
  46. package/es/LmEditTable/style/index.css +92 -0
  47. package/es/LmEditTable/style/variables.css +92 -0
  48. package/es/LmEditTable/util.d.ts +8 -0
  49. package/es/LmEditTable/util.js +103 -7
  50. package/es/LmEditTable/virtual/VirtualRow.d.ts +7 -0
  51. package/es/LmEditTable/virtual/VirtualRow.js +140 -0
  52. package/es/LmEditTable/virtual/VirtualRow2.d.ts +7 -0
  53. package/es/LmEditTable/virtual/VirtualRow2.js +62 -0
  54. package/es/LmEditTable/virtual/VirtualTable.d.ts +3 -0
  55. package/es/LmEditTable/virtual/VirtualTable.js +62 -0
  56. package/es/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
  57. package/es/LmEditTable/virtual/VirtualWrapper.js +60 -0
  58. package/es/LmEditTable/virtual/context.d.ts +13 -0
  59. package/es/LmEditTable/virtual/context.js +66 -0
  60. package/es/LmEditTable/virtual/index.d.ts +4 -0
  61. package/es/LmEditTable/virtual/index.js +4 -0
  62. package/es/LmFilter/filterFns/index.js +7 -2
  63. package/es/LmTable/virTual/VirtualRow.d.ts +1 -1
  64. package/es/LmTable/virTual/VirtualRow.js +82 -48
  65. package/es/LmTable/virTual/VirtualTable.js +17 -9
  66. package/es/LmTable/virTual/context.js +14 -2
  67. package/es/hooks/useEvent/index.js +1 -1
  68. package/es/index.d.ts +1 -2
  69. package/es/styles/variables.css +92 -0
  70. package/lib/InputNumber/index.js +9 -9
  71. package/lib/LmEditTable/DndContainer.d.ts +6 -3
  72. package/lib/LmEditTable/DndContainer.js +74 -9
  73. package/lib/LmEditTable/DragHandle.js +1 -1
  74. package/lib/LmEditTable/EditTable.d.ts +10 -5
  75. package/lib/LmEditTable/EditTable.js +362 -357
  76. package/lib/LmEditTable/components/DraggableContainer.d.ts +10 -0
  77. package/lib/LmEditTable/components/DraggableContainer.js +52 -0
  78. package/lib/LmEditTable/components/QuickOpetate.d.ts +12 -0
  79. package/lib/LmEditTable/components/QuickOpetate.js +96 -0
  80. package/lib/LmEditTable/components/bottomOpetateComponent.d.ts +13 -0
  81. package/lib/LmEditTable/components/bottomOpetateComponent.js +34 -0
  82. package/lib/LmEditTable/components/customRenderEmpty.d.ts +2 -0
  83. package/lib/LmEditTable/components/customRenderEmpty.js +32 -0
  84. package/lib/LmEditTable/components/index.d.ts +17 -0
  85. package/lib/LmEditTable/components/index.js +45 -0
  86. package/lib/LmEditTable/hooks/useForkRef.d.ts +2 -0
  87. package/lib/LmEditTable/hooks/useForkRef.js +29 -0
  88. package/lib/LmEditTable/rowSort/DndContainerRow.d.ts +10 -0
  89. package/lib/LmEditTable/rowSort/DndContainerRow.js +99 -0
  90. package/lib/LmEditTable/sortableItem.d.ts +3 -2
  91. package/lib/LmEditTable/sortableItem.js +19 -5
  92. package/lib/LmEditTable/sortableItemCol.js +37 -8
  93. package/lib/LmEditTable/style/index.css +92 -0
  94. package/lib/LmEditTable/style/variables.css +92 -0
  95. package/lib/LmEditTable/util.d.ts +8 -0
  96. package/lib/LmEditTable/util.js +110 -6
  97. package/lib/LmEditTable/virtual/VirtualRow.d.ts +7 -0
  98. package/lib/LmEditTable/virtual/VirtualRow.js +155 -0
  99. package/lib/LmEditTable/virtual/VirtualRow2.d.ts +7 -0
  100. package/lib/LmEditTable/virtual/VirtualRow2.js +78 -0
  101. package/lib/LmEditTable/virtual/VirtualTable.d.ts +3 -0
  102. package/lib/LmEditTable/virtual/VirtualTable.js +79 -0
  103. package/lib/LmEditTable/virtual/VirtualWrapper.d.ts +3 -0
  104. package/lib/LmEditTable/virtual/VirtualWrapper.js +73 -0
  105. package/lib/LmEditTable/virtual/context.d.ts +13 -0
  106. package/lib/LmEditTable/virtual/context.js +76 -0
  107. package/lib/LmEditTable/virtual/index.d.ts +4 -0
  108. package/lib/LmEditTable/virtual/index.js +31 -0
  109. package/lib/LmFilter/filterFns/index.js +7 -2
  110. package/lib/LmTable/virTual/VirtualRow.d.ts +1 -1
  111. package/lib/LmTable/virTual/VirtualRow.js +81 -48
  112. package/lib/LmTable/virTual/VirtualTable.js +16 -8
  113. package/lib/LmTable/virTual/context.js +14 -2
  114. package/lib/hooks/useEvent/index.js +1 -1
  115. package/lib/index.d.ts +1 -2
  116. package/lib/styles/variables.css +92 -0
  117. package/package.json +7 -9
@@ -0,0 +1,78 @@
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;
@@ -0,0 +1,3 @@
1
+ import React, { PropsWithChildren } from 'react';
2
+ declare const VirtualTable: React.MemoExoticComponent<(tableProps: PropsWithChildren<any>) => JSX.Element>;
3
+ export default VirtualTable;
@@ -0,0 +1,79 @@
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
+
43
+ var columnEstimateSize = (0, _react.useCallback)(function (i) {
44
+ var _a, _b;
45
+
46
+ var colWidths = (_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;
47
+ var leftColumnsLen = state.sliceColumns.leftColumns.length;
48
+ var centerColumnsLen = state.sliceColumns.centerColumns.length; // 获取非固定列
49
+
50
+ var virList = colWidths.slice(leftColumnsLen, leftColumnsLen + centerColumnsLen);
51
+ return virList[i] || 0;
52
+ }, [(_c = (_b = tableProps.children[0]) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.colWidths, state.sliceColumns.leftColumns.length, state.sliceColumns.centerColumns.length]); // 列虚拟化
53
+
54
+ var columnVirtual = (0, _reactVirtual.useVirtual)({
55
+ horizontal: true,
56
+ size: state.columnsLen,
57
+ parentRef: {
58
+ current: (_d = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _d === void 0 ? void 0 : _d.parentNode
59
+ },
60
+ estimateSize: columnEstimateSize,
61
+ overscan: 5
62
+ });
63
+ var instance = {
64
+ rowVirtual: rowVirtual,
65
+ columnVirtual: columnVirtual
66
+ };
67
+ return /*#__PURE__*/_react.default.createElement(_context.TableContext.Provider, {
68
+ value: {
69
+ state: state,
70
+ dispatch: dispatch,
71
+ instance: instance
72
+ }
73
+ }, /*#__PURE__*/_react.default.createElement("table", Object.assign({
74
+ ref: bodyRef
75
+ }, tableProps)));
76
+ });
77
+
78
+ var _default = VirtualTable;
79
+ exports.default = _default;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const VirtualWrapper: React.MemoExoticComponent<(wrapperProps: React.PropsWithChildren<any>) => JSX.Element>;
3
+ export default VirtualWrapper;
@@ -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,76 @@
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
+ sliceColumns: {
31
+ leftColumns: [],
32
+ centerColumns: [],
33
+ rightColumns: []
34
+ }
35
+ };
36
+
37
+ var reducer = function reducer(state, action) {
38
+ var totalLen = action.totalLen,
39
+ columnsLen = action.columnsLen,
40
+ rowHeight = action.rowHeight,
41
+ sliceColumns = action.sliceColumns;
42
+
43
+ switch (action.type) {
44
+ // 数据数量
45
+ case 'changeTotalLen':
46
+ return Object.assign(Object.assign({}, state), {
47
+ totalLen: totalLen
48
+ });
49
+ // 列数量
50
+
51
+ case 'changeColumnsLen':
52
+ return Object.assign(Object.assign({}, state), {
53
+ columnsLen: columnsLen
54
+ });
55
+ // 初始化行高度
56
+
57
+ case 'initHeight':
58
+ return Object.assign(Object.assign({}, state), {
59
+ rowHeight: rowHeight
60
+ });
61
+
62
+ case 'changeSliceColumns':
63
+ return Object.assign(Object.assign({}, state), {
64
+ sliceColumns: sliceColumns
65
+ });
66
+
67
+ default:
68
+ throw new Error();
69
+ }
70
+ };
71
+
72
+ var useRealive = function useRealive() {
73
+ return (0, _react.useReducer)(reducer, initialState);
74
+ };
75
+
76
+ exports.useRealive = useRealive;
@@ -0,0 +1,4 @@
1
+ import VirtualTable from './VirtualTable';
2
+ import VirtualWrapper from './VirtualWrapper';
3
+ import VirtualRow from './VirtualRow';
4
+ export { VirtualTable, VirtualWrapper, VirtualRow };
@@ -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"));
@@ -188,7 +188,12 @@ var useCoreOptions = function useCoreOptions(_ref) {
188
188
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
189
189
  type: item.type,
190
190
  value: Array.isArray(itemValue) ? itemValue : [itemValue],
191
- operator: (item === null || item === void 0 ? void 0 : item.operator) || obj[cur].mode === 'and' ? 'equal' : 'contains'
191
+
192
+ /**
193
+ * and 等同于逻辑关系contains: 选中的值包含所有值
194
+ * or 等同于逻辑关系in: 选中的值存在于所有值之中
195
+ */
196
+ operator: obj[cur].mode === 'and' ? 'contains' : 'in'
192
197
  }]);
193
198
  }
194
199
 
@@ -359,7 +364,7 @@ var useCoreOptions = function useCoreOptions(_ref) {
359
364
  fieldType: (item === null || item === void 0 ? void 0 : item.valueType) || 'string',
360
365
  type: item.type,
361
366
  value: Array.isArray(itemValue) ? itemValue : [itemValue],
362
- operator: complexFilter[cur].mode === 'and' ? 'equal' : 'contains'
367
+ operator: complexFilter[cur].mode === 'and' ? 'contains' : 'in'
363
368
  };
364
369
  }
365
370
 
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  interface rowProps {
3
- children: any;
3
+ children?: any;
4
4
  }
5
5
  declare const VirtualRow: React.NamedExoticComponent<rowProps>;
6
6
  export default VirtualRow;
@@ -24,33 +24,62 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
24
24
  return t;
25
25
  };
26
26
 
27
- var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
28
- var children = _a.children,
29
- resetProps = __rest(_a, ["children"]);
27
+ var useOptions = function useOptions(_ref) {
28
+ var children = _ref.children,
29
+ ref = _ref.ref,
30
+ trRef = _ref.trRef;
30
31
 
31
32
  var _useStore = (0, _context.useStore)(),
32
33
  state = _useStore.state,
33
34
  dispatch = _useStore.dispatch,
34
35
  instance = _useStore.instance;
35
36
 
37
+ var virtualItems = instance.columnVirtual.virtualItems;
36
38
  var rowHeight = state.rowHeight,
37
39
  totalLen = state.totalLen;
38
- var virtualItems = instance.columnVirtual.virtualItems;
39
- var trRef = (0, _react.useRef)(null); // 列长度
40
+ var sliceColumns = (0, _react.useMemo)(function () {
41
+ return children === null || children === void 0 ? void 0 : children.reduce(function (pre, cur) {
42
+ var _a, _b;
40
43
 
41
- var columnsLen = (0, _react.useMemo)(function () {
42
- var _a;
44
+ if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
45
+ pre.leftColumns.push(cur);
46
+ return pre;
47
+ }
43
48
 
44
- return (_a = children === null || children === void 0 ? void 0 : children.length) !== null && _a !== void 0 ? _a : 0;
49
+ if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
50
+ pre.rightColumns.push(cur);
51
+ return pre;
52
+ }
53
+
54
+ pre.centerColumns.push(cur);
55
+ return pre;
56
+ }, {
57
+ leftColumns: [],
58
+ rightColumns: [],
59
+ centerColumns: []
60
+ });
45
61
  }, [children]);
46
62
  (0, _react.useEffect)(function () {
47
- if (state.columnsLen !== columnsLen) {
63
+ dispatch({
64
+ type: 'changeSliceColumns',
65
+ sliceColumns: sliceColumns
66
+ });
67
+ }, [sliceColumns]); // 非固定列长度
68
+
69
+ var centerColumnsLen = (0, _react.useMemo)(function () {
70
+ var _a;
71
+
72
+ return (_a = sliceColumns.centerColumns.length) !== null && _a !== void 0 ? _a : 0;
73
+ }, [sliceColumns]);
74
+ (0, _react.useEffect)(function () {
75
+ if (state.columnsLen !== centerColumnsLen) {
48
76
  dispatch({
49
77
  type: 'changeColumnsLen',
50
- columnsLen: columnsLen !== null && columnsLen !== void 0 ? columnsLen : 0
78
+ columnsLen: centerColumnsLen !== null && centerColumnsLen !== void 0 ? centerColumnsLen : 0
51
79
  });
52
80
  }
53
- }, [columnsLen, dispatch, state.columnsLen]);
81
+ }, [centerColumnsLen, dispatch, state.columnsLen]); // 获取行的高度
82
+
54
83
  (0, _react.useEffect)(function () {
55
84
  var initHeight = function initHeight(tempRef) {
56
85
  var _a, _b, _c;
@@ -59,56 +88,60 @@ var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
59
88
  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
89
  dispatch({
61
90
  type: 'initHeight',
62
- rowHeight: tempRowHeight
91
+ rowHeight: tempRowHeight + 1
63
92
  });
64
93
  }
65
94
  };
66
95
 
67
96
  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;
97
+ }, [trRef, dispatch, rowHeight, totalLen, ref]); // 横向单元格合并
73
98
 
74
- if (typeof ((_a = cur.props) === null || _a === void 0 ? void 0 : _a.fixLeft) === 'number') {
75
- pre.fixedLeft.push(cur);
76
- return pre;
77
- }
99
+ var leftColSpan = (0, _react.useMemo)(function () {
100
+ var _a;
78
101
 
79
- if (typeof ((_b = cur.props) === null || _b === void 0 ? void 0 : _b.fixRight) === 'number') {
80
- pre.fixedRight.push(cur);
81
- return pre;
82
- }
102
+ return (_a = virtualItems[0]) === null || _a === void 0 ? void 0 : _a.index;
103
+ }, [virtualItems]); // 右侧隐藏数量
104
+
105
+ var rightColSpan = (0, _react.useMemo)(function () {
106
+ return sliceColumns.centerColumns.length - virtualItems.length - leftColSpan || 0;
107
+ }, [sliceColumns.centerColumns.length, virtualItems.length, leftColSpan]);
108
+ return Object.assign(Object.assign({
109
+ virtualItems: virtualItems
110
+ }, sliceColumns), {
111
+ leftColSpan: leftColSpan,
112
+ rightColSpan: rightColSpan
113
+ });
114
+ };
83
115
 
84
- pre.columns.push(cur);
85
- return pre;
86
- }, {
87
- fixedLeft: [],
88
- fixedRight: [],
89
- columns: []
90
- });
91
- }, [children]); // 截取非固定列
116
+ var VirtualRow = /*#__PURE__*/_react.default.memo(function (_a, ref) {
117
+ var children = _a.children,
118
+ resetProps = __rest(_a, ["children"]);
92
119
 
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]); // 横线单元格合并
120
+ var trRef = (0, _react.useRef)(null);
98
121
 
99
- var colSpan = (0, _react.useMemo)(function () {
100
- var _a;
122
+ var _useOptions = useOptions({
123
+ children: children,
124
+ ref: ref,
125
+ trRef: trRef
126
+ }),
127
+ virtualItems = _useOptions.virtualItems,
128
+ leftColumns = _useOptions.leftColumns,
129
+ centerColumns = _useOptions.centerColumns,
130
+ rightColumns = _useOptions.rightColumns,
131
+ leftColSpan = _useOptions.leftColSpan,
132
+ rightColSpan = _useOptions.rightColSpan;
101
133
 
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
134
  return /*#__PURE__*/_react.default.createElement("tr", Object.assign({}, resetProps, {
106
135
  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);
136
+ }), leftColumns, !!leftColSpan && /*#__PURE__*/_react.default.createElement("td", {
137
+ key: "leftColSpan",
138
+ colSpan: leftColSpan
139
+ }), virtualItems.map(function (virtualCol) {
140
+ return centerColumns[virtualCol.index];
141
+ }), !!rightColSpan && /*#__PURE__*/_react.default.createElement("td", {
142
+ key: "rightColSpan",
143
+ colSpan: rightColSpan
144
+ }), rightColumns);
112
145
  });
113
146
 
114
147
  var _default = VirtualRow;
@@ -25,7 +25,7 @@ var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
25
25
  var _useRealive = (0, _context.useRealive)(),
26
26
  _useRealive2 = (0, _slicedToArray2.default)(_useRealive, 2),
27
27
  state = _useRealive2[0],
28
- dispatch = _useRealive2[1]; // { totalSize, virtualItems }
28
+ dispatch = _useRealive2[1]; // 行虚拟化 { totalSize, virtualItems }
29
29
 
30
30
 
31
31
  var rowVirtual = (0, _reactVirtual.useVirtual)({
@@ -38,18 +38,26 @@ var VirtualTable = /*#__PURE__*/_react.default.memo(function (tableProps) {
38
38
  return state.rowHeight;
39
39
  }, [state.rowHeight]),
40
40
  overscan: 5
41
- });
41
+ }); // 列动态宽度
42
+
43
+ var columnEstimateSize = (0, _react.useCallback)(function (i) {
44
+ var _a, _b;
45
+
46
+ var colWidths = (_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;
47
+ var leftColumnsLen = state.sliceColumns.leftColumns.length;
48
+ var centerColumnsLen = state.sliceColumns.centerColumns.length; // 获取非固定列
49
+
50
+ var virList = colWidths.slice(leftColumnsLen, leftColumnsLen + centerColumnsLen);
51
+ return virList[i] || 0;
52
+ }, [(_c = (_b = tableProps.children[0]) === null || _b === void 0 ? void 0 : _b.props) === null || _c === void 0 ? void 0 : _c.colWidths, state.sliceColumns.leftColumns.length, state.sliceColumns.centerColumns.length]); // 列虚拟化
53
+
42
54
  var columnVirtual = (0, _reactVirtual.useVirtual)({
43
55
  horizontal: true,
44
56
  size: state.columnsLen,
45
57
  parentRef: {
46
- current: (_b = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _b === void 0 ? void 0 : _b.parentNode
58
+ current: (_d = bodyRef === null || bodyRef === void 0 ? void 0 : bodyRef.current) === null || _d === void 0 ? void 0 : _d.parentNode
47
59
  },
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]),
60
+ estimateSize: columnEstimateSize,
53
61
  overscan: 5
54
62
  });
55
63
  var instance = {
@@ -25,13 +25,20 @@ var initialState = {
25
25
  rowHeight: 0,
26
26
  columnsLen: 0,
27
27
  // 总行数
28
- totalLen: 0
28
+ totalLen: 0,
29
+ // 分割后的列数组
30
+ sliceColumns: {
31
+ leftColumns: [],
32
+ centerColumns: [],
33
+ rightColumns: []
34
+ }
29
35
  };
30
36
 
31
37
  var reducer = function reducer(state, action) {
32
38
  var totalLen = action.totalLen,
33
39
  columnsLen = action.columnsLen,
34
- rowHeight = action.rowHeight;
40
+ rowHeight = action.rowHeight,
41
+ sliceColumns = action.sliceColumns;
35
42
 
36
43
  switch (action.type) {
37
44
  // 数据数量
@@ -52,6 +59,11 @@ var reducer = function reducer(state, action) {
52
59
  rowHeight: rowHeight
53
60
  });
54
61
 
62
+ case 'changeSliceColumns':
63
+ return Object.assign(Object.assign({}, state), {
64
+ sliceColumns: sliceColumns
65
+ });
66
+
55
67
  default:
56
68
  throw new Error();
57
69
  }
@@ -17,7 +17,7 @@ function useEvent(handler) {
17
17
 
18
18
  return (0, _react.useCallback)(function () {
19
19
  var fn = handlerRef.current;
20
- return fn.apply(void 0, arguments);
20
+ return fn === null || fn === void 0 ? void 0 : fn.apply(void 0, arguments);
21
21
  }, []);
22
22
  }
23
23